]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/ata/pata_jmicron.c
libata-link: linkify reset
[linux-2.6-omap-h63xx.git] / drivers / ata / pata_jmicron.c
index 7a635dd326f85825d044a957d906a827497145c6..1619b86b74af5d78357ab7af0df9bb7b7bc648a0 100644 (file)
@@ -19,7 +19,7 @@
 #include <linux/ata.h>
 
 #define DRV_NAME       "pata_jmicron"
-#define DRV_VERSION    "0.1.4"
+#define DRV_VERSION    "0.1.5"
 
 typedef enum {
        PORT_PATA0 = 0,
@@ -29,18 +29,19 @@ typedef enum {
 
 /**
  *     jmicron_pre_reset       -       check for 40/80 pin
- *     @ap: Port
+ *     @link: ATA link
+ *     @deadline: deadline jiffies for the operation
  *
  *     Perform the PATA port setup we need.
-
+ *
  *     On the Jmicron 361/363 there is a single PATA port that can be mapped
  *     either as primary or secondary (or neither). We don't do any policy
  *     and setup here. We assume that has been done by init_one and the
  *     BIOS.
  */
-
-static int jmicron_pre_reset(struct ata_port *ap)
+static int jmicron_pre_reset(struct ata_link *link, unsigned long deadline)
 {
+       struct ata_port *ap = link->ap;
        struct pci_dev *pdev = to_pci_dev(ap->host->dev);
        u32 control;
        u32 control5;
@@ -102,7 +103,7 @@ static int jmicron_pre_reset(struct ata_port *ap)
                ap->cbl = ATA_CBL_SATA;
                break;
        }
-       return ata_std_prereset(ap);
+       return ata_std_prereset(link, deadline);
 }
 
 /**
@@ -190,61 +191,32 @@ static const struct ata_port_operations jmicron_ops = {
 
 static int jmicron_init_one (struct pci_dev *pdev, const struct pci_device_id *id)
 {
-       static struct ata_port_info info = {
+       static const struct ata_port_info info = {
                .sht            = &jmicron_sht,
-               .flags  = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST,
+               .flags  = ATA_FLAG_SLAVE_POSS,
 
                .pio_mask       = 0x1f,
                .mwdma_mask     = 0x07,
-               .udma_mask      = 0x3f,
+               .udma_mask      = ATA_UDMA5,
 
                .port_ops       = &jmicron_ops,
        };
-       struct ata_port_info *port_info[2] = { &info, &info };
+       const struct ata_port_info *ppi[] = { &info, NULL };
 
-       u32 reg;
-
-       /* PATA controller is fn 1, AHCI is fn 0 */
-       if (id->driver_data != 368 && PCI_FUNC(pdev->devfn) != 1)
-               return -ENODEV;
-
-       /* The 365/66 have two PATA channels, redirect the second */
-       if (id->driver_data == 365 || id->driver_data == 366) {
-               pci_read_config_dword(pdev, 0x80, &reg);
-               reg |= (1 << 24);       /* IDE1 to PATA IDE secondary */
-               pci_write_config_dword(pdev, 0x80, reg);
-       }
-
-       return ata_pci_init_one(pdev, port_info, 2);
-}
-
-static int jmicron_reinit_one(struct pci_dev *pdev)
-{
-       u32 reg;
-
-       switch(pdev->device) {
-               case PCI_DEVICE_ID_JMICRON_JMB368:
-                       break;
-               case PCI_DEVICE_ID_JMICRON_JMB365:
-               case PCI_DEVICE_ID_JMICRON_JMB366:
-                       /* Restore mapping or disks swap and boy does it get ugly */
-                       pci_read_config_dword(pdev, 0x80, &reg);
-                       reg |= (1 << 24);       /* IDE1 to PATA IDE secondary */
-                       pci_write_config_dword(pdev, 0x80, reg);
-                       /* Fall through */
-               default:
-                       /* Make sure AHCI is turned back on */
-                       pci_write_config_byte(pdev, 0x41, 0xa1);
-       }
-       return ata_pci_device_resume(pdev);
+       return ata_pci_init_one(pdev, ppi);
 }
 
 static const struct pci_device_id jmicron_pci_tbl[] = {
-       { PCI_VDEVICE(JMICRON, PCI_DEVICE_ID_JMICRON_JMB361), 361},
-       { PCI_VDEVICE(JMICRON, PCI_DEVICE_ID_JMICRON_JMB363), 363},
-       { PCI_VDEVICE(JMICRON, PCI_DEVICE_ID_JMICRON_JMB365), 365},
-       { PCI_VDEVICE(JMICRON, PCI_DEVICE_ID_JMICRON_JMB366), 366},
-       { PCI_VDEVICE(JMICRON, PCI_DEVICE_ID_JMICRON_JMB368), 368},
+       { PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB361,
+         PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_STORAGE_IDE << 8, 0xffff00, 361 },
+       { PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB363,
+         PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_STORAGE_IDE << 8, 0xffff00, 363 },
+       { PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB365,
+         PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_STORAGE_IDE << 8, 0xffff00, 365 },
+       { PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB366,
+         PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_STORAGE_IDE << 8, 0xffff00, 366 },
+       { PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB368,
+         PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_STORAGE_IDE << 8, 0xffff00, 368 },
 
        { }     /* terminate list */
 };
@@ -254,8 +226,10 @@ static struct pci_driver jmicron_pci_driver = {
        .id_table               = jmicron_pci_tbl,
        .probe                  = jmicron_init_one,
        .remove                 = ata_pci_remove_one,
+#ifdef CONFIG_PM
        .suspend                = ata_pci_device_suspend,
-       .resume                 = jmicron_reinit_one,
+       .resume                 = ata_pci_device_resume,
+#endif
 };
 
 static int __init jmicron_init(void)