OMAP3: PM: default defconfig for PM kernel testing
[linux-ginger.git] / drivers / net / ks8842.c
blob99e954167fa6da32251a3c68e1f1092a367c8186
1 /*
2 * ks8842_main.c timberdale KS8842 ethernet driver
3 * Copyright (c) 2009 Intel Corporation
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 /* Supports:
20 * The Micrel KS8842 behind the timberdale FPGA
23 #include <linux/kernel.h>
24 #include <linux/module.h>
25 #include <linux/platform_device.h>
26 #include <linux/netdevice.h>
27 #include <linux/etherdevice.h>
28 #include <linux/ethtool.h>
30 #define DRV_NAME "ks8842"
32 /* Timberdale specific Registers */
33 #define REG_TIMB_RST 0x1c
35 /* KS8842 registers */
37 #define REG_SELECT_BANK 0x0e
39 /* bank 0 registers */
40 #define REG_QRFCR 0x04
42 /* bank 2 registers */
43 #define REG_MARL 0x00
44 #define REG_MARM 0x02
45 #define REG_MARH 0x04
47 /* bank 3 registers */
48 #define REG_GRR 0x06
50 /* bank 16 registers */
51 #define REG_TXCR 0x00
52 #define REG_TXSR 0x02
53 #define REG_RXCR 0x04
54 #define REG_TXMIR 0x08
55 #define REG_RXMIR 0x0A
57 /* bank 17 registers */
58 #define REG_TXQCR 0x00
59 #define REG_RXQCR 0x02
60 #define REG_TXFDPR 0x04
61 #define REG_RXFDPR 0x06
62 #define REG_QMU_DATA_LO 0x08
63 #define REG_QMU_DATA_HI 0x0A
65 /* bank 18 registers */
66 #define REG_IER 0x00
67 #define IRQ_LINK_CHANGE 0x8000
68 #define IRQ_TX 0x4000
69 #define IRQ_RX 0x2000
70 #define IRQ_RX_OVERRUN 0x0800
71 #define IRQ_TX_STOPPED 0x0200
72 #define IRQ_RX_STOPPED 0x0100
73 #define IRQ_RX_ERROR 0x0080
74 #define ENABLED_IRQS (IRQ_LINK_CHANGE | IRQ_TX | IRQ_RX | IRQ_RX_STOPPED | \
75 IRQ_TX_STOPPED | IRQ_RX_OVERRUN | IRQ_RX_ERROR)
76 #define REG_ISR 0x02
77 #define REG_RXSR 0x04
78 #define RXSR_VALID 0x8000
79 #define RXSR_BROADCAST 0x80
80 #define RXSR_MULTICAST 0x40
81 #define RXSR_UNICAST 0x20
82 #define RXSR_FRAMETYPE 0x08
83 #define RXSR_TOO_LONG 0x04
84 #define RXSR_RUNT 0x02
85 #define RXSR_CRC_ERROR 0x01
86 #define RXSR_ERROR (RXSR_TOO_LONG | RXSR_RUNT | RXSR_CRC_ERROR)
88 /* bank 32 registers */
89 #define REG_SW_ID_AND_ENABLE 0x00
90 #define REG_SGCR1 0x02
91 #define REG_SGCR2 0x04
92 #define REG_SGCR3 0x06
94 /* bank 39 registers */
95 #define REG_MACAR1 0x00
96 #define REG_MACAR2 0x02
97 #define REG_MACAR3 0x04
99 /* bank 45 registers */
100 #define REG_P1MBCR 0x00
101 #define REG_P1MBSR 0x02
103 /* bank 46 registers */
104 #define REG_P2MBCR 0x00
105 #define REG_P2MBSR 0x02
107 /* bank 48 registers */
108 #define REG_P1CR2 0x02
110 /* bank 49 registers */
111 #define REG_P1CR4 0x02
112 #define REG_P1SR 0x04
114 struct ks8842_adapter {
115 void __iomem *hw_addr;
116 int irq;
117 struct tasklet_struct tasklet;
118 spinlock_t lock; /* spinlock to be interrupt safe */
119 struct platform_device *pdev;
122 static inline void ks8842_select_bank(struct ks8842_adapter *adapter, u16 bank)
124 iowrite16(bank, adapter->hw_addr + REG_SELECT_BANK);
127 static inline void ks8842_write8(struct ks8842_adapter *adapter, u16 bank,
128 u8 value, int offset)
130 ks8842_select_bank(adapter, bank);
131 iowrite8(value, adapter->hw_addr + offset);
134 static inline void ks8842_write16(struct ks8842_adapter *adapter, u16 bank,
135 u16 value, int offset)
137 ks8842_select_bank(adapter, bank);
138 iowrite16(value, adapter->hw_addr + offset);
141 static inline void ks8842_enable_bits(struct ks8842_adapter *adapter, u16 bank,
142 u16 bits, int offset)
144 u16 reg;
145 ks8842_select_bank(adapter, bank);
146 reg = ioread16(adapter->hw_addr + offset);
147 reg |= bits;
148 iowrite16(reg, adapter->hw_addr + offset);
151 static inline void ks8842_clear_bits(struct ks8842_adapter *adapter, u16 bank,
152 u16 bits, int offset)
154 u16 reg;
155 ks8842_select_bank(adapter, bank);
156 reg = ioread16(adapter->hw_addr + offset);
157 reg &= ~bits;
158 iowrite16(reg, adapter->hw_addr + offset);
161 static inline void ks8842_write32(struct ks8842_adapter *adapter, u16 bank,
162 u32 value, int offset)
164 ks8842_select_bank(adapter, bank);
165 iowrite32(value, adapter->hw_addr + offset);
168 static inline u8 ks8842_read8(struct ks8842_adapter *adapter, u16 bank,
169 int offset)
171 ks8842_select_bank(adapter, bank);
172 return ioread8(adapter->hw_addr + offset);
175 static inline u16 ks8842_read16(struct ks8842_adapter *adapter, u16 bank,
176 int offset)
178 ks8842_select_bank(adapter, bank);
179 return ioread16(adapter->hw_addr + offset);
182 static inline u32 ks8842_read32(struct ks8842_adapter *adapter, u16 bank,
183 int offset)
185 ks8842_select_bank(adapter, bank);
186 return ioread32(adapter->hw_addr + offset);
189 static void ks8842_reset(struct ks8842_adapter *adapter)
191 /* The KS8842 goes haywire when doing softare reset
192 * a work around in the timberdale IP is implemented to
193 * do a hardware reset instead
194 ks8842_write16(adapter, 3, 1, REG_GRR);
195 msleep(10);
196 iowrite16(0, adapter->hw_addr + REG_GRR);
198 iowrite16(32, adapter->hw_addr + REG_SELECT_BANK);
199 iowrite32(0x1, adapter->hw_addr + REG_TIMB_RST);
200 msleep(20);
203 static void ks8842_update_link_status(struct net_device *netdev,
204 struct ks8842_adapter *adapter)
206 /* check the status of the link */
207 if (ks8842_read16(adapter, 45, REG_P1MBSR) & 0x4) {
208 netif_carrier_on(netdev);
209 netif_wake_queue(netdev);
210 } else {
211 netif_stop_queue(netdev);
212 netif_carrier_off(netdev);
216 static void ks8842_enable_tx(struct ks8842_adapter *adapter)
218 ks8842_enable_bits(adapter, 16, 0x01, REG_TXCR);
221 static void ks8842_disable_tx(struct ks8842_adapter *adapter)
223 ks8842_clear_bits(adapter, 16, 0x01, REG_TXCR);
226 static void ks8842_enable_rx(struct ks8842_adapter *adapter)
228 ks8842_enable_bits(adapter, 16, 0x01, REG_RXCR);
231 static void ks8842_disable_rx(struct ks8842_adapter *adapter)
233 ks8842_clear_bits(adapter, 16, 0x01, REG_RXCR);
236 static void ks8842_reset_hw(struct ks8842_adapter *adapter)
238 /* reset the HW */
239 ks8842_reset(adapter);
241 /* Enable QMU Transmit flow control / transmit padding / Transmit CRC */
242 ks8842_write16(adapter, 16, 0x000E, REG_TXCR);
244 /* enable the receiver, uni + multi + broadcast + flow ctrl
245 + crc strip */
246 ks8842_write16(adapter, 16, 0x8 | 0x20 | 0x40 | 0x80 | 0x400,
247 REG_RXCR);
249 /* TX frame pointer autoincrement */
250 ks8842_write16(adapter, 17, 0x4000, REG_TXFDPR);
252 /* RX frame pointer autoincrement */
253 ks8842_write16(adapter, 17, 0x4000, REG_RXFDPR);
255 /* RX 2 kb high watermark */
256 ks8842_write16(adapter, 0, 0x1000, REG_QRFCR);
258 /* aggresive back off in half duplex */
259 ks8842_enable_bits(adapter, 32, 1 << 8, REG_SGCR1);
261 /* enable no excessive collison drop */
262 ks8842_enable_bits(adapter, 32, 1 << 3, REG_SGCR2);
264 /* Enable port 1 force flow control / back pressure / transmit / recv */
265 ks8842_write16(adapter, 48, 0x1E07, REG_P1CR2);
267 /* restart port auto-negotiation */
268 ks8842_enable_bits(adapter, 49, 1 << 13, REG_P1CR4);
269 /* only advertise 10Mbps */
270 ks8842_clear_bits(adapter, 49, 3 << 2, REG_P1CR4);
272 /* Enable the transmitter */
273 ks8842_enable_tx(adapter);
275 /* Enable the receiver */
276 ks8842_enable_rx(adapter);
278 /* clear all interrupts */
279 ks8842_write16(adapter, 18, 0xffff, REG_ISR);
281 /* enable interrupts */
282 ks8842_write16(adapter, 18, ENABLED_IRQS, REG_IER);
284 /* enable the switch */
285 ks8842_write16(adapter, 32, 0x1, REG_SW_ID_AND_ENABLE);
288 static void ks8842_read_mac_addr(struct ks8842_adapter *adapter, u8 *dest)
290 int i;
291 u16 mac;
293 for (i = 0; i < ETH_ALEN; i++)
294 dest[ETH_ALEN - i - 1] = ks8842_read8(adapter, 2, REG_MARL + i);
296 /* make sure the switch port uses the same MAC as the QMU */
297 mac = ks8842_read16(adapter, 2, REG_MARL);
298 ks8842_write16(adapter, 39, mac, REG_MACAR1);
299 mac = ks8842_read16(adapter, 2, REG_MARM);
300 ks8842_write16(adapter, 39, mac, REG_MACAR2);
301 mac = ks8842_read16(adapter, 2, REG_MARH);
302 ks8842_write16(adapter, 39, mac, REG_MACAR3);
305 static inline u16 ks8842_tx_fifo_space(struct ks8842_adapter *adapter)
307 return ks8842_read16(adapter, 16, REG_TXMIR) & 0x1fff;
310 static int ks8842_tx_frame(struct sk_buff *skb, struct net_device *netdev)
312 struct ks8842_adapter *adapter = netdev_priv(netdev);
313 int len = skb->len;
314 u32 *ptr = (u32 *)skb->data;
315 u32 ctrl;
317 dev_dbg(&adapter->pdev->dev,
318 "%s: len %u head %p data %p tail %p end %p\n",
319 __func__, skb->len, skb->head, skb->data,
320 skb_tail_pointer(skb), skb_end_pointer(skb));
322 /* check FIFO buffer space, we need space for CRC and command bits */
323 if (ks8842_tx_fifo_space(adapter) < len + 8)
324 return NETDEV_TX_BUSY;
326 /* the control word, enable IRQ, port 1 and the length */
327 ctrl = 0x8000 | 0x100 | (len << 16);
328 ks8842_write32(adapter, 17, ctrl, REG_QMU_DATA_LO);
330 netdev->stats.tx_bytes += len;
332 /* copy buffer */
333 while (len > 0) {
334 iowrite32(*ptr, adapter->hw_addr + REG_QMU_DATA_LO);
335 len -= sizeof(u32);
336 ptr++;
339 /* enqueue packet */
340 ks8842_write16(adapter, 17, 1, REG_TXQCR);
342 dev_kfree_skb(skb);
344 return NETDEV_TX_OK;
347 static void ks8842_rx_frame(struct net_device *netdev,
348 struct ks8842_adapter *adapter)
350 u32 status = ks8842_read32(adapter, 17, REG_QMU_DATA_LO);
351 int len = (status >> 16) & 0x7ff;
353 status &= 0xffff;
355 dev_dbg(&adapter->pdev->dev, "%s - rx_data: status: %x\n",
356 __func__, status);
358 /* check the status */
359 if ((status & RXSR_VALID) && !(status & RXSR_ERROR)) {
360 struct sk_buff *skb = netdev_alloc_skb(netdev, len + 2);
362 dev_dbg(&adapter->pdev->dev, "%s, got package, len: %d\n",
363 __func__, len);
364 if (skb) {
365 u32 *data;
367 netdev->stats.rx_packets++;
368 netdev->stats.rx_bytes += len;
369 if (status & RXSR_MULTICAST)
370 netdev->stats.multicast++;
372 /* Align socket buffer in 4-byte boundary for
373 better performance. */
374 skb_reserve(skb, 2);
375 data = (u32 *)skb_put(skb, len);
377 ks8842_select_bank(adapter, 17);
378 while (len > 0) {
379 *data++ = ioread32(adapter->hw_addr +
380 REG_QMU_DATA_LO);
381 len -= sizeof(u32);
384 skb->protocol = eth_type_trans(skb, netdev);
385 netif_rx(skb);
386 } else
387 netdev->stats.rx_dropped++;
388 } else {
389 dev_dbg(&adapter->pdev->dev, "RX error, status: %x\n", status);
390 netdev->stats.rx_errors++;
391 if (status & RXSR_TOO_LONG)
392 netdev->stats.rx_length_errors++;
393 if (status & RXSR_CRC_ERROR)
394 netdev->stats.rx_crc_errors++;
395 if (status & RXSR_RUNT)
396 netdev->stats.rx_frame_errors++;
399 /* set high watermark to 3K */
400 ks8842_clear_bits(adapter, 0, 1 << 12, REG_QRFCR);
402 /* release the frame */
403 ks8842_write16(adapter, 17, 0x01, REG_RXQCR);
405 /* set high watermark to 2K */
406 ks8842_enable_bits(adapter, 0, 1 << 12, REG_QRFCR);
409 void ks8842_handle_rx(struct net_device *netdev, struct ks8842_adapter *adapter)
411 u16 rx_data = ks8842_read16(adapter, 16, REG_RXMIR) & 0x1fff;
412 dev_dbg(&adapter->pdev->dev, "%s Entry - rx_data: %d\n",
413 __func__, rx_data);
414 while (rx_data) {
415 ks8842_rx_frame(netdev, adapter);
416 rx_data = ks8842_read16(adapter, 16, REG_RXMIR) & 0x1fff;
420 void ks8842_handle_tx(struct net_device *netdev, struct ks8842_adapter *adapter)
422 u16 sr = ks8842_read16(adapter, 16, REG_TXSR);
423 dev_dbg(&adapter->pdev->dev, "%s - entry, sr: %x\n", __func__, sr);
424 netdev->stats.tx_packets++;
425 if (netif_queue_stopped(netdev))
426 netif_wake_queue(netdev);
429 void ks8842_handle_rx_overrun(struct net_device *netdev,
430 struct ks8842_adapter *adapter)
432 dev_dbg(&adapter->pdev->dev, "%s: entry\n", __func__);
433 netdev->stats.rx_errors++;
434 netdev->stats.rx_fifo_errors++;
437 void ks8842_tasklet(unsigned long arg)
439 struct net_device *netdev = (struct net_device *)arg;
440 struct ks8842_adapter *adapter = netdev_priv(netdev);
441 u16 isr;
442 unsigned long flags;
443 u16 entry_bank;
445 /* read current bank to be able to set it back */
446 spin_lock_irqsave(&adapter->lock, flags);
447 entry_bank = ioread16(adapter->hw_addr + REG_SELECT_BANK);
448 spin_unlock_irqrestore(&adapter->lock, flags);
450 isr = ks8842_read16(adapter, 18, REG_ISR);
451 dev_dbg(&adapter->pdev->dev, "%s - ISR: 0x%x\n", __func__, isr);
453 /* Ack */
454 ks8842_write16(adapter, 18, isr, REG_ISR);
456 if (!netif_running(netdev))
457 return;
459 if (isr & IRQ_LINK_CHANGE)
460 ks8842_update_link_status(netdev, adapter);
462 if (isr & (IRQ_RX | IRQ_RX_ERROR))
463 ks8842_handle_rx(netdev, adapter);
465 if (isr & IRQ_TX)
466 ks8842_handle_tx(netdev, adapter);
468 if (isr & IRQ_RX_OVERRUN)
469 ks8842_handle_rx_overrun(netdev, adapter);
471 if (isr & IRQ_TX_STOPPED) {
472 ks8842_disable_tx(adapter);
473 ks8842_enable_tx(adapter);
476 if (isr & IRQ_RX_STOPPED) {
477 ks8842_disable_rx(adapter);
478 ks8842_enable_rx(adapter);
481 /* re-enable interrupts, put back the bank selection register */
482 spin_lock_irqsave(&adapter->lock, flags);
483 ks8842_write16(adapter, 18, ENABLED_IRQS, REG_IER);
484 iowrite16(entry_bank, adapter->hw_addr + REG_SELECT_BANK);
485 spin_unlock_irqrestore(&adapter->lock, flags);
488 static irqreturn_t ks8842_irq(int irq, void *devid)
490 struct ks8842_adapter *adapter = devid;
491 u16 isr;
492 u16 entry_bank = ioread16(adapter->hw_addr + REG_SELECT_BANK);
493 irqreturn_t ret = IRQ_NONE;
495 isr = ks8842_read16(adapter, 18, REG_ISR);
496 dev_dbg(&adapter->pdev->dev, "%s - ISR: 0x%x\n", __func__, isr);
498 if (isr) {
499 /* disable IRQ */
500 ks8842_write16(adapter, 18, 0x00, REG_IER);
502 /* schedule tasklet */
503 tasklet_schedule(&adapter->tasklet);
505 ret = IRQ_HANDLED;
508 iowrite16(entry_bank, adapter->hw_addr + REG_SELECT_BANK);
510 return ret;
514 /* Netdevice operations */
516 static int ks8842_open(struct net_device *netdev)
518 struct ks8842_adapter *adapter = netdev_priv(netdev);
519 int err;
521 dev_dbg(&adapter->pdev->dev, "%s - entry\n", __func__);
523 /* reset the HW */
524 ks8842_reset_hw(adapter);
526 ks8842_update_link_status(netdev, adapter);
528 err = request_irq(adapter->irq, ks8842_irq, IRQF_SHARED, DRV_NAME,
529 adapter);
530 if (err) {
531 printk(KERN_ERR "Failed to request IRQ: %d: %d\n",
532 adapter->irq, err);
533 return err;
536 return 0;
539 static int ks8842_close(struct net_device *netdev)
541 struct ks8842_adapter *adapter = netdev_priv(netdev);
543 dev_dbg(&adapter->pdev->dev, "%s - entry\n", __func__);
545 /* free the irq */
546 free_irq(adapter->irq, adapter);
548 /* disable the switch */
549 ks8842_write16(adapter, 32, 0x0, REG_SW_ID_AND_ENABLE);
551 return 0;
554 static netdev_tx_t ks8842_xmit_frame(struct sk_buff *skb,
555 struct net_device *netdev)
557 int ret;
558 struct ks8842_adapter *adapter = netdev_priv(netdev);
560 dev_dbg(&adapter->pdev->dev, "%s: entry\n", __func__);
562 ret = ks8842_tx_frame(skb, netdev);
564 if (ks8842_tx_fifo_space(adapter) < netdev->mtu + 8)
565 netif_stop_queue(netdev);
567 return ret;
570 static int ks8842_set_mac(struct net_device *netdev, void *p)
572 struct ks8842_adapter *adapter = netdev_priv(netdev);
573 unsigned long flags;
574 struct sockaddr *addr = p;
575 char *mac = (u8 *)addr->sa_data;
576 int i;
578 dev_dbg(&adapter->pdev->dev, "%s: entry\n", __func__);
580 if (!is_valid_ether_addr(addr->sa_data))
581 return -EADDRNOTAVAIL;
583 memcpy(netdev->dev_addr, mac, netdev->addr_len);
585 spin_lock_irqsave(&adapter->lock, flags);
586 for (i = 0; i < ETH_ALEN; i++) {
587 ks8842_write8(adapter, 2, mac[ETH_ALEN - i - 1], REG_MARL + i);
588 ks8842_write8(adapter, 39, mac[ETH_ALEN - i - 1],
589 REG_MACAR1 + i);
591 spin_unlock_irqrestore(&adapter->lock, flags);
592 return 0;
595 static void ks8842_tx_timeout(struct net_device *netdev)
597 struct ks8842_adapter *adapter = netdev_priv(netdev);
598 unsigned long flags;
600 dev_dbg(&adapter->pdev->dev, "%s: entry\n", __func__);
602 spin_lock_irqsave(&adapter->lock, flags);
603 /* disable interrupts */
604 ks8842_write16(adapter, 18, 0, REG_IER);
605 ks8842_write16(adapter, 18, 0xFFFF, REG_ISR);
606 spin_unlock_irqrestore(&adapter->lock, flags);
608 ks8842_reset_hw(adapter);
610 ks8842_update_link_status(netdev, adapter);
613 static const struct net_device_ops ks8842_netdev_ops = {
614 .ndo_open = ks8842_open,
615 .ndo_stop = ks8842_close,
616 .ndo_start_xmit = ks8842_xmit_frame,
617 .ndo_set_mac_address = ks8842_set_mac,
618 .ndo_tx_timeout = ks8842_tx_timeout,
619 .ndo_validate_addr = eth_validate_addr
622 static const struct ethtool_ops ks8842_ethtool_ops = {
623 .get_link = ethtool_op_get_link,
626 static int __devinit ks8842_probe(struct platform_device *pdev)
628 int err = -ENOMEM;
629 struct resource *iomem;
630 struct net_device *netdev;
631 struct ks8842_adapter *adapter;
632 u16 id;
634 iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
635 if (!request_mem_region(iomem->start, resource_size(iomem), DRV_NAME))
636 goto err_mem_region;
638 netdev = alloc_etherdev(sizeof(struct ks8842_adapter));
639 if (!netdev)
640 goto err_alloc_etherdev;
642 SET_NETDEV_DEV(netdev, &pdev->dev);
644 adapter = netdev_priv(netdev);
645 adapter->hw_addr = ioremap(iomem->start, resource_size(iomem));
646 if (!adapter->hw_addr)
647 goto err_ioremap;
649 adapter->irq = platform_get_irq(pdev, 0);
650 if (adapter->irq < 0) {
651 err = adapter->irq;
652 goto err_get_irq;
655 adapter->pdev = pdev;
657 tasklet_init(&adapter->tasklet, ks8842_tasklet, (unsigned long)netdev);
658 spin_lock_init(&adapter->lock);
660 netdev->netdev_ops = &ks8842_netdev_ops;
661 netdev->ethtool_ops = &ks8842_ethtool_ops;
663 ks8842_read_mac_addr(adapter, netdev->dev_addr);
665 id = ks8842_read16(adapter, 32, REG_SW_ID_AND_ENABLE);
667 strcpy(netdev->name, "eth%d");
668 err = register_netdev(netdev);
669 if (err)
670 goto err_register;
672 platform_set_drvdata(pdev, netdev);
674 printk(KERN_INFO DRV_NAME
675 " Found chip, family: 0x%x, id: 0x%x, rev: 0x%x\n",
676 (id >> 8) & 0xff, (id >> 4) & 0xf, (id >> 1) & 0x7);
678 return 0;
680 err_register:
681 err_get_irq:
682 iounmap(adapter->hw_addr);
683 err_ioremap:
684 free_netdev(netdev);
685 err_alloc_etherdev:
686 release_mem_region(iomem->start, resource_size(iomem));
687 err_mem_region:
688 return err;
691 static int __devexit ks8842_remove(struct platform_device *pdev)
693 struct net_device *netdev = platform_get_drvdata(pdev);
694 struct ks8842_adapter *adapter = netdev_priv(netdev);
695 struct resource *iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
697 unregister_netdev(netdev);
698 tasklet_kill(&adapter->tasklet);
699 iounmap(adapter->hw_addr);
700 free_netdev(netdev);
701 release_mem_region(iomem->start, resource_size(iomem));
702 platform_set_drvdata(pdev, NULL);
703 return 0;
707 static struct platform_driver ks8842_platform_driver = {
708 .driver = {
709 .name = DRV_NAME,
710 .owner = THIS_MODULE,
712 .probe = ks8842_probe,
713 .remove = ks8842_remove,
716 static int __init ks8842_init(void)
718 return platform_driver_register(&ks8842_platform_driver);
721 static void __exit ks8842_exit(void)
723 platform_driver_unregister(&ks8842_platform_driver);
726 module_init(ks8842_init);
727 module_exit(ks8842_exit);
729 MODULE_DESCRIPTION("Timberdale KS8842 ethernet driver");
730 MODULE_AUTHOR("Mocean Laboratories <info@mocean-labs.com>");
731 MODULE_LICENSE("GPL v2");
732 MODULE_ALIAS("platform:ks8842");