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