1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2011 Michal Simek <monstr@monstr.eu>
4 * Copyright (C) 2011 PetaLogix
5 * Copyright (C) 2010 Xilinx, Inc. All rights reserved.
15 #include <asm/global_data.h>
20 #include <linux/delay.h>
22 DECLARE_GLOBAL_DATA_PTR;
25 #define XAE_EMMC_LINKSPEED_MASK 0xC0000000 /* Link speed */
26 #define XAE_EMMC_LINKSPD_10 0x00000000 /* Link Speed mask for 10 Mbit */
27 #define XAE_EMMC_LINKSPD_100 0x40000000 /* Link Speed mask for 100 Mbit */
28 #define XAE_EMMC_LINKSPD_1000 0x80000000 /* Link Speed mask for 1000 Mbit */
30 /* Interrupt Status/Enable/Mask Registers bit definitions */
31 #define XAE_INT_RXRJECT_MASK 0x00000008 /* Rx frame rejected */
32 #define XAE_INT_MGTRDY_MASK 0x00000080 /* MGT clock Lock */
34 /* Receive Configuration Word 1 (RCW1) Register bit definitions */
35 #define XAE_RCW1_RX_MASK 0x10000000 /* Receiver enable */
37 /* Transmitter Configuration (TC) Register bit definitions */
38 #define XAE_TC_TX_MASK 0x10000000 /* Transmitter enable */
40 #define XAE_UAW1_UNICASTADDR_MASK 0x0000FFFF
42 /* MDIO Management Configuration (MC) Register bit definitions */
43 #define XAE_MDIO_MC_MDIOEN_MASK 0x00000040 /* MII management enable*/
45 /* MDIO Management Control Register (MCR) Register bit definitions */
46 #define XAE_MDIO_MCR_PHYAD_MASK 0x1F000000 /* Phy Address Mask */
47 #define XAE_MDIO_MCR_PHYAD_SHIFT 24 /* Phy Address Shift */
48 #define XAE_MDIO_MCR_REGAD_MASK 0x001F0000 /* Reg Address Mask */
49 #define XAE_MDIO_MCR_REGAD_SHIFT 16 /* Reg Address Shift */
50 #define XAE_MDIO_MCR_OP_READ_MASK 0x00008000 /* Op Code Read Mask */
51 #define XAE_MDIO_MCR_OP_WRITE_MASK 0x00004000 /* Op Code Write Mask */
52 #define XAE_MDIO_MCR_INITIATE_MASK 0x00000800 /* Ready Mask */
53 #define XAE_MDIO_MCR_READY_MASK 0x00000080 /* Ready Mask */
55 #define XAE_MDIO_DIV_DFT 29 /* Default MDIO clock divisor */
57 #define XAXIDMA_BD_STS_ACTUAL_LEN_MASK 0x007FFFFF /* Actual len */
60 /* Bitmasks of XAXIDMA_CR_OFFSET register */
61 #define XAXIDMA_CR_RUNSTOP_MASK 0x00000001 /* Start/stop DMA channel */
62 #define XAXIDMA_CR_RESET_MASK 0x00000004 /* Reset DMA engine */
64 /* Bitmasks of XAXIDMA_SR_OFFSET register */
65 #define XAXIDMA_HALTED_MASK 0x00000001 /* DMA channel halted */
67 /* Bitmask for interrupts */
68 #define XAXIDMA_IRQ_IOC_MASK 0x00001000 /* Completion intr */
69 #define XAXIDMA_IRQ_DELAY_MASK 0x00002000 /* Delay interrupt */
70 #define XAXIDMA_IRQ_ALL_MASK 0x00007000 /* All interrupts */
72 /* Bitmasks of XAXIDMA_BD_CTRL_OFFSET register */
73 #define XAXIDMA_BD_CTRL_TXSOF_MASK 0x08000000 /* First tx packet */
74 #define XAXIDMA_BD_CTRL_TXEOF_MASK 0x04000000 /* Last tx packet */
78 static u8 rxframe[PKTSIZE_ALIGN] __attribute((aligned(DMAALIGN)));
80 /* Reflect dma offsets */
82 u32 control; /* DMACR */
83 u32 status; /* DMASR */
84 u32 current; /* CURDESC low 32 bit */
85 u32 current_hi; /* CURDESC high 32 bit */
86 u32 tail; /* TAILDESC low 32 bit */
87 u32 tail_hi; /* TAILDESC high 32 bit */
90 /* Platform data structures */
92 struct eth_pdata eth_pdata;
93 struct axidma_reg *dmatx;
94 struct axidma_reg *dmarx;
100 /* Private driver structures */
102 struct axidma_reg *dmatx;
103 struct axidma_reg *dmarx;
105 struct axi_regs *iobase;
106 phy_interface_t interface;
107 struct phy_device *phydev;
115 u32 next_desc; /* Next descriptor pointer */
117 u32 buf_addr; /* Buffer address */
121 u32 cntrl; /* Control */
122 u32 status; /* Status */
124 u32 app1; /* TX start << 16 | insert */
125 u32 app2; /* TX csum seed */
133 /* Static BDs - driver uses only one BD */
134 static struct axidma_bd tx_bd __attribute((aligned(DMAALIGN)));
135 static struct axidma_bd rx_bd __attribute((aligned(DMAALIGN)));
139 u32 is; /* 0xC: Interrupt status */
141 u32 ie; /* 0x14: Interrupt enable */
143 u32 rcw1; /* 0x404: Rx Configuration Word 1 */
144 u32 tc; /* 0x408: Tx Configuration */
146 u32 emmc; /* 0x410: EMAC mode configuration */
148 u32 mdio_mc; /* 0x500: MII Management Config */
149 u32 mdio_mcr; /* 0x504: MII Management Control */
150 u32 mdio_mwd; /* 0x508: MII Management Write Data */
151 u32 mdio_mrd; /* 0x50C: MII Management Read Data */
153 u32 uaw0; /* 0x700: Unicast address word 0 */
154 u32 uaw1; /* 0x704: Unicast address word 1 */
157 /* Use MII register 1 (MII status register) to detect PHY */
158 #define PHY_DETECT_REG 1
161 * Mask used to verify certain PHY features (or register contents)
162 * in the register above:
163 * 0x1000: 10Mbps full duplex support
164 * 0x0800: 10Mbps half duplex support
165 * 0x0008: Auto-negotiation support
167 #define PHY_DETECT_MASK 0x1808
169 static inline int mdio_wait(struct axi_regs *regs)
173 /* Wait till MDIO interface is ready to accept a new transaction. */
174 while (timeout && (!(readl(®s->mdio_mcr)
175 & XAE_MDIO_MCR_READY_MASK))) {
180 printf("%s: Timeout\n", __func__);
187 * axienet_dma_write - Memory mapped Axi DMA register Buffer Descriptor write.
188 * @bd: pointer to BD descriptor structure
189 * @desc: Address offset of DMA descriptors
191 * This function writes the value into the corresponding Axi DMA register.
193 static inline void axienet_dma_write(struct axidma_bd *bd, u32 *desc)
195 #if defined(CONFIG_PHYS_64BIT)
196 writeq((unsigned long)bd, desc);
198 writel((u32)bd, desc);
202 static u32 phyread(struct axidma_priv *priv, u32 phyaddress, u32 registernum,
205 struct axi_regs *regs = priv->iobase;
211 mdioctrlreg = ((phyaddress << XAE_MDIO_MCR_PHYAD_SHIFT) &
212 XAE_MDIO_MCR_PHYAD_MASK) |
213 ((registernum << XAE_MDIO_MCR_REGAD_SHIFT)
214 & XAE_MDIO_MCR_REGAD_MASK) |
215 XAE_MDIO_MCR_INITIATE_MASK |
216 XAE_MDIO_MCR_OP_READ_MASK;
218 writel(mdioctrlreg, ®s->mdio_mcr);
224 *val = readl(®s->mdio_mrd);
228 static u32 phywrite(struct axidma_priv *priv, u32 phyaddress, u32 registernum,
231 struct axi_regs *regs = priv->iobase;
237 mdioctrlreg = ((phyaddress << XAE_MDIO_MCR_PHYAD_SHIFT) &
238 XAE_MDIO_MCR_PHYAD_MASK) |
239 ((registernum << XAE_MDIO_MCR_REGAD_SHIFT)
240 & XAE_MDIO_MCR_REGAD_MASK) |
241 XAE_MDIO_MCR_INITIATE_MASK |
242 XAE_MDIO_MCR_OP_WRITE_MASK;
245 writel(data, ®s->mdio_mwd);
247 writel(mdioctrlreg, ®s->mdio_mcr);
255 static int axiemac_phy_init(struct udevice *dev)
260 struct axidma_priv *priv = dev_get_priv(dev);
261 struct axi_regs *regs = priv->iobase;
262 struct phy_device *phydev;
264 u32 supported = SUPPORTED_10baseT_Half |
265 SUPPORTED_10baseT_Full |
266 SUPPORTED_100baseT_Half |
267 SUPPORTED_100baseT_Full |
268 SUPPORTED_1000baseT_Half |
269 SUPPORTED_1000baseT_Full;
271 /* Set default MDIO divisor */
272 writel(XAE_MDIO_DIV_DFT | XAE_MDIO_MC_MDIOEN_MASK, ®s->mdio_mc);
274 if (priv->phyaddr == -1) {
275 /* Detect the PHY address */
276 for (i = 31; i >= 0; i--) {
277 ret = phyread(priv, i, PHY_DETECT_REG, &phyreg);
278 if (!ret && (phyreg != 0xFFFF) &&
279 ((phyreg & PHY_DETECT_MASK) == PHY_DETECT_MASK)) {
280 /* Found a valid PHY address */
282 debug("axiemac: Found valid phy address, %x\n",
289 /* Interface - look at tsec */
290 phydev = phy_connect(priv->bus, priv->phyaddr, dev, priv->interface);
292 phydev->supported &= supported;
293 phydev->advertising = phydev->supported;
294 priv->phydev = phydev;
295 if (priv->phy_of_handle)
296 priv->phydev->node = offset_to_ofnode(priv->phy_of_handle);
302 /* Setting axi emac and phy to proper setting */
303 static int setup_phy(struct udevice *dev)
306 u32 speed, emmc_reg, ret;
307 struct axidma_priv *priv = dev_get_priv(dev);
308 struct axi_regs *regs = priv->iobase;
309 struct phy_device *phydev = priv->phydev;
311 if (priv->interface == PHY_INTERFACE_MODE_SGMII) {
313 * In SGMII cases the isolate bit might set
314 * after DMA and ethernet resets and hence
315 * check and clear if set.
317 ret = phyread(priv, priv->phyaddr, MII_BMCR, &temp);
320 if (temp & BMCR_ISOLATE) {
321 temp &= ~BMCR_ISOLATE;
322 ret = phywrite(priv, priv->phyaddr, MII_BMCR, temp);
328 if (phy_startup(phydev)) {
329 printf("axiemac: could not initialize PHY %s\n",
334 printf("%s: No link.\n", phydev->dev->name);
338 switch (phydev->speed) {
340 speed = XAE_EMMC_LINKSPD_1000;
343 speed = XAE_EMMC_LINKSPD_100;
346 speed = XAE_EMMC_LINKSPD_10;
352 /* Setup the emac for the phy speed */
353 emmc_reg = readl(®s->emmc);
354 emmc_reg &= ~XAE_EMMC_LINKSPEED_MASK;
357 /* Write new speed setting out to Axi Ethernet */
358 writel(emmc_reg, ®s->emmc);
361 * Setting the operating speed of the MAC needs a delay. There
362 * doesn't seem to be register to poll, so please consider this
363 * during your application design.
370 /* STOP DMA transfers */
371 static void axiemac_stop(struct udevice *dev)
373 struct axidma_priv *priv = dev_get_priv(dev);
376 /* Stop the hardware */
377 temp = readl(&priv->dmatx->control);
378 temp &= ~XAXIDMA_CR_RUNSTOP_MASK;
379 writel(temp, &priv->dmatx->control);
381 temp = readl(&priv->dmarx->control);
382 temp &= ~XAXIDMA_CR_RUNSTOP_MASK;
383 writel(temp, &priv->dmarx->control);
385 debug("axiemac: Halted\n");
388 static int axi_ethernet_init(struct axidma_priv *priv)
390 struct axi_regs *regs = priv->iobase;
394 * Check the status of the MgtRdy bit in the interrupt status
395 * registers. This must be done to allow the MGT clock to become stable
396 * for the Sgmii and 1000BaseX PHY interfaces. No other register reads
397 * will be valid until this bit is valid.
398 * The bit is always a 1 for all other PHY interfaces.
399 * Interrupt status and enable registers are not available in non
400 * processor mode and hence bypass in this mode
402 if (!priv->eth_hasnobuf) {
403 err = wait_for_bit_le32(®s->is, XAE_INT_MGTRDY_MASK,
406 printf("%s: Timeout\n", __func__);
411 * Stop the device and reset HW
414 writel(0, ®s->ie);
417 /* Disable the receiver */
418 writel(readl(®s->rcw1) & ~XAE_RCW1_RX_MASK, ®s->rcw1);
421 * Stopping the receiver in mid-packet causes a dropped packet
422 * indication from HW. Clear it.
424 if (!priv->eth_hasnobuf) {
425 /* Set the interrupt status register to clear the interrupt */
426 writel(XAE_INT_RXRJECT_MASK, ®s->is);
430 /* Set default MDIO divisor */
431 writel(XAE_MDIO_DIV_DFT | XAE_MDIO_MC_MDIOEN_MASK, ®s->mdio_mc);
433 debug("axiemac: InitHw done\n");
437 static int axiemac_write_hwaddr(struct udevice *dev)
439 struct eth_pdata *pdata = dev_get_plat(dev);
440 struct axidma_priv *priv = dev_get_priv(dev);
441 struct axi_regs *regs = priv->iobase;
443 /* Set the MAC address */
444 int val = ((pdata->enetaddr[3] << 24) | (pdata->enetaddr[2] << 16) |
445 (pdata->enetaddr[1] << 8) | (pdata->enetaddr[0]));
446 writel(val, ®s->uaw0);
448 val = (pdata->enetaddr[5] << 8) | pdata->enetaddr[4];
449 val |= readl(®s->uaw1) & ~XAE_UAW1_UNICASTADDR_MASK;
450 writel(val, ®s->uaw1);
454 /* Reset DMA engine */
455 static void axi_dma_init(struct axidma_priv *priv)
459 /* Reset the engine so the hardware starts from a known state */
460 writel(XAXIDMA_CR_RESET_MASK, &priv->dmatx->control);
461 writel(XAXIDMA_CR_RESET_MASK, &priv->dmarx->control);
463 /* At the initialization time, hardware should finish reset quickly */
465 /* Check transmit/receive channel */
466 /* Reset is done when the reset bit is low */
467 if (!((readl(&priv->dmatx->control) |
468 readl(&priv->dmarx->control))
469 & XAXIDMA_CR_RESET_MASK)) {
474 printf("%s: Timeout\n", __func__);
477 static int axiemac_start(struct udevice *dev)
479 struct axidma_priv *priv = dev_get_priv(dev);
480 struct axi_regs *regs = priv->iobase;
483 debug("axiemac: Init started\n");
485 * Initialize AXIDMA engine. AXIDMA engine must be initialized before
486 * AxiEthernet. During AXIDMA engine initialization, AXIDMA hardware is
487 * reset, and since AXIDMA reset line is connected to AxiEthernet, this
488 * would ensure a reset of AxiEthernet.
492 /* Initialize AxiEthernet hardware. */
493 if (axi_ethernet_init(priv))
496 /* Disable all RX interrupts before RxBD space setup */
497 temp = readl(&priv->dmarx->control);
498 temp &= ~XAXIDMA_IRQ_ALL_MASK;
499 writel(temp, &priv->dmarx->control);
501 /* Start DMA RX channel. Now it's ready to receive data.*/
502 axienet_dma_write(&rx_bd, &priv->dmarx->current);
505 memset(&rx_bd, 0, sizeof(rx_bd));
506 rx_bd.next_desc = lower_32_bits((unsigned long)&rx_bd);
507 rx_bd.buf_addr = lower_32_bits((unsigned long)&rxframe);
508 #if defined(CONFIG_PHYS_64BIT)
509 rx_bd.next_desc_msb = upper_32_bits((unsigned long)&rx_bd);
510 rx_bd.buf_addr_msb = upper_32_bits((unsigned long)&rxframe);
512 rx_bd.cntrl = sizeof(rxframe);
513 /* Flush the last BD so DMA core could see the updates */
514 flush_cache((phys_addr_t)&rx_bd, sizeof(rx_bd));
516 /* It is necessary to flush rxframe because if you don't do it
517 * then cache can contain uninitialized data */
518 flush_cache((phys_addr_t)&rxframe, sizeof(rxframe));
520 /* Start the hardware */
521 temp = readl(&priv->dmarx->control);
522 temp |= XAXIDMA_CR_RUNSTOP_MASK;
523 writel(temp, &priv->dmarx->control);
525 /* Rx BD is ready - start */
526 axienet_dma_write(&rx_bd, &priv->dmarx->tail);
529 writel(XAE_TC_TX_MASK, ®s->tc);
531 writel(XAE_RCW1_RX_MASK, ®s->rcw1);
534 if (!setup_phy(dev)) {
539 debug("axiemac: Init complete\n");
543 static int axiemac_send(struct udevice *dev, void *ptr, int len)
545 struct axidma_priv *priv = dev_get_priv(dev);
548 if (len > PKTSIZE_ALIGN)
551 /* Flush packet to main memory to be trasfered by DMA */
552 flush_cache((phys_addr_t)ptr, len);
555 memset(&tx_bd, 0, sizeof(tx_bd));
556 /* At the end of the ring, link the last BD back to the top */
557 tx_bd.next_desc = lower_32_bits((unsigned long)&tx_bd);
558 tx_bd.buf_addr = lower_32_bits((unsigned long)ptr);
559 #if defined(CONFIG_PHYS_64BIT)
560 tx_bd.next_desc_msb = upper_32_bits((unsigned long)&tx_bd);
561 tx_bd.buf_addr_msb = upper_32_bits((unsigned long)ptr);
564 tx_bd.cntrl = len | XAXIDMA_BD_CTRL_TXSOF_MASK |
565 XAXIDMA_BD_CTRL_TXEOF_MASK;
567 /* Flush the last BD so DMA core could see the updates */
568 flush_cache((phys_addr_t)&tx_bd, sizeof(tx_bd));
570 if (readl(&priv->dmatx->status) & XAXIDMA_HALTED_MASK) {
572 axienet_dma_write(&tx_bd, &priv->dmatx->current);
573 /* Start the hardware */
574 temp = readl(&priv->dmatx->control);
575 temp |= XAXIDMA_CR_RUNSTOP_MASK;
576 writel(temp, &priv->dmatx->control);
580 axienet_dma_write(&tx_bd, &priv->dmatx->tail);
582 /* Wait for transmission to complete */
583 debug("axiemac: Waiting for tx to be done\n");
585 while (timeout && (!(readl(&priv->dmatx->status) &
586 (XAXIDMA_IRQ_DELAY_MASK | XAXIDMA_IRQ_IOC_MASK)))) {
591 printf("%s: Timeout\n", __func__);
595 debug("axiemac: Sending complete\n");
599 static int isrxready(struct axidma_priv *priv)
603 /* Read pending interrupts */
604 status = readl(&priv->dmarx->status);
606 /* Acknowledge pending interrupts */
607 writel(status & XAXIDMA_IRQ_ALL_MASK, &priv->dmarx->status);
610 * If Reception done interrupt is asserted, call RX call back function
611 * to handle the processed BDs and then raise the according flag.
613 if ((status & (XAXIDMA_IRQ_DELAY_MASK | XAXIDMA_IRQ_IOC_MASK)))
619 static int axiemac_recv(struct udevice *dev, int flags, uchar **packetp)
622 struct axidma_priv *priv = dev_get_priv(dev);
625 /* Wait for an incoming packet */
626 if (!isrxready(priv))
629 debug("axiemac: RX data ready\n");
631 /* Disable IRQ for a moment till packet is handled */
632 temp = readl(&priv->dmarx->control);
633 temp &= ~XAXIDMA_IRQ_ALL_MASK;
634 writel(temp, &priv->dmarx->control);
635 if (!priv->eth_hasnobuf)
636 length = rx_bd.app4 & 0xFFFF; /* max length mask */
638 length = rx_bd.status & XAXIDMA_BD_STS_ACTUAL_LEN_MASK;
641 print_buffer(&rxframe, &rxframe[0], 1, length, 16);
648 static int axiemac_free_pkt(struct udevice *dev, uchar *packet, int length)
650 struct axidma_priv *priv = dev_get_priv(dev);
653 /* It is useful to clear buffer to be sure that it is consistent */
654 memset(rxframe, 0, sizeof(rxframe));
657 /* Clear the whole buffer and setup it again - all flags are cleared */
658 memset(&rx_bd, 0, sizeof(rx_bd));
659 rx_bd.next_desc = lower_32_bits((unsigned long)&rx_bd);
660 rx_bd.buf_addr = lower_32_bits((unsigned long)&rxframe);
661 #if defined(CONFIG_PHYS_64BIT)
662 rx_bd.next_desc_msb = upper_32_bits((unsigned long)&rx_bd);
663 rx_bd.buf_addr_msb = upper_32_bits((unsigned long)&rxframe);
665 rx_bd.cntrl = sizeof(rxframe);
668 flush_cache((phys_addr_t)&rx_bd, sizeof(rx_bd));
670 /* It is necessary to flush rxframe because if you don't do it
671 * then cache will contain previous packet */
672 flush_cache((phys_addr_t)&rxframe, sizeof(rxframe));
674 /* Rx BD is ready - start again */
675 axienet_dma_write(&rx_bd, &priv->dmarx->tail);
677 debug("axiemac: RX completed, framelength = %d\n", length);
682 static int axiemac_miiphy_read(struct mii_dev *bus, int addr,
688 ret = phyread(bus->priv, addr, reg, &value);
689 debug("axiemac: Read MII 0x%x, 0x%x, 0x%x, %d\n", addr, reg,
694 static int axiemac_miiphy_write(struct mii_dev *bus, int addr, int devad,
697 debug("axiemac: Write MII 0x%x, 0x%x, 0x%x\n", addr, reg, value);
698 return phywrite(bus->priv, addr, reg, value);
701 static int axi_emac_probe(struct udevice *dev)
703 struct axidma_plat *plat = dev_get_plat(dev);
704 struct eth_pdata *pdata = &plat->eth_pdata;
705 struct axidma_priv *priv = dev_get_priv(dev);
708 priv->iobase = (struct axi_regs *)pdata->iobase;
709 priv->dmatx = plat->dmatx;
710 /* RX channel offset is 0x30 */
711 priv->dmarx = (struct axidma_reg *)((phys_addr_t)priv->dmatx + 0x30);
712 priv->eth_hasnobuf = plat->eth_hasnobuf;
713 priv->phyaddr = plat->phyaddr;
714 priv->phy_of_handle = plat->phy_of_handle;
715 priv->interface = pdata->phy_interface;
717 priv->bus = mdio_alloc();
718 priv->bus->read = axiemac_miiphy_read;
719 priv->bus->write = axiemac_miiphy_write;
720 priv->bus->priv = priv;
722 ret = mdio_register_seq(priv->bus, dev_seq(dev));
726 axiemac_phy_init(dev);
731 static int axi_emac_remove(struct udevice *dev)
733 struct axidma_priv *priv = dev_get_priv(dev);
736 mdio_unregister(priv->bus);
737 mdio_free(priv->bus);
742 static const struct eth_ops axi_emac_ops = {
743 .start = axiemac_start,
744 .send = axiemac_send,
745 .recv = axiemac_recv,
746 .free_pkt = axiemac_free_pkt,
747 .stop = axiemac_stop,
748 .write_hwaddr = axiemac_write_hwaddr,
751 static int axi_emac_of_to_plat(struct udevice *dev)
753 struct axidma_plat *plat = dev_get_plat(dev);
754 struct eth_pdata *pdata = &plat->eth_pdata;
755 int node = dev_of_offset(dev);
757 const char *phy_mode;
759 pdata->iobase = dev_read_addr(dev);
761 offset = fdtdec_lookup_phandle(gd->fdt_blob, node,
762 "axistream-connected");
764 printf("%s: axistream is not found\n", __func__);
767 plat->dmatx = (struct axidma_reg *)fdtdec_get_addr(gd->fdt_blob,
770 printf("%s: axi_dma register space not found\n", __func__);
776 offset = fdtdec_lookup_phandle(gd->fdt_blob, node, "phy-handle");
778 plat->phyaddr = fdtdec_get_int(gd->fdt_blob, offset, "reg", -1);
779 plat->phy_of_handle = offset;
782 phy_mode = fdt_getprop(gd->fdt_blob, node, "phy-mode", NULL);
784 pdata->phy_interface = phy_get_interface_by_name(phy_mode);
785 if (pdata->phy_interface == -1) {
786 printf("%s: Invalid PHY interface '%s'\n", __func__, phy_mode);
790 plat->eth_hasnobuf = fdtdec_get_bool(gd->fdt_blob, node,
791 "xlnx,eth-hasnobuf");
793 printf("AXI EMAC: %lx, phyaddr %d, interface %s\n", (ulong)pdata->iobase,
794 plat->phyaddr, phy_string_for_interface(pdata->phy_interface));
799 static const struct udevice_id axi_emac_ids[] = {
800 { .compatible = "xlnx,axi-ethernet-1.00.a" },
804 U_BOOT_DRIVER(axi_emac) = {
807 .of_match = axi_emac_ids,
808 .of_to_plat = axi_emac_of_to_plat,
809 .probe = axi_emac_probe,
810 .remove = axi_emac_remove,
811 .ops = &axi_emac_ops,
812 .priv_auto = sizeof(struct axidma_priv),
813 .plat_auto = sizeof(struct axidma_plat),