Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / drivers / net / ioc3-eth.c
index d520b59..ae71ed5 100644 (file)
 #include <linux/ip.h>
 #include <linux/tcp.h>
 #include <linux/udp.h>
+#include <linux/dma-mapping.h>
 
 #ifdef CONFIG_SERIAL_8250
-#include <linux/serial.h>
-#include <asm/serial.h>
-#define IOC3_BAUD (22000000 / (3*16))
-#define IOC3_COM_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST)
+#include <linux/serial_core.h>
+#include <linux/serial_8250.h>
 #endif
 
 #include <linux/netdevice.h>
@@ -499,7 +498,7 @@ static int ioc3_mdio_read(struct net_device *dev, int phy, int reg)
        ioc3_w_micr((phy << MICR_PHYADDR_SHIFT) | reg | MICR_READTRIG);
        while (ioc3_r_micr() & MICR_BUSY);
 
-       return ioc3_r_micr() & MIDR_DATA_MASK;
+       return ioc3_r_midr_r() & MIDR_DATA_MASK;
 }
 
 static void ioc3_mdio_write(struct net_device *dev, int phy, int reg, int data)
@@ -1146,12 +1145,11 @@ static inline int ioc3_is_menet(struct pci_dev *pdev)
  * around ioc3 oddities in this respect.
  *
  * The IOC3 serials use a 22MHz clock rate with an additional divider by 3.
- * (IOC3_BAUD = (22000000 / (3*16)))
  */
 
 static void __devinit ioc3_serial_probe(struct pci_dev *pdev, struct ioc3 *ioc3)
 {
-       struct serial_struct req;
+       struct uart_port port;
 
        /*
         * We need to recognice and treat the fourth MENET serial as it
@@ -1165,20 +1163,25 @@ static void __devinit ioc3_serial_probe(struct pci_dev *pdev, struct ioc3 *ioc3)
        if (ioc3_is_menet(pdev) && PCI_SLOT(pdev->devfn) == 3)
                return;
 
-       /* Register to interrupt zero because we share the interrupt with
-          the serial driver which we don't properly support yet.  */
-       memset(&req, 0, sizeof(req));
-       req.irq             = 0;
-       req.flags           = IOC3_COM_FLAGS;
-       req.io_type         = SERIAL_IO_MEM;
-       req.iomem_reg_shift = 0;
-       req.baud_base       = IOC3_BAUD;
-
-       req.iomem_base      = (unsigned char *) &ioc3->sregs.uarta;
-       register_serial(&req);
-
-       req.iomem_base      = (unsigned char *) &ioc3->sregs.uartb;
-       register_serial(&req);
+       /*
+        * 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.
+        */
+       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);
 }
 #endif
 
@@ -1193,17 +1196,17 @@ static int ioc3_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        int err, pci_using_dac;
 
        /* Configure DMA attributes. */
-       err = pci_set_dma_mask(pdev, 0xffffffffffffffffULL);
+       err = pci_set_dma_mask(pdev, DMA_64BIT_MASK);
        if (!err) {
                pci_using_dac = 1;
-               err = pci_set_consistent_dma_mask(pdev, 0xffffffffffffffffULL);
+               err = pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK);
                if (err < 0) {
                        printk(KERN_ERR "%s: Unable to obtain 64 bit DMA "
                               "for consistent allocations\n", pci_name(pdev));
                        goto out;
                }
        } else {
-               err = pci_set_dma_mask(pdev, 0xffffffffULL);
+               err = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
                if (err) {
                        printk(KERN_ERR "%s: No usable DMA configuration, "
                               "aborting.\n", pci_name(pdev));
@@ -1291,7 +1294,6 @@ static int ioc3_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        dev->features           = NETIF_F_IP_CSUM;
 #endif
 
-       ioc3_setup_duplex(ip);
        sw_physid1 = ioc3_mdio_read(dev, ip->mii.phy_id, MII_PHYSID1);
        sw_physid2 = ioc3_mdio_read(dev, ip->mii.phy_id, MII_PHYSID2);
 
@@ -1300,6 +1302,7 @@ static int ioc3_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                goto out_stop;
 
        mii_check_media(&ip->mii, 1, 1);
+       ioc3_setup_duplex(ip);
 
        vendor = (sw_physid1 << 12) | (sw_physid2 >> 4);
        model  = (sw_physid2 >> 4) & 0x3f;
@@ -1358,7 +1361,7 @@ static struct pci_driver ioc3_driver = {
 
 static int __init ioc3_init_module(void)
 {
-       return pci_module_init(&ioc3_driver);
+       return pci_register_driver(&ioc3_driver);
 }
 
 static void __exit ioc3_cleanup_module(void)
@@ -1524,7 +1527,7 @@ static void ioc3_get_drvinfo (struct net_device *dev,
        struct ethtool_drvinfo *info)
 {
        struct ioc3_private *ip = netdev_priv(dev);
-                                                                                
+
         strcpy (info->driver, IOC3_NAME);
         strcpy (info->version, IOC3_VERSION);
         strcpy (info->bus_info, pci_name(ip->pdev));
@@ -1550,7 +1553,7 @@ static int ioc3_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
        spin_lock_irq(&ip->ioc3_lock);
        rc = mii_ethtool_sset(&ip->mii, cmd);
        spin_unlock_irq(&ip->ioc3_lock);
-                                                                        
+
        return rc;
 }