PCI: Change all drivers to use pci_device->revision
[GitHub/LineageOS/android_kernel_motorola_exynos9610.git] / drivers / ata / sata_mv.c
index 705a020e1597e0d7eaab86b7aed75f17d45bcd6f..6dcfc628aab1b581e4e7737e4e350dadc0d9a2e9 100644 (file)
  *
  */
 
+/*
+  sata_mv TODO list:
+
+  1) Needs a full errata audit for all chipsets.  I implemented most
+  of the errata workarounds found in the Marvell vendor driver, but
+  I distinctly remember a couple workarounds (one related to PCI-X)
+  are still needed.
+
+  2) Convert to LibATA new EH.  Required for hotplug, NCQ, and sane
+  probing/error handling in general.  MUST HAVE.
+
+  3) Add hotplug support (easy, once new-EH support appears)
+
+  4) Add NCQ support (easy to intermediate, once new-EH support appears)
+
+  5) Investigate problems with PCI Message Signalled Interrupts (MSI).
+
+  6) Add port multiplier support (intermediate)
+
+  7) Test and verify 3.0 Gbps support
+
+  8) Develop a low-power-consumption strategy, and implement it.
+
+  9) [Experiment, low priority] See if ATAPI can be supported using
+  "unknown FIS" or "vendor-specific FIS" support, or something creative
+  like that.
+
+  10) [Experiment, low priority] Investigate interrupt coalescing.
+  Quite often, especially with PCI Message Signalled Interrupts (MSI),
+  the overhead reduced by interrupt mitigation is quite often not
+  worth the latency cost.
+
+  11) [Experiment, Marvell value added] Is it possible to use target
+  mode to cross-connect two Linux boxes with Marvell cards?  If so,
+  creating LibATA target mode support would be very interesting.
+
+  Target mode, for those without docs, is the ability to directly
+  connect two SATA controllers.
+
+  13) Verify that 7042 is fully supported.  I only have a 6042.
+
+*/
+
+
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/pci.h>
@@ -482,44 +526,44 @@ static const struct ata_port_info mv_port_info[] = {
        {  /* chip_504x */
                .flags          = MV_COMMON_FLAGS,
                .pio_mask       = 0x1f, /* pio0-4 */
-               .udma_mask      = 0x7f, /* udma0-6 */
+               .udma_mask      = ATA_UDMA6,
                .port_ops       = &mv5_ops,
        },
        {  /* chip_508x */
                .flags          = (MV_COMMON_FLAGS | MV_FLAG_DUAL_HC),
                .pio_mask       = 0x1f, /* pio0-4 */
-               .udma_mask      = 0x7f, /* udma0-6 */
+               .udma_mask      = ATA_UDMA6,
                .port_ops       = &mv5_ops,
        },
        {  /* chip_5080 */
                .flags          = (MV_COMMON_FLAGS | MV_FLAG_DUAL_HC),
                .pio_mask       = 0x1f, /* pio0-4 */
-               .udma_mask      = 0x7f, /* udma0-6 */
+               .udma_mask      = ATA_UDMA6,
                .port_ops       = &mv5_ops,
        },
        {  /* chip_604x */
                .flags          = (MV_COMMON_FLAGS | MV_6XXX_FLAGS),
                .pio_mask       = 0x1f, /* pio0-4 */
-               .udma_mask      = 0x7f, /* udma0-6 */
+               .udma_mask      = ATA_UDMA6,
                .port_ops       = &mv6_ops,
        },
        {  /* chip_608x */
                .flags          = (MV_COMMON_FLAGS | MV_6XXX_FLAGS |
                                   MV_FLAG_DUAL_HC),
                .pio_mask       = 0x1f, /* pio0-4 */
-               .udma_mask      = 0x7f, /* udma0-6 */
+               .udma_mask      = ATA_UDMA6,
                .port_ops       = &mv6_ops,
        },
        {  /* chip_6042 */
                .flags          = (MV_COMMON_FLAGS | MV_6XXX_FLAGS),
                .pio_mask       = 0x1f, /* pio0-4 */
-               .udma_mask      = 0x7f, /* udma0-6 */
+               .udma_mask      = ATA_UDMA6,
                .port_ops       = &mv_iie_ops,
        },
        {  /* chip_7042 */
                .flags          = (MV_COMMON_FLAGS | MV_6XXX_FLAGS),
                .pio_mask       = 0x1f, /* pio0-4 */
-               .udma_mask      = 0x7f, /* udma0-6 */
+               .udma_mask      = ATA_UDMA6,
                .port_ops       = &mv_iie_ops,
        },
 };
