diff options
Diffstat (limited to 'drivers/ata/ahci.c')
-rw-r--r-- | drivers/ata/ahci.c | 72 |
1 files changed, 48 insertions, 24 deletions
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index 6978469eb16d..17ee6ed985d9 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c | |||
@@ -49,6 +49,10 @@ | |||
49 | #define DRV_NAME "ahci" | 49 | #define DRV_NAME "ahci" |
50 | #define DRV_VERSION "3.0" | 50 | #define DRV_VERSION "3.0" |
51 | 51 | ||
52 | static int ahci_skip_host_reset; | ||
53 | module_param_named(skip_host_reset, ahci_skip_host_reset, int, 0444); | ||
54 | MODULE_PARM_DESC(skip_host_reset, "skip global host reset (0=don't skip, 1=skip)"); | ||
55 | |||
52 | static int ahci_enable_alpm(struct ata_port *ap, | 56 | static int ahci_enable_alpm(struct ata_port *ap, |
53 | enum link_pm policy); | 57 | enum link_pm policy); |
54 | static void ahci_disable_alpm(struct ata_port *ap); | 58 | static void ahci_disable_alpm(struct ata_port *ap); |
@@ -587,6 +591,7 @@ static const struct pci_device_id ahci_pci_tbl[] = { | |||
587 | 591 | ||
588 | /* Marvell */ | 592 | /* Marvell */ |
589 | { PCI_VDEVICE(MARVELL, 0x6145), board_ahci_mv }, /* 6145 */ | 593 | { PCI_VDEVICE(MARVELL, 0x6145), board_ahci_mv }, /* 6145 */ |
594 | { PCI_VDEVICE(MARVELL, 0x6121), board_ahci_mv }, /* 6121 */ | ||
590 | 595 | ||
591 | /* Generic, PCI class code for AHCI */ | 596 | /* Generic, PCI class code for AHCI */ |
592 | { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, | 597 | { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, |
@@ -661,6 +666,7 @@ static void ahci_save_initial_config(struct pci_dev *pdev, | |||
661 | void __iomem *mmio = pcim_iomap_table(pdev)[AHCI_PCI_BAR]; | 666 | void __iomem *mmio = pcim_iomap_table(pdev)[AHCI_PCI_BAR]; |
662 | u32 cap, port_map; | 667 | u32 cap, port_map; |
663 | int i; | 668 | int i; |
669 | int mv; | ||
664 | 670 | ||
665 | /* make sure AHCI mode is enabled before accessing CAP */ | 671 | /* make sure AHCI mode is enabled before accessing CAP */ |
666 | ahci_enable_ahci(mmio); | 672 | ahci_enable_ahci(mmio); |
@@ -696,12 +702,16 @@ static void ahci_save_initial_config(struct pci_dev *pdev, | |||
696 | * presence register, as bit 4 (counting from 0) | 702 | * presence register, as bit 4 (counting from 0) |
697 | */ | 703 | */ |
698 | if (hpriv->flags & AHCI_HFLAG_MV_PATA) { | 704 | if (hpriv->flags & AHCI_HFLAG_MV_PATA) { |
705 | if (pdev->device == 0x6121) | ||
706 | mv = 0x3; | ||
707 | else | ||
708 | mv = 0xf; | ||
699 | dev_printk(KERN_ERR, &pdev->dev, | 709 | dev_printk(KERN_ERR, &pdev->dev, |
700 | "MV_AHCI HACK: port_map %x -> %x\n", | 710 | "MV_AHCI HACK: port_map %x -> %x\n", |
701 | hpriv->port_map, | 711 | port_map, |
702 | hpriv->port_map & 0xf); | 712 | port_map & mv); |
703 | 713 | ||
704 | port_map &= 0xf; | 714 | port_map &= mv; |
705 | } | 715 | } |
706 | 716 | ||
707 | /* cross check port_map and cap.n_ports */ | 717 | /* cross check port_map and cap.n_ports */ |
@@ -1088,29 +1098,35 @@ static int ahci_reset_controller(struct ata_host *host) | |||
1088 | ahci_enable_ahci(mmio); | 1098 | ahci_enable_ahci(mmio); |
1089 | 1099 | ||
1090 | /* global controller reset */ | 1100 | /* global controller reset */ |
1091 | tmp = readl(mmio + HOST_CTL); | 1101 | if (!ahci_skip_host_reset) { |
1092 | if ((tmp & HOST_RESET) == 0) { | 1102 | tmp = readl(mmio + HOST_CTL); |
1093 | writel(tmp | HOST_RESET, mmio + HOST_CTL); | 1103 | if ((tmp & HOST_RESET) == 0) { |
1094 | readl(mmio + HOST_CTL); /* flush */ | 1104 | writel(tmp | HOST_RESET, mmio + HOST_CTL); |
1095 | } | 1105 | readl(mmio + HOST_CTL); /* flush */ |
1106 | } | ||
1096 | 1107 | ||
1097 | /* reset must complete within 1 second, or | 1108 | /* reset must complete within 1 second, or |
1098 | * the hardware should be considered fried. | 1109 | * the hardware should be considered fried. |
1099 | */ | 1110 | */ |
1100 | ssleep(1); | 1111 | ssleep(1); |
1101 | 1112 | ||
1102 | tmp = readl(mmio + HOST_CTL); | 1113 | tmp = readl(mmio + HOST_CTL); |
1103 | if (tmp & HOST_RESET) { | 1114 | if (tmp & HOST_RESET) { |
1104 | dev_printk(KERN_ERR, host->dev, | 1115 | dev_printk(KERN_ERR, host->dev, |
1105 | "controller reset failed (0x%x)\n", tmp); | 1116 | "controller reset failed (0x%x)\n", tmp); |
1106 | return -EIO; | 1117 | return -EIO; |
1107 | } | 1118 | } |
1108 | 1119 | ||
1109 | /* turn on AHCI mode */ | 1120 | /* turn on AHCI mode */ |
1110 | ahci_enable_ahci(mmio); | 1121 | ahci_enable_ahci(mmio); |
1111 | 1122 | ||
1112 | /* some registers might be cleared on reset. restore initial values */ | 1123 | /* Some registers might be cleared on reset. Restore |
1113 | ahci_restore_initial_config(host); | 1124 | * initial values. |
1125 | */ | ||
1126 | ahci_restore_initial_config(host); | ||
1127 | } else | ||
1128 | dev_printk(KERN_INFO, host->dev, | ||
1129 | "skipping global host reset\n"); | ||
1114 | 1130 | ||
1115 | if (pdev->vendor == PCI_VENDOR_ID_INTEL) { | 1131 | if (pdev->vendor == PCI_VENDOR_ID_INTEL) { |
1116 | u16 tmp16; | 1132 | u16 tmp16; |
@@ -1162,9 +1178,14 @@ static void ahci_init_controller(struct ata_host *host) | |||
1162 | int i; | 1178 | int i; |
1163 | void __iomem *port_mmio; | 1179 | void __iomem *port_mmio; |
1164 | u32 tmp; | 1180 | u32 tmp; |
1181 | int mv; | ||
1165 | 1182 | ||
1166 | if (hpriv->flags & AHCI_HFLAG_MV_PATA) { | 1183 | if (hpriv->flags & AHCI_HFLAG_MV_PATA) { |
1167 | port_mmio = __ahci_port_base(host, 4); | 1184 | if (pdev->device == 0x6121) |
1185 | mv = 2; | ||
1186 | else | ||
1187 | mv = 4; | ||
1188 | port_mmio = __ahci_port_base(host, mv); | ||
1168 | 1189 | ||
1169 | writel(0, port_mmio + PORT_IRQ_MASK); | 1190 | writel(0, port_mmio + PORT_IRQ_MASK); |
1170 | 1191 | ||
@@ -2241,7 +2262,10 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
2241 | if (rc) | 2262 | if (rc) |
2242 | return rc; | 2263 | return rc; |
2243 | 2264 | ||
2244 | rc = pcim_iomap_regions(pdev, 1 << AHCI_PCI_BAR, DRV_NAME); | 2265 | /* AHCI controllers often implement SFF compatible interface. |
2266 | * Grab all PCI BARs just in case. | ||
2267 | */ | ||
2268 | rc = pcim_iomap_regions_request_all(pdev, 1 << AHCI_PCI_BAR, DRV_NAME); | ||
2245 | if (rc == -EBUSY) | 2269 | if (rc == -EBUSY) |
2246 | pcim_pin_device(pdev); | 2270 | pcim_pin_device(pdev); |
2247 | if (rc) | 2271 | if (rc) |