]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/sgiseeq.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/avi/kvm
[linux-2.6-omap-h63xx.git] / drivers / net / sgiseeq.c
index a833e7f9757f4b12757f9229e8aa127b9527172d..384b4685e977a453884d56fc81c4f2b0747680da 100644 (file)
 #include <linux/init.h>
 #include <linux/types.h>
 #include <linux/interrupt.h>
-#include <linux/ioport.h>
-#include <linux/socket.h>
-#include <linux/in.h>
-#include <linux/route.h>
 #include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/delay.h>
 #include <linux/netdevice.h>
+#include <linux/platform_device.h>
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
-#include <linux/bitops.h>
 
-#include <asm/byteorder.h>
-#include <asm/io.h>
-#include <asm/system.h>
-#include <asm/page.h>
-#include <asm/pgtable.h>
 #include <asm/sgi/hpc3.h>
 #include <asm/sgi/ip22.h>
-#include <asm/sgialib.h>
+#include <asm/sgi/seeq.h>
 
 #include "sgiseeq.h"
 
@@ -103,13 +94,9 @@ struct sgiseeq_private {
 
        struct net_device_stats stats;
 
-       struct net_device *next_module;
        spinlock_t tx_lock;
 };
 
-/* A list of all installed seeq devices, for removing the driver module. */
-static struct net_device *root_sgiseeq_dev;
-
 static inline void hpc3_eth_reset(struct hpc3_ethregs *hregs)
 {
        hregs->reset = HPC3_ERST_CRESET | HPC3_ERST_CLRIRQ;
@@ -329,12 +316,11 @@ static inline void sgiseeq_rx(struct net_device *dev, struct sgiseeq_private *sp
                        skb = dev_alloc_skb(len + 2);
 
                        if (skb) {
-                               skb->dev = dev;
                                skb_reserve(skb, 2);
                                skb_put(skb, len);
 
                                /* Copy out of kseg1 to avoid silly cache flush. */
-                               eth_copy_and_sum(skb, pkt_pointer + 2, len, 0);
+                               skb_copy_to_linear_data(skb, pkt_pointer + 2, len);
                                skb->protocol = eth_type_trans(skb, dev);
 
                                /* We don't want to receive our own packets */
@@ -546,7 +532,7 @@ static int sgiseeq_start_xmit(struct sk_buff *skb, struct net_device *dev)
         *    entry and the HPC got to the end of the chain before we
         *    added this new entry and restarted it.
         */
-       memcpy((char *)(long)td->buf_vaddr, skb->data, skblen);
+       skb_copy_from_linear_data(skb, (char *)(long)td->buf_vaddr, skblen);
        if (len != skblen)
                memset((char *)(long)td->buf_vaddr + skb->len, 0, len-skblen);
        td->tdma.cntinfo = (len & HPCDMA_BCNT) |
@@ -636,9 +622,12 @@ static inline void setup_rx_ring(struct sgiseeq_rx_desc *buf, int nbufs)
 
 #define ALIGNED(x)  ((((unsigned long)(x)) + 0xf) & ~(0xf))
 
-static int sgiseeq_init(struct hpc3_regs* hpcregs, int irq)
+static int __init sgiseeq_probe(struct platform_device *pdev)
 {
+       struct sgiseeq_platform_data *pd = pdev->dev.platform_data;
+       struct hpc3_regs *hpcregs = pd->hpc;
        struct sgiseeq_init_block *sr;
+       unsigned int irq = pd->irq;
        struct sgiseeq_private *sp;
        struct net_device *dev;
        int err, i;
@@ -649,6 +638,8 @@ static int sgiseeq_init(struct hpc3_regs* hpcregs, int irq)
                err = -ENOMEM;
                goto err_out;
        }
+
+       platform_set_drvdata(pdev, dev);
        sp = netdev_priv(dev);
 
        /* Make private data page aligned */
@@ -660,13 +651,7 @@ static int sgiseeq_init(struct hpc3_regs* hpcregs, int irq)
        }
        sp->srings = sr;
 
-#define EADDR_NVOFS     250
-       for (i = 0; i < 3; i++) {
-               unsigned short tmp = ip22_nvram_read(EADDR_NVOFS / 2 + i);
-
-               dev->dev_addr[2 * i]     = tmp >> 8;
-               dev->dev_addr[2 * i + 1] = tmp & 0xff;
-       }
+       memcpy(dev->dev_addr, pd->mac, ETH_ALEN);
 
 #ifdef DEBUG
        gpriv = sp;
@@ -690,6 +675,11 @@ static int sgiseeq_init(struct hpc3_regs* hpcregs, int irq)
        setup_rx_ring(sp->rx_desc, SEEQ_RX_BUFFERS);
        setup_tx_ring(sp->tx_desc, SEEQ_TX_BUFFERS);
 
+       /* Setup PIO and DMA transfer timing */
+       sp->hregs->pconfig = 0x161;
+       sp->hregs->dconfig = HPC3_EDCFG_FIRQ | HPC3_EDCFG_FEOP |
+                            HPC3_EDCFG_FRXDC | HPC3_EDCFG_PTO | 0x026;
+
        /* Setup PIO and DMA transfer timing */
        sp->hregs->pconfig = 0x161;
        sp->hregs->dconfig = HPC3_EDCFG_FIRQ | HPC3_EDCFG_FEOP |
@@ -725,9 +715,6 @@ static int sgiseeq_init(struct hpc3_regs* hpcregs, int irq)
        for (i = 0; i < 6; i++)
                printk("%2.2x%c", dev->dev_addr[i], i == 5 ? '\n' : ':');
 
-       sp->next_module = root_sgiseeq_dev;
-       root_sgiseeq_dev = dev;
-
        return 0;
 
 err_out_free_page:
@@ -739,28 +726,42 @@ err_out:
        return err;
 }
 
-static int __init sgiseeq_probe(void)
+static void __exit sgiseeq_remove(struct platform_device *pdev)
 {
-       /* On board adapter on 1st HPC is always present */
-       return sgiseeq_init(hpc3c0, SGI_ENET_IRQ);
+       struct net_device *dev = platform_get_drvdata(pdev);
+       struct sgiseeq_private *sp = netdev_priv(dev);
+
+       unregister_netdev(dev);
+       free_page((unsigned long) sp->srings);
+       free_netdev(dev);
+       platform_set_drvdata(pdev, NULL);
 }
 
-static void __exit sgiseeq_exit(void)
-{
-       struct net_device *next, *dev;
-       struct sgiseeq_private *sp;
+static struct platform_driver sgiseeq_driver = {
+       .probe  = sgiseeq_probe,
+       .remove = __devexit_p(sgiseeq_remove),
+       .driver = {
+               .name   = "sgiseeq"
+       }
+};
 
-       for (dev = root_sgiseeq_dev; dev; dev = next) {
-               sp = (struct sgiseeq_private *) netdev_priv(dev);
-               next = sp->next_module;
-               unregister_netdev(dev);
-               free_page((unsigned long) sp->srings);
-               free_netdev(dev);
+static int __init sgiseeq_module_init(void)
+{
+       if (platform_driver_register(&sgiseeq_driver)) {
+               printk(KERN_ERR "Driver registration failed\n");
+               return -ENODEV;
        }
+
+       return 0;
+}
+
+static void __exit sgiseeq_module_exit(void)
+{
+       platform_driver_unregister(&sgiseeq_driver);
 }
 
-module_init(sgiseeq_probe);
-module_exit(sgiseeq_exit);
+module_init(sgiseeq_module_init);
+module_exit(sgiseeq_module_exit);
 
 MODULE_DESCRIPTION("SGI Seeq 8003 driver");
 MODULE_AUTHOR("Linux/MIPS Mailing List <linux-mips@linux-mips.org>");