cpm_8xx.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687
  1. /*
  2. * MPC8xx Communication Processor Module.
  3. * Copyright (c) 1997 Dan Malek (dmalek@jlc.net)
  4. *
  5. * (C) Copyright 2000-2006
  6. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  7. *
  8. * This file contains structures and information for the communication
  9. * processor channels. Some CPM control and status is available
  10. * through the MPC8xx internal memory map. See immap.h for details.
  11. * This file only contains what I need for the moment, not the total
  12. * CPM capabilities. I (or someone else) will add definitions as they
  13. * are needed. -- Dan
  14. *
  15. */
  16. #ifndef __CPM_8XX__
  17. #define __CPM_8XX__
  18. #include <asm/immap_8xx.h>
  19. /* CPM Command register.
  20. */
  21. #define CPM_CR_RST ((ushort)0x8000)
  22. #define CPM_CR_OPCODE ((ushort)0x0f00)
  23. #define CPM_CR_CHAN ((ushort)0x00f0)
  24. #define CPM_CR_FLG ((ushort)0x0001)
  25. /* Some commands (there are more...later)
  26. */
  27. #define CPM_CR_INIT_TRX ((ushort)0x0000)
  28. #define CPM_CR_INIT_RX ((ushort)0x0001)
  29. #define CPM_CR_INIT_TX ((ushort)0x0002)
  30. #define CPM_CR_HUNT_MODE ((ushort)0x0003)
  31. #define CPM_CR_STOP_TX ((ushort)0x0004)
  32. #define CPM_CR_RESTART_TX ((ushort)0x0006)
  33. #define CPM_CR_SET_GADDR ((ushort)0x0008)
  34. /* Channel numbers.
  35. */
  36. #define CPM_CR_CH_SCC1 ((ushort)0x0000)
  37. #define CPM_CR_CH_I2C ((ushort)0x0001) /* I2C and IDMA1 */
  38. #define CPM_CR_CH_SCC2 ((ushort)0x0004)
  39. #define CPM_CR_CH_SPI ((ushort)0x0005) /* SPI/IDMA2/Timers */
  40. #define CPM_CR_CH_SCC3 ((ushort)0x0008)
  41. #define CPM_CR_CH_SMC1 ((ushort)0x0009) /* SMC1 / DSP1 */
  42. #define CPM_CR_CH_SCC4 ((ushort)0x000c)
  43. #define CPM_CR_CH_SMC2 ((ushort)0x000d) /* SMC2 / DSP2 */
  44. #define mk_cr_cmd(CH, CMD) ((CMD << 8) | (CH << 4))
  45. /*
  46. * DPRAM defines and allocation functions
  47. */
  48. #define CPM_SERIAL_BASE 0x1800
  49. #define CPM_I2C_BASE 0x1820
  50. #define CPM_SPI_BASE 0x1840
  51. #define CPM_FEC_BASE 0x1860
  52. #define CPM_SERIAL2_BASE 0x18e0
  53. #define CPM_SCC_BASE 0x1900
  54. #define CPM_POST_BASE 0x1980
  55. #define CPM_WLKBD_BASE 0x1a00
  56. #define BD_IIC_START ((uint) 0x0400) /* <- please use CPM_I2C_BASE !! */
  57. /* Export the base address of the communication processor registers
  58. * and dual port ram.
  59. */
  60. extern cpm8xx_t *cpmp; /* Pointer to comm processor */
  61. /* Buffer descriptors used by many of the CPM protocols.
  62. */
  63. typedef struct cpm_buf_desc {
  64. ushort cbd_sc; /* Status and Control */
  65. ushort cbd_datlen; /* Data length in buffer */
  66. uint cbd_bufaddr; /* Buffer address in host memory */
  67. } cbd_t;
  68. #define BD_SC_EMPTY ((ushort)0x8000) /* Receive is empty */
  69. #define BD_SC_READY ((ushort)0x8000) /* Transmit is ready */
  70. #define BD_SC_WRAP ((ushort)0x2000) /* Last buffer descriptor */
  71. #define BD_SC_INTRPT ((ushort)0x1000) /* Interrupt on change */
  72. #define BD_SC_LAST ((ushort)0x0800) /* Last buffer in frame */
  73. #define BD_SC_TC ((ushort)0x0400) /* Transmit CRC */
  74. #define BD_SC_CM ((ushort)0x0200) /* Continuous mode */
  75. #define BD_SC_ID ((ushort)0x0100) /* Rec'd too many idles */
  76. #define BD_SC_P ((ushort)0x0100) /* xmt preamble */
  77. #define BD_SC_BR ((ushort)0x0020) /* Break received */
  78. #define BD_SC_FR ((ushort)0x0010) /* Framing error */
  79. #define BD_SC_PR ((ushort)0x0008) /* Parity error */
  80. #define BD_SC_OV ((ushort)0x0002) /* Overrun */
  81. #define BD_SC_CD ((ushort)0x0001) /* Carrier Detect lost */
  82. /* Parameter RAM offsets.
  83. */
  84. #define PROFF_SCC1 ((uint)0x0000)
  85. #define PROFF_IIC ((uint)0x0080)
  86. #define PROFF_REVNUM ((uint)0x00b0)
  87. #define PROFF_SCC2 ((uint)0x0100)
  88. #define PROFF_SPI ((uint)0x0180)
  89. #define PROFF_SCC3 ((uint)0x0200)
  90. #define PROFF_SMC1 ((uint)0x0280)
  91. #define PROFF_SCC4 ((uint)0x0300)
  92. #define PROFF_SMC2 ((uint)0x0380)
  93. /* Define enough so I can at least use the serial port as a UART.
  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. u_char res1[8];
  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_DDCMP ((uint)0x00000009)
  278. #define SCC_GSMRL_MODE_BISYNC ((uint)0x00000008)
  279. #define SCC_GSMRL_MODE_V14 ((uint)0x00000007)
  280. #define SCC_GSMRL_MODE_AHDLC ((uint)0x00000006)
  281. #define SCC_GSMRL_MODE_PROFIBUS ((uint)0x00000005)
  282. #define SCC_GSMRL_MODE_UART ((uint)0x00000004)
  283. #define SCC_GSMRL_MODE_SS7 ((uint)0x00000003)
  284. #define SCC_GSMRL_MODE_ATALK ((uint)0x00000002)
  285. #define SCC_GSMRL_MODE_HDLC ((uint)0x00000000)
  286. #define SCC_TODR_TOD ((ushort)0x8000)
  287. /* SCC Event and Mask register.
  288. */
  289. #define SCCM_TXE ((unsigned char)0x10)
  290. #define SCCM_BSY ((unsigned char)0x04)
  291. #define SCCM_TX ((unsigned char)0x02)
  292. #define SCCM_RX ((unsigned char)0x01)
  293. typedef struct scc_param {
  294. ushort scc_rbase; /* Rx Buffer descriptor base address */
  295. ushort scc_tbase; /* Tx Buffer descriptor base address */
  296. u_char scc_rfcr; /* Rx function code */
  297. u_char scc_tfcr; /* Tx function code */
  298. ushort scc_mrblr; /* Max receive buffer length */
  299. uint scc_rstate; /* Internal */
  300. uint scc_idp; /* Internal */
  301. ushort scc_rbptr; /* Internal */
  302. ushort scc_ibc; /* Internal */
  303. uint scc_rxtmp; /* Internal */
  304. uint scc_tstate; /* Internal */
  305. uint scc_tdp; /* Internal */
  306. ushort scc_tbptr; /* Internal */
  307. ushort scc_tbc; /* Internal */
  308. uint scc_txtmp; /* Internal */
  309. uint scc_rcrc; /* Internal */
  310. uint scc_tcrc; /* Internal */
  311. } sccp_t;
  312. /* Function code bits.
  313. */
  314. #define SCC_EB ((u_char)0x10) /* Set big endian byte order */
  315. /* CPM Ethernet through SCCx.
  316. */
  317. typedef struct scc_enet {
  318. sccp_t sen_genscc;
  319. uint sen_cpres; /* Preset CRC */
  320. uint sen_cmask; /* Constant mask for CRC */
  321. uint sen_crcec; /* CRC Error counter */
  322. uint sen_alec; /* alignment error counter */
  323. uint sen_disfc; /* discard frame counter */
  324. ushort sen_pads; /* Tx short frame pad character */
  325. ushort sen_retlim; /* Retry limit threshold */
  326. ushort sen_retcnt; /* Retry limit counter */
  327. ushort sen_maxflr; /* maximum frame length register */
  328. ushort sen_minflr; /* minimum frame length register */
  329. ushort sen_maxd1; /* maximum DMA1 length */
  330. ushort sen_maxd2; /* maximum DMA2 length */
  331. ushort sen_maxd; /* Rx max DMA */
  332. ushort sen_dmacnt; /* Rx DMA counter */
  333. ushort sen_maxb; /* Max BD byte count */
  334. ushort sen_gaddr1; /* Group address filter */
  335. ushort sen_gaddr2;
  336. ushort sen_gaddr3;
  337. ushort sen_gaddr4;
  338. uint sen_tbuf0data0; /* Save area 0 - current frame */
  339. uint sen_tbuf0data1; /* Save area 1 - current frame */
  340. uint sen_tbuf0rba; /* Internal */
  341. uint sen_tbuf0crc; /* Internal */
  342. ushort sen_tbuf0bcnt; /* Internal */
  343. ushort sen_paddrh; /* physical address (MSB) */
  344. ushort sen_paddrm;
  345. ushort sen_paddrl; /* physical address (LSB) */
  346. ushort sen_pper; /* persistence */
  347. ushort sen_rfbdptr; /* Rx first BD pointer */
  348. ushort sen_tfbdptr; /* Tx first BD pointer */
  349. ushort sen_tlbdptr; /* Tx last BD pointer */
  350. uint sen_tbuf1data0; /* Save area 0 - current frame */
  351. uint sen_tbuf1data1; /* Save area 1 - current frame */
  352. uint sen_tbuf1rba; /* Internal */
  353. uint sen_tbuf1crc; /* Internal */
  354. ushort sen_tbuf1bcnt; /* Internal */
  355. ushort sen_txlen; /* Tx Frame length counter */
  356. ushort sen_iaddr1; /* Individual address filter */
  357. ushort sen_iaddr2;
  358. ushort sen_iaddr3;
  359. ushort sen_iaddr4;
  360. ushort sen_boffcnt; /* Backoff counter */
  361. /* NOTE: Some versions of the manual have the following items
  362. * incorrectly documented. Below is the proper order.
  363. */
  364. ushort sen_taddrh; /* temp address (MSB) */
  365. ushort sen_taddrm;
  366. ushort sen_taddrl; /* temp address (LSB) */
  367. } scc_enet_t;
  368. /*********************************************************************/
  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 (PSMR) 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. /* Buffer descriptor control/status used by Ethernet receive.
  393. */
  394. #define BD_ENET_RX_EMPTY ((ushort)0x8000)
  395. #define BD_ENET_RX_WRAP ((ushort)0x2000)
  396. #define BD_ENET_RX_INTR ((ushort)0x1000)
  397. #define BD_ENET_RX_LAST ((ushort)0x0800)
  398. #define BD_ENET_RX_FIRST ((ushort)0x0400)
  399. #define BD_ENET_RX_MISS ((ushort)0x0100)
  400. #define BD_ENET_RX_LG ((ushort)0x0020)
  401. #define BD_ENET_RX_NO ((ushort)0x0010)
  402. #define BD_ENET_RX_SH ((ushort)0x0008)
  403. #define BD_ENET_RX_CR ((ushort)0x0004)
  404. #define BD_ENET_RX_OV ((ushort)0x0002)
  405. #define BD_ENET_RX_CL ((ushort)0x0001)
  406. #define BD_ENET_RX_STATS ((ushort)0x013f) /* All status bits */
  407. /* Buffer descriptor control/status used by Ethernet transmit.
  408. */
  409. #define BD_ENET_TX_READY ((ushort)0x8000)
  410. #define BD_ENET_TX_PAD ((ushort)0x4000)
  411. #define BD_ENET_TX_WRAP ((ushort)0x2000)
  412. #define BD_ENET_TX_INTR ((ushort)0x1000)
  413. #define BD_ENET_TX_LAST ((ushort)0x0800)
  414. #define BD_ENET_TX_TC ((ushort)0x0400)
  415. #define BD_ENET_TX_DEF ((ushort)0x0200)
  416. #define BD_ENET_TX_HB ((ushort)0x0100)
  417. #define BD_ENET_TX_LC ((ushort)0x0080)
  418. #define BD_ENET_TX_RL ((ushort)0x0040)
  419. #define BD_ENET_TX_RCMASK ((ushort)0x003c)
  420. #define BD_ENET_TX_UN ((ushort)0x0002)
  421. #define BD_ENET_TX_CSL ((ushort)0x0001)
  422. #define BD_ENET_TX_STATS ((ushort)0x03ff) /* All status bits */
  423. /* SCC as UART
  424. */
  425. typedef struct scc_uart {
  426. sccp_t scc_genscc;
  427. uint scc_res1; /* Reserved */
  428. uint scc_res2; /* Reserved */
  429. ushort scc_maxidl; /* Maximum idle chars */
  430. ushort scc_idlc; /* temp idle counter */
  431. ushort scc_brkcr; /* Break count register */
  432. ushort scc_parec; /* receive parity error counter */
  433. ushort scc_frmec; /* receive framing error counter */
  434. ushort scc_nosec; /* receive noise counter */
  435. ushort scc_brkec; /* receive break condition counter */
  436. ushort scc_brkln; /* last received break length */
  437. ushort scc_uaddr1; /* UART address character 1 */
  438. ushort scc_uaddr2; /* UART address character 2 */
  439. ushort scc_rtemp; /* Temp storage */
  440. ushort scc_toseq; /* Transmit out of sequence char */
  441. ushort scc_char1; /* control character 1 */
  442. ushort scc_char2; /* control character 2 */
  443. ushort scc_char3; /* control character 3 */
  444. ushort scc_char4; /* control character 4 */
  445. ushort scc_char5; /* control character 5 */
  446. ushort scc_char6; /* control character 6 */
  447. ushort scc_char7; /* control character 7 */
  448. ushort scc_char8; /* control character 8 */
  449. ushort scc_rccm; /* receive control character mask */
  450. ushort scc_rccr; /* receive control character register */
  451. ushort scc_rlbc; /* receive last break character */
  452. } scc_uart_t;
  453. /* SCC Event and Mask registers when it is used as a UART.
  454. */
  455. #define UART_SCCM_GLR ((ushort)0x1000)
  456. #define UART_SCCM_GLT ((ushort)0x0800)
  457. #define UART_SCCM_AB ((ushort)0x0200)
  458. #define UART_SCCM_IDL ((ushort)0x0100)
  459. #define UART_SCCM_GRA ((ushort)0x0080)
  460. #define UART_SCCM_BRKE ((ushort)0x0040)
  461. #define UART_SCCM_BRKS ((ushort)0x0020)
  462. #define UART_SCCM_CCR ((ushort)0x0008)
  463. #define UART_SCCM_BSY ((ushort)0x0004)
  464. #define UART_SCCM_TX ((ushort)0x0002)
  465. #define UART_SCCM_RX ((ushort)0x0001)
  466. /* The SCC PSMR when used as a UART.
  467. */
  468. #define SCU_PSMR_FLC ((ushort)0x8000)
  469. #define SCU_PSMR_SL ((ushort)0x4000)
  470. #define SCU_PSMR_CL ((ushort)0x3000)
  471. #define SCU_PSMR_UM ((ushort)0x0c00)
  472. #define SCU_PSMR_FRZ ((ushort)0x0200)
  473. #define SCU_PSMR_RZS ((ushort)0x0100)
  474. #define SCU_PSMR_SYN ((ushort)0x0080)
  475. #define SCU_PSMR_DRT ((ushort)0x0040)
  476. #define SCU_PSMR_PEN ((ushort)0x0010)
  477. #define SCU_PSMR_RPM ((ushort)0x000c)
  478. #define SCU_PSMR_REVP ((ushort)0x0008)
  479. #define SCU_PSMR_TPM ((ushort)0x0003)
  480. #define SCU_PSMR_TEVP ((ushort)0x0003)
  481. /* CPM Transparent mode SCC.
  482. */
  483. typedef struct scc_trans {
  484. sccp_t st_genscc;
  485. uint st_cpres; /* Preset CRC */
  486. uint st_cmask; /* Constant mask for CRC */
  487. } scc_trans_t;
  488. #define BD_SCC_TX_LAST ((ushort)0x0800)
  489. /* IIC parameter RAM.
  490. */
  491. typedef struct iic {
  492. ushort iic_rbase; /* Rx Buffer descriptor base address */
  493. ushort iic_tbase; /* Tx Buffer descriptor base address */
  494. u_char iic_rfcr; /* Rx function code */
  495. u_char iic_tfcr; /* Tx function code */
  496. ushort iic_mrblr; /* Max receive buffer length */
  497. uint iic_rstate; /* Internal */
  498. uint iic_rdp; /* Internal */
  499. ushort iic_rbptr; /* Internal */
  500. ushort iic_rbc; /* Internal */
  501. uint iic_rxtmp; /* Internal */
  502. uint iic_tstate; /* Internal */
  503. uint iic_tdp; /* Internal */
  504. ushort iic_tbptr; /* Internal */
  505. ushort iic_tbc; /* Internal */
  506. uint iic_txtmp; /* Internal */
  507. uint iic_res; /* reserved */
  508. ushort iic_rpbase; /* Relocation pointer */
  509. ushort iic_res2; /* reserved */
  510. } iic_t;
  511. /* SPI parameter RAM.
  512. */
  513. typedef struct spi {
  514. ushort spi_rbase; /* Rx Buffer descriptor base address */
  515. ushort spi_tbase; /* Tx Buffer descriptor base address */
  516. u_char spi_rfcr; /* Rx function code */
  517. u_char spi_tfcr; /* Tx function code */
  518. ushort spi_mrblr; /* Max receive buffer length */
  519. uint spi_rstate; /* Internal */
  520. uint spi_rdp; /* Internal */
  521. ushort spi_rbptr; /* Internal */
  522. ushort spi_rbc; /* Internal */
  523. uint spi_rxtmp; /* Internal */
  524. uint spi_tstate; /* Internal */
  525. uint spi_tdp; /* Internal */
  526. ushort spi_tbptr; /* Internal */
  527. ushort spi_tbc; /* Internal */
  528. uint spi_txtmp; /* Internal */
  529. uint spi_res;
  530. ushort spi_rpbase; /* Relocation pointer */
  531. ushort spi_res2;
  532. } spi_t;
  533. /* SPI Mode register.
  534. */
  535. #define SPMODE_LOOP ((ushort)0x4000) /* Loopback */
  536. #define SPMODE_CI ((ushort)0x2000) /* Clock Invert */
  537. #define SPMODE_CP ((ushort)0x1000) /* Clock Phase */
  538. #define SPMODE_DIV16 ((ushort)0x0800) /* BRG/16 mode */
  539. #define SPMODE_REV ((ushort)0x0400) /* Reversed Data */
  540. #define SPMODE_MSTR ((ushort)0x0200) /* SPI Master */
  541. #define SPMODE_EN ((ushort)0x0100) /* Enable */
  542. #define SPMODE_LENMSK ((ushort)0x00f0) /* character length */
  543. #define SPMODE_PMMSK ((ushort)0x000f) /* prescale modulus */
  544. #define SPMODE_LEN(x) ((((x) - 1) & 0xF) << 4)
  545. #define SPMODE_PM(x) ((x) & 0xF)
  546. /* HDLC parameter RAM.
  547. */
  548. typedef struct hdlc_pram_s {
  549. /*
  550. * SCC parameter RAM
  551. */
  552. ushort rbase; /* Rx Buffer descriptor base address */
  553. ushort tbase; /* Tx Buffer descriptor base address */
  554. uchar rfcr; /* Rx function code */
  555. uchar tfcr; /* Tx function code */
  556. ushort mrblr; /* Rx buffer length */
  557. ulong rstate; /* Rx internal state */
  558. ulong rptr; /* Rx internal data pointer */
  559. ushort rbptr; /* rb BD Pointer */
  560. ushort rcount; /* Rx internal byte count */
  561. ulong rtemp; /* Rx temp */
  562. ulong tstate; /* Tx internal state */
  563. ulong tptr; /* Tx internal data pointer */
  564. ushort tbptr; /* Tx BD pointer */
  565. ushort tcount; /* Tx byte count */
  566. ulong ttemp; /* Tx temp */
  567. ulong rcrc; /* temp receive CRC */
  568. ulong tcrc; /* temp transmit CRC */
  569. /*
  570. * HDLC specific parameter RAM
  571. */
  572. uchar res[4]; /* reserved */
  573. ulong c_mask; /* CRC constant */
  574. ulong c_pres; /* CRC preset */
  575. ushort disfc; /* discarded frame counter */
  576. ushort crcec; /* CRC error counter */
  577. ushort abtsc; /* abort sequence counter */
  578. ushort nmarc; /* nonmatching address rx cnt */
  579. ushort retrc; /* frame retransmission cnt */
  580. ushort mflr; /* maximum frame length reg */
  581. ushort max_cnt; /* maximum length counter */
  582. ushort rfthr; /* received frames threshold */
  583. ushort rfcnt; /* received frames count */
  584. ushort hmask; /* user defined frm addr mask */
  585. ushort haddr1; /* user defined frm address 1 */
  586. ushort haddr2; /* user defined frm address 2 */
  587. ushort haddr3; /* user defined frm address 3 */
  588. ushort haddr4; /* user defined frm address 4 */
  589. ushort tmp; /* temp */
  590. ushort tmp_mb; /* temp */
  591. } hdlc_pram_t;
  592. /* CPM interrupts. There are nearly 32 interrupts generated by CPM
  593. * channels or devices. All of these are presented to the PPC core
  594. * as a single interrupt. The CPM interrupt handler dispatches its
  595. * own handlers, in a similar fashion to the PPC core handler. We
  596. * use the table as defined in the manuals (i.e. no special high
  597. * priority and SCC1 == SCCa, etc...).
  598. */
  599. #define CPMVEC_NR 32
  600. #define CPMVEC_OFFSET 0x00010000
  601. #define CPMVEC_PIO_PC15 ((ushort)0x1f | CPMVEC_OFFSET)
  602. #define CPMVEC_SCC1 ((ushort)0x1e | CPMVEC_OFFSET)
  603. #define CPMVEC_SCC2 ((ushort)0x1d | CPMVEC_OFFSET)
  604. #define CPMVEC_SCC3 ((ushort)0x1c | CPMVEC_OFFSET)
  605. #define CPMVEC_SCC4 ((ushort)0x1b | CPMVEC_OFFSET)
  606. #define CPMVEC_PIO_PC14 ((ushort)0x1a | CPMVEC_OFFSET)
  607. #define CPMVEC_TIMER1 ((ushort)0x19 | CPMVEC_OFFSET)
  608. #define CPMVEC_PIO_PC13 ((ushort)0x18 | CPMVEC_OFFSET)
  609. #define CPMVEC_PIO_PC12 ((ushort)0x17 | CPMVEC_OFFSET)
  610. #define CPMVEC_SDMA_CB_ERR ((ushort)0x16 | CPMVEC_OFFSET)
  611. #define CPMVEC_IDMA1 ((ushort)0x15 | CPMVEC_OFFSET)
  612. #define CPMVEC_IDMA2 ((ushort)0x14 | CPMVEC_OFFSET)
  613. #define CPMVEC_TIMER2 ((ushort)0x12 | CPMVEC_OFFSET)
  614. #define CPMVEC_RISCTIMER ((ushort)0x11 | CPMVEC_OFFSET)
  615. #define CPMVEC_I2C ((ushort)0x10 | CPMVEC_OFFSET)
  616. #define CPMVEC_PIO_PC11 ((ushort)0x0f | CPMVEC_OFFSET)
  617. #define CPMVEC_PIO_PC10 ((ushort)0x0e | CPMVEC_OFFSET)
  618. #define CPMVEC_TIMER3 ((ushort)0x0c | CPMVEC_OFFSET)
  619. #define CPMVEC_PIO_PC9 ((ushort)0x0b | CPMVEC_OFFSET)
  620. #define CPMVEC_PIO_PC8 ((ushort)0x0a | CPMVEC_OFFSET)
  621. #define CPMVEC_PIO_PC7 ((ushort)0x09 | CPMVEC_OFFSET)
  622. #define CPMVEC_TIMER4 ((ushort)0x07 | CPMVEC_OFFSET)
  623. #define CPMVEC_PIO_PC6 ((ushort)0x06 | CPMVEC_OFFSET)
  624. #define CPMVEC_SPI ((ushort)0x05 | CPMVEC_OFFSET)
  625. #define CPMVEC_SMC1 ((ushort)0x04 | CPMVEC_OFFSET)
  626. #define CPMVEC_SMC2 ((ushort)0x03 | CPMVEC_OFFSET)
  627. #define CPMVEC_PIO_PC5 ((ushort)0x02 | CPMVEC_OFFSET)
  628. #define CPMVEC_PIO_PC4 ((ushort)0x01 | CPMVEC_OFFSET)
  629. #define CPMVEC_ERROR ((ushort)0x00 | CPMVEC_OFFSET)
  630. void irq_install_handler(int vec, void (*handler)(void *), void *dev_id);
  631. /* CPM interrupt configuration vector.
  632. */
  633. #define CICR_SCD_SCC4 ((uint)0x00c00000) /* SCC4 @ SCCd */
  634. #define CICR_SCC_SCC3 ((uint)0x00200000) /* SCC3 @ SCCc */
  635. #define CICR_SCB_SCC2 ((uint)0x00040000) /* SCC2 @ SCCb */
  636. #define CICR_SCA_SCC1 ((uint)0x00000000) /* SCC1 @ SCCa */
  637. #define CICR_IRL_MASK ((uint)0x0000e000) /* Core interrupt */
  638. #define CICR_HP_MASK ((uint)0x00001f00) /* Hi-pri int. */
  639. #define CICR_IEN ((uint)0x00000080) /* Int. enable */
  640. #define CICR_SPS ((uint)0x00000001) /* SCC Spread */
  641. #endif /* __CPM_8XX__ */