aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--MAINTAINERS7
-rw-r--r--drivers/ata/Kconfig18
-rw-r--r--drivers/ata/Makefile1
-rw-r--r--drivers/ata/ahci.c8
-rw-r--r--drivers/ata/ahci.h6
-rw-r--r--drivers/ata/ata_generic.c2
-rw-r--r--drivers/ata/ata_piix.c2
-rw-r--r--drivers/ata/libata-acpi.c3
-rw-r--r--drivers/ata/libata-core.c54
-rw-r--r--drivers/ata/libata-eh.c60
-rw-r--r--drivers/ata/libata-scsi.c15
-rw-r--r--drivers/ata/libata-sff.c17
-rw-r--r--drivers/ata/libata.h1
-rw-r--r--drivers/ata/pata_acpi.c2
-rw-r--r--drivers/ata/pata_arasan_cf.c983
-rw-r--r--drivers/ata/pata_at32.c2
-rw-r--r--drivers/ata/pata_bf54x.c4
-rw-r--r--drivers/ata/pata_hpt366.c7
-rw-r--r--drivers/ata/pata_hpt37x.c23
-rw-r--r--drivers/ata/pata_hpt3x2n.c13
-rw-r--r--drivers/ata/pata_hpt3x3.c2
-rw-r--r--drivers/ata/pata_it821x.c4
-rw-r--r--drivers/ata/pata_ixp4xx_cf.c2
-rw-r--r--drivers/ata/pata_macio.c3
-rw-r--r--drivers/ata/pata_marvell.c2
-rw-r--r--drivers/ata/pata_ninja32.c2
-rw-r--r--drivers/ata/pata_octeon_cf.c3
-rw-r--r--drivers/ata/pata_palmld.c2
-rw-r--r--drivers/ata/pata_pcmcia.c2
-rw-r--r--drivers/ata/pata_pdc2027x.c6
-rw-r--r--drivers/ata/pata_pxa.c1
-rw-r--r--drivers/ata/pata_rb532_cf.c1
-rw-r--r--drivers/ata/pata_samsung_cf.c1
-rw-r--r--drivers/ata/pata_scc.c2
-rw-r--r--drivers/ata/pata_sis.c2
-rw-r--r--drivers/ata/pdc_adma.c4
-rw-r--r--drivers/ata/sata_dwc_460ex.c75
-rw-r--r--drivers/ata/sata_fsl.c22
-rw-r--r--drivers/ata/sata_mv.c3
-rw-r--r--drivers/ata/sata_nv.c14
-rw-r--r--drivers/ata/sata_promise.c4
-rw-r--r--drivers/ata/sata_qstor.c3
-rw-r--r--drivers/ata/sata_sil.c3
-rw-r--r--drivers/ata/sata_sil24.c3
-rw-r--r--drivers/ata/sata_sis.c2
-rw-r--r--drivers/ata/sata_svw.c12
-rw-r--r--drivers/ata/sata_sx4.c5
-rw-r--r--drivers/ata/sata_uli.c3
-rw-r--r--drivers/ata/sata_via.c9
-rw-r--r--drivers/ata/sata_vsc.c3
-rw-r--r--drivers/scsi/ipr.c9
-rw-r--r--drivers/scsi/libsas/sas_ata.c94
-rw-r--r--drivers/scsi/libsas/sas_scsi_host.c14
-rw-r--r--include/linux/ata.h163
-rw-r--r--include/linux/libata.h10
-rw-r--r--include/linux/pata_arasan_cf_data.h49
-rw-r--r--include/scsi/sas_ata.h22
57 files changed, 1521 insertions, 268 deletions
diff --git a/MAINTAINERS b/MAINTAINERS
index f1bc3dc6b369..2a2cddd2f88c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -557,6 +557,13 @@ S: Maintained
557F: drivers/net/appletalk/ 557F: drivers/net/appletalk/
558F: net/appletalk/ 558F: net/appletalk/
559 559
560ARASAN COMPACT FLASH PATA CONTROLLER
561M: Viresh Kumar <viresh.kumar@st.com>
562L: linux-ide@vger.kernel.org
563S: Maintained
564F: include/linux/pata_arasan_cf_data.h
565F: drivers/ata/pata_arasan_cf.c
566
560ARC FRAMEBUFFER DRIVER 567ARC FRAMEBUFFER DRIVER
561M: Jaya Kumar <jayalk@intworks.biz> 568M: Jaya Kumar <jayalk@intworks.biz>
562S: Maintained 569S: Maintained
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index c2328aed0836..75afa75a515e 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -202,6 +202,18 @@ config SATA_DWC
202 202
203 If unsure, say N. 203 If unsure, say N.
204 204
205config SATA_DWC_DEBUG
206 bool "Debugging driver version"
207 depends on SATA_DWC
208 help
209 This option enables debugging output in the driver.
210
211config SATA_DWC_VDEBUG
212 bool "Verbose debug output"
213 depends on SATA_DWC_DEBUG
214 help
215 This option enables the taskfile dumping and NCQ debugging.
216
205config SATA_MV 217config SATA_MV
206 tristate "Marvell SATA support" 218 tristate "Marvell SATA support"
207 help 219 help
@@ -299,6 +311,12 @@ config PATA_AMD
299 311
300 If unsure, say N. 312 If unsure, say N.
301 313
314config PATA_ARASAN_CF
315 tristate "ARASAN CompactFlash PATA Controller Support"
316 select DMA_ENGINE
317 help
318 Say Y here to support the ARASAN CompactFlash PATA controller
319
302config PATA_ARTOP 320config PATA_ARTOP
303 tristate "ARTOP 6210/6260 PATA support" 321 tristate "ARTOP 6210/6260 PATA support"
304 depends on PCI 322 depends on PCI
diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile
index 27291aad6ca7..8ac64e1aa051 100644
--- a/drivers/ata/Makefile
+++ b/drivers/ata/Makefile
@@ -12,6 +12,7 @@ obj-$(CONFIG_SATA_DWC) += sata_dwc_460ex.o
12 12
13# SFF w/ custom DMA 13# SFF w/ custom DMA
14obj-$(CONFIG_PDC_ADMA) += pdc_adma.o 14obj-$(CONFIG_PDC_ADMA) += pdc_adma.o
15obj-$(CONFIG_PATA_ARASAN_CF) += pata_arasan_cf.o
15obj-$(CONFIG_PATA_OCTEON_CF) += pata_octeon_cf.o 16obj-$(CONFIG_PATA_OCTEON_CF) += pata_octeon_cf.o
16obj-$(CONFIG_SATA_QSTOR) += sata_qstor.o 17obj-$(CONFIG_SATA_QSTOR) += sata_qstor.o
17obj-$(CONFIG_SATA_SX4) += sata_sx4.o 18obj-$(CONFIG_SATA_SX4) += sata_sx4.o
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index b8d96ce37fc9..e62f693be8ea 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -175,8 +175,7 @@ static const struct ata_port_info ahci_port_info[] = {
175 { 175 {
176 AHCI_HFLAGS (AHCI_HFLAG_NO_NCQ | AHCI_HFLAG_NO_MSI | 176 AHCI_HFLAGS (AHCI_HFLAG_NO_NCQ | AHCI_HFLAG_NO_MSI |
177 AHCI_HFLAG_MV_PATA | AHCI_HFLAG_NO_PMP), 177 AHCI_HFLAG_MV_PATA | AHCI_HFLAG_NO_PMP),
178 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 178 .flags = ATA_FLAG_SATA | ATA_FLAG_PIO_DMA,
179 ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA,
180 .pio_mask = ATA_PIO4, 179 .pio_mask = ATA_PIO4,
181 .udma_mask = ATA_UDMA6, 180 .udma_mask = ATA_UDMA6,
182 .port_ops = &ahci_ops, 181 .port_ops = &ahci_ops,
@@ -260,6 +259,7 @@ static const struct pci_device_id ahci_pci_tbl[] = {
260 { PCI_VDEVICE(INTEL, 0x1d02), board_ahci }, /* PBG AHCI */ 259 { PCI_VDEVICE(INTEL, 0x1d02), board_ahci }, /* PBG AHCI */
261 { PCI_VDEVICE(INTEL, 0x1d04), board_ahci }, /* PBG RAID */ 260 { PCI_VDEVICE(INTEL, 0x1d04), board_ahci }, /* PBG RAID */
262 { PCI_VDEVICE(INTEL, 0x1d06), board_ahci }, /* PBG RAID */ 261 { PCI_VDEVICE(INTEL, 0x1d06), board_ahci }, /* PBG RAID */
262 { PCI_VDEVICE(INTEL, 0x2826), board_ahci }, /* PBG RAID */
263 { PCI_VDEVICE(INTEL, 0x2323), board_ahci }, /* DH89xxCC AHCI */ 263 { PCI_VDEVICE(INTEL, 0x2323), board_ahci }, /* DH89xxCC AHCI */
264 264
265 /* JMicron 360/1/3/5/6, match class to avoid IDE function */ 265 /* JMicron 360/1/3/5/6, match class to avoid IDE function */
@@ -383,6 +383,10 @@ static const struct pci_device_id ahci_pci_tbl[] = {
383 .class = PCI_CLASS_STORAGE_SATA_AHCI, 383 .class = PCI_CLASS_STORAGE_SATA_AHCI,
384 .class_mask = 0xffffff, 384 .class_mask = 0xffffff,
385 .driver_data = board_ahci_yes_fbs }, /* 88se9128 */ 385 .driver_data = board_ahci_yes_fbs }, /* 88se9128 */
386 { PCI_DEVICE(0x1b4b, 0x9125),
387 .driver_data = board_ahci_yes_fbs }, /* 88se9125 */
388 { PCI_DEVICE(0x1b4b, 0x91a3),
389 .driver_data = board_ahci_yes_fbs },
386 390
387 /* Promise */ 391 /* Promise */
388 { PCI_VDEVICE(PROMISE, 0x3f20), board_ahci }, /* PDC42819 */ 392 { PCI_VDEVICE(PROMISE, 0x3f20), board_ahci }, /* PDC42819 */
diff --git a/drivers/ata/ahci.h b/drivers/ata/ahci.h
index 3e606c34f57b..ccaf08122058 100644
--- a/drivers/ata/ahci.h
+++ b/drivers/ata/ahci.h
@@ -213,10 +213,8 @@ enum {
213 213
214 /* ap->flags bits */ 214 /* ap->flags bits */
215 215
216 AHCI_FLAG_COMMON = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 216 AHCI_FLAG_COMMON = ATA_FLAG_SATA | ATA_FLAG_PIO_DMA |
217 ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA | 217 ATA_FLAG_ACPI_SATA | ATA_FLAG_AN,
218 ATA_FLAG_ACPI_SATA | ATA_FLAG_AN |
219 ATA_FLAG_LPM,
220 218
221 ICH_MAP = 0x90, /* ICH MAP register */ 219 ICH_MAP = 0x90, /* ICH MAP register */
222 220
diff --git a/drivers/ata/ata_generic.c b/drivers/ata/ata_generic.c
index 6981f7680a00..721d38bfa339 100644
--- a/drivers/ata/ata_generic.c
+++ b/drivers/ata/ata_generic.c
@@ -237,7 +237,7 @@ static struct pci_device_id ata_generic[] = {
237#endif 237#endif
238 /* Intel, IDE class device */ 238 /* Intel, IDE class device */
239 { PCI_VENDOR_ID_INTEL, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 239 { PCI_VENDOR_ID_INTEL, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
240 PCI_CLASS_STORAGE_IDE << 8, 0xFFFFFF00UL, 240 PCI_CLASS_STORAGE_IDE << 8, 0xFFFFFF00UL,
241 .driver_data = ATA_GEN_INTEL_IDER }, 241 .driver_data = ATA_GEN_INTEL_IDER },
242 /* Must come last. If you add entries adjust this table appropriately */ 242 /* Must come last. If you add entries adjust this table appropriately */
243 { PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_IDE << 8, 0xFFFFFF00UL), 243 { PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_IDE << 8, 0xFFFFFF00UL),
diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
index 6cb14ca8ee85..cdec4ab3b159 100644
--- a/drivers/ata/ata_piix.c
+++ b/drivers/ata/ata_piix.c
@@ -230,7 +230,7 @@ static const struct pci_device_id piix_pci_tbl[] = {
230 { 0x8086, 0x2850, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 }, 230 { 0x8086, 0x2850, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
231 231
232 /* SATA ports */ 232 /* SATA ports */
233 233
234 /* 82801EB (ICH5) */ 234 /* 82801EB (ICH5) */
235 { 0x8086, 0x24d1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich5_sata }, 235 { 0x8086, 0x24d1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich5_sata },
236 /* 82801EB (ICH5) */ 236 /* 82801EB (ICH5) */
diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
index 8b5ea399a4f4..a791b8ce6294 100644
--- a/drivers/ata/libata-acpi.c
+++ b/drivers/ata/libata-acpi.c
@@ -660,8 +660,7 @@ static int ata_acpi_filter_tf(struct ata_device *dev,
660 * @dev: target ATA device 660 * @dev: target ATA device
661 * @gtf: raw ATA taskfile register set (0x1f1 - 0x1f7) 661 * @gtf: raw ATA taskfile register set (0x1f1 - 0x1f7)
662 * 662 *
663 * Outputs ATA taskfile to standard ATA host controller using MMIO 663 * Outputs ATA taskfile to standard ATA host controller.
664 * or PIO as indicated by the ATA_FLAG_MMIO flag.
665 * Writes the control, feature, nsect, lbal, lbam, and lbah registers. 664 * Writes the control, feature, nsect, lbal, lbam, and lbah registers.
666 * Optionally (ATA_TFLAG_LBA48) writes hob_feature, hob_nsect, 665 * Optionally (ATA_TFLAG_LBA48) writes hob_feature, hob_nsect,
667 * hob_lbal, hob_lbam, and hob_lbah. 666 * hob_lbal, hob_lbam, and hob_lbah.
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index d4e52e214859..b91e19cab102 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -4210,7 +4210,7 @@ static int glob_match (const char *text, const char *pattern)
4210 return 0; /* End of both strings: match */ 4210 return 0; /* End of both strings: match */
4211 return 1; /* No match */ 4211 return 1; /* No match */
4212} 4212}
4213 4213
4214static unsigned long ata_dev_blacklisted(const struct ata_device *dev) 4214static unsigned long ata_dev_blacklisted(const struct ata_device *dev)
4215{ 4215{
4216 unsigned char model_num[ATA_ID_PROD_LEN + 1]; 4216 unsigned char model_num[ATA_ID_PROD_LEN + 1];
@@ -5479,7 +5479,7 @@ struct ata_port *ata_port_alloc(struct ata_host *host)
5479 ap = kzalloc(sizeof(*ap), GFP_KERNEL); 5479 ap = kzalloc(sizeof(*ap), GFP_KERNEL);
5480 if (!ap) 5480 if (!ap)
5481 return NULL; 5481 return NULL;
5482 5482
5483 ap->pflags |= ATA_PFLAG_INITIALIZING; 5483 ap->pflags |= ATA_PFLAG_INITIALIZING;
5484 ap->lock = &host->lock; 5484 ap->lock = &host->lock;
5485 ap->print_id = -1; 5485 ap->print_id = -1;
@@ -5887,21 +5887,9 @@ void ata_host_init(struct ata_host *host, struct device *dev,
5887 host->ops = ops; 5887 host->ops = ops;
5888} 5888}
5889 5889
5890 5890int ata_port_probe(struct ata_port *ap)
5891static void async_port_probe(void *data, async_cookie_t cookie)
5892{ 5891{
5893 int rc; 5892 int rc = 0;
5894 struct ata_port *ap = data;
5895
5896 /*
5897 * If we're not allowed to scan this host in parallel,
5898 * we need to wait until all previous scans have completed
5899 * before going further.
5900 * Jeff Garzik says this is only within a controller, so we
5901 * don't need to wait for port 0, only for later ports.
5902 */
5903 if (!(ap->host->flags & ATA_HOST_PARALLEL_SCAN) && ap->port_no != 0)
5904 async_synchronize_cookie(cookie);
5905 5893
5906 /* probe */ 5894 /* probe */
5907 if (ap->ops->error_handler) { 5895 if (ap->ops->error_handler) {
@@ -5927,23 +5915,33 @@ static void async_port_probe(void *data, async_cookie_t cookie)
5927 DPRINTK("ata%u: bus probe begin\n", ap->print_id); 5915 DPRINTK("ata%u: bus probe begin\n", ap->print_id);
5928 rc = ata_bus_probe(ap); 5916 rc = ata_bus_probe(ap);
5929 DPRINTK("ata%u: bus probe end\n", ap->print_id); 5917 DPRINTK("ata%u: bus probe end\n", ap->print_id);
5930
5931 if (rc) {
5932 /* FIXME: do something useful here?
5933 * Current libata behavior will
5934 * tear down everything when
5935 * the module is removed
5936 * or the h/w is unplugged.
5937 */
5938 }
5939 } 5918 }
5919 return rc;
5920}
5921
5922
5923static void async_port_probe(void *data, async_cookie_t cookie)
5924{
5925 struct ata_port *ap = data;
5926
5927 /*
5928 * If we're not allowed to scan this host in parallel,
5929 * we need to wait until all previous scans have completed
5930 * before going further.
5931 * Jeff Garzik says this is only within a controller, so we
5932 * don't need to wait for port 0, only for later ports.
5933 */
5934 if (!(ap->host->flags & ATA_HOST_PARALLEL_SCAN) && ap->port_no != 0)
5935 async_synchronize_cookie(cookie);
5936
5937 (void)ata_port_probe(ap);
5940 5938
5941 /* in order to keep device order, we need to synchronize at this point */ 5939 /* in order to keep device order, we need to synchronize at this point */
5942 async_synchronize_cookie(cookie); 5940 async_synchronize_cookie(cookie);
5943 5941
5944 ata_scsi_scan_host(ap, 1); 5942 ata_scsi_scan_host(ap, 1);
5945
5946} 5943}
5944
5947/** 5945/**
5948 * ata_host_register - register initialized ATA host 5946 * ata_host_register - register initialized ATA host
5949 * @host: ATA host to register 5947 * @host: ATA host to register
@@ -5983,7 +5981,7 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
5983 for (i = 0; i < host->n_ports; i++) 5981 for (i = 0; i < host->n_ports; i++)
5984 host->ports[i]->print_id = ata_print_id++; 5982 host->ports[i]->print_id = ata_print_id++;
5985 5983
5986 5984
5987 /* Create associated sysfs transport objects */ 5985 /* Create associated sysfs transport objects */
5988 for (i = 0; i < host->n_ports; i++) { 5986 for (i = 0; i < host->n_ports; i++) {
5989 rc = ata_tport_add(host->dev,host->ports[i]); 5987 rc = ata_tport_add(host->dev,host->ports[i]);
@@ -6471,7 +6469,7 @@ static int __init ata_init(void)
6471 ata_sff_exit(); 6469 ata_sff_exit();
6472 rc = -ENOMEM; 6470 rc = -ENOMEM;
6473 goto err_out; 6471 goto err_out;
6474 } 6472 }
6475 6473
6476 printk(KERN_DEBUG "libata version " DRV_VERSION " loaded.\n"); 6474 printk(KERN_DEBUG "libata version " DRV_VERSION " loaded.\n");
6477 return 0; 6475 return 0;
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index 17a637877d03..df3f3140c9c7 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -587,11 +587,43 @@ static void ata_eh_unload(struct ata_port *ap)
587void ata_scsi_error(struct Scsi_Host *host) 587void ata_scsi_error(struct Scsi_Host *host)
588{ 588{
589 struct ata_port *ap = ata_shost_to_port(host); 589 struct ata_port *ap = ata_shost_to_port(host);
590 int i;
591 unsigned long flags; 590 unsigned long flags;
591 LIST_HEAD(eh_work_q);
592 592
593 DPRINTK("ENTER\n"); 593 DPRINTK("ENTER\n");
594 594
595 spin_lock_irqsave(host->host_lock, flags);
596 list_splice_init(&host->eh_cmd_q, &eh_work_q);
597 spin_unlock_irqrestore(host->host_lock, flags);
598
599 ata_scsi_cmd_error_handler(host, ap, &eh_work_q);
600
601 /* If we timed raced normal completion and there is nothing to
602 recover nr_timedout == 0 why exactly are we doing error recovery ? */
603 ata_scsi_port_error_handler(host, ap);
604
605 /* finish or retry handled scmd's and clean up */
606 WARN_ON(host->host_failed || !list_empty(&eh_work_q));
607
608 DPRINTK("EXIT\n");
609}
610
611/**
612 * ata_scsi_cmd_error_handler - error callback for a list of commands
613 * @host: scsi host containing the port
614 * @ap: ATA port within the host
615 * @eh_work_q: list of commands to process
616 *
617 * process the given list of commands and return those finished to the
618 * ap->eh_done_q. This function is the first part of the libata error
619 * handler which processes a given list of failed commands.
620 */
621void ata_scsi_cmd_error_handler(struct Scsi_Host *host, struct ata_port *ap,
622 struct list_head *eh_work_q)
623{
624 int i;
625 unsigned long flags;
626
595 /* make sure sff pio task is not running */ 627 /* make sure sff pio task is not running */
596 ata_sff_flush_pio_task(ap); 628 ata_sff_flush_pio_task(ap);
597 629
@@ -627,7 +659,7 @@ void ata_scsi_error(struct Scsi_Host *host)
627 if (ap->ops->lost_interrupt) 659 if (ap->ops->lost_interrupt)
628 ap->ops->lost_interrupt(ap); 660 ap->ops->lost_interrupt(ap);
629 661
630 list_for_each_entry_safe(scmd, tmp, &host->eh_cmd_q, eh_entry) { 662 list_for_each_entry_safe(scmd, tmp, eh_work_q, eh_entry) {
631 struct ata_queued_cmd *qc; 663 struct ata_queued_cmd *qc;
632 664
633 for (i = 0; i < ATA_MAX_QUEUE; i++) { 665 for (i = 0; i < ATA_MAX_QUEUE; i++) {
@@ -671,8 +703,20 @@ void ata_scsi_error(struct Scsi_Host *host)
671 } else 703 } else
672 spin_unlock_wait(ap->lock); 704 spin_unlock_wait(ap->lock);
673 705
674 /* If we timed raced normal completion and there is nothing to 706}
675 recover nr_timedout == 0 why exactly are we doing error recovery ? */ 707EXPORT_SYMBOL(ata_scsi_cmd_error_handler);
708
709/**
710 * ata_scsi_port_error_handler - recover the port after the commands
711 * @host: SCSI host containing the port
712 * @ap: the ATA port
713 *
714 * Handle the recovery of the port @ap after all the commands
715 * have been recovered.
716 */
717void ata_scsi_port_error_handler(struct Scsi_Host *host, struct ata_port *ap)
718{
719 unsigned long flags;
676 720
677 /* invoke error handler */ 721 /* invoke error handler */
678 if (ap->ops->error_handler) { 722 if (ap->ops->error_handler) {
@@ -761,9 +805,6 @@ void ata_scsi_error(struct Scsi_Host *host)
761 ap->ops->eng_timeout(ap); 805 ap->ops->eng_timeout(ap);
762 } 806 }
763 807
764 /* finish or retry handled scmd's and clean up */
765 WARN_ON(host->host_failed || !list_empty(&host->eh_cmd_q));
766
767 scsi_eh_flush_done_q(&ap->eh_done_q); 808 scsi_eh_flush_done_q(&ap->eh_done_q);
768 809
769 /* clean up */ 810 /* clean up */
@@ -784,9 +825,8 @@ void ata_scsi_error(struct Scsi_Host *host)
784 wake_up_all(&ap->eh_wait_q); 825 wake_up_all(&ap->eh_wait_q);
785 826
786 spin_unlock_irqrestore(ap->lock, flags); 827 spin_unlock_irqrestore(ap->lock, flags);
787
788 DPRINTK("EXIT\n");
789} 828}
829EXPORT_SYMBOL_GPL(ata_scsi_port_error_handler);
790 830
791/** 831/**
792 * ata_port_wait_eh - Wait for the currently pending EH to complete 832 * ata_port_wait_eh - Wait for the currently pending EH to complete
@@ -1618,7 +1658,7 @@ static void ata_eh_analyze_serror(struct ata_link *link)
1618 * host links. For disabled PMP links, only N bit is 1658 * host links. For disabled PMP links, only N bit is
1619 * considered as X bit is left at 1 for link plugging. 1659 * considered as X bit is left at 1 for link plugging.
1620 */ 1660 */
1621 if (link->lpm_policy != ATA_LPM_MAX_POWER) 1661 if (link->lpm_policy > ATA_LPM_MAX_POWER)
1622 hotplug_mask = 0; /* hotplug doesn't work w/ LPM */ 1662 hotplug_mask = 0; /* hotplug doesn't work w/ LPM */
1623 else if (!(link->flags & ATA_LFLAG_DISABLED) || ata_is_host_link(link)) 1663 else if (!(link->flags & ATA_LFLAG_DISABLED) || ata_is_host_link(link))
1624 hotplug_mask = SERR_PHYRDY_CHG | SERR_DEV_XCHG; 1664 hotplug_mask = SERR_PHYRDY_CHG | SERR_DEV_XCHG;
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 600f6353ecf8..a83419991357 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -2056,6 +2056,17 @@ static unsigned int ata_scsiop_inq_83(struct ata_scsi_args *args, u8 *rbuf)
2056 ATA_ID_SERNO_LEN); 2056 ATA_ID_SERNO_LEN);
2057 num += ATA_ID_SERNO_LEN; 2057 num += ATA_ID_SERNO_LEN;
2058 2058
2059 if (ata_id_has_wwn(args->id)) {
2060 /* SAT defined lu world wide name */
2061 /* piv=0, assoc=lu, code_set=binary, designator=NAA */
2062 rbuf[num + 0] = 1;
2063 rbuf[num + 1] = 3;
2064 rbuf[num + 3] = ATA_ID_WWN_LEN;
2065 num += 4;
2066 ata_id_string(args->id, (unsigned char *) rbuf + num,
2067 ATA_ID_WWN, ATA_ID_WWN_LEN);
2068 num += ATA_ID_WWN_LEN;
2069 }
2059 rbuf[3] = num - 4; /* page len (assume less than 256 bytes) */ 2070 rbuf[3] = num - 4; /* page len (assume less than 256 bytes) */
2060 return 0; 2071 return 0;
2061} 2072}
@@ -3759,7 +3770,7 @@ struct ata_port *ata_sas_port_alloc(struct ata_host *host,
3759 return NULL; 3770 return NULL;
3760 3771
3761 ap->port_no = 0; 3772 ap->port_no = 0;
3762 ap->lock = shost->host_lock; 3773 ap->lock = &host->lock;
3763 ap->pio_mask = port_info->pio_mask; 3774 ap->pio_mask = port_info->pio_mask;
3764 ap->mwdma_mask = port_info->mwdma_mask; 3775 ap->mwdma_mask = port_info->mwdma_mask;
3765 ap->udma_mask = port_info->udma_mask; 3776 ap->udma_mask = port_info->udma_mask;
@@ -3821,7 +3832,7 @@ int ata_sas_port_init(struct ata_port *ap)
3821 3832
3822 if (!rc) { 3833 if (!rc) {
3823 ap->print_id = ata_print_id++; 3834 ap->print_id = ata_print_id++;
3824 rc = ata_bus_probe(ap); 3835 rc = ata_port_probe(ap);
3825 } 3836 }
3826 3837
3827 return rc; 3838 return rc;
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c
index af6141bb1ba3..cf7acbc0cfcb 100644
--- a/drivers/ata/libata-sff.c
+++ b/drivers/ata/libata-sff.c
@@ -1302,6 +1302,18 @@ fsm_start:
1302} 1302}
1303EXPORT_SYMBOL_GPL(ata_sff_hsm_move); 1303EXPORT_SYMBOL_GPL(ata_sff_hsm_move);
1304 1304
1305void ata_sff_queue_work(struct work_struct *work)
1306{
1307 queue_work(ata_sff_wq, work);
1308}
1309EXPORT_SYMBOL_GPL(ata_sff_queue_work);
1310
1311void ata_sff_queue_delayed_work(struct delayed_work *dwork, unsigned long delay)
1312{
1313 queue_delayed_work(ata_sff_wq, dwork, delay);
1314}
1315EXPORT_SYMBOL_GPL(ata_sff_queue_delayed_work);
1316
1305void ata_sff_queue_pio_task(struct ata_link *link, unsigned long delay) 1317void ata_sff_queue_pio_task(struct ata_link *link, unsigned long delay)
1306{ 1318{
1307 struct ata_port *ap = link->ap; 1319 struct ata_port *ap = link->ap;
@@ -1311,8 +1323,7 @@ void ata_sff_queue_pio_task(struct ata_link *link, unsigned long delay)
1311 ap->sff_pio_task_link = link; 1323 ap->sff_pio_task_link = link;
1312 1324
1313 /* may fail if ata_sff_flush_pio_task() in progress */ 1325 /* may fail if ata_sff_flush_pio_task() in progress */
1314 queue_delayed_work(ata_sff_wq, &ap->sff_pio_task, 1326 ata_sff_queue_delayed_work(&ap->sff_pio_task, msecs_to_jiffies(delay));
1315 msecs_to_jiffies(delay));
1316} 1327}
1317EXPORT_SYMBOL_GPL(ata_sff_queue_pio_task); 1328EXPORT_SYMBOL_GPL(ata_sff_queue_pio_task);
1318 1329
@@ -1336,7 +1347,7 @@ static void ata_sff_pio_task(struct work_struct *work)
1336 u8 status; 1347 u8 status;
1337 int poll_next; 1348 int poll_next;
1338 1349
1339 BUG_ON(ap->sff_pio_task_link == NULL); 1350 BUG_ON(ap->sff_pio_task_link == NULL);
1340 /* qc can be NULL if timeout occurred */ 1351 /* qc can be NULL if timeout occurred */
1341 qc = ata_qc_from_tag(ap, link->active_tag); 1352 qc = ata_qc_from_tag(ap, link->active_tag);
1342 if (!qc) { 1353 if (!qc) {
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
index a9be110dbf51..773de97988a2 100644
--- a/drivers/ata/libata.h
+++ b/drivers/ata/libata.h
@@ -103,6 +103,7 @@ extern int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg);
103extern int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg); 103extern int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg);
104extern struct ata_port *ata_port_alloc(struct ata_host *host); 104extern struct ata_port *ata_port_alloc(struct ata_host *host);
105extern const char *sata_spd_string(unsigned int spd); 105extern const char *sata_spd_string(unsigned int spd);
106extern int ata_port_probe(struct ata_port *ap);
106 107
107/* libata-acpi.c */ 108/* libata-acpi.c */
108#ifdef CONFIG_ATA_ACPI 109#ifdef CONFIG_ATA_ACPI
diff --git a/drivers/ata/pata_acpi.c b/drivers/ata/pata_acpi.c
index c8d47034d5e9..91949d997555 100644
--- a/drivers/ata/pata_acpi.c
+++ b/drivers/ata/pata_acpi.c
@@ -245,7 +245,7 @@ static struct ata_port_operations pacpi_ops = {
245static int pacpi_init_one (struct pci_dev *pdev, const struct pci_device_id *id) 245static int pacpi_init_one (struct pci_dev *pdev, const struct pci_device_id *id)
246{ 246{
247 static const struct ata_port_info info = { 247 static const struct ata_port_info info = {
248 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 248 .flags = ATA_FLAG_SLAVE_POSS,
249 249
250 .pio_mask = ATA_PIO4, 250 .pio_mask = ATA_PIO4,
251 .mwdma_mask = ATA_MWDMA2, 251 .mwdma_mask = ATA_MWDMA2,
diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
new file mode 100644
index 000000000000..65cee74605b4
--- /dev/null
+++ b/drivers/ata/pata_arasan_cf.c
@@ -0,0 +1,983 @@
1/*
2 * drivers/ata/pata_arasan_cf.c
3 *
4 * Arasan Compact Flash host controller source file
5 *
6 * Copyright (C) 2011 ST Microelectronics
7 * Viresh Kumar <viresh.kumar@st.com>
8 *
9 * This file is licensed under the terms of the GNU General Public
10 * License version 2. This program is licensed "as is" without any
11 * warranty of any kind, whether express or implied.
12 */
13
14/*
15 * The Arasan CompactFlash Device Controller IP core has three basic modes of
16 * operation: PC card ATA using I/O mode, PC card ATA using memory mode, PC card
17 * ATA using true IDE modes. This driver supports only True IDE mode currently.
18 *
19 * Arasan CF Controller shares global irq register with Arasan XD Controller.
20 *
21 * Tested on arch/arm/mach-spear13xx
22 */
23
24#include <linux/ata.h>
25#include <linux/clk.h>
26#include <linux/completion.h>
27#include <linux/delay.h>
28#include <linux/dmaengine.h>
29#include <linux/io.h>
30#include <linux/irq.h>
31#include <linux/kernel.h>
32#include <linux/libata.h>
33#include <linux/module.h>
34#include <linux/pata_arasan_cf_data.h>
35#include <linux/platform_device.h>
36#include <linux/pm.h>
37#include <linux/slab.h>
38#include <linux/spinlock.h>
39#include <linux/types.h>
40#include <linux/workqueue.h>
41
42#define DRIVER_NAME "arasan_cf"
43#define TIMEOUT msecs_to_jiffies(3000)
44
45/* Registers */
46/* CompactFlash Interface Status */
47#define CFI_STS 0x000
48 #define STS_CHG (1)
49 #define BIN_AUDIO_OUT (1 << 1)
50 #define CARD_DETECT1 (1 << 2)
51 #define CARD_DETECT2 (1 << 3)
52 #define INP_ACK (1 << 4)
53 #define CARD_READY (1 << 5)
54 #define IO_READY (1 << 6)
55 #define B16_IO_PORT_SEL (1 << 7)
56/* IRQ */
57#define IRQ_STS 0x004
58/* Interrupt Enable */
59#define IRQ_EN 0x008
60 #define CARD_DETECT_IRQ (1)
61 #define STATUS_CHNG_IRQ (1 << 1)
62 #define MEM_MODE_IRQ (1 << 2)
63 #define IO_MODE_IRQ (1 << 3)
64 #define TRUE_IDE_MODE_IRQ (1 << 8)
65 #define PIO_XFER_ERR_IRQ (1 << 9)
66 #define BUF_AVAIL_IRQ (1 << 10)
67 #define XFER_DONE_IRQ (1 << 11)
68 #define IGNORED_IRQS (STATUS_CHNG_IRQ | MEM_MODE_IRQ | IO_MODE_IRQ |\
69 TRUE_IDE_MODE_IRQ)
70 #define TRUE_IDE_IRQS (CARD_DETECT_IRQ | PIO_XFER_ERR_IRQ |\
71 BUF_AVAIL_IRQ | XFER_DONE_IRQ)
72/* Operation Mode */
73#define OP_MODE 0x00C
74 #define CARD_MODE_MASK (0x3)
75 #define MEM_MODE (0x0)
76 #define IO_MODE (0x1)
77 #define TRUE_IDE_MODE (0x2)
78
79 #define CARD_TYPE_MASK (1 << 2)
80 #define CF_CARD (0)
81 #define CF_PLUS_CARD (1 << 2)
82
83 #define CARD_RESET (1 << 3)
84 #define CFHOST_ENB (1 << 4)
85 #define OUTPUTS_TRISTATE (1 << 5)
86 #define ULTRA_DMA_ENB (1 << 8)
87 #define MULTI_WORD_DMA_ENB (1 << 9)
88 #define DRQ_BLOCK_SIZE_MASK (0x3 << 11)
89 #define DRQ_BLOCK_SIZE_512 (0)
90 #define DRQ_BLOCK_SIZE_1024 (1 << 11)
91 #define DRQ_BLOCK_SIZE_2048 (2 << 11)
92 #define DRQ_BLOCK_SIZE_4096 (3 << 11)
93/* CF Interface Clock Configuration */
94#define CLK_CFG 0x010
95 #define CF_IF_CLK_MASK (0XF)
96/* CF Timing Mode Configuration */
97#define TM_CFG 0x014
98 #define MEM_MODE_TIMING_MASK (0x3)
99 #define MEM_MODE_TIMING_250NS (0x0)
100 #define MEM_MODE_TIMING_120NS (0x1)
101 #define MEM_MODE_TIMING_100NS (0x2)
102 #define MEM_MODE_TIMING_80NS (0x3)
103
104 #define IO_MODE_TIMING_MASK (0x3 << 2)
105 #define IO_MODE_TIMING_250NS (0x0 << 2)
106 #define IO_MODE_TIMING_120NS (0x1 << 2)
107 #define IO_MODE_TIMING_100NS (0x2 << 2)
108 #define IO_MODE_TIMING_80NS (0x3 << 2)
109
110 #define TRUEIDE_PIO_TIMING_MASK (0x7 << 4)
111 #define TRUEIDE_PIO_TIMING_SHIFT 4
112
113 #define TRUEIDE_MWORD_DMA_TIMING_MASK (0x7 << 7)
114 #define TRUEIDE_MWORD_DMA_TIMING_SHIFT 7
115
116 #define ULTRA_DMA_TIMING_MASK (0x7 << 10)
117 #define ULTRA_DMA_TIMING_SHIFT 10
118/* CF Transfer Address */
119#define XFER_ADDR 0x014
120 #define XFER_ADDR_MASK (0x7FF)
121 #define MAX_XFER_COUNT 0x20000u
122/* Transfer Control */
123#define XFER_CTR 0x01C
124 #define XFER_COUNT_MASK (0x3FFFF)
125 #define ADDR_INC_DISABLE (1 << 24)
126 #define XFER_WIDTH_MASK (1 << 25)
127 #define XFER_WIDTH_8B (0)
128 #define XFER_WIDTH_16B (1 << 25)
129
130 #define MEM_TYPE_MASK (1 << 26)
131 #define MEM_TYPE_COMMON (0)
132 #define MEM_TYPE_ATTRIBUTE (1 << 26)
133
134 #define MEM_IO_XFER_MASK (1 << 27)
135 #define MEM_XFER (0)
136 #define IO_XFER (1 << 27)
137
138 #define DMA_XFER_MODE (1 << 28)
139
140 #define AHB_BUS_NORMAL_PIO_OPRTN (~(1 << 29))
141 #define XFER_DIR_MASK (1 << 30)
142 #define XFER_READ (0)
143 #define XFER_WRITE (1 << 30)
144
145 #define XFER_START (1 << 31)
146/* Write Data Port */
147#define WRITE_PORT 0x024
148/* Read Data Port */
149#define READ_PORT 0x028
150/* ATA Data Port */
151#define ATA_DATA_PORT 0x030
152 #define ATA_DATA_PORT_MASK (0xFFFF)
153/* ATA Error/Features */
154#define ATA_ERR_FTR 0x034
155/* ATA Sector Count */
156#define ATA_SC 0x038
157/* ATA Sector Number */
158#define ATA_SN 0x03C
159/* ATA Cylinder Low */
160#define ATA_CL 0x040
161/* ATA Cylinder High */
162#define ATA_CH 0x044
163/* ATA Select Card/Head */
164#define ATA_SH 0x048
165/* ATA Status-Command */
166#define ATA_STS_CMD 0x04C
167/* ATA Alternate Status/Device Control */
168#define ATA_ASTS_DCTR 0x050
169/* Extended Write Data Port 0x200-0x3FC */
170#define EXT_WRITE_PORT 0x200
171/* Extended Read Data Port 0x400-0x5FC */
172#define EXT_READ_PORT 0x400
173 #define FIFO_SIZE 0x200u
174/* Global Interrupt Status */
175#define GIRQ_STS 0x800
176/* Global Interrupt Status enable */
177#define GIRQ_STS_EN 0x804
178/* Global Interrupt Signal enable */
179#define GIRQ_SGN_EN 0x808
180 #define GIRQ_CF (1)
181 #define GIRQ_XD (1 << 1)
182
183/* Compact Flash Controller Dev Structure */
184struct arasan_cf_dev {
185 /* pointer to ata_host structure */
186 struct ata_host *host;
187 /* clk structure, only if HAVE_CLK is defined */
188#ifdef CONFIG_HAVE_CLK
189 struct clk *clk;
190#endif
191
192 /* physical base address of controller */
193 dma_addr_t pbase;
194 /* virtual base address of controller */
195 void __iomem *vbase;
196 /* irq number*/
197 int irq;
198
199 /* status to be updated to framework regarding DMA transfer */
200 u8 dma_status;
201 /* Card is present or Not */
202 u8 card_present;
203
204 /* dma specific */
205 /* Completion for transfer complete interrupt from controller */
206 struct completion cf_completion;
207 /* Completion for DMA transfer complete. */
208 struct completion dma_completion;
209 /* Dma channel allocated */
210 struct dma_chan *dma_chan;
211 /* Mask for DMA transfers */
212 dma_cap_mask_t mask;
213 /* dma channel private data */
214 void *dma_priv;
215 /* DMA transfer work */
216 struct work_struct work;
217 /* DMA delayed finish work */
218 struct delayed_work dwork;
219 /* qc to be transferred using DMA */
220 struct ata_queued_cmd *qc;
221};
222
223static struct scsi_host_template arasan_cf_sht = {
224 ATA_BASE_SHT(DRIVER_NAME),
225 .sg_tablesize = SG_NONE,
226 .dma_boundary = 0xFFFFFFFFUL,
227};
228
229static void cf_dumpregs(struct arasan_cf_dev *acdev)
230{
231 struct device *dev = acdev->host->dev;
232
233 dev_dbg(dev, ": =========== REGISTER DUMP ===========");
234 dev_dbg(dev, ": CFI_STS: %x", readl(acdev->vbase + CFI_STS));
235 dev_dbg(dev, ": IRQ_STS: %x", readl(acdev->vbase + IRQ_STS));
236 dev_dbg(dev, ": IRQ_EN: %x", readl(acdev->vbase + IRQ_EN));
237 dev_dbg(dev, ": OP_MODE: %x", readl(acdev->vbase + OP_MODE));
238 dev_dbg(dev, ": CLK_CFG: %x", readl(acdev->vbase + CLK_CFG));
239 dev_dbg(dev, ": TM_CFG: %x", readl(acdev->vbase + TM_CFG));
240 dev_dbg(dev, ": XFER_CTR: %x", readl(acdev->vbase + XFER_CTR));
241 dev_dbg(dev, ": GIRQ_STS: %x", readl(acdev->vbase + GIRQ_STS));
242 dev_dbg(dev, ": GIRQ_STS_EN: %x", readl(acdev->vbase + GIRQ_STS_EN));
243 dev_dbg(dev, ": GIRQ_SGN_EN: %x", readl(acdev->vbase + GIRQ_SGN_EN));
244 dev_dbg(dev, ": =====================================");
245}
246
247/* Enable/Disable global interrupts shared between CF and XD ctrlr. */
248static void cf_ginterrupt_enable(struct arasan_cf_dev *acdev, bool enable)
249{
250 /* enable should be 0 or 1 */
251 writel(enable, acdev->vbase + GIRQ_STS_EN);
252 writel(enable, acdev->vbase + GIRQ_SGN_EN);
253}
254
255/* Enable/Disable CF interrupts */
256static inline void
257cf_interrupt_enable(struct arasan_cf_dev *acdev, u32 mask, bool enable)
258{
259 u32 val = readl(acdev->vbase + IRQ_EN);
260 /* clear & enable/disable irqs */
261 if (enable) {
262 writel(mask, acdev->vbase + IRQ_STS);
263 writel(val | mask, acdev->vbase + IRQ_EN);
264 } else
265 writel(val & ~mask, acdev->vbase + IRQ_EN);
266}
267
268static inline void cf_card_reset(struct arasan_cf_dev *acdev)
269{
270 u32 val = readl(acdev->vbase + OP_MODE);
271
272 writel(val | CARD_RESET, acdev->vbase + OP_MODE);
273 udelay(200);
274 writel(val & ~CARD_RESET, acdev->vbase + OP_MODE);
275}
276
277static inline void cf_ctrl_reset(struct arasan_cf_dev *acdev)
278{
279 writel(readl(acdev->vbase + OP_MODE) & ~CFHOST_ENB,
280 acdev->vbase + OP_MODE);
281 writel(readl(acdev->vbase + OP_MODE) | CFHOST_ENB,
282 acdev->vbase + OP_MODE);
283}
284
285static void cf_card_detect(struct arasan_cf_dev *acdev, bool hotplugged)
286{
287 struct ata_port *ap = acdev->host->ports[0];
288 struct ata_eh_info *ehi = &ap->link.eh_info;
289 u32 val = readl(acdev->vbase + CFI_STS);
290
291 /* Both CD1 & CD2 should be low if card inserted completely */
292 if (!(val & (CARD_DETECT1 | CARD_DETECT2))) {
293 if (acdev->card_present)
294 return;
295 acdev->card_present = 1;
296 cf_card_reset(acdev);
297 } else {
298 if (!acdev->card_present)
299 return;
300 acdev->card_present = 0;
301 }
302
303 if (hotplugged) {
304 ata_ehi_hotplugged(ehi);
305 ata_port_freeze(ap);
306 }
307}
308
309static int cf_init(struct arasan_cf_dev *acdev)
310{
311 struct arasan_cf_pdata *pdata = dev_get_platdata(acdev->host->dev);
312 unsigned long flags;
313 int ret = 0;
314
315#ifdef CONFIG_HAVE_CLK
316 ret = clk_enable(acdev->clk);
317 if (ret) {
318 dev_dbg(acdev->host->dev, "clock enable failed");
319 return ret;
320 }
321#endif
322
323 spin_lock_irqsave(&acdev->host->lock, flags);
324 /* configure CF interface clock */
325 writel((pdata->cf_if_clk <= CF_IF_CLK_200M) ? pdata->cf_if_clk :
326 CF_IF_CLK_166M, acdev->vbase + CLK_CFG);
327
328 writel(TRUE_IDE_MODE | CFHOST_ENB, acdev->vbase + OP_MODE);
329 cf_interrupt_enable(acdev, CARD_DETECT_IRQ, 1);
330 cf_ginterrupt_enable(acdev, 1);
331 spin_unlock_irqrestore(&acdev->host->lock, flags);
332
333 return ret;
334}
335
336static void cf_exit(struct arasan_cf_dev *acdev)
337{
338 unsigned long flags;
339
340 spin_lock_irqsave(&acdev->host->lock, flags);
341 cf_ginterrupt_enable(acdev, 0);
342 cf_interrupt_enable(acdev, TRUE_IDE_IRQS, 0);
343 cf_card_reset(acdev);
344 writel(readl(acdev->vbase + OP_MODE) & ~CFHOST_ENB,
345 acdev->vbase + OP_MODE);
346 spin_unlock_irqrestore(&acdev->host->lock, flags);
347#ifdef CONFIG_HAVE_CLK
348 clk_disable(acdev->clk);
349#endif
350}
351
352static void dma_callback(void *dev)
353{
354 struct arasan_cf_dev *acdev = (struct arasan_cf_dev *) dev;
355
356 complete(&acdev->dma_completion);
357}
358
359static bool filter(struct dma_chan *chan, void *slave)
360{
361 chan->private = slave;
362 return true;
363}
364
365static inline void dma_complete(struct arasan_cf_dev *acdev)
366{
367 struct ata_queued_cmd *qc = acdev->qc;
368 unsigned long flags;
369
370 acdev->qc = NULL;
371 ata_sff_interrupt(acdev->irq, acdev->host);
372
373 spin_lock_irqsave(&acdev->host->lock, flags);
374 if (unlikely(qc->err_mask) && ata_is_dma(qc->tf.protocol))
375 ata_ehi_push_desc(&qc->ap->link.eh_info, "DMA Failed: Timeout");
376 spin_unlock_irqrestore(&acdev->host->lock, flags);
377}
378
379static inline int wait4buf(struct arasan_cf_dev *acdev)
380{
381 if (!wait_for_completion_timeout(&acdev->cf_completion, TIMEOUT)) {
382 u32 rw = acdev->qc->tf.flags & ATA_TFLAG_WRITE;
383
384 dev_err(acdev->host->dev, "%s TimeOut", rw ? "write" : "read");
385 return -ETIMEDOUT;
386 }
387
388 /* Check if PIO Error interrupt has occured */
389 if (acdev->dma_status & ATA_DMA_ERR)
390 return -EAGAIN;
391
392 return 0;
393}
394
395static int
396dma_xfer(struct arasan_cf_dev *acdev, dma_addr_t src, dma_addr_t dest, u32 len)
397{
398 struct dma_async_tx_descriptor *tx;
399 struct dma_chan *chan = acdev->dma_chan;
400 dma_cookie_t cookie;
401 unsigned long flags = DMA_PREP_INTERRUPT | DMA_COMPL_SKIP_SRC_UNMAP |
402 DMA_COMPL_SKIP_DEST_UNMAP;
403 int ret = 0;
404
405 tx = chan->device->device_prep_dma_memcpy(chan, dest, src, len, flags);
406 if (!tx) {
407 dev_err(acdev->host->dev, "device_prep_dma_memcpy failed\n");
408 return -EAGAIN;
409 }
410
411 tx->callback = dma_callback;
412 tx->callback_param = acdev;
413 cookie = tx->tx_submit(tx);
414
415 ret = dma_submit_error(cookie);
416 if (ret) {
417 dev_err(acdev->host->dev, "dma_submit_error\n");
418 return ret;
419 }
420
421 chan->device->device_issue_pending(chan);
422
423 /* Wait for DMA to complete */
424 if (!wait_for_completion_timeout(&acdev->dma_completion, TIMEOUT)) {
425 chan->device->device_control(chan, DMA_TERMINATE_ALL, 0);
426 dev_err(acdev->host->dev, "wait_for_completion_timeout\n");
427 return -ETIMEDOUT;
428 }
429
430 return ret;
431}
432
433static int sg_xfer(struct arasan_cf_dev *acdev, struct scatterlist *sg)
434{
435 dma_addr_t dest = 0, src = 0;
436 u32 xfer_cnt, sglen, dma_len, xfer_ctr;
437 u32 write = acdev->qc->tf.flags & ATA_TFLAG_WRITE;
438 unsigned long flags;
439 int ret = 0;
440
441 sglen = sg_dma_len(sg);
442 if (write) {
443 src = sg_dma_address(sg);
444 dest = acdev->pbase + EXT_WRITE_PORT;
445 } else {
446 dest = sg_dma_address(sg);
447 src = acdev->pbase + EXT_READ_PORT;
448 }
449
450 /*
451 * For each sg:
452 * MAX_XFER_COUNT data will be transferred before we get transfer
453 * complete interrupt. Inbetween after FIFO_SIZE data
454 * buffer available interrupt will be generated. At this time we will
455 * fill FIFO again: max FIFO_SIZE data.
456 */
457 while (sglen) {
458 xfer_cnt = min(sglen, MAX_XFER_COUNT);
459 spin_lock_irqsave(&acdev->host->lock, flags);
460 xfer_ctr = readl(acdev->vbase + XFER_CTR) &
461 ~XFER_COUNT_MASK;
462 writel(xfer_ctr | xfer_cnt | XFER_START,
463 acdev->vbase + XFER_CTR);
464 spin_unlock_irqrestore(&acdev->host->lock, flags);
465
466 /* continue dma xfers untill current sg is completed */
467 while (xfer_cnt) {
468 /* wait for read to complete */
469 if (!write) {
470 ret = wait4buf(acdev);
471 if (ret)
472 goto fail;
473 }
474
475 /* read/write FIFO in chunk of FIFO_SIZE */
476 dma_len = min(xfer_cnt, FIFO_SIZE);
477 ret = dma_xfer(acdev, src, dest, dma_len);
478 if (ret) {
479 dev_err(acdev->host->dev, "dma failed");
480 goto fail;
481 }
482
483 if (write)
484 src += dma_len;
485 else
486 dest += dma_len;
487
488 sglen -= dma_len;
489 xfer_cnt -= dma_len;
490
491 /* wait for write to complete */
492 if (write) {
493 ret = wait4buf(acdev);
494 if (ret)
495 goto fail;
496 }
497 }
498 }
499
500fail:
501 spin_lock_irqsave(&acdev->host->lock, flags);
502 writel(readl(acdev->vbase + XFER_CTR) & ~XFER_START,
503 acdev->vbase + XFER_CTR);
504 spin_unlock_irqrestore(&acdev->host->lock, flags);
505
506 return ret;
507}
508
509/*
510 * This routine uses External DMA controller to read/write data to FIFO of CF
511 * controller. There are two xfer related interrupt supported by CF controller:
512 * - buf_avail: This interrupt is generated as soon as we have buffer of 512
513 * bytes available for reading or empty buffer available for writing.
514 * - xfer_done: This interrupt is generated on transfer of "xfer_size" amount of
515 * data to/from FIFO. xfer_size is programmed in XFER_CTR register.
516 *
517 * Max buffer size = FIFO_SIZE = 512 Bytes.
518 * Max xfer_size = MAX_XFER_COUNT = 256 KB.
519 */
520static void data_xfer(struct work_struct *work)
521{
522 struct arasan_cf_dev *acdev = container_of(work, struct arasan_cf_dev,
523 work);
524 struct ata_queued_cmd *qc = acdev->qc;
525 struct scatterlist *sg;
526 unsigned long flags;
527 u32 temp;
528 int ret = 0;
529
530 /* request dma channels */
531 /* dma_request_channel may sleep, so calling from process context */
532 acdev->dma_chan = dma_request_channel(acdev->mask, filter,
533 acdev->dma_priv);
534 if (!acdev->dma_chan) {
535 dev_err(acdev->host->dev, "Unable to get dma_chan\n");
536 goto chan_request_fail;
537 }
538
539 for_each_sg(qc->sg, sg, qc->n_elem, temp) {
540 ret = sg_xfer(acdev, sg);
541 if (ret)
542 break;
543 }
544
545 dma_release_channel(acdev->dma_chan);
546
547 /* data xferred successfully */
548 if (!ret) {
549 u32 status;
550
551 spin_lock_irqsave(&acdev->host->lock, flags);
552 status = ioread8(qc->ap->ioaddr.altstatus_addr);
553 spin_unlock_irqrestore(&acdev->host->lock, flags);
554 if (status & (ATA_BUSY | ATA_DRQ)) {
555 ata_sff_queue_delayed_work(&acdev->dwork, 1);
556 return;
557 }
558
559 goto sff_intr;
560 }
561
562 cf_dumpregs(acdev);
563
564chan_request_fail:
565 spin_lock_irqsave(&acdev->host->lock, flags);
566 /* error when transfering data to/from memory */
567 qc->err_mask |= AC_ERR_HOST_BUS;
568 qc->ap->hsm_task_state = HSM_ST_ERR;
569
570 cf_ctrl_reset(acdev);
571 spin_unlock_irqrestore(qc->ap->lock, flags);
572sff_intr:
573 dma_complete(acdev);
574}
575
576static void delayed_finish(struct work_struct *work)
577{
578 struct arasan_cf_dev *acdev = container_of(work, struct arasan_cf_dev,
579 dwork.work);
580 struct ata_queued_cmd *qc = acdev->qc;
581 unsigned long flags;
582 u8 status;
583
584 spin_lock_irqsave(&acdev->host->lock, flags);
585 status = ioread8(qc->ap->ioaddr.altstatus_addr);
586 spin_unlock_irqrestore(&acdev->host->lock, flags);
587
588 if (status & (ATA_BUSY | ATA_DRQ))
589 ata_sff_queue_delayed_work(&acdev->dwork, 1);
590 else
591 dma_complete(acdev);
592}
593
594static irqreturn_t arasan_cf_interrupt(int irq, void *dev)
595{
596 struct arasan_cf_dev *acdev = ((struct ata_host *)dev)->private_data;
597 unsigned long flags;
598 u32 irqsts;
599
600 irqsts = readl(acdev->vbase + GIRQ_STS);
601 if (!(irqsts & GIRQ_CF))
602 return IRQ_NONE;
603
604 spin_lock_irqsave(&acdev->host->lock, flags);
605 irqsts = readl(acdev->vbase + IRQ_STS);
606 writel(irqsts, acdev->vbase + IRQ_STS); /* clear irqs */
607 writel(GIRQ_CF, acdev->vbase + GIRQ_STS); /* clear girqs */
608
609 /* handle only relevant interrupts */
610 irqsts &= ~IGNORED_IRQS;
611
612 if (irqsts & CARD_DETECT_IRQ) {
613 cf_card_detect(acdev, 1);
614 spin_unlock_irqrestore(&acdev->host->lock, flags);
615 return IRQ_HANDLED;
616 }
617
618 if (irqsts & PIO_XFER_ERR_IRQ) {
619 acdev->dma_status = ATA_DMA_ERR;
620 writel(readl(acdev->vbase + XFER_CTR) & ~XFER_START,
621 acdev->vbase + XFER_CTR);
622 spin_unlock_irqrestore(&acdev->host->lock, flags);
623 complete(&acdev->cf_completion);
624 dev_err(acdev->host->dev, "pio xfer err irq\n");
625 return IRQ_HANDLED;
626 }
627
628 spin_unlock_irqrestore(&acdev->host->lock, flags);
629
630 if (irqsts & BUF_AVAIL_IRQ) {
631 complete(&acdev->cf_completion);
632 return IRQ_HANDLED;
633 }
634
635 if (irqsts & XFER_DONE_IRQ) {
636 struct ata_queued_cmd *qc = acdev->qc;
637
638 /* Send Complete only for write */
639 if (qc->tf.flags & ATA_TFLAG_WRITE)
640 complete(&acdev->cf_completion);
641 }
642
643 return IRQ_HANDLED;
644}
645
646static void arasan_cf_freeze(struct ata_port *ap)
647{
648 struct arasan_cf_dev *acdev = ap->host->private_data;
649
650 /* stop transfer and reset controller */
651 writel(readl(acdev->vbase + XFER_CTR) & ~XFER_START,
652 acdev->vbase + XFER_CTR);
653 cf_ctrl_reset(acdev);
654 acdev->dma_status = ATA_DMA_ERR;
655
656 ata_sff_dma_pause(ap);
657 ata_sff_freeze(ap);
658}
659
660void arasan_cf_error_handler(struct ata_port *ap)
661{
662 struct arasan_cf_dev *acdev = ap->host->private_data;
663
664 /*
665 * DMA transfers using an external DMA controller may be scheduled.
666 * Abort them before handling error. Refer data_xfer() for further
667 * details.
668 */
669 cancel_work_sync(&acdev->work);
670 cancel_delayed_work_sync(&acdev->dwork);
671 return ata_sff_error_handler(ap);
672}
673
674static void arasan_cf_dma_start(struct arasan_cf_dev *acdev)
675{
676 u32 xfer_ctr = readl(acdev->vbase + XFER_CTR) & ~XFER_DIR_MASK;
677 u32 write = acdev->qc->tf.flags & ATA_TFLAG_WRITE;
678
679 xfer_ctr |= write ? XFER_WRITE : XFER_READ;
680 writel(xfer_ctr, acdev->vbase + XFER_CTR);
681
682 acdev->qc->ap->ops->sff_exec_command(acdev->qc->ap, &acdev->qc->tf);
683 ata_sff_queue_work(&acdev->work);
684}
685
686unsigned int arasan_cf_qc_issue(struct ata_queued_cmd *qc)
687{
688 struct ata_port *ap = qc->ap;
689 struct arasan_cf_dev *acdev = ap->host->private_data;
690
691 /* defer PIO handling to sff_qc_issue */
692 if (!ata_is_dma(qc->tf.protocol))
693 return ata_sff_qc_issue(qc);
694
695 /* select the device */
696 ata_wait_idle(ap);
697 ata_sff_dev_select(ap, qc->dev->devno);
698 ata_wait_idle(ap);
699
700 /* start the command */
701 switch (qc->tf.protocol) {
702 case ATA_PROT_DMA:
703 WARN_ON_ONCE(qc->tf.flags & ATA_TFLAG_POLLING);
704
705 ap->ops->sff_tf_load(ap, &qc->tf);
706 acdev->dma_status = 0;
707 acdev->qc = qc;
708 arasan_cf_dma_start(acdev);
709 ap->hsm_task_state = HSM_ST_LAST;
710 break;
711
712 default:
713 WARN_ON(1);
714 return AC_ERR_SYSTEM;
715 }
716
717 return 0;
718}
719
720static void arasan_cf_set_piomode(struct ata_port *ap, struct ata_device *adev)
721{
722 struct arasan_cf_dev *acdev = ap->host->private_data;
723 u8 pio = adev->pio_mode - XFER_PIO_0;
724 unsigned long flags;
725 u32 val;
726
727 /* Arasan ctrl supports Mode0 -> Mode6 */
728 if (pio > 6) {
729 dev_err(ap->dev, "Unknown PIO mode\n");
730 return;
731 }
732
733 spin_lock_irqsave(&acdev->host->lock, flags);
734 val = readl(acdev->vbase + OP_MODE) &
735 ~(ULTRA_DMA_ENB | MULTI_WORD_DMA_ENB | DRQ_BLOCK_SIZE_MASK);
736 writel(val, acdev->vbase + OP_MODE);
737 val = readl(acdev->vbase + TM_CFG) & ~TRUEIDE_PIO_TIMING_MASK;
738 val |= pio << TRUEIDE_PIO_TIMING_SHIFT;
739 writel(val, acdev->vbase + TM_CFG);
740
741 cf_interrupt_enable(acdev, BUF_AVAIL_IRQ | XFER_DONE_IRQ, 0);
742 cf_interrupt_enable(acdev, PIO_XFER_ERR_IRQ, 1);
743 spin_unlock_irqrestore(&acdev->host->lock, flags);
744}
745
746static void arasan_cf_set_dmamode(struct ata_port *ap, struct ata_device *adev)
747{
748 struct arasan_cf_dev *acdev = ap->host->private_data;
749 u32 opmode, tmcfg, dma_mode = adev->dma_mode;
750 unsigned long flags;
751
752 spin_lock_irqsave(&acdev->host->lock, flags);
753 opmode = readl(acdev->vbase + OP_MODE) &
754 ~(MULTI_WORD_DMA_ENB | ULTRA_DMA_ENB);
755 tmcfg = readl(acdev->vbase + TM_CFG);
756
757 if ((dma_mode >= XFER_UDMA_0) && (dma_mode <= XFER_UDMA_6)) {
758 opmode |= ULTRA_DMA_ENB;
759 tmcfg &= ~ULTRA_DMA_TIMING_MASK;
760 tmcfg |= (dma_mode - XFER_UDMA_0) << ULTRA_DMA_TIMING_SHIFT;
761 } else if ((dma_mode >= XFER_MW_DMA_0) && (dma_mode <= XFER_MW_DMA_4)) {
762 opmode |= MULTI_WORD_DMA_ENB;
763 tmcfg &= ~TRUEIDE_MWORD_DMA_TIMING_MASK;
764 tmcfg |= (dma_mode - XFER_MW_DMA_0) <<
765 TRUEIDE_MWORD_DMA_TIMING_SHIFT;
766 } else {
767 dev_err(ap->dev, "Unknown DMA mode\n");
768 spin_unlock_irqrestore(&acdev->host->lock, flags);
769 return;
770 }
771
772 writel(opmode, acdev->vbase + OP_MODE);
773 writel(tmcfg, acdev->vbase + TM_CFG);
774 writel(DMA_XFER_MODE, acdev->vbase + XFER_CTR);
775
776 cf_interrupt_enable(acdev, PIO_XFER_ERR_IRQ, 0);
777 cf_interrupt_enable(acdev, BUF_AVAIL_IRQ | XFER_DONE_IRQ, 1);
778 spin_unlock_irqrestore(&acdev->host->lock, flags);
779}
780
781static struct ata_port_operations arasan_cf_ops = {
782 .inherits = &ata_sff_port_ops,
783 .freeze = arasan_cf_freeze,
784 .error_handler = arasan_cf_error_handler,
785 .qc_issue = arasan_cf_qc_issue,
786 .set_piomode = arasan_cf_set_piomode,
787 .set_dmamode = arasan_cf_set_dmamode,
788};
789
790static int __devinit arasan_cf_probe(struct platform_device *pdev)
791{
792 struct arasan_cf_dev *acdev;
793 struct arasan_cf_pdata *pdata = dev_get_platdata(&pdev->dev);
794 struct ata_host *host;
795 struct ata_port *ap;
796 struct resource *res;
797 irq_handler_t irq_handler = NULL;
798 int ret = 0;
799
800 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
801 if (!res)
802 return -EINVAL;
803
804 if (!devm_request_mem_region(&pdev->dev, res->start, resource_size(res),
805 DRIVER_NAME)) {
806 dev_warn(&pdev->dev, "Failed to get memory region resource\n");
807 return -ENOENT;
808 }
809
810 acdev = devm_kzalloc(&pdev->dev, sizeof(*acdev), GFP_KERNEL);
811 if (!acdev) {
812 dev_warn(&pdev->dev, "kzalloc fail\n");
813 return -ENOMEM;
814 }
815
816 /* if irq is 0, support only PIO */
817 acdev->irq = platform_get_irq(pdev, 0);
818 if (acdev->irq)
819 irq_handler = arasan_cf_interrupt;
820 else
821 pdata->quirk |= CF_BROKEN_MWDMA | CF_BROKEN_UDMA;
822
823 acdev->pbase = res->start;
824 acdev->vbase = devm_ioremap_nocache(&pdev->dev, res->start,
825 resource_size(res));
826 if (!acdev->vbase) {
827 dev_warn(&pdev->dev, "ioremap fail\n");
828 return -ENOMEM;
829 }
830
831#ifdef CONFIG_HAVE_CLK
832 acdev->clk = clk_get(&pdev->dev, NULL);
833 if (IS_ERR(acdev->clk)) {
834 dev_warn(&pdev->dev, "Clock not found\n");
835 return PTR_ERR(acdev->clk);
836 }
837#endif
838
839 /* allocate host */
840 host = ata_host_alloc(&pdev->dev, 1);
841 if (!host) {
842 ret = -ENOMEM;
843 dev_warn(&pdev->dev, "alloc host fail\n");
844 goto free_clk;
845 }
846
847 ap = host->ports[0];
848 host->private_data = acdev;
849 acdev->host = host;
850 ap->ops = &arasan_cf_ops;
851 ap->pio_mask = ATA_PIO6;
852 ap->mwdma_mask = ATA_MWDMA4;
853 ap->udma_mask = ATA_UDMA6;
854
855 init_completion(&acdev->cf_completion);
856 init_completion(&acdev->dma_completion);
857 INIT_WORK(&acdev->work, data_xfer);
858 INIT_DELAYED_WORK(&acdev->dwork, delayed_finish);
859 dma_cap_set(DMA_MEMCPY, acdev->mask);
860 acdev->dma_priv = pdata->dma_priv;
861
862 /* Handle platform specific quirks */
863 if (pdata->quirk) {
864 if (pdata->quirk & CF_BROKEN_PIO) {
865 ap->ops->set_piomode = NULL;
866 ap->pio_mask = 0;
867 }
868 if (pdata->quirk & CF_BROKEN_MWDMA)
869 ap->mwdma_mask = 0;
870 if (pdata->quirk & CF_BROKEN_UDMA)
871 ap->udma_mask = 0;
872 }
873 ap->flags |= ATA_FLAG_PIO_POLLING | ATA_FLAG_NO_ATAPI;
874
875 ap->ioaddr.cmd_addr = acdev->vbase + ATA_DATA_PORT;
876 ap->ioaddr.data_addr = acdev->vbase + ATA_DATA_PORT;
877 ap->ioaddr.error_addr = acdev->vbase + ATA_ERR_FTR;
878 ap->ioaddr.feature_addr = acdev->vbase + ATA_ERR_FTR;
879 ap->ioaddr.nsect_addr = acdev->vbase + ATA_SC;
880 ap->ioaddr.lbal_addr = acdev->vbase + ATA_SN;
881 ap->ioaddr.lbam_addr = acdev->vbase + ATA_CL;
882 ap->ioaddr.lbah_addr = acdev->vbase + ATA_CH;
883 ap->ioaddr.device_addr = acdev->vbase + ATA_SH;
884 ap->ioaddr.status_addr = acdev->vbase + ATA_STS_CMD;
885 ap->ioaddr.command_addr = acdev->vbase + ATA_STS_CMD;
886 ap->ioaddr.altstatus_addr = acdev->vbase + ATA_ASTS_DCTR;
887 ap->ioaddr.ctl_addr = acdev->vbase + ATA_ASTS_DCTR;
888
889 ata_port_desc(ap, "phy_addr %llx virt_addr %p",
890 (unsigned long long) res->start, acdev->vbase);
891
892 ret = cf_init(acdev);
893 if (ret)
894 goto free_clk;
895
896 cf_card_detect(acdev, 0);
897
898 return ata_host_activate(host, acdev->irq, irq_handler, 0,
899 &arasan_cf_sht);
900
901free_clk:
902#ifdef CONFIG_HAVE_CLK
903 clk_put(acdev->clk);
904#endif
905 return ret;
906}
907
908static int __devexit arasan_cf_remove(struct platform_device *pdev)
909{
910 struct ata_host *host = dev_get_drvdata(&pdev->dev);
911 struct arasan_cf_dev *acdev = host->ports[0]->private_data;
912
913 ata_host_detach(host);
914 cf_exit(acdev);
915#ifdef CONFIG_HAVE_CLK
916 clk_put(acdev->clk);
917#endif
918
919 return 0;
920}
921
922#ifdef CONFIG_PM
923static int arasan_cf_suspend(struct device *dev)
924{
925 struct platform_device *pdev = to_platform_device(dev);
926 struct ata_host *host = dev_get_drvdata(&pdev->dev);
927 struct arasan_cf_dev *acdev = host->ports[0]->private_data;
928
929 if (acdev->dma_chan) {
930 acdev->dma_chan->device->device_control(acdev->dma_chan,
931 DMA_TERMINATE_ALL, 0);
932 dma_release_channel(acdev->dma_chan);
933 }
934 cf_exit(acdev);
935 return ata_host_suspend(host, PMSG_SUSPEND);
936}
937
938static int arasan_cf_resume(struct device *dev)
939{
940 struct platform_device *pdev = to_platform_device(dev);
941 struct ata_host *host = dev_get_drvdata(&pdev->dev);
942 struct arasan_cf_dev *acdev = host->ports[0]->private_data;
943
944 cf_init(acdev);
945 ata_host_resume(host);
946
947 return 0;
948}
949
950static const struct dev_pm_ops arasan_cf_pm_ops = {
951 .suspend = arasan_cf_suspend,
952 .resume = arasan_cf_resume,
953};
954#endif
955
956static struct platform_driver arasan_cf_driver = {
957 .probe = arasan_cf_probe,
958 .remove = __devexit_p(arasan_cf_remove),
959 .driver = {
960 .name = DRIVER_NAME,
961 .owner = THIS_MODULE,
962#ifdef CONFIG_PM
963 .pm = &arasan_cf_pm_ops,
964#endif
965 },
966};
967
968static int __init arasan_cf_init(void)
969{
970 return platform_driver_register(&arasan_cf_driver);
971}
972module_init(arasan_cf_init);
973
974static void __exit arasan_cf_exit(void)
975{
976 platform_driver_unregister(&arasan_cf_driver);
977}
978module_exit(arasan_cf_exit);
979
980MODULE_AUTHOR("Viresh Kumar <viresh.kumar@st.com>");
981MODULE_DESCRIPTION("Arasan ATA Compact Flash driver");
982MODULE_LICENSE("GPL");
983MODULE_ALIAS("platform:" DRIVER_NAME);
diff --git a/drivers/ata/pata_at32.c b/drivers/ata/pata_at32.c
index 66ce6a526f27..36f189c7ee8c 100644
--- a/drivers/ata/pata_at32.c
+++ b/drivers/ata/pata_at32.c
@@ -194,7 +194,7 @@ static int __init pata_at32_init_one(struct device *dev,
194 /* Setup ATA bindings */ 194 /* Setup ATA bindings */
195 ap->ops = &at32_port_ops; 195 ap->ops = &at32_port_ops;
196 ap->pio_mask = PIO_MASK; 196 ap->pio_mask = PIO_MASK;
197 ap->flags |= ATA_FLAG_MMIO | ATA_FLAG_SLAVE_POSS; 197 ap->flags |= ATA_FLAG_SLAVE_POSS;
198 198
199 /* 199 /*
200 * Since all 8-bit taskfile transfers has to go on the lower 200 * Since all 8-bit taskfile transfers has to go on the lower
diff --git a/drivers/ata/pata_bf54x.c b/drivers/ata/pata_bf54x.c
index 7aed5c792597..e0b58b8dfe6f 100644
--- a/drivers/ata/pata_bf54x.c
+++ b/drivers/ata/pata_bf54x.c
@@ -1454,9 +1454,7 @@ static struct ata_port_operations bfin_pata_ops = {
1454 1454
1455static struct ata_port_info bfin_port_info[] = { 1455static struct ata_port_info bfin_port_info[] = {
1456 { 1456 {
1457 .flags = ATA_FLAG_SLAVE_POSS 1457 .flags = ATA_FLAG_SLAVE_POSS,
1458 | ATA_FLAG_MMIO
1459 | ATA_FLAG_NO_LEGACY,
1460 .pio_mask = ATA_PIO4, 1458 .pio_mask = ATA_PIO4,
1461 .mwdma_mask = 0, 1459 .mwdma_mask = 0,
1462 .udma_mask = 0, 1460 .udma_mask = 0,
diff --git a/drivers/ata/pata_hpt366.c b/drivers/ata/pata_hpt366.c
index 538ec38ba995..6c77d68dbd05 100644
--- a/drivers/ata/pata_hpt366.c
+++ b/drivers/ata/pata_hpt366.c
@@ -14,6 +14,7 @@
14 * Look into engine reset on timeout errors. Should not be required. 14 * Look into engine reset on timeout errors. Should not be required.
15 */ 15 */
16 16
17#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
17 18
18#include <linux/kernel.h> 19#include <linux/kernel.h>
19#include <linux/module.h> 20#include <linux/module.h>
@@ -25,7 +26,7 @@
25#include <linux/libata.h> 26#include <linux/libata.h>
26 27
27#define DRV_NAME "pata_hpt366" 28#define DRV_NAME "pata_hpt366"
28#define DRV_VERSION "0.6.10" 29#define DRV_VERSION "0.6.11"
29 30
30struct hpt_clock { 31struct hpt_clock {
31 u8 xfer_mode; 32 u8 xfer_mode;
@@ -160,8 +161,8 @@ static int hpt_dma_blacklisted(const struct ata_device *dev, char *modestr,
160 161
161 while (list[i] != NULL) { 162 while (list[i] != NULL) {
162 if (!strcmp(list[i], model_num)) { 163 if (!strcmp(list[i], model_num)) {
163 pr_warning(DRV_NAME ": %s is not supported for %s.\n", 164 pr_warn("%s is not supported for %s\n",
164 modestr, list[i]); 165 modestr, list[i]);
165 return 1; 166 return 1;
166 } 167 }
167 i++; 168 i++;
diff --git a/drivers/ata/pata_hpt37x.c b/drivers/ata/pata_hpt37x.c
index 4c5b5183225e..9620636aa405 100644
--- a/drivers/ata/pata_hpt37x.c
+++ b/drivers/ata/pata_hpt37x.c
@@ -14,6 +14,8 @@
14 * Look into engine reset on timeout errors. Should not be required. 14 * Look into engine reset on timeout errors. Should not be required.
15 */ 15 */
16 16
17#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
18
17#include <linux/kernel.h> 19#include <linux/kernel.h>
18#include <linux/module.h> 20#include <linux/module.h>
19#include <linux/pci.h> 21#include <linux/pci.h>
@@ -24,7 +26,7 @@
24#include <linux/libata.h> 26#include <linux/libata.h>
25 27
26#define DRV_NAME "pata_hpt37x" 28#define DRV_NAME "pata_hpt37x"
27#define DRV_VERSION "0.6.22" 29#define DRV_VERSION "0.6.23"
28 30
29struct hpt_clock { 31struct hpt_clock {
30 u8 xfer_speed; 32 u8 xfer_speed;
@@ -229,8 +231,8 @@ static int hpt_dma_blacklisted(const struct ata_device *dev, char *modestr,
229 231
230 while (list[i] != NULL) { 232 while (list[i] != NULL) {
231 if (!strcmp(list[i], model_num)) { 233 if (!strcmp(list[i], model_num)) {
232 pr_warning(DRV_NAME ": %s is not supported for %s.\n", 234 pr_warn("%s is not supported for %s\n",
233 modestr, list[i]); 235 modestr, list[i]);
234 return 1; 236 return 1;
235 } 237 }
236 i++; 238 i++;
@@ -863,8 +865,8 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
863 chip_table = &hpt372; 865 chip_table = &hpt372;
864 break; 866 break;
865 default: 867 default:
866 pr_err(DRV_NAME ": Unknown HPT366 subtype, " 868 pr_err("Unknown HPT366 subtype, please report (%d)\n",
867 "please report (%d).\n", rev); 869 rev);
868 return -ENODEV; 870 return -ENODEV;
869 } 871 }
870 break; 872 break;
@@ -904,8 +906,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
904 *ppi = &info_hpt374_fn1; 906 *ppi = &info_hpt374_fn1;
905 break; 907 break;
906 default: 908 default:
907 pr_err(DRV_NAME ": PCI table is bogus, please report (%d).\n", 909 pr_err("PCI table is bogus, please report (%d)\n", dev->device);
908 dev->device);
909 return -ENODEV; 910 return -ENODEV;
910 } 911 }
911 /* Ok so this is a chip we support */ 912 /* Ok so this is a chip we support */
@@ -953,7 +954,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
953 u8 sr; 954 u8 sr;
954 u32 total = 0; 955 u32 total = 0;
955 956
956 pr_warning(DRV_NAME ": BIOS has not set timing clocks.\n"); 957 pr_warn("BIOS has not set timing clocks\n");
957 958
958 /* This is the process the HPT371 BIOS is reported to use */ 959 /* This is the process the HPT371 BIOS is reported to use */
959 for (i = 0; i < 128; i++) { 960 for (i = 0; i < 128; i++) {
@@ -1009,7 +1010,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
1009 (f_high << 16) | f_low | 0x100); 1010 (f_high << 16) | f_low | 0x100);
1010 } 1011 }
1011 if (adjust == 8) { 1012 if (adjust == 8) {
1012 pr_err(DRV_NAME ": DPLL did not stabilize!\n"); 1013 pr_err("DPLL did not stabilize!\n");
1013 return -ENODEV; 1014 return -ENODEV;
1014 } 1015 }
1015 if (dpll == 3) 1016 if (dpll == 3)
@@ -1017,7 +1018,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
1017 else 1018 else
1018 private_data = (void *)hpt37x_timings_50; 1019 private_data = (void *)hpt37x_timings_50;
1019 1020
1020 pr_info(DRV_NAME ": bus clock %dMHz, using %dMHz DPLL.\n", 1021 pr_info("bus clock %dMHz, using %dMHz DPLL\n",
1021 MHz[clock_slot], MHz[dpll]); 1022 MHz[clock_slot], MHz[dpll]);
1022 } else { 1023 } else {
1023 private_data = (void *)chip_table->clocks[clock_slot]; 1024 private_data = (void *)chip_table->clocks[clock_slot];
@@ -1032,7 +1033,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
1032 if (clock_slot < 2 && ppi[0] == &info_hpt370a) 1033 if (clock_slot < 2 && ppi[0] == &info_hpt370a)
1033 ppi[0] = &info_hpt370a_33; 1034 ppi[0] = &info_hpt370a_33;
1034 1035
1035 pr_info(DRV_NAME ": %s using %dMHz bus clock.\n", 1036 pr_info("%s using %dMHz bus clock\n",
1036 chip_table->name, MHz[clock_slot]); 1037 chip_table->name, MHz[clock_slot]);
1037 } 1038 }
1038 1039
diff --git a/drivers/ata/pata_hpt3x2n.c b/drivers/ata/pata_hpt3x2n.c
index eca68caf5f46..765f136d8cd3 100644
--- a/drivers/ata/pata_hpt3x2n.c
+++ b/drivers/ata/pata_hpt3x2n.c
@@ -15,6 +15,8 @@
15 * Work out best PLL policy 15 * Work out best PLL policy
16 */ 16 */
17 17
18#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
19
18#include <linux/kernel.h> 20#include <linux/kernel.h>
19#include <linux/module.h> 21#include <linux/module.h>
20#include <linux/pci.h> 22#include <linux/pci.h>
@@ -25,7 +27,7 @@
25#include <linux/libata.h> 27#include <linux/libata.h>
26 28
27#define DRV_NAME "pata_hpt3x2n" 29#define DRV_NAME "pata_hpt3x2n"
28#define DRV_VERSION "0.3.14" 30#define DRV_VERSION "0.3.15"
29 31
30enum { 32enum {
31 HPT_PCI_FAST = (1 << 31), 33 HPT_PCI_FAST = (1 << 31),
@@ -418,7 +420,7 @@ static int hpt3x2n_pci_clock(struct pci_dev *pdev)
418 u16 sr; 420 u16 sr;
419 u32 total = 0; 421 u32 total = 0;
420 422
421 pr_warning(DRV_NAME ": BIOS clock data not set.\n"); 423 pr_warn("BIOS clock data not set\n");
422 424
423 /* This is the process the HPT371 BIOS is reported to use */ 425 /* This is the process the HPT371 BIOS is reported to use */
424 for (i = 0; i < 128; i++) { 426 for (i = 0; i < 128; i++) {
@@ -528,8 +530,7 @@ hpt372n:
528 ppi[0] = &info_hpt372n; 530 ppi[0] = &info_hpt372n;
529 break; 531 break;
530 default: 532 default:
531 pr_err(DRV_NAME ": PCI table is bogus, please report (%d).\n", 533 pr_err("PCI table is bogus, please report (%d)\n", dev->device);
532 dev->device);
533 return -ENODEV; 534 return -ENODEV;
534 } 535 }
535 536
@@ -578,11 +579,11 @@ hpt372n:
578 pci_write_config_dword(dev, 0x5C, (f_high << 16) | f_low); 579 pci_write_config_dword(dev, 0x5C, (f_high << 16) | f_low);
579 } 580 }
580 if (adjust == 8) { 581 if (adjust == 8) {
581 pr_err(DRV_NAME ": DPLL did not stabilize!\n"); 582 pr_err("DPLL did not stabilize!\n");
582 return -ENODEV; 583 return -ENODEV;
583 } 584 }
584 585
585 pr_info(DRV_NAME ": bus clock %dMHz, using 66MHz DPLL.\n", pci_mhz); 586 pr_info("bus clock %dMHz, using 66MHz DPLL\n", pci_mhz);
586 587
587 /* 588 /*
588 * Set our private data up. We only need a few flags 589 * Set our private data up. We only need a few flags
diff --git a/drivers/ata/pata_hpt3x3.c b/drivers/ata/pata_hpt3x3.c
index b63d5e2d4628..24d7df81546b 100644
--- a/drivers/ata/pata_hpt3x3.c
+++ b/drivers/ata/pata_hpt3x3.c
@@ -151,7 +151,7 @@ static struct ata_port_operations hpt3x3_port_ops = {
151 .check_atapi_dma= hpt3x3_atapi_dma, 151 .check_atapi_dma= hpt3x3_atapi_dma,
152 .freeze = hpt3x3_freeze, 152 .freeze = hpt3x3_freeze,
153#endif 153#endif
154 154
155}; 155};
156 156
157/** 157/**
diff --git a/drivers/ata/pata_it821x.c b/drivers/ata/pata_it821x.c
index aa0e0c51cc08..2d15f2548a10 100644
--- a/drivers/ata/pata_it821x.c
+++ b/drivers/ata/pata_it821x.c
@@ -616,7 +616,7 @@ static void it821x_display_disk(int n, u8 *buf)
616 if (buf[52] > 4) /* No Disk */ 616 if (buf[52] > 4) /* No Disk */
617 return; 617 return;
618 618
619 ata_id_c_string((u16 *)buf, id, 0, 41); 619 ata_id_c_string((u16 *)buf, id, 0, 41);
620 620
621 if (buf[51]) { 621 if (buf[51]) {
622 mode = ffs(buf[51]); 622 mode = ffs(buf[51]);
@@ -910,7 +910,7 @@ static int it821x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
910 rc = pcim_enable_device(pdev); 910 rc = pcim_enable_device(pdev);
911 if (rc) 911 if (rc)
912 return rc; 912 return rc;
913 913
914 if (pdev->vendor == PCI_VENDOR_ID_RDC) { 914 if (pdev->vendor == PCI_VENDOR_ID_RDC) {
915 /* Deal with Vortex86SX */ 915 /* Deal with Vortex86SX */
916 if (pdev->revision == 0x11) 916 if (pdev->revision == 0x11)
diff --git a/drivers/ata/pata_ixp4xx_cf.c b/drivers/ata/pata_ixp4xx_cf.c
index ba54b089f98c..5253b271b3fe 100644
--- a/drivers/ata/pata_ixp4xx_cf.c
+++ b/drivers/ata/pata_ixp4xx_cf.c
@@ -177,7 +177,7 @@ static __devinit int ixp4xx_pata_probe(struct platform_device *pdev)
177 177
178 ap->ops = &ixp4xx_port_ops; 178 ap->ops = &ixp4xx_port_ops;
179 ap->pio_mask = ATA_PIO4; 179 ap->pio_mask = ATA_PIO4;
180 ap->flags |= ATA_FLAG_MMIO | ATA_FLAG_NO_LEGACY | ATA_FLAG_NO_ATAPI; 180 ap->flags |= ATA_FLAG_NO_ATAPI;
181 181
182 ixp4xx_setup_port(ap, data, cs0->start, cs1->start); 182 ixp4xx_setup_port(ap, data, cs0->start, cs1->start);
183 183
diff --git a/drivers/ata/pata_macio.c b/drivers/ata/pata_macio.c
index 75b49d01780b..46f589edccdb 100644
--- a/drivers/ata/pata_macio.c
+++ b/drivers/ata/pata_macio.c
@@ -1053,8 +1053,7 @@ static int __devinit pata_macio_common_init(struct pata_macio_priv *priv,
1053 /* Allocate libata host for 1 port */ 1053 /* Allocate libata host for 1 port */
1054 memset(&pinfo, 0, sizeof(struct ata_port_info)); 1054 memset(&pinfo, 0, sizeof(struct ata_port_info));
1055 pmac_macio_calc_timing_masks(priv, &pinfo); 1055 pmac_macio_calc_timing_masks(priv, &pinfo);
1056 pinfo.flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_MMIO | 1056 pinfo.flags = ATA_FLAG_SLAVE_POSS;
1057 ATA_FLAG_NO_LEGACY;
1058 pinfo.port_ops = &pata_macio_ops; 1057 pinfo.port_ops = &pata_macio_ops;
1059 pinfo.private_data = priv; 1058 pinfo.private_data = priv;
1060 1059
diff --git a/drivers/ata/pata_marvell.c b/drivers/ata/pata_marvell.c
index dd38083dcbeb..75a6a0c0094f 100644
--- a/drivers/ata/pata_marvell.c
+++ b/drivers/ata/pata_marvell.c
@@ -38,7 +38,7 @@ static int marvell_pata_active(struct pci_dev *pdev)
38 38
39 /* We don't yet know how to do this for other devices */ 39 /* We don't yet know how to do this for other devices */
40 if (pdev->device != 0x6145) 40 if (pdev->device != 0x6145)
41 return 1; 41 return 1;
42 42
43 barp = pci_iomap(pdev, 5, 0x10); 43 barp = pci_iomap(pdev, 5, 0x10);
44 if (barp == NULL) 44 if (barp == NULL)
diff --git a/drivers/ata/pata_ninja32.c b/drivers/ata/pata_ninja32.c
index cc50bd09aa26..e277a142138c 100644
--- a/drivers/ata/pata_ninja32.c
+++ b/drivers/ata/pata_ninja32.c
@@ -165,7 +165,7 @@ static int ninja32_reinit_one(struct pci_dev *pdev)
165 return rc; 165 return rc;
166 ninja32_program(host->iomap[0]); 166 ninja32_program(host->iomap[0]);
167 ata_host_resume(host); 167 ata_host_resume(host);
168 return 0; 168 return 0;
169} 169}
170#endif 170#endif
171 171
diff --git a/drivers/ata/pata_octeon_cf.c b/drivers/ata/pata_octeon_cf.c
index fa1b95a9a7ff..220ddc90608f 100644
--- a/drivers/ata/pata_octeon_cf.c
+++ b/drivers/ata/pata_octeon_cf.c
@@ -848,8 +848,7 @@ static int __devinit octeon_cf_probe(struct platform_device *pdev)
848 cf_port->ap = ap; 848 cf_port->ap = ap;
849 ap->ops = &octeon_cf_ops; 849 ap->ops = &octeon_cf_ops;
850 ap->pio_mask = ATA_PIO6; 850 ap->pio_mask = ATA_PIO6;
851 ap->flags |= ATA_FLAG_MMIO | ATA_FLAG_NO_LEGACY 851 ap->flags |= ATA_FLAG_NO_ATAPI | ATA_FLAG_PIO_POLLING;
852 | ATA_FLAG_NO_ATAPI | ATA_FLAG_PIO_POLLING;
853 852
854 base = cs0 + ocd->base_region_bias; 853 base = cs0 + ocd->base_region_bias;
855 if (!ocd->is16bit) { 854 if (!ocd->is16bit) {
diff --git a/drivers/ata/pata_palmld.c b/drivers/ata/pata_palmld.c
index 11fb4ccc74b4..a2a73d953840 100644
--- a/drivers/ata/pata_palmld.c
+++ b/drivers/ata/pata_palmld.c
@@ -85,7 +85,7 @@ static __devinit int palmld_pata_probe(struct platform_device *pdev)
85 ap = host->ports[0]; 85 ap = host->ports[0];
86 ap->ops = &palmld_port_ops; 86 ap->ops = &palmld_port_ops;
87 ap->pio_mask = ATA_PIO4; 87 ap->pio_mask = ATA_PIO4;
88 ap->flags |= ATA_FLAG_MMIO | ATA_FLAG_NO_LEGACY | ATA_FLAG_PIO_POLLING; 88 ap->flags |= ATA_FLAG_PIO_POLLING;
89 89
90 /* memory mapping voodoo */ 90 /* memory mapping voodoo */
91 ap->ioaddr.cmd_addr = mem + 0x10; 91 ap->ioaddr.cmd_addr = mem + 0x10;
diff --git a/drivers/ata/pata_pcmcia.c b/drivers/ata/pata_pcmcia.c
index 806292160b3f..29af660d968b 100644
--- a/drivers/ata/pata_pcmcia.c
+++ b/drivers/ata/pata_pcmcia.c
@@ -124,7 +124,7 @@ static unsigned int ata_data_xfer_8bit(struct ata_device *dev,
124 * reset will recover the device. 124 * reset will recover the device.
125 * 125 *
126 */ 126 */
127 127
128static void pcmcia_8bit_drain_fifo(struct ata_queued_cmd *qc) 128static void pcmcia_8bit_drain_fifo(struct ata_queued_cmd *qc)
129{ 129{
130 int count; 130 int count;
diff --git a/drivers/ata/pata_pdc2027x.c b/drivers/ata/pata_pdc2027x.c
index b18351122525..9765ace16921 100644
--- a/drivers/ata/pata_pdc2027x.c
+++ b/drivers/ata/pata_pdc2027x.c
@@ -150,8 +150,7 @@ static struct ata_port_operations pdc2027x_pata133_ops = {
150static struct ata_port_info pdc2027x_port_info[] = { 150static struct ata_port_info pdc2027x_port_info[] = {
151 /* PDC_UDMA_100 */ 151 /* PDC_UDMA_100 */
152 { 152 {
153 .flags = ATA_FLAG_NO_LEGACY | ATA_FLAG_SLAVE_POSS | 153 .flags = ATA_FLAG_SLAVE_POSS,
154 ATA_FLAG_MMIO,
155 .pio_mask = ATA_PIO4, 154 .pio_mask = ATA_PIO4,
156 .mwdma_mask = ATA_MWDMA2, 155 .mwdma_mask = ATA_MWDMA2,
157 .udma_mask = ATA_UDMA5, 156 .udma_mask = ATA_UDMA5,
@@ -159,8 +158,7 @@ static struct ata_port_info pdc2027x_port_info[] = {
159 }, 158 },
160 /* PDC_UDMA_133 */ 159 /* PDC_UDMA_133 */
161 { 160 {
162 .flags = ATA_FLAG_NO_LEGACY | ATA_FLAG_SLAVE_POSS | 161 .flags = ATA_FLAG_SLAVE_POSS,
163 ATA_FLAG_MMIO,
164 .pio_mask = ATA_PIO4, 162 .pio_mask = ATA_PIO4,
165 .mwdma_mask = ATA_MWDMA2, 163 .mwdma_mask = ATA_MWDMA2,
166 .udma_mask = ATA_UDMA6, 164 .udma_mask = ATA_UDMA6,
diff --git a/drivers/ata/pata_pxa.c b/drivers/ata/pata_pxa.c
index 1898c6ed4b4e..b4ede40f8ae1 100644
--- a/drivers/ata/pata_pxa.c
+++ b/drivers/ata/pata_pxa.c
@@ -292,7 +292,6 @@ static int __devinit pxa_ata_probe(struct platform_device *pdev)
292 ap->ops = &pxa_ata_port_ops; 292 ap->ops = &pxa_ata_port_ops;
293 ap->pio_mask = ATA_PIO4; 293 ap->pio_mask = ATA_PIO4;
294 ap->mwdma_mask = ATA_MWDMA2; 294 ap->mwdma_mask = ATA_MWDMA2;
295 ap->flags = ATA_FLAG_MMIO;
296 295
297 ap->ioaddr.cmd_addr = devm_ioremap(&pdev->dev, cmd_res->start, 296 ap->ioaddr.cmd_addr = devm_ioremap(&pdev->dev, cmd_res->start,
298 resource_size(cmd_res)); 297 resource_size(cmd_res));
diff --git a/drivers/ata/pata_rb532_cf.c b/drivers/ata/pata_rb532_cf.c
index 0ffd631000b7..baeaf938d55b 100644
--- a/drivers/ata/pata_rb532_cf.c
+++ b/drivers/ata/pata_rb532_cf.c
@@ -91,7 +91,6 @@ static void rb532_pata_setup_ports(struct ata_host *ah)
91 91
92 ap->ops = &rb532_pata_port_ops; 92 ap->ops = &rb532_pata_port_ops;
93 ap->pio_mask = ATA_PIO4; 93 ap->pio_mask = ATA_PIO4;
94 ap->flags = ATA_FLAG_NO_LEGACY | ATA_FLAG_MMIO;
95 94
96 ap->ioaddr.cmd_addr = info->iobase + RB500_CF_REG_BASE; 95 ap->ioaddr.cmd_addr = info->iobase + RB500_CF_REG_BASE;
97 ap->ioaddr.ctl_addr = info->iobase + RB500_CF_REG_CTRL; 96 ap->ioaddr.ctl_addr = info->iobase + RB500_CF_REG_CTRL;
diff --git a/drivers/ata/pata_samsung_cf.c b/drivers/ata/pata_samsung_cf.c
index 8a51d673e5b2..c446ae6055a3 100644
--- a/drivers/ata/pata_samsung_cf.c
+++ b/drivers/ata/pata_samsung_cf.c
@@ -531,7 +531,6 @@ static int __init pata_s3c_probe(struct platform_device *pdev)
531 } 531 }
532 532
533 ap = host->ports[0]; 533 ap = host->ports[0];
534 ap->flags |= ATA_FLAG_MMIO;
535 ap->pio_mask = ATA_PIO4; 534 ap->pio_mask = ATA_PIO4;
536 535
537 if (cpu_type == TYPE_S3C64XX) { 536 if (cpu_type == TYPE_S3C64XX) {
diff --git a/drivers/ata/pata_scc.c b/drivers/ata/pata_scc.c
index 093715c3273a..88ea9b677b47 100644
--- a/drivers/ata/pata_scc.c
+++ b/drivers/ata/pata_scc.c
@@ -959,7 +959,7 @@ static struct ata_port_operations scc_pata_ops = {
959 959
960static struct ata_port_info scc_port_info[] = { 960static struct ata_port_info scc_port_info[] = {
961 { 961 {
962 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_MMIO | ATA_FLAG_NO_LEGACY, 962 .flags = ATA_FLAG_SLAVE_POSS,
963 .pio_mask = ATA_PIO4, 963 .pio_mask = ATA_PIO4,
964 /* No MWDMA */ 964 /* No MWDMA */
965 .udma_mask = ATA_UDMA6, 965 .udma_mask = ATA_UDMA6,
diff --git a/drivers/ata/pata_sis.c b/drivers/ata/pata_sis.c
index 60cea13cccce..c04abc393fc5 100644
--- a/drivers/ata/pata_sis.c
+++ b/drivers/ata/pata_sis.c
@@ -593,7 +593,7 @@ static const struct ata_port_info sis_info133 = {
593 .port_ops = &sis_133_ops, 593 .port_ops = &sis_133_ops,
594}; 594};
595const struct ata_port_info sis_info133_for_sata = { 595const struct ata_port_info sis_info133_for_sata = {
596 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST, 596 .flags = ATA_FLAG_SLAVE_POSS,
597 .pio_mask = ATA_PIO4, 597 .pio_mask = ATA_PIO4,
598 /* No MWDMA */ 598 /* No MWDMA */
599 .udma_mask = ATA_UDMA6, 599 .udma_mask = ATA_UDMA6,
diff --git a/drivers/ata/pdc_adma.c b/drivers/ata/pdc_adma.c
index adbe0426c8f0..1111712b3d7d 100644
--- a/drivers/ata/pdc_adma.c
+++ b/drivers/ata/pdc_adma.c
@@ -166,9 +166,7 @@ static struct ata_port_operations adma_ata_ops = {
166static struct ata_port_info adma_port_info[] = { 166static struct ata_port_info adma_port_info[] = {
167 /* board_1841_idx */ 167 /* board_1841_idx */
168 { 168 {
169 .flags = ATA_FLAG_SLAVE_POSS | 169 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_PIO_POLLING,
170 ATA_FLAG_NO_LEGACY | ATA_FLAG_MMIO |
171 ATA_FLAG_PIO_POLLING,
172 .pio_mask = ATA_PIO4_ONLY, 170 .pio_mask = ATA_PIO4_ONLY,
173 .udma_mask = ATA_UDMA4, 171 .udma_mask = ATA_UDMA4,
174 .port_ops = &adma_ata_ops, 172 .port_ops = &adma_ata_ops,
diff --git a/drivers/ata/sata_dwc_460ex.c b/drivers/ata/sata_dwc_460ex.c
index 6cf57c5c2b5f..712ab5a4922e 100644
--- a/drivers/ata/sata_dwc_460ex.c
+++ b/drivers/ata/sata_dwc_460ex.c
@@ -40,8 +40,11 @@
40#include <scsi/scsi_host.h> 40#include <scsi/scsi_host.h>
41#include <scsi/scsi_cmnd.h> 41#include <scsi/scsi_cmnd.h>
42 42
43/* These two are defined in "libata.h" */
44#undef DRV_NAME
45#undef DRV_VERSION
43#define DRV_NAME "sata-dwc" 46#define DRV_NAME "sata-dwc"
44#define DRV_VERSION "1.0" 47#define DRV_VERSION "1.3"
45 48
46/* SATA DMA driver Globals */ 49/* SATA DMA driver Globals */
47#define DMA_NUM_CHANS 1 50#define DMA_NUM_CHANS 1
@@ -333,11 +336,47 @@ static int dma_dwc_xfer_setup(struct scatterlist *sg, int num_elems,
333 void __iomem *addr, int dir); 336 void __iomem *addr, int dir);
334static void dma_dwc_xfer_start(int dma_ch); 337static void dma_dwc_xfer_start(int dma_ch);
335 338
339static const char *get_prot_descript(u8 protocol)
340{
341 switch ((enum ata_tf_protocols)protocol) {
342 case ATA_PROT_NODATA:
343 return "ATA no data";
344 case ATA_PROT_PIO:
345 return "ATA PIO";
346 case ATA_PROT_DMA:
347 return "ATA DMA";
348 case ATA_PROT_NCQ:
349 return "ATA NCQ";
350 case ATAPI_PROT_NODATA:
351 return "ATAPI no data";
352 case ATAPI_PROT_PIO:
353 return "ATAPI PIO";
354 case ATAPI_PROT_DMA:
355 return "ATAPI DMA";
356 default:
357 return "unknown";
358 }
359}
360
361static const char *get_dma_dir_descript(int dma_dir)
362{
363 switch ((enum dma_data_direction)dma_dir) {
364 case DMA_BIDIRECTIONAL:
365 return "bidirectional";
366 case DMA_TO_DEVICE:
367 return "to device";
368 case DMA_FROM_DEVICE:
369 return "from device";
370 default:
371 return "none";
372 }
373}
374
336static void sata_dwc_tf_dump(struct ata_taskfile *tf) 375static void sata_dwc_tf_dump(struct ata_taskfile *tf)
337{ 376{
338 dev_vdbg(host_pvt.dwc_dev, "taskfile cmd: 0x%02x protocol: %s flags:" 377 dev_vdbg(host_pvt.dwc_dev, "taskfile cmd: 0x%02x protocol: %s flags:"
339 "0x%lx device: %x\n", tf->command, ata_get_cmd_descript\ 378 "0x%lx device: %x\n", tf->command,
340 (tf->protocol), tf->flags, tf->device); 379 get_prot_descript(tf->protocol), tf->flags, tf->device);
341 dev_vdbg(host_pvt.dwc_dev, "feature: 0x%02x nsect: 0x%x lbal: 0x%x " 380 dev_vdbg(host_pvt.dwc_dev, "feature: 0x%02x nsect: 0x%x lbal: 0x%x "
342 "lbam: 0x%x lbah: 0x%x\n", tf->feature, tf->nsect, tf->lbal, 381 "lbam: 0x%x lbah: 0x%x\n", tf->feature, tf->nsect, tf->lbal,
343 tf->lbam, tf->lbah); 382 tf->lbam, tf->lbah);
@@ -715,7 +754,7 @@ static int dma_dwc_xfer_setup(struct scatterlist *sg, int num_elems,
715 /* Program the CTL register with src enable / dst enable */ 754 /* Program the CTL register with src enable / dst enable */
716 out_le32(&(host_pvt.sata_dma_regs->chan_regs[dma_ch].ctl.low), 755 out_le32(&(host_pvt.sata_dma_regs->chan_regs[dma_ch].ctl.low),
717 DMA_CTL_LLP_SRCEN | DMA_CTL_LLP_DSTEN); 756 DMA_CTL_LLP_SRCEN | DMA_CTL_LLP_DSTEN);
718 return 0; 757 return dma_ch;
719} 758}
720 759
721/* 760/*
@@ -967,7 +1006,7 @@ static irqreturn_t sata_dwc_isr(int irq, void *dev_instance)
967 } 1006 }
968 1007
969 dev_dbg(ap->dev, "%s non-NCQ cmd interrupt, protocol: %s\n", 1008 dev_dbg(ap->dev, "%s non-NCQ cmd interrupt, protocol: %s\n",
970 __func__, ata_get_cmd_descript(qc->tf.protocol)); 1009 __func__, get_prot_descript(qc->tf.protocol));
971DRVSTILLBUSY: 1010DRVSTILLBUSY:
972 if (ata_is_dma(qc->tf.protocol)) { 1011 if (ata_is_dma(qc->tf.protocol)) {
973 /* 1012 /*
@@ -1057,7 +1096,7 @@ DRVSTILLBUSY:
1057 1096
1058 /* Process completed command */ 1097 /* Process completed command */
1059 dev_dbg(ap->dev, "%s NCQ command, protocol: %s\n", __func__, 1098 dev_dbg(ap->dev, "%s NCQ command, protocol: %s\n", __func__,
1060 ata_get_cmd_descript(qc->tf.protocol)); 1099 get_prot_descript(qc->tf.protocol));
1061 if (ata_is_dma(qc->tf.protocol)) { 1100 if (ata_is_dma(qc->tf.protocol)) {
1062 host_pvt.dma_interrupt_count++; 1101 host_pvt.dma_interrupt_count++;
1063 if (hsdevp->dma_pending[tag] == \ 1102 if (hsdevp->dma_pending[tag] == \
@@ -1142,8 +1181,8 @@ static void sata_dwc_dma_xfer_complete(struct ata_port *ap, u32 check_status)
1142 if (tag > 0) { 1181 if (tag > 0) {
1143 dev_info(ap->dev, "%s tag=%u cmd=0x%02x dma dir=%s proto=%s " 1182 dev_info(ap->dev, "%s tag=%u cmd=0x%02x dma dir=%s proto=%s "
1144 "dmacr=0x%08x\n", __func__, qc->tag, qc->tf.command, 1183 "dmacr=0x%08x\n", __func__, qc->tag, qc->tf.command,
1145 ata_get_cmd_descript(qc->dma_dir), 1184 get_dma_dir_descript(qc->dma_dir),
1146 ata_get_cmd_descript(qc->tf.protocol), 1185 get_prot_descript(qc->tf.protocol),
1147 in_le32(&(hsdev->sata_dwc_regs->dmacr))); 1186 in_le32(&(hsdev->sata_dwc_regs->dmacr)));
1148 } 1187 }
1149#endif 1188#endif
@@ -1354,7 +1393,7 @@ static void sata_dwc_exec_command_by_tag(struct ata_port *ap,
1354 struct sata_dwc_device_port *hsdevp = HSDEVP_FROM_AP(ap); 1393 struct sata_dwc_device_port *hsdevp = HSDEVP_FROM_AP(ap);
1355 1394
1356 dev_dbg(ap->dev, "%s cmd(0x%02x): %s tag=%d\n", __func__, tf->command, 1395 dev_dbg(ap->dev, "%s cmd(0x%02x): %s tag=%d\n", __func__, tf->command,
1357 ata_get_cmd_descript(tf), tag); 1396 ata_get_cmd_descript(tf->command), tag);
1358 1397
1359 spin_lock_irqsave(&ap->host->lock, flags); 1398 spin_lock_irqsave(&ap->host->lock, flags);
1360 hsdevp->cmd_issued[tag] = cmd_issued; 1399 hsdevp->cmd_issued[tag] = cmd_issued;
@@ -1413,7 +1452,7 @@ static void sata_dwc_bmdma_start_by_tag(struct ata_queued_cmd *qc, u8 tag)
1413 1452
1414 dev_dbg(ap->dev, "%s qc=%p tag: %x cmd: 0x%02x dma_dir: %s " 1453 dev_dbg(ap->dev, "%s qc=%p tag: %x cmd: 0x%02x dma_dir: %s "
1415 "start_dma? %x\n", __func__, qc, tag, qc->tf.command, 1454 "start_dma? %x\n", __func__, qc, tag, qc->tf.command,
1416 ata_get_cmd_descript(qc->dma_dir), start_dma); 1455 get_dma_dir_descript(qc->dma_dir), start_dma);
1417 sata_dwc_tf_dump(&(qc->tf)); 1456 sata_dwc_tf_dump(&(qc->tf));
1418 1457
1419 if (start_dma) { 1458 if (start_dma) {
@@ -1462,10 +1501,9 @@ static void sata_dwc_qc_prep_by_tag(struct ata_queued_cmd *qc, u8 tag)
1462 int dma_chan; 1501 int dma_chan;
1463 struct sata_dwc_device *hsdev = HSDEV_FROM_AP(ap); 1502 struct sata_dwc_device *hsdev = HSDEV_FROM_AP(ap);
1464 struct sata_dwc_device_port *hsdevp = HSDEVP_FROM_AP(ap); 1503 struct sata_dwc_device_port *hsdevp = HSDEVP_FROM_AP(ap);
1465 int err;
1466 1504
1467 dev_dbg(ap->dev, "%s: port=%d dma dir=%s n_elem=%d\n", 1505 dev_dbg(ap->dev, "%s: port=%d dma dir=%s n_elem=%d\n",
1468 __func__, ap->port_no, ata_get_cmd_descript(qc->dma_dir), 1506 __func__, ap->port_no, get_dma_dir_descript(qc->dma_dir),
1469 qc->n_elem); 1507 qc->n_elem);
1470 1508
1471 dma_chan = dma_dwc_xfer_setup(sg, qc->n_elem, hsdevp->llit[tag], 1509 dma_chan = dma_dwc_xfer_setup(sg, qc->n_elem, hsdevp->llit[tag],
@@ -1474,7 +1512,7 @@ static void sata_dwc_qc_prep_by_tag(struct ata_queued_cmd *qc, u8 tag)
1474 dmadr), qc->dma_dir); 1512 dmadr), qc->dma_dir);
1475 if (dma_chan < 0) { 1513 if (dma_chan < 0) {
1476 dev_err(ap->dev, "%s: dma_dwc_xfer_setup returns err %d\n", 1514 dev_err(ap->dev, "%s: dma_dwc_xfer_setup returns err %d\n",
1477 __func__, err); 1515 __func__, dma_chan);
1478 return; 1516 return;
1479 } 1517 }
1480 hsdevp->dma_chan[tag] = dma_chan; 1518 hsdevp->dma_chan[tag] = dma_chan;
@@ -1491,8 +1529,8 @@ static unsigned int sata_dwc_qc_issue(struct ata_queued_cmd *qc)
1491 dev_info(ap->dev, "%s ap id=%d cmd(0x%02x)=%s qc tag=%d " 1529 dev_info(ap->dev, "%s ap id=%d cmd(0x%02x)=%s qc tag=%d "
1492 "prot=%s ap active_tag=0x%08x ap sactive=0x%08x\n", 1530 "prot=%s ap active_tag=0x%08x ap sactive=0x%08x\n",
1493 __func__, ap->print_id, qc->tf.command, 1531 __func__, ap->print_id, qc->tf.command,
1494 ata_get_cmd_descript(&qc->tf), 1532 ata_get_cmd_descript(qc->tf.command),
1495 qc->tag, ata_get_cmd_descript(qc->tf.protocol), 1533 qc->tag, get_prot_descript(qc->tf.protocol),
1496 ap->link.active_tag, ap->link.sactive); 1534 ap->link.active_tag, ap->link.sactive);
1497#endif 1535#endif
1498 1536
@@ -1533,7 +1571,7 @@ static void sata_dwc_qc_prep(struct ata_queued_cmd *qc)
1533#ifdef DEBUG_NCQ 1571#ifdef DEBUG_NCQ
1534 if (qc->tag > 0) 1572 if (qc->tag > 0)
1535 dev_info(qc->ap->dev, "%s: qc->tag=%d ap->active_tag=0x%08x\n", 1573 dev_info(qc->ap->dev, "%s: qc->tag=%d ap->active_tag=0x%08x\n",
1536 __func__, tag, qc->ap->link.active_tag); 1574 __func__, qc->tag, qc->ap->link.active_tag);
1537 1575
1538 return ; 1576 return ;
1539#endif 1577#endif
@@ -1580,9 +1618,8 @@ static struct ata_port_operations sata_dwc_ops = {
1580 1618
1581static const struct ata_port_info sata_dwc_port_info[] = { 1619static const struct ata_port_info sata_dwc_port_info[] = {
1582 { 1620 {
1583 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 1621 .flags = ATA_FLAG_SATA | ATA_FLAG_NCQ,
1584 ATA_FLAG_MMIO | ATA_FLAG_NCQ, 1622 .pio_mask = ATA_PIO4,
1585 .pio_mask = 0x1f, /* pio 0-4 */
1586 .udma_mask = ATA_UDMA6, 1623 .udma_mask = ATA_UDMA6,
1587 .port_ops = &sata_dwc_ops, 1624 .port_ops = &sata_dwc_ops,
1588 }, 1625 },
diff --git a/drivers/ata/sata_fsl.c b/drivers/ata/sata_fsl.c
index b0214d00d50b..7f9eab34a386 100644
--- a/drivers/ata/sata_fsl.c
+++ b/drivers/ata/sata_fsl.c
@@ -33,8 +33,7 @@ enum {
33 SATA_FSL_MAX_PRD_USABLE = SATA_FSL_MAX_PRD - 1, 33 SATA_FSL_MAX_PRD_USABLE = SATA_FSL_MAX_PRD - 1,
34 SATA_FSL_MAX_PRD_DIRECT = 16, /* Direct PRDT entries */ 34 SATA_FSL_MAX_PRD_DIRECT = 16, /* Direct PRDT entries */
35 35
36 SATA_FSL_HOST_FLAGS = (ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 36 SATA_FSL_HOST_FLAGS = (ATA_FLAG_SATA | ATA_FLAG_PIO_DMA |
37 ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA |
38 ATA_FLAG_PMP | ATA_FLAG_NCQ | ATA_FLAG_AN), 37 ATA_FLAG_PMP | ATA_FLAG_NCQ | ATA_FLAG_AN),
39 38
40 SATA_FSL_MAX_CMDS = SATA_FSL_QUEUE_DEPTH, 39 SATA_FSL_MAX_CMDS = SATA_FSL_QUEUE_DEPTH,
@@ -186,6 +185,11 @@ enum {
186 COMMANDSTAT = 0x20, 185 COMMANDSTAT = 0x20,
187}; 186};
188 187
188/* TRANSCFG (transport-layer) configuration control */
189enum {
190 TRANSCFG_RX_WATER_MARK = (1 << 4),
191};
192
189/* PHY (link-layer) configuration control */ 193/* PHY (link-layer) configuration control */
190enum { 194enum {
191 PHY_BIST_ENABLE = 0x01, 195 PHY_BIST_ENABLE = 0x01,
@@ -1040,12 +1044,15 @@ static void sata_fsl_error_intr(struct ata_port *ap)
1040 1044
1041 /* find out the offending link and qc */ 1045 /* find out the offending link and qc */
1042 if (ap->nr_pmp_links) { 1046 if (ap->nr_pmp_links) {
1047 unsigned int dev_num;
1048
1043 dereg = ioread32(hcr_base + DE); 1049 dereg = ioread32(hcr_base + DE);
1044 iowrite32(dereg, hcr_base + DE); 1050 iowrite32(dereg, hcr_base + DE);
1045 iowrite32(cereg, hcr_base + CE); 1051 iowrite32(cereg, hcr_base + CE);
1046 1052
1047 if (dereg < ap->nr_pmp_links) { 1053 dev_num = ffs(dereg) - 1;
1048 link = &ap->pmp_link[dereg]; 1054 if (dev_num < ap->nr_pmp_links && dereg != 0) {
1055 link = &ap->pmp_link[dev_num];
1049 ehi = &link->eh_info; 1056 ehi = &link->eh_info;
1050 qc = ata_qc_from_tag(ap, link->active_tag); 1057 qc = ata_qc_from_tag(ap, link->active_tag);
1051 /* 1058 /*
@@ -1303,6 +1310,7 @@ static int sata_fsl_probe(struct platform_device *ofdev,
1303 struct sata_fsl_host_priv *host_priv = NULL; 1310 struct sata_fsl_host_priv *host_priv = NULL;
1304 int irq; 1311 int irq;
1305 struct ata_host *host; 1312 struct ata_host *host;
1313 u32 temp;
1306 1314
1307 struct ata_port_info pi = sata_fsl_port_info[0]; 1315 struct ata_port_info pi = sata_fsl_port_info[0];
1308 const struct ata_port_info *ppi[] = { &pi, NULL }; 1316 const struct ata_port_info *ppi[] = { &pi, NULL };
@@ -1317,6 +1325,12 @@ static int sata_fsl_probe(struct platform_device *ofdev,
1317 ssr_base = hcr_base + 0x100; 1325 ssr_base = hcr_base + 0x100;
1318 csr_base = hcr_base + 0x140; 1326 csr_base = hcr_base + 0x140;
1319 1327
1328 if (!of_device_is_compatible(ofdev->dev.of_node, "fsl,mpc8315-sata")) {
1329 temp = ioread32(csr_base + TRANSCFG);
1330 temp = temp & 0xffffffe0;
1331 iowrite32(temp | TRANSCFG_RX_WATER_MARK, csr_base + TRANSCFG);
1332 }
1333
1320 DPRINTK("@reset i/o = 0x%x\n", ioread32(csr_base + TRANSCFG)); 1334 DPRINTK("@reset i/o = 0x%x\n", ioread32(csr_base + TRANSCFG));
1321 DPRINTK("sizeof(cmd_desc) = %d\n", sizeof(struct command_desc)); 1335 DPRINTK("sizeof(cmd_desc) = %d\n", sizeof(struct command_desc));
1322 DPRINTK("sizeof(#define cmd_desc) = %d\n", SATA_FSL_CMD_DESC_SIZE); 1336 DPRINTK("sizeof(#define cmd_desc) = %d\n", SATA_FSL_CMD_DESC_SIZE);
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
index bf74a36d3cc3..cd40651e9b72 100644
--- a/drivers/ata/sata_mv.c
+++ b/drivers/ata/sata_mv.c
@@ -160,8 +160,7 @@ enum {
160 /* Host Flags */ 160 /* Host Flags */
161 MV_FLAG_DUAL_HC = (1 << 30), /* two SATA Host Controllers */ 161 MV_FLAG_DUAL_HC = (1 << 30), /* two SATA Host Controllers */
162 162
163 MV_COMMON_FLAGS = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 163 MV_COMMON_FLAGS = ATA_FLAG_SATA | ATA_FLAG_PIO_POLLING,
164 ATA_FLAG_MMIO | ATA_FLAG_PIO_POLLING,
165 164
166 MV_GEN_I_FLAGS = MV_COMMON_FLAGS | ATA_FLAG_NO_ATAPI, 165 MV_GEN_I_FLAGS = MV_COMMON_FLAGS | ATA_FLAG_NO_ATAPI,
167 166
diff --git a/drivers/ata/sata_nv.c b/drivers/ata/sata_nv.c
index 7254e255fd78..42344e3c686d 100644
--- a/drivers/ata/sata_nv.c
+++ b/drivers/ata/sata_nv.c
@@ -539,7 +539,7 @@ struct nv_pi_priv {
539static const struct ata_port_info nv_port_info[] = { 539static const struct ata_port_info nv_port_info[] = {
540 /* generic */ 540 /* generic */
541 { 541 {
542 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY, 542 .flags = ATA_FLAG_SATA,
543 .pio_mask = NV_PIO_MASK, 543 .pio_mask = NV_PIO_MASK,
544 .mwdma_mask = NV_MWDMA_MASK, 544 .mwdma_mask = NV_MWDMA_MASK,
545 .udma_mask = NV_UDMA_MASK, 545 .udma_mask = NV_UDMA_MASK,
@@ -548,7 +548,7 @@ static const struct ata_port_info nv_port_info[] = {
548 }, 548 },
549 /* nforce2/3 */ 549 /* nforce2/3 */
550 { 550 {
551 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY, 551 .flags = ATA_FLAG_SATA,
552 .pio_mask = NV_PIO_MASK, 552 .pio_mask = NV_PIO_MASK,
553 .mwdma_mask = NV_MWDMA_MASK, 553 .mwdma_mask = NV_MWDMA_MASK,
554 .udma_mask = NV_UDMA_MASK, 554 .udma_mask = NV_UDMA_MASK,
@@ -557,7 +557,7 @@ static const struct ata_port_info nv_port_info[] = {
557 }, 557 },
558 /* ck804 */ 558 /* ck804 */
559 { 559 {
560 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY, 560 .flags = ATA_FLAG_SATA,
561 .pio_mask = NV_PIO_MASK, 561 .pio_mask = NV_PIO_MASK,
562 .mwdma_mask = NV_MWDMA_MASK, 562 .mwdma_mask = NV_MWDMA_MASK,
563 .udma_mask = NV_UDMA_MASK, 563 .udma_mask = NV_UDMA_MASK,
@@ -566,8 +566,7 @@ static const struct ata_port_info nv_port_info[] = {
566 }, 566 },
567 /* ADMA */ 567 /* ADMA */
568 { 568 {
569 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 569 .flags = ATA_FLAG_SATA | ATA_FLAG_NCQ,
570 ATA_FLAG_MMIO | ATA_FLAG_NCQ,
571 .pio_mask = NV_PIO_MASK, 570 .pio_mask = NV_PIO_MASK,
572 .mwdma_mask = NV_MWDMA_MASK, 571 .mwdma_mask = NV_MWDMA_MASK,
573 .udma_mask = NV_UDMA_MASK, 572 .udma_mask = NV_UDMA_MASK,
@@ -576,7 +575,7 @@ static const struct ata_port_info nv_port_info[] = {
576 }, 575 },
577 /* MCP5x */ 576 /* MCP5x */
578 { 577 {
579 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY, 578 .flags = ATA_FLAG_SATA,
580 .pio_mask = NV_PIO_MASK, 579 .pio_mask = NV_PIO_MASK,
581 .mwdma_mask = NV_MWDMA_MASK, 580 .mwdma_mask = NV_MWDMA_MASK,
582 .udma_mask = NV_UDMA_MASK, 581 .udma_mask = NV_UDMA_MASK,
@@ -585,8 +584,7 @@ static const struct ata_port_info nv_port_info[] = {
585 }, 584 },
586 /* SWNCQ */ 585 /* SWNCQ */
587 { 586 {
588 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 587 .flags = ATA_FLAG_SATA | ATA_FLAG_NCQ,
589 ATA_FLAG_NCQ,
590 .pio_mask = NV_PIO_MASK, 588 .pio_mask = NV_PIO_MASK,
591 .mwdma_mask = NV_MWDMA_MASK, 589 .mwdma_mask = NV_MWDMA_MASK,
592 .udma_mask = NV_UDMA_MASK, 590 .udma_mask = NV_UDMA_MASK,
diff --git a/drivers/ata/sata_promise.c b/drivers/ata/sata_promise.c
index f03ad48273ff..a004b1e0ea6d 100644
--- a/drivers/ata/sata_promise.c
+++ b/drivers/ata/sata_promise.c
@@ -134,9 +134,7 @@ enum {
134 PDC_IRQ_DISABLE = (1 << 10), 134 PDC_IRQ_DISABLE = (1 << 10),
135 PDC_RESET = (1 << 11), /* HDMA reset */ 135 PDC_RESET = (1 << 11), /* HDMA reset */
136 136
137 PDC_COMMON_FLAGS = ATA_FLAG_NO_LEGACY | 137 PDC_COMMON_FLAGS = ATA_FLAG_PIO_POLLING,
138 ATA_FLAG_MMIO |
139 ATA_FLAG_PIO_POLLING,
140 138
141 /* ap->flags bits */ 139 /* ap->flags bits */
142 PDC_FLAG_GEN_II = (1 << 24), 140 PDC_FLAG_GEN_II = (1 << 24),
diff --git a/drivers/ata/sata_qstor.c b/drivers/ata/sata_qstor.c
index daeebf19a6a9..c5603265fa58 100644
--- a/drivers/ata/sata_qstor.c
+++ b/drivers/ata/sata_qstor.c
@@ -155,8 +155,7 @@ static struct ata_port_operations qs_ata_ops = {
155static const struct ata_port_info qs_port_info[] = { 155static const struct ata_port_info qs_port_info[] = {
156 /* board_2068_idx */ 156 /* board_2068_idx */
157 { 157 {
158 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 158 .flags = ATA_FLAG_SATA | ATA_FLAG_PIO_POLLING,
159 ATA_FLAG_MMIO | ATA_FLAG_PIO_POLLING,
160 .pio_mask = ATA_PIO4_ONLY, 159 .pio_mask = ATA_PIO4_ONLY,
161 .udma_mask = ATA_UDMA6, 160 .udma_mask = ATA_UDMA6,
162 .port_ops = &qs_ata_ops, 161 .port_ops = &qs_ata_ops,
diff --git a/drivers/ata/sata_sil.c b/drivers/ata/sata_sil.c
index 3a4f84219719..b42edaaf3a53 100644
--- a/drivers/ata/sata_sil.c
+++ b/drivers/ata/sata_sil.c
@@ -61,8 +61,7 @@ enum {
61 SIL_FLAG_RERR_ON_DMA_ACT = (1 << 29), 61 SIL_FLAG_RERR_ON_DMA_ACT = (1 << 29),
62 SIL_FLAG_MOD15WRITE = (1 << 30), 62 SIL_FLAG_MOD15WRITE = (1 << 30),
63 63
64 SIL_DFL_PORT_FLAGS = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 64 SIL_DFL_PORT_FLAGS = ATA_FLAG_SATA,
65 ATA_FLAG_MMIO,
66 65
67 /* 66 /*
68 * Controller IDs 67 * Controller IDs
diff --git a/drivers/ata/sata_sil24.c b/drivers/ata/sata_sil24.c
index af41c6fd1254..06c564e55051 100644
--- a/drivers/ata/sata_sil24.c
+++ b/drivers/ata/sata_sil24.c
@@ -244,8 +244,7 @@ enum {
244 BID_SIL3131 = 2, 244 BID_SIL3131 = 2,
245 245
246 /* host flags */ 246 /* host flags */
247 SIL24_COMMON_FLAGS = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 247 SIL24_COMMON_FLAGS = ATA_FLAG_SATA | ATA_FLAG_PIO_DMA |
248 ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA |
249 ATA_FLAG_NCQ | ATA_FLAG_ACPI_SATA | 248 ATA_FLAG_NCQ | ATA_FLAG_ACPI_SATA |
250 ATA_FLAG_AN | ATA_FLAG_PMP, 249 ATA_FLAG_AN | ATA_FLAG_PMP,
251 SIL24_FLAG_PCIX_IRQ_WOC = (1 << 24), /* IRQ loss errata on PCI-X */ 250 SIL24_FLAG_PCIX_IRQ_WOC = (1 << 24), /* IRQ loss errata on PCI-X */
diff --git a/drivers/ata/sata_sis.c b/drivers/ata/sata_sis.c
index 2bfe3ae03976..cdcc13e9cf51 100644
--- a/drivers/ata/sata_sis.c
+++ b/drivers/ata/sata_sis.c
@@ -96,7 +96,7 @@ static struct ata_port_operations sis_ops = {
96}; 96};
97 97
98static const struct ata_port_info sis_port_info = { 98static const struct ata_port_info sis_port_info = {
99 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY, 99 .flags = ATA_FLAG_SATA,
100 .pio_mask = ATA_PIO4, 100 .pio_mask = ATA_PIO4,
101 .mwdma_mask = ATA_MWDMA2, 101 .mwdma_mask = ATA_MWDMA2,
102 .udma_mask = ATA_UDMA6, 102 .udma_mask = ATA_UDMA6,
diff --git a/drivers/ata/sata_svw.c b/drivers/ata/sata_svw.c
index 7d9db4aaf07e..35eabcf34568 100644
--- a/drivers/ata/sata_svw.c
+++ b/drivers/ata/sata_svw.c
@@ -359,8 +359,7 @@ static struct ata_port_operations k2_sata_ops = {
359static const struct ata_port_info k2_port_info[] = { 359static const struct ata_port_info k2_port_info[] = {
360 /* chip_svw4 */ 360 /* chip_svw4 */
361 { 361 {
362 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 362 .flags = ATA_FLAG_SATA | K2_FLAG_NO_ATAPI_DMA,
363 ATA_FLAG_MMIO | K2_FLAG_NO_ATAPI_DMA,
364 .pio_mask = ATA_PIO4, 363 .pio_mask = ATA_PIO4,
365 .mwdma_mask = ATA_MWDMA2, 364 .mwdma_mask = ATA_MWDMA2,
366 .udma_mask = ATA_UDMA6, 365 .udma_mask = ATA_UDMA6,
@@ -368,8 +367,7 @@ static const struct ata_port_info k2_port_info[] = {
368 }, 367 },
369 /* chip_svw8 */ 368 /* chip_svw8 */
370 { 369 {
371 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 370 .flags = ATA_FLAG_SATA | K2_FLAG_NO_ATAPI_DMA |
372 ATA_FLAG_MMIO | K2_FLAG_NO_ATAPI_DMA |
373 K2_FLAG_SATA_8_PORTS, 371 K2_FLAG_SATA_8_PORTS,
374 .pio_mask = ATA_PIO4, 372 .pio_mask = ATA_PIO4,
375 .mwdma_mask = ATA_MWDMA2, 373 .mwdma_mask = ATA_MWDMA2,
@@ -378,8 +376,7 @@ static const struct ata_port_info k2_port_info[] = {
378 }, 376 },
379 /* chip_svw42 */ 377 /* chip_svw42 */
380 { 378 {
381 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 379 .flags = ATA_FLAG_SATA | K2_FLAG_BAR_POS_3,
382 ATA_FLAG_MMIO | K2_FLAG_BAR_POS_3,
383 .pio_mask = ATA_PIO4, 380 .pio_mask = ATA_PIO4,
384 .mwdma_mask = ATA_MWDMA2, 381 .mwdma_mask = ATA_MWDMA2,
385 .udma_mask = ATA_UDMA6, 382 .udma_mask = ATA_UDMA6,
@@ -387,8 +384,7 @@ static const struct ata_port_info k2_port_info[] = {
387 }, 384 },
388 /* chip_svw43 */ 385 /* chip_svw43 */
389 { 386 {
390 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 387 .flags = ATA_FLAG_SATA,
391 ATA_FLAG_MMIO,
392 .pio_mask = ATA_PIO4, 388 .pio_mask = ATA_PIO4,
393 .mwdma_mask = ATA_MWDMA2, 389 .mwdma_mask = ATA_MWDMA2,
394 .udma_mask = ATA_UDMA6, 390 .udma_mask = ATA_UDMA6,
diff --git a/drivers/ata/sata_sx4.c b/drivers/ata/sata_sx4.c
index bedd5188e5b0..8fd3b7252bda 100644
--- a/drivers/ata/sata_sx4.c
+++ b/drivers/ata/sata_sx4.c
@@ -273,9 +273,8 @@ static struct ata_port_operations pdc_20621_ops = {
273static const struct ata_port_info pdc_port_info[] = { 273static const struct ata_port_info pdc_port_info[] = {
274 /* board_20621 */ 274 /* board_20621 */
275 { 275 {
276 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 276 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_ATAPI |
277 ATA_FLAG_SRST | ATA_FLAG_MMIO | 277 ATA_FLAG_PIO_POLLING,
278 ATA_FLAG_NO_ATAPI | ATA_FLAG_PIO_POLLING,
279 .pio_mask = ATA_PIO4, 278 .pio_mask = ATA_PIO4,
280 .mwdma_mask = ATA_MWDMA2, 279 .mwdma_mask = ATA_MWDMA2,
281 .udma_mask = ATA_UDMA6, 280 .udma_mask = ATA_UDMA6,
diff --git a/drivers/ata/sata_uli.c b/drivers/ata/sata_uli.c
index b8578c32d344..235be717a713 100644
--- a/drivers/ata/sata_uli.c
+++ b/drivers/ata/sata_uli.c
@@ -88,8 +88,7 @@ static struct ata_port_operations uli_ops = {
88}; 88};
89 89
90static const struct ata_port_info uli_port_info = { 90static const struct ata_port_info uli_port_info = {
91 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 91 .flags = ATA_FLAG_SATA | ATA_FLAG_IGN_SIMPLEX,
92 ATA_FLAG_IGN_SIMPLEX,
93 .pio_mask = ATA_PIO4, 92 .pio_mask = ATA_PIO4,
94 .udma_mask = ATA_UDMA6, 93 .udma_mask = ATA_UDMA6,
95 .port_ops = &uli_ops, 94 .port_ops = &uli_ops,
diff --git a/drivers/ata/sata_via.c b/drivers/ata/sata_via.c
index 8b677bbf2d37..21242c5709a0 100644
--- a/drivers/ata/sata_via.c
+++ b/drivers/ata/sata_via.c
@@ -148,7 +148,7 @@ static struct ata_port_operations vt8251_ops = {
148}; 148};
149 149
150static const struct ata_port_info vt6420_port_info = { 150static const struct ata_port_info vt6420_port_info = {
151 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY, 151 .flags = ATA_FLAG_SATA,
152 .pio_mask = ATA_PIO4, 152 .pio_mask = ATA_PIO4,
153 .mwdma_mask = ATA_MWDMA2, 153 .mwdma_mask = ATA_MWDMA2,
154 .udma_mask = ATA_UDMA6, 154 .udma_mask = ATA_UDMA6,
@@ -156,7 +156,7 @@ static const struct ata_port_info vt6420_port_info = {
156}; 156};
157 157
158static struct ata_port_info vt6421_sport_info = { 158static struct ata_port_info vt6421_sport_info = {
159 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY, 159 .flags = ATA_FLAG_SATA,
160 .pio_mask = ATA_PIO4, 160 .pio_mask = ATA_PIO4,
161 .mwdma_mask = ATA_MWDMA2, 161 .mwdma_mask = ATA_MWDMA2,
162 .udma_mask = ATA_UDMA6, 162 .udma_mask = ATA_UDMA6,
@@ -164,7 +164,7 @@ static struct ata_port_info vt6421_sport_info = {
164}; 164};
165 165
166static struct ata_port_info vt6421_pport_info = { 166static struct ata_port_info vt6421_pport_info = {
167 .flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_NO_LEGACY, 167 .flags = ATA_FLAG_SLAVE_POSS,
168 .pio_mask = ATA_PIO4, 168 .pio_mask = ATA_PIO4,
169 /* No MWDMA */ 169 /* No MWDMA */
170 .udma_mask = ATA_UDMA6, 170 .udma_mask = ATA_UDMA6,
@@ -172,8 +172,7 @@ static struct ata_port_info vt6421_pport_info = {
172}; 172};
173 173
174static struct ata_port_info vt8251_port_info = { 174static struct ata_port_info vt8251_port_info = {
175 .flags = ATA_FLAG_SATA | ATA_FLAG_SLAVE_POSS | 175 .flags = ATA_FLAG_SATA | ATA_FLAG_SLAVE_POSS,
176 ATA_FLAG_NO_LEGACY,
177 .pio_mask = ATA_PIO4, 176 .pio_mask = ATA_PIO4,
178 .mwdma_mask = ATA_MWDMA2, 177 .mwdma_mask = ATA_MWDMA2,
179 .udma_mask = ATA_UDMA6, 178 .udma_mask = ATA_UDMA6,
diff --git a/drivers/ata/sata_vsc.c b/drivers/ata/sata_vsc.c
index e079cf29ed5d..7c987371136e 100644
--- a/drivers/ata/sata_vsc.c
+++ b/drivers/ata/sata_vsc.c
@@ -340,8 +340,7 @@ static int __devinit vsc_sata_init_one(struct pci_dev *pdev,
340 const struct pci_device_id *ent) 340 const struct pci_device_id *ent)
341{ 341{
342 static const struct ata_port_info pi = { 342 static const struct ata_port_info pi = {
343 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 343 .flags = ATA_FLAG_SATA,
344 ATA_FLAG_MMIO,
345 .pio_mask = ATA_PIO4, 344 .pio_mask = ATA_PIO4,
346 .mwdma_mask = ATA_MWDMA2, 345 .mwdma_mask = ATA_MWDMA2,
347 .udma_mask = ATA_UDMA6, 346 .udma_mask = ATA_UDMA6,
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index 9c5c8be72231..d841e98a8bd5 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -6219,11 +6219,10 @@ static struct ata_port_operations ipr_sata_ops = {
6219}; 6219};
6220 6220
6221static struct ata_port_info sata_port_info = { 6221static struct ata_port_info sata_port_info = {
6222 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | ATA_FLAG_SATA_RESET | 6222 .flags = ATA_FLAG_SATA | ATA_FLAG_PIO_DMA,
6223 ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA, 6223 .pio_mask = ATA_PIO4_ONLY,
6224 .pio_mask = 0x10, /* pio4 */ 6224 .mwdma_mask = ATA_MWDMA2,
6225 .mwdma_mask = 0x07, 6225 .udma_mask = ATA_UDMA6,
6226 .udma_mask = 0x7f, /* udma0-6 */
6227 .port_ops = &ipr_sata_ops 6226 .port_ops = &ipr_sata_ops
6228}; 6227};
6229 6228
diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
index e1a395b438ee..4d3b704ede1c 100644
--- a/drivers/scsi/libsas/sas_ata.c
+++ b/drivers/scsi/libsas/sas_ata.c
@@ -238,37 +238,43 @@ static bool sas_ata_qc_fill_rtf(struct ata_queued_cmd *qc)
238 return true; 238 return true;
239} 239}
240 240
241static void sas_ata_phy_reset(struct ata_port *ap) 241static int sas_ata_hard_reset(struct ata_link *link, unsigned int *class,
242 unsigned long deadline)
242{ 243{
244 struct ata_port *ap = link->ap;
243 struct domain_device *dev = ap->private_data; 245 struct domain_device *dev = ap->private_data;
244 struct sas_internal *i = 246 struct sas_internal *i =
245 to_sas_internal(dev->port->ha->core.shost->transportt); 247 to_sas_internal(dev->port->ha->core.shost->transportt);
246 int res = TMF_RESP_FUNC_FAILED; 248 int res = TMF_RESP_FUNC_FAILED;
249 int ret = 0;
247 250
248 if (i->dft->lldd_I_T_nexus_reset) 251 if (i->dft->lldd_I_T_nexus_reset)
249 res = i->dft->lldd_I_T_nexus_reset(dev); 252 res = i->dft->lldd_I_T_nexus_reset(dev);
250 253
251 if (res != TMF_RESP_FUNC_COMPLETE) 254 if (res != TMF_RESP_FUNC_COMPLETE) {
252 SAS_DPRINTK("%s: Unable to reset I T nexus?\n", __func__); 255 SAS_DPRINTK("%s: Unable to reset I T nexus?\n", __func__);
256 ret = -EAGAIN;
257 }
253 258
254 switch (dev->sata_dev.command_set) { 259 switch (dev->sata_dev.command_set) {
255 case ATA_COMMAND_SET: 260 case ATA_COMMAND_SET:
256 SAS_DPRINTK("%s: Found ATA device.\n", __func__); 261 SAS_DPRINTK("%s: Found ATA device.\n", __func__);
257 ap->link.device[0].class = ATA_DEV_ATA; 262 *class = ATA_DEV_ATA;
258 break; 263 break;
259 case ATAPI_COMMAND_SET: 264 case ATAPI_COMMAND_SET:
260 SAS_DPRINTK("%s: Found ATAPI device.\n", __func__); 265 SAS_DPRINTK("%s: Found ATAPI device.\n", __func__);
261 ap->link.device[0].class = ATA_DEV_ATAPI; 266 *class = ATA_DEV_ATAPI;
262 break; 267 break;
263 default: 268 default:
264 SAS_DPRINTK("%s: Unknown SATA command set: %d.\n", 269 SAS_DPRINTK("%s: Unknown SATA command set: %d.\n",
265 __func__, 270 __func__,
266 dev->sata_dev.command_set); 271 dev->sata_dev.command_set);
267 ap->link.device[0].class = ATA_DEV_UNKNOWN; 272 *class = ATA_DEV_UNKNOWN;
268 break; 273 break;
269 } 274 }
270 275
271 ap->cbl = ATA_CBL_SATA; 276 ap->cbl = ATA_CBL_SATA;
277 return ret;
272} 278}
273 279
274static void sas_ata_post_internal(struct ata_queued_cmd *qc) 280static void sas_ata_post_internal(struct ata_queued_cmd *qc)
@@ -349,7 +355,11 @@ static int sas_ata_scr_read(struct ata_link *link, unsigned int sc_reg_in,
349} 355}
350 356
351static struct ata_port_operations sas_sata_ops = { 357static struct ata_port_operations sas_sata_ops = {
352 .phy_reset = sas_ata_phy_reset, 358 .prereset = ata_std_prereset,
359 .softreset = NULL,
360 .hardreset = sas_ata_hard_reset,
361 .postreset = ata_std_postreset,
362 .error_handler = ata_std_error_handler,
353 .post_internal_cmd = sas_ata_post_internal, 363 .post_internal_cmd = sas_ata_post_internal,
354 .qc_defer = ata_std_qc_defer, 364 .qc_defer = ata_std_qc_defer,
355 .qc_prep = ata_noop_qc_prep, 365 .qc_prep = ata_noop_qc_prep,
@@ -362,10 +372,9 @@ static struct ata_port_operations sas_sata_ops = {
362}; 372};
363 373
364static struct ata_port_info sata_port_info = { 374static struct ata_port_info sata_port_info = {
365 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | ATA_FLAG_SATA_RESET | 375 .flags = ATA_FLAG_SATA | ATA_FLAG_PIO_DMA | ATA_FLAG_NCQ,
366 ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA | ATA_FLAG_NCQ, 376 .pio_mask = ATA_PIO4,
367 .pio_mask = 0x1f, /* PIO0-4 */ 377 .mwdma_mask = ATA_MWDMA2,
368 .mwdma_mask = 0x07, /* MWDMA0-2 */
369 .udma_mask = ATA_UDMA6, 378 .udma_mask = ATA_UDMA6,
370 .port_ops = &sas_sata_ops 379 .port_ops = &sas_sata_ops
371}; 380};
@@ -781,3 +790,68 @@ int sas_discover_sata(struct domain_device *dev)
781 790
782 return res; 791 return res;
783} 792}
793
794void sas_ata_strategy_handler(struct Scsi_Host *shost)
795{
796 struct scsi_device *sdev;
797
798 shost_for_each_device(sdev, shost) {
799 struct domain_device *ddev = sdev_to_domain_dev(sdev);
800 struct ata_port *ap = ddev->sata_dev.ap;
801
802 if (!dev_is_sata(ddev))
803 continue;
804
805 ata_port_printk(ap, KERN_DEBUG, "sas eh calling libata port error handler");
806 ata_scsi_port_error_handler(shost, ap);
807 }
808}
809
810int sas_ata_timed_out(struct scsi_cmnd *cmd, struct sas_task *task,
811 enum blk_eh_timer_return *rtn)
812{
813 struct domain_device *ddev = cmd_to_domain_dev(cmd);
814
815 if (!dev_is_sata(ddev) || task)
816 return 0;
817
818 /* we're a sata device with no task, so this must be a libata
819 * eh timeout. Ideally should hook into libata timeout
820 * handling, but there's no point, it just wants to activate
821 * the eh thread */
822 *rtn = BLK_EH_NOT_HANDLED;
823 return 1;
824}
825
826int sas_ata_eh(struct Scsi_Host *shost, struct list_head *work_q,
827 struct list_head *done_q)
828{
829 int rtn = 0;
830 struct scsi_cmnd *cmd, *n;
831 struct ata_port *ap;
832
833 do {
834 LIST_HEAD(sata_q);
835
836 ap = NULL;
837
838 list_for_each_entry_safe(cmd, n, work_q, eh_entry) {
839 struct domain_device *ddev = cmd_to_domain_dev(cmd);
840
841 if (!dev_is_sata(ddev) || TO_SAS_TASK(cmd))
842 continue;
843 if(ap && ap != ddev->sata_dev.ap)
844 continue;
845 ap = ddev->sata_dev.ap;
846 rtn = 1;
847 list_move(&cmd->eh_entry, &sata_q);
848 }
849
850 if (!list_empty(&sata_q)) {
851 ata_port_printk(ap, KERN_DEBUG,"sas eh calling libata cmd error handler\n");
852 ata_scsi_cmd_error_handler(shost, ap, &sata_q);
853 }
854 } while (ap);
855
856 return rtn;
857}
diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c
index 9a7aaf5f1311..67758ea8eb7f 100644
--- a/drivers/scsi/libsas/sas_scsi_host.c
+++ b/drivers/scsi/libsas/sas_scsi_host.c
@@ -663,11 +663,16 @@ void sas_scsi_recover_host(struct Scsi_Host *shost)
663 * scsi_unjam_host does, but we skip scsi_eh_abort_cmds because any 663 * scsi_unjam_host does, but we skip scsi_eh_abort_cmds because any
664 * command we see here has no sas_task and is thus unknown to the HA. 664 * command we see here has no sas_task and is thus unknown to the HA.
665 */ 665 */
666 if (!scsi_eh_get_sense(&eh_work_q, &ha->eh_done_q)) 666 if (!sas_ata_eh(shost, &eh_work_q, &ha->eh_done_q))
667 scsi_eh_ready_devs(shost, &eh_work_q, &ha->eh_done_q); 667 if (!scsi_eh_get_sense(&eh_work_q, &ha->eh_done_q))
668 scsi_eh_ready_devs(shost, &eh_work_q, &ha->eh_done_q);
668 669
669out: 670out:
671 /* now link into libata eh --- if we have any ata devices */
672 sas_ata_strategy_handler(shost);
673
670 scsi_eh_flush_done_q(&ha->eh_done_q); 674 scsi_eh_flush_done_q(&ha->eh_done_q);
675
671 SAS_DPRINTK("--- Exit %s\n", __func__); 676 SAS_DPRINTK("--- Exit %s\n", __func__);
672 return; 677 return;
673} 678}
@@ -676,6 +681,11 @@ enum blk_eh_timer_return sas_scsi_timed_out(struct scsi_cmnd *cmd)
676{ 681{
677 struct sas_task *task = TO_SAS_TASK(cmd); 682 struct sas_task *task = TO_SAS_TASK(cmd);
678 unsigned long flags; 683 unsigned long flags;
684 enum blk_eh_timer_return rtn;
685
686 if (sas_ata_timed_out(cmd, task, &rtn))
687 return rtn;
688
679 689
680 if (!task) { 690 if (!task) {
681 cmd->request->timeout /= 2; 691 cmd->request->timeout /= 2;
diff --git a/include/linux/ata.h b/include/linux/ata.h
index 0c4929fa34d3..32df2b6ef0e0 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -89,6 +89,7 @@ enum {
89 ATA_ID_SPG = 98, 89 ATA_ID_SPG = 98,
90 ATA_ID_LBA_CAPACITY_2 = 100, 90 ATA_ID_LBA_CAPACITY_2 = 100,
91 ATA_ID_SECTOR_SIZE = 106, 91 ATA_ID_SECTOR_SIZE = 106,
92 ATA_ID_WWN = 108,
92 ATA_ID_LOGICAL_SECTOR_SIZE = 117, /* and 118 */ 93 ATA_ID_LOGICAL_SECTOR_SIZE = 117, /* and 118 */
93 ATA_ID_LAST_LUN = 126, 94 ATA_ID_LAST_LUN = 126,
94 ATA_ID_DLF = 128, 95 ATA_ID_DLF = 128,
@@ -103,6 +104,7 @@ enum {
103 ATA_ID_SERNO_LEN = 20, 104 ATA_ID_SERNO_LEN = 20,
104 ATA_ID_FW_REV_LEN = 8, 105 ATA_ID_FW_REV_LEN = 8,
105 ATA_ID_PROD_LEN = 40, 106 ATA_ID_PROD_LEN = 40,
107 ATA_ID_WWN_LEN = 8,
106 108
107 ATA_PCI_CTL_OFS = 2, 109 ATA_PCI_CTL_OFS = 2,
108 110
@@ -598,42 +600,42 @@ static inline bool ata_id_has_dipm(const u16 *id)
598} 600}
599 601
600 602
601static inline int ata_id_has_fua(const u16 *id) 603static inline bool ata_id_has_fua(const u16 *id)
602{ 604{
603 if ((id[ATA_ID_CFSSE] & 0xC000) != 0x4000) 605 if ((id[ATA_ID_CFSSE] & 0xC000) != 0x4000)
604 return 0; 606 return false;
605 return id[ATA_ID_CFSSE] & (1 << 6); 607 return id[ATA_ID_CFSSE] & (1 << 6);
606} 608}
607 609
608static inline int ata_id_has_flush(const u16 *id) 610static inline bool ata_id_has_flush(const u16 *id)
609{ 611{
610 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000) 612 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000)
611 return 0; 613 return false;
612 return id[ATA_ID_COMMAND_SET_2] & (1 << 12); 614 return id[ATA_ID_COMMAND_SET_2] & (1 << 12);
613} 615}
614 616
615static inline int ata_id_flush_enabled(const u16 *id) 617static inline bool ata_id_flush_enabled(const u16 *id)
616{ 618{
617 if (ata_id_has_flush(id) == 0) 619 if (ata_id_has_flush(id) == 0)
618 return 0; 620 return false;
619 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000) 621 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000)
620 return 0; 622 return false;
621 return id[ATA_ID_CFS_ENABLE_2] & (1 << 12); 623 return id[ATA_ID_CFS_ENABLE_2] & (1 << 12);
622} 624}
623 625
624static inline int ata_id_has_flush_ext(const u16 *id) 626static inline bool ata_id_has_flush_ext(const u16 *id)
625{ 627{
626 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000) 628 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000)
627 return 0; 629 return false;
628 return id[ATA_ID_COMMAND_SET_2] & (1 << 13); 630 return id[ATA_ID_COMMAND_SET_2] & (1 << 13);
629} 631}
630 632
631static inline int ata_id_flush_ext_enabled(const u16 *id) 633static inline bool ata_id_flush_ext_enabled(const u16 *id)
632{ 634{
633 if (ata_id_has_flush_ext(id) == 0) 635 if (ata_id_has_flush_ext(id) == 0)
634 return 0; 636 return false;
635 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000) 637 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000)
636 return 0; 638 return false;
637 /* 639 /*
638 * some Maxtor disks have bit 13 defined incorrectly 640 * some Maxtor disks have bit 13 defined incorrectly
639 * so check bit 10 too 641 * so check bit 10 too
@@ -686,64 +688,64 @@ static inline u16 ata_id_logical_sector_offset(const u16 *id,
686 return 0; 688 return 0;
687} 689}
688 690
689static inline int ata_id_has_lba48(const u16 *id) 691static inline bool ata_id_has_lba48(const u16 *id)
690{ 692{
691 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000) 693 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000)
692 return 0; 694 return false;
693 if (!ata_id_u64(id, ATA_ID_LBA_CAPACITY_2)) 695 if (!ata_id_u64(id, ATA_ID_LBA_CAPACITY_2))
694 return 0; 696 return false;
695 return id[ATA_ID_COMMAND_SET_2] & (1 << 10); 697 return id[ATA_ID_COMMAND_SET_2] & (1 << 10);
696} 698}
697 699
698static inline int ata_id_lba48_enabled(const u16 *id) 700static inline bool ata_id_lba48_enabled(const u16 *id)
699{ 701{
700 if (ata_id_has_lba48(id) == 0) 702 if (ata_id_has_lba48(id) == 0)
701 return 0; 703 return false;
702 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000) 704 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000)
703 return 0; 705 return false;
704 return id[ATA_ID_CFS_ENABLE_2] & (1 << 10); 706 return id[ATA_ID_CFS_ENABLE_2] & (1 << 10);
705} 707}
706 708
707static inline int ata_id_hpa_enabled(const u16 *id) 709static inline bool ata_id_hpa_enabled(const u16 *id)
708{ 710{
709 /* Yes children, word 83 valid bits cover word 82 data */ 711 /* Yes children, word 83 valid bits cover word 82 data */
710 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000) 712 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000)
711 return 0; 713 return false;
712 /* And 87 covers 85-87 */ 714 /* And 87 covers 85-87 */
713 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000) 715 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000)
714 return 0; 716 return false;
715 /* Check command sets enabled as well as supported */ 717 /* Check command sets enabled as well as supported */
716 if ((id[ATA_ID_CFS_ENABLE_1] & (1 << 10)) == 0) 718 if ((id[ATA_ID_CFS_ENABLE_1] & (1 << 10)) == 0)
717 return 0; 719 return false;
718 return id[ATA_ID_COMMAND_SET_1] & (1 << 10); 720 return id[ATA_ID_COMMAND_SET_1] & (1 << 10);
719} 721}
720 722
721static inline int ata_id_has_wcache(const u16 *id) 723static inline bool ata_id_has_wcache(const u16 *id)
722{ 724{
723 /* Yes children, word 83 valid bits cover word 82 data */ 725 /* Yes children, word 83 valid bits cover word 82 data */
724 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000) 726 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000)
725 return 0; 727 return false;
726 return id[ATA_ID_COMMAND_SET_1] & (1 << 5); 728 return id[ATA_ID_COMMAND_SET_1] & (1 << 5);
727} 729}
728 730
729static inline int ata_id_has_pm(const u16 *id) 731static inline bool ata_id_has_pm(const u16 *id)
730{ 732{
731 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000) 733 if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000)
732 return 0; 734 return false;
733 return id[ATA_ID_COMMAND_SET_1] & (1 << 3); 735 return id[ATA_ID_COMMAND_SET_1] & (1 << 3);
734} 736}
735 737
736static inline int ata_id_rahead_enabled(const u16 *id) 738static inline bool ata_id_rahead_enabled(const u16 *id)
737{ 739{
738 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000) 740 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000)
739 return 0; 741 return false;
740 return id[ATA_ID_CFS_ENABLE_1] & (1 << 6); 742 return id[ATA_ID_CFS_ENABLE_1] & (1 << 6);
741} 743}
742 744
743static inline int ata_id_wcache_enabled(const u16 *id) 745static inline bool ata_id_wcache_enabled(const u16 *id)
744{ 746{
745 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000) 747 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000)
746 return 0; 748 return false;
747 return id[ATA_ID_CFS_ENABLE_1] & (1 << 5); 749 return id[ATA_ID_CFS_ENABLE_1] & (1 << 5);
748} 750}
749 751
@@ -773,7 +775,7 @@ static inline unsigned int ata_id_major_version(const u16 *id)
773 return mver; 775 return mver;
774} 776}
775 777
776static inline int ata_id_is_sata(const u16 *id) 778static inline bool ata_id_is_sata(const u16 *id)
777{ 779{
778 /* 780 /*
779 * See if word 93 is 0 AND drive is at least ATA-5 compatible 781 * See if word 93 is 0 AND drive is at least ATA-5 compatible
@@ -782,37 +784,40 @@ static inline int ata_id_is_sata(const u16 *id)
782 * 0x0000 and 0xffff along with the earlier ATA revisions... 784 * 0x0000 and 0xffff along with the earlier ATA revisions...
783 */ 785 */
784 if (id[ATA_ID_HW_CONFIG] == 0 && (short)id[ATA_ID_MAJOR_VER] >= 0x0020) 786 if (id[ATA_ID_HW_CONFIG] == 0 && (short)id[ATA_ID_MAJOR_VER] >= 0x0020)
785 return 1; 787 return true;
786 return 0; 788 return false;
787} 789}
788 790
789static inline int ata_id_has_tpm(const u16 *id) 791static inline bool ata_id_has_tpm(const u16 *id)
790{ 792{
791 /* The TPM bits are only valid on ATA8 */ 793 /* The TPM bits are only valid on ATA8 */
792 if (ata_id_major_version(id) < 8) 794 if (ata_id_major_version(id) < 8)
793 return 0; 795 return false;
794 if ((id[48] & 0xC000) != 0x4000) 796 if ((id[48] & 0xC000) != 0x4000)
795 return 0; 797 return false;
796 return id[48] & (1 << 0); 798 return id[48] & (1 << 0);
797} 799}
798 800
799static inline int ata_id_has_dword_io(const u16 *id) 801static inline bool ata_id_has_dword_io(const u16 *id)
800{ 802{
801 /* ATA 8 reuses this flag for "trusted" computing */ 803 /* ATA 8 reuses this flag for "trusted" computing */
802 if (ata_id_major_version(id) > 7) 804 if (ata_id_major_version(id) > 7)
803 return 0; 805 return false;
804 if (id[ATA_ID_DWORD_IO] & (1 << 0)) 806 return id[ATA_ID_DWORD_IO] & (1 << 0);
805 return 1;
806 return 0;
807} 807}
808 808
809static inline int ata_id_has_unload(const u16 *id) 809static inline bool ata_id_has_unload(const u16 *id)
810{ 810{
811 if (ata_id_major_version(id) >= 7 && 811 if (ata_id_major_version(id) >= 7 &&
812 (id[ATA_ID_CFSSE] & 0xC000) == 0x4000 && 812 (id[ATA_ID_CFSSE] & 0xC000) == 0x4000 &&
813 id[ATA_ID_CFSSE] & (1 << 13)) 813 id[ATA_ID_CFSSE] & (1 << 13))
814 return 1; 814 return true;
815 return 0; 815 return false;
816}
817
818static inline bool ata_id_has_wwn(const u16 *id)
819{
820 return (id[ATA_ID_CSF_DEFAULT] & 0xC100) == 0x4100;
816} 821}
817 822
818static inline int ata_id_form_factor(const u16 *id) 823static inline int ata_id_form_factor(const u16 *id)
@@ -843,25 +848,25 @@ static inline int ata_id_rotation_rate(const u16 *id)
843 return val; 848 return val;
844} 849}
845 850
846static inline int ata_id_has_trim(const u16 *id) 851static inline bool ata_id_has_trim(const u16 *id)
847{ 852{
848 if (ata_id_major_version(id) >= 7 && 853 if (ata_id_major_version(id) >= 7 &&
849 (id[ATA_ID_DATA_SET_MGMT] & 1)) 854 (id[ATA_ID_DATA_SET_MGMT] & 1))
850 return 1; 855 return true;
851 return 0; 856 return false;
852} 857}
853 858
854static inline int ata_id_has_zero_after_trim(const u16 *id) 859static inline bool ata_id_has_zero_after_trim(const u16 *id)
855{ 860{
856 /* DSM supported, deterministic read, and read zero after trim set */ 861 /* DSM supported, deterministic read, and read zero after trim set */
857 if (ata_id_has_trim(id) && 862 if (ata_id_has_trim(id) &&
858 (id[ATA_ID_ADDITIONAL_SUPP] & 0x4020) == 0x4020) 863 (id[ATA_ID_ADDITIONAL_SUPP] & 0x4020) == 0x4020)
859 return 1; 864 return true;
860 865
861 return 0; 866 return false;
862} 867}
863 868
864static inline int ata_id_current_chs_valid(const u16 *id) 869static inline bool ata_id_current_chs_valid(const u16 *id)
865{ 870{
866 /* For ATA-1 devices, if the INITIALIZE DEVICE PARAMETERS command 871 /* For ATA-1 devices, if the INITIALIZE DEVICE PARAMETERS command
867 has not been issued to the device then the values of 872 has not been issued to the device then the values of
@@ -873,11 +878,11 @@ static inline int ata_id_current_chs_valid(const u16 *id)
873 id[ATA_ID_CUR_SECTORS]; /* sectors in current translation */ 878 id[ATA_ID_CUR_SECTORS]; /* sectors in current translation */
874} 879}
875 880
876static inline int ata_id_is_cfa(const u16 *id) 881static inline bool ata_id_is_cfa(const u16 *id)
877{ 882{
878 if ((id[ATA_ID_CONFIG] == 0x848A) || /* Traditional CF */ 883 if ((id[ATA_ID_CONFIG] == 0x848A) || /* Traditional CF */
879 (id[ATA_ID_CONFIG] == 0x844A)) /* Delkin Devices CF */ 884 (id[ATA_ID_CONFIG] == 0x844A)) /* Delkin Devices CF */
880 return 1; 885 return true;
881 /* 886 /*
882 * CF specs don't require specific value in the word 0 anymore and yet 887 * CF specs don't require specific value in the word 0 anymore and yet
883 * they forbid to report the ATA version in the word 80 and require the 888 * they forbid to report the ATA version in the word 80 and require the
@@ -886,44 +891,40 @@ static inline int ata_id_is_cfa(const u16 *id)
886 * and while those that don't indicate CFA feature support need some 891 * and while those that don't indicate CFA feature support need some
887 * sort of quirk list, it seems impractical for the ones that do... 892 * sort of quirk list, it seems impractical for the ones that do...
888 */ 893 */
889 if ((id[ATA_ID_COMMAND_SET_2] & 0xC004) == 0x4004) 894 return (id[ATA_ID_COMMAND_SET_2] & 0xC004) == 0x4004;
890 return 1;
891 return 0;
892} 895}
893 896
894static inline int ata_id_is_ssd(const u16 *id) 897static inline bool ata_id_is_ssd(const u16 *id)
895{ 898{
896 return id[ATA_ID_ROT_SPEED] == 0x01; 899 return id[ATA_ID_ROT_SPEED] == 0x01;
897} 900}
898 901
899static inline int ata_id_pio_need_iordy(const u16 *id, const u8 pio) 902static inline bool ata_id_pio_need_iordy(const u16 *id, const u8 pio)
900{ 903{
901 /* CF spec. r4.1 Table 22 says no IORDY on PIO5 and PIO6. */ 904 /* CF spec. r4.1 Table 22 says no IORDY on PIO5 and PIO6. */
902 if (pio > 4 && ata_id_is_cfa(id)) 905 if (pio > 4 && ata_id_is_cfa(id))
903 return 0; 906 return false;
904 /* For PIO3 and higher it is mandatory. */ 907 /* For PIO3 and higher it is mandatory. */
905 if (pio > 2) 908 if (pio > 2)
906 return 1; 909 return true;
907 /* Turn it on when possible. */ 910 /* Turn it on when possible. */
908 if (ata_id_has_iordy(id)) 911 return ata_id_has_iordy(id);
909 return 1;
910 return 0;
911} 912}
912 913
913static inline int ata_drive_40wire(const u16 *dev_id) 914static inline bool ata_drive_40wire(const u16 *dev_id)
914{ 915{
915 if (ata_id_is_sata(dev_id)) 916 if (ata_id_is_sata(dev_id))
916 return 0; /* SATA */ 917 return false; /* SATA */
917 if ((dev_id[ATA_ID_HW_CONFIG] & 0xE000) == 0x6000) 918 if ((dev_id[ATA_ID_HW_CONFIG] & 0xE000) == 0x6000)
918 return 0; /* 80 wire */ 919 return false; /* 80 wire */
919 return 1; 920 return true;
920} 921}
921 922
922static inline int ata_drive_40wire_relaxed(const u16 *dev_id) 923static inline bool ata_drive_40wire_relaxed(const u16 *dev_id)
923{ 924{
924 if ((dev_id[ATA_ID_HW_CONFIG] & 0x2000) == 0x2000) 925 if ((dev_id[ATA_ID_HW_CONFIG] & 0x2000) == 0x2000)
925 return 0; /* 80 wire */ 926 return false; /* 80 wire */
926 return 1; 927 return true;
927} 928}
928 929
929static inline int atapi_cdb_len(const u16 *dev_id) 930static inline int atapi_cdb_len(const u16 *dev_id)
@@ -936,12 +937,12 @@ static inline int atapi_cdb_len(const u16 *dev_id)
936 } 937 }
937} 938}
938 939
939static inline int atapi_command_packet_set(const u16 *dev_id) 940static inline bool atapi_command_packet_set(const u16 *dev_id)
940{ 941{
941 return (dev_id[ATA_ID_CONFIG] >> 8) & 0x1f; 942 return (dev_id[ATA_ID_CONFIG] >> 8) & 0x1f;
942} 943}
943 944
944static inline int atapi_id_dmadir(const u16 *dev_id) 945static inline bool atapi_id_dmadir(const u16 *dev_id)
945{ 946{
946 return ata_id_major_version(dev_id) >= 7 && (dev_id[62] & 0x8000); 947 return ata_id_major_version(dev_id) >= 7 && (dev_id[62] & 0x8000);
947} 948}
@@ -954,13 +955,13 @@ static inline int atapi_id_dmadir(const u16 *dev_id)
954 * 955 *
955 * It is called only once for each device. 956 * It is called only once for each device.
956 */ 957 */
957static inline int ata_id_is_lba_capacity_ok(u16 *id) 958static inline bool ata_id_is_lba_capacity_ok(u16 *id)
958{ 959{
959 unsigned long lba_sects, chs_sects, head, tail; 960 unsigned long lba_sects, chs_sects, head, tail;
960 961
961 /* No non-LBA info .. so valid! */ 962 /* No non-LBA info .. so valid! */
962 if (id[ATA_ID_CYLS] == 0) 963 if (id[ATA_ID_CYLS] == 0)
963 return 1; 964 return true;
964 965
965 lba_sects = ata_id_u32(id, ATA_ID_LBA_CAPACITY); 966 lba_sects = ata_id_u32(id, ATA_ID_LBA_CAPACITY);
966 967
@@ -975,13 +976,13 @@ static inline int ata_id_is_lba_capacity_ok(u16 *id)
975 id[ATA_ID_SECTORS] == 63 && 976 id[ATA_ID_SECTORS] == 63 &&
976 (id[ATA_ID_HEADS] == 15 || id[ATA_ID_HEADS] == 16) && 977 (id[ATA_ID_HEADS] == 15 || id[ATA_ID_HEADS] == 16) &&
977 (lba_sects >= 16383 * 63 * id[ATA_ID_HEADS])) 978 (lba_sects >= 16383 * 63 * id[ATA_ID_HEADS]))
978 return 1; 979 return true;
979 980
980 chs_sects = id[ATA_ID_CYLS] * id[ATA_ID_HEADS] * id[ATA_ID_SECTORS]; 981 chs_sects = id[ATA_ID_CYLS] * id[ATA_ID_HEADS] * id[ATA_ID_SECTORS];
981 982
982 /* perform a rough sanity check on lba_sects: within 10% is OK */ 983 /* perform a rough sanity check on lba_sects: within 10% is OK */
983 if (lba_sects - chs_sects < chs_sects/10) 984 if (lba_sects - chs_sects < chs_sects/10)
984 return 1; 985 return true;
985 986
986 /* some drives have the word order reversed */ 987 /* some drives have the word order reversed */
987 head = (lba_sects >> 16) & 0xffff; 988 head = (lba_sects >> 16) & 0xffff;
@@ -990,10 +991,10 @@ static inline int ata_id_is_lba_capacity_ok(u16 *id)
990 991
991 if (lba_sects - chs_sects < chs_sects/10) { 992 if (lba_sects - chs_sects < chs_sects/10) {
992 *(__le32 *)&id[ATA_ID_LBA_CAPACITY] = __cpu_to_le32(lba_sects); 993 *(__le32 *)&id[ATA_ID_LBA_CAPACITY] = __cpu_to_le32(lba_sects);
993 return 1; /* LBA capacity is (now) good */ 994 return true; /* LBA capacity is (now) good */
994 } 995 }
995 996
996 return 0; /* LBA capacity value may be bad */ 997 return false; /* LBA capacity value may be bad */
997} 998}
998 999
999static inline void ata_id_to_hd_driveid(u16 *id) 1000static inline void ata_id_to_hd_driveid(u16 *id)
@@ -1051,19 +1052,19 @@ static inline int is_multi_taskfile(struct ata_taskfile *tf)
1051 (tf->command == ATA_CMD_WRITE_MULTI_FUA_EXT); 1052 (tf->command == ATA_CMD_WRITE_MULTI_FUA_EXT);
1052} 1053}
1053 1054
1054static inline int ata_ok(u8 status) 1055static inline bool ata_ok(u8 status)
1055{ 1056{
1056 return ((status & (ATA_BUSY | ATA_DRDY | ATA_DF | ATA_DRQ | ATA_ERR)) 1057 return ((status & (ATA_BUSY | ATA_DRDY | ATA_DF | ATA_DRQ | ATA_ERR))
1057 == ATA_DRDY); 1058 == ATA_DRDY);
1058} 1059}
1059 1060
1060static inline int lba_28_ok(u64 block, u32 n_block) 1061static inline bool lba_28_ok(u64 block, u32 n_block)
1061{ 1062{
1062 /* check the ending block number: must be LESS THAN 0x0fffffff */ 1063 /* check the ending block number: must be LESS THAN 0x0fffffff */
1063 return ((block + n_block) < ((1 << 28) - 1)) && (n_block <= 256); 1064 return ((block + n_block) < ((1 << 28) - 1)) && (n_block <= 256);
1064} 1065}
1065 1066
1066static inline int lba_48_ok(u64 block, u32 n_block) 1067static inline bool lba_48_ok(u64 block, u32 n_block)
1067{ 1068{
1068 /* check the ending block number */ 1069 /* check the ending block number */
1069 return ((block + n_block - 1) < ((u64)1 << 48)) && (n_block <= 65536); 1070 return ((block + n_block - 1) < ((u64)1 << 48)) && (n_block <= 65536);
diff --git a/include/linux/libata.h b/include/linux/libata.h
index c9c5d7ad1a2b..c71f46960f39 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -179,10 +179,6 @@ enum {
179 ATA_FLAG_SLAVE_POSS = (1 << 0), /* host supports slave dev */ 179 ATA_FLAG_SLAVE_POSS = (1 << 0), /* host supports slave dev */
180 /* (doesn't imply presence) */ 180 /* (doesn't imply presence) */
181 ATA_FLAG_SATA = (1 << 1), 181 ATA_FLAG_SATA = (1 << 1),
182 ATA_FLAG_NO_LEGACY = (1 << 2), /* no legacy mode check */
183 ATA_FLAG_MMIO = (1 << 3), /* use MMIO, not PIO */
184 ATA_FLAG_SRST = (1 << 4), /* (obsolete) use ATA SRST, not E.D.D. */
185 ATA_FLAG_SATA_RESET = (1 << 5), /* (obsolete) use COMRESET */
186 ATA_FLAG_NO_ATAPI = (1 << 6), /* No ATAPI support */ 182 ATA_FLAG_NO_ATAPI = (1 << 6), /* No ATAPI support */
187 ATA_FLAG_PIO_DMA = (1 << 7), /* PIO cmds via DMA */ 183 ATA_FLAG_PIO_DMA = (1 << 7), /* PIO cmds via DMA */
188 ATA_FLAG_PIO_LBA48 = (1 << 8), /* Host DMA engine is LBA28 only */ 184 ATA_FLAG_PIO_LBA48 = (1 << 8), /* Host DMA engine is LBA28 only */
@@ -198,7 +194,6 @@ enum {
198 ATA_FLAG_ACPI_SATA = (1 << 17), /* need native SATA ACPI layout */ 194 ATA_FLAG_ACPI_SATA = (1 << 17), /* need native SATA ACPI layout */
199 ATA_FLAG_AN = (1 << 18), /* controller supports AN */ 195 ATA_FLAG_AN = (1 << 18), /* controller supports AN */
200 ATA_FLAG_PMP = (1 << 19), /* controller supports PMP */ 196 ATA_FLAG_PMP = (1 << 19), /* controller supports PMP */
201 ATA_FLAG_LPM = (1 << 20), /* driver can handle LPM */
202 ATA_FLAG_EM = (1 << 21), /* driver supports enclosure 197 ATA_FLAG_EM = (1 << 21), /* driver supports enclosure
203 * management */ 198 * management */
204 ATA_FLAG_SW_ACTIVITY = (1 << 22), /* driver supports sw activity 199 ATA_FLAG_SW_ACTIVITY = (1 << 22), /* driver supports sw activity
@@ -1050,6 +1045,8 @@ extern int ata_scsi_change_queue_depth(struct scsi_device *sdev,
1050 int queue_depth, int reason); 1045 int queue_depth, int reason);
1051extern struct ata_device *ata_dev_pair(struct ata_device *adev); 1046extern struct ata_device *ata_dev_pair(struct ata_device *adev);
1052extern int ata_do_set_mode(struct ata_link *link, struct ata_device **r_failed_dev); 1047extern int ata_do_set_mode(struct ata_link *link, struct ata_device **r_failed_dev);
1048extern void ata_scsi_port_error_handler(struct Scsi_Host *host, struct ata_port *ap);
1049extern void ata_scsi_cmd_error_handler(struct Scsi_Host *host, struct ata_port *ap, struct list_head *eh_q);
1053 1050
1054extern int ata_cable_40wire(struct ata_port *ap); 1051extern int ata_cable_40wire(struct ata_port *ap);
1055extern int ata_cable_80wire(struct ata_port *ap); 1052extern int ata_cable_80wire(struct ata_port *ap);
@@ -1613,6 +1610,9 @@ extern void ata_sff_irq_on(struct ata_port *ap);
1613extern void ata_sff_irq_clear(struct ata_port *ap); 1610extern void ata_sff_irq_clear(struct ata_port *ap);
1614extern int ata_sff_hsm_move(struct ata_port *ap, struct ata_queued_cmd *qc, 1611extern int ata_sff_hsm_move(struct ata_port *ap, struct ata_queued_cmd *qc,
1615 u8 status, int in_wq); 1612 u8 status, int in_wq);
1613extern void ata_sff_queue_work(struct work_struct *work);
1614extern void ata_sff_queue_delayed_work(struct delayed_work *dwork,
1615 unsigned long delay);
1616extern void ata_sff_queue_pio_task(struct ata_link *link, unsigned long delay); 1616extern void ata_sff_queue_pio_task(struct ata_link *link, unsigned long delay);
1617extern unsigned int ata_sff_qc_issue(struct ata_queued_cmd *qc); 1617extern unsigned int ata_sff_qc_issue(struct ata_queued_cmd *qc);
1618extern bool ata_sff_qc_fill_rtf(struct ata_queued_cmd *qc); 1618extern bool ata_sff_qc_fill_rtf(struct ata_queued_cmd *qc);
diff --git a/include/linux/pata_arasan_cf_data.h b/include/linux/pata_arasan_cf_data.h
new file mode 100644
index 000000000000..a6ee9aa898bb
--- /dev/null
+++ b/include/linux/pata_arasan_cf_data.h
@@ -0,0 +1,49 @@
1/*
2 * include/linux/pata_arasan_cf_data.h
3 *
4 * Arasan Compact Flash host controller platform data header file
5 *
6 * Copyright (C) 2011 ST Microelectronics
7 * Viresh Kumar <viresh.kumar@st.com>
8 *
9 * This file is licensed under the terms of the GNU General Public
10 * License version 2. This program is licensed "as is" without any
11 * warranty of any kind, whether express or implied.
12 */
13
14#ifndef _PATA_ARASAN_CF_DATA_H
15#define _PATA_ARASAN_CF_DATA_H
16
17#include <linux/platform_device.h>
18
19struct arasan_cf_pdata {
20 u8 cf_if_clk;
21 #define CF_IF_CLK_100M (0x0)
22 #define CF_IF_CLK_75M (0x1)
23 #define CF_IF_CLK_66M (0x2)
24 #define CF_IF_CLK_50M (0x3)
25 #define CF_IF_CLK_40M (0x4)
26 #define CF_IF_CLK_33M (0x5)
27 #define CF_IF_CLK_25M (0x6)
28 #define CF_IF_CLK_125M (0x7)
29 #define CF_IF_CLK_150M (0x8)
30 #define CF_IF_CLK_166M (0x9)
31 #define CF_IF_CLK_200M (0xA)
32 /*
33 * Platform specific incapabilities of CF controller is handled via
34 * quirks
35 */
36 u32 quirk;
37 #define CF_BROKEN_PIO (1)
38 #define CF_BROKEN_MWDMA (1 << 1)
39 #define CF_BROKEN_UDMA (1 << 2)
40 /* This is platform specific data for the DMA controller */
41 void *dma_priv;
42};
43
44static inline void
45set_arasan_cf_pdata(struct platform_device *pdev, struct arasan_cf_pdata *data)
46{
47 pdev->dev.platform_data = data;
48}
49#endif /* _PATA_ARASAN_CF_DATA_H */
diff --git a/include/scsi/sas_ata.h b/include/scsi/sas_ata.h
index c583193ae929..9c159f74c6d0 100644
--- a/include/scsi/sas_ata.h
+++ b/include/scsi/sas_ata.h
@@ -39,6 +39,11 @@ int sas_ata_init_host_and_port(struct domain_device *found_dev,
39 struct scsi_target *starget); 39 struct scsi_target *starget);
40 40
41void sas_ata_task_abort(struct sas_task *task); 41void sas_ata_task_abort(struct sas_task *task);
42void sas_ata_strategy_handler(struct Scsi_Host *shost);
43int sas_ata_timed_out(struct scsi_cmnd *cmd, struct sas_task *task,
44 enum blk_eh_timer_return *rtn);
45int sas_ata_eh(struct Scsi_Host *shost, struct list_head *work_q,
46 struct list_head *done_q);
42 47
43#else 48#else
44 49
@@ -55,6 +60,23 @@ static inline int sas_ata_init_host_and_port(struct domain_device *found_dev,
55static inline void sas_ata_task_abort(struct sas_task *task) 60static inline void sas_ata_task_abort(struct sas_task *task)
56{ 61{
57} 62}
63
64static inline void sas_ata_strategy_handler(struct Scsi_Host *shost)
65{
66}
67
68static inline int sas_ata_timed_out(struct scsi_cmnd *cmd,
69 struct sas_task *task,
70 enum blk_eh_timer_return *rtn)
71{
72 return 0;
73}
74static inline int sas_ata_eh(struct Scsi_Host *shost, struct list_head *work_q,
75 struct list_head *done_q)
76{
77 return 0;
78}
79
58#endif 80#endif
59 81
60#endif /* _SAS_ATA_H_ */ 82#endif /* _SAS_ATA_H_ */