spi-cavium.h 7.1 KB

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