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