blob: 7e54d4642ddfdda54b32ce2846800370ad45f99f [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Kuo-Jung Suc4775472013-05-07 14:33:31 +08002/*
3 * Faraday 10/100Mbps Ethernet Controller
4 *
Kuo-Jung Su102a8cd2013-07-10 09:25:47 +08005 * (C) Copyright 2013 Faraday Technology
Kuo-Jung Suc4775472013-05-07 14:33:31 +08006 * Dante Su <dantesu@faraday-tech.com>
Kuo-Jung Suc4775472013-05-07 14:33:31 +08007 */
8
9#include <common.h>
10#include <command.h>
Simon Glassf7ae49f2020-05-10 11:40:05 -060011#include <log.h>
Kuo-Jung Suc4775472013-05-07 14:33:31 +080012#include <malloc.h>
13#include <net.h>
Simon Glass90526e92020-05-10 11:39:56 -060014#include <asm/cache.h>
Masahiro Yamada1221ce42016-09-21 11:28:55 +090015#include <linux/errno.h>
Kuo-Jung Suc4775472013-05-07 14:33:31 +080016#include <asm/io.h>
Masahiro Yamada9d86b892020-02-14 16:40:19 +090017#include <linux/dma-mapping.h>
Kuo-Jung Suc4775472013-05-07 14:33:31 +080018
19#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
20#include <miiphy.h>
21#endif
22
23#include "ftmac110.h"
24
25#define CFG_RXDES_NUM 8
26#define CFG_TXDES_NUM 2
27#define CFG_XBUF_SIZE 1536
28
29#define CFG_MDIORD_TIMEOUT (CONFIG_SYS_HZ >> 1) /* 500 ms */
30#define CFG_MDIOWR_TIMEOUT (CONFIG_SYS_HZ >> 1) /* 500 ms */
31#define CFG_LINKUP_TIMEOUT (CONFIG_SYS_HZ << 2) /* 4 sec */
32
33/*
34 * FTMAC110 DMA design issue
35 *
36 * Its DMA engine has a weird restriction that its Rx DMA engine
37 * accepts only 16-bits aligned address, 32-bits aligned is not
38 * acceptable. However this restriction does not apply to Tx DMA.
39 *
40 * Conclusion:
41 * (1) Tx DMA Buffer Address:
42 * 1 bytes aligned: Invalid
43 * 2 bytes aligned: O.K
44 * 4 bytes aligned: O.K (-> u-boot ZeroCopy is possible)
45 * (2) Rx DMA Buffer Address:
46 * 1 bytes aligned: Invalid
47 * 2 bytes aligned: O.K
48 * 4 bytes aligned: Invalid
49 */
50
51struct ftmac110_chip {
52 void __iomem *regs;
53 uint32_t imr;
54 uint32_t maccr;
55 uint32_t lnkup;
56 uint32_t phy_addr;
57
Kuo-Jung Su0628cb22013-07-10 09:25:49 +080058 struct ftmac110_desc *rxd;
Kuo-Jung Suc4775472013-05-07 14:33:31 +080059 ulong rxd_dma;
60 uint32_t rxd_idx;
61
Kuo-Jung Su0628cb22013-07-10 09:25:49 +080062 struct ftmac110_desc *txd;
Kuo-Jung Suc4775472013-05-07 14:33:31 +080063 ulong txd_dma;
64 uint32_t txd_idx;
65};
66
67static int ftmac110_reset(struct eth_device *dev);
68
69static uint16_t mdio_read(struct eth_device *dev,
70 uint8_t phyaddr, uint8_t phyreg)
71{
72 struct ftmac110_chip *chip = dev->priv;
Kuo-Jung Su4b7be192013-07-10 09:25:48 +080073 struct ftmac110_regs *regs = chip->regs;
Kuo-Jung Suc4775472013-05-07 14:33:31 +080074 uint32_t tmp, ts;
75 uint16_t ret = 0xffff;
76
77 tmp = PHYCR_READ
78 | (phyaddr << PHYCR_ADDR_SHIFT)
79 | (phyreg << PHYCR_REG_SHIFT);
80
81 writel(tmp, &regs->phycr);
82
83 for (ts = get_timer(0); get_timer(ts) < CFG_MDIORD_TIMEOUT; ) {
84 tmp = readl(&regs->phycr);
85 if (tmp & PHYCR_READ)
86 continue;
87 break;
88 }
89
90 if (tmp & PHYCR_READ)
91 printf("ftmac110: mdio read timeout\n");
92 else
93 ret = (uint16_t)(tmp & 0xffff);
94
95 return ret;
96}
97
98static void mdio_write(struct eth_device *dev,
99 uint8_t phyaddr, uint8_t phyreg, uint16_t phydata)
100{
101 struct ftmac110_chip *chip = dev->priv;
Kuo-Jung Su4b7be192013-07-10 09:25:48 +0800102 struct ftmac110_regs *regs = chip->regs;
Kuo-Jung Suc4775472013-05-07 14:33:31 +0800103 uint32_t tmp, ts;
104
105 tmp = PHYCR_WRITE
106 | (phyaddr << PHYCR_ADDR_SHIFT)
107 | (phyreg << PHYCR_REG_SHIFT);
108
109 writel(phydata, &regs->phydr);
110 writel(tmp, &regs->phycr);
111
112 for (ts = get_timer(0); get_timer(ts) < CFG_MDIOWR_TIMEOUT; ) {
113 if (readl(&regs->phycr) & PHYCR_WRITE)
114 continue;
115 break;
116 }
117
118 if (readl(&regs->phycr) & PHYCR_WRITE)
119 printf("ftmac110: mdio write timeout\n");
120}
121
122static uint32_t ftmac110_phyqry(struct eth_device *dev)
123{
124 ulong ts;
125 uint32_t maccr;
126 uint16_t pa, tmp, bmsr, bmcr;
127 struct ftmac110_chip *chip = dev->priv;
128
129 /* Default = 100Mbps Full */
130 maccr = MACCR_100M | MACCR_FD;
131
132 /* 1. find the phy device */
133 for (pa = 0; pa < 32; ++pa) {
134 tmp = mdio_read(dev, pa, MII_PHYSID1);
135 if (tmp == 0xFFFF || tmp == 0x0000)
136 continue;
137 chip->phy_addr = pa;
138 break;
139 }
140 if (pa >= 32) {
141 puts("ftmac110: phy device not found!\n");
142 goto exit;
143 }
144
145 /* 2. wait until link-up & auto-negotiation complete */
146 chip->lnkup = 0;
147 bmcr = mdio_read(dev, chip->phy_addr, MII_BMCR);
148 ts = get_timer(0);
149 do {
150 bmsr = mdio_read(dev, chip->phy_addr, MII_BMSR);
151 chip->lnkup = (bmsr & BMSR_LSTATUS) ? 1 : 0;
152 if (!chip->lnkup)
153 continue;
154 if (!(bmcr & BMCR_ANENABLE) || (bmsr & BMSR_ANEGCOMPLETE))
155 break;
156 } while (get_timer(ts) < CFG_LINKUP_TIMEOUT);
157 if (!chip->lnkup) {
158 puts("ftmac110: link down\n");
159 goto exit;
160 }
161 if (!(bmcr & BMCR_ANENABLE))
162 puts("ftmac110: auto negotiation disabled\n");
163 else if (!(bmsr & BMSR_ANEGCOMPLETE))
164 puts("ftmac110: auto negotiation timeout\n");
165
166 /* 3. derive MACCR */
167 if ((bmcr & BMCR_ANENABLE) && (bmsr & BMSR_ANEGCOMPLETE)) {
168 tmp = mdio_read(dev, chip->phy_addr, MII_ADVERTISE);
169 tmp &= mdio_read(dev, chip->phy_addr, MII_LPA);
170 if (tmp & LPA_100FULL) /* 100Mbps full-duplex */
171 maccr = MACCR_100M | MACCR_FD;
172 else if (tmp & LPA_100HALF) /* 100Mbps half-duplex */
173 maccr = MACCR_100M;
174 else if (tmp & LPA_10FULL) /* 10Mbps full-duplex */
175 maccr = MACCR_FD;
176 else if (tmp & LPA_10HALF) /* 10Mbps half-duplex */
177 maccr = 0;
178 } else {
179 if (bmcr & BMCR_SPEED100)
180 maccr = MACCR_100M;
181 else
182 maccr = 0;
183 if (bmcr & BMCR_FULLDPLX)
184 maccr |= MACCR_FD;
185 }
186
187exit:
188 printf("ftmac110: %d Mbps, %s\n",
189 (maccr & MACCR_100M) ? 100 : 10,
190 (maccr & MACCR_FD) ? "Full" : "half");
191 return maccr;
192}
193
194static int ftmac110_reset(struct eth_device *dev)
195{
196 uint8_t *a;
197 uint32_t i, maccr;
198 struct ftmac110_chip *chip = dev->priv;
Kuo-Jung Su4b7be192013-07-10 09:25:48 +0800199 struct ftmac110_regs *regs = chip->regs;
Kuo-Jung Suc4775472013-05-07 14:33:31 +0800200
201 /* 1. MAC reset */
202 writel(MACCR_RESET, &regs->maccr);
203 for (i = get_timer(0); get_timer(i) < 1000; ) {
204 if (readl(&regs->maccr) & MACCR_RESET)
205 continue;
206 break;
207 }
208 if (readl(&regs->maccr) & MACCR_RESET) {
209 printf("ftmac110: reset failed\n");
210 return -ENXIO;
211 }
212
213 /* 1-1. Init tx ring */
214 for (i = 0; i < CFG_TXDES_NUM; ++i) {
215 /* owned by SW */
Kuo-Jung Su0628cb22013-07-10 09:25:49 +0800216 chip->txd[i].ctrl &= cpu_to_le64(FTMAC110_TXD_CLRMASK);
Kuo-Jung Suc4775472013-05-07 14:33:31 +0800217 }
218 chip->txd_idx = 0;
219
220 /* 1-2. Init rx ring */
221 for (i = 0; i < CFG_RXDES_NUM; ++i) {
222 /* owned by HW */
Kuo-Jung Su0628cb22013-07-10 09:25:49 +0800223 chip->rxd[i].ctrl &= cpu_to_le64(FTMAC110_RXD_CLRMASK);
224 chip->rxd[i].ctrl |= cpu_to_le64(FTMAC110_RXD_OWNER);
Kuo-Jung Suc4775472013-05-07 14:33:31 +0800225 }
226 chip->rxd_idx = 0;
227
228 /* 2. PHY status query */
229 maccr = ftmac110_phyqry(dev);
230
231 /* 3. Fix up the MACCR value */
232 chip->maccr = maccr | MACCR_CRCAPD | MACCR_RXALL | MACCR_RXRUNT
233 | MACCR_RXEN | MACCR_TXEN | MACCR_RXDMAEN | MACCR_TXDMAEN;
234
235 /* 4. MAC address setup */
236 a = dev->enetaddr;
237 writel(a[1] | (a[0] << 8), &regs->mac[0]);
238 writel(a[5] | (a[4] << 8) | (a[3] << 16)
239 | (a[2] << 24), &regs->mac[1]);
240
241 /* 5. MAC registers setup */
242 writel(chip->rxd_dma, &regs->rxba);
243 writel(chip->txd_dma, &regs->txba);
244 /* interrupt at each tx/rx */
245 writel(ITC_DEFAULT, &regs->itc);
246 /* no tx pool, rx poll = 1 normal cycle */
247 writel(APTC_DEFAULT, &regs->aptc);
248 /* rx threshold = [6/8 fifo, 2/8 fifo] */
249 writel(DBLAC_DEFAULT, &regs->dblac);
250 /* disable & clear all interrupt status */
251 chip->imr = 0;
252 writel(ISR_ALL, &regs->isr);
253 writel(chip->imr, &regs->imr);
254 /* enable mac */
255 writel(chip->maccr, &regs->maccr);
256
257 return 0;
258}
259
Masahiro Yamadab75d8dc2020-06-26 15:13:33 +0900260static int ftmac110_probe(struct eth_device *dev, struct bd_info *bis)
Kuo-Jung Suc4775472013-05-07 14:33:31 +0800261{
262 debug("ftmac110: probe\n");
263
264 if (ftmac110_reset(dev))
265 return -1;
266
267 return 0;
268}
269
270static void ftmac110_halt(struct eth_device *dev)
271{
272 struct ftmac110_chip *chip = dev->priv;
Kuo-Jung Su4b7be192013-07-10 09:25:48 +0800273 struct ftmac110_regs *regs = chip->regs;
Kuo-Jung Suc4775472013-05-07 14:33:31 +0800274
275 writel(0, &regs->imr);
276 writel(0, &regs->maccr);
277
278 debug("ftmac110: halt\n");
279}
280
281static int ftmac110_send(struct eth_device *dev, void *pkt, int len)
282{
283 struct ftmac110_chip *chip = dev->priv;
Kuo-Jung Su4b7be192013-07-10 09:25:48 +0800284 struct ftmac110_regs *regs = chip->regs;
Kuo-Jung Su0628cb22013-07-10 09:25:49 +0800285 struct ftmac110_desc *txd;
286 uint64_t ctrl;
Kuo-Jung Suc4775472013-05-07 14:33:31 +0800287
288 if (!chip->lnkup)
289 return 0;
290
291 if (len <= 0 || len > CFG_XBUF_SIZE) {
292 printf("ftmac110: bad tx pkt len(%d)\n", len);
293 return 0;
294 }
295
296 len = max(60, len);
297
Kuo-Jung Su0628cb22013-07-10 09:25:49 +0800298 txd = &chip->txd[chip->txd_idx];
299 ctrl = le64_to_cpu(txd->ctrl);
300 if (ctrl & FTMAC110_TXD_OWNER) {
Kuo-Jung Suc4775472013-05-07 14:33:31 +0800301 /* kick-off Tx DMA */
302 writel(0xffffffff, &regs->txpd);
303 printf("ftmac110: out of txd\n");
304 return 0;
305 }
306
Kuo-Jung Su0628cb22013-07-10 09:25:49 +0800307 memcpy(txd->vbuf, (void *)pkt, len);
308 dma_map_single(txd->vbuf, len, DMA_TO_DEVICE);
Kuo-Jung Suc4775472013-05-07 14:33:31 +0800309
Kuo-Jung Su0628cb22013-07-10 09:25:49 +0800310 /* clear control bits */
311 ctrl &= FTMAC110_TXD_CLRMASK;
312 /* set len, fts and lts */
313 ctrl |= FTMAC110_TXD_LEN(len) | FTMAC110_TXD_FTS | FTMAC110_TXD_LTS;
314 /* set owner bit */
315 ctrl |= FTMAC110_TXD_OWNER;
316 /* write back to descriptor */
317 txd->ctrl = cpu_to_le64(ctrl);
Kuo-Jung Suc4775472013-05-07 14:33:31 +0800318
319 /* kick-off Tx DMA */
320 writel(0xffffffff, &regs->txpd);
321
322 chip->txd_idx = (chip->txd_idx + 1) % CFG_TXDES_NUM;
323
324 return len;
325}
326
327static int ftmac110_recv(struct eth_device *dev)
328{
329 struct ftmac110_chip *chip = dev->priv;
Kuo-Jung Su0628cb22013-07-10 09:25:49 +0800330 struct ftmac110_desc *rxd;
331 uint32_t len, rlen = 0;
332 uint64_t ctrl;
Kuo-Jung Suc4775472013-05-07 14:33:31 +0800333 uint8_t *buf;
334
335 if (!chip->lnkup)
336 return 0;
337
338 do {
Kuo-Jung Su0628cb22013-07-10 09:25:49 +0800339 rxd = &chip->rxd[chip->rxd_idx];
340 ctrl = le64_to_cpu(rxd->ctrl);
341 if (ctrl & FTMAC110_RXD_OWNER)
Kuo-Jung Suc4775472013-05-07 14:33:31 +0800342 break;
343
Kuo-Jung Su0628cb22013-07-10 09:25:49 +0800344 len = (uint32_t)FTMAC110_RXD_LEN(ctrl);
345 buf = rxd->vbuf;
Kuo-Jung Suc4775472013-05-07 14:33:31 +0800346
Kuo-Jung Su0628cb22013-07-10 09:25:49 +0800347 if (ctrl & FTMAC110_RXD_ERRMASK) {
Kuo-Jung Suc4775472013-05-07 14:33:31 +0800348 printf("ftmac110: rx error\n");
349 } else {
350 dma_map_single(buf, len, DMA_FROM_DEVICE);
Joe Hershberger1fd92db2015-04-08 01:41:06 -0500351 net_process_received_packet(buf, len);
Kuo-Jung Suc4775472013-05-07 14:33:31 +0800352 rlen += len;
353 }
354
355 /* owned by hardware */
Kuo-Jung Su0628cb22013-07-10 09:25:49 +0800356 ctrl &= FTMAC110_RXD_CLRMASK;
357 ctrl |= FTMAC110_RXD_OWNER;
358 rxd->ctrl |= cpu_to_le64(ctrl);
Kuo-Jung Suc4775472013-05-07 14:33:31 +0800359
360 chip->rxd_idx = (chip->rxd_idx + 1) % CFG_RXDES_NUM;
361 } while (0);
362
363 return rlen;
364}
365
366#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
367
Joe Hershberger5a49f172016-08-08 11:28:38 -0500368static int ftmac110_mdio_read(struct mii_dev *bus, int addr, int devad,
369 int reg)
Kuo-Jung Suc4775472013-05-07 14:33:31 +0800370{
Joe Hershberger5a49f172016-08-08 11:28:38 -0500371 uint16_t value = 0;
Kuo-Jung Suc4775472013-05-07 14:33:31 +0800372 int ret = 0;
373 struct eth_device *dev;
374
Joe Hershberger5a49f172016-08-08 11:28:38 -0500375 dev = eth_get_dev_by_name(bus->name);
Kuo-Jung Suc4775472013-05-07 14:33:31 +0800376 if (dev == NULL) {
Joe Hershberger5a49f172016-08-08 11:28:38 -0500377 printf("%s: no such device\n", bus->name);
Kuo-Jung Suc4775472013-05-07 14:33:31 +0800378 ret = -1;
379 } else {
Joe Hershberger5a49f172016-08-08 11:28:38 -0500380 value = mdio_read(dev, addr, reg);
Kuo-Jung Suc4775472013-05-07 14:33:31 +0800381 }
382
Joe Hershberger5a49f172016-08-08 11:28:38 -0500383 if (ret < 0)
384 return ret;
385 return value;
Kuo-Jung Suc4775472013-05-07 14:33:31 +0800386}
387
Joe Hershberger5a49f172016-08-08 11:28:38 -0500388static int ftmac110_mdio_write(struct mii_dev *bus, int addr, int devad,
389 int reg, u16 value)
Kuo-Jung Suc4775472013-05-07 14:33:31 +0800390{
391 int ret = 0;
392 struct eth_device *dev;
393
Joe Hershberger5a49f172016-08-08 11:28:38 -0500394 dev = eth_get_dev_by_name(bus->name);
Kuo-Jung Suc4775472013-05-07 14:33:31 +0800395 if (dev == NULL) {
Joe Hershberger5a49f172016-08-08 11:28:38 -0500396 printf("%s: no such device\n", bus->name);
Kuo-Jung Suc4775472013-05-07 14:33:31 +0800397 ret = -1;
398 } else {
399 mdio_write(dev, addr, reg, value);
400 }
401
402 return ret;
403}
404
405#endif /* #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) */
406
Masahiro Yamadab75d8dc2020-06-26 15:13:33 +0900407int ftmac110_initialize(struct bd_info *bis)
Kuo-Jung Suc4775472013-05-07 14:33:31 +0800408{
409 int i, card_nr = 0;
410 struct eth_device *dev;
411 struct ftmac110_chip *chip;
412
413 dev = malloc(sizeof(*dev) + sizeof(*chip));
414 if (dev == NULL) {
415 panic("ftmac110: out of memory 1\n");
416 return -1;
417 }
418 chip = (struct ftmac110_chip *)(dev + 1);
419 memset(dev, 0, sizeof(*dev) + sizeof(*chip));
420
421 sprintf(dev->name, "FTMAC110#%d", card_nr);
422
423 dev->iobase = CONFIG_FTMAC110_BASE;
424 chip->regs = (void __iomem *)dev->iobase;
425 dev->priv = chip;
426 dev->init = ftmac110_probe;
427 dev->halt = ftmac110_halt;
428 dev->send = ftmac110_send;
429 dev->recv = ftmac110_recv;
430
Kuo-Jung Suc4775472013-05-07 14:33:31 +0800431 /* allocate tx descriptors (it must be 16 bytes aligned) */
432 chip->txd = dma_alloc_coherent(
Kuo-Jung Su0628cb22013-07-10 09:25:49 +0800433 sizeof(struct ftmac110_desc) * CFG_TXDES_NUM, &chip->txd_dma);
Kuo-Jung Suc4775472013-05-07 14:33:31 +0800434 if (!chip->txd)
435 panic("ftmac110: out of memory 3\n");
436 memset(chip->txd, 0,
Kuo-Jung Su0628cb22013-07-10 09:25:49 +0800437 sizeof(struct ftmac110_desc) * CFG_TXDES_NUM);
Kuo-Jung Suc4775472013-05-07 14:33:31 +0800438 for (i = 0; i < CFG_TXDES_NUM; ++i) {
439 void *va = memalign(ARCH_DMA_MINALIGN, CFG_XBUF_SIZE);
Kuo-Jung Su0628cb22013-07-10 09:25:49 +0800440
Kuo-Jung Suc4775472013-05-07 14:33:31 +0800441 if (!va)
442 panic("ftmac110: out of memory 4\n");
Kuo-Jung Su0628cb22013-07-10 09:25:49 +0800443 chip->txd[i].vbuf = va;
444 chip->txd[i].pbuf = cpu_to_le32(virt_to_phys(va));
445 chip->txd[i].ctrl = 0; /* owned by SW */
Kuo-Jung Suc4775472013-05-07 14:33:31 +0800446 }
Kuo-Jung Su0628cb22013-07-10 09:25:49 +0800447 chip->txd[i - 1].ctrl |= cpu_to_le64(FTMAC110_TXD_END);
Kuo-Jung Suc4775472013-05-07 14:33:31 +0800448 chip->txd_idx = 0;
449
450 /* allocate rx descriptors (it must be 16 bytes aligned) */
451 chip->rxd = dma_alloc_coherent(
Kuo-Jung Su0628cb22013-07-10 09:25:49 +0800452 sizeof(struct ftmac110_desc) * CFG_RXDES_NUM, &chip->rxd_dma);
Kuo-Jung Suc4775472013-05-07 14:33:31 +0800453 if (!chip->rxd)
454 panic("ftmac110: out of memory 4\n");
455 memset((void *)chip->rxd, 0,
Kuo-Jung Su0628cb22013-07-10 09:25:49 +0800456 sizeof(struct ftmac110_desc) * CFG_RXDES_NUM);
Kuo-Jung Suc4775472013-05-07 14:33:31 +0800457 for (i = 0; i < CFG_RXDES_NUM; ++i) {
458 void *va = memalign(ARCH_DMA_MINALIGN, CFG_XBUF_SIZE + 2);
Kuo-Jung Su0628cb22013-07-10 09:25:49 +0800459
Kuo-Jung Suc4775472013-05-07 14:33:31 +0800460 if (!va)
461 panic("ftmac110: out of memory 5\n");
462 /* it needs to be exactly 2 bytes aligned */
463 va = ((uint8_t *)va + 2);
Kuo-Jung Su0628cb22013-07-10 09:25:49 +0800464 chip->rxd[i].vbuf = va;
465 chip->rxd[i].pbuf = cpu_to_le32(virt_to_phys(va));
466 chip->rxd[i].ctrl = cpu_to_le64(FTMAC110_RXD_OWNER
467 | FTMAC110_RXD_BUFSZ(CFG_XBUF_SIZE));
Kuo-Jung Suc4775472013-05-07 14:33:31 +0800468 }
Kuo-Jung Su0628cb22013-07-10 09:25:49 +0800469 chip->rxd[i - 1].ctrl |= cpu_to_le64(FTMAC110_RXD_END);
Kuo-Jung Suc4775472013-05-07 14:33:31 +0800470 chip->rxd_idx = 0;
471
472 eth_register(dev);
473
474#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
Joe Hershberger5a49f172016-08-08 11:28:38 -0500475 int retval;
476 struct mii_dev *mdiodev = mdio_alloc();
477 if (!mdiodev)
478 return -ENOMEM;
Vladimir Oltean1a5d3e92021-09-27 14:21:50 +0300479 strlcpy(mdiodev->name, dev->name, MDIO_NAME_LEN);
Joe Hershberger5a49f172016-08-08 11:28:38 -0500480 mdiodev->read = ftmac110_mdio_read;
481 mdiodev->write = ftmac110_mdio_write;
482
483 retval = mdio_register(mdiodev);
484 if (retval < 0)
485 return retval;
Kuo-Jung Suc4775472013-05-07 14:33:31 +0800486#endif
487
488 card_nr++;
489
490 return card_nr;
491}