blob: 89ab786da25f7545353ef9c1911cb9916dad3b57 [file] [log] [blame]
Wan ZongShuna50a97d2009-07-16 02:55:05 +00001/*
2 * Copyright (c) 2008-2009 Nuvoton technology corporation.
3 *
4 * Wan ZongShun <mcuos.com@gmail.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation;version 2 of the License.
9 *
10 */
11
12#include <linux/module.h>
13#include <linux/init.h>
14#include <linux/mii.h>
15#include <linux/netdevice.h>
16#include <linux/etherdevice.h>
17#include <linux/skbuff.h>
18#include <linux/ethtool.h>
19#include <linux/platform_device.h>
20#include <linux/clk.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090021#include <linux/gfp.h>
Wan ZongShuna50a97d2009-07-16 02:55:05 +000022
23#define DRV_MODULE_NAME "w90p910-emc"
24#define DRV_MODULE_VERSION "0.1"
25
26/* Ethernet MAC Registers */
27#define REG_CAMCMR 0x00
28#define REG_CAMEN 0x04
29#define REG_CAMM_BASE 0x08
30#define REG_CAML_BASE 0x0c
31#define REG_TXDLSA 0x88
32#define REG_RXDLSA 0x8C
33#define REG_MCMDR 0x90
34#define REG_MIID 0x94
35#define REG_MIIDA 0x98
36#define REG_FFTCR 0x9C
37#define REG_TSDR 0xa0
38#define REG_RSDR 0xa4
39#define REG_DMARFC 0xa8
40#define REG_MIEN 0xac
41#define REG_MISTA 0xb0
42#define REG_CTXDSA 0xcc
43#define REG_CTXBSA 0xd0
44#define REG_CRXDSA 0xd4
45#define REG_CRXBSA 0xd8
46
47/* mac controller bit */
48#define MCMDR_RXON 0x01
49#define MCMDR_ACP (0x01 << 3)
50#define MCMDR_SPCRC (0x01 << 5)
51#define MCMDR_TXON (0x01 << 8)
52#define MCMDR_FDUP (0x01 << 18)
53#define MCMDR_ENMDC (0x01 << 19)
54#define MCMDR_OPMOD (0x01 << 20)
55#define SWR (0x01 << 24)
56
57/* cam command regiser */
58#define CAMCMR_AUP 0x01
59#define CAMCMR_AMP (0x01 << 1)
60#define CAMCMR_ABP (0x01 << 2)
61#define CAMCMR_CCAM (0x01 << 3)
62#define CAMCMR_ECMP (0x01 << 4)
63#define CAM0EN 0x01
64
65/* mac mii controller bit */
66#define MDCCR (0x0a << 20)
67#define PHYAD (0x01 << 8)
68#define PHYWR (0x01 << 16)
69#define PHYBUSY (0x01 << 17)
70#define PHYPRESP (0x01 << 18)
71#define CAM_ENTRY_SIZE 0x08
72
73/* rx and tx status */
74#define TXDS_TXCP (0x01 << 19)
75#define RXDS_CRCE (0x01 << 17)
76#define RXDS_PTLE (0x01 << 19)
77#define RXDS_RXGD (0x01 << 20)
78#define RXDS_ALIE (0x01 << 21)
79#define RXDS_RP (0x01 << 22)
80
81/* mac interrupt status*/
82#define MISTA_EXDEF (0x01 << 19)
83#define MISTA_TXBERR (0x01 << 24)
84#define MISTA_TDU (0x01 << 23)
85#define MISTA_RDU (0x01 << 10)
86#define MISTA_RXBERR (0x01 << 11)
87
88#define ENSTART 0x01
89#define ENRXINTR 0x01
90#define ENRXGD (0x01 << 4)
91#define ENRXBERR (0x01 << 11)
92#define ENTXINTR (0x01 << 16)
93#define ENTXCP (0x01 << 18)
94#define ENTXABT (0x01 << 21)
95#define ENTXBERR (0x01 << 24)
96#define ENMDC (0x01 << 19)
97#define PHYBUSY (0x01 << 17)
98#define MDCCR_VAL 0xa00000
99
100/* rx and tx owner bit */
101#define RX_OWEN_DMA (0x01 << 31)
102#define RX_OWEN_CPU (~(0x03 << 30))
103#define TX_OWEN_DMA (0x01 << 31)
104#define TX_OWEN_CPU (~(0x01 << 31))
105
106/* tx frame desc controller bit */
107#define MACTXINTEN 0x04
108#define CRCMODE 0x02
109#define PADDINGMODE 0x01
110
111/* fftcr controller bit */
112#define TXTHD (0x03 << 8)
113#define BLENGTH (0x01 << 20)
114
115/* global setting for driver */
116#define RX_DESC_SIZE 50
117#define TX_DESC_SIZE 10
118#define MAX_RBUFF_SZ 0x600
119#define MAX_TBUFF_SZ 0x600
Eric Dumazetc63fdf42010-11-03 22:49:35 +0000120#define TX_TIMEOUT (HZ/2)
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000121#define DELAY 1000
122#define CAM0 0x0
123
124static int w90p910_mdio_read(struct net_device *dev, int phy_id, int reg);
125
126struct w90p910_rxbd {
127 unsigned int sl;
128 unsigned int buffer;
129 unsigned int reserved;
130 unsigned int next;
131};
132
133struct w90p910_txbd {
134 unsigned int mode;
135 unsigned int buffer;
136 unsigned int sl;
137 unsigned int next;
138};
139
140struct recv_pdesc {
141 struct w90p910_rxbd desclist[RX_DESC_SIZE];
142 char recv_buf[RX_DESC_SIZE][MAX_RBUFF_SZ];
143};
144
145struct tran_pdesc {
146 struct w90p910_txbd desclist[TX_DESC_SIZE];
Wan ZongShun1e5053b2009-08-09 03:06:19 +0000147 char tran_buf[TX_DESC_SIZE][MAX_TBUFF_SZ];
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000148};
149
150struct w90p910_ether {
151 struct recv_pdesc *rdesc;
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000152 struct tran_pdesc *tdesc;
Wan ZongShun1e5053b2009-08-09 03:06:19 +0000153 dma_addr_t rdesc_phys;
154 dma_addr_t tdesc_phys;
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000155 struct platform_device *pdev;
Wan ZongShun1e5053b2009-08-09 03:06:19 +0000156 struct resource *res;
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000157 struct sk_buff *skb;
158 struct clk *clk;
159 struct clk *rmiiclk;
160 struct mii_if_info mii;
161 struct timer_list check_timer;
162 void __iomem *reg;
Wan ZongShunddb14172009-11-11 04:35:22 +0000163 int rxirq;
164 int txirq;
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000165 unsigned int cur_tx;
166 unsigned int cur_rx;
167 unsigned int finish_tx;
168 unsigned int rx_packets;
169 unsigned int rx_bytes;
170 unsigned int start_tx_ptr;
171 unsigned int start_rx_ptr;
172 unsigned int linkflag;
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000173};
174
175static void update_linkspeed_register(struct net_device *dev,
176 unsigned int speed, unsigned int duplex)
177{
178 struct w90p910_ether *ether = netdev_priv(dev);
179 unsigned int val;
180
181 val = __raw_readl(ether->reg + REG_MCMDR);
182
183 if (speed == SPEED_100) {
184 /* 100 full/half duplex */
185 if (duplex == DUPLEX_FULL) {
186 val |= (MCMDR_OPMOD | MCMDR_FDUP);
187 } else {
188 val |= MCMDR_OPMOD;
189 val &= ~MCMDR_FDUP;
190 }
191 } else {
192 /* 10 full/half duplex */
193 if (duplex == DUPLEX_FULL) {
194 val |= MCMDR_FDUP;
195 val &= ~MCMDR_OPMOD;
196 } else {
197 val &= ~(MCMDR_FDUP | MCMDR_OPMOD);
198 }
199 }
200
201 __raw_writel(val, ether->reg + REG_MCMDR);
202}
203
204static void update_linkspeed(struct net_device *dev)
205{
206 struct w90p910_ether *ether = netdev_priv(dev);
207 struct platform_device *pdev;
208 unsigned int bmsr, bmcr, lpa, speed, duplex;
209
210 pdev = ether->pdev;
211
212 if (!mii_link_ok(&ether->mii)) {
213 ether->linkflag = 0x0;
214 netif_carrier_off(dev);
215 dev_warn(&pdev->dev, "%s: Link down.\n", dev->name);
216 return;
217 }
218
219 if (ether->linkflag == 1)
220 return;
221
222 bmsr = w90p910_mdio_read(dev, ether->mii.phy_id, MII_BMSR);
223 bmcr = w90p910_mdio_read(dev, ether->mii.phy_id, MII_BMCR);
224
225 if (bmcr & BMCR_ANENABLE) {
226 if (!(bmsr & BMSR_ANEGCOMPLETE))
227 return;
228
229 lpa = w90p910_mdio_read(dev, ether->mii.phy_id, MII_LPA);
230
231 if ((lpa & LPA_100FULL) || (lpa & LPA_100HALF))
232 speed = SPEED_100;
233 else
234 speed = SPEED_10;
235
236 if ((lpa & LPA_100FULL) || (lpa & LPA_10FULL))
237 duplex = DUPLEX_FULL;
238 else
239 duplex = DUPLEX_HALF;
240
241 } else {
242 speed = (bmcr & BMCR_SPEED100) ? SPEED_100 : SPEED_10;
243 duplex = (bmcr & BMCR_FULLDPLX) ? DUPLEX_FULL : DUPLEX_HALF;
244 }
245
246 update_linkspeed_register(dev, speed, duplex);
247
248 dev_info(&pdev->dev, "%s: Link now %i-%s\n", dev->name, speed,
249 (duplex == DUPLEX_FULL) ? "FullDuplex" : "HalfDuplex");
250 ether->linkflag = 0x01;
251
252 netif_carrier_on(dev);
253}
254
255static void w90p910_check_link(unsigned long dev_id)
256{
257 struct net_device *dev = (struct net_device *) dev_id;
258 struct w90p910_ether *ether = netdev_priv(dev);
259
260 update_linkspeed(dev);
261 mod_timer(&ether->check_timer, jiffies + msecs_to_jiffies(1000));
262}
263
264static void w90p910_write_cam(struct net_device *dev,
265 unsigned int x, unsigned char *pval)
266{
267 struct w90p910_ether *ether = netdev_priv(dev);
268 unsigned int msw, lsw;
269
270 msw = (pval[0] << 24) | (pval[1] << 16) | (pval[2] << 8) | pval[3];
271
272 lsw = (pval[4] << 24) | (pval[5] << 16);
273
274 __raw_writel(lsw, ether->reg + REG_CAML_BASE + x * CAM_ENTRY_SIZE);
275 __raw_writel(msw, ether->reg + REG_CAMM_BASE + x * CAM_ENTRY_SIZE);
276}
277
Wan ZongShun1e5053b2009-08-09 03:06:19 +0000278static int w90p910_init_desc(struct net_device *dev)
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000279{
280 struct w90p910_ether *ether;
Wan ZongShun1e5053b2009-08-09 03:06:19 +0000281 struct w90p910_txbd *tdesc;
282 struct w90p910_rxbd *rdesc;
283 struct platform_device *pdev;
284 unsigned int i;
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000285
286 ether = netdev_priv(dev);
Wan ZongShun1e5053b2009-08-09 03:06:19 +0000287 pdev = ether->pdev;
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000288
Joe Perchesd0320f72013-03-14 13:07:21 +0000289 ether->tdesc = dma_alloc_coherent(&pdev->dev, sizeof(struct tran_pdesc),
290 &ether->tdesc_phys, GFP_KERNEL);
291 if (!ether->tdesc)
Wan ZongShun1e5053b2009-08-09 03:06:19 +0000292 return -ENOMEM;
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000293
Joe Perchesd0320f72013-03-14 13:07:21 +0000294 ether->rdesc = dma_alloc_coherent(&pdev->dev, sizeof(struct recv_pdesc),
295 &ether->rdesc_phys, GFP_KERNEL);
Wan ZongShun1e5053b2009-08-09 03:06:19 +0000296 if (!ether->rdesc) {
Wan ZongShun1e5053b2009-08-09 03:06:19 +0000297 dma_free_coherent(&pdev->dev, sizeof(struct tran_pdesc),
Joe Perchesd0320f72013-03-14 13:07:21 +0000298 ether->tdesc, ether->tdesc_phys);
Wan ZongShun1e5053b2009-08-09 03:06:19 +0000299 return -ENOMEM;
300 }
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000301
302 for (i = 0; i < TX_DESC_SIZE; i++) {
Wan ZongShun1e5053b2009-08-09 03:06:19 +0000303 unsigned int offset;
304
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000305 tdesc = &(ether->tdesc->desclist[i]);
306
Wan ZongShun1e5053b2009-08-09 03:06:19 +0000307 if (i == TX_DESC_SIZE - 1)
308 offset = offsetof(struct tran_pdesc, desclist[0]);
309 else
310 offset = offsetof(struct tran_pdesc, desclist[i + 1]);
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000311
Wan ZongShun1e5053b2009-08-09 03:06:19 +0000312 tdesc->next = ether->tdesc_phys + offset;
313 tdesc->buffer = ether->tdesc_phys +
314 offsetof(struct tran_pdesc, tran_buf[i]);
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000315 tdesc->sl = 0;
316 tdesc->mode = 0;
317 }
318
Wan ZongShun1e5053b2009-08-09 03:06:19 +0000319 ether->start_tx_ptr = ether->tdesc_phys;
320
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000321 for (i = 0; i < RX_DESC_SIZE; i++) {
Wan ZongShun1e5053b2009-08-09 03:06:19 +0000322 unsigned int offset;
323
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000324 rdesc = &(ether->rdesc->desclist[i]);
325
Wan ZongShun1e5053b2009-08-09 03:06:19 +0000326 if (i == RX_DESC_SIZE - 1)
327 offset = offsetof(struct recv_pdesc, desclist[0]);
328 else
329 offset = offsetof(struct recv_pdesc, desclist[i + 1]);
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000330
Wan ZongShun1e5053b2009-08-09 03:06:19 +0000331 rdesc->next = ether->rdesc_phys + offset;
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000332 rdesc->sl = RX_OWEN_DMA;
Wan ZongShun1e5053b2009-08-09 03:06:19 +0000333 rdesc->buffer = ether->rdesc_phys +
334 offsetof(struct recv_pdesc, recv_buf[i]);
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000335 }
Wan ZongShun1e5053b2009-08-09 03:06:19 +0000336
337 ether->start_rx_ptr = ether->rdesc_phys;
338
339 return 0;
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000340}
341
342static void w90p910_set_fifo_threshold(struct net_device *dev)
343{
344 struct w90p910_ether *ether = netdev_priv(dev);
345 unsigned int val;
346
347 val = TXTHD | BLENGTH;
348 __raw_writel(val, ether->reg + REG_FFTCR);
349}
350
351static void w90p910_return_default_idle(struct net_device *dev)
352{
353 struct w90p910_ether *ether = netdev_priv(dev);
354 unsigned int val;
355
356 val = __raw_readl(ether->reg + REG_MCMDR);
357 val |= SWR;
358 __raw_writel(val, ether->reg + REG_MCMDR);
359}
360
361static void w90p910_trigger_rx(struct net_device *dev)
362{
363 struct w90p910_ether *ether = netdev_priv(dev);
364
365 __raw_writel(ENSTART, ether->reg + REG_RSDR);
366}
367
368static void w90p910_trigger_tx(struct net_device *dev)
369{
370 struct w90p910_ether *ether = netdev_priv(dev);
371
372 __raw_writel(ENSTART, ether->reg + REG_TSDR);
373}
374
375static void w90p910_enable_mac_interrupt(struct net_device *dev)
376{
377 struct w90p910_ether *ether = netdev_priv(dev);
378 unsigned int val;
379
380 val = ENTXINTR | ENRXINTR | ENRXGD | ENTXCP;
381 val |= ENTXBERR | ENRXBERR | ENTXABT;
382
383 __raw_writel(val, ether->reg + REG_MIEN);
384}
385
386static void w90p910_get_and_clear_int(struct net_device *dev,
387 unsigned int *val)
388{
389 struct w90p910_ether *ether = netdev_priv(dev);
390
391 *val = __raw_readl(ether->reg + REG_MISTA);
392 __raw_writel(*val, ether->reg + REG_MISTA);
393}
394
395static void w90p910_set_global_maccmd(struct net_device *dev)
396{
397 struct w90p910_ether *ether = netdev_priv(dev);
398 unsigned int val;
399
400 val = __raw_readl(ether->reg + REG_MCMDR);
401 val |= MCMDR_SPCRC | MCMDR_ENMDC | MCMDR_ACP | ENMDC;
402 __raw_writel(val, ether->reg + REG_MCMDR);
403}
404
405static void w90p910_enable_cam(struct net_device *dev)
406{
407 struct w90p910_ether *ether = netdev_priv(dev);
408 unsigned int val;
409
410 w90p910_write_cam(dev, CAM0, dev->dev_addr);
411
412 val = __raw_readl(ether->reg + REG_CAMEN);
413 val |= CAM0EN;
414 __raw_writel(val, ether->reg + REG_CAMEN);
415}
416
417static void w90p910_enable_cam_command(struct net_device *dev)
418{
419 struct w90p910_ether *ether = netdev_priv(dev);
420 unsigned int val;
421
422 val = CAMCMR_ECMP | CAMCMR_ABP | CAMCMR_AMP;
423 __raw_writel(val, ether->reg + REG_CAMCMR);
424}
425
426static void w90p910_enable_tx(struct net_device *dev, unsigned int enable)
427{
428 struct w90p910_ether *ether = netdev_priv(dev);
429 unsigned int val;
430
431 val = __raw_readl(ether->reg + REG_MCMDR);
432
433 if (enable)
434 val |= MCMDR_TXON;
435 else
436 val &= ~MCMDR_TXON;
437
438 __raw_writel(val, ether->reg + REG_MCMDR);
439}
440
441static void w90p910_enable_rx(struct net_device *dev, unsigned int enable)
442{
443 struct w90p910_ether *ether = netdev_priv(dev);
444 unsigned int val;
445
446 val = __raw_readl(ether->reg + REG_MCMDR);
447
448 if (enable)
449 val |= MCMDR_RXON;
450 else
451 val &= ~MCMDR_RXON;
452
453 __raw_writel(val, ether->reg + REG_MCMDR);
454}
455
456static void w90p910_set_curdest(struct net_device *dev)
457{
458 struct w90p910_ether *ether = netdev_priv(dev);
459
460 __raw_writel(ether->start_rx_ptr, ether->reg + REG_RXDLSA);
461 __raw_writel(ether->start_tx_ptr, ether->reg + REG_TXDLSA);
462}
463
464static void w90p910_reset_mac(struct net_device *dev)
465{
466 struct w90p910_ether *ether = netdev_priv(dev);
467
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000468 w90p910_enable_tx(dev, 0);
469 w90p910_enable_rx(dev, 0);
470 w90p910_set_fifo_threshold(dev);
471 w90p910_return_default_idle(dev);
472
473 if (!netif_queue_stopped(dev))
474 netif_stop_queue(dev);
475
476 w90p910_init_desc(dev);
477
Florian Westphal860e9532016-05-03 16:33:13 +0200478 netif_trans_update(dev); /* prevent tx timeout */
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000479 ether->cur_tx = 0x0;
480 ether->finish_tx = 0x0;
481 ether->cur_rx = 0x0;
482
483 w90p910_set_curdest(dev);
484 w90p910_enable_cam(dev);
485 w90p910_enable_cam_command(dev);
486 w90p910_enable_mac_interrupt(dev);
487 w90p910_enable_tx(dev, 1);
488 w90p910_enable_rx(dev, 1);
489 w90p910_trigger_tx(dev);
490 w90p910_trigger_rx(dev);
491
Florian Westphal860e9532016-05-03 16:33:13 +0200492 netif_trans_update(dev); /* prevent tx timeout */
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000493
494 if (netif_queue_stopped(dev))
495 netif_wake_queue(dev);
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000496}
497
498static void w90p910_mdio_write(struct net_device *dev,
499 int phy_id, int reg, int data)
500{
501 struct w90p910_ether *ether = netdev_priv(dev);
502 struct platform_device *pdev;
503 unsigned int val, i;
504
505 pdev = ether->pdev;
506
507 __raw_writel(data, ether->reg + REG_MIID);
508
509 val = (phy_id << 0x08) | reg;
510 val |= PHYBUSY | PHYWR | MDCCR_VAL;
511 __raw_writel(val, ether->reg + REG_MIIDA);
512
513 for (i = 0; i < DELAY; i++) {
514 if ((__raw_readl(ether->reg + REG_MIIDA) & PHYBUSY) == 0)
515 break;
516 }
517
518 if (i == DELAY)
519 dev_warn(&pdev->dev, "mdio write timed out\n");
520}
521
522static int w90p910_mdio_read(struct net_device *dev, int phy_id, int reg)
523{
524 struct w90p910_ether *ether = netdev_priv(dev);
525 struct platform_device *pdev;
526 unsigned int val, i, data;
527
528 pdev = ether->pdev;
529
530 val = (phy_id << 0x08) | reg;
531 val |= PHYBUSY | MDCCR_VAL;
532 __raw_writel(val, ether->reg + REG_MIIDA);
533
534 for (i = 0; i < DELAY; i++) {
535 if ((__raw_readl(ether->reg + REG_MIIDA) & PHYBUSY) == 0)
536 break;
537 }
538
539 if (i == DELAY) {
540 dev_warn(&pdev->dev, "mdio read timed out\n");
541 data = 0xffff;
542 } else {
543 data = __raw_readl(ether->reg + REG_MIID);
544 }
545
546 return data;
547}
548
Wan ZongShun1e5053b2009-08-09 03:06:19 +0000549static int w90p910_set_mac_address(struct net_device *dev, void *addr)
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000550{
551 struct sockaddr *address = addr;
552
553 if (!is_valid_ether_addr(address->sa_data))
554 return -EADDRNOTAVAIL;
555
556 memcpy(dev->dev_addr, address->sa_data, dev->addr_len);
557 w90p910_write_cam(dev, CAM0, dev->dev_addr);
558
559 return 0;
560}
561
562static int w90p910_ether_close(struct net_device *dev)
563{
564 struct w90p910_ether *ether = netdev_priv(dev);
Wan ZongShun1e5053b2009-08-09 03:06:19 +0000565 struct platform_device *pdev;
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000566
Wan ZongShun1e5053b2009-08-09 03:06:19 +0000567 pdev = ether->pdev;
568
569 dma_free_coherent(&pdev->dev, sizeof(struct recv_pdesc),
570 ether->rdesc, ether->rdesc_phys);
571 dma_free_coherent(&pdev->dev, sizeof(struct tran_pdesc),
572 ether->tdesc, ether->tdesc_phys);
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000573
574 netif_stop_queue(dev);
575
576 del_timer_sync(&ether->check_timer);
577 clk_disable(ether->rmiiclk);
578 clk_disable(ether->clk);
579
580 free_irq(ether->txirq, dev);
581 free_irq(ether->rxirq, dev);
582
583 return 0;
584}
585
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000586static int w90p910_send_frame(struct net_device *dev,
587 unsigned char *data, int length)
588{
589 struct w90p910_ether *ether;
590 struct w90p910_txbd *txbd;
591 struct platform_device *pdev;
592 unsigned char *buffer;
593
594 ether = netdev_priv(dev);
595 pdev = ether->pdev;
596
597 txbd = &ether->tdesc->desclist[ether->cur_tx];
598 buffer = ether->tdesc->tran_buf[ether->cur_tx];
Wan ZongShun1e5053b2009-08-09 03:06:19 +0000599
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000600 if (length > 1514) {
601 dev_err(&pdev->dev, "send data %d bytes, check it\n", length);
602 length = 1514;
603 }
604
605 txbd->sl = length & 0xFFFF;
606
607 memcpy(buffer, data, length);
608
609 txbd->mode = TX_OWEN_DMA | PADDINGMODE | CRCMODE | MACTXINTEN;
610
611 w90p910_enable_tx(dev, 1);
612
613 w90p910_trigger_tx(dev);
614
Wan ZongShun1e5053b2009-08-09 03:06:19 +0000615 if (++ether->cur_tx >= TX_DESC_SIZE)
616 ether->cur_tx = 0;
617
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000618 txbd = &ether->tdesc->desclist[ether->cur_tx];
619
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000620 if (txbd->mode & TX_OWEN_DMA)
621 netif_stop_queue(dev);
622
623 return 0;
624}
625
626static int w90p910_ether_start_xmit(struct sk_buff *skb, struct net_device *dev)
627{
628 struct w90p910_ether *ether = netdev_priv(dev);
629
630 if (!(w90p910_send_frame(dev, skb->data, skb->len))) {
631 ether->skb = skb;
632 dev_kfree_skb_irq(skb);
633 return 0;
634 }
Wan ZongShun1e5053b2009-08-09 03:06:19 +0000635 return -EAGAIN;
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000636}
637
638static irqreturn_t w90p910_tx_interrupt(int irq, void *dev_id)
639{
640 struct w90p910_ether *ether;
641 struct w90p910_txbd *txbd;
642 struct platform_device *pdev;
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000643 struct net_device *dev;
644 unsigned int cur_entry, entry, status;
645
Wan ZongShun1e5053b2009-08-09 03:06:19 +0000646 dev = dev_id;
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000647 ether = netdev_priv(dev);
648 pdev = ether->pdev;
649
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000650 w90p910_get_and_clear_int(dev, &status);
651
652 cur_entry = __raw_readl(ether->reg + REG_CTXDSA);
653
Wan ZongShun1e5053b2009-08-09 03:06:19 +0000654 entry = ether->tdesc_phys +
655 offsetof(struct tran_pdesc, desclist[ether->finish_tx]);
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000656
657 while (entry != cur_entry) {
658 txbd = &ether->tdesc->desclist[ether->finish_tx];
659
Wan ZongShun1e5053b2009-08-09 03:06:19 +0000660 if (++ether->finish_tx >= TX_DESC_SIZE)
661 ether->finish_tx = 0;
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000662
663 if (txbd->sl & TXDS_TXCP) {
Tobias Klauserb09a9532017-04-07 10:17:33 +0200664 dev->stats.tx_packets++;
665 dev->stats.tx_bytes += txbd->sl & 0xFFFF;
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000666 } else {
Tobias Klauserb09a9532017-04-07 10:17:33 +0200667 dev->stats.tx_errors++;
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000668 }
669
670 txbd->sl = 0x0;
671 txbd->mode = 0x0;
672
673 if (netif_queue_stopped(dev))
674 netif_wake_queue(dev);
675
Wan ZongShun1e5053b2009-08-09 03:06:19 +0000676 entry = ether->tdesc_phys +
677 offsetof(struct tran_pdesc, desclist[ether->finish_tx]);
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000678 }
679
680 if (status & MISTA_EXDEF) {
681 dev_err(&pdev->dev, "emc defer exceed interrupt\n");
682 } else if (status & MISTA_TXBERR) {
Wan ZongShun1e5053b2009-08-09 03:06:19 +0000683 dev_err(&pdev->dev, "emc bus error interrupt\n");
684 w90p910_reset_mac(dev);
685 } else if (status & MISTA_TDU) {
686 if (netif_queue_stopped(dev))
687 netif_wake_queue(dev);
688 }
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000689
690 return IRQ_HANDLED;
691}
692
693static void netdev_rx(struct net_device *dev)
694{
695 struct w90p910_ether *ether;
696 struct w90p910_rxbd *rxbd;
697 struct platform_device *pdev;
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000698 struct sk_buff *skb;
699 unsigned char *data;
700 unsigned int length, status, val, entry;
701
702 ether = netdev_priv(dev);
703 pdev = ether->pdev;
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000704
705 rxbd = &ether->rdesc->desclist[ether->cur_rx];
706
707 do {
708 val = __raw_readl(ether->reg + REG_CRXDSA);
Wan ZongShun1e5053b2009-08-09 03:06:19 +0000709
710 entry = ether->rdesc_phys +
711 offsetof(struct recv_pdesc, desclist[ether->cur_rx]);
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000712
713 if (val == entry)
714 break;
715
716 status = rxbd->sl;
717 length = status & 0xFFFF;
718
719 if (status & RXDS_RXGD) {
720 data = ether->rdesc->recv_buf[ether->cur_rx];
Pradeep A. Dalvidae2e9f2012-02-06 11:16:13 +0000721 skb = netdev_alloc_skb(dev, length + 2);
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000722 if (!skb) {
Tobias Klauserb09a9532017-04-07 10:17:33 +0200723 dev->stats.rx_dropped++;
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000724 return;
725 }
726
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000727 skb_reserve(skb, 2);
728 skb_put(skb, length);
729 skb_copy_to_linear_data(skb, data, length);
730 skb->protocol = eth_type_trans(skb, dev);
Tobias Klauserb09a9532017-04-07 10:17:33 +0200731 dev->stats.rx_packets++;
732 dev->stats.rx_bytes += length;
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000733 netif_rx(skb);
734 } else {
Tobias Klauserb09a9532017-04-07 10:17:33 +0200735 dev->stats.rx_errors++;
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000736
737 if (status & RXDS_RP) {
738 dev_err(&pdev->dev, "rx runt err\n");
Tobias Klauserb09a9532017-04-07 10:17:33 +0200739 dev->stats.rx_length_errors++;
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000740 } else if (status & RXDS_CRCE) {
Wan ZongShun1e5053b2009-08-09 03:06:19 +0000741 dev_err(&pdev->dev, "rx crc err\n");
Tobias Klauserb09a9532017-04-07 10:17:33 +0200742 dev->stats.rx_crc_errors++;
Wan ZongShun1e5053b2009-08-09 03:06:19 +0000743 } else if (status & RXDS_ALIE) {
Colin Ian King6b2a3142016-08-17 18:31:35 +0100744 dev_err(&pdev->dev, "rx alignment err\n");
Tobias Klauserb09a9532017-04-07 10:17:33 +0200745 dev->stats.rx_frame_errors++;
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000746 } else if (status & RXDS_PTLE) {
Wan ZongShun1e5053b2009-08-09 03:06:19 +0000747 dev_err(&pdev->dev, "rx longer err\n");
Tobias Klauserb09a9532017-04-07 10:17:33 +0200748 dev->stats.rx_over_errors++;
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000749 }
Wan ZongShun1e5053b2009-08-09 03:06:19 +0000750 }
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000751
752 rxbd->sl = RX_OWEN_DMA;
753 rxbd->reserved = 0x0;
Wan ZongShun1e5053b2009-08-09 03:06:19 +0000754
755 if (++ether->cur_rx >= RX_DESC_SIZE)
756 ether->cur_rx = 0;
757
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000758 rxbd = &ether->rdesc->desclist[ether->cur_rx];
759
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000760 } while (1);
761}
762
763static irqreturn_t w90p910_rx_interrupt(int irq, void *dev_id)
764{
765 struct net_device *dev;
766 struct w90p910_ether *ether;
767 struct platform_device *pdev;
768 unsigned int status;
769
Wan ZongShun1e5053b2009-08-09 03:06:19 +0000770 dev = dev_id;
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000771 ether = netdev_priv(dev);
772 pdev = ether->pdev;
773
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000774 w90p910_get_and_clear_int(dev, &status);
775
776 if (status & MISTA_RDU) {
777 netdev_rx(dev);
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000778 w90p910_trigger_rx(dev);
779
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000780 return IRQ_HANDLED;
781 } else if (status & MISTA_RXBERR) {
Wan ZongShun1e5053b2009-08-09 03:06:19 +0000782 dev_err(&pdev->dev, "emc rx bus error\n");
783 w90p910_reset_mac(dev);
784 }
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000785
786 netdev_rx(dev);
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000787 return IRQ_HANDLED;
788}
789
790static int w90p910_ether_open(struct net_device *dev)
791{
792 struct w90p910_ether *ether;
793 struct platform_device *pdev;
794
795 ether = netdev_priv(dev);
796 pdev = ether->pdev;
797
798 w90p910_reset_mac(dev);
799 w90p910_set_fifo_threshold(dev);
800 w90p910_set_curdest(dev);
801 w90p910_enable_cam(dev);
802 w90p910_enable_cam_command(dev);
803 w90p910_enable_mac_interrupt(dev);
804 w90p910_set_global_maccmd(dev);
805 w90p910_enable_rx(dev, 1);
806
Wan ZongShund1853dc2010-07-13 23:48:45 +0000807 clk_enable(ether->rmiiclk);
808 clk_enable(ether->clk);
809
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000810 ether->rx_packets = 0x0;
811 ether->rx_bytes = 0x0;
812
813 if (request_irq(ether->txirq, w90p910_tx_interrupt,
814 0x0, pdev->name, dev)) {
815 dev_err(&pdev->dev, "register irq tx failed\n");
816 return -EAGAIN;
817 }
818
819 if (request_irq(ether->rxirq, w90p910_rx_interrupt,
820 0x0, pdev->name, dev)) {
821 dev_err(&pdev->dev, "register irq rx failed\n");
Wan ZongShun1e5053b2009-08-09 03:06:19 +0000822 free_irq(ether->txirq, dev);
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000823 return -EAGAIN;
824 }
825
826 mod_timer(&ether->check_timer, jiffies + msecs_to_jiffies(1000));
827 netif_start_queue(dev);
828 w90p910_trigger_rx(dev);
829
830 dev_info(&pdev->dev, "%s is OPENED\n", dev->name);
831
832 return 0;
833}
834
835static void w90p910_ether_set_multicast_list(struct net_device *dev)
836{
837 struct w90p910_ether *ether;
838 unsigned int rx_mode;
839
840 ether = netdev_priv(dev);
841
842 if (dev->flags & IFF_PROMISC)
843 rx_mode = CAMCMR_AUP | CAMCMR_AMP | CAMCMR_ABP | CAMCMR_ECMP;
Jiri Pirko3b9a7722010-02-19 23:06:27 +0000844 else if ((dev->flags & IFF_ALLMULTI) || !netdev_mc_empty(dev))
845 rx_mode = CAMCMR_AMP | CAMCMR_ABP | CAMCMR_ECMP;
846 else
847 rx_mode = CAMCMR_ECMP | CAMCMR_ABP;
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000848 __raw_writel(rx_mode, ether->reg + REG_CAMCMR);
849}
850
851static int w90p910_ether_ioctl(struct net_device *dev,
852 struct ifreq *ifr, int cmd)
853{
854 struct w90p910_ether *ether = netdev_priv(dev);
855 struct mii_ioctl_data *data = if_mii(ifr);
856
857 return generic_mii_ioctl(&ether->mii, data, cmd, NULL);
858}
859
860static void w90p910_get_drvinfo(struct net_device *dev,
861 struct ethtool_drvinfo *info)
862{
Jiri Pirko7826d432013-01-06 00:44:26 +0000863 strlcpy(info->driver, DRV_MODULE_NAME, sizeof(info->driver));
864 strlcpy(info->version, DRV_MODULE_VERSION, sizeof(info->version));
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000865}
866
Philippe Reynes2efbe142017-02-12 21:38:29 +0100867static int w90p910_get_link_ksettings(struct net_device *dev,
868 struct ethtool_link_ksettings *cmd)
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000869{
870 struct w90p910_ether *ether = netdev_priv(dev);
yuval.shaia@oracle.com82c01a82017-06-04 20:22:00 +0300871
872 mii_ethtool_get_link_ksettings(&ether->mii, cmd);
873
874 return 0;
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000875}
876
Philippe Reynes2efbe142017-02-12 21:38:29 +0100877static int w90p910_set_link_ksettings(struct net_device *dev,
878 const struct ethtool_link_ksettings *cmd)
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000879{
880 struct w90p910_ether *ether = netdev_priv(dev);
Philippe Reynes2efbe142017-02-12 21:38:29 +0100881 return mii_ethtool_set_link_ksettings(&ether->mii, cmd);
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000882}
883
884static int w90p910_nway_reset(struct net_device *dev)
885{
886 struct w90p910_ether *ether = netdev_priv(dev);
887 return mii_nway_restart(&ether->mii);
888}
889
890static u32 w90p910_get_link(struct net_device *dev)
891{
892 struct w90p910_ether *ether = netdev_priv(dev);
893 return mii_link_ok(&ether->mii);
894}
895
896static const struct ethtool_ops w90p910_ether_ethtool_ops = {
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000897 .get_drvinfo = w90p910_get_drvinfo,
898 .nway_reset = w90p910_nway_reset,
899 .get_link = w90p910_get_link,
Philippe Reynes2efbe142017-02-12 21:38:29 +0100900 .get_link_ksettings = w90p910_get_link_ksettings,
901 .set_link_ksettings = w90p910_set_link_ksettings,
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000902};
903
904static const struct net_device_ops w90p910_ether_netdev_ops = {
905 .ndo_open = w90p910_ether_open,
906 .ndo_stop = w90p910_ether_close,
907 .ndo_start_xmit = w90p910_ether_start_xmit,
Jiri Pirkoafc4b132011-08-16 06:29:01 +0000908 .ndo_set_rx_mode = w90p910_ether_set_multicast_list,
Wan ZongShun1e5053b2009-08-09 03:06:19 +0000909 .ndo_set_mac_address = w90p910_set_mac_address,
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000910 .ndo_do_ioctl = w90p910_ether_ioctl,
911 .ndo_validate_addr = eth_validate_addr,
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000912};
913
914static void __init get_mac_address(struct net_device *dev)
915{
916 struct w90p910_ether *ether = netdev_priv(dev);
917 struct platform_device *pdev;
Joe Perches1409a932013-08-01 16:17:49 -0700918 char addr[ETH_ALEN];
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000919
920 pdev = ether->pdev;
921
922 addr[0] = 0x00;
923 addr[1] = 0x02;
924 addr[2] = 0xac;
925 addr[3] = 0x55;
926 addr[4] = 0x88;
927 addr[5] = 0xa8;
928
929 if (is_valid_ether_addr(addr))
Joe Perches1409a932013-08-01 16:17:49 -0700930 memcpy(dev->dev_addr, &addr, ETH_ALEN);
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000931 else
932 dev_err(&pdev->dev, "invalid mac address\n");
933}
934
935static int w90p910_ether_setup(struct net_device *dev)
936{
937 struct w90p910_ether *ether = netdev_priv(dev);
938
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000939 dev->netdev_ops = &w90p910_ether_netdev_ops;
940 dev->ethtool_ops = &w90p910_ether_ethtool_ops;
941
942 dev->tx_queue_len = 16;
943 dev->dma = 0x0;
944 dev->watchdog_timeo = TX_TIMEOUT;
945
946 get_mac_address(dev);
947
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000948 ether->cur_tx = 0x0;
949 ether->cur_rx = 0x0;
950 ether->finish_tx = 0x0;
951 ether->linkflag = 0x0;
952 ether->mii.phy_id = 0x01;
953 ether->mii.phy_id_mask = 0x1f;
954 ether->mii.reg_num_mask = 0x1f;
955 ether->mii.dev = dev;
956 ether->mii.mdio_read = w90p910_mdio_read;
957 ether->mii.mdio_write = w90p910_mdio_write;
958
959 setup_timer(&ether->check_timer, w90p910_check_link,
960 (unsigned long)dev);
961
962 return 0;
963}
964
Bill Pemberton26735f22012-12-03 09:23:19 -0500965static int w90p910_ether_probe(struct platform_device *pdev)
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000966{
967 struct w90p910_ether *ether;
968 struct net_device *dev;
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000969 int error;
970
971 dev = alloc_etherdev(sizeof(struct w90p910_ether));
972 if (!dev)
973 return -ENOMEM;
974
Wan ZongShun1e5053b2009-08-09 03:06:19 +0000975 ether = netdev_priv(dev);
976
977 ether->res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
978 if (ether->res == NULL) {
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000979 dev_err(&pdev->dev, "failed to get I/O memory\n");
980 error = -ENXIO;
981 goto failed_free;
982 }
983
Wan ZongShun1e5053b2009-08-09 03:06:19 +0000984 if (!request_mem_region(ether->res->start,
985 resource_size(ether->res), pdev->name)) {
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000986 dev_err(&pdev->dev, "failed to request I/O memory\n");
987 error = -EBUSY;
988 goto failed_free;
989 }
990
Wan ZongShun1e5053b2009-08-09 03:06:19 +0000991 ether->reg = ioremap(ether->res->start, resource_size(ether->res));
Wan ZongShuna50a97d2009-07-16 02:55:05 +0000992 if (ether->reg == NULL) {
993 dev_err(&pdev->dev, "failed to remap I/O memory\n");
994 error = -ENXIO;
995 goto failed_free_mem;
996 }
997
998 ether->txirq = platform_get_irq(pdev, 0);
999 if (ether->txirq < 0) {
1000 dev_err(&pdev->dev, "failed to get ether tx irq\n");
1001 error = -ENXIO;
1002 goto failed_free_io;
1003 }
1004
1005 ether->rxirq = platform_get_irq(pdev, 1);
1006 if (ether->rxirq < 0) {
1007 dev_err(&pdev->dev, "failed to get ether rx irq\n");
1008 error = -ENXIO;
Julia Lawall0a171932013-09-02 11:54:21 +02001009 goto failed_free_io;
Wan ZongShuna50a97d2009-07-16 02:55:05 +00001010 }
1011
1012 platform_set_drvdata(pdev, dev);
1013
1014 ether->clk = clk_get(&pdev->dev, NULL);
1015 if (IS_ERR(ether->clk)) {
1016 dev_err(&pdev->dev, "failed to get ether clock\n");
1017 error = PTR_ERR(ether->clk);
Julia Lawall0a171932013-09-02 11:54:21 +02001018 goto failed_free_io;
Wan ZongShuna50a97d2009-07-16 02:55:05 +00001019 }
1020
1021 ether->rmiiclk = clk_get(&pdev->dev, "RMII");
1022 if (IS_ERR(ether->rmiiclk)) {
1023 dev_err(&pdev->dev, "failed to get ether clock\n");
1024 error = PTR_ERR(ether->rmiiclk);
1025 goto failed_put_clk;
1026 }
1027
1028 ether->pdev = pdev;
1029
1030 w90p910_ether_setup(dev);
1031
1032 error = register_netdev(dev);
1033 if (error != 0) {
Masanari Iidafc4fa6e2015-12-13 15:26:11 +09001034 dev_err(&pdev->dev, "Register EMC w90p910 FAILED\n");
Wan ZongShuna50a97d2009-07-16 02:55:05 +00001035 error = -ENODEV;
1036 goto failed_put_rmiiclk;
1037 }
1038
1039 return 0;
1040failed_put_rmiiclk:
1041 clk_put(ether->rmiiclk);
1042failed_put_clk:
1043 clk_put(ether->clk);
Wan ZongShuna50a97d2009-07-16 02:55:05 +00001044failed_free_io:
1045 iounmap(ether->reg);
1046failed_free_mem:
Wan ZongShun1e5053b2009-08-09 03:06:19 +00001047 release_mem_region(ether->res->start, resource_size(ether->res));
Wan ZongShuna50a97d2009-07-16 02:55:05 +00001048failed_free:
1049 free_netdev(dev);
1050 return error;
1051}
1052
Bill Pemberton26735f22012-12-03 09:23:19 -05001053static int w90p910_ether_remove(struct platform_device *pdev)
Wan ZongShuna50a97d2009-07-16 02:55:05 +00001054{
1055 struct net_device *dev = platform_get_drvdata(pdev);
1056 struct w90p910_ether *ether = netdev_priv(dev);
1057
1058 unregister_netdev(dev);
Wan ZongShun1e5053b2009-08-09 03:06:19 +00001059
Wan ZongShuna50a97d2009-07-16 02:55:05 +00001060 clk_put(ether->rmiiclk);
1061 clk_put(ether->clk);
Wan ZongShun1e5053b2009-08-09 03:06:19 +00001062
1063 iounmap(ether->reg);
1064 release_mem_region(ether->res->start, resource_size(ether->res));
1065
Wan ZongShuna50a97d2009-07-16 02:55:05 +00001066 del_timer_sync(&ether->check_timer);
Wan ZongShun1e5053b2009-08-09 03:06:19 +00001067
Wan ZongShuna50a97d2009-07-16 02:55:05 +00001068 free_netdev(dev);
1069 return 0;
1070}
1071
1072static struct platform_driver w90p910_ether_driver = {
1073 .probe = w90p910_ether_probe,
Bill Pemberton26735f22012-12-03 09:23:19 -05001074 .remove = w90p910_ether_remove,
Wan ZongShuna50a97d2009-07-16 02:55:05 +00001075 .driver = {
Wan ZongShun456d8992009-08-18 23:34:58 -07001076 .name = "nuc900-emc",
Wan ZongShuna50a97d2009-07-16 02:55:05 +00001077 },
1078};
1079
Axel Lindb62f682011-11-27 16:44:17 +00001080module_platform_driver(w90p910_ether_driver);
Wan ZongShuna50a97d2009-07-16 02:55:05 +00001081
1082MODULE_AUTHOR("Wan ZongShun <mcuos.com@gmail.com>");
1083MODULE_DESCRIPTION("w90p910 MAC driver!");
1084MODULE_LICENSE("GPL");
Wan ZongShun456d8992009-08-18 23:34:58 -07001085MODULE_ALIAS("platform:nuc900-emc");
Wan ZongShuna50a97d2009-07-16 02:55:05 +00001086