blob: 2ce6271afe82065e957b71d4b45fb9fa1d7879b6 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Michal Simek6fc7c452011-10-06 20:35:35 +00002/*
3 * Copyright (C) 2011 Michal Simek <monstr@monstr.eu>
4 * Copyright (C) 2011 PetaLogix
5 * Copyright (C) 2010 Xilinx, Inc. All rights reserved.
Michal Simek6fc7c452011-10-06 20:35:35 +00006 */
7
8#include <config.h>
9#include <common.h>
Simon Glass63334482019-11-14 12:57:39 -070010#include <cpu_func.h>
Michal Simek682baac2015-12-08 15:44:41 +010011#include <dm.h>
Simon Glass0f2af882020-05-10 11:40:05 -060012#include <log.h>
Michal Simek6fc7c452011-10-06 20:35:35 +000013#include <net.h>
14#include <malloc.h>
Simon Glass3ba929a2020-10-30 21:38:53 -060015#include <asm/global_data.h>
Michal Simek6fc7c452011-10-06 20:35:35 +000016#include <asm/io.h>
17#include <phy.h>
18#include <miiphy.h>
Siva Durga Prasad Paladugu20633622017-01-06 16:18:50 +053019#include <wait_bit.h>
Simon Glassdbd79542020-05-10 11:40:11 -060020#include <linux/delay.h>
Michal Simek6fc7c452011-10-06 20:35:35 +000021
Michal Simek682baac2015-12-08 15:44:41 +010022DECLARE_GLOBAL_DATA_PTR;
23
Michal Simek6fc7c452011-10-06 20:35:35 +000024/* Link setup */
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 */
29
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 */
33
34/* Receive Configuration Word 1 (RCW1) Register bit definitions */
35#define XAE_RCW1_RX_MASK 0x10000000 /* Receiver enable */
36
37/* Transmitter Configuration (TC) Register bit definitions */
38#define XAE_TC_TX_MASK 0x10000000 /* Transmitter enable */
39
40#define XAE_UAW1_UNICASTADDR_MASK 0x0000FFFF
41
42/* MDIO Management Configuration (MC) Register bit definitions */
43#define XAE_MDIO_MC_MDIOEN_MASK 0x00000040 /* MII management enable*/
44
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 */
54
55#define XAE_MDIO_DIV_DFT 29 /* Default MDIO clock divisor */
56
Siva Durga Prasad Paladuguf8026032017-01-06 16:27:15 +053057#define XAXIDMA_BD_STS_ACTUAL_LEN_MASK 0x007FFFFF /* Actual len */
58
Michal Simek6fc7c452011-10-06 20:35:35 +000059/* DMA macros */
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 */
63
64/* Bitmasks of XAXIDMA_SR_OFFSET register */
65#define XAXIDMA_HALTED_MASK 0x00000001 /* DMA channel halted */
66
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 */
71
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 */
75
76#define DMAALIGN 128
77
78static u8 rxframe[PKTSIZE_ALIGN] __attribute((aligned(DMAALIGN)));
79
80/* Reflect dma offsets */
81struct axidma_reg {
82 u32 control; /* DMACR */
83 u32 status; /* DMASR */
Vipul Kumar3b06a0f2018-01-23 14:52:35 +053084 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 */
Michal Simek6fc7c452011-10-06 20:35:35 +000088};
89
90/* Private driver structures */
91struct axidma_priv {
92 struct axidma_reg *dmatx;
93 struct axidma_reg *dmarx;
94 int phyaddr;
Michal Simek6cb55e72015-12-09 14:39:42 +010095 struct axi_regs *iobase;
Michal Simek682baac2015-12-08 15:44:41 +010096 phy_interface_t interface;
Michal Simek6fc7c452011-10-06 20:35:35 +000097 struct phy_device *phydev;
98 struct mii_dev *bus;
Siva Durga Prasad Paladuguf8026032017-01-06 16:27:15 +053099 u8 eth_hasnobuf;
Siva Durga Prasad Paladuguc3d94f62019-03-15 17:46:45 +0530100 int phy_of_handle;
Michal Simek6fc7c452011-10-06 20:35:35 +0000101};
102
103/* BD descriptors */
104struct axidma_bd {
Ashok Reddy Soma91d455a2020-09-03 08:36:43 -0600105 u32 next_desc; /* Next descriptor pointer */
106 u32 next_desc_msb;
107 u32 buf_addr; /* Buffer address */
108 u32 buf_addr_msb;
Michal Simek6fc7c452011-10-06 20:35:35 +0000109 u32 reserved3;
110 u32 reserved4;
111 u32 cntrl; /* Control */
112 u32 status; /* Status */
113 u32 app0;
114 u32 app1; /* TX start << 16 | insert */
115 u32 app2; /* TX csum seed */
116 u32 app3;
117 u32 app4;
118 u32 sw_id_offset;
119 u32 reserved5;
120 u32 reserved6;
121};
122
123/* Static BDs - driver uses only one BD */
124static struct axidma_bd tx_bd __attribute((aligned(DMAALIGN)));
125static struct axidma_bd rx_bd __attribute((aligned(DMAALIGN)));
126
127struct axi_regs {
128 u32 reserved[3];
129 u32 is; /* 0xC: Interrupt status */
130 u32 reserved2;
131 u32 ie; /* 0x14: Interrupt enable */
132 u32 reserved3[251];
133 u32 rcw1; /* 0x404: Rx Configuration Word 1 */
134 u32 tc; /* 0x408: Tx Configuration */
135 u32 reserved4;
136 u32 emmc; /* 0x410: EMAC mode configuration */
137 u32 reserved5[59];
138 u32 mdio_mc; /* 0x500: MII Management Config */
139 u32 mdio_mcr; /* 0x504: MII Management Control */
140 u32 mdio_mwd; /* 0x508: MII Management Write Data */
141 u32 mdio_mrd; /* 0x50C: MII Management Read Data */
142 u32 reserved6[124];
143 u32 uaw0; /* 0x700: Unicast address word 0 */
144 u32 uaw1; /* 0x704: Unicast address word 1 */
145};
146
147/* Use MII register 1 (MII status register) to detect PHY */
148#define PHY_DETECT_REG 1
149
150/*
151 * Mask used to verify certain PHY features (or register contents)
152 * in the register above:
153 * 0x1000: 10Mbps full duplex support
154 * 0x0800: 10Mbps half duplex support
155 * 0x0008: Auto-negotiation support
156 */
157#define PHY_DETECT_MASK 0x1808
158
Michal Simekf5221872015-12-09 14:36:31 +0100159static inline int mdio_wait(struct axi_regs *regs)
Michal Simek6fc7c452011-10-06 20:35:35 +0000160{
Michal Simek6fc7c452011-10-06 20:35:35 +0000161 u32 timeout = 200;
162
163 /* Wait till MDIO interface is ready to accept a new transaction. */
Siva Durga Prasad Paladugud227c9a2017-11-23 12:23:12 +0530164 while (timeout && (!(readl(&regs->mdio_mcr)
Michal Simek6fc7c452011-10-06 20:35:35 +0000165 & XAE_MDIO_MCR_READY_MASK))) {
166 timeout--;
167 udelay(1);
168 }
169 if (!timeout) {
170 printf("%s: Timeout\n", __func__);
171 return 1;
172 }
173 return 0;
174}
175
Vipul Kumar3b06a0f2018-01-23 14:52:35 +0530176/**
177 * axienet_dma_write - Memory mapped Axi DMA register Buffer Descriptor write.
178 * @bd: pointer to BD descriptor structure
179 * @desc: Address offset of DMA descriptors
180 *
181 * This function writes the value into the corresponding Axi DMA register.
182 */
183static inline void axienet_dma_write(struct axidma_bd *bd, u32 *desc)
184{
185#if defined(CONFIG_PHYS_64BIT)
Ashok Reddy Soma91d455a2020-09-03 08:36:43 -0600186 writeq((unsigned long)bd, desc);
Vipul Kumar3b06a0f2018-01-23 14:52:35 +0530187#else
188 writel((u32)bd, desc);
189#endif
190}
191
Michal Simek41beca12015-12-09 14:44:38 +0100192static u32 phyread(struct axidma_priv *priv, u32 phyaddress, u32 registernum,
193 u16 *val)
Michal Simek6fc7c452011-10-06 20:35:35 +0000194{
Michal Simek41beca12015-12-09 14:44:38 +0100195 struct axi_regs *regs = priv->iobase;
Michal Simek6fc7c452011-10-06 20:35:35 +0000196 u32 mdioctrlreg = 0;
197
Michal Simekf5221872015-12-09 14:36:31 +0100198 if (mdio_wait(regs))
Michal Simek6fc7c452011-10-06 20:35:35 +0000199 return 1;
200
201 mdioctrlreg = ((phyaddress << XAE_MDIO_MCR_PHYAD_SHIFT) &
202 XAE_MDIO_MCR_PHYAD_MASK) |
203 ((registernum << XAE_MDIO_MCR_REGAD_SHIFT)
204 & XAE_MDIO_MCR_REGAD_MASK) |
205 XAE_MDIO_MCR_INITIATE_MASK |
206 XAE_MDIO_MCR_OP_READ_MASK;
207
Siva Durga Prasad Paladugud227c9a2017-11-23 12:23:12 +0530208 writel(mdioctrlreg, &regs->mdio_mcr);
Michal Simek6fc7c452011-10-06 20:35:35 +0000209
Michal Simekf5221872015-12-09 14:36:31 +0100210 if (mdio_wait(regs))
Michal Simek6fc7c452011-10-06 20:35:35 +0000211 return 1;
212
213 /* Read data */
Siva Durga Prasad Paladugud227c9a2017-11-23 12:23:12 +0530214 *val = readl(&regs->mdio_mrd);
Michal Simek6fc7c452011-10-06 20:35:35 +0000215 return 0;
216}
217
Michal Simek41beca12015-12-09 14:44:38 +0100218static u32 phywrite(struct axidma_priv *priv, u32 phyaddress, u32 registernum,
219 u32 data)
Michal Simek6fc7c452011-10-06 20:35:35 +0000220{
Michal Simek41beca12015-12-09 14:44:38 +0100221 struct axi_regs *regs = priv->iobase;
Michal Simek6fc7c452011-10-06 20:35:35 +0000222 u32 mdioctrlreg = 0;
223
Michal Simekf5221872015-12-09 14:36:31 +0100224 if (mdio_wait(regs))
Michal Simek6fc7c452011-10-06 20:35:35 +0000225 return 1;
226
227 mdioctrlreg = ((phyaddress << XAE_MDIO_MCR_PHYAD_SHIFT) &
228 XAE_MDIO_MCR_PHYAD_MASK) |
229 ((registernum << XAE_MDIO_MCR_REGAD_SHIFT)
230 & XAE_MDIO_MCR_REGAD_MASK) |
231 XAE_MDIO_MCR_INITIATE_MASK |
232 XAE_MDIO_MCR_OP_WRITE_MASK;
233
234 /* Write data */
Siva Durga Prasad Paladugud227c9a2017-11-23 12:23:12 +0530235 writel(data, &regs->mdio_mwd);
Michal Simek6fc7c452011-10-06 20:35:35 +0000236
Siva Durga Prasad Paladugud227c9a2017-11-23 12:23:12 +0530237 writel(mdioctrlreg, &regs->mdio_mcr);
Michal Simek6fc7c452011-10-06 20:35:35 +0000238
Michal Simekf5221872015-12-09 14:36:31 +0100239 if (mdio_wait(regs))
Michal Simek6fc7c452011-10-06 20:35:35 +0000240 return 1;
241
242 return 0;
243}
244
Michal Simek0b13ee22015-12-08 16:10:05 +0100245static int axiemac_phy_init(struct udevice *dev)
Michal Simek6fc7c452011-10-06 20:35:35 +0000246{
247 u16 phyreg;
Patrick van Gelder70ab9432020-06-03 14:18:04 +0200248 int i;
249 u32 ret;
Michal Simek682baac2015-12-08 15:44:41 +0100250 struct axidma_priv *priv = dev_get_priv(dev);
Michal Simek6cb55e72015-12-09 14:39:42 +0100251 struct axi_regs *regs = priv->iobase;
Michal Simek6fc7c452011-10-06 20:35:35 +0000252 struct phy_device *phydev;
253
254 u32 supported = SUPPORTED_10baseT_Half |
255 SUPPORTED_10baseT_Full |
256 SUPPORTED_100baseT_Half |
257 SUPPORTED_100baseT_Full |
258 SUPPORTED_1000baseT_Half |
259 SUPPORTED_1000baseT_Full;
260
Michal Simek0b13ee22015-12-08 16:10:05 +0100261 /* Set default MDIO divisor */
Siva Durga Prasad Paladugud227c9a2017-11-23 12:23:12 +0530262 writel(XAE_MDIO_DIV_DFT | XAE_MDIO_MC_MDIOEN_MASK, &regs->mdio_mc);
Michal Simek0b13ee22015-12-08 16:10:05 +0100263
Michal Simek6fc7c452011-10-06 20:35:35 +0000264 if (priv->phyaddr == -1) {
265 /* Detect the PHY address */
266 for (i = 31; i >= 0; i--) {
Michal Simek41beca12015-12-09 14:44:38 +0100267 ret = phyread(priv, i, PHY_DETECT_REG, &phyreg);
Michal Simek6fc7c452011-10-06 20:35:35 +0000268 if (!ret && (phyreg != 0xFFFF) &&
269 ((phyreg & PHY_DETECT_MASK) == PHY_DETECT_MASK)) {
270 /* Found a valid PHY address */
271 priv->phyaddr = i;
272 debug("axiemac: Found valid phy address, %x\n",
Michal Simek2f1e0652015-12-09 10:54:53 +0100273 i);
Michal Simek6fc7c452011-10-06 20:35:35 +0000274 break;
275 }
276 }
277 }
278
279 /* Interface - look at tsec */
Siva Durga Prasad Paladugu49348512016-02-21 15:46:14 +0530280 phydev = phy_connect(priv->bus, priv->phyaddr, dev, priv->interface);
Michal Simek6fc7c452011-10-06 20:35:35 +0000281
282 phydev->supported &= supported;
283 phydev->advertising = phydev->supported;
284 priv->phydev = phydev;
Siva Durga Prasad Paladuguc3d94f62019-03-15 17:46:45 +0530285 if (priv->phy_of_handle)
286 priv->phydev->node = offset_to_ofnode(priv->phy_of_handle);
Michal Simek6fc7c452011-10-06 20:35:35 +0000287 phy_config(phydev);
Michal Simek0b13ee22015-12-08 16:10:05 +0100288
289 return 0;
290}
291
292/* Setting axi emac and phy to proper setting */
293static int setup_phy(struct udevice *dev)
294{
Siva Durga Prasad Paladugua1c6ed82016-02-21 15:46:15 +0530295 u16 temp;
296 u32 speed, emmc_reg, ret;
Michal Simek0b13ee22015-12-08 16:10:05 +0100297 struct axidma_priv *priv = dev_get_priv(dev);
298 struct axi_regs *regs = priv->iobase;
299 struct phy_device *phydev = priv->phydev;
300
Siva Durga Prasad Paladugua1c6ed82016-02-21 15:46:15 +0530301 if (priv->interface == PHY_INTERFACE_MODE_SGMII) {
302 /*
303 * In SGMII cases the isolate bit might set
304 * after DMA and ethernet resets and hence
305 * check and clear if set.
306 */
307 ret = phyread(priv, priv->phyaddr, MII_BMCR, &temp);
308 if (ret)
309 return 0;
310 if (temp & BMCR_ISOLATE) {
311 temp &= ~BMCR_ISOLATE;
312 ret = phywrite(priv, priv->phyaddr, MII_BMCR, temp);
313 if (ret)
314 return 0;
315 }
316 }
317
Timur Tabi42387462012-07-09 08:52:43 +0000318 if (phy_startup(phydev)) {
319 printf("axiemac: could not initialize PHY %s\n",
320 phydev->dev->name);
321 return 0;
322 }
Michal Simek5848f132013-11-21 16:15:51 +0100323 if (!phydev->link) {
324 printf("%s: No link.\n", phydev->dev->name);
325 return 0;
326 }
Michal Simek6fc7c452011-10-06 20:35:35 +0000327
328 switch (phydev->speed) {
329 case 1000:
330 speed = XAE_EMMC_LINKSPD_1000;
331 break;
332 case 100:
333 speed = XAE_EMMC_LINKSPD_100;
334 break;
335 case 10:
336 speed = XAE_EMMC_LINKSPD_10;
337 break;
338 default:
339 return 0;
340 }
341
342 /* Setup the emac for the phy speed */
Siva Durga Prasad Paladugud227c9a2017-11-23 12:23:12 +0530343 emmc_reg = readl(&regs->emmc);
Michal Simek6fc7c452011-10-06 20:35:35 +0000344 emmc_reg &= ~XAE_EMMC_LINKSPEED_MASK;
345 emmc_reg |= speed;
346
347 /* Write new speed setting out to Axi Ethernet */
Siva Durga Prasad Paladugud227c9a2017-11-23 12:23:12 +0530348 writel(emmc_reg, &regs->emmc);
Michal Simek6fc7c452011-10-06 20:35:35 +0000349
350 /*
351 * Setting the operating speed of the MAC needs a delay. There
352 * doesn't seem to be register to poll, so please consider this
353 * during your application design.
354 */
355 udelay(1);
356
357 return 1;
358}
359
360/* STOP DMA transfers */
Michal Simek8fbf79f2015-12-16 09:18:12 +0100361static void axiemac_stop(struct udevice *dev)
Michal Simek6fc7c452011-10-06 20:35:35 +0000362{
Michal Simek682baac2015-12-08 15:44:41 +0100363 struct axidma_priv *priv = dev_get_priv(dev);
Michal Simek6fc7c452011-10-06 20:35:35 +0000364 u32 temp;
365
366 /* Stop the hardware */
Siva Durga Prasad Paladugud227c9a2017-11-23 12:23:12 +0530367 temp = readl(&priv->dmatx->control);
Michal Simek6fc7c452011-10-06 20:35:35 +0000368 temp &= ~XAXIDMA_CR_RUNSTOP_MASK;
Siva Durga Prasad Paladugud227c9a2017-11-23 12:23:12 +0530369 writel(temp, &priv->dmatx->control);
Michal Simek6fc7c452011-10-06 20:35:35 +0000370
Siva Durga Prasad Paladugud227c9a2017-11-23 12:23:12 +0530371 temp = readl(&priv->dmarx->control);
Michal Simek6fc7c452011-10-06 20:35:35 +0000372 temp &= ~XAXIDMA_CR_RUNSTOP_MASK;
Siva Durga Prasad Paladugud227c9a2017-11-23 12:23:12 +0530373 writel(temp, &priv->dmarx->control);
Michal Simek6fc7c452011-10-06 20:35:35 +0000374
375 debug("axiemac: Halted\n");
376}
377
Michal Simek638c0ef2015-12-09 14:53:51 +0100378static int axi_ethernet_init(struct axidma_priv *priv)
Michal Simek6fc7c452011-10-06 20:35:35 +0000379{
Michal Simek638c0ef2015-12-09 14:53:51 +0100380 struct axi_regs *regs = priv->iobase;
Siva Durga Prasad Paladugu20633622017-01-06 16:18:50 +0530381 int err;
Michal Simek6fc7c452011-10-06 20:35:35 +0000382
383 /*
384 * Check the status of the MgtRdy bit in the interrupt status
385 * registers. This must be done to allow the MGT clock to become stable
386 * for the Sgmii and 1000BaseX PHY interfaces. No other register reads
387 * will be valid until this bit is valid.
388 * The bit is always a 1 for all other PHY interfaces.
Siva Durga Prasad Paladuguf8026032017-01-06 16:27:15 +0530389 * Interrupt status and enable registers are not available in non
390 * processor mode and hence bypass in this mode
Michal Simek6fc7c452011-10-06 20:35:35 +0000391 */
Siva Durga Prasad Paladuguf8026032017-01-06 16:27:15 +0530392 if (!priv->eth_hasnobuf) {
Álvaro Fernández Rojas918de032018-01-23 17:14:55 +0100393 err = wait_for_bit_le32(&regs->is, XAE_INT_MGTRDY_MASK,
394 true, 200, false);
Siva Durga Prasad Paladuguf8026032017-01-06 16:27:15 +0530395 if (err) {
396 printf("%s: Timeout\n", __func__);
397 return 1;
398 }
Michal Simek6fc7c452011-10-06 20:35:35 +0000399
Siva Durga Prasad Paladuguf8026032017-01-06 16:27:15 +0530400 /*
401 * Stop the device and reset HW
402 * Disable interrupts
403 */
Siva Durga Prasad Paladugud227c9a2017-11-23 12:23:12 +0530404 writel(0, &regs->ie);
Siva Durga Prasad Paladuguf8026032017-01-06 16:27:15 +0530405 }
Michal Simek6fc7c452011-10-06 20:35:35 +0000406
407 /* Disable the receiver */
Siva Durga Prasad Paladugud227c9a2017-11-23 12:23:12 +0530408 writel(readl(&regs->rcw1) & ~XAE_RCW1_RX_MASK, &regs->rcw1);
Michal Simek6fc7c452011-10-06 20:35:35 +0000409
410 /*
411 * Stopping the receiver in mid-packet causes a dropped packet
412 * indication from HW. Clear it.
413 */
Siva Durga Prasad Paladuguf8026032017-01-06 16:27:15 +0530414 if (!priv->eth_hasnobuf) {
415 /* Set the interrupt status register to clear the interrupt */
Siva Durga Prasad Paladugud227c9a2017-11-23 12:23:12 +0530416 writel(XAE_INT_RXRJECT_MASK, &regs->is);
Siva Durga Prasad Paladuguf8026032017-01-06 16:27:15 +0530417 }
Michal Simek6fc7c452011-10-06 20:35:35 +0000418
419 /* Setup HW */
420 /* Set default MDIO divisor */
Siva Durga Prasad Paladugud227c9a2017-11-23 12:23:12 +0530421 writel(XAE_MDIO_DIV_DFT | XAE_MDIO_MC_MDIOEN_MASK, &regs->mdio_mc);
Michal Simek6fc7c452011-10-06 20:35:35 +0000422
423 debug("axiemac: InitHw done\n");
424 return 0;
425}
426
Michal Simek8fbf79f2015-12-16 09:18:12 +0100427static int axiemac_write_hwaddr(struct udevice *dev)
Michal Simek6fc7c452011-10-06 20:35:35 +0000428{
Simon Glassfa20e932020-12-03 16:55:20 -0700429 struct eth_pdata *pdata = dev_get_plat(dev);
Michal Simek682baac2015-12-08 15:44:41 +0100430 struct axidma_priv *priv = dev_get_priv(dev);
431 struct axi_regs *regs = priv->iobase;
Michal Simek6fc7c452011-10-06 20:35:35 +0000432
433 /* Set the MAC address */
Michal Simek682baac2015-12-08 15:44:41 +0100434 int val = ((pdata->enetaddr[3] << 24) | (pdata->enetaddr[2] << 16) |
435 (pdata->enetaddr[1] << 8) | (pdata->enetaddr[0]));
Siva Durga Prasad Paladugud227c9a2017-11-23 12:23:12 +0530436 writel(val, &regs->uaw0);
Michal Simek6fc7c452011-10-06 20:35:35 +0000437
Michal Simek682baac2015-12-08 15:44:41 +0100438 val = (pdata->enetaddr[5] << 8) | pdata->enetaddr[4];
Siva Durga Prasad Paladugud227c9a2017-11-23 12:23:12 +0530439 val |= readl(&regs->uaw1) & ~XAE_UAW1_UNICASTADDR_MASK;
440 writel(val, &regs->uaw1);
Michal Simek6fc7c452011-10-06 20:35:35 +0000441 return 0;
442}
443
444/* Reset DMA engine */
Michal Simek638c0ef2015-12-09 14:53:51 +0100445static void axi_dma_init(struct axidma_priv *priv)
Michal Simek6fc7c452011-10-06 20:35:35 +0000446{
Michal Simek6fc7c452011-10-06 20:35:35 +0000447 u32 timeout = 500;
448
449 /* Reset the engine so the hardware starts from a known state */
Siva Durga Prasad Paladugud227c9a2017-11-23 12:23:12 +0530450 writel(XAXIDMA_CR_RESET_MASK, &priv->dmatx->control);
451 writel(XAXIDMA_CR_RESET_MASK, &priv->dmarx->control);
Michal Simek6fc7c452011-10-06 20:35:35 +0000452
453 /* At the initialization time, hardware should finish reset quickly */
454 while (timeout--) {
455 /* Check transmit/receive channel */
456 /* Reset is done when the reset bit is low */
Siva Durga Prasad Paladugud227c9a2017-11-23 12:23:12 +0530457 if (!((readl(&priv->dmatx->control) |
458 readl(&priv->dmarx->control))
Michal Simek5aa45392015-10-28 11:00:47 +0100459 & XAXIDMA_CR_RESET_MASK)) {
Michal Simek6fc7c452011-10-06 20:35:35 +0000460 break;
461 }
462 }
463 if (!timeout)
464 printf("%s: Timeout\n", __func__);
465}
466
Michal Simek8fbf79f2015-12-16 09:18:12 +0100467static int axiemac_start(struct udevice *dev)
Michal Simek6fc7c452011-10-06 20:35:35 +0000468{
Michal Simek682baac2015-12-08 15:44:41 +0100469 struct axidma_priv *priv = dev_get_priv(dev);
470 struct axi_regs *regs = priv->iobase;
Michal Simek6fc7c452011-10-06 20:35:35 +0000471 u32 temp;
472
473 debug("axiemac: Init started\n");
474 /*
475 * Initialize AXIDMA engine. AXIDMA engine must be initialized before
476 * AxiEthernet. During AXIDMA engine initialization, AXIDMA hardware is
477 * reset, and since AXIDMA reset line is connected to AxiEthernet, this
478 * would ensure a reset of AxiEthernet.
479 */
Michal Simek638c0ef2015-12-09 14:53:51 +0100480 axi_dma_init(priv);
Michal Simek6fc7c452011-10-06 20:35:35 +0000481
482 /* Initialize AxiEthernet hardware. */
Michal Simek638c0ef2015-12-09 14:53:51 +0100483 if (axi_ethernet_init(priv))
Michal Simek6fc7c452011-10-06 20:35:35 +0000484 return -1;
485
486 /* Disable all RX interrupts before RxBD space setup */
Siva Durga Prasad Paladugud227c9a2017-11-23 12:23:12 +0530487 temp = readl(&priv->dmarx->control);
Michal Simek6fc7c452011-10-06 20:35:35 +0000488 temp &= ~XAXIDMA_IRQ_ALL_MASK;
Siva Durga Prasad Paladugud227c9a2017-11-23 12:23:12 +0530489 writel(temp, &priv->dmarx->control);
Michal Simek6fc7c452011-10-06 20:35:35 +0000490
491 /* Start DMA RX channel. Now it's ready to receive data.*/
Vipul Kumar3b06a0f2018-01-23 14:52:35 +0530492 axienet_dma_write(&rx_bd, &priv->dmarx->current);
Michal Simek6fc7c452011-10-06 20:35:35 +0000493
494 /* Setup the BD. */
495 memset(&rx_bd, 0, sizeof(rx_bd));
Ashok Reddy Soma91d455a2020-09-03 08:36:43 -0600496 rx_bd.next_desc = lower_32_bits((unsigned long)&rx_bd);
497 rx_bd.buf_addr = lower_32_bits((unsigned long)&rxframe);
498#if defined(CONFIG_PHYS_64BIT)
499 rx_bd.next_desc_msb = upper_32_bits((unsigned long)&rx_bd);
500 rx_bd.buf_addr_msb = upper_32_bits((unsigned long)&rxframe);
501#endif
Michal Simek6fc7c452011-10-06 20:35:35 +0000502 rx_bd.cntrl = sizeof(rxframe);
503 /* Flush the last BD so DMA core could see the updates */
Ashok Reddy Somaf29a5702020-09-03 08:36:44 -0600504 flush_cache((phys_addr_t)&rx_bd, sizeof(rx_bd));
Michal Simek6fc7c452011-10-06 20:35:35 +0000505
506 /* It is necessary to flush rxframe because if you don't do it
507 * then cache can contain uninitialized data */
Ashok Reddy Somaf29a5702020-09-03 08:36:44 -0600508 flush_cache((phys_addr_t)&rxframe, sizeof(rxframe));
Michal Simek6fc7c452011-10-06 20:35:35 +0000509
510 /* Start the hardware */
Siva Durga Prasad Paladugud227c9a2017-11-23 12:23:12 +0530511 temp = readl(&priv->dmarx->control);
Michal Simek6fc7c452011-10-06 20:35:35 +0000512 temp |= XAXIDMA_CR_RUNSTOP_MASK;
Siva Durga Prasad Paladugud227c9a2017-11-23 12:23:12 +0530513 writel(temp, &priv->dmarx->control);
Michal Simek6fc7c452011-10-06 20:35:35 +0000514
515 /* Rx BD is ready - start */
Vipul Kumar3b06a0f2018-01-23 14:52:35 +0530516 axienet_dma_write(&rx_bd, &priv->dmarx->tail);
Michal Simek6fc7c452011-10-06 20:35:35 +0000517
518 /* Enable TX */
Siva Durga Prasad Paladugud227c9a2017-11-23 12:23:12 +0530519 writel(XAE_TC_TX_MASK, &regs->tc);
Michal Simek6fc7c452011-10-06 20:35:35 +0000520 /* Enable RX */
Siva Durga Prasad Paladugud227c9a2017-11-23 12:23:12 +0530521 writel(XAE_RCW1_RX_MASK, &regs->rcw1);
Michal Simek6fc7c452011-10-06 20:35:35 +0000522
523 /* PHY setup */
524 if (!setup_phy(dev)) {
Michal Simek8fbf79f2015-12-16 09:18:12 +0100525 axiemac_stop(dev);
Michal Simek6fc7c452011-10-06 20:35:35 +0000526 return -1;
527 }
528
529 debug("axiemac: Init complete\n");
530 return 0;
531}
532
Michal Simek682baac2015-12-08 15:44:41 +0100533static int axiemac_send(struct udevice *dev, void *ptr, int len)
Michal Simek6fc7c452011-10-06 20:35:35 +0000534{
Michal Simek682baac2015-12-08 15:44:41 +0100535 struct axidma_priv *priv = dev_get_priv(dev);
Michal Simek6fc7c452011-10-06 20:35:35 +0000536 u32 timeout;
537
538 if (len > PKTSIZE_ALIGN)
539 len = PKTSIZE_ALIGN;
540
541 /* Flush packet to main memory to be trasfered by DMA */
Ashok Reddy Somaf29a5702020-09-03 08:36:44 -0600542 flush_cache((phys_addr_t)ptr, len);
Michal Simek6fc7c452011-10-06 20:35:35 +0000543
544 /* Setup Tx BD */
545 memset(&tx_bd, 0, sizeof(tx_bd));
546 /* At the end of the ring, link the last BD back to the top */
Ashok Reddy Soma91d455a2020-09-03 08:36:43 -0600547 tx_bd.next_desc = lower_32_bits((unsigned long)&tx_bd);
548 tx_bd.buf_addr = lower_32_bits((unsigned long)ptr);
549#if defined(CONFIG_PHYS_64BIT)
550 tx_bd.next_desc_msb = upper_32_bits((unsigned long)&tx_bd);
551 tx_bd.buf_addr_msb = upper_32_bits((unsigned long)ptr);
552#endif
Michal Simek6fc7c452011-10-06 20:35:35 +0000553 /* Save len */
554 tx_bd.cntrl = len | XAXIDMA_BD_CTRL_TXSOF_MASK |
555 XAXIDMA_BD_CTRL_TXEOF_MASK;
556
557 /* Flush the last BD so DMA core could see the updates */
Ashok Reddy Somaf29a5702020-09-03 08:36:44 -0600558 flush_cache((phys_addr_t)&tx_bd, sizeof(tx_bd));
Michal Simek6fc7c452011-10-06 20:35:35 +0000559
Siva Durga Prasad Paladugud227c9a2017-11-23 12:23:12 +0530560 if (readl(&priv->dmatx->status) & XAXIDMA_HALTED_MASK) {
Michal Simek6fc7c452011-10-06 20:35:35 +0000561 u32 temp;
Vipul Kumar3b06a0f2018-01-23 14:52:35 +0530562 axienet_dma_write(&tx_bd, &priv->dmatx->current);
Michal Simek6fc7c452011-10-06 20:35:35 +0000563 /* Start the hardware */
Siva Durga Prasad Paladugud227c9a2017-11-23 12:23:12 +0530564 temp = readl(&priv->dmatx->control);
Michal Simek6fc7c452011-10-06 20:35:35 +0000565 temp |= XAXIDMA_CR_RUNSTOP_MASK;
Siva Durga Prasad Paladugud227c9a2017-11-23 12:23:12 +0530566 writel(temp, &priv->dmatx->control);
Michal Simek6fc7c452011-10-06 20:35:35 +0000567 }
568
569 /* Start transfer */
Vipul Kumar3b06a0f2018-01-23 14:52:35 +0530570 axienet_dma_write(&tx_bd, &priv->dmatx->tail);
Michal Simek6fc7c452011-10-06 20:35:35 +0000571
572 /* Wait for transmission to complete */
573 debug("axiemac: Waiting for tx to be done\n");
574 timeout = 200;
Siva Durga Prasad Paladugud227c9a2017-11-23 12:23:12 +0530575 while (timeout && (!(readl(&priv->dmatx->status) &
Michal Simek5aa45392015-10-28 11:00:47 +0100576 (XAXIDMA_IRQ_DELAY_MASK | XAXIDMA_IRQ_IOC_MASK)))) {
Michal Simek6fc7c452011-10-06 20:35:35 +0000577 timeout--;
578 udelay(1);
579 }
580 if (!timeout) {
581 printf("%s: Timeout\n", __func__);
582 return 1;
583 }
584
585 debug("axiemac: Sending complete\n");
586 return 0;
587}
588
Michal Simek638c0ef2015-12-09 14:53:51 +0100589static int isrxready(struct axidma_priv *priv)
Michal Simek6fc7c452011-10-06 20:35:35 +0000590{
591 u32 status;
Michal Simek6fc7c452011-10-06 20:35:35 +0000592
593 /* Read pending interrupts */
Siva Durga Prasad Paladugud227c9a2017-11-23 12:23:12 +0530594 status = readl(&priv->dmarx->status);
Michal Simek6fc7c452011-10-06 20:35:35 +0000595
596 /* Acknowledge pending interrupts */
Siva Durga Prasad Paladugud227c9a2017-11-23 12:23:12 +0530597 writel(status & XAXIDMA_IRQ_ALL_MASK, &priv->dmarx->status);
Michal Simek6fc7c452011-10-06 20:35:35 +0000598
599 /*
600 * If Reception done interrupt is asserted, call RX call back function
601 * to handle the processed BDs and then raise the according flag.
602 */
603 if ((status & (XAXIDMA_IRQ_DELAY_MASK | XAXIDMA_IRQ_IOC_MASK)))
604 return 1;
605
606 return 0;
607}
608
Michal Simek682baac2015-12-08 15:44:41 +0100609static int axiemac_recv(struct udevice *dev, int flags, uchar **packetp)
Michal Simek6fc7c452011-10-06 20:35:35 +0000610{
611 u32 length;
Michal Simek682baac2015-12-08 15:44:41 +0100612 struct axidma_priv *priv = dev_get_priv(dev);
Michal Simek6fc7c452011-10-06 20:35:35 +0000613 u32 temp;
614
615 /* Wait for an incoming packet */
Michal Simek638c0ef2015-12-09 14:53:51 +0100616 if (!isrxready(priv))
Michal Simek682baac2015-12-08 15:44:41 +0100617 return -1;
Michal Simek6fc7c452011-10-06 20:35:35 +0000618
619 debug("axiemac: RX data ready\n");
620
621 /* Disable IRQ for a moment till packet is handled */
Siva Durga Prasad Paladugud227c9a2017-11-23 12:23:12 +0530622 temp = readl(&priv->dmarx->control);
Michal Simek6fc7c452011-10-06 20:35:35 +0000623 temp &= ~XAXIDMA_IRQ_ALL_MASK;
Siva Durga Prasad Paladugud227c9a2017-11-23 12:23:12 +0530624 writel(temp, &priv->dmarx->control);
Siva Durga Prasad Paladuguf8026032017-01-06 16:27:15 +0530625 if (!priv->eth_hasnobuf)
626 length = rx_bd.app4 & 0xFFFF; /* max length mask */
627 else
628 length = rx_bd.status & XAXIDMA_BD_STS_ACTUAL_LEN_MASK;
Michal Simek6fc7c452011-10-06 20:35:35 +0000629
Michal Simek6fc7c452011-10-06 20:35:35 +0000630#ifdef DEBUG
631 print_buffer(&rxframe, &rxframe[0], 1, length, 16);
632#endif
Michal Simek0305be82015-12-09 14:13:23 +0100633
634 *packetp = rxframe;
635 return length;
636}
637
638static int axiemac_free_pkt(struct udevice *dev, uchar *packet, int length)
639{
640 struct axidma_priv *priv = dev_get_priv(dev);
Michal Simek6fc7c452011-10-06 20:35:35 +0000641
642#ifdef DEBUG
643 /* It is useful to clear buffer to be sure that it is consistent */
644 memset(rxframe, 0, sizeof(rxframe));
645#endif
646 /* Setup RxBD */
647 /* Clear the whole buffer and setup it again - all flags are cleared */
648 memset(&rx_bd, 0, sizeof(rx_bd));
Ashok Reddy Soma91d455a2020-09-03 08:36:43 -0600649 rx_bd.next_desc = lower_32_bits((unsigned long)&rx_bd);
650 rx_bd.buf_addr = lower_32_bits((unsigned long)&rxframe);
651#if defined(CONFIG_PHYS_64BIT)
652 rx_bd.next_desc_msb = upper_32_bits((unsigned long)&rx_bd);
653 rx_bd.buf_addr_msb = upper_32_bits((unsigned long)&rxframe);
654#endif
Michal Simek6fc7c452011-10-06 20:35:35 +0000655 rx_bd.cntrl = sizeof(rxframe);
656
657 /* Write bd to HW */
Ashok Reddy Somaf29a5702020-09-03 08:36:44 -0600658 flush_cache((phys_addr_t)&rx_bd, sizeof(rx_bd));
Michal Simek6fc7c452011-10-06 20:35:35 +0000659
660 /* It is necessary to flush rxframe because if you don't do it
661 * then cache will contain previous packet */
Ashok Reddy Somaf29a5702020-09-03 08:36:44 -0600662 flush_cache((phys_addr_t)&rxframe, sizeof(rxframe));
Michal Simek6fc7c452011-10-06 20:35:35 +0000663
664 /* Rx BD is ready - start again */
Vipul Kumar3b06a0f2018-01-23 14:52:35 +0530665 axienet_dma_write(&rx_bd, &priv->dmarx->tail);
Michal Simek6fc7c452011-10-06 20:35:35 +0000666
667 debug("axiemac: RX completed, framelength = %d\n", length);
668
Michal Simek682baac2015-12-08 15:44:41 +0100669 return 0;
Michal Simek6fc7c452011-10-06 20:35:35 +0000670}
671
Michal Simek682baac2015-12-08 15:44:41 +0100672static int axiemac_miiphy_read(struct mii_dev *bus, int addr,
673 int devad, int reg)
Michal Simek6fc7c452011-10-06 20:35:35 +0000674{
Michal Simek682baac2015-12-08 15:44:41 +0100675 int ret;
676 u16 value;
Michal Simek6fc7c452011-10-06 20:35:35 +0000677
Michal Simek682baac2015-12-08 15:44:41 +0100678 ret = phyread(bus->priv, addr, reg, &value);
679 debug("axiemac: Read MII 0x%x, 0x%x, 0x%x, %d\n", addr, reg,
680 value, ret);
681 return value;
Michal Simek6fc7c452011-10-06 20:35:35 +0000682}
683
Michal Simek682baac2015-12-08 15:44:41 +0100684static int axiemac_miiphy_write(struct mii_dev *bus, int addr, int devad,
685 int reg, u16 value)
Michal Simek6fc7c452011-10-06 20:35:35 +0000686{
Michal Simek682baac2015-12-08 15:44:41 +0100687 debug("axiemac: Write MII 0x%x, 0x%x, 0x%x\n", addr, reg, value);
688 return phywrite(bus->priv, addr, reg, value);
Michal Simek6fc7c452011-10-06 20:35:35 +0000689}
690
Michal Simek682baac2015-12-08 15:44:41 +0100691static int axi_emac_probe(struct udevice *dev)
Michal Simek6fc7c452011-10-06 20:35:35 +0000692{
Michal Simek682baac2015-12-08 15:44:41 +0100693 struct axidma_priv *priv = dev_get_priv(dev);
694 int ret;
695
696 priv->bus = mdio_alloc();
697 priv->bus->read = axiemac_miiphy_read;
698 priv->bus->write = axiemac_miiphy_write;
699 priv->bus->priv = priv;
Michal Simek682baac2015-12-08 15:44:41 +0100700
Simon Glass75e534b2020-12-16 21:20:07 -0700701 ret = mdio_register_seq(priv->bus, dev_seq(dev));
Michal Simek682baac2015-12-08 15:44:41 +0100702 if (ret)
703 return ret;
704
Michal Simek0b13ee22015-12-08 16:10:05 +0100705 axiemac_phy_init(dev);
706
Michal Simek6fc7c452011-10-06 20:35:35 +0000707 return 0;
708}
709
Michal Simek682baac2015-12-08 15:44:41 +0100710static int axi_emac_remove(struct udevice *dev)
Michal Simek6fc7c452011-10-06 20:35:35 +0000711{
Michal Simek682baac2015-12-08 15:44:41 +0100712 struct axidma_priv *priv = dev_get_priv(dev);
Michal Simek6fc7c452011-10-06 20:35:35 +0000713
Michal Simek682baac2015-12-08 15:44:41 +0100714 free(priv->phydev);
715 mdio_unregister(priv->bus);
716 mdio_free(priv->bus);
Michal Simek6fc7c452011-10-06 20:35:35 +0000717
Michal Simek682baac2015-12-08 15:44:41 +0100718 return 0;
719}
720
721static const struct eth_ops axi_emac_ops = {
Michal Simek8fbf79f2015-12-16 09:18:12 +0100722 .start = axiemac_start,
Michal Simek682baac2015-12-08 15:44:41 +0100723 .send = axiemac_send,
724 .recv = axiemac_recv,
Michal Simek0305be82015-12-09 14:13:23 +0100725 .free_pkt = axiemac_free_pkt,
Michal Simek8fbf79f2015-12-16 09:18:12 +0100726 .stop = axiemac_stop,
727 .write_hwaddr = axiemac_write_hwaddr,
Michal Simek682baac2015-12-08 15:44:41 +0100728};
729
Simon Glassaad29ae2020-12-03 16:55:21 -0700730static int axi_emac_of_to_plat(struct udevice *dev)
Michal Simek682baac2015-12-08 15:44:41 +0100731{
Simon Glassfa20e932020-12-03 16:55:20 -0700732 struct eth_pdata *pdata = dev_get_plat(dev);
Michal Simek682baac2015-12-08 15:44:41 +0100733 struct axidma_priv *priv = dev_get_priv(dev);
Simon Glassdd79d6e2017-01-17 16:52:55 -0700734 int node = dev_of_offset(dev);
Michal Simek682baac2015-12-08 15:44:41 +0100735 int offset = 0;
736 const char *phy_mode;
Michal Simek6fc7c452011-10-06 20:35:35 +0000737
Masahiro Yamadaa89b4de2020-07-17 14:36:48 +0900738 pdata->iobase = dev_read_addr(dev);
Michal Simek682baac2015-12-08 15:44:41 +0100739 priv->iobase = (struct axi_regs *)pdata->iobase;
Michal Simek6fc7c452011-10-06 20:35:35 +0000740
Simon Glassdd79d6e2017-01-17 16:52:55 -0700741 offset = fdtdec_lookup_phandle(gd->fdt_blob, node,
Michal Simek682baac2015-12-08 15:44:41 +0100742 "axistream-connected");
743 if (offset <= 0) {
744 printf("%s: axistream is not found\n", __func__);
745 return -EINVAL;
746 }
Siva Durga Prasad Paladugu6372e3f2017-06-22 11:14:55 +0530747 priv->dmatx = (struct axidma_reg *)fdtdec_get_addr(gd->fdt_blob,
748 offset, "reg");
Michal Simek682baac2015-12-08 15:44:41 +0100749 if (!priv->dmatx) {
750 printf("%s: axi_dma register space not found\n", __func__);
751 return -EINVAL;
752 }
Michal Simek6fc7c452011-10-06 20:35:35 +0000753 /* RX channel offset is 0x30 */
Ashok Reddy Soma91d455a2020-09-03 08:36:43 -0600754 priv->dmarx = (struct axidma_reg *)((phys_addr_t)priv->dmatx + 0x30);
Michal Simek6fc7c452011-10-06 20:35:35 +0000755
Michal Simek6fc7c452011-10-06 20:35:35 +0000756 priv->phyaddr = -1;
Michal Simek6fc7c452011-10-06 20:35:35 +0000757
Simon Glassdd79d6e2017-01-17 16:52:55 -0700758 offset = fdtdec_lookup_phandle(gd->fdt_blob, node, "phy-handle");
Siva Durga Prasad Paladuguc3d94f62019-03-15 17:46:45 +0530759 if (offset > 0) {
Michal Simek682baac2015-12-08 15:44:41 +0100760 priv->phyaddr = fdtdec_get_int(gd->fdt_blob, offset, "reg", -1);
Siva Durga Prasad Paladuguc3d94f62019-03-15 17:46:45 +0530761 priv->phy_of_handle = offset;
762 }
Michal Simek6fc7c452011-10-06 20:35:35 +0000763
Simon Glassdd79d6e2017-01-17 16:52:55 -0700764 phy_mode = fdt_getprop(gd->fdt_blob, node, "phy-mode", NULL);
Michal Simek682baac2015-12-08 15:44:41 +0100765 if (phy_mode)
766 pdata->phy_interface = phy_get_interface_by_name(phy_mode);
767 if (pdata->phy_interface == -1) {
Michal Simek9dbfc0d2016-02-08 13:54:05 +0100768 printf("%s: Invalid PHY interface '%s'\n", __func__, phy_mode);
Michal Simek682baac2015-12-08 15:44:41 +0100769 return -EINVAL;
770 }
771 priv->interface = pdata->phy_interface;
772
Siva Durga Prasad Paladuguf8026032017-01-06 16:27:15 +0530773 priv->eth_hasnobuf = fdtdec_get_bool(gd->fdt_blob, node,
774 "xlnx,eth-hasnobuf");
775
Michal Simek682baac2015-12-08 15:44:41 +0100776 printf("AXI EMAC: %lx, phyaddr %d, interface %s\n", (ulong)priv->iobase,
777 priv->phyaddr, phy_string_for_interface(priv->interface));
778
779 return 0;
Michal Simek6fc7c452011-10-06 20:35:35 +0000780}
Michal Simek682baac2015-12-08 15:44:41 +0100781
782static const struct udevice_id axi_emac_ids[] = {
783 { .compatible = "xlnx,axi-ethernet-1.00.a" },
784 { }
785};
786
787U_BOOT_DRIVER(axi_emac) = {
788 .name = "axi_emac",
789 .id = UCLASS_ETH,
790 .of_match = axi_emac_ids,
Simon Glassaad29ae2020-12-03 16:55:21 -0700791 .of_to_plat = axi_emac_of_to_plat,
Michal Simek682baac2015-12-08 15:44:41 +0100792 .probe = axi_emac_probe,
793 .remove = axi_emac_remove,
794 .ops = &axi_emac_ops,
Simon Glass8a2b47f2020-12-03 16:55:17 -0700795 .priv_auto = sizeof(struct axidma_priv),
Simon Glass71fa5b42020-12-03 16:55:18 -0700796 .plat_auto = sizeof(struct eth_pdata),
Michal Simek682baac2015-12-08 15:44:41 +0100797};