aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ata')
-rw-r--r--drivers/ata/Kconfig9
-rw-r--r--drivers/ata/Makefile1
-rw-r--r--drivers/ata/ahci.c100
-rw-r--r--drivers/ata/libata-acpi.c104
-rw-r--r--drivers/ata/libata-core.c22
-rw-r--r--drivers/ata/libata-eh.c10
-rw-r--r--drivers/ata/libata-scsi.c19
-rw-r--r--drivers/ata/libata-sff.c36
-rw-r--r--drivers/ata/libata.h1
-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_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_svw.c77
16 files changed, 603 insertions, 108 deletions
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index ba8f7f4dfa11..e469647330de 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -538,6 +538,15 @@ config PATA_RADISYS
538 538
539 If unsure, say N. 539 If unsure, say N.
540 540
541config PATA_RB500
542 tristate "RouterBoard 500 PATA CompactFlash support"
543 depends on MIKROTIK_RB500
544 help
545 This option enables support for the RouterBoard 500
546 PATA CompactFlash controller.
547
548 If unsure, say N.
549
541config PATA_RZ1000 550config PATA_RZ1000
542 tristate "PC Tech RZ1000 PATA support" 551 tristate "PC Tech RZ1000 PATA support"
543 depends on PCI 552 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..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
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,7 @@ 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_SECT255 | AHCI_HFLAG_NO_PMP),
429 .flags = AHCI_FLAG_COMMON, 437 .flags = AHCI_FLAG_COMMON,
430 .link_flags = AHCI_LFLAG_COMMON, 438 .link_flags = AHCI_LFLAG_COMMON,
431 .pio_mask = 0x1f, /* pio0-4 */ 439 .pio_mask = 0x1f, /* pio0-4 */
@@ -563,6 +571,18 @@ static const struct pci_device_id ahci_pci_tbl[] = {
563 { PCI_VDEVICE(NVIDIA, 0x0abd), board_ahci }, /* MCP79 */ 571 { PCI_VDEVICE(NVIDIA, 0x0abd), board_ahci }, /* MCP79 */
564 { PCI_VDEVICE(NVIDIA, 0x0abe), board_ahci }, /* MCP79 */ 572 { PCI_VDEVICE(NVIDIA, 0x0abe), board_ahci }, /* MCP79 */
565 { 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 */
566 586
567 /* SiS */ 587 /* SiS */
568 { PCI_VDEVICE(SI, 0x1184), board_ahci }, /* SiS 966 */ 588 { PCI_VDEVICE(SI, 0x1184), board_ahci }, /* SiS 966 */
@@ -571,6 +591,7 @@ static const struct pci_device_id ahci_pci_tbl[] = {
571 591
572 /* Marvell */ 592 /* Marvell */
573 { 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 */
574 595
575 /* Generic, PCI class code for AHCI */ 596 /* Generic, PCI class code for AHCI */
576 { 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,
@@ -645,6 +666,7 @@ static void ahci_save_initial_config(struct pci_dev *pdev,
645 void __iomem *mmio = pcim_iomap_table(pdev)[AHCI_PCI_BAR]; 666 void __iomem *mmio = pcim_iomap_table(pdev)[AHCI_PCI_BAR];
646 u32 cap, port_map; 667 u32 cap, port_map;
647 int i; 668 int i;
669 int mv;
648 670
649 /* make sure AHCI mode is enabled before accessing CAP */ 671 /* make sure AHCI mode is enabled before accessing CAP */
650 ahci_enable_ahci(mmio); 672 ahci_enable_ahci(mmio);
@@ -668,7 +690,7 @@ static void ahci_save_initial_config(struct pci_dev *pdev,
668 cap &= ~HOST_CAP_NCQ; 690 cap &= ~HOST_CAP_NCQ;
669 } 691 }
670 692
671 if ((cap && HOST_CAP_PMP) && (hpriv->flags & AHCI_HFLAG_NO_PMP)) { 693 if ((cap & HOST_CAP_PMP) && (hpriv->flags & AHCI_HFLAG_NO_PMP)) {
672 dev_printk(KERN_INFO, &pdev->dev, 694 dev_printk(KERN_INFO, &pdev->dev,
673 "controller can't do PMP, turning off CAP_PMP\n"); 695 "controller can't do PMP, turning off CAP_PMP\n");
674 cap &= ~HOST_CAP_PMP; 696 cap &= ~HOST_CAP_PMP;
@@ -680,12 +702,16 @@ static void ahci_save_initial_config(struct pci_dev *pdev,
680 * presence register, as bit 4 (counting from 0) 702 * presence register, as bit 4 (counting from 0)
681 */ 703 */
682 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;
683 dev_printk(KERN_ERR, &pdev->dev, 709 dev_printk(KERN_ERR, &pdev->dev,
684 "MV_AHCI HACK: port_map %x -> %x\n", 710 "MV_AHCI HACK: port_map %x -> %x\n",
685 hpriv->port_map, 711 port_map,
686 hpriv->port_map & 0xf); 712 port_map & mv);
687 713
688 port_map &= 0xf; 714 port_map &= mv;
689 } 715 }
690 716
691 /* cross check port_map and cap.n_ports */ 717 /* cross check port_map and cap.n_ports */
@@ -1072,29 +1098,35 @@ static int ahci_reset_controller(struct ata_host *host)
1072 ahci_enable_ahci(mmio); 1098 ahci_enable_ahci(mmio);
1073 1099
1074 /* global controller reset */ 1100 /* global controller reset */
1075 tmp = readl(mmio + HOST_CTL); 1101 if (!ahci_skip_host_reset) {
1076 if ((tmp & HOST_RESET) == 0) { 1102 tmp = readl(mmio + HOST_CTL);
1077 writel(tmp | HOST_RESET, mmio + HOST_CTL); 1103 if ((tmp & HOST_RESET) == 0) {
1078 readl(mmio + HOST_CTL); /* flush */ 1104 writel(tmp | HOST_RESET, mmio + HOST_CTL);
1079 } 1105 readl(mmio + HOST_CTL); /* flush */
1106 }
1080 1107
1081 /* reset must complete within 1 second, or 1108 /* reset must complete within 1 second, or
1082 * the hardware should be considered fried. 1109 * the hardware should be considered fried.
1083 */ 1110 */
1084 ssleep(1); 1111 ssleep(1);
1085 1112
1086 tmp = readl(mmio + HOST_CTL); 1113 tmp = readl(mmio + HOST_CTL);
1087 if (tmp & HOST_RESET) { 1114 if (tmp & HOST_RESET) {
1088 dev_printk(KERN_ERR, host->dev, 1115 dev_printk(KERN_ERR, host->dev,
1089 "controller reset failed (0x%x)\n", tmp); 1116 "controller reset failed (0x%x)\n", tmp);
1090 return -EIO; 1117 return -EIO;
1091 } 1118 }
1092 1119
1093 /* turn on AHCI mode */ 1120 /* turn on AHCI mode */
1094 ahci_enable_ahci(mmio); 1121 ahci_enable_ahci(mmio);
1095 1122
1096 /* some registers might be cleared on reset. restore initial values */ 1123 /* Some registers might be cleared on reset. Restore
1097 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");
1098 1130
1099 if (pdev->vendor == PCI_VENDOR_ID_INTEL) { 1131 if (pdev->vendor == PCI_VENDOR_ID_INTEL) {
1100 u16 tmp16; 1132 u16 tmp16;
@@ -1146,9 +1178,14 @@ static void ahci_init_controller(struct ata_host *host)
1146 int i; 1178 int i;
1147 void __iomem *port_mmio; 1179 void __iomem *port_mmio;
1148 u32 tmp; 1180 u32 tmp;
1181 int mv;
1149 1182
1150 if (hpriv->flags & AHCI_HFLAG_MV_PATA) { 1183 if (hpriv->flags & AHCI_HFLAG_MV_PATA) {
1151 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);
1152 1189
1153 writel(0, port_mmio + PORT_IRQ_MASK); 1190 writel(0, port_mmio + PORT_IRQ_MASK);
1154 1191
@@ -1176,6 +1213,14 @@ static void ahci_init_controller(struct ata_host *host)
1176 VPRINTK("HOST_CTL 0x%x\n", tmp); 1213 VPRINTK("HOST_CTL 0x%x\n", tmp);
1177} 1214}
1178 1215
1216static void ahci_dev_config(struct ata_device *dev)
1217{
1218 struct ahci_host_priv *hpriv = dev->link->ap->host->private_data;
1219
1220 if (hpriv->flags & AHCI_HFLAG_SECT255)
1221 dev->max_sectors = 255;
1222}
1223
1179static unsigned int ahci_dev_classify(struct ata_port *ap) 1224static unsigned int ahci_dev_classify(struct ata_port *ap)
1180{ 1225{
1181 void __iomem *port_mmio = ahci_port_base(ap); 1226 void __iomem *port_mmio = ahci_port_base(ap);
@@ -2217,7 +2262,10 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2217 if (rc) 2262 if (rc)
2218 return rc; 2263 return rc;
2219 2264
2220 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);
2221 if (rc == -EBUSY) 2269 if (rc == -EBUSY)
2222 pcim_pin_device(pdev); 2270 pcim_pin_device(pdev);
2223 if (rc) 2271 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 fbc24358ada0..4bbe31f98ef8 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -106,14 +106,15 @@ 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;
113module_param(atapi_enabled, int, 0444); 114module_param(atapi_enabled, int, 0444);
114MODULE_PARM_DESC(atapi_enabled, "Enable discovery of ATAPI devices (0=off, 1=on)"); 115MODULE_PARM_DESC(atapi_enabled, "Enable discovery of ATAPI devices (0=off, 1=on)");
115 116
116int atapi_dmadir = 0; 117static int atapi_dmadir = 0;
117module_param(atapi_dmadir, int, 0444); 118module_param(atapi_dmadir, int, 0444);
118MODULE_PARM_DESC(atapi_dmadir, "Enable ATAPI DMADIR bridge support (0=off, 1=on)"); 119MODULE_PARM_DESC(atapi_dmadir, "Enable ATAPI DMADIR bridge support (0=off, 1=on)");
119 120
@@ -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:
@@ -2253,12 +2254,12 @@ int ata_dev_configure(struct ata_device *dev)
2253 2254
2254 if (!ata_dev_enabled(dev) && ata_msg_info(ap)) { 2255 if (!ata_dev_enabled(dev) && ata_msg_info(ap)) {
2255 ata_dev_printk(dev, KERN_INFO, "%s: ENTER/EXIT -- nodev\n", 2256 ata_dev_printk(dev, KERN_INFO, "%s: ENTER/EXIT -- nodev\n",
2256 __FUNCTION__); 2257 __func__);
2257 return 0; 2258 return 0;
2258 } 2259 }
2259 2260
2260 if (ata_msg_probe(ap)) 2261 if (ata_msg_probe(ap))
2261 ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER\n", __FUNCTION__); 2262 ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER\n", __func__);
2262 2263
2263 /* set horkage */ 2264 /* set horkage */
2264 dev->horkage |= ata_dev_blacklisted(dev); 2265 dev->horkage |= ata_dev_blacklisted(dev);
@@ -2279,7 +2280,7 @@ int ata_dev_configure(struct ata_device *dev)
2279 ata_dev_printk(dev, KERN_DEBUG, 2280 ata_dev_printk(dev, KERN_DEBUG,
2280 "%s: cfg 49:%04x 82:%04x 83:%04x 84:%04x " 2281 "%s: cfg 49:%04x 82:%04x 83:%04x 84:%04x "
2281 "85:%04x 86:%04x 87:%04x 88:%04x\n", 2282 "85:%04x 86:%04x 87:%04x 88:%04x\n",
2282 __FUNCTION__, 2283 __func__,
2283 id[49], id[82], id[83], id[84], 2284 id[49], id[82], id[83], id[84],
2284 id[85], id[86], id[87], id[88]); 2285 id[85], id[86], id[87], id[88]);
2285 2286
@@ -2511,13 +2512,13 @@ int ata_dev_configure(struct ata_device *dev)
2511 2512
2512 if (ata_msg_probe(ap)) 2513 if (ata_msg_probe(ap))
2513 ata_dev_printk(dev, KERN_DEBUG, "%s: EXIT, drv_stat = 0x%x\n", 2514 ata_dev_printk(dev, KERN_DEBUG, "%s: EXIT, drv_stat = 0x%x\n",
2514 __FUNCTION__, ata_chk_status(ap)); 2515 __func__, ata_chk_status(ap));
2515 return 0; 2516 return 0;
2516 2517
2517err_out_nosup: 2518err_out_nosup:
2518 if (ata_msg_probe(ap)) 2519 if (ata_msg_probe(ap))
2519 ata_dev_printk(dev, KERN_DEBUG, 2520 ata_dev_printk(dev, KERN_DEBUG,
2520 "%s: EXIT, err\n", __FUNCTION__); 2521 "%s: EXIT, err\n", __func__);
2521 return rc; 2522 return rc;
2522} 2523}
2523 2524
@@ -6567,6 +6568,8 @@ int ata_host_suspend(struct ata_host *host, pm_message_t mesg)
6567 ata_lpm_enable(host); 6568 ata_lpm_enable(host);
6568 6569
6569 rc = ata_host_request_pm(host, mesg, 0, ATA_EHI_QUIET, 1); 6570 rc = ata_host_request_pm(host, mesg, 0, ATA_EHI_QUIET, 1);
6571 if (rc == 0)
6572 host->dev->power.power_state = mesg;
6570 return rc; 6573 return rc;
6571} 6574}
6572 6575
@@ -6585,6 +6588,7 @@ void ata_host_resume(struct ata_host *host)
6585{ 6588{
6586 ata_host_request_pm(host, PMSG_ON, ATA_EH_SOFTRESET, 6589 ata_host_request_pm(host, PMSG_ON, ATA_EH_SOFTRESET,
6587 ATA_EHI_NO_AUTOPSY | ATA_EHI_QUIET, 0); 6590 ATA_EHI_NO_AUTOPSY | ATA_EHI_QUIET, 0);
6591 host->dev->power.power_state = PMSG_ON;
6588 6592
6589 /* reenable link pm */ 6593 /* reenable link pm */
6590 ata_lpm_disable(host); 6594 ata_lpm_disable(host);
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 0562b0a49f3b..8f0e8f2bc628 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -862,9 +862,10 @@ static int ata_scsi_dev_config(struct scsi_device *sdev,
862 struct request_queue *q = sdev->request_queue; 862 struct request_queue *q = sdev->request_queue;
863 void *buf; 863 void *buf;
864 864
865 /* set the min alignment */ 865 /* set the min alignment and padding */
866 blk_queue_update_dma_alignment(sdev->request_queue, 866 blk_queue_update_dma_alignment(sdev->request_queue,
867 ATA_DMA_PAD_SZ - 1); 867 ATA_DMA_PAD_SZ - 1);
868 blk_queue_dma_pad(sdev->request_queue, ATA_DMA_PAD_SZ - 1);
868 869
869 /* configure draining */ 870 /* configure draining */
870 buf = kmalloc(ATAPI_MAX_DRAIN, q->bounce_gfp | GFP_KERNEL); 871 buf = kmalloc(ATAPI_MAX_DRAIN, q->bounce_gfp | GFP_KERNEL);
@@ -1694,12 +1695,17 @@ void ata_scsi_rbuf_fill(struct ata_scsi_args *args,
1694 u8 *rbuf; 1695 u8 *rbuf;
1695 unsigned int buflen, rc; 1696 unsigned int buflen, rc;
1696 struct scsi_cmnd *cmd = args->cmd; 1697 struct scsi_cmnd *cmd = args->cmd;
1698 unsigned long flags;
1699
1700 local_irq_save(flags);
1697 1701
1698 buflen = ata_scsi_rbuf_get(cmd, &rbuf); 1702 buflen = ata_scsi_rbuf_get(cmd, &rbuf);
1699 memset(rbuf, 0, buflen); 1703 memset(rbuf, 0, buflen);
1700 rc = actor(args, rbuf, buflen); 1704 rc = actor(args, rbuf, buflen);
1701 ata_scsi_rbuf_put(cmd, rbuf); 1705 ata_scsi_rbuf_put(cmd, rbuf);
1702 1706
1707 local_irq_restore(flags);
1708
1703 if (rc == 0) 1709 if (rc == 0)
1704 cmd->result = SAM_STAT_GOOD; 1710 cmd->result = SAM_STAT_GOOD;
1705 args->done(cmd); 1711 args->done(cmd);
@@ -2473,6 +2479,9 @@ static void atapi_qc_complete(struct ata_queued_cmd *qc)
2473 if ((scsicmd[0] == INQUIRY) && ((scsicmd[1] & 0x03) == 0)) { 2479 if ((scsicmd[0] == INQUIRY) && ((scsicmd[1] & 0x03) == 0)) {
2474 u8 *buf = NULL; 2480 u8 *buf = NULL;
2475 unsigned int buflen; 2481 unsigned int buflen;
2482 unsigned long flags;
2483
2484 local_irq_save(flags);
2476 2485
2477 buflen = ata_scsi_rbuf_get(cmd, &buf); 2486 buflen = ata_scsi_rbuf_get(cmd, &buf);
2478 2487
@@ -2490,6 +2499,8 @@ static void atapi_qc_complete(struct ata_queued_cmd *qc)
2490 } 2499 }
2491 2500
2492 ata_scsi_rbuf_put(cmd, buf); 2501 ata_scsi_rbuf_put(cmd, buf);
2502
2503 local_irq_restore(flags);
2493 } 2504 }
2494 2505
2495 cmd->result = SAM_STAT_GOOD; 2506 cmd->result = SAM_STAT_GOOD;
@@ -2528,7 +2539,7 @@ static unsigned int atapi_xlat(struct ata_queued_cmd *qc)
2528 } 2539 }
2529 2540
2530 qc->tf.command = ATA_CMD_PACKET; 2541 qc->tf.command = ATA_CMD_PACKET;
2531 qc->nbytes = scsi_bufflen(scmd); 2542 qc->nbytes = scsi_bufflen(scmd) + scmd->request->extra_len;
2532 2543
2533 /* check whether ATAPI DMA is safe */ 2544 /* check whether ATAPI DMA is safe */
2534 if (!using_pio && ata_check_atapi_dma(qc)) 2545 if (!using_pio && ata_check_atapi_dma(qc))
@@ -2539,7 +2550,7 @@ static unsigned int atapi_xlat(struct ata_queued_cmd *qc)
2539 * want to set it properly, and for DMA where it is 2550 * want to set it properly, and for DMA where it is
2540 * effectively meaningless. 2551 * effectively meaningless.
2541 */ 2552 */
2542 nbytes = min(scmd->request->raw_data_len, (unsigned int)63 * 1024); 2553 nbytes = min(scmd->request->data_len, (unsigned int)63 * 1024);
2543 2554
2544 /* Most ATAPI devices which honor transfer chunk size don't 2555 /* Most ATAPI devices which honor transfer chunk size don't
2545 * behave according to the spec when odd chunk size which 2556 * behave according to the spec when odd chunk size which
@@ -2865,7 +2876,7 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc)
2865 * TODO: find out if we need to do more here to 2876 * TODO: find out if we need to do more here to
2866 * cover scatter/gather case. 2877 * cover scatter/gather case.
2867 */ 2878 */
2868 qc->nbytes = scsi_bufflen(scmd); 2879 qc->nbytes = scsi_bufflen(scmd) + scmd->request->extra_len;
2869 2880
2870 /* request result TF and be quiet about device error */ 2881 /* request result TF and be quiet about device error */
2871 qc->flags |= ATA_QCFLAG_RESULT_TF | ATA_QCFLAG_QUIET; 2882 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/libata.h b/drivers/ata/libata.h
index 6036dedfe377..aa884f71a12a 100644
--- a/drivers/ata/libata.h
+++ b/drivers/ata/libata.h
@@ -56,7 +56,6 @@ enum {
56extern unsigned int ata_print_id; 56extern unsigned int ata_print_id;
57extern struct workqueue_struct *ata_aux_wq; 57extern struct workqueue_struct *ata_aux_wq;
58extern int atapi_enabled; 58extern int atapi_enabled;
59extern int atapi_dmadir;
60extern int atapi_passthru16; 59extern int atapi_passthru16;
61extern int libata_fua; 60extern int libata_fua;
62extern int libata_noacpi; 61extern int libata_noacpi;
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_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_svw.c b/drivers/ata/sata_svw.c
index 69f651e0bc98..840d1c4a7850 100644
--- a/drivers/ata/sata_svw.c
+++ b/drivers/ata/sata_svw.c
@@ -45,6 +45,8 @@
45#include <linux/interrupt.h> 45#include <linux/interrupt.h>
46#include <linux/device.h> 46#include <linux/device.h>
47#include <scsi/scsi_host.h> 47#include <scsi/scsi_host.h>
48#include <scsi/scsi_cmnd.h>
49#include <scsi/scsi.h>
48#include <linux/libata.h> 50#include <linux/libata.h>
49 51
50#ifdef CONFIG_PPC_OF 52#ifdef CONFIG_PPC_OF
@@ -59,6 +61,7 @@ enum {
59 /* ap->flags bits */ 61 /* ap->flags bits */
60 K2_FLAG_SATA_8_PORTS = (1 << 24), 62 K2_FLAG_SATA_8_PORTS = (1 << 24),
61 K2_FLAG_NO_ATAPI_DMA = (1 << 25), 63 K2_FLAG_NO_ATAPI_DMA = (1 << 25),
64 K2_FLAG_BAR_POS_3 = (1 << 26),
62 65
63 /* Taskfile registers offsets */ 66 /* Taskfile registers offsets */
64 K2_SATA_TF_CMD_OFFSET = 0x00, 67 K2_SATA_TF_CMD_OFFSET = 0x00,
@@ -88,8 +91,10 @@ enum {
88 /* Port stride */ 91 /* Port stride */
89 K2_SATA_PORT_OFFSET = 0x100, 92 K2_SATA_PORT_OFFSET = 0x100,
90 93
91 board_svw4 = 0, 94 chip_svw4 = 0,
92 board_svw8 = 1, 95 chip_svw8 = 1,
96 chip_svw42 = 2, /* bar 3 */
97 chip_svw43 = 3, /* bar 5 */
93}; 98};
94 99
95static u8 k2_stat_check_status(struct ata_port *ap); 100static u8 k2_stat_check_status(struct ata_port *ap);
@@ -97,10 +102,25 @@ static u8 k2_stat_check_status(struct ata_port *ap);
97 102
98static int k2_sata_check_atapi_dma(struct ata_queued_cmd *qc) 103static int k2_sata_check_atapi_dma(struct ata_queued_cmd *qc)
99{ 104{
105 u8 cmnd = qc->scsicmd->cmnd[0];
106
100 if (qc->ap->flags & K2_FLAG_NO_ATAPI_DMA) 107 if (qc->ap->flags & K2_FLAG_NO_ATAPI_DMA)
101 return -1; /* ATAPI DMA not supported */ 108 return -1; /* ATAPI DMA not supported */
109 else {
110 switch (cmnd) {
111 case READ_10:
112 case READ_12:
113 case READ_16:
114 case WRITE_10:
115 case WRITE_12:
116 case WRITE_16:
117 return 0;
118
119 default:
120 return -1;
121 }
102 122
103 return 0; 123 }
104} 124}
105 125
106static int k2_sata_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val) 126static int k2_sata_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val)
@@ -354,7 +374,7 @@ static const struct ata_port_operations k2_sata_ops = {
354}; 374};
355 375
356static const struct ata_port_info k2_port_info[] = { 376static const struct ata_port_info k2_port_info[] = {
357 /* board_svw4 */ 377 /* chip_svw4 */
358 { 378 {
359 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 379 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
360 ATA_FLAG_MMIO | K2_FLAG_NO_ATAPI_DMA, 380 ATA_FLAG_MMIO | K2_FLAG_NO_ATAPI_DMA,
@@ -363,7 +383,7 @@ static const struct ata_port_info k2_port_info[] = {
363 .udma_mask = ATA_UDMA6, 383 .udma_mask = ATA_UDMA6,
364 .port_ops = &k2_sata_ops, 384 .port_ops = &k2_sata_ops,
365 }, 385 },
366 /* board_svw8 */ 386 /* chip_svw8 */
367 { 387 {
368 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 388 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
369 ATA_FLAG_MMIO | K2_FLAG_NO_ATAPI_DMA | 389 ATA_FLAG_MMIO | K2_FLAG_NO_ATAPI_DMA |
@@ -373,6 +393,24 @@ static const struct ata_port_info k2_port_info[] = {
373 .udma_mask = ATA_UDMA6, 393 .udma_mask = ATA_UDMA6,
374 .port_ops = &k2_sata_ops, 394 .port_ops = &k2_sata_ops,
375 }, 395 },
396 /* chip_svw42 */
397 {
398 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
399 ATA_FLAG_MMIO | K2_FLAG_BAR_POS_3,
400 .pio_mask = 0x1f,
401 .mwdma_mask = 0x07,
402 .udma_mask = ATA_UDMA6,
403 .port_ops = &k2_sata_ops,
404 },
405 /* chip_svw43 */
406 {
407 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
408 ATA_FLAG_MMIO,
409 .pio_mask = 0x1f,
410 .mwdma_mask = 0x07,
411 .udma_mask = ATA_UDMA6,
412 .port_ops = &k2_sata_ops,
413 },
376}; 414};
377 415
378static void k2_sata_setup_port(struct ata_ioports *port, void __iomem *base) 416static void k2_sata_setup_port(struct ata_ioports *port, void __iomem *base)
@@ -402,7 +440,7 @@ static int k2_sata_init_one(struct pci_dev *pdev, const struct pci_device_id *en
402 { &k2_port_info[ent->driver_data], NULL }; 440 { &k2_port_info[ent->driver_data], NULL };
403 struct ata_host *host; 441 struct ata_host *host;
404 void __iomem *mmio_base; 442 void __iomem *mmio_base;
405 int n_ports, i, rc; 443 int n_ports, i, rc, bar_pos;
406 444
407 if (!printed_version++) 445 if (!printed_version++)
408 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); 446 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
@@ -416,6 +454,9 @@ static int k2_sata_init_one(struct pci_dev *pdev, const struct pci_device_id *en
416 if (!host) 454 if (!host)
417 return -ENOMEM; 455 return -ENOMEM;
418 456
457 bar_pos = 5;
458 if (ppi[0]->flags & K2_FLAG_BAR_POS_3)
459 bar_pos = 3;
419 /* 460 /*
420 * If this driver happens to only be useful on Apple's K2, then 461 * If this driver happens to only be useful on Apple's K2, then
421 * we should check that here as it has a normal Serverworks ID 462 * we should check that here as it has a normal Serverworks ID
@@ -428,17 +469,23 @@ static int k2_sata_init_one(struct pci_dev *pdev, const struct pci_device_id *en
428 * Check if we have resources mapped at all (second function may 469 * Check if we have resources mapped at all (second function may
429 * have been disabled by firmware) 470 * have been disabled by firmware)
430 */ 471 */
431 if (pci_resource_len(pdev, 5) == 0) 472 if (pci_resource_len(pdev, bar_pos) == 0) {
473 /* In IDE mode we need to pin the device to ensure that
474 pcim_release does not clear the busmaster bit in config
475 space, clearing causes busmaster DMA to fail on
476 ports 3 & 4 */
477 pcim_pin_device(pdev);
432 return -ENODEV; 478 return -ENODEV;
479 }
433 480
434 /* Request and iomap PCI regions */ 481 /* Request and iomap PCI regions */
435 rc = pcim_iomap_regions(pdev, 1 << 5, DRV_NAME); 482 rc = pcim_iomap_regions(pdev, 1 << bar_pos, DRV_NAME);
436 if (rc == -EBUSY) 483 if (rc == -EBUSY)
437 pcim_pin_device(pdev); 484 pcim_pin_device(pdev);
438 if (rc) 485 if (rc)
439 return rc; 486 return rc;
440 host->iomap = pcim_iomap_table(pdev); 487 host->iomap = pcim_iomap_table(pdev);
441 mmio_base = host->iomap[5]; 488 mmio_base = host->iomap[bar_pos];
442 489
443 /* different controllers have different number of ports - currently 4 or 8 */ 490 /* different controllers have different number of ports - currently 4 or 8 */
444 /* All ports are on the same function. Multi-function device is no 491 /* All ports are on the same function. Multi-function device is no
@@ -483,11 +530,13 @@ static int k2_sata_init_one(struct pci_dev *pdev, const struct pci_device_id *en
483 * controller 530 * controller
484 * */ 531 * */
485static const struct pci_device_id k2_sata_pci_tbl[] = { 532static const struct pci_device_id k2_sata_pci_tbl[] = {
486 { PCI_VDEVICE(SERVERWORKS, 0x0240), board_svw4 }, 533 { PCI_VDEVICE(SERVERWORKS, 0x0240), chip_svw4 },
487 { PCI_VDEVICE(SERVERWORKS, 0x0241), board_svw4 }, 534 { PCI_VDEVICE(SERVERWORKS, 0x0241), chip_svw4 },
488 { PCI_VDEVICE(SERVERWORKS, 0x0242), board_svw8 }, 535 { PCI_VDEVICE(SERVERWORKS, 0x0242), chip_svw8 },
489 { PCI_VDEVICE(SERVERWORKS, 0x024a), board_svw4 }, 536 { PCI_VDEVICE(SERVERWORKS, 0x024a), chip_svw4 },
490 { PCI_VDEVICE(SERVERWORKS, 0x024b), board_svw4 }, 537 { PCI_VDEVICE(SERVERWORKS, 0x024b), chip_svw4 },
538 { PCI_VDEVICE(SERVERWORKS, 0x0410), chip_svw42 },
539 { PCI_VDEVICE(SERVERWORKS, 0x0411), chip_svw43 },
491 540
492 { } 541 { }
493}; 542};