aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-octeontx2.h
blob: 84dfae89a8f874152f9ec07e44dc0c824d3674ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __SPI_OCTEONTX2_H
#define __SPI_OCTEONTX2_H

#include <linux/clk.h>

#define PCI_DEVID_OCTEONTX2_SPI 0xA00B
#define PCI_SUBSYS_DEVID_OTX2_96XX 0xB200
#define PCI_SUBSYS_DEVID_OTX2_95XX 0xB300
#define PCI_SUBSYS_DEVID_OTX2_LOKI 0xB400

#define OCTEONTX2_SPI_MAX_BYTES 1024
#define OCTEONTX2_SPI_MAX_CLOCK_HZ 25000000

struct octeontx2_spi_regs {
	int config;
	int status;
	int xmit;
	int wbuf;
};

struct octeontx2_spi {
	void __iomem *register_base;
	u64 last_cfg;
	u64 cs_enax;
	int sys_freq;
	struct octeontx2_spi_regs regs;
	struct clk *clk;
};

#define OCTEONTX2_SPI_CFG(x)	((x)->regs.config)
#define OCTEONTX2_SPI_STS(x)	((x)->regs.status)
#define OCTEONTX2_SPI_XMIT(x)	((x)->regs.xmit)
#define OCTEONTX2_SPI_WBUF(x)	((x)->regs.wbuf)

int octeontx2_spi_transfer_one_message(struct spi_master *master,
				       struct spi_message *msg);


union mpix_cfg {
	uint64_t u64;
	struct mpix_cfg_s {
#ifdef __BIG_ENDIAN_BITFIELD
		uint64_t reserved_50_63:14;
		uint64_t tb100_en:1;
		uint64_t reserved_48:1;
		uint64_t cs_espi_en:4;
		uint64_t reserved_36_43:8;
		uint64_t iomode:2;
		uint64_t reserved_32_33:2;
		uint64_t legacy_dis:1;
		uint64_t reserved_29_30:2;
		uint64_t clkdiv:13;
		uint64_t csena3:1;
		uint64_t csena2:1;
		uint64_t csena1:1;
		uint64_t csena0:1;
		uint64_t cslate:1;
		uint64_t tritx:1;
		uint64_t idleclks:2;
		uint64_t cshi:1;
		uint64_t reserved_6:1;
		uint64_t cs_sticky:1;
		uint64_t lsbfirst:1;
		uint64_t wireor:1;
		uint64_t clk_cont:1;
		uint64_t idlelo:1;
		uint64_t enable:1;
#else
		uint64_t enable:1;
		uint64_t idlelo:1;
		uint64_t clk_cont:1;
		uint64_t wireor:1;
		uint64_t lsbfirst:1;
		uint64_t cs_sticky:1;
		uint64_t reserved_6:1;
		uint64_t cshi:1;
		uint64_t idleclks:2;
		uint64_t tritx:1;
		uint64_t cslate:1;
		uint64_t csena0:1;
		uint64_t csena1:1;
		uint64_t csena2:1;
		uint64_t csena3:1;
		uint64_t clkdiv:13;
		uint64_t reserved_29_30:2;
		uint64_t legacy_dis:1;
		uint64_t reserved_32_33:2;
		uint64_t iomode:2;
		uint64_t reserved_36_43:8;
		uint64_t cs_espi_en:4;
		uint64_t reserved_48:1;
		uint64_t tb100_en:1;
		uint64_t reserved_50_63:14;
#endif
	} s;
};

union mpix_sts {
	uint64_t u64;
	struct mpix_sts_s {
#ifdef __BIG_ENDIAN_BITFIELD
		uint64_t reserved_40_63:24;
		uint64_t crc:8;
		uint64_t reserved_27_31:5;
		uint64_t crc_err:1;
		uint64_t reserved_19_25:7;
		uint64_t rxnum:11;
		uint64_t reserved_2_7:6;
		uint64_t mpi_intr:1;
		uint64_t busy:1;
#else
		uint64_t busy:1;
		uint64_t mpi_intr:1;
		uint64_t reserved_2_7:6;
		uint64_t rxnum:11;
		uint64_t reserved_19_25:7;
		uint64_t crc_err:1;
		uint64_t reserved_27_31:5;
		uint64_t crc:8;
		uint64_t reserved_40_63:24;
#endif
	} s;
};

union mpix_xmit {
	uint64_t u64;
	struct mpix_xmit_s {
#ifdef __BIG_ENDIAN_BITFIELD
		uint64_t reserved_63:1;
		uint64_t csid:2;
		uint64_t leavecs:1;
		uint64_t reserved_31_59:29;
		uint64_t txnum:11;
		uint64_t reserved_11_19:9;
		uint64_t totnum:11;
#else
		uint64_t totnum:11;
		uint64_t reserved_11_19:9;
		uint64_t txnum:11;
		uint64_t reserved_31_59:29;
		uint64_t leavecs:1;
		uint64_t csid:2;
		uint64_t reserved_63:1;
#endif
	} s;
};
#endif /* __SPI_OCTEONTX2_H */