RT-AC56 3.0.0.4.374.37 core
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / drivers / net / arm / at91_ether.c
blob69d8a8511576a157f61943a8590821e8d23eddd1
1 /*
2 * Ethernet driver for the Atmel AT91RM9200 (Thunder)
4 * Copyright (C) 2003 SAN People (Pty) Ltd
6 * Based on an earlier Atmel EMAC macrocell driver by Atmel and Lineo Inc.
7 * Initial version by Rick Bronson 01/11/2003
9 * Intel LXT971A PHY support by Christopher Bahns & David Knickerbocker
10 * (Polaroid Corporation)
12 * Realtek RTL8201(B)L PHY support by Roman Avramenko <roman@imsystems.ru>
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.
20 #include <linux/module.h>
21 #include <linux/init.h>
22 #include <linux/mii.h>
23 #include <linux/netdevice.h>
24 #include <linux/etherdevice.h>
25 #include <linux/skbuff.h>
26 #include <linux/dma-mapping.h>
27 #include <linux/ethtool.h>
28 #include <linux/platform_device.h>
29 #include <linux/clk.h>
30 #include <linux/gfp.h>
32 #include <asm/io.h>
33 #include <asm/uaccess.h>
34 #include <asm/mach-types.h>
36 #include <mach/at91rm9200_emac.h>
37 #include <mach/gpio.h>
38 #include <mach/board.h>
40 #include "at91_ether.h"
42 #define DRV_NAME "at91_ether"
43 #define DRV_VERSION "1.0"
45 #define LINK_POLL_INTERVAL (HZ)
47 /* ..................................................................... */
50 * Read from a EMAC register.
52 static inline unsigned long at91_emac_read(unsigned int reg)
54 void __iomem *emac_base = (void __iomem *)AT91_VA_BASE_EMAC;
56 return __raw_readl(emac_base + reg);
60 * Write to a EMAC register.
62 static inline void at91_emac_write(unsigned int reg, unsigned long value)
64 void __iomem *emac_base = (void __iomem *)AT91_VA_BASE_EMAC;
66 __raw_writel(value, emac_base + reg);
69 /* ........................... PHY INTERFACE ........................... */
72 * Enable the MDIO bit in MAC control register
73 * When not called from an interrupt-handler, access to the PHY must be
74 * protected by a spinlock.
76 static void enable_mdi(void)
78 unsigned long ctl;
80 ctl = at91_emac_read(AT91_EMAC_CTL);
81 at91_emac_write(AT91_EMAC_CTL, ctl | AT91_EMAC_MPE); /* enable management port */
85 * Disable the MDIO bit in the MAC control register
87 static void disable_mdi(void)
89 unsigned long ctl;
91 ctl = at91_emac_read(AT91_EMAC_CTL);
92 at91_emac_write(AT91_EMAC_CTL, ctl & ~AT91_EMAC_MPE); /* disable management port */
96 * Wait until the PHY operation is complete.
98 static inline void at91_phy_wait(void) {
99 unsigned long timeout = jiffies + 2;
101 while (!(at91_emac_read(AT91_EMAC_SR) & AT91_EMAC_SR_IDLE)) {
102 if (time_after(jiffies, timeout)) {
103 printk("at91_ether: MIO timeout\n");
104 break;
106 cpu_relax();
111 * Write value to the a PHY register
112 * Note: MDI interface is assumed to already have been enabled.
114 static void write_phy(unsigned char phy_addr, unsigned char address, unsigned int value)
116 at91_emac_write(AT91_EMAC_MAN, AT91_EMAC_MAN_802_3 | AT91_EMAC_RW_W
117 | ((phy_addr & 0x1f) << 23) | (address << 18) | (value & AT91_EMAC_DATA));
119 /* Wait until IDLE bit in Network Status register is cleared */
120 at91_phy_wait();
124 * Read value stored in a PHY register.
125 * Note: MDI interface is assumed to already have been enabled.
127 static void read_phy(unsigned char phy_addr, unsigned char address, unsigned int *value)
129 at91_emac_write(AT91_EMAC_MAN, AT91_EMAC_MAN_802_3 | AT91_EMAC_RW_R
130 | ((phy_addr & 0x1f) << 23) | (address << 18));
132 /* Wait until IDLE bit in Network Status register is cleared */
133 at91_phy_wait();
135 *value = at91_emac_read(AT91_EMAC_MAN) & AT91_EMAC_DATA;
138 /* ........................... PHY MANAGEMENT .......................... */
141 * Access the PHY to determine the current link speed and mode, and update the
142 * MAC accordingly.
143 * If no link or auto-negotiation is busy, then no changes are made.
145 static void update_linkspeed(struct net_device *dev, int silent)
147 struct at91_private *lp = netdev_priv(dev);
148 unsigned int bmsr, bmcr, lpa, mac_cfg;
149 unsigned int speed, duplex;
151 if (!mii_link_ok(&lp->mii)) { /* no link */
152 netif_carrier_off(dev);
153 if (!silent)
154 printk(KERN_INFO "%s: Link down.\n", dev->name);
155 return;
158 /* Link up, or auto-negotiation still in progress */
159 read_phy(lp->phy_address, MII_BMSR, &bmsr);
160 read_phy(lp->phy_address, MII_BMCR, &bmcr);
161 if (bmcr & BMCR_ANENABLE) { /* AutoNegotiation is enabled */
162 if (!(bmsr & BMSR_ANEGCOMPLETE))
163 return; /* Do nothing - another interrupt generated when negotiation complete */
165 read_phy(lp->phy_address, MII_LPA, &lpa);
166 if ((lpa & LPA_100FULL) || (lpa & LPA_100HALF)) speed = SPEED_100;
167 else speed = SPEED_10;
168 if ((lpa & LPA_100FULL) || (lpa & LPA_10FULL)) duplex = DUPLEX_FULL;
169 else duplex = DUPLEX_HALF;
170 } else {
171 speed = (bmcr & BMCR_SPEED100) ? SPEED_100 : SPEED_10;
172 duplex = (bmcr & BMCR_FULLDPLX) ? DUPLEX_FULL : DUPLEX_HALF;
175 /* Update the MAC */
176 mac_cfg = at91_emac_read(AT91_EMAC_CFG) & ~(AT91_EMAC_SPD | AT91_EMAC_FD);
177 if (speed == SPEED_100) {
178 if (duplex == DUPLEX_FULL) /* 100 Full Duplex */
179 mac_cfg |= AT91_EMAC_SPD | AT91_EMAC_FD;
180 else /* 100 Half Duplex */
181 mac_cfg |= AT91_EMAC_SPD;
182 } else {
183 if (duplex == DUPLEX_FULL) /* 10 Full Duplex */
184 mac_cfg |= AT91_EMAC_FD;
185 else {} /* 10 Half Duplex */
187 at91_emac_write(AT91_EMAC_CFG, mac_cfg);
189 if (!silent)
190 printk(KERN_INFO "%s: Link now %i-%s\n", dev->name, speed, (duplex == DUPLEX_FULL) ? "FullDuplex" : "HalfDuplex");
191 netif_carrier_on(dev);
195 * Handle interrupts from the PHY
197 static irqreturn_t at91ether_phy_interrupt(int irq, void *dev_id)
199 struct net_device *dev = (struct net_device *) dev_id;
200 struct at91_private *lp = netdev_priv(dev);
201 unsigned int phy;
204 * This hander is triggered on both edges, but the PHY chips expect
205 * level-triggering. We therefore have to check if the PHY actually has
206 * an IRQ pending.
208 enable_mdi();
209 if ((lp->phy_type == MII_DM9161_ID) || (lp->phy_type == MII_DM9161A_ID)) {
210 read_phy(lp->phy_address, MII_DSINTR_REG, &phy); /* ack interrupt in Davicom PHY */
211 if (!(phy & (1 << 0)))
212 goto done;
214 else if (lp->phy_type == MII_LXT971A_ID) {
215 read_phy(lp->phy_address, MII_ISINTS_REG, &phy); /* ack interrupt in Intel PHY */
216 if (!(phy & (1 << 2)))
217 goto done;
219 else if (lp->phy_type == MII_BCM5221_ID) {
220 read_phy(lp->phy_address, MII_BCMINTR_REG, &phy); /* ack interrupt in Broadcom PHY */
221 if (!(phy & (1 << 0)))
222 goto done;
224 else if (lp->phy_type == MII_KS8721_ID) {
225 read_phy(lp->phy_address, MII_TPISTATUS, &phy); /* ack interrupt in Micrel PHY */
226 if (!(phy & ((1 << 2) | 1)))
227 goto done;
229 else if (lp->phy_type == MII_T78Q21x3_ID) { /* ack interrupt in Teridian PHY */
230 read_phy(lp->phy_address, MII_T78Q21INT_REG, &phy);
231 if (!(phy & ((1 << 2) | 1)))
232 goto done;
234 else if (lp->phy_type == MII_DP83848_ID) {
235 read_phy(lp->phy_address, MII_DPPHYSTS_REG, &phy); /* ack interrupt in DP83848 PHY */
236 if (!(phy & (1 << 7)))
237 goto done;
240 update_linkspeed(dev, 0);
242 done:
243 disable_mdi();
245 return IRQ_HANDLED;
249 * Initialize and enable the PHY interrupt for link-state changes
251 static void enable_phyirq(struct net_device *dev)
253 struct at91_private *lp = netdev_priv(dev);
254 unsigned int dsintr, irq_number;
255 int status;
257 irq_number = lp->board_data.phy_irq_pin;
258 if (!irq_number) {
260 * PHY doesn't have an IRQ pin (RTL8201, DP83847, AC101L),
261 * or board does not have it connected.
263 mod_timer(&lp->check_timer, jiffies + LINK_POLL_INTERVAL);
264 return;
267 status = request_irq(irq_number, at91ether_phy_interrupt, 0, dev->name, dev);
268 if (status) {
269 printk(KERN_ERR "at91_ether: PHY IRQ %d request failed - status %d!\n", irq_number, status);
270 return;
273 spin_lock_irq(&lp->lock);
274 enable_mdi();
276 if ((lp->phy_type == MII_DM9161_ID) || (lp->phy_type == MII_DM9161A_ID)) { /* for Davicom PHY */
277 read_phy(lp->phy_address, MII_DSINTR_REG, &dsintr);
278 dsintr = dsintr & ~0xf00; /* clear bits 8..11 */
279 write_phy(lp->phy_address, MII_DSINTR_REG, dsintr);
281 else if (lp->phy_type == MII_LXT971A_ID) { /* for Intel PHY */
282 read_phy(lp->phy_address, MII_ISINTE_REG, &dsintr);
283 dsintr = dsintr | 0xf2; /* set bits 1, 4..7 */
284 write_phy(lp->phy_address, MII_ISINTE_REG, dsintr);
286 else if (lp->phy_type == MII_BCM5221_ID) { /* for Broadcom PHY */
287 dsintr = (1 << 15) | ( 1 << 14);
288 write_phy(lp->phy_address, MII_BCMINTR_REG, dsintr);
290 else if (lp->phy_type == MII_KS8721_ID) { /* for Micrel PHY */
291 dsintr = (1 << 10) | ( 1 << 8);
292 write_phy(lp->phy_address, MII_TPISTATUS, dsintr);
294 else if (lp->phy_type == MII_T78Q21x3_ID) { /* for Teridian PHY */
295 read_phy(lp->phy_address, MII_T78Q21INT_REG, &dsintr);
296 dsintr = dsintr | 0x500; /* set bits 8, 10 */
297 write_phy(lp->phy_address, MII_T78Q21INT_REG, dsintr);
299 else if (lp->phy_type == MII_DP83848_ID) { /* National Semiconductor DP83848 PHY */
300 read_phy(lp->phy_address, MII_DPMISR_REG, &dsintr);
301 dsintr = dsintr | 0x3c; /* set bits 2..5 */
302 write_phy(lp->phy_address, MII_DPMISR_REG, dsintr);
303 read_phy(lp->phy_address, MII_DPMICR_REG, &dsintr);
304 dsintr = dsintr | 0x3; /* set bits 0,1 */
305 write_phy(lp->phy_address, MII_DPMICR_REG, dsintr);
308 disable_mdi();
309 spin_unlock_irq(&lp->lock);
313 * Disable the PHY interrupt
315 static void disable_phyirq(struct net_device *dev)
317 struct at91_private *lp = netdev_priv(dev);
318 unsigned int dsintr;
319 unsigned int irq_number;
321 irq_number = lp->board_data.phy_irq_pin;
322 if (!irq_number) {
323 del_timer_sync(&lp->check_timer);
324 return;
327 spin_lock_irq(&lp->lock);
328 enable_mdi();
330 if ((lp->phy_type == MII_DM9161_ID) || (lp->phy_type == MII_DM9161A_ID)) { /* for Davicom PHY */
331 read_phy(lp->phy_address, MII_DSINTR_REG, &dsintr);
332 dsintr = dsintr | 0xf00; /* set bits 8..11 */
333 write_phy(lp->phy_address, MII_DSINTR_REG, dsintr);
335 else if (lp->phy_type == MII_LXT971A_ID) { /* for Intel PHY */
336 read_phy(lp->phy_address, MII_ISINTE_REG, &dsintr);
337 dsintr = dsintr & ~0xf2; /* clear bits 1, 4..7 */
338 write_phy(lp->phy_address, MII_ISINTE_REG, dsintr);
340 else if (lp->phy_type == MII_BCM5221_ID) { /* for Broadcom PHY */
341 read_phy(lp->phy_address, MII_BCMINTR_REG, &dsintr);
342 dsintr = ~(1 << 14);
343 write_phy(lp->phy_address, MII_BCMINTR_REG, dsintr);
345 else if (lp->phy_type == MII_KS8721_ID) { /* for Micrel PHY */
346 read_phy(lp->phy_address, MII_TPISTATUS, &dsintr);
347 dsintr = ~((1 << 10) | (1 << 8));
348 write_phy(lp->phy_address, MII_TPISTATUS, dsintr);
350 else if (lp->phy_type == MII_T78Q21x3_ID) { /* for Teridian PHY */
351 read_phy(lp->phy_address, MII_T78Q21INT_REG, &dsintr);
352 dsintr = dsintr & ~0x500; /* clear bits 8, 10 */
353 write_phy(lp->phy_address, MII_T78Q21INT_REG, dsintr);
355 else if (lp->phy_type == MII_DP83848_ID) { /* National Semiconductor DP83848 PHY */
356 read_phy(lp->phy_address, MII_DPMICR_REG, &dsintr);
357 dsintr = dsintr & ~0x3; /* clear bits 0, 1 */
358 write_phy(lp->phy_address, MII_DPMICR_REG, dsintr);
359 read_phy(lp->phy_address, MII_DPMISR_REG, &dsintr);
360 dsintr = dsintr & ~0x3c; /* clear bits 2..5 */
361 write_phy(lp->phy_address, MII_DPMISR_REG, dsintr);
364 disable_mdi();
365 spin_unlock_irq(&lp->lock);
367 free_irq(irq_number, dev); /* Free interrupt handler */
371 * Perform a software reset of the PHY.
374 static void at91ether_check_link(unsigned long dev_id)
376 struct net_device *dev = (struct net_device *) dev_id;
377 struct at91_private *lp = netdev_priv(dev);
379 enable_mdi();
380 update_linkspeed(dev, 1);
381 disable_mdi();
383 mod_timer(&lp->check_timer, jiffies + LINK_POLL_INTERVAL);
386 /* ......................... ADDRESS MANAGEMENT ........................ */
389 * NOTE: Your bootloader must always set the MAC address correctly before
390 * booting into Linux.
392 * - It must always set the MAC address after reset, even if it doesn't
393 * happen to access the Ethernet while it's booting. Some versions of
394 * U-Boot on the AT91RM9200-DK do not do this.
396 * - Likewise it must store the addresses in the correct byte order.
397 * MicroMonitor (uMon) on the CSB337 does this incorrectly (and
398 * continues to do so, for bug-compatibility).
401 static short __init unpack_mac_address(struct net_device *dev, unsigned int hi, unsigned int lo)
403 char addr[6];
405 if (machine_is_csb337()) {
406 addr[5] = (lo & 0xff); /* The CSB337 bootloader stores the MAC the wrong-way around */
407 addr[4] = (lo & 0xff00) >> 8;
408 addr[3] = (lo & 0xff0000) >> 16;
409 addr[2] = (lo & 0xff000000) >> 24;
410 addr[1] = (hi & 0xff);
411 addr[0] = (hi & 0xff00) >> 8;
413 else {
414 addr[0] = (lo & 0xff);
415 addr[1] = (lo & 0xff00) >> 8;
416 addr[2] = (lo & 0xff0000) >> 16;
417 addr[3] = (lo & 0xff000000) >> 24;
418 addr[4] = (hi & 0xff);
419 addr[5] = (hi & 0xff00) >> 8;
422 if (is_valid_ether_addr(addr)) {
423 memcpy(dev->dev_addr, &addr, 6);
424 return 1;
426 return 0;
430 * Set the ethernet MAC address in dev->dev_addr
432 static void __init get_mac_address(struct net_device *dev)
434 /* Check Specific-Address 1 */
435 if (unpack_mac_address(dev, at91_emac_read(AT91_EMAC_SA1H), at91_emac_read(AT91_EMAC_SA1L)))
436 return;
437 /* Check Specific-Address 2 */
438 if (unpack_mac_address(dev, at91_emac_read(AT91_EMAC_SA2H), at91_emac_read(AT91_EMAC_SA2L)))
439 return;
440 /* Check Specific-Address 3 */
441 if (unpack_mac_address(dev, at91_emac_read(AT91_EMAC_SA3H), at91_emac_read(AT91_EMAC_SA3L)))
442 return;
443 /* Check Specific-Address 4 */
444 if (unpack_mac_address(dev, at91_emac_read(AT91_EMAC_SA4H), at91_emac_read(AT91_EMAC_SA4L)))
445 return;
447 printk(KERN_ERR "at91_ether: Your bootloader did not configure a MAC address.\n");
451 * Program the hardware MAC address from dev->dev_addr.
453 static void update_mac_address(struct net_device *dev)
455 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]));
456 at91_emac_write(AT91_EMAC_SA1H, (dev->dev_addr[5] << 8) | (dev->dev_addr[4]));
458 at91_emac_write(AT91_EMAC_SA2L, 0);
459 at91_emac_write(AT91_EMAC_SA2H, 0);
463 * Store the new hardware address in dev->dev_addr, and update the MAC.
465 static int set_mac_address(struct net_device *dev, void* addr)
467 struct sockaddr *address = addr;
469 if (!is_valid_ether_addr(address->sa_data))
470 return -EADDRNOTAVAIL;
472 memcpy(dev->dev_addr, address->sa_data, dev->addr_len);
473 update_mac_address(dev);
475 printk("%s: Setting MAC address to %pM\n", dev->name,
476 dev->dev_addr);
478 return 0;
481 static int inline hash_bit_value(int bitnr, __u8 *addr)
483 if (addr[bitnr / 8] & (1 << (bitnr % 8)))
484 return 1;
485 return 0;
489 * The hash address register is 64 bits long and takes up two locations in the memory map.
490 * The least significant bits are stored in EMAC_HSL and the most significant
491 * bits in EMAC_HSH.
493 * The unicast hash enable and the multicast hash enable bits in the network configuration
494 * register enable the reception of hash matched frames. The destination address is
495 * reduced to a 6 bit index into the 64 bit hash register using the following hash function.
496 * The hash function is an exclusive or of every sixth bit of the destination address.
497 * hash_index[5] = da[5] ^ da[11] ^ da[17] ^ da[23] ^ da[29] ^ da[35] ^ da[41] ^ da[47]
498 * hash_index[4] = da[4] ^ da[10] ^ da[16] ^ da[22] ^ da[28] ^ da[34] ^ da[40] ^ da[46]
499 * hash_index[3] = da[3] ^ da[09] ^ da[15] ^ da[21] ^ da[27] ^ da[33] ^ da[39] ^ da[45]
500 * hash_index[2] = da[2] ^ da[08] ^ da[14] ^ da[20] ^ da[26] ^ da[32] ^ da[38] ^ da[44]
501 * hash_index[1] = da[1] ^ da[07] ^ da[13] ^ da[19] ^ da[25] ^ da[31] ^ da[37] ^ da[43]
502 * hash_index[0] = da[0] ^ da[06] ^ da[12] ^ da[18] ^ da[24] ^ da[30] ^ da[36] ^ da[42]
503 * da[0] represents the least significant bit of the first byte received, that is, the multicast/
504 * unicast indicator, and da[47] represents the most significant bit of the last byte
505 * received.
506 * If the hash index points to a bit that is set in the hash register then the frame will be
507 * matched according to whether the frame is multicast or unicast.
508 * A multicast match will be signalled if the multicast hash enable bit is set, da[0] is 1 and
509 * the hash index points to a bit set in the hash register.
510 * A unicast match will be signalled if the unicast hash enable bit is set, da[0] is 0 and the
511 * hash index points to a bit set in the hash register.
512 * To receive all multicast frames, the hash register should be set with all ones and the
513 * multicast hash enable bit should be set in the network configuration register.
517 * Return the hash index value for the specified address.
519 static int hash_get_index(__u8 *addr)
521 int i, j, bitval;
522 int hash_index = 0;
524 for (j = 0; j < 6; j++) {
525 for (i = 0, bitval = 0; i < 8; i++)
526 bitval ^= hash_bit_value(i*6 + j, addr);
528 hash_index |= (bitval << j);
531 return hash_index;
535 * Add multicast addresses to the internal multicast-hash table.
537 static void at91ether_sethashtable(struct net_device *dev)
539 struct netdev_hw_addr *ha;
540 unsigned long mc_filter[2];
541 unsigned int bitnr;
543 mc_filter[0] = mc_filter[1] = 0;
545 netdev_for_each_mc_addr(ha, dev) {
546 bitnr = hash_get_index(ha->addr);
547 mc_filter[bitnr >> 5] |= 1 << (bitnr & 31);
550 at91_emac_write(AT91_EMAC_HSL, mc_filter[0]);
551 at91_emac_write(AT91_EMAC_HSH, mc_filter[1]);
555 * Enable/Disable promiscuous and multicast modes.
557 static void at91ether_set_multicast_list(struct net_device *dev)
559 unsigned long cfg;
561 cfg = at91_emac_read(AT91_EMAC_CFG);
563 if (dev->flags & IFF_PROMISC) /* Enable promiscuous mode */
564 cfg |= AT91_EMAC_CAF;
565 else if (dev->flags & (~IFF_PROMISC)) /* Disable promiscuous mode */
566 cfg &= ~AT91_EMAC_CAF;
568 if (dev->flags & IFF_ALLMULTI) { /* Enable all multicast mode */
569 at91_emac_write(AT91_EMAC_HSH, -1);
570 at91_emac_write(AT91_EMAC_HSL, -1);
571 cfg |= AT91_EMAC_MTI;
572 } else if (!netdev_mc_empty(dev)) { /* Enable specific multicasts */
573 at91ether_sethashtable(dev);
574 cfg |= AT91_EMAC_MTI;
575 } else if (dev->flags & (~IFF_ALLMULTI)) { /* Disable all multicast mode */
576 at91_emac_write(AT91_EMAC_HSH, 0);
577 at91_emac_write(AT91_EMAC_HSL, 0);
578 cfg &= ~AT91_EMAC_MTI;
581 at91_emac_write(AT91_EMAC_CFG, cfg);
584 /* ......................... ETHTOOL SUPPORT ........................... */
586 static int mdio_read(struct net_device *dev, int phy_id, int location)
588 unsigned int value;
590 read_phy(phy_id, location, &value);
591 return value;
594 static void mdio_write(struct net_device *dev, int phy_id, int location, int value)
596 write_phy(phy_id, location, value);
599 static int at91ether_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
601 struct at91_private *lp = netdev_priv(dev);
602 int ret;
604 spin_lock_irq(&lp->lock);
605 enable_mdi();
607 ret = mii_ethtool_gset(&lp->mii, cmd);
609 disable_mdi();
610 spin_unlock_irq(&lp->lock);
612 if (lp->phy_media == PORT_FIBRE) { /* override media type since mii.c doesn't know */
613 cmd->supported = SUPPORTED_FIBRE;
614 cmd->port = PORT_FIBRE;
617 return ret;
620 static int at91ether_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
622 struct at91_private *lp = netdev_priv(dev);
623 int ret;
625 spin_lock_irq(&lp->lock);
626 enable_mdi();
628 ret = mii_ethtool_sset(&lp->mii, cmd);
630 disable_mdi();
631 spin_unlock_irq(&lp->lock);
633 return ret;
636 static int at91ether_nwayreset(struct net_device *dev)
638 struct at91_private *lp = netdev_priv(dev);
639 int ret;
641 spin_lock_irq(&lp->lock);
642 enable_mdi();
644 ret = mii_nway_restart(&lp->mii);
646 disable_mdi();
647 spin_unlock_irq(&lp->lock);
649 return ret;
652 static void at91ether_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
654 strlcpy(info->driver, DRV_NAME, sizeof(info->driver));
655 strlcpy(info->version, DRV_VERSION, sizeof(info->version));
656 strlcpy(info->bus_info, dev_name(dev->dev.parent), sizeof(info->bus_info));
659 static const struct ethtool_ops at91ether_ethtool_ops = {
660 .get_settings = at91ether_get_settings,
661 .set_settings = at91ether_set_settings,
662 .get_drvinfo = at91ether_get_drvinfo,
663 .nway_reset = at91ether_nwayreset,
664 .get_link = ethtool_op_get_link,
667 static int at91ether_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
669 struct at91_private *lp = netdev_priv(dev);
670 int res;
672 if (!netif_running(dev))
673 return -EINVAL;
675 spin_lock_irq(&lp->lock);
676 enable_mdi();
677 res = generic_mii_ioctl(&lp->mii, if_mii(rq), cmd, NULL);
678 disable_mdi();
679 spin_unlock_irq(&lp->lock);
681 return res;
684 /* ................................ MAC ................................ */
687 * Initialize and start the Receiver and Transmit subsystems
689 static void at91ether_start(struct net_device *dev)
691 struct at91_private *lp = netdev_priv(dev);
692 struct recv_desc_bufs *dlist, *dlist_phys;
693 int i;
694 unsigned long ctl;
696 dlist = lp->dlist;
697 dlist_phys = lp->dlist_phys;
699 for (i = 0; i < MAX_RX_DESCR; i++) {
700 dlist->descriptors[i].addr = (unsigned int) &dlist_phys->recv_buf[i][0];
701 dlist->descriptors[i].size = 0;
704 /* Set the Wrap bit on the last descriptor */
705 dlist->descriptors[i-1].addr |= EMAC_DESC_WRAP;
707 /* Reset buffer index */
708 lp->rxBuffIndex = 0;
710 /* Program address of descriptor list in Rx Buffer Queue register */
711 at91_emac_write(AT91_EMAC_RBQP, (unsigned long) dlist_phys);
713 /* Enable Receive and Transmit */
714 ctl = at91_emac_read(AT91_EMAC_CTL);
715 at91_emac_write(AT91_EMAC_CTL, ctl | AT91_EMAC_RE | AT91_EMAC_TE);
719 * Open the ethernet interface
721 static int at91ether_open(struct net_device *dev)
723 struct at91_private *lp = netdev_priv(dev);
724 unsigned long ctl;
726 if (!is_valid_ether_addr(dev->dev_addr))
727 return -EADDRNOTAVAIL;
729 clk_enable(lp->ether_clk); /* Re-enable Peripheral clock */
731 /* Clear internal statistics */
732 ctl = at91_emac_read(AT91_EMAC_CTL);
733 at91_emac_write(AT91_EMAC_CTL, ctl | AT91_EMAC_CSR);
735 /* Update the MAC address (incase user has changed it) */
736 update_mac_address(dev);
738 /* Enable PHY interrupt */
739 enable_phyirq(dev);
741 /* Enable MAC interrupts */
742 at91_emac_write(AT91_EMAC_IER, AT91_EMAC_RCOM | AT91_EMAC_RBNA
743 | AT91_EMAC_TUND | AT91_EMAC_RTRY | AT91_EMAC_TCOM
744 | AT91_EMAC_ROVR | AT91_EMAC_ABT);
746 /* Determine current link speed */
747 spin_lock_irq(&lp->lock);
748 enable_mdi();
749 update_linkspeed(dev, 0);
750 disable_mdi();
751 spin_unlock_irq(&lp->lock);
753 at91ether_start(dev);
754 netif_start_queue(dev);
755 return 0;
759 * Close the interface
761 static int at91ether_close(struct net_device *dev)
763 struct at91_private *lp = netdev_priv(dev);
764 unsigned long ctl;
766 /* Disable Receiver and Transmitter */
767 ctl = at91_emac_read(AT91_EMAC_CTL);
768 at91_emac_write(AT91_EMAC_CTL, ctl & ~(AT91_EMAC_TE | AT91_EMAC_RE));
770 /* Disable PHY interrupt */
771 disable_phyirq(dev);
773 /* Disable MAC interrupts */
774 at91_emac_write(AT91_EMAC_IDR, AT91_EMAC_RCOM | AT91_EMAC_RBNA
775 | AT91_EMAC_TUND | AT91_EMAC_RTRY | AT91_EMAC_TCOM
776 | AT91_EMAC_ROVR | AT91_EMAC_ABT);
778 netif_stop_queue(dev);
780 clk_disable(lp->ether_clk); /* Disable Peripheral clock */
782 return 0;
786 * Transmit packet.
788 static int at91ether_start_xmit(struct sk_buff *skb, struct net_device *dev)
790 struct at91_private *lp = netdev_priv(dev);
792 if (at91_emac_read(AT91_EMAC_TSR) & AT91_EMAC_TSR_BNQ) {
793 netif_stop_queue(dev);
795 /* Store packet information (to free when Tx completed) */
796 lp->skb = skb;
797 lp->skb_length = skb->len;
798 lp->skb_physaddr = dma_map_single(NULL, skb->data, skb->len, DMA_TO_DEVICE);
799 dev->stats.tx_bytes += skb->len;
801 /* Set address of the data in the Transmit Address register */
802 at91_emac_write(AT91_EMAC_TAR, lp->skb_physaddr);
803 /* Set length of the packet in the Transmit Control register */
804 at91_emac_write(AT91_EMAC_TCR, skb->len);
806 } else {
807 printk(KERN_ERR "at91_ether.c: at91ether_start_xmit() called, but device is busy!\n");
808 return NETDEV_TX_BUSY; /* if we return anything but zero, dev.c:1055 calls kfree_skb(skb)
809 on this skb, he also reports -ENETDOWN and printk's, so either
810 we free and return(0) or don't free and return 1 */
813 return NETDEV_TX_OK;
817 * Update the current statistics from the internal statistics registers.
819 static struct net_device_stats *at91ether_stats(struct net_device *dev)
821 int ale, lenerr, seqe, lcol, ecol;
823 if (netif_running(dev)) {
824 dev->stats.rx_packets += at91_emac_read(AT91_EMAC_OK); /* Good frames received */
825 ale = at91_emac_read(AT91_EMAC_ALE);
826 dev->stats.rx_frame_errors += ale; /* Alignment errors */
827 lenerr = at91_emac_read(AT91_EMAC_ELR) + at91_emac_read(AT91_EMAC_USF);
828 dev->stats.rx_length_errors += lenerr; /* Excessive Length or Undersize Frame error */
829 seqe = at91_emac_read(AT91_EMAC_SEQE);
830 dev->stats.rx_crc_errors += seqe; /* CRC error */
831 dev->stats.rx_fifo_errors += at91_emac_read(AT91_EMAC_DRFC); /* Receive buffer not available */
832 dev->stats.rx_errors += (ale + lenerr + seqe
833 + at91_emac_read(AT91_EMAC_CDE) + at91_emac_read(AT91_EMAC_RJB));
835 dev->stats.tx_packets += at91_emac_read(AT91_EMAC_FRA); /* Frames successfully transmitted */
836 dev->stats.tx_fifo_errors += at91_emac_read(AT91_EMAC_TUE); /* Transmit FIFO underruns */
837 dev->stats.tx_carrier_errors += at91_emac_read(AT91_EMAC_CSE); /* Carrier Sense errors */
838 dev->stats.tx_heartbeat_errors += at91_emac_read(AT91_EMAC_SQEE);/* Heartbeat error */
840 lcol = at91_emac_read(AT91_EMAC_LCOL);
841 ecol = at91_emac_read(AT91_EMAC_ECOL);
842 dev->stats.tx_window_errors += lcol; /* Late collisions */
843 dev->stats.tx_aborted_errors += ecol; /* 16 collisions */
845 dev->stats.collisions += (at91_emac_read(AT91_EMAC_SCOL) + at91_emac_read(AT91_EMAC_MCOL) + lcol + ecol);
847 return &dev->stats;
851 * Extract received frame from buffer descriptors and sent to upper layers.
852 * (Called from interrupt context)
854 static void at91ether_rx(struct net_device *dev)
856 struct at91_private *lp = netdev_priv(dev);
857 struct recv_desc_bufs *dlist;
858 unsigned char *p_recv;
859 struct sk_buff *skb;
860 unsigned int pktlen;
862 dlist = lp->dlist;
863 while (dlist->descriptors[lp->rxBuffIndex].addr & EMAC_DESC_DONE) {
864 p_recv = dlist->recv_buf[lp->rxBuffIndex];
865 pktlen = dlist->descriptors[lp->rxBuffIndex].size & 0x7ff; /* Length of frame including FCS */
866 skb = dev_alloc_skb(pktlen + 2);
867 if (skb != NULL) {
868 skb_reserve(skb, 2);
869 memcpy(skb_put(skb, pktlen), p_recv, pktlen);
871 skb->protocol = eth_type_trans(skb, dev);
872 dev->stats.rx_bytes += pktlen;
873 netif_rx(skb);
875 else {
876 dev->stats.rx_dropped += 1;
877 printk(KERN_NOTICE "%s: Memory squeeze, dropping packet.\n", dev->name);
880 if (dlist->descriptors[lp->rxBuffIndex].size & EMAC_MULTICAST)
881 dev->stats.multicast++;
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++;
892 * MAC interrupt handler
894 static irqreturn_t at91ether_interrupt(int irq, void *dev_id)
896 struct net_device *dev = (struct net_device *) dev_id;
897 struct at91_private *lp = netdev_priv(dev);
898 unsigned long intstatus, ctl;
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);
904 if (intstatus & AT91_EMAC_RCOM) /* Receive complete */
905 at91ether_rx(dev);
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 dev->stats.tx_errors += 1;
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);
917 netif_wake_queue(dev);
920 if (intstatus & AT91_EMAC_RBNA) {
921 ctl = at91_emac_read(AT91_EMAC_CTL);
922 at91_emac_write(AT91_EMAC_CTL, ctl & ~AT91_EMAC_RE);
923 at91_emac_write(AT91_EMAC_CTL, ctl | AT91_EMAC_RE);
926 if (intstatus & AT91_EMAC_ROVR)
927 printk("%s: ROVR error\n", dev->name);
929 return IRQ_HANDLED;
932 #ifdef CONFIG_NET_POLL_CONTROLLER
933 static void at91ether_poll_controller(struct net_device *dev)
935 unsigned long flags;
937 local_irq_save(flags);
938 at91ether_interrupt(dev->irq, dev);
939 local_irq_restore(flags);
941 #endif
943 static const struct net_device_ops at91ether_netdev_ops = {
944 .ndo_open = at91ether_open,
945 .ndo_stop = at91ether_close,
946 .ndo_start_xmit = at91ether_start_xmit,
947 .ndo_get_stats = at91ether_stats,
948 .ndo_set_multicast_list = at91ether_set_multicast_list,
949 .ndo_set_mac_address = set_mac_address,
950 .ndo_do_ioctl = at91ether_ioctl,
951 .ndo_validate_addr = eth_validate_addr,
952 .ndo_change_mtu = eth_change_mtu,
953 #ifdef CONFIG_NET_POLL_CONTROLLER
954 .ndo_poll_controller = at91ether_poll_controller,
955 #endif
959 * Initialize the ethernet interface
961 static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_address,
962 struct platform_device *pdev, struct clk *ether_clk)
964 struct at91_eth_data *board_data = pdev->dev.platform_data;
965 struct net_device *dev;
966 struct at91_private *lp;
967 unsigned int val;
968 int res;
970 dev = alloc_etherdev(sizeof(struct at91_private));
971 if (!dev)
972 return -ENOMEM;
974 dev->base_addr = AT91_VA_BASE_EMAC;
975 dev->irq = AT91RM9200_ID_EMAC;
977 /* Install the interrupt handler */
978 if (request_irq(dev->irq, at91ether_interrupt, 0, dev->name, dev)) {
979 free_netdev(dev);
980 return -EBUSY;
983 /* Allocate memory for DMA Receive descriptors */
984 lp = netdev_priv(dev);
985 lp->dlist = (struct recv_desc_bufs *) dma_alloc_coherent(NULL, sizeof(struct recv_desc_bufs), (dma_addr_t *) &lp->dlist_phys, GFP_KERNEL);
986 if (lp->dlist == NULL) {
987 free_irq(dev->irq, dev);
988 free_netdev(dev);
989 return -ENOMEM;
991 lp->board_data = *board_data;
992 lp->ether_clk = ether_clk;
993 platform_set_drvdata(pdev, dev);
995 spin_lock_init(&lp->lock);
997 ether_setup(dev);
998 dev->netdev_ops = &at91ether_netdev_ops;
999 dev->ethtool_ops = &at91ether_ethtool_ops;
1001 SET_NETDEV_DEV(dev, &pdev->dev);
1003 get_mac_address(dev); /* Get ethernet address and store it in dev->dev_addr */
1004 update_mac_address(dev); /* Program ethernet address into MAC */
1006 at91_emac_write(AT91_EMAC_CTL, 0);
1008 if (lp->board_data.is_rmii)
1009 at91_emac_write(AT91_EMAC_CFG, AT91_EMAC_CLK_DIV32 | AT91_EMAC_BIG | AT91_EMAC_RMII);
1010 else
1011 at91_emac_write(AT91_EMAC_CFG, AT91_EMAC_CLK_DIV32 | AT91_EMAC_BIG);
1013 /* Perform PHY-specific initialization */
1014 spin_lock_irq(&lp->lock);
1015 enable_mdi();
1016 if ((phy_type == MII_DM9161_ID) || (lp->phy_type == MII_DM9161A_ID)) {
1017 read_phy(phy_address, MII_DSCR_REG, &val);
1018 if ((val & (1 << 10)) == 0) /* DSCR bit 10 is 0 -- fiber mode */
1019 lp->phy_media = PORT_FIBRE;
1020 } else if (machine_is_csb337()) {
1021 /* mix link activity status into LED2 link state */
1022 write_phy(phy_address, MII_LEDCTRL_REG, 0x0d22);
1023 } else if (machine_is_ecbat91())
1024 write_phy(phy_address, MII_LEDCTRL_REG, 0x156A);
1026 disable_mdi();
1027 spin_unlock_irq(&lp->lock);
1029 lp->mii.dev = dev; /* Support for ethtool */
1030 lp->mii.mdio_read = mdio_read;
1031 lp->mii.mdio_write = mdio_write;
1032 lp->mii.phy_id = phy_address;
1033 lp->mii.phy_id_mask = 0x1f;
1034 lp->mii.reg_num_mask = 0x1f;
1036 lp->phy_type = phy_type; /* Type of PHY connected */
1037 lp->phy_address = phy_address; /* MDI address of PHY */
1039 /* Register the network interface */
1040 res = register_netdev(dev);
1041 if (res) {
1042 free_irq(dev->irq, dev);
1043 free_netdev(dev);
1044 dma_free_coherent(NULL, sizeof(struct recv_desc_bufs), lp->dlist, (dma_addr_t)lp->dlist_phys);
1045 return res;
1048 /* Determine current link speed */
1049 spin_lock_irq(&lp->lock);
1050 enable_mdi();
1051 update_linkspeed(dev, 0);
1052 disable_mdi();
1053 spin_unlock_irq(&lp->lock);
1054 netif_carrier_off(dev); /* will be enabled in open() */
1056 /* If board has no PHY IRQ, use a timer to poll the PHY */
1057 if (!lp->board_data.phy_irq_pin) {
1058 init_timer(&lp->check_timer);
1059 lp->check_timer.data = (unsigned long)dev;
1060 lp->check_timer.function = at91ether_check_link;
1061 } else if (lp->board_data.phy_irq_pin >= 32)
1062 gpio_request(lp->board_data.phy_irq_pin, "ethernet_phy");
1064 /* Display ethernet banner */
1065 printk(KERN_INFO "%s: AT91 ethernet at 0x%08x int=%d %s%s (%pM)\n",
1066 dev->name, (uint) dev->base_addr, dev->irq,
1067 at91_emac_read(AT91_EMAC_CFG) & AT91_EMAC_SPD ? "100-" : "10-",
1068 at91_emac_read(AT91_EMAC_CFG) & AT91_EMAC_FD ? "FullDuplex" : "HalfDuplex",
1069 dev->dev_addr);
1070 if ((phy_type == MII_DM9161_ID) || (lp->phy_type == MII_DM9161A_ID))
1071 printk(KERN_INFO "%s: Davicom 9161 PHY %s\n", dev->name, (lp->phy_media == PORT_FIBRE) ? "(Fiber)" : "(Copper)");
1072 else if (phy_type == MII_LXT971A_ID)
1073 printk(KERN_INFO "%s: Intel LXT971A PHY\n", dev->name);
1074 else if (phy_type == MII_RTL8201_ID)
1075 printk(KERN_INFO "%s: Realtek RTL8201(B)L PHY\n", dev->name);
1076 else if (phy_type == MII_BCM5221_ID)
1077 printk(KERN_INFO "%s: Broadcom BCM5221 PHY\n", dev->name);
1078 else if (phy_type == MII_DP83847_ID)
1079 printk(KERN_INFO "%s: National Semiconductor DP83847 PHY\n", dev->name);
1080 else if (phy_type == MII_DP83848_ID)
1081 printk(KERN_INFO "%s: National Semiconductor DP83848 PHY\n", dev->name);
1082 else if (phy_type == MII_AC101L_ID)
1083 printk(KERN_INFO "%s: Altima AC101L PHY\n", dev->name);
1084 else if (phy_type == MII_KS8721_ID)
1085 printk(KERN_INFO "%s: Micrel KS8721 PHY\n", dev->name);
1086 else if (phy_type == MII_T78Q21x3_ID)
1087 printk(KERN_INFO "%s: Teridian 78Q21x3 PHY\n", dev->name);
1088 else if (phy_type == MII_LAN83C185_ID)
1089 printk(KERN_INFO "%s: SMSC LAN83C185 PHY\n", dev->name);
1091 return 0;
1095 * Detect MAC and PHY and perform initialization
1097 static int __init at91ether_probe(struct platform_device *pdev)
1099 unsigned int phyid1, phyid2;
1100 int detected = -1;
1101 unsigned long phy_id;
1102 unsigned short phy_address = 0;
1103 struct clk *ether_clk;
1105 ether_clk = clk_get(&pdev->dev, "ether_clk");
1106 if (IS_ERR(ether_clk)) {
1107 printk(KERN_ERR "at91_ether: no clock defined\n");
1108 return -ENODEV;
1110 clk_enable(ether_clk); /* Enable Peripheral clock */
1112 while ((detected != 0) && (phy_address < 32)) {
1113 /* Read the PHY ID registers */
1114 enable_mdi();
1115 read_phy(phy_address, MII_PHYSID1, &phyid1);
1116 read_phy(phy_address, MII_PHYSID2, &phyid2);
1117 disable_mdi();
1119 phy_id = (phyid1 << 16) | (phyid2 & 0xfff0);
1120 switch (phy_id) {
1121 case MII_DM9161_ID: /* Davicom 9161: PHY_ID1 = 0x181, PHY_ID2 = B881 */
1122 case MII_DM9161A_ID: /* Davicom 9161A: PHY_ID1 = 0x181, PHY_ID2 = B8A0 */
1123 case MII_LXT971A_ID: /* Intel LXT971A: PHY_ID1 = 0x13, PHY_ID2 = 78E0 */
1124 case MII_RTL8201_ID: /* Realtek RTL8201: PHY_ID1 = 0, PHY_ID2 = 0x8201 */
1125 case MII_BCM5221_ID: /* Broadcom BCM5221: PHY_ID1 = 0x40, PHY_ID2 = 0x61e0 */
1126 case MII_DP83847_ID: /* National Semiconductor DP83847: */
1127 case MII_DP83848_ID: /* National Semiconductor DP83848: */
1128 case MII_AC101L_ID: /* Altima AC101L: PHY_ID1 = 0x22, PHY_ID2 = 0x5520 */
1129 case MII_KS8721_ID: /* Micrel KS8721: PHY_ID1 = 0x22, PHY_ID2 = 0x1610 */
1130 case MII_T78Q21x3_ID: /* Teridian 78Q21x3: PHY_ID1 = 0x0E, PHY_ID2 = 7237 */
1131 case MII_LAN83C185_ID: /* SMSC LAN83C185: PHY_ID1 = 0x0007, PHY_ID2 = 0xC0A1 */
1132 detected = at91ether_setup(phy_id, phy_address, pdev, ether_clk);
1133 break;
1136 phy_address++;
1139 clk_disable(ether_clk); /* Disable Peripheral clock */
1141 return detected;
1144 static int __devexit at91ether_remove(struct platform_device *pdev)
1146 struct net_device *dev = platform_get_drvdata(pdev);
1147 struct at91_private *lp = netdev_priv(dev);
1149 if (lp->board_data.phy_irq_pin >= 32)
1150 gpio_free(lp->board_data.phy_irq_pin);
1152 unregister_netdev(dev);
1153 free_irq(dev->irq, dev);
1154 dma_free_coherent(NULL, sizeof(struct recv_desc_bufs), lp->dlist, (dma_addr_t)lp->dlist_phys);
1155 clk_put(lp->ether_clk);
1157 platform_set_drvdata(pdev, NULL);
1158 free_netdev(dev);
1159 return 0;
1162 #ifdef CONFIG_PM
1164 static int at91ether_suspend(struct platform_device *pdev, pm_message_t mesg)
1166 struct net_device *net_dev = platform_get_drvdata(pdev);
1167 struct at91_private *lp = netdev_priv(net_dev);
1168 int phy_irq = lp->board_data.phy_irq_pin;
1170 if (netif_running(net_dev)) {
1171 if (phy_irq)
1172 disable_irq(phy_irq);
1174 netif_stop_queue(net_dev);
1175 netif_device_detach(net_dev);
1177 clk_disable(lp->ether_clk);
1179 return 0;
1182 static int at91ether_resume(struct platform_device *pdev)
1184 struct net_device *net_dev = platform_get_drvdata(pdev);
1185 struct at91_private *lp = netdev_priv(net_dev);
1186 int phy_irq = lp->board_data.phy_irq_pin;
1188 if (netif_running(net_dev)) {
1189 clk_enable(lp->ether_clk);
1191 netif_device_attach(net_dev);
1192 netif_start_queue(net_dev);
1194 if (phy_irq)
1195 enable_irq(phy_irq);
1197 return 0;
1200 #else
1201 #define at91ether_suspend NULL
1202 #define at91ether_resume NULL
1203 #endif
1205 static struct platform_driver at91ether_driver = {
1206 .remove = __devexit_p(at91ether_remove),
1207 .suspend = at91ether_suspend,
1208 .resume = at91ether_resume,
1209 .driver = {
1210 .name = DRV_NAME,
1211 .owner = THIS_MODULE,
1215 static int __init at91ether_init(void)
1217 return platform_driver_probe(&at91ether_driver, at91ether_probe);
1220 static void __exit at91ether_exit(void)
1222 platform_driver_unregister(&at91ether_driver);
1225 module_init(at91ether_init)
1226 module_exit(at91ether_exit)
1228 MODULE_LICENSE("GPL");
1229 MODULE_DESCRIPTION("AT91RM9200 EMAC Ethernet driver");
1230 MODULE_AUTHOR("Andrew Victor");
1231 MODULE_ALIAS("platform:" DRV_NAME);