cpm1.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * MPC8xx Communication Processor Module.
  4. * Copyright (c) 1997 Dan Malek ([email protected])
  5. *
  6. * This file contains structures and information for the communication
  7. * processor channels. Some CPM control and status is available
  8. * through the MPC8xx internal memory map. See immap.h for details.
  9. * This file only contains what I need for the moment, not the total
  10. * CPM capabilities. I (or someone else) will add definitions as they
  11. * are needed. -- Dan
  12. *
  13. * On the MBX board, EPPC-Bug loads CPM microcode into the first 512
  14. * bytes of the DP RAM and relocates the I2C parameter area to the
  15. * IDMA1 space. The remaining DP RAM is available for buffer descriptors
  16. * or other use.
  17. */
  18. #ifndef __CPM1__
  19. #define __CPM1__
  20. #include <linux/init.h>
  21. #include <asm/8xx_immap.h>
  22. #include <asm/ptrace.h>
  23. #include <asm/cpm.h>
  24. /* CPM Command register.
  25. */
  26. #define CPM_CR_RST ((ushort)0x8000)
  27. #define CPM_CR_OPCODE ((ushort)0x0f00)
  28. #define CPM_CR_CHAN ((ushort)0x00f0)
  29. #define CPM_CR_FLG ((ushort)0x0001)
  30. /* Channel numbers.
  31. */
  32. #define CPM_CR_CH_SCC1 ((ushort)0x0000)
  33. #define CPM_CR_CH_I2C ((ushort)0x0001) /* I2C and IDMA1 */
  34. #define CPM_CR_CH_SCC2 ((ushort)0x0004)
  35. #define CPM_CR_CH_SPI ((ushort)0x0005) /* SPI / IDMA2 / Timers */
  36. #define CPM_CR_CH_TIMER CPM_CR_CH_SPI
  37. #define CPM_CR_CH_SCC3 ((ushort)0x0008)
  38. #define CPM_CR_CH_SMC1 ((ushort)0x0009) /* SMC1 / DSP1 */
  39. #define CPM_CR_CH_SCC4 ((ushort)0x000c)
  40. #define CPM_CR_CH_SMC2 ((ushort)0x000d) /* SMC2 / DSP2 */
  41. #define mk_cr_cmd(CH, CMD) ((CMD << 8) | (CH << 4))
  42. /* Export the base address of the communication processor registers
  43. * and dual port ram.
  44. */
  45. extern cpm8xx_t __iomem *cpmp; /* Pointer to comm processor */
  46. #define cpm_dpalloc cpm_muram_alloc
  47. #define cpm_dpfree cpm_muram_free
  48. #define cpm_dpram_addr cpm_muram_addr
  49. #define cpm_dpram_phys cpm_muram_dma
  50. extern void cpm_setbrg(uint brg, uint rate);
  51. extern void __init cpm_load_patch(cpm8xx_t *cp);
  52. extern void cpm_reset(void);
  53. /* Parameter RAM offsets.
  54. */
  55. #define PROFF_SCC1 ((uint)0x0000)
  56. #define PROFF_IIC ((uint)0x0080)
  57. #define PROFF_SCC2 ((uint)0x0100)
  58. #define PROFF_SPI ((uint)0x0180)
  59. #define PROFF_SCC3 ((uint)0x0200)
  60. #define PROFF_SMC1 ((uint)0x0280)
  61. #define PROFF_DSP1 ((uint)0x02c0)
  62. #define PROFF_SCC4 ((uint)0x0300)
  63. #define PROFF_SMC2 ((uint)0x0380)
  64. /* Define enough so I can at least use the serial port as a UART.
  65. * The MBX uses SMC1 as the host serial port.
  66. */
  67. typedef struct smc_uart {
  68. ushort smc_rbase; /* Rx Buffer descriptor base address */
  69. ushort smc_tbase; /* Tx Buffer descriptor base address */
  70. u_char smc_rfcr; /* Rx function code */
  71. u_char smc_tfcr; /* Tx function code */
  72. ushort smc_mrblr; /* Max receive buffer length */
  73. uint smc_rstate; /* Internal */
  74. uint smc_idp; /* Internal */
  75. ushort smc_rbptr; /* Internal */
  76. ushort smc_ibc; /* Internal */
  77. uint smc_rxtmp; /* Internal */
  78. uint smc_tstate; /* Internal */
  79. uint smc_tdp; /* Internal */
  80. ushort smc_tbptr; /* Internal */
  81. ushort smc_tbc; /* Internal */
  82. uint smc_txtmp; /* Internal */
  83. ushort smc_maxidl; /* Maximum idle characters */
  84. ushort smc_tmpidl; /* Temporary idle counter */
  85. ushort smc_brklen; /* Last received break length */
  86. ushort smc_brkec; /* rcv'd break condition counter */
  87. ushort smc_brkcr; /* xmt break count register */
  88. ushort smc_rmask; /* Temporary bit mask */
  89. char res1[8]; /* Reserved */
  90. ushort smc_rpbase; /* Relocation pointer */
  91. } smc_uart_t;
  92. /* Function code bits.
  93. */
  94. #define SMC_EB ((u_char)0x10) /* Set big endian byte order */
  95. /* SMC uart mode register.
  96. */
  97. #define SMCMR_REN ((ushort)0x0001)
  98. #define SMCMR_TEN ((ushort)0x0002)
  99. #define SMCMR_DM ((ushort)0x000c)
  100. #define SMCMR_SM_GCI ((ushort)0x0000)
  101. #define SMCMR_SM_UART ((ushort)0x0020)
  102. #define SMCMR_SM_TRANS ((ushort)0x0030)
  103. #define SMCMR_SM_MASK ((ushort)0x0030)
  104. #define SMCMR_PM_EVEN ((ushort)0x0100) /* Even parity, else odd */
  105. #define SMCMR_REVD SMCMR_PM_EVEN
  106. #define SMCMR_PEN ((ushort)0x0200) /* Parity enable */
  107. #define SMCMR_BS SMCMR_PEN
  108. #define SMCMR_SL ((ushort)0x0400) /* Two stops, else one */
  109. #define SMCR_CLEN_MASK ((ushort)0x7800) /* Character length */
  110. #define smcr_mk_clen(C) (((C) << 11) & SMCR_CLEN_MASK)
  111. /* SMC2 as Centronics parallel printer. It is half duplex, in that
  112. * it can only receive or transmit. The parameter ram values for
  113. * each direction are either unique or properly overlap, so we can
  114. * include them in one structure.
  115. */
  116. typedef struct smc_centronics {
  117. ushort scent_rbase;
  118. ushort scent_tbase;
  119. u_char scent_cfcr;
  120. u_char scent_smask;
  121. ushort scent_mrblr;
  122. uint scent_rstate;
  123. uint scent_r_ptr;
  124. ushort scent_rbptr;
  125. ushort scent_r_cnt;
  126. uint scent_rtemp;
  127. uint scent_tstate;
  128. uint scent_t_ptr;
  129. ushort scent_tbptr;
  130. ushort scent_t_cnt;
  131. uint scent_ttemp;
  132. ushort scent_max_sl;
  133. ushort scent_sl_cnt;
  134. ushort scent_character1;
  135. ushort scent_character2;
  136. ushort scent_character3;
  137. ushort scent_character4;
  138. ushort scent_character5;
  139. ushort scent_character6;
  140. ushort scent_character7;
  141. ushort scent_character8;
  142. ushort scent_rccm;
  143. ushort scent_rccr;
  144. } smc_cent_t;
  145. /* Centronics Status Mask Register.
  146. */
  147. #define SMC_CENT_F ((u_char)0x08)
  148. #define SMC_CENT_PE ((u_char)0x04)
  149. #define SMC_CENT_S ((u_char)0x02)
  150. /* SMC Event and Mask register.
  151. */
  152. #define SMCM_BRKE ((unsigned char)0x40) /* When in UART Mode */
  153. #define SMCM_BRK ((unsigned char)0x10) /* When in UART Mode */
  154. #define SMCM_TXE ((unsigned char)0x10) /* When in Transparent Mode */
  155. #define SMCM_BSY ((unsigned char)0x04)
  156. #define SMCM_TX ((unsigned char)0x02)
  157. #define SMCM_RX ((unsigned char)0x01)
  158. /* Baud rate generators.
  159. */
  160. #define CPM_BRG_RST ((uint)0x00020000)
  161. #define CPM_BRG_EN ((uint)0x00010000)
  162. #define CPM_BRG_EXTC_INT ((uint)0x00000000)
  163. #define CPM_BRG_EXTC_CLK2 ((uint)0x00004000)
  164. #define CPM_BRG_EXTC_CLK6 ((uint)0x00008000)
  165. #define CPM_BRG_ATB ((uint)0x00002000)
  166. #define CPM_BRG_CD_MASK ((uint)0x00001ffe)
  167. #define CPM_BRG_DIV16 ((uint)0x00000001)
  168. /* SI Clock Route Register
  169. */
  170. #define SICR_RCLK_SCC1_BRG1 ((uint)0x00000000)
  171. #define SICR_TCLK_SCC1_BRG1 ((uint)0x00000000)
  172. #define SICR_RCLK_SCC2_BRG2 ((uint)0x00000800)
  173. #define SICR_TCLK_SCC2_BRG2 ((uint)0x00000100)
  174. #define SICR_RCLK_SCC3_BRG3 ((uint)0x00100000)
  175. #define SICR_TCLK_SCC3_BRG3 ((uint)0x00020000)
  176. #define SICR_RCLK_SCC4_BRG4 ((uint)0x18000000)
  177. #define SICR_TCLK_SCC4_BRG4 ((uint)0x03000000)
  178. /* SCCs.
  179. */
  180. #define SCC_GSMRH_IRP ((uint)0x00040000)
  181. #define SCC_GSMRH_GDE ((uint)0x00010000)
  182. #define SCC_GSMRH_TCRC_CCITT ((uint)0x00008000)
  183. #define SCC_GSMRH_TCRC_BISYNC ((uint)0x00004000)
  184. #define SCC_GSMRH_TCRC_HDLC ((uint)0x00000000)
  185. #define SCC_GSMRH_REVD ((uint)0x00002000)
  186. #define SCC_GSMRH_TRX ((uint)0x00001000)
  187. #define SCC_GSMRH_TTX ((uint)0x00000800)
  188. #define SCC_GSMRH_CDP ((uint)0x00000400)
  189. #define SCC_GSMRH_CTSP ((uint)0x00000200)
  190. #define SCC_GSMRH_CDS ((uint)0x00000100)
  191. #define SCC_GSMRH_CTSS ((uint)0x00000080)
  192. #define SCC_GSMRH_TFL ((uint)0x00000040)
  193. #define SCC_GSMRH_RFW ((uint)0x00000020)
  194. #define SCC_GSMRH_TXSY ((uint)0x00000010)
  195. #define SCC_GSMRH_SYNL16 ((uint)0x0000000c)
  196. #define SCC_GSMRH_SYNL8 ((uint)0x00000008)
  197. #define SCC_GSMRH_SYNL4 ((uint)0x00000004)
  198. #define SCC_GSMRH_RTSM ((uint)0x00000002)
  199. #define SCC_GSMRH_RSYN ((uint)0x00000001)
  200. #define SCC_GSMRL_SIR ((uint)0x80000000) /* SCC2 only */
  201. #define SCC_GSMRL_EDGE_NONE ((uint)0x60000000)
  202. #define SCC_GSMRL_EDGE_NEG ((uint)0x40000000)
  203. #define SCC_GSMRL_EDGE_POS ((uint)0x20000000)
  204. #define SCC_GSMRL_EDGE_BOTH ((uint)0x00000000)
  205. #define SCC_GSMRL_TCI ((uint)0x10000000)
  206. #define SCC_GSMRL_TSNC_3 ((uint)0x0c000000)
  207. #define SCC_GSMRL_TSNC_4 ((uint)0x08000000)
  208. #define SCC_GSMRL_TSNC_14 ((uint)0x04000000)
  209. #define SCC_GSMRL_TSNC_INF ((uint)0x00000000)
  210. #define SCC_GSMRL_RINV ((uint)0x02000000)
  211. #define SCC_GSMRL_TINV ((uint)0x01000000)
  212. #define SCC_GSMRL_TPL_128 ((uint)0x00c00000)
  213. #define SCC_GSMRL_TPL_64 ((uint)0x00a00000)
  214. #define SCC_GSMRL_TPL_48 ((uint)0x00800000)
  215. #define SCC_GSMRL_TPL_32 ((uint)0x00600000)
  216. #define SCC_GSMRL_TPL_16 ((uint)0x00400000)
  217. #define SCC_GSMRL_TPL_8 ((uint)0x00200000)
  218. #define SCC_GSMRL_TPL_NONE ((uint)0x00000000)
  219. #define SCC_GSMRL_TPP_ALL1 ((uint)0x00180000)
  220. #define SCC_GSMRL_TPP_01 ((uint)0x00100000)
  221. #define SCC_GSMRL_TPP_10 ((uint)0x00080000)
  222. #define SCC_GSMRL_TPP_ZEROS ((uint)0x00000000)
  223. #define SCC_GSMRL_TEND ((uint)0x00040000)
  224. #define SCC_GSMRL_TDCR_32 ((uint)0x00030000)
  225. #define SCC_GSMRL_TDCR_16 ((uint)0x00020000)
  226. #define SCC_GSMRL_TDCR_8 ((uint)0x00010000)
  227. #define SCC_GSMRL_TDCR_1 ((uint)0x00000000)
  228. #define SCC_GSMRL_RDCR_32 ((uint)0x0000c000)
  229. #define SCC_GSMRL_RDCR_16 ((uint)0x00008000)
  230. #define SCC_GSMRL_RDCR_8 ((uint)0x00004000)
  231. #define SCC_GSMRL_RDCR_1 ((uint)0x00000000)
  232. #define SCC_GSMRL_RENC_DFMAN ((uint)0x00003000)
  233. #define SCC_GSMRL_RENC_MANCH ((uint)0x00002000)
  234. #define SCC_GSMRL_RENC_FM0 ((uint)0x00001000)
  235. #define SCC_GSMRL_RENC_NRZI ((uint)0x00000800)
  236. #define SCC_GSMRL_RENC_NRZ ((uint)0x00000000)
  237. #define SCC_GSMRL_TENC_DFMAN ((uint)0x00000600)
  238. #define SCC_GSMRL_TENC_MANCH ((uint)0x00000400)
  239. #define SCC_GSMRL_TENC_FM0 ((uint)0x00000200)
  240. #define SCC_GSMRL_TENC_NRZI ((uint)0x00000100)
  241. #define SCC_GSMRL_TENC_NRZ ((uint)0x00000000)
  242. #define SCC_GSMRL_DIAG_LE ((uint)0x000000c0) /* Loop and echo */
  243. #define SCC_GSMRL_DIAG_ECHO ((uint)0x00000080)
  244. #define SCC_GSMRL_DIAG_LOOP ((uint)0x00000040)
  245. #define SCC_GSMRL_DIAG_NORM ((uint)0x00000000)
  246. #define SCC_GSMRL_ENR ((uint)0x00000020)
  247. #define SCC_GSMRL_ENT ((uint)0x00000010)
  248. #define SCC_GSMRL_MODE_ENET ((uint)0x0000000c)
  249. #define SCC_GSMRL_MODE_QMC ((uint)0x0000000a)
  250. #define SCC_GSMRL_MODE_DDCMP ((uint)0x00000009)
  251. #define SCC_GSMRL_MODE_BISYNC ((uint)0x00000008)
  252. #define SCC_GSMRL_MODE_V14 ((uint)0x00000007)
  253. #define SCC_GSMRL_MODE_AHDLC ((uint)0x00000006)
  254. #define SCC_GSMRL_MODE_PROFIBUS ((uint)0x00000005)
  255. #define SCC_GSMRL_MODE_UART ((uint)0x00000004)
  256. #define SCC_GSMRL_MODE_SS7 ((uint)0x00000003)
  257. #define SCC_GSMRL_MODE_ATALK ((uint)0x00000002)
  258. #define SCC_GSMRL_MODE_HDLC ((uint)0x00000000)
  259. #define SCC_TODR_TOD ((ushort)0x8000)
  260. /* SCC Event and Mask register.
  261. */
  262. #define SCCM_TXE ((unsigned char)0x10)
  263. #define SCCM_BSY ((unsigned char)0x04)
  264. #define SCCM_TX ((unsigned char)0x02)
  265. #define SCCM_RX ((unsigned char)0x01)
  266. typedef struct scc_param {
  267. ushort scc_rbase; /* Rx Buffer descriptor base address */
  268. ushort scc_tbase; /* Tx Buffer descriptor base address */
  269. u_char scc_rfcr; /* Rx function code */
  270. u_char scc_tfcr; /* Tx function code */
  271. ushort scc_mrblr; /* Max receive buffer length */
  272. uint scc_rstate; /* Internal */
  273. uint scc_idp; /* Internal */
  274. ushort scc_rbptr; /* Internal */
  275. ushort scc_ibc; /* Internal */
  276. uint scc_rxtmp; /* Internal */
  277. uint scc_tstate; /* Internal */
  278. uint scc_tdp; /* Internal */
  279. ushort scc_tbptr; /* Internal */
  280. ushort scc_tbc; /* Internal */
  281. uint scc_txtmp; /* Internal */
  282. uint scc_rcrc; /* Internal */
  283. uint scc_tcrc; /* Internal */
  284. } sccp_t;
  285. /* Function code bits.
  286. */
  287. #define SCC_EB ((u_char)0x10) /* Set big endian byte order */
  288. /* CPM Ethernet through SCCx.
  289. */
  290. typedef struct scc_enet {
  291. sccp_t sen_genscc;
  292. uint sen_cpres; /* Preset CRC */
  293. uint sen_cmask; /* Constant mask for CRC */
  294. uint sen_crcec; /* CRC Error counter */
  295. uint sen_alec; /* alignment error counter */
  296. uint sen_disfc; /* discard frame counter */
  297. ushort sen_pads; /* Tx short frame pad character */
  298. ushort sen_retlim; /* Retry limit threshold */
  299. ushort sen_retcnt; /* Retry limit counter */
  300. ushort sen_maxflr; /* maximum frame length register */
  301. ushort sen_minflr; /* minimum frame length register */
  302. ushort sen_maxd1; /* maximum DMA1 length */
  303. ushort sen_maxd2; /* maximum DMA2 length */
  304. ushort sen_maxd; /* Rx max DMA */
  305. ushort sen_dmacnt; /* Rx DMA counter */
  306. ushort sen_maxb; /* Max BD byte count */
  307. ushort sen_gaddr1; /* Group address filter */
  308. ushort sen_gaddr2;
  309. ushort sen_gaddr3;
  310. ushort sen_gaddr4;
  311. uint sen_tbuf0data0; /* Save area 0 - current frame */
  312. uint sen_tbuf0data1; /* Save area 1 - current frame */
  313. uint sen_tbuf0rba; /* Internal */
  314. uint sen_tbuf0crc; /* Internal */
  315. ushort sen_tbuf0bcnt; /* Internal */
  316. ushort sen_paddrh; /* physical address (MSB) */
  317. ushort sen_paddrm;
  318. ushort sen_paddrl; /* physical address (LSB) */
  319. ushort sen_pper; /* persistence */
  320. ushort sen_rfbdptr; /* Rx first BD pointer */
  321. ushort sen_tfbdptr; /* Tx first BD pointer */
  322. ushort sen_tlbdptr; /* Tx last BD pointer */
  323. uint sen_tbuf1data0; /* Save area 0 - current frame */
  324. uint sen_tbuf1data1; /* Save area 1 - current frame */
  325. uint sen_tbuf1rba; /* Internal */
  326. uint sen_tbuf1crc; /* Internal */
  327. ushort sen_tbuf1bcnt; /* Internal */
  328. ushort sen_txlen; /* Tx Frame length counter */
  329. ushort sen_iaddr1; /* Individual address filter */
  330. ushort sen_iaddr2;
  331. ushort sen_iaddr3;
  332. ushort sen_iaddr4;
  333. ushort sen_boffcnt; /* Backoff counter */
  334. /* NOTE: Some versions of the manual have the following items
  335. * incorrectly documented. Below is the proper order.
  336. */
  337. ushort sen_taddrh; /* temp address (MSB) */
  338. ushort sen_taddrm;
  339. ushort sen_taddrl; /* temp address (LSB) */
  340. } scc_enet_t;
  341. /* SCC Event register as used by Ethernet.
  342. */
  343. #define SCCE_ENET_GRA ((ushort)0x0080) /* Graceful stop complete */
  344. #define SCCE_ENET_TXE ((ushort)0x0010) /* Transmit Error */
  345. #define SCCE_ENET_RXF ((ushort)0x0008) /* Full frame received */
  346. #define SCCE_ENET_BSY ((ushort)0x0004) /* All incoming buffers full */
  347. #define SCCE_ENET_TXB ((ushort)0x0002) /* A buffer was transmitted */
  348. #define SCCE_ENET_RXB ((ushort)0x0001) /* A buffer was received */
  349. /* SCC Mode Register (PMSR) as used by Ethernet.
  350. */
  351. #define SCC_PSMR_HBC ((ushort)0x8000) /* Enable heartbeat */
  352. #define SCC_PSMR_FC ((ushort)0x4000) /* Force collision */
  353. #define SCC_PSMR_RSH ((ushort)0x2000) /* Receive short frames */
  354. #define SCC_PSMR_IAM ((ushort)0x1000) /* Check individual hash */
  355. #define SCC_PSMR_ENCRC ((ushort)0x0800) /* Ethernet CRC mode */
  356. #define SCC_PSMR_PRO ((ushort)0x0200) /* Promiscuous mode */
  357. #define SCC_PSMR_BRO ((ushort)0x0100) /* Catch broadcast pkts */
  358. #define SCC_PSMR_SBT ((ushort)0x0080) /* Special backoff timer */
  359. #define SCC_PSMR_LPB ((ushort)0x0040) /* Set Loopback mode */
  360. #define SCC_PSMR_SIP ((ushort)0x0020) /* Sample Input Pins */
  361. #define SCC_PSMR_LCW ((ushort)0x0010) /* Late collision window */
  362. #define SCC_PSMR_NIB22 ((ushort)0x000a) /* Start frame search */
  363. #define SCC_PSMR_FDE ((ushort)0x0001) /* Full duplex enable */
  364. /* SCC as UART
  365. */
  366. typedef struct scc_uart {
  367. sccp_t scc_genscc;
  368. char res1[8]; /* Reserved */
  369. ushort scc_maxidl; /* Maximum idle chars */
  370. ushort scc_idlc; /* temp idle counter */
  371. ushort scc_brkcr; /* Break count register */
  372. ushort scc_parec; /* receive parity error counter */
  373. ushort scc_frmec; /* receive framing error counter */
  374. ushort scc_nosec; /* receive noise counter */
  375. ushort scc_brkec; /* receive break condition counter */
  376. ushort scc_brkln; /* last received break length */
  377. ushort scc_uaddr1; /* UART address character 1 */
  378. ushort scc_uaddr2; /* UART address character 2 */
  379. ushort scc_rtemp; /* Temp storage */
  380. ushort scc_toseq; /* Transmit out of sequence char */
  381. ushort scc_char1; /* control character 1 */
  382. ushort scc_char2; /* control character 2 */
  383. ushort scc_char3; /* control character 3 */
  384. ushort scc_char4; /* control character 4 */
  385. ushort scc_char5; /* control character 5 */
  386. ushort scc_char6; /* control character 6 */
  387. ushort scc_char7; /* control character 7 */
  388. ushort scc_char8; /* control character 8 */
  389. ushort scc_rccm; /* receive control character mask */
  390. ushort scc_rccr; /* receive control character register */
  391. ushort scc_rlbc; /* receive last break character */
  392. } scc_uart_t;
  393. /* SCC Event and Mask registers when it is used as a UART.
  394. */
  395. #define UART_SCCM_GLR ((ushort)0x1000)
  396. #define UART_SCCM_GLT ((ushort)0x0800)
  397. #define UART_SCCM_AB ((ushort)0x0200)
  398. #define UART_SCCM_IDL ((ushort)0x0100)
  399. #define UART_SCCM_GRA ((ushort)0x0080)
  400. #define UART_SCCM_BRKE ((ushort)0x0040)
  401. #define UART_SCCM_BRKS ((ushort)0x0020)
  402. #define UART_SCCM_CCR ((ushort)0x0008)
  403. #define UART_SCCM_BSY ((ushort)0x0004)
  404. #define UART_SCCM_TX ((ushort)0x0002)
  405. #define UART_SCCM_RX ((ushort)0x0001)
  406. /* The SCC PMSR when used as a UART.
  407. */
  408. #define SCU_PSMR_FLC ((ushort)0x8000)
  409. #define SCU_PSMR_SL ((ushort)0x4000)
  410. #define SCU_PSMR_CL ((ushort)0x3000)
  411. #define SCU_PSMR_UM ((ushort)0x0c00)
  412. #define SCU_PSMR_FRZ ((ushort)0x0200)
  413. #define SCU_PSMR_RZS ((ushort)0x0100)
  414. #define SCU_PSMR_SYN ((ushort)0x0080)
  415. #define SCU_PSMR_DRT ((ushort)0x0040)
  416. #define SCU_PSMR_PEN ((ushort)0x0010)
  417. #define SCU_PSMR_RPM ((ushort)0x000c)
  418. #define SCU_PSMR_REVP ((ushort)0x0008)
  419. #define SCU_PSMR_TPM ((ushort)0x0003)
  420. #define SCU_PSMR_TEVP ((ushort)0x0002)
  421. /* CPM Transparent mode SCC.
  422. */
  423. typedef struct scc_trans {
  424. sccp_t st_genscc;
  425. uint st_cpres; /* Preset CRC */
  426. uint st_cmask; /* Constant mask for CRC */
  427. } scc_trans_t;
  428. /* IIC parameter RAM.
  429. */
  430. typedef struct iic {
  431. ushort iic_rbase; /* Rx Buffer descriptor base address */
  432. ushort iic_tbase; /* Tx Buffer descriptor base address */
  433. u_char iic_rfcr; /* Rx function code */
  434. u_char iic_tfcr; /* Tx function code */
  435. ushort iic_mrblr; /* Max receive buffer length */
  436. uint iic_rstate; /* Internal */
  437. uint iic_rdp; /* Internal */
  438. ushort iic_rbptr; /* Internal */
  439. ushort iic_rbc; /* Internal */
  440. uint iic_rxtmp; /* Internal */
  441. uint iic_tstate; /* Internal */
  442. uint iic_tdp; /* Internal */
  443. ushort iic_tbptr; /* Internal */
  444. ushort iic_tbc; /* Internal */
  445. uint iic_txtmp; /* Internal */
  446. char res1[4]; /* Reserved */
  447. ushort iic_rpbase; /* Relocation pointer */
  448. char res2[2]; /* Reserved */
  449. } iic_t;
  450. /*
  451. * RISC Controller Configuration Register definitons
  452. */
  453. #define RCCR_TIME 0x8000 /* RISC Timer Enable */
  454. #define RCCR_TIMEP(t) (((t) & 0x3F)<<8) /* RISC Timer Period */
  455. #define RCCR_TIME_MASK 0x00FF /* not RISC Timer related bits */
  456. /* RISC Timer Parameter RAM offset */
  457. #define PROFF_RTMR ((uint)0x01B0)
  458. typedef struct risc_timer_pram {
  459. unsigned short tm_base; /* RISC Timer Table Base Address */
  460. unsigned short tm_ptr; /* RISC Timer Table Pointer (internal) */
  461. unsigned short r_tmr; /* RISC Timer Mode Register */
  462. unsigned short r_tmv; /* RISC Timer Valid Register */
  463. unsigned long tm_cmd; /* RISC Timer Command Register */
  464. unsigned long tm_cnt; /* RISC Timer Internal Count */
  465. } rt_pram_t;
  466. /* Bits in RISC Timer Command Register */
  467. #define TM_CMD_VALID 0x80000000 /* Valid - Enables the timer */
  468. #define TM_CMD_RESTART 0x40000000 /* Restart - for automatic restart */
  469. #define TM_CMD_PWM 0x20000000 /* Run in Pulse Width Modulation Mode */
  470. #define TM_CMD_NUM(n) (((n)&0xF)<<16) /* Timer Number */
  471. #define TM_CMD_PERIOD(p) ((p)&0xFFFF) /* Timer Period */
  472. /* CPM interrupts. There are nearly 32 interrupts generated by CPM
  473. * channels or devices. All of these are presented to the PPC core
  474. * as a single interrupt. The CPM interrupt handler dispatches its
  475. * own handlers, in a similar fashion to the PPC core handler. We
  476. * use the table as defined in the manuals (i.e. no special high
  477. * priority and SCC1 == SCCa, etc...).
  478. */
  479. #define CPMVEC_NR 32
  480. #define CPMVEC_PIO_PC15 ((ushort)0x1f)
  481. #define CPMVEC_SCC1 ((ushort)0x1e)
  482. #define CPMVEC_SCC2 ((ushort)0x1d)
  483. #define CPMVEC_SCC3 ((ushort)0x1c)
  484. #define CPMVEC_SCC4 ((ushort)0x1b)
  485. #define CPMVEC_PIO_PC14 ((ushort)0x1a)
  486. #define CPMVEC_TIMER1 ((ushort)0x19)
  487. #define CPMVEC_PIO_PC13 ((ushort)0x18)
  488. #define CPMVEC_PIO_PC12 ((ushort)0x17)
  489. #define CPMVEC_SDMA_CB_ERR ((ushort)0x16)
  490. #define CPMVEC_IDMA1 ((ushort)0x15)
  491. #define CPMVEC_IDMA2 ((ushort)0x14)
  492. #define CPMVEC_TIMER2 ((ushort)0x12)
  493. #define CPMVEC_RISCTIMER ((ushort)0x11)
  494. #define CPMVEC_I2C ((ushort)0x10)
  495. #define CPMVEC_PIO_PC11 ((ushort)0x0f)
  496. #define CPMVEC_PIO_PC10 ((ushort)0x0e)
  497. #define CPMVEC_TIMER3 ((ushort)0x0c)
  498. #define CPMVEC_PIO_PC9 ((ushort)0x0b)
  499. #define CPMVEC_PIO_PC8 ((ushort)0x0a)
  500. #define CPMVEC_PIO_PC7 ((ushort)0x09)
  501. #define CPMVEC_TIMER4 ((ushort)0x07)
  502. #define CPMVEC_PIO_PC6 ((ushort)0x06)
  503. #define CPMVEC_SPI ((ushort)0x05)
  504. #define CPMVEC_SMC1 ((ushort)0x04)
  505. #define CPMVEC_SMC2 ((ushort)0x03)
  506. #define CPMVEC_PIO_PC5 ((ushort)0x02)
  507. #define CPMVEC_PIO_PC4 ((ushort)0x01)
  508. #define CPMVEC_ERROR ((ushort)0x00)
  509. /* CPM interrupt configuration vector.
  510. */
  511. #define CICR_SCD_SCC4 ((uint)0x00c00000) /* SCC4 @ SCCd */
  512. #define CICR_SCC_SCC3 ((uint)0x00200000) /* SCC3 @ SCCc */
  513. #define CICR_SCB_SCC2 ((uint)0x00040000) /* SCC2 @ SCCb */
  514. #define CICR_SCA_SCC1 ((uint)0x00000000) /* SCC1 @ SCCa */
  515. #define CICR_IRL_MASK ((uint)0x0000e000) /* Core interrupt */
  516. #define CICR_HP_MASK ((uint)0x00001f00) /* Hi-pri int. */
  517. #define CICR_IEN ((uint)0x00000080) /* Int. enable */
  518. #define CICR_SPS ((uint)0x00000001) /* SCC Spread */
  519. #define CPM_PIN_INPUT 0
  520. #define CPM_PIN_OUTPUT 1
  521. #define CPM_PIN_PRIMARY 0
  522. #define CPM_PIN_SECONDARY 2
  523. #define CPM_PIN_GPIO 4
  524. #define CPM_PIN_OPENDRAIN 8
  525. #define CPM_PIN_FALLEDGE 16
  526. #define CPM_PIN_ANYEDGE 0
  527. enum cpm_port {
  528. CPM_PORTA,
  529. CPM_PORTB,
  530. CPM_PORTC,
  531. CPM_PORTD,
  532. CPM_PORTE,
  533. };
  534. void cpm1_set_pin(enum cpm_port port, int pin, int flags);
  535. enum cpm_clk_dir {
  536. CPM_CLK_RX,
  537. CPM_CLK_TX,
  538. CPM_CLK_RTX
  539. };
  540. enum cpm_clk_target {
  541. CPM_CLK_SCC1,
  542. CPM_CLK_SCC2,
  543. CPM_CLK_SCC3,
  544. CPM_CLK_SCC4,
  545. CPM_CLK_SMC1,
  546. CPM_CLK_SMC2,
  547. };
  548. enum cpm_clk {
  549. CPM_BRG1, /* Baud Rate Generator 1 */
  550. CPM_BRG2, /* Baud Rate Generator 2 */
  551. CPM_BRG3, /* Baud Rate Generator 3 */
  552. CPM_BRG4, /* Baud Rate Generator 4 */
  553. CPM_CLK1, /* Clock 1 */
  554. CPM_CLK2, /* Clock 2 */
  555. CPM_CLK3, /* Clock 3 */
  556. CPM_CLK4, /* Clock 4 */
  557. CPM_CLK5, /* Clock 5 */
  558. CPM_CLK6, /* Clock 6 */
  559. CPM_CLK7, /* Clock 7 */
  560. CPM_CLK8, /* Clock 8 */
  561. };
  562. int cpm1_clk_setup(enum cpm_clk_target target, int clock, int mode);
  563. int cpm1_gpiochip_add16(struct device *dev);
  564. int cpm1_gpiochip_add32(struct device *dev);
  565. #endif /* __CPM1__ */