natsemi: fix MMIO for PPC 44x platforms
[safe/jmp/linux-2.6] / drivers / net / fec.c
index 0ba9f77..d7a3ea8 100644 (file)
@@ -25,7 +25,6 @@
  * Copyright (c) 2004-2006 Macq Electronique SA.
  */
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/string.h>
@@ -48,6 +47,7 @@
 #include <asm/uaccess.h>
 #include <asm/io.h>
 #include <asm/pgtable.h>
+#include <asm/cacheflush.h>
 
 #if defined(CONFIG_M523x) || defined(CONFIG_M527x) || \
     defined(CONFIG_M5272) || defined(CONFIG_M528x) || \
@@ -99,8 +99,6 @@ static unsigned char  fec_mac_default[] = {
 #define        FEC_FLASHMAC    0xf0006006
 #elif defined(CONFIG_GILBARCONAP) || defined(CONFIG_SCALES)
 #define        FEC_FLASHMAC    0xf0006000
-#elif defined (CONFIG_MTD_KeyTechnology)
-#define        FEC_FLASHMAC    0xffe04000
 #elif defined(CONFIG_CANCam)
 #define        FEC_FLASHMAC    0xf0020000
 #elif defined (CONFIG_M5272C3)
@@ -192,6 +190,8 @@ struct fec_enet_private {
        /* Hardware registers of the FEC device */
        volatile fec_t  *hwp;
 
+       struct net_device *netdev;
+
        /* The saved address of a sent-in-place packet/buffer, for skfree(). */
        unsigned char *tx_bounce[TX_RING_SIZE];
        struct  sk_buff* tx_skbuff[TX_RING_SIZE];
@@ -204,7 +204,6 @@ struct fec_enet_private {
        cbd_t   *tx_bd_base;
        cbd_t   *cur_rx, *cur_tx;               /* The next free ring entry */
        cbd_t   *dirty_tx;      /* The ring entries to be free()ed. */
-       struct  net_device_stats stats;
        uint    tx_full;
        spinlock_t lock;
 
@@ -230,11 +229,10 @@ struct fec_enet_private {
 static int fec_enet_open(struct net_device *dev);
 static int fec_enet_start_xmit(struct sk_buff *skb, struct net_device *dev);
 static void fec_enet_mii(struct net_device *dev);
-static irqreturn_t fec_enet_interrupt(int irq, void * dev_id, struct pt_regs * regs);
+static irqreturn_t fec_enet_interrupt(int irq, void * dev_id);
 static void fec_enet_tx(struct net_device *dev);
 static void fec_enet_rx(struct net_device *dev);
 static int fec_enet_close(struct net_device *dev);
-static struct net_device_stats *fec_enet_get_stats(struct net_device *dev);
 static void set_multicast_list(struct net_device *dev);
 static void fec_restart(struct net_device *dev, int duplex);
 static void fec_stop(struct net_device *dev);
@@ -257,7 +255,7 @@ static mii_list_t   *mii_free;
 static mii_list_t      *mii_head;
 static mii_list_t      *mii_tail;
 
-static int     mii_queue(struct net_device *dev, int request, 
+static int     mii_queue(struct net_device *dev, int request,
                                void (*func)(uint, struct net_device *));
 
 /* Make MII read/write commands for the FEC.
@@ -278,7 +276,7 @@ static int  mii_queue(struct net_device *dev, int request,
 #define MII_REG_SR          1  /* Status Register                          */
 #define MII_REG_PHYIR1      2  /* PHY Identification Register 1            */
 #define MII_REG_PHYIR2      3  /* PHY Identification Register 2            */
-#define MII_REG_ANAR        4  /* A-N Advertisement Register               */ 
+#define MII_REG_ANAR        4  /* A-N Advertisement Register               */
 #define MII_REG_ANLPAR      5  /* A-N Link Partner Ability Register        */
 #define MII_REG_ANER        6  /* A-N Expansion Register                   */
 #define MII_REG_ANNPTR      7  /* A-N Next Page Transmit Register          */
@@ -290,18 +288,18 @@ static int        mii_queue(struct net_device *dev, int request,
 #define PHY_CONF_LOOP  0x0002  /* 1 loopback mode enabled */
 #define PHY_CONF_SPMASK        0x00f0  /* mask for speed */
 #define PHY_CONF_10HDX 0x0010  /* 10 Mbit half duplex supported */
-#define PHY_CONF_10FDX 0x0020  /* 10 Mbit full duplex supported */ 
+#define PHY_CONF_10FDX 0x0020  /* 10 Mbit full duplex supported */
 #define PHY_CONF_100HDX        0x0040  /* 100 Mbit half duplex supported */
-#define PHY_CONF_100FDX        0x0080  /* 100 Mbit full duplex supported */ 
+#define PHY_CONF_100FDX        0x0080  /* 100 Mbit full duplex supported */
 
 #define PHY_STAT_LINK  0x0100  /* 1 up - 0 down */
 #define PHY_STAT_FAULT 0x0200  /* 1 remote fault */
 #define PHY_STAT_ANC   0x0400  /* 1 auto-negotiation complete  */
 #define PHY_STAT_SPMASK        0xf000  /* mask for speed */
 #define PHY_STAT_10HDX 0x1000  /* 10 Mbit half duplex selected */
-#define PHY_STAT_10FDX 0x2000  /* 10 Mbit full duplex selected */ 
+#define PHY_STAT_10FDX 0x2000  /* 10 Mbit full duplex selected */
 #define PHY_STAT_100HDX        0x4000  /* 100 Mbit half duplex selected */
-#define PHY_STAT_100FDX        0x8000  /* 100 Mbit full duplex selected */ 
+#define PHY_STAT_100FDX        0x8000  /* 100 Mbit full duplex selected */
 
 
 static int
@@ -310,6 +308,7 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
        struct fec_enet_private *fep;
        volatile fec_t  *fecp;
        volatile cbd_t  *bdp;
+       unsigned short  status;
 
        fep = netdev_priv(dev);
        fecp = (volatile fec_t*)dev->base_addr;
@@ -322,8 +321,9 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
        /* Fill in a Tx ring entry */
        bdp = fep->cur_tx;
 
+       status = bdp->cbd_sc;
 #ifndef final_version
-       if (bdp->cbd_sc & BD_ENET_TX_READY) {
+       if (status & BD_ENET_TX_READY) {
                /* Ooops.  All transmit buffers are full.  Bail out.
                 * This should not happen, since dev->tbusy should be set.
                 */
@@ -334,7 +334,7 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
 
        /* Clear all of the status flags.
         */
-       bdp->cbd_sc &= ~BD_ENET_TX_STATS;
+       status &= ~BD_ENET_TX_STATS;
 
        /* Set buffer length and buffer pointer.
        */
@@ -357,9 +357,9 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
        */
        fep->tx_skbuff[fep->skb_cur] = skb;
 
-       fep->stats.tx_bytes += skb->len;
+       dev->stats.tx_bytes += skb->len;
        fep->skb_cur = (fep->skb_cur+1) & TX_RING_MOD_MASK;
-       
+
        /* Push the data cache so the CPM does not get stale memory
         * data.
         */
@@ -368,21 +368,22 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
 
        spin_lock_irq(&fep->lock);
 
-       /* Send it on its way.  Tell FEC its ready, interrupt when done,
-        * its the last BD of the frame, and to put the CRC on the end.
+       /* Send it on its way.  Tell FEC it's ready, interrupt when done,
+        * it's the last BD of the frame, and to put the CRC on the end.
         */
 
-       bdp->cbd_sc |= (BD_ENET_TX_READY | BD_ENET_TX_INTR
+       status |= (BD_ENET_TX_READY | BD_ENET_TX_INTR
                        | BD_ENET_TX_LAST | BD_ENET_TX_TC);
+       bdp->cbd_sc = status;
 
        dev->trans_start = jiffies;
 
        /* Trigger transmission start */
-       fecp->fec_x_des_active = 0x01000000;
+       fecp->fec_x_des_active = 0;
 
        /* If this was the last BD in the ring, start at the beginning again.
        */
-       if (bdp->cbd_sc & BD_ENET_TX_WRAP) {
+       if (status & BD_ENET_TX_WRAP) {
                bdp = fep->tx_bd_base;
        } else {
                bdp++;
@@ -406,7 +407,7 @@ fec_timeout(struct net_device *dev)
        struct fec_enet_private *fep = netdev_priv(dev);
 
        printk("%s: transmit timed out.\n", dev->name);
-       fep->stats.tx_errors++;
+       dev->stats.tx_errors++;
 #ifndef final_version
        {
        int     i;
@@ -420,7 +421,7 @@ fec_timeout(struct net_device *dev)
        bdp = fep->tx_bd_base;
        printk(" tx: %u buffers\n",  TX_RING_SIZE);
        for (i = 0 ; i < TX_RING_SIZE; i++) {
-               printk("  %08x: %04x %04x %08x\n", 
+               printk("  %08x: %04x %04x %08x\n",
                       (uint) bdp,
                       bdp->cbd_sc,
                       bdp->cbd_datlen,
@@ -448,7 +449,7 @@ fec_timeout(struct net_device *dev)
  * This is called from the MPC core interrupt.
  */
 static irqreturn_t
-fec_enet_interrupt(int irq, void * dev_id, struct pt_regs * regs)
+fec_enet_interrupt(int irq, void * dev_id)
 {
        struct  net_device *dev = dev_id;
        volatile fec_t  *fecp;
@@ -482,7 +483,7 @@ fec_enet_interrupt(int irq, void * dev_id, struct pt_regs * regs)
                        handled = 1;
                        fec_enet_mii(dev);
                }
-       
+
        }
        return IRQ_RETVAL(handled);
 }
@@ -493,58 +494,59 @@ fec_enet_tx(struct net_device *dev)
 {
        struct  fec_enet_private *fep;
        volatile cbd_t  *bdp;
+       unsigned short status;
        struct  sk_buff *skb;
 
        fep = netdev_priv(dev);
        spin_lock(&fep->lock);
        bdp = fep->dirty_tx;
 
-       while ((bdp->cbd_sc&BD_ENET_TX_READY) == 0) {
+       while (((status = bdp->cbd_sc) & BD_ENET_TX_READY) == 0) {
                if (bdp == fep->cur_tx && fep->tx_full == 0) break;
 
                skb = fep->tx_skbuff[fep->skb_dirty];
                /* Check for errors. */
-               if (bdp->cbd_sc & (BD_ENET_TX_HB | BD_ENET_TX_LC |
+               if (status & (BD_ENET_TX_HB | BD_ENET_TX_LC |
                                   BD_ENET_TX_RL | BD_ENET_TX_UN |
                                   BD_ENET_TX_CSL)) {
-                       fep->stats.tx_errors++;
-                       if (bdp->cbd_sc & BD_ENET_TX_HB)  /* No heartbeat */
-                               fep->stats.tx_heartbeat_errors++;
-                       if (bdp->cbd_sc & BD_ENET_TX_LC)  /* Late collision */
-                               fep->stats.tx_window_errors++;
-                       if (bdp->cbd_sc & BD_ENET_TX_RL)  /* Retrans limit */
-                               fep->stats.tx_aborted_errors++;
-                       if (bdp->cbd_sc & BD_ENET_TX_UN)  /* Underrun */
-                               fep->stats.tx_fifo_errors++;
-                       if (bdp->cbd_sc & BD_ENET_TX_CSL) /* Carrier lost */
-                               fep->stats.tx_carrier_errors++;
+                       dev->stats.tx_errors++;
+                       if (status & BD_ENET_TX_HB)  /* No heartbeat */
+                               dev->stats.tx_heartbeat_errors++;
+                       if (status & BD_ENET_TX_LC)  /* Late collision */
+                               dev->stats.tx_window_errors++;
+                       if (status & BD_ENET_TX_RL)  /* Retrans limit */
+                               dev->stats.tx_aborted_errors++;
+                       if (status & BD_ENET_TX_UN)  /* Underrun */
+                               dev->stats.tx_fifo_errors++;
+                       if (status & BD_ENET_TX_CSL) /* Carrier lost */
+                               dev->stats.tx_carrier_errors++;
                } else {
-                       fep->stats.tx_packets++;
+                       dev->stats.tx_packets++;
                }
 
 #ifndef final_version
-               if (bdp->cbd_sc & BD_ENET_TX_READY)
+               if (status & BD_ENET_TX_READY)
                        printk("HEY! Enet xmit interrupt and TX_READY.\n");
 #endif
                /* Deferred means some collisions occurred during transmit,
                 * but we eventually sent the packet OK.
                 */
-               if (bdp->cbd_sc & BD_ENET_TX_DEF)
-                       fep->stats.collisions++;
-           
+               if (status & BD_ENET_TX_DEF)
+                       dev->stats.collisions++;
+
                /* Free the sk buffer associated with this last transmit.
                 */
                dev_kfree_skb_any(skb);
                fep->tx_skbuff[fep->skb_dirty] = NULL;
                fep->skb_dirty = (fep->skb_dirty + 1) & TX_RING_MOD_MASK;
-           
+
                /* Update pointer to next buffer descriptor to be transmitted.
                 */
-               if (bdp->cbd_sc & BD_ENET_TX_WRAP)
+               if (status & BD_ENET_TX_WRAP)
                        bdp = fep->tx_bd_base;
                else
                        bdp++;
-           
+
                /* Since we have freed up a buffer, the ring is no longer
                 * full.
                 */
@@ -570,10 +572,15 @@ fec_enet_rx(struct net_device *dev)
        struct  fec_enet_private *fep;
        volatile fec_t  *fecp;
        volatile cbd_t *bdp;
+       unsigned short status;
        struct  sk_buff *skb;
        ushort  pkt_len;
        __u8 *data;
 
+#ifdef CONFIG_M532x
+       flush_cache_all();
+#endif
+
        fep = netdev_priv(dev);
        fecp = (volatile fec_t*)dev->base_addr;
 
@@ -582,13 +589,13 @@ fec_enet_rx(struct net_device *dev)
         */
        bdp = fep->cur_rx;
 
-while (!(bdp->cbd_sc & BD_ENET_RX_EMPTY)) {
+while (!((status = bdp->cbd_sc) & BD_ENET_RX_EMPTY)) {
 
 #ifndef final_version
        /* Since we have allocated space to hold a complete frame,
         * the last indicator should be set.
         */
-       if ((bdp->cbd_sc & BD_ENET_RX_LAST) == 0)
+       if ((status & BD_ENET_RX_LAST) == 0)
                printk("FEC ENET: rcv is not +last\n");
 #endif
 
@@ -596,36 +603,36 @@ while (!(bdp->cbd_sc & BD_ENET_RX_EMPTY)) {
                goto rx_processing_done;
 
        /* Check for errors. */
-       if (bdp->cbd_sc & (BD_ENET_RX_LG | BD_ENET_RX_SH | BD_ENET_RX_NO |
+       if (status & (BD_ENET_RX_LG | BD_ENET_RX_SH | BD_ENET_RX_NO |
                           BD_ENET_RX_CR | BD_ENET_RX_OV)) {
-               fep->stats.rx_errors++;       
-               if (bdp->cbd_sc & (BD_ENET_RX_LG | BD_ENET_RX_SH)) {
+               dev->stats.rx_errors++;
+               if (status & (BD_ENET_RX_LG | BD_ENET_RX_SH)) {
                /* Frame too long or too short. */
-                       fep->stats.rx_length_errors++;
+                       dev->stats.rx_length_errors++;
                }
-               if (bdp->cbd_sc & BD_ENET_RX_NO)        /* Frame alignment */
-                       fep->stats.rx_frame_errors++;
-               if (bdp->cbd_sc & BD_ENET_RX_CR)        /* CRC Error */
-                       fep->stats.rx_crc_errors++;
-               if (bdp->cbd_sc & BD_ENET_RX_OV)        /* FIFO overrun */
-                       fep->stats.rx_crc_errors++;
+               if (status & BD_ENET_RX_NO)     /* Frame alignment */
+                       dev->stats.rx_frame_errors++;
+               if (status & BD_ENET_RX_CR)     /* CRC Error */
+                       dev->stats.rx_crc_errors++;
+               if (status & BD_ENET_RX_OV)     /* FIFO overrun */
+                       dev->stats.rx_fifo_errors++;
        }
 
        /* Report late collisions as a frame error.
         * On this error, the BD is closed, but we don't know what we
         * have in the buffer.  So, just drop this frame on the floor.
         */
-       if (bdp->cbd_sc & BD_ENET_RX_CL) {
-               fep->stats.rx_errors++;
-               fep->stats.rx_frame_errors++;
+       if (status & BD_ENET_RX_CL) {
+               dev->stats.rx_errors++;
+               dev->stats.rx_frame_errors++;
                goto rx_processing_done;
        }
 
        /* Process the incoming frame.
         */
-       fep->stats.rx_packets++;
+       dev->stats.rx_packets++;
        pkt_len = bdp->cbd_datlen;
-       fep->stats.rx_bytes += pkt_len;
+       dev->stats.rx_bytes += pkt_len;
        data = (__u8*)__va(bdp->cbd_bufaddr);
 
        /* This does 16 byte alignment, exactly what we need.
@@ -637,13 +644,10 @@ while (!(bdp->cbd_sc & BD_ENET_RX_EMPTY)) {
 
        if (skb == NULL) {
                printk("%s: Memory squeeze, dropping packet.\n", dev->name);
-               fep->stats.rx_dropped++;
+               dev->stats.rx_dropped++;
        } else {
-               skb->dev = dev;
                skb_put(skb,pkt_len-4); /* Make room */
-               eth_copy_and_sum(skb,
-                                (unsigned char *)__va(bdp->cbd_bufaddr),
-                                pkt_len-4, 0);
+               skb_copy_to_linear_data(skb, data, pkt_len-4);
                skb->protocol=eth_type_trans(skb,dev);
                netif_rx(skb);
        }
@@ -651,27 +655,28 @@ while (!(bdp->cbd_sc & BD_ENET_RX_EMPTY)) {
 
        /* Clear the status flags for this buffer.
        */
-       bdp->cbd_sc &= ~BD_ENET_RX_STATS;
+       status &= ~BD_ENET_RX_STATS;
 
        /* Mark the buffer empty.
        */
-       bdp->cbd_sc |= BD_ENET_RX_EMPTY;
+       status |= BD_ENET_RX_EMPTY;
+       bdp->cbd_sc = status;
 
        /* Update BD pointer to next entry.
        */
-       if (bdp->cbd_sc & BD_ENET_RX_WRAP)
+       if (status & BD_ENET_RX_WRAP)
                bdp = fep->rx_bd_base;
        else
                bdp++;
-       
+
 #if 1
        /* Doing this here will keep the FEC running while we process
         * incoming frames.  On a heavily loaded network, we should be
         * able to keep up at the expense of system resources.
         */
-       fecp->fec_r_des_active = 0x01000000;
+       fecp->fec_r_des_active = 0;
 #endif
-   } /* while (!(bdp->cbd_sc & BD_ENET_RX_EMPTY)) */
+   } /* while (!((status = bdp->cbd_sc) & BD_ENET_RX_EMPTY)) */
        fep->cur_rx = (cbd_t *)bdp;
 
 #if 0
@@ -682,11 +687,12 @@ while (!(bdp->cbd_sc & BD_ENET_RX_EMPTY)) {
         * our way back to the interrupt return only to come right back
         * here.
         */
-       fecp->fec_r_des_active = 0x01000000;
+       fecp->fec_r_des_active = 0;
 #endif
 }
 
 
+/* called from interrupt context */
 static void
 fec_enet_mii(struct net_device *dev)
 {
@@ -698,10 +704,12 @@ fec_enet_mii(struct net_device *dev)
        fep = netdev_priv(dev);
        ep = fep->hwp;
        mii_reg = ep->fec_mii_data;
-       
+
+       spin_lock(&fep->lock);
+
        if ((mip = mii_head) == NULL) {
                printk("MII and no head!\n");
-               return;
+               goto unlock;
        }
 
        if (mip->mii_func != NULL)
@@ -713,6 +721,9 @@ fec_enet_mii(struct net_device *dev)
 
        if ((mip = mii_head) != NULL)
                ep->fec_mii_data = mip->mii_regval;
+
+unlock:
+       spin_unlock(&fep->lock);
 }
 
 static int
@@ -730,8 +741,7 @@ mii_queue(struct net_device *dev, int regval, void (*func)(uint, struct net_devi
 
        retval = 0;
 
-       save_flags(flags);
-       cli();
+       spin_lock_irqsave(&fep->lock,flags);
 
        if ((mip = mii_free) != NULL) {
                mii_free = mip->mii_next;
@@ -741,31 +751,26 @@ mii_queue(struct net_device *dev, int regval, void (*func)(uint, struct net_devi
                if (mii_head) {
                        mii_tail->mii_next = mip;
                        mii_tail = mip;
-               }
-               else {
+               } else {
                        mii_head = mii_tail = mip;
                        fep->hwp->fec_mii_data = regval;
                }
-       }
-       else {
+       } else {
                retval = 1;
        }
 
-       restore_flags(flags);
+       spin_unlock_irqrestore(&fep->lock,flags);
 
        return(retval);
 }
 
 static void mii_do_cmd(struct net_device *dev, const phy_cmd_t *c)
 {
-       int k;
-
        if(!c)
                return;
 
-       for(k = 0; (c+k)->mii_data != mk_mii_end; k++) {
-               mii_queue(dev, (c+k)->mii_data, (c+k)->funct);
-       }
+       for (; c->mii_data != mk_mii_end; c++)
+               mii_queue(dev, c->mii_data, c->funct);
 }
 
 static void mii_parse_sr(uint mii_reg, struct net_device *dev)
@@ -782,7 +787,6 @@ static void mii_parse_sr(uint mii_reg, struct net_device *dev)
                status |= PHY_STAT_FAULT;
        if (mii_reg & 0x0020)
                status |= PHY_STAT_ANC;
-
        *s = status;
 }
 
@@ -874,14 +878,14 @@ static phy_cmd_t const phy_cmd_lxt970_shutdown[] = { /* disable interrupts */
                { mk_mii_end, }
        };
 static phy_info_t const phy_info_lxt970 = {
-       .id = 0x07810000, 
+       .id = 0x07810000,
        .name = "LXT970",
        .config = phy_cmd_lxt970_config,
        .startup = phy_cmd_lxt970_startup,
        .ack_int = phy_cmd_lxt970_ack_int,
        .shutdown = phy_cmd_lxt970_shutdown
 };
-       
+
 /* ------------------------------------------------------------------------- */
 /* The Level one LXT971 is used on some of my custom boards                  */
 
@@ -894,7 +898,7 @@ static phy_info_t const phy_info_lxt970 = {
 #define MII_LXT971_LCR       20  /* LED Control Register      */
 #define MII_LXT971_TCR       30  /* Transmit Control Register */
 
-/* 
+/*
  * I had some nice ideas of running the MDIO faster...
  * The 971 should support 8MHz and I tried it, but things acted really
  * weird, so 2.5 MHz ought to be enough for anyone...
@@ -932,9 +936,9 @@ static void mii_parse_lxt971_sr2(uint mii_reg, struct net_device *dev)
 
        *s = status;
 }
-       
+
 static phy_cmd_t const phy_cmd_lxt971_config[] = {
-               /* limit to 10MBit because my prototype board 
+               /* limit to 10MBit because my prototype board
                 * doesn't work with 100. */
                { mk_mii_read(MII_REG_CR), mii_parse_cr },
                { mk_mii_read(MII_REG_ANAR), mii_parse_anar },
@@ -948,7 +952,7 @@ static phy_cmd_t const phy_cmd_lxt971_startup[] = {  /* enable interrupts */
                /* Somehow does the 971 tell me that the link is down
                 * the first read after power-up.
                 * read here to get a valid value in ack_int */
-               { mk_mii_read(MII_REG_SR), mii_parse_sr }, 
+               { mk_mii_read(MII_REG_SR), mii_parse_sr },
                { mk_mii_end, }
        };
 static phy_cmd_t const phy_cmd_lxt971_ack_int[] = {
@@ -964,7 +968,7 @@ static phy_cmd_t const phy_cmd_lxt971_shutdown[] = { /* disable interrupts */
                { mk_mii_end, }
        };
 static phy_info_t const phy_info_lxt971 = {
-       .id = 0x0001378e, 
+       .id = 0x0001378e,
        .name = "LXT971",
        .config = phy_cmd_lxt971_config,
        .startup = phy_cmd_lxt971_startup,
@@ -1003,7 +1007,7 @@ static void mii_parse_qs6612_pcr(uint mii_reg, struct net_device *dev)
 }
 
 static phy_cmd_t const phy_cmd_qs6612_config[] = {
-               /* The PHY powers up isolated on the RPX, 
+               /* The PHY powers up isolated on the RPX,
                 * so send a command to allow operation.
                 */
                { mk_mii_write(MII_QS6612_PCR, 0x0dc0), NULL },
@@ -1033,7 +1037,7 @@ static phy_cmd_t const phy_cmd_qs6612_shutdown[] = { /* disable interrupts */
                { mk_mii_end, }
        };
 static phy_info_t const phy_info_qs6612 = {
-       .id = 0x00181440, 
+       .id = 0x00181440,
        .name = "QS6612",
        .config = phy_cmd_qs6612_config,
        .startup = phy_cmd_qs6612_startup,
@@ -1081,7 +1085,7 @@ static phy_cmd_t const phy_cmd_am79c874_config[] = {
 static phy_cmd_t const phy_cmd_am79c874_startup[] = {  /* enable interrupts */
                { mk_mii_write(MII_AM79C874_ICSR, 0xff00), NULL },
                { mk_mii_write(MII_REG_CR, 0x1200), NULL }, /* autonegotiate */
-               { mk_mii_read(MII_REG_SR), mii_parse_sr }, 
+               { mk_mii_read(MII_REG_SR), mii_parse_sr },
                { mk_mii_end, }
        };
 static phy_cmd_t const phy_cmd_am79c874_ack_int[] = {
@@ -1123,7 +1127,7 @@ static phy_cmd_t const phy_cmd_ks8721bl_config[] = {
 static phy_cmd_t const phy_cmd_ks8721bl_startup[] = {  /* enable interrupts */
                { mk_mii_write(MII_KS8721BL_ICSR, 0xff00), NULL },
                { mk_mii_write(MII_REG_CR, 0x1200), NULL }, /* autonegotiate */
-               { mk_mii_read(MII_REG_SR), mii_parse_sr }, 
+               { mk_mii_read(MII_REG_SR), mii_parse_sr },
                { mk_mii_end, }
        };
 static phy_cmd_t const phy_cmd_ks8721bl_ack_int[] = {
@@ -1138,7 +1142,7 @@ static phy_cmd_t const phy_cmd_ks8721bl_shutdown[] = { /* disable interrupts */
                { mk_mii_end, }
        };
 static phy_info_t const phy_info_ks8721bl = {
-       .id = 0x00022161, 
+       .id = 0x00022161,
        .name = "KS8721BL",
        .config = phy_cmd_ks8721bl_config,
        .startup = phy_cmd_ks8721bl_startup,
@@ -1224,12 +1228,11 @@ static void
 mii_link_interrupt(void *dev_id);
 #else
 static irqreturn_t
-mii_link_interrupt(int irq, void * dev_id, struct pt_regs * regs);
+mii_link_interrupt(int irq, void * dev_id);
 #endif
 #endif
 
 #if defined(CONFIG_M5272)
-
 /*
  *     Code specific to Coldfire 5272 setup.
  */
@@ -1239,7 +1242,7 @@ static void __inline__ fec_request_intrs(struct net_device *dev)
        static const struct idesc {
                char *name;
                unsigned short irq;
-               irqreturn_t (*handler)(int, void *, struct pt_regs *);
+               irq_handler_t handler;
        } *idp, id[] = {
                { "fec(RX)", 86, fec_enet_interrupt },
                { "fec(TX)", 87, fec_enet_interrupt },
@@ -1250,7 +1253,7 @@ static void __inline__ fec_request_intrs(struct net_device *dev)
 
        /* Setup interrupt handlers. */
        for (idp = id; idp->name; idp++) {
-               if (request_irq(idp->irq, idp->handler, 0, idp->name, dev) != 0)
+               if (request_irq(idp->irq, idp->handler, IRQF_DISABLED, idp->name, dev) != 0)
                        printk("FEC: Could not allocate %s IRQ(%d)!\n", idp->name, idp->irq);
        }
 
@@ -1258,7 +1261,7 @@ static void __inline__ fec_request_intrs(struct net_device *dev)
        icrp = (volatile unsigned long *) (MCF_MBAR + MCFSIM_ICR3);
        *icrp = 0x00000ddd;
        icrp = (volatile unsigned long *) (MCF_MBAR + MCFSIM_ICR1);
-       *icrp = (*icrp & 0x70777777) | 0x0d000000;
+       *icrp = 0x0d000000;
 }
 
 static void __inline__ fec_set_mii(struct net_device *dev, struct fec_enet_private *fep)
@@ -1320,7 +1323,7 @@ static void __inline__ fec_disable_phy_intr(void)
 {
        volatile unsigned long *icrp;
        icrp = (volatile unsigned long *) (MCF_MBAR + MCFSIM_ICR1);
-       *icrp = (*icrp & 0x70777777) | 0x08000000;
+       *icrp = 0x08000000;
 }
 
 static void __inline__ fec_phy_ack_intr(void)
@@ -1328,7 +1331,7 @@ static void __inline__ fec_phy_ack_intr(void)
        volatile unsigned long *icrp;
        /* Acknowledge the interrupt */
        icrp = (volatile unsigned long *) (MCF_MBAR + MCFSIM_ICR1);
-       *icrp = (*icrp & 0x77777777) | 0x08000000;
+       *icrp = 0x0d000000;
 }
 
 static void __inline__ fec_localhw_setup(void)
@@ -1379,7 +1382,7 @@ static void __inline__ fec_request_intrs(struct net_device *dev)
 
        /* Setup interrupt handlers. */
        for (idp = id; idp->name; idp++) {
-               if (request_irq(b+idp->irq, fec_enet_interrupt, 0, idp->name, dev) != 0)
+               if (request_irq(b+idp->irq, fec_enet_interrupt, IRQF_DISABLED, idp->name, dev) != 0)
                        printk("FEC: Could not allocate %s IRQ(%d)!\n", idp->name, b+idp->irq);
        }
 
@@ -1387,13 +1390,13 @@ static void __inline__ fec_request_intrs(struct net_device *dev)
        {
                volatile unsigned char  *icrp;
                volatile unsigned long  *imrp;
-               int i;
+               int i, ilip;
 
                b = (fep->index) ? MCFICM_INTC1 : MCFICM_INTC0;
                icrp = (volatile unsigned char *) (MCF_IPSBAR + b +
                        MCFINTC_ICR0);
-               for (i = 23; (i < 36); i++)
-                       icrp[i] = 0x23;
+               for (i = 23, ilip = 0x28; (i < 36); i++)
+                       icrp[i] = ilip--;
 
                imrp = (volatile unsigned long *) (MCF_IPSBAR + b +
                        MCFINTC_IMRH);
@@ -1408,13 +1411,36 @@ static void __inline__ fec_request_intrs(struct net_device *dev)
        {
                volatile u16 *gpio_paspar;
                volatile u8 *gpio_pehlpar;
-  
+
                gpio_paspar = (volatile u16 *) (MCF_IPSBAR + 0x100056);
                gpio_pehlpar = (volatile u16 *) (MCF_IPSBAR + 0x100058);
                *gpio_paspar |= 0x0f00;
                *gpio_pehlpar = 0xc0;
        }
 #endif
+
+#if defined(CONFIG_M527x)
+       /* Set up gpio outputs for MII lines */
+       {
+               volatile u8 *gpio_par_fec;
+               volatile u16 *gpio_par_feci2c;
+
+               gpio_par_feci2c = (volatile u16 *)(MCF_IPSBAR + 0x100082);
+               /* Set up gpio outputs for FEC0 MII lines */
+               gpio_par_fec = (volatile u8 *)(MCF_IPSBAR + 0x100078);
+
+               *gpio_par_feci2c |= 0x0f00;
+               *gpio_par_fec |= 0xc0;
+
+#if defined(CONFIG_FEC2)
+               /* Set up gpio outputs for FEC1 MII lines */
+               gpio_par_fec = (volatile u8 *)(MCF_IPSBAR + 0x100079);
+
+               *gpio_par_feci2c |= 0x00a0;
+               *gpio_par_fec |= 0xc0;
+#endif /* CONFIG_FEC2 */
+       }
+#endif /* CONFIG_M527x */
 }
 
 static void __inline__ fec_set_mii(struct net_device *dev, struct fec_enet_private *fep)
@@ -1527,7 +1553,7 @@ static void __inline__ fec_request_intrs(struct net_device *dev)
 
        /* Setup interrupt handlers. */
        for (idp = id; idp->name; idp++) {
-               if (request_irq(b+idp->irq,fec_enet_interrupt,0,idp->name,dev)!=0)
+               if (request_irq(b+idp->irq, fec_enet_interrupt, IRQF_DISABLED, idp->name,dev) != 0)
                        printk("FEC: Could not allocate %s IRQ(%d)!\n", idp->name, b+idp->irq);
        }
 
@@ -1654,8 +1680,8 @@ static void __inline__ fec_request_intrs(struct net_device *dev)
 
        /* Setup interrupt handlers. */
        for (idp = id; idp->name; idp++) {
-               if (request_irq(b+idp->irq,fec_enet_interrupt,0,idp->name,dev)!=0)
-                       printk("FEC: Could not allocate %s IRQ(%d)!\n", 
+               if (request_irq(b+idp->irq, fec_enet_interrupt, IRQF_DISABLED, idp->name,dev) != 0)
+                       printk("FEC: Could not allocate %s IRQ(%d)!\n",
                                idp->name, b+idp->irq);
        }
 
@@ -1844,10 +1870,10 @@ static void __inline__ fec_set_mii(struct net_device *dev, struct fec_enet_priva
                immap->im_ioport.iop_pddir = 0x1c58;    /* Pre rev. D */
        else
                immap->im_ioport.iop_pddir = 0x1fff;    /* Rev. D and later */
-       
+
        /* Set MII speed to 2.5 MHz
        */
-       fecp->fec_mii_speed = fep->phy_speed = 
+       fecp->fec_mii_speed = fep->phy_speed =
                ((bd->bi_busfreq * 1000000) / 2500000) & 0x7e;
 }
 
@@ -1857,7 +1883,7 @@ static void __inline__ fec_enable_phy_intr(void)
 
        fecp = fep->hwp;
 
-       /* Enable MII command finished interrupt 
+       /* Enable MII command finished interrupt
        */
        fecp->fec_ivec = (FEC_INTERRUPT/2) << 29;
 }
@@ -1929,9 +1955,10 @@ static void mii_display_status(struct net_device *dev)
        printk(".\n");
 }
 
-static void mii_display_config(struct net_device *dev)
+static void mii_display_config(struct work_struct *work)
 {
-       struct fec_enet_private *fep = netdev_priv(dev);
+       struct fec_enet_private *fep = container_of(work, struct fec_enet_private, phy_task);
+       struct net_device *dev = fep->netdev;
        uint status = fep->phy_status;
 
        /*
@@ -1959,15 +1986,16 @@ static void mii_display_config(struct net_device *dev)
 
        if (status & PHY_CONF_LOOP)
                printk(", loopback enabled");
-       
+
        printk(".\n");
 
        fep->sequence_done = 1;
 }
 
-static void mii_relink(struct net_device *dev)
+static void mii_relink(struct work_struct *work)
 {
-       struct fec_enet_private *fep = netdev_priv(dev);
+       struct fec_enet_private *fep = container_of(work, struct fec_enet_private, phy_task);
+       struct net_device *dev = fep->netdev;
        int duplex;
 
        /*
@@ -1981,12 +2009,11 @@ static void mii_relink(struct net_device *dev)
 
        if (fep->link) {
                duplex = 0;
-               if (fep->phy_status 
+               if (fep->phy_status
                    & (PHY_STAT_100FDX | PHY_STAT_10FDX))
                        duplex = 1;
                fec_restart(dev, duplex);
-       }
-       else
+       } else
                fec_stop(dev);
 
 #if 0
@@ -2011,7 +2038,7 @@ static void mii_queue_relink(uint mii_reg, struct net_device *dev)
                return;
 
        fep->mii_phy_task_queued = 1;
-       INIT_WORK(&fep->phy_task, (void*)mii_relink, dev);
+       INIT_WORK(&fep->phy_task, mii_relink);
        schedule_work(&fep->phy_task);
 }
 
@@ -2024,7 +2051,7 @@ static void mii_queue_config(uint mii_reg, struct net_device *dev)
                return;
 
        fep->mii_phy_task_queued = 1;
-       INIT_WORK(&fep->phy_task, (void*)mii_display_config, dev);
+       INIT_WORK(&fep->phy_task, mii_display_config);
        schedule_work(&fep->phy_task);
 }
 
@@ -2058,7 +2085,7 @@ mii_discover_phy3(uint mii_reg, struct net_device *dev)
                printk(" -- %s\n", phy_info[i]->name);
        else
                printk(" -- unknown PHY!\n");
-      
+
        fep->phy = phy_info[i];
        fep->phy_id_done = 1;
 }
@@ -2078,14 +2105,13 @@ mii_discover_phy(uint mii_reg, struct net_device *dev)
 
        if (fep->phy_addr < 32) {
                if ((phytype = (mii_reg & 0xffff)) != 0xffff && phytype != 0) {
-                       
+
                        /* Got first part of ID, now get remainder.
                        */
                        fep->phy_id = phytype << 16;
                        mii_queue(dev, mk_mii_read(MII_REG_PHYIR2),
                                                        mii_discover_phy3);
-               }
-               else {
+               } else {
                        fep->phy_addr++;
                        mii_queue(dev, mk_mii_read(MII_REG_PHYIR1),
                                                        mii_discover_phy);
@@ -2105,7 +2131,7 @@ static void
 mii_link_interrupt(void *dev_id)
 #else
 static irqreturn_t
-mii_link_interrupt(int irq, void * dev_id, struct pt_regs * regs)
+mii_link_interrupt(int irq, void * dev_id)
 #endif
 {
        struct  net_device *dev = dev_id;
@@ -2183,13 +2209,6 @@ fec_enet_close(struct net_device *dev)
        return 0;
 }
 
-static struct net_device_stats *fec_enet_get_stats(struct net_device *dev)
-{
-       struct fec_enet_private *fep = netdev_priv(dev);
-
-       return &fep->stats;
-}
-
 /* Set or clear the multicast filter for this adaptor.
  * Skeleton taken from sunlance driver.
  * The CPM Ethernet implementation allows Multicast as well as individual
@@ -2215,8 +2234,6 @@ static void set_multicast_list(struct net_device *dev)
        ep = fep->hwp;
 
        if (dev->flags&IFF_PROMISC) {
-               /* Log any net taps. */
-               printk("%s: Promiscuous mode enabled.\n", dev->name);
                ep->fec_r_cntrl |= 0x0008;
        } else {
 
@@ -2233,7 +2250,7 @@ static void set_multicast_list(struct net_device *dev)
                        */
                        ep->fec_hash_table_high = 0;
                        ep->fec_hash_table_low = 0;
-            
+
                        dmi = dev->mc_list;
 
                        for (j = 0; j < dev->mc_count; j++, dmi = dmi->next)
@@ -2242,7 +2259,7 @@ static void set_multicast_list(struct net_device *dev)
                                */
                                if (!(dmi->dmi_addr[0] & 1))
                                        continue;
-                       
+
                                /* calculate crc32 value of mac address
                                */
                                crc = 0xffffffff;
@@ -2261,7 +2278,7 @@ static void set_multicast_list(struct net_device *dev)
                                   which point to specific bit in he hash registers
                                */
                                hash = (crc >> (32 - HASH_BITS)) & 0x3f;
-                       
+
                                if (hash > 31)
                                        ep->fec_hash_table_high |= 1 << (hash - 32);
                                else
@@ -2321,6 +2338,7 @@ int __init fec_enet_init(struct net_device *dev)
 
        fep->index = index;
        fep->hwp = fecp;
+       fep->netdev = dev;
 
        /* Whack a reset.  We should wait for this.
        */
@@ -2426,7 +2444,6 @@ int __init fec_enet_init(struct net_device *dev)
        dev->tx_timeout = fec_timeout;
        dev->watchdog_timeo = TX_TIMEOUT;
        dev->stop = fec_enet_close;
-       dev->get_stats = fec_enet_get_stats;
        dev->set_multicast_list = set_multicast_list;
 
        for (i=0; i<NMII-1; i++)
@@ -2548,8 +2565,7 @@ fec_restart(struct net_device *dev, int duplex)
        if (duplex) {
                fecp->fec_r_cntrl = OPT_FRAME_SIZE | 0x04;/* MII enable */
                fecp->fec_x_cntrl = 0x04;                 /* FD enable */
-       }
-       else {
+       } else {
                /* MII enable|No Rcv on Xmit */
                fecp->fec_r_cntrl = OPT_FRAME_SIZE | 0x06;
                fecp->fec_x_cntrl = 0x00;
@@ -2609,6 +2625,7 @@ static int __init fec_enet_module_init(void)
 {
        struct net_device *dev;
        int i, j, err;
+       DECLARE_MAC_BUF(mac);
 
        printk("FEC ENET Version 0.2\n");
 
@@ -2627,10 +2644,8 @@ static int __init fec_enet_module_init(void)
                        return -EIO;
                }
 
-               printk("%s: ethernet ", dev->name);
-               for (j = 0; (j < 5); j++)
-                       printk("%02x:", dev->dev_addr[j]);
-               printk("%02x\n", dev->dev_addr[5]);
+               printk("%s: ethernet %s\n",
+                      dev->name, print_mac(mac, dev->dev_addr));
        }
        return 0;
 }