ide: deprecate CONFIG_BLK_DEV_OFFBOARD
[safe/jmp/linux-2.6] / drivers / ide / pci / jmicron.c
index c1cec23..0083eaf 100644 (file)
@@ -22,29 +22,13 @@ typedef enum {
 } port_type;
 
 /**
- *     jmicron_ratemask        -       Compute available modes
- *     @drive: IDE drive
- *
- *     Compute the available speeds for the devices on the interface. This
- *     is all modes to ATA133 clipped by drive cable setup.
- */
-
-static u8 jmicron_ratemask(ide_drive_t *drive)
-{
-       u8 mode = 4;
-       if (!eighty_ninty_three(drive))
-               mode = min(mode, (u8)1);
-       return mode;
-}
-
-/**
  *     ata66_jmicron           -       Cable check
  *     @hwif: IDE port
  *
- *     Return 1 if the cable is 80pin
+ *     Returns the cable type.
  */
 
-static int __devinit ata66_jmicron(ide_hwif_t *hwif)
+static u8 __devinit ata66_jmicron(ide_hwif_t *hwif)
 {
        struct pci_dev *pdev = hwif->pci_dev;
 
@@ -86,89 +70,33 @@ static int __devinit ata66_jmicron(ide_hwif_t *hwif)
        {
        case PORT_PATA0:
                if (control & (1 << 3)) /* 40/80 pin primary */
-                       return 1;
-               return 0;
+                       return ATA_CBL_PATA40;
+               return ATA_CBL_PATA80;
        case PORT_PATA1:
                if (control5 & (1 << 19))       /* 40/80 pin secondary */
-                       return 0;
-               return 1;
+                       return ATA_CBL_PATA40;
+               return ATA_CBL_PATA80;
        case PORT_SATA:
-               return 1;
+               break;
        }
+       /* Avoid bogus "control reaches end of non-void function" */
+       return ATA_CBL_PATA80;
 }
 
-static void jmicron_tuneproc (ide_drive_t *drive, byte mode_wanted)
-{
-       return;
-}
-
-/**
- *     config_jmicron_chipset_for_pio  -       set drive timings
- *     @drive: drive to tune
- *     @speed we want
- *
- */
-
-static void config_jmicron_chipset_for_pio (ide_drive_t *drive, byte set_speed)
-{
-       u8 speed = XFER_PIO_0 + ide_get_best_pio_mode(drive, 255, 5, NULL);
-       if (set_speed)
-               (void) ide_config_drive_speed(drive, speed);
-}
-
-/**
- *     jmicron_tune_chipset    -       set controller timings
- *     @drive: Drive to set up
- *     @xferspeed: speed we want to achieve
- *
- *     As the JMicron snoops for timings all we actually need to do is
- *     make sure we don't set an invalid mode. We do need to honour
- *     the cable detect here.
- */
-
-static int jmicron_tune_chipset (ide_drive_t *drive, byte xferspeed)
-{
-
-       u8 speed                = ide_rate_filter(jmicron_ratemask(drive), xferspeed);
-
-       return ide_config_drive_speed(drive, speed);
-}
-
-/**
- *     config_chipset_for_dma  -       configure for DMA
- *     @drive: drive to configure
- *
- *     As the JMicron snoops for timings all we actually need to do is
- *     make sure we don't set an invalid mode.
- */
-
-static int config_chipset_for_dma (ide_drive_t *drive)
+static void jmicron_set_pio_mode(ide_drive_t *drive, const u8 pio)
 {
-       u8 speed        = ide_dma_speed(drive, jmicron_ratemask(drive));
-
-       config_jmicron_chipset_for_pio(drive, !speed);
-       jmicron_tune_chipset(drive, speed);
-       return ide_dma_enable(drive);
 }
 
 /**
- *     jmicron_configure_drive_for_dma -       set up for DMA transfers
- *     @drive: drive we are going to set up
+ *     jmicron_set_dma_mode    -       set host controller for DMA mode
+ *     @drive: drive
+ *     @mode: DMA mode
  *
- *     As the JMicron snoops for timings all we actually need to do is
- *     make sure we don't set an invalid mode.
+ *     As the JMicron snoops for timings we don't need to do anything here.
  */
 
