[PATCH] count ghost references to vfsmounts
[safe/jmp/linux-2.6] / drivers / ata / pata_via.c
index e4c71f7..d119a68 100644 (file)
 #include <linux/delay.h>
 #include <scsi/scsi_host.h>
 #include <linux/libata.h>
+#include <linux/dmi.h>
 
 #define DRV_NAME "pata_via"
-#define DRV_VERSION "0.3.1"
+#define DRV_VERSION "0.3.3"
 
 /*
  *     The following comes directly from Vojtech Pavlik's ide/pci/via82cxxx
@@ -83,6 +84,7 @@ enum {
        VIA_BAD_ID      = 0x100, /* Has wrong vendor ID (0x1107) */
        VIA_BAD_AST     = 0x200, /* Don't touch Address Setup Timing */
        VIA_NO_ENABLES  = 0x400, /* Has no enablebits */
+       VIA_SATA_PATA   = 0x800, /* SATA/PATA combined configuration */
 };
 
 /*
@@ -96,9 +98,10 @@ static const struct via_isa_bridge {
        u8 rev_max;
        u16 flags;
 } via_isa_bridges[] = {
+       { "vx800",      PCI_DEVICE_ID_VIA_VX800,    0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST },
        { "vt8237s",    PCI_DEVICE_ID_VIA_8237S,    0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST },
        { "vt8251",     PCI_DEVICE_ID_VIA_8251,     0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST },
-       { "cx700",      PCI_DEVICE_ID_VIA_CX700,    0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST },
+       { "cx700",      PCI_DEVICE_ID_VIA_CX700,    0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST | VIA_SATA_PATA },
        { "vt6410",     PCI_DEVICE_ID_VIA_6410,     0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST | VIA_NO_ENABLES},
        { "vt8237a",    PCI_DEVICE_ID_VIA_8237A,    0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST },
        { "vt8237",     PCI_DEVICE_ID_VIA_8237,     0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST },
@@ -122,6 +125,34 @@ static const struct via_isa_bridge {
        { NULL }
 };
 
+
+/*
+ *     Cable special cases
+ */
+
+static const struct dmi_system_id cable_dmi_table[] = {
+       {
+               .ident = "Acer Ferrari 3400",
+               .matches = {
+                       DMI_MATCH(DMI_BOARD_VENDOR, "Acer,Inc."),
+                       DMI_MATCH(DMI_BOARD_NAME, "Ferrari 3400"),
+               },
+       },
+       { }
+};
+
+static int via_cable_override(struct pci_dev *pdev)
+{
+       /* Systems by DMI */
+       if (dmi_check_system(cable_dmi_table))
+               return 1;
+       /* Arima W730-K8/Targa Visionary 811/... */
+       if (pdev->subsystem_vendor == 0x161F && pdev->subsystem_device == 0x2032)
+               return 1;
+       return 0;
+}
+
+
 /**
  *     via_cable_detect        -       cable detection
  *     @ap: ATA port
@@ -139,11 +170,17 @@ static int via_cable_detect(struct ata_port *ap) {
        struct pci_dev *pdev = to_pci_dev(ap->host->dev);
        u32 ata66;
 
+       if (via_cable_override(pdev))
+               return ATA_CBL_PATA40_SHORT;
+
+       if ((config->flags & VIA_SATA_PATA) && ap->port_no == 0)
+               return ATA_CBL_SATA;
+
        /* Early chips are 40 wire */
        if ((config->flags & VIA_UDMA) < VIA_UDMA_66)
                return ATA_CBL_PATA40;
        /* UDMA 66 chips have only drive side logic */
-       else if((config->flags & VIA_UDMA) < VIA_UDMA_100)
+       else if ((config->flags & VIA_UDMA) < VIA_UDMA_100)
                return ATA_CBL_PATA_UNK;
        /* UDMA 100 or later */
        pci_read_config_dword(pdev, 0x50, &ata66);
