blob: 0156324032bf3ed450084a02504d9908a9f4f3f6 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Simon Glassc6011d22016-01-17 14:52:00 -07002/*
3 * (C) Copyright 2001-2015
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * Joe Hershberger, National Instruments
Simon Glassc6011d22016-01-17 14:52:00 -07006 */
7
8#include <common.h>
Simon Glass1ea97892020-05-10 11:40:00 -06009#include <bootstage.h>
Simon Glassc6011d22016-01-17 14:52:00 -070010#include <dm.h>
Simon Glass5e6201b2019-08-01 09:46:51 -060011#include <env.h>
Simon Glass0f2af882020-05-10 11:40:05 -060012#include <log.h>
Simon Glassc6011d22016-01-17 14:52:00 -070013#include <net.h>
14#include <dm/device-internal.h>
15#include <dm/uclass-internal.h>
Ramon Friedac598c12019-07-18 21:43:30 +030016#include <net/pcap.h>
Simon Glassc6011d22016-01-17 14:52:00 -070017#include "eth_internal.h"
Ye Licd5bb772020-05-03 22:41:14 +080018#include <eth_phy.h>
Simon Glassc6011d22016-01-17 14:52:00 -070019
Simon Glass004b8912016-01-30 15:45:14 -070020DECLARE_GLOBAL_DATA_PTR;
21
Simon Glassc6011d22016-01-17 14:52:00 -070022/**
23 * struct eth_device_priv - private structure for each Ethernet device
24 *
25 * @state: The state of the Ethernet MAC driver (defined by enum eth_state_t)
26 */
27struct eth_device_priv {
28 enum eth_state_t state;
29};
30
31/**
32 * struct eth_uclass_priv - The structure attached to the uclass itself
33 *
34 * @current: The Ethernet device that the network functions are using
35 */
36struct eth_uclass_priv {
37 struct udevice *current;
38};
39
40/* eth_errno - This stores the most recent failure code from DM functions */
41static int eth_errno;
42
43static struct eth_uclass_priv *eth_get_uclass_priv(void)
44{
45 struct uclass *uc;
Peng Fan46ec1042020-05-03 22:41:13 +080046 int ret;
Simon Glassc6011d22016-01-17 14:52:00 -070047
Peng Fan46ec1042020-05-03 22:41:13 +080048 ret = uclass_get(UCLASS_ETH, &uc);
49 if (ret)
50 return NULL;
51
Simon Glassc6011d22016-01-17 14:52:00 -070052 assert(uc);
Simon Glass95588622020-12-22 19:30:28 -070053 return uclass_get_priv(uc);
Simon Glassc6011d22016-01-17 14:52:00 -070054}
55
56void eth_set_current_to_next(void)
57{
58 struct eth_uclass_priv *uc_priv;
59
60 uc_priv = eth_get_uclass_priv();
61 if (uc_priv->current)
62 uclass_next_device(&uc_priv->current);
63 if (!uc_priv->current)
64 uclass_first_device(UCLASS_ETH, &uc_priv->current);
65}
66
67/*
68 * Typically this will simply return the active device.
69 * In the case where the most recent active device was unset, this will attempt
70 * to return the first device. If that device doesn't exist or fails to probe,
71 * this function will return NULL.
72 */
73struct udevice *eth_get_dev(void)
74{
75 struct eth_uclass_priv *uc_priv;
76
77 uc_priv = eth_get_uclass_priv();
Sean Anderson35e82982020-09-12 17:45:43 -040078 if (!uc_priv)
79 return NULL;
80
Simon Glassc6011d22016-01-17 14:52:00 -070081 if (!uc_priv->current)
82 eth_errno = uclass_first_device(UCLASS_ETH,
83 &uc_priv->current);
84 return uc_priv->current;
85}
86
87/*
88 * Typically this will just store a device pointer.
89 * In case it was not probed, we will attempt to do so.
90 * dev may be NULL to unset the active device.
91 */
92void eth_set_dev(struct udevice *dev)
93{
94 if (dev && !device_active(dev)) {
95 eth_errno = device_probe(dev);
96 if (eth_errno)
97 dev = NULL;
98 }
99
100 eth_get_uclass_priv()->current = dev;
101}
102
103/*
104 * Find the udevice that either has the name passed in as devname or has an
105 * alias named devname.
106 */
107struct udevice *eth_get_dev_by_name(const char *devname)
108{
109 int seq = -1;
110 char *endp = NULL;
111 const char *startp = NULL;
112 struct udevice *it;
113 struct uclass *uc;
114 int len = strlen("eth");
Peng Fan46ec1042020-05-03 22:41:13 +0800115 int ret;
Simon Glassc6011d22016-01-17 14:52:00 -0700116
117 /* Must be longer than 3 to be an alias */
118 if (!strncmp(devname, "eth", len) && strlen(devname) > len) {
119 startp = devname + len;
120 seq = simple_strtoul(startp, &endp, 10);
121 }
122
Peng Fan46ec1042020-05-03 22:41:13 +0800123 ret = uclass_get(UCLASS_ETH, &uc);
124 if (ret)
125 return NULL;
126
Simon Glassc6011d22016-01-17 14:52:00 -0700127 uclass_foreach_dev(it, uc) {
128 /*
Simon Glassc6011d22016-01-17 14:52:00 -0700129 * We don't care about errors from probe here. Either they won't
130 * match an alias or it will match a literal name and we'll pick
131 * up the error when we try to probe again in eth_set_dev().
132 */
133 if (device_probe(it))
134 continue;
135 /* Check for the name or the sequence number to match */
136 if (strcmp(it->name, devname) == 0 ||
Simon Glass75e534b2020-12-16 21:20:07 -0700137 (endp > startp && dev_seq(it) == seq))
Simon Glassc6011d22016-01-17 14:52:00 -0700138 return it;
139 }
140
141 return NULL;
142}
143
144unsigned char *eth_get_ethaddr(void)
145{
146 struct eth_pdata *pdata;
147
148 if (eth_get_dev()) {
Simon Glass95588622020-12-22 19:30:28 -0700149 pdata = dev_get_plat(eth_get_dev());
Simon Glassc6011d22016-01-17 14:52:00 -0700150 return pdata->enetaddr;
151 }
152
153 return NULL;
154}
155
156/* Set active state without calling start on the driver */
157int eth_init_state_only(void)
158{
159 struct udevice *current;
160 struct eth_device_priv *priv;
161
162 current = eth_get_dev();
163 if (!current || !device_active(current))
164 return -EINVAL;
165
Simon Glass95588622020-12-22 19:30:28 -0700166 priv = dev_get_uclass_priv(current);
Simon Glassc6011d22016-01-17 14:52:00 -0700167 priv->state = ETH_STATE_ACTIVE;
168
169 return 0;
170}
171
172/* Set passive state without calling stop on the driver */
173void eth_halt_state_only(void)
174{
175 struct udevice *current;
176 struct eth_device_priv *priv;
177
178 current = eth_get_dev();
179 if (!current || !device_active(current))
180 return;
181
Simon Glass95588622020-12-22 19:30:28 -0700182 priv = dev_get_uclass_priv(current);
Simon Glassc6011d22016-01-17 14:52:00 -0700183 priv->state = ETH_STATE_PASSIVE;
184}
185
186int eth_get_dev_index(void)
187{
188 if (eth_get_dev())
Simon Glass75e534b2020-12-16 21:20:07 -0700189 return dev_seq(eth_get_dev());
Simon Glassc6011d22016-01-17 14:52:00 -0700190 return -1;
191}
192
193static int eth_write_hwaddr(struct udevice *dev)
194{
xypron.glpk@gmx.de0211e392017-05-16 05:07:01 +0200195 struct eth_pdata *pdata;
Simon Glassc6011d22016-01-17 14:52:00 -0700196 int ret = 0;
197
198 if (!dev || !device_active(dev))
199 return -EINVAL;
200
201 /* seq is valid since the device is active */
Simon Glass75e534b2020-12-16 21:20:07 -0700202 if (eth_get_ops(dev)->write_hwaddr && !eth_mac_skip(dev_seq(dev))) {
Simon Glass95588622020-12-22 19:30:28 -0700203 pdata = dev_get_plat(dev);
Simon Glassc6011d22016-01-17 14:52:00 -0700204 if (!is_valid_ethaddr(pdata->enetaddr)) {
205 printf("\nError: %s address %pM illegal value\n",
206 dev->name, pdata->enetaddr);
207 return -EINVAL;
208 }
209
210 /*
211 * Drivers are allowed to decide not to implement this at
212 * run-time. E.g. Some devices may use it and some may not.
213 */
214 ret = eth_get_ops(dev)->write_hwaddr(dev);
215 if (ret == -ENOSYS)
216 ret = 0;
217 if (ret)
218 printf("\nWarning: %s failed to set MAC address\n",
219 dev->name);
220 }
221
222 return ret;
223}
224
225static int on_ethaddr(const char *name, const char *value, enum env_op op,
226 int flags)
227{
228 int index;
229 int retval;
230 struct udevice *dev;
231
232 /* look for an index after "eth" */
233 index = simple_strtoul(name + 3, NULL, 10);
234
Simon Glass07e13382020-12-16 21:20:29 -0700235 retval = uclass_find_device_by_seq(UCLASS_ETH, index, &dev);
Simon Glassc6011d22016-01-17 14:52:00 -0700236 if (!retval) {
Simon Glass95588622020-12-22 19:30:28 -0700237 struct eth_pdata *pdata = dev_get_plat(dev);
Simon Glassc6011d22016-01-17 14:52:00 -0700238 switch (op) {
239 case env_op_create:
240 case env_op_overwrite:
Joe Hershberger8e7545e2019-09-13 19:21:16 -0500241 string_to_enetaddr(value, pdata->enetaddr);
Hannes Schmelzer3071f072016-09-02 14:48:17 +0200242 eth_write_hwaddr(dev);
Simon Glassc6011d22016-01-17 14:52:00 -0700243 break;
244 case env_op_delete:
oliver@schinagl.nl496904b2016-11-25 16:30:19 +0100245 memset(pdata->enetaddr, 0, ARP_HLEN);
Simon Glassc6011d22016-01-17 14:52:00 -0700246 }
247 }
248
249 return 0;
250}
251U_BOOT_ENV_CALLBACK(ethaddr, on_ethaddr);
252
253int eth_init(void)
254{
Simon Glass64b723f2017-08-03 12:22:12 -0600255 char *ethact = env_get("ethact");
256 char *ethrotate = env_get("ethrotate");
Simon Glassc6011d22016-01-17 14:52:00 -0700257 struct udevice *current = NULL;
258 struct udevice *old_current;
259 int ret = -ENODEV;
260
261 /*
262 * When 'ethrotate' variable is set to 'no' and 'ethact' variable
263 * is already set to an ethernet device, we should stick to 'ethact'.
264 */
265 if ((ethrotate != NULL) && (strcmp(ethrotate, "no") == 0)) {
266 if (ethact) {
267 current = eth_get_dev_by_name(ethact);
268 if (!current)
269 return -EINVAL;
270 }
271 }
272
273 if (!current) {
274 current = eth_get_dev();
275 if (!current) {
Heinrich Schuchardt653f3ee2020-09-14 11:00:18 +0200276 log_err("No ethernet found.\n");
Simon Glassc6011d22016-01-17 14:52:00 -0700277 return -ENODEV;
278 }
279 }
280
281 old_current = current;
282 do {
283 if (current) {
284 debug("Trying %s\n", current->name);
285
286 if (device_active(current)) {
287 ret = eth_get_ops(current)->start(current);
288 if (ret >= 0) {
289 struct eth_device_priv *priv =
Simon Glass95588622020-12-22 19:30:28 -0700290 dev_get_uclass_priv(current);
Simon Glassc6011d22016-01-17 14:52:00 -0700291
292 priv->state = ETH_STATE_ACTIVE;
293 return 0;
294 }
295 } else {
296 ret = eth_errno;
297 }
298
299 debug("FAIL\n");
300 } else {
301 debug("PROBE FAIL\n");
302 }
303
304 /*
305 * If ethrotate is enabled, this will change "current",
306 * otherwise we will drop out of this while loop immediately
307 */
308 eth_try_another(0);
309 /* This will ensure the new "current" attempted to probe */
310 current = eth_get_dev();
311 } while (old_current != current);
312
313 return ret;
314}
315
316void eth_halt(void)
317{
318 struct udevice *current;
319 struct eth_device_priv *priv;
320
321 current = eth_get_dev();
Joe Hershberger3c91d152018-07-02 14:47:46 -0500322 if (!current || !eth_is_active(current))
Simon Glassc6011d22016-01-17 14:52:00 -0700323 return;
324
325 eth_get_ops(current)->stop(current);
Simon Glass95588622020-12-22 19:30:28 -0700326 priv = dev_get_uclass_priv(current);
Jean-Jacques Hiblotd21faa52018-08-09 16:17:41 +0200327 if (priv)
328 priv->state = ETH_STATE_PASSIVE;
Simon Glassc6011d22016-01-17 14:52:00 -0700329}
330
331int eth_is_active(struct udevice *dev)
332{
333 struct eth_device_priv *priv;
334
335 if (!dev || !device_active(dev))
336 return 0;
337
338 priv = dev_get_uclass_priv(dev);
339 return priv->state == ETH_STATE_ACTIVE;
340}
341
342int eth_send(void *packet, int length)
343{
344 struct udevice *current;
345 int ret;
346
347 current = eth_get_dev();
348 if (!current)
349 return -ENODEV;
350
Alexander Graf71511492018-03-15 15:07:09 +0100351 if (!eth_is_active(current))
Simon Glassc6011d22016-01-17 14:52:00 -0700352 return -EINVAL;
353
354 ret = eth_get_ops(current)->send(current, packet, length);
355 if (ret < 0) {
356 /* We cannot completely return the error at present */
357 debug("%s: send() returned error %d\n", __func__, ret);
358 }
Ramon Friedac598c12019-07-18 21:43:30 +0300359#if defined(CONFIG_CMD_PCAP)
360 if (ret >= 0)
361 pcap_post(packet, length, true);
362#endif
Simon Glassc6011d22016-01-17 14:52:00 -0700363 return ret;
364}
365
366int eth_rx(void)
367{
368 struct udevice *current;
369 uchar *packet;
370 int flags;
371 int ret;
372 int i;
373
374 current = eth_get_dev();
375 if (!current)
376 return -ENODEV;
377
Alexander Graf71511492018-03-15 15:07:09 +0100378 if (!eth_is_active(current))
Simon Glassc6011d22016-01-17 14:52:00 -0700379 return -EINVAL;
380
381 /* Process up to 32 packets at one time */
382 flags = ETH_RECV_CHECK_DEVICE;
Patrick Wildtd47430a2020-10-07 11:03:30 +0200383 for (i = 0; i < ETH_PACKETS_BATCH_RECV; i++) {
Simon Glassc6011d22016-01-17 14:52:00 -0700384 ret = eth_get_ops(current)->recv(current, flags, &packet);
385 flags = 0;
386 if (ret > 0)
387 net_process_received_packet(packet, ret);
388 if (ret >= 0 && eth_get_ops(current)->free_pkt)
389 eth_get_ops(current)->free_pkt(current, packet, ret);
390 if (ret <= 0)
391 break;
392 }
393 if (ret == -EAGAIN)
394 ret = 0;
395 if (ret < 0) {
396 /* We cannot completely return the error at present */
397 debug("%s: recv() returned error %d\n", __func__, ret);
398 }
399 return ret;
400}
401
402int eth_initialize(void)
403{
404 int num_devices = 0;
405 struct udevice *dev;
406
407 eth_common_init();
408
409 /*
410 * Devices need to write the hwaddr even if not started so that Linux
411 * will have access to the hwaddr that u-boot stored for the device.
412 * This is accomplished by attempting to probe each device and calling
413 * their write_hwaddr() operation.
414 */
Mario Six865c3872018-04-27 14:52:56 +0200415 uclass_first_device_check(UCLASS_ETH, &dev);
Simon Glassc6011d22016-01-17 14:52:00 -0700416 if (!dev) {
Heinrich Schuchardt653f3ee2020-09-14 11:00:18 +0200417 log_err("No ethernet found.\n");
Simon Glassc6011d22016-01-17 14:52:00 -0700418 bootstage_error(BOOTSTAGE_ID_NET_ETH_START);
419 } else {
Simon Glass64b723f2017-08-03 12:22:12 -0600420 char *ethprime = env_get("ethprime");
Simon Glassc6011d22016-01-17 14:52:00 -0700421 struct udevice *prime_dev = NULL;
422
423 if (ethprime)
424 prime_dev = eth_get_dev_by_name(ethprime);
425 if (prime_dev) {
426 eth_set_dev(prime_dev);
427 eth_current_changed();
428 } else {
429 eth_set_dev(NULL);
430 }
431
432 bootstage_mark(BOOTSTAGE_ID_NET_ETH_INIT);
433 do {
Simon Glass3e14a222020-12-16 21:20:16 -0700434 if (device_active(dev)) {
Michael Walle902c7962019-10-22 01:03:10 +0200435 if (num_devices)
436 printf(", ");
Simon Glassc6011d22016-01-17 14:52:00 -0700437
Simon Glass75e534b2020-12-16 21:20:07 -0700438 printf("eth%d: %s", dev_seq(dev), dev->name);
Simon Glassc6011d22016-01-17 14:52:00 -0700439
Michael Walle902c7962019-10-22 01:03:10 +0200440 if (ethprime && dev == prime_dev)
441 printf(" [PRIME]");
442 }
Simon Glassc6011d22016-01-17 14:52:00 -0700443
444 eth_write_hwaddr(dev);
445
Simon Glass3e14a222020-12-16 21:20:16 -0700446 if (device_active(dev))
Michael Walle902c7962019-10-22 01:03:10 +0200447 num_devices++;
Mario Six865c3872018-04-27 14:52:56 +0200448 uclass_next_device_check(&dev);
Simon Glassc6011d22016-01-17 14:52:00 -0700449 } while (dev);
450
Michael Walle902c7962019-10-22 01:03:10 +0200451 if (!num_devices)
Heinrich Schuchardt653f3ee2020-09-14 11:00:18 +0200452 log_err("No ethernet found.\n");
Simon Glassc6011d22016-01-17 14:52:00 -0700453 putc('\n');
454 }
455
456 return num_devices;
457}
458
459static int eth_post_bind(struct udevice *dev)
460{
461 if (strchr(dev->name, ' ')) {
462 printf("\nError: eth device name \"%s\" has a space!\n",
463 dev->name);
464 return -EINVAL;
465 }
466
Ye Licd5bb772020-05-03 22:41:14 +0800467#ifdef CONFIG_DM_ETH_PHY
468 eth_phy_binds_nodes(dev);
469#endif
470
Simon Glassc6011d22016-01-17 14:52:00 -0700471 return 0;
472}
473
474static int eth_pre_unbind(struct udevice *dev)
475{
476 /* Don't hang onto a pointer that is going away */
477 if (dev == eth_get_uclass_priv()->current)
478 eth_set_dev(NULL);
479
480 return 0;
481}
482
Thierry Reding8fe08532019-05-20 17:59:57 +0200483static bool eth_dev_get_mac_address(struct udevice *dev, u8 mac[ARP_HLEN])
484{
485#if IS_ENABLED(CONFIG_OF_CONTROL)
486 const uint8_t *p;
487
488 p = dev_read_u8_array_ptr(dev, "mac-address", ARP_HLEN);
489 if (!p)
490 p = dev_read_u8_array_ptr(dev, "local-mac-address", ARP_HLEN);
491
492 if (!p)
493 return false;
494
495 memcpy(mac, p, ARP_HLEN);
496
497 return true;
498#else
499 return false;
500#endif
501}
502
Simon Glassc6011d22016-01-17 14:52:00 -0700503static int eth_post_probe(struct udevice *dev)
504{
Simon Glass95588622020-12-22 19:30:28 -0700505 struct eth_device_priv *priv = dev_get_uclass_priv(dev);
506 struct eth_pdata *pdata = dev_get_plat(dev);
oliver@schinagl.nl496904b2016-11-25 16:30:19 +0100507 unsigned char env_enetaddr[ARP_HLEN];
Michal Simek31411132020-03-16 11:36:17 +0100508 char *source = "DT";
Simon Glassc6011d22016-01-17 14:52:00 -0700509
510#if defined(CONFIG_NEEDS_MANUAL_RELOC)
511 struct eth_ops *ops = eth_get_ops(dev);
512 static int reloc_done;
513
514 if (!reloc_done) {
515 if (ops->start)
516 ops->start += gd->reloc_off;
517 if (ops->send)
518 ops->send += gd->reloc_off;
519 if (ops->recv)
520 ops->recv += gd->reloc_off;
521 if (ops->free_pkt)
522 ops->free_pkt += gd->reloc_off;
523 if (ops->stop)
524 ops->stop += gd->reloc_off;
Simon Glassc6011d22016-01-17 14:52:00 -0700525 if (ops->mcast)
526 ops->mcast += gd->reloc_off;
Simon Glassc6011d22016-01-17 14:52:00 -0700527 if (ops->write_hwaddr)
528 ops->write_hwaddr += gd->reloc_off;
529 if (ops->read_rom_hwaddr)
530 ops->read_rom_hwaddr += gd->reloc_off;
531
532 reloc_done++;
533 }
534#endif
535
536 priv->state = ETH_STATE_INIT;
537
Thierry Reding8fe08532019-05-20 17:59:57 +0200538 /* Check if the device has a valid MAC address in device tree */
539 if (!eth_dev_get_mac_address(dev, pdata->enetaddr) ||
540 !is_valid_ethaddr(pdata->enetaddr)) {
Michal Simek31411132020-03-16 11:36:17 +0100541 source = "ROM";
Thierry Reding8fe08532019-05-20 17:59:57 +0200542 /* Check if the device has a MAC address in ROM */
543 if (eth_get_ops(dev)->read_rom_hwaddr)
544 eth_get_ops(dev)->read_rom_hwaddr(dev);
545 }
Simon Glassc6011d22016-01-17 14:52:00 -0700546
Simon Glass75e534b2020-12-16 21:20:07 -0700547 eth_env_get_enetaddr_by_index("eth", dev_seq(dev), env_enetaddr);
Simon Glassc6011d22016-01-17 14:52:00 -0700548 if (!is_zero_ethaddr(env_enetaddr)) {
549 if (!is_zero_ethaddr(pdata->enetaddr) &&
oliver@schinagl.nl496904b2016-11-25 16:30:19 +0100550 memcmp(pdata->enetaddr, env_enetaddr, ARP_HLEN)) {
Simon Glassc6011d22016-01-17 14:52:00 -0700551 printf("\nWarning: %s MAC addresses don't match:\n",
552 dev->name);
Michal Simek31411132020-03-16 11:36:17 +0100553 printf("Address in %s is\t\t%pM\n",
554 source, pdata->enetaddr);
555 printf("Address in environment is\t%pM\n",
Simon Glassc6011d22016-01-17 14:52:00 -0700556 env_enetaddr);
557 }
558
559 /* Override the ROM MAC address */
oliver@schinagl.nl496904b2016-11-25 16:30:19 +0100560 memcpy(pdata->enetaddr, env_enetaddr, ARP_HLEN);
Simon Glassc6011d22016-01-17 14:52:00 -0700561 } else if (is_valid_ethaddr(pdata->enetaddr)) {
Simon Glass75e534b2020-12-16 21:20:07 -0700562 eth_env_set_enetaddr_by_index("eth", dev_seq(dev),
563 pdata->enetaddr);
Siva Durga Prasad Paladugue0b7bc72016-11-02 12:52:13 +0100564 } else if (is_zero_ethaddr(pdata->enetaddr) ||
565 !is_valid_ethaddr(pdata->enetaddr)) {
Simon Glassc6011d22016-01-17 14:52:00 -0700566#ifdef CONFIG_NET_RANDOM_ETHADDR
567 net_random_ethaddr(pdata->enetaddr);
568 printf("\nWarning: %s (eth%d) using random MAC address - %pM\n",
Simon Glass75e534b2020-12-16 21:20:07 -0700569 dev->name, dev_seq(dev), pdata->enetaddr);
Simon Glassc6011d22016-01-17 14:52:00 -0700570#else
571 printf("\nError: %s address not set.\n",
572 dev->name);
573 return -EINVAL;
574#endif
575 }
576
Thierry Reding13064872019-05-20 17:59:56 +0200577 eth_write_hwaddr(dev);
578
Simon Glassc6011d22016-01-17 14:52:00 -0700579 return 0;
580}
581
582static int eth_pre_remove(struct udevice *dev)
583{
Simon Glass95588622020-12-22 19:30:28 -0700584 struct eth_pdata *pdata = dev_get_plat(dev);
Simon Glassc6011d22016-01-17 14:52:00 -0700585
586 eth_get_ops(dev)->stop(dev);
587
588 /* clear the MAC address */
oliver@schinagl.nl496904b2016-11-25 16:30:19 +0100589 memset(pdata->enetaddr, 0, ARP_HLEN);
Simon Glassc6011d22016-01-17 14:52:00 -0700590
591 return 0;
592}
593
594UCLASS_DRIVER(eth) = {
595 .name = "eth",
596 .id = UCLASS_ETH,
597 .post_bind = eth_post_bind,
598 .pre_unbind = eth_pre_unbind,
599 .post_probe = eth_post_probe,
600 .pre_remove = eth_pre_remove,
Simon Glass8a2b47f2020-12-03 16:55:17 -0700601 .priv_auto = sizeof(struct eth_uclass_priv),
602 .per_device_auto = sizeof(struct eth_device_priv),
Simon Glassc6011d22016-01-17 14:52:00 -0700603 .flags = DM_UC_FLAG_SEQ_ALIAS,
604};