aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ata')
-rw-r--r--drivers/ata/Kconfig10
-rw-r--r--drivers/ata/Makefile1
-rw-r--r--drivers/ata/ahci.c104
-rw-r--r--drivers/ata/libata-acpi.c104
-rw-r--r--drivers/ata/libata-core.c63
-rw-r--r--drivers/ata/libata-eh.c10
-rw-r--r--drivers/ata/libata-scsi.c17
-rw-r--r--drivers/ata/libata-sff.c36
-rw-r--r--drivers/ata/pata_ali.c2
-rw-r--r--drivers/ata/pata_hpt366.c6
-rw-r--r--drivers/ata/pata_hpt37x.c6
-rw-r--r--drivers/ata/pata_it821x.c2
-rw-r--r--drivers/ata/pata_pdc2027x.c2
-rw-r--r--drivers/ata/pata_rb500_cf.c314
-rw-r--r--drivers/ata/pata_serverworks.c2
-rw-r--r--drivers/ata/sata_promise.c109
16 files changed, 656 insertions, 132 deletions
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index ba8f7f4dfa11..25aba69b59b4 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -30,6 +30,7 @@ config ATA_NONSTANDARD
30config ATA_ACPI 30config ATA_ACPI
31 bool 31 bool
32 depends on ACPI && PCI 32 depends on ACPI && PCI
33 select ACPI_DOCK
33 default y 34 default y
34 help 35 help
35 This option adds support for ATA-related ACPI objects. 36 This option adds support for ATA-related ACPI objects.
@@ -538,6 +539,15 @@ config PATA_RADISYS
538 539
539 If unsure, say N. 540 If unsure, say N.
540 541
542config PATA_RB500
543 tristate "RouterBoard 500 PATA CompactFlash support"
544 depends on MIKROTIK_RB500
545 help
546 This option enables support for the RouterBoard 500
547 PATA CompactFlash controller.
548
549 If unsure, say N.
550
541config PATA_RZ1000 551config PATA_RZ1000
542 tristate "PC Tech RZ1000 PATA support" 552 tristate "PC Tech RZ1000 PATA support"
543 depends on PCI 553 depends on PCI
diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile
index 701651e37c89..0511e6f0bb58 100644
--- a/drivers/ata/Makefile
+++ b/drivers/ata/Makefile
@@ -55,6 +55,7 @@ obj-$(CONFIG_PATA_PDC2027X) += pata_pdc2027x.o
55obj-$(CONFIG_PATA_PDC_OLD) += pata_pdc202xx_old.o 55obj-$(CONFIG_PATA_PDC_OLD) += pata_pdc202xx_old.o
56obj-$(CONFIG_PATA_QDI) += pata_qdi.o 56obj-$(CONFIG_PATA_QDI) += pata_qdi.o
57obj-$(CONFIG_PATA_RADISYS) += pata_radisys.o 57obj-$(CONFIG_PATA_RADISYS) += pata_radisys.o
58obj-$(CONFIG_PATA_RB500) += pata_rb500_cf.o
58obj-$(CONFIG_PATA_RZ1000) += pata_rz1000.o 59obj-$(CONFIG_PATA_RZ1000) += pata_rz1000.o
59obj-$(CONFIG_PATA_SC1200) += pata_sc1200.o 60obj-$(CONFIG_PATA_SC1200) += pata_sc1200.o
60obj-$(CONFIG_PATA_SERVERWORKS) += pata_serverworks.o 61obj-$(CONFIG_PATA_SERVERWORKS) += pata_serverworks.o
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 1db93b619074..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
52static int ahci_skip_host_reset;
53module_param_named(skip_host_reset, ahci_skip_host_reset, int, 0444);
54MODULE_PARM_DESC(skip_host_reset, "skip global host reset (0=don't skip, 1=skip)");
55
52static int ahci_enable_alpm(struct ata_port *ap, 56static int ahci_enable_alpm(struct ata_port *ap,
53 enum link_pm policy); 57 enum link_pm policy);
54static void ahci_disable_alpm(struct ata_port *ap); 58static void ahci_disable_alpm(struct ata_port *ap);
@@ -186,6 +190,7 @@ enum {
186 AHCI_HFLAG_NO_MSI = (1 << 5), /* no PCI MSI */ 190 AHCI_HFLAG_NO_MSI = (1 << 5), /* no PCI MSI */
187 AHCI_HFLAG_NO_PMP = (1 << 6), /* no PMP */ 191 AHCI_HFLAG_NO_PMP = (1 << 6), /* no PMP */
188 AHCI_HFLAG_NO_HOTPLUG = (1 << 7), /* ignore PxSERR.DIAG.N */ 192 AHCI_HFLAG_NO_HOTPLUG = (1 << 7), /* ignore PxSERR.DIAG.N */
193 AHCI_HFLAG_SECT255 = (1 << 8), /* max 255 sectors */
189 194
190 /* ap->flags bits */ 195 /* ap->flags bits */
191 196
@@ -255,6 +260,7 @@ static void ahci_vt8251_error_handler(struct ata_port *ap);
255static void ahci_p5wdh_error_handler(struct ata_port *ap); 260static void ahci_p5wdh_error_handler(struct ata_port *ap);
256static void ahci_post_internal_cmd(struct ata_queued_cmd *qc); 261static void ahci_post_internal_cmd(struct ata_queued_cmd *qc);
257static int ahci_port_resume(struct ata_port *ap); 262static int ahci_port_resume(struct ata_port *ap);
263static void ahci_dev_config(struct ata_device *dev);
258static unsigned int ahci_fill_sg(struct ata_queued_cmd *qc, void *cmd_tbl); 264static unsigned int ahci_fill_sg(struct ata_queued_cmd *qc, void *cmd_tbl);
259static void ahci_fill_cmd_slot(struct ahci_port_priv *pp, unsigned int tag, 265static void ahci_fill_cmd_slot(struct ahci_port_priv *pp, unsigned int tag,
260 u32 opts); 266 u32 opts);
@@ -294,6 +300,8 @@ static const struct ata_port_operations ahci_ops = {
294 .check_altstatus = ahci_check_status, 300 .check_altstatus = ahci_check_status,
295 .dev_select = ata_noop_dev_select, 301 .dev_select = ata_noop_dev_select,
296 302
303 .dev_config = ahci_dev_config,
304
297 .tf_read = ahci_tf_read, 305 .tf_read = ahci_tf_read,
298 306
299 .qc_defer = sata_pmp_qc_defer_cmd_switch, 307 .qc_defer = sata_pmp_qc_defer_cmd_switch,
@@ -425,7 +433,8 @@ static const struct ata_port_info ahci_port_info[] = {
425 /* board_ahci_sb600 */ 433 /* board_ahci_sb600 */
426 { 434 {
427 AHCI_HFLAGS (AHCI_HFLAG_IGN_SERR_INTERNAL | 435 AHCI_HFLAGS (AHCI_HFLAG_IGN_SERR_INTERNAL |
428 AHCI_HFLAG_32BIT_ONLY | AHCI_HFLAG_NO_PMP), 436 AHCI_HFLAG_32BIT_ONLY |
437 AHCI_HFLAG_SECT255 | AHCI_HFLAG_NO_PMP),
429 .flags = AHCI_FLAG_COMMON, 438 .flags = AHCI_FLAG_COMMON,
430 .link_flags = AHCI_LFLAG_COMMON, 439 .link_flags = AHCI_LFLAG_COMMON,
431 .pio_mask = 0x1f, /* pio0-4 */ 440 .pio_mask = 0x1f, /* pio0-4 */
@@ -563,6 +572,18 @@ static const struct pci_device_id ahci_pci_tbl[] = {
563 { PCI_VDEVICE(NVIDIA, 0x0abd), board_ahci }, /* MCP79 */ 572 { PCI_VDEVICE(NVIDIA, 0x0abd), board_ahci }, /* MCP79 */
564 { PCI_VDEVICE(NVIDIA, 0x0abe), board_ahci }, /* MCP79 */ 573 { PCI_VDEVICE(NVIDIA, 0x0abe), board_ahci }, /* MCP79 */
565 { PCI_VDEVICE(NVIDIA, 0x0abf), board_ahci }, /* MCP79 */ 574 { PCI_VDEVICE(NVIDIA, 0x0abf), board_ahci }, /* MCP79 */
575 { PCI_VDEVICE(NVIDIA, 0x0bc8), board_ahci }, /* MCP7B */
576 { PCI_VDEVICE(NVIDIA, 0x0bc9), board_ahci }, /* MCP7B */
577 { PCI_VDEVICE(NVIDIA, 0x0bca), board_ahci }, /* MCP7B */
578 { PCI_VDEVICE(NVIDIA, 0x0bcb), board_ahci }, /* MCP7B */
579 { PCI_VDEVICE(NVIDIA, 0x0bcc), board_ahci }, /* MCP7B */
580 { PCI_VDEVICE(NVIDIA, 0x0bcd), board_ahci }, /* MCP7B */
581 { PCI_VDEVICE(NVIDIA, 0x0bce), board_ahci }, /* MCP7B */
582 { PCI_VDEVICE(NVIDIA, 0x0bcf), board_ahci }, /* MCP7B */
583 { PCI_VDEVICE(NVIDIA, 0x0bd0), board_ahci }, /* MCP7B */
584 { PCI_VDEVICE(NVIDIA, 0x0bd1), board_ahci }, /* MCP7B */
585 { PCI_VDEVICE(NVIDIA, 0x0bd2), board_ahci }, /* MCP7B */
586 { PCI_VDEVICE(NVIDIA, 0x0bd3), board_ahci }, /* MCP7B */
566 587
567 /* SiS */ 588 /* SiS */
568 { PCI_VDEVICE(SI, 0x1184), board_ahci }, /* SiS 966 */ 589 { PCI_VDEVICE(SI, 0x1184), board_ahci }, /* SiS 966 */
@@ -571,6 +592,7 @@ static const struct pci_device_id ahci_pci_tbl[] = {
571 592
572 /* Marvell */ 593 /* Marvell */
573 { 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 */
574 596
575 /* Generic, PCI class code for AHCI */ 597 /* Generic, PCI class code for AHCI */
576 { 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,
@@ -645,6 +667,7 @@ static void ahci_save_initial_config(struct pci_dev *pdev,
645 void __iomem *mmio = pcim_iomap_table(pdev)[AHCI_PCI_BAR]; 667 void __iomem *mmio = pcim_iomap_table(pdev)[AHCI_PCI_BAR];
646 u32 cap, port_map; 668 u32 cap, port_map;
647 int i; 669 int i;
670 int mv;
648 671
649 /* make sure AHCI mode is enabled before accessing CAP */ 672 /* make sure AHCI mode is enabled before accessing CAP */
650 ahci_enable_ahci(mmio); 673 ahci_enable_ahci(mmio);
@@ -668,7 +691,7 @@ static void ahci_save_initial_config(struct pci_dev *pdev,
668 cap &= ~HOST_CAP_NCQ; 691 cap &= ~HOST_CAP_NCQ;
669 } 692 }
670 693
671 if ((cap && HOST_CAP_PMP) && (hpriv->flags & AHCI_HFLAG_NO_PMP)) { 694 if ((cap & HOST_CAP_PMP) && (hpriv->flags & AHCI_HFLAG_NO_PMP)) {
672 dev_printk(KERN_INFO, &pdev->dev, 695 dev_printk(KERN_INFO, &pdev->dev,
673 "controller can't do PMP, turning off CAP_PMP\n"); 696 "controller can't do PMP, turning off CAP_PMP\n");
674 cap &= ~HOST_CAP_PMP; 697 cap &= ~HOST_CAP_PMP;
@@ -680,12 +703,16 @@ static void ahci_save_initial_config(struct pci_dev *pdev,
680 * presence register, as bit 4 (counting from 0) 703 * presence register, as bit 4 (counting from 0)
681 */ 704 */
682 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;
683 dev_printk(KERN_ERR, &pdev->dev, 710 dev_printk(KERN_ERR, &pdev->dev,
684 "MV_AHCI HACK: port_map %x -> %x\n", 711 "MV_AHCI HACK: port_map %x -> %x\n",
685 hpriv->port_map, 712 port_map,
686 hpriv->port_map & 0xf); 713 port_map & mv);
687 714
688 port_map &= 0xf; 715 port_map &= mv;
689 } 716 }
690 717
691 /* cross check port_map and cap.n_ports */ 718 /* cross check port_map and cap.n_ports */
@@ -1072,29 +1099,35 @@ static int ahci_reset_controller(struct ata_host *host)
1072 ahci_enable_ahci(mmio); 1099 ahci_enable_ahci(mmio);
1073 1100
1074 /* global controller reset */ 1101 /* global controller reset */
1075 tmp = readl(mmio + HOST_CTL); 1102 if (!ahci_skip_host_reset) {
1076 if ((tmp & HOST_RESET) == 0) { 1103 tmp = readl(mmio + HOST_CTL);
1077 writel(tmp | HOST_RESET, mmio + HOST_CTL); 1104 if ((tmp & HOST_RESET) == 0) {
1078 readl(mmio + HOST_CTL); /* flush */ 1105 writel(tmp | HOST_RESET, mmio + HOST_CTL);
1079 } 1106 readl(mmio + HOST_CTL); /* flush */
1107 }
1080 1108
1081 /* reset must complete within 1 second, or 1109 /* reset must complete within 1 second, or
1082 * the hardware should be considered fried. 1110 * the hardware should be considered fried.
1083 */ 1111 */
1084 ssleep(1); 1112 ssleep(1);
1085 1113
1086 tmp = readl(mmio + HOST_CTL); 1114 tmp = readl(mmio + HOST_CTL);
1087 if (tmp & HOST_RESET) { 1115 if (tmp & HOST_RESET) {
1088 dev_printk(KERN_ERR, host->dev, 1116 dev_printk(KERN_ERR, host->dev,
1089 "controller reset failed (0x%x)\n", tmp); 1117 "controller reset failed (0x%x)\n", tmp);
1090 return -EIO; 1118 return -EIO;
1091 } 1119 }
1092 1120
1093 /* turn on AHCI mode */ 1121 /* turn on AHCI mode */
1094 ahci_enable_ahci(mmio); 1122 ahci_enable_ahci(mmio);
1095 1123
1096 /* some registers might be cleared on reset. restore initial values */ 1124 /* Some registers might be cleared on reset. Restore
1097 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");
1098 1131
1099 if (pdev->vendor == PCI_VENDOR_ID_INTEL) { 1132 if (pdev->vendor == PCI_VENDOR_ID_INTEL) {
1100 u16 tmp16; 1133 u16 tmp16;
@@ -1146,9 +1179,14 @@ static void ahci_init_controller(struct ata_host *host)
1146 int i; 1179 int i;
1147 void __iomem *port_mmio; 1180 void __iomem *port_mmio;
1148 u32 tmp; 1181 u32 tmp;
1182 int mv;
1149 1183
1150 if (hpriv->flags & AHCI_HFLAG_MV_PATA) { 1184 if (hpriv->flags & AHCI_HFLAG_MV_PATA) {
1151 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);
1152 1190
1153 writel(0, port_mmio + PORT_IRQ_MASK); 1191 writel(0, port_mmio + PORT_IRQ_MASK);
1154 1192
@@ -1176,6 +1214,17 @@ static void ahci_init_controller(struct ata_host *host)
1176 VPRINTK("HOST_CTL 0x%x\n", tmp); 1214 VPRINTK("HOST_CTL 0x%x\n", tmp);
1177} 1215}
1178 1216
1217static void ahci_dev_config(struct ata_device *dev)
1218{
1219 struct ahci_host_priv *hpriv = dev->link->ap->host->private_data;
1220
1221 if (hpriv->flags & AHCI_HFLAG_SECT255) {
1222 dev->max_sectors = 255;
1223 ata_dev_printk(dev, KERN_INFO,
1224 "SB600 AHCI: limiting to 255 sectors per cmd\n");
1225 }
1226}
1227
1179static unsigned int ahci_dev_classify(struct ata_port *ap) 1228static unsigned int ahci_dev_classify(struct ata_port *ap)
1180{ 1229{
1181 void __iomem *port_mmio = ahci_port_base(ap); 1230 void __iomem *port_mmio = ahci_port_base(ap);
@@ -2217,7 +2266,10 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2217 if (rc) 2266 if (rc)
2218 return rc; 2267 return rc;
2219 2268
2220 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);
2221 if (rc == -EBUSY) 2273 if (rc == -EBUSY)
2222 pcim_pin_device(pdev); 2274 pcim_pin_device(pdev);
2223 if (rc) 2275 if (rc)
diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
index 9e8ec19260af..bf98a566adac 100644
--- a/drivers/ata/libata-acpi.c
+++ b/drivers/ata/libata-acpi.c
@@ -118,45 +118,77 @@ static void ata_acpi_associate_ide_port(struct ata_port *ap)
118 ap->pflags |= ATA_PFLAG_INIT_GTM_VALID; 118 ap->pflags |= ATA_PFLAG_INIT_GTM_VALID;
119} 119}
120 120
121static void ata_acpi_handle_hotplug(struct ata_port *ap, struct kobject *kobj, 121static void ata_acpi_handle_hotplug(struct ata_port *ap, struct ata_device *dev,
122 u32 event) 122 u32 event)
123{ 123{
124 char event_string[12]; 124 char event_string[12];
125 char *envp[] = { event_string, NULL }; 125 char *envp[] = { event_string, NULL };
126 struct ata_eh_info *ehi = &ap->link.eh_info; 126 struct ata_eh_info *ehi;
127 127 struct kobject *kobj = NULL;
128 if (event == 0 || event == 1) { 128 int wait = 0;
129 unsigned long flags; 129 unsigned long flags;
130 spin_lock_irqsave(ap->lock, flags); 130
131 ata_ehi_clear_desc(ehi); 131 if (!ap)
132 ata_ehi_push_desc(ehi, "ACPI event"); 132 ap = dev->link->ap;
133 ata_ehi_hotplugged(ehi); 133 ehi = &ap->link.eh_info;
134 ata_port_freeze(ap); 134
135 spin_unlock_irqrestore(ap->lock, flags); 135 spin_lock_irqsave(ap->lock, flags);
136
137 switch (event) {
138 case ACPI_NOTIFY_BUS_CHECK:
139 case ACPI_NOTIFY_DEVICE_CHECK:
140 ata_ehi_push_desc(ehi, "ACPI event");
141 ata_ehi_hotplugged(ehi);
142 ata_port_freeze(ap);
143 break;
144
145 case ACPI_NOTIFY_EJECT_REQUEST:
146 ata_ehi_push_desc(ehi, "ACPI event");
147 if (dev)
148 dev->flags |= ATA_DFLAG_DETACH;
149 else {
150 struct ata_link *tlink;
151 struct ata_device *tdev;
152
153 ata_port_for_each_link(tlink, ap)
154 ata_link_for_each_dev(tdev, tlink)
155 tdev->flags |= ATA_DFLAG_DETACH;
156 }
157
158 ata_port_schedule_eh(ap);
159 wait = 1;
160 break;
136 } 161 }
137 162
163 if (dev) {
164 if (dev->sdev)
165 kobj = &dev->sdev->sdev_gendev.kobj;
166 } else
167 kobj = &ap->dev->kobj;
168
138 if (kobj) { 169 if (kobj) {
139 sprintf(event_string, "BAY_EVENT=%d", event); 170 sprintf(event_string, "BAY_EVENT=%d", event);
140 kobject_uevent_env(kobj, KOBJ_CHANGE, envp); 171 kobject_uevent_env(kobj, KOBJ_CHANGE, envp);
141 } 172 }
173
174 spin_unlock_irqrestore(ap->lock, flags);
175
176 if (wait)
177 ata_port_wait_eh(ap);
142} 178}
143 179
144static void ata_acpi_dev_notify(acpi_handle handle, u32 event, void *data) 180static void ata_acpi_dev_notify(acpi_handle handle, u32 event, void *data)
145{ 181{
146 struct ata_device *dev = data; 182 struct ata_device *dev = data;
147 struct kobject *kobj = NULL;
148 183
149 if (dev->sdev) 184 ata_acpi_handle_hotplug(NULL, dev, event);
150 kobj = &dev->sdev->sdev_gendev.kobj;
151
152 ata_acpi_handle_hotplug(dev->link->ap, kobj, event);
153} 185}
154 186
155static void ata_acpi_ap_notify(acpi_handle handle, u32 event, void *data) 187static void ata_acpi_ap_notify(acpi_handle handle, u32 event, void *data)
156{ 188{
157 struct ata_port *ap = data; 189 struct ata_port *ap = data;
158 190
159 ata_acpi_handle_hotplug(ap, &ap->dev->kobj, event); 191 ata_acpi_handle_hotplug(ap, NULL, event);
160} 192}
161 193
162/** 194/**
@@ -191,20 +223,30 @@ void ata_acpi_associate(struct ata_host *host)
191 else 223 else
192 ata_acpi_associate_ide_port(ap); 224 ata_acpi_associate_ide_port(ap);
193 225
194 if (ap->acpi_handle) 226 if (ap->acpi_handle) {
195 acpi_install_notify_handler (ap->acpi_handle, 227 acpi_install_notify_handler(ap->acpi_handle,
196 ACPI_SYSTEM_NOTIFY, 228 ACPI_SYSTEM_NOTIFY,
197 ata_acpi_ap_notify, 229 ata_acpi_ap_notify, ap);
198 ap); 230#if defined(CONFIG_ACPI_DOCK) || defined(CONFIG_ACPI_DOCK_MODULE)
231 /* we might be on a docking station */
232 register_hotplug_dock_device(ap->acpi_handle,
233 ata_acpi_ap_notify, ap);
234#endif
235 }
199 236
200 for (j = 0; j < ata_link_max_devices(&ap->link); j++) { 237 for (j = 0; j < ata_link_max_devices(&ap->link); j++) {
201 struct ata_device *dev = &ap->link.device[j]; 238 struct ata_device *dev = &ap->link.device[j];
202 239
203 if (dev->acpi_handle) 240 if (dev->acpi_handle) {
204 acpi_install_notify_handler (dev->acpi_handle, 241 acpi_install_notify_handler(dev->acpi_handle,
205 ACPI_SYSTEM_NOTIFY, 242 ACPI_SYSTEM_NOTIFY,
206 ata_acpi_dev_notify, 243 ata_acpi_dev_notify, dev);
207 dev); 244#if defined(CONFIG_ACPI_DOCK) || defined(CONFIG_ACPI_DOCK_MODULE)
245 /* we might be on a docking station */
246 register_hotplug_dock_device(dev->acpi_handle,
247 ata_acpi_dev_notify, dev);
248#endif
249 }
208 } 250 }
209 } 251 }
210} 252}
@@ -382,7 +424,7 @@ static int ata_dev_get_GTF(struct ata_device *dev, struct ata_acpi_gtf **gtf)
382 424
383 if (ata_msg_probe(ap)) 425 if (ata_msg_probe(ap))
384 ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER: port#: %d\n", 426 ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER: port#: %d\n",
385 __FUNCTION__, ap->port_no); 427 __func__, ap->port_no);
386 428
387 /* _GTF has no input parameters */ 429 /* _GTF has no input parameters */
388 status = acpi_evaluate_object(dev->acpi_handle, "_GTF", NULL, &output); 430 status = acpi_evaluate_object(dev->acpi_handle, "_GTF", NULL, &output);
@@ -402,7 +444,7 @@ static int ata_dev_get_GTF(struct ata_device *dev, struct ata_acpi_gtf **gtf)
402 if (ata_msg_probe(ap)) 444 if (ata_msg_probe(ap))
403 ata_dev_printk(dev, KERN_DEBUG, "%s: Run _GTF: " 445 ata_dev_printk(dev, KERN_DEBUG, "%s: Run _GTF: "
404 "length or ptr is NULL (0x%llx, 0x%p)\n", 446 "length or ptr is NULL (0x%llx, 0x%p)\n",
405 __FUNCTION__, 447 __func__,
406 (unsigned long long)output.length, 448 (unsigned long long)output.length,
407 output.pointer); 449 output.pointer);
408 rc = -EINVAL; 450 rc = -EINVAL;
@@ -432,7 +474,7 @@ static int ata_dev_get_GTF(struct ata_device *dev, struct ata_acpi_gtf **gtf)
432 if (ata_msg_probe(ap)) 474 if (ata_msg_probe(ap))
433 ata_dev_printk(dev, KERN_DEBUG, 475 ata_dev_printk(dev, KERN_DEBUG,
434 "%s: returning gtf=%p, gtf_count=%d\n", 476 "%s: returning gtf=%p, gtf_count=%d\n",
435 __FUNCTION__, *gtf, rc); 477 __func__, *gtf, rc);
436 } 478 }
437 return rc; 479 return rc;
438 480
@@ -725,7 +767,7 @@ static int ata_acpi_push_id(struct ata_device *dev)
725 767
726 if (ata_msg_probe(ap)) 768 if (ata_msg_probe(ap))
727 ata_dev_printk(dev, KERN_DEBUG, "%s: ix = %d, port#: %d\n", 769 ata_dev_printk(dev, KERN_DEBUG, "%s: ix = %d, port#: %d\n",
728 __FUNCTION__, dev->devno, ap->port_no); 770 __func__, dev->devno, ap->port_no);
729 771
730 /* Give the drive Identify data to the drive via the _SDD method */ 772 /* Give the drive Identify data to the drive via the _SDD method */
731 /* _SDD: set up input parameters */ 773 /* _SDD: set up input parameters */
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 4fbcce758b04..c4248b37ff64 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -106,7 +106,8 @@ static struct ata_force_ent *ata_force_tbl;
106static int ata_force_tbl_size; 106static int ata_force_tbl_size;
107 107
108static char ata_force_param_buf[PAGE_SIZE] __initdata; 108static char ata_force_param_buf[PAGE_SIZE] __initdata;
109module_param_string(force, ata_force_param_buf, sizeof(ata_force_param_buf), 0444); 109/* param_buf is thrown away after initialization, disallow read */
110module_param_string(force, ata_force_param_buf, sizeof(ata_force_param_buf), 0);
110MODULE_PARM_DESC(force, "Force ATA configurations including cable type, link speed and transfer mode (see Documentation/kernel-parameters.txt for details)"); 111MODULE_PARM_DESC(force, "Force ATA configurations including cable type, link speed and transfer mode (see Documentation/kernel-parameters.txt for details)");
111 112
112int atapi_enabled = 1; 113int atapi_enabled = 1;
@@ -1415,12 +1416,12 @@ static int ata_hpa_resize(struct ata_device *dev)
1415 /* read native max address */ 1416 /* read native max address */
1416 rc = ata_read_native_max_address(dev, &native_sectors); 1417 rc = ata_read_native_max_address(dev, &native_sectors);
1417 if (rc) { 1418 if (rc) {
1418 /* If HPA isn't going to be unlocked, skip HPA 1419 /* If device aborted the command or HPA isn't going to
1419 * resizing from the next try. 1420 * be unlocked, skip HPA resizing.
1420 */ 1421 */
1421 if (!ata_ignore_hpa) { 1422 if (rc == -EACCES || !ata_ignore_hpa) {
1422 ata_dev_printk(dev, KERN_WARNING, "HPA support seems " 1423 ata_dev_printk(dev, KERN_WARNING, "HPA support seems "
1423 "broken, will skip HPA handling\n"); 1424 "broken, skipping HPA handling\n");
1424 dev->horkage |= ATA_HORKAGE_BROKEN_HPA; 1425 dev->horkage |= ATA_HORKAGE_BROKEN_HPA;
1425 1426
1426 /* we can continue if device aborted the command */ 1427 /* we can continue if device aborted the command */
@@ -1719,7 +1720,7 @@ void ata_port_flush_task(struct ata_port *ap)
1719 cancel_rearming_delayed_work(&ap->port_task); 1720 cancel_rearming_delayed_work(&ap->port_task);
1720 1721
1721 if (ata_msg_ctl(ap)) 1722 if (ata_msg_ctl(ap))
1722 ata_port_printk(ap, KERN_DEBUG, "%s: EXIT\n", __FUNCTION__); 1723 ata_port_printk(ap, KERN_DEBUG, "%s: EXIT\n", __func__);
1723} 1724}
1724 1725
1725static void ata_qc_complete_internal(struct ata_queued_cmd *qc) 1726static void ata_qc_complete_internal(struct ata_queued_cmd *qc)
@@ -2056,7 +2057,7 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class,
2056 int rc; 2057 int rc;
2057 2058
2058 if (ata_msg_ctl(ap)) 2059 if (ata_msg_ctl(ap))
2059 ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER\n", __FUNCTION__); 2060 ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER\n", __func__);
2060 2061
2061 ata_dev_select(ap, dev->devno, 1, 1); /* select device 0/1 */ 2062 ata_dev_select(ap, dev->devno, 1, 1); /* select device 0/1 */
2062 retry: 2063 retry:
@@ -2091,24 +2092,34 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class,
2091 id, sizeof(id[0]) * ATA_ID_WORDS, 0); 2092 id, sizeof(id[0]) * ATA_ID_WORDS, 0);
2092 if (err_mask) { 2093 if (err_mask) {
2093 if (err_mask & AC_ERR_NODEV_HINT) { 2094 if (err_mask & AC_ERR_NODEV_HINT) {
2094 DPRINTK("ata%u.%d: NODEV after polling detection\n", 2095 ata_dev_printk(dev, KERN_DEBUG,
2095 ap->print_id, dev->devno); 2096 "NODEV after polling detection\n");
2096 return -ENOENT; 2097 return -ENOENT;
2097 } 2098 }
2098 2099
2099 /* Device or controller might have reported the wrong 2100 if ((err_mask == AC_ERR_DEV) && (tf.feature & ATA_ABORTED)) {
2100 * device class. Give a shot at the other IDENTIFY if 2101 /* Device or controller might have reported
2101 * the current one is aborted by the device. 2102 * the wrong device class. Give a shot at the
2102 */ 2103 * other IDENTIFY if the current one is
2103 if (may_fallback && 2104 * aborted by the device.
2104 (err_mask == AC_ERR_DEV) && (tf.feature & ATA_ABORTED)) { 2105 */
2105 may_fallback = 0; 2106 if (may_fallback) {
2107 may_fallback = 0;
2106 2108
2107 if (class == ATA_DEV_ATA) 2109 if (class == ATA_DEV_ATA)
2108 class = ATA_DEV_ATAPI; 2110 class = ATA_DEV_ATAPI;
2109 else 2111 else
2110 class = ATA_DEV_ATA; 2112 class = ATA_DEV_ATA;
2111 goto retry; 2113 goto retry;
2114 }
2115
2116 /* Control reaches here iff the device aborted
2117 * both flavors of IDENTIFYs which happens
2118 * sometimes with phantom devices.
2119 */
2120 ata_dev_printk(dev, KERN_DEBUG,
2121 "both IDENTIFYs aborted, assuming NODEV\n");
2122 return -ENOENT;
2112 } 2123 }
2113 2124
2114 rc = -EIO; 2125 rc = -EIO;
@@ -2253,12 +2264,12 @@ int ata_dev_configure(struct ata_device *dev)
2253 2264
2254 if (!ata_dev_enabled(dev) && ata_msg_info(ap)) { 2265 if (!ata_dev_enabled(dev) && ata_msg_info(ap)) {
2255 ata_dev_printk(dev, KERN_INFO, "%s: ENTER/EXIT -- nodev\n", 2266 ata_dev_printk(dev, KERN_INFO, "%s: ENTER/EXIT -- nodev\n",
2256 __FUNCTION__); 2267 __func__);
2257 return 0; 2268 return 0;
2258 } 2269 }
2259 2270
2260 if (ata_msg_probe(ap)) 2271 if (ata_msg_probe(ap))
2261 ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER\n", __FUNCTION__); 2272 ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER\n", __func__);
2262 2273
2263 /* set horkage */ 2274 /* set horkage */
2264 dev->horkage |= ata_dev_blacklisted(dev); 2275 dev->horkage |= ata_dev_blacklisted(dev);
@@ -2279,7 +2290,7 @@ int ata_dev_configure(struct ata_device *dev)
2279 ata_dev_printk(dev, KERN_DEBUG, 2290 ata_dev_printk(dev, KERN_DEBUG,
2280 "%s: cfg 49:%04x 82:%04x 83:%04x 84:%04x " 2291 "%s: cfg 49:%04x 82:%04x 83:%04x 84:%04x "
2281 "85:%04x 86:%04x 87:%04x 88:%04x\n", 2292 "85:%04x 86:%04x 87:%04x 88:%04x\n",
2282 __FUNCTION__, 2293 __func__,
2283 id[49], id[82], id[83], id[84], 2294 id[49], id[82], id[83], id[84],
2284 id[85], id[86], id[87], id[88]); 2295 id[85], id[86], id[87], id[88]);
2285 2296
@@ -2511,13 +2522,13 @@ int ata_dev_configure(struct ata_device *dev)
2511 2522
2512 if (ata_msg_probe(ap)) 2523 if (ata_msg_probe(ap))
2513 ata_dev_printk(dev, KERN_DEBUG, "%s: EXIT, drv_stat = 0x%x\n", 2524 ata_dev_printk(dev, KERN_DEBUG, "%s: EXIT, drv_stat = 0x%x\n",
2514 __FUNCTION__, ata_chk_status(ap)); 2525 __func__, ata_chk_status(ap));
2515 return 0; 2526 return 0;
2516 2527
2517err_out_nosup: 2528err_out_nosup:
2518 if (ata_msg_probe(ap)) 2529 if (ata_msg_probe(ap))
2519 ata_dev_printk(dev, KERN_DEBUG, 2530 ata_dev_printk(dev, KERN_DEBUG,
2520 "%s: EXIT, err\n", __FUNCTION__); 2531 "%s: EXIT, err\n", __func__);
2521 return rc; 2532 return rc;
2522} 2533}
2523 2534
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index 698ce2cea52c..681252fd8143 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -2150,6 +2150,15 @@ int ata_eh_reset(struct ata_link *link, int classify,
2150 ap->ops->set_piomode(ap, dev); 2150 ap->ops->set_piomode(ap, dev);
2151 } 2151 }
2152 2152
2153 if (!softreset && !hardreset) {
2154 if (verbose)
2155 ata_link_printk(link, KERN_INFO, "no reset method "
2156 "available, skipping reset\n");
2157 if (!(lflags & ATA_LFLAG_ASSUME_CLASS))
2158 lflags |= ATA_LFLAG_ASSUME_ATA;
2159 goto done;
2160 }
2161
2153 /* Determine which reset to use and record in ehc->i.action. 2162 /* Determine which reset to use and record in ehc->i.action.
2154 * prereset() may examine and modify it. 2163 * prereset() may examine and modify it.
2155 */ 2164 */
@@ -2254,6 +2263,7 @@ int ata_eh_reset(struct ata_link *link, int classify,
2254 lflags |= ATA_LFLAG_ASSUME_ATA; 2263 lflags |= ATA_LFLAG_ASSUME_ATA;
2255 } 2264 }
2256 2265
2266 done:
2257 ata_link_for_each_dev(dev, link) { 2267 ata_link_for_each_dev(dev, link) {
2258 /* After the reset, the device state is PIO 0 and the 2268 /* After the reset, the device state is PIO 0 and the
2259 * controller state is undefined. Reset also wakes up 2269 * controller state is undefined. Reset also wakes up
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 7b1f1ee8131d..15795394b0a8 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -527,6 +527,14 @@ static struct ata_queued_cmd *ata_scsi_qc_new(struct ata_device *dev,
527 return qc; 527 return qc;
528} 528}
529 529
530static void ata_qc_set_pc_nbytes(struct ata_queued_cmd *qc)
531{
532 struct scsi_cmnd *scmd = qc->scsicmd;
533
534 qc->extrabytes = scmd->request->extra_len;
535 qc->nbytes = scsi_bufflen(scmd) + qc->extrabytes;
536}
537
530/** 538/**
531 * ata_dump_status - user friendly display of error info 539 * ata_dump_status - user friendly display of error info
532 * @id: id of the port in question 540 * @id: id of the port in question
@@ -862,9 +870,10 @@ static int ata_scsi_dev_config(struct scsi_device *sdev,
862 struct request_queue *q = sdev->request_queue; 870 struct request_queue *q = sdev->request_queue;
863 void *buf; 871 void *buf;
864 872
865 /* set the min alignment */ 873 /* set the min alignment and padding */
866 blk_queue_update_dma_alignment(sdev->request_queue, 874 blk_queue_update_dma_alignment(sdev->request_queue,
867 ATA_DMA_PAD_SZ - 1); 875 ATA_DMA_PAD_SZ - 1);
876 blk_queue_dma_pad(sdev->request_queue, ATA_DMA_PAD_SZ - 1);
868 877
869 /* configure draining */ 878 /* configure draining */
870 buf = kmalloc(ATAPI_MAX_DRAIN, q->bounce_gfp | GFP_KERNEL); 879 buf = kmalloc(ATAPI_MAX_DRAIN, q->bounce_gfp | GFP_KERNEL);
@@ -2538,7 +2547,7 @@ static unsigned int atapi_xlat(struct ata_queued_cmd *qc)
2538 } 2547 }
2539 2548
2540 qc->tf.command = ATA_CMD_PACKET; 2549 qc->tf.command = ATA_CMD_PACKET;
2541 qc->nbytes = scsi_bufflen(scmd); 2550 ata_qc_set_pc_nbytes(qc);
2542 2551
2543 /* check whether ATAPI DMA is safe */ 2552 /* check whether ATAPI DMA is safe */
2544 if (!using_pio && ata_check_atapi_dma(qc)) 2553 if (!using_pio && ata_check_atapi_dma(qc))
@@ -2549,7 +2558,7 @@ static unsigned int atapi_xlat(struct ata_queued_cmd *qc)
2549 * want to set it properly, and for DMA where it is 2558 * want to set it properly, and for DMA where it is
2550 * effectively meaningless. 2559 * effectively meaningless.
2551 */ 2560 */
2552 nbytes = min(scmd->request->raw_data_len, (unsigned int)63 * 1024); 2561 nbytes = min(ata_qc_raw_nbytes(qc), (unsigned int)63 * 1024);
2553 2562
2554 /* Most ATAPI devices which honor transfer chunk size don't 2563 /* Most ATAPI devices which honor transfer chunk size don't
2555 * behave according to the spec when odd chunk size which 2564 * behave according to the spec when odd chunk size which
@@ -2875,7 +2884,7 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc)
2875 * TODO: find out if we need to do more here to 2884 * TODO: find out if we need to do more here to
2876 * cover scatter/gather case. 2885 * cover scatter/gather case.
2877 */ 2886 */
2878 qc->nbytes = scsi_bufflen(scmd); 2887 ata_qc_set_pc_nbytes(qc);
2879 2888
2880 /* request result TF and be quiet about device error */ 2889 /* request result TF and be quiet about device error */
2881 qc->flags |= ATA_QCFLAG_RESULT_TF | ATA_QCFLAG_QUIET; 2890 qc->flags |= ATA_QCFLAG_RESULT_TF | ATA_QCFLAG_QUIET;
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c
index 60cd4b179766..20dc572fb45a 100644
--- a/drivers/ata/libata-sff.c
+++ b/drivers/ata/libata-sff.c
@@ -56,7 +56,8 @@ u8 ata_irq_on(struct ata_port *ap)
56 ap->ctl &= ~ATA_NIEN; 56 ap->ctl &= ~ATA_NIEN;
57 ap->last_ctl = ap->ctl; 57 ap->last_ctl = ap->ctl;
58 58
59 iowrite8(ap->ctl, ioaddr->ctl_addr); 59 if (ioaddr->ctl_addr)
60 iowrite8(ap->ctl, ioaddr->ctl_addr);
60 tmp = ata_wait_idle(ap); 61 tmp = ata_wait_idle(ap);
61 62
62 ap->ops->irq_clear(ap); 63 ap->ops->irq_clear(ap);
@@ -81,12 +82,14 @@ void ata_tf_load(struct ata_port *ap, const struct ata_taskfile *tf)
81 unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR; 82 unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR;
82 83
83 if (tf->ctl != ap->last_ctl) { 84 if (tf->ctl != ap->last_ctl) {
84 iowrite8(tf->ctl, ioaddr->ctl_addr); 85 if (ioaddr->ctl_addr)
86 iowrite8(tf->ctl, ioaddr->ctl_addr);
85 ap->last_ctl = tf->ctl; 87 ap->last_ctl = tf->ctl;
86 ata_wait_idle(ap); 88 ata_wait_idle(ap);
87 } 89 }
88 90
89 if (is_addr && (tf->flags & ATA_TFLAG_LBA48)) { 91 if (is_addr && (tf->flags & ATA_TFLAG_LBA48)) {
92 WARN_ON(!ioaddr->ctl_addr);
90 iowrite8(tf->hob_feature, ioaddr->feature_addr); 93 iowrite8(tf->hob_feature, ioaddr->feature_addr);
91 iowrite8(tf->hob_nsect, ioaddr->nsect_addr); 94 iowrite8(tf->hob_nsect, ioaddr->nsect_addr);
92 iowrite8(tf->hob_lbal, ioaddr->lbal_addr); 95 iowrite8(tf->hob_lbal, ioaddr->lbal_addr);
@@ -167,14 +170,17 @@ void ata_tf_read(struct ata_port *ap, struct ata_taskfile *tf)
167 tf->device = ioread8(ioaddr->device_addr); 170 tf->device = ioread8(ioaddr->device_addr);
168 171
169 if (tf->flags & ATA_TFLAG_LBA48) { 172 if (tf->flags & ATA_TFLAG_LBA48) {
170 iowrite8(tf->ctl | ATA_HOB, ioaddr->ctl_addr); 173 if (likely(ioaddr->ctl_addr)) {
171 tf->hob_feature = ioread8(ioaddr->error_addr); 174 iowrite8(tf->ctl | ATA_HOB, ioaddr->ctl_addr);
172 tf->hob_nsect = ioread8(ioaddr->nsect_addr); 175 tf->hob_feature = ioread8(ioaddr->error_addr);
173 tf->hob_lbal = ioread8(ioaddr->lbal_addr); 176 tf->hob_nsect = ioread8(ioaddr->nsect_addr);
174 tf->hob_lbam = ioread8(ioaddr->lbam_addr); 177 tf->hob_lbal = ioread8(ioaddr->lbal_addr);
175 tf->hob_lbah = ioread8(ioaddr->lbah_addr); 178 tf->hob_lbam = ioread8(ioaddr->lbam_addr);
176 iowrite8(tf->ctl, ioaddr->ctl_addr); 179 tf->hob_lbah = ioread8(ioaddr->lbah_addr);
177 ap->last_ctl = tf->ctl; 180 iowrite8(tf->ctl, ioaddr->ctl_addr);
181 ap->last_ctl = tf->ctl;
182 } else
183 WARN_ON(1);
178 } 184 }
179} 185}
180 186
@@ -352,7 +358,8 @@ void ata_bmdma_freeze(struct ata_port *ap)
352 ap->ctl |= ATA_NIEN; 358 ap->ctl |= ATA_NIEN;
353 ap->last_ctl = ap->ctl; 359 ap->last_ctl = ap->ctl;
354 360
355 iowrite8(ap->ctl, ioaddr->ctl_addr); 361 if (ioaddr->ctl_addr)
362 iowrite8(ap->ctl, ioaddr->ctl_addr);
356 363
357 /* Under certain circumstances, some controllers raise IRQ on 364 /* Under certain circumstances, some controllers raise IRQ on
358 * ATA_NIEN manipulation. Also, many controllers fail to mask 365 * ATA_NIEN manipulation. Also, many controllers fail to mask
@@ -459,13 +466,14 @@ void ata_bmdma_drive_eh(struct ata_port *ap, ata_prereset_fn_t prereset,
459 */ 466 */
460void ata_bmdma_error_handler(struct ata_port *ap) 467void ata_bmdma_error_handler(struct ata_port *ap)
461{ 468{
462 ata_reset_fn_t hardreset; 469 ata_reset_fn_t softreset = NULL, hardreset = NULL;
463 470
464 hardreset = NULL; 471 if (ap->ioaddr.ctl_addr)
472 softreset = ata_std_softreset;
465 if (sata_scr_valid(&ap->link)) 473 if (sata_scr_valid(&ap->link))
466 hardreset = sata_std_hardreset; 474 hardreset = sata_std_hardreset;
467 475
468 ata_bmdma_drive_eh(ap, ata_std_prereset, ata_std_softreset, hardreset, 476 ata_bmdma_drive_eh(ap, ata_std_prereset, softreset, hardreset,
469 ata_std_postreset); 477 ata_std_postreset);
470} 478}
471 479
diff --git a/drivers/ata/pata_ali.c b/drivers/ata/pata_ali.c
index 7e68edf3c0f3..8786455c901d 100644
--- a/drivers/ata/pata_ali.c
+++ b/drivers/ata/pata_ali.c
@@ -295,7 +295,7 @@ static void ali_lock_sectors(struct ata_device *adev)
295static int ali_check_atapi_dma(struct ata_queued_cmd *qc) 295static int ali_check_atapi_dma(struct ata_queued_cmd *qc)
296{ 296{
297 /* If its not a media command, its not worth it */ 297 /* If its not a media command, its not worth it */
298 if (qc->nbytes < 2048) 298 if (atapi_cmd_type(qc->cdb[0]) == ATAPI_MISC)
299 return -EOPNOTSUPP; 299 return -EOPNOTSUPP;
300 return 0; 300 return 0;
301} 301}
diff --git a/drivers/ata/pata_hpt366.c b/drivers/ata/pata_hpt366.c
index 0713872cf65c..a742efa0da2b 100644
--- a/drivers/ata/pata_hpt366.c
+++ b/drivers/ata/pata_hpt366.c
@@ -27,7 +27,7 @@
27#include <linux/libata.h> 27#include <linux/libata.h>
28 28
29#define DRV_NAME "pata_hpt366" 29#define DRV_NAME "pata_hpt366"
30#define DRV_VERSION "0.6.1" 30#define DRV_VERSION "0.6.2"
31 31
32struct hpt_clock { 32struct hpt_clock {
33 u8 xfer_speed; 33 u8 xfer_speed;
@@ -180,9 +180,9 @@ static unsigned long hpt366_filter(struct ata_device *adev, unsigned long mask)
180 if (hpt_dma_blacklisted(adev, "UDMA", bad_ata33)) 180 if (hpt_dma_blacklisted(adev, "UDMA", bad_ata33))
181 mask &= ~ATA_MASK_UDMA; 181 mask &= ~ATA_MASK_UDMA;
182 if (hpt_dma_blacklisted(adev, "UDMA3", bad_ata66_3)) 182 if (hpt_dma_blacklisted(adev, "UDMA3", bad_ata66_3))
183 mask &= ~(0x07 << ATA_SHIFT_UDMA); 183 mask &= ~(0xF8 << ATA_SHIFT_UDMA);
184 if (hpt_dma_blacklisted(adev, "UDMA4", bad_ata66_4)) 184 if (hpt_dma_blacklisted(adev, "UDMA4", bad_ata66_4))
185 mask &= ~(0x0F << ATA_SHIFT_UDMA); 185 mask &= ~(0xF0 << ATA_SHIFT_UDMA);
186 } 186 }
187 return ata_pci_default_filter(adev, mask); 187 return ata_pci_default_filter(adev, mask);
188} 188}
diff --git a/drivers/ata/pata_hpt37x.c b/drivers/ata/pata_hpt37x.c
index 68eb34929cec..9a10878b2ad8 100644
--- a/drivers/ata/pata_hpt37x.c
+++ b/drivers/ata/pata_hpt37x.c
@@ -24,7 +24,7 @@
24#include <linux/libata.h> 24#include <linux/libata.h>
25 25
26#define DRV_NAME "pata_hpt37x" 26#define DRV_NAME "pata_hpt37x"
27#define DRV_VERSION "0.6.9" 27#define DRV_VERSION "0.6.11"
28 28
29struct hpt_clock { 29struct hpt_clock {
30 u8 xfer_speed; 30 u8 xfer_speed;
@@ -281,7 +281,7 @@ static unsigned long hpt370_filter(struct ata_device *adev, unsigned long mask)
281 if (hpt_dma_blacklisted(adev, "UDMA", bad_ata33)) 281 if (hpt_dma_blacklisted(adev, "UDMA", bad_ata33))
282 mask &= ~ATA_MASK_UDMA; 282 mask &= ~ATA_MASK_UDMA;
283 if (hpt_dma_blacklisted(adev, "UDMA100", bad_ata100_5)) 283 if (hpt_dma_blacklisted(adev, "UDMA100", bad_ata100_5))
284 mask &= ~(0x1F << ATA_SHIFT_UDMA); 284 mask &= ~(0xE0 << ATA_SHIFT_UDMA);
285 } 285 }
286 return ata_pci_default_filter(adev, mask); 286 return ata_pci_default_filter(adev, mask);
287} 287}
@@ -297,7 +297,7 @@ static unsigned long hpt370a_filter(struct ata_device *adev, unsigned long mask)
297{ 297{
298 if (adev->class == ATA_DEV_ATA) { 298 if (adev->class == ATA_DEV_ATA) {
299 if (hpt_dma_blacklisted(adev, "UDMA100", bad_ata100_5)) 299 if (hpt_dma_blacklisted(adev, "UDMA100", bad_ata100_5))
300 mask &= ~ (0x1F << ATA_SHIFT_UDMA); 300 mask &= ~(0xE0 << ATA_SHIFT_UDMA);
301 } 301 }
302 return ata_pci_default_filter(adev, mask); 302 return ata_pci_default_filter(adev, mask);
303} 303}
diff --git a/drivers/ata/pata_it821x.c b/drivers/ata/pata_it821x.c
index 109ddd42c266..257951d03dbb 100644
--- a/drivers/ata/pata_it821x.c
+++ b/drivers/ata/pata_it821x.c
@@ -564,7 +564,7 @@ static int it821x_check_atapi_dma(struct ata_queued_cmd *qc)
564 struct it821x_dev *itdev = ap->private_data; 564 struct it821x_dev *itdev = ap->private_data;
565 565
566 /* Only use dma for transfers to/from the media. */ 566 /* Only use dma for transfers to/from the media. */
567 if (qc->nbytes < 2048) 567 if (ata_qc_raw_nbytes(qc) < 2048)
568 return -EOPNOTSUPP; 568 return -EOPNOTSUPP;
569 569
570 /* No ATAPI DMA in smart mode */ 570 /* No ATAPI DMA in smart mode */
diff --git a/drivers/ata/pata_pdc2027x.c b/drivers/ata/pata_pdc2027x.c
index 028af5dbeed6..511c89b9bae8 100644
--- a/drivers/ata/pata_pdc2027x.c
+++ b/drivers/ata/pata_pdc2027x.c
@@ -39,7 +39,7 @@
39#undef PDC_DEBUG 39#undef PDC_DEBUG
40 40
41#ifdef PDC_DEBUG 41#ifdef PDC_DEBUG
42#define PDPRINTK(fmt, args...) printk(KERN_ERR "%s: " fmt, __FUNCTION__, ## args) 42#define PDPRINTK(fmt, args...) printk(KERN_ERR "%s: " fmt, __func__, ## args)
43#else 43#else
44#define PDPRINTK(fmt, args...) 44#define PDPRINTK(fmt, args...)
45#endif 45#endif
diff --git a/drivers/ata/pata_rb500_cf.c b/drivers/ata/pata_rb500_cf.c
new file mode 100644
index 000000000000..4ce9b03fe6c8
--- /dev/null
+++ b/drivers/ata/pata_rb500_cf.c
@@ -0,0 +1,314 @@
1/*
2 * A low-level PATA driver to handle a Compact Flash connected on the
3 * Mikrotik's RouterBoard 532 board.
4 *
5 * Copyright (C) 2007 Gabor Juhos <juhosg at openwrt.org>
6 * Copyright (C) 2008 Florian Fainelli <florian@openwrt.org>
7 *
8 * This file was based on: drivers/ata/pata_ixp4xx_cf.c
9 * Copyright (C) 2006-07 Tower Technologies
10 * Author: Alessandro Zummo <a.zummo@towertech.it>
11 *
12 * Also was based on the driver for Linux 2.4.xx published by Mikrotik for
13 * their RouterBoard 1xx and 5xx series devices. The original Mikrotik code
14 * seems not to have a license.
15 *
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License version 2 as
18 * published by the Free Software Foundation.
19 *
20 */
21
22#include <linux/kernel.h>
23#include <linux/module.h>
24#include <linux/platform_device.h>
25
26#include <linux/io.h>
27#include <linux/interrupt.h>
28#include <linux/irq.h>
29
30#include <linux/libata.h>
31#include <scsi/scsi_host.h>
32
33#include <asm/gpio.h>
34
35#define DRV_NAME "pata-rb500-cf"
36#define DRV_VERSION "0.1.0"
37#define DRV_DESC "PATA driver for RouterBOARD 532 Compact Flash"
38
39#define RB500_CF_MAXPORTS 1
40#define RB500_CF_IO_DELAY 400
41
42#define RB500_CF_REG_CMD 0x0800
43#define RB500_CF_REG_CTRL 0x080E
44#define RB500_CF_REG_DATA 0x0C00
45
46struct rb500_cf_info {
47 void __iomem *iobase;
48 unsigned int gpio_line;
49 int frozen;
50 unsigned int irq;
51};
52
53/* ------------------------------------------------------------------------ */
54
55static inline void rb500_pata_finish_io(struct ata_port *ap)
56{
57 struct ata_host *ah = ap->host;
58 struct rb500_cf_info *info = ah->private_data;
59
60 ata_altstatus(ap);
61 ndelay(RB500_CF_IO_DELAY);
62
63 set_irq_type(info->irq, IRQ_TYPE_LEVEL_HIGH);
64}
65
66static void rb500_pata_exec_command(struct ata_port *ap,
67 const struct ata_taskfile *tf)
68{
69 writeb(tf->command, ap->ioaddr.command_addr);
70 rb500_pata_finish_io(ap);
71}
72
73static void rb500_pata_data_xfer(struct ata_device *adev, unsigned char *buf,
74 unsigned int buflen, int write_data)
75{
76 struct ata_port *ap = adev->link->ap;
77 void __iomem *ioaddr = ap->ioaddr.data_addr;
78
79 if (write_data) {
80 for (; buflen > 0; buflen--, buf++)
81 writeb(*buf, ioaddr);
82 } else {
83 for (; buflen > 0; buflen--, buf++)
84 *buf = readb(ioaddr);
85 }
86
87 rb500_pata_finish_io(adev->link->ap);
88}
89
90static void rb500_pata_freeze(struct ata_port *ap)
91{
92 struct rb500_cf_info *info = ap->host->private_data;
93
94 info->frozen = 1;
95}
96
97static void rb500_pata_thaw(struct ata_port *ap)
98{
99 struct rb500_cf_info *info = ap->host->private_data;
100
101 info->frozen = 0;
102}
103
104static irqreturn_t rb500_pata_irq_handler(int irq, void *dev_instance)
105{
106 struct ata_host *ah = dev_instance;
107 struct rb500_cf_info *info = ah->private_data;
108
109 if (gpio_get_value(info->gpio_line)) {
110 set_irq_type(info->irq, IRQ_TYPE_LEVEL_LOW);
111 if (!info->frozen)
112 ata_interrupt(info->irq, dev_instance);
113 } else {
114 set_irq_type(info->irq, IRQ_TYPE_LEVEL_HIGH);
115 }
116
117 return IRQ_HANDLED;
118}
119
120static void rb500_pata_irq_clear(struct ata_port *ap)
121{
122}
123
124static int rb500_pata_port_start(struct ata_port *ap)
125{
126 return 0;
127}
128
129static struct ata_port_operations rb500_pata_port_ops = {
130 .tf_load = ata_tf_load,
131 .tf_read = ata_tf_read,
132
133 .exec_command = rb500_pata_exec_command,
134 .check_status = ata_check_status,
135 .dev_select = ata_std_dev_select,
136
137 .data_xfer = rb500_pata_data_xfer,
138
139 .qc_prep = ata_qc_prep,
140 .qc_issue = ata_qc_issue_prot,
141
142 .freeze = rb500_pata_freeze,
143 .thaw = rb500_pata_thaw,
144 .error_handler = ata_bmdma_error_handler,
145
146 .irq_handler = rb500_pata_irq_handler,
147 .irq_clear = rb500_pata_irq_clear,
148 .irq_on = ata_irq_on,
149
150 .port_start = rb500_pata_port_start,
151};
152
153/* ------------------------------------------------------------------------ */
154
155static struct scsi_host_template rb500_pata_sht = {
156 .module = THIS_MODULE,
157 .name = DRV_NAME,
158 .ioctl = ata_scsi_ioctl,
159 .queuecommand = ata_scsi_queuecmd,
160 .slave_configure = ata_scsi_slave_config,
161 .slave_destroy = ata_scsi_slave_destroy,
162 .bios_param = ata_std_bios_param,
163 .proc_name = DRV_NAME,
164
165 .can_queue = ATA_DEF_QUEUE,
166 .this_id = ATA_SHT_THIS_ID,
167 .sg_tablesize = LIBATA_MAX_PRD,
168 .dma_boundary = ATA_DMA_BOUNDARY,
169 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
170 .emulated = ATA_SHT_EMULATED,
171 .use_clustering = ATA_SHT_USE_CLUSTERING,
172};
173
174/* ------------------------------------------------------------------------ */
175
176static void rb500_pata_setup_ports(struct ata_host *ah)
177{
178 struct rb500_cf_info *info = ah->private_data;
179 struct ata_port *ap;
180
181 ap = ah->ports[0];
182
183 ap->ops = &rb500_pata_port_ops;
184 ap->pio_mask = 0x1f; /* PIO4 */
185 ap->flags = ATA_FLAG_NO_LEGACY | ATA_FLAG_MMIO;
186
187 ap->ioaddr.cmd_addr = info->iobase + RB500_CF_REG_CMD;
188 ap->ioaddr.ctl_addr = info->iobase + RB500_CF_REG_CTRL;
189 ap->ioaddr.altstatus_addr = info->iobase + RB500_CF_REG_CTRL;
190
191 ata_std_ports(&ap->ioaddr);
192
193 ap->ioaddr.data_addr = info->iobase + RB500_CF_REG_DATA;
194}
195
196static __devinit int rb500_pata_driver_probe(struct platform_device *pdev)
197{
198 unsigned int irq;
199 int gpio;
200 struct resource *res;
201 struct ata_host *ah;
202 struct rb500_cf_info *info;
203 int ret;
204
205 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
206 if (!res) {
207 dev_err(&pdev->dev, "no IOMEM resource found\n");
208 return -EINVAL;
209 }
210
211 irq = platform_get_irq(pdev, 0);
212 if (irq <= 0) {
213 dev_err(&pdev->dev, "no IRQ resource found\n");
214 return -ENOENT;
215 }
216
217 gpio = irq_to_gpio(irq);
218 if (gpio < 0) {
219 dev_err(&pdev->dev, "no GPIO found for irq%d\n", irq);
220 return -ENOENT;
221 }
222
223 ret = gpio_request(gpio, DRV_NAME);
224 if (ret) {
225 dev_err(&pdev->dev, "GPIO request failed\n");
226 return ret;
227 }
228
229 /* allocate host */
230 ah = ata_host_alloc(&pdev->dev, RB500_CF_MAXPORTS);
231 if (!ah)
232 return -ENOMEM;
233
234 platform_set_drvdata(pdev, ah);
235
236 info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
237 if (!info)
238 return -ENOMEM;
239
240 ah->private_data = info;
241 info->gpio_line = gpio;
242 info->irq = irq;
243
244 info->iobase = devm_ioremap_nocache(&pdev->dev, res->start,
245 res->end - res->start + 1);
246 if (!info->iobase)
247 return -ENOMEM;
248
249 ret = gpio_direction_input(gpio);
250 if (ret) {
251 dev_err(&pdev->dev, "unable to set GPIO direction, err=%d\n",
252 ret);
253 goto err_free_gpio;
254 }
255
256 rb500_pata_setup_ports(ah);
257
258 ret = ata_host_activate(ah, irq, rb500_pata_irq_handler,
259 IRQF_TRIGGER_LOW, &rb500_pata_sht);
260 if (ret)
261 goto err_free_gpio;
262
263 return 0;
264
265err_free_gpio:
266 gpio_free(gpio);
267
268 return ret;
269}
270
271static __devexit int rb500_pata_driver_remove(struct platform_device *pdev)
272{
273 struct ata_host *ah = platform_get_drvdata(pdev);
274 struct rb500_cf_info *info = ah->private_data;
275
276 ata_host_detach(ah);
277 gpio_free(info->gpio_line);
278
279 return 0;
280}
281
282static struct platform_driver rb500_pata_platform_driver = {
283 .probe = rb500_pata_driver_probe,
284 .remove = __devexit_p(rb500_pata_driver_remove),
285 .driver = {
286 .name = DRV_NAME,
287 .owner = THIS_MODULE,
288 },
289};
290
291/* ------------------------------------------------------------------------ */
292
293#define DRV_INFO DRV_DESC " version " DRV_VERSION
294
295static int __init rb500_pata_module_init(void)
296{
297 printk(KERN_INFO DRV_INFO "\n");
298
299 return platform_driver_register(&rb500_pata_platform_driver);
300}
301
302static void __exit rb500_pata_module_exit(void)
303{
304 platform_driver_unregister(&rb500_pata_platform_driver);
305}
306
307MODULE_AUTHOR("Gabor Juhos <juhosg at openwrt.org>");
308MODULE_AUTHOR("Florian Fainelli <florian@openwrt.org>");
309MODULE_DESCRIPTION(DRV_DESC);
310MODULE_VERSION(DRV_VERSION);
311MODULE_LICENSE("GPL");
312
313module_init(rb500_pata_module_init);
314module_exit(rb500_pata_module_exit);
diff --git a/drivers/ata/pata_serverworks.c b/drivers/ata/pata_serverworks.c
index 9c523fbf529e..a589c0fa0dbb 100644
--- a/drivers/ata/pata_serverworks.c
+++ b/drivers/ata/pata_serverworks.c
@@ -226,7 +226,7 @@ static unsigned long serverworks_csb_filter(struct ata_device *adev, unsigned lo
226 226
227 for (i = 0; (p = csb_bad_ata100[i]) != NULL; i++) { 227 for (i = 0; (p = csb_bad_ata100[i]) != NULL; i++) {
228 if (!strcmp(p, model_num)) 228 if (!strcmp(p, model_num))
229 mask &= ~(0x1F << ATA_SHIFT_UDMA); 229 mask &= ~(0xE0 << ATA_SHIFT_UDMA);
230 } 230 }
231 return ata_pci_default_filter(adev, mask); 231 return ata_pci_default_filter(adev, mask);
232} 232}
diff --git a/drivers/ata/sata_promise.c b/drivers/ata/sata_promise.c
index f251a5f569d5..11c1afea2db2 100644
--- a/drivers/ata/sata_promise.c
+++ b/drivers/ata/sata_promise.c
@@ -46,7 +46,7 @@
46#include "sata_promise.h" 46#include "sata_promise.h"
47 47
48#define DRV_NAME "sata_promise" 48#define DRV_NAME "sata_promise"
49#define DRV_VERSION "2.11" 49#define DRV_VERSION "2.12"
50 50
51enum { 51enum {
52 PDC_MAX_PORTS = 4, 52 PDC_MAX_PORTS = 4,
@@ -145,7 +145,9 @@ static int pdc_old_sata_check_atapi_dma(struct ata_queued_cmd *qc);
145static void pdc_irq_clear(struct ata_port *ap); 145static void pdc_irq_clear(struct ata_port *ap);
146static unsigned int pdc_qc_issue_prot(struct ata_queued_cmd *qc); 146static unsigned int pdc_qc_issue_prot(struct ata_queued_cmd *qc);
147static void pdc_freeze(struct ata_port *ap); 147static void pdc_freeze(struct ata_port *ap);
148static void pdc_sata_freeze(struct ata_port *ap);
148static void pdc_thaw(struct ata_port *ap); 149static void pdc_thaw(struct ata_port *ap);
150static void pdc_sata_thaw(struct ata_port *ap);
149static void pdc_pata_error_handler(struct ata_port *ap); 151static void pdc_pata_error_handler(struct ata_port *ap);
150static void pdc_sata_error_handler(struct ata_port *ap); 152static void pdc_sata_error_handler(struct ata_port *ap);
151static void pdc_post_internal_cmd(struct ata_queued_cmd *qc); 153static void pdc_post_internal_cmd(struct ata_queued_cmd *qc);
@@ -180,8 +182,8 @@ static const struct ata_port_operations pdc_sata_ops = {
180 182
181 .qc_prep = pdc_qc_prep, 183 .qc_prep = pdc_qc_prep,
182 .qc_issue = pdc_qc_issue_prot, 184 .qc_issue = pdc_qc_issue_prot,
183 .freeze = pdc_freeze, 185 .freeze = pdc_sata_freeze,
184 .thaw = pdc_thaw, 186 .thaw = pdc_sata_thaw,
185 .error_handler = pdc_sata_error_handler, 187 .error_handler = pdc_sata_error_handler,
186 .post_internal_cmd = pdc_post_internal_cmd, 188 .post_internal_cmd = pdc_post_internal_cmd,
187 .cable_detect = pdc_sata_cable_detect, 189 .cable_detect = pdc_sata_cable_detect,
@@ -205,8 +207,8 @@ static const struct ata_port_operations pdc_old_sata_ops = {
205 207
206 .qc_prep = pdc_qc_prep, 208 .qc_prep = pdc_qc_prep,
207 .qc_issue = pdc_qc_issue_prot, 209 .qc_issue = pdc_qc_issue_prot,
208 .freeze = pdc_freeze, 210 .freeze = pdc_sata_freeze,
209 .thaw = pdc_thaw, 211 .thaw = pdc_sata_thaw,
210 .error_handler = pdc_sata_error_handler, 212 .error_handler = pdc_sata_error_handler,
211 .post_internal_cmd = pdc_post_internal_cmd, 213 .post_internal_cmd = pdc_post_internal_cmd,
212 .cable_detect = pdc_sata_cable_detect, 214 .cable_detect = pdc_sata_cable_detect,
@@ -631,6 +633,41 @@ static void pdc_qc_prep(struct ata_queued_cmd *qc)
631 } 633 }
632} 634}
633 635
636static int pdc_is_sataii_tx4(unsigned long flags)
637{
638 const unsigned long mask = PDC_FLAG_GEN_II | PDC_FLAG_4_PORTS;
639 return (flags & mask) == mask;
640}
641
642static unsigned int pdc_port_no_to_ata_no(unsigned int port_no,
643 int is_sataii_tx4)
644{
645 static const unsigned char sataii_tx4_port_remap[4] = { 3, 1, 0, 2};
646 return is_sataii_tx4 ? sataii_tx4_port_remap[port_no] : port_no;
647}
648
649static unsigned int pdc_sata_nr_ports(const struct ata_port *ap)
650{
651 return (ap->flags & PDC_FLAG_4_PORTS) ? 4 : 2;
652}
653
654static unsigned int pdc_sata_ata_port_to_ata_no(const struct ata_port *ap)
655{
656 const struct ata_host *host = ap->host;
657 unsigned int nr_ports = pdc_sata_nr_ports(ap);
658 unsigned int i;
659
660 for(i = 0; i < nr_ports && host->ports[i] != ap; ++i)
661 ;
662 BUG_ON(i >= nr_ports);
663 return pdc_port_no_to_ata_no(i, pdc_is_sataii_tx4(ap->flags));
664}
665
666static unsigned int pdc_sata_hotplug_offset(const struct ata_port *ap)
667{
668 return (ap->flags & PDC_FLAG_GEN_II) ? PDC2_SATA_PLUG_CSR : PDC_SATA_PLUG_CSR;
669}
670
634static void pdc_freeze(struct ata_port *ap) 671static void pdc_freeze(struct ata_port *ap)
635{ 672{
636 void __iomem *mmio = ap->ioaddr.cmd_addr; 673 void __iomem *mmio = ap->ioaddr.cmd_addr;
@@ -643,6 +680,29 @@ static void pdc_freeze(struct ata_port *ap)
643 readl(mmio + PDC_CTLSTAT); /* flush */ 680 readl(mmio + PDC_CTLSTAT); /* flush */
644} 681}
645 682
683static void pdc_sata_freeze(struct ata_port *ap)
684{
685 struct ata_host *host = ap->host;
686 void __iomem *host_mmio = host->iomap[PDC_MMIO_BAR];
687 unsigned int hotplug_offset = pdc_sata_hotplug_offset(ap);
688 unsigned int ata_no = pdc_sata_ata_port_to_ata_no(ap);
689 u32 hotplug_status;
690
691 /* Disable hotplug events on this port.
692 *
693 * Locking:
694 * 1) hotplug register accesses must be serialised via host->lock
695 * 2) ap->lock == &ap->host->lock
696 * 3) ->freeze() and ->thaw() are called with ap->lock held
697 */
698 hotplug_status = readl(host_mmio + hotplug_offset);
699 hotplug_status |= 0x11 << (ata_no + 16);
700 writel(hotplug_status, host_mmio + hotplug_offset);
701 readl(host_mmio + hotplug_offset); /* flush */
702
703 pdc_freeze(ap);
704}
705
646static void pdc_thaw(struct ata_port *ap) 706static void pdc_thaw(struct ata_port *ap)
647{ 707{
648 void __iomem *mmio = ap->ioaddr.cmd_addr; 708 void __iomem *mmio = ap->ioaddr.cmd_addr;
@@ -658,6 +718,26 @@ static void pdc_thaw(struct ata_port *ap)
658 readl(mmio + PDC_CTLSTAT); /* flush */ 718 readl(mmio + PDC_CTLSTAT); /* flush */
659} 719}
660 720
721static void pdc_sata_thaw(struct ata_port *ap)
722{
723 struct ata_host *host = ap->host;
724 void __iomem *host_mmio = host->iomap[PDC_MMIO_BAR];
725 unsigned int hotplug_offset = pdc_sata_hotplug_offset(ap);
726 unsigned int ata_no = pdc_sata_ata_port_to_ata_no(ap);
727 u32 hotplug_status;
728
729 pdc_thaw(ap);
730
731 /* Enable hotplug events on this port.
732 * Locking: see pdc_sata_freeze().
733 */
734 hotplug_status = readl(host_mmio + hotplug_offset);
735 hotplug_status |= 0x11 << ata_no;
736 hotplug_status &= ~(0x11 << (ata_no + 16));
737 writel(hotplug_status, host_mmio + hotplug_offset);
738 readl(host_mmio + hotplug_offset); /* flush */
739}
740
661static void pdc_common_error_handler(struct ata_port *ap, ata_reset_fn_t hardreset) 741static void pdc_common_error_handler(struct ata_port *ap, ata_reset_fn_t hardreset)
662{ 742{
663 if (!(ap->pflags & ATA_PFLAG_FROZEN)) 743 if (!(ap->pflags & ATA_PFLAG_FROZEN))
@@ -765,19 +845,6 @@ static void pdc_irq_clear(struct ata_port *ap)
765 readl(mmio + PDC_INT_SEQMASK); 845 readl(mmio + PDC_INT_SEQMASK);
766} 846}
767 847
768static int pdc_is_sataii_tx4(unsigned long flags)
769{
770 const unsigned long mask = PDC_FLAG_GEN_II | PDC_FLAG_4_PORTS;
771 return (flags & mask) == mask;
772}
773
774static unsigned int pdc_port_no_to_ata_no(unsigned int port_no,
775 int is_sataii_tx4)
776{
777 static const unsigned char sataii_tx4_port_remap[4] = { 3, 1, 0, 2};
778 return is_sataii_tx4 ? sataii_tx4_port_remap[port_no] : port_no;
779}
780
781static irqreturn_t pdc_interrupt(int irq, void *dev_instance) 848static irqreturn_t pdc_interrupt(int irq, void *dev_instance)
782{ 849{
783 struct ata_host *host = dev_instance; 850 struct ata_host *host = dev_instance;
@@ -799,6 +866,8 @@ static irqreturn_t pdc_interrupt(int irq, void *dev_instance)
799 866
800 mmio_base = host->iomap[PDC_MMIO_BAR]; 867 mmio_base = host->iomap[PDC_MMIO_BAR];
801 868
869 spin_lock(&host->lock);
870
802 /* read and clear hotplug flags for all ports */ 871 /* read and clear hotplug flags for all ports */
803 if (host->ports[0]->flags & PDC_FLAG_GEN_II) 872 if (host->ports[0]->flags & PDC_FLAG_GEN_II)
804 hotplug_offset = PDC2_SATA_PLUG_CSR; 873 hotplug_offset = PDC2_SATA_PLUG_CSR;
@@ -814,11 +883,9 @@ static irqreturn_t pdc_interrupt(int irq, void *dev_instance)
814 883
815 if (mask == 0xffffffff && hotplug_status == 0) { 884 if (mask == 0xffffffff && hotplug_status == 0) {
816 VPRINTK("QUICK EXIT 2\n"); 885 VPRINTK("QUICK EXIT 2\n");
817 return IRQ_NONE; 886 goto done_irq;
818 } 887 }
819 888
820 spin_lock(&host->lock);
821
822 mask &= 0xffff; /* only 16 tags possible */ 889 mask &= 0xffff; /* only 16 tags possible */
823 if (mask == 0 && hotplug_status == 0) { 890 if (mask == 0 && hotplug_status == 0) {
824 VPRINTK("QUICK EXIT 3\n"); 891 VPRINTK("QUICK EXIT 3\n");