@@ -151,11 +188,16 @@ static int via_cable_detect(struct ata_port *ap) {
           two drives */
        if (ata66 & (0x10100000 >> (16 * ap->port_no)))
                return ATA_CBL_PATA80;
+       /* Check with ACPI so we can spot BIOS reported SATA bridges */
+       if (ata_acpi_init_gtm(ap) &&
+           ata_acpi_cbl_80wire(ap, ata_acpi_init_gtm(ap)))
+               return ATA_CBL_PATA80;
        return ATA_CBL_PATA40;
 }
 
-static int via_pre_reset(struct ata_port *ap, unsigned long deadline)
+static int via_pre_reset(struct ata_link *link, unsigned long deadline)
 {
+       struct ata_port *ap = link->ap;
        const struct via_isa_bridge *config = ap->host->private_data;
 
        if (!(config->flags & VIA_NO_ENABLES)) {
@@ -168,7 +210,7 @@ static int via_pre_reset(struct ata_port *ap, unsigned long deadline)
                        return -ENOENT;
        }
 
-       return ata_std_prereset(ap, deadline);
+       return ata_std_prereset(link, deadline);
 }
 
 
@@ -211,7 +253,6 @@ static void via_do_set_mode(struct ata_port *ap, struct ata_device *adev, int mo
        int ut;
        int offset = 3 - (2*ap->port_no) - adev->devno;
 
-
        /* Calculate the timing values we require */
        ata_timing_compute(adev, mode, &t, T, UT);
 
@@ -258,9 +299,17 @@ static void via_do_set_mode(struct ata_port *ap, struct ata_device *adev, int mo
                        ut = t.udma ? (0xe0 | (FIT(t.udma, 2, 9) - 2)) : 0x07;
                        break;
        }
+
        /* Set UDMA unless device is not UDMA capable */
-       if (udma_type)
-               pci_write_config_byte(pdev, 0x50 + offset, ut);
+       if (udma_type && t.udma) {
+               u8 cable80_status;
+
+               /* Get 80-wire cable detection bit */
+               pci_read_config_byte(pdev, 0x50 + offset, &cable80_status);
+               cable80_status &= 0x10;
+
+               pci_write_config_byte(pdev, 0x50 + offset, ut | cable80_status);
+       }
 }
 
 static void via_set_piomode(struct ata_port *ap, struct ata_device *adev)
