cpm1.h 21 KB

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