]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/fs_enet/fs_enet-main.c
Merge branch 'for-2.6.25' of master.kernel.org:/pub/scm/linux/kernel/git/arnd/cell...
[linux-2.6-omap-h63xx.git] / drivers / net / fs_enet / fs_enet-main.c
index f6789a8db8cd1b8cf3a5319d5ca2d978225f051d..af869cf9ae7d7278fdae1b717431c0f7447476b3 100644 (file)
@@ -1,17 +1,17 @@
 /*
  * Combined Ethernet driver for Motorola MPC8xx and MPC82xx.
  *
- * Copyright (c) 2003 Intracom S.A. 
+ * Copyright (c) 2003 Intracom S.A.
  *  by Pantelis Antoniou <panto@intracom.gr>
- * 
- * 2005 (c) MontaVista Software, Inc. 
+ *
+ * 2005 (c) MontaVista Software, Inc.
  * Vitaly Bordug <vbordug@ru.mvista.com>
  *
  * Heavily based on original FEC driver by Dan Malek <dan@embeddededge.com>
  * and modifications by Joakim Tjernlund <joakim.tjernlund@lumentis.se>
  *
- * This file is licensed under the terms of the GNU General Public License 
- * version 2. This program is licensed "as is" without any warranty of any 
+ * This file is licensed under the terms of the GNU General Public License
+ * version 2. This program is licensed "as is" without any warranty of any
  * kind, whether express or implied.
  */
 
 #include <asm/irq.h>
 #include <asm/uaccess.h>
 
+#ifdef CONFIG_PPC_CPM_NEW_BINDING
+#include <asm/of_platform.h>
+#endif
+
 #include "fs_enet.h"
 
 /*************************************************/
 
+#ifndef CONFIG_PPC_CPM_NEW_BINDING
 static char version[] __devinitdata =
     DRV_MODULE_NAME ".c:v" DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")" "\n";
+#endif
 
 MODULE_AUTHOR("Pantelis Antoniou <panto@intracom.gr>");
 MODULE_DESCRIPTION("Freescale Ethernet Driver");
 MODULE_LICENSE("GPL");
 MODULE_VERSION(DRV_MODULE_VERSION);
 
-int fs_enet_debug = -1;                /* -1 == use FS_ENET_DEF_MSG_ENABLE as value */
+static int fs_enet_debug = -1; /* -1 == use FS_ENET_DEF_MSG_ENABLE as value */
 module_param(fs_enet_debug, int, 0);
 MODULE_PARM_DESC(fs_enet_debug,
                 "Freescale bitmapped debugging message enable value");
 
+#ifdef CONFIG_NET_POLL_CONTROLLER
+static void fs_enet_netpoll(struct net_device *dev);
+#endif
 
 static void fs_set_multicast_list(struct net_device *dev)
 {
@@ -67,21 +76,26 @@ static void fs_set_multicast_list(struct net_device *dev)
        (*fep->ops->set_multicast_list)(dev);
 }
 