@@ -304,7 +353,6 @@ static struct scsi_host_template via_sht = {
 };
 
 static struct ata_port_operations via_port_ops = {
-       .port_disable   = ata_port_disable,
        .set_piomode    = via_set_piomode,
        .set_dmamode    = via_set_dmamode,
        .mode_filter    = ata_pci_default_filter,
@@ -334,13 +382,11 @@ static struct ata_port_operations via_port_ops = {
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
        .irq_on         = ata_irq_on,
-       .irq_ack        = ata_irq_ack,
 
-       .port_start     = ata_port_start,
+       .port_start     = ata_sff_port_start,
 };
 
 static struct ata_port_operations via_port_ops_noirq = {
-       .port_disable   = ata_port_disable,
        .set_piomode    = via_set_piomode,
        .set_dmamode    = via_set_dmamode,
        .mode_filter    = ata_pci_default_filter,
@@ -370,9 +416,8 @@ static struct ata_port_operations via_port_ops_noirq = {
        .irq_handler    = ata_interrupt,
        .irq_clear      = ata_bmdma_irq_clear,
        .irq_on         = ata_irq_on,
-       .irq_ack        = ata_irq_ack,
 
-       .port_start     = ata_port_start,
+       .port_start     = ata_sff_port_start,
 };
 
 /**
@@ -380,7 +425,7 @@ static struct ata_port_operations via_port_ops_noirq = {
  *     @pdev: PCI device
  *     @flags: configuration flags
  *
- *     Set the FIFO properties for this device if neccessary. Used both on
+ *     Set the FIFO properties for this device if necessary. Used both on
  *     set up and on and the resume path
  */
 
@@ -423,7 +468,7 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
        /* Early VIA without UDMA support */
        static const struct ata_port_info via_mwdma_info = {
                .sht = &via_sht,
-               .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING,
+               .flags = ATA_FLAG_SLAVE_POSS,
                .pio_mask = 0x1f,
                .mwdma_mask = 0x07,
                .port_ops = &via_port_ops
@@ -431,7 +476,7 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
        /* Ditto with IRQ masking required */
        static const struct ata_port_info via_mwdma_info_borked = {
                .sht = &via_sht,
-               .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING,
+               .flags = ATA_FLAG_SLAVE_POSS,
                .pio_mask = 0x1f,
                .mwdma_mask = 0x07,
                .port_ops = &via_port_ops_noirq,
@@ -439,37 +484,37 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
        /* VIA UDMA 33 devices (and borked 66) */
        static const struct ata_port_info via_udma33_info = {
                .sht = &via_sht,
-               .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING,
+               .flags = ATA_FLAG_SLAVE_POSS,
                .pio_mask = 0x1f,
                .mwdma_mask = 0x07,
-               .udma_mask = 0x7,
+               .udma_mask = ATA_UDMA2,
                .port_ops = &via_port_ops
        };
        /* VIA UDMA 66 devices */
        static const struct ata_port_info via_udma66_info = {
                .sht = &via_sht,
-               .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING,
+               .flags = ATA_FLAG_SLAVE_POSS,
                .pio_mask = 0x1f,
                .mwdma_mask = 0x07,
-               .udma_mask = 0x1f,
+               .udma_mask = ATA_UDMA4,
                .port_ops = &via_port_ops
        };
        /* VIA UDMA 100 devices */
        static const struct ata_port_info via_udma100_info = {
                .sht = &via_sht,
-               .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING,
+               .flags = ATA_FLAG_SLAVE_POSS,
                .pio_mask = 0x1f,
                .mwdma_mask = 0x07,
-               .udma_mask = 0x3f,
+               .udma_mask = ATA_UDMA5,
                .port_ops = &via_port_ops
        };
        /* UDMA133 with bad AST (All current 133) */
        static const struct ata_port_info via_udma133_info = {
                .sht = &via_sht,
-               .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SETXFER_POLLING,
+               .flags = ATA_FLAG_SLAVE_POSS,
                .pio_mask = 0x1f,
                .mwdma_mask = 0x07,
-               .udma_mask = 0x7f,      /* FIXME: should check north bridge */
+               .udma_mask = ATA_UDMA6, /* FIXME: should check north bridge */
                .port_ops = &via_port_ops
        };
        struct ata_port_info type;
@@ -477,7 +522,6 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
        struct pci_dev *isa = NULL;
        const struct via_isa_bridge *config;
        static int printed_version;
-       u8 t;
        u8 enable;
        u32 timing;
 
@@ -491,9 +535,8 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
                        !!(config->flags & VIA_BAD_ID),
                        config->id, NULL))) {
 
-                       pci_read_config_byte(isa, PCI_REVISION_ID, &t);
-                       if (t >= config->rev_min &&
-                           t <= config->rev_max)
+                       if (isa->revision >= config->rev_min &&
+                           isa->revision <= config->rev_max)
                                break;
                        pci_dev_put(isa);
                }
@@ -592,10 +635,11 @@ static int via_reinit_one(struct pci_dev *pdev)
 #endif
 
 static const struct pci_device_id via[] = {
-       { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_82C576_1), },
-       { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_82C586_1), },
-       { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_6410), },
-       { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_SATA_EIDE), },
+       { PCI_VDEVICE(VIA, 0x0571), },
+       { PCI_VDEVICE(VIA, 0x0581), },
+       { PCI_VDEVICE(VIA, 0x1571), },
+       { PCI_VDEVICE(VIA, 0x3164), },
+       { PCI_VDEVICE(VIA, 0x5324), },
 
        { },
 };