-static int jmicron_config_drive_for_dma (ide_drive_t *drive)
+static void jmicron_set_dma_mode(ide_drive_t *drive, const u8 mode)
 {
-       ide_hwif_t *hwif        = drive->hwif;
-
-       if (ide_use_dma(drive)) {
-               if (config_chipset_for_dma(drive))
-                       return hwif->ide_dma_on(drive);
-       }
-       config_jmicron_chipset_for_pio(drive, 1);
-       return hwif->ide_dma_off_quietly(drive);
 }
 
 /**
@@ -180,48 +108,24 @@ static int jmicron_config_drive_for_dma (ide_drive_t *drive)
 
 static void __devinit init_hwif_jmicron(ide_hwif_t *hwif)
 {
-       hwif->speedproc = &jmicron_tune_chipset;
-       hwif->tuneproc  = &jmicron_tuneproc;
-
-       hwif->drives[0].autotune = 1;
-       hwif->drives[1].autotune = 1;
-
-       if (!hwif->dma_base)
-               goto fallback;
+       hwif->set_pio_mode = &jmicron_set_pio_mode;
+       hwif->set_dma_mode = &jmicron_set_dma_mode;
 
-       hwif->atapi_dma = 1;
-       hwif->ultra_mask = 0x7f;
-       hwif->mwdma_mask = 0x07;
+       if (hwif->dma_base == 0)
+               return;
 
-       hwif->ide_dma_check = &jmicron_config_drive_for_dma;
-       if (!(hwif->udma_four))
-               hwif->udma_four = ata66_jmicron(hwif);
-
-       hwif->autodma = 1;
-       hwif->drives[0].autodma = hwif->autodma;
-       hwif->drives[1].autodma = hwif->autodma;
-       return;
-fallback:
-       hwif->autodma = 0;
-       return;
+       if (hwif->cbl != ATA_CBL_PATA40_SHORT)
+               hwif->cbl = ata66_jmicron(hwif);
 }
 
-#define DECLARE_JMB_DEV(name_str)                      \
-       {                                               \
-               .name           = name_str,             \
-               .init_hwif      = init_hwif_jmicron,    \
-               .channels       = 2,                    \
-               .autodma        = AUTODMA,              \
-               .bootable       = ON_BOARD,             \
-               .enablebits     = { {0x40, 1, 1}, {0x40, 0x10, 0x10} }, \
-       }
-
-static ide_pci_device_t jmicron_chipsets[] __devinitdata = {
-       /* 0 */ DECLARE_JMB_DEV("JMB361"),
-       /* 1 */ DECLARE_JMB_DEV("JMB363"),
-       /* 2 */ DECLARE_JMB_DEV("JMB365"),
-       /* 3 */ DECLARE_JMB_DEV("JMB366"),
-       /* 4 */ DECLARE_JMB_DEV("JMB368"),
+static const struct ide_port_info jmicron_chipset __devinitdata = {
+       .name           = "JMB",
+       .init_hwif      = init_hwif_jmicron,
+       .host_flags     = IDE_HFLAG_BOOTABLE,
+       .enablebits     = { { 0x40, 0x01, 0x01 }, { 0x40, 0x10, 0x10 } },
+       .pio_mask       = ATA_PIO5,
+       .mwdma_mask     = ATA_MWDMA2,
+       .udma_mask      = ATA_UDMA6,
 };
 
 /**
@@ -235,16 +139,28 @@ static ide_pci_device_t jmicron_chipsets[] __devinitdata = {
 
 static int __devinit jmicron_init_one(struct pci_dev *dev, const struct pci_device_id *id)
 {
-       ide_setup_pci_device(dev, &jmicron_chipsets[id->driver_data]);
-       return 0;
+       return ide_setup_pci_device(dev, &jmicron_chipset);
 }
 
+/* All JMB PATA controllers have and will continue to have the same
+ * interface.  Matching vendor and device class is enough for all
+ * current and future controllers if the controller is programmed
+ * properly.
+ *
+ * If libata is configured, jmicron PCI quirk programs the controller
+ * into the correct mode.  If libata isn't configured, match known
+ * device IDs too to maintain backward compatibility.
+ */
 static struct pci_device_id jmicron_pci_tbl[] = {
-       { PCI_DEVICE(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB361), 0},
-       { PCI_DEVICE(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB363), 1},
-       { PCI_DEVICE(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB365), 2},
-       { PCI_DEVICE(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB366), 3},
-       { PCI_DEVICE(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB368), 4},
+#if !defined(CONFIG_ATA) && !defined(CONFIG_ATA_MODULE)
+       { PCI_VDEVICE(JMICRON, PCI_DEVICE_ID_JMICRON_JMB361) },
+       { PCI_VDEVICE(JMICRON, PCI_DEVICE_ID_JMICRON_JMB363) },
+       { PCI_VDEVICE(JMICRON, PCI_DEVICE_ID_JMICRON_JMB365) },
+       { PCI_VDEVICE(JMICRON, PCI_DEVICE_ID_JMICRON_JMB366) },
+       { PCI_VDEVICE(JMICRON, PCI_DEVICE_ID_JMICRON_JMB368) },
+#endif
+       { PCI_VENDOR_ID_JMICRON, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
+         PCI_CLASS_STORAGE_IDE << 8, 0xffff00, 0 },
        { 0, },
 };