[PATCH] libertas: fix misspelling in debug message
[safe/jmp/linux-2.6] / drivers / net / sgiseeq.c
index a9d2e4f..0fb74cb 100644 (file)
@@ -3,37 +3,29 @@
  *
  * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com)
  */
+
+#undef DEBUG
+
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/errno.h>
 #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"
 
-static char *version = "sgiseeq.c: David S. Miller (dm@engr.sgi.com)\n";
-
 static char *sgiseeqstr = "SGI Seeq8003";
 
 /*
@@ -61,8 +53,6 @@ static char *sgiseeqstr = "SGI Seeq8003";
                            sp->tx_old + (SEEQ_TX_BUFFERS - 1) - sp->tx_new : \
                            sp->tx_old - sp->tx_new - 1)
 
-#define DEBUG
-
 struct sgiseeq_rx_desc {
        volatile struct hpc_dma_desc rdma;
        volatile signed int buf_vaddr;
@@ -104,18 +94,14 @@ 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->rx_reset = HPC3_ERXRST_CRESET | HPC3_ERXRST_CLRIRQ;
+       hregs->reset = HPC3_ERST_CRESET | HPC3_ERST_CLRIRQ;
        udelay(20);
-       hregs->rx_reset = 0;
+       hregs->reset = 0;
 }
 
 static inline void reset_hpc3_and_seeq(struct hpc3_ethregs *hregs,
@@ -211,7 +197,7 @@ static int seeq_init_ring(struct net_device *dev)
 static struct sgiseeq_private *gpriv;
 static struct net_device *gdev;
 
-void sgiseeq_dump_rings(void)
+static void sgiseeq_dump_rings(void)
 {
        static int once;
        struct sgiseeq_rx_desc *r = gpriv->rx_desc;
@@ -252,7 +238,6 @@ void sgiseeq_dump_rings(void)
 
 #define TSTAT_INIT_SEEQ (SEEQ_TCMD_IPT|SEEQ_TCMD_I16|SEEQ_TCMD_IC|SEEQ_TCMD_IUF)
 #define TSTAT_INIT_EDLC ((TSTAT_INIT_SEEQ) | SEEQ_TCMD_RB2)
-#define RDMACFG_INIT    (HPC3_ERXDCFG_FRXDC | HPC3_ERXDCFG_FEOP | HPC3_ERXDCFG_FIRQ)
 
 static int init_seeq(struct net_device *dev, struct sgiseeq_private *sp,
                     struct sgiseeq_regs *sregs)
@@ -274,8 +259,6 @@ static int init_seeq(struct net_device *dev, struct sgiseeq_private *sp,
                sregs->tstat = TSTAT_INIT_SEEQ;
        }
 
-       hregs->rx_dconfig |= RDMACFG_INIT;
-
        hregs->rx_ndptr = CPHYSADDR(sp->rx_desc);
        hregs->tx_ndptr = CPHYSADDR(sp->tx_desc);
 
@@ -316,9 +299,9 @@ static inline void sgiseeq_rx(struct net_device *dev, struct sgiseeq_private *sp
                              struct sgiseeq_regs *sregs)
 {
        struct sgiseeq_rx_desc *rd;
-       struct sk_buff *skb = 0;
+       struct sk_buff *skb = NULL;
        unsigned char pkt_status;
-       unsigned char *pkt_pointer = 0;
+       unsigned char *pkt_pointer = NULL;
        int len = 0;
        unsigned int orig_end = PREV_RX(sp->rx_new);
 
@@ -333,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 */
@@ -436,7 +418,7 @@ static inline void sgiseeq_tx(struct net_device *dev, struct sgiseeq_private *sp
        }
 }
 
-static irqreturn_t sgiseeq_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t sgiseeq_interrupt(int irq, void *dev_id)
 {
        struct net_device *dev = (struct net_device *) dev_id;
        struct sgiseeq_private *sp = netdev_priv(dev);
@@ -446,7 +428,7 @@ static irqreturn_t sgiseeq_interrupt(int irq, void *dev_id, struct pt_regs *regs
        spin_lock(&sp->tx_lock);
 
        /* Ack the IRQ and set software state. */
-       hregs->rx_reset = HPC3_ERXRST_CLRIRQ;
+       hregs->reset = HPC3_ERST_CLRIRQ;
 
        /* Always check for received packets. */
        sgiseeq_rx(dev, sp, hregs, sregs);
@@ -520,12 +502,6 @@ static inline int sgiseeq_reset(struct net_device *dev)
        return 0;
 }
 
-void sgiseeq_my_reset(void)
-{
-       printk("RESET!\n");
-       sgiseeq_reset(gdev);
-}
-
 static int sgiseeq_start_xmit(struct sk_buff *skb, struct net_device *dev)
 {
        struct sgiseeq_private *sp = netdev_priv(dev);
@@ -556,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) |
@@ -646,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* regs, 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;
@@ -659,6 +638,8 @@ static int sgiseeq_init(struct hpc3_regs* regs, int irq)
                err = -ENOMEM;
                goto err_out;
        }
+
+       platform_set_drvdata(pdev, dev);
        sp = netdev_priv(dev);
 
        /* Make private data page aligned */
@@ -670,20 +651,14 @@ static int sgiseeq_init(struct hpc3_regs* regs, 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;
        gdev = dev;
 #endif
-       sp->sregs = (struct sgiseeq_regs *) &hpc3c0->eth_ext[0];
-       sp->hregs = &hpc3c0->ethregs;
+       sp->sregs = (struct sgiseeq_regs *) &hpcregs->eth_ext[0];
+       sp->hregs = &hpcregs->ethregs;
        sp->name = sgiseeqstr;
        sp->mode = SEEQ_RCMD_RBCAST;
 
@@ -700,6 +675,16 @@ static int sgiseeq_init(struct hpc3_regs* regs, 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 |
+                            HPC3_EDCFG_FRXDC | HPC3_EDCFG_PTO | 0x026;
+
        /* Reset the chip. */
        hpc3_eth_reset(sp->hregs);
 
@@ -726,13 +711,10 @@ static int sgiseeq_init(struct hpc3_regs* regs, int irq)
                goto err_out_free_page;
        }
 
-       printk(KERN_INFO "%s: SGI Seeq8003 ", dev->name);
+       printk(KERN_INFO "%s: %s ", dev->name, sgiseeqstr);
        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:
@@ -744,29 +726,45 @@ err_out:
        return err;
 }
 
-static int __init sgiseeq_probe(void)
+static int __exit sgiseeq_remove(struct platform_device *pdev)
 {
-       printk(version);
+       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);
 
-       /* On board adapter on 1st HPC is always present */
-       return sgiseeq_init(hpc3c0, SGI_ENET_IRQ);
+       return 0;
 }
 
-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>");
 MODULE_LICENSE("GPL");