ide: mark "idebus=" kernel parameter as obsoleted (take 2)
[linux-2.6-block.git] / drivers / ide / pci / opti621.c
index 9fa06393469a835a8b78a3fcadf8099c8072385a..684160d3cc0ebf36e004f1097df02bb00a1ea19a 100644 (file)
@@ -1,6 +1,4 @@
 /*
- *  linux/drivers/ide/pci/opti621.c            Version 0.7     Sept 10, 2002
- *
  *  Copyright (C) 1996-1998  Linus Torvalds & authors (see below)
  */
 
  * If you then set the second drive to another PIO, the old value
  * (automatically selected) will be overrided by yours.
  * There is a 25/33MHz switch in configuration
- * register, but driver is written for use at any frequency which get
- * (use idebus=xx to select PCI bus speed).
- * Use hda=autotune and hdb=autotune for automatical tune of the PIO modes.
- * If you get strange results, do not use this and set PIO manually
- * by hdparm.
+ * register, but driver is written for use at any frequency.
  *
  * Version 0.1, Nov 8, 1996
- * by Jaromir Koutek, for 2.1.8. 
+ * by Jaromir Koutek, for 2.1.8.
  * Initial version of driver.
- * 
+ *
  * Version 0.2
  * Number 0.2 skipped.
  *
@@ -80,7 +74,7 @@
  * by Jaromir Koutek
  * Updates for use with (again) new IDE block driver.
  * Update of documentation.
- * 
+ *
  * Version 0.6, Jan 2, 1999
  * by Jaromir Koutek
  * Reversed to version 0.3 of the driver, because
 #include <linux/types.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
-#include <linux/delay.h>
-#include <linux/timer.h>
-#include <linux/mm.h>
-#include <linux/ioport.h>
-#include <linux/blkdev.h>
 #include <linux/pci.h>
 #include <linux/hdreg.h>
 #include <linux/ide.h>
@@ -136,6 +125,8 @@ static int reg_base;
 #define PIO_NOT_EXIST 254
 #define PIO_DONT_KNOW 255
 
+static DEFINE_SPINLOCK(opti621_lock);
+
 /* there are stored pio numbers from other calls of opti621_set_pio_mode */
 static void compute_pios(ide_drive_t *drive, const u8 pio)
 /* Store values into drive->drive_data
@@ -216,29 +207,34 @@ typedef struct pio_clocks_s {
 
 static void compute_clocks(int pio, pio_clocks_t *clks)
 {
-        if (pio != PIO_NOT_EXIST) {
-               int adr_setup, data_pls;
-               int bus_speed = system_bus_clock();
-
-               adr_setup = ide_pio_timings[pio].setup_time;
-               data_pls = ide_pio_timings[pio].active_time;
-               clks->address_time = cmpt_clk(adr_setup, bus_speed);
-               clks->data_time = cmpt_clk(data_pls, bus_speed);
-               clks->recovery_time = cmpt_clk(ide_pio_timings[pio].cycle_time
-                       - adr_setup-data_pls, bus_speed);
-               if (clks->address_time<1) clks->address_time = 1;
-               if (clks->address_time>4) clks->address_time = 4;
-               if (clks->data_time<1) clks->data_time = 1;
-               if (clks->data_time>16) clks->data_time = 16;
-               if (clks->recovery_time<2) clks->recovery_time = 2;
-               if (clks->recovery_time>17) clks->recovery_time = 17;
+       if (pio != PIO_NOT_EXIST) {
+               int adr_setup, data_pls;
+               int bus_speed = ide_pci_clk ? ide_pci_clk : system_bus_clock();
+
+               adr_setup = ide_pio_timings[pio].setup_time;
+               data_pls = ide_pio_timings[pio].active_time;
+               clks->address_time = cmpt_clk(adr_setup, bus_speed);
+               clks->data_time = cmpt_clk(data_pls, bus_speed);
+               clks->recovery_time = cmpt_clk(ide_pio_timings[pio].cycle_time
+                       - adr_setup-data_pls, bus_speed);
+               if (clks->address_time < 1)
+                       clks->address_time = 1;
+               if (clks->address_time > 4)
+                       clks->address_time = 4;
+               if (clks->data_time < 1)
+                       clks->data_time = 1;
+               if (clks->data_time > 16)
+                       clks->data_time = 16;
+               if (clks->recovery_time < 2)
+                       clks->recovery_time = 2;
+               if (clks->recovery_time > 17)
+                       clks->recovery_time = 17;
        } else {
                clks->address_time = 1;
                clks->data_time = 1;
                clks->recovery_time = 2;
                /* minimal values */
        }
 }
 
 static void opti621_set_pio_mode(ide_drive_t *drive, const u8 pio)
@@ -255,8 +251,8 @@ static void opti621_set_pio_mode(ide_drive_t *drive, const u8 pio)
 
        /* sets drive->drive_data for both drives */
        compute_pios(drive, pio);
