cpm1.h 23 KB

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