[POWERPC] Clean up vio.h
[powerpc.git] / include / asm-powerpc / cpm2.h
1 /*
2  * Communication Processor Module v2.
3  *
4  * This file contains structures and information for the communication
5  * processor channels found in the dual port RAM or parameter RAM.
6  * All CPM control and status is available through the CPM2 internal
7  * memory map.  See immap_cpm2.h for details.
8  */
9 #ifdef __KERNEL__
10 #ifndef __CPM2__
11 #define __CPM2__
12
13 #include <asm/immap_cpm2.h>
14 #include <asm/cpm.h>
15
16 /* CPM Command register.
17 */
18 #define CPM_CR_RST      ((uint)0x80000000)
19 #define CPM_CR_PAGE     ((uint)0x7c000000)
20 #define CPM_CR_SBLOCK   ((uint)0x03e00000)
21 #define CPM_CR_FLG      ((uint)0x00010000)
22 #define CPM_CR_MCN      ((uint)0x00003fc0)
23 #define CPM_CR_OPCODE   ((uint)0x0000000f)
24
25 /* Device sub-block and page codes.
26 */
27 #define CPM_CR_SCC1_SBLOCK      (0x04)
28 #define CPM_CR_SCC2_SBLOCK      (0x05)
29 #define CPM_CR_SCC3_SBLOCK      (0x06)
30 #define CPM_CR_SCC4_SBLOCK      (0x07)
31 #define CPM_CR_SMC1_SBLOCK      (0x08)
32 #define CPM_CR_SMC2_SBLOCK      (0x09)
33 #define CPM_CR_SPI_SBLOCK       (0x0a)
34 #define CPM_CR_I2C_SBLOCK       (0x0b)
35 #define CPM_CR_TIMER_SBLOCK     (0x0f)
36 #define CPM_CR_RAND_SBLOCK      (0x0e)
37 #define CPM_CR_FCC1_SBLOCK      (0x10)
38 #define CPM_CR_FCC2_SBLOCK      (0x11)
39 #define CPM_CR_FCC3_SBLOCK      (0x12)
40 #define CPM_CR_IDMA1_SBLOCK     (0x14)
41 #define CPM_CR_IDMA2_SBLOCK     (0x15)
42 #define CPM_CR_IDMA3_SBLOCK     (0x16)
43 #define CPM_CR_IDMA4_SBLOCK     (0x17)
44 #define CPM_CR_MCC1_SBLOCK      (0x1c)
45
46 #define CPM_CR_FCC_SBLOCK(x)    (x + 0x10)
47
48 #define CPM_CR_SCC1_PAGE        (0x00)
49 #define CPM_CR_SCC2_PAGE        (0x01)
50 #define CPM_CR_SCC3_PAGE        (0x02)
51 #define CPM_CR_SCC4_PAGE        (0x03)
52 #define CPM_CR_SMC1_PAGE        (0x07)
53 #define CPM_CR_SMC2_PAGE        (0x08)
54 #define CPM_CR_SPI_PAGE         (0x09)
55 #define CPM_CR_I2C_PAGE         (0x0a)
56 #define CPM_CR_TIMER_PAGE       (0x0a)
57 #define CPM_CR_RAND_PAGE        (0x0a)
58 #define CPM_CR_FCC1_PAGE        (0x04)
59 #define CPM_CR_FCC2_PAGE        (0x05)
60 #define CPM_CR_FCC3_PAGE        (0x06)
61 #define CPM_CR_IDMA1_PAGE       (0x07)
62 #define CPM_CR_IDMA2_PAGE       (0x08)
63 #define CPM_CR_IDMA3_PAGE       (0x09)
64 #define CPM_CR_IDMA4_PAGE       (0x0a)
65 #define CPM_CR_MCC1_PAGE        (0x07)
66 #define CPM_CR_MCC2_PAGE        (0x08)
67
68 #define CPM_CR_FCC_PAGE(x)      (x + 0x04)
69
70 /* Some opcodes (there are more...later)
71 */
72 #define CPM_CR_INIT_TRX         ((ushort)0x0000)
73 #define CPM_CR_INIT_RX          ((ushort)0x0001)
74 #define CPM_CR_INIT_TX          ((ushort)0x0002)
75 #define CPM_CR_HUNT_MODE        ((ushort)0x0003)
76 #define CPM_CR_STOP_TX          ((ushort)0x0004)
77 #define CPM_CR_GRA_STOP_TX      ((ushort)0x0005)
78 #define CPM_CR_RESTART_TX       ((ushort)0x0006)
79 #define CPM_CR_SET_GADDR        ((ushort)0x0008)
80 #define CPM_CR_START_IDMA       ((ushort)0x0009)
81 #define CPM_CR_STOP_IDMA        ((ushort)0x000b)
82
83 #define mk_cr_cmd(PG, SBC, MCN, OP) \
84         ((PG << 26) | (SBC << 21) | (MCN << 6) | OP)
85
86 #ifndef CONFIG_PPC_CPM_NEW_BINDING
87 /* Dual Port RAM addresses.  The first 16K is available for almost
88  * any CPM use, so we put the BDs there.  The first 128 bytes are
89  * used for SMC1 and SMC2 parameter RAM, so we start allocating
90  * BDs above that.  All of this must change when we start
91  * downloading RAM microcode.
92  */
93 #define CPM_DATAONLY_BASE       ((uint)128)
94 #define CPM_DP_NOSPACE          ((uint)0x7fffffff)
95 #if defined(CONFIG_8272) || defined(CONFIG_MPC8555)
96 #define CPM_DATAONLY_SIZE       ((uint)(8 * 1024) - CPM_DATAONLY_BASE)
97 #define CPM_FCC_SPECIAL_BASE    ((uint)0x00009000)
98 #else
99 #define CPM_DATAONLY_SIZE       ((uint)(16 * 1024) - CPM_DATAONLY_BASE)
100 #define CPM_FCC_SPECIAL_BASE    ((uint)0x0000b000)
101 #endif
102 #endif
103
104 /* The number of pages of host memory we allocate for CPM.  This is
105  * done early in kernel initialization to get physically contiguous
106  * pages.
107  */
108 #define NUM_CPM_HOST_PAGES      2
109
110 /* Export the base address of the communication processor registers
111  * and dual port ram.
112  */
113 extern cpm_cpm2_t __iomem *cpmp; /* Pointer to comm processor */
114
115 #ifdef CONFIG_PPC_CPM_NEW_BINDING
116 #define cpm_dpalloc cpm_muram_alloc
117 #define cpm_dpfree cpm_muram_free
118 #define cpm_dpram_addr cpm_muram_addr
119 #else
120 extern unsigned long cpm_dpalloc(uint size, uint align);
121 extern int cpm_dpfree(unsigned long offset);
122 extern unsigned long cpm_dpalloc_fixed(unsigned long offset, uint size, uint align);
123 extern void cpm_dpdump(void);
124 extern void *cpm_dpram_addr(unsigned long offset);
125 #endif
126
127 extern void cpm_setbrg(uint brg, uint rate);
128 extern void cpm2_fastbrg(uint brg, uint rate, int div16);
129 extern void cpm2_reset(void);
130
131
132 /* Buffer descriptors used by many of the CPM protocols.
133 */
134 typedef struct cpm_buf_desc {
135         ushort  cbd_sc;         /* Status and Control */
136         ushort  cbd_datlen;     /* Data length in buffer */
137         uint    cbd_bufaddr;    /* Buffer address in host memory */
138 } cbd_t;
139
140 #define BD_SC_EMPTY     ((ushort)0x8000)        /* Receive is empty */
141 #define BD_SC_READY     ((ushort)0x8000)        /* Transmit is ready */
142 #define BD_SC_WRAP      ((ushort)0x2000)        /* Last buffer descriptor */
143 #define BD_SC_INTRPT    ((ushort)0x1000)        /* Interrupt on change */
144 #define BD_SC_LAST      ((ushort)0x0800)        /* Last buffer in frame */
145 #define BD_SC_CM        ((ushort)0x0200)        /* Continous mode */
146 #define BD_SC_ID        ((ushort)0x0100)        /* Rec'd too many idles */
147 #define BD_SC_P         ((ushort)0x0100)        /* xmt preamble */
148 #define BD_SC_BR        ((ushort)0x0020)        /* Break received */
149 #define BD_SC_FR        ((ushort)0x0010)        /* Framing error */
150 #define BD_SC_PR        ((ushort)0x0008)        /* Parity error */
151 #define BD_SC_OV        ((ushort)0x0002)        /* Overrun */
152 #define BD_SC_CD        ((ushort)0x0001)        /* ?? */
153
154 /* Function code bits, usually generic to devices.
155 */
156 #define CPMFCR_GBL      ((u_char)0x20)  /* Set memory snooping */
157 #define CPMFCR_EB       ((u_char)0x10)  /* Set big endian byte order */
158 #define CPMFCR_TC2      ((u_char)0x04)  /* Transfer code 2 value */
159 #define CPMFCR_DTB      ((u_char)0x02)  /* Use local bus for data when set */
160 #define CPMFCR_BDB      ((u_char)0x01)  /* Use local bus for BD when set */
161
162 /* Parameter RAM offsets from the base.
163 */
164 #define PROFF_SCC1              ((uint)0x8000)
165 #define PROFF_SCC2              ((uint)0x8100)
166 #define PROFF_SCC3              ((uint)0x8200)
167 #define PROFF_SCC4              ((uint)0x8300)
168 #define PROFF_FCC1              ((uint)0x8400)
169 #define PROFF_FCC2              ((uint)0x8500)
170 #define PROFF_FCC3              ((uint)0x8600)
171 #define PROFF_MCC1              ((uint)0x8700)
172 #define PROFF_SMC1_BASE         ((uint)0x87fc)
173 #define PROFF_IDMA1_BASE        ((uint)0x87fe)
174 #define PROFF_MCC2              ((uint)0x8800)
175 #define PROFF_SMC2_BASE         ((uint)0x88fc)
176 #define PROFF_IDMA2_BASE        ((uint)0x88fe)
177 #define PROFF_SPI_BASE          ((uint)0x89fc)
178 #define PROFF_IDMA3_BASE        ((uint)0x89fe)
179 #define PROFF_TIMERS            ((uint)0x8ae0)
180 #define PROFF_REVNUM            ((uint)0x8af0)
181 #define PROFF_RAND              ((uint)0x8af8)
182 #define PROFF_I2C_BASE          ((uint)0x8afc)
183 #define PROFF_IDMA4_BASE        ((uint)0x8afe)
184
185 #define PROFF_SCC_SIZE          ((uint)0x100)
186 #define PROFF_FCC_SIZE          ((uint)0x100)
187 #define PROFF_SMC_SIZE          ((uint)64)
188
189 /* The SMCs are relocated to any of the first eight DPRAM pages.
190  * We will fix these at the first locations of DPRAM, until we
191  * get some microcode patches :-).
192  * The parameter ram space for the SMCs is fifty-some bytes, and
193  * they are required to start on a 64 byte boundary.
194  */
195 #define PROFF_SMC1      (0)
196 #define PROFF_SMC2      (64)
197
198
199 /* Define enough so I can at least use the serial port as a UART.
200  */
201 typedef struct smc_uart {
202         ushort  smc_rbase;      /* Rx Buffer descriptor base address */
203         ushort  smc_tbase;      /* Tx Buffer descriptor base address */
204         u_char  smc_rfcr;       /* Rx function code */
205         u_char  smc_tfcr;       /* Tx function code */
206         ushort  smc_mrblr;      /* Max receive buffer length */
207         uint    smc_rstate;     /* Internal */
208         uint    smc_idp;        /* Internal */
209         ushort  smc_rbptr;      /* Internal */
210         ushort  smc_ibc;        /* Internal */
211         uint    smc_rxtmp;      /* Internal */
212         uint    smc_tstate;     /* Internal */
213         uint    smc_tdp;        /* Internal */
214         ushort  smc_tbptr;      /* Internal */
215         ushort  smc_tbc;        /* Internal */
216         uint    smc_txtmp;      /* Internal */
217         ushort  smc_maxidl;     /* Maximum idle characters */
218         ushort  smc_tmpidl;     /* Temporary idle counter */
219         ushort  smc_brklen;     /* Last received break length */
220         ushort  smc_brkec;      /* rcv'd break condition counter */
221         ushort  smc_brkcr;      /* xmt break count register */
222         ushort  smc_rmask;      /* Temporary bit mask */
223         uint    smc_stmp;       /* SDMA Temp */
224 } smc_uart_t;
225
226 /* SMC uart mode register (Internal memory map).
227 */
228 #define SMCMR_REN       ((ushort)0x0001)
229 #define SMCMR_TEN       ((ushort)0x0002)
230 #define SMCMR_DM        ((ushort)0x000c)
231 #define SMCMR_SM_GCI    ((ushort)0x0000)
232 #define SMCMR_SM_UART   ((ushort)0x0020)
233 #define SMCMR_SM_TRANS  ((ushort)0x0030)
234 #define SMCMR_SM_MASK   ((ushort)0x0030)
235 #define SMCMR_PM_EVEN   ((ushort)0x0100)        /* Even parity, else odd */
236 #define SMCMR_REVD      SMCMR_PM_EVEN
237 #define SMCMR_PEN       ((ushort)0x0200)        /* Parity enable */
238 #define SMCMR_BS        SMCMR_PEN
239 #define SMCMR_SL        ((ushort)0x0400)        /* Two stops, else one */
240 #define SMCR_CLEN_MASK  ((ushort)0x7800)        /* Character length */
241 #define smcr_mk_clen(C) (((C) << 11) & SMCR_CLEN_MASK)
242
243 /* SMC Event and Mask register.
244 */
245 #define SMCM_BRKE       ((unsigned char)0x40)   /* When in UART Mode */
246 #define SMCM_BRK        ((unsigned char)0x10)   /* When in UART Mode */
247 #define SMCM_TXE        ((unsigned char)0x10)
248 #define SMCM_BSY        ((unsigned char)0x04)
249 #define SMCM_TX         ((unsigned char)0x02)
250 #define SMCM_RX         ((unsigned char)0x01)
251
252 /* Baud rate generators.
253 */
254 #define CPM_BRG_RST             ((uint)0x00020000)
255 #define CPM_BRG_EN              ((uint)0x00010000)
256 #define CPM_BRG_EXTC_INT        ((uint)0x00000000)
257 #define CPM_BRG_EXTC_CLK3_9     ((uint)0x00004000)
258 #define CPM_BRG_EXTC_CLK5_15    ((uint)0x00008000)
259 #define CPM_BRG_ATB             ((uint)0x00002000)
260 #define CPM_BRG_CD_MASK         ((uint)0x00001ffe)
261 #define CPM_BRG_DIV16           ((uint)0x00000001)
262
263 /* SCCs.
264 */
265 #define SCC_GSMRH_IRP           ((uint)0x00040000)
266 #define SCC_GSMRH_GDE           ((uint)0x00010000)
267 #define SCC_GSMRH_TCRC_CCITT    ((uint)0x00008000)
268 #define SCC_GSMRH_TCRC_BISYNC   ((uint)0x00004000)
269 #define SCC_GSMRH_TCRC_HDLC     ((uint)0x00000000)
270 #define SCC_GSMRH_REVD          ((uint)0x00002000)
271 #define SCC_GSMRH_TRX           ((uint)0x00001000)
272 #define SCC_GSMRH_TTX           ((uint)0x00000800)
273 #define SCC_GSMRH_CDP           ((uint)0x00000400)
274 #define SCC_GSMRH_CTSP          ((uint)0x00000200)
275 #define SCC_GSMRH_CDS           ((uint)0x00000100)
276 #define SCC_GSMRH_CTSS          ((uint)0x00000080)
277 #define SCC_GSMRH_TFL           ((uint)0x00000040)
278 #define SCC_GSMRH_RFW           ((uint)0x00000020)
279 #define SCC_GSMRH_TXSY          ((uint)0x00000010)
280 #define SCC_GSMRH_SYNL16        ((uint)0x0000000c)
281 #define SCC_GSMRH_SYNL8         ((uint)0x00000008)
282 #define SCC_GSMRH_SYNL4         ((uint)0x00000004)
283 #define SCC_GSMRH_RTSM          ((uint)0x00000002)
284 #define SCC_GSMRH_RSYN          ((uint)0x00000001)
285
286 #define SCC_GSMRL_SIR           ((uint)0x80000000)      /* SCC2 only */
287 #define SCC_GSMRL_EDGE_NONE     ((uint)0x60000000)
288 #define SCC_GSMRL_EDGE_NEG      ((uint)0x40000000)
289 #define SCC_GSMRL_EDGE_POS      ((uint)0x20000000)
290 #define SCC_GSMRL_EDGE_BOTH     ((uint)0x00000000)
291 #define SCC_GSMRL_TCI           ((uint)0x10000000)
292 #define SCC_GSMRL_TSNC_3        ((uint)0x0c000000)
293 #define SCC_GSMRL_TSNC_4        ((uint)0x08000000)
294 #define SCC_GSMRL_TSNC_14       ((uint)0x04000000)
295 #define SCC_GSMRL_TSNC_INF      ((uint)0x00000000)
296 #define SCC_GSMRL_RINV          ((uint)0x02000000)
297 #define SCC_GSMRL_TINV          ((uint)0x01000000)
298 #define SCC_GSMRL_TPL_128       ((uint)0x00c00000)
299 #define SCC_GSMRL_TPL_64        ((uint)0x00a00000)
300 #define SCC_GSMRL_TPL_48        ((uint)0x00800000)
301 #define SCC_GSMRL_TPL_32        ((uint)0x00600000)
302 #define SCC_GSMRL_TPL_16        ((uint)0x00400000)
303 #define SCC_GSMRL_TPL_8         ((uint)0x00200000)
304 #define SCC_GSMRL_TPL_NONE      ((uint)0x00000000)
305 #define SCC_GSMRL_TPP_ALL1      ((uint)0x00180000)
306 #define SCC_GSMRL_TPP_01        ((uint)0x00100000)
307 #define SCC_GSMRL_TPP_10        ((uint)0x00080000)
308 #define SCC_GSMRL_TPP_ZEROS     ((uint)0x00000000)
309 #define SCC_GSMRL_TEND          ((uint)0x00040000)
310 #define SCC_GSMRL_TDCR_32       ((uint)0x00030000)
311 #define SCC_GSMRL_TDCR_16       ((uint)0x00020000)
312 #define SCC_GSMRL_TDCR_8        ((uint)0x00010000)
313 #define SCC_GSMRL_TDCR_1        ((uint)0x00000000)
314 #define SCC_GSMRL_RDCR_32       ((uint)0x0000c000)
315 #define SCC_GSMRL_RDCR_16       ((uint)0x00008000)
316 #define SCC_GSMRL_RDCR_8        ((uint)0x00004000)
317 #define SCC_GSMRL_RDCR_1        ((uint)0x00000000)
318 #define SCC_GSMRL_RENC_DFMAN    ((uint)0x00003000)
319 #define SCC_GSMRL_RENC_MANCH    ((uint)0x00002000)
320 #define SCC_GSMRL_RENC_FM0      ((uint)0x00001000)
321 #define SCC_GSMRL_RENC_NRZI     ((uint)0x00000800)
322 #define SCC_GSMRL_RENC_NRZ      ((uint)0x00000000)
323 #define SCC_GSMRL_TENC_DFMAN    ((uint)0x00000600)
324 #define SCC_GSMRL_TENC_MANCH    ((uint)0x00000400)
325 #define SCC_GSMRL_TENC_FM0      ((uint)0x00000200)
326 #define SCC_GSMRL_TENC_NRZI     ((uint)0x00000100)
327 #define SCC_GSMRL_TENC_NRZ      ((uint)0x00000000)
328 #define SCC_GSMRL_DIAG_LE       ((uint)0x000000c0)      /* Loop and echo */
329 #define SCC_GSMRL_DIAG_ECHO     ((uint)0x00000080)
330 #define SCC_GSMRL_DIAG_LOOP     ((uint)0x00000040)
331 #define SCC_GSMRL_DIAG_NORM     ((uint)0x00000000)
332 #define SCC_GSMRL_ENR           ((uint)0x00000020)
333 #define SCC_GSMRL_ENT           ((uint)0x00000010)
334 #define SCC_GSMRL_MODE_ENET     ((uint)0x0000000c)
335 #define SCC_GSMRL_MODE_DDCMP    ((uint)0x00000009)
336 #define SCC_GSMRL_MODE_BISYNC   ((uint)0x00000008)
337 #define SCC_GSMRL_MODE_V14      ((uint)0x00000007)
338 #define SCC_GSMRL_MODE_AHDLC    ((uint)0x00000006)
339 #define SCC_GSMRL_MODE_PROFIBUS ((uint)0x00000005)
340 #define SCC_GSMRL_MODE_UART     ((uint)0x00000004)
341 #define SCC_GSMRL_MODE_SS7      ((uint)0x00000003)
342 #define SCC_GSMRL_MODE_ATALK    ((uint)0x00000002)
343 #define SCC_GSMRL_MODE_HDLC     ((uint)0x00000000)
344
345 #define SCC_TODR_TOD            ((ushort)0x8000)
346
347 /* SCC Event and Mask register.
348 */
349 #define SCCM_TXE        ((unsigned char)0x10)
350 #define SCCM_BSY        ((unsigned char)0x04)
351 #define SCCM_TX         ((unsigned char)0x02)
352 #define SCCM_RX         ((unsigned char)0x01)
353
354 typedef struct scc_param {
355         ushort  scc_rbase;      /* Rx Buffer descriptor base address */
356         ushort  scc_tbase;      /* Tx Buffer descriptor base address */
357         u_char  scc_rfcr;       /* Rx function code */
358         u_char  scc_tfcr;       /* Tx function code */
359         ushort  scc_mrblr;      /* Max receive buffer length */
360         uint    scc_rstate;     /* Internal */
361         uint    scc_idp;        /* Internal */
362         ushort  scc_rbptr;      /* Internal */
363         ushort  scc_ibc;        /* Internal */
364         uint    scc_rxtmp;      /* Internal */
365         uint    scc_tstate;     /* Internal */
366         uint    scc_tdp;        /* Internal */
367         ushort  scc_tbptr;      /* Internal */
368         ushort  scc_tbc;        /* Internal */
369         uint    scc_txtmp;      /* Internal */
370         uint    scc_rcrc;       /* Internal */
371         uint    scc_tcrc;       /* Internal */
372 } sccp_t;
373
374 /* CPM Ethernet through SCC1.
375  */
376 typedef struct scc_enet {
377         sccp_t  sen_genscc;
378         uint    sen_cpres;      /* Preset CRC */
379         uint    sen_cmask;      /* Constant mask for CRC */
380         uint    sen_crcec;      /* CRC Error counter */
381         uint    sen_alec;       /* alignment error counter */
382         uint    sen_disfc;      /* discard frame counter */
383         ushort  sen_pads;       /* Tx short frame pad character */
384         ushort  sen_retlim;     /* Retry limit threshold */
385         ushort  sen_retcnt;     /* Retry limit counter */
386         ushort  sen_maxflr;     /* maximum frame length register */
387         ushort  sen_minflr;     /* minimum frame length register */
388         ushort  sen_maxd1;      /* maximum DMA1 length */
389         ushort  sen_maxd2;      /* maximum DMA2 length */
390         ushort  sen_maxd;       /* Rx max DMA */
391         ushort  sen_dmacnt;     /* Rx DMA counter */
392         ushort  sen_maxb;       /* Max BD byte count */
393         ushort  sen_gaddr1;     /* Group address filter */
394         ushort  sen_gaddr2;
395         ushort  sen_gaddr3;
396         ushort  sen_gaddr4;
397         uint    sen_tbuf0data0; /* Save area 0 - current frame */
398         uint    sen_tbuf0data1; /* Save area 1 - current frame */
399         uint    sen_tbuf0rba;   /* Internal */
400         uint    sen_tbuf0crc;   /* Internal */
401         ushort  sen_tbuf0bcnt;  /* Internal */
402         ushort  sen_paddrh;     /* physical address (MSB) */
403         ushort  sen_paddrm;
404         ushort  sen_paddrl;     /* physical address (LSB) */
405         ushort  sen_pper;       /* persistence */
406         ushort  sen_rfbdptr;    /* Rx first BD pointer */
407         ushort  sen_tfbdptr;    /* Tx first BD pointer */
408         ushort  sen_tlbdptr;    /* Tx last BD pointer */
409         uint    sen_tbuf1data0; /* Save area 0 - current frame */
410         uint    sen_tbuf1data1; /* Save area 1 - current frame */
411         uint    sen_tbuf1rba;   /* Internal */
412         uint    sen_tbuf1crc;   /* Internal */
413         ushort  sen_tbuf1bcnt;  /* Internal */
414         ushort  sen_txlen;      /* Tx Frame length counter */
415         ushort  sen_iaddr1;     /* Individual address filter */
416         ushort  sen_iaddr2;
417         ushort  sen_iaddr3;
418         ushort  sen_iaddr4;
419         ushort  sen_boffcnt;    /* Backoff counter */
420
421         /* NOTE: Some versions of the manual have the following items
422          * incorrectly documented.  Below is the proper order.
423          */
424         ushort  sen_taddrh;     /* temp address (MSB) */
425         ushort  sen_taddrm;
426         ushort  sen_taddrl;     /* temp address (LSB) */
427 } scc_enet_t;
428
429
430 /* SCC Event register as used by Ethernet.
431 */
432 #define SCCE_ENET_GRA   ((ushort)0x0080)        /* Graceful stop complete */
433 #define SCCE_ENET_TXE   ((ushort)0x0010)        /* Transmit Error */
434 #define SCCE_ENET_RXF   ((ushort)0x0008)        /* Full frame received */
435 #define SCCE_ENET_BSY   ((ushort)0x0004)        /* All incoming buffers full */
436 #define SCCE_ENET_TXB   ((ushort)0x0002)        /* A buffer was transmitted */
437 #define SCCE_ENET_RXB   ((ushort)0x0001)        /* A buffer was received */
438
439 /* SCC Mode Register (PSMR) as used by Ethernet.
440 */
441 #define SCC_PSMR_HBC    ((ushort)0x8000)        /* Enable heartbeat */
442 #define SCC_PSMR_FC     ((ushort)0x4000)        /* Force collision */
443 #define SCC_PSMR_RSH    ((ushort)0x2000)        /* Receive short frames */
444 #define SCC_PSMR_IAM    ((ushort)0x1000)        /* Check individual hash */
445 #define SCC_PSMR_ENCRC  ((ushort)0x0800)        /* Ethernet CRC mode */
446 #define SCC_PSMR_PRO    ((ushort)0x0200)        /* Promiscuous mode */
447 #define SCC_PSMR_BRO    ((ushort)0x0100)        /* Catch broadcast pkts */
448 #define SCC_PSMR_SBT    ((ushort)0x0080)        /* Special backoff timer */
449 #define SCC_PSMR_LPB    ((ushort)0x0040)        /* Set Loopback mode */
450 #define SCC_PSMR_SIP    ((ushort)0x0020)        /* Sample Input Pins */
451 #define SCC_PSMR_LCW    ((ushort)0x0010)        /* Late collision window */
452 #define SCC_PSMR_NIB22  ((ushort)0x000a)        /* Start frame search */
453 #define SCC_PSMR_FDE    ((ushort)0x0001)        /* Full duplex enable */
454
455 /* Buffer descriptor control/status used by Ethernet receive.
456  * Common to SCC and FCC.
457  */
458 #define BD_ENET_RX_EMPTY        ((ushort)0x8000)
459 #define BD_ENET_RX_WRAP         ((ushort)0x2000)
460 #define BD_ENET_RX_INTR         ((ushort)0x1000)
461 #define BD_ENET_RX_LAST         ((ushort)0x0800)
462 #define BD_ENET_RX_FIRST        ((ushort)0x0400)
463 #define BD_ENET_RX_MISS         ((ushort)0x0100)
464 #define BD_ENET_RX_BC           ((ushort)0x0080)        /* FCC Only */
465 #define BD_ENET_RX_MC           ((ushort)0x0040)        /* FCC Only */
466 #define BD_ENET_RX_LG           ((ushort)0x0020)
467 #define BD_ENET_RX_NO           ((ushort)0x0010)
468 #define BD_ENET_RX_SH           ((ushort)0x0008)
469 #define BD_ENET_RX_CR           ((ushort)0x0004)
470 #define BD_ENET_RX_OV           ((ushort)0x0002)
471 #define BD_ENET_RX_CL           ((ushort)0x0001)
472 #define BD_ENET_RX_STATS        ((ushort)0x01ff)        /* All status bits */
473
474 /* Buffer descriptor control/status used by Ethernet transmit.
475  * Common to SCC and FCC.
476  */
477 #define BD_ENET_TX_READY        ((ushort)0x8000)
478 #define BD_ENET_TX_PAD          ((ushort)0x4000)
479 #define BD_ENET_TX_WRAP         ((ushort)0x2000)
480 #define BD_ENET_TX_INTR         ((ushort)0x1000)
481 #define BD_ENET_TX_LAST         ((ushort)0x0800)
482 #define BD_ENET_TX_TC           ((ushort)0x0400)
483 #define BD_ENET_TX_DEF          ((ushort)0x0200)
484 #define BD_ENET_TX_HB           ((ushort)0x0100)
485 #define BD_ENET_TX_LC           ((ushort)0x0080)
486 #define BD_ENET_TX_RL           ((ushort)0x0040)
487 #define BD_ENET_TX_RCMASK       ((ushort)0x003c)
488 #define BD_ENET_TX_UN           ((ushort)0x0002)
489 #define BD_ENET_TX_CSL          ((ushort)0x0001)
490 #define BD_ENET_TX_STATS        ((ushort)0x03ff)        /* All status bits */
491
492 /* SCC as UART
493 */
494 typedef struct scc_uart {
495         sccp_t  scc_genscc;
496         uint    scc_res1;       /* Reserved */
497         uint    scc_res2;       /* Reserved */
498         ushort  scc_maxidl;     /* Maximum idle chars */
499         ushort  scc_idlc;       /* temp idle counter */
500         ushort  scc_brkcr;      /* Break count register */
501         ushort  scc_parec;      /* receive parity error counter */
502         ushort  scc_frmec;      /* receive framing error counter */
503         ushort  scc_nosec;      /* receive noise counter */
504         ushort  scc_brkec;      /* receive break condition counter */
505         ushort  scc_brkln;      /* last received break length */
506         ushort  scc_uaddr1;     /* UART address character 1 */
507         ushort  scc_uaddr2;     /* UART address character 2 */
508         ushort  scc_rtemp;      /* Temp storage */
509         ushort  scc_toseq;      /* Transmit out of sequence char */
510         ushort  scc_char1;      /* control character 1 */
511         ushort  scc_char2;      /* control character 2 */
512         ushort  scc_char3;      /* control character 3 */
513         ushort  scc_char4;      /* control character 4 */
514         ushort  scc_char5;      /* control character 5 */
515         ushort  scc_char6;      /* control character 6 */
516         ushort  scc_char7;      /* control character 7 */
517         ushort  scc_char8;      /* control character 8 */
518         ushort  scc_rccm;       /* receive control character mask */
519         ushort  scc_rccr;       /* receive control character register */
520         ushort  scc_rlbc;       /* receive last break character */
521 } scc_uart_t;
522
523 /* SCC Event and Mask registers when it is used as a UART.
524 */
525 #define UART_SCCM_GLR           ((ushort)0x1000)
526 #define UART_SCCM_GLT           ((ushort)0x0800)
527 #define UART_SCCM_AB            ((ushort)0x0200)
528 #define UART_SCCM_IDL           ((ushort)0x0100)
529 #define UART_SCCM_GRA           ((ushort)0x0080)
530 #define UART_SCCM_BRKE          ((ushort)0x0040)
531 #define UART_SCCM_BRKS          ((ushort)0x0020)
532 #define UART_SCCM_CCR           ((ushort)0x0008)
533 #define UART_SCCM_BSY           ((ushort)0x0004)
534 #define UART_SCCM_TX            ((ushort)0x0002)
535 #define UART_SCCM_RX            ((ushort)0x0001)
536
537 /* The SCC PSMR when used as a UART.
538 */
539 #define SCU_PSMR_FLC            ((ushort)0x8000)
540 #define SCU_PSMR_SL             ((ushort)0x4000)
541 #define SCU_PSMR_CL             ((ushort)0x3000)
542 #define SCU_PSMR_UM             ((ushort)0x0c00)
543 #define SCU_PSMR_FRZ            ((ushort)0x0200)
544 #define SCU_PSMR_RZS            ((ushort)0x0100)
545 #define SCU_PSMR_SYN            ((ushort)0x0080)
546 #define SCU_PSMR_DRT            ((ushort)0x0040)
547 #define SCU_PSMR_PEN            ((ushort)0x0010)
548 #define SCU_PSMR_RPM            ((ushort)0x000c)
549 #define SCU_PSMR_REVP           ((ushort)0x0008)
550 #define SCU_PSMR_TPM            ((ushort)0x0003)
551 #define SCU_PSMR_TEVP           ((ushort)0x0002)
552
553 /* CPM Transparent mode SCC.
554  */
555 typedef struct scc_trans {
556         sccp_t  st_genscc;
557         uint    st_cpres;       /* Preset CRC */
558         uint    st_cmask;       /* Constant mask for CRC */
559 } scc_trans_t;
560
561 #define BD_SCC_TX_LAST          ((ushort)0x0800)
562
563 /* How about some FCCs.....
564 */
565 #define FCC_GFMR_DIAG_NORM      ((uint)0x00000000)
566 #define FCC_GFMR_DIAG_LE        ((uint)0x40000000)
567 #define FCC_GFMR_DIAG_AE        ((uint)0x80000000)
568 #define FCC_GFMR_DIAG_ALE       ((uint)0xc0000000)
569 #define FCC_GFMR_TCI            ((uint)0x20000000)
570 #define FCC_GFMR_TRX            ((uint)0x10000000)
571 #define FCC_GFMR_TTX            ((uint)0x08000000)
572 #define FCC_GFMR_TTX            ((uint)0x08000000)
573 #define FCC_GFMR_CDP            ((uint)0x04000000)
574 #define FCC_GFMR_CTSP           ((uint)0x02000000)
575 #define FCC_GFMR_CDS            ((uint)0x01000000)
576 #define FCC_GFMR_CTSS           ((uint)0x00800000)
577 #define FCC_GFMR_SYNL_NONE      ((uint)0x00000000)
578 #define FCC_GFMR_SYNL_AUTO      ((uint)0x00004000)
579 #define FCC_GFMR_SYNL_8         ((uint)0x00008000)
580 #define FCC_GFMR_SYNL_16        ((uint)0x0000c000)
581 #define FCC_GFMR_RTSM           ((uint)0x00002000)
582 #define FCC_GFMR_RENC_NRZ       ((uint)0x00000000)
583 #define FCC_GFMR_RENC_NRZI      ((uint)0x00000800)
584 #define FCC_GFMR_REVD           ((uint)0x00000400)
585 #define FCC_GFMR_TENC_NRZ       ((uint)0x00000000)
586 #define FCC_GFMR_TENC_NRZI      ((uint)0x00000100)
587 #define FCC_GFMR_TCRC_16        ((uint)0x00000000)
588 #define FCC_GFMR_TCRC_32        ((uint)0x00000080)
589 #define FCC_GFMR_ENR            ((uint)0x00000020)
590 #define FCC_GFMR_ENT            ((uint)0x00000010)
591 #define FCC_GFMR_MODE_ENET      ((uint)0x0000000c)
592 #define FCC_GFMR_MODE_ATM       ((uint)0x0000000a)
593 #define FCC_GFMR_MODE_HDLC      ((uint)0x00000000)
594
595 /* Generic FCC parameter ram.
596 */
597 typedef struct fcc_param {
598         ushort  fcc_riptr;      /* Rx Internal temp pointer */
599         ushort  fcc_tiptr;      /* Tx Internal temp pointer */
600         ushort  fcc_res1;
601         ushort  fcc_mrblr;      /* Max receive buffer length, mod 32 bytes */
602         uint    fcc_rstate;     /* Upper byte is Func code, must be set */
603         uint    fcc_rbase;      /* Receive BD base */
604         ushort  fcc_rbdstat;    /* RxBD status */
605         ushort  fcc_rbdlen;     /* RxBD down counter */
606         uint    fcc_rdptr;      /* RxBD internal data pointer */
607         uint    fcc_tstate;     /* Upper byte is Func code, must be set */
608         uint    fcc_tbase;      /* Transmit BD base */
609         ushort  fcc_tbdstat;    /* TxBD status */
610         ushort  fcc_tbdlen;     /* TxBD down counter */
611         uint    fcc_tdptr;      /* TxBD internal data pointer */
612         uint    fcc_rbptr;      /* Rx BD Internal buf pointer */
613         uint    fcc_tbptr;      /* Tx BD Internal buf pointer */
614         uint    fcc_rcrc;       /* Rx temp CRC */
615         uint    fcc_res2;
616         uint    fcc_tcrc;       /* Tx temp CRC */
617 } fccp_t;
618
619
620 /* Ethernet controller through FCC.
621 */
622 typedef struct fcc_enet {
623         fccp_t  fen_genfcc;
624         uint    fen_statbuf;    /* Internal status buffer */
625         uint    fen_camptr;     /* CAM address */
626         uint    fen_cmask;      /* Constant mask for CRC */
627         uint    fen_cpres;      /* Preset CRC */
628         uint    fen_crcec;      /* CRC Error counter */
629         uint    fen_alec;       /* alignment error counter */
630         uint    fen_disfc;      /* discard frame counter */
631         ushort  fen_retlim;     /* Retry limit */
632         ushort  fen_retcnt;     /* Retry counter */
633         ushort  fen_pper;       /* Persistence */
634         ushort  fen_boffcnt;    /* backoff counter */
635         uint    fen_gaddrh;     /* Group address filter, high 32-bits */
636         uint    fen_gaddrl;     /* Group address filter, low 32-bits */
637         ushort  fen_tfcstat;    /* out of sequence TxBD */
638         ushort  fen_tfclen;
639         uint    fen_tfcptr;
640         ushort  fen_mflr;       /* Maximum frame length (1518) */
641         ushort  fen_paddrh;     /* MAC address */
642         ushort  fen_paddrm;
643         ushort  fen_paddrl;
644         ushort  fen_ibdcount;   /* Internal BD counter */
645         ushort  fen_ibdstart;   /* Internal BD start pointer */
646         ushort  fen_ibdend;     /* Internal BD end pointer */
647         ushort  fen_txlen;      /* Internal Tx frame length counter */
648         uint    fen_ibdbase[8]; /* Internal use */
649         uint    fen_iaddrh;     /* Individual address filter */
650         uint    fen_iaddrl;
651         ushort  fen_minflr;     /* Minimum frame length (64) */
652         ushort  fen_taddrh;     /* Filter transfer MAC address */
653         ushort  fen_taddrm;
654         ushort  fen_taddrl;
655         ushort  fen_padptr;     /* Pointer to pad byte buffer */
656         ushort  fen_cftype;     /* control frame type */
657         ushort  fen_cfrange;    /* control frame range */
658         ushort  fen_maxb;       /* maximum BD count */
659         ushort  fen_maxd1;      /* Max DMA1 length (1520) */
660         ushort  fen_maxd2;      /* Max DMA2 length (1520) */
661         ushort  fen_maxd;       /* internal max DMA count */
662         ushort  fen_dmacnt;     /* internal DMA counter */
663         uint    fen_octc;       /* Total octect counter */
664         uint    fen_colc;       /* Total collision counter */
665         uint    fen_broc;       /* Total broadcast packet counter */
666         uint    fen_mulc;       /* Total multicast packet count */
667         uint    fen_uspc;       /* Total packets < 64 bytes */
668         uint    fen_frgc;       /* Total packets < 64 bytes with errors */
669         uint    fen_ospc;       /* Total packets > 1518 */
670         uint    fen_jbrc;       /* Total packets > 1518 with errors */
671         uint    fen_p64c;       /* Total packets == 64 bytes */
672         uint    fen_p65c;       /* Total packets 64 < bytes <= 127 */
673         uint    fen_p128c;      /* Total packets 127 < bytes <= 255 */
674         uint    fen_p256c;      /* Total packets 256 < bytes <= 511 */
675         uint    fen_p512c;      /* Total packets 512 < bytes <= 1023 */
676         uint    fen_p1024c;     /* Total packets 1024 < bytes <= 1518 */
677         uint    fen_cambuf;     /* Internal CAM buffer poiner */
678         ushort  fen_rfthr;      /* Received frames threshold */
679         ushort  fen_rfcnt;      /* Received frames count */
680 } fcc_enet_t;
681
682 /* FCC Event/Mask register as used by Ethernet.
683 */
684 #define FCC_ENET_GRA    ((ushort)0x0080)        /* Graceful stop complete */
685 #define FCC_ENET_RXC    ((ushort)0x0040)        /* Control Frame Received */
686 #define FCC_ENET_TXC    ((ushort)0x0020)        /* Out of seq. Tx sent */
687 #define FCC_ENET_TXE    ((ushort)0x0010)        /* Transmit Error */
688 #define FCC_ENET_RXF    ((ushort)0x0008)        /* Full frame received */
689 #define FCC_ENET_BSY    ((ushort)0x0004)        /* Busy.  Rx Frame dropped */
690 #define FCC_ENET_TXB    ((ushort)0x0002)        /* A buffer was transmitted */
691 #define FCC_ENET_RXB    ((ushort)0x0001)        /* A buffer was received */
692
693 /* FCC Mode Register (FPSMR) as used by Ethernet.
694 */
695 #define FCC_PSMR_HBC    ((uint)0x80000000)      /* Enable heartbeat */
696 #define FCC_PSMR_FC     ((uint)0x40000000)      /* Force Collision */
697 #define FCC_PSMR_SBT    ((uint)0x20000000)      /* Stop backoff timer */
698 #define FCC_PSMR_LPB    ((uint)0x10000000)      /* Local protect. 1 = FDX */
699 #define FCC_PSMR_LCW    ((uint)0x08000000)      /* Late collision select */
700 #define FCC_PSMR_FDE    ((uint)0x04000000)      /* Full Duplex Enable */
701 #define FCC_PSMR_MON    ((uint)0x02000000)      /* RMON Enable */
702 #define FCC_PSMR_PRO    ((uint)0x00400000)      /* Promiscuous Enable */
703 #define FCC_PSMR_FCE    ((uint)0x00200000)      /* Flow Control Enable */
704 #define FCC_PSMR_RSH    ((uint)0x00100000)      /* Receive Short Frames */
705 #define FCC_PSMR_CAM    ((uint)0x00000400)      /* CAM enable */
706 #define FCC_PSMR_BRO    ((uint)0x00000200)      /* Broadcast pkt discard */
707 #define FCC_PSMR_ENCRC  ((uint)0x00000080)      /* Use 32-bit CRC */
708
709 /* IIC parameter RAM.
710 */
711 typedef struct iic {
712         ushort  iic_rbase;      /* Rx Buffer descriptor base address */
713         ushort  iic_tbase;      /* Tx Buffer descriptor base address */
714         u_char  iic_rfcr;       /* Rx function code */
715         u_char  iic_tfcr;       /* Tx function code */
716         ushort  iic_mrblr;      /* Max receive buffer length */
717         uint    iic_rstate;     /* Internal */
718         uint    iic_rdp;        /* Internal */
719         ushort  iic_rbptr;      /* Internal */
720         ushort  iic_rbc;        /* Internal */
721         uint    iic_rxtmp;      /* Internal */
722         uint    iic_tstate;     /* Internal */
723         uint    iic_tdp;        /* Internal */
724         ushort  iic_tbptr;      /* Internal */
725         ushort  iic_tbc;        /* Internal */
726         uint    iic_txtmp;      /* Internal */
727 } iic_t;
728
729 /* SPI parameter RAM.
730 */
731 typedef struct spi {
732         ushort  spi_rbase;      /* Rx Buffer descriptor base address */
733         ushort  spi_tbase;      /* Tx Buffer descriptor base address */
734         u_char  spi_rfcr;       /* Rx function code */
735         u_char  spi_tfcr;       /* Tx function code */
736         ushort  spi_mrblr;      /* Max receive buffer length */
737         uint    spi_rstate;     /* Internal */
738         uint    spi_rdp;        /* Internal */
739         ushort  spi_rbptr;      /* Internal */
740         ushort  spi_rbc;        /* Internal */
741         uint    spi_rxtmp;      /* Internal */
742         uint    spi_tstate;     /* Internal */
743         uint    spi_tdp;        /* Internal */
744         ushort  spi_tbptr;      /* Internal */
745         ushort  spi_tbc;        /* Internal */
746         uint    spi_txtmp;      /* Internal */
747         uint    spi_res;        /* Tx temp. */
748         uint    spi_res1[4];    /* SDMA temp. */
749 } spi_t;
750
751 /* SPI Mode register.
752 */
753 #define SPMODE_LOOP     ((ushort)0x4000)        /* Loopback */
754 #define SPMODE_CI       ((ushort)0x2000)        /* Clock Invert */
755 #define SPMODE_CP       ((ushort)0x1000)        /* Clock Phase */
756 #define SPMODE_DIV16    ((ushort)0x0800)        /* BRG/16 mode */
757 #define SPMODE_REV      ((ushort)0x0400)        /* Reversed Data */
758 #define SPMODE_MSTR     ((ushort)0x0200)        /* SPI Master */
759 #define SPMODE_EN       ((ushort)0x0100)        /* Enable */
760 #define SPMODE_LENMSK   ((ushort)0x00f0)        /* character length */
761 #define SPMODE_PMMSK    ((ushort)0x000f)        /* prescale modulus */
762
763 #define SPMODE_LEN(x)   ((((x)-1)&0xF)<<4)
764 #define SPMODE_PM(x)    ((x) &0xF)
765
766 #define SPI_EB          ((u_char)0x10)          /* big endian byte order */
767
768 #define BD_IIC_START            ((ushort)0x0400)
769
770 /* IDMA parameter RAM
771 */
772 typedef struct idma {
773         ushort ibase;           /* IDMA buffer descriptor table base address */
774         ushort dcm;             /* DMA channel mode */
775         ushort ibdptr;          /* IDMA current buffer descriptor pointer */
776         ushort dpr_buf;         /* IDMA transfer buffer base address */
777         ushort buf_inv;         /* internal buffer inventory */
778         ushort ss_max;          /* steady-state maximum transfer size */
779         ushort dpr_in_ptr;      /* write pointer inside the internal buffer */
780         ushort sts;             /* source transfer size */
781         ushort dpr_out_ptr;     /* read pointer inside the internal buffer */
782         ushort seob;            /* source end of burst */
783         ushort deob;            /* destination end of burst */
784         ushort dts;             /* destination transfer size */
785         ushort ret_add;         /* return address when working in ERM=1 mode */
786         ushort res0;            /* reserved */
787         uint   bd_cnt;          /* internal byte count */
788         uint   s_ptr;           /* source internal data pointer */
789         uint   d_ptr;           /* destination internal data pointer */
790         uint   istate;          /* internal state */
791         u_char res1[20];        /* pad to 64-byte length */
792 } idma_t;
793
794 /* DMA channel mode bit fields
795 */
796 #define IDMA_DCM_FB             ((ushort)0x8000) /* fly-by mode */
797 #define IDMA_DCM_LP             ((ushort)0x4000) /* low priority */
798 #define IDMA_DCM_TC2            ((ushort)0x0400) /* value driven on TC[2] */
799 #define IDMA_DCM_DMA_WRAP_MASK  ((ushort)0x01c0) /* mask for DMA wrap */
800 #define IDMA_DCM_DMA_WRAP_64    ((ushort)0x0000) /* 64-byte DMA xfer buffer */
801 #define IDMA_DCM_DMA_WRAP_128   ((ushort)0x0040) /* 128-byte DMA xfer buffer */
802 #define IDMA_DCM_DMA_WRAP_256   ((ushort)0x0080) /* 256-byte DMA xfer buffer */
803 #define IDMA_DCM_DMA_WRAP_512   ((ushort)0x00c0) /* 512-byte DMA xfer buffer */
804 #define IDMA_DCM_DMA_WRAP_1024  ((ushort)0x0100) /* 1024-byte DMA xfer buffer */
805 #define IDMA_DCM_DMA_WRAP_2048  ((ushort)0x0140) /* 2048-byte DMA xfer buffer */
806 #define IDMA_DCM_SINC           ((ushort)0x0020) /* source inc addr */
807 #define IDMA_DCM_DINC           ((ushort)0x0010) /* destination inc addr */
808 #define IDMA_DCM_ERM            ((ushort)0x0008) /* external request mode */
809 #define IDMA_DCM_DT             ((ushort)0x0004) /* DONE treatment */
810 #define IDMA_DCM_SD_MASK        ((ushort)0x0003) /* mask for SD bit field */
811 #define IDMA_DCM_SD_MEM2MEM     ((ushort)0x0000) /* memory-to-memory xfer */
812 #define IDMA_DCM_SD_PER2MEM     ((ushort)0x0002) /* peripheral-to-memory xfer */
813 #define IDMA_DCM_SD_MEM2PER     ((ushort)0x0001) /* memory-to-peripheral xfer */
814
815 /* IDMA Buffer Descriptors
816 */
817 typedef struct idma_bd {
818         uint flags;
819         uint len;       /* data length */
820         uint src;       /* source data buffer pointer */
821         uint dst;       /* destination data buffer pointer */
822 } idma_bd_t;
823
824 /* IDMA buffer descriptor flag bit fields
825 */
826 #define IDMA_BD_V       ((uint)0x80000000)      /* valid */
827 #define IDMA_BD_W       ((uint)0x20000000)      /* wrap */
828 #define IDMA_BD_I       ((uint)0x10000000)      /* interrupt */
829 #define IDMA_BD_L       ((uint)0x08000000)      /* last */
830 #define IDMA_BD_CM      ((uint)0x02000000)      /* continuous mode */
831 #define IDMA_BD_SDN     ((uint)0x00400000)      /* source done */
832 #define IDMA_BD_DDN     ((uint)0x00200000)      /* destination done */
833 #define IDMA_BD_DGBL    ((uint)0x00100000)      /* destination global */
834 #define IDMA_BD_DBO_LE  ((uint)0x00040000)      /* little-end dest byte order */
835 #define IDMA_BD_DBO_BE  ((uint)0x00080000)      /* big-end dest byte order */
836 #define IDMA_BD_DDTB    ((uint)0x00010000)      /* destination data bus */
837 #define IDMA_BD_SGBL    ((uint)0x00002000)      /* source global */
838 #define IDMA_BD_SBO_LE  ((uint)0x00000800)      /* little-end src byte order */
839 #define IDMA_BD_SBO_BE  ((uint)0x00001000)      /* big-end src byte order */
840 #define IDMA_BD_SDTB    ((uint)0x00000200)      /* source data bus */
841
842 /* per-channel IDMA registers
843 */
844 typedef struct im_idma {
845         u_char idsr;                    /* IDMAn event status register */
846         u_char res0[3];
847         u_char idmr;                    /* IDMAn event mask register */
848         u_char res1[3];
849 } im_idma_t;
850
851 /* IDMA event register bit fields
852 */
853 #define IDMA_EVENT_SC   ((unsigned char)0x08)   /* stop completed */
854 #define IDMA_EVENT_OB   ((unsigned char)0x04)   /* out of buffers */
855 #define IDMA_EVENT_EDN  ((unsigned char)0x02)   /* external DONE asserted */
856 #define IDMA_EVENT_BC   ((unsigned char)0x01)   /* buffer descriptor complete */
857
858 /* RISC Controller Configuration Register (RCCR) bit fields
859 */
860 #define RCCR_TIME       ((uint)0x80000000) /* timer enable */
861 #define RCCR_TIMEP_MASK ((uint)0x3f000000) /* mask for timer period bit field */
862 #define RCCR_DR0M       ((uint)0x00800000) /* IDMA0 request mode */
863 #define RCCR_DR1M       ((uint)0x00400000) /* IDMA1 request mode */
864 #define RCCR_DR2M       ((uint)0x00000080) /* IDMA2 request mode */
865 #define RCCR_DR3M       ((uint)0x00000040) /* IDMA3 request mode */
866 #define RCCR_DR0QP_MASK ((uint)0x00300000) /* mask for IDMA0 req priority */
867 #define RCCR_DR0QP_HIGH ((uint)0x00000000) /* IDMA0 has high req priority */
868 #define RCCR_DR0QP_MED  ((uint)0x00100000) /* IDMA0 has medium req priority */
869 #define RCCR_DR0QP_LOW  ((uint)0x00200000) /* IDMA0 has low req priority */
870 #define RCCR_DR1QP_MASK ((uint)0x00030000) /* mask for IDMA1 req priority */
871 #define RCCR_DR1QP_HIGH ((uint)0x00000000) /* IDMA1 has high req priority */
872 #define RCCR_DR1QP_MED  ((uint)0x00010000) /* IDMA1 has medium req priority */
873 #define RCCR_DR1QP_LOW  ((uint)0x00020000) /* IDMA1 has low req priority */
874 #define RCCR_DR2QP_MASK ((uint)0x00000030) /* mask for IDMA2 req priority */
875 #define RCCR_DR2QP_HIGH ((uint)0x00000000) /* IDMA2 has high req priority */
876 #define RCCR_DR2QP_MED  ((uint)0x00000010) /* IDMA2 has medium req priority */
877 #define RCCR_DR2QP_LOW  ((uint)0x00000020) /* IDMA2 has low req priority */
878 #define RCCR_DR3QP_MASK ((uint)0x00000003) /* mask for IDMA3 req priority */
879 #define RCCR_DR3QP_HIGH ((uint)0x00000000) /* IDMA3 has high req priority */
880 #define RCCR_DR3QP_MED  ((uint)0x00000001) /* IDMA3 has medium req priority */
881 #define RCCR_DR3QP_LOW  ((uint)0x00000002) /* IDMA3 has low req priority */
882 #define RCCR_EIE        ((uint)0x00080000) /* external interrupt enable */
883 #define RCCR_SCD        ((uint)0x00040000) /* scheduler configuration */
884 #define RCCR_ERAM_MASK  ((uint)0x0000e000) /* mask for enable RAM microcode */
885 #define RCCR_ERAM_0KB   ((uint)0x00000000) /* use 0KB of dpram for microcode */
886 #define RCCR_ERAM_2KB   ((uint)0x00002000) /* use 2KB of dpram for microcode */
887 #define RCCR_ERAM_4KB   ((uint)0x00004000) /* use 4KB of dpram for microcode */
888 #define RCCR_ERAM_6KB   ((uint)0x00006000) /* use 6KB of dpram for microcode */
889 #define RCCR_ERAM_8KB   ((uint)0x00008000) /* use 8KB of dpram for microcode */
890 #define RCCR_ERAM_10KB  ((uint)0x0000a000) /* use 10KB of dpram for microcode */
891 #define RCCR_ERAM_12KB  ((uint)0x0000c000) /* use 12KB of dpram for microcode */
892 #define RCCR_EDM0       ((uint)0x00000800) /* DREQ0 edge detect mode */
893 #define RCCR_EDM1       ((uint)0x00000400) /* DREQ1 edge detect mode */
894 #define RCCR_EDM2       ((uint)0x00000200) /* DREQ2 edge detect mode */
895 #define RCCR_EDM3       ((uint)0x00000100) /* DREQ3 edge detect mode */
896 #define RCCR_DEM01      ((uint)0x00000008) /* DONE0/DONE1 edge detect mode */
897 #define RCCR_DEM23      ((uint)0x00000004) /* DONE2/DONE3 edge detect mode */
898
899 /*-----------------------------------------------------------------------
900  * CMXFCR - CMX FCC Clock Route Register
901  */
902 #define CMXFCR_FC1         0x40000000   /* FCC1 connection              */
903 #define CMXFCR_RF1CS_MSK   0x38000000   /* Receive FCC1 Clock Source Mask */
904 #define CMXFCR_TF1CS_MSK   0x07000000   /* Transmit FCC1 Clock Source Mask */
905 #define CMXFCR_FC2         0x00400000   /* FCC2 connection              */
906 #define CMXFCR_RF2CS_MSK   0x00380000   /* Receive FCC2 Clock Source Mask */
907 #define CMXFCR_TF2CS_MSK   0x00070000   /* Transmit FCC2 Clock Source Mask */
908 #define CMXFCR_FC3         0x00004000   /* FCC3 connection              */
909 #define CMXFCR_RF3CS_MSK   0x00003800   /* Receive FCC3 Clock Source Mask */
910 #define CMXFCR_TF3CS_MSK   0x00000700   /* Transmit FCC3 Clock Source Mask */
911
912 #define CMXFCR_RF1CS_BRG5  0x00000000   /* Receive FCC1 Clock Source is BRG5 */
913 #define CMXFCR_RF1CS_BRG6  0x08000000   /* Receive FCC1 Clock Source is BRG6 */
914 #define CMXFCR_RF1CS_BRG7  0x10000000   /* Receive FCC1 Clock Source is BRG7 */
915 #define CMXFCR_RF1CS_BRG8  0x18000000   /* Receive FCC1 Clock Source is BRG8 */
916 #define CMXFCR_RF1CS_CLK9  0x20000000   /* Receive FCC1 Clock Source is CLK9 */
917 #define CMXFCR_RF1CS_CLK10 0x28000000   /* Receive FCC1 Clock Source is CLK10 */
918 #define CMXFCR_RF1CS_CLK11 0x30000000   /* Receive FCC1 Clock Source is CLK11 */
919 #define CMXFCR_RF1CS_CLK12 0x38000000   /* Receive FCC1 Clock Source is CLK12 */
920
921 #define CMXFCR_TF1CS_BRG5  0x00000000   /* Transmit FCC1 Clock Source is BRG5 */
922 #define CMXFCR_TF1CS_BRG6  0x01000000   /* Transmit FCC1 Clock Source is BRG6 */
923 #define CMXFCR_TF1CS_BRG7  0x02000000   /* Transmit FCC1 Clock Source is BRG7 */
924 #define CMXFCR_TF1CS_BRG8  0x03000000   /* Transmit FCC1 Clock Source is BRG8 */
925 #define CMXFCR_TF1CS_CLK9  0x04000000   /* Transmit FCC1 Clock Source is CLK9 */
926 #define CMXFCR_TF1CS_CLK10 0x05000000   /* Transmit FCC1 Clock Source is CLK10 */
927 #define CMXFCR_TF1CS_CLK11 0x06000000   /* Transmit FCC1 Clock Source is CLK11 */
928 #define CMXFCR_TF1CS_CLK12 0x07000000   /* Transmit FCC1 Clock Source is CLK12 */
929
930 #define CMXFCR_RF2CS_BRG5  0x00000000   /* Receive FCC2 Clock Source is BRG5 */
931 #define CMXFCR_RF2CS_BRG6  0x00080000   /* Receive FCC2 Clock Source is BRG6 */
932 #define CMXFCR_RF2CS_BRG7  0x00100000   /* Receive FCC2 Clock Source is BRG7 */
933 #define CMXFCR_RF2CS_BRG8  0x00180000   /* Receive FCC2 Clock Source is BRG8 */
934 #define CMXFCR_RF2CS_CLK13 0x00200000   /* Receive FCC2 Clock Source is CLK13 */
935 #define CMXFCR_RF2CS_CLK14 0x00280000   /* Receive FCC2 Clock Source is CLK14 */
936 #define CMXFCR_RF2CS_CLK15 0x00300000   /* Receive FCC2 Clock Source is CLK15 */
937 #define CMXFCR_RF2CS_CLK16 0x00380000   /* Receive FCC2 Clock Source is CLK16 */
938
939 #define CMXFCR_TF2CS_BRG5  0x00000000   /* Transmit FCC2 Clock Source is BRG5 */
940 #define CMXFCR_TF2CS_BRG6  0x00010000   /* Transmit FCC2 Clock Source is BRG6 */
941 #define CMXFCR_TF2CS_BRG7  0x00020000   /* Transmit FCC2 Clock Source is BRG7 */
942 #define CMXFCR_TF2CS_BRG8  0x00030000   /* Transmit FCC2 Clock Source is BRG8 */
943 #define CMXFCR_TF2CS_CLK13 0x00040000   /* Transmit FCC2 Clock Source is CLK13 */
944 #define CMXFCR_TF2CS_CLK14 0x00050000   /* Transmit FCC2 Clock Source is CLK14 */
945 #define CMXFCR_TF2CS_CLK15 0x00060000   /* Transmit FCC2 Clock Source is CLK15 */
946 #define CMXFCR_TF2CS_CLK16 0x00070000   /* Transmit FCC2 Clock Source is CLK16 */
947
948 #define CMXFCR_RF3CS_BRG5  0x00000000   /* Receive FCC3 Clock Source is BRG5 */
949 #define CMXFCR_RF3CS_BRG6  0x00000800   /* Receive FCC3 Clock Source is BRG6 */
950 #define CMXFCR_RF3CS_BRG7  0x00001000   /* Receive FCC3 Clock Source is BRG7 */
951 #define CMXFCR_RF3CS_BRG8  0x00001800   /* Receive FCC3 Clock Source is BRG8 */
952 #define CMXFCR_RF3CS_CLK13 0x00002000   /* Receive FCC3 Clock Source is CLK13 */
953 #define CMXFCR_RF3CS_CLK14 0x00002800   /* Receive FCC3 Clock Source is CLK14 */
954 #define CMXFCR_RF3CS_CLK15 0x00003000   /* Receive FCC3 Clock Source is CLK15 */
955 #define CMXFCR_RF3CS_CLK16 0x00003800   /* Receive FCC3 Clock Source is CLK16 */
956
957 #define CMXFCR_TF3CS_BRG5  0x00000000   /* Transmit FCC3 Clock Source is BRG5 */
958 #define CMXFCR_TF3CS_BRG6  0x00000100   /* Transmit FCC3 Clock Source is BRG6 */
959 #define CMXFCR_TF3CS_BRG7  0x00000200   /* Transmit FCC3 Clock Source is BRG7 */
960 #define CMXFCR_TF3CS_BRG8  0x00000300   /* Transmit FCC3 Clock Source is BRG8 */
961 #define CMXFCR_TF3CS_CLK13 0x00000400   /* Transmit FCC3 Clock Source is CLK13 */
962 #define CMXFCR_TF3CS_CLK14 0x00000500   /* Transmit FCC3 Clock Source is CLK14 */
963 #define CMXFCR_TF3CS_CLK15 0x00000600   /* Transmit FCC3 Clock Source is CLK15 */
964 #define CMXFCR_TF3CS_CLK16 0x00000700   /* Transmit FCC3 Clock Source is CLK16 */
965
966 /*-----------------------------------------------------------------------
967  * CMXSCR - CMX SCC Clock Route Register
968  */
969 #define CMXSCR_GR1         0x80000000   /* Grant Support of SCC1        */
970 #define CMXSCR_SC1         0x40000000   /* SCC1 connection              */
971 #define CMXSCR_RS1CS_MSK   0x38000000   /* Receive SCC1 Clock Source Mask */
972 #define CMXSCR_TS1CS_MSK   0x07000000   /* Transmit SCC1 Clock Source Mask */
973 #define CMXSCR_GR2         0x00800000   /* Grant Support of SCC2        */
974 #define CMXSCR_SC2         0x00400000   /* SCC2 connection              */
975 #define CMXSCR_RS2CS_MSK   0x00380000   /* Receive SCC2 Clock Source Mask */
976 #define CMXSCR_TS2CS_MSK   0x00070000   /* Transmit SCC2 Clock Source Mask */
977 #define CMXSCR_GR3         0x00008000   /* Grant Support of SCC3        */
978 #define CMXSCR_SC3         0x00004000   /* SCC3 connection              */
979 #define CMXSCR_RS3CS_MSK   0x00003800   /* Receive SCC3 Clock Source Mask */
980 #define CMXSCR_TS3CS_MSK   0x00000700   /* Transmit SCC3 Clock Source Mask */
981 #define CMXSCR_GR4         0x00000080   /* Grant Support of SCC4        */
982 #define CMXSCR_SC4         0x00000040   /* SCC4 connection              */
983 #define CMXSCR_RS4CS_MSK   0x00000038   /* Receive SCC4 Clock Source Mask */
984 #define CMXSCR_TS4CS_MSK   0x00000007   /* Transmit SCC4 Clock Source Mask */
985
986 #define CMXSCR_RS1CS_BRG1  0x00000000   /* SCC1 Rx Clock Source is BRG1 */
987 #define CMXSCR_RS1CS_BRG2  0x08000000   /* SCC1 Rx Clock Source is BRG2 */
988 #define CMXSCR_RS1CS_BRG3  0x10000000   /* SCC1 Rx Clock Source is BRG3 */
989 #define CMXSCR_RS1CS_BRG4  0x18000000   /* SCC1 Rx Clock Source is BRG4 */
990 #define CMXSCR_RS1CS_CLK11 0x20000000   /* SCC1 Rx Clock Source is CLK11 */
991 #define CMXSCR_RS1CS_CLK12 0x28000000   /* SCC1 Rx Clock Source is CLK12 */
992 #define CMXSCR_RS1CS_CLK3  0x30000000   /* SCC1 Rx Clock Source is CLK3 */
993 #define CMXSCR_RS1CS_CLK4  0x38000000   /* SCC1 Rx Clock Source is CLK4 */
994
995 #define CMXSCR_TS1CS_BRG1  0x00000000   /* SCC1 Tx Clock Source is BRG1 */
996 #define CMXSCR_TS1CS_BRG2  0x01000000   /* SCC1 Tx Clock Source is BRG2 */
997 #define CMXSCR_TS1CS_BRG3  0x02000000   /* SCC1 Tx Clock Source is BRG3 */
998 #define CMXSCR_TS1CS_BRG4  0x03000000   /* SCC1 Tx Clock Source is BRG4 */
999 #define CMXSCR_TS1CS_CLK11 0x04000000   /* SCC1 Tx Clock Source is CLK11 */
1000 #define CMXSCR_TS1CS_CLK12 0x05000000   /* SCC1 Tx Clock Source is CLK12 */
1001 #define CMXSCR_TS1CS_CLK3  0x06000000   /* SCC1 Tx Clock Source is CLK3 */
1002 #define CMXSCR_TS1CS_CLK4  0x07000000   /* SCC1 Tx Clock Source is CLK4 */
1003
1004 #define CMXSCR_RS2CS_BRG1  0x00000000   /* SCC2 Rx Clock Source is BRG1 */
1005 #define CMXSCR_RS2CS_BRG2  0x00080000   /* SCC2 Rx Clock Source is BRG2 */
1006 #define CMXSCR_RS2CS_BRG3  0x00100000   /* SCC2 Rx Clock Source is BRG3 */
1007 #define CMXSCR_RS2CS_BRG4  0x00180000   /* SCC2 Rx Clock Source is BRG4 */
1008 #define CMXSCR_RS2CS_CLK11 0x00200000   /* SCC2 Rx Clock Source is CLK11 */
1009 #define CMXSCR_RS2CS_CLK12 0x00280000   /* SCC2 Rx Clock Source is CLK12 */
1010 #define CMXSCR_RS2CS_CLK3  0x00300000   /* SCC2 Rx Clock Source is CLK3 */
1011 #define CMXSCR_RS2CS_CLK4  0x00380000   /* SCC2 Rx Clock Source is CLK4 */
1012
1013 #define CMXSCR_TS2CS_BRG1  0x00000000   /* SCC2 Tx Clock Source is BRG1 */
1014 #define CMXSCR_TS2CS_BRG2  0x00010000   /* SCC2 Tx Clock Source is BRG2 */
1015 #define CMXSCR_TS2CS_BRG3  0x00020000   /* SCC2 Tx Clock Source is BRG3 */
1016 #define CMXSCR_TS2CS_BRG4  0x00030000   /* SCC2 Tx Clock Source is BRG4 */
1017 #define CMXSCR_TS2CS_CLK11 0x00040000   /* SCC2 Tx Clock Source is CLK11 */
1018 #define CMXSCR_TS2CS_CLK12 0x00050000   /* SCC2 Tx Clock Source is CLK12 */
1019 #define CMXSCR_TS2CS_CLK3  0x00060000   /* SCC2 Tx Clock Source is CLK3 */
1020 #define CMXSCR_TS2CS_CLK4  0x00070000   /* SCC2 Tx Clock Source is CLK4 */
1021
1022 #define CMXSCR_RS3CS_BRG1  0x00000000   /* SCC3 Rx Clock Source is BRG1 */
1023 #define CMXSCR_RS3CS_BRG2  0x00000800   /* SCC3 Rx Clock Source is BRG2 */
1024 #define CMXSCR_RS3CS_BRG3  0x00001000   /* SCC3 Rx Clock Source is BRG3 */
1025 #define CMXSCR_RS3CS_BRG4  0x00001800   /* SCC3 Rx Clock Source is BRG4 */
1026 #define CMXSCR_RS3CS_CLK5  0x00002000   /* SCC3 Rx Clock Source is CLK5 */
1027 #define CMXSCR_RS3CS_CLK6  0x00002800   /* SCC3 Rx Clock Source is CLK6 */
1028 #define CMXSCR_RS3CS_CLK7  0x00003000   /* SCC3 Rx Clock Source is CLK7 */
1029 #define CMXSCR_RS3CS_CLK8  0x00003800   /* SCC3 Rx Clock Source is CLK8 */
1030
1031 #define CMXSCR_TS3CS_BRG1  0x00000000   /* SCC3 Tx Clock Source is BRG1 */
1032 #define CMXSCR_TS3CS_BRG2  0x00000100   /* SCC3 Tx Clock Source is BRG2 */
1033 #define CMXSCR_TS3CS_BRG3  0x00000200   /* SCC3 Tx Clock Source is BRG3 */
1034 #define CMXSCR_TS3CS_BRG4  0x00000300   /* SCC3 Tx Clock Source is BRG4 */
1035 #define CMXSCR_TS3CS_CLK5  0x00000400   /* SCC3 Tx Clock Source is CLK5 */
1036 #define CMXSCR_TS3CS_CLK6  0x00000500   /* SCC3 Tx Clock Source is CLK6 */
1037 #define CMXSCR_TS3CS_CLK7  0x00000600   /* SCC3 Tx Clock Source is CLK7 */
1038 #define CMXSCR_TS3CS_CLK8  0x00000700   /* SCC3 Tx Clock Source is CLK8 */
1039
1040 #define CMXSCR_RS4CS_BRG1  0x00000000   /* SCC4 Rx Clock Source is BRG1 */
1041 #define CMXSCR_RS4CS_BRG2  0x00000008   /* SCC4 Rx Clock Source is BRG2 */
1042 #define CMXSCR_RS4CS_BRG3  0x00000010   /* SCC4 Rx Clock Source is BRG3 */
1043 #define CMXSCR_RS4CS_BRG4  0x00000018   /* SCC4 Rx Clock Source is BRG4 */
1044 #define CMXSCR_RS4CS_CLK5  0x00000020   /* SCC4 Rx Clock Source is CLK5 */
1045 #define CMXSCR_RS4CS_CLK6  0x00000028   /* SCC4 Rx Clock Source is CLK6 */
1046 #define CMXSCR_RS4CS_CLK7  0x00000030   /* SCC4 Rx Clock Source is CLK7 */
1047 #define CMXSCR_RS4CS_CLK8  0x00000038   /* SCC4 Rx Clock Source is CLK8 */
1048
1049 #define CMXSCR_TS4CS_BRG1  0x00000000   /* SCC4 Tx Clock Source is BRG1 */
1050 #define CMXSCR_TS4CS_BRG2  0x00000001   /* SCC4 Tx Clock Source is BRG2 */
1051 #define CMXSCR_TS4CS_BRG3  0x00000002   /* SCC4 Tx Clock Source is BRG3 */
1052 #define CMXSCR_TS4CS_BRG4  0x00000003   /* SCC4 Tx Clock Source is BRG4 */
1053 #define CMXSCR_TS4CS_CLK5  0x00000004   /* SCC4 Tx Clock Source is CLK5 */
1054 #define CMXSCR_TS4CS_CLK6  0x00000005   /* SCC4 Tx Clock Source is CLK6 */
1055 #define CMXSCR_TS4CS_CLK7  0x00000006   /* SCC4 Tx Clock Source is CLK7 */
1056 #define CMXSCR_TS4CS_CLK8  0x00000007   /* SCC4 Tx Clock Source is CLK8 */
1057
1058 /*-----------------------------------------------------------------------
1059  * SIUMCR - SIU Module Configuration Register                            4-31
1060  */
1061 #define SIUMCR_BBD      0x80000000      /* Bus Busy Disable             */
1062 #define SIUMCR_ESE      0x40000000      /* External Snoop Enable        */
1063 #define SIUMCR_PBSE     0x20000000      /* Parity Byte Select Enable    */
1064 #define SIUMCR_CDIS     0x10000000      /* Core Disable                 */
1065 #define SIUMCR_DPPC00   0x00000000      /* Data Parity Pins Configuration*/
1066 #define SIUMCR_DPPC01   0x04000000      /* - " -                        */
1067 #define SIUMCR_DPPC10   0x08000000      /* - " -                        */
1068 #define SIUMCR_DPPC11   0x0c000000      /* - " -                        */
1069 #define SIUMCR_L2CPC00  0x00000000      /* L2 Cache Pins Configuration  */
1070 #define SIUMCR_L2CPC01  0x01000000      /* - " -                        */
1071 #define SIUMCR_L2CPC10  0x02000000      /* - " -                        */
1072 #define SIUMCR_L2CPC11  0x03000000      /* - " -                        */
1073 #define SIUMCR_LBPC00   0x00000000      /* Local Bus Pins Configuration */
1074 #define SIUMCR_LBPC01   0x00400000      /* - " -                        */
1075 #define SIUMCR_LBPC10   0x00800000      /* - " -                        */
1076 #define SIUMCR_LBPC11   0x00c00000      /* - " -                        */
1077 #define SIUMCR_APPC00   0x00000000      /* Address Parity Pins Configuration*/
1078 #define SIUMCR_APPC01   0x00100000      /* - " -                        */
1079 #define SIUMCR_APPC10   0x00200000      /* - " -                        */
1080 #define SIUMCR_APPC11   0x00300000      /* - " -                        */
1081 #define SIUMCR_CS10PC00 0x00000000      /* CS10 Pin Configuration       */
1082 #define SIUMCR_CS10PC01 0x00040000      /* - " -                        */
1083 #define SIUMCR_CS10PC10 0x00080000      /* - " -                        */
1084 #define SIUMCR_CS10PC11 0x000c0000      /* - " -                        */
1085 #define SIUMCR_BCTLC00  0x00000000      /* Buffer Control Configuration */
1086 #define SIUMCR_BCTLC01  0x00010000      /* - " -                        */
1087 #define SIUMCR_BCTLC10  0x00020000      /* - " -                        */
1088 #define SIUMCR_BCTLC11  0x00030000      /* - " -                        */
1089 #define SIUMCR_MMR00    0x00000000      /* Mask Masters Requests        */
1090 #define SIUMCR_MMR01    0x00004000      /* - " -                        */
1091 #define SIUMCR_MMR10    0x00008000      /* - " -                        */
1092 #define SIUMCR_MMR11    0x0000c000      /* - " -                        */
1093 #define SIUMCR_LPBSE    0x00002000      /* LocalBus Parity Byte Select Enable*/
1094
1095 /*-----------------------------------------------------------------------
1096  * SCCR - System Clock Control Register                                  9-8
1097 */
1098 #define SCCR_PCI_MODE   0x00000100      /* PCI Mode     */
1099 #define SCCR_PCI_MODCK  0x00000080      /* Value of PCI_MODCK pin       */
1100 #define SCCR_PCIDF_MSK  0x00000078      /* PCI division factor  */
1101 #define SCCR_PCIDF_SHIFT 3
1102
1103 #ifndef CPM_IMMR_OFFSET
1104 #define CPM_IMMR_OFFSET 0x101a8
1105 #endif
1106
1107 #define FCC_PSMR_RMII   ((uint)0x00020000)      /* Use RMII interface */
1108
1109 /* FCC iop & clock configuration. BSP code is responsible to define Fx_RXCLK & Fx_TXCLK
1110  * in order to use clock-computing stuff below for the FCC x
1111  */
1112
1113 /* Automatically generates register configurations */
1114 #define PC_CLK(x)       ((uint)(1<<(x-1)))      /* FCC CLK I/O ports */
1115
1116 #define CMXFCR_RF1CS(x) ((uint)((x-5)<<27))     /* FCC1 Receive Clock Source */
1117 #define CMXFCR_TF1CS(x) ((uint)((x-5)<<24))     /* FCC1 Transmit Clock Source */
1118 #define CMXFCR_RF2CS(x) ((uint)((x-9)<<19))     /* FCC2 Receive Clock Source */
1119 #define CMXFCR_TF2CS(x) ((uint)((x-9)<<16))     /* FCC2 Transmit Clock Source */
1120 #define CMXFCR_RF3CS(x) ((uint)((x-9)<<11))     /* FCC3 Receive Clock Source */
1121 #define CMXFCR_TF3CS(x) ((uint)((x-9)<<8))      /* FCC3 Transmit Clock Source */
1122
1123 #define PC_F1RXCLK      PC_CLK(F1_RXCLK)
1124 #define PC_F1TXCLK      PC_CLK(F1_TXCLK)
1125 #define CMX1_CLK_ROUTE  (CMXFCR_RF1CS(F1_RXCLK) | CMXFCR_TF1CS(F1_TXCLK))
1126 #define CMX1_CLK_MASK   ((uint)0xff000000)
1127
1128 #define PC_F2RXCLK      PC_CLK(F2_RXCLK)
1129 #define PC_F2TXCLK      PC_CLK(F2_TXCLK)
1130 #define CMX2_CLK_ROUTE  (CMXFCR_RF2CS(F2_RXCLK) | CMXFCR_TF2CS(F2_TXCLK))
1131 #define CMX2_CLK_MASK   ((uint)0x00ff0000)
1132
1133 #define PC_F3RXCLK      PC_CLK(F3_RXCLK)
1134 #define PC_F3TXCLK      PC_CLK(F3_TXCLK)
1135 #define CMX3_CLK_ROUTE  (CMXFCR_RF3CS(F3_RXCLK) | CMXFCR_TF3CS(F3_TXCLK))
1136 #define CMX3_CLK_MASK   ((uint)0x0000ff00)
1137
1138 #define CPMUX_CLK_MASK (CMX3_CLK_MASK | CMX2_CLK_MASK)
1139 #define CPMUX_CLK_ROUTE (CMX3_CLK_ROUTE | CMX2_CLK_ROUTE)
1140
1141 #define CLK_TRX (PC_F3TXCLK | PC_F3RXCLK | PC_F2TXCLK | PC_F2RXCLK)
1142
1143 /* I/O Pin assignment for FCC1.  I don't yet know the best way to do this,
1144  * but there is little variation among the choices.
1145  */
1146 #define PA1_COL         0x00000001U
1147 #define PA1_CRS         0x00000002U
1148 #define PA1_TXER        0x00000004U
1149 #define PA1_TXEN        0x00000008U
1150 #define PA1_RXDV        0x00000010U
1151 #define PA1_RXER        0x00000020U
1152 #define PA1_TXDAT       0x00003c00U
1153 #define PA1_RXDAT       0x0003c000U
1154 #define PA1_PSORA0      (PA1_RXDAT | PA1_TXDAT)
1155 #define PA1_PSORA1      (PA1_COL | PA1_CRS | PA1_TXER | PA1_TXEN | \
1156                 PA1_RXDV | PA1_RXER)
1157 #define PA1_DIRA0       (PA1_RXDAT | PA1_CRS | PA1_COL | PA1_RXER | PA1_RXDV)
1158 #define PA1_DIRA1       (PA1_TXDAT | PA1_TXEN | PA1_TXER)
1159
1160
1161 /* I/O Pin assignment for FCC2.  I don't yet know the best way to do this,
1162  * but there is little variation among the choices.
1163  */
1164 #define PB2_TXER        0x00000001U
1165 #define PB2_RXDV        0x00000002U
1166 #define PB2_TXEN        0x00000004U
1167 #define PB2_RXER        0x00000008U
1168 #define PB2_COL         0x00000010U
1169 #define PB2_CRS         0x00000020U
1170 #define PB2_TXDAT       0x000003c0U
1171 #define PB2_RXDAT       0x00003c00U
1172 #define PB2_PSORB0      (PB2_RXDAT | PB2_TXDAT | PB2_CRS | PB2_COL | \
1173                 PB2_RXER | PB2_RXDV | PB2_TXER)
1174 #define PB2_PSORB1      (PB2_TXEN)
1175 #define PB2_DIRB0       (PB2_RXDAT | PB2_CRS | PB2_COL | PB2_RXER | PB2_RXDV)
1176 #define PB2_DIRB1       (PB2_TXDAT | PB2_TXEN | PB2_TXER)
1177
1178
1179 /* I/O Pin assignment for FCC3.  I don't yet know the best way to do this,
1180  * but there is little variation among the choices.
1181  */
1182 #define PB3_RXDV        0x00004000U
1183 #define PB3_RXER        0x00008000U
1184 #define PB3_TXER        0x00010000U
1185 #define PB3_TXEN        0x00020000U
1186 #define PB3_COL         0x00040000U
1187 #define PB3_CRS         0x00080000U
1188 #define PB3_TXDAT       0x0f000000U
1189 #define PC3_TXDAT       0x00000010U
1190 #define PB3_RXDAT       0x00f00000U
1191 #define PB3_PSORB0      (PB3_RXDAT | PB3_TXDAT | PB3_CRS | PB3_COL | \
1192                 PB3_RXER | PB3_RXDV | PB3_TXER | PB3_TXEN)
1193 #define PB3_PSORB1      0
1194 #define PB3_DIRB0       (PB3_RXDAT | PB3_CRS | PB3_COL | PB3_RXER | PB3_RXDV)
1195 #define PB3_DIRB1       (PB3_TXDAT | PB3_TXEN | PB3_TXER)
1196 #define PC3_DIRC1       (PC3_TXDAT)
1197
1198 /* Handy macro to specify mem for FCCs*/
1199 #define FCC_MEM_OFFSET(x) (CPM_FCC_SPECIAL_BASE + (x*128))
1200 #define FCC1_MEM_OFFSET FCC_MEM_OFFSET(0)
1201 #define FCC2_MEM_OFFSET FCC_MEM_OFFSET(1)
1202 #define FCC3_MEM_OFFSET FCC_MEM_OFFSET(2)
1203
1204 /* Clocks and GRG's */
1205
1206 enum cpm_clk_dir {
1207         CPM_CLK_RX,
1208         CPM_CLK_TX,
1209         CPM_CLK_RTX
1210 };
1211
1212 enum cpm_clk_target {
1213         CPM_CLK_SCC1,
1214         CPM_CLK_SCC2,
1215         CPM_CLK_SCC3,
1216         CPM_CLK_SCC4,
1217         CPM_CLK_FCC1,
1218         CPM_CLK_FCC2,
1219         CPM_CLK_FCC3,
1220         CPM_CLK_SMC1,
1221         CPM_CLK_SMC2,
1222 };
1223
1224 enum cpm_clk {
1225         CPM_CLK_NONE = 0,
1226         CPM_BRG1,       /* Baud Rate Generator  1 */
1227         CPM_BRG2,       /* Baud Rate Generator  2 */
1228         CPM_BRG3,       /* Baud Rate Generator  3 */
1229         CPM_BRG4,       /* Baud Rate Generator  4 */
1230         CPM_BRG5,       /* Baud Rate Generator  5 */
1231         CPM_BRG6,       /* Baud Rate Generator  6 */
1232         CPM_BRG7,       /* Baud Rate Generator  7 */
1233         CPM_BRG8,       /* Baud Rate Generator  8 */
1234         CPM_CLK1,       /* Clock  1 */
1235         CPM_CLK2,       /* Clock  2 */
1236         CPM_CLK3,       /* Clock  3 */
1237         CPM_CLK4,       /* Clock  4 */
1238         CPM_CLK5,       /* Clock  5 */
1239         CPM_CLK6,       /* Clock  6 */
1240         CPM_CLK7,       /* Clock  7 */
1241         CPM_CLK8,       /* Clock  8 */
1242         CPM_CLK9,       /* Clock  9 */
1243         CPM_CLK10,      /* Clock 10 */
1244         CPM_CLK11,      /* Clock 11 */
1245         CPM_CLK12,      /* Clock 12 */
1246         CPM_CLK13,      /* Clock 13 */
1247         CPM_CLK14,      /* Clock 14 */
1248         CPM_CLK15,      /* Clock 15 */
1249         CPM_CLK16,      /* Clock 16 */
1250         CPM_CLK17,      /* Clock 17 */
1251         CPM_CLK18,      /* Clock 18 */
1252         CPM_CLK19,      /* Clock 19 */
1253         CPM_CLK20,      /* Clock 20 */
1254         CPM_CLK_DUMMY
1255 };
1256
1257 extern int cpm2_clk_setup(enum cpm_clk_target target, int clock, int mode);
1258 extern int cpm2_smc_clk_setup(enum cpm_clk_target target, int clock);
1259
1260 #define CPM_PIN_INPUT     0
1261 #define CPM_PIN_OUTPUT    1
1262 #define CPM_PIN_PRIMARY   0
1263 #define CPM_PIN_SECONDARY 2
1264 #define CPM_PIN_GPIO      4
1265 #define CPM_PIN_OPENDRAIN 8
1266
1267 void cpm2_set_pin(int port, int pin, int flags);
1268
1269 #endif /* __CPM2__ */
1270 #endif /* __KERNEL__ */