+static void skb_align(struct sk_buff *skb, int align)
+{
+       int off = ((unsigned long)skb->data) & (align - 1);
+
+       if (off)
+               skb_reserve(skb, align - off);
+}
+
 /* NAPI receive function */
 static int fs_enet_rx_napi(struct napi_struct *napi, int budget)
 {
        struct fs_enet_private *fep = container_of(napi, struct fs_enet_private, napi);
-       struct net_device *dev = to_net_dev(fep->dev);
+       struct net_device *dev = fep->ndev;
        const struct fs_platform_info *fpi = fep->fpi;
-       cbd_t *bdp;
+       cbd_t __iomem *bdp;
        struct sk_buff *skb, *skbn, *skbt;
        int received = 0;
        u16 pkt_len, sc;
        int curidx;
 
-       if (!netif_running(dev))
-               return 0;
-
        /*
         * First, grab all of the stats for the incoming packet.
         * These get messed up if we get called due to a busy condition.
@@ -104,7 +118,7 @@ static int fs_enet_rx_napi(struct napi_struct *napi, int budget)
                               dev->name);
 
                /*
-                * Check for errors. 
+                * Check for errors.
                 */
                if (sc & (BD_ENET_RX_LG | BD_ENET_RX_SH | BD_ENET_RX_CL |
                          BD_ENET_RX_NO | BD_ENET_RX_CR | BD_ENET_RX_OV)) {
@@ -156,9 +170,13 @@ static int fs_enet_rx_napi(struct napi_struct *napi, int budget)
                                        skb = skbn;
                                        skbn = skbt;
                                }
-                       } else
+                       } else {
                                skbn = dev_alloc_skb(ENET_RX_FRSIZE);
 
+                               if (skbn)
+                                       skb_align(skbn, ENET_RX_ALIGN);
+                       }
+
                        if (skbn != NULL) {
                                skb_put(skb, pkt_len);  /* Make room */
                                skb->protocol = eth_type_trans(skb, dev);
@@ -181,7 +199,7 @@ static int fs_enet_rx_napi(struct napi_struct *napi, int budget)
                CBDW_SC(bdp, (sc & ~BD_ENET_RX_STATS) | BD_ENET_RX_EMPTY);
 
                /*
-                * Update BD pointer to next entry. 
+                * Update BD pointer to next entry.
                 */
                if ((sc & BD_ENET_RX_WRAP) == 0)
                        bdp++;
@@ -196,7 +214,7 @@ static int fs_enet_rx_napi(struct napi_struct *napi, int budget)
 
        fep->cur_rx = bdp;
 
-       if (received >= budget) {
+       if (received < budget) {
                /* done */
                netif_rx_complete(dev, napi);
                (*fep->ops->napi_enable_rx)(dev);
@@ -209,7 +227,7 @@ static int fs_enet_rx_non_napi(struct net_device *dev)
 {
        struct fs_enet_private *fep = netdev_priv(dev);
        const struct fs_platform_info *fpi = fep->fpi;
-       cbd_t *bdp;
+       cbd_t __iomem *bdp;
        struct sk_buff *skb, *skbn, *skbt;
        int received = 0;
        u16 pkt_len, sc;
@@ -234,7 +252,7 @@ static int fs_enet_rx_non_napi(struct net_device *dev)
                               dev->name);
 
                /*
-                * Check for errors. 
+                * Check for errors.
                 */
                if (sc & (BD_ENET_RX_LG | BD_ENET_RX_SH | BD_ENET_RX_CL |
                          BD_ENET_RX_NO | BD_ENET_RX_CR | BD_ENET_RX_OV)) {
@@ -287,9 +305,13 @@ static int fs_enet_rx_non_napi(struct net_device *dev)
                                        skb = skbn;
                                        skbn = skbt;
                                }
-                       } else
+                       } else {
                                skbn = dev_alloc_skb(ENET_RX_FRSIZE);
 
+                               if (skbn)
+                                       skb_align(skbn, ENET_RX_ALIGN);
+                       }
+
                        if (skbn != NULL) {
                                skb_put(skb, pkt_len);  /* Make room */
                                skb->protocol = eth_type_trans(skb, dev);
@@ -312,7 +334,7 @@ static int fs_enet_rx_non_napi(struct net_device *dev)
                CBDW_SC(bdp, (sc & ~BD_ENET_RX_STATS) | BD_ENET_RX_EMPTY);
 
                /*
-                * Update BD pointer to next entry. 
+                * Update BD pointer to next entry.
                 */
                if ((sc & BD_ENET_RX_WRAP) == 0)
                        bdp++;
@@ -330,17 +352,16 @@ static int fs_enet_rx_non_napi(struct net_device *dev)
 static void fs_enet_tx(struct net_device *dev)
 {
        struct fs_enet_private *fep = netdev_priv(dev);
-       cbd_t *bdp;
+       cbd_t __iomem *bdp;
        struct sk_buff *skb;
        int dirtyidx, do_wake, do_restart;
        u16 sc;
 
-       spin_lock(&fep->lock);
+       spin_lock(&fep->tx_lock);
        bdp = fep->dirty_tx;
 
        do_wake = do_restart = 0;
        while (((sc = CBDR_SC(bdp)) & BD_ENET_TX_READY) == 0) {
-
                dirtyidx = bdp - fep->tx_bd_base;
 
                if (fep->tx_free == fep->tx_ring)
@@ -349,7 +370,7 @@ static void fs_enet_tx(struct net_device *dev)
                skb = fep->tx_skbuff[dirtyidx];
 
                /*
-                * Check for errors. 
+                * Check for errors.
                 */
                if (sc & (BD_ENET_TX_HB | BD_ENET_TX_LC |
                          BD_ENET_TX_RL | BD_ENET_TX_UN | BD_ENET_TX_CSL)) {
@@ -389,13 +410,13 @@ static void fs_enet_tx(struct net_device *dev)
                                skb->len, DMA_TO_DEVICE);
 
                /*
-                * Free the sk buffer associated with this last transmit. 
+                * Free the sk buffer associated with this last transmit.
                 */
                dev_kfree_skb_irq(skb);
                fep->tx_skbuff[dirtyidx] = NULL;
 
                /*
-                * Update pointer to next buffer descriptor to be transmitted. 
+                * Update pointer to next buffer descriptor to be transmitted.
                 */
                if ((sc & BD_ENET_TX_WRAP) == 0)
                        bdp++;
@@ -415,7 +436,7 @@ static void fs_enet_tx(struct net_device *dev)
        if (do_restart)
                (*fep->ops->tx_restart)(dev);
 
-       spin_unlock(&fep->lock);
+       spin_unlock(&fep->tx_lock);
 
        if (do_wake)
                netif_wake_queue(dev);
@@ -441,7 +462,6 @@ fs_enet_interrupt(int irq, void *dev_id)
 
        nr = 0;
        while ((int_events = (*fep->ops->get_int_events)(dev)) != 0) {
-
                nr++;
 
                int_clr_events = int_events;
@@ -480,7 +500,7 @@ fs_enet_interrupt(int irq, void *dev_id)
 void fs_init_bds(struct net_device *dev)
 {
        struct fs_enet_private *fep = netdev_priv(dev);
-       cbd_t *bdp;
+       cbd_t __iomem *bdp;
        struct sk_buff *skb;
        int i;
 
@@ -491,7 +511,7 @@ void fs_init_bds(struct net_device *dev)
        fep->cur_rx = fep->rx_bd_base;
 
        /*
-        * Initialize the receive buffer descriptors. 
+        * Initialize the receive buffer descriptors.
         */
        for (i = 0, bdp = fep->rx_bd_base; i < fep->rx_ring; i++, bdp++) {
                skb = dev_alloc_skb(ENET_RX_FRSIZE);
@@ -501,6 +521,7 @@ void fs_init_bds(struct net_device *dev)
                               dev->name);
                        break;
                }
+               skb_align(skb, ENET_RX_ALIGN);
                fep->rx_skbuff[i] = skb;
                CBDW_BUFADDR(bdp,
                        dma_map_single(fep->dev, skb->data,
@@ -511,7 +532,7 @@ void fs_init_bds(struct net_device *dev)
                        ((i < fep->rx_ring - 1) ? 0 : BD_SC_WRAP));
        }
        /*
-        * if we failed, fillup remainder 
+        * if we failed, fillup remainder
         */
        for (; i < fep->rx_ring; i++, bdp++) {
                fep->rx_skbuff[i] = NULL;
@@ -519,7 +540,7 @@ void fs_init_bds(struct net_device *dev)
        }
 
        /*
-        * ...and the same for transmit.  
+        * ...and the same for transmit.
         */
        for (i = 0, bdp = fep->tx_bd_base; i < fep->tx_ring; i++, bdp++) {
                fep->tx_skbuff[i] = NULL;
@@ -533,11 +554,11 @@ void fs_cleanup_bds(struct net_device *dev)
 {
        struct fs_enet_private *fep = netdev_priv(dev);
        struct sk_buff *skb;
-       cbd_t *bdp;
+       cbd_t __iomem *bdp;
        int i;
 
        /*
-        * Reset SKB transmit buffers.  
+        * Reset SKB transmit buffers.
         */
        for (i = 0, bdp = fep->tx_bd_base; i < fep->tx_ring; i++, bdp++) {
                if ((skb = fep->tx_skbuff[i]) == NULL)
@@ -552,7 +573,7 @@ void fs_cleanup_bds(struct net_device *dev)
        }
 
        /*
-        * Reset SKB receive buffers 
+        * Reset SKB receive buffers
         */
        for (i = 0, bdp = fep->rx_bd_base; i < fep->rx_ring; i++, bdp++) {
                if ((skb = fep->rx_skbuff[i]) == NULL)
@@ -574,7 +595,7 @@ void fs_cleanup_bds(struct net_device *dev)
 static int fs_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
 {
        struct fs_enet_private *fep = netdev_priv(dev);
-       cbd_t *bdp;
+       cbd_t __iomem *bdp;
        int curidx;
        u16 sc;
        unsigned long flags;
@@ -582,7 +603,7 @@ static int fs_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
        spin_lock_irqsave(&fep->tx_lock, flags);
 
        /*
-        * Fill in a Tx ring entry 
+        * Fill in a Tx ring entry
         */
        bdp = fep->cur_tx;
 
@@ -601,19 +622,19 @@ static int fs_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
 
        curidx = bdp - fep->tx_bd_base;
        /*
-        * Clear all of the status flags. 
+        * Clear all of the status flags.
         */
        CBDC_SC(bdp, BD_ENET_TX_STATS);
 
        /*
-        * Save skb pointer. 
+        * Save skb pointer.
         */
        fep->tx_skbuff[curidx] = skb;
 
        fep->stats.tx_bytes += skb->len;
 
        /*
-        * Push the data cache so the CPM does not get stale memory data. 
+        * Push the data cache so the CPM does not get stale memory data.
         */
        CBDW_BUFADDR(bdp, dma_map_single(fep->dev,
                                skb->data, skb->len, DMA_TO_DEVICE));
@@ -622,7 +643,7 @@ static int fs_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
        dev->trans_start = jiffies;
 
        /*
-        * If this was the last BD in the ring, start at the beginning again. 
+        * If this was the last BD in the ring, start at the beginning again.
         */
        if ((CBDR_SC(bdp) & BD_ENET_TX_WRAP) == 0)
                fep->cur_tx++;
@@ -697,45 +718,43 @@ static void fs_timeout(struct net_device *dev)
  *-----------------------------------------------------------------------------*/
 static void generic_adjust_link(struct  net_device *dev)
 {
-       struct fs_enet_private *fep = netdev_priv(dev);
-       struct phy_device *phydev = fep->phydev;
-       int new_state = 0;
-
-       if (phydev->link) {
-
-               /* adjust to duplex mode */
-               if (phydev->duplex != fep->oldduplex){
-                       new_state = 1;
-                       fep->oldduplex = phydev->duplex;
-               }
-
-               if (phydev->speed != fep->oldspeed) {
-                       new_state = 1;
-                       fep->oldspeed = phydev->speed;
-               }
-
-               if (!fep->oldlink) {
-                       new_state = 1;
-                       fep->oldlink = 1;
-                       netif_schedule(dev);
-                       netif_carrier_on(dev);
-                       netif_start_queue(dev);
-               }
-
-               if (new_state)
-                       fep->ops->restart(dev);
-
-       } else if (fep->oldlink) {
-               new_state = 1;
-               fep->oldlink = 0;
-               fep->oldspeed = 0;
-               fep->oldduplex = -1;
-               netif_carrier_off(dev);
-               netif_stop_queue(dev);
-       }
-
-       if (new_state && netif_msg_link(fep))
-               phy_print_status(phydev);
+       struct fs_enet_private *fep = netdev_priv(dev);
+       struct phy_device *phydev = fep->phydev;
+       int new_state = 0;
+
+       if (phydev->link) {
+               /* adjust to duplex mode */
+               if (phydev->duplex != fep->oldduplex) {
+                       new_state = 1;
+                       fep->oldduplex = phydev->duplex;
+               }
+
+               if (phydev->speed != fep->oldspeed) {
+                       new_state = 1;
+                       fep->oldspeed = phydev->speed;
+               }
+
+               if (!fep->oldlink) {
+                       new_state = 1;
+                       fep->oldlink = 1;
+                       netif_schedule(dev);
+                       netif_carrier_on(dev);
+                       netif_start_queue(dev);
+               }
+
+               if (new_state)
+                       fep->ops->restart(dev);
+       } else if (fep->oldlink) {
+               new_state = 1;
+               fep->oldlink = 0;
+               fep->oldspeed = 0;
+               fep->oldduplex = -1;
+               netif_carrier_off(dev);
+               netif_stop_queue(dev);
+       }
+
+       if (new_state && netif_msg_link(fep))
+               phy_print_status(phydev);
 }
 
 
@@ -779,27 +798,29 @@ static int fs_init_phy(struct net_device *dev)
        return 0;
 }
 
-
 static int fs_enet_open(struct net_device *dev)
 {
        struct fs_enet_private *fep = netdev_priv(dev);
        int r;
        int err;
 
-       napi_enable(&fep->napi);
+       if (fep->fpi->use_napi)
+               napi_enable(&fep->napi);
 
        /* Install our interrupt handler. */
        r = fs_request_irq(dev, fep->interrupt, "fs_enet-mac", fs_enet_interrupt);
        if (r != 0) {
                printk(KERN_ERR DRV_MODULE_NAME
                       ": %s Could not allocate FS_ENET IRQ!", dev->name);
-               napi_disable(&fep->napi);
+               if (fep->fpi->use_napi)
+                       napi_disable(&fep->napi);
                return -EINVAL;
        }
 
        err = fs_init_phy(dev);
-       if(err) {
-               napi_disable(&fep->napi);
+       if (err) {
+               if (fep->fpi->use_napi)
+                       napi_disable(&fep->napi);
                return err;
        }
        phy_start(fep->phydev);
@@ -818,7 +839,9 @@ static int fs_enet_close(struct net_device *dev)
        phy_stop(fep->phydev);
 
        spin_lock_irqsave(&fep->lock, flags);
+       spin_lock(&fep->tx_lock);
        (*fep->ops->stop)(dev);
+       spin_unlock(&fep->tx_lock);
        spin_unlock_irqrestore(&fep->lock, flags);
 
        /* release any irqs */
@@ -871,14 +894,21 @@ static void fs_get_regs(struct net_device *dev, struct ethtool_regs *regs,
 static int fs_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 {
        struct fs_enet_private *fep = netdev_priv(dev);
+
+       if (!fep->phydev)
+               return -ENODEV;
+
        return phy_ethtool_gset(fep->phydev, cmd);
 }
 
 static int fs_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 {
        struct fs_enet_private *fep = netdev_priv(dev);
-       phy_ethtool_sset(fep->phydev, cmd);
-       return 0;
+
+       if (!fep->phydev)
+               return -ENODEV;
+
+       return phy_ethtool_sset(fep->phydev, cmd);
 }
 
 static int fs_nway_reset(struct net_device *dev)
@@ -907,9 +937,7 @@ static const struct ethtool_ops fs_ethtool_ops = {
        .get_link = ethtool_op_get_link,
        .get_msglevel = fs_get_msglevel,
        .set_msglevel = fs_set_msglevel,
-       .get_tx_csum = ethtool_op_get_tx_csum,
        .set_tx_csum = ethtool_op_set_tx_csum,  /* local! */
-       .get_sg = ethtool_op_get_sg,
        .set_sg = ethtool_op_set_sg,
        .get_regs = fs_get_regs,
 };
@@ -918,21 +946,17 @@ static int fs_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 {
        struct fs_enet_private *fep = netdev_priv(dev);
        struct mii_ioctl_data *mii = (struct mii_ioctl_data *)&rq->ifr_data;
-       unsigned long flags;
-       int rc;
 
        if (!netif_running(dev))
                return -EINVAL;
 
-       spin_lock_irqsave(&fep->lock, flags);
-       rc = phy_mii_ioctl(fep->phydev, mii, cmd);
-       spin_unlock_irqrestore(&fep->lock, flags);
-       return rc;
+       return phy_mii_ioctl(fep->phydev, mii, cmd);
 }
 
 extern int fs_mii_connect(struct net_device *dev);
 extern void fs_mii_disconnect(struct net_device *dev);
 
+#ifndef CONFIG_PPC_CPM_NEW_BINDING
 static struct net_device *fs_init_instance(struct device *dev,
                struct fs_platform_info *fpi)
 {
@@ -968,7 +992,7 @@ static struct net_device *fs_init_instance(struct device *dev,
 #endif
 
 #ifdef CONFIG_FS_ENET_HAS_SCC
-       if (fs_get_scc_index(fpi->fs_no) >=0 )
+       if (fs_get_scc_index(fpi->fs_no) >=0)
                fep->ops = &fs_scc_ops;
 #endif
 
@@ -1003,13 +1027,13 @@ static struct net_device *fs_init_instance(struct device *dev,
        spin_lock_init(&fep->tx_lock);
 
        /*
-        * Set the Ethernet address. 
+        * Set the Ethernet address.
         */
        for (i = 0; i < 6; i++)
                ndev->dev_addr[i] = fpi->macaddr[i];
-       
+
        r = (*fep->ops->allocate_bd)(ndev);
-       
+
        if (fep->ring_base == NULL) {
                printk(KERN_ERR DRV_MODULE_NAME
                       ": %s buffer descriptor alloc failed (%d).\n", ndev->name, r);
@@ -1028,7 +1052,7 @@ static struct net_device *fs_init_instance(struct device *dev,
        fep->rx_ring = fpi->rx_ring;
 
        /*
-        * The FEC Ethernet specific entries in the device structure. 
+        * The FEC Ethernet specific entries in the device structure.
         */
        ndev->open = fs_enet_open;
        ndev->hard_start_xmit = fs_enet_start_xmit;
@@ -1037,6 +1061,11 @@ static struct net_device *fs_init_instance(struct device *dev,
        ndev->stop = fs_enet_close;
        ndev->get_stats = fs_enet_get_stats;
        ndev->set_multicast_list = fs_set_multicast_list;
+
+#ifdef CONFIG_NET_POLL_CONTROLLER
+       ndev->poll_controller = fs_enet_netpoll;
+#endif
+
        netif_napi_add(ndev, &fep->napi,
                       fs_enet_rx_napi, fpi->napi_weight);
 
@@ -1058,9 +1087,8 @@ static struct net_device *fs_init_instance(struct device *dev,
 
        return ndev;
 
-      err:
+err:
        if (ndev != NULL) {
-
                if (registered)
                        unregister_netdev(ndev);
 
@@ -1095,7 +1123,7 @@ static int fs_cleanup_instance(struct net_device *ndev)
        unregister_netdev(ndev);
 
        dma_free_coherent(fep->dev, (fpi->tx_ring + fpi->rx_ring) * sizeof(cbd_t),
-                         fep->ring_base, fep->ring_mem_addr);
+                         (void __force *)fep->ring_base, fep->ring_mem_addr);
 
        /* reset it */
        (*fep->ops->cleanup_data)(ndev);
@@ -1110,43 +1138,267 @@ static int fs_cleanup_instance(struct net_device *ndev)
 
        return 0;
 }
+#endif
 
 /**************************************************************************************/
 
 /* handy pointer to the immap */
-void *fs_enet_immap = NULL;
+void __iomem *fs_enet_immap = NULL;
 
 static int setup_immap(void)
 {
-       phys_addr_t paddr = 0;
-       unsigned long size = 0;
-
 #ifdef CONFIG_CPM1
-       paddr = IMAP_ADDR;
-       size = 0x10000; /* map 64K */
-#endif
-
-#ifdef CONFIG_CPM2
-       paddr = CPM_MAP_ADDR;
-       size = 0x40000; /* map 256 K */
+       fs_enet_immap = ioremap(IMAP_ADDR, 0x4000);
+       WARN_ON(!fs_enet_immap);
+#elif defined(CONFIG_CPM2)
+       fs_enet_immap = cpm2_immr;
 #endif
-       fs_enet_immap = ioremap(paddr, size);
-       if (fs_enet_immap == NULL)
-               return -EBADF;  /* XXX ahem; maybe just BUG_ON? */
 
        return 0;
 }
 
 static void cleanup_immap(void)
 {
-       if (fs_enet_immap != NULL) {
-               iounmap(fs_enet_immap);
-               fs_enet_immap = NULL;
-       }
+#if defined(CONFIG_CPM1)
+       iounmap(fs_enet_immap);
+#endif
 }
 
 /**************************************************************************************/
 
+#ifdef CONFIG_PPC_CPM_NEW_BINDING
+static int __devinit find_phy(struct device_node *np,
+                              struct fs_platform_info *fpi)
+{
+       struct device_node *phynode, *mdionode;
+       struct resource res;
+       int ret = 0, len;
+       const u32 *data;
+
+       data  = of_get_property(np, "fixed-link", NULL);
+       if (data) {
+               snprintf(fpi->bus_id, 16, PHY_ID_FMT, 0, *data);
+               return 0;
+       }
+
+       data = of_get_property(np, "phy-handle", &len);
+       if (!data || len != 4)
+               return -EINVAL;
+
+       phynode = of_find_node_by_phandle(*data);
+       if (!phynode)
+               return -EINVAL;
+
+       mdionode = of_get_parent(phynode);
+       if (!mdionode)
+               goto out_put_phy;
+
+       ret = of_address_to_resource(mdionode, 0, &res);
+       if (ret)
+               goto out_put_mdio;
+
+       data = of_get_property(phynode, "reg", &len);
+       if (!data || len != 4)
+               goto out_put_mdio;
+
+       snprintf(fpi->bus_id, 16, PHY_ID_FMT, res.start, *data);
+
+out_put_mdio:
+       of_node_put(mdionode);
+out_put_phy:
+       of_node_put(phynode);
+       return ret;
+}
+
+#ifdef CONFIG_FS_ENET_HAS_FEC
+#define IS_FEC(match) ((match)->data == &fs_fec_ops)
+#else
+#define IS_FEC(match) 0
+#endif
+
+static int __devinit fs_enet_probe(struct of_device *ofdev,
+                                   const struct of_device_id *match)
+{
+       struct net_device *ndev;
+       struct fs_enet_private *fep;
+       struct fs_platform_info *fpi;
+       const u32 *data;
+       const u8 *mac_addr;
+       int privsize, len, ret = -ENODEV;
+
+       fpi = kzalloc(sizeof(*fpi), GFP_KERNEL);
+       if (!fpi)
+               return -ENOMEM;
+
+       if (!IS_FEC(match)) {
+               data = of_get_property(ofdev->node, "fsl,cpm-command", &len);
+               if (!data || len != 4)
+                       goto out_free_fpi;
+
+               fpi->cp_command = *data;
+       }
+
+       fpi->rx_ring = 32;
+       fpi->tx_ring = 32;
+       fpi->rx_copybreak = 240;
+       fpi->use_napi = 1;
+       fpi->napi_weight = 17;
+
+       ret = find_phy(ofdev->node, fpi);
+       if (ret)
+               goto out_free_fpi;
+
+       privsize = sizeof(*fep) +
+                  sizeof(struct sk_buff **) *
+                  (fpi->rx_ring + fpi->tx_ring);
+
+       ndev = alloc_etherdev(privsize);
+       if (!ndev) {
+               ret = -ENOMEM;
+               goto out_free_fpi;
+       }
+
+       dev_set_drvdata(&ofdev->dev, ndev);
+
+       fep = netdev_priv(ndev);
+       fep->dev = &ofdev->dev;
+       fep->ndev = ndev;
+       fep->fpi = fpi;
+       fep->ops = match->data;
+
+       ret = fep->ops->setup_data(ndev);
+       if (ret)
+               goto out_free_dev;
+
+       fep->rx_skbuff = (struct sk_buff **)&fep[1];
+       fep->tx_skbuff = fep->rx_skbuff + fpi->rx_ring;
+
+       spin_lock_init(&fep->lock);
+       spin_lock_init(&fep->tx_lock);
+
+       mac_addr = of_get_mac_address(ofdev->node);
+       if (mac_addr)
+               memcpy(ndev->dev_addr, mac_addr, 6);
+
+       ret = fep->ops->allocate_bd(ndev);
+       if (ret)
+               goto out_cleanup_data;
+
+       fep->rx_bd_base = fep->ring_base;
+       fep->tx_bd_base = fep->rx_bd_base + fpi->rx_ring;
+
+       fep->tx_ring = fpi->tx_ring;
+       fep->rx_ring = fpi->rx_ring;
+
+       ndev->open = fs_enet_open;
+       ndev->hard_start_xmit = fs_enet_start_xmit;
+       ndev->tx_timeout = fs_timeout;
+       ndev->watchdog_timeo = 2 * HZ;
+       ndev->stop = fs_enet_close;
+       ndev->get_stats = fs_enet_get_stats;
+       ndev->set_multicast_list = fs_set_multicast_list;
+
+       if (fpi->use_napi)
+               netif_napi_add(ndev, &fep->napi, fs_enet_rx_napi,
+                              fpi->napi_weight);
+
+       ndev->ethtool_ops = &fs_ethtool_ops;
+       ndev->do_ioctl = fs_ioctl;
+
+       init_timer(&fep->phy_timer_list);
+
+       netif_carrier_off(ndev);
+
+       ret = register_netdev(ndev);
+       if (ret)
+               goto out_free_bd;
+
+       printk(KERN_INFO "%s: fs_enet: %02x:%02x:%02x:%02x:%02x:%02x\n",
+              ndev->name,
+              ndev->dev_addr[0], ndev->dev_addr[1], ndev->dev_addr[2],
+              ndev->dev_addr[3], ndev->dev_addr[4], ndev->dev_addr[5]);
+
+       return 0;
+
+out_free_bd:
+       fep->ops->free_bd(ndev);
+out_cleanup_data:
+       fep->ops->cleanup_data(ndev);
+out_free_dev:
+       free_netdev(ndev);
+       dev_set_drvdata(&ofdev->dev, NULL);
+out_free_fpi:
+       kfree(fpi);
+       return ret;
+}
+
+static int fs_enet_remove(struct of_device *ofdev)
+{
+       struct net_device *ndev = dev_get_drvdata(&ofdev->dev);
+       struct fs_enet_private *fep = netdev_priv(ndev);
+
+       unregister_netdev(ndev);
+
+       fep->ops->free_bd(ndev);
+       fep->ops->cleanup_data(ndev);
+       dev_set_drvdata(fep->dev, NULL);
+
+       free_netdev(ndev);
+       return 0;
+}
+
+static struct of_device_id fs_enet_match[] = {
+#ifdef CONFIG_FS_ENET_HAS_SCC
+       {
+               .compatible = "fsl,cpm1-scc-enet",
+               .data = (void *)&fs_scc_ops,
+       },
+#endif
+#ifdef CONFIG_FS_ENET_HAS_FCC
+       {
+               .compatible = "fsl,cpm2-fcc-enet",
+               .data = (void *)&fs_fcc_ops,
+       },
+#endif
+#ifdef CONFIG_FS_ENET_HAS_FEC
+       {
+               .compatible = "fsl,pq1-fec-enet",
+               .data = (void *)&fs_fec_ops,
+       },
+#endif
+       {}
+};
+
+static struct of_platform_driver fs_enet_driver = {
+       .name   = "fs_enet",
+       .match_table = fs_enet_match,
+       .probe = fs_enet_probe,
+       .remove = fs_enet_remove,
+};
+
+static int __init fs_init(void)
+{
+       int r = setup_immap();
+       if (r != 0)
+               return r;
+
+       r = of_register_platform_driver(&fs_enet_driver);
+       if (r != 0)
+               goto out;
+
+       return 0;
+
+out:
+       cleanup_immap();
+       return r;
+}
+
+static void __exit fs_cleanup(void)
+{
+       of_unregister_platform_driver(&fs_enet_driver);
+       cleanup_immap();
+}
+#else
 static int __devinit fs_enet_probe(struct device *dev)
 {
        struct net_device *ndev;
@@ -1251,7 +1503,6 @@ static int __init fs_init(void)
 err:
        cleanup_immap();
        return r;
-       
 }
 
 static void __exit fs_cleanup(void)
@@ -1261,6 +1512,16 @@ static void __exit fs_cleanup(void)
        driver_unregister(&fs_enet_scc_driver);
        cleanup_immap();
 }
+#endif
+
+#ifdef CONFIG_NET_POLL_CONTROLLER
+static void fs_enet_netpoll(struct net_device *dev)
+{
+       disable_irq(dev->irq);
+       fs_enet_interrupt(dev->irq, dev, NULL);
+       enable_irq(dev->irq);
+}
+#endif
 
 /**************************************************************************************/