xref: /openbmc/u-boot/include/tsec.h (revision 83d290c56fab2d38cd1ab4c4cc7099559c1d5046)
1*83d290c5STom Rini /* SPDX-License-Identifier: GPL-2.0+ */
2dd3d1f56SAndy Fleming /*
3dd3d1f56SAndy Fleming  *  tsec.h
4dd3d1f56SAndy Fleming  *
5dd3d1f56SAndy Fleming  *  Driver for the Motorola Triple Speed Ethernet Controller
6dd3d1f56SAndy Fleming  *
7aec84bf6SClaudiu Manoil  * Copyright 2004, 2007, 2009, 2011, 2013 Freescale Semiconductor, Inc.
8dd3d1f56SAndy Fleming  * (C) Copyright 2003, Motorola, Inc.
9dd3d1f56SAndy Fleming  * maintained by Xianghua Xiao (x.xiao@motorola.com)
10dd3d1f56SAndy Fleming  * author Andy Fleming
11dd3d1f56SAndy Fleming  */
12dd3d1f56SAndy Fleming 
13dd3d1f56SAndy Fleming #ifndef __TSEC_H
14dd3d1f56SAndy Fleming #define __TSEC_H
15dd3d1f56SAndy Fleming 
16dd3d1f56SAndy Fleming #include <net.h>
17dd3d1f56SAndy Fleming #include <config.h>
18063c1263SAndy Fleming #include <phy.h>
19dd3d1f56SAndy Fleming 
209a1d6af5SBin Meng #ifndef CONFIG_DM_ETH
219a1d6af5SBin Meng 
2273fb5838SYork Sun #ifdef CONFIG_ARCH_LS1021A
2352d00a81SAlison Wang #define TSEC_SIZE		0x40000
2452d00a81SAlison Wang #define TSEC_MDIO_OFFSET	0x40000
2552d00a81SAlison Wang #else
26dd3d1f56SAndy Fleming #define TSEC_SIZE 		0x01000
27b9e186fcSSandeep Gopalpet #define TSEC_MDIO_OFFSET	0x01000
2852d00a81SAlison Wang #endif
29dd3d1f56SAndy Fleming 
3040ac3d46SAndy Fleming #define CONFIG_SYS_MDIO_BASE_ADDR (MDIO_BASE_ADDR + 0x520)
31063c1263SAndy Fleming 
32aec84bf6SClaudiu Manoil #define TSEC_GET_REGS(num, offset) \
33aec84bf6SClaudiu Manoil 	(struct tsec __iomem *)\
34aec84bf6SClaudiu Manoil 	(TSEC_BASE_ADDR + (((num) - 1) * (offset)))
35aec84bf6SClaudiu Manoil 
36aec84bf6SClaudiu Manoil #define TSEC_GET_REGS_BASE(num) \
37aec84bf6SClaudiu Manoil 	TSEC_GET_REGS((num), TSEC_SIZE)
38aec84bf6SClaudiu Manoil 
39aec84bf6SClaudiu Manoil #define TSEC_GET_MDIO_REGS(num, offset) \
40aec84bf6SClaudiu Manoil 	(struct tsec_mii_mng __iomem *)\
41aec84bf6SClaudiu Manoil 	(CONFIG_SYS_MDIO_BASE_ADDR  + ((num) - 1) * (offset))
42aec84bf6SClaudiu Manoil 
43aec84bf6SClaudiu Manoil #define TSEC_GET_MDIO_REGS_BASE(num) \
44aec84bf6SClaudiu Manoil 	TSEC_GET_MDIO_REGS((num), TSEC_MDIO_OFFSET)
45aec84bf6SClaudiu Manoil 
46063c1263SAndy Fleming #define DEFAULT_MII_NAME "FSL_MDIO"
47063c1263SAndy Fleming 
4875b9d4aeSAndy Fleming #define STD_TSEC_INFO(num) \
4975b9d4aeSAndy Fleming {			\
50aec84bf6SClaudiu Manoil 	.regs = TSEC_GET_REGS_BASE(num), \
51aec84bf6SClaudiu Manoil 	.miiregs_sgmii = TSEC_GET_MDIO_REGS_BASE(num), \
5275b9d4aeSAndy Fleming 	.devname = CONFIG_TSEC##num##_NAME, \
5375b9d4aeSAndy Fleming 	.phyaddr = TSEC##num##_PHY_ADDR, \
54063c1263SAndy Fleming 	.flags = TSEC##num##_FLAGS, \
55063c1263SAndy Fleming 	.mii_devname = DEFAULT_MII_NAME \
5675b9d4aeSAndy Fleming }
5775b9d4aeSAndy Fleming 
5875b9d4aeSAndy Fleming #define SET_STD_TSEC_INFO(x, num) \
5975b9d4aeSAndy Fleming {			\
60aec84bf6SClaudiu Manoil 	x.regs = TSEC_GET_REGS_BASE(num); \
61aec84bf6SClaudiu Manoil 	x.miiregs_sgmii = TSEC_GET_MDIO_REGS_BASE(num); \
6275b9d4aeSAndy Fleming 	x.devname = CONFIG_TSEC##num##_NAME; \
6375b9d4aeSAndy Fleming 	x.phyaddr = TSEC##num##_PHY_ADDR; \
6475b9d4aeSAndy Fleming 	x.flags = TSEC##num##_FLAGS;\
65063c1263SAndy Fleming 	x.mii_devname = DEFAULT_MII_NAME;\
6675b9d4aeSAndy Fleming }
6775b9d4aeSAndy Fleming 
689a1d6af5SBin Meng #endif /* CONFIG_DM_ETH */
699a1d6af5SBin Meng 
70dd3d1f56SAndy Fleming #define MAC_ADDR_LEN		6
71dd3d1f56SAndy Fleming 
72dd3d1f56SAndy Fleming /* #define TSEC_TIMEOUT	1000000 */
73dd3d1f56SAndy Fleming #define TSEC_TIMEOUT		1000
74dd3d1f56SAndy Fleming #define TOUT_LOOP		1000000
75dd3d1f56SAndy Fleming 
762abe361cSAndy Fleming /* TBI register addresses */
772abe361cSAndy Fleming #define TBI_CR			0x00
782abe361cSAndy Fleming #define TBI_SR			0x01
792abe361cSAndy Fleming #define TBI_ANA			0x04
802abe361cSAndy Fleming #define TBI_ANLPBPA		0x05
812abe361cSAndy Fleming #define TBI_ANEX		0x06
822abe361cSAndy Fleming #define TBI_TBICON		0x11
832abe361cSAndy Fleming 
842abe361cSAndy Fleming /* TBI MDIO register bit fields*/
852abe361cSAndy Fleming #define TBICON_CLK_SELECT	0x0020
862abe361cSAndy Fleming #define TBIANA_ASYMMETRIC_PAUSE	0x0100
872abe361cSAndy Fleming #define TBIANA_SYMMETRIC_PAUSE	0x0080
882abe361cSAndy Fleming #define TBIANA_HALF_DUPLEX	0x0040
892abe361cSAndy Fleming #define TBIANA_FULL_DUPLEX	0x0020
902abe361cSAndy Fleming #define TBICR_PHY_RESET		0x8000
912abe361cSAndy Fleming #define TBICR_ANEG_ENABLE	0x1000
922abe361cSAndy Fleming #define TBICR_RESTART_ANEG	0x0200
932abe361cSAndy Fleming #define TBICR_FULL_DUPLEX	0x0100
942abe361cSAndy Fleming #define TBICR_SPEED1_SET	0x0040
952abe361cSAndy Fleming 
96dd3d1f56SAndy Fleming /* MAC register bits */
97dd3d1f56SAndy Fleming #define MACCFG1_SOFT_RESET	0x80000000
98dd3d1f56SAndy Fleming #define MACCFG1_RESET_RX_MC	0x00080000
99dd3d1f56SAndy Fleming #define MACCFG1_RESET_TX_MC	0x00040000
100dd3d1f56SAndy Fleming #define MACCFG1_RESET_RX_FUN	0x00020000
101dd3d1f56SAndy Fleming #define MACCFG1_RESET_TX_FUN	0x00010000
102dd3d1f56SAndy Fleming #define MACCFG1_LOOPBACK	0x00000100
103dd3d1f56SAndy Fleming #define MACCFG1_RX_FLOW		0x00000020
104dd3d1f56SAndy Fleming #define MACCFG1_TX_FLOW		0x00000010
105dd3d1f56SAndy Fleming #define MACCFG1_SYNCD_RX_EN	0x00000008
106dd3d1f56SAndy Fleming #define MACCFG1_RX_EN		0x00000004
107dd3d1f56SAndy Fleming #define MACCFG1_SYNCD_TX_EN	0x00000002
108dd3d1f56SAndy Fleming #define MACCFG1_TX_EN		0x00000001
109dd3d1f56SAndy Fleming 
110dd3d1f56SAndy Fleming #define MACCFG2_INIT_SETTINGS	0x00007205
111dd3d1f56SAndy Fleming #define MACCFG2_FULL_DUPLEX	0x00000001
112dd3d1f56SAndy Fleming #define MACCFG2_IF		0x00000300
113dd3d1f56SAndy Fleming #define MACCFG2_GMII		0x00000200
114dd3d1f56SAndy Fleming #define MACCFG2_MII		0x00000100
115dd3d1f56SAndy Fleming 
116dd3d1f56SAndy Fleming #define ECNTRL_INIT_SETTINGS	0x00001000
117dd3d1f56SAndy Fleming #define ECNTRL_TBI_MODE		0x00000020
118063c1263SAndy Fleming #define ECNTRL_REDUCED_MODE	0x00000010
119dd3d1f56SAndy Fleming #define ECNTRL_R100		0x00000008
120063c1263SAndy Fleming #define ECNTRL_REDUCED_MII_MODE	0x00000004
121dd3d1f56SAndy Fleming #define ECNTRL_SGMII_MODE	0x00000002
122dd3d1f56SAndy Fleming 
1236d0f6bcfSJean-Christophe PLAGNIOL-VILLARD #ifndef CONFIG_SYS_TBIPA_VALUE
1246d0f6bcfSJean-Christophe PLAGNIOL-VILLARD # define CONFIG_SYS_TBIPA_VALUE	0x1f
125dd3d1f56SAndy Fleming #endif
126dd3d1f56SAndy Fleming 
127dd3d1f56SAndy Fleming #define MRBLR_INIT_SETTINGS	PKTSIZE_ALIGN
128dd3d1f56SAndy Fleming 
129dd3d1f56SAndy Fleming #define MINFLR_INIT_SETTINGS	0x00000040
130dd3d1f56SAndy Fleming 
131dd3d1f56SAndy Fleming #define DMACTRL_INIT_SETTINGS	0x000000c3
132dd3d1f56SAndy Fleming #define DMACTRL_GRS		0x00000010
133dd3d1f56SAndy Fleming #define DMACTRL_GTS		0x00000008
13452d00a81SAlison Wang #define DMACTRL_LE		0x00008000
135dd3d1f56SAndy Fleming 
136dd3d1f56SAndy Fleming #define TSTAT_CLEAR_THALT	0x80000000
137dd3d1f56SAndy Fleming #define RSTAT_CLEAR_RHALT	0x00800000
138dd3d1f56SAndy Fleming 
139dd3d1f56SAndy Fleming #define IEVENT_INIT_CLEAR	0xffffffff
140dd3d1f56SAndy Fleming #define IEVENT_BABR		0x80000000
141dd3d1f56SAndy Fleming #define IEVENT_RXC		0x40000000
142dd3d1f56SAndy Fleming #define IEVENT_BSY		0x20000000
143dd3d1f56SAndy Fleming #define IEVENT_EBERR		0x10000000
144dd3d1f56SAndy Fleming #define IEVENT_MSRO		0x04000000
145dd3d1f56SAndy Fleming #define IEVENT_GTSC		0x02000000
146dd3d1f56SAndy Fleming #define IEVENT_BABT		0x01000000
147dd3d1f56SAndy Fleming #define IEVENT_TXC		0x00800000
148dd3d1f56SAndy Fleming #define IEVENT_TXE		0x00400000
149dd3d1f56SAndy Fleming #define IEVENT_TXB		0x00200000
150dd3d1f56SAndy Fleming #define IEVENT_TXF		0x00100000
151dd3d1f56SAndy Fleming #define IEVENT_IE		0x00080000
152dd3d1f56SAndy Fleming #define IEVENT_LC		0x00040000
153dd3d1f56SAndy Fleming #define IEVENT_CRL		0x00020000
154dd3d1f56SAndy Fleming #define IEVENT_XFUN		0x00010000
155dd3d1f56SAndy Fleming #define IEVENT_RXB0		0x00008000
156dd3d1f56SAndy Fleming #define IEVENT_GRSC		0x00000100
157dd3d1f56SAndy Fleming #define IEVENT_RXF0		0x00000080
158dd3d1f56SAndy Fleming 
159dd3d1f56SAndy Fleming #define IMASK_INIT_CLEAR	0x00000000
160dd3d1f56SAndy Fleming #define IMASK_TXEEN		0x00400000
161dd3d1f56SAndy Fleming #define IMASK_TXBEN		0x00200000
162dd3d1f56SAndy Fleming #define IMASK_TXFEN		0x00100000
163dd3d1f56SAndy Fleming #define IMASK_RXFEN0		0x00000080
164dd3d1f56SAndy Fleming 
165dd3d1f56SAndy Fleming /* Default Attribute fields */
166dd3d1f56SAndy Fleming #define ATTR_INIT_SETTINGS	0x000000c0
167dd3d1f56SAndy Fleming #define ATTRELI_INIT_SETTINGS	0x00000000
168dd3d1f56SAndy Fleming 
169dd3d1f56SAndy Fleming /* TxBD status field bits */
170dd3d1f56SAndy Fleming #define TXBD_READY		0x8000
171dd3d1f56SAndy Fleming #define TXBD_PADCRC		0x4000
172dd3d1f56SAndy Fleming #define TXBD_WRAP		0x2000
173dd3d1f56SAndy Fleming #define TXBD_INTERRUPT		0x1000
174dd3d1f56SAndy Fleming #define TXBD_LAST		0x0800
175dd3d1f56SAndy Fleming #define TXBD_CRC		0x0400
176dd3d1f56SAndy Fleming #define TXBD_DEF		0x0200
177dd3d1f56SAndy Fleming #define TXBD_HUGEFRAME		0x0080
178dd3d1f56SAndy Fleming #define TXBD_LATECOLLISION	0x0080
179dd3d1f56SAndy Fleming #define TXBD_RETRYLIMIT		0x0040
180dd3d1f56SAndy Fleming #define TXBD_RETRYCOUNTMASK	0x003c
181dd3d1f56SAndy Fleming #define TXBD_UNDERRUN		0x0002
182dd3d1f56SAndy Fleming #define TXBD_STATS		0x03ff
183dd3d1f56SAndy Fleming 
184dd3d1f56SAndy Fleming /* RxBD status field bits */
185dd3d1f56SAndy Fleming #define RXBD_EMPTY		0x8000
186dd3d1f56SAndy Fleming #define RXBD_RO1		0x4000
187dd3d1f56SAndy Fleming #define RXBD_WRAP		0x2000
188dd3d1f56SAndy Fleming #define RXBD_INTERRUPT		0x1000
189dd3d1f56SAndy Fleming #define RXBD_LAST		0x0800
190dd3d1f56SAndy Fleming #define RXBD_FIRST		0x0400
191dd3d1f56SAndy Fleming #define RXBD_MISS		0x0100
192dd3d1f56SAndy Fleming #define RXBD_BROADCAST		0x0080
193dd3d1f56SAndy Fleming #define RXBD_MULTICAST		0x0040
194dd3d1f56SAndy Fleming #define RXBD_LARGE		0x0020
195dd3d1f56SAndy Fleming #define RXBD_NONOCTET		0x0010
196dd3d1f56SAndy Fleming #define RXBD_SHORT		0x0008
197dd3d1f56SAndy Fleming #define RXBD_CRCERR		0x0004
198dd3d1f56SAndy Fleming #define RXBD_OVERRUN		0x0002
199dd3d1f56SAndy Fleming #define RXBD_TRUNCATED		0x0001
200dd3d1f56SAndy Fleming #define RXBD_STATS		0x003f
201dd3d1f56SAndy Fleming 
2029c9141fdSClaudiu Manoil struct txbd8 {
2039c9141fdSClaudiu Manoil 	uint16_t status;	/* Status Fields */
2049c9141fdSClaudiu Manoil 	uint16_t length;	/* Buffer length */
2059c9141fdSClaudiu Manoil 	uint32_t bufptr;	/* Buffer Pointer */
2069c9141fdSClaudiu Manoil };
207dd3d1f56SAndy Fleming 
2089c9141fdSClaudiu Manoil struct rxbd8 {
2099c9141fdSClaudiu Manoil 	uint16_t status;	/* Status Fields */
2109c9141fdSClaudiu Manoil 	uint16_t length;	/* Buffer Length */
2119c9141fdSClaudiu Manoil 	uint32_t bufptr;	/* Buffer Pointer */
2129c9141fdSClaudiu Manoil };
213dd3d1f56SAndy Fleming 
21482ef75caSClaudiu Manoil struct tsec_rmon_mib {
215dd3d1f56SAndy Fleming 	/* Transmit and Receive Counters */
21682ef75caSClaudiu Manoil 	u32	tr64;		/* Tx/Rx 64-byte Frame Counter */
21782ef75caSClaudiu Manoil 	u32	tr127;		/* Tx/Rx 65-127 byte Frame Counter */
21882ef75caSClaudiu Manoil 	u32	tr255;		/* Tx/Rx 128-255 byte Frame Counter */
21982ef75caSClaudiu Manoil 	u32	tr511;		/* Tx/Rx 256-511 byte Frame Counter */
22082ef75caSClaudiu Manoil 	u32	tr1k;		/* Tx/Rx 512-1023 byte Frame Counter */
22182ef75caSClaudiu Manoil 	u32	trmax;		/* Tx/Rx 1024-1518 byte Frame Counter */
22282ef75caSClaudiu Manoil 	u32	trmgv;		/* Tx/Rx 1519-1522 byte Good VLAN Frame */
223dd3d1f56SAndy Fleming 	/* Receive Counters */
22482ef75caSClaudiu Manoil 	u32	rbyt;		/* Receive Byte Counter */
22582ef75caSClaudiu Manoil 	u32	rpkt;		/* Receive Packet Counter */
22682ef75caSClaudiu Manoil 	u32	rfcs;		/* Receive FCS Error Counter */
22782ef75caSClaudiu Manoil 	u32	rmca;		/* Receive Multicast Packet (Counter) */
22882ef75caSClaudiu Manoil 	u32	rbca;		/* Receive Broadcast Packet */
22982ef75caSClaudiu Manoil 	u32	rxcf;		/* Receive Control Frame Packet */
23082ef75caSClaudiu Manoil 	u32	rxpf;		/* Receive Pause Frame Packet */
23182ef75caSClaudiu Manoil 	u32	rxuo;		/* Receive Unknown OP Code */
23282ef75caSClaudiu Manoil 	u32	raln;		/* Receive Alignment Error */
23382ef75caSClaudiu Manoil 	u32	rflr;		/* Receive Frame Length Error */
23482ef75caSClaudiu Manoil 	u32	rcde;		/* Receive Code Error */
23582ef75caSClaudiu Manoil 	u32	rcse;		/* Receive Carrier Sense Error */
23682ef75caSClaudiu Manoil 	u32	rund;		/* Receive Undersize Packet */
23782ef75caSClaudiu Manoil 	u32	rovr;		/* Receive Oversize Packet */
23882ef75caSClaudiu Manoil 	u32	rfrg;		/* Receive Fragments */
23982ef75caSClaudiu Manoil 	u32	rjbr;		/* Receive Jabber */
24082ef75caSClaudiu Manoil 	u32	rdrp;		/* Receive Drop */
241dd3d1f56SAndy Fleming 	/* Transmit Counters */
24282ef75caSClaudiu Manoil 	u32	tbyt;		/* Transmit Byte Counter */
24382ef75caSClaudiu Manoil 	u32	tpkt;		/* Transmit Packet */
24482ef75caSClaudiu Manoil 	u32	tmca;		/* Transmit Multicast Packet */
24582ef75caSClaudiu Manoil 	u32	tbca;		/* Transmit Broadcast Packet */
24682ef75caSClaudiu Manoil 	u32	txpf;		/* Transmit Pause Control Frame */
24782ef75caSClaudiu Manoil 	u32	tdfr;		/* Transmit Deferral Packet */
24882ef75caSClaudiu Manoil 	u32	tedf;		/* Transmit Excessive Deferral Packet */
24982ef75caSClaudiu Manoil 	u32	tscl;		/* Transmit Single Collision Packet */
250dd3d1f56SAndy Fleming 	/* (0x2_n700) */
25182ef75caSClaudiu Manoil 	u32	tmcl;		/* Transmit Multiple Collision Packet */
25282ef75caSClaudiu Manoil 	u32	tlcl;		/* Transmit Late Collision Packet */
25382ef75caSClaudiu Manoil 	u32	txcl;		/* Transmit Excessive Collision Packet */
25482ef75caSClaudiu Manoil 	u32	tncl;		/* Transmit Total Collision */
255dd3d1f56SAndy Fleming 
25682ef75caSClaudiu Manoil 	u32	res2;
257dd3d1f56SAndy Fleming 
25882ef75caSClaudiu Manoil 	u32	tdrp;		/* Transmit Drop Frame */
25982ef75caSClaudiu Manoil 	u32	tjbr;		/* Transmit Jabber Frame */
26082ef75caSClaudiu Manoil 	u32	tfcs;		/* Transmit FCS Error */
26182ef75caSClaudiu Manoil 	u32	txcf;		/* Transmit Control Frame */
26282ef75caSClaudiu Manoil 	u32	tovr;		/* Transmit Oversize Frame */
26382ef75caSClaudiu Manoil 	u32	tund;		/* Transmit Undersize Frame */
26482ef75caSClaudiu Manoil 	u32	tfrg;		/* Transmit Fragments Frame */
265dd3d1f56SAndy Fleming 	/* General Registers */
26682ef75caSClaudiu Manoil 	u32	car1;		/* Carry Register One */
26782ef75caSClaudiu Manoil 	u32	car2;		/* Carry Register Two */
26882ef75caSClaudiu Manoil 	u32	cam1;		/* Carry Register One Mask */
26982ef75caSClaudiu Manoil 	u32	cam2;		/* Carry Register Two Mask */
27082ef75caSClaudiu Manoil };
271dd3d1f56SAndy Fleming 
27282ef75caSClaudiu Manoil struct tsec_hash_regs {
27382ef75caSClaudiu Manoil 	u32	iaddr0;		/* Individual Address Register 0 */
27482ef75caSClaudiu Manoil 	u32	iaddr1;		/* Individual Address Register 1 */
27582ef75caSClaudiu Manoil 	u32	iaddr2;		/* Individual Address Register 2 */
27682ef75caSClaudiu Manoil 	u32	iaddr3;		/* Individual Address Register 3 */
27782ef75caSClaudiu Manoil 	u32	iaddr4;		/* Individual Address Register 4 */
27882ef75caSClaudiu Manoil 	u32	iaddr5;		/* Individual Address Register 5 */
27982ef75caSClaudiu Manoil 	u32	iaddr6;		/* Individual Address Register 6 */
28082ef75caSClaudiu Manoil 	u32	iaddr7;		/* Individual Address Register 7 */
28182ef75caSClaudiu Manoil 	u32	res1[24];
28282ef75caSClaudiu Manoil 	u32	gaddr0;		/* Group Address Register 0 */
28382ef75caSClaudiu Manoil 	u32	gaddr1;		/* Group Address Register 1 */
28482ef75caSClaudiu Manoil 	u32	gaddr2;		/* Group Address Register 2 */
28582ef75caSClaudiu Manoil 	u32	gaddr3;		/* Group Address Register 3 */
28682ef75caSClaudiu Manoil 	u32	gaddr4;		/* Group Address Register 4 */
28782ef75caSClaudiu Manoil 	u32	gaddr5;		/* Group Address Register 5 */
28882ef75caSClaudiu Manoil 	u32	gaddr6;		/* Group Address Register 6 */
28982ef75caSClaudiu Manoil 	u32	gaddr7;		/* Group Address Register 7 */
29082ef75caSClaudiu Manoil 	u32	res2[24];
29182ef75caSClaudiu Manoil };
292dd3d1f56SAndy Fleming 
293aec84bf6SClaudiu Manoil struct tsec {
294dd3d1f56SAndy Fleming 	/* General Control and Status Registers (0x2_n000) */
29582ef75caSClaudiu Manoil 	u32	res000[4];
296dd3d1f56SAndy Fleming 
29782ef75caSClaudiu Manoil 	u32	ievent;		/* Interrupt Event */
29882ef75caSClaudiu Manoil 	u32	imask;		/* Interrupt Mask */
29982ef75caSClaudiu Manoil 	u32	edis;		/* Error Disabled */
30082ef75caSClaudiu Manoil 	u32	res01c;
30182ef75caSClaudiu Manoil 	u32	ecntrl;		/* Ethernet Control */
30282ef75caSClaudiu Manoil 	u32	minflr;		/* Minimum Frame Length */
30382ef75caSClaudiu Manoil 	u32	ptv;		/* Pause Time Value */
30482ef75caSClaudiu Manoil 	u32	dmactrl;	/* DMA Control */
30582ef75caSClaudiu Manoil 	u32	tbipa;		/* TBI PHY Address */
306dd3d1f56SAndy Fleming 
30782ef75caSClaudiu Manoil 	u32	res034[3];
30882ef75caSClaudiu Manoil 	u32	res040[48];
309dd3d1f56SAndy Fleming 
310dd3d1f56SAndy Fleming 	/* Transmit Control and Status Registers (0x2_n100) */
31182ef75caSClaudiu Manoil 	u32	tctrl;		/* Transmit Control */
31282ef75caSClaudiu Manoil 	u32	tstat;		/* Transmit Status */
31382ef75caSClaudiu Manoil 	u32	res108;
31482ef75caSClaudiu Manoil 	u32	tbdlen;		/* Tx BD Data Length */
31582ef75caSClaudiu Manoil 	u32	res110[5];
31682ef75caSClaudiu Manoil 	u32	ctbptr;		/* Current TxBD Pointer */
31782ef75caSClaudiu Manoil 	u32	res128[23];
31882ef75caSClaudiu Manoil 	u32	tbptr;		/* TxBD Pointer */
31982ef75caSClaudiu Manoil 	u32	res188[30];
320dd3d1f56SAndy Fleming 	/* (0x2_n200) */
32182ef75caSClaudiu Manoil 	u32	res200;
32282ef75caSClaudiu Manoil 	u32	tbase;		/* TxBD Base Address */
32382ef75caSClaudiu Manoil 	u32	res208[42];
32482ef75caSClaudiu Manoil 	u32	ostbd;		/* Out of Sequence TxBD */
32582ef75caSClaudiu Manoil 	u32	ostbdp;		/* Out of Sequence Tx Data Buffer Pointer */
32682ef75caSClaudiu Manoil 	u32	res2b8[18];
327dd3d1f56SAndy Fleming 
328dd3d1f56SAndy Fleming 	/* Receive Control and Status Registers (0x2_n300) */
32982ef75caSClaudiu Manoil 	u32	rctrl;		/* Receive Control */
33082ef75caSClaudiu Manoil 	u32	rstat;		/* Receive Status */
33182ef75caSClaudiu Manoil 	u32	res308;
33282ef75caSClaudiu Manoil 	u32	rbdlen;		/* RxBD Data Length */
33382ef75caSClaudiu Manoil 	u32	res310[4];
33482ef75caSClaudiu Manoil 	u32	res320;
33582ef75caSClaudiu Manoil 	u32	crbptr;		/* Current Receive Buffer Pointer */
33682ef75caSClaudiu Manoil 	u32	res328[6];
33782ef75caSClaudiu Manoil 	u32	mrblr;		/* Maximum Receive Buffer Length */
33882ef75caSClaudiu Manoil 	u32	res344[16];
33982ef75caSClaudiu Manoil 	u32	rbptr;		/* RxBD Pointer */
34082ef75caSClaudiu Manoil 	u32	res388[30];
341dd3d1f56SAndy Fleming 	/* (0x2_n400) */
34282ef75caSClaudiu Manoil 	u32	res400;
34382ef75caSClaudiu Manoil 	u32	rbase;		/* RxBD Base Address */
34482ef75caSClaudiu Manoil 	u32	res408[62];
345dd3d1f56SAndy Fleming 
346dd3d1f56SAndy Fleming 	/* MAC Registers (0x2_n500) */
34782ef75caSClaudiu Manoil 	u32	maccfg1;	/* MAC Configuration #1 */
34882ef75caSClaudiu Manoil 	u32	maccfg2;	/* MAC Configuration #2 */
34982ef75caSClaudiu Manoil 	u32	ipgifg;		/* Inter Packet Gap/Inter Frame Gap */
35082ef75caSClaudiu Manoil 	u32	hafdup;		/* Half-duplex */
35182ef75caSClaudiu Manoil 	u32	maxfrm;		/* Maximum Frame */
35282ef75caSClaudiu Manoil 	u32	res514;
35382ef75caSClaudiu Manoil 	u32	res518;
354dd3d1f56SAndy Fleming 
35582ef75caSClaudiu Manoil 	u32	res51c;
356dd3d1f56SAndy Fleming 
35782ef75caSClaudiu Manoil 	u32	resmdio[6];
358dd3d1f56SAndy Fleming 
35982ef75caSClaudiu Manoil 	u32	res538;
360dd3d1f56SAndy Fleming 
36182ef75caSClaudiu Manoil 	u32	ifstat;		/* Interface Status */
36282ef75caSClaudiu Manoil 	u32	macstnaddr1;	/* Station Address, part 1 */
36382ef75caSClaudiu Manoil 	u32	macstnaddr2;	/* Station Address, part 2 */
36482ef75caSClaudiu Manoil 	u32	res548[46];
365dd3d1f56SAndy Fleming 
366dd3d1f56SAndy Fleming 	/* (0x2_n600) */
36782ef75caSClaudiu Manoil 	u32	res600[32];
368dd3d1f56SAndy Fleming 
369dd3d1f56SAndy Fleming 	/* RMON MIB Registers (0x2_n680-0x2_n73c) */
37082ef75caSClaudiu Manoil 	struct tsec_rmon_mib	rmon;
37182ef75caSClaudiu Manoil 	u32	res740[48];
372dd3d1f56SAndy Fleming 
373dd3d1f56SAndy Fleming 	/* Hash Function Registers (0x2_n800) */
37482ef75caSClaudiu Manoil 	struct tsec_hash_regs	hash;
375dd3d1f56SAndy Fleming 
37682ef75caSClaudiu Manoil 	u32	res900[128];
377dd3d1f56SAndy Fleming 
378dd3d1f56SAndy Fleming 	/* Pattern Registers (0x2_nb00) */
37982ef75caSClaudiu Manoil 	u32	resb00[62];
38082ef75caSClaudiu Manoil 	u32	attr; /* Default Attribute Register */
38182ef75caSClaudiu Manoil 	u32	attreli; /* Default Attribute Extract Length and Index */
382dd3d1f56SAndy Fleming 
383dd3d1f56SAndy Fleming 	/* TSEC Future Expansion Space (0x2_nc00-0x2_nffc) */
38482ef75caSClaudiu Manoil 	u32	resc00[256];
385aec84bf6SClaudiu Manoil };
386dd3d1f56SAndy Fleming 
387063c1263SAndy Fleming #define TSEC_GIGABIT	(1 << 0)
388dd3d1f56SAndy Fleming 
389063c1263SAndy Fleming /* These flags currently only have meaning if we're using the eTSEC */
3905f6b1442SPeter Tyser #define TSEC_REDUCED	(1 << 1)	/* MAC-PHY interface uses RGMII */
3915f6b1442SPeter Tyser #define TSEC_SGMII	(1 << 2)	/* MAC-PHY interface uses SGMII */
3922abe361cSAndy Fleming 
393e677da97SBin Meng #define TX_BUF_CNT	2
394e677da97SBin Meng 
395dd3d1f56SAndy Fleming struct tsec_private {
396e677da97SBin Meng 	struct txbd8 __iomem txbd[TX_BUF_CNT];
397e677da97SBin Meng 	struct rxbd8 __iomem rxbd[PKTBUFSRX];
398aec84bf6SClaudiu Manoil 	struct tsec __iomem *regs;
399aec84bf6SClaudiu Manoil 	struct tsec_mii_mng __iomem *phyregs_sgmii;
400063c1263SAndy Fleming 	struct phy_device *phydev;
401063c1263SAndy Fleming 	phy_interface_t interface;
402063c1263SAndy Fleming 	struct mii_dev *bus;
403dd3d1f56SAndy Fleming 	uint phyaddr;
404a1c76c15SBin Meng 	uint tbiaddr;
405063c1263SAndy Fleming 	char mii_devname[16];
406dd3d1f56SAndy Fleming 	u32 flags;
407362b123fSBin Meng 	uint rx_idx;	/* index of the current RX buffer */
408362b123fSBin Meng 	uint tx_idx;	/* index of the current TX buffer */
4099a1d6af5SBin Meng #ifndef CONFIG_DM_ETH
41056a27a1eSBin Meng 	struct eth_device *dev;
4119a1d6af5SBin Meng #else
4129a1d6af5SBin Meng 	struct udevice *dev;
4139a1d6af5SBin Meng #endif
414dd3d1f56SAndy Fleming };
415dd3d1f56SAndy Fleming 
416dd3d1f56SAndy Fleming struct tsec_info_struct {
417aec84bf6SClaudiu Manoil 	struct tsec __iomem *regs;
418aec84bf6SClaudiu Manoil 	struct tsec_mii_mng __iomem *miiregs_sgmii;
41975b9d4aeSAndy Fleming 	char *devname;
420063c1263SAndy Fleming 	char *mii_devname;
421063c1263SAndy Fleming 	phy_interface_t interface;
422dd3d1f56SAndy Fleming 	unsigned int phyaddr;
423dd3d1f56SAndy Fleming 	u32 flags;
424dd3d1f56SAndy Fleming };
425dd3d1f56SAndy Fleming 
4269a1d6af5SBin Meng #ifndef CONFIG_DM_ETH
42775b9d4aeSAndy Fleming int tsec_standard_init(bd_t *bis);
42875b9d4aeSAndy Fleming int tsec_eth_init(bd_t *bis, struct tsec_info_struct *tsec_info, int num);
4299a1d6af5SBin Meng #endif
43075b9d4aeSAndy Fleming 
431dd3d1f56SAndy Fleming #endif /* __TSEC_H */
432