2 * ks8842.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.
20 * The Micrel KS8842 behind the timberdale FPGA
23 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
25 #include <linux/kernel.h>
26 #include <linux/module.h>
27 #include <linux/platform_device.h>
28 #include <linux/netdevice.h>
29 #include <linux/etherdevice.h>
30 #include <linux/ethtool.h>
31 #include <linux/ks8842.h>
33 #define DRV_NAME "ks8842"
35 /* Timberdale specific Registers */
36 #define REG_TIMB_RST 0x1c
38 /* KS8842 registers */
40 #define REG_SELECT_BANK 0x0e
42 /* bank 0 registers */
43 #define REG_QRFCR 0x04
45 /* bank 2 registers */
50 /* bank 3 registers */
53 /* bank 16 registers */
57 #define REG_TXMIR 0x08
58 #define REG_RXMIR 0x0A
60 /* bank 17 registers */
61 #define REG_TXQCR 0x00
62 #define REG_RXQCR 0x02
63 #define REG_TXFDPR 0x04
64 #define REG_RXFDPR 0x06
65 #define REG_QMU_DATA_LO 0x08
66 #define REG_QMU_DATA_HI 0x0A
68 /* bank 18 registers */
70 #define IRQ_LINK_CHANGE 0x8000
73 #define IRQ_RX_OVERRUN 0x0800
74 #define IRQ_TX_STOPPED 0x0200
75 #define IRQ_RX_STOPPED 0x0100
76 #define IRQ_RX_ERROR 0x0080
77 #define ENABLED_IRQS (IRQ_LINK_CHANGE | IRQ_TX | IRQ_RX | IRQ_RX_STOPPED | \
78 IRQ_TX_STOPPED | IRQ_RX_OVERRUN | IRQ_RX_ERROR)
81 #define RXSR_VALID 0x8000
82 #define RXSR_BROADCAST 0x80
83 #define RXSR_MULTICAST 0x40
84 #define RXSR_UNICAST 0x20
85 #define RXSR_FRAMETYPE 0x08
86 #define RXSR_TOO_LONG 0x04
87 #define RXSR_RUNT 0x02
88 #define RXSR_CRC_ERROR 0x01
89 #define RXSR_ERROR (RXSR_TOO_LONG | RXSR_RUNT | RXSR_CRC_ERROR)
91 /* bank 32 registers */
92 #define REG_SW_ID_AND_ENABLE 0x00
93 #define REG_SGCR1 0x02
94 #define REG_SGCR2 0x04
95 #define REG_SGCR3 0x06
97 /* bank 39 registers */
98 #define REG_MACAR1 0x00
99 #define REG_MACAR2 0x02
100 #define REG_MACAR3 0x04
102 /* bank 45 registers */
103 #define REG_P1MBCR 0x00
104 #define REG_P1MBSR 0x02
106 /* bank 46 registers */
107 #define REG_P2MBCR 0x00
108 #define REG_P2MBSR 0x02
110 /* bank 48 registers */
111 #define REG_P1CR2 0x02
113 /* bank 49 registers */
114 #define REG_P1CR4 0x02
115 #define REG_P1SR 0x04
117 struct ks8842_adapter
{
118 void __iomem
*hw_addr
;
120 struct tasklet_struct tasklet
;
121 spinlock_t lock
; /* spinlock to be interrupt safe */
122 struct platform_device
*pdev
;
125 static inline void ks8842_select_bank(struct ks8842_adapter
*adapter
, u16 bank
)
127 iowrite16(bank
, adapter
->hw_addr
+ REG_SELECT_BANK
);
130 static inline void ks8842_write8(struct ks8842_adapter
*adapter
, u16 bank
,
131 u8 value
, int offset
)
133 ks8842_select_bank(adapter
, bank
);
134 iowrite8(value
, adapter
->hw_addr
+ offset
);
137 static inline void ks8842_write16(struct ks8842_adapter
*adapter
, u16 bank
,
138 u16 value
, int offset
)
140 ks8842_select_bank(adapter
, bank
);
141 iowrite16(value
, adapter
->hw_addr
+ offset
);
144 static inline void ks8842_enable_bits(struct ks8842_adapter
*adapter
, u16 bank
,
145 u16 bits
, int offset
)
148 ks8842_select_bank(adapter
, bank
);
149 reg
= ioread16(adapter
->hw_addr
+ offset
);
151 iowrite16(reg
, adapter
->hw_addr
+ offset
);
154 static inline void ks8842_clear_bits(struct ks8842_adapter
*adapter
, u16 bank
,
155 u16 bits
, int offset
)
158 ks8842_select_bank(adapter
, bank
);
159 reg
= ioread16(adapter
->hw_addr
+ offset
);
161 iowrite16(reg
, adapter
->hw_addr
+ offset
);
164 static inline void ks8842_write32(struct ks8842_adapter
*adapter
, u16 bank
,
165 u32 value
, int offset
)
167 ks8842_select_bank(adapter
, bank
);
168 iowrite32(value
, adapter
->hw_addr
+ offset
);
171 static inline u8
ks8842_read8(struct ks8842_adapter
*adapter
, u16 bank
,
174 ks8842_select_bank(adapter
, bank
);
175 return ioread8(adapter
->hw_addr
+ offset
);
178 static inline u16
ks8842_read16(struct ks8842_adapter
*adapter
, u16 bank
,
181 ks8842_select_bank(adapter
, bank
);
182 return ioread16(adapter
->hw_addr
+ offset
);
185 static inline u32
ks8842_read32(struct ks8842_adapter
*adapter
, u16 bank
,
188 ks8842_select_bank(adapter
, bank
);
189 return ioread32(adapter
->hw_addr
+ offset
);
192 static void ks8842_reset(struct ks8842_adapter
*adapter
)
194 /* The KS8842 goes haywire when doing softare reset
195 * a work around in the timberdale IP is implemented to
196 * do a hardware reset instead
197 ks8842_write16(adapter, 3, 1, REG_GRR);
199 iowrite16(0, adapter->hw_addr + REG_GRR);
201 iowrite16(32, adapter
->hw_addr
+ REG_SELECT_BANK
);
202 iowrite32(0x1, adapter
->hw_addr
+ REG_TIMB_RST
);
206 static void ks8842_update_link_status(struct net_device
*netdev
,
207 struct ks8842_adapter
*adapter
)
209 /* check the status of the link */
210 if (ks8842_read16(adapter
, 45, REG_P1MBSR
) & 0x4) {
211 netif_carrier_on(netdev
);
212 netif_wake_queue(netdev
);
214 netif_stop_queue(netdev
);
215 netif_carrier_off(netdev
);
219 static void ks8842_enable_tx(struct ks8842_adapter
*adapter
)
221 ks8842_enable_bits(adapter
, 16, 0x01, REG_TXCR
);
224 static void ks8842_disable_tx(struct ks8842_adapter
*adapter
)
226 ks8842_clear_bits(adapter
, 16, 0x01, REG_TXCR
);
229 static void ks8842_enable_rx(struct ks8842_adapter
*adapter
)
231 ks8842_enable_bits(adapter
, 16, 0x01, REG_RXCR
);
234 static void ks8842_disable_rx(struct ks8842_adapter
*adapter
)
236 ks8842_clear_bits(adapter
, 16, 0x01, REG_RXCR
);
239 static void ks8842_reset_hw(struct ks8842_adapter
*adapter
)
242 ks8842_reset(adapter
);
244 /* Enable QMU Transmit flow control / transmit padding / Transmit CRC */
245 ks8842_write16(adapter
, 16, 0x000E, REG_TXCR
);
247 /* enable the receiver, uni + multi + broadcast + flow ctrl
249 ks8842_write16(adapter
, 16, 0x8 | 0x20 | 0x40 | 0x80 | 0x400,
252 /* TX frame pointer autoincrement */
253 ks8842_write16(adapter
, 17, 0x4000, REG_TXFDPR
);
255 /* RX frame pointer autoincrement */
256 ks8842_write16(adapter
, 17, 0x4000, REG_RXFDPR
);
258 /* RX 2 kb high watermark */
259 ks8842_write16(adapter
, 0, 0x1000, REG_QRFCR
);
261 /* aggresive back off in half duplex */
262 ks8842_enable_bits(adapter
, 32, 1 << 8, REG_SGCR1
);
264 /* enable no excessive collison drop */
265 ks8842_enable_bits(adapter
, 32, 1 << 3, REG_SGCR2
);
267 /* Enable port 1 force flow control / back pressure / transmit / recv */
268 ks8842_write16(adapter
, 48, 0x1E07, REG_P1CR2
);
270 /* restart port auto-negotiation */
271 ks8842_enable_bits(adapter
, 49, 1 << 13, REG_P1CR4
);
272 /* only advertise 10Mbps */
273 ks8842_clear_bits(adapter
, 49, 3 << 2, REG_P1CR4
);
275 /* Enable the transmitter */
276 ks8842_enable_tx(adapter
);
278 /* Enable the receiver */
279 ks8842_enable_rx(adapter
);
281 /* clear all interrupts */
282 ks8842_write16(adapter
, 18, 0xffff, REG_ISR
);
284 /* enable interrupts */
285 ks8842_write16(adapter
, 18, ENABLED_IRQS
, REG_IER
);
287 /* enable the switch */
288 ks8842_write16(adapter
, 32, 0x1, REG_SW_ID_AND_ENABLE
);
291 static void ks8842_read_mac_addr(struct ks8842_adapter
*adapter
, u8
*dest
)
296 for (i
= 0; i
< ETH_ALEN
; i
++)
297 dest
[ETH_ALEN
- i
- 1] = ks8842_read8(adapter
, 2, REG_MARL
+ i
);
299 /* make sure the switch port uses the same MAC as the QMU */
300 mac
= ks8842_read16(adapter
, 2, REG_MARL
);
301 ks8842_write16(adapter
, 39, mac
, REG_MACAR1
);
302 mac
= ks8842_read16(adapter
, 2, REG_MARM
);
303 ks8842_write16(adapter
, 39, mac
, REG_MACAR2
);
304 mac
= ks8842_read16(adapter
, 2, REG_MARH
);
305 ks8842_write16(adapter
, 39, mac
, REG_MACAR3
);
308 static void ks8842_write_mac_addr(struct ks8842_adapter
*adapter
, u8
*mac
)
313 spin_lock_irqsave(&adapter
->lock
, flags
);
314 for (i
= 0; i
< ETH_ALEN
; i
++) {
315 ks8842_write8(adapter
, 2, mac
[ETH_ALEN
- i
- 1], REG_MARL
+ i
);
316 ks8842_write8(adapter
, 39, mac
[ETH_ALEN
- i
- 1],
319 spin_unlock_irqrestore(&adapter
->lock
, flags
);
322 static inline u16
ks8842_tx_fifo_space(struct ks8842_adapter
*adapter
)
324 return ks8842_read16(adapter
, 16, REG_TXMIR
) & 0x1fff;
327 static int ks8842_tx_frame(struct sk_buff
*skb
, struct net_device
*netdev
)
329 struct ks8842_adapter
*adapter
= netdev_priv(netdev
);
331 u32
*ptr
= (u32
*)skb
->data
;
334 dev_dbg(&adapter
->pdev
->dev
,
335 "%s: len %u head %p data %p tail %p end %p\n",
336 __func__
, skb
->len
, skb
->head
, skb
->data
,
337 skb_tail_pointer(skb
), skb_end_pointer(skb
));
339 /* check FIFO buffer space, we need space for CRC and command bits */
340 if (ks8842_tx_fifo_space(adapter
) < len
+ 8)
341 return NETDEV_TX_BUSY
;
343 /* the control word, enable IRQ, port 1 and the length */
344 ctrl
= 0x8000 | 0x100 | (len
<< 16);
345 ks8842_write32(adapter
, 17, ctrl
, REG_QMU_DATA_LO
);
347 netdev
->stats
.tx_bytes
+= len
;
351 iowrite32(*ptr
, adapter
->hw_addr
+ REG_QMU_DATA_LO
);
357 ks8842_write16(adapter
, 17, 1, REG_TXQCR
);
364 static void ks8842_rx_frame(struct net_device
*netdev
,
365 struct ks8842_adapter
*adapter
)
367 u32 status
= ks8842_read32(adapter
, 17, REG_QMU_DATA_LO
);
368 int len
= (status
>> 16) & 0x7ff;
372 dev_dbg(&adapter
->pdev
->dev
, "%s - rx_data: status: %x\n",
375 /* check the status */
376 if ((status
& RXSR_VALID
) && !(status
& RXSR_ERROR
)) {
377 struct sk_buff
*skb
= netdev_alloc_skb_ip_align(netdev
, len
);
379 dev_dbg(&adapter
->pdev
->dev
, "%s, got package, len: %d\n",
384 netdev
->stats
.rx_packets
++;
385 netdev
->stats
.rx_bytes
+= len
;
386 if (status
& RXSR_MULTICAST
)
387 netdev
->stats
.multicast
++;
389 data
= (u32
*)skb_put(skb
, len
);
391 ks8842_select_bank(adapter
, 17);
393 *data
++ = ioread32(adapter
->hw_addr
+
398 skb
->protocol
= eth_type_trans(skb
, netdev
);
401 netdev
->stats
.rx_dropped
++;
403 dev_dbg(&adapter
->pdev
->dev
, "RX error, status: %x\n", status
);
404 netdev
->stats
.rx_errors
++;
405 if (status
& RXSR_TOO_LONG
)
406 netdev
->stats
.rx_length_errors
++;
407 if (status
& RXSR_CRC_ERROR
)
408 netdev
->stats
.rx_crc_errors
++;
409 if (status
& RXSR_RUNT
)
410 netdev
->stats
.rx_frame_errors
++;
413 /* set high watermark to 3K */
414 ks8842_clear_bits(adapter
, 0, 1 << 12, REG_QRFCR
);
416 /* release the frame */
417 ks8842_write16(adapter
, 17, 0x01, REG_RXQCR
);
419 /* set high watermark to 2K */
420 ks8842_enable_bits(adapter
, 0, 1 << 12, REG_QRFCR
);
423 void ks8842_handle_rx(struct net_device
*netdev
, struct ks8842_adapter
*adapter
)
425 u16 rx_data
= ks8842_read16(adapter
, 16, REG_RXMIR
) & 0x1fff;
426 dev_dbg(&adapter
->pdev
->dev
, "%s Entry - rx_data: %d\n",
429 ks8842_rx_frame(netdev
, adapter
);
430 rx_data
= ks8842_read16(adapter
, 16, REG_RXMIR
) & 0x1fff;
434 void ks8842_handle_tx(struct net_device
*netdev
, struct ks8842_adapter
*adapter
)
436 u16 sr
= ks8842_read16(adapter
, 16, REG_TXSR
);
437 dev_dbg(&adapter
->pdev
->dev
, "%s - entry, sr: %x\n", __func__
, sr
);
438 netdev
->stats
.tx_packets
++;
439 if (netif_queue_stopped(netdev
))
440 netif_wake_queue(netdev
);
443 void ks8842_handle_rx_overrun(struct net_device
*netdev
,
444 struct ks8842_adapter
*adapter
)
446 dev_dbg(&adapter
->pdev
->dev
, "%s: entry\n", __func__
);
447 netdev
->stats
.rx_errors
++;
448 netdev
->stats
.rx_fifo_errors
++;
451 void ks8842_tasklet(unsigned long arg
)
453 struct net_device
*netdev
= (struct net_device
*)arg
;
454 struct ks8842_adapter
*adapter
= netdev_priv(netdev
);
459 /* read current bank to be able to set it back */
460 spin_lock_irqsave(&adapter
->lock
, flags
);
461 entry_bank
= ioread16(adapter
->hw_addr
+ REG_SELECT_BANK
);
462 spin_unlock_irqrestore(&adapter
->lock
, flags
);
464 isr
= ks8842_read16(adapter
, 18, REG_ISR
);
465 dev_dbg(&adapter
->pdev
->dev
, "%s - ISR: 0x%x\n", __func__
, isr
);
468 ks8842_write16(adapter
, 18, isr
, REG_ISR
);
470 if (!netif_running(netdev
))
473 if (isr
& IRQ_LINK_CHANGE
)
474 ks8842_update_link_status(netdev
, adapter
);
476 if (isr
& (IRQ_RX
| IRQ_RX_ERROR
))
477 ks8842_handle_rx(netdev
, adapter
);
480 ks8842_handle_tx(netdev
, adapter
);
482 if (isr
& IRQ_RX_OVERRUN
)
483 ks8842_handle_rx_overrun(netdev
, adapter
);
485 if (isr
& IRQ_TX_STOPPED
) {
486 ks8842_disable_tx(adapter
);
487 ks8842_enable_tx(adapter
);
490 if (isr
& IRQ_RX_STOPPED
) {
491 ks8842_disable_rx(adapter
);
492 ks8842_enable_rx(adapter
);
495 /* re-enable interrupts, put back the bank selection register */
496 spin_lock_irqsave(&adapter
->lock
, flags
);
497 ks8842_write16(adapter
, 18, ENABLED_IRQS
, REG_IER
);
498 iowrite16(entry_bank
, adapter
->hw_addr
+ REG_SELECT_BANK
);
499 spin_unlock_irqrestore(&adapter
->lock
, flags
);
502 static irqreturn_t
ks8842_irq(int irq
, void *devid
)
504 struct ks8842_adapter
*adapter
= devid
;
506 u16 entry_bank
= ioread16(adapter
->hw_addr
+ REG_SELECT_BANK
);
507 irqreturn_t ret
= IRQ_NONE
;
509 isr
= ks8842_read16(adapter
, 18, REG_ISR
);
510 dev_dbg(&adapter
->pdev
->dev
, "%s - ISR: 0x%x\n", __func__
, isr
);
514 ks8842_write16(adapter
, 18, 0x00, REG_IER
);
516 /* schedule tasklet */
517 tasklet_schedule(&adapter
->tasklet
);
522 iowrite16(entry_bank
, adapter
->hw_addr
+ REG_SELECT_BANK
);
528 /* Netdevice operations */
530 static int ks8842_open(struct net_device
*netdev
)
532 struct ks8842_adapter
*adapter
= netdev_priv(netdev
);
535 dev_dbg(&adapter
->pdev
->dev
, "%s - entry\n", __func__
);
538 ks8842_reset_hw(adapter
);
540 ks8842_write_mac_addr(adapter
, netdev
->dev_addr
);
542 ks8842_update_link_status(netdev
, adapter
);
544 err
= request_irq(adapter
->irq
, ks8842_irq
, IRQF_SHARED
, DRV_NAME
,
547 pr_err("Failed to request IRQ: %d: %d\n", adapter
->irq
, err
);
554 static int ks8842_close(struct net_device
*netdev
)
556 struct ks8842_adapter
*adapter
= netdev_priv(netdev
);
558 dev_dbg(&adapter
->pdev
->dev
, "%s - entry\n", __func__
);
561 free_irq(adapter
->irq
, adapter
);
563 /* disable the switch */
564 ks8842_write16(adapter
, 32, 0x0, REG_SW_ID_AND_ENABLE
);
569 static netdev_tx_t
ks8842_xmit_frame(struct sk_buff
*skb
,
570 struct net_device
*netdev
)
573 struct ks8842_adapter
*adapter
= netdev_priv(netdev
);
575 dev_dbg(&adapter
->pdev
->dev
, "%s: entry\n", __func__
);
577 ret
= ks8842_tx_frame(skb
, netdev
);
579 if (ks8842_tx_fifo_space(adapter
) < netdev
->mtu
+ 8)
580 netif_stop_queue(netdev
);
585 static int ks8842_set_mac(struct net_device
*netdev
, void *p
)
587 struct ks8842_adapter
*adapter
= netdev_priv(netdev
);
588 struct sockaddr
*addr
= p
;
589 char *mac
= (u8
*)addr
->sa_data
;
591 dev_dbg(&adapter
->pdev
->dev
, "%s: entry\n", __func__
);
593 if (!is_valid_ether_addr(addr
->sa_data
))
594 return -EADDRNOTAVAIL
;
596 memcpy(netdev
->dev_addr
, mac
, netdev
->addr_len
);
598 ks8842_write_mac_addr(adapter
, mac
);
602 static void ks8842_tx_timeout(struct net_device
*netdev
)
604 struct ks8842_adapter
*adapter
= netdev_priv(netdev
);
607 dev_dbg(&adapter
->pdev
->dev
, "%s: entry\n", __func__
);
609 spin_lock_irqsave(&adapter
->lock
, flags
);
610 /* disable interrupts */
611 ks8842_write16(adapter
, 18, 0, REG_IER
);
612 ks8842_write16(adapter
, 18, 0xFFFF, REG_ISR
);
613 spin_unlock_irqrestore(&adapter
->lock
, flags
);
615 ks8842_reset_hw(adapter
);
617 ks8842_write_mac_addr(adapter
, netdev
->dev_addr
);
619 ks8842_update_link_status(netdev
, adapter
);
622 static const struct net_device_ops ks8842_netdev_ops
= {
623 .ndo_open
= ks8842_open
,
624 .ndo_stop
= ks8842_close
,
625 .ndo_start_xmit
= ks8842_xmit_frame
,
626 .ndo_set_mac_address
= ks8842_set_mac
,
627 .ndo_tx_timeout
= ks8842_tx_timeout
,
628 .ndo_validate_addr
= eth_validate_addr
631 static const struct ethtool_ops ks8842_ethtool_ops
= {
632 .get_link
= ethtool_op_get_link
,
635 static int __devinit
ks8842_probe(struct platform_device
*pdev
)
638 struct resource
*iomem
;
639 struct net_device
*netdev
;
640 struct ks8842_adapter
*adapter
;
641 struct ks8842_platform_data
*pdata
= pdev
->dev
.platform_data
;
645 iomem
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
646 if (!request_mem_region(iomem
->start
, resource_size(iomem
), DRV_NAME
))
649 netdev
= alloc_etherdev(sizeof(struct ks8842_adapter
));
651 goto err_alloc_etherdev
;
653 SET_NETDEV_DEV(netdev
, &pdev
->dev
);
655 adapter
= netdev_priv(netdev
);
656 adapter
->hw_addr
= ioremap(iomem
->start
, resource_size(iomem
));
657 if (!adapter
->hw_addr
)
660 adapter
->irq
= platform_get_irq(pdev
, 0);
661 if (adapter
->irq
< 0) {
666 adapter
->pdev
= pdev
;
668 tasklet_init(&adapter
->tasklet
, ks8842_tasklet
, (unsigned long)netdev
);
669 spin_lock_init(&adapter
->lock
);
671 netdev
->netdev_ops
= &ks8842_netdev_ops
;
672 netdev
->ethtool_ops
= &ks8842_ethtool_ops
;
674 /* Check if a mac address was given */
675 i
= netdev
->addr_len
;
677 for (i
= 0; i
< netdev
->addr_len
; i
++)
678 if (pdata
->macaddr
[i
] != 0)
681 if (i
< netdev
->addr_len
)
682 /* an address was passed, use it */
683 memcpy(netdev
->dev_addr
, pdata
->macaddr
,
687 if (i
== netdev
->addr_len
) {
688 ks8842_read_mac_addr(adapter
, netdev
->dev_addr
);
690 if (!is_valid_ether_addr(netdev
->dev_addr
))
691 random_ether_addr(netdev
->dev_addr
);
694 id
= ks8842_read16(adapter
, 32, REG_SW_ID_AND_ENABLE
);
696 strcpy(netdev
->name
, "eth%d");
697 err
= register_netdev(netdev
);
701 platform_set_drvdata(pdev
, netdev
);
703 pr_info("Found chip, family: 0x%x, id: 0x%x, rev: 0x%x\n",
704 (id
>> 8) & 0xff, (id
>> 4) & 0xf, (id
>> 1) & 0x7);
710 iounmap(adapter
->hw_addr
);
714 release_mem_region(iomem
->start
, resource_size(iomem
));
719 static int __devexit
ks8842_remove(struct platform_device
*pdev
)
721 struct net_device
*netdev
= platform_get_drvdata(pdev
);
722 struct ks8842_adapter
*adapter
= netdev_priv(netdev
);
723 struct resource
*iomem
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
725 unregister_netdev(netdev
);
726 tasklet_kill(&adapter
->tasklet
);
727 iounmap(adapter
->hw_addr
);
729 release_mem_region(iomem
->start
, resource_size(iomem
));
730 platform_set_drvdata(pdev
, NULL
);
735 static struct platform_driver ks8842_platform_driver
= {
738 .owner
= THIS_MODULE
,
740 .probe
= ks8842_probe
,
741 .remove
= ks8842_remove
,
744 static int __init
ks8842_init(void)
746 return platform_driver_register(&ks8842_platform_driver
);
749 static void __exit
ks8842_exit(void)
751 platform_driver_unregister(&ks8842_platform_driver
);
754 module_init(ks8842_init
);
755 module_exit(ks8842_exit
);
757 MODULE_DESCRIPTION("Timberdale KS8842 ethernet driver");
758 MODULE_AUTHOR("Mocean Laboratories <info@mocean-labs.com>");
759 MODULE_LICENSE("GPL v2");
760 MODULE_ALIAS("platform:ks8842");