blob: e90095121bdd40f85b01615ac946cc6fc98ef7b6 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
wdenk42d1f032003-10-15 23:53:47 +00002/*
3 * tsec.h
4 *
5 * Driver for the Motorola Triple Speed Ethernet Controller
6 *
Claudiu Manoilaec84bf2013-09-30 12:44:42 +03007 * Copyright 2004, 2007, 2009, 2011, 2013 Freescale Semiconductor, Inc.
wdenk42d1f032003-10-15 23:53:47 +00008 * (C) Copyright 2003, Motorola, Inc.
9 * maintained by Xianghua Xiao (x.xiao@motorola.com)
10 * author Andy Fleming
wdenk42d1f032003-10-15 23:53:47 +000011 */
12
13#ifndef __TSEC_H
14#define __TSEC_H
15
16#include <net.h>
Eran Libertyf046ccd2005-07-28 10:08:46 -050017#include <config.h>
Andy Fleming063c1262011-04-08 02:10:54 -050018#include <phy.h>
wdenk42d1f032003-10-15 23:53:47 +000019
Bin Meng9a1d6af2016-01-11 22:41:24 -080020#ifndef CONFIG_DM_ETH
21
York Sun73fb5832017-03-27 11:41:03 -070022#ifdef CONFIG_ARCH_LS1021A
Alison Wang52d00a82014-09-05 13:52:38 +080023#define TSEC_SIZE 0x40000
24#define TSEC_MDIO_OFFSET 0x40000
25#else
Sandeep Gopalpetb9e186f2009-10-31 00:35:04 +053026#define TSEC_SIZE 0x01000
27#define TSEC_MDIO_OFFSET 0x01000
Alison Wang52d00a82014-09-05 13:52:38 +080028#endif
Eran Libertyf046ccd2005-07-28 10:08:46 -050029
Andy Fleming40ac3d42011-04-29 02:26:52 -050030#define CONFIG_SYS_MDIO_BASE_ADDR (MDIO_BASE_ADDR + 0x520)
Andy Fleming063c1262011-04-08 02:10:54 -050031
Claudiu Manoilaec84bf2013-09-30 12:44:42 +030032#define TSEC_GET_REGS(num, offset) \
33 (struct tsec __iomem *)\
34 (TSEC_BASE_ADDR + (((num) - 1) * (offset)))
35
36#define TSEC_GET_REGS_BASE(num) \
37 TSEC_GET_REGS((num), TSEC_SIZE)
38
39#define TSEC_GET_MDIO_REGS(num, offset) \
40 (struct tsec_mii_mng __iomem *)\
41 (CONFIG_SYS_MDIO_BASE_ADDR + ((num) - 1) * (offset))
42
43#define TSEC_GET_MDIO_REGS_BASE(num) \
44 TSEC_GET_MDIO_REGS((num), TSEC_MDIO_OFFSET)
45
Andy Fleming063c1262011-04-08 02:10:54 -050046#define DEFAULT_MII_NAME "FSL_MDIO"
47
Andy Fleming75b9d4a2008-08-31 16:33:26 -050048#define STD_TSEC_INFO(num) \
49{ \
Claudiu Manoilaec84bf2013-09-30 12:44:42 +030050 .regs = TSEC_GET_REGS_BASE(num), \
51 .miiregs_sgmii = TSEC_GET_MDIO_REGS_BASE(num), \
Andy Fleming75b9d4a2008-08-31 16:33:26 -050052 .devname = CONFIG_TSEC##num##_NAME, \
53 .phyaddr = TSEC##num##_PHY_ADDR, \
Andy Fleming063c1262011-04-08 02:10:54 -050054 .flags = TSEC##num##_FLAGS, \
55 .mii_devname = DEFAULT_MII_NAME \
Andy Fleming75b9d4a2008-08-31 16:33:26 -050056}
57
58#define SET_STD_TSEC_INFO(x, num) \
59{ \
Claudiu Manoilaec84bf2013-09-30 12:44:42 +030060 x.regs = TSEC_GET_REGS_BASE(num); \
61 x.miiregs_sgmii = TSEC_GET_MDIO_REGS_BASE(num); \
Andy Fleming75b9d4a2008-08-31 16:33:26 -050062 x.devname = CONFIG_TSEC##num##_NAME; \
63 x.phyaddr = TSEC##num##_PHY_ADDR; \
64 x.flags = TSEC##num##_FLAGS;\
Andy Fleming063c1262011-04-08 02:10:54 -050065 x.mii_devname = DEFAULT_MII_NAME;\
Andy Fleming75b9d4a2008-08-31 16:33:26 -050066}
67
Bin Meng9a1d6af2016-01-11 22:41:24 -080068#endif /* CONFIG_DM_ETH */
69
Bin Meng9872b732016-01-11 22:41:18 -080070#define MAC_ADDR_LEN 6
wdenk42d1f032003-10-15 23:53:47 +000071
Wolfgang Denk53677ef2008-05-20 16:00:29 +020072/* #define TSEC_TIMEOUT 1000000 */
Bin Meng9872b732016-01-11 22:41:18 -080073#define TSEC_TIMEOUT 1000
74#define TOUT_LOOP 1000000
wdenk42d1f032003-10-15 23:53:47 +000075
Andy Fleming2abe3612008-08-31 16:33:27 -050076/* TBI register addresses */
77#define TBI_CR 0x00
78#define TBI_SR 0x01
79#define TBI_ANA 0x04
80#define TBI_ANLPBPA 0x05
81#define TBI_ANEX 0x06
82#define TBI_TBICON 0x11
83
84/* TBI MDIO register bit fields*/
85#define TBICON_CLK_SELECT 0x0020
Bin Meng9872b732016-01-11 22:41:18 -080086#define TBIANA_ASYMMETRIC_PAUSE 0x0100
87#define TBIANA_SYMMETRIC_PAUSE 0x0080
Andy Fleming2abe3612008-08-31 16:33:27 -050088#define TBIANA_HALF_DUPLEX 0x0040
89#define TBIANA_FULL_DUPLEX 0x0020
90#define TBICR_PHY_RESET 0x8000
91#define TBICR_ANEG_ENABLE 0x1000
92#define TBICR_RESTART_ANEG 0x0200
93#define TBICR_FULL_DUPLEX 0x0100
94#define TBICR_SPEED1_SET 0x0040
95
wdenk42d1f032003-10-15 23:53:47 +000096/* MAC register bits */
97#define MACCFG1_SOFT_RESET 0x80000000
98#define MACCFG1_RESET_RX_MC 0x00080000
99#define MACCFG1_RESET_TX_MC 0x00040000
100#define MACCFG1_RESET_RX_FUN 0x00020000
Bin Meng9872b732016-01-11 22:41:18 -0800101#define MACCFG1_RESET_TX_FUN 0x00010000
wdenk42d1f032003-10-15 23:53:47 +0000102#define MACCFG1_LOOPBACK 0x00000100
103#define MACCFG1_RX_FLOW 0x00000020
104#define MACCFG1_TX_FLOW 0x00000010
105#define MACCFG1_SYNCD_RX_EN 0x00000008
106#define MACCFG1_RX_EN 0x00000004
107#define MACCFG1_SYNCD_TX_EN 0x00000002
108#define MACCFG1_TX_EN 0x00000001
109
110#define MACCFG2_INIT_SETTINGS 0x00007205
111#define MACCFG2_FULL_DUPLEX 0x00000001
Wolfgang Denk53677ef2008-05-20 16:00:29 +0200112#define MACCFG2_IF 0x00000300
wdenk97d80fc2004-06-09 00:34:46 +0000113#define MACCFG2_GMII 0x00000200
Wolfgang Denk53677ef2008-05-20 16:00:29 +0200114#define MACCFG2_MII 0x00000100
wdenk42d1f032003-10-15 23:53:47 +0000115
116#define ECNTRL_INIT_SETTINGS 0x00001000
Wolfgang Denk53677ef2008-05-20 16:00:29 +0200117#define ECNTRL_TBI_MODE 0x00000020
Andy Fleming063c1262011-04-08 02:10:54 -0500118#define ECNTRL_REDUCED_MODE 0x00000010
Jon Loeligerd9b94f22005-07-25 14:05:07 -0500119#define ECNTRL_R100 0x00000008
Andy Fleming063c1262011-04-08 02:10:54 -0500120#define ECNTRL_REDUCED_MII_MODE 0x00000004
Andy Fleming81f481c2007-04-23 02:24:28 -0500121#define ECNTRL_SGMII_MODE 0x00000002
wdenk42d1f032003-10-15 23:53:47 +0000122
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200123#ifndef CONFIG_SYS_TBIPA_VALUE
Bin Meng9872b732016-01-11 22:41:18 -0800124# define CONFIG_SYS_TBIPA_VALUE 0x1f
Joe Hammandcb84b72007-08-09 09:08:18 -0500125#endif
wdenk42d1f032003-10-15 23:53:47 +0000126
127#define MRBLR_INIT_SETTINGS PKTSIZE_ALIGN
128
129#define MINFLR_INIT_SETTINGS 0x00000040
130
Wolfgang Denk53677ef2008-05-20 16:00:29 +0200131#define DMACTRL_INIT_SETTINGS 0x000000c3
132#define DMACTRL_GRS 0x00000010
133#define DMACTRL_GTS 0x00000008
Alison Wang52d00a82014-09-05 13:52:38 +0800134#define DMACTRL_LE 0x00008000
wdenk42d1f032003-10-15 23:53:47 +0000135
Wolfgang Denk53677ef2008-05-20 16:00:29 +0200136#define TSTAT_CLEAR_THALT 0x80000000
137#define RSTAT_CLEAR_RHALT 0x00800000
wdenk42d1f032003-10-15 23:53:47 +0000138
wdenk42d1f032003-10-15 23:53:47 +0000139#define IEVENT_INIT_CLEAR 0xffffffff
140#define IEVENT_BABR 0x80000000
141#define IEVENT_RXC 0x40000000
142#define IEVENT_BSY 0x20000000
143#define IEVENT_EBERR 0x10000000
144#define IEVENT_MSRO 0x04000000
145#define IEVENT_GTSC 0x02000000
146#define IEVENT_BABT 0x01000000
147#define IEVENT_TXC 0x00800000
148#define IEVENT_TXE 0x00400000
149#define IEVENT_TXB 0x00200000
150#define IEVENT_TXF 0x00100000
151#define IEVENT_IE 0x00080000
152#define IEVENT_LC 0x00040000
153#define IEVENT_CRL 0x00020000
154#define IEVENT_XFUN 0x00010000
155#define IEVENT_RXB0 0x00008000
156#define IEVENT_GRSC 0x00000100
157#define IEVENT_RXF0 0x00000080
158
159#define IMASK_INIT_CLEAR 0x00000000
160#define IMASK_TXEEN 0x00400000
161#define IMASK_TXBEN 0x00200000
Wolfgang Denk53677ef2008-05-20 16:00:29 +0200162#define IMASK_TXFEN 0x00100000
wdenk42d1f032003-10-15 23:53:47 +0000163#define IMASK_RXFEN0 0x00000080
164
wdenk42d1f032003-10-15 23:53:47 +0000165/* Default Attribute fields */
Bin Meng9872b732016-01-11 22:41:18 -0800166#define ATTR_INIT_SETTINGS 0x000000c0
167#define ATTRELI_INIT_SETTINGS 0x00000000
wdenk42d1f032003-10-15 23:53:47 +0000168
169/* TxBD status field bits */
170#define TXBD_READY 0x8000
171#define TXBD_PADCRC 0x4000
172#define TXBD_WRAP 0x2000
173#define TXBD_INTERRUPT 0x1000
174#define TXBD_LAST 0x0800
175#define TXBD_CRC 0x0400
176#define TXBD_DEF 0x0200
177#define TXBD_HUGEFRAME 0x0080
178#define TXBD_LATECOLLISION 0x0080
179#define TXBD_RETRYLIMIT 0x0040
Bin Meng9872b732016-01-11 22:41:18 -0800180#define TXBD_RETRYCOUNTMASK 0x003c
wdenk42d1f032003-10-15 23:53:47 +0000181#define TXBD_UNDERRUN 0x0002
Wolfgang Denk53677ef2008-05-20 16:00:29 +0200182#define TXBD_STATS 0x03ff
wdenk42d1f032003-10-15 23:53:47 +0000183
184/* RxBD status field bits */
185#define RXBD_EMPTY 0x8000
186#define RXBD_RO1 0x4000
187#define RXBD_WRAP 0x2000
188#define RXBD_INTERRUPT 0x1000
189#define RXBD_LAST 0x0800
190#define RXBD_FIRST 0x0400
191#define RXBD_MISS 0x0100
192#define RXBD_BROADCAST 0x0080
193#define RXBD_MULTICAST 0x0040
194#define RXBD_LARGE 0x0020
195#define RXBD_NONOCTET 0x0010
196#define RXBD_SHORT 0x0008
197#define RXBD_CRCERR 0x0004
198#define RXBD_OVERRUN 0x0002
199#define RXBD_TRUNCATED 0x0001
200#define RXBD_STATS 0x003f
201
Claudiu Manoil9c9141f2013-10-04 19:13:53 +0300202struct txbd8 {
Bin Meng9872b732016-01-11 22:41:18 -0800203 uint16_t status; /* Status Fields */
204 uint16_t length; /* Buffer length */
205 uint32_t bufptr; /* Buffer Pointer */
Claudiu Manoil9c9141f2013-10-04 19:13:53 +0300206};
wdenk42d1f032003-10-15 23:53:47 +0000207
Claudiu Manoil9c9141f2013-10-04 19:13:53 +0300208struct rxbd8 {
Bin Meng9872b732016-01-11 22:41:18 -0800209 uint16_t status; /* Status Fields */
210 uint16_t length; /* Buffer Length */
211 uint32_t bufptr; /* Buffer Pointer */
Claudiu Manoil9c9141f2013-10-04 19:13:53 +0300212};
wdenk42d1f032003-10-15 23:53:47 +0000213
Claudiu Manoil82ef75c2013-09-30 12:44:46 +0300214struct tsec_rmon_mib {
wdenk42d1f032003-10-15 23:53:47 +0000215 /* Transmit and Receive Counters */
Claudiu Manoil82ef75c2013-09-30 12:44:46 +0300216 u32 tr64; /* Tx/Rx 64-byte Frame Counter */
217 u32 tr127; /* Tx/Rx 65-127 byte Frame Counter */
218 u32 tr255; /* Tx/Rx 128-255 byte Frame Counter */
219 u32 tr511; /* Tx/Rx 256-511 byte Frame Counter */
220 u32 tr1k; /* Tx/Rx 512-1023 byte Frame Counter */
221 u32 trmax; /* Tx/Rx 1024-1518 byte Frame Counter */
222 u32 trmgv; /* Tx/Rx 1519-1522 byte Good VLAN Frame */
wdenk42d1f032003-10-15 23:53:47 +0000223 /* Receive Counters */
Claudiu Manoil82ef75c2013-09-30 12:44:46 +0300224 u32 rbyt; /* Receive Byte Counter */
225 u32 rpkt; /* Receive Packet Counter */
226 u32 rfcs; /* Receive FCS Error Counter */
227 u32 rmca; /* Receive Multicast Packet (Counter) */
228 u32 rbca; /* Receive Broadcast Packet */
229 u32 rxcf; /* Receive Control Frame Packet */
230 u32 rxpf; /* Receive Pause Frame Packet */
231 u32 rxuo; /* Receive Unknown OP Code */
232 u32 raln; /* Receive Alignment Error */
233 u32 rflr; /* Receive Frame Length Error */
234 u32 rcde; /* Receive Code Error */
235 u32 rcse; /* Receive Carrier Sense Error */
236 u32 rund; /* Receive Undersize Packet */
237 u32 rovr; /* Receive Oversize Packet */
238 u32 rfrg; /* Receive Fragments */
239 u32 rjbr; /* Receive Jabber */
240 u32 rdrp; /* Receive Drop */
wdenk42d1f032003-10-15 23:53:47 +0000241 /* Transmit Counters */
Claudiu Manoil82ef75c2013-09-30 12:44:46 +0300242 u32 tbyt; /* Transmit Byte Counter */
243 u32 tpkt; /* Transmit Packet */
244 u32 tmca; /* Transmit Multicast Packet */
245 u32 tbca; /* Transmit Broadcast Packet */
246 u32 txpf; /* Transmit Pause Control Frame */
247 u32 tdfr; /* Transmit Deferral Packet */
248 u32 tedf; /* Transmit Excessive Deferral Packet */
249 u32 tscl; /* Transmit Single Collision Packet */
wdenk42d1f032003-10-15 23:53:47 +0000250 /* (0x2_n700) */
Claudiu Manoil82ef75c2013-09-30 12:44:46 +0300251 u32 tmcl; /* Transmit Multiple Collision Packet */
252 u32 tlcl; /* Transmit Late Collision Packet */
253 u32 txcl; /* Transmit Excessive Collision Packet */
254 u32 tncl; /* Transmit Total Collision */
wdenk42d1f032003-10-15 23:53:47 +0000255
Claudiu Manoil82ef75c2013-09-30 12:44:46 +0300256 u32 res2;
wdenk42d1f032003-10-15 23:53:47 +0000257
Claudiu Manoil82ef75c2013-09-30 12:44:46 +0300258 u32 tdrp; /* Transmit Drop Frame */
259 u32 tjbr; /* Transmit Jabber Frame */
260 u32 tfcs; /* Transmit FCS Error */
261 u32 txcf; /* Transmit Control Frame */
262 u32 tovr; /* Transmit Oversize Frame */
263 u32 tund; /* Transmit Undersize Frame */
264 u32 tfrg; /* Transmit Fragments Frame */
wdenk42d1f032003-10-15 23:53:47 +0000265 /* General Registers */
Claudiu Manoil82ef75c2013-09-30 12:44:46 +0300266 u32 car1; /* Carry Register One */
267 u32 car2; /* Carry Register Two */
268 u32 cam1; /* Carry Register One Mask */
269 u32 cam2; /* Carry Register Two Mask */
270};
wdenk42d1f032003-10-15 23:53:47 +0000271
Claudiu Manoil82ef75c2013-09-30 12:44:46 +0300272struct tsec_hash_regs {
273 u32 iaddr0; /* Individual Address Register 0 */
274 u32 iaddr1; /* Individual Address Register 1 */
275 u32 iaddr2; /* Individual Address Register 2 */
276 u32 iaddr3; /* Individual Address Register 3 */
277 u32 iaddr4; /* Individual Address Register 4 */
278 u32 iaddr5; /* Individual Address Register 5 */
279 u32 iaddr6; /* Individual Address Register 6 */
280 u32 iaddr7; /* Individual Address Register 7 */
281 u32 res1[24];
282 u32 gaddr0; /* Group Address Register 0 */
283 u32 gaddr1; /* Group Address Register 1 */
284 u32 gaddr2; /* Group Address Register 2 */
285 u32 gaddr3; /* Group Address Register 3 */
286 u32 gaddr4; /* Group Address Register 4 */
287 u32 gaddr5; /* Group Address Register 5 */
288 u32 gaddr6; /* Group Address Register 6 */
289 u32 gaddr7; /* Group Address Register 7 */
290 u32 res2[24];
291};
wdenk42d1f032003-10-15 23:53:47 +0000292
Claudiu Manoilaec84bf2013-09-30 12:44:42 +0300293struct tsec {
wdenk42d1f032003-10-15 23:53:47 +0000294 /* General Control and Status Registers (0x2_n000) */
Claudiu Manoil82ef75c2013-09-30 12:44:46 +0300295 u32 res000[4];
wdenk42d1f032003-10-15 23:53:47 +0000296
Claudiu Manoil82ef75c2013-09-30 12:44:46 +0300297 u32 ievent; /* Interrupt Event */
298 u32 imask; /* Interrupt Mask */
299 u32 edis; /* Error Disabled */
300 u32 res01c;
301 u32 ecntrl; /* Ethernet Control */
302 u32 minflr; /* Minimum Frame Length */
303 u32 ptv; /* Pause Time Value */
304 u32 dmactrl; /* DMA Control */
305 u32 tbipa; /* TBI PHY Address */
wdenk42d1f032003-10-15 23:53:47 +0000306
Claudiu Manoil82ef75c2013-09-30 12:44:46 +0300307 u32 res034[3];
308 u32 res040[48];
wdenk42d1f032003-10-15 23:53:47 +0000309
310 /* Transmit Control and Status Registers (0x2_n100) */
Claudiu Manoil82ef75c2013-09-30 12:44:46 +0300311 u32 tctrl; /* Transmit Control */
312 u32 tstat; /* Transmit Status */
313 u32 res108;
314 u32 tbdlen; /* Tx BD Data Length */
315 u32 res110[5];
316 u32 ctbptr; /* Current TxBD Pointer */
317 u32 res128[23];
318 u32 tbptr; /* TxBD Pointer */
319 u32 res188[30];
wdenk42d1f032003-10-15 23:53:47 +0000320 /* (0x2_n200) */
Claudiu Manoil82ef75c2013-09-30 12:44:46 +0300321 u32 res200;
322 u32 tbase; /* TxBD Base Address */
323 u32 res208[42];
324 u32 ostbd; /* Out of Sequence TxBD */
325 u32 ostbdp; /* Out of Sequence Tx Data Buffer Pointer */
326 u32 res2b8[18];
wdenk42d1f032003-10-15 23:53:47 +0000327
328 /* Receive Control and Status Registers (0x2_n300) */
Claudiu Manoil82ef75c2013-09-30 12:44:46 +0300329 u32 rctrl; /* Receive Control */
330 u32 rstat; /* Receive Status */
331 u32 res308;
332 u32 rbdlen; /* RxBD Data Length */
333 u32 res310[4];
334 u32 res320;
Bin Meng9872b732016-01-11 22:41:18 -0800335 u32 crbptr; /* Current Receive Buffer Pointer */
Claudiu Manoil82ef75c2013-09-30 12:44:46 +0300336 u32 res328[6];
Bin Meng9872b732016-01-11 22:41:18 -0800337 u32 mrblr; /* Maximum Receive Buffer Length */
Claudiu Manoil82ef75c2013-09-30 12:44:46 +0300338 u32 res344[16];
Bin Meng9872b732016-01-11 22:41:18 -0800339 u32 rbptr; /* RxBD Pointer */
Claudiu Manoil82ef75c2013-09-30 12:44:46 +0300340 u32 res388[30];
wdenk42d1f032003-10-15 23:53:47 +0000341 /* (0x2_n400) */
Claudiu Manoil82ef75c2013-09-30 12:44:46 +0300342 u32 res400;
Bin Meng9872b732016-01-11 22:41:18 -0800343 u32 rbase; /* RxBD Base Address */
Claudiu Manoil82ef75c2013-09-30 12:44:46 +0300344 u32 res408[62];
wdenk42d1f032003-10-15 23:53:47 +0000345
346 /* MAC Registers (0x2_n500) */
Claudiu Manoil82ef75c2013-09-30 12:44:46 +0300347 u32 maccfg1; /* MAC Configuration #1 */
348 u32 maccfg2; /* MAC Configuration #2 */
349 u32 ipgifg; /* Inter Packet Gap/Inter Frame Gap */
350 u32 hafdup; /* Half-duplex */
351 u32 maxfrm; /* Maximum Frame */
352 u32 res514;
353 u32 res518;
wdenk42d1f032003-10-15 23:53:47 +0000354
Claudiu Manoil82ef75c2013-09-30 12:44:46 +0300355 u32 res51c;
wdenk42d1f032003-10-15 23:53:47 +0000356
Claudiu Manoil82ef75c2013-09-30 12:44:46 +0300357 u32 resmdio[6];
wdenk42d1f032003-10-15 23:53:47 +0000358
Claudiu Manoil82ef75c2013-09-30 12:44:46 +0300359 u32 res538;
wdenk42d1f032003-10-15 23:53:47 +0000360
Claudiu Manoil82ef75c2013-09-30 12:44:46 +0300361 u32 ifstat; /* Interface Status */
362 u32 macstnaddr1; /* Station Address, part 1 */
363 u32 macstnaddr2; /* Station Address, part 2 */
364 u32 res548[46];
wdenk42d1f032003-10-15 23:53:47 +0000365
366 /* (0x2_n600) */
Claudiu Manoil82ef75c2013-09-30 12:44:46 +0300367 u32 res600[32];
wdenk42d1f032003-10-15 23:53:47 +0000368
369 /* RMON MIB Registers (0x2_n680-0x2_n73c) */
Claudiu Manoil82ef75c2013-09-30 12:44:46 +0300370 struct tsec_rmon_mib rmon;
371 u32 res740[48];
wdenk42d1f032003-10-15 23:53:47 +0000372
373 /* Hash Function Registers (0x2_n800) */
Claudiu Manoil82ef75c2013-09-30 12:44:46 +0300374 struct tsec_hash_regs hash;
wdenk42d1f032003-10-15 23:53:47 +0000375
Claudiu Manoil82ef75c2013-09-30 12:44:46 +0300376 u32 res900[128];
wdenk42d1f032003-10-15 23:53:47 +0000377
378 /* Pattern Registers (0x2_nb00) */
Claudiu Manoil82ef75c2013-09-30 12:44:46 +0300379 u32 resb00[62];
380 u32 attr; /* Default Attribute Register */
381 u32 attreli; /* Default Attribute Extract Length and Index */
wdenk42d1f032003-10-15 23:53:47 +0000382
383 /* TSEC Future Expansion Space (0x2_nc00-0x2_nffc) */
Claudiu Manoil82ef75c2013-09-30 12:44:46 +0300384 u32 resc00[256];
Claudiu Manoilaec84bf2013-09-30 12:44:42 +0300385};
wdenk42d1f032003-10-15 23:53:47 +0000386
Bin Meng9872b732016-01-11 22:41:18 -0800387#define TSEC_GIGABIT (1 << 0)
Jon Loeligerd9b94f22005-07-25 14:05:07 -0500388
Andy Fleming063c1262011-04-08 02:10:54 -0500389/* These flags currently only have meaning if we're using the eTSEC */
Peter Tyser5f6b1442009-11-09 13:09:48 -0600390#define TSEC_REDUCED (1 << 1) /* MAC-PHY interface uses RGMII */
391#define TSEC_SGMII (1 << 2) /* MAC-PHY interface uses SGMII */
Jon Loeligerd9b94f22005-07-25 14:05:07 -0500392
Bin Menge677da92016-01-11 22:41:20 -0800393#define TX_BUF_CNT 2
394
wdenk97d80fc2004-06-09 00:34:46 +0000395struct tsec_private {
Bin Menge677da92016-01-11 22:41:20 -0800396 struct txbd8 __iomem txbd[TX_BUF_CNT];
397 struct rxbd8 __iomem rxbd[PKTBUFSRX];
Claudiu Manoilaec84bf2013-09-30 12:44:42 +0300398 struct tsec __iomem *regs;
399 struct tsec_mii_mng __iomem *phyregs_sgmii;
Andy Fleming063c1262011-04-08 02:10:54 -0500400 struct phy_device *phydev;
401 phy_interface_t interface;
402 struct mii_dev *bus;
wdenk97d80fc2004-06-09 00:34:46 +0000403 uint phyaddr;
Bin Menga1c76c12016-01-11 22:41:25 -0800404 uint tbiaddr;
Andy Fleming063c1262011-04-08 02:10:54 -0500405 char mii_devname[16];
Jon Loeligerd9b94f22005-07-25 14:05:07 -0500406 u32 flags;
Bin Meng362b1232016-01-11 22:41:19 -0800407 uint rx_idx; /* index of the current RX buffer */
408 uint tx_idx; /* index of the current TX buffer */
Bin Meng9a1d6af2016-01-11 22:41:24 -0800409#ifndef CONFIG_DM_ETH
Bin Meng56a27a12016-01-11 22:41:22 -0800410 struct eth_device *dev;
Bin Meng9a1d6af2016-01-11 22:41:24 -0800411#else
412 struct udevice *dev;
413#endif
wdenk97d80fc2004-06-09 00:34:46 +0000414};
415
Andy Flemingdd3d1f52008-08-31 16:33:25 -0500416struct tsec_info_struct {
Claudiu Manoilaec84bf2013-09-30 12:44:42 +0300417 struct tsec __iomem *regs;
418 struct tsec_mii_mng __iomem *miiregs_sgmii;
Andy Fleming75b9d4a2008-08-31 16:33:26 -0500419 char *devname;
Andy Fleming063c1262011-04-08 02:10:54 -0500420 char *mii_devname;
421 phy_interface_t interface;
Andy Flemingdd3d1f52008-08-31 16:33:25 -0500422 unsigned int phyaddr;
423 u32 flags;
Andy Flemingdd3d1f52008-08-31 16:33:25 -0500424};
425
Bin Meng9a1d6af2016-01-11 22:41:24 -0800426#ifndef CONFIG_DM_ETH
Andy Fleming75b9d4a2008-08-31 16:33:26 -0500427int tsec_standard_init(bd_t *bis);
428int tsec_eth_init(bd_t *bis, struct tsec_info_struct *tsec_info, int num);
Bin Meng9a1d6af2016-01-11 22:41:24 -0800429#endif
Andy Fleming75b9d4a2008-08-31 16:33:26 -0500430
wdenk42d1f032003-10-15 23:53:47 +0000431#endif /* __TSEC_H */