diff options
Diffstat (limited to 'drivers/ata/ahci.c')
-rw-r--r-- | drivers/ata/ahci.c | 86 |
1 files changed, 61 insertions, 25 deletions
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index 8a49835bd0f8..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); |
@@ -567,6 +571,18 @@ static const struct pci_device_id ahci_pci_tbl[] = { | |||
567 | { PCI_VDEVICE(NVIDIA, 0x0abd), board_ahci }, /* MCP79 */ | 571 | { PCI_VDEVICE(NVIDIA, 0x0abd), board_ahci }, /* MCP79 */ |
568 | { PCI_VDEVICE(NVIDIA, 0x0abe), board_ahci }, /* MCP79 */ | 572 | { PCI_VDEVICE(NVIDIA, 0x0abe), board_ahci }, /* MCP79 */ |
569 | { PCI_VDEVICE(NVIDIA, 0x0abf), board_ahci }, /* MCP79 */ | 573 | { PCI_VDEVICE(NVIDIA, 0x0abf), board_ahci }, /* MCP79 */ |
574 | { PCI_VDEVICE(NVIDIA, 0x0bc8), board_ahci }, /* MCP7B */ | ||
575 | { PCI_VDEVICE(NVIDIA, 0x0bc9), board_ahci }, /* MCP7B */ | ||
576 | { PCI_VDEVICE(NVIDIA, 0x0bca), board_ahci }, /* MCP7B */ | ||
577 | { PCI_VDEVICE(NVIDIA, 0x0bcb), board_ahci }, /* MCP7B */ | ||
578 | { PCI_VDEVICE(NVIDIA, 0x0bcc), board_ahci }, /* MCP7B */ | ||
579 | { PCI_VDEVICE(NVIDIA, 0x0bcd), board_ahci }, /* MCP7B */ | ||
580 | { PCI_VDEVICE(NVIDIA, 0x0bce), board_ahci }, /* MCP7B */ | ||
581 | { PCI_VDEVICE(NVIDIA, 0x0bcf), board_ahci }, /* MCP7B */ | ||
582 | { PCI_VDEVICE(NVIDIA, 0x0bd0), board_ahci }, /* MCP7B */ | ||
583 | { PCI_VDEVICE(NVIDIA, 0x0bd1), board_ahci }, /* MCP7B */ | ||
584 | { PCI_VDEVICE(NVIDIA, 0x0bd2), board_ahci }, /* MCP7B */ | ||
585 | { PCI_VDEVICE(NVIDIA, 0x0bd3), board_ahci }, /* MCP7B */ | ||
570 | 586 | ||
571 | /* SiS */ | 587 | /* SiS */ |
572 | { PCI_VDEVICE(SI, 0x1184), board_ahci }, /* SiS 966 */ | 588 | { PCI_VDEVICE(SI, 0x1184), board_ahci }, /* SiS 966 */ |
@@ -575,6 +591,7 @@ static const struct pci_device_id ahci_pci_tbl[] = { | |||
575 | 591 | ||
576 | /* Marvell */ | 592 | /* Marvell */ |
577 | { 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 */ | ||
578 | 595 | ||
579 | /* Generic, PCI class code for AHCI */ | 596 | /* Generic, PCI class code for AHCI */ |
580 | { 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, |
@@ -649,6 +666,7 @@ static void ahci_save_initial_config(struct pci_dev *pdev, | |||
649 | void __iomem *mmio = pcim_iomap_table(pdev)[AHCI_PCI_BAR]; | 666 | void __iomem *mmio = pcim_iomap_table(pdev)[AHCI_PCI_BAR]; |
650 | u32 cap, port_map; | 667 | u32 cap, port_map; |
651 | int i; | 668 | int i; |
669 | int mv; | ||
652 | 670 | ||
653 | /* make sure AHCI mode is enabled before accessing CAP */ | 671 | /* make sure AHCI mode is enabled before accessing CAP */ |
654 | ahci_enable_ahci(mmio); | 672 | ahci_enable_ahci(mmio); |
@@ -672,7 +690,7 @@ static void ahci_save_initial_config(struct pci_dev *pdev, | |||
672 | cap &= ~HOST_CAP_NCQ; | 690 | cap &= ~HOST_CAP_NCQ; |
673 | } | 691 | } |
674 | 692 | ||
675 | if ((cap && HOST_CAP_PMP) && (hpriv->flags & AHCI_HFLAG_NO_PMP)) { | 693 | if ((cap & HOST_CAP_PMP) && (hpriv->flags & AHCI_HFLAG_NO_PMP)) { |
676 | dev_printk(KERN_INFO, &pdev->dev, | 694 | dev_printk(KERN_INFO, &pdev->dev, |
677 | "controller can't do PMP, turning off CAP_PMP\n"); | 695 | "controller can't do PMP, turning off CAP_PMP\n"); |
678 | cap &= ~HOST_CAP_PMP; | 696 | cap &= ~HOST_CAP_PMP; |
@@ -684,12 +702,16 @@ static void ahci_save_initial_config(struct pci_dev *pdev, | |||
684 | * presence register, as bit 4 (counting from 0) | 702 | * presence register, as bit 4 (counting from 0) |
685 | */ | 703 | */ |
686 | 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; | ||
687 | dev_printk(KERN_ERR, &pdev->dev, | 709 | dev_printk(KERN_ERR, &pdev->dev, |
688 | "MV_AHCI HACK: port_map %x -> %x\n", | 710 | "MV_AHCI HACK: port_map %x -> %x\n", |
689 | hpriv->port_map, | 711 | port_map, |
690 | hpriv->port_map & 0xf); | 712 | port_map & mv); |
691 | 713 | ||
692 | port_map &= 0xf; | 714 | port_map &= mv; |
693 | } | 715 | } |
694 | 716 | ||
695 | /* cross check port_map and cap.n_ports */ | 717 | /* cross check port_map and cap.n_ports */ |
@@ -1076,29 +1098,35 @@ static int ahci_reset_controller(struct ata_host *host) | |||
1076 | ahci_enable_ahci(mmio); | 1098 | ahci_enable_ahci(mmio); |
1077 | 1099 | ||
1078 | /* global controller reset */ | 1100 | /* global controller reset */ |
1079 | tmp = readl(mmio + HOST_CTL); | 1101 | if (!ahci_skip_host_reset) { |
1080 | if ((tmp & HOST_RESET) == 0) { | 1102 | tmp = readl(mmio + HOST_CTL); |
1081 | writel(tmp | HOST_RESET, mmio + HOST_CTL); | 1103 | if ((tmp & HOST_RESET) == 0) { |
1082 | readl(mmio + HOST_CTL); /* flush */ | 1104 | writel(tmp | HOST_RESET, mmio + HOST_CTL); |
1083 | } | 1105 | readl(mmio + HOST_CTL); /* flush */ |
1106 | } | ||
1084 | 1107 | ||
1085 | /* reset must complete within 1 second, or | 1108 | /* reset must complete within 1 second, or |
1086 | * the hardware should be considered fried. | 1109 | * the hardware should be considered fried. |
1087 | */ | 1110 | */ |
1088 | ssleep(1); | 1111 | ssleep(1); |
1089 | 1112 | ||
1090 | tmp = readl(mmio + HOST_CTL); | 1113 | tmp = readl(mmio + HOST_CTL); |
1091 | if (tmp & HOST_RESET) { | 1114 | if (tmp & HOST_RESET) { |
1092 | dev_printk(KERN_ERR, host->dev, | 1115 | dev_printk(KERN_ERR, host->dev, |
1093 | "controller reset failed (0x%x)\n", tmp); | 1116 | "controller reset failed (0x%x)\n", tmp); |
1094 | return -EIO; | 1117 | return -EIO; |
1095 | } | 1118 | } |
1096 | 1119 | ||
1097 | /* turn on AHCI mode */ | 1120 | /* turn on AHCI mode */ |
1098 | ahci_enable_ahci(mmio); | 1121 | ahci_enable_ahci(mmio); |
1099 | 1122 | ||
1100 | /* some registers might be cleared on reset. restore initial values */ | 1123 | /* Some registers might be cleared on reset. Restore |
1101 | 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"); | ||
1102 | 1130 | ||
1103 | if (pdev->vendor == PCI_VENDOR_ID_INTEL) { | 1131 | if (pdev->vendor == PCI_VENDOR_ID_INTEL) { |
1104 | u16 tmp16; | 1132 | u16 tmp16; |
@@ -1150,9 +1178,14 @@ static void ahci_init_controller(struct ata_host *host) | |||
1150 | int i; | 1178 | int i; |
1151 | void __iomem *port_mmio; | 1179 | void __iomem *port_mmio; |
1152 | u32 tmp; | 1180 | u32 tmp; |
1181 | int mv; | ||
1153 | 1182 | ||
1154 | if (hpriv->flags & AHCI_HFLAG_MV_PATA) { | 1183 | if (hpriv->flags & AHCI_HFLAG_MV_PATA) { |
1155 | 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); | ||
1156 | 1189 | ||
1157 | writel(0, port_mmio + PORT_IRQ_MASK); | 1190 | writel(0, port_mmio + PORT_IRQ_MASK); |
1158 | 1191 | ||
@@ -2229,7 +2262,10 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
2229 | if (rc) | 2262 | if (rc) |
2230 | return rc; | 2263 | return rc; |
2231 | 2264 | ||
2232 | 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); | ||
2233 | if (rc == -EBUSY) | 2269 | if (rc == -EBUSY) |
2234 | pcim_pin_device(pdev); | 2270 | pcim_pin_device(pdev); |
2235 | if (rc) | 2271 | if (rc) |