]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/ioc3-eth.c
Pull misc into release branch
[linux-2.6-omap-h63xx.git] / drivers / net / ioc3-eth.c
index 4ad780719a848de644fb503a2f2e3f8dabfcb2dd..0834ef0eddb4e7b61c6e33ae6c7283c8965c8705 100644 (file)
@@ -48,6 +48,7 @@
 #ifdef CONFIG_SERIAL_8250
 #include <linux/serial_core.h>
 #include <linux/serial_8250.h>
+#include <linux/serial_reg.h>
 #endif
 
 #include <linux/netdevice.h>
@@ -352,13 +353,12 @@ static u64 nic_find(struct ioc3 *ioc3, int *last)
 
 static int nic_init(struct ioc3 *ioc3)
 {
-       const char *type;
+       const char *unknown = "unknown";
+       const char *type = unknown;
        u8 crc;
        u8 serial[6];
        int save = 0, i;
 
-       type = "unknown";
-
        while (1) {
                u64 reg;
                reg = nic_find(ioc3, &save);
@@ -392,7 +392,7 @@ static int nic_init(struct ioc3 *ioc3)
        }
 
        printk("Found %s NIC", type);
-       if (type != "unknown") {
+       if (type != unknown) {
                printk (" registration number %02x:%02x:%02x:%02x:%02x:%02x,"
                        " CRC %02x", serial[0], serial[1], serial[2],
                        serial[3], serial[4], serial[5], crc);
@@ -633,8 +633,6 @@ static inline void ioc3_rx(struct ioc3_private *ip)
 
                        ip->rx_skbs[rx_entry] = NULL;   /* Poison  */
 
-                       new_skb->dev = priv_netdev(ip);
-
                        /* Because we reserve afterwards. */
                        skb_put(new_skb, (1664 + RX_OFFSET));
                        rxb = (struct ioc3_erxbuf *) new_skb->data;
@@ -940,7 +938,6 @@ static void ioc3_alloc_rings(struct net_device *dev)
                        }
 
                        ip->rx_skbs[i] = skb;
-                       skb->dev = dev;
 
                        /* Because we reserve afterwards. */
                        skb_put(skb, (1664 + RX_OFFSET));
@@ -1106,20 +1103,28 @@ static int ioc3_close(struct net_device *dev)
  * MiniDINs; all other subdevices are left swinging in the wind, leave
  * them disabled.
  */
-static inline int ioc3_is_menet(struct pci_dev *pdev)
+
+static int ioc3_adjacent_is_ioc3(struct pci_dev *pdev, int slot)
 {
-       struct pci_dev *dev;
-
-       return pdev->bus->parent == NULL
-              && (dev = pci_find_slot(pdev->bus->number, PCI_DEVFN(0, 0)))
-              && dev->vendor == PCI_VENDOR_ID_SGI
-              && dev->device == PCI_DEVICE_ID_SGI_IOC3
-              && (dev = pci_find_slot(pdev->bus->number, PCI_DEVFN(1, 0)))
-              && dev->vendor == PCI_VENDOR_ID_SGI
-              && dev->device == PCI_DEVICE_ID_SGI_IOC3
-              && (dev = pci_find_slot(pdev->bus->number, PCI_DEVFN(2, 0)))
-              && dev->vendor == PCI_VENDOR_ID_SGI
-              && dev->device == PCI_DEVICE_ID_SGI_IOC3;
+       struct pci_dev *dev = pci_get_slot(pdev->bus, PCI_DEVFN(slot, 0));
+       int ret = 0;
+
+       if (dev) {
+               if (dev->vendor == PCI_VENDOR_ID_SGI &&
+                       dev->device == PCI_DEVICE_ID_SGI_IOC3)
+                       ret = 1;
+               pci_dev_put(dev);
+       }
+
+       return ret;
+}
+
+static int ioc3_is_menet(struct pci_dev *pdev)
+{
+       return pdev->bus->parent == NULL &&
+              ioc3_adjacent_is_ioc3(pdev, 0) &&
+              ioc3_adjacent_is_ioc3(pdev, 1) &&
+              ioc3_adjacent_is_ioc3(pdev, 2);
 }
 
 #ifdef CONFIG_SERIAL_8250
@@ -1147,13 +1152,41 @@ static inline int ioc3_is_menet(struct pci_dev *pdev)
  * Also look in ip27-pci.c:pci_fixup_ioc3() for some comments on working
  * around ioc3 oddities in this respect.
  *
- * The IOC3 serials use a 22MHz clock rate with an additional divider by 3.
+ * The IOC3 serials use a 22MHz clock rate with an additional divider which
+ * can be programmed in the SCR register if the DLAB bit is set.
+ *
+ * Register to interrupt zero because we share the interrupt with
+ * the serial driver which we don't properly support yet.
+ *
+ * Can't use UPF_IOREMAP as the whole of IOC3 resources have already been
+ * registered.
  */
+static void __devinit ioc3_8250_register(struct ioc3_uartregs __iomem *uart)
+{
+#define COSMISC_CONSTANT 6
+
+       struct uart_port port = {
+               .irq            = 0,
+               .flags          = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
+               .iotype         = UPIO_MEM,
+               .regshift       = 0,
+               .uartclk        = (22000000 << 1) / COSMISC_CONSTANT,
+
+               .membase        = (unsigned char __iomem *) uart,
+               .mapbase        = (unsigned long) uart,
+       };
+       unsigned char lcr;
+
+       lcr = uart->iu_lcr;
+       uart->iu_lcr = lcr | UART_LCR_DLAB;
+       uart->iu_scr = COSMISC_CONSTANT,
+       uart->iu_lcr = lcr;
+       uart->iu_lcr;
+       serial8250_register_port(&port);
+}
 
 static void __devinit ioc3_serial_probe(struct pci_dev *pdev, struct ioc3 *ioc3)
 {
-       struct uart_port port;
-
        /*
         * We need to recognice and treat the fourth MENET serial as it
         * does not have an SuperIO chip attached to it, therefore attempting
@@ -1167,24 +1200,35 @@ static void __devinit ioc3_serial_probe(struct pci_dev *pdev, struct ioc3 *ioc3)
                return;
 
        /*
-        * Register to interrupt zero because we share the interrupt with
-        * the serial driver which we don't properly support yet.
-        *
-        * Can't use UPF_IOREMAP as the whole of IOC3 resources have already
-        * been registered.
+        * Switch IOC3 to PIO mode.  It probably already was but let's be
+        * paranoid
         */
-       memset(&port, 0, sizeof(port));
-       port.irq      = 0;
-       port.flags    = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF;
-       port.iotype   = UPIO_MEM;
-       port.regshift = 0;
-       port.uartclk  = 22000000 / 3;
-
-       port.membase  = (unsigned char *) &ioc3->sregs.uarta;
-       serial8250_register_port(&port);
-
-       port.membase  = (unsigned char *) &ioc3->sregs.uartb;
-       serial8250_register_port(&port);
+       ioc3->gpcr_s = GPCR_UARTA_MODESEL | GPCR_UARTB_MODESEL;
+       ioc3->gpcr_s;
+       ioc3->gppr_6 = 0;
+       ioc3->gppr_6;
+       ioc3->gppr_7 = 0;
+       ioc3->gppr_7;
+       ioc3->sscr_a = ioc3->sscr_a & ~SSCR_DMA_EN;
+       ioc3->sscr_a;
+       ioc3->sscr_b = ioc3->sscr_b & ~SSCR_DMA_EN;
+       ioc3->sscr_b;
+       /* Disable all SA/B interrupts except for SA/B_INT in SIO_IEC. */
+       ioc3->sio_iec &= ~ (SIO_IR_SA_TX_MT | SIO_IR_SA_RX_FULL |
+                           SIO_IR_SA_RX_HIGH | SIO_IR_SA_RX_TIMER |
+                           SIO_IR_SA_DELTA_DCD | SIO_IR_SA_DELTA_CTS |
+                           SIO_IR_SA_TX_EXPLICIT | SIO_IR_SA_MEMERR);
+       ioc3->sio_iec |= SIO_IR_SA_INT;
+       ioc3->sscr_a = 0;
+       ioc3->sio_iec &= ~ (SIO_IR_SB_TX_MT | SIO_IR_SB_RX_FULL |
+                           SIO_IR_SB_RX_HIGH | SIO_IR_SB_RX_TIMER |
+                           SIO_IR_SB_DELTA_DCD | SIO_IR_SB_DELTA_CTS |
+                           SIO_IR_SB_TX_EXPLICIT | SIO_IR_SB_MEMERR);
+       ioc3->sio_iec |= SIO_IR_SB_INT;
+       ioc3->sscr_b = 0;
+
+       ioc3_8250_register(&ioc3->sregs.uarta);
+       ioc3_8250_register(&ioc3->sregs.uartb);
 }
 #endif
 
@@ -1396,9 +1440,9 @@ static int ioc3_start_xmit(struct sk_buff *skb, struct net_device *dev)
         * manually.
         */
        if (skb->ip_summed == CHECKSUM_PARTIAL) {
-               int proto = ntohs(skb->nh.iph->protocol);
+               const struct iphdr *ih = ip_hdr(skb);
+               const int proto = ntohs(ih->protocol);
                unsigned int csoff;
-               struct iphdr *ih = skb->nh.iph;
                uint32_t csum, ehsum;
                uint16_t *eh;
 
@@ -1425,11 +1469,11 @@ static int ioc3_start_xmit(struct sk_buff *skb, struct net_device *dev)
                csoff = ETH_HLEN + (ih->ihl << 2);
                if (proto == IPPROTO_UDP) {
                        csoff += offsetof(struct udphdr, check);
-                       skb->h.uh->check = csum;
+                       udp_hdr(skb)->check = csum;
                }
                if (proto == IPPROTO_TCP) {
                        csoff += offsetof(struct tcphdr, check);
-                       skb->h.th->check = csum;
+                       tcp_hdr(skb)->check = csum;
                }
 
                w0 = ETXD_DOCHECKSUM | (csoff << ETXD_CHKOFF_SHIFT);
@@ -1446,7 +1490,7 @@ static int ioc3_start_xmit(struct sk_buff *skb, struct net_device *dev)
 
        if (len <= 104) {
                /* Short packet, let's copy it directly into the ring.  */
-               memcpy(desc->data, skb->data, skb->len);
+               skb_copy_from_linear_data(skb, desc->data, skb->len);
                if (len < ETH_ZLEN) {
                        /* Very short packet, pad with zeros at the end. */
                        memset(desc->data + len, 0, ETH_ZLEN - len);