fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / ide / pci / sl82c105.c
index 563c44c..170a261 100644 (file)
@@ -13,7 +13,6 @@
  *  -- Benjamin Herrenschmidt (01/11/03) benh@kernel.crashing.org
  */
 
-#include <linux/config.h>
 #include <linux/types.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
@@ -236,15 +235,13 @@ static int sl82c105_ide_dma_lost_irq(ide_drive_t *drive)
  * The generic IDE core will have disabled the BMEN bit before this
  * function is called.
  */
-static int sl82c105_ide_dma_begin(ide_drive_t *drive)
+static void sl82c105_ide_dma_start(ide_drive_t *drive)
 {
        ide_hwif_t *hwif = HWIF(drive);
        struct pci_dev *dev = hwif->pci_dev;
 
-//     DBG(("sl82c105_ide_dma_begin(drive:%s)\n", drive->name));
-
        sl82c105_reset_host(dev);
-       return __ide_dma_begin(drive);
+       ide_dma_start(drive);
 }
 
 static int sl82c105_ide_dma_timeout(ide_drive_t *drive)
@@ -302,14 +299,14 @@ static void sl82c105_selectproc(ide_drive_t *drive)
        //DBG(("sl82c105_selectproc(drive:%s)\n", drive->name));
 
        mask = hwif->channel ? CTRL_P1F16 : CTRL_P0F16;
-       old = val = *((u32 *)&hwif->hwif_data);
+       old = val = (u32)pci_get_drvdata(dev);
        if (drive->using_dma)
                val &= ~mask;
        else
                val |= mask;
        if (old != val) {
                pci_write_config_dword(dev, 0x40, val); 
-               *((u32 *)&hwif->hwif_data) = val;
+               pci_set_drvdata(dev, (void *)val);
        }
 }
 
@@ -319,14 +316,13 @@ static void sl82c105_selectproc(ide_drive_t *drive)
  */
 static void sl82c105_resetproc(ide_drive_t *drive)
 {
-       ide_hwif_t *hwif = HWIF(drive);
-       struct pci_dev *dev = hwif->pci_dev;
+       struct pci_dev *dev = HWIF(drive)->pci_dev;
        u32 val;
 
        DBG(("sl82c105_resetproc(drive:%s)\n", drive->name));
 
        pci_read_config_dword(dev, 0x40, &val);
-       *((u32 *)&hwif->hwif_data) = val;
+       pci_set_drvdata(dev, (void *)val);
 }
        
 /*
@@ -388,7 +384,7 @@ static unsigned int sl82c105_bridge_revision(struct pci_dev *dev)
  * channel 0 here at least, but channel 1 has to be enabled by
  * firmware or arch code. We still set both to 16 bits mode.
  */
