1 // SPDX-License-Identifier: GPL-2.0+
4 * Vipin Kumar, ST Micoelectronics, vipin.kumar@st.com.
8 * Designware ethernet IP driver for U-Boot
22 #include <asm/cache.h>
23 #include <dm/device_compat.h>
24 #include <dm/devres.h>
25 #include <linux/compiler.h>
26 #include <linux/delay.h>
27 #include <linux/err.h>
28 #include <linux/kernel.h>
30 #include <power/regulator.h>
31 #include "designware.h"
33 static int dw_mdio_read(struct mii_dev *bus, int addr, int devad, int reg)
36 struct dw_eth_dev *priv = dev_get_priv((struct udevice *)bus->priv);
37 struct eth_mac_regs *mac_p = priv->mac_regs_p;
39 struct eth_mac_regs *mac_p = bus->priv;
43 int timeout = CONFIG_MDIO_TIMEOUT;
45 miiaddr = ((addr << MIIADDRSHIFT) & MII_ADDRMSK) |
46 ((reg << MIIREGSHIFT) & MII_REGMSK);
48 writel(miiaddr | MII_CLKRANGE_150_250M | MII_BUSY, &mac_p->miiaddr);
51 while (get_timer(start) < timeout) {
52 if (!(readl(&mac_p->miiaddr) & MII_BUSY))
53 return readl(&mac_p->miidata);
60 static int dw_mdio_write(struct mii_dev *bus, int addr, int devad, int reg,
64 struct dw_eth_dev *priv = dev_get_priv((struct udevice *)bus->priv);
65 struct eth_mac_regs *mac_p = priv->mac_regs_p;
67 struct eth_mac_regs *mac_p = bus->priv;
71 int ret = -ETIMEDOUT, timeout = CONFIG_MDIO_TIMEOUT;
73 writel(val, &mac_p->miidata);
74 miiaddr = ((addr << MIIADDRSHIFT) & MII_ADDRMSK) |
75 ((reg << MIIREGSHIFT) & MII_REGMSK) | MII_WRITE;
77 writel(miiaddr | MII_CLKRANGE_150_250M | MII_BUSY, &mac_p->miiaddr);
80 while (get_timer(start) < timeout) {
81 if (!(readl(&mac_p->miiaddr) & MII_BUSY)) {
91 #if defined(CONFIG_DM_ETH) && CONFIG_IS_ENABLED(DM_GPIO)
92 static int dw_mdio_reset(struct mii_dev *bus)
94 struct udevice *dev = bus->priv;
95 struct dw_eth_dev *priv = dev_get_priv(dev);
96 struct dw_eth_pdata *pdata = dev_get_platdata(dev);
99 if (!dm_gpio_is_valid(&priv->reset_gpio))
103 ret = dm_gpio_set_value(&priv->reset_gpio, 0);
107 udelay(pdata->reset_delays[0]);
109 ret = dm_gpio_set_value(&priv->reset_gpio, 1);
113 udelay(pdata->reset_delays[1]);
115 ret = dm_gpio_set_value(&priv->reset_gpio, 0);
119 udelay(pdata->reset_delays[2]);
125 static int dw_mdio_init(const char *name, void *priv)
127 struct mii_dev *bus = mdio_alloc();
130 printf("Failed to allocate MDIO bus\n");
134 bus->read = dw_mdio_read;
135 bus->write = dw_mdio_write;
136 snprintf(bus->name, sizeof(bus->name), "%s", name);
137 #if defined(CONFIG_DM_ETH) && CONFIG_IS_ENABLED(DM_GPIO)
138 bus->reset = dw_mdio_reset;
143 return mdio_register(bus);
146 static void tx_descs_init(struct dw_eth_dev *priv)
148 struct eth_dma_regs *dma_p = priv->dma_regs_p;
149 struct dmamacdescr *desc_table_p = &priv->tx_mac_descrtable[0];
150 char *txbuffs = &priv->txbuffs[0];
151 struct dmamacdescr *desc_p;
154 for (idx = 0; idx < CONFIG_TX_DESCR_NUM; idx++) {
155 desc_p = &desc_table_p[idx];
156 desc_p->dmamac_addr = (ulong)&txbuffs[idx * CONFIG_ETH_BUFSIZE];
157 desc_p->dmamac_next = (ulong)&desc_table_p[idx + 1];
159 #if defined(CONFIG_DW_ALTDESCRIPTOR)
160 desc_p->txrx_status &= ~(DESC_TXSTS_TXINT | DESC_TXSTS_TXLAST |
161 DESC_TXSTS_TXFIRST | DESC_TXSTS_TXCRCDIS |
162 DESC_TXSTS_TXCHECKINSCTRL |
163 DESC_TXSTS_TXRINGEND | DESC_TXSTS_TXPADDIS);
165 desc_p->txrx_status |= DESC_TXSTS_TXCHAIN;
166 desc_p->dmamac_cntl = 0;
167 desc_p->txrx_status &= ~(DESC_TXSTS_MSK | DESC_TXSTS_OWNBYDMA);
169 desc_p->dmamac_cntl = DESC_TXCTRL_TXCHAIN;
170 desc_p->txrx_status = 0;
174 /* Correcting the last pointer of the chain */
175 desc_p->dmamac_next = (ulong)&desc_table_p[0];
177 /* Flush all Tx buffer descriptors at once */
178 flush_dcache_range((ulong)priv->tx_mac_descrtable,
179 (ulong)priv->tx_mac_descrtable +
180 sizeof(priv->tx_mac_descrtable));
182 writel((ulong)&desc_table_p[0], &dma_p->txdesclistaddr);
183 priv->tx_currdescnum = 0;
186 static void rx_descs_init(struct dw_eth_dev *priv)
188 struct eth_dma_regs *dma_p = priv->dma_regs_p;
189 struct dmamacdescr *desc_table_p = &priv->rx_mac_descrtable[0];
190 char *rxbuffs = &priv->rxbuffs[0];
191 struct dmamacdescr *desc_p;
194 /* Before passing buffers to GMAC we need to make sure zeros
195 * written there right after "priv" structure allocation were
197 * Otherwise there's a chance to get some of them flushed in RAM when
198 * GMAC is already pushing data to RAM via DMA. This way incoming from
199 * GMAC data will be corrupted. */
200 flush_dcache_range((ulong)rxbuffs, (ulong)rxbuffs + RX_TOTAL_BUFSIZE);
202 for (idx = 0; idx < CONFIG_RX_DESCR_NUM; idx++) {
203 desc_p = &desc_table_p[idx];
204 desc_p->dmamac_addr = (ulong)&rxbuffs[idx * CONFIG_ETH_BUFSIZE];
205 desc_p->dmamac_next = (ulong)&desc_table_p[idx + 1];
207 desc_p->dmamac_cntl =
208 (MAC_MAX_FRAME_SZ & DESC_RXCTRL_SIZE1MASK) |
211 desc_p->txrx_status = DESC_RXSTS_OWNBYDMA;
214 /* Correcting the last pointer of the chain */
215 desc_p->dmamac_next = (ulong)&desc_table_p[0];
217 /* Flush all Rx buffer descriptors at once */
218 flush_dcache_range((ulong)priv->rx_mac_descrtable,
219 (ulong)priv->rx_mac_descrtable +
220 sizeof(priv->rx_mac_descrtable));
222 writel((ulong)&desc_table_p[0], &dma_p->rxdesclistaddr);
223 priv->rx_currdescnum = 0;
226 static int _dw_write_hwaddr(struct dw_eth_dev *priv, u8 *mac_id)
228 struct eth_mac_regs *mac_p = priv->mac_regs_p;
229 u32 macid_lo, macid_hi;
231 macid_lo = mac_id[0] + (mac_id[1] << 8) + (mac_id[2] << 16) +
233 macid_hi = mac_id[4] + (mac_id[5] << 8);
235 writel(macid_hi, &mac_p->macaddr0hi);
236 writel(macid_lo, &mac_p->macaddr0lo);
241 static int dw_adjust_link(struct dw_eth_dev *priv, struct eth_mac_regs *mac_p,
242 struct phy_device *phydev)
244 u32 conf = readl(&mac_p->conf) | FRAMEBURSTENABLE | DISABLERXOWN;
247 printf("%s: No link.\n", phydev->dev->name);
251 if (phydev->speed != 1000)
252 conf |= MII_PORTSELECT;
254 conf &= ~MII_PORTSELECT;
256 if (phydev->speed == 100)
260 conf |= FULLDPLXMODE;
262 writel(conf, &mac_p->conf);
264 printf("Speed: %d, %s duplex%s\n", phydev->speed,
265 (phydev->duplex) ? "full" : "half",
266 (phydev->port == PORT_FIBRE) ? ", fiber mode" : "");
271 static void _dw_eth_halt(struct dw_eth_dev *priv)
273 struct eth_mac_regs *mac_p = priv->mac_regs_p;
274 struct eth_dma_regs *dma_p = priv->dma_regs_p;
276 writel(readl(&mac_p->conf) & ~(RXENABLE | TXENABLE), &mac_p->conf);
277 writel(readl(&dma_p->opmode) & ~(RXSTART | TXSTART), &dma_p->opmode);
279 phy_shutdown(priv->phydev);
282 int designware_eth_init(struct dw_eth_dev *priv, u8 *enetaddr)
284 struct eth_mac_regs *mac_p = priv->mac_regs_p;
285 struct eth_dma_regs *dma_p = priv->dma_regs_p;
289 writel(readl(&dma_p->busmode) | DMAMAC_SRST, &dma_p->busmode);
292 * When a MII PHY is used, we must set the PS bit for the DMA
295 if (priv->phydev->interface == PHY_INTERFACE_MODE_MII)
296 writel(readl(&mac_p->conf) | MII_PORTSELECT, &mac_p->conf);
298 writel(readl(&mac_p->conf) & ~MII_PORTSELECT, &mac_p->conf);
300 start = get_timer(0);
301 while (readl(&dma_p->busmode) & DMAMAC_SRST) {
302 if (get_timer(start) >= CONFIG_MACRESET_TIMEOUT) {
303 printf("DMA reset timeout\n");
311 * Soft reset above clears HW address registers.
312 * So we have to set it here once again.
314 _dw_write_hwaddr(priv, enetaddr);
319 writel(FIXEDBURST | PRIORXTX_41 | DMA_PBL, &dma_p->busmode);
321 #ifndef CONFIG_DW_MAC_FORCE_THRESHOLD_MODE
322 writel(readl(&dma_p->opmode) | FLUSHTXFIFO | STOREFORWARD,
325 writel(readl(&dma_p->opmode) | FLUSHTXFIFO,
329 writel(readl(&dma_p->opmode) | RXSTART | TXSTART, &dma_p->opmode);
331 #ifdef CONFIG_DW_AXI_BURST_LEN
332 writel((CONFIG_DW_AXI_BURST_LEN & 0x1FF >> 1), &dma_p->axibus);
335 /* Start up the PHY */
336 ret = phy_startup(priv->phydev);
338 printf("Could not initialize PHY %s\n",
339 priv->phydev->dev->name);
343 ret = dw_adjust_link(priv, mac_p, priv->phydev);
350 int designware_eth_enable(struct dw_eth_dev *priv)
352 struct eth_mac_regs *mac_p = priv->mac_regs_p;
354 if (!priv->phydev->link)
357 writel(readl(&mac_p->conf) | RXENABLE | TXENABLE, &mac_p->conf);
364 static int _dw_eth_send(struct dw_eth_dev *priv, void *packet, int length)
366 struct eth_dma_regs *dma_p = priv->dma_regs_p;
367 u32 desc_num = priv->tx_currdescnum;
368 struct dmamacdescr *desc_p = &priv->tx_mac_descrtable[desc_num];
369 ulong desc_start = (ulong)desc_p;
370 ulong desc_end = desc_start +
371 roundup(sizeof(*desc_p), ARCH_DMA_MINALIGN);
372 ulong data_start = desc_p->dmamac_addr;
373 ulong data_end = data_start + roundup(length, ARCH_DMA_MINALIGN);
375 * Strictly we only need to invalidate the "txrx_status" field
376 * for the following check, but on some platforms we cannot
377 * invalidate only 4 bytes, so we flush the entire descriptor,
378 * which is 16 bytes in total. This is safe because the
379 * individual descriptors in the array are each aligned to
380 * ARCH_DMA_MINALIGN and padded appropriately.
382 invalidate_dcache_range(desc_start, desc_end);
384 /* Check if the descriptor is owned by CPU */
385 if (desc_p->txrx_status & DESC_TXSTS_OWNBYDMA) {
386 printf("CPU not owner of tx frame\n");
390 memcpy((void *)data_start, packet, length);
391 if (length < ETH_ZLEN) {
392 memset(&((char *)data_start)[length], 0, ETH_ZLEN - length);
396 /* Flush data to be sent */
397 flush_dcache_range(data_start, data_end);
399 #if defined(CONFIG_DW_ALTDESCRIPTOR)
400 desc_p->txrx_status |= DESC_TXSTS_TXFIRST | DESC_TXSTS_TXLAST;
401 desc_p->dmamac_cntl = (desc_p->dmamac_cntl & ~DESC_TXCTRL_SIZE1MASK) |
402 ((length << DESC_TXCTRL_SIZE1SHFT) &
403 DESC_TXCTRL_SIZE1MASK);
405 desc_p->txrx_status &= ~(DESC_TXSTS_MSK);
406 desc_p->txrx_status |= DESC_TXSTS_OWNBYDMA;
408 desc_p->dmamac_cntl = (desc_p->dmamac_cntl & ~DESC_TXCTRL_SIZE1MASK) |
409 ((length << DESC_TXCTRL_SIZE1SHFT) &
410 DESC_TXCTRL_SIZE1MASK) | DESC_TXCTRL_TXLAST |
413 desc_p->txrx_status = DESC_TXSTS_OWNBYDMA;
416 /* Flush modified buffer descriptor */
417 flush_dcache_range(desc_start, desc_end);
419 /* Test the wrap-around condition. */
420 if (++desc_num >= CONFIG_TX_DESCR_NUM)
423 priv->tx_currdescnum = desc_num;
425 /* Start the transmission */
426 writel(POLL_DATA, &dma_p->txpolldemand);
431 static int _dw_eth_recv(struct dw_eth_dev *priv, uchar **packetp)
433 u32 status, desc_num = priv->rx_currdescnum;
434 struct dmamacdescr *desc_p = &priv->rx_mac_descrtable[desc_num];
435 int length = -EAGAIN;
436 ulong desc_start = (ulong)desc_p;
437 ulong desc_end = desc_start +
438 roundup(sizeof(*desc_p), ARCH_DMA_MINALIGN);
439 ulong data_start = desc_p->dmamac_addr;
442 /* Invalidate entire buffer descriptor */
443 invalidate_dcache_range(desc_start, desc_end);
445 status = desc_p->txrx_status;
447 /* Check if the owner is the CPU */
448 if (!(status & DESC_RXSTS_OWNBYDMA)) {
450 length = (status & DESC_RXSTS_FRMLENMSK) >>
451 DESC_RXSTS_FRMLENSHFT;
453 /* Invalidate received data */
454 data_end = data_start + roundup(length, ARCH_DMA_MINALIGN);
455 invalidate_dcache_range(data_start, data_end);
456 *packetp = (uchar *)(ulong)desc_p->dmamac_addr;
462 static int _dw_free_pkt(struct dw_eth_dev *priv)
464 u32 desc_num = priv->rx_currdescnum;
465 struct dmamacdescr *desc_p = &priv->rx_mac_descrtable[desc_num];
466 ulong desc_start = (ulong)desc_p;
467 ulong desc_end = desc_start +
468 roundup(sizeof(*desc_p), ARCH_DMA_MINALIGN);
471 * Make the current descriptor valid again and go to
474 desc_p->txrx_status |= DESC_RXSTS_OWNBYDMA;
476 /* Flush only status field - others weren't changed */
477 flush_dcache_range(desc_start, desc_end);
479 /* Test the wrap-around condition. */
480 if (++desc_num >= CONFIG_RX_DESCR_NUM)
482 priv->rx_currdescnum = desc_num;
487 static int dw_phy_init(struct dw_eth_dev *priv, void *dev)
489 struct phy_device *phydev;
490 int phy_addr = -1, ret;
492 #ifdef CONFIG_PHY_ADDR
493 phy_addr = CONFIG_PHY_ADDR;
496 phydev = phy_connect(priv->bus, phy_addr, dev, priv->interface);
500 phydev->supported &= PHY_GBIT_FEATURES;
501 if (priv->max_speed) {
502 ret = phy_set_supported(phydev, priv->max_speed);
506 phydev->advertising = phydev->supported;
508 priv->phydev = phydev;
514 #ifndef CONFIG_DM_ETH
515 static int dw_eth_init(struct eth_device *dev, struct bd_info *bis)
519 ret = designware_eth_init(dev->priv, dev->enetaddr);
521 ret = designware_eth_enable(dev->priv);
526 static int dw_eth_send(struct eth_device *dev, void *packet, int length)
528 return _dw_eth_send(dev->priv, packet, length);
531 static int dw_eth_recv(struct eth_device *dev)
536 length = _dw_eth_recv(dev->priv, &packet);
537 if (length == -EAGAIN)
539 net_process_received_packet(packet, length);
541 _dw_free_pkt(dev->priv);
546 static void dw_eth_halt(struct eth_device *dev)
548 return _dw_eth_halt(dev->priv);
551 static int dw_write_hwaddr(struct eth_device *dev)
553 return _dw_write_hwaddr(dev->priv, dev->enetaddr);
556 int designware_initialize(ulong base_addr, u32 interface)
558 struct eth_device *dev;
559 struct dw_eth_dev *priv;
561 dev = (struct eth_device *) malloc(sizeof(struct eth_device));
566 * Since the priv structure contains the descriptors which need a strict
567 * buswidth alignment, memalign is used to allocate memory
569 priv = (struct dw_eth_dev *) memalign(ARCH_DMA_MINALIGN,
570 sizeof(struct dw_eth_dev));
576 if ((phys_addr_t)priv + sizeof(*priv) > (1ULL << 32)) {
577 printf("designware: buffers are outside DMA memory\n");
581 memset(dev, 0, sizeof(struct eth_device));
582 memset(priv, 0, sizeof(struct dw_eth_dev));
584 sprintf(dev->name, "dwmac.%lx", base_addr);
585 dev->iobase = (int)base_addr;
589 priv->mac_regs_p = (struct eth_mac_regs *)base_addr;
590 priv->dma_regs_p = (struct eth_dma_regs *)(base_addr +
593 dev->init = dw_eth_init;
594 dev->send = dw_eth_send;
595 dev->recv = dw_eth_recv;
596 dev->halt = dw_eth_halt;
597 dev->write_hwaddr = dw_write_hwaddr;
601 priv->interface = interface;
603 dw_mdio_init(dev->name, priv->mac_regs_p);
604 priv->bus = miiphy_get_dev_by_name(dev->name);
606 return dw_phy_init(priv, dev);
611 static int designware_eth_start(struct udevice *dev)
613 struct eth_pdata *pdata = dev_get_platdata(dev);
614 struct dw_eth_dev *priv = dev_get_priv(dev);
617 ret = designware_eth_init(priv, pdata->enetaddr);
620 ret = designware_eth_enable(priv);
627 int designware_eth_send(struct udevice *dev, void *packet, int length)
629 struct dw_eth_dev *priv = dev_get_priv(dev);
631 return _dw_eth_send(priv, packet, length);
634 int designware_eth_recv(struct udevice *dev, int flags, uchar **packetp)
636 struct dw_eth_dev *priv = dev_get_priv(dev);
638 return _dw_eth_recv(priv, packetp);
641 int designware_eth_free_pkt(struct udevice *dev, uchar *packet, int length)
643 struct dw_eth_dev *priv = dev_get_priv(dev);
645 return _dw_free_pkt(priv);
648 void designware_eth_stop(struct udevice *dev)
650 struct dw_eth_dev *priv = dev_get_priv(dev);
652 return _dw_eth_halt(priv);
655 int designware_eth_write_hwaddr(struct udevice *dev)
657 struct eth_pdata *pdata = dev_get_platdata(dev);
658 struct dw_eth_dev *priv = dev_get_priv(dev);
660 return _dw_write_hwaddr(priv, pdata->enetaddr);
663 static int designware_eth_bind(struct udevice *dev)
666 static int num_cards;
669 /* Create a unique device name for PCI type devices */
670 if (device_is_on_pci_bus(dev)) {
671 sprintf(name, "eth_designware#%u", num_cards++);
672 device_set_name(dev, name);
679 int designware_eth_probe(struct udevice *dev)
681 struct eth_pdata *pdata = dev_get_platdata(dev);
682 struct dw_eth_dev *priv = dev_get_priv(dev);
683 u32 iobase = pdata->iobase;
686 struct reset_ctl_bulk reset_bulk;
690 priv->clock_count = 0;
691 clock_nb = dev_count_phandle_with_args(dev, "clocks", "#clock-cells",
694 priv->clocks = devm_kcalloc(dev, clock_nb, sizeof(struct clk),
699 for (i = 0; i < clock_nb; i++) {
700 err = clk_get_by_index(dev, i, &priv->clocks[i]);
704 err = clk_enable(&priv->clocks[i]);
705 if (err && err != -ENOSYS && err != -ENOTSUPP) {
706 pr_err("failed to enable clock %d\n", i);
707 clk_free(&priv->clocks[i]);
712 } else if (clock_nb != -ENOENT) {
713 pr_err("failed to get clock phandle(%d)\n", clock_nb);
718 #if defined(CONFIG_DM_REGULATOR)
719 struct udevice *phy_supply;
721 ret = device_get_supply_regulator(dev, "phy-supply",
724 debug("%s: No phy supply\n", dev->name);
726 ret = regulator_set_enable(phy_supply, true);
728 puts("Error enabling phy supply\n");
734 ret = reset_get_bulk(dev, &reset_bulk);
736 dev_warn(dev, "Can't get reset: %d\n", ret);
738 reset_deassert_bulk(&reset_bulk);
742 * If we are on PCI bus, either directly attached to a PCI root port,
743 * or via a PCI bridge, fill in platdata before we probe the hardware.
745 if (device_is_on_pci_bus(dev)) {
746 dm_pci_read_config32(dev, PCI_BASE_ADDRESS_0, &iobase);
747 iobase &= PCI_BASE_ADDRESS_MEM_MASK;
748 iobase = dm_pci_mem_to_phys(dev, iobase);
750 pdata->iobase = iobase;
751 pdata->phy_interface = PHY_INTERFACE_MODE_RMII;
755 debug("%s, iobase=%x, priv=%p\n", __func__, iobase, priv);
757 priv->mac_regs_p = (struct eth_mac_regs *)ioaddr;
758 priv->dma_regs_p = (struct eth_dma_regs *)(ioaddr + DW_DMA_BASE_OFFSET);
759 priv->interface = pdata->phy_interface;
760 priv->max_speed = pdata->max_speed;
762 ret = dw_mdio_init(dev->name, dev);
767 priv->bus = miiphy_get_dev_by_name(dev->name);
769 ret = dw_phy_init(priv, dev);
770 debug("%s, ret=%d\n", __func__, ret);
774 /* continue here for cleanup if no PHY found */
776 mdio_unregister(priv->bus);
777 mdio_free(priv->bus);
782 ret = clk_release_all(priv->clocks, priv->clock_count);
784 pr_err("failed to disable all clocks\n");
790 static int designware_eth_remove(struct udevice *dev)
792 struct dw_eth_dev *priv = dev_get_priv(dev);
795 mdio_unregister(priv->bus);
796 mdio_free(priv->bus);
799 return clk_release_all(priv->clocks, priv->clock_count);
805 const struct eth_ops designware_eth_ops = {
806 .start = designware_eth_start,
807 .send = designware_eth_send,
808 .recv = designware_eth_recv,
809 .free_pkt = designware_eth_free_pkt,
810 .stop = designware_eth_stop,
811 .write_hwaddr = designware_eth_write_hwaddr,
814 int designware_eth_ofdata_to_platdata(struct udevice *dev)
816 struct dw_eth_pdata *dw_pdata = dev_get_platdata(dev);
817 #if CONFIG_IS_ENABLED(DM_GPIO)
818 struct dw_eth_dev *priv = dev_get_priv(dev);
820 struct eth_pdata *pdata = &dw_pdata->eth_pdata;
821 const char *phy_mode;
822 #if CONFIG_IS_ENABLED(DM_GPIO)
823 int reset_flags = GPIOD_IS_OUT;
827 pdata->iobase = dev_read_addr(dev);
828 pdata->phy_interface = -1;
829 phy_mode = dev_read_string(dev, "phy-mode");
831 pdata->phy_interface = phy_get_interface_by_name(phy_mode);
832 if (pdata->phy_interface == -1) {
833 debug("%s: Invalid PHY interface '%s'\n", __func__, phy_mode);
837 pdata->max_speed = dev_read_u32_default(dev, "max-speed", 0);
839 #if CONFIG_IS_ENABLED(DM_GPIO)
840 if (dev_read_bool(dev, "snps,reset-active-low"))
841 reset_flags |= GPIOD_ACTIVE_LOW;
843 ret = gpio_request_by_name(dev, "snps,reset-gpio", 0,
844 &priv->reset_gpio, reset_flags);
846 ret = dev_read_u32_array(dev, "snps,reset-delays-us",
847 dw_pdata->reset_delays, 3);
848 } else if (ret == -ENOENT) {
856 static const struct udevice_id designware_eth_ids[] = {
857 { .compatible = "allwinner,sun7i-a20-gmac" },
858 { .compatible = "amlogic,meson6-dwmac" },
859 { .compatible = "amlogic,meson-gx-dwmac" },
860 { .compatible = "amlogic,meson-gxbb-dwmac" },
861 { .compatible = "amlogic,meson-axg-dwmac" },
862 { .compatible = "st,stm32-dwmac" },
863 { .compatible = "snps,arc-dwmac-3.70a" },
867 U_BOOT_DRIVER(eth_designware) = {
868 .name = "eth_designware",
870 .of_match = designware_eth_ids,
871 .ofdata_to_platdata = designware_eth_ofdata_to_platdata,
872 .bind = designware_eth_bind,
873 .probe = designware_eth_probe,
874 .remove = designware_eth_remove,
875 .ops = &designware_eth_ops,
876 .priv_auto_alloc_size = sizeof(struct dw_eth_dev),
877 .platdata_auto_alloc_size = sizeof(struct dw_eth_pdata),
878 .flags = DM_FLAG_ALLOC_PRIV_DMA,
881 static struct pci_device_id supported[] = {
882 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_QRK_EMAC) },
886 U_BOOT_PCI_DEVICE(eth_designware, supported);