-       pio1 = hwif->drives[0].drive_data;
-       pio2 = hwif->drives[1].drive_data;
+       pio1 = hwif->drives[0].drive_data;
+       pio2 = hwif->drives[1].drive_data;
 
        compute_clocks(pio1, &first);
        compute_clocks(pio2, &second);
@@ -281,9 +277,9 @@ static void opti621_set_pio_mode(ide_drive_t *drive, const u8 pio)
                second.recovery_time, drdy);
 #endif
 
-       spin_lock_irqsave(&ide_lock, flags);
+       spin_lock_irqsave(&opti621_lock, flags);
 
-       reg_base = hwif->io_ports[IDE_DATA_OFFSET];
+       reg_base = hwif->io_ports[IDE_DATA_OFFSET];
 
        /* allow Register-B */
        outb(0xc0, reg_base + CNTRL_REG);
@@ -320,48 +316,37 @@ static void opti621_set_pio_mode(ide_drive_t *drive, const u8 pio)
        /*  and read prefetch for both drives */
        write_reg(misc, MISC_REG);
 
-       spin_unlock_irqrestore(&ide_lock, flags);
+       spin_unlock_irqrestore(&opti621_lock, flags);
 }
 
-/*
- * init_hwif_opti621() is called once for each hwif found at boot.
- */
-static void __devinit init_hwif_opti621 (ide_hwif_t *hwif)
+static void __devinit opti621_port_init_devs(ide_hwif_t *hwif)
 {
-       hwif->autodma = 0;
        hwif->drives[0].drive_data = PIO_DONT_KNOW;
        hwif->drives[1].drive_data = PIO_DONT_KNOW;
-
-       hwif->set_pio_mode = &opti621_set_pio_mode;
-
-       if (!(hwif->dma_base))
-               return;
-
-       hwif->atapi_dma = 1;
-       hwif->mwdma_mask = 0x07;
-       hwif->swdma_mask = 0x07;
-
-       if (!noautodma)
-               hwif->autodma = 1;
-       hwif->drives[0].autodma = hwif->autodma;
-       hwif->drives[1].autodma = hwif->autodma;
 }
 
-static ide_pci_device_t opti621_chipsets[] __devinitdata = {
+static const struct ide_port_ops opti621_port_ops = {
+       .port_init_devs         = opti621_port_init_devs,
+       .set_pio_mode           = opti621_set_pio_mode,
+};
+
+static const struct ide_port_info opti621_chipsets[] __devinitdata = {
        {       /* 0 */
                .name           = "OPTI621",
-               .init_hwif      = init_hwif_opti621,
-               .autodma        = AUTODMA,
-               .enablebits     = {{0x45,0x80,0x00}, {0x40,0x08,0x00}},
-               .bootable       = ON_BOARD,
+               .enablebits     = { {0x45, 0x80, 0x00}, {0x40, 0x08, 0x00} },
+               .port_ops       = &opti621_port_ops,
+               .host_flags     = IDE_HFLAG_TRUST_BIOS_FOR_DMA,
                .pio_mask       = ATA_PIO3,
-       },{     /* 1 */
+               .swdma_mask     = ATA_SWDMA2,
+               .mwdma_mask     = ATA_MWDMA2,
+       }, {    /* 1 */
                .name           = "OPTI621X",
-               .init_hwif      = init_hwif_opti621,
-               .autodma        = AUTODMA,
-               .enablebits     = {{0x45,0x80,0x00}, {0x40,0x08,0x00}},
-               .bootable       = ON_BOARD,
+               .enablebits     = { {0x45, 0x80, 0x00}, {0x40, 0x08, 0x00} },
+               .port_ops       = &opti621_port_ops,
+               .host_flags     = IDE_HFLAG_TRUST_BIOS_FOR_DMA,
                .pio_mask       = ATA_PIO3,
+               .swdma_mask     = ATA_SWDMA2,
+               .mwdma_mask     = ATA_MWDMA2,
        }
 };
 
@@ -370,9 +355,9 @@ static int __devinit opti621_init_one(struct pci_dev *dev, const struct pci_devi
        return ide_setup_pci_device(dev, &opti621_chipsets[id->driver_data]);
 }
 
-static struct pci_device_id opti621_pci_tbl[] = {
-       { PCI_VENDOR_ID_OPTI, PCI_DEVICE_ID_OPTI_82C621, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-       { PCI_VENDOR_ID_OPTI, PCI_DEVICE_ID_OPTI_82C825, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1},
+static const struct pci_device_id opti621_pci_tbl[] = {
+       { PCI_VDEVICE(OPTI, PCI_DEVICE_ID_OPTI_82C621), 0 },
+       { PCI_VDEVICE(OPTI, PCI_DEVICE_ID_OPTI_82C825), 1 },
        { 0, },
 };
 MODULE_DEVICE_TABLE(pci, opti621_pci_tbl);