blob: cc773662d9f970aa2f0431fd8526fca23fd2d94a [file] [log] [blame]
Andrew Victord4b77802006-03-24 11:50:17 +02001/*
2 * Ethernet driver for the Atmel AT91RM9200 (Thunder)
3 *
4 * Copyright (C) 2003 SAN People (Pty) Ltd
5 *
6 * Based on an earlier Atmel EMAC macrocell driver by Atmel and Lineo Inc.
7 * Initial version by Rick Bronson 01/11/2003
8 *
9 * Intel LXT971A PHY support by Christopher Bahns & David Knickerbocker
10 * (Polaroid Corporation)
11 *
12 * Realtek RTL8201(B)L PHY support by Roman Avramenko <roman@imsystems.ru>
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version
17 * 2 of the License, or (at your option) any later version.
18 */
19
20#include <linux/module.h>
21#include <linux/init.h>
22#include <linux/config.h>
23#include <linux/mii.h>
24#include <linux/netdevice.h>
25#include <linux/etherdevice.h>
26#include <linux/skbuff.h>
27#include <linux/dma-mapping.h>
28#include <linux/ethtool.h>
29#include <linux/platform_device.h>
30#include <linux/clk.h>
31
32#include <asm/io.h>
33#include <asm/uaccess.h>
34#include <asm/mach-types.h>
35
36#include <asm/arch/at91rm9200_emac.h>
37#include <asm/arch/gpio.h>
38#include <asm/arch/board.h>
39
40#include "at91_ether.h"
41
42#define DRV_NAME "at91_ether"
43#define DRV_VERSION "1.0"
44
45static struct net_device *at91_dev;
46static struct clk *ether_clk;
47
Andrew Victor775637d2006-06-20 11:50:23 +020048static struct timer_list check_timer;
49#define LINK_POLL_INTERVAL (HZ)
50
Andrew Victord4b77802006-03-24 11:50:17 +020051/* ..................................................................... */
52
53/*
54 * Read from a EMAC register.
55 */
56static inline unsigned long at91_emac_read(unsigned int reg)
57{
58 void __iomem *emac_base = (void __iomem *)AT91_VA_BASE_EMAC;
59
60 return __raw_readl(emac_base + reg);
61}
62
63/*
64 * Write to a EMAC register.
65 */
66static inline void at91_emac_write(unsigned int reg, unsigned long value)
67{
68 void __iomem *emac_base = (void __iomem *)AT91_VA_BASE_EMAC;
69
70 __raw_writel(value, emac_base + reg);
71}
72
73/* ........................... PHY INTERFACE ........................... */
74
75/*
76 * Enable the MDIO bit in MAC control register
77 * When not called from an interrupt-handler, access to the PHY must be
78 * protected by a spinlock.
79 */
80static void enable_mdi(void)
81{
82 unsigned long ctl;
83
84 ctl = at91_emac_read(AT91_EMAC_CTL);
85 at91_emac_write(AT91_EMAC_CTL, ctl | AT91_EMAC_MPE); /* enable management port */
86}
87
88/*
89 * Disable the MDIO bit in the MAC control register
90 */
91static void disable_mdi(void)
92{
93 unsigned long ctl;
94
95 ctl = at91_emac_read(AT91_EMAC_CTL);
96 at91_emac_write(AT91_EMAC_CTL, ctl & ~AT91_EMAC_MPE); /* disable management port */
97}
98
99/*
100 * Wait until the PHY operation is complete.
101 */
102static inline void at91_phy_wait(void) {
103 unsigned long timeout = jiffies + 2;
104
105 while (!(at91_emac_read(AT91_EMAC_SR) & AT91_EMAC_SR_IDLE)) {
106 if (time_after(jiffies, timeout)) {
107 printk("at91_ether: MIO timeout\n");
108 break;
109 }
110 cpu_relax();
111 }
112}
113
114/*
115 * Write value to the a PHY register
116 * Note: MDI interface is assumed to already have been enabled.
117 */
118static void write_phy(unsigned char phy_addr, unsigned char address, unsigned int value)
119{
120 at91_emac_write(AT91_EMAC_MAN, AT91_EMAC_MAN_802_3 | AT91_EMAC_RW_W
121 | ((phy_addr & 0x1f) << 23) | (address << 18) | (value & AT91_EMAC_DATA));
122
123 /* Wait until IDLE bit in Network Status register is cleared */
124 at91_phy_wait();
125}
126
127/*
128 * Read value stored in a PHY register.
129 * Note: MDI interface is assumed to already have been enabled.
130 */
131static void read_phy(unsigned char phy_addr, unsigned char address, unsigned int *value)
132{
133 at91_emac_write(AT91_EMAC_MAN, AT91_EMAC_MAN_802_3 | AT91_EMAC_RW_R
134 | ((phy_addr & 0x1f) << 23) | (address << 18));
135
136 /* Wait until IDLE bit in Network Status register is cleared */
137 at91_phy_wait();
138
139 *value = at91_emac_read(AT91_EMAC_MAN) & AT91_EMAC_DATA;
140}
141
142/* ........................... PHY MANAGEMENT .......................... */
143
144/*
145 * Access the PHY to determine the current link speed and mode, and update the
146 * MAC accordingly.
147 * If no link or auto-negotiation is busy, then no changes are made.
148 */
Andrew Victor775637d2006-06-20 11:50:23 +0200149static void update_linkspeed(struct net_device *dev, int silent)
Andrew Victord4b77802006-03-24 11:50:17 +0200150{
151 struct at91_private *lp = (struct at91_private *) dev->priv;
152 unsigned int bmsr, bmcr, lpa, mac_cfg;
153 unsigned int speed, duplex;
154
155 if (!mii_link_ok(&lp->mii)) { /* no link */
156 netif_carrier_off(dev);
Andrew Victor775637d2006-06-20 11:50:23 +0200157 if (!silent)
158 printk(KERN_INFO "%s: Link down.\n", dev->name);
Andrew Victord4b77802006-03-24 11:50:17 +0200159 return;
160 }
161
162 /* Link up, or auto-negotiation still in progress */
163 read_phy(lp->phy_address, MII_BMSR, &bmsr);
164 read_phy(lp->phy_address, MII_BMCR, &bmcr);
165 if (bmcr & BMCR_ANENABLE) { /* AutoNegotiation is enabled */
166 if (!(bmsr & BMSR_ANEGCOMPLETE))
167 return; /* Do nothing - another interrupt generated when negotiation complete */
168
169 read_phy(lp->phy_address, MII_LPA, &lpa);
170 if ((lpa & LPA_100FULL) || (lpa & LPA_100HALF)) speed = SPEED_100;
171 else speed = SPEED_10;
172 if ((lpa & LPA_100FULL) || (lpa & LPA_10FULL)) duplex = DUPLEX_FULL;
173 else duplex = DUPLEX_HALF;
174 } else {
175 speed = (bmcr & BMCR_SPEED100) ? SPEED_100 : SPEED_10;
176 duplex = (bmcr & BMCR_FULLDPLX) ? DUPLEX_FULL : DUPLEX_HALF;
177 }
178
179 /* Update the MAC */
180 mac_cfg = at91_emac_read(AT91_EMAC_CFG) & ~(AT91_EMAC_SPD | AT91_EMAC_FD);
181 if (speed == SPEED_100) {
182 if (duplex == DUPLEX_FULL) /* 100 Full Duplex */
183 mac_cfg |= AT91_EMAC_SPD | AT91_EMAC_FD;
184 else /* 100 Half Duplex */
185 mac_cfg |= AT91_EMAC_SPD;
186 } else {
187 if (duplex == DUPLEX_FULL) /* 10 Full Duplex */
188 mac_cfg |= AT91_EMAC_FD;
189 else {} /* 10 Half Duplex */
190 }
191 at91_emac_write(AT91_EMAC_CFG, mac_cfg);
192
Andrew Victor775637d2006-06-20 11:50:23 +0200193 if (!silent)
194 printk(KERN_INFO "%s: Link now %i-%s\n", dev->name, speed, (duplex == DUPLEX_FULL) ? "FullDuplex" : "HalfDuplex");
Andrew Victord4b77802006-03-24 11:50:17 +0200195 netif_carrier_on(dev);
196}
197
198/*
199 * Handle interrupts from the PHY
200 */
201static irqreturn_t at91ether_phy_interrupt(int irq, void *dev_id, struct pt_regs *regs)
202{
203 struct net_device *dev = (struct net_device *) dev_id;
204 struct at91_private *lp = (struct at91_private *) dev->priv;
205 unsigned int phy;
206
207 /*
208 * This hander is triggered on both edges, but the PHY chips expect
209 * level-triggering. We therefore have to check if the PHY actually has
210 * an IRQ pending.
211 */
212 enable_mdi();
213 if ((lp->phy_type == MII_DM9161_ID) || (lp->phy_type == MII_DM9161A_ID)) {
214 read_phy(lp->phy_address, MII_DSINTR_REG, &phy); /* ack interrupt in Davicom PHY */
215 if (!(phy & (1 << 0)))
216 goto done;
217 }
218 else if (lp->phy_type == MII_LXT971A_ID) {
219 read_phy(lp->phy_address, MII_ISINTS_REG, &phy); /* ack interrupt in Intel PHY */
220 if (!(phy & (1 << 2)))
221 goto done;
222 }
223 else if (lp->phy_type == MII_BCM5221_ID) {
224 read_phy(lp->phy_address, MII_BCMINTR_REG, &phy); /* ack interrupt in Broadcom PHY */
225 if (!(phy & (1 << 0)))
226 goto done;
227 }
228 else if (lp->phy_type == MII_KS8721_ID) {
229 read_phy(lp->phy_address, MII_TPISTATUS, &phy); /* ack interrupt in Micrel PHY */
230 if (!(phy & ((1 << 2) | 1)))
231 goto done;
232 }
233
Andrew Victor775637d2006-06-20 11:50:23 +0200234 update_linkspeed(dev, 0);
Andrew Victord4b77802006-03-24 11:50:17 +0200235
236done:
237 disable_mdi();
238
239 return IRQ_HANDLED;
240}
241
242/*
243 * Initialize and enable the PHY interrupt for link-state changes
244 */
245static void enable_phyirq(struct net_device *dev)
246{
247 struct at91_private *lp = (struct at91_private *) dev->priv;
248 unsigned int dsintr, irq_number;
249 int status;
250
Andrew Victord4b77802006-03-24 11:50:17 +0200251 irq_number = lp->board_data.phy_irq_pin;
Andrew Victor775637d2006-06-20 11:50:23 +0200252 if (!irq_number) {
253 /*
254 * PHY doesn't have an IRQ pin (RTL8201, DP83847, AC101L),
255 * or board does not have it connected.
256 */
257 check_timer.expires = jiffies + LINK_POLL_INTERVAL;
258 add_timer(&check_timer);
259 return;
260 }
261
Andrew Victord4b77802006-03-24 11:50:17 +0200262 status = request_irq(irq_number, at91ether_phy_interrupt, 0, dev->name, dev);
263 if (status) {
264 printk(KERN_ERR "at91_ether: PHY IRQ %d request failed - status %d!\n", irq_number, status);
265 return;
266 }
267
268 spin_lock_irq(&lp->lock);
269 enable_mdi();
270
271 if ((lp->phy_type == MII_DM9161_ID) || (lp->phy_type == MII_DM9161A_ID)) { /* for Davicom PHY */
272 read_phy(lp->phy_address, MII_DSINTR_REG, &dsintr);
273 dsintr = dsintr & ~0xf00; /* clear bits 8..11 */
274 write_phy(lp->phy_address, MII_DSINTR_REG, dsintr);
275 }
276 else if (lp->phy_type == MII_LXT971A_ID) { /* for Intel PHY */
277 read_phy(lp->phy_address, MII_ISINTE_REG, &dsintr);
278 dsintr = dsintr | 0xf2; /* set bits 1, 4..7 */
279 write_phy(lp->phy_address, MII_ISINTE_REG, dsintr);
280 }
281 else if (lp->phy_type == MII_BCM5221_ID) { /* for Broadcom PHY */
282 dsintr = (1 << 15) | ( 1 << 14);
283 write_phy(lp->phy_address, MII_BCMINTR_REG, dsintr);
284 }
285 else if (lp->phy_type == MII_KS8721_ID) { /* for Micrel PHY */
286 dsintr = (1 << 10) | ( 1 << 8);
287 write_phy(lp->phy_address, MII_TPISTATUS, dsintr);
288 }
289
290 disable_mdi();
291 spin_unlock_irq(&lp->lock);
292}
293
294/*
295 * Disable the PHY interrupt
296 */
297static void disable_phyirq(struct net_device *dev)
298{
299 struct at91_private *lp = (struct at91_private *) dev->priv;
300 unsigned int dsintr;
301 unsigned int irq_number;
302
Andrew Victor775637d2006-06-20 11:50:23 +0200303 irq_number = lp->board_data.phy_irq_pin;
304 if (!irq_number) {
305 del_timer_sync(&check_timer);
Andrew Victord4b77802006-03-24 11:50:17 +0200306 return;
Andrew Victor775637d2006-06-20 11:50:23 +0200307 }
Andrew Victord4b77802006-03-24 11:50:17 +0200308
309 spin_lock_irq(&lp->lock);
310 enable_mdi();
311
312 if ((lp->phy_type == MII_DM9161_ID) || (lp->phy_type == MII_DM9161A_ID)) { /* for Davicom PHY */
313 read_phy(lp->phy_address, MII_DSINTR_REG, &dsintr);
314 dsintr = dsintr | 0xf00; /* set bits 8..11 */
315 write_phy(lp->phy_address, MII_DSINTR_REG, dsintr);
316 }
317 else if (lp->phy_type == MII_LXT971A_ID) { /* for Intel PHY */
318 read_phy(lp->phy_address, MII_ISINTE_REG, &dsintr);
319 dsintr = dsintr & ~0xf2; /* clear bits 1, 4..7 */
320 write_phy(lp->phy_address, MII_ISINTE_REG, dsintr);
321 }
322 else if (lp->phy_type == MII_BCM5221_ID) { /* for Broadcom PHY */
323 read_phy(lp->phy_address, MII_BCMINTR_REG, &dsintr);
324 dsintr = ~(1 << 14);
325 write_phy(lp->phy_address, MII_BCMINTR_REG, dsintr);
326 }
327 else if (lp->phy_type == MII_KS8721_ID) { /* for Micrel PHY */
328 read_phy(lp->phy_address, MII_TPISTATUS, &dsintr);
329 dsintr = ~((1 << 10) | (1 << 8));
330 write_phy(lp->phy_address, MII_TPISTATUS, dsintr);
331 }
332
333 disable_mdi();
334 spin_unlock_irq(&lp->lock);
335
Andrew Victord4b77802006-03-24 11:50:17 +0200336 free_irq(irq_number, dev); /* Free interrupt handler */
337}
338
339/*
340 * Perform a software reset of the PHY.
341 */
342#if 0
343static void reset_phy(struct net_device *dev)
344{
345 struct at91_private *lp = (struct at91_private *) dev->priv;
346 unsigned int bmcr;
347
348 spin_lock_irq(&lp->lock);
349 enable_mdi();
350
351 /* Perform PHY reset */
352 write_phy(lp->phy_address, MII_BMCR, BMCR_RESET);
353
354 /* Wait until PHY reset is complete */
355 do {
356 read_phy(lp->phy_address, MII_BMCR, &bmcr);
357 } while (!(bmcr && BMCR_RESET));
358
359 disable_mdi();
360 spin_unlock_irq(&lp->lock);
361}
362#endif
363
Andrew Victor775637d2006-06-20 11:50:23 +0200364static void at91ether_check_link(unsigned long dev_id)
365{
366 struct net_device *dev = (struct net_device *) dev_id;
367
368 enable_mdi();
369 update_linkspeed(dev, 1);
370 disable_mdi();
371
372 check_timer.expires = jiffies + LINK_POLL_INTERVAL;
373 add_timer(&check_timer);
374}
375
Andrew Victord4b77802006-03-24 11:50:17 +0200376/* ......................... ADDRESS MANAGEMENT ........................ */
377
378/*
379 * NOTE: Your bootloader must always set the MAC address correctly before
380 * booting into Linux.
381 *
382 * - It must always set the MAC address after reset, even if it doesn't
383 * happen to access the Ethernet while it's booting. Some versions of
384 * U-Boot on the AT91RM9200-DK do not do this.
385 *
386 * - Likewise it must store the addresses in the correct byte order.
387 * MicroMonitor (uMon) on the CSB337 does this incorrectly (and
388 * continues to do so, for bug-compatibility).
389 */
390
391static short __init unpack_mac_address(struct net_device *dev, unsigned int hi, unsigned int lo)
392{
393 char addr[6];
394
395 if (machine_is_csb337()) {
396 addr[5] = (lo & 0xff); /* The CSB337 bootloader stores the MAC the wrong-way around */
397 addr[4] = (lo & 0xff00) >> 8;
398 addr[3] = (lo & 0xff0000) >> 16;
399 addr[2] = (lo & 0xff000000) >> 24;
400 addr[1] = (hi & 0xff);
401 addr[0] = (hi & 0xff00) >> 8;
402 }
403 else {
404 addr[0] = (lo & 0xff);
405 addr[1] = (lo & 0xff00) >> 8;
406 addr[2] = (lo & 0xff0000) >> 16;
407 addr[3] = (lo & 0xff000000) >> 24;
408 addr[4] = (hi & 0xff);
409 addr[5] = (hi & 0xff00) >> 8;
410 }
411
412 if (is_valid_ether_addr(addr)) {
413 memcpy(dev->dev_addr, &addr, 6);
414 return 1;
415 }
416 return 0;
417}
418
419/*
420 * Set the ethernet MAC address in dev->dev_addr
421 */
422static void __init get_mac_address(struct net_device *dev)
423{
424 /* Check Specific-Address 1 */
425 if (unpack_mac_address(dev, at91_emac_read(AT91_EMAC_SA1H), at91_emac_read(AT91_EMAC_SA1L)))
426 return;
427 /* Check Specific-Address 2 */
428 if (unpack_mac_address(dev, at91_emac_read(AT91_EMAC_SA2H), at91_emac_read(AT91_EMAC_SA2L)))
429 return;
430 /* Check Specific-Address 3 */
431 if (unpack_mac_address(dev, at91_emac_read(AT91_EMAC_SA3H), at91_emac_read(AT91_EMAC_SA3L)))
432 return;
433 /* Check Specific-Address 4 */
434 if (unpack_mac_address(dev, at91_emac_read(AT91_EMAC_SA4H), at91_emac_read(AT91_EMAC_SA4L)))
435 return;
436
437 printk(KERN_ERR "at91_ether: Your bootloader did not configure a MAC address.\n");
438}
439
440/*
441 * Program the hardware MAC address from dev->dev_addr.
442 */
443static void update_mac_address(struct net_device *dev)
444{
445 at91_emac_write(AT91_EMAC_SA1L, (dev->dev_addr[3] << 24) | (dev->dev_addr[2] << 16) | (dev->dev_addr[1] << 8) | (dev->dev_addr[0]));
446 at91_emac_write(AT91_EMAC_SA1H, (dev->dev_addr[5] << 8) | (dev->dev_addr[4]));
447
448 at91_emac_write(AT91_EMAC_SA2L, 0);
449 at91_emac_write(AT91_EMAC_SA2H, 0);
450}
451
452/*
453 * Store the new hardware address in dev->dev_addr, and update the MAC.
454 */
455static int set_mac_address(struct net_device *dev, void* addr)
456{
457 struct sockaddr *address = addr;
458
459 if (!is_valid_ether_addr(address->sa_data))
460 return -EADDRNOTAVAIL;
461
462 memcpy(dev->dev_addr, address->sa_data, dev->addr_len);
463 update_mac_address(dev);
464
465 printk("%s: Setting MAC address to %02x:%02x:%02x:%02x:%02x:%02x\n", dev->name,
466 dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2],
467 dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]);
468
469 return 0;
470}
471
472static int inline hash_bit_value(int bitnr, __u8 *addr)
473{
474 if (addr[bitnr / 8] & (1 << (bitnr % 8)))
475 return 1;
476 return 0;
477}
478
479/*
480 * The hash address register is 64 bits long and takes up two locations in the memory map.
481 * The least significant bits are stored in EMAC_HSL and the most significant
482 * bits in EMAC_HSH.
483 *
484 * The unicast hash enable and the multicast hash enable bits in the network configuration
485 * register enable the reception of hash matched frames. The destination address is
486 * reduced to a 6 bit index into the 64 bit hash register using the following hash function.
487 * The hash function is an exclusive or of every sixth bit of the destination address.
488 * hash_index[5] = da[5] ^ da[11] ^ da[17] ^ da[23] ^ da[29] ^ da[35] ^ da[41] ^ da[47]
489 * hash_index[4] = da[4] ^ da[10] ^ da[16] ^ da[22] ^ da[28] ^ da[34] ^ da[40] ^ da[46]
490 * hash_index[3] = da[3] ^ da[09] ^ da[15] ^ da[21] ^ da[27] ^ da[33] ^ da[39] ^ da[45]
491 * hash_index[2] = da[2] ^ da[08] ^ da[14] ^ da[20] ^ da[26] ^ da[32] ^ da[38] ^ da[44]
492 * hash_index[1] = da[1] ^ da[07] ^ da[13] ^ da[19] ^ da[25] ^ da[31] ^ da[37] ^ da[43]
493 * hash_index[0] = da[0] ^ da[06] ^ da[12] ^ da[18] ^ da[24] ^ da[30] ^ da[36] ^ da[42]
494 * da[0] represents the least significant bit of the first byte received, that is, the multicast/
495 * unicast indicator, and da[47] represents the most significant bit of the last byte
496 * received.
497 * If the hash index points to a bit that is set in the hash register then the frame will be
498 * matched according to whether the frame is multicast or unicast.
499 * A multicast match will be signalled if the multicast hash enable bit is set, da[0] is 1 and
500 * the hash index points to a bit set in the hash register.
501 * A unicast match will be signalled if the unicast hash enable bit is set, da[0] is 0 and the
502 * hash index points to a bit set in the hash register.
503 * To receive all multicast frames, the hash register should be set with all ones and the
504 * multicast hash enable bit should be set in the network configuration register.
505 */
506
507/*
508 * Return the hash index value for the specified address.
509 */
510static int hash_get_index(__u8 *addr)
511{
512 int i, j, bitval;
513 int hash_index = 0;
514
515 for (j = 0; j < 6; j++) {
516 for (i = 0, bitval = 0; i < 8; i++)
517 bitval ^= hash_bit_value(i*6 + j, addr);
518
519 hash_index |= (bitval << j);
520 }
521
522 return hash_index;
523}
524
525/*
526 * Add multicast addresses to the internal multicast-hash table.
527 */
528static void at91ether_sethashtable(struct net_device *dev)
529{
530 struct dev_mc_list *curr;
531 unsigned long mc_filter[2];
532 unsigned int i, bitnr;
533
534 mc_filter[0] = mc_filter[1] = 0;
535
536 curr = dev->mc_list;
537 for (i = 0; i < dev->mc_count; i++, curr = curr->next) {
538 if (!curr) break; /* unexpected end of list */
539
540 bitnr = hash_get_index(curr->dmi_addr);
541 mc_filter[bitnr >> 5] |= 1 << (bitnr & 31);
542 }
543
544 at91_emac_write(AT91_EMAC_HSH, mc_filter[0]);
545 at91_emac_write(AT91_EMAC_HSL, mc_filter[1]);
546}
547
548/*
549 * Enable/Disable promiscuous and multicast modes.
550 */
551static void at91ether_set_rx_mode(struct net_device *dev)
552{
553 unsigned long cfg;
554
555 cfg = at91_emac_read(AT91_EMAC_CFG);
556
557 if (dev->flags & IFF_PROMISC) /* Enable promiscuous mode */
558 cfg |= AT91_EMAC_CAF;
559 else if (dev->flags & (~IFF_PROMISC)) /* Disable promiscuous mode */
560 cfg &= ~AT91_EMAC_CAF;
561
562 if (dev->flags & IFF_ALLMULTI) { /* Enable all multicast mode */
563 at91_emac_write(AT91_EMAC_HSH, -1);
564 at91_emac_write(AT91_EMAC_HSL, -1);
565 cfg |= AT91_EMAC_MTI;
566 } else if (dev->mc_count > 0) { /* Enable specific multicasts */
567 at91ether_sethashtable(dev);
568 cfg |= AT91_EMAC_MTI;
569 } else if (dev->flags & (~IFF_ALLMULTI)) { /* Disable all multicast mode */
570 at91_emac_write(AT91_EMAC_HSH, 0);
571 at91_emac_write(AT91_EMAC_HSL, 0);
572 cfg &= ~AT91_EMAC_MTI;
573 }
574
575 at91_emac_write(AT91_EMAC_CFG, cfg);
576}
577
578
579/* ......................... ETHTOOL SUPPORT ........................... */
580
581
582static int mdio_read(struct net_device *dev, int phy_id, int location)
583{
584 unsigned int value;
585
586 read_phy(phy_id, location, &value);
587 return value;
588}
589
590static void mdio_write(struct net_device *dev, int phy_id, int location, int value)
591{
592 write_phy(phy_id, location, value);
593}
594
595static int at91ether_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
596{
597 struct at91_private *lp = (struct at91_private *) dev->priv;
598 int ret;
599
600 spin_lock_irq(&lp->lock);
601 enable_mdi();
602
603 ret = mii_ethtool_gset(&lp->mii, cmd);
604
605 disable_mdi();
606 spin_unlock_irq(&lp->lock);
607
608 if (lp->phy_media == PORT_FIBRE) { /* override media type since mii.c doesn't know */
609 cmd->supported = SUPPORTED_FIBRE;
610 cmd->port = PORT_FIBRE;
611 }
612
613 return ret;
614}
615
616static int at91ether_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
617{
618 struct at91_private *lp = (struct at91_private *) dev->priv;
619 int ret;
620
621 spin_lock_irq(&lp->lock);
622 enable_mdi();
623
624 ret = mii_ethtool_sset(&lp->mii, cmd);
625
626 disable_mdi();
627 spin_unlock_irq(&lp->lock);
628
629 return ret;
630}
631
632static int at91ether_nwayreset(struct net_device *dev)
633{
634 struct at91_private *lp = (struct at91_private *) dev->priv;
635 int ret;
636
637 spin_lock_irq(&lp->lock);
638 enable_mdi();
639
640 ret = mii_nway_restart(&lp->mii);
641
642 disable_mdi();
643 spin_unlock_irq(&lp->lock);
644
645 return ret;
646}
647
648static void at91ether_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
649{
650 strlcpy(info->driver, DRV_NAME, sizeof(info->driver));
651 strlcpy(info->version, DRV_VERSION, sizeof(info->version));
652 strlcpy(info->bus_info, dev->class_dev.dev->bus_id, sizeof(info->bus_info));
653}
654
655static struct ethtool_ops at91ether_ethtool_ops = {
656 .get_settings = at91ether_get_settings,
657 .set_settings = at91ether_set_settings,
658 .get_drvinfo = at91ether_get_drvinfo,
659 .nway_reset = at91ether_nwayreset,
660 .get_link = ethtool_op_get_link,
661};
662
Andrew Victorca5585e2006-06-20 11:59:05 +0200663static int at91ether_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
664{
665 struct at91_private *lp = (struct at91_private *) dev->priv;
666 int res;
667
668 if (!netif_running(dev))
669 return -EINVAL;
670
671 spin_lock_irq(&lp->lock);
672 enable_mdi();
673 res = generic_mii_ioctl(&lp->mii, if_mii(rq), cmd, NULL);
674 disable_mdi();
675 spin_unlock_irq(&lp->lock);
676
677 return res;
678}
Andrew Victord4b77802006-03-24 11:50:17 +0200679
680/* ................................ MAC ................................ */
681
682/*
683 * Initialize and start the Receiver and Transmit subsystems
684 */
685static void at91ether_start(struct net_device *dev)
686{
687 struct at91_private *lp = (struct at91_private *) dev->priv;
688 struct recv_desc_bufs *dlist, *dlist_phys;
689 int i;
690 unsigned long ctl;
691
692 dlist = lp->dlist;
693 dlist_phys = lp->dlist_phys;
694
695 for (i = 0; i < MAX_RX_DESCR; i++) {
696 dlist->descriptors[i].addr = (unsigned int) &dlist_phys->recv_buf[i][0];
697 dlist->descriptors[i].size = 0;
698 }
699
700 /* Set the Wrap bit on the last descriptor */
701 dlist->descriptors[i-1].addr |= EMAC_DESC_WRAP;
702
703 /* Reset buffer index */
704 lp->rxBuffIndex = 0;
705
706 /* Program address of descriptor list in Rx Buffer Queue register */
707 at91_emac_write(AT91_EMAC_RBQP, (unsigned long) dlist_phys);
708
709 /* Enable Receive and Transmit */
710 ctl = at91_emac_read(AT91_EMAC_CTL);
711 at91_emac_write(AT91_EMAC_CTL, ctl | AT91_EMAC_RE | AT91_EMAC_TE);
712}
713
714/*
715 * Open the ethernet interface
716 */
717static int at91ether_open(struct net_device *dev)
718{
719 struct at91_private *lp = (struct at91_private *) dev->priv;
720 unsigned long ctl;
721
722 if (!is_valid_ether_addr(dev->dev_addr))
723 return -EADDRNOTAVAIL;
724
725 clk_enable(ether_clk); /* Re-enable Peripheral clock */
726
727 /* Clear internal statistics */
728 ctl = at91_emac_read(AT91_EMAC_CTL);
729 at91_emac_write(AT91_EMAC_CTL, ctl | AT91_EMAC_CSR);
730
731 /* Update the MAC address (incase user has changed it) */
732 update_mac_address(dev);
733
734 /* Enable PHY interrupt */
735 enable_phyirq(dev);
736
737 /* Enable MAC interrupts */
738 at91_emac_write(AT91_EMAC_IER, AT91_EMAC_RCOM | AT91_EMAC_RBNA
739 | AT91_EMAC_TUND | AT91_EMAC_RTRY | AT91_EMAC_TCOM
740 | AT91_EMAC_ROVR | AT91_EMAC_ABT);
741
742 /* Determine current link speed */
743 spin_lock_irq(&lp->lock);
744 enable_mdi();
Andrew Victor775637d2006-06-20 11:50:23 +0200745 update_linkspeed(dev, 0);
Andrew Victord4b77802006-03-24 11:50:17 +0200746 disable_mdi();
747 spin_unlock_irq(&lp->lock);
748
749 at91ether_start(dev);
750 netif_start_queue(dev);
751 return 0;
752}
753
754/*
755 * Close the interface
756 */
757static int at91ether_close(struct net_device *dev)
758{
759 unsigned long ctl;
760
761 /* Disable Receiver and Transmitter */
762 ctl = at91_emac_read(AT91_EMAC_CTL);
763 at91_emac_write(AT91_EMAC_CTL, ctl & ~(AT91_EMAC_TE | AT91_EMAC_RE));
764
765 /* Disable PHY interrupt */
766 disable_phyirq(dev);
767
768 /* Disable MAC interrupts */
769 at91_emac_write(AT91_EMAC_IDR, AT91_EMAC_RCOM | AT91_EMAC_RBNA
770 | AT91_EMAC_TUND | AT91_EMAC_RTRY | AT91_EMAC_TCOM
771 | AT91_EMAC_ROVR | AT91_EMAC_ABT);
772
773 netif_stop_queue(dev);
774
775 clk_disable(ether_clk); /* Disable Peripheral clock */
776
777 return 0;
778}
779
780/*
781 * Transmit packet.
782 */
783static int at91ether_tx(struct sk_buff *skb, struct net_device *dev)
784{
785 struct at91_private *lp = (struct at91_private *) dev->priv;
786
787 if (at91_emac_read(AT91_EMAC_TSR) & AT91_EMAC_TSR_BNQ) {
788 netif_stop_queue(dev);
789
790 /* Store packet information (to free when Tx completed) */
791 lp->skb = skb;
792 lp->skb_length = skb->len;
793 lp->skb_physaddr = dma_map_single(NULL, skb->data, skb->len, DMA_TO_DEVICE);
794 lp->stats.tx_bytes += skb->len;
795
796 /* Set address of the data in the Transmit Address register */
797 at91_emac_write(AT91_EMAC_TAR, lp->skb_physaddr);
798 /* Set length of the packet in the Transmit Control register */
799 at91_emac_write(AT91_EMAC_TCR, skb->len);
800
801 dev->trans_start = jiffies;
802 } else {
803 printk(KERN_ERR "at91_ether.c: at91ether_tx() called, but device is busy!\n");
804 return 1; /* if we return anything but zero, dev.c:1055 calls kfree_skb(skb)
805 on this skb, he also reports -ENETDOWN and printk's, so either
806 we free and return(0) or don't free and return 1 */
807 }
808
809 return 0;
810}
811
812/*
813 * Update the current statistics from the internal statistics registers.
814 */
815static struct net_device_stats *at91ether_stats(struct net_device *dev)
816{
817 struct at91_private *lp = (struct at91_private *) dev->priv;
818 int ale, lenerr, seqe, lcol, ecol;
819
820 if (netif_running(dev)) {
821 lp->stats.rx_packets += at91_emac_read(AT91_EMAC_OK); /* Good frames received */
822 ale = at91_emac_read(AT91_EMAC_ALE);
823 lp->stats.rx_frame_errors += ale; /* Alignment errors */
824 lenerr = at91_emac_read(AT91_EMAC_ELR) + at91_emac_read(AT91_EMAC_USF);
825 lp->stats.rx_length_errors += lenerr; /* Excessive Length or Undersize Frame error */
826 seqe = at91_emac_read(AT91_EMAC_SEQE);
827 lp->stats.rx_crc_errors += seqe; /* CRC error */
828 lp->stats.rx_fifo_errors += at91_emac_read(AT91_EMAC_DRFC); /* Receive buffer not available */
829 lp->stats.rx_errors += (ale + lenerr + seqe
830 + at91_emac_read(AT91_EMAC_CDE) + at91_emac_read(AT91_EMAC_RJB));
831
832 lp->stats.tx_packets += at91_emac_read(AT91_EMAC_FRA); /* Frames successfully transmitted */
833 lp->stats.tx_fifo_errors += at91_emac_read(AT91_EMAC_TUE); /* Transmit FIFO underruns */
834 lp->stats.tx_carrier_errors += at91_emac_read(AT91_EMAC_CSE); /* Carrier Sense errors */
835 lp->stats.tx_heartbeat_errors += at91_emac_read(AT91_EMAC_SQEE);/* Heartbeat error */
836
837 lcol = at91_emac_read(AT91_EMAC_LCOL);
838 ecol = at91_emac_read(AT91_EMAC_ECOL);
839 lp->stats.tx_window_errors += lcol; /* Late collisions */
840 lp->stats.tx_aborted_errors += ecol; /* 16 collisions */
841
842 lp->stats.collisions += (at91_emac_read(AT91_EMAC_SCOL) + at91_emac_read(AT91_EMAC_MCOL) + lcol + ecol);
843 }
844 return &lp->stats;
845}
846
847/*
848 * Extract received frame from buffer descriptors and sent to upper layers.
849 * (Called from interrupt context)
850 */
851static void at91ether_rx(struct net_device *dev)
852{
853 struct at91_private *lp = (struct at91_private *) dev->priv;
854 struct recv_desc_bufs *dlist;
855 unsigned char *p_recv;
856 struct sk_buff *skb;
857 unsigned int pktlen;
858
859 dlist = lp->dlist;
860 while (dlist->descriptors[lp->rxBuffIndex].addr & EMAC_DESC_DONE) {
861 p_recv = dlist->recv_buf[lp->rxBuffIndex];
862 pktlen = dlist->descriptors[lp->rxBuffIndex].size & 0x7ff; /* Length of frame including FCS */
863 skb = alloc_skb(pktlen + 2, GFP_ATOMIC);
864 if (skb != NULL) {
865 skb_reserve(skb, 2);
866 memcpy(skb_put(skb, pktlen), p_recv, pktlen);
867
868 skb->dev = dev;
869 skb->protocol = eth_type_trans(skb, dev);
870 skb->len = pktlen;
871 dev->last_rx = jiffies;
872 lp->stats.rx_bytes += pktlen;
873 netif_rx(skb);
874 }
875 else {
876 lp->stats.rx_dropped += 1;
877 printk(KERN_NOTICE "%s: Memory squeeze, dropping packet.\n", dev->name);
878 }
879
880 if (dlist->descriptors[lp->rxBuffIndex].size & EMAC_MULTICAST)
881 lp->stats.multicast++;
882
883 dlist->descriptors[lp->rxBuffIndex].addr &= ~EMAC_DESC_DONE; /* reset ownership bit */
884 if (lp->rxBuffIndex == MAX_RX_DESCR-1) /* wrap after last buffer */
885 lp->rxBuffIndex = 0;
886 else
887 lp->rxBuffIndex++;
888 }
889}
890
891/*
892 * MAC interrupt handler
893 */
894static irqreturn_t at91ether_interrupt(int irq, void *dev_id, struct pt_regs *regs)
895{
896 struct net_device *dev = (struct net_device *) dev_id;
897 struct at91_private *lp = (struct at91_private *) dev->priv;
898 unsigned long intstatus, ctl;
899
900 /* MAC Interrupt Status register indicates what interrupts are pending.
901 It is automatically cleared once read. */
902 intstatus = at91_emac_read(AT91_EMAC_ISR);
903
904 if (intstatus & AT91_EMAC_RCOM) /* Receive complete */
905 at91ether_rx(dev);
906
907 if (intstatus & AT91_EMAC_TCOM) { /* Transmit complete */
908 /* The TCOM bit is set even if the transmission failed. */
909 if (intstatus & (AT91_EMAC_TUND | AT91_EMAC_RTRY))
910 lp->stats.tx_errors += 1;
911
912 if (lp->skb) {
913 dev_kfree_skb_irq(lp->skb);
914 lp->skb = NULL;
915 dma_unmap_single(NULL, lp->skb_physaddr, lp->skb_length, DMA_TO_DEVICE);
916 }
917 netif_wake_queue(dev);
918 }
919
920 /* Work-around for Errata #11 */
921 if (intstatus & AT91_EMAC_RBNA) {
922 ctl = at91_emac_read(AT91_EMAC_CTL);
923 at91_emac_write(AT91_EMAC_CTL, ctl & ~AT91_EMAC_RE);
924 at91_emac_write(AT91_EMAC_CTL, ctl | AT91_EMAC_RE);
925 }
926
927 if (intstatus & AT91_EMAC_ROVR)
928 printk("%s: ROVR error\n", dev->name);
929
930 return IRQ_HANDLED;
931}
932
933/*
934 * Initialize the ethernet interface
935 */
936static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_address, struct platform_device *pdev)
937{
938 struct at91_eth_data *board_data = pdev->dev.platform_data;
939 struct net_device *dev;
940 struct at91_private *lp;
941 unsigned int val;
942 int res;
943
944 if (at91_dev) /* already initialized */
945 return 0;
946
947 dev = alloc_etherdev(sizeof(struct at91_private));
948 if (!dev)
949 return -ENOMEM;
950
951 dev->base_addr = AT91_VA_BASE_EMAC;
952 dev->irq = AT91_ID_EMAC;
953 SET_MODULE_OWNER(dev);
954
955 /* Install the interrupt handler */
956 if (request_irq(dev->irq, at91ether_interrupt, 0, dev->name, dev)) {
957 free_netdev(dev);
958 return -EBUSY;
959 }
960
961 /* Allocate memory for DMA Receive descriptors */
962 lp = (struct at91_private *)dev->priv;
963 lp->dlist = (struct recv_desc_bufs *) dma_alloc_coherent(NULL, sizeof(struct recv_desc_bufs), (dma_addr_t *) &lp->dlist_phys, GFP_KERNEL);
964 if (lp->dlist == NULL) {
965 free_irq(dev->irq, dev);
966 free_netdev(dev);
967 return -ENOMEM;
968 }
969 lp->board_data = *board_data;
970 platform_set_drvdata(pdev, dev);
971
972 spin_lock_init(&lp->lock);
973
974 ether_setup(dev);
975 dev->open = at91ether_open;
976 dev->stop = at91ether_close;
977 dev->hard_start_xmit = at91ether_tx;
978 dev->get_stats = at91ether_stats;
979 dev->set_multicast_list = at91ether_set_rx_mode;
980 dev->set_mac_address = set_mac_address;
981 dev->ethtool_ops = &at91ether_ethtool_ops;
Andrew Victorca5585e2006-06-20 11:59:05 +0200982 dev->do_ioctl = at91ether_ioctl;
Andrew Victord4b77802006-03-24 11:50:17 +0200983
984 SET_NETDEV_DEV(dev, &pdev->dev);
985
986 get_mac_address(dev); /* Get ethernet address and store it in dev->dev_addr */
987 update_mac_address(dev); /* Program ethernet address into MAC */
988
989 at91_emac_write(AT91_EMAC_CTL, 0);
990
991 if (lp->board_data.is_rmii)
992 at91_emac_write(AT91_EMAC_CFG, AT91_EMAC_CLK_DIV32 | AT91_EMAC_BIG | AT91_EMAC_RMII);
993 else
994 at91_emac_write(AT91_EMAC_CFG, AT91_EMAC_CLK_DIV32 | AT91_EMAC_BIG);
995
996 /* Perform PHY-specific initialization */
997 spin_lock_irq(&lp->lock);
998 enable_mdi();
999 if ((phy_type == MII_DM9161_ID) || (lp->phy_type == MII_DM9161A_ID)) {
1000 read_phy(phy_address, MII_DSCR_REG, &val);
1001 if ((val & (1 << 10)) == 0) /* DSCR bit 10 is 0 -- fiber mode */
1002 lp->phy_media = PORT_FIBRE;
1003 } else if (machine_is_csb337()) {
1004 /* mix link activity status into LED2 link state */
1005 write_phy(phy_address, MII_LEDCTRL_REG, 0x0d22);
1006 }
1007 disable_mdi();
1008 spin_unlock_irq(&lp->lock);
1009
1010 lp->mii.dev = dev; /* Support for ethtool */
1011 lp->mii.mdio_read = mdio_read;
1012 lp->mii.mdio_write = mdio_write;
Andrew Victorca5585e2006-06-20 11:59:05 +02001013 lp->mii.phy_id = phy_address;
1014 lp->mii.phy_id_mask = 0x1f;
1015 lp->mii.reg_num_mask = 0x1f;
Andrew Victord4b77802006-03-24 11:50:17 +02001016
1017 lp->phy_type = phy_type; /* Type of PHY connected */
1018 lp->phy_address = phy_address; /* MDI address of PHY */
1019
1020 /* Register the network interface */
1021 res = register_netdev(dev);
1022 if (res) {
1023 free_irq(dev->irq, dev);
1024 free_netdev(dev);
1025 dma_free_coherent(NULL, sizeof(struct recv_desc_bufs), lp->dlist, (dma_addr_t)lp->dlist_phys);
1026 return res;
1027 }
1028 at91_dev = dev;
1029
1030 /* Determine current link speed */
1031 spin_lock_irq(&lp->lock);
1032 enable_mdi();
Andrew Victor775637d2006-06-20 11:50:23 +02001033 update_linkspeed(dev, 0);
Andrew Victord4b77802006-03-24 11:50:17 +02001034 disable_mdi();
1035 spin_unlock_irq(&lp->lock);
1036 netif_carrier_off(dev); /* will be enabled in open() */
1037
Andrew Victor775637d2006-06-20 11:50:23 +02001038 /* If board has no PHY IRQ, use a timer to poll the PHY */
1039 if (!lp->board_data.phy_irq_pin) {
1040 init_timer(&check_timer);
1041 check_timer.data = (unsigned long)dev;
1042 check_timer.function = at91ether_check_link;
1043 }
1044
Andrew Victord4b77802006-03-24 11:50:17 +02001045 /* Display ethernet banner */
1046 printk(KERN_INFO "%s: AT91 ethernet at 0x%08x int=%d %s%s (%02x:%02x:%02x:%02x:%02x:%02x)\n",
1047 dev->name, (uint) dev->base_addr, dev->irq,
1048 at91_emac_read(AT91_EMAC_CFG) & AT91_EMAC_SPD ? "100-" : "10-",
1049 at91_emac_read(AT91_EMAC_CFG) & AT91_EMAC_FD ? "FullDuplex" : "HalfDuplex",
1050 dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2],
1051 dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]);
1052 if ((phy_type == MII_DM9161_ID) || (lp->phy_type == MII_DM9161A_ID))
1053 printk(KERN_INFO "%s: Davicom 9196 PHY %s\n", dev->name, (lp->phy_media == PORT_FIBRE) ? "(Fiber)" : "(Copper)");
1054 else if (phy_type == MII_LXT971A_ID)
1055 printk(KERN_INFO "%s: Intel LXT971A PHY\n", dev->name);
1056 else if (phy_type == MII_RTL8201_ID)
1057 printk(KERN_INFO "%s: Realtek RTL8201(B)L PHY\n", dev->name);
1058 else if (phy_type == MII_BCM5221_ID)
1059 printk(KERN_INFO "%s: Broadcom BCM5221 PHY\n", dev->name);
1060 else if (phy_type == MII_DP83847_ID)
1061 printk(KERN_INFO "%s: National Semiconductor DP83847 PHY\n", dev->name);
1062 else if (phy_type == MII_AC101L_ID)
1063 printk(KERN_INFO "%s: Altima AC101L PHY\n", dev->name);
1064 else if (phy_type == MII_KS8721_ID)
1065 printk(KERN_INFO "%s: Micrel KS8721 PHY\n", dev->name);
1066
1067 return 0;
1068}
1069
1070/*
1071 * Detect MAC and PHY and perform initialization
1072 */
1073static int __init at91ether_probe(struct platform_device *pdev)
1074{
1075 unsigned int phyid1, phyid2;
1076 int detected = -1;
1077 unsigned long phy_id;
1078 unsigned short phy_address = 0;
1079
1080 ether_clk = clk_get(&pdev->dev, "ether_clk");
1081 if (!ether_clk) {
1082 printk(KERN_ERR "at91_ether: no clock defined\n");
1083 return -ENODEV;
1084 }
1085 clk_enable(ether_clk); /* Enable Peripheral clock */
1086
1087 while ((detected != 0) && (phy_address < 32)) {
1088 /* Read the PHY ID registers */
1089 enable_mdi();
1090 read_phy(phy_address, MII_PHYSID1, &phyid1);
1091 read_phy(phy_address, MII_PHYSID2, &phyid2);
1092 disable_mdi();
1093
1094 phy_id = (phyid1 << 16) | (phyid2 & 0xfff0);
1095 switch (phy_id) {
1096 case MII_DM9161_ID: /* Davicom 9161: PHY_ID1 = 0x181, PHY_ID2 = B881 */
1097 case MII_DM9161A_ID: /* Davicom 9161A: PHY_ID1 = 0x181, PHY_ID2 = B8A0 */
1098 case MII_LXT971A_ID: /* Intel LXT971A: PHY_ID1 = 0x13, PHY_ID2 = 78E0 */
1099 case MII_RTL8201_ID: /* Realtek RTL8201: PHY_ID1 = 0, PHY_ID2 = 0x8201 */
1100 case MII_BCM5221_ID: /* Broadcom BCM5221: PHY_ID1 = 0x40, PHY_ID2 = 0x61e0 */
1101 case MII_DP83847_ID: /* National Semiconductor DP83847: */
1102 case MII_AC101L_ID: /* Altima AC101L: PHY_ID1 = 0x22, PHY_ID2 = 0x5520 */
1103 case MII_KS8721_ID: /* Micrel KS8721: PHY_ID1 = 0x22, PHY_ID2 = 0x1610 */
1104 detected = at91ether_setup(phy_id, phy_address, pdev);
1105 break;
1106 }
1107
1108 phy_address++;
1109 }
1110
1111 clk_disable(ether_clk); /* Disable Peripheral clock */
1112
1113 return detected;
1114}
1115
1116static int __devexit at91ether_remove(struct platform_device *pdev)
1117{
1118 struct at91_private *lp = (struct at91_private *) at91_dev->priv;
1119
1120 unregister_netdev(at91_dev);
1121 free_irq(at91_dev->irq, at91_dev);
1122 dma_free_coherent(NULL, sizeof(struct recv_desc_bufs), lp->dlist, (dma_addr_t)lp->dlist_phys);
1123 clk_put(ether_clk);
1124
1125 free_netdev(at91_dev);
1126 at91_dev = NULL;
1127 return 0;
1128}
1129
1130static struct platform_driver at91ether_driver = {
1131 .probe = at91ether_probe,
1132 .remove = __devexit_p(at91ether_remove),
1133 /* FIXME: support suspend and resume */
1134 .driver = {
1135 .name = DRV_NAME,
1136 .owner = THIS_MODULE,
1137 },
1138};
1139
1140static int __init at91ether_init(void)
1141{
1142 return platform_driver_register(&at91ether_driver);
1143}
1144
1145static void __exit at91ether_exit(void)
1146{
1147 platform_driver_unregister(&at91ether_driver);
1148}
1149
1150module_init(at91ether_init)
1151module_exit(at91ether_exit)
1152
1153MODULE_LICENSE("GPL");
1154MODULE_DESCRIPTION("AT91RM9200 EMAC Ethernet driver");
1155MODULE_AUTHOR("Andrew Victor");