spi-cavium.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __SPI_CAVIUM_H
  3. #define __SPI_CAVIUM_H
  4. #include <linux/clk.h>
  5. #define OCTEON_SPI_MAX_BYTES 9
  6. #define OCTEON_SPI_MAX_CLOCK_HZ 16000000
  7. struct octeon_spi_regs {
  8. int config;
  9. int status;
  10. int tx;
  11. int data;
  12. };
  13. struct octeon_spi {
  14. void __iomem *register_base;
  15. u64 last_cfg;
  16. u64 cs_enax;
  17. int sys_freq;
  18. struct octeon_spi_regs regs;
  19. struct clk *clk;
  20. };
  21. #define OCTEON_SPI_CFG(x) (x->regs.config)
  22. #define OCTEON_SPI_STS(x) (x->regs.status)
  23. #define OCTEON_SPI_TX(x) (x->regs.tx)
  24. #define OCTEON_SPI_DAT0(x) (x->regs.data)
  25. int octeon_spi_transfer_one_message(struct spi_master *master,
  26. struct spi_message *msg);
  27. /* MPI register descriptions */
  28. #define CVMX_MPI_CFG (CVMX_ADD_IO_SEG(0x0001070000001000ull))
  29. #define CVMX_MPI_DATX(offset) (CVMX_ADD_IO_SEG(0x0001070000001080ull) + ((offset) & 15) * 8)
  30. #define CVMX_MPI_STS (CVMX_ADD_IO_SEG(0x0001070000001008ull))
  31. #define CVMX_MPI_TX (CVMX_ADD_IO_SEG(0x0001070000001010ull))
  32. union cvmx_mpi_cfg {
  33. uint64_t u64;
  34. struct cvmx_mpi_cfg_s {
  35. #ifdef __BIG_ENDIAN_BITFIELD
  36. uint64_t reserved_29_63:35;
  37. uint64_t clkdiv:13;
  38. uint64_t csena3:1;
  39. uint64_t csena2:1;
  40. uint64_t csena1:1;
  41. uint64_t csena0:1;
  42. uint64_t cslate:1;
  43. uint64_t tritx:1;
  44. uint64_t idleclks:2;
  45. uint64_t cshi:1;
  46. uint64_t csena:1;
  47. uint64_t int_ena:1;
  48. uint64_t lsbfirst:1;
  49. uint64_t wireor:1;
  50. uint64_t clk_cont:1;
  51. uint64_t idlelo:1;
  52. uint64_t enable:1;
  53. #else
  54. uint64_t enable:1;
  55. uint64_t idlelo:1;
  56. uint64_t clk_cont:1;
  57. uint64_t wireor:1;
  58. uint64_t lsbfirst:1;
  59. uint64_t int_ena:1;
  60. uint64_t csena:1;
  61. uint64_t cshi:1;
  62. uint64_t idleclks:2;
  63. uint64_t tritx:1;
  64. uint64_t cslate:1;
  65. uint64_t csena0:1;
  66. uint64_t csena1:1;
  67. uint64_t csena2:1;
  68. uint64_t csena3:1;
  69. uint64_t clkdiv:13;
  70. uint64_t reserved_29_63:35;
  71. #endif
  72. } s;
  73. struct cvmx_mpi_cfg_cn30xx {
  74. #ifdef __BIG_ENDIAN_BITFIELD
  75. uint64_t reserved_29_63:35;
  76. uint64_t clkdiv:13;
  77. uint64_t reserved_12_15:4;
  78. uint64_t cslate:1;
  79. uint64_t tritx:1;
  80. uint64_t idleclks:2;
  81. uint64_t cshi:1;
  82. uint64_t csena:1;
  83. uint64_t int_ena:1;
  84. uint64_t lsbfirst:1;
  85. uint64_t wireor:1;
  86. uint64_t clk_cont:1;
  87. uint64_t idlelo:1;
  88. uint64_t enable:1;
  89. #else
  90. uint64_t enable:1;
  91. uint64_t idlelo:1;
  92. uint64_t clk_cont:1;
  93. uint64_t wireor:1;
  94. uint64_t lsbfirst:1;
  95. uint64_t int_ena:1;
  96. uint64_t csena:1;
  97. uint64_t cshi:1;
  98. uint64_t idleclks:2;
  99. uint64_t tritx:1;
  100. uint64_t cslate:1;
  101. uint64_t reserved_12_15:4;
  102. uint64_t clkdiv:13;
  103. uint64_t reserved_29_63:35;
  104. #endif
  105. } cn30xx;
  106. struct cvmx_mpi_cfg_cn31xx {
  107. #ifdef __BIG_ENDIAN_BITFIELD
  108. uint64_t reserved_29_63:35;
  109. uint64_t clkdiv:13;
  110. uint64_t reserved_11_15:5;
  111. uint64_t tritx:1;
  112. uint64_t idleclks:2;
  113. uint64_t cshi:1;
  114. uint64_t csena:1;
  115. uint64_t int_ena:1;
  116. uint64_t lsbfirst:1;
  117. uint64_t wireor:1;
  118. uint64_t clk_cont:1;
  119. uint64_t idlelo:1;
  120. uint64_t enable:1;
  121. #else
  122. uint64_t enable:1;
  123. uint64_t idlelo:1;
  124. uint64_t clk_cont:1;
  125. uint64_t wireor:1;
  126. uint64_t lsbfirst:1;
  127. uint64_t int_ena:1;
  128. uint64_t csena:1;
  129. uint64_t cshi:1;
  130. uint64_t idleclks:2;
  131. uint64_t tritx:1;
  132. uint64_t reserved_11_15:5;
  133. uint64_t clkdiv:13;
  134. uint64_t reserved_29_63:35;
  135. #endif
  136. } cn31xx;
  137. struct cvmx_mpi_cfg_cn30xx cn50xx;
  138. struct cvmx_mpi_cfg_cn61xx {
  139. #ifdef __BIG_ENDIAN_BITFIELD
  140. uint64_t reserved_29_63:35;
  141. uint64_t clkdiv:13;
  142. uint64_t reserved_14_15:2;
  143. uint64_t csena1:1;
  144. uint64_t csena0:1;
  145. uint64_t cslate:1;
  146. uint64_t tritx:1;
  147. uint64_t idleclks:2;
  148. uint64_t cshi:1;
  149. uint64_t reserved_6_6:1;
  150. uint64_t int_ena:1;
  151. uint64_t lsbfirst:1;
  152. uint64_t wireor:1;
  153. uint64_t clk_cont:1;
  154. uint64_t idlelo:1;
  155. uint64_t enable:1;
  156. #else
  157. uint64_t enable:1;
  158. uint64_t idlelo:1;
  159. uint64_t clk_cont:1;
  160. uint64_t wireor:1;
  161. uint64_t lsbfirst:1;
  162. uint64_t int_ena:1;
  163. uint64_t reserved_6_6:1;
  164. uint64_t cshi:1;
  165. uint64_t idleclks:2;
  166. uint64_t tritx:1;
  167. uint64_t cslate:1;
  168. uint64_t csena0:1;
  169. uint64_t csena1:1;
  170. uint64_t reserved_14_15:2;
  171. uint64_t clkdiv:13;
  172. uint64_t reserved_29_63:35;
  173. #endif
  174. } cn61xx;
  175. struct cvmx_mpi_cfg_cn66xx {
  176. #ifdef __BIG_ENDIAN_BITFIELD
  177. uint64_t reserved_29_63:35;
  178. uint64_t clkdiv:13;
  179. uint64_t csena3:1;
  180. uint64_t csena2:1;
  181. uint64_t reserved_12_13:2;
  182. uint64_t cslate:1;
  183. uint64_t tritx:1;
  184. uint64_t idleclks:2;
  185. uint64_t cshi:1;
  186. uint64_t reserved_6_6:1;
  187. uint64_t int_ena:1;
  188. uint64_t lsbfirst:1;
  189. uint64_t wireor:1;
  190. uint64_t clk_cont:1;
  191. uint64_t idlelo:1;
  192. uint64_t enable:1;
  193. #else
  194. uint64_t enable:1;
  195. uint64_t idlelo:1;
  196. uint64_t clk_cont:1;
  197. uint64_t wireor:1;
  198. uint64_t lsbfirst:1;
  199. uint64_t int_ena:1;
  200. uint64_t reserved_6_6:1;
  201. uint64_t cshi:1;
  202. uint64_t idleclks:2;
  203. uint64_t tritx:1;
  204. uint64_t cslate:1;
  205. uint64_t reserved_12_13:2;
  206. uint64_t csena2:1;
  207. uint64_t csena3:1;
  208. uint64_t clkdiv:13;
  209. uint64_t reserved_29_63:35;
  210. #endif
  211. } cn66xx;
  212. struct cvmx_mpi_cfg_cn61xx cnf71xx;
  213. };
  214. union cvmx_mpi_datx {
  215. uint64_t u64;
  216. struct cvmx_mpi_datx_s {
  217. #ifdef __BIG_ENDIAN_BITFIELD
  218. uint64_t reserved_8_63:56;
  219. uint64_t data:8;
  220. #else
  221. uint64_t data:8;
  222. uint64_t reserved_8_63:56;
  223. #endif
  224. } s;
  225. struct cvmx_mpi_datx_s cn30xx;
  226. struct cvmx_mpi_datx_s cn31xx;
  227. struct cvmx_mpi_datx_s cn50xx;
  228. struct cvmx_mpi_datx_s cn61xx;
  229. struct cvmx_mpi_datx_s cn66xx;
  230. struct cvmx_mpi_datx_s cnf71xx;
  231. };
  232. union cvmx_mpi_sts {
  233. uint64_t u64;
  234. struct cvmx_mpi_sts_s {
  235. #ifdef __BIG_ENDIAN_BITFIELD
  236. uint64_t reserved_13_63:51;
  237. uint64_t rxnum:5;
  238. uint64_t reserved_1_7:7;
  239. uint64_t busy:1;
  240. #else
  241. uint64_t busy:1;
  242. uint64_t reserved_1_7:7;
  243. uint64_t rxnum:5;
  244. uint64_t reserved_13_63:51;
  245. #endif
  246. } s;
  247. struct cvmx_mpi_sts_s cn30xx;
  248. struct cvmx_mpi_sts_s cn31xx;
  249. struct cvmx_mpi_sts_s cn50xx;
  250. struct cvmx_mpi_sts_s cn61xx;
  251. struct cvmx_mpi_sts_s cn66xx;
  252. struct cvmx_mpi_sts_s cnf71xx;
  253. };
  254. union cvmx_mpi_tx {
  255. uint64_t u64;
  256. struct cvmx_mpi_tx_s {
  257. #ifdef __BIG_ENDIAN_BITFIELD
  258. uint64_t reserved_22_63:42;
  259. uint64_t csid:2;
  260. uint64_t reserved_17_19:3;
  261. uint64_t leavecs:1;
  262. uint64_t reserved_13_15:3;
  263. uint64_t txnum:5;
  264. uint64_t reserved_5_7:3;
  265. uint64_t totnum:5;
  266. #else
  267. uint64_t totnum:5;
  268. uint64_t reserved_5_7:3;
  269. uint64_t txnum:5;
  270. uint64_t reserved_13_15:3;
  271. uint64_t leavecs:1;
  272. uint64_t reserved_17_19:3;
  273. uint64_t csid:2;
  274. uint64_t reserved_22_63:42;
  275. #endif
  276. } s;
  277. struct cvmx_mpi_tx_cn30xx {
  278. #ifdef __BIG_ENDIAN_BITFIELD
  279. uint64_t reserved_17_63:47;
  280. uint64_t leavecs:1;
  281. uint64_t reserved_13_15:3;
  282. uint64_t txnum:5;
  283. uint64_t reserved_5_7:3;
  284. uint64_t totnum:5;
  285. #else
  286. uint64_t totnum:5;
  287. uint64_t reserved_5_7:3;
  288. uint64_t txnum:5;
  289. uint64_t reserved_13_15:3;
  290. uint64_t leavecs:1;
  291. uint64_t reserved_17_63:47;
  292. #endif
  293. } cn30xx;
  294. struct cvmx_mpi_tx_cn30xx cn31xx;
  295. struct cvmx_mpi_tx_cn30xx cn50xx;
  296. struct cvmx_mpi_tx_cn61xx {
  297. #ifdef __BIG_ENDIAN_BITFIELD
  298. uint64_t reserved_21_63:43;
  299. uint64_t csid:1;
  300. uint64_t reserved_17_19:3;
  301. uint64_t leavecs:1;
  302. uint64_t reserved_13_15:3;
  303. uint64_t txnum:5;
  304. uint64_t reserved_5_7:3;
  305. uint64_t totnum:5;
  306. #else
  307. uint64_t totnum:5;
  308. uint64_t reserved_5_7:3;
  309. uint64_t txnum:5;
  310. uint64_t reserved_13_15:3;
  311. uint64_t leavecs:1;
  312. uint64_t reserved_17_19:3;
  313. uint64_t csid:1;
  314. uint64_t reserved_21_63:43;
  315. #endif
  316. } cn61xx;
  317. struct cvmx_mpi_tx_s cn66xx;
  318. struct cvmx_mpi_tx_cn61xx cnf71xx;
  319. };
  320. #endif /* __SPI_CAVIUM_H */