blob: bd4ebdd745a6cee5828ef1584518589c7667e667 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
wdenk9c53f402003-10-15 23:53:47 +00002/*
wdenka445ddf2004-06-09 00:34:46 +00003 * Freescale Three Speed Ethernet Controller driver
wdenk9c53f402003-10-15 23:53:47 +00004 *
Claudiu Manoilcd0c4122013-09-30 12:44:42 +03005 * Copyright 2004-2011, 2013 Freescale Semiconductor, Inc.
wdenk9c53f402003-10-15 23:53:47 +00006 * (C) Copyright 2003, Motorola, Inc.
wdenk9c53f402003-10-15 23:53:47 +00007 * author Andy Fleming
wdenk9c53f402003-10-15 23:53:47 +00008 */
9
10#include <config.h>
Bin Meng1048f612016-01-11 22:41:24 -080011#include <dm.h>
wdenk9c53f402003-10-15 23:53:47 +000012#include <malloc.h>
13#include <net.h>
14#include <command.h>
Andy Flemingc067fc12008-08-31 16:33:25 -050015#include <tsec.h>
Andy Fleming422effd2011-04-08 02:10:54 -050016#include <fsl_mdio.h>
Simon Glass4dcacfc2020-05-10 11:40:13 -060017#include <linux/bitops.h>
Simon Glassdbd79542020-05-10 11:40:11 -060018#include <linux/delay.h>
Masahiro Yamada56a931c2016-09-21 11:28:55 +090019#include <linux/errno.h>
Hou Zhiqiangd35de972020-07-16 18:09:12 +080020#include <miiphy.h>
chenhui zhaoc8caa8a2011-10-03 08:38:50 -050021#include <asm/processor.h>
Alison Wang32cc5912014-09-05 13:52:38 +080022#include <asm/io.h>
wdenk9c53f402003-10-15 23:53:47 +000023
Andy Flemingac65e072008-08-31 16:33:27 -050024#define TBIANA_SETTINGS ( \
25 TBIANA_ASYMMETRIC_PAUSE \
26 | TBIANA_SYMMETRIC_PAUSE \
27 | TBIANA_FULL_DUPLEX \
28 )
29
Felix Radensky27f98e02010-06-28 01:57:39 +030030/* By default force the TBI PHY into 1000Mbps full duplex when in SGMII mode */
Tom Rinie6179b52022-12-04 10:14:01 -050031#ifndef CFG_TSEC_TBICR_SETTINGS
32#define CFG_TSEC_TBICR_SETTINGS ( \
Andy Flemingac65e072008-08-31 16:33:27 -050033 TBICR_PHY_RESET \
Kumar Galac1457f92010-12-01 22:55:54 -060034 | TBICR_ANEG_ENABLE \
Andy Flemingac65e072008-08-31 16:33:27 -050035 | TBICR_FULL_DUPLEX \
36 | TBICR_SPEED1_SET \
37 )
Tom Rinie6179b52022-12-04 10:14:01 -050038#endif /* CFG_TSEC_TBICR_SETTINGS */
Peter Tyser583c1f42009-11-03 17:52:07 -060039
Andy Flemingac65e072008-08-31 16:33:27 -050040/* Configure the TBI for SGMII operation */
41static void tsec_configure_serdes(struct tsec_private *priv)
42{
Bin Meng79cd33a2016-01-11 22:41:18 -080043 /*
44 * Access TBI PHY registers at given TSEC register offset as opposed
45 * to the register offset used for external PHY accesses
46 */
Andy Fleming422effd2011-04-08 02:10:54 -050047 tsec_local_mdio_write(priv->phyregs_sgmii, in_be32(&priv->regs->tbipa),
Mario Sixc29fcc72018-01-15 11:08:21 +010048 0, TBI_ANA, TBIANA_SETTINGS);
Andy Fleming422effd2011-04-08 02:10:54 -050049 tsec_local_mdio_write(priv->phyregs_sgmii, in_be32(&priv->regs->tbipa),
Mario Sixc29fcc72018-01-15 11:08:21 +010050 0, TBI_TBICON, TBICON_CLK_SELECT);
Andy Fleming422effd2011-04-08 02:10:54 -050051 tsec_local_mdio_write(priv->phyregs_sgmii, in_be32(&priv->regs->tbipa),
Tom Rinie6179b52022-12-04 10:14:01 -050052 0, TBI_CR, CFG_TSEC_TBICR_SETTINGS);
David Updegraff0451b012007-04-20 14:34:48 -050053}
54
Chris Packhambbe18572018-11-26 21:00:28 +130055/* the 'way' for ethernet-CRC-32. Spliced in from Linux lib/crc32.c
56 * and this is the ethernet-crc method needed for TSEC -- and perhaps
57 * some other adapter -- hash tables
58 */
59#define CRCPOLY_LE 0xedb88320
60static u32 ether_crc(size_t len, unsigned char const *p)
61{
62 int i;
63 u32 crc;
64
65 crc = ~0;
66 while (len--) {
67 crc ^= *p++;
68 for (i = 0; i < 8; i++)
69 crc = (crc >> 1) ^ ((crc & 1) ? CRCPOLY_LE : 0);
70 }
71 /* an reverse the bits, cuz of way they arrive -- last-first */
72 crc = (crc >> 16) | (crc << 16);
73 crc = (crc >> 8 & 0x00ff00ff) | (crc << 8 & 0xff00ff00);
74 crc = (crc >> 4 & 0x0f0f0f0f) | (crc << 4 & 0xf0f0f0f0);
75 crc = (crc >> 2 & 0x33333333) | (crc << 2 & 0xcccccccc);
76 crc = (crc >> 1 & 0x55555555) | (crc << 1 & 0xaaaaaaaa);
77 return crc;
78}
79
Mingkai Hue0653bf2011-01-27 12:52:46 +080080/* CREDITS: linux gianfar driver, slightly adjusted... thanx. */
81
82/* Set the appropriate hash bit for the given addr */
83
Bin Meng79cd33a2016-01-11 22:41:18 -080084/*
85 * The algorithm works like so:
Mingkai Hue0653bf2011-01-27 12:52:46 +080086 * 1) Take the Destination Address (ie the multicast address), and
87 * do a CRC on it (little endian), and reverse the bits of the
88 * result.
89 * 2) Use the 8 most significant bits as a hash into a 256-entry
90 * table. The table is controlled through 8 32-bit registers:
Claudiu Manoil461511b2013-09-30 12:44:40 +030091 * gaddr0-7. gaddr0's MSB is entry 0, and gaddr7's LSB is entry
92 * 255. This means that the 3 most significant bits in the
Mingkai Hue0653bf2011-01-27 12:52:46 +080093 * hash index which gaddr register to use, and the 5 other bits
94 * indicate which bit (assuming an IBM numbering scheme, which
Claudiu Manoil461511b2013-09-30 12:44:40 +030095 * for PowerPC (tm) is usually the case) in the register holds
Bin Meng79cd33a2016-01-11 22:41:18 -080096 * the entry.
97 */
Chris Packhama55ef7f2018-11-26 21:00:29 +130098static int tsec_mcast_addr(struct udevice *dev, const u8 *mcast_mac, int join)
Mingkai Hue0653bf2011-01-27 12:52:46 +080099{
Simon Glass95588622020-12-22 19:30:28 -0700100 struct tsec_private *priv;
101 struct tsec __iomem *regs;
Claudiu Manoil461511b2013-09-30 12:44:40 +0300102 u32 result, value;
103 u8 whichbit, whichreg;
Mingkai Hue0653bf2011-01-27 12:52:46 +0800104
Simon Glass95588622020-12-22 19:30:28 -0700105 priv = dev_get_priv(dev);
Simon Glass95588622020-12-22 19:30:28 -0700106 regs = priv->regs;
Claudiu Manoil461511b2013-09-30 12:44:40 +0300107 result = ether_crc(MAC_ADDR_LEN, mcast_mac);
108 whichbit = (result >> 24) & 0x1f; /* the 5 LSB = which bit to set */
109 whichreg = result >> 29; /* the 3 MSB = which reg to set it in */
Mingkai Hue0653bf2011-01-27 12:52:46 +0800110
Mario Sixc29fcc72018-01-15 11:08:21 +0100111 value = BIT(31 - whichbit);
Claudiu Manoil461511b2013-09-30 12:44:40 +0300112
Chris Packhama55ef7f2018-11-26 21:00:29 +1300113 if (join)
Claudiu Manoil461511b2013-09-30 12:44:40 +0300114 setbits_be32(&regs->hash.gaddr0 + whichreg, value);
115 else
116 clrbits_be32(&regs->hash.gaddr0 + whichreg, value);
Mingkai Hue0653bf2011-01-27 12:52:46 +0800117
Mingkai Hue0653bf2011-01-27 12:52:46 +0800118 return 0;
119}
Mingkai Hue0653bf2011-01-27 12:52:46 +0800120
Marek Vasutbe6e05b2022-12-17 18:41:13 +0100121static int __maybe_unused tsec_set_promisc(struct udevice *dev, bool enable)
Vladimir Oltean3556c4d2021-09-29 18:04:36 +0300122{
123 struct tsec_private *priv = dev_get_priv(dev);
124 struct tsec __iomem *regs = priv->regs;
125
126 if (enable)
127 setbits_be32(&regs->rctrl, RCTRL_PROM);
128 else
129 clrbits_be32(&regs->rctrl, RCTRL_PROM);
130
131 return 0;
132}
133
Bin Meng79cd33a2016-01-11 22:41:18 -0800134/*
135 * Initialized required registers to appropriate values, zeroing
Mingkai Hue0653bf2011-01-27 12:52:46 +0800136 * those we don't care about (unless zero is bad, in which case,
137 * choose a more appropriate value)
138 */
Claudiu Manoilcd0c4122013-09-30 12:44:42 +0300139static void init_registers(struct tsec __iomem *regs)
Mingkai Hue0653bf2011-01-27 12:52:46 +0800140{
141 /* Clear IEVENT */
142 out_be32(&regs->ievent, IEVENT_INIT_CLEAR);
143
144 out_be32(&regs->imask, IMASK_INIT_CLEAR);
145
146 out_be32(&regs->hash.iaddr0, 0);
147 out_be32(&regs->hash.iaddr1, 0);
148 out_be32(&regs->hash.iaddr2, 0);
149 out_be32(&regs->hash.iaddr3, 0);
150 out_be32(&regs->hash.iaddr4, 0);
151 out_be32(&regs->hash.iaddr5, 0);
152 out_be32(&regs->hash.iaddr6, 0);
153 out_be32(&regs->hash.iaddr7, 0);
154
155 out_be32(&regs->hash.gaddr0, 0);
156 out_be32(&regs->hash.gaddr1, 0);
157 out_be32(&regs->hash.gaddr2, 0);
158 out_be32(&regs->hash.gaddr3, 0);
159 out_be32(&regs->hash.gaddr4, 0);
160 out_be32(&regs->hash.gaddr5, 0);
161 out_be32(&regs->hash.gaddr6, 0);
162 out_be32(&regs->hash.gaddr7, 0);
163
Mingkai Hue0653bf2011-01-27 12:52:46 +0800164 /* Init RMON mib registers */
Claudiu Manoila18ab902013-09-30 12:44:46 +0300165 memset((void *)&regs->rmon, 0, sizeof(regs->rmon));
Mingkai Hue0653bf2011-01-27 12:52:46 +0800166
167 out_be32(&regs->rmon.cam1, 0xffffffff);
168 out_be32(&regs->rmon.cam2, 0xffffffff);
169
170 out_be32(&regs->mrblr, MRBLR_INIT_SETTINGS);
171
172 out_be32(&regs->minflr, MINFLR_INIT_SETTINGS);
173
174 out_be32(&regs->attr, ATTR_INIT_SETTINGS);
175 out_be32(&regs->attreli, ATTRELI_INIT_SETTINGS);
Mingkai Hue0653bf2011-01-27 12:52:46 +0800176}
177
Bin Meng79cd33a2016-01-11 22:41:18 -0800178/*
179 * Configure maccfg2 based on negotiated speed and duplex
Mingkai Hue0653bf2011-01-27 12:52:46 +0800180 * reported by PHY handling code
181 */
Andy Fleming422effd2011-04-08 02:10:54 -0500182static void adjust_link(struct tsec_private *priv, struct phy_device *phydev)
Mingkai Hue0653bf2011-01-27 12:52:46 +0800183{
Claudiu Manoilcd0c4122013-09-30 12:44:42 +0300184 struct tsec __iomem *regs = priv->regs;
Mingkai Hue0653bf2011-01-27 12:52:46 +0800185 u32 ecntrl, maccfg2;
186
Andy Fleming422effd2011-04-08 02:10:54 -0500187 if (!phydev->link) {
188 printf("%s: No link.\n", phydev->dev->name);
Mingkai Hue0653bf2011-01-27 12:52:46 +0800189 return;
190 }
191
192 /* clear all bits relative with interface mode */
193 ecntrl = in_be32(&regs->ecntrl);
194 ecntrl &= ~ECNTRL_R100;
195
196 maccfg2 = in_be32(&regs->maccfg2);
197 maccfg2 &= ~(MACCFG2_IF | MACCFG2_FULL_DUPLEX);
198
Andy Fleming422effd2011-04-08 02:10:54 -0500199 if (phydev->duplex)
Mingkai Hue0653bf2011-01-27 12:52:46 +0800200 maccfg2 |= MACCFG2_FULL_DUPLEX;
201
Andy Fleming422effd2011-04-08 02:10:54 -0500202 switch (phydev->speed) {
Mingkai Hue0653bf2011-01-27 12:52:46 +0800203 case 1000:
204 maccfg2 |= MACCFG2_GMII;
205 break;
206 case 100:
207 case 10:
208 maccfg2 |= MACCFG2_MII;
209
Bin Meng79cd33a2016-01-11 22:41:18 -0800210 /*
211 * Set R100 bit in all modes although
Mingkai Hue0653bf2011-01-27 12:52:46 +0800212 * it is only used in RGMII mode
213 */
Andy Fleming422effd2011-04-08 02:10:54 -0500214 if (phydev->speed == 100)
Mingkai Hue0653bf2011-01-27 12:52:46 +0800215 ecntrl |= ECNTRL_R100;
216 break;
217 default:
Andy Fleming422effd2011-04-08 02:10:54 -0500218 printf("%s: Speed was bad\n", phydev->dev->name);
Mingkai Hue0653bf2011-01-27 12:52:46 +0800219 break;
220 }
221
222 out_be32(&regs->ecntrl, ecntrl);
223 out_be32(&regs->maccfg2, maccfg2);
wdenkf41ff3b2005-04-04 23:43:44 +0000224
Andy Fleming422effd2011-04-08 02:10:54 -0500225 printf("Speed: %d, %s duplex%s\n", phydev->speed,
Mario Sixc29fcc72018-01-15 11:08:21 +0100226 (phydev->duplex) ? "full" : "half",
227 (phydev->port == PORT_FIBRE) ? ", fiber mode" : "");
Mingkai Hue0653bf2011-01-27 12:52:46 +0800228}
wdenkbfad55d2005-03-14 23:56:42 +0000229
Bin Meng80b1a1c2016-01-11 22:41:21 -0800230/*
231 * This returns the status bits of the device. The return value
232 * is never checked, and this is what the 8260 driver did, so we
233 * do the same. Presumably, this would be zero if there were no
234 * errors
235 */
Bin Meng1048f612016-01-11 22:41:24 -0800236static int tsec_send(struct udevice *dev, void *packet, int length)
Bin Meng80b1a1c2016-01-11 22:41:21 -0800237{
Simon Glass95588622020-12-22 19:30:28 -0700238 struct tsec_private *priv;
239 struct tsec __iomem *regs;
Bin Meng80b1a1c2016-01-11 22:41:21 -0800240 int result = 0;
Vladimir Olteana11c89d2019-07-19 00:29:55 +0300241 u16 status;
Bin Meng80b1a1c2016-01-11 22:41:21 -0800242 int i;
243
Simon Glass95588622020-12-22 19:30:28 -0700244 priv = dev_get_priv(dev);
Simon Glass95588622020-12-22 19:30:28 -0700245 regs = priv->regs;
Bin Meng80b1a1c2016-01-11 22:41:21 -0800246 /* Find an empty buffer descriptor */
247 for (i = 0;
248 in_be16(&priv->txbd[priv->tx_idx].status) & TXBD_READY;
249 i++) {
250 if (i >= TOUT_LOOP) {
Vladimir Oltean8ec8eaa2019-07-19 00:29:56 +0300251 printf("%s: tsec: tx buffers full\n", dev->name);
Bin Meng80b1a1c2016-01-11 22:41:21 -0800252 return result;
253 }
254 }
255
256 out_be32(&priv->txbd[priv->tx_idx].bufptr, (u32)packet);
257 out_be16(&priv->txbd[priv->tx_idx].length, length);
258 status = in_be16(&priv->txbd[priv->tx_idx].status);
259 out_be16(&priv->txbd[priv->tx_idx].status, status |
260 (TXBD_READY | TXBD_LAST | TXBD_CRC | TXBD_INTERRUPT));
261
262 /* Tell the DMA to go */
263 out_be32(&regs->tstat, TSTAT_CLEAR_THALT);
264
265 /* Wait for buffer to be transmitted */
266 for (i = 0;
267 in_be16(&priv->txbd[priv->tx_idx].status) & TXBD_READY;
268 i++) {
269 if (i >= TOUT_LOOP) {
Vladimir Oltean8ec8eaa2019-07-19 00:29:56 +0300270 printf("%s: tsec: tx error\n", dev->name);
Bin Meng80b1a1c2016-01-11 22:41:21 -0800271 return result;
272 }
273 }
274
275 priv->tx_idx = (priv->tx_idx + 1) % TX_BUF_CNT;
276 result = in_be16(&priv->txbd[priv->tx_idx].status) & TXBD_STATS;
277
278 return result;
279}
280
J. NeuschÀfer46d28712025-02-16 22:18:12 +0100281static int tsec_free_pkt(struct udevice *dev, uchar *packet, int length)
282{
283 struct tsec_private *priv = (struct tsec_private *)dev_get_priv(dev);
284 u16 status;
285
286 out_be16(&priv->rxbd[priv->rx_idx].length, 0);
287
288 status = RXBD_EMPTY;
289 /* Set the wrap bit if this is the last element in the list */
290 if ((priv->rx_idx + 1) == PKTBUFSRX)
291 status |= RXBD_WRAP;
292 out_be16(&priv->rxbd[priv->rx_idx].status, status);
293
294 priv->rx_idx = (priv->rx_idx + 1) % PKTBUFSRX;
295
296 return 0;
297}
298
Bin Meng1048f612016-01-11 22:41:24 -0800299static int tsec_recv(struct udevice *dev, int flags, uchar **packetp)
300{
Simon Glass95588622020-12-22 19:30:28 -0700301 struct tsec_private *priv = (struct tsec_private *)dev_get_priv(dev);
Bin Meng1048f612016-01-11 22:41:24 -0800302 struct tsec __iomem *regs = priv->regs;
303 int ret = -1;
304
305 if (!(in_be16(&priv->rxbd[priv->rx_idx].status) & RXBD_EMPTY)) {
306 int length = in_be16(&priv->rxbd[priv->rx_idx].length);
Mario Sixc29fcc72018-01-15 11:08:21 +0100307 u16 status = in_be16(&priv->rxbd[priv->rx_idx].status);
308 u32 buf;
Bin Meng1048f612016-01-11 22:41:24 -0800309
310 /* Send the packet up if there were no errors */
311 if (!(status & RXBD_STATS)) {
312 buf = in_be32(&priv->rxbd[priv->rx_idx].bufptr);
313 *packetp = (uchar *)buf;
314 ret = length - 4;
315 } else {
316 printf("Got error %x\n", (status & RXBD_STATS));
J. NeuschÀfer3b03c952025-02-16 22:18:13 +0100317
318 /* Rearm the packet buffer */
319 tsec_free_pkt(dev, NULL, 0);
Bin Meng1048f612016-01-11 22:41:24 -0800320 }
321 }
322
323 if (in_be32(&regs->ievent) & IEVENT_BSY) {
324 out_be32(&regs->ievent, IEVENT_BSY);
325 out_be32(&regs->rstat, RSTAT_CLEAR_RHALT);
326 }
327
328 return ret;
329}
330
Bin Meng1048f612016-01-11 22:41:24 -0800331static void tsec_halt(struct udevice *dev)
Bin Meng80b1a1c2016-01-11 22:41:21 -0800332{
Simon Glass95588622020-12-22 19:30:28 -0700333 struct tsec_private *priv;
334 struct tsec __iomem *regs;
Simon Glass95588622020-12-22 19:30:28 -0700335 priv = dev_get_priv(dev);
Simon Glass95588622020-12-22 19:30:28 -0700336 regs = priv->regs;
Bin Meng80b1a1c2016-01-11 22:41:21 -0800337
338 clrbits_be32(&regs->dmactrl, DMACTRL_GRS | DMACTRL_GTS);
339 setbits_be32(&regs->dmactrl, DMACTRL_GRS | DMACTRL_GTS);
340
341 while ((in_be32(&regs->ievent) & (IEVENT_GRSC | IEVENT_GTSC))
342 != (IEVENT_GRSC | IEVENT_GTSC))
343 ;
344
345 clrbits_be32(&regs->maccfg1, MACCFG1_TX_EN | MACCFG1_RX_EN);
346
347 /* Shut down the PHY, as needed */
348 phy_shutdown(priv->phydev);
349}
350
chenhui zhaoc8caa8a2011-10-03 08:38:50 -0500351#ifdef CONFIG_SYS_FSL_ERRATUM_NMG_ETSEC129
352/*
353 * When MACCFG1[Rx_EN] is enabled during system boot as part
354 * of the eTSEC port initialization sequence,
355 * the eTSEC Rx logic may not be properly initialized.
356 */
Bin Meng18864072021-11-01 14:15:12 +0800357static void redundant_init(struct tsec_private *priv)
chenhui zhaoc8caa8a2011-10-03 08:38:50 -0500358{
Claudiu Manoilcd0c4122013-09-30 12:44:42 +0300359 struct tsec __iomem *regs = priv->regs;
chenhui zhaoc8caa8a2011-10-03 08:38:50 -0500360 uint t, count = 0;
361 int fail = 1;
362 static const u8 pkt[] = {
363 0x00, 0x1e, 0x4f, 0x12, 0xcb, 0x2c, 0x00, 0x25,
364 0x64, 0xbb, 0xd1, 0xab, 0x08, 0x00, 0x45, 0x00,
365 0x00, 0x5c, 0xdd, 0x22, 0x00, 0x00, 0x80, 0x01,
366 0x1f, 0x71, 0x0a, 0xc1, 0x14, 0x22, 0x0a, 0xc1,
367 0x14, 0x6a, 0x08, 0x00, 0xef, 0x7e, 0x02, 0x00,
368 0x94, 0x05, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,
369 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e,
370 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76,
371 0x77, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
372 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
373 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
374 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
375 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70,
376 0x71, 0x72};
377
378 /* Enable promiscuous mode */
Vladimir Oltean3556c4d2021-09-29 18:04:36 +0300379 setbits_be32(&regs->rctrl, RCTRL_PROM);
chenhui zhaoc8caa8a2011-10-03 08:38:50 -0500380 /* Enable loopback mode */
381 setbits_be32(&regs->maccfg1, MACCFG1_LOOPBACK);
382 /* Enable transmit and receive */
383 setbits_be32(&regs->maccfg1, MACCFG1_RX_EN | MACCFG1_TX_EN);
384
385 /* Tell the DMA it is clear to go */
386 setbits_be32(&regs->dmactrl, DMACTRL_INIT_SETTINGS);
387 out_be32(&regs->tstat, TSTAT_CLEAR_THALT);
388 out_be32(&regs->rstat, RSTAT_CLEAR_RHALT);
389 clrbits_be32(&regs->dmactrl, DMACTRL_GRS | DMACTRL_GTS);
390
391 do {
Mario Sixc29fcc72018-01-15 11:08:21 +0100392 u16 status;
393
Bin Menge86a6cd2016-01-11 22:41:22 -0800394 tsec_send(priv->dev, (void *)pkt, sizeof(pkt));
chenhui zhaoc8caa8a2011-10-03 08:38:50 -0500395
396 /* Wait for buffer to be received */
Bin Meng1120c542016-01-11 22:41:20 -0800397 for (t = 0;
398 in_be16(&priv->rxbd[priv->rx_idx].status) & RXBD_EMPTY;
Bin Meng76f53992016-01-11 22:41:19 -0800399 t++) {
chenhui zhaoc8caa8a2011-10-03 08:38:50 -0500400 if (t >= 10 * TOUT_LOOP) {
Bin Menge86a6cd2016-01-11 22:41:22 -0800401 printf("%s: tsec: rx error\n", priv->dev->name);
chenhui zhaoc8caa8a2011-10-03 08:38:50 -0500402 break;
403 }
404 }
405
Bin Meng76f53992016-01-11 22:41:19 -0800406 if (!memcmp(pkt, net_rx_packets[priv->rx_idx], sizeof(pkt)))
chenhui zhaoc8caa8a2011-10-03 08:38:50 -0500407 fail = 0;
408
Bin Meng1120c542016-01-11 22:41:20 -0800409 out_be16(&priv->rxbd[priv->rx_idx].length, 0);
Claudiu Manoileec416b2013-10-04 19:13:53 +0300410 status = RXBD_EMPTY;
Bin Meng76f53992016-01-11 22:41:19 -0800411 if ((priv->rx_idx + 1) == PKTBUFSRX)
Claudiu Manoileec416b2013-10-04 19:13:53 +0300412 status |= RXBD_WRAP;
Bin Meng1120c542016-01-11 22:41:20 -0800413 out_be16(&priv->rxbd[priv->rx_idx].status, status);
Bin Meng76f53992016-01-11 22:41:19 -0800414 priv->rx_idx = (priv->rx_idx + 1) % PKTBUFSRX;
chenhui zhaoc8caa8a2011-10-03 08:38:50 -0500415
416 if (in_be32(&regs->ievent) & IEVENT_BSY) {
417 out_be32(&regs->ievent, IEVENT_BSY);
418 out_be32(&regs->rstat, RSTAT_CLEAR_RHALT);
419 }
420 if (fail) {
421 printf("loopback recv packet error!\n");
422 clrbits_be32(&regs->maccfg1, MACCFG1_RX_EN);
423 udelay(1000);
424 setbits_be32(&regs->maccfg1, MACCFG1_RX_EN);
425 }
426 } while ((count++ < 4) && (fail == 1));
427
428 if (fail)
429 panic("eTSEC init fail!\n");
430 /* Disable promiscuous mode */
Vladimir Oltean3556c4d2021-09-29 18:04:36 +0300431 clrbits_be32(&regs->rctrl, RCTRL_PROM);
chenhui zhaoc8caa8a2011-10-03 08:38:50 -0500432 /* Disable loopback mode */
433 clrbits_be32(&regs->maccfg1, MACCFG1_LOOPBACK);
434}
435#endif
436
Bin Meng79cd33a2016-01-11 22:41:18 -0800437/*
438 * Set up the buffers and their descriptors, and bring up the
Mingkai Hue0653bf2011-01-27 12:52:46 +0800439 * interface
Jon Loeligerb7ced082006-10-10 17:03:43 -0500440 */
Bin Menge86a6cd2016-01-11 22:41:22 -0800441static void startup_tsec(struct tsec_private *priv)
Wolfgang Denkf0c4e462006-03-12 22:50:55 +0100442{
Claudiu Manoilcd0c4122013-09-30 12:44:42 +0300443 struct tsec __iomem *regs = priv->regs;
Mario Sixc29fcc72018-01-15 11:08:21 +0100444 u16 status;
Claudiu Manoileec416b2013-10-04 19:13:53 +0300445 int i;
Wolfgang Denkf0c4e462006-03-12 22:50:55 +0100446
Andy Fleming422effd2011-04-08 02:10:54 -0500447 /* reset the indices to zero */
Bin Meng76f53992016-01-11 22:41:19 -0800448 priv->rx_idx = 0;
449 priv->tx_idx = 0;
chenhui zhaoc8caa8a2011-10-03 08:38:50 -0500450#ifdef CONFIG_SYS_FSL_ERRATUM_NMG_ETSEC129
451 uint svr;
452#endif
Andy Fleming422effd2011-04-08 02:10:54 -0500453
Mingkai Hue0653bf2011-01-27 12:52:46 +0800454 /* Point to the buffer descriptors */
Bin Meng1120c542016-01-11 22:41:20 -0800455 out_be32(&regs->tbase, (u32)&priv->txbd[0]);
456 out_be32(&regs->rbase, (u32)&priv->rxbd[0]);
Wolfgang Denkf0c4e462006-03-12 22:50:55 +0100457
Mingkai Hue0653bf2011-01-27 12:52:46 +0800458 /* Initialize the Rx Buffer descriptors */
459 for (i = 0; i < PKTBUFSRX; i++) {
Bin Meng1120c542016-01-11 22:41:20 -0800460 out_be16(&priv->rxbd[i].status, RXBD_EMPTY);
461 out_be16(&priv->rxbd[i].length, 0);
462 out_be32(&priv->rxbd[i].bufptr, (u32)net_rx_packets[i]);
Mingkai Hue0653bf2011-01-27 12:52:46 +0800463 }
Bin Meng1120c542016-01-11 22:41:20 -0800464 status = in_be16(&priv->rxbd[PKTBUFSRX - 1].status);
465 out_be16(&priv->rxbd[PKTBUFSRX - 1].status, status | RXBD_WRAP);
Wolfgang Denkf0c4e462006-03-12 22:50:55 +0100466
Mingkai Hue0653bf2011-01-27 12:52:46 +0800467 /* Initialize the TX Buffer Descriptors */
468 for (i = 0; i < TX_BUF_CNT; i++) {
Bin Meng1120c542016-01-11 22:41:20 -0800469 out_be16(&priv->txbd[i].status, 0);
470 out_be16(&priv->txbd[i].length, 0);
471 out_be32(&priv->txbd[i].bufptr, 0);
Wolfgang Denkf0c4e462006-03-12 22:50:55 +0100472 }
Bin Meng1120c542016-01-11 22:41:20 -0800473 status = in_be16(&priv->txbd[TX_BUF_CNT - 1].status);
474 out_be16(&priv->txbd[TX_BUF_CNT - 1].status, status | TXBD_WRAP);
Wolfgang Denkf0c4e462006-03-12 22:50:55 +0100475
chenhui zhaoc8caa8a2011-10-03 08:38:50 -0500476#ifdef CONFIG_SYS_FSL_ERRATUM_NMG_ETSEC129
477 svr = get_svr();
478 if ((SVR_MAJ(svr) == 1) || IS_SVR_REV(svr, 2, 0))
Bin Menge86a6cd2016-01-11 22:41:22 -0800479 redundant_init(priv);
chenhui zhaoc8caa8a2011-10-03 08:38:50 -0500480#endif
Mingkai Hue0653bf2011-01-27 12:52:46 +0800481 /* Enable Transmit and Receive */
482 setbits_be32(&regs->maccfg1, MACCFG1_RX_EN | MACCFG1_TX_EN);
483
484 /* Tell the DMA it is clear to go */
485 setbits_be32(&regs->dmactrl, DMACTRL_INIT_SETTINGS);
486 out_be32(&regs->tstat, TSTAT_CLEAR_THALT);
487 out_be32(&regs->rstat, RSTAT_CLEAR_RHALT);
488 clrbits_be32(&regs->dmactrl, DMACTRL_GRS | DMACTRL_GTS);
Wolfgang Denkf0c4e462006-03-12 22:50:55 +0100489}
490
Bin Meng79cd33a2016-01-11 22:41:18 -0800491/*
Bin Meng79cd33a2016-01-11 22:41:18 -0800492 * Initializes data structures and registers for the controller,
493 * and brings the interface up. Returns the link status, meaning
Mingkai Hue0653bf2011-01-27 12:52:46 +0800494 * that it returns success if the link is up, failure otherwise.
Bin Meng79cd33a2016-01-11 22:41:18 -0800495 * This allows U-Boot to find the first active controller.
Jon Loeligerb7ced082006-10-10 17:03:43 -0500496 */
Bin Meng1048f612016-01-11 22:41:24 -0800497static int tsec_init(struct udevice *dev)
wdenka445ddf2004-06-09 00:34:46 +0000498{
Simon Glass95588622020-12-22 19:30:28 -0700499 struct tsec_private *priv;
500 struct tsec __iomem *regs;
Simon Glassfa20e932020-12-03 16:55:20 -0700501 struct eth_pdata *pdata = dev_get_plat(dev);
Claudiu Manoildcb38fe2013-09-30 12:44:47 +0300502 u32 tempval;
Timur Tabi42387462012-07-09 08:52:43 +0000503 int ret;
wdenka445ddf2004-06-09 00:34:46 +0000504
Simon Glass95588622020-12-22 19:30:28 -0700505 priv = dev_get_priv(dev);
Simon Glass95588622020-12-22 19:30:28 -0700506 regs = priv->regs;
Mingkai Hue0653bf2011-01-27 12:52:46 +0800507 /* Make sure the controller is stopped */
508 tsec_halt(dev);
wdenka445ddf2004-06-09 00:34:46 +0000509
Mingkai Hue0653bf2011-01-27 12:52:46 +0800510 /* Init MACCFG2. Defaults to GMII */
511 out_be32(&regs->maccfg2, MACCFG2_INIT_SETTINGS);
wdenka445ddf2004-06-09 00:34:46 +0000512
Mingkai Hue0653bf2011-01-27 12:52:46 +0800513 /* Init ECNTRL */
514 out_be32(&regs->ecntrl, ECNTRL_INIT_SETTINGS);
wdenka445ddf2004-06-09 00:34:46 +0000515
Bin Meng79cd33a2016-01-11 22:41:18 -0800516 /*
517 * Copy the station address into the address registers.
Claudiu Manoildcb38fe2013-09-30 12:44:47 +0300518 * For a station address of 0x12345678ABCD in transmission
519 * order (BE), MACnADDR1 is set to 0xCDAB7856 and
520 * MACnADDR2 is set to 0x34120000.
521 */
Bin Meng1048f612016-01-11 22:41:24 -0800522 tempval = (pdata->enetaddr[5] << 24) | (pdata->enetaddr[4] << 16) |
523 (pdata->enetaddr[3] << 8) | pdata->enetaddr[2];
wdenka445ddf2004-06-09 00:34:46 +0000524
Mingkai Hue0653bf2011-01-27 12:52:46 +0800525 out_be32(&regs->macstnaddr1, tempval);
wdenka445ddf2004-06-09 00:34:46 +0000526
Bin Meng1048f612016-01-11 22:41:24 -0800527 tempval = (pdata->enetaddr[1] << 24) | (pdata->enetaddr[0] << 16);
wdenka445ddf2004-06-09 00:34:46 +0000528
Mingkai Hue0653bf2011-01-27 12:52:46 +0800529 out_be32(&regs->macstnaddr2, tempval);
wdenka445ddf2004-06-09 00:34:46 +0000530
Mingkai Hue0653bf2011-01-27 12:52:46 +0800531 /* Clear out (for the most part) the other registers */
532 init_registers(regs);
533
534 /* Ready the device for tx/rx */
Bin Menge86a6cd2016-01-11 22:41:22 -0800535 startup_tsec(priv);
Mingkai Hue0653bf2011-01-27 12:52:46 +0800536
Andy Fleming422effd2011-04-08 02:10:54 -0500537 /* Start up the PHY */
Timur Tabi42387462012-07-09 08:52:43 +0000538 ret = phy_startup(priv->phydev);
539 if (ret) {
540 printf("Could not initialize PHY %s\n",
541 priv->phydev->dev->name);
542 return ret;
543 }
Andy Fleming422effd2011-04-08 02:10:54 -0500544
545 adjust_link(priv, priv->phydev);
546
Mingkai Hue0653bf2011-01-27 12:52:46 +0800547 /* If there's no link, fail */
Andy Fleming422effd2011-04-08 02:10:54 -0500548 return priv->phydev->link ? 0 : -1;
549}
550
Ramon Fried8ca1e6b2021-09-28 18:49:02 +0300551static phy_interface_t __maybe_unused tsec_get_interface(struct tsec_private *priv)
Andy Fleming422effd2011-04-08 02:10:54 -0500552{
Claudiu Manoilcd0c4122013-09-30 12:44:42 +0300553 struct tsec __iomem *regs = priv->regs;
Andy Fleming422effd2011-04-08 02:10:54 -0500554 u32 ecntrl;
555
556 ecntrl = in_be32(&regs->ecntrl);
557
558 if (ecntrl & ECNTRL_SGMII_MODE)
559 return PHY_INTERFACE_MODE_SGMII;
560
561 if (ecntrl & ECNTRL_TBI_MODE) {
562 if (ecntrl & ECNTRL_REDUCED_MODE)
563 return PHY_INTERFACE_MODE_RTBI;
564 else
565 return PHY_INTERFACE_MODE_TBI;
566 }
567
568 if (ecntrl & ECNTRL_REDUCED_MODE) {
Mario Sixc29fcc72018-01-15 11:08:21 +0100569 phy_interface_t interface;
570
Andy Fleming422effd2011-04-08 02:10:54 -0500571 if (ecntrl & ECNTRL_REDUCED_MII_MODE)
572 return PHY_INTERFACE_MODE_RMII;
Andy Fleming422effd2011-04-08 02:10:54 -0500573
Mario Sixc29fcc72018-01-15 11:08:21 +0100574 interface = priv->interface;
Andy Fleming422effd2011-04-08 02:10:54 -0500575
Mario Sixc29fcc72018-01-15 11:08:21 +0100576 /*
577 * This isn't autodetected, so it must
578 * be set by the platform code.
579 */
580 if (interface == PHY_INTERFACE_MODE_RGMII_ID ||
581 interface == PHY_INTERFACE_MODE_RGMII_TXID ||
582 interface == PHY_INTERFACE_MODE_RGMII_RXID)
583 return interface;
584
585 return PHY_INTERFACE_MODE_RGMII;
Andy Fleming422effd2011-04-08 02:10:54 -0500586 }
587
588 if (priv->flags & TSEC_GIGABIT)
589 return PHY_INTERFACE_MODE_GMII;
590
591 return PHY_INTERFACE_MODE_MII;
Mingkai Hue0653bf2011-01-27 12:52:46 +0800592}
593
Bin Meng79cd33a2016-01-11 22:41:18 -0800594/*
595 * Discover which PHY is attached to the device, and configure it
Mingkai Hue0653bf2011-01-27 12:52:46 +0800596 * properly. If the PHY is not recognized, then return 0
597 * (failure). Otherwise, return 1
wdenk78924a72004-04-18 21:45:42 +0000598 */
Bin Menge86a6cd2016-01-11 22:41:22 -0800599static int init_phy(struct tsec_private *priv)
wdenk78924a72004-04-18 21:45:42 +0000600{
Andy Fleming422effd2011-04-08 02:10:54 -0500601 struct phy_device *phydev;
Claudiu Manoilcd0c4122013-09-30 12:44:42 +0300602 struct tsec __iomem *regs = priv->regs;
Andy Fleming422effd2011-04-08 02:10:54 -0500603 u32 supported = (SUPPORTED_10baseT_Half |
604 SUPPORTED_10baseT_Full |
605 SUPPORTED_100baseT_Half |
606 SUPPORTED_100baseT_Full);
607
608 if (priv->flags & TSEC_GIGABIT)
609 supported |= SUPPORTED_1000baseT_Full;
wdenk78924a72004-04-18 21:45:42 +0000610
Mingkai Hue0653bf2011-01-27 12:52:46 +0800611 /* Assign a Physical address to the TBI */
Bin Meng74314f12016-01-11 22:41:25 -0800612 out_be32(&regs->tbipa, priv->tbiaddr);
Mingkai Hue0653bf2011-01-27 12:52:46 +0800613
Andy Fleming422effd2011-04-08 02:10:54 -0500614 if (priv->interface == PHY_INTERFACE_MODE_SGMII)
615 tsec_configure_serdes(priv);
Mingkai Hue0653bf2011-01-27 12:52:46 +0800616
Tom Rinie8020a52022-11-27 10:25:04 -0500617#if defined(CONFIG_DM_MDIO)
Vladimir Oltean26980e92021-03-14 20:14:56 +0800618 phydev = dm_eth_phy_connect(priv->dev);
Hou Zhiqiangd35de972020-07-16 18:09:12 +0800619#else
Bin Menge86a6cd2016-01-11 22:41:22 -0800620 phydev = phy_connect(priv->bus, priv->phyaddr, priv->dev,
621 priv->interface);
Hou Zhiqiangd35de972020-07-16 18:09:12 +0800622#endif
Claudiu Manoilfe56fec2013-12-10 15:21:04 +0200623 if (!phydev)
624 return 0;
Mingkai Hue0653bf2011-01-27 12:52:46 +0800625
Andy Fleming422effd2011-04-08 02:10:54 -0500626 phydev->supported &= supported;
627 phydev->advertising = phydev->supported;
wdenka445ddf2004-06-09 00:34:46 +0000628
Andy Fleming422effd2011-04-08 02:10:54 -0500629 priv->phydev = phydev;
wdenk78924a72004-04-18 21:45:42 +0000630
Andy Fleming422effd2011-04-08 02:10:54 -0500631 phy_config(phydev);
Mingkai Hue0653bf2011-01-27 12:52:46 +0800632
633 return 1;
wdenk78924a72004-04-18 21:45:42 +0000634}
635
Bin Meng1048f612016-01-11 22:41:24 -0800636int tsec_probe(struct udevice *dev)
637{
Simon Glassfa20e932020-12-03 16:55:20 -0700638 struct eth_pdata *pdata = dev_get_plat(dev);
Vladimir Olteana11c89d2019-07-19 00:29:55 +0300639 struct tsec_private *priv = dev_get_priv(dev);
Mario Six00ba0552018-01-15 11:08:23 +0100640 struct ofnode_phandle_args phandle_args;
Tom Rini6a5dccc2022-11-16 13:10:41 -0500641 u32 tbiaddr = CFG_SYS_TBIPA_VALUE;
Hou Zhiqiang5966b6d2020-07-16 18:09:14 +0800642 struct tsec_data *data;
Bin Mengdbc4c2e2021-03-14 20:15:01 +0800643 ofnode parent, child;
Vladimir Oltean3095e342019-07-19 00:29:54 +0300644 fdt_addr_t reg;
Aleksandar Gerasimovski1d3c81b2021-06-04 13:40:58 +0000645 u32 max_speed;
Bin Meng1048f612016-01-11 22:41:24 -0800646 int ret;
647
Hou Zhiqiang5966b6d2020-07-16 18:09:14 +0800648 data = (struct tsec_data *)dev_get_driver_data(dev);
649
Mario Six00ba0552018-01-15 11:08:23 +0100650 pdata->iobase = (phys_addr_t)dev_read_addr(dev);
Bin Mengdbc4c2e2021-03-14 20:15:01 +0800651 if (pdata->iobase == FDT_ADDR_T_NONE) {
652 ofnode_for_each_subnode(child, dev_ofnode(dev)) {
653 if (strncmp(ofnode_get_name(child), "queue-group",
654 strlen("queue-group")))
655 continue;
656
657 reg = ofnode_get_addr(child);
658 if (reg == FDT_ADDR_T_NONE) {
659 printf("No 'reg' property of <queue-group>\n");
660 return -ENOENT;
661 }
662 pdata->iobase = reg;
663
664 /*
665 * if there are multiple queue groups,
666 * only the first one is used.
667 */
668 break;
669 }
670
671 if (!ofnode_valid(child)) {
672 printf("No child node for <queue-group>?\n");
673 return -ENOENT;
674 }
675 }
676
Bin Meng8699b2e2021-03-14 20:14:59 +0800677 priv->regs = map_physmem(pdata->iobase, 0, MAP_NOCACHE);
Bin Meng1048f612016-01-11 22:41:24 -0800678
Vladimir Olteand6392202019-07-19 00:29:53 +0300679 ret = dev_read_phandle_with_args(dev, "tbi-handle", NULL, 0, 0,
680 &phandle_args);
Hou Zhiqiang53907d52020-05-03 22:48:43 +0800681 if (ret == 0) {
Vladimir Olteand6392202019-07-19 00:29:53 +0300682 ofnode_read_u32(phandle_args.node, "reg", &tbiaddr);
683
Hou Zhiqiang53907d52020-05-03 22:48:43 +0800684 parent = ofnode_get_parent(phandle_args.node);
685 if (!ofnode_valid(parent)) {
686 printf("No parent node for TBI PHY?\n");
687 return -ENOENT;
688 }
689
690 reg = ofnode_get_addr_index(parent, 0);
691 if (reg == FDT_ADDR_T_NONE) {
692 printf("No 'reg' property of MII for TBI PHY\n");
693 return -ENOENT;
694 }
695
Hou Zhiqiang5966b6d2020-07-16 18:09:14 +0800696 priv->phyregs_sgmii = map_physmem(reg + data->mdio_regs_off,
Hou Zhiqiang53907d52020-05-03 22:48:43 +0800697 0, MAP_NOCACHE);
698 }
699
Vladimir Olteand6392202019-07-19 00:29:53 +0300700 priv->tbiaddr = tbiaddr;
Bin Meng74314f12016-01-11 22:41:25 -0800701
Marek BehĂșnbc194772022-04-07 00:33:01 +0200702 pdata->phy_interface = dev_read_phy_mode(dev);
Marek BehĂșn48631e42022-04-07 00:33:03 +0200703 if (pdata->phy_interface == PHY_INTERFACE_MODE_NA)
Vladimir Oltean0e577572021-09-18 15:46:54 +0300704 pdata->phy_interface = tsec_get_interface(priv);
705
Bin Meng1048f612016-01-11 22:41:24 -0800706 priv->interface = pdata->phy_interface;
707
Aleksandar Gerasimovski1d3c81b2021-06-04 13:40:58 +0000708 /* Check for speed limit, default is 1000Mbps */
709 max_speed = dev_read_u32_default(dev, "max-speed", 1000);
710
Bin Meng1048f612016-01-11 22:41:24 -0800711 /* Initialize flags */
Aleksandar Gerasimovski1d3c81b2021-06-04 13:40:58 +0000712 if (max_speed == 1000)
713 priv->flags = TSEC_GIGABIT;
Bin Meng1048f612016-01-11 22:41:24 -0800714 if (priv->interface == PHY_INTERFACE_MODE_SGMII)
715 priv->flags |= TSEC_SGMII;
716
Bin Meng1048f612016-01-11 22:41:24 -0800717 /* Reset the MAC */
718 setbits_be32(&priv->regs->maccfg1, MACCFG1_SOFT_RESET);
719 udelay(2); /* Soft Reset must be asserted for 3 TX clocks */
720 clrbits_be32(&priv->regs->maccfg1, MACCFG1_SOFT_RESET);
721
722 priv->dev = dev;
723 priv->bus = miiphy_get_dev_by_name(dev->name);
724
725 /* Try to initialize PHY here, and return */
726 return !init_phy(priv);
727}
728
729int tsec_remove(struct udevice *dev)
730{
Simon Glass95588622020-12-22 19:30:28 -0700731 struct tsec_private *priv = dev_get_priv(dev);
Bin Meng1048f612016-01-11 22:41:24 -0800732
733 free(priv->phydev);
734 mdio_unregister(priv->bus);
735 mdio_free(priv->bus);
736
737 return 0;
738}
739
740static const struct eth_ops tsec_ops = {
741 .start = tsec_init,
742 .send = tsec_send,
743 .recv = tsec_recv,
744 .free_pkt = tsec_free_pkt,
745 .stop = tsec_halt,
Bin Meng1048f612016-01-11 22:41:24 -0800746 .mcast = tsec_mcast_addr,
Vladimir Oltean3556c4d2021-09-29 18:04:36 +0300747 .set_promisc = tsec_set_promisc,
Bin Meng1048f612016-01-11 22:41:24 -0800748};
749
Hou Zhiqiang5966b6d2020-07-16 18:09:14 +0800750static struct tsec_data etsec2_data = {
751 .mdio_regs_off = TSEC_MDIO_REGS_OFFSET,
752};
753
754static struct tsec_data gianfar_data = {
755 .mdio_regs_off = 0x0,
756};
757
Bin Meng1048f612016-01-11 22:41:24 -0800758static const struct udevice_id tsec_ids[] = {
Hou Zhiqiang5966b6d2020-07-16 18:09:14 +0800759 { .compatible = "fsl,etsec2", .data = (ulong)&etsec2_data },
760 { .compatible = "gianfar", .data = (ulong)&gianfar_data },
Bin Meng1048f612016-01-11 22:41:24 -0800761 { }
762};
763
764U_BOOT_DRIVER(eth_tsec) = {
765 .name = "tsec",
766 .id = UCLASS_ETH,
767 .of_match = tsec_ids,
768 .probe = tsec_probe,
769 .remove = tsec_remove,
770 .ops = &tsec_ops,
Simon Glass8a2b47f2020-12-03 16:55:17 -0700771 .priv_auto = sizeof(struct tsec_private),
Simon Glass71fa5b42020-12-03 16:55:18 -0700772 .plat_auto = sizeof(struct eth_pdata),
Bin Meng1048f612016-01-11 22:41:24 -0800773 .flags = DM_FLAG_ALLOC_PRIV_DMA,
774};