diff options
Diffstat (limited to 'drivers/ata/ahci.c')
-rw-r--r-- | drivers/ata/ahci.c | 78 |
1 files changed, 53 insertions, 25 deletions
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index 6978469eb16d..b1eb4e24c86a 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); |
@@ -429,6 +433,7 @@ static const struct ata_port_info ahci_port_info[] = { | |||
429 | /* board_ahci_sb600 */ | 433 | /* board_ahci_sb600 */ |
430 | { | 434 | { |
431 | AHCI_HFLAGS (AHCI_HFLAG_IGN_SERR_INTERNAL | | 435 | AHCI_HFLAGS (AHCI_HFLAG_IGN_SERR_INTERNAL | |
436 | AHCI_HFLAG_32BIT_ONLY | | ||
432 | AHCI_HFLAG_SECT255 | AHCI_HFLAG_NO_PMP), | 437 | AHCI_HFLAG_SECT255 | AHCI_HFLAG_NO_PMP), |
433 | .flags = AHCI_FLAG_COMMON, | 438 | .flags = AHCI_FLAG_COMMON, |
434 | .link_flags = AHCI_LFLAG_COMMON, | 439 | .link_flags = AHCI_LFLAG_COMMON, |
@@ -587,6 +592,7 @@ static const struct pci_device_id ahci_pci_tbl[] = { | |||
587 | 592 | ||
588 | /* Marvell */ | 593 | /* Marvell */ |
589 | { PCI_VDEVICE(MARVELL, 0x6145), board_ahci_mv }, /* 6145 */ | 594 | { PCI_VDEVICE(MARVELL, 0x6145), board_ahci_mv }, /* 6145 */ |
595 | { PCI_VDEVICE(MARVELL, 0x6121), board_ahci_mv }, /* 6121 */ | ||
590 | 596 | ||
591 | /* Generic, PCI class code for AHCI */ | 597 | /* Generic, PCI class code for AHCI */ |
592 | { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, | 598 | { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, |
@@ -661,6 +667,7 @@ static void ahci_save_initial_config(struct pci_dev *pdev, | |||
661 | void __iomem *mmio = pcim_iomap_table(pdev)[AHCI_PCI_BAR]; | 667 | void __iomem *mmio = pcim_iomap_table(pdev)[AHCI_PCI_BAR]; |
662 | u32 cap, port_map; | 668 | u32 cap, port_map; |
663 | int i; | 669 | int i; |
670 | int mv; | ||
664 | 671 | ||
665 | /* make sure AHCI mode is enabled before accessing CAP */ | 672 | /* make sure AHCI mode is enabled before accessing CAP */ |
666 | ahci_enable_ahci(mmio); | 673 | ahci_enable_ahci(mmio); |
@@ -696,12 +703,16 @@ static void ahci_save_initial_config(struct pci_dev *pdev, | |||
696 | * presence register, as bit 4 (counting from 0) | 703 | * presence register, as bit 4 (counting from 0) |
697 | */ | 704 | */ |
698 | if (hpriv->flags & AHCI_HFLAG_MV_PATA) { | 705 | if (hpriv->flags & AHCI_HFLAG_MV_PATA) { |
706 | if (pdev->device == 0x6121) | ||
707 | mv = 0x3; | ||
708 | else | ||
709 | mv = 0xf; | ||
699 | dev_printk(KERN_ERR, &pdev->dev, | 710 | dev_printk(KERN_ERR, &pdev->dev, |
700 | "MV_AHCI HACK: port_map %x -> %x\n", | 711 | "MV_AHCI HACK: port_map %x -> %x\n", |
701 | hpriv->port_map, | 712 | port_map, |
702 | hpriv->port_map & 0xf); | 713 | port_map & mv); |
703 | 714 | ||
704 | port_map &= 0xf; | 715 | port_map &= mv; |
705 | } | 716 | } |
706 | 717 | ||
707 | /* cross check port_map and cap.n_ports */ | 718 | /* cross check port_map and cap.n_ports */ |
@@ -1088,29 +1099,35 @@ static int ahci_reset_controller(struct ata_host *host) | |||
1088 | ahci_enable_ahci(mmio); | 1099 | ahci_enable_ahci(mmio); |
1089 | 1100 | ||
1090 | /* global controller reset */ | 1101 | /* global controller reset */ |
1091 | tmp = readl(mmio + HOST_CTL); | 1102 | if (!ahci_skip_host_reset) { |
1092 | if ((tmp & HOST_RESET) == 0) { | 1103 | tmp = readl(mmio + HOST_CTL); |
1093 | writel(tmp | HOST_RESET, mmio + HOST_CTL); | 1104 | if ((tmp & HOST_RESET) == 0) { |
1094 | readl(mmio + HOST_CTL); /* flush */ | 1105 | writel(tmp | HOST_RESET, mmio + HOST_CTL); |
1095 | } | 1106 | readl(mmio + HOST_CTL); /* flush */ |
1107 | } | ||
1096 | 1108 | ||
1097 | /* reset must complete within 1 second, or | 1109 | /* reset must complete within 1 second, or |
1098 | * the hardware should be considered fried. | 1110 | * the hardware should be considered fried. |
1099 | */ | 1111 | */ |
1100 | ssleep(1); | 1112 | ssleep(1); |
1101 | 1113 | ||
1102 | tmp = readl(mmio + HOST_CTL); | 1114 | tmp = readl(mmio + HOST_CTL); |
1103 | if (tmp & HOST_RESET) { | 1115 | if (tmp & HOST_RESET) { |
1104 | dev_printk(KERN_ERR, host->dev, | 1116 | dev_printk(KERN_ERR, host->dev, |
1105 | "controller reset failed (0x%x)\n", tmp); | 1117 | "controller reset failed (0x%x)\n", tmp); |
1106 | return -EIO; | 1118 | return -EIO; |
1107 | } | 1119 | } |
1108 | 1120 | ||
1109 | /* turn on AHCI mode */ | 1121 | /* turn on AHCI mode */ |
1110 | ahci_enable_ahci(mmio); | 1122 | ahci_enable_ahci(mmio); |
1111 | 1123 | ||
1112 | /* some registers might be cleared on reset. restore initial values */ | 1124 | /* Some registers might be cleared on reset. Restore |
1113 | ahci_restore_initial_config(host); | 1125 | * initial values. |
1126 | */ | ||
1127 | ahci_restore_initial_config(host); | ||
1128 | } else | ||
1129 | dev_printk(KERN_INFO, host->dev, | ||
1130 | "skipping global host reset\n"); | ||
1114 | 1131 | ||
1115 | if (pdev->vendor == PCI_VENDOR_ID_INTEL) { | 1132 | if (pdev->vendor == PCI_VENDOR_ID_INTEL) { |
1116 | u16 tmp16; | 1133 | u16 tmp16; |
@@ -1162,9 +1179,14 @@ static void ahci_init_controller(struct ata_host *host) | |||
1162 | int i; | 1179 | int i; |
1163 | void __iomem *port_mmio; | 1180 | void __iomem *port_mmio; |
1164 | u32 tmp; | 1181 | u32 tmp; |
1182 | int mv; | ||
1165 | 1183 | ||
1166 | if (hpriv->flags & AHCI_HFLAG_MV_PATA) { | 1184 | if (hpriv->flags & AHCI_HFLAG_MV_PATA) { |
1167 | port_mmio = __ahci_port_base(host, 4); | 1185 | if (pdev->device == 0x6121) |
1186 | mv = 2; | ||
1187 | else | ||
1188 | mv = 4; | ||
1189 | port_mmio = __ahci_port_base(host, mv); | ||
1168 | 1190 | ||
1169 | writel(0, port_mmio + PORT_IRQ_MASK); | 1191 | writel(0, port_mmio + PORT_IRQ_MASK); |
1170 | 1192 | ||
@@ -1196,8 +1218,11 @@ static void ahci_dev_config(struct ata_device *dev) | |||
1196 | { | 1218 | { |
1197 | struct ahci_host_priv *hpriv = dev->link->ap->host->private_data; | 1219 | struct ahci_host_priv *hpriv = dev->link->ap->host->private_data; |
1198 | 1220 | ||
1199 | if (hpriv->flags & AHCI_HFLAG_SECT255) | 1221 | if (hpriv->flags & AHCI_HFLAG_SECT255) { |
1200 | dev->max_sectors = 255; | 1222 | dev->max_sectors = 255; |
1223 | ata_dev_printk(dev, KERN_INFO, | ||
1224 | "SB600 AHCI: limiting to 255 sectors per cmd\n"); | ||
1225 | } | ||
1201 | } | 1226 | } |
1202 | 1227 | ||
1203 | static unsigned int ahci_dev_classify(struct ata_port *ap) | 1228 | static unsigned int ahci_dev_classify(struct ata_port *ap) |
@@ -2241,7 +2266,10 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
2241 | if (rc) | 2266 | if (rc) |
2242 | return rc; | 2267 | return rc; |
2243 | 2268 | ||
2244 | rc = pcim_iomap_regions(pdev, 1 << AHCI_PCI_BAR, DRV_NAME); | 2269 | /* AHCI controllers often implement SFF compatible interface. |
2270 | * Grab all PCI BARs just in case. | ||
2271 | */ | ||
2272 | rc = pcim_iomap_regions_request_all(pdev, 1 << AHCI_PCI_BAR, DRV_NAME); | ||
2245 | if (rc == -EBUSY) | 2273 | if (rc == -EBUSY) |
2246 | pcim_pin_device(pdev); | 2274 | pcim_pin_device(pdev); |
2247 | if (rc) | 2275 | if (rc) |