@@ -538,6 +582,9 @@ static const struct pci_device_id mv_pci_tbl[] = {
 
        { PCI_VDEVICE(ADAPTEC2, 0x0241), chip_604x },
 
+       /* Adaptec 1430SA */
+       { PCI_VDEVICE(ADAPTEC2, 0x0243), chip_7042 },
+
        { PCI_VDEVICE(TTI, 0x2310), chip_7042 },
 
        /* add Marvell 7042 support */
@@ -1526,12 +1573,9 @@ static void mv5_scr_write(struct ata_port *ap, unsigned int sc_reg_in, u32 val)
 
 static void mv5_reset_bus(struct pci_dev *pdev, void __iomem *mmio)
 {
-       u8 rev_id;
        int early_5080;
 
-       pci_read_config_byte(pdev, PCI_REVISION_ID, &rev_id);
-
-       early_5080 = (pdev->device == 0x5080) && (rev_id == 0);
+       early_5080 = (pdev->device == 0x5080) && (pdev->revision == 0);
 
        if (!early_5080) {
                u32 tmp = readl(mmio + MV_PCI_EXP_ROM_BAR_CTL);
@@ -2092,17 +2136,14 @@ static int mv_chip_id(struct ata_host *host, unsigned int board_idx)
 {
        struct pci_dev *pdev = to_pci_dev(host->dev);
        struct mv_host_priv *hpriv = host->private_data;
-       u8 rev_id;
        u32 hp_flags = hpriv->hp_flags;
 
-       pci_read_config_byte(pdev, PCI_REVISION_ID, &rev_id);
-
        switch(board_idx) {
        case chip_5080:
                hpriv->ops = &mv5xxx_ops;
                hp_flags |= MV_HP_50XX;
 
-               switch (rev_id) {
+               switch (pdev->revision) {
                case 0x1:
                        hp_flags |= MV_HP_ERRATA_50XXB0;
                        break;
@@ -2122,7 +2163,7 @@ static int mv_chip_id(struct ata_host *host, unsigned int board_idx)
                hpriv->ops = &mv5xxx_ops;
                hp_flags |= MV_HP_50XX;
 
-               switch (rev_id) {
+               switch (pdev->revision) {
                case 0x0:
                        hp_flags |= MV_HP_ERRATA_50XXB0;
                        break;
@@ -2141,7 +2182,7 @@ static int mv_chip_id(struct ata_host *host, unsigned int board_idx)
        case chip_608x:
                hpriv->ops = &mv6xxx_ops;
 
-               switch (rev_id) {
+               switch (pdev->revision) {
                case 0x7:
                        hp_flags |= MV_HP_ERRATA_60X1B2;
                        break;
@@ -2162,7 +2203,7 @@ static int mv_chip_id(struct ata_host *host, unsigned int board_idx)
 
                hp_flags |= MV_HP_GEN_IIE;
 
-               switch (rev_id) {
+               switch (pdev->revision) {
                case 0x0:
                        hp_flags |= MV_HP_ERRATA_XX42A0;
                        break;
@@ -2290,25 +2331,32 @@ static void mv_print_info(struct ata_host *host)
 {
        struct pci_dev *pdev = to_pci_dev(host->dev);
        struct mv_host_priv *hpriv = host->private_data;
-       u8 rev_id, scc;
-       const char *scc_s;
+       u8 scc;
+       const char *scc_s, *gen;
 
        /* Use this to determine the HW stepping of the chip so we know
         * what errata to workaround
         */
-       pci_read_config_byte(pdev, PCI_REVISION_ID, &rev_id);
-
        pci_read_config_byte(pdev, PCI_CLASS_DEVICE, &scc);
        if (scc == 0)
                scc_s = "SCSI";
        else if (scc == 0x01)
                scc_s = "RAID";
        else
-               scc_s = "unknown";
+               scc_s = "?";
+
+       if (IS_GEN_I(hpriv))
+               gen = "I";
+       else if (IS_GEN_II(hpriv))
+               gen = "II";
+       else if (IS_GEN_IIE(hpriv))
+               gen = "IIE";
+       else
+               gen = "?";
 
        dev_printk(KERN_INFO, &pdev->dev,
-              "%u slots %u ports %s mode IRQ via %s\n",
-              (unsigned)MV_MAX_Q_DEPTH, host->n_ports,
+              "Gen-%s %u slots %u ports %s mode IRQ via %s\n",
+              gen, (unsigned)MV_MAX_Q_DEPTH, host->n_ports,
               scc_s, (MV_HP_FLAG_MSI & hpriv->hp_flags) ? "MSI" : "INTx");
 }