-static unsigned int __init init_chipset_sl82c105(struct pci_dev *dev, const char *msg)
+static unsigned int __devinit init_chipset_sl82c105(struct pci_dev *dev, const char *msg)
 {
        u32 val;
 
@@ -397,93 +393,82 @@ static unsigned int __init init_chipset_sl82c105(struct pci_dev *dev, const char
        pci_read_config_dword(dev, 0x40, &val);
        val |= CTRL_P0EN | CTRL_P0F16 | CTRL_P1F16;
        pci_write_config_dword(dev, 0x40, val);
+       pci_set_drvdata(dev, (void *)val);
 
        return dev->irq;
 }
 
-static void __init init_dma_sl82c105(ide_hwif_t *hwif, unsigned long dma_base)
+/*
+ * Initialise the chip
+ */
+
+static void __devinit init_hwif_sl82c105(ide_hwif_t *hwif)
 {
        unsigned int rev;
        u8 dma_state;
 
-       DBG(("init_dma_sl82c105(hwif: ide%d, dma_base: 0x%08x)\n", hwif->index, dma_base));
+       DBG(("init_hwif_sl82c105(hwif: ide%d)\n", hwif->index));
+
+       hwif->tuneproc = tune_sl82c105;
+       hwif->selectproc = sl82c105_selectproc;
+       hwif->resetproc = sl82c105_resetproc;
 
+       /*
+        * Default to PIO 0 for fallback unless tuned otherwise.
+        * We always autotune PIO,  this is done before DMA is checked,
+        * so there's no risk of accidentally disabling DMA
+        */
+       hwif->drives[0].pio_speed = XFER_PIO_0;
+       hwif->drives[0].autotune = 1;
+       hwif->drives[1].pio_speed = XFER_PIO_0;
+       hwif->drives[1].autotune = 1;
+
+       hwif->atapi_dma = 0;
+       hwif->mwdma_mask = 0;
+       hwif->swdma_mask = 0;
        hwif->autodma = 0;
 
-       if (!dma_base)
+       if (!hwif->dma_base)
                return;
 
-       dma_state = hwif->INB(dma_base + 2);
+       dma_state = hwif->INB(hwif->dma_base + 2) & ~0x60;
        rev = sl82c105_bridge_revision(hwif->pci_dev);
        if (rev <= 5) {
+               /*
+                * Never ever EVER under any circumstances enable
+                * DMA when the bridge is this old.
+                */
                printk("    %s: Winbond 553 bridge revision %d, BM-DMA disabled\n",
                       hwif->name, rev);
-               dma_state &= ~0x60;
        } else {
                dma_state |= 0x60;
-               if (!noautodma)
-                       hwif->autodma = 1;
-       }
-       hwif->OUTB(dma_state, dma_base + 2);
-
-       ide_setup_dma(hwif, dma_base, 8);
-}
 
-/*
- * Initialise the chip
- */
+               hwif->atapi_dma = 1;
+               hwif->mwdma_mask = 0x07;
+               hwif->swdma_mask = 0x07;
 
-static void __init init_hwif_sl82c105(ide_hwif_t *hwif)
-{
-       struct pci_dev *dev = hwif->pci_dev;
-       u32 val;
-       
-       DBG(("init_hwif_sl82c105(hwif: ide%d)\n", hwif->index));
+               hwif->ide_dma_check = &sl82c105_check_drive;
+               hwif->ide_dma_on = &sl82c105_ide_dma_on;
+               hwif->ide_dma_off_quietly = &sl82c105_ide_dma_off_quietly;
+               hwif->ide_dma_lostirq = &sl82c105_ide_dma_lost_irq;
+               hwif->dma_start = &sl82c105_ide_dma_start;
+               hwif->ide_dma_timeout = &sl82c105_ide_dma_timeout;
 
-       hwif->tuneproc = tune_sl82c105;
-       hwif->selectproc = sl82c105_selectproc;
-       hwif->resetproc = sl82c105_resetproc;
-       
-       /* Default to PIO 0 for fallback unless tuned otherwise,
-        * we always autotune PIO, this is done before DMA is
-        * checked, so there is no risk of accidentally disabling
-        * DMA
-         */
-       hwif->drives[0].pio_speed = XFER_PIO_0;
-       hwif->drives[0].autotune = 1;
-       hwif->drives[1].pio_speed = XFER_PIO_1;
-       hwif->drives[1].autotune = 1;
-
-       pci_read_config_dword(dev, 0x40, &val);
-       *((u32 *)&hwif->hwif_data) = val;
-       
-       if (!hwif->dma_base)
-               return;
+               if (!noautodma)
+                       hwif->autodma = 1;
+               hwif->drives[0].autodma = hwif->autodma;
+               hwif->drives[1].autodma = hwif->autodma;
 
-       hwif->atapi_dma = 1;
-       hwif->mwdma_mask = 0x07;
-       hwif->swdma_mask = 0x07;
-
-#ifdef CONFIG_BLK_DEV_IDEDMA
-       hwif->ide_dma_check = &sl82c105_check_drive;
-       hwif->ide_dma_on = &sl82c105_ide_dma_on;
-       hwif->ide_dma_off_quietly = &sl82c105_ide_dma_off_quietly;
-       hwif->ide_dma_lostirq = &sl82c105_ide_dma_lost_irq;
-       hwif->ide_dma_begin = &sl82c105_ide_dma_begin;
-       hwif->ide_dma_timeout = &sl82c105_ide_dma_timeout;
-
-       if (!noautodma)
-               hwif->autodma = 1;
-       hwif->drives[0].autodma = hwif->autodma;
-       hwif->drives[1].autodma = hwif->autodma;
-#endif /* CONFIG_BLK_DEV_IDEDMA */
+               if (hwif->mate)
+                       hwif->serialized = hwif->mate->serialized = 1;
+       }
+       hwif->OUTB(dma_state, hwif->dma_base + 2);
 }
 
 static ide_pci_device_t sl82c105_chipset __devinitdata = {
        .name           = "W82C105",
        .init_chipset   = init_chipset_sl82c105,
        .init_hwif      = init_hwif_sl82c105,
-       .init_dma       = init_dma_sl82c105,
        .channels       = 2,
        .autodma        = NOAUTODMA,
        .enablebits     = {{0x40,0x01,0x01}, {0x40,0x10,0x10}},
@@ -492,12 +477,11 @@ static ide_pci_device_t sl82c105_chipset __devinitdata = {
 
 static int __devinit sl82c105_init_one(struct pci_dev *dev, const struct pci_device_id *id)
 {
-       ide_setup_pci_device(dev, &sl82c105_chipset);
-       return 0;
+       return ide_setup_pci_device(dev, &sl82c105_chipset);
 }
 
 static struct pci_device_id sl82c105_pci_tbl[] = {
-       { PCI_VENDOR_ID_WINBOND, PCI_DEVICE_ID_WINBOND_82C105, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+       { PCI_DEVICE(PCI_VENDOR_ID_WINBOND, PCI_DEVICE_ID_WINBOND_82C105), 0},
        { 0, },
 };
 MODULE_DEVICE_TABLE(pci, sl82c105_pci_tbl);
@@ -508,7 +492,7 @@ static struct pci_driver driver = {
        .probe          = sl82c105_init_one,
 };
 
-static int sl82c105_ide_init(void)
+static int __init sl82c105_ide_init(void)
 {
        return ide_pci_register_driver(&driver);
 }