xref: /openbmc/u-boot/drivers/net/altera_tse.h (revision c960b13e)
1*c960b13eSThomas Chou /*
2*c960b13eSThomas Chou  * Altera 10/100/1000 triple speed ethernet mac
3*c960b13eSThomas Chou  *
4*c960b13eSThomas Chou  * Copyright (C) 2008 Altera Corporation.
5*c960b13eSThomas Chou  * Copyright (C) 2010 Thomas Chou <thomas@wytron.com.tw>
6*c960b13eSThomas Chou  *
7*c960b13eSThomas Chou  * This program is free software; you can redistribute it and/or modify
8*c960b13eSThomas Chou  * it under the terms of the GNU General Public License version 2 as
9*c960b13eSThomas Chou  * published by the Free Software Foundation.
10*c960b13eSThomas Chou  */
11*c960b13eSThomas Chou #ifndef _ALTERA_TSE_H_
12*c960b13eSThomas Chou #define _ALTERA_TSE_H_
13*c960b13eSThomas Chou 
14*c960b13eSThomas Chou #define __packed_1_    __attribute__ ((packed, aligned(1)))
15*c960b13eSThomas Chou 
16*c960b13eSThomas Chou /* PHY Stuff */
17*c960b13eSThomas Chou #define miim_end -2
18*c960b13eSThomas Chou #define miim_read -1
19*c960b13eSThomas Chou 
20*c960b13eSThomas Chou #define PHY_AUTONEGOTIATE_TIMEOUT	5000	/* in ms */
21*c960b13eSThomas Chou 
22*c960b13eSThomas Chou #ifndef CONFIG_SYS_TBIPA_VALUE
23*c960b13eSThomas Chou #define CONFIG_SYS_TBIPA_VALUE	0x1f
24*c960b13eSThomas Chou #endif
25*c960b13eSThomas Chou #define MIIMCFG_INIT_VALUE	0x00000003
26*c960b13eSThomas Chou #define MIIMCFG_RESET		0x80000000
27*c960b13eSThomas Chou 
28*c960b13eSThomas Chou #define MIIMIND_BUSY		0x00000001
29*c960b13eSThomas Chou #define MIIMIND_NOTVALID	0x00000004
30*c960b13eSThomas Chou 
31*c960b13eSThomas Chou #define MIIM_CONTROL		0x00
32*c960b13eSThomas Chou #define MIIM_CONTROL_RESET	0x00009140
33*c960b13eSThomas Chou #define MIIM_CONTROL_INIT	0x00001140
34*c960b13eSThomas Chou #define MIIM_CONTROL_RESTART	0x00001340
35*c960b13eSThomas Chou #define MIIM_ANEN		0x00001000
36*c960b13eSThomas Chou 
37*c960b13eSThomas Chou #define MIIM_CR		0x00
38*c960b13eSThomas Chou #define MIIM_CR_RST		0x00008000
39*c960b13eSThomas Chou #define MIIM_CR_INIT		0x00001000
40*c960b13eSThomas Chou 
41*c960b13eSThomas Chou #define MIIM_STATUS		0x1
42*c960b13eSThomas Chou #define MIIM_STATUS_AN_DONE	0x00000020
43*c960b13eSThomas Chou #define MIIM_STATUS_LINK	0x0004
44*c960b13eSThomas Chou #define PHY_BMSR_AUTN_ABLE	0x0008
45*c960b13eSThomas Chou #define PHY_BMSR_AUTN_COMP	0x0020
46*c960b13eSThomas Chou 
47*c960b13eSThomas Chou #define MIIM_PHYIR1		0x2
48*c960b13eSThomas Chou #define MIIM_PHYIR2		0x3
49*c960b13eSThomas Chou 
50*c960b13eSThomas Chou #define MIIM_ANAR		0x4
51*c960b13eSThomas Chou #define MIIM_ANAR_INIT		0x1e1
52*c960b13eSThomas Chou 
53*c960b13eSThomas Chou #define MIIM_TBI_ANLPBPA	0x5
54*c960b13eSThomas Chou #define MIIM_TBI_ANLPBPA_HALF	0x00000040
55*c960b13eSThomas Chou #define MIIM_TBI_ANLPBPA_FULL	0x00000020
56*c960b13eSThomas Chou 
57*c960b13eSThomas Chou #define MIIM_TBI_ANEX		0x6
58*c960b13eSThomas Chou #define MIIM_TBI_ANEX_NP	0x00000004
59*c960b13eSThomas Chou #define MIIM_TBI_ANEX_PRX	0x00000002
60*c960b13eSThomas Chou 
61*c960b13eSThomas Chou #define MIIM_GBIT_CONTROL	0x9
62*c960b13eSThomas Chou #define MIIM_GBIT_CONTROL_INIT	0xe00
63*c960b13eSThomas Chou 
64*c960b13eSThomas Chou #define MIIM_EXT_PAGE_ACCESS	0x1f
65*c960b13eSThomas Chou 
66*c960b13eSThomas Chou /* 88E1011 PHY Status Register */
67*c960b13eSThomas Chou #define MIIM_88E1011_PHY_STATUS	0x11
68*c960b13eSThomas Chou #define MIIM_88E1011_PHYSTAT_SPEED	0xc000
69*c960b13eSThomas Chou #define MIIM_88E1011_PHYSTAT_GBIT	0x8000
70*c960b13eSThomas Chou #define MIIM_88E1011_PHYSTAT_100	0x4000
71*c960b13eSThomas Chou #define MIIM_88E1011_PHYSTAT_DUPLEX	0x2000
72*c960b13eSThomas Chou #define MIIM_88E1011_PHYSTAT_SPDDONE	0x0800
73*c960b13eSThomas Chou #define MIIM_88E1011_PHYSTAT_LINK	0x0400
74*c960b13eSThomas Chou 
75*c960b13eSThomas Chou #define MIIM_88E1011_PHY_SCR		0x10
76*c960b13eSThomas Chou #define MIIM_88E1011_PHY_MDI_X_AUTO	0x0060
77*c960b13eSThomas Chou 
78*c960b13eSThomas Chou #define MIIM_88E1111_PHY_EXT_CR	0x14
79*c960b13eSThomas Chou #define MIIM_88E1111_PHY_EXT_SR	0x1b
80*c960b13eSThomas Chou 
81*c960b13eSThomas Chou /* 88E1111 PHY LED Control Register */
82*c960b13eSThomas Chou #define MIIM_88E1111_PHY_LED_CONTROL	24
83*c960b13eSThomas Chou #define MIIM_88E1111_PHY_LED_DIRECT	0x4100
84*c960b13eSThomas Chou #define MIIM_88E1111_PHY_LED_COMBINE	0x411C
85*c960b13eSThomas Chou 
86*c960b13eSThomas Chou #define MIIM_READ_COMMAND	0x00000001
87*c960b13eSThomas Chou 
88*c960b13eSThomas Chou /* struct phy_info: a structure which defines attributes for a PHY
89*c960b13eSThomas Chou  * id will contain a number which represents the PHY.  During
90*c960b13eSThomas Chou  * startup, the driver will poll the PHY to find out what its
91*c960b13eSThomas Chou  * UID--as defined by registers 2 and 3--is.  The 32-bit result
92*c960b13eSThomas Chou  * gotten from the PHY will be shifted right by "shift" bits to
93*c960b13eSThomas Chou  * discard any bits which may change based on revision numbers
94*c960b13eSThomas Chou  * unimportant to functionality
95*c960b13eSThomas Chou  *
96*c960b13eSThomas Chou  * The struct phy_cmd entries represent pointers to an arrays of
97*c960b13eSThomas Chou  * commands which tell the driver what to do to the PHY.
98*c960b13eSThomas Chou  */
99*c960b13eSThomas Chou struct phy_info {
100*c960b13eSThomas Chou 	uint id;
101*c960b13eSThomas Chou 	char *name;
102*c960b13eSThomas Chou 	uint shift;
103*c960b13eSThomas Chou 	/* Called to configure the PHY, and modify the controller
104*c960b13eSThomas Chou 	 * based on the results */
105*c960b13eSThomas Chou 	struct phy_cmd *config;
106*c960b13eSThomas Chou 
107*c960b13eSThomas Chou 	/* Called when starting up the controller */
108*c960b13eSThomas Chou 	struct phy_cmd *startup;
109*c960b13eSThomas Chou 
110*c960b13eSThomas Chou 	/* Called when bringing down the controller */
111*c960b13eSThomas Chou 	struct phy_cmd *shutdown;
112*c960b13eSThomas Chou };
113*c960b13eSThomas Chou 
114*c960b13eSThomas Chou /* SGDMA Stuff */
115*c960b13eSThomas Chou #define ALT_SGDMA_STATUS_ERROR_MSK			(0x00000001)
116*c960b13eSThomas Chou #define ALT_SGDMA_STATUS_EOP_ENCOUNTERED_MSK		(0x00000002)
117*c960b13eSThomas Chou #define ALT_SGDMA_STATUS_DESC_COMPLETED_MSK		(0x00000004)
118*c960b13eSThomas Chou #define ALT_SGDMA_STATUS_CHAIN_COMPLETED_MSK		(0x00000008)
119*c960b13eSThomas Chou #define ALT_SGDMA_STATUS_BUSY_MSK			(0x00000010)
120*c960b13eSThomas Chou 
121*c960b13eSThomas Chou #define ALT_SGDMA_CONTROL_IE_ERROR_MSK			(0x00000001)
122*c960b13eSThomas Chou #define ALT_SGDMA_CONTROL_IE_EOP_ENCOUNTERED_MSK	(0x00000002)
123*c960b13eSThomas Chou #define ALT_SGDMA_CONTROL_IE_DESC_COMPLETED_MSK	(0x00000004)
124*c960b13eSThomas Chou #define ALT_SGDMA_CONTROL_IE_CHAIN_COMPLETED_MSK	(0x00000008)
125*c960b13eSThomas Chou #define ALT_SGDMA_CONTROL_IE_GLOBAL_MSK		(0x00000010)
126*c960b13eSThomas Chou #define ALT_SGDMA_CONTROL_RUN_MSK			(0x00000020)
127*c960b13eSThomas Chou #define ALT_SGDMA_CONTROL_STOP_DMA_ER_MSK		(0x00000040)
128*c960b13eSThomas Chou #define ALT_SGDMA_CONTROL_IE_MAX_DESC_PROCESSED_MSK	(0x00000080)
129*c960b13eSThomas Chou #define ALT_SGDMA_CONTROL_MAX_DESC_PROCESSED_MSK	(0x0000FF00)
130*c960b13eSThomas Chou #define ALT_SGDMA_CONTROL_SOFTWARERESET_MSK		(0x00010000)
131*c960b13eSThomas Chou #define ALT_SGDMA_CONTROL_PARK_MSK			(0x00020000)
132*c960b13eSThomas Chou #define ALT_SGDMA_CONTROL_CLEAR_INTERRUPT_MSK		(0x80000000)
133*c960b13eSThomas Chou 
134*c960b13eSThomas Chou #define ALTERA_TSE_SGDMA_INTR_MASK  (ALT_SGDMA_CONTROL_IE_CHAIN_COMPLETED_MSK \
135*c960b13eSThomas Chou 			| ALT_SGDMA_STATUS_DESC_COMPLETED_MSK \
136*c960b13eSThomas Chou 			| ALT_SGDMA_CONTROL_IE_GLOBAL_MSK)
137*c960b13eSThomas Chou 
138*c960b13eSThomas Chou /*
139*c960b13eSThomas Chou  * Descriptor control bit masks & offsets
140*c960b13eSThomas Chou  *
141*c960b13eSThomas Chou  * Note: The control byte physically occupies bits [31:24] in memory.
142*c960b13eSThomas Chou  *	 The following bit-offsets are expressed relative to the LSB of
143*c960b13eSThomas Chou  *	 the control register bitfield.
144*c960b13eSThomas Chou  */
145*c960b13eSThomas Chou #define ALT_SGDMA_DESCRIPTOR_CONTROL_GENERATE_EOP_MSK		(0x00000001)
146*c960b13eSThomas Chou #define ALT_SGDMA_DESCRIPTOR_CONTROL_READ_FIXED_ADDRESS_MSK	(0x00000002)
147*c960b13eSThomas Chou #define ALT_SGDMA_DESCRIPTOR_CONTROL_WRITE_FIXED_ADDRESS_MSK	(0x00000004)
148*c960b13eSThomas Chou #define ALT_SGDMA_DESCRIPTOR_CONTROL_ATLANTIC_CHANNEL_MSK	(0x00000008)
149*c960b13eSThomas Chou #define ALT_SGDMA_DESCRIPTOR_CONTROL_OWNED_BY_HW_MSK		(0x00000080)
150*c960b13eSThomas Chou 
151*c960b13eSThomas Chou /*
152*c960b13eSThomas Chou  * Descriptor status bit masks & offsets
153*c960b13eSThomas Chou  *
154*c960b13eSThomas Chou  * Note: The status byte physically occupies bits [23:16] in memory.
155*c960b13eSThomas Chou  *	 The following bit-offsets are expressed relative to the LSB of
156*c960b13eSThomas Chou  *	 the status register bitfield.
157*c960b13eSThomas Chou  */
158*c960b13eSThomas Chou #define ALT_SGDMA_DESCRIPTOR_STATUS_E_CRC_MSK			(0x00000001)
159*c960b13eSThomas Chou #define ALT_SGDMA_DESCRIPTOR_STATUS_E_PARITY_MSK		(0x00000002)
160*c960b13eSThomas Chou #define ALT_SGDMA_DESCRIPTOR_STATUS_E_OVERFLOW_MSK		(0x00000004)
161*c960b13eSThomas Chou #define ALT_SGDMA_DESCRIPTOR_STATUS_E_SYNC_MSK			(0x00000008)
162*c960b13eSThomas Chou #define ALT_SGDMA_DESCRIPTOR_STATUS_E_UEOP_MSK			(0x00000010)
163*c960b13eSThomas Chou #define ALT_SGDMA_DESCRIPTOR_STATUS_E_MEOP_MSK			(0x00000020)
164*c960b13eSThomas Chou #define ALT_SGDMA_DESCRIPTOR_STATUS_E_MSOP_MSK			(0x00000040)
165*c960b13eSThomas Chou #define ALT_SGDMA_DESCRIPTOR_STATUS_TERMINATED_BY_EOP_MSK	(0x00000080)
166*c960b13eSThomas Chou #define ALT_SGDMA_DESCRIPTOR_STATUS_ERROR_MSK			(0x0000007F)
167*c960b13eSThomas Chou 
168*c960b13eSThomas Chou /*
169*c960b13eSThomas Chou  * The SGDMA controller buffer descriptor allocates
170*c960b13eSThomas Chou  * 64 bits for each address. To support ANSI C, the
171*c960b13eSThomas Chou  * struct implementing a descriptor places 32-bits
172*c960b13eSThomas Chou  * of padding directly above each address; each pad must
173*c960b13eSThomas Chou  * be cleared when initializing a descriptor.
174*c960b13eSThomas Chou  */
175*c960b13eSThomas Chou 
176*c960b13eSThomas Chou /*
177*c960b13eSThomas Chou  * Buffer Descriptor data structure
178*c960b13eSThomas Chou  *
179*c960b13eSThomas Chou  */
180*c960b13eSThomas Chou struct alt_sgdma_descriptor {
181*c960b13eSThomas Chou 	unsigned int *source;	/* the address of data to be read. */
182*c960b13eSThomas Chou 	unsigned int source_pad;
183*c960b13eSThomas Chou 
184*c960b13eSThomas Chou 	unsigned int *destination;	/* the address to write data */
185*c960b13eSThomas Chou 	unsigned int destination_pad;
186*c960b13eSThomas Chou 
187*c960b13eSThomas Chou 	unsigned int *next;	/* the next descriptor in the list. */
188*c960b13eSThomas Chou 	unsigned int next_pad;
189*c960b13eSThomas Chou 
190*c960b13eSThomas Chou 	unsigned short bytes_to_transfer; /* the number of bytes to transfer */
191*c960b13eSThomas Chou 	unsigned char read_burst;
192*c960b13eSThomas Chou 	unsigned char write_burst;
193*c960b13eSThomas Chou 
194*c960b13eSThomas Chou 	unsigned short actual_bytes_transferred;/* bytes transferred by DMA */
195*c960b13eSThomas Chou 	unsigned char descriptor_status;
196*c960b13eSThomas Chou 	unsigned char descriptor_control;
197*c960b13eSThomas Chou 
198*c960b13eSThomas Chou } __packed_1_;
199*c960b13eSThomas Chou 
200*c960b13eSThomas Chou /* SG-DMA Control/Status Slave registers map */
201*c960b13eSThomas Chou 
202*c960b13eSThomas Chou struct alt_sgdma_registers {
203*c960b13eSThomas Chou 	unsigned int status;
204*c960b13eSThomas Chou 	unsigned int status_pad[3];
205*c960b13eSThomas Chou 	unsigned int control;
206*c960b13eSThomas Chou 	unsigned int control_pad[3];
207*c960b13eSThomas Chou 	unsigned int next_descriptor_pointer;
208*c960b13eSThomas Chou 	unsigned int descriptor_pad[3];
209*c960b13eSThomas Chou };
210*c960b13eSThomas Chou 
211*c960b13eSThomas Chou /* TSE Stuff */
212*c960b13eSThomas Chou #define ALTERA_TSE_CMD_TX_ENA_MSK		(0x00000001)
213*c960b13eSThomas Chou #define ALTERA_TSE_CMD_RX_ENA_MSK		(0x00000002)
214*c960b13eSThomas Chou #define ALTERA_TSE_CMD_XON_GEN_MSK		(0x00000004)
215*c960b13eSThomas Chou #define ALTERA_TSE_CMD_ETH_SPEED_MSK		(0x00000008)
216*c960b13eSThomas Chou #define ALTERA_TSE_CMD_PROMIS_EN_MSK		(0x00000010)
217*c960b13eSThomas Chou #define ALTERA_TSE_CMD_PAD_EN_MSK		(0x00000020)
218*c960b13eSThomas Chou #define ALTERA_TSE_CMD_CRC_FWD_MSK		(0x00000040)
219*c960b13eSThomas Chou #define ALTERA_TSE_CMD_PAUSE_FWD_MSK		(0x00000080)
220*c960b13eSThomas Chou #define ALTERA_TSE_CMD_PAUSE_IGNORE_MSK	(0x00000100)
221*c960b13eSThomas Chou #define ALTERA_TSE_CMD_TX_ADDR_INS_MSK		(0x00000200)
222*c960b13eSThomas Chou #define ALTERA_TSE_CMD_HD_ENA_MSK		(0x00000400)
223*c960b13eSThomas Chou #define ALTERA_TSE_CMD_EXCESS_COL_MSK		(0x00000800)
224*c960b13eSThomas Chou #define ALTERA_TSE_CMD_LATE_COL_MSK		(0x00001000)
225*c960b13eSThomas Chou #define ALTERA_TSE_CMD_SW_RESET_MSK		(0x00002000)
226*c960b13eSThomas Chou #define ALTERA_TSE_CMD_MHASH_SEL_MSK		(0x00004000)
227*c960b13eSThomas Chou #define ALTERA_TSE_CMD_LOOPBACK_MSK		(0x00008000)
228*c960b13eSThomas Chou /* Bits (18:16) = address select */
229*c960b13eSThomas Chou #define ALTERA_TSE_CMD_TX_ADDR_SEL_MSK		(0x00070000)
230*c960b13eSThomas Chou #define ALTERA_TSE_CMD_MAGIC_ENA_MSK		(0x00080000)
231*c960b13eSThomas Chou #define ALTERA_TSE_CMD_SLEEP_MSK		(0x00100000)
232*c960b13eSThomas Chou #define ALTERA_TSE_CMD_WAKEUP_MSK		(0x00200000)
233*c960b13eSThomas Chou #define ALTERA_TSE_CMD_XOFF_GEN_MSK		(0x00400000)
234*c960b13eSThomas Chou #define ALTERA_TSE_CMD_CNTL_FRM_ENA_MSK	(0x00800000)
235*c960b13eSThomas Chou #define ALTERA_TSE_CMD_NO_LENGTH_CHECK_MSK	(0x01000000)
236*c960b13eSThomas Chou #define ALTERA_TSE_CMD_ENA_10_MSK		(0x02000000)
237*c960b13eSThomas Chou #define ALTERA_TSE_CMD_RX_ERR_DISC_MSK		(0x04000000)
238*c960b13eSThomas Chou /* Bits (30..27) reserved */
239*c960b13eSThomas Chou #define ALTERA_TSE_CMD_CNT_RESET_MSK		(0x80000000)
240*c960b13eSThomas Chou 
241*c960b13eSThomas Chou #define ALTERA_TSE_TX_CMD_STAT_TX_SHIFT16	(0x00040000)
242*c960b13eSThomas Chou #define ALTERA_TSE_TX_CMD_STAT_OMIT_CRC	(0x00020000)
243*c960b13eSThomas Chou 
244*c960b13eSThomas Chou #define ALTERA_TSE_RX_CMD_STAT_RX_SHIFT16	(0x02000000)
245*c960b13eSThomas Chou 
246*c960b13eSThomas Chou #define ALT_TSE_SW_RESET_WATCHDOG_CNTR		10000
247*c960b13eSThomas Chou #define ALT_TSE_SGDMA_BUSY_WATCHDOG_CNTR	90000000
248*c960b13eSThomas Chou 
249*c960b13eSThomas Chou /* Command_Config Register Bit Definitions */
250*c960b13eSThomas Chou 
251*c960b13eSThomas Chou typedef volatile union __alt_tse_command_config {
252*c960b13eSThomas Chou 	unsigned int image;
253*c960b13eSThomas Chou 	struct {
254*c960b13eSThomas Chou 		unsigned int
255*c960b13eSThomas Chou 		 transmit_enable:1,		/* bit 0 */
256*c960b13eSThomas Chou 		 receive_enable:1,		/* bit 1 */
257*c960b13eSThomas Chou 		 pause_frame_xon_gen:1,	/* bit 2 */
258*c960b13eSThomas Chou 		 ethernet_speed:1,		/* bit 3 */
259*c960b13eSThomas Chou 		 promiscuous_enable:1,		/* bit 4 */
260*c960b13eSThomas Chou 		 pad_enable:1,			/* bit 5 */
261*c960b13eSThomas Chou 		 crc_forward:1,		/* bit 6 */
262*c960b13eSThomas Chou 		 pause_frame_forward:1,	/* bit 7 */
263*c960b13eSThomas Chou 		 pause_frame_ignore:1,		/* bit 8 */
264*c960b13eSThomas Chou 		 set_mac_address_on_tx:1,	/* bit 9 */
265*c960b13eSThomas Chou 		 halfduplex_enable:1,		/* bit 10 */
266*c960b13eSThomas Chou 		 excessive_collision:1,	/* bit 11 */
267*c960b13eSThomas Chou 		 late_collision:1,		/* bit 12 */
268*c960b13eSThomas Chou 		 software_reset:1,		/* bit 13 */
269*c960b13eSThomas Chou 		 multicast_hash_mode_sel:1,	/* bit 14 */
270*c960b13eSThomas Chou 		 loopback_enable:1,		/* bit 15 */
271*c960b13eSThomas Chou 		 src_mac_addr_sel_on_tx:3,	/* bit 18:16 */
272*c960b13eSThomas Chou 		 magic_packet_detect:1,	/* bit 19 */
273*c960b13eSThomas Chou 		 sleep_mode_enable:1,		/* bit 20 */
274*c960b13eSThomas Chou 		 wake_up_request:1,		/* bit 21 */
275*c960b13eSThomas Chou 		 pause_frame_xoff_gen:1,	/* bit 22 */
276*c960b13eSThomas Chou 		 control_frame_enable:1,	/* bit 23 */
277*c960b13eSThomas Chou 		 payload_len_chk_disable:1,	/* bit 24 */
278*c960b13eSThomas Chou 		 enable_10mbps_intf:1,		/* bit 25 */
279*c960b13eSThomas Chou 		 rx_error_discard_enable:1,	/* bit 26 */
280*c960b13eSThomas Chou 		 reserved_bits:4,		/* bit 30:27 */
281*c960b13eSThomas Chou 		 self_clear_counter_reset:1;	/* bit 31 */
282*c960b13eSThomas Chou 	} __packed_1_ bits;
283*c960b13eSThomas Chou } __packed_1_ alt_tse_command_config;
284*c960b13eSThomas Chou 
285*c960b13eSThomas Chou /* Tx_Cmd_Stat Register Bit Definitions */
286*c960b13eSThomas Chou 
287*c960b13eSThomas Chou typedef volatile union __alt_tse_tx_cmd_stat {
288*c960b13eSThomas Chou 	unsigned int image;
289*c960b13eSThomas Chou 	struct {
290*c960b13eSThomas Chou 		unsigned int reserved_lsbs:17,	/* bit 16:0  */
291*c960b13eSThomas Chou 		 omit_crc:1,			/* bit 17 */
292*c960b13eSThomas Chou 		 tx_shift16:1,			/* bit 18 */
293*c960b13eSThomas Chou 		 reserved_msbs:13;		/* bit 31:19 */
294*c960b13eSThomas Chou 
295*c960b13eSThomas Chou 	} __packed_1_ bits;
296*c960b13eSThomas Chou } alt_tse_tx_cmd_stat;
297*c960b13eSThomas Chou 
298*c960b13eSThomas Chou /* Rx_Cmd_Stat Register Bit Definitions */
299*c960b13eSThomas Chou 
300*c960b13eSThomas Chou typedef volatile union __alt_tse_rx_cmd_stat {
301*c960b13eSThomas Chou 	unsigned int image;
302*c960b13eSThomas Chou 	struct {
303*c960b13eSThomas Chou 		unsigned int reserved_lsbs:25,	/* bit 24:0  */
304*c960b13eSThomas Chou 		 rx_shift16:1,			/* bit 25 */
305*c960b13eSThomas Chou 		 reserved_msbs:6;		/* bit 31:26 */
306*c960b13eSThomas Chou 
307*c960b13eSThomas Chou 	} __packed_1_ bits;
308*c960b13eSThomas Chou } alt_tse_rx_cmd_stat;
309*c960b13eSThomas Chou 
310*c960b13eSThomas Chou struct alt_tse_mdio {
311*c960b13eSThomas Chou 	unsigned int control;	/*PHY device operation control register */
312*c960b13eSThomas Chou 	unsigned int status;	/*PHY device operation status register */
313*c960b13eSThomas Chou 	unsigned int phy_id1;	/*Bits 31:16 of PHY identifier. */
314*c960b13eSThomas Chou 	unsigned int phy_id2;	/*Bits 15:0 of PHY identifier. */
315*c960b13eSThomas Chou 	unsigned int auto_negotiation_advertisement;
316*c960b13eSThomas Chou 	unsigned int remote_partner_base_page_ability;
317*c960b13eSThomas Chou 
318*c960b13eSThomas Chou 	unsigned int reg6;
319*c960b13eSThomas Chou 	unsigned int reg7;
320*c960b13eSThomas Chou 	unsigned int reg8;
321*c960b13eSThomas Chou 	unsigned int reg9;
322*c960b13eSThomas Chou 	unsigned int rega;
323*c960b13eSThomas Chou 	unsigned int regb;
324*c960b13eSThomas Chou 	unsigned int regc;
325*c960b13eSThomas Chou 	unsigned int regd;
326*c960b13eSThomas Chou 	unsigned int rege;
327*c960b13eSThomas Chou 	unsigned int regf;
328*c960b13eSThomas Chou 	unsigned int reg10;
329*c960b13eSThomas Chou 	unsigned int reg11;
330*c960b13eSThomas Chou 	unsigned int reg12;
331*c960b13eSThomas Chou 	unsigned int reg13;
332*c960b13eSThomas Chou 	unsigned int reg14;
333*c960b13eSThomas Chou 	unsigned int reg15;
334*c960b13eSThomas Chou 	unsigned int reg16;
335*c960b13eSThomas Chou 	unsigned int reg17;
336*c960b13eSThomas Chou 	unsigned int reg18;
337*c960b13eSThomas Chou 	unsigned int reg19;
338*c960b13eSThomas Chou 	unsigned int reg1a;
339*c960b13eSThomas Chou 	unsigned int reg1b;
340*c960b13eSThomas Chou 	unsigned int reg1c;
341*c960b13eSThomas Chou 	unsigned int reg1d;
342*c960b13eSThomas Chou 	unsigned int reg1e;
343*c960b13eSThomas Chou 	unsigned int reg1f;
344*c960b13eSThomas Chou };
345*c960b13eSThomas Chou 
346*c960b13eSThomas Chou /* MAC register Space */
347*c960b13eSThomas Chou 
348*c960b13eSThomas Chou struct alt_tse_mac {
349*c960b13eSThomas Chou 	unsigned int megacore_revision;
350*c960b13eSThomas Chou 	unsigned int scratch_pad;
351*c960b13eSThomas Chou 	alt_tse_command_config command_config;
352*c960b13eSThomas Chou 	unsigned int mac_addr_0;
353*c960b13eSThomas Chou 	unsigned int mac_addr_1;
354*c960b13eSThomas Chou 	unsigned int max_frame_length;
355*c960b13eSThomas Chou 	unsigned int pause_quanta;
356*c960b13eSThomas Chou 	unsigned int rx_sel_empty_threshold;
357*c960b13eSThomas Chou 	unsigned int rx_sel_full_threshold;
358*c960b13eSThomas Chou 	unsigned int tx_sel_empty_threshold;
359*c960b13eSThomas Chou 	unsigned int tx_sel_full_threshold;
360*c960b13eSThomas Chou 	unsigned int rx_almost_empty_threshold;
361*c960b13eSThomas Chou 	unsigned int rx_almost_full_threshold;
362*c960b13eSThomas Chou 	unsigned int tx_almost_empty_threshold;
363*c960b13eSThomas Chou 	unsigned int tx_almost_full_threshold;
364*c960b13eSThomas Chou 	unsigned int mdio_phy0_addr;
365*c960b13eSThomas Chou 	unsigned int mdio_phy1_addr;
366*c960b13eSThomas Chou 
367*c960b13eSThomas Chou 	/* only if 100/1000 BaseX PCS, reserved otherwise */
368*c960b13eSThomas Chou 	unsigned int reservedx44[5];
369*c960b13eSThomas Chou 
370*c960b13eSThomas Chou 	unsigned int reg_read_access_status;
371*c960b13eSThomas Chou 	unsigned int min_tx_ipg_length;
372*c960b13eSThomas Chou 
373*c960b13eSThomas Chou 	/* IEEE 802.3 oEntity Managed Object Support */
374*c960b13eSThomas Chou 	unsigned int aMACID_1;	/*The MAC addresses */
375*c960b13eSThomas Chou 	unsigned int aMACID_2;
376*c960b13eSThomas Chou 	unsigned int aFramesTransmittedOK;
377*c960b13eSThomas Chou 	unsigned int aFramesReceivedOK;
378*c960b13eSThomas Chou 	unsigned int aFramesCheckSequenceErrors;
379*c960b13eSThomas Chou 	unsigned int aAlignmentErrors;
380*c960b13eSThomas Chou 	unsigned int aOctetsTransmittedOK;
381*c960b13eSThomas Chou 	unsigned int aOctetsReceivedOK;
382*c960b13eSThomas Chou 
383*c960b13eSThomas Chou 	/* IEEE 802.3 oPausedEntity Managed Object Support */
384*c960b13eSThomas Chou 	unsigned int aTxPAUSEMACCtrlFrames;
385*c960b13eSThomas Chou 	unsigned int aRxPAUSEMACCtrlFrames;
386*c960b13eSThomas Chou 
387*c960b13eSThomas Chou 	/* IETF MIB (MIB-II) Object Support */
388*c960b13eSThomas Chou 	unsigned int ifInErrors;
389*c960b13eSThomas Chou 	unsigned int ifOutErrors;
390*c960b13eSThomas Chou 	unsigned int ifInUcastPkts;
391*c960b13eSThomas Chou 	unsigned int ifInMulticastPkts;
392*c960b13eSThomas Chou 	unsigned int ifInBroadcastPkts;
393*c960b13eSThomas Chou 	unsigned int ifOutDiscards;
394*c960b13eSThomas Chou 	unsigned int ifOutUcastPkts;
395*c960b13eSThomas Chou 	unsigned int ifOutMulticastPkts;
396*c960b13eSThomas Chou 	unsigned int ifOutBroadcastPkts;
397*c960b13eSThomas Chou 
398*c960b13eSThomas Chou 	/* IETF RMON MIB Object Support */
399*c960b13eSThomas Chou 	unsigned int etherStatsDropEvent;
400*c960b13eSThomas Chou 	unsigned int etherStatsOctets;
401*c960b13eSThomas Chou 	unsigned int etherStatsPkts;
402*c960b13eSThomas Chou 	unsigned int etherStatsUndersizePkts;
403*c960b13eSThomas Chou 	unsigned int etherStatsOversizePkts;
404*c960b13eSThomas Chou 	unsigned int etherStatsPkts64Octets;
405*c960b13eSThomas Chou 	unsigned int etherStatsPkts65to127Octets;
406*c960b13eSThomas Chou 	unsigned int etherStatsPkts128to255Octets;
407*c960b13eSThomas Chou 	unsigned int etherStatsPkts256to511Octets;
408*c960b13eSThomas Chou 	unsigned int etherStatsPkts512to1023Octets;
409*c960b13eSThomas Chou 	unsigned int etherStatsPkts1024to1518Octets;
410*c960b13eSThomas Chou 
411*c960b13eSThomas Chou 	unsigned int etherStatsPkts1519toXOctets;
412*c960b13eSThomas Chou 	unsigned int etherStatsJabbers;
413*c960b13eSThomas Chou 	unsigned int etherStatsFragments;
414*c960b13eSThomas Chou 
415*c960b13eSThomas Chou 	unsigned int reservedxE4;
416*c960b13eSThomas Chou 
417*c960b13eSThomas Chou 	/*FIFO control register. */
418*c960b13eSThomas Chou 	alt_tse_tx_cmd_stat tx_cmd_stat;
419*c960b13eSThomas Chou 	alt_tse_rx_cmd_stat rx_cmd_stat;
420*c960b13eSThomas Chou 
421*c960b13eSThomas Chou 	unsigned int ipaccTxConf;
422*c960b13eSThomas Chou 	unsigned int ipaccRxConf;
423*c960b13eSThomas Chou 	unsigned int ipaccRxStat;
424*c960b13eSThomas Chou 	unsigned int ipaccRxStatSum;
425*c960b13eSThomas Chou 
426*c960b13eSThomas Chou 	/*Multicast address resolution table */
427*c960b13eSThomas Chou 	unsigned int hash_table[64];
428*c960b13eSThomas Chou 
429*c960b13eSThomas Chou 	/*Registers 0 to 31 within PHY device 0/1 */
430*c960b13eSThomas Chou 	struct alt_tse_mdio mdio_phy0;
431*c960b13eSThomas Chou 	struct alt_tse_mdio mdio_phy1;
432*c960b13eSThomas Chou 
433*c960b13eSThomas Chou 	/*4 Supplemental MAC Addresses */
434*c960b13eSThomas Chou 	unsigned int supp_mac_addr_0_0;
435*c960b13eSThomas Chou 	unsigned int supp_mac_addr_0_1;
436*c960b13eSThomas Chou 	unsigned int supp_mac_addr_1_0;
437*c960b13eSThomas Chou 	unsigned int supp_mac_addr_1_1;
438*c960b13eSThomas Chou 	unsigned int supp_mac_addr_2_0;
439*c960b13eSThomas Chou 	unsigned int supp_mac_addr_2_1;
440*c960b13eSThomas Chou 	unsigned int supp_mac_addr_3_0;
441*c960b13eSThomas Chou 	unsigned int supp_mac_addr_3_1;
442*c960b13eSThomas Chou 
443*c960b13eSThomas Chou 	unsigned int reservedx320[56];
444*c960b13eSThomas Chou };
445*c960b13eSThomas Chou 
446*c960b13eSThomas Chou /* flags: TSE MII modes */
447*c960b13eSThomas Chou /* GMII/MII	= 0 */
448*c960b13eSThomas Chou /* RGMII	= 1 */
449*c960b13eSThomas Chou /* RGMII_ID	= 2 */
450*c960b13eSThomas Chou /* RGMII_TXID	= 3 */
451*c960b13eSThomas Chou /* RGMII_RXID	= 4 */
452*c960b13eSThomas Chou /* SGMII	= 5 */
453*c960b13eSThomas Chou struct altera_tse_priv {
454*c960b13eSThomas Chou 	char devname[16];
455*c960b13eSThomas Chou 	volatile struct alt_tse_mac *mac_dev;
456*c960b13eSThomas Chou 	volatile struct alt_sgdma_registers *sgdma_rx;
457*c960b13eSThomas Chou 	volatile struct alt_sgdma_registers *sgdma_tx;
458*c960b13eSThomas Chou 	unsigned int rx_sgdma_irq;
459*c960b13eSThomas Chou 	unsigned int tx_sgdma_irq;
460*c960b13eSThomas Chou 	unsigned int has_descriptor_mem;
461*c960b13eSThomas Chou 	unsigned int descriptor_mem_base;
462*c960b13eSThomas Chou 	unsigned int descriptor_mem_size;
463*c960b13eSThomas Chou 	volatile struct alt_sgdma_descriptor *rx_desc;
464*c960b13eSThomas Chou 	volatile struct alt_sgdma_descriptor *tx_desc;
465*c960b13eSThomas Chou 	volatile unsigned char *rx_buf;
466*c960b13eSThomas Chou 	struct phy_info *phyinfo;
467*c960b13eSThomas Chou 	unsigned int phyaddr;
468*c960b13eSThomas Chou 	unsigned int flags;
469*c960b13eSThomas Chou 	unsigned int link;
470*c960b13eSThomas Chou 	unsigned int duplexity;
471*c960b13eSThomas Chou 	unsigned int speed;
472*c960b13eSThomas Chou };
473*c960b13eSThomas Chou 
474*c960b13eSThomas Chou /* Phy stuff continued */
475*c960b13eSThomas Chou /*
476*c960b13eSThomas Chou  * struct phy_cmd:  A command for reading or writing a PHY register
477*c960b13eSThomas Chou  *
478*c960b13eSThomas Chou  * mii_reg:  The register to read or write
479*c960b13eSThomas Chou  *
480*c960b13eSThomas Chou  * mii_data:  For writes, the value to put in the register.
481*c960b13eSThomas Chou  *	A value of -1 indicates this is a read.
482*c960b13eSThomas Chou  *
483*c960b13eSThomas Chou  * funct: A function pointer which is invoked for each command.
484*c960b13eSThomas Chou  *	For reads, this function will be passed the value read
485*c960b13eSThomas Chou  *	from the PHY, and process it.
486*c960b13eSThomas Chou  *	For writes, the result of this function will be written
487*c960b13eSThomas Chou  *	to the PHY register
488*c960b13eSThomas Chou  */
489*c960b13eSThomas Chou struct phy_cmd {
490*c960b13eSThomas Chou 	uint mii_reg;
491*c960b13eSThomas Chou 	uint mii_data;
492*c960b13eSThomas Chou 	uint(*funct) (uint mii_reg, struct altera_tse_priv *priv);
493*c960b13eSThomas Chou };
494*c960b13eSThomas Chou #endif /* _ALTERA_TSE_H_ */
495