commproc.h 27 KB

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