cpm1.h 24 KB

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