cpm1.h 22 KB

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