2 * BK Id: %F% %I% %G% %U% %#%
6 * MPC8xx Communication Processor Module.
7 * Copyright (c) 1997 Dan Malek (dmalek@jlc.net)
9 * This file contains structures and information for the communication
10 * processor channels. Some CPM control and status is available
11 * throught the MPC8xx internal memory map. See immap.h for details.
12 * This file only contains what I need for the moment, not the total
13 * CPM capabilities. I (or someone else) will add definitions as they
16 * On the MBX board, EPPC-Bug loads CPM microcode into the first 512
17 * bytes of the DP RAM and relocates the I2C parameter area to the
18 * IDMA1 space. The remaining DP RAM is available for buffer descriptors
24 #include <linux/config.h>
25 #include <asm/8xx_immap.h>
27 /* CPM Command register.
29 #define CPM_CR_RST ((ushort)0x8000)
30 #define CPM_CR_OPCODE ((ushort)0x0f00)
31 #define CPM_CR_CHAN ((ushort)0x00f0)
32 #define CPM_CR_FLG ((ushort)0x0001)
34 /* Some commands (there are more...later)
36 #define CPM_CR_INIT_TRX ((ushort)0x0000)
37 #define CPM_CR_INIT_RX ((ushort)0x0001)
38 #define CPM_CR_INIT_TX ((ushort)0x0002)
39 #define CPM_CR_HUNT_MODE ((ushort)0x0003)
40 #define CPM_CR_STOP_TX ((ushort)0x0004)
41 #define CPM_CR_RESTART_TX ((ushort)0x0006)
42 #define CPM_CR_CLOSE_RX_BD ((ushort)0x0007)
43 #define CPM_CR_SET_GADDR ((ushort)0x0008)
44 #define CPM_CR_SET_TIMER CPM_CR_SET_GADDR
48 #define CPM_CR_CH_SCC1 ((ushort)0x0000)
49 #define CPM_CR_CH_I2C ((ushort)0x0001) /* I2C and IDMA1 */
50 #define CPM_CR_CH_SCC2 ((ushort)0x0004)
51 #define CPM_CR_CH_SPI ((ushort)0x0005) /* SPI / IDMA2 / Timers */
52 #define CPM_CR_CH_TIMER CPM_CR_CH_SPI
53 #define CPM_CR_CH_SCC3 ((ushort)0x0008)
54 #define CPM_CR_CH_SMC1 ((ushort)0x0009) /* SMC1 / DSP1 */
55 #define CPM_CR_CH_SCC4 ((ushort)0x000c)
56 #define CPM_CR_CH_SMC2 ((ushort)0x000d) /* SMC2 / DSP2 */
58 #define mk_cr_cmd(CH, CMD) ((CMD << 8) | (CH << 4))
60 /* The dual ported RAM is multi-functional. Some areas can be (and are
61 * being) used for microcode. There is an area that can only be used
62 * as data ram for buffer descriptors, which is all we use right now.
63 * Currently the first 512 and last 256 bytes are used for microcode.
65 #define CPM_DATAONLY_BASE ((uint)0x0800)
66 #define CPM_DATAONLY_SIZE ((uint)0x0700)
67 #define CPM_DP_NOSPACE ((uint)0x7fffffff)
69 /* Export the base address of the communication processor registers
72 extern cpm8xx_t *cpmp; /* Pointer to comm processor */
73 uint m8xx_cpm_dpalloc(uint size);
74 uint m8xx_cpm_hostalloc(uint size);
75 void m8xx_cpm_setbrg(uint brg, uint rate);
77 /* Buffer descriptors used by many of the CPM protocols.
79 typedef struct cpm_buf_desc {
80 ushort cbd_sc; /* Status and Control */
81 ushort cbd_datlen; /* Data length in buffer */
82 uint cbd_bufaddr; /* Buffer address in host memory */
85 #define BD_SC_EMPTY ((ushort)0x8000) /* Receive is empty */
86 #define BD_SC_READY ((ushort)0x8000) /* Transmit is ready */
87 #define BD_SC_WRAP ((ushort)0x2000) /* Last buffer descriptor */
88 #define BD_SC_INTRPT ((ushort)0x1000) /* Interrupt on change */
89 #define BD_SC_LAST ((ushort)0x0800) /* Last buffer in frame */
90 #define BD_SC_TC ((ushort)0x0400) /* Transmit CRC */
91 #define BD_SC_CM ((ushort)0x0200) /* Continous mode */
92 #define BD_SC_ID ((ushort)0x0100) /* Rec'd too many idles */
93 #define BD_SC_P ((ushort)0x0100) /* xmt preamble */
94 #define BD_SC_BR ((ushort)0x0020) /* Break received */
95 #define BD_SC_FR ((ushort)0x0010) /* Framing error */
96 #define BD_SC_PR ((ushort)0x0008) /* Parity error */
97 #define BD_SC_NAK ((ushort)0x0004) /* NAK - did not respond */
98 #define BD_SC_OV ((ushort)0x0002) /* Overrun */
99 #define BD_SC_UN ((ushort)0x0002) /* Underrun */
100 #define BD_SC_CD ((ushort)0x0001) /* ?? */
101 #define BD_SC_CL ((ushort)0x0001) /* Collision */
103 /* Parameter RAM offsets.
105 #define PROFF_SCC1 ((uint)0x0000)
106 #define PROFF_IIC ((uint)0x0080)
107 #define PROFF_SCC2 ((uint)0x0100)
108 #define PROFF_SPI ((uint)0x0180)
109 #define PROFF_SCC3 ((uint)0x0200)
110 #define PROFF_SMC1 ((uint)0x0280)
111 #define PROFF_SCC4 ((uint)0x0300)
112 #define PROFF_SMC2 ((uint)0x0380)
114 /* Define enough so I can at least use the serial port as a UART.
115 * The MBX uses SMC1 as the host serial port.
117 typedef struct smc_uart {
118 ushort smc_rbase; /* Rx Buffer descriptor base address */
119 ushort smc_tbase; /* Tx Buffer descriptor base address */
120 u_char smc_rfcr; /* Rx function code */
121 u_char smc_tfcr; /* Tx function code */
122 ushort smc_mrblr; /* Max receive buffer length */
123 uint smc_rstate; /* Internal */
124 uint smc_idp; /* Internal */
125 ushort smc_rbptr; /* Internal */
126 ushort smc_ibc; /* Internal */
127 uint smc_rxtmp; /* Internal */
128 uint smc_tstate; /* Internal */
129 uint smc_tdp; /* Internal */
130 ushort smc_tbptr; /* Internal */
131 ushort smc_tbc; /* Internal */
132 uint smc_txtmp; /* Internal */
133 ushort smc_maxidl; /* Maximum idle characters */
134 ushort smc_tmpidl; /* Temporary idle counter */
135 ushort smc_brklen; /* Last received break length */
136 ushort smc_brkec; /* rcv'd break condition counter */
137 ushort smc_brkcr; /* xmt break count register */
138 ushort smc_rmask; /* Temporary bit mask */
141 /* Function code bits.
143 #define SMC_EB ((u_char)0x10) /* Set big endian byte order */
145 /* SMC uart mode register.
147 #define SMCMR_REN ((ushort)0x0001)
148 #define SMCMR_TEN ((ushort)0x0002)
149 #define SMCMR_DM ((ushort)0x000c)
150 #define SMCMR_SM_GCI ((ushort)0x0000)
151 #define SMCMR_SM_UART ((ushort)0x0020)
152 #define SMCMR_SM_TRANS ((ushort)0x0030)
153 #define SMCMR_SM_MASK ((ushort)0x0030)
154 #define SMCMR_PM_EVEN ((ushort)0x0100) /* Even parity, else odd */
155 #define SMCMR_REVD SMCMR_PM_EVEN
156 #define SMCMR_PEN ((ushort)0x0200) /* Parity enable */
157 #define SMCMR_BS SMCMR_PEN
158 #define SMCMR_SL ((ushort)0x0400) /* Two stops, else one */
159 #define SMCR_CLEN_MASK ((ushort)0x7800) /* Character length */
160 #define smcr_mk_clen(C) (((C) << 11) & SMCR_CLEN_MASK)
162 /* SMC2 as Centronics parallel printer. It is half duplex, in that
163 * it can only receive or transmit. The parameter ram values for
164 * each direction are either unique or properly overlap, so we can
165 * include them in one structure.
167 typedef struct smc_centronics {
185 ushort scent_character1;
186 ushort scent_character2;
187 ushort scent_character3;
188 ushort scent_character4;
189 ushort scent_character5;
190 ushort scent_character6;
191 ushort scent_character7;
192 ushort scent_character8;
197 /* Centronics Status Mask Register.
199 #define SMC_CENT_F ((u_char)0x08)
200 #define SMC_CENT_PE ((u_char)0x04)
201 #define SMC_CENT_S ((u_char)0x02)
203 /* SMC Event and Mask register.
205 #define SMCM_BRKE ((unsigned char)0x40) /* When in UART Mode */
206 #define SMCM_BRK ((unsigned char)0x10) /* When in UART Mode */
207 #define SMCM_TXE ((unsigned char)0x10) /* When in Transparent Mode */
208 #define SMCM_BSY ((unsigned char)0x04)
209 #define SMCM_TX ((unsigned char)0x02)
210 #define SMCM_RX ((unsigned char)0x01)
212 /* Baud rate generators.
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)
223 /* SI Clock Route Register
225 #define SICR_RCLK_SCC1_BRG1 ((uint)0x00000000)
226 #define SICR_TCLK_SCC1_BRG1 ((uint)0x00000000)
227 #define SICR_RCLK_SCC2_BRG2 ((uint)0x00000800)
228 #define SICR_TCLK_SCC2_BRG2 ((uint)0x00000100)
229 #define SICR_RCLK_SCC3_BRG3 ((uint)0x00100000)
230 #define SICR_TCLK_SCC3_BRG3 ((uint)0x00020000)
231 #define SICR_RCLK_SCC4_BRG4 ((uint)0x18000000)
232 #define SICR_TCLK_SCC4_BRG4 ((uint)0x03000000)
236 #define SCC_GSMRH_IRP ((uint)0x00040000)
237 #define SCC_GSMRH_GDE ((uint)0x00010000)
238 #define SCC_GSMRH_TCRC_CCITT ((uint)0x00008000)
239 #define SCC_GSMRH_TCRC_BISYNC ((uint)0x00004000)
240 #define SCC_GSMRH_TCRC_HDLC ((uint)0x00000000)
241 #define SCC_GSMRH_REVD ((uint)0x00002000)
242 #define SCC_GSMRH_TRX ((uint)0x00001000)
243 #define SCC_GSMRH_TTX ((uint)0x00000800)
244 #define SCC_GSMRH_CDP ((uint)0x00000400)
245 #define SCC_GSMRH_CTSP ((uint)0x00000200)
246 #define SCC_GSMRH_CDS ((uint)0x00000100)
247 #define SCC_GSMRH_CTSS ((uint)0x00000080)
248 #define SCC_GSMRH_TFL ((uint)0x00000040)
249 #define SCC_GSMRH_RFW ((uint)0x00000020)
250 #define SCC_GSMRH_TXSY ((uint)0x00000010)
251 #define SCC_GSMRH_SYNL16 ((uint)0x0000000c)
252 #define SCC_GSMRH_SYNL8 ((uint)0x00000008)
253 #define SCC_GSMRH_SYNL4 ((uint)0x00000004)
254 #define SCC_GSMRH_RTSM ((uint)0x00000002)
255 #define SCC_GSMRH_RSYN ((uint)0x00000001)
257 #define SCC_GSMRL_SIR ((uint)0x80000000) /* SCC2 only */
258 #define SCC_GSMRL_EDGE_NONE ((uint)0x60000000)
259 #define SCC_GSMRL_EDGE_NEG ((uint)0x40000000)
260 #define SCC_GSMRL_EDGE_POS ((uint)0x20000000)
261 #define SCC_GSMRL_EDGE_BOTH ((uint)0x00000000)
262 #define SCC_GSMRL_TCI ((uint)0x10000000)
263 #define SCC_GSMRL_TSNC_3 ((uint)0x0c000000)
264 #define SCC_GSMRL_TSNC_4 ((uint)0x08000000)
265 #define SCC_GSMRL_TSNC_14 ((uint)0x04000000)
266 #define SCC_GSMRL_TSNC_INF ((uint)0x00000000)
267 #define SCC_GSMRL_RINV ((uint)0x02000000)
268 #define SCC_GSMRL_TINV ((uint)0x01000000)
269 #define SCC_GSMRL_TPL_128 ((uint)0x00c00000)
270 #define SCC_GSMRL_TPL_64 ((uint)0x00a00000)
271 #define SCC_GSMRL_TPL_48 ((uint)0x00800000)
272 #define SCC_GSMRL_TPL_32 ((uint)0x00600000)
273 #define SCC_GSMRL_TPL_16 ((uint)0x00400000)
274 #define SCC_GSMRL_TPL_8 ((uint)0x00200000)
275 #define SCC_GSMRL_TPL_NONE ((uint)0x00000000)
276 #define SCC_GSMRL_TPP_ALL1 ((uint)0x00180000)
277 #define SCC_GSMRL_TPP_01 ((uint)0x00100000)
278 #define SCC_GSMRL_TPP_10 ((uint)0x00080000)
279 #define SCC_GSMRL_TPP_ZEROS ((uint)0x00000000)
280 #define SCC_GSMRL_TEND ((uint)0x00040000)
281 #define SCC_GSMRL_TDCR_32 ((uint)0x00030000)
282 #define SCC_GSMRL_TDCR_16 ((uint)0x00020000)
283 #define SCC_GSMRL_TDCR_8 ((uint)0x00010000)
284 #define SCC_GSMRL_TDCR_1 ((uint)0x00000000)
285 #define SCC_GSMRL_RDCR_32 ((uint)0x0000c000)
286 #define SCC_GSMRL_RDCR_16 ((uint)0x00008000)
287 #define SCC_GSMRL_RDCR_8 ((uint)0x00004000)
288 #define SCC_GSMRL_RDCR_1 ((uint)0x00000000)
289 #define SCC_GSMRL_RENC_DFMAN ((uint)0x00003000)
290 #define SCC_GSMRL_RENC_MANCH ((uint)0x00002000)
291 #define SCC_GSMRL_RENC_FM0 ((uint)0x00001000)
292 #define SCC_GSMRL_RENC_NRZI ((uint)0x00000800)
293 #define SCC_GSMRL_RENC_NRZ ((uint)0x00000000)
294 #define SCC_GSMRL_TENC_DFMAN ((uint)0x00000600)
295 #define SCC_GSMRL_TENC_MANCH ((uint)0x00000400)
296 #define SCC_GSMRL_TENC_FM0 ((uint)0x00000200)
297 #define SCC_GSMRL_TENC_NRZI ((uint)0x00000100)
298 #define SCC_GSMRL_TENC_NRZ ((uint)0x00000000)
299 #define SCC_GSMRL_DIAG_LE ((uint)0x000000c0) /* Loop and echo */
300 #define SCC_GSMRL_DIAG_ECHO ((uint)0x00000080)
301 #define SCC_GSMRL_DIAG_LOOP ((uint)0x00000040)
302 #define SCC_GSMRL_DIAG_NORM ((uint)0x00000000)
303 #define SCC_GSMRL_ENR ((uint)0x00000020)
304 #define SCC_GSMRL_ENT ((uint)0x00000010)
305 #define SCC_GSMRL_MODE_ENET ((uint)0x0000000c)
306 #define SCC_GSMRL_MODE_DDCMP ((uint)0x00000009)
307 #define SCC_GSMRL_MODE_BISYNC ((uint)0x00000008)
308 #define SCC_GSMRL_MODE_V14 ((uint)0x00000007)
309 #define SCC_GSMRL_MODE_AHDLC ((uint)0x00000006)
310 #define SCC_GSMRL_MODE_PROFIBUS ((uint)0x00000005)
311 #define SCC_GSMRL_MODE_UART ((uint)0x00000004)
312 #define SCC_GSMRL_MODE_SS7 ((uint)0x00000003)
313 #define SCC_GSMRL_MODE_ATALK ((uint)0x00000002)
314 #define SCC_GSMRL_MODE_HDLC ((uint)0x00000000)
316 #define SCC_TODR_TOD ((ushort)0x8000)
318 /* SCC Event and Mask register.
320 #define SCCM_TXE ((unsigned char)0x10)
321 #define SCCM_BSY ((unsigned char)0x04)
322 #define SCCM_TX ((unsigned char)0x02)
323 #define SCCM_RX ((unsigned char)0x01)
325 typedef struct scc_param {
326 ushort scc_rbase; /* Rx Buffer descriptor base address */
327 ushort scc_tbase; /* Tx Buffer descriptor base address */
328 u_char scc_rfcr; /* Rx function code */
329 u_char scc_tfcr; /* Tx function code */
330 ushort scc_mrblr; /* Max receive buffer length */
331 uint scc_rstate; /* Internal */
332 uint scc_idp; /* Internal */
333 ushort scc_rbptr; /* Internal */
334 ushort scc_ibc; /* Internal */
335 uint scc_rxtmp; /* Internal */
336 uint scc_tstate; /* Internal */
337 uint scc_tdp; /* Internal */
338 ushort scc_tbptr; /* Internal */
339 ushort scc_tbc; /* Internal */
340 uint scc_txtmp; /* Internal */
341 uint scc_rcrc; /* Internal */
342 uint scc_tcrc; /* Internal */
345 /* Function code bits.
347 #define SCC_EB ((u_char)0x10) /* Set big endian byte order */
349 /* CPM Ethernet through SCCx.
351 typedef struct scc_enet {
353 uint sen_cpres; /* Preset CRC */
354 uint sen_cmask; /* Constant mask for CRC */
355 uint sen_crcec; /* CRC Error counter */
356 uint sen_alec; /* alignment error counter */
357 uint sen_disfc; /* discard frame counter */
358 ushort sen_pads; /* Tx short frame pad character */
359 ushort sen_retlim; /* Retry limit threshold */
360 ushort sen_retcnt; /* Retry limit counter */
361 ushort sen_maxflr; /* maximum frame length register */
362 ushort sen_minflr; /* minimum frame length register */
363 ushort sen_maxd1; /* maximum DMA1 length */
364 ushort sen_maxd2; /* maximum DMA2 length */
365 ushort sen_maxd; /* Rx max DMA */
366 ushort sen_dmacnt; /* Rx DMA counter */
367 ushort sen_maxb; /* Max BD byte count */
368 ushort sen_gaddr1; /* Group address filter */
372 uint sen_tbuf0data0; /* Save area 0 - current frame */
373 uint sen_tbuf0data1; /* Save area 1 - current frame */
374 uint sen_tbuf0rba; /* Internal */
375 uint sen_tbuf0crc; /* Internal */
376 ushort sen_tbuf0bcnt; /* Internal */
377 ushort sen_paddrh; /* physical address (MSB) */
379 ushort sen_paddrl; /* physical address (LSB) */
380 ushort sen_pper; /* persistence */
381 ushort sen_rfbdptr; /* Rx first BD pointer */
382 ushort sen_tfbdptr; /* Tx first BD pointer */
383 ushort sen_tlbdptr; /* Tx last BD pointer */
384 uint sen_tbuf1data0; /* Save area 0 - current frame */
385 uint sen_tbuf1data1; /* Save area 1 - current frame */
386 uint sen_tbuf1rba; /* Internal */
387 uint sen_tbuf1crc; /* Internal */
388 ushort sen_tbuf1bcnt; /* Internal */
389 ushort sen_txlen; /* Tx Frame length counter */
390 ushort sen_iaddr1; /* Individual address filter */
394 ushort sen_boffcnt; /* Backoff counter */
396 /* NOTE: Some versions of the manual have the following items
397 * incorrectly documented. Below is the proper order.
399 ushort sen_taddrh; /* temp address (MSB) */
401 ushort sen_taddrl; /* temp address (LSB) */
404 /*** MBX ************************************************************/
407 /* Bits in parallel I/O port registers that have to be set/cleared
408 * to configure the pins for SCC1 use. The TCLK and RCLK seem unique
409 * to the MBX860 board. Any two of the four available clocks could be
410 * used, and the MPC860 cookbook manual has an example using different
413 #define PA_ENET_RXD ((ushort)0x0001)
414 #define PA_ENET_TXD ((ushort)0x0002)
415 #define PA_ENET_TCLK ((ushort)0x0200)
416 #define PA_ENET_RCLK ((ushort)0x0800)
417 #define PC_ENET_TENA ((ushort)0x0001)
418 #define PC_ENET_CLSN ((ushort)0x0010)
419 #define PC_ENET_RENA ((ushort)0x0020)
421 /* Control bits in the SICR to route TCLK (CLK2) and RCLK (CLK4) to
422 * SCC1. Also, make sure GR1 (bit 24) and SC1 (bit 25) are zero.
424 #define SICR_ENET_MASK ((uint)0x000000ff)
425 #define SICR_ENET_CLKRT ((uint)0x0000003d)
426 #endif /* CONFIG_MBX */
428 /*** RPXLITE ********************************************************/
430 #ifdef CONFIG_RPXLITE
431 /* This ENET stuff is for the MPC850 with ethernet on SCC2. Some of
432 * this may be unique to the RPX-Lite configuration.
433 * Note TENA is on Port B.
435 #define PA_ENET_RXD ((ushort)0x0004)
436 #define PA_ENET_TXD ((ushort)0x0008)
437 #define PA_ENET_TCLK ((ushort)0x0200)
438 #define PA_ENET_RCLK ((ushort)0x0800)
439 #define PB_ENET_TENA ((uint)0x00002000)
440 #define PC_ENET_CLSN ((ushort)0x0040)
441 #define PC_ENET_RENA ((ushort)0x0080)
443 #define SICR_ENET_MASK ((uint)0x0000ff00)
444 #define SICR_ENET_CLKRT ((uint)0x00003d00)
445 #endif /* CONFIG_RPXLITE */
447 /*** BSEIP **********************************************************/
450 /* This ENET stuff is for the MPC823 with ethernet on SCC2.
451 * This is unique to the BSE ip-Engine board.
453 #define PA_ENET_RXD ((ushort)0x0004)
454 #define PA_ENET_TXD ((ushort)0x0008)
455 #define PA_ENET_TCLK ((ushort)0x0100)
456 #define PA_ENET_RCLK ((ushort)0x0200)
457 #define PB_ENET_TENA ((uint)0x00002000)
458 #define PC_ENET_CLSN ((ushort)0x0040)
459 #define PC_ENET_RENA ((ushort)0x0080)
461 /* BSE uses port B and C bits for PHY control also.
463 #define PB_BSE_POWERUP ((uint)0x00000004)
464 #define PB_BSE_FDXDIS ((uint)0x00008000)
465 #define PC_BSE_LOOPBACK ((ushort)0x0800)
467 #define SICR_ENET_MASK ((uint)0x0000ff00)
468 #define SICR_ENET_CLKRT ((uint)0x00002c00)
469 #endif /* CONFIG_BSEIP */
471 /*** RPXCLASSIC *****************************************************/
473 #ifdef CONFIG_RPXCLASSIC
474 /* Bits in parallel I/O port registers that have to be set/cleared
475 * to configure the pins for SCC1 use.
477 #define PA_ENET_RXD ((ushort)0x0001)
478 #define PA_ENET_TXD ((ushort)0x0002)
479 #define PA_ENET_TCLK ((ushort)0x0200)
480 #define PA_ENET_RCLK ((ushort)0x0800)
481 #define PB_ENET_TENA ((uint)0x00001000)
482 #define PC_ENET_CLSN ((ushort)0x0010)
483 #define PC_ENET_RENA ((ushort)0x0020)
485 /* Control bits in the SICR to route TCLK (CLK2) and RCLK (CLK4) to
486 * SCC1. Also, make sure GR1 (bit 24) and SC1 (bit 25) are zero.
488 #define SICR_ENET_MASK ((uint)0x000000ff)
489 #define SICR_ENET_CLKRT ((uint)0x0000003d)
490 #endif /* CONFIG_RPXCLASSIC */
492 /*** TQM823L, TQM850L ***********************************************/
494 #if defined(CONFIG_TQM823L) || defined(CONFIG_TQM850L)
495 /* Bits in parallel I/O port registers that have to be set/cleared
496 * to configure the pins for SCC1 use.
498 #define PA_ENET_RXD ((ushort)0x0004) /* PA 13 */
499 #define PA_ENET_TXD ((ushort)0x0008) /* PA 12 */
500 #define PA_ENET_RCLK ((ushort)0x0100) /* PA 7 */
501 #define PA_ENET_TCLK ((ushort)0x0400) /* PA 5 */
503 #define PB_ENET_TENA ((uint)0x00002000) /* PB 18 */
505 #define PC_ENET_CLSN ((ushort)0x0040) /* PC 9 */
506 #define PC_ENET_RENA ((ushort)0x0080) /* PC 8 */
508 /* Control bits in the SICR to route TCLK (CLK3) and RCLK (CLK1) to
509 * SCC2. Also, make sure GR2 (bit 16) and SC2 (bit 17) are zero.
511 #define SICR_ENET_MASK ((uint)0x0000ff00)
512 #define SICR_ENET_CLKRT ((uint)0x00002600)
513 #endif /* CONFIG_TQM823L, CONFIG_TQM850L */
515 /*** FPS850L *********************************************************/
517 #ifdef CONFIG_FPS850L
518 /* Bits in parallel I/O port registers that have to be set/cleared
519 * to configure the pins for SCC1 use.
521 #define PA_ENET_RXD ((ushort)0x0004) /* PA 13 */
522 #define PA_ENET_TXD ((ushort)0x0008) /* PA 12 */
523 #define PA_ENET_RCLK ((ushort)0x0100) /* PA 7 */
524 #define PA_ENET_TCLK ((ushort)0x0400) /* PA 5 */
526 #define PC_ENET_TENA ((ushort)0x0002) /* PC 14 */
527 #define PC_ENET_CLSN ((ushort)0x0040) /* PC 9 */
528 #define PC_ENET_RENA ((ushort)0x0080) /* PC 8 */
530 /* Control bits in the SICR to route TCLK (CLK2) and RCLK (CLK4) to
531 * SCC2. Also, make sure GR2 (bit 16) and SC2 (bit 17) are zero.
533 #define SICR_ENET_MASK ((uint)0x0000ff00)
534 #define SICR_ENET_CLKRT ((uint)0x00002600)
535 #endif /* CONFIG_FPS850L */
537 /*** TQM860L ********************************************************/
539 #ifdef CONFIG_TQM860L
540 /* Bits in parallel I/O port registers that have to be set/cleared
541 * to configure the pins for SCC1 use.
543 #define PA_ENET_RXD ((ushort)0x0001) /* PA 15 */
544 #define PA_ENET_TXD ((ushort)0x0002) /* PA 14 */
545 #define PA_ENET_RCLK ((ushort)0x0100) /* PA 7 */
546 #define PA_ENET_TCLK ((ushort)0x0400) /* PA 5 */
548 #define PC_ENET_TENA ((ushort)0x0001) /* PC 15 */
549 #define PC_ENET_CLSN ((ushort)0x0010) /* PC 11 */
550 #define PC_ENET_RENA ((ushort)0x0020) /* PC 10 */
552 /* Control bits in the SICR to route TCLK (CLK3) and RCLK (CLK1) to
553 * SCC1. Also, make sure GR1 (bit 24) and SC1 (bit 25) are zero.
555 #define SICR_ENET_MASK ((uint)0x000000ff)
556 #define SICR_ENET_CLKRT ((uint)0x00000026)
557 #endif /* CONFIG_TQM860L */
559 /*** SPD823TS *******************************************************/
561 #ifdef CONFIG_SPD823TS
562 /* Bits in parallel I/O port registers that have to be set/cleared
563 * to configure the pins for SCC2 use.
565 #define PA_ENET_MDC ((ushort)0x0001) /* PA 15 !!! */
566 #define PA_ENET_MDIO ((ushort)0x0002) /* PA 14 !!! */
567 #define PA_ENET_RXD ((ushort)0x0004) /* PA 13 */
568 #define PA_ENET_TXD ((ushort)0x0008) /* PA 12 */
569 #define PA_ENET_RCLK ((ushort)0x0200) /* PA 6 */
570 #define PA_ENET_TCLK ((ushort)0x0400) /* PA 5 */
572 #define PB_ENET_TENA ((uint)0x00002000) /* PB 18 */
574 #define PC_ENET_CLSN ((ushort)0x0040) /* PC 9 */
575 #define PC_ENET_RENA ((ushort)0x0080) /* PC 8 */
576 #define PC_ENET_RESET ((ushort)0x0100) /* PC 7 !!! */
578 /* Control bits in the SICR to route TCLK (CLK3) and RCLK (CLK2) to
579 * SCC2. Also, make sure GR2 (bit 16) and SC2 (bit 17) are zero.
581 #define SICR_ENET_MASK ((uint)0x0000ff00)
582 #define SICR_ENET_CLKRT ((uint)0x00002E00)
583 #endif /* CONFIG_SPD823TS */
586 /*** SM850 *********************************************************/
588 /* The SM850 Service Module uses SCC2 for IrDA and SCC3 for Ethernet */
591 #define PB_ENET_RXD ((uint)0x00000004) /* PB 29 */
592 #define PB_ENET_TXD ((uint)0x00000002) /* PB 30 */
593 #define PA_ENET_RCLK ((ushort)0x0100) /* PA 7 */
594 #define PA_ENET_TCLK ((ushort)0x0400) /* PA 5 */
596 #define PC_ENET_LBK ((ushort)0x0008) /* PC 12 */
597 #define PC_ENET_TENA ((ushort)0x0004) /* PC 13 */
599 #define PC_ENET_RENA ((ushort)0x0800) /* PC 4 */
600 #define PC_ENET_CLSN ((ushort)0x0400) /* PC 5 */
602 /* Control bits in the SICR to route TCLK (CLK3) and RCLK (CLK1) to
603 * SCC3. Also, make sure GR3 (bit 8) and SC3 (bit 9) are zero.
605 #define SICR_ENET_MASK ((uint)0x00FF0000)
606 #define SICR_ENET_CLKRT ((uint)0x00260000)
607 #endif /* CONFIG_SM850 */
609 /*********************************************************************/
611 /* SCC Event register as used by Ethernet.
613 #define SCCE_ENET_GRA ((ushort)0x0080) /* Graceful stop complete */
614 #define SCCE_ENET_TXE ((ushort)0x0010) /* Transmit Error */
615 #define SCCE_ENET_RXF ((ushort)0x0008) /* Full frame received */
616 #define SCCE_ENET_BSY ((ushort)0x0004) /* All incoming buffers full */
617 #define SCCE_ENET_TXB ((ushort)0x0002) /* A buffer was transmitted */
618 #define SCCE_ENET_RXB ((ushort)0x0001) /* A buffer was received */
620 /* SCC Mode Register (PMSR) as used by Ethernet.
622 #define SCC_PMSR_HBC ((ushort)0x8000) /* Enable heartbeat */
623 #define SCC_PMSR_FC ((ushort)0x4000) /* Force collision */
624 #define SCC_PMSR_RSH ((ushort)0x2000) /* Receive short frames */
625 #define SCC_PMSR_IAM ((ushort)0x1000) /* Check individual hash */
626 #define SCC_PMSR_ENCRC ((ushort)0x0800) /* Ethernet CRC mode */
627 #define SCC_PMSR_PRO ((ushort)0x0200) /* Promiscuous mode */
628 #define SCC_PMSR_BRO ((ushort)0x0100) /* Catch broadcast pkts */
629 #define SCC_PMSR_SBT ((ushort)0x0080) /* Special backoff timer */
630 #define SCC_PMSR_LPB ((ushort)0x0040) /* Set Loopback mode */
631 #define SCC_PMSR_SIP ((ushort)0x0020) /* Sample Input Pins */
632 #define SCC_PMSR_LCW ((ushort)0x0010) /* Late collision window */
633 #define SCC_PMSR_NIB22 ((ushort)0x000a) /* Start frame search */
634 #define SCC_PMSR_FDE ((ushort)0x0001) /* Full duplex enable */
636 /* Buffer descriptor control/status used by Ethernet receive.
638 #define BD_ENET_RX_EMPTY ((ushort)0x8000)
639 #define BD_ENET_RX_WRAP ((ushort)0x2000)
640 #define BD_ENET_RX_INTR ((ushort)0x1000)
641 #define BD_ENET_RX_LAST ((ushort)0x0800)
642 #define BD_ENET_RX_FIRST ((ushort)0x0400)
643 #define BD_ENET_RX_MISS ((ushort)0x0100)
644 #define BD_ENET_RX_LG ((ushort)0x0020)
645 #define BD_ENET_RX_NO ((ushort)0x0010)
646 #define BD_ENET_RX_SH ((ushort)0x0008)
647 #define BD_ENET_RX_CR ((ushort)0x0004)
648 #define BD_ENET_RX_OV ((ushort)0x0002)
649 #define BD_ENET_RX_CL ((ushort)0x0001)
650 #define BD_ENET_RX_BC ((ushort)0x0080) /* DA is Broadcast */
651 #define BD_ENET_RX_MC ((ushort)0x0040) /* DA is Multicast */
652 #define BD_ENET_RX_STATS ((ushort)0x013f) /* All status bits */
654 /* Buffer descriptor control/status used by Ethernet transmit.
656 #define BD_ENET_TX_READY ((ushort)0x8000)
657 #define BD_ENET_TX_PAD ((ushort)0x4000)
658 #define BD_ENET_TX_WRAP ((ushort)0x2000)
659 #define BD_ENET_TX_INTR ((ushort)0x1000)
660 #define BD_ENET_TX_LAST ((ushort)0x0800)
661 #define BD_ENET_TX_TC ((ushort)0x0400)
662 #define BD_ENET_TX_DEF ((ushort)0x0200)
663 #define BD_ENET_TX_HB ((ushort)0x0100)
664 #define BD_ENET_TX_LC ((ushort)0x0080)
665 #define BD_ENET_TX_RL ((ushort)0x0040)
666 #define BD_ENET_TX_RCMASK ((ushort)0x003c)
667 #define BD_ENET_TX_UN ((ushort)0x0002)
668 #define BD_ENET_TX_CSL ((ushort)0x0001)
669 #define BD_ENET_TX_STATS ((ushort)0x03ff) /* All status bits */
673 typedef struct scc_uart {
675 uint scc_res1; /* Reserved */
676 uint scc_res2; /* Reserved */
677 ushort scc_maxidl; /* Maximum idle chars */
678 ushort scc_idlc; /* temp idle counter */
679 ushort scc_brkcr; /* Break count register */
680 ushort scc_parec; /* receive parity error counter */
681 ushort scc_frmec; /* receive framing error counter */
682 ushort scc_nosec; /* receive noise counter */
683 ushort scc_brkec; /* receive break condition counter */
684 ushort scc_brkln; /* last received break length */
685 ushort scc_uaddr1; /* UART address character 1 */
686 ushort scc_uaddr2; /* UART address character 2 */
687 ushort scc_rtemp; /* Temp storage */
688 ushort scc_toseq; /* Transmit out of sequence char */
689 ushort scc_char1; /* control character 1 */
690 ushort scc_char2; /* control character 2 */
691 ushort scc_char3; /* control character 3 */
692 ushort scc_char4; /* control character 4 */
693 ushort scc_char5; /* control character 5 */
694 ushort scc_char6; /* control character 6 */
695 ushort scc_char7; /* control character 7 */
696 ushort scc_char8; /* control character 8 */
697 ushort scc_rccm; /* receive control character mask */
698 ushort scc_rccr; /* receive control character register */
699 ushort scc_rlbc; /* receive last break character */
702 /* SCC Event and Mask registers when it is used as a UART.
704 #define UART_SCCM_GLR ((ushort)0x1000)
705 #define UART_SCCM_GLT ((ushort)0x0800)
706 #define UART_SCCM_AB ((ushort)0x0200)
707 #define UART_SCCM_IDL ((ushort)0x0100)
708 #define UART_SCCM_GRA ((ushort)0x0080)
709 #define UART_SCCM_BRKE ((ushort)0x0040)
710 #define UART_SCCM_BRKS ((ushort)0x0020)
711 #define UART_SCCM_CCR ((ushort)0x0008)
712 #define UART_SCCM_BSY ((ushort)0x0004)
713 #define UART_SCCM_TX ((ushort)0x0002)
714 #define UART_SCCM_RX ((ushort)0x0001)
716 /* The SCC PMSR when used as a UART.
718 #define SCU_PMSR_FLC ((ushort)0x8000)
719 #define SCU_PMSR_SL ((ushort)0x4000)
720 #define SCU_PMSR_CL ((ushort)0x3000)
721 #define SCU_PMSR_UM ((ushort)0x0c00)
722 #define SCU_PMSR_FRZ ((ushort)0x0200)
723 #define SCU_PMSR_RZS ((ushort)0x0100)
724 #define SCU_PMSR_SYN ((ushort)0x0080)
725 #define SCU_PMSR_DRT ((ushort)0x0040)
726 #define SCU_PMSR_PEN ((ushort)0x0010)
727 #define SCU_PMSR_RPM ((ushort)0x000c)
728 #define SCU_PMSR_REVP ((ushort)0x0008)
729 #define SCU_PMSR_TPM ((ushort)0x0003)
730 #define SCU_PMSR_TEVP ((ushort)0x0002)
732 /* CPM Transparent mode SCC.
734 typedef struct scc_trans {
736 uint st_cpres; /* Preset CRC */
737 uint st_cmask; /* Constant mask for CRC */
740 #define BD_SCC_TX_LAST ((ushort)0x0800)
742 /* IIC parameter RAM.
745 ushort iic_rbase; /* Rx Buffer descriptor base address */
746 ushort iic_tbase; /* Tx Buffer descriptor base address */
747 u_char iic_rfcr; /* Rx function code */
748 u_char iic_tfcr; /* Tx function code */
749 ushort iic_mrblr; /* Max receive buffer length */
750 uint iic_rstate; /* Internal */
751 uint iic_rdp; /* Internal */
752 ushort iic_rbptr; /* Internal */
753 ushort iic_rbc; /* Internal */
754 uint iic_rxtmp; /* Internal */
755 uint iic_tstate; /* Internal */
756 uint iic_tdp; /* Internal */
757 ushort iic_tbptr; /* Internal */
758 ushort iic_tbc; /* Internal */
759 uint iic_txtmp; /* Internal */
760 uint iic_res; /* reserved */
761 ushort iic_rpbase; /* Relocation pointer */
762 ushort iic_res2; /* reserved */
765 #define BD_IIC_START ((ushort)0x0400)
767 /* SPI parameter RAM.
770 ushort spi_rbase; /* Rx Buffer descriptor base address */
771 ushort spi_tbase; /* Tx Buffer descriptor base address */
772 u_char spi_rfcr; /* Rx function code */
773 u_char spi_tfcr; /* Tx function code */
774 ushort spi_mrblr; /* Max receive buffer length */
775 uint spi_rstate; /* Internal */
776 uint spi_rdp; /* Internal */
777 ushort spi_rbptr; /* Internal */
778 ushort spi_rbc; /* Internal */
779 uint spi_rxtmp; /* Internal */
780 uint spi_tstate; /* Internal */
781 uint spi_tdp; /* Internal */
782 ushort spi_tbptr; /* Internal */
783 ushort spi_tbc; /* Internal */
784 uint spi_txtmp; /* Internal */
786 ushort spi_rpbase; /* Relocation pointer */
790 /* SPI Mode register.
792 #define SPMODE_LOOP ((ushort)0x4000) /* Loopback */
793 #define SPMODE_CI ((ushort)0x2000) /* Clock Invert */
794 #define SPMODE_CP ((ushort)0x1000) /* Clock Phase */
795 #define SPMODE_DIV16 ((ushort)0x0800) /* BRG/16 mode */
796 #define SPMODE_REV ((ushort)0x0400) /* Reversed Data */
797 #define SPMODE_MSTR ((ushort)0x0200) /* SPI Master */
798 #define SPMODE_EN ((ushort)0x0100) /* Enable */
799 #define SPMODE_LENMSK ((ushort)0x00f0) /* character length */
800 #define SPMODE_LEN4 ((ushort)0x0030) /* 4 bits per char */
801 #define SPMODE_LEN8 ((ushort)0x0070) /* 8 bits per char */
802 #define SPMODE_LEN16 ((ushort)0x00f0) /* 16 bits per char */
803 #define SPMODE_PMMSK ((ushort)0x000f) /* prescale modulus */
806 #define SPIE_MME 0x20
807 #define SPIE_TXE 0x10
808 #define SPIE_BSY 0x04
809 #define SPIE_TXB 0x02
810 #define SPIE_RXB 0x01
813 * RISC Controller Configuration Register definitons
815 #define RCCR_TIME 0x8000 /* RISC Timer Enable */
816 #define RCCR_TIMEP(t) (((t) & 0x3F)<<8) /* RISC Timer Period */
817 #define RCCR_TIME_MASK 0x00FF /* not RISC Timer related bits */
819 /* RISC Timer Parameter RAM offset */
820 #define PROFF_RTMR ((uint)0x01B0)
822 typedef struct risc_timer_pram {
823 unsigned short tm_base; /* RISC Timer Table Base Address */
824 unsigned short tm_ptr; /* RISC Timer Table Pointer (internal) */
825 unsigned short r_tmr; /* RISC Timer Mode Register */
826 unsigned short r_tmv; /* RISC Timer Valid Register */
827 unsigned long tm_cmd; /* RISC Timer Command Register */
828 unsigned long tm_cnt; /* RISC Timer Internal Count */
831 /* Bits in RISC Timer Command Register */
832 #define TM_CMD_VALID 0x80000000 /* Valid - Enables the timer */
833 #define TM_CMD_RESTART 0x40000000 /* Restart - for automatic restart */
834 #define TM_CMD_PWM 0x20000000 /* Run in Pulse Width Modulation Mode */
835 #define TM_CMD_NUM(n) (((n)&0xF)<<16) /* Timer Number */
836 #define TM_CMD_PERIOD(p) ((p)&0xFFFF) /* Timer Period */
839 /* CPM interrupts. There are nearly 32 interrupts generated by CPM
840 * channels or devices. All of these are presented to the PPC core
841 * as a single interrupt. The CPM interrupt handler dispatches its
842 * own handlers, in a similar fashion to the PPC core handler. We
843 * use the table as defined in the manuals (i.e. no special high
844 * priority and SCC1 == SCCa, etc...).
847 #define CPMVEC_PIO_PC15 ((ushort)0x1f)
848 #define CPMVEC_SCC1 ((ushort)0x1e)
849 #define CPMVEC_SCC2 ((ushort)0x1d)
850 #define CPMVEC_SCC3 ((ushort)0x1c)
851 #define CPMVEC_SCC4 ((ushort)0x1b)
852 #define CPMVEC_PIO_PC14 ((ushort)0x1a)
853 #define CPMVEC_TIMER1 ((ushort)0x19)
854 #define CPMVEC_PIO_PC13 ((ushort)0x18)
855 #define CPMVEC_PIO_PC12 ((ushort)0x17)
856 #define CPMVEC_SDMA_CB_ERR ((ushort)0x16)
857 #define CPMVEC_IDMA1 ((ushort)0x15)
858 #define CPMVEC_IDMA2 ((ushort)0x14)
859 #define CPMVEC_TIMER2 ((ushort)0x12)
860 #define CPMVEC_RISCTIMER ((ushort)0x11)
861 #define CPMVEC_I2C ((ushort)0x10)
862 #define CPMVEC_PIO_PC11 ((ushort)0x0f)
863 #define CPMVEC_PIO_PC10 ((ushort)0x0e)
864 #define CPMVEC_TIMER3 ((ushort)0x0c)
865 #define CPMVEC_PIO_PC9 ((ushort)0x0b)
866 #define CPMVEC_PIO_PC8 ((ushort)0x0a)
867 #define CPMVEC_PIO_PC7 ((ushort)0x09)
868 #define CPMVEC_TIMER4 ((ushort)0x07)
869 #define CPMVEC_PIO_PC6 ((ushort)0x06)
870 #define CPMVEC_SPI ((ushort)0x05)
871 #define CPMVEC_SMC1 ((ushort)0x04)
872 #define CPMVEC_SMC2 ((ushort)0x03)
873 #define CPMVEC_PIO_PC5 ((ushort)0x02)
874 #define CPMVEC_PIO_PC4 ((ushort)0x01)
875 #define CPMVEC_ERROR ((ushort)0x00)
877 /* CPM interrupt configuration vector.
879 #define CICR_SCD_SCC4 ((uint)0x00c00000) /* SCC4 @ SCCd */
880 #define CICR_SCC_SCC3 ((uint)0x00200000) /* SCC3 @ SCCc */
881 #define CICR_SCB_SCC2 ((uint)0x00040000) /* SCC2 @ SCCb */
882 #define CICR_SCA_SCC1 ((uint)0x00000000) /* SCC1 @ SCCa */
883 #define CICR_IRL_MASK ((uint)0x0000e000) /* Core interrrupt */
884 #define CICR_HP_MASK ((uint)0x00001f00) /* Hi-pri int. */
885 #define CICR_IEN ((uint)0x00000080) /* Int. enable */
886 #define CICR_SPS ((uint)0x00000001) /* SCC Spread */
888 extern void cpm_install_handler(int vec,
889 void (*handler)(void *, struct pt_regs *regs), void *dev_id);
890 extern void cpm_free_handler(int vec);
892 #endif /* __CPM_8XX__ */