]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/sgiseeq.c
Add support for Seeq 8003 on Challenge S Mezz board.
[linux-2.6-omap-h63xx.git] / drivers / net / sgiseeq.c
index a4614df38a903a53207507485eeec9a5486f50ae..1fc77300b0552d688d14148ba4def8d82148e0ca 100644 (file)
@@ -3,32 +3,24 @@
  *
  * 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/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 "sgiseeq.h"
 
@@ -59,8 +51,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;
@@ -209,7 +199,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;
@@ -311,9 +301,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);
 
@@ -328,7 +318,6 @@ 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);
 
@@ -431,7 +420,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);
@@ -515,12 +504,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);
@@ -551,7 +534,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) |
@@ -641,7 +624,7 @@ 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 sgiseeq_init(struct hpc3_regs* hpcregs, int irq, int has_eeprom)
 {
        struct sgiseeq_init_block *sr;
        struct sgiseeq_private *sp;
@@ -667,7 +650,9 @@ static int sgiseeq_init(struct hpc3_regs* hpcregs, int irq)
 
 #define EADDR_NVOFS     250
        for (i = 0; i < 3; i++) {
-               unsigned short tmp = ip22_nvram_read(EADDR_NVOFS / 2 + i);
+               unsigned short tmp = has_eeprom ?
+                       ip22_eeprom_read(&hpcregs->eeprom, EADDR_NVOFS / 2+i) :
+                       ip22_nvram_read(EADDR_NVOFS / 2+i);
 
                dev->dev_addr[2 * i]     = tmp >> 8;
                dev->dev_addr[2 * i + 1] = tmp & 0xff;
@@ -695,6 +680,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 |
@@ -746,8 +736,23 @@ err_out:
 
 static int __init sgiseeq_probe(void)
 {
+       unsigned int tmp, ret1, ret2 = 0;
+
        /* On board adapter on 1st HPC is always present */
-       return sgiseeq_init(hpc3c0, SGI_ENET_IRQ);
+       ret1 = sgiseeq_init(hpc3c0, SGI_ENET_IRQ, 0);
+       /* Let's see if second HPC is there */
+       if (!(ip22_is_fullhouse()) &&
+           get_dbe(tmp, (unsigned int *)&hpc3c1->pbdma[1]) == 0) {
+               sgimc->giopar |= SGIMC_GIOPAR_MASTEREXP1 |
+                                SGIMC_GIOPAR_EXP164 |
+                                SGIMC_GIOPAR_HPC264;
+               hpc3c1->pbus_piocfg[0][0] = 0x3ffff;
+               /* interrupt/config register on Challenge S Mezz board */
+               hpc3c1->pbus_extregs[0][0] = 0x30;
+               ret2 = sgiseeq_init(hpc3c1, SGI_GIO_0_IRQ, 1);
+       }
+
+       return (ret1 & ret2) ? ret1 : 0;
 }
 
 static void __exit sgiseeq_exit(void)