aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/devicetree/bindings/ata/ahci-platform.txt5
-rw-r--r--Documentation/kernel-parameters.txt2
-rw-r--r--arch/arm/boot/dts/ecx-common.dtsi2
-rw-r--r--drivers/ata/Kconfig1
-rw-r--r--drivers/ata/acard-ahci.c4
-rw-r--r--drivers/ata/ahci.c11
-rw-r--r--drivers/ata/ahci.h2
-rw-r--r--drivers/ata/ahci_platform.c1
-rw-r--r--drivers/ata/ata_piix.c8
-rw-r--r--drivers/ata/libahci.c26
-rw-r--r--drivers/ata/libata-core.c9
-rw-r--r--drivers/ata/libata-pmp.c33
-rw-r--r--drivers/ata/libata-scsi.c37
-rw-r--r--drivers/ata/libata-transport.c4
-rw-r--r--drivers/ata/libata-zpodd.c7
-rw-r--r--drivers/ata/pata_ali.c2
-rw-r--r--drivers/ata/pata_amd.c2
-rw-r--r--drivers/ata/pata_arasan_cf.c2
-rw-r--r--drivers/ata/pata_artop.c2
-rw-r--r--drivers/ata/pata_at91.c2
-rw-r--r--drivers/ata/pata_atp867x.c2
-rw-r--r--drivers/ata/pata_bf54x.c10
-rw-r--r--drivers/ata/pata_cmd640.c2
-rw-r--r--drivers/ata/pata_cmd64x.c2
-rw-r--r--drivers/ata/pata_cs5520.c4
-rw-r--r--drivers/ata/pata_cs5530.c2
-rw-r--r--drivers/ata/pata_hpt366.c2
-rw-r--r--drivers/ata/pata_hpt3x3.c2
-rw-r--r--drivers/ata/pata_imx.c2
-rw-r--r--drivers/ata/pata_it821x.c2
-rw-r--r--drivers/ata/pata_macio.c6
-rw-r--r--drivers/ata/pata_mpc52xx.c4
-rw-r--r--drivers/ata/pata_ninja32.c2
-rw-r--r--drivers/ata/pata_ns87415.c2
-rw-r--r--drivers/ata/pata_pdc2027x.c2
-rw-r--r--drivers/ata/pata_pxa.c2
-rw-r--r--drivers/ata/pata_rdc.c2
-rw-r--r--drivers/ata/pata_rz1000.c2
-rw-r--r--drivers/ata/pata_serverworks.c2
-rw-r--r--drivers/ata/pata_sil680.c2
-rw-r--r--drivers/ata/pata_sis.c2
-rw-r--r--drivers/ata/pata_sl82c105.c2
-rw-r--r--drivers/ata/pata_triflex.c2
-rw-r--r--drivers/ata/pata_via.c2
-rw-r--r--drivers/ata/sata_fsl.c14
-rw-r--r--drivers/ata/sata_highbank.c181
-rw-r--r--drivers/ata/sata_inic162x.c2
-rw-r--r--drivers/ata/sata_nv.c2
-rw-r--r--drivers/ata/sata_rcar.c138
-rw-r--r--drivers/ata/sata_sil.c2
-rw-r--r--drivers/ata/sata_sil24.c2
-rw-r--r--drivers/scsi/ipr.c1
-rw-r--r--include/linux/libata.h5
53 files changed, 388 insertions, 185 deletions
diff --git a/Documentation/devicetree/bindings/ata/ahci-platform.txt b/Documentation/devicetree/bindings/ata/ahci-platform.txt
index b519f9b699c3..3ec0c5c4f0e9 100644
--- a/Documentation/devicetree/bindings/ata/ahci-platform.txt
+++ b/Documentation/devicetree/bindings/ata/ahci-platform.txt
@@ -12,6 +12,11 @@ Optional properties:
12- calxeda,port-phys: phandle-combophy and lane assignment, which maps each 12- calxeda,port-phys: phandle-combophy and lane assignment, which maps each
13 SATA port to a combophy and a lane within that 13 SATA port to a combophy and a lane within that
14 combophy 14 combophy
15- calxeda,sgpio-gpio: phandle-gpio bank, bit offset, and default on or off,
16 which indicates that the driver supports SGPIO
17 indicator lights using the indicated GPIOs
18- calxeda,led-order : a u32 array that map port numbers to offsets within the
19 SGPIO bitstream.
15- dma-coherent : Present if dma operations are coherent 20- dma-coherent : Present if dma operations are coherent
16 21
17Example: 22Example:
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index ef8bd35814cf..25dc4a0e7e48 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -1458,6 +1458,8 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
1458 1458
1459 * dump_id: dump IDENTIFY data. 1459 * dump_id: dump IDENTIFY data.
1460 1460
1461 * atapi_dmadir: Enable ATAPI DMADIR bridge support
1462
1461 If there are multiple matching configurations changing 1463 If there are multiple matching configurations changing
1462 the same attribute, the last one is used. 1464 the same attribute, the last one is used.
1463 1465
diff --git a/arch/arm/boot/dts/ecx-common.dtsi b/arch/arm/boot/dts/ecx-common.dtsi
index d61b535f682a..e8559b753c9d 100644
--- a/arch/arm/boot/dts/ecx-common.dtsi
+++ b/arch/arm/boot/dts/ecx-common.dtsi
@@ -33,6 +33,8 @@
33 calxeda,port-phys = <&combophy5 0 &combophy0 0 33 calxeda,port-phys = <&combophy5 0 &combophy0 0
34 &combophy0 1 &combophy0 2 34 &combophy0 1 &combophy0 2
35 &combophy0 3>; 35 &combophy0 3>;
36 calxeda,sgpio-gpio =<&gpioh 5 1 &gpioh 6 1 &gpioh 7 1>;
37 calxeda,led-order = <4 0 1 2 3>;
36 }; 38 };
37 39
38 sdhci@ffe0e000 { 40 sdhci@ffe0e000 {
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index a5a3ebcbdd2c..aba6e93b0502 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -263,7 +263,6 @@ config SATA_PROMISE
263 263
264config SATA_RCAR 264config SATA_RCAR
265 tristate "Renesas R-Car SATA support" 265 tristate "Renesas R-Car SATA support"
266 depends on ARCH_SHMOBILE && ARCH_R8A7779
267 help 266 help
268 This option enables support for Renesas R-Car Serial ATA. 267 This option enables support for Renesas R-Car Serial ATA.
269 268
diff --git a/drivers/ata/acard-ahci.c b/drivers/ata/acard-ahci.c
index 9d0cf019ce59..fd665d919df2 100644
--- a/drivers/ata/acard-ahci.c
+++ b/drivers/ata/acard-ahci.c
@@ -128,7 +128,7 @@ static struct pci_driver acard_ahci_pci_driver = {
128#ifdef CONFIG_PM 128#ifdef CONFIG_PM
129static int acard_ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg) 129static int acard_ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg)
130{ 130{
131 struct ata_host *host = dev_get_drvdata(&pdev->dev); 131 struct ata_host *host = pci_get_drvdata(pdev);
132 struct ahci_host_priv *hpriv = host->private_data; 132 struct ahci_host_priv *hpriv = host->private_data;
133 void __iomem *mmio = hpriv->mmio; 133 void __iomem *mmio = hpriv->mmio;
134 u32 ctl; 134 u32 ctl;
@@ -156,7 +156,7 @@ static int acard_ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg
156 156
157static int acard_ahci_pci_device_resume(struct pci_dev *pdev) 157static int acard_ahci_pci_device_resume(struct pci_dev *pdev)
158{ 158{
159 struct ata_host *host = dev_get_drvdata(&pdev->dev); 159 struct ata_host *host = pci_get_drvdata(pdev);
160 int rc; 160 int rc;
161 161
162 rc = ata_pci_device_do_resume(pdev); 162 rc = ata_pci_device_do_resume(pdev);
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index fe1a889c6910..5064f3ea20f1 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -291,6 +291,7 @@ static const struct pci_device_id ahci_pci_tbl[] = {
291 { PCI_VDEVICE(INTEL, 0x8d64), board_ahci }, /* Wellsburg RAID */ 291 { PCI_VDEVICE(INTEL, 0x8d64), board_ahci }, /* Wellsburg RAID */
292 { PCI_VDEVICE(INTEL, 0x8d66), board_ahci }, /* Wellsburg RAID */ 292 { PCI_VDEVICE(INTEL, 0x8d66), board_ahci }, /* Wellsburg RAID */
293 { PCI_VDEVICE(INTEL, 0x8d6e), board_ahci }, /* Wellsburg RAID */ 293 { PCI_VDEVICE(INTEL, 0x8d6e), board_ahci }, /* Wellsburg RAID */
294 { PCI_VDEVICE(INTEL, 0x23a3), board_ahci }, /* Coleto Creek AHCI */
294 295
295 /* JMicron 360/1/3/5/6, match class to avoid IDE function */ 296 /* JMicron 360/1/3/5/6, match class to avoid IDE function */
296 { PCI_VENDOR_ID_JMICRON, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 297 { PCI_VENDOR_ID_JMICRON, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
@@ -586,7 +587,7 @@ static int ahci_p5wdh_hardreset(struct ata_link *link, unsigned int *class,
586 587
587 /* clear D2H reception area to properly wait for D2H FIS */ 588 /* clear D2H reception area to properly wait for D2H FIS */
588 ata_tf_init(link->device, &tf); 589 ata_tf_init(link->device, &tf);
589 tf.command = 0x80; 590 tf.command = ATA_BUSY;
590 ata_tf_to_fis(&tf, 0, 0, d2h_fis); 591 ata_tf_to_fis(&tf, 0, 0, d2h_fis);
591 592
592 rc = sata_link_hardreset(link, sata_ehc_deb_timing(&link->eh_context), 593 rc = sata_link_hardreset(link, sata_ehc_deb_timing(&link->eh_context),
@@ -619,7 +620,7 @@ static int ahci_p5wdh_hardreset(struct ata_link *link, unsigned int *class,
619#ifdef CONFIG_PM 620#ifdef CONFIG_PM
620static int ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg) 621static int ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg)
621{ 622{
622 struct ata_host *host = dev_get_drvdata(&pdev->dev); 623 struct ata_host *host = pci_get_drvdata(pdev);
623 struct ahci_host_priv *hpriv = host->private_data; 624 struct ahci_host_priv *hpriv = host->private_data;
624 void __iomem *mmio = hpriv->mmio; 625 void __iomem *mmio = hpriv->mmio;
625 u32 ctl; 626 u32 ctl;
@@ -647,7 +648,7 @@ static int ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg)
647 648
648static int ahci_pci_device_resume(struct pci_dev *pdev) 649static int ahci_pci_device_resume(struct pci_dev *pdev)
649{ 650{
650 struct ata_host *host = dev_get_drvdata(&pdev->dev); 651 struct ata_host *host = pci_get_drvdata(pdev);
651 int rc; 652 int rc;
652 653
653 rc = ata_pci_device_do_resume(pdev); 654 rc = ata_pci_device_do_resume(pdev);
@@ -1145,9 +1146,11 @@ int ahci_host_activate(struct ata_host *host, int irq, unsigned int n_msis)
1145 return rc; 1146 return rc;
1146 1147
1147 for (i = 0; i < host->n_ports; i++) { 1148 for (i = 0; i < host->n_ports; i++) {
1149 struct ahci_port_priv *pp = host->ports[i]->private_data;
1150
1148 rc = devm_request_threaded_irq(host->dev, 1151 rc = devm_request_threaded_irq(host->dev,
1149 irq + i, ahci_hw_interrupt, ahci_thread_fn, IRQF_SHARED, 1152 irq + i, ahci_hw_interrupt, ahci_thread_fn, IRQF_SHARED,
1150 dev_driver_string(host->dev), host->ports[i]); 1153 pp->irq_desc, host->ports[i]);
1151 if (rc) 1154 if (rc)
1152 goto out_free_irqs; 1155 goto out_free_irqs;
1153 } 1156 }
diff --git a/drivers/ata/ahci.h b/drivers/ata/ahci.h
index 10b14d45cfd2..11456371f29b 100644
--- a/drivers/ata/ahci.h
+++ b/drivers/ata/ahci.h
@@ -306,6 +306,7 @@ struct ahci_port_priv {
306 int fbs_last_dev; /* save FBS.DEV of last FIS */ 306 int fbs_last_dev; /* save FBS.DEV of last FIS */
307 /* enclosure management info per PM slot */ 307 /* enclosure management info per PM slot */
308 struct ahci_em_priv em_priv[EM_MAX_SLOTS]; 308 struct ahci_em_priv em_priv[EM_MAX_SLOTS];
309 char *irq_desc; /* desc in /proc/interrupts */
309}; 310};
310 311
311struct ahci_host_priv { 312struct ahci_host_priv {
@@ -321,6 +322,7 @@ struct ahci_host_priv {
321 u32 em_buf_sz; /* EM buffer size in byte */ 322 u32 em_buf_sz; /* EM buffer size in byte */
322 u32 em_msg_type; /* EM message type */ 323 u32 em_msg_type; /* EM message type */
323 struct clk *clk; /* Only for platforms supporting clk */ 324 struct clk *clk; /* Only for platforms supporting clk */
325 void *plat_data; /* Other platform data */
324}; 326};
325 327
326extern int ahci_ignore_sss; 328extern int ahci_ignore_sss;
diff --git a/drivers/ata/ahci_platform.c b/drivers/ata/ahci_platform.c
index 7a8a2841fe64..2daaee05cab1 100644
--- a/drivers/ata/ahci_platform.c
+++ b/drivers/ata/ahci_platform.c
@@ -327,6 +327,7 @@ static SIMPLE_DEV_PM_OPS(ahci_pm_ops, ahci_suspend, ahci_resume);
327 327
328static const struct of_device_id ahci_of_match[] = { 328static const struct of_device_id ahci_of_match[] = {
329 { .compatible = "snps,spear-ahci", }, 329 { .compatible = "snps,spear-ahci", },
330 { .compatible = "snps,exynos5440-ahci", },
330 {}, 331 {},
331}; 332};
332MODULE_DEVICE_TABLE(of, ahci_of_match); 333MODULE_DEVICE_TABLE(of, ahci_of_match);
diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
index 9a8a674e8fac..b52a10c8eeb9 100644
--- a/drivers/ata/ata_piix.c
+++ b/drivers/ata/ata_piix.c
@@ -338,6 +338,8 @@ static const struct pci_device_id piix_pci_tbl[] = {
338 /* SATA Controller IDE (BayTrail) */ 338 /* SATA Controller IDE (BayTrail) */
339 { 0x8086, 0x0F20, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata_byt }, 339 { 0x8086, 0x0F20, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata_byt },
340 { 0x8086, 0x0F21, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata_byt }, 340 { 0x8086, 0x0F21, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata_byt },
341 /* SATA Controller IDE (Coleto Creek) */
342 { 0x8086, 0x23a6, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata },
341 343
342 { } /* terminate list */ 344 { } /* terminate list */
343}; 345};
@@ -993,7 +995,7 @@ static int piix_broken_suspend(void)
993 995
994static int piix_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg) 996static int piix_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg)
995{ 997{
996 struct ata_host *host = dev_get_drvdata(&pdev->dev); 998 struct ata_host *host = pci_get_drvdata(pdev);
997 unsigned long flags; 999 unsigned long flags;
998 int rc = 0; 1000 int rc = 0;
999 1001
@@ -1028,7 +1030,7 @@ static int piix_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg)
1028 1030
1029static int piix_pci_device_resume(struct pci_dev *pdev) 1031static int piix_pci_device_resume(struct pci_dev *pdev)
1030{ 1032{
1031 struct ata_host *host = dev_get_drvdata(&pdev->dev); 1033 struct ata_host *host = pci_get_drvdata(pdev);
1032 unsigned long flags; 1034 unsigned long flags;
1033 int rc; 1035 int rc;
1034 1036
@@ -1751,7 +1753,7 @@ static int piix_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1751 1753
1752static void piix_remove_one(struct pci_dev *pdev) 1754static void piix_remove_one(struct pci_dev *pdev)
1753{ 1755{
1754 struct ata_host *host = dev_get_drvdata(&pdev->dev); 1756 struct ata_host *host = pci_get_drvdata(pdev);
1755 struct piix_host_priv *hpriv = host->private_data; 1757 struct piix_host_priv *hpriv = host->private_data;
1756 1758
1757 pci_write_config_dword(pdev, PIIX_IOCFG, hpriv->saved_iocfg); 1759 pci_write_config_dword(pdev, PIIX_IOCFG, hpriv->saved_iocfg);
diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
index a70ff154f586..acfd0f711069 100644
--- a/drivers/ata/libahci.c
+++ b/drivers/ata/libahci.c
@@ -173,6 +173,7 @@ struct ata_port_operations ahci_ops = {
173 .em_store = ahci_led_store, 173 .em_store = ahci_led_store,
174 .sw_activity_show = ahci_activity_show, 174 .sw_activity_show = ahci_activity_show,
175 .sw_activity_store = ahci_activity_store, 175 .sw_activity_store = ahci_activity_store,
176 .transmit_led_message = ahci_transmit_led_message,
176#ifdef CONFIG_PM 177#ifdef CONFIG_PM
177 .port_suspend = ahci_port_suspend, 178 .port_suspend = ahci_port_suspend,
178 .port_resume = ahci_port_resume, 179 .port_resume = ahci_port_resume,
@@ -774,7 +775,7 @@ static void ahci_start_port(struct ata_port *ap)
774 775
775 /* EM Transmit bit maybe busy during init */ 776 /* EM Transmit bit maybe busy during init */
776 for (i = 0; i < EM_MAX_RETRY; i++) { 777 for (i = 0; i < EM_MAX_RETRY; i++) {
777 rc = ahci_transmit_led_message(ap, 778 rc = ap->ops->transmit_led_message(ap,
778 emp->led_state, 779 emp->led_state,
779 4); 780 4);
780 if (rc == -EBUSY) 781 if (rc == -EBUSY)
@@ -915,7 +916,7 @@ static void ahci_sw_activity_blink(unsigned long arg)
915 led_message |= (1 << 16); 916 led_message |= (1 << 16);
916 } 917 }
917 spin_unlock_irqrestore(ap->lock, flags); 918 spin_unlock_irqrestore(ap->lock, flags);
918 ahci_transmit_led_message(ap, led_message, 4); 919 ap->ops->transmit_led_message(ap, led_message, 4);
919} 920}
920 921
921static void ahci_init_sw_activity(struct ata_link *link) 922static void ahci_init_sw_activity(struct ata_link *link)
@@ -1044,7 +1045,7 @@ static ssize_t ahci_led_store(struct ata_port *ap, const char *buf,
1044 if (emp->blink_policy) 1045 if (emp->blink_policy)
1045 state &= ~EM_MSG_LED_VALUE_ACTIVITY; 1046 state &= ~EM_MSG_LED_VALUE_ACTIVITY;
1046 1047
1047 return ahci_transmit_led_message(ap, state, size); 1048 return ap->ops->transmit_led_message(ap, state, size);
1048} 1049}
1049 1050
1050static ssize_t ahci_activity_store(struct ata_device *dev, enum sw_activity val) 1051static ssize_t ahci_activity_store(struct ata_device *dev, enum sw_activity val)
@@ -1063,7 +1064,7 @@ static ssize_t ahci_activity_store(struct ata_device *dev, enum sw_activity val)
1063 /* set the LED to OFF */ 1064 /* set the LED to OFF */
1064 port_led_state &= EM_MSG_LED_VALUE_OFF; 1065 port_led_state &= EM_MSG_LED_VALUE_OFF;
1065 port_led_state |= (ap->port_no | (link->pmp << 8)); 1066 port_led_state |= (ap->port_no | (link->pmp << 8));
1066 ahci_transmit_led_message(ap, port_led_state, 4); 1067 ap->ops->transmit_led_message(ap, port_led_state, 4);
1067 } else { 1068 } else {
1068 link->flags |= ATA_LFLAG_SW_ACTIVITY; 1069 link->flags |= ATA_LFLAG_SW_ACTIVITY;
1069 if (val == BLINK_OFF) { 1070 if (val == BLINK_OFF) {
@@ -1071,7 +1072,7 @@ static ssize_t ahci_activity_store(struct ata_device *dev, enum sw_activity val)
1071 port_led_state &= EM_MSG_LED_VALUE_OFF; 1072 port_led_state &= EM_MSG_LED_VALUE_OFF;
1072 port_led_state |= (ap->port_no | (link->pmp << 8)); 1073 port_led_state |= (ap->port_no | (link->pmp << 8));
1073 port_led_state |= EM_MSG_LED_VALUE_ON; /* check this */ 1074 port_led_state |= EM_MSG_LED_VALUE_ON; /* check this */
1074 ahci_transmit_led_message(ap, port_led_state, 4); 1075 ap->ops->transmit_led_message(ap, port_led_state, 4);
1075 } 1076 }
1076 } 1077 }
1077 emp->blink_policy = val; 1078 emp->blink_policy = val;
@@ -1412,7 +1413,7 @@ static int ahci_hardreset(struct ata_link *link, unsigned int *class,
1412 1413
1413 /* clear D2H reception area to properly wait for D2H FIS */ 1414 /* clear D2H reception area to properly wait for D2H FIS */
1414 ata_tf_init(link->device, &tf); 1415 ata_tf_init(link->device, &tf);
1415 tf.command = 0x80; 1416 tf.command = ATA_BUSY;
1416 ata_tf_to_fis(&tf, 0, 0, d2h_fis); 1417 ata_tf_to_fis(&tf, 0, 0, d2h_fis);
1417 1418
1418 rc = sata_link_hardreset(link, timing, deadline, &online, 1419 rc = sata_link_hardreset(link, timing, deadline, &online,
@@ -1560,8 +1561,7 @@ static void ahci_error_intr(struct ata_port *ap, u32 irq_stat)
1560 u32 fbs = readl(port_mmio + PORT_FBS); 1561 u32 fbs = readl(port_mmio + PORT_FBS);
1561 int pmp = fbs >> PORT_FBS_DWE_OFFSET; 1562 int pmp = fbs >> PORT_FBS_DWE_OFFSET;
1562 1563
1563 if ((fbs & PORT_FBS_SDE) && (pmp < ap->nr_pmp_links) && 1564 if ((fbs & PORT_FBS_SDE) && (pmp < ap->nr_pmp_links)) {
1564 ata_link_online(&ap->pmp_link[pmp])) {
1565 link = &ap->pmp_link[pmp]; 1565 link = &ap->pmp_link[pmp];
1566 fbs_need_dec = true; 1566 fbs_need_dec = true;
1567 } 1567 }
@@ -2234,6 +2234,16 @@ static int ahci_port_start(struct ata_port *ap)
2234 if (!pp) 2234 if (!pp)
2235 return -ENOMEM; 2235 return -ENOMEM;
2236 2236
2237 if (ap->host->n_ports > 1) {
2238 pp->irq_desc = devm_kzalloc(dev, 8, GFP_KERNEL);
2239 if (!pp->irq_desc) {
2240 devm_kfree(dev, pp);
2241 return -ENOMEM;
2242 }
2243 snprintf(pp->irq_desc, 8,
2244 "%s%d", dev_driver_string(dev), ap->port_no);
2245 }
2246
2237 /* check FBS capability */ 2247 /* check FBS capability */
2238 if ((hpriv->cap & HOST_CAP_FBS) && sata_pmp_supported(ap)) { 2248 if ((hpriv->cap & HOST_CAP_FBS) && sata_pmp_supported(ap)) {
2239 void __iomem *port_mmio = ahci_port_base(ap); 2249 void __iomem *port_mmio = ahci_port_base(ap);
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 6e458a40a93b..c24354d44f3d 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -2401,7 +2401,7 @@ int ata_dev_configure(struct ata_device *dev)
2401 cdb_intr_string = ", CDB intr"; 2401 cdb_intr_string = ", CDB intr";
2402 } 2402 }
2403 2403
2404 if (atapi_dmadir || atapi_id_dmadir(dev->id)) { 2404 if (atapi_dmadir || (dev->horkage & ATA_HORKAGE_ATAPI_DMADIR) || atapi_id_dmadir(dev->id)) {
2405 dev->flags |= ATA_DFLAG_DMADIR; 2405 dev->flags |= ATA_DFLAG_DMADIR;
2406 dma_dir_string = ", DMADIR"; 2406 dma_dir_string = ", DMADIR";
2407 } 2407 }
@@ -5642,6 +5642,7 @@ struct ata_port *ata_port_alloc(struct ata_host *host)
5642 ap->pflags |= ATA_PFLAG_INITIALIZING | ATA_PFLAG_FROZEN; 5642 ap->pflags |= ATA_PFLAG_INITIALIZING | ATA_PFLAG_FROZEN;
5643 ap->lock = &host->lock; 5643 ap->lock = &host->lock;
5644 ap->print_id = -1; 5644 ap->print_id = -1;
5645 ap->local_port_no = -1;
5645 ap->host = host; 5646 ap->host = host;
5646 ap->dev = host->dev; 5647 ap->dev = host->dev;
5647 5648
@@ -6132,9 +6133,10 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
6132 kfree(host->ports[i]); 6133 kfree(host->ports[i]);
6133 6134
6134 /* give ports names and add SCSI hosts */ 6135 /* give ports names and add SCSI hosts */
6135 for (i = 0; i < host->n_ports; i++) 6136 for (i = 0; i < host->n_ports; i++) {
6136 host->ports[i]->print_id = atomic_inc_return(&ata_print_id); 6137 host->ports[i]->print_id = atomic_inc_return(&ata_print_id);
6137 6138 host->ports[i]->local_port_no = i + 1;
6139 }
6138 6140
6139 /* Create associated sysfs transport objects */ 6141 /* Create associated sysfs transport objects */
6140 for (i = 0; i < host->n_ports; i++) { 6142 for (i = 0; i < host->n_ports; i++) {
@@ -6502,6 +6504,7 @@ static int __init ata_parse_force_one(char **cur,
6502 { "nosrst", .lflags = ATA_LFLAG_NO_SRST }, 6504 { "nosrst", .lflags = ATA_LFLAG_NO_SRST },
6503 { "norst", .lflags = ATA_LFLAG_NO_HRST | ATA_LFLAG_NO_SRST }, 6505 { "norst", .lflags = ATA_LFLAG_NO_HRST | ATA_LFLAG_NO_SRST },
6504 { "rstonce", .lflags = ATA_LFLAG_RST_ONCE }, 6506 { "rstonce", .lflags = ATA_LFLAG_RST_ONCE },
6507 { "atapi_dmadir", .horkage_on = ATA_HORKAGE_ATAPI_DMADIR },
6505 }; 6508 };
6506 char *start = *cur, *p = *cur; 6509 char *start = *cur, *p = *cur;
6507 char *id, *val, *endp; 6510 char *id, *val, *endp;
diff --git a/drivers/ata/libata-pmp.c b/drivers/ata/libata-pmp.c
index 61c59ee45ce9..1c41722bb7e2 100644
--- a/drivers/ata/libata-pmp.c
+++ b/drivers/ata/libata-pmp.c
@@ -389,9 +389,13 @@ static void sata_pmp_quirks(struct ata_port *ap)
389 /* link reports offline after LPM */ 389 /* link reports offline after LPM */
390 link->flags |= ATA_LFLAG_NO_LPM; 390 link->flags |= ATA_LFLAG_NO_LPM;
391 391
392 /* Class code report is unreliable. */ 392 /*
393 * Class code report is unreliable and SRST times
394 * out under certain configurations.
395 */
393 if (link->pmp < 5) 396 if (link->pmp < 5)
394 link->flags |= ATA_LFLAG_ASSUME_ATA; 397 link->flags |= ATA_LFLAG_NO_SRST |
398 ATA_LFLAG_ASSUME_ATA;
395 399
396 /* port 5 is for SEMB device and it doesn't like SRST */ 400 /* port 5 is for SEMB device and it doesn't like SRST */
397 if (link->pmp == 5) 401 if (link->pmp == 5)
@@ -399,20 +403,17 @@ static void sata_pmp_quirks(struct ata_port *ap)
399 ATA_LFLAG_ASSUME_SEMB; 403 ATA_LFLAG_ASSUME_SEMB;
400 } 404 }
401 } else if (vendor == 0x1095 && devid == 0x4723) { 405 } else if (vendor == 0x1095 && devid == 0x4723) {
402 /* sil4723 quirks */ 406 /*
403 ata_for_each_link(link, ap, EDGE) { 407 * sil4723 quirks
404 /* link reports offline after LPM */ 408 *
405 link->flags |= ATA_LFLAG_NO_LPM; 409 * Link reports offline after LPM. Class code report is
406 410 * unreliable. SIMG PMPs never got SRST reliable and the
407 /* class code report is unreliable */ 411 * config device at port 2 locks up on SRST.
408 if (link->pmp < 2) 412 */
409 link->flags |= ATA_LFLAG_ASSUME_ATA; 413 ata_for_each_link(link, ap, EDGE)
410 414 link->flags |= ATA_LFLAG_NO_LPM |
411 /* the config device at port 2 locks up on SRST */ 415 ATA_LFLAG_NO_SRST |
412 if (link->pmp == 2) 416 ATA_LFLAG_ASSUME_ATA;
413 link->flags |= ATA_LFLAG_NO_SRST |
414 ATA_LFLAG_ASSUME_ATA;
415 }
416 } else if (vendor == 0x1095 && devid == 0x4726) { 417 } else if (vendor == 0x1095 && devid == 0x4726) {
417 /* sil4726 quirks */ 418 /* sil4726 quirks */
418 ata_for_each_link(link, ap, EDGE) { 419 ata_for_each_link(link, ap, EDGE) {
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 0101af541436..83c08907e042 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -849,25 +849,24 @@ static void ata_to_sense_error(unsigned id, u8 drv_stat, u8 drv_err, u8 *sk,
849 /* Bad address mark */ 849 /* Bad address mark */
850 {0x01, MEDIUM_ERROR, 0x13, 0x00}, // Address mark not found Address mark not found for data field 850 {0x01, MEDIUM_ERROR, 0x13, 0x00}, // Address mark not found Address mark not found for data field
851 /* TRK0 */ 851 /* TRK0 */
852 {0x02, HARDWARE_ERROR, 0x00, 0x00}, // Track 0 not found Hardware error 852 {0x02, HARDWARE_ERROR, 0x00, 0x00}, // Track 0 not found Hardware error
853 /* Abort & !ICRC */ 853 /* Abort: 0x04 is not translated here, see below */
854 {0x04, ABORTED_COMMAND, 0x00, 0x00}, // Aborted command Aborted command
855 /* Media change request */ 854 /* Media change request */
856 {0x08, NOT_READY, 0x04, 0x00}, // Media change request FIXME: faking offline 855 {0x08, NOT_READY, 0x04, 0x00}, // Media change request FIXME: faking offline
857 /* SRV */ 856 /* SRV/IDNF */
858 {0x10, ABORTED_COMMAND, 0x14, 0x00}, // ID not found Recorded entity not found 857 {0x10, ILLEGAL_REQUEST, 0x21, 0x00}, // ID not found Logical address out of range
859 /* Media change */ 858 /* MC */
860 {0x08, NOT_READY, 0x04, 0x00}, // Media change FIXME: faking offline 859 {0x20, UNIT_ATTENTION, 0x28, 0x00}, // Media Changed Not ready to ready change, medium may have changed
861 /* ECC */ 860 /* ECC */
862 {0x40, MEDIUM_ERROR, 0x11, 0x04}, // Uncorrectable ECC error Unrecovered read error 861 {0x40, MEDIUM_ERROR, 0x11, 0x04}, // Uncorrectable ECC error Unrecovered read error
863 /* BBD - block marked bad */ 862 /* BBD - block marked bad */
864 {0x80, MEDIUM_ERROR, 0x11, 0x04}, // Block marked bad Medium error, unrecovered read error 863 {0x80, MEDIUM_ERROR, 0x11, 0x04}, // Block marked bad Medium error, unrecovered read error
865 {0xFF, 0xFF, 0xFF, 0xFF}, // END mark 864 {0xFF, 0xFF, 0xFF, 0xFF}, // END mark
866 }; 865 };
867 static const unsigned char stat_table[][4] = { 866 static const unsigned char stat_table[][4] = {
868 /* Must be first because BUSY means no other bits valid */ 867 /* Must be first because BUSY means no other bits valid */
869 {0x80, ABORTED_COMMAND, 0x47, 0x00}, // Busy, fake parity for now 868 {0x80, ABORTED_COMMAND, 0x47, 0x00}, // Busy, fake parity for now
870 {0x20, HARDWARE_ERROR, 0x00, 0x00}, // Device fault 869 {0x20, HARDWARE_ERROR, 0x44, 0x00}, // Device fault, internal target failure
871 {0x08, ABORTED_COMMAND, 0x47, 0x00}, // Timed out in xfer, fake parity for now 870 {0x08, ABORTED_COMMAND, 0x47, 0x00}, // Timed out in xfer, fake parity for now
872 {0x04, RECOVERED_ERROR, 0x11, 0x00}, // Recovered ECC error Medium error, recovered 871 {0x04, RECOVERED_ERROR, 0x11, 0x00}, // Recovered ECC error Medium error, recovered
873 {0xFF, 0xFF, 0xFF, 0xFF}, // END mark 872 {0xFF, 0xFF, 0xFF, 0xFF}, // END mark
@@ -892,13 +891,13 @@ static void ata_to_sense_error(unsigned id, u8 drv_stat, u8 drv_err, u8 *sk,
892 goto translate_done; 891 goto translate_done;
893 } 892 }
894 } 893 }
895 /* No immediate match */
896 if (verbose)
897 printk(KERN_WARNING "ata%u: no sense translation for "
898 "error 0x%02x\n", id, drv_err);
899 } 894 }
900 895
901 /* Fall back to interpreting status bits */ 896 /*
897 * Fall back to interpreting status bits. Note that if the drv_err
898 * has only the ABRT bit set, we decode drv_stat. ABRT by itself
899 * is not descriptive enough.
900 */
902 for (i = 0; stat_table[i][0] != 0xFF; i++) { 901 for (i = 0; stat_table[i][0] != 0xFF; i++) {
903 if (stat_table[i][0] & drv_stat) { 902 if (stat_table[i][0] & drv_stat) {
904 *sk = stat_table[i][1]; 903 *sk = stat_table[i][1];
@@ -907,13 +906,11 @@ static void ata_to_sense_error(unsigned id, u8 drv_stat, u8 drv_err, u8 *sk,
907 goto translate_done; 906 goto translate_done;
908 } 907 }
909 } 908 }
910 /* No error? Undecoded? */
911 if (verbose)
912 printk(KERN_WARNING "ata%u: no sense translation for "
913 "status: 0x%02x\n", id, drv_stat);
914 909
915 /* We need a sensible error return here, which is tricky, and one 910 /*
916 that won't cause people to do things like return a disk wrongly */ 911 * We need a sensible error return here, which is tricky, and one
912 * that won't cause people to do things like return a disk wrongly.
913 */
917 *sk = ABORTED_COMMAND; 914 *sk = ABORTED_COMMAND;
918 *asc = 0x00; 915 *asc = 0x00;
919 *ascq = 0x00; 916 *ascq = 0x00;
diff --git a/drivers/ata/libata-transport.c b/drivers/ata/libata-transport.c
index c04d393d20c1..077a856f5fd0 100644
--- a/drivers/ata/libata-transport.c
+++ b/drivers/ata/libata-transport.c
@@ -37,7 +37,7 @@
37#include "libata.h" 37#include "libata.h"
38#include "libata-transport.h" 38#include "libata-transport.h"
39 39
40#define ATA_PORT_ATTRS 2 40#define ATA_PORT_ATTRS 3
41#define ATA_LINK_ATTRS 3 41#define ATA_LINK_ATTRS 3
42#define ATA_DEV_ATTRS 9 42#define ATA_DEV_ATTRS 9
43 43
@@ -216,6 +216,7 @@ static DEVICE_ATTR(name, S_IRUGO, show_ata_port_##name, NULL)
216 216
217ata_port_simple_attr(nr_pmp_links, nr_pmp_links, "%d\n", int); 217ata_port_simple_attr(nr_pmp_links, nr_pmp_links, "%d\n", int);
218ata_port_simple_attr(stats.idle_irq, idle_irq, "%ld\n", unsigned long); 218ata_port_simple_attr(stats.idle_irq, idle_irq, "%ld\n", unsigned long);
219ata_port_simple_attr(local_port_no, port_no, "%u\n", unsigned int);
219 220
220static DECLARE_TRANSPORT_CLASS(ata_port_class, 221static DECLARE_TRANSPORT_CLASS(ata_port_class,
221 "ata_port", NULL, NULL, NULL); 222 "ata_port", NULL, NULL, NULL);
@@ -709,6 +710,7 @@ struct scsi_transport_template *ata_attach_transport(void)
709 count = 0; 710 count = 0;
710 SETUP_PORT_ATTRIBUTE(nr_pmp_links); 711 SETUP_PORT_ATTRIBUTE(nr_pmp_links);
711 SETUP_PORT_ATTRIBUTE(idle_irq); 712 SETUP_PORT_ATTRIBUTE(idle_irq);
713 SETUP_PORT_ATTRIBUTE(port_no);
712 BUG_ON(count > ATA_PORT_ATTRS); 714 BUG_ON(count > ATA_PORT_ATTRS);
713 i->port_attrs[count] = NULL; 715 i->port_attrs[count] = NULL;
714 716
diff --git a/drivers/ata/libata-zpodd.c b/drivers/ata/libata-zpodd.c
index 90b159b740b3..cd8daf47188b 100644
--- a/drivers/ata/libata-zpodd.c
+++ b/drivers/ata/libata-zpodd.c
@@ -32,13 +32,14 @@ struct zpodd {
32 32
33static int eject_tray(struct ata_device *dev) 33static int eject_tray(struct ata_device *dev)
34{ 34{
35 struct ata_taskfile tf = {}; 35 struct ata_taskfile tf;
36 const char cdb[] = { GPCMD_START_STOP_UNIT, 36 const char cdb[] = { GPCMD_START_STOP_UNIT,
37 0, 0, 0, 37 0, 0, 0,
38 0x02, /* LoEj */ 38 0x02, /* LoEj */
39 0, 0, 0, 0, 0, 0, 0, 39 0, 0, 0, 0, 0, 0, 0,
40 }; 40 };
41 41
42 ata_tf_init(dev, &tf);
42 tf.flags = ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; 43 tf.flags = ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
43 tf.command = ATA_CMD_PACKET; 44 tf.command = ATA_CMD_PACKET;
44 tf.protocol = ATAPI_PROT_NODATA; 45 tf.protocol = ATAPI_PROT_NODATA;
@@ -52,8 +53,7 @@ static enum odd_mech_type zpodd_get_mech_type(struct ata_device *dev)
52 char buf[16]; 53 char buf[16];
53 unsigned int ret; 54 unsigned int ret;
54 struct rm_feature_desc *desc = (void *)(buf + 8); 55 struct rm_feature_desc *desc = (void *)(buf + 8);
55 struct ata_taskfile tf = {}; 56 struct ata_taskfile tf;
56
57 char cdb[] = { GPCMD_GET_CONFIGURATION, 57 char cdb[] = { GPCMD_GET_CONFIGURATION,
58 2, /* only 1 feature descriptor requested */ 58 2, /* only 1 feature descriptor requested */
59 0, 3, /* 3, removable medium feature */ 59 0, 3, /* 3, removable medium feature */
@@ -62,6 +62,7 @@ static enum odd_mech_type zpodd_get_mech_type(struct ata_device *dev)
62 0, 0, 0, 62 0, 0, 0,
63 }; 63 };
64 64
65 ata_tf_init(dev, &tf);
65 tf.flags = ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; 66 tf.flags = ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
66 tf.command = ATA_CMD_PACKET; 67 tf.command = ATA_CMD_PACKET;
67 tf.protocol = ATAPI_PROT_PIO; 68 tf.protocol = ATAPI_PROT_PIO;
diff --git a/drivers/ata/pata_ali.c b/drivers/ata/pata_ali.c
index 61da0694aecd..1b7b2ccabcff 100644
--- a/drivers/ata/pata_ali.c
+++ b/drivers/ata/pata_ali.c
@@ -592,7 +592,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
592#ifdef CONFIG_PM 592#ifdef CONFIG_PM
593static int ali_reinit_one(struct pci_dev *pdev) 593static int ali_reinit_one(struct pci_dev *pdev)
594{ 594{
595 struct ata_host *host = dev_get_drvdata(&pdev->dev); 595 struct ata_host *host = pci_get_drvdata(pdev);
596 int rc; 596 int rc;
597 597
598 rc = ata_pci_device_do_resume(pdev); 598 rc = ata_pci_device_do_resume(pdev);
diff --git a/drivers/ata/pata_amd.c b/drivers/ata/pata_amd.c
index 82a08922afcd..d23e2b3ca0b6 100644
--- a/drivers/ata/pata_amd.c
+++ b/drivers/ata/pata_amd.c
@@ -578,7 +578,7 @@ static int amd_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
578#ifdef CONFIG_PM 578#ifdef CONFIG_PM
579static int amd_reinit_one(struct pci_dev *pdev) 579static int amd_reinit_one(struct pci_dev *pdev)
580{ 580{
581 struct ata_host *host = dev_get_drvdata(&pdev->dev); 581 struct ata_host *host = pci_get_drvdata(pdev);
582 int rc; 582 int rc;
583 583
584 rc = ata_pci_device_do_resume(pdev); 584 rc = ata_pci_device_do_resume(pdev);
diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
index 7638121cb5d1..848ed3254ddd 100644
--- a/drivers/ata/pata_arasan_cf.c
+++ b/drivers/ata/pata_arasan_cf.c
@@ -908,7 +908,7 @@ free_clk:
908 908
909static int arasan_cf_remove(struct platform_device *pdev) 909static int arasan_cf_remove(struct platform_device *pdev)
910{ 910{
911 struct ata_host *host = dev_get_drvdata(&pdev->dev); 911 struct ata_host *host = platform_get_drvdata(pdev);
912 struct arasan_cf_dev *acdev = host->ports[0]->private_data; 912 struct arasan_cf_dev *acdev = host->ports[0]->private_data;
913 913
914 ata_host_detach(host); 914 ata_host_detach(host);
diff --git a/drivers/ata/pata_artop.c b/drivers/ata/pata_artop.c
index 74b215c09b21..1581dee2967a 100644
--- a/drivers/ata/pata_artop.c
+++ b/drivers/ata/pata_artop.c
@@ -426,7 +426,7 @@ static const struct pci_device_id artop_pci_tbl[] = {
426#ifdef CONFIG_PM 426#ifdef CONFIG_PM
427static int atp8xx_reinit_one(struct pci_dev *pdev) 427static int atp8xx_reinit_one(struct pci_dev *pdev)
428{ 428{
429 struct ata_host *host = dev_get_drvdata(&pdev->dev); 429 struct ata_host *host = pci_get_drvdata(pdev);
430 int rc; 430 int rc;
431 431
432 rc = ata_pci_device_do_resume(pdev); 432 rc = ata_pci_device_do_resume(pdev);
diff --git a/drivers/ata/pata_at91.c b/drivers/ata/pata_at91.c
index 033f3f4c20ad..5364f97b42c6 100644
--- a/drivers/ata/pata_at91.c
+++ b/drivers/ata/pata_at91.c
@@ -422,7 +422,7 @@ err_put:
422 422
423static int pata_at91_remove(struct platform_device *pdev) 423static int pata_at91_remove(struct platform_device *pdev)
424{ 424{
425 struct ata_host *host = dev_get_drvdata(&pdev->dev); 425 struct ata_host *host = platform_get_drvdata(pdev);
426 struct at91_ide_info *info; 426 struct at91_ide_info *info;
427 427
428 if (!host) 428 if (!host)
diff --git a/drivers/ata/pata_atp867x.c b/drivers/ata/pata_atp867x.c
index 041f50d53240..2ca5026f2c15 100644
--- a/drivers/ata/pata_atp867x.c
+++ b/drivers/ata/pata_atp867x.c
@@ -534,7 +534,7 @@ err_out:
534#ifdef CONFIG_PM 534#ifdef CONFIG_PM
535static int atp867x_reinit_one(struct pci_dev *pdev) 535static int atp867x_reinit_one(struct pci_dev *pdev)
536{ 536{
537 struct ata_host *host = dev_get_drvdata(&pdev->dev); 537 struct ata_host *host = pci_get_drvdata(pdev);
538 int rc; 538 int rc;
539 539
540 rc = ata_pci_device_do_resume(pdev); 540 rc = ata_pci_device_do_resume(pdev);
diff --git a/drivers/ata/pata_bf54x.c b/drivers/ata/pata_bf54x.c
index 8d43510c6bec..ba0d8a29dc23 100644
--- a/drivers/ata/pata_bf54x.c
+++ b/drivers/ata/pata_bf54x.c
@@ -1596,7 +1596,7 @@ static int bfin_atapi_probe(struct platform_device *pdev)
1596 return -ENODEV; 1596 return -ENODEV;
1597 } 1597 }
1598 1598
1599 dev_set_drvdata(&pdev->dev, host); 1599 platform_set_drvdata(pdev, host);
1600 1600
1601 return 0; 1601 return 0;
1602} 1602}
@@ -1610,11 +1610,9 @@ static int bfin_atapi_probe(struct platform_device *pdev)
1610 */ 1610 */
1611static int bfin_atapi_remove(struct platform_device *pdev) 1611static int bfin_atapi_remove(struct platform_device *pdev)
1612{ 1612{
1613 struct device *dev = &pdev->dev; 1613 struct ata_host *host = platform_get_drvdata(pdev);
1614 struct ata_host *host = dev_get_drvdata(dev);
1615 1614
1616 ata_host_detach(host); 1615 ata_host_detach(host);
1617 dev_set_drvdata(&pdev->dev, NULL);
1618 1616
1619 peripheral_free_list(atapi_io_port); 1617 peripheral_free_list(atapi_io_port);
1620 1618
@@ -1624,7 +1622,7 @@ static int bfin_atapi_remove(struct platform_device *pdev)
1624#ifdef CONFIG_PM 1622#ifdef CONFIG_PM
1625static int bfin_atapi_suspend(struct platform_device *pdev, pm_message_t state) 1623static int bfin_atapi_suspend(struct platform_device *pdev, pm_message_t state)
1626{ 1624{
1627 struct ata_host *host = dev_get_drvdata(&pdev->dev); 1625 struct ata_host *host = platform_get_drvdata(pdev);
1628 if (host) 1626 if (host)
1629 return ata_host_suspend(host, state); 1627 return ata_host_suspend(host, state);
1630 else 1628 else
@@ -1633,7 +1631,7 @@ static int bfin_atapi_suspend(struct platform_device *pdev, pm_message_t state)
1633 1631
1634static int bfin_atapi_resume(struct platform_device *pdev) 1632static int bfin_atapi_resume(struct platform_device *pdev)
1635{ 1633{
1636 struct ata_host *host = dev_get_drvdata(&pdev->dev); 1634 struct ata_host *host = platform_get_drvdata(pdev);
1637 int ret; 1635 int ret;
1638 1636
1639 if (host) { 1637 if (host) {
diff --git a/drivers/ata/pata_cmd640.c b/drivers/ata/pata_cmd640.c
index 504b98b58e19..8fb69e5ca1b7 100644
--- a/drivers/ata/pata_cmd640.c
+++ b/drivers/ata/pata_cmd640.c
@@ -235,7 +235,7 @@ static int cmd640_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
235#ifdef CONFIG_PM 235#ifdef CONFIG_PM
236static int cmd640_reinit_one(struct pci_dev *pdev) 236static int cmd640_reinit_one(struct pci_dev *pdev)
237{ 237{
238 struct ata_host *host = dev_get_drvdata(&pdev->dev); 238 struct ata_host *host = pci_get_drvdata(pdev);
239 int rc; 239 int rc;
240 240
241 rc = ata_pci_device_do_resume(pdev); 241 rc = ata_pci_device_do_resume(pdev);
diff --git a/drivers/ata/pata_cmd64x.c b/drivers/ata/pata_cmd64x.c
index 2949cfc2dd31..1275a8d4dedc 100644
--- a/drivers/ata/pata_cmd64x.c
+++ b/drivers/ata/pata_cmd64x.c
@@ -491,7 +491,7 @@ static int cmd64x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
491#ifdef CONFIG_PM 491#ifdef CONFIG_PM
492static int cmd64x_reinit_one(struct pci_dev *pdev) 492static int cmd64x_reinit_one(struct pci_dev *pdev)
493{ 493{
494 struct ata_host *host = dev_get_drvdata(&pdev->dev); 494 struct ata_host *host = pci_get_drvdata(pdev);
495 int rc; 495 int rc;
496 496
497 rc = ata_pci_device_do_resume(pdev); 497 rc = ata_pci_device_do_resume(pdev);
diff --git a/drivers/ata/pata_cs5520.c b/drivers/ata/pata_cs5520.c
index bfcf377e8f77..f10baabbf5db 100644
--- a/drivers/ata/pata_cs5520.c
+++ b/drivers/ata/pata_cs5520.c
@@ -241,7 +241,7 @@ static int cs5520_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
241 241
242static int cs5520_reinit_one(struct pci_dev *pdev) 242static int cs5520_reinit_one(struct pci_dev *pdev)
243{ 243{
244 struct ata_host *host = dev_get_drvdata(&pdev->dev); 244 struct ata_host *host = pci_get_drvdata(pdev);
245 u8 pcicfg; 245 u8 pcicfg;
246 int rc; 246 int rc;
247 247
@@ -269,7 +269,7 @@ static int cs5520_reinit_one(struct pci_dev *pdev)
269 269
270static int cs5520_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg) 270static int cs5520_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg)
271{ 271{
272 struct ata_host *host = dev_get_drvdata(&pdev->dev); 272 struct ata_host *host = pci_get_drvdata(pdev);
273 int rc = 0; 273 int rc = 0;
274 274
275 rc = ata_host_suspend(host, mesg); 275 rc = ata_host_suspend(host, mesg);
diff --git a/drivers/ata/pata_cs5530.c b/drivers/ata/pata_cs5530.c
index 48389ae0b330..f07f2296acdc 100644
--- a/drivers/ata/pata_cs5530.c
+++ b/drivers/ata/pata_cs5530.c
@@ -330,7 +330,7 @@ static int cs5530_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
330#ifdef CONFIG_PM 330#ifdef CONFIG_PM
331static int cs5530_reinit_one(struct pci_dev *pdev) 331static int cs5530_reinit_one(struct pci_dev *pdev)
332{ 332{
333 struct ata_host *host = dev_get_drvdata(&pdev->dev); 333 struct ata_host *host = pci_get_drvdata(pdev);
334 int rc; 334 int rc;
335 335
336 rc = ata_pci_device_do_resume(pdev); 336 rc = ata_pci_device_do_resume(pdev);
diff --git a/drivers/ata/pata_hpt366.c b/drivers/ata/pata_hpt366.c
index 4be884a9f5ed..35b521348d31 100644
--- a/drivers/ata/pata_hpt366.c
+++ b/drivers/ata/pata_hpt366.c
@@ -390,7 +390,7 @@ static int hpt36x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
390#ifdef CONFIG_PM 390#ifdef CONFIG_PM
391static int hpt36x_reinit_one(struct pci_dev *dev) 391static int hpt36x_reinit_one(struct pci_dev *dev)
392{ 392{
393 struct ata_host *host = dev_get_drvdata(&dev->dev); 393 struct ata_host *host = pci_get_drvdata(dev);
394 int rc; 394 int rc;
395 395
396 rc = ata_pci_device_do_resume(dev); 396 rc = ata_pci_device_do_resume(dev);
diff --git a/drivers/ata/pata_hpt3x3.c b/drivers/ata/pata_hpt3x3.c
index 76c9314bb824..85cf2861e0b7 100644
--- a/drivers/ata/pata_hpt3x3.c
+++ b/drivers/ata/pata_hpt3x3.c
@@ -253,7 +253,7 @@ static int hpt3x3_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
253#ifdef CONFIG_PM 253#ifdef CONFIG_PM
254static int hpt3x3_reinit_one(struct pci_dev *dev) 254static int hpt3x3_reinit_one(struct pci_dev *dev)
255{ 255{
256 struct ata_host *host = dev_get_drvdata(&dev->dev); 256 struct ata_host *host = pci_get_drvdata(dev);
257 int rc; 257 int rc;
258 258
259 rc = ata_pci_device_do_resume(dev); 259 rc = ata_pci_device_do_resume(dev);
diff --git a/drivers/ata/pata_imx.c b/drivers/ata/pata_imx.c
index aa3d166e02eb..4ec7c04b3f82 100644
--- a/drivers/ata/pata_imx.c
+++ b/drivers/ata/pata_imx.c
@@ -177,7 +177,7 @@ err:
177 177
178static int pata_imx_remove(struct platform_device *pdev) 178static int pata_imx_remove(struct platform_device *pdev)
179{ 179{
180 struct ata_host *host = dev_get_drvdata(&pdev->dev); 180 struct ata_host *host = platform_get_drvdata(pdev);
181 struct pata_imx_priv *priv = host->private_data; 181 struct pata_imx_priv *priv = host->private_data;
182 182
183 ata_host_detach(host); 183 ata_host_detach(host);
diff --git a/drivers/ata/pata_it821x.c b/drivers/ata/pata_it821x.c
index 9cc05d808ad5..581e04d80367 100644
--- a/drivers/ata/pata_it821x.c
+++ b/drivers/ata/pata_it821x.c
@@ -939,7 +939,7 @@ static int it821x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
939#ifdef CONFIG_PM 939#ifdef CONFIG_PM
940static int it821x_reinit_one(struct pci_dev *pdev) 940static int it821x_reinit_one(struct pci_dev *pdev)
941{ 941{
942 struct ata_host *host = dev_get_drvdata(&pdev->dev); 942 struct ata_host *host = pci_get_drvdata(pdev);
943 int rc; 943 int rc;
944 944
945 rc = ata_pci_device_do_resume(pdev); 945 rc = ata_pci_device_do_resume(pdev);
diff --git a/drivers/ata/pata_macio.c b/drivers/ata/pata_macio.c
index e5725edcf515..c28d0645e851 100644
--- a/drivers/ata/pata_macio.c
+++ b/drivers/ata/pata_macio.c
@@ -1311,7 +1311,7 @@ static int pata_macio_pci_attach(struct pci_dev *pdev,
1311 1311
1312static void pata_macio_pci_detach(struct pci_dev *pdev) 1312static void pata_macio_pci_detach(struct pci_dev *pdev)
1313{ 1313{
1314 struct ata_host *host = dev_get_drvdata(&pdev->dev); 1314 struct ata_host *host = pci_get_drvdata(pdev);
1315 1315
1316 ata_host_detach(host); 1316 ata_host_detach(host);
1317} 1317}
@@ -1320,14 +1320,14 @@ static void pata_macio_pci_detach(struct pci_dev *pdev)
1320 1320
1321static int pata_macio_pci_suspend(struct pci_dev *pdev, pm_message_t mesg) 1321static int pata_macio_pci_suspend(struct pci_dev *pdev, pm_message_t mesg)
1322{ 1322{
1323 struct ata_host *host = dev_get_drvdata(&pdev->dev); 1323 struct ata_host *host = pci_get_drvdata(pdev);
1324 1324
1325 return pata_macio_do_suspend(host->private_data, mesg); 1325 return pata_macio_do_suspend(host->private_data, mesg);
1326} 1326}
1327 1327
1328static int pata_macio_pci_resume(struct pci_dev *pdev) 1328static int pata_macio_pci_resume(struct pci_dev *pdev)
1329{ 1329{
1330 struct ata_host *host = dev_get_drvdata(&pdev->dev); 1330 struct ata_host *host = pci_get_drvdata(pdev);
1331 1331
1332 return pata_macio_do_resume(host->private_data); 1332 return pata_macio_do_resume(host->private_data);
1333} 1333}
diff --git a/drivers/ata/pata_mpc52xx.c b/drivers/ata/pata_mpc52xx.c
index 3a8fb28b71f2..0024ced3e200 100644
--- a/drivers/ata/pata_mpc52xx.c
+++ b/drivers/ata/pata_mpc52xx.c
@@ -825,7 +825,7 @@ mpc52xx_ata_remove(struct platform_device *op)
825static int 825static int
826mpc52xx_ata_suspend(struct platform_device *op, pm_message_t state) 826mpc52xx_ata_suspend(struct platform_device *op, pm_message_t state)
827{ 827{
828 struct ata_host *host = dev_get_drvdata(&op->dev); 828 struct ata_host *host = platform_get_drvdata(op);
829 829
830 return ata_host_suspend(host, state); 830 return ata_host_suspend(host, state);
831} 831}
@@ -833,7 +833,7 @@ mpc52xx_ata_suspend(struct platform_device *op, pm_message_t state)
833static int 833static int
834mpc52xx_ata_resume(struct platform_device *op) 834mpc52xx_ata_resume(struct platform_device *op)
835{ 835{
836 struct ata_host *host = dev_get_drvdata(&op->dev); 836 struct ata_host *host = platform_get_drvdata(op);
837 struct mpc52xx_ata_priv *priv = host->private_data; 837 struct mpc52xx_ata_priv *priv = host->private_data;
838 int rv; 838 int rv;
839 839
diff --git a/drivers/ata/pata_ninja32.c b/drivers/ata/pata_ninja32.c
index 12010ed596c4..9513e071040d 100644
--- a/drivers/ata/pata_ninja32.c
+++ b/drivers/ata/pata_ninja32.c
@@ -157,7 +157,7 @@ static int ninja32_init_one(struct pci_dev *dev, const struct pci_device_id *id)
157 157
158static int ninja32_reinit_one(struct pci_dev *pdev) 158static int ninja32_reinit_one(struct pci_dev *pdev)
159{ 159{
160 struct ata_host *host = dev_get_drvdata(&pdev->dev); 160 struct ata_host *host = pci_get_drvdata(pdev);
161 int rc; 161 int rc;
162 162
163 rc = ata_pci_device_do_resume(pdev); 163 rc = ata_pci_device_do_resume(pdev);
diff --git a/drivers/ata/pata_ns87415.c b/drivers/ata/pata_ns87415.c
index 6f6fa1060505..16dc3a63a23d 100644
--- a/drivers/ata/pata_ns87415.c
+++ b/drivers/ata/pata_ns87415.c
@@ -389,7 +389,7 @@ static const struct pci_device_id ns87415_pci_tbl[] = {
389#ifdef CONFIG_PM 389#ifdef CONFIG_PM
390static int ns87415_reinit_one(struct pci_dev *pdev) 390static int ns87415_reinit_one(struct pci_dev *pdev)
391{ 391{
392 struct ata_host *host = dev_get_drvdata(&pdev->dev); 392 struct ata_host *host = pci_get_drvdata(pdev);
393 int rc; 393 int rc;
394 394
395 rc = ata_pci_device_do_resume(pdev); 395 rc = ata_pci_device_do_resume(pdev);
diff --git a/drivers/ata/pata_pdc2027x.c b/drivers/ata/pata_pdc2027x.c
index c76e65927b0e..9d874c85d64d 100644
--- a/drivers/ata/pata_pdc2027x.c
+++ b/drivers/ata/pata_pdc2027x.c
@@ -765,7 +765,7 @@ static int pdc2027x_init_one(struct pci_dev *pdev,
765#ifdef CONFIG_PM 765#ifdef CONFIG_PM
766static int pdc2027x_reinit_one(struct pci_dev *pdev) 766static int pdc2027x_reinit_one(struct pci_dev *pdev)
767{ 767{
768 struct ata_host *host = dev_get_drvdata(&pdev->dev); 768 struct ata_host *host = pci_get_drvdata(pdev);
769 unsigned int board_idx; 769 unsigned int board_idx;
770 int rc; 770 int rc;
771 771
diff --git a/drivers/ata/pata_pxa.c b/drivers/ata/pata_pxa.c
index b0ac9e0c5e01..942ef94b29e6 100644
--- a/drivers/ata/pata_pxa.c
+++ b/drivers/ata/pata_pxa.c
@@ -371,7 +371,7 @@ static int pxa_ata_probe(struct platform_device *pdev)
371 371
372static int pxa_ata_remove(struct platform_device *pdev) 372static int pxa_ata_remove(struct platform_device *pdev)
373{ 373{
374 struct ata_host *host = dev_get_drvdata(&pdev->dev); 374 struct ata_host *host = platform_get_drvdata(pdev);
375 struct pata_pxa_data *data = host->ports[0]->private_data; 375 struct pata_pxa_data *data = host->ports[0]->private_data;
376 376
377 pxa_free_dma(data->dma_channel); 377 pxa_free_dma(data->dma_channel);
diff --git a/drivers/ata/pata_rdc.c b/drivers/ata/pata_rdc.c
index 6a8665574fee..79a970f05a2e 100644
--- a/drivers/ata/pata_rdc.c
+++ b/drivers/ata/pata_rdc.c
@@ -364,7 +364,7 @@ static int rdc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
364 364
365static void rdc_remove_one(struct pci_dev *pdev) 365static void rdc_remove_one(struct pci_dev *pdev)
366{ 366{
367 struct ata_host *host = dev_get_drvdata(&pdev->dev); 367 struct ata_host *host = pci_get_drvdata(pdev);
368 struct rdc_host_priv *hpriv = host->private_data; 368 struct rdc_host_priv *hpriv = host->private_data;
369 369
370 pci_write_config_dword(pdev, 0x54, hpriv->saved_iocfg); 370 pci_write_config_dword(pdev, 0x54, hpriv->saved_iocfg);
diff --git a/drivers/ata/pata_rz1000.c b/drivers/ata/pata_rz1000.c
index 60f4de2dd47d..040b093617a4 100644
--- a/drivers/ata/pata_rz1000.c
+++ b/drivers/ata/pata_rz1000.c
@@ -105,7 +105,7 @@ static int rz1000_init_one (struct pci_dev *pdev, const struct pci_device_id *en
105#ifdef CONFIG_PM 105#ifdef CONFIG_PM
106static int rz1000_reinit_one(struct pci_dev *pdev) 106static int rz1000_reinit_one(struct pci_dev *pdev)
107{ 107{
108 struct ata_host *host = dev_get_drvdata(&pdev->dev); 108 struct ata_host *host = pci_get_drvdata(pdev);
109 int rc; 109 int rc;
110 110
111 rc = ata_pci_device_do_resume(pdev); 111 rc = ata_pci_device_do_resume(pdev);
diff --git a/drivers/ata/pata_serverworks.c b/drivers/ata/pata_serverworks.c
index f3febbce6c46..96c6a79ef606 100644
--- a/drivers/ata/pata_serverworks.c
+++ b/drivers/ata/pata_serverworks.c
@@ -440,7 +440,7 @@ static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id
440#ifdef CONFIG_PM 440#ifdef CONFIG_PM
441static int serverworks_reinit_one(struct pci_dev *pdev) 441static int serverworks_reinit_one(struct pci_dev *pdev)
442{ 442{
443 struct ata_host *host = dev_get_drvdata(&pdev->dev); 443 struct ata_host *host = pci_get_drvdata(pdev);
444 int rc; 444 int rc;
445 445
446 rc = ata_pci_device_do_resume(pdev); 446 rc = ata_pci_device_do_resume(pdev);
diff --git a/drivers/ata/pata_sil680.c b/drivers/ata/pata_sil680.c
index 64c5f0d0f812..c4b0b073ba8e 100644
--- a/drivers/ata/pata_sil680.c
+++ b/drivers/ata/pata_sil680.c
@@ -407,7 +407,7 @@ use_ioports:
407#ifdef CONFIG_PM 407#ifdef CONFIG_PM
408static int sil680_reinit_one(struct pci_dev *pdev) 408static int sil680_reinit_one(struct pci_dev *pdev)
409{ 409{
410 struct ata_host *host = dev_get_drvdata(&pdev->dev); 410 struct ata_host *host = pci_get_drvdata(pdev);
411 int try_mmio, rc; 411 int try_mmio, rc;
412 412
413 rc = ata_pci_device_do_resume(pdev); 413 rc = ata_pci_device_do_resume(pdev);
diff --git a/drivers/ata/pata_sis.c b/drivers/ata/pata_sis.c
index 2d5ac1361262..1e8363640bf5 100644
--- a/drivers/ata/pata_sis.c
+++ b/drivers/ata/pata_sis.c
@@ -873,7 +873,7 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
873#ifdef CONFIG_PM 873#ifdef CONFIG_PM
874static int sis_reinit_one(struct pci_dev *pdev) 874static int sis_reinit_one(struct pci_dev *pdev)
875{ 875{
876 struct ata_host *host = dev_get_drvdata(&pdev->dev); 876 struct ata_host *host = pci_get_drvdata(pdev);
877 int rc; 877 int rc;
878 878
879 rc = ata_pci_device_do_resume(pdev); 879 rc = ata_pci_device_do_resume(pdev);
diff --git a/drivers/ata/pata_sl82c105.c b/drivers/ata/pata_sl82c105.c
index 738e000107d6..6816911ac422 100644
--- a/drivers/ata/pata_sl82c105.c
+++ b/drivers/ata/pata_sl82c105.c
@@ -341,7 +341,7 @@ static int sl82c105_init_one(struct pci_dev *dev, const struct pci_device_id *id
341#ifdef CONFIG_PM 341#ifdef CONFIG_PM
342static int sl82c105_reinit_one(struct pci_dev *pdev) 342static int sl82c105_reinit_one(struct pci_dev *pdev)
343{ 343{
344 struct ata_host *host = dev_get_drvdata(&pdev->dev); 344 struct ata_host *host = pci_get_drvdata(pdev);
345 int rc; 345 int rc;
346 346
347 rc = ata_pci_device_do_resume(pdev); 347 rc = ata_pci_device_do_resume(pdev);
diff --git a/drivers/ata/pata_triflex.c b/drivers/ata/pata_triflex.c
index c8e589d91231..94473da68c02 100644
--- a/drivers/ata/pata_triflex.c
+++ b/drivers/ata/pata_triflex.c
@@ -211,7 +211,7 @@ static const struct pci_device_id triflex[] = {
211#ifdef CONFIG_PM 211#ifdef CONFIG_PM
212static int triflex_ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg) 212static int triflex_ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg)
213{ 213{
214 struct ata_host *host = dev_get_drvdata(&pdev->dev); 214 struct ata_host *host = pci_get_drvdata(pdev);
215 int rc = 0; 215 int rc = 0;
216 216
217 rc = ata_host_suspend(host, mesg); 217 rc = ata_host_suspend(host, mesg);
diff --git a/drivers/ata/pata_via.c b/drivers/ata/pata_via.c
index 8d2a9fdf6b8d..c3ab9a6c3965 100644
--- a/drivers/ata/pata_via.c
+++ b/drivers/ata/pata_via.c
@@ -673,7 +673,7 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
673 673
674static int via_reinit_one(struct pci_dev *pdev) 674static int via_reinit_one(struct pci_dev *pdev)
675{ 675{
676 struct ata_host *host = dev_get_drvdata(&pdev->dev); 676 struct ata_host *host = pci_get_drvdata(pdev);
677 int rc; 677 int rc;
678 678
679 rc = ata_pci_device_do_resume(pdev); 679 rc = ata_pci_device_do_resume(pdev);
diff --git a/drivers/ata/sata_fsl.c b/drivers/ata/sata_fsl.c
index d40e403e82dd..19720a0a4a65 100644
--- a/drivers/ata/sata_fsl.c
+++ b/drivers/ata/sata_fsl.c
@@ -1532,7 +1532,7 @@ static int sata_fsl_probe(struct platform_device *ofdev)
1532 ata_host_activate(host, irq, sata_fsl_interrupt, SATA_FSL_IRQ_FLAG, 1532 ata_host_activate(host, irq, sata_fsl_interrupt, SATA_FSL_IRQ_FLAG,
1533 &sata_fsl_sht); 1533 &sata_fsl_sht);
1534 1534
1535 dev_set_drvdata(&ofdev->dev, host); 1535 platform_set_drvdata(ofdev, host);
1536 1536
1537 host_priv->intr_coalescing.show = fsl_sata_intr_coalescing_show; 1537 host_priv->intr_coalescing.show = fsl_sata_intr_coalescing_show;
1538 host_priv->intr_coalescing.store = fsl_sata_intr_coalescing_store; 1538 host_priv->intr_coalescing.store = fsl_sata_intr_coalescing_store;
@@ -1558,10 +1558,8 @@ static int sata_fsl_probe(struct platform_device *ofdev)
1558 1558
1559error_exit_with_cleanup: 1559error_exit_with_cleanup:
1560 1560
1561 if (host) { 1561 if (host)
1562 dev_set_drvdata(&ofdev->dev, NULL);
1563 ata_host_detach(host); 1562 ata_host_detach(host);
1564 }
1565 1563
1566 if (hcr_base) 1564 if (hcr_base)
1567 iounmap(hcr_base); 1565 iounmap(hcr_base);
@@ -1572,7 +1570,7 @@ error_exit_with_cleanup:
1572 1570
1573static int sata_fsl_remove(struct platform_device *ofdev) 1571static int sata_fsl_remove(struct platform_device *ofdev)
1574{ 1572{
1575 struct ata_host *host = dev_get_drvdata(&ofdev->dev); 1573 struct ata_host *host = platform_get_drvdata(ofdev);
1576 struct sata_fsl_host_priv *host_priv = host->private_data; 1574 struct sata_fsl_host_priv *host_priv = host->private_data;
1577 1575
1578 device_remove_file(&ofdev->dev, &host_priv->intr_coalescing); 1576 device_remove_file(&ofdev->dev, &host_priv->intr_coalescing);
@@ -1580,8 +1578,6 @@ static int sata_fsl_remove(struct platform_device *ofdev)
1580 1578
1581 ata_host_detach(host); 1579 ata_host_detach(host);
1582 1580
1583 dev_set_drvdata(&ofdev->dev, NULL);
1584
1585 irq_dispose_mapping(host_priv->irq); 1581 irq_dispose_mapping(host_priv->irq);
1586 iounmap(host_priv->hcr_base); 1582 iounmap(host_priv->hcr_base);
1587 kfree(host_priv); 1583 kfree(host_priv);
@@ -1592,13 +1588,13 @@ static int sata_fsl_remove(struct platform_device *ofdev)
1592#ifdef CONFIG_PM 1588#ifdef CONFIG_PM
1593static int sata_fsl_suspend(struct platform_device *op, pm_message_t state) 1589static int sata_fsl_suspend(struct platform_device *op, pm_message_t state)
1594{ 1590{
1595 struct ata_host *host = dev_get_drvdata(&op->dev); 1591 struct ata_host *host = platform_get_drvdata(op);
1596 return ata_host_suspend(host, state); 1592 return ata_host_suspend(host, state);
1597} 1593}
1598 1594
1599static int sata_fsl_resume(struct platform_device *op) 1595static int sata_fsl_resume(struct platform_device *op)
1600{ 1596{
1601 struct ata_host *host = dev_get_drvdata(&op->dev); 1597 struct ata_host *host = platform_get_drvdata(op);
1602 struct sata_fsl_host_priv *host_priv = host->private_data; 1598 struct sata_fsl_host_priv *host_priv = host->private_data;
1603 int ret; 1599 int ret;
1604 void __iomem *hcr_base = host_priv->hcr_base; 1600 void __iomem *hcr_base = host_priv->hcr_base;
diff --git a/drivers/ata/sata_highbank.c b/drivers/ata/sata_highbank.c
index b20aa96b958d..d047d92a456f 100644
--- a/drivers/ata/sata_highbank.c
+++ b/drivers/ata/sata_highbank.c
@@ -33,6 +33,9 @@
33#include <linux/interrupt.h> 33#include <linux/interrupt.h>
34#include <linux/delay.h> 34#include <linux/delay.h>
35#include <linux/export.h> 35#include <linux/export.h>
36#include <linux/gpio.h>
37#include <linux/of_gpio.h>
38
36#include "ahci.h" 39#include "ahci.h"
37 40
38#define CPHY_MAP(dev, addr) ((((dev) & 0x1f) << 7) | (((addr) >> 9) & 0x7f)) 41#define CPHY_MAP(dev, addr) ((((dev) & 0x1f) << 7) | (((addr) >> 9) & 0x7f))
@@ -66,6 +69,146 @@ struct phy_lane_info {
66}; 69};
67static struct phy_lane_info port_data[CPHY_PORT_COUNT]; 70static struct phy_lane_info port_data[CPHY_PORT_COUNT];
68 71
72static DEFINE_SPINLOCK(sgpio_lock);
73#define SCLOCK 0
74#define SLOAD 1
75#define SDATA 2
76#define SGPIO_PINS 3
77#define SGPIO_PORTS 8
78
79/* can be cast as an ahci_host_priv for compatibility with most functions */
80struct ecx_plat_data {
81 u32 n_ports;
82 unsigned sgpio_gpio[SGPIO_PINS];
83 u32 sgpio_pattern;
84 u32 port_to_sgpio[SGPIO_PORTS];
85};
86
87#define SGPIO_SIGNALS 3
88#define ECX_ACTIVITY_BITS 0x300000
89#define ECX_ACTIVITY_SHIFT 2
90#define ECX_LOCATE_BITS 0x80000
91#define ECX_LOCATE_SHIFT 1
92#define ECX_FAULT_BITS 0x400000
93#define ECX_FAULT_SHIFT 0
94static inline int sgpio_bit_shift(struct ecx_plat_data *pdata, u32 port,
95 u32 shift)
96{
97 return 1 << (3 * pdata->port_to_sgpio[port] + shift);
98}
99
100static void ecx_parse_sgpio(struct ecx_plat_data *pdata, u32 port, u32 state)
101{
102 if (state & ECX_ACTIVITY_BITS)
103 pdata->sgpio_pattern |= sgpio_bit_shift(pdata, port,
104 ECX_ACTIVITY_SHIFT);
105 else
106 pdata->sgpio_pattern &= ~sgpio_bit_shift(pdata, port,
107 ECX_ACTIVITY_SHIFT);
108 if (state & ECX_LOCATE_BITS)
109 pdata->sgpio_pattern |= sgpio_bit_shift(pdata, port,
110 ECX_LOCATE_SHIFT);
111 else
112 pdata->sgpio_pattern &= ~sgpio_bit_shift(pdata, port,
113 ECX_LOCATE_SHIFT);
114 if (state & ECX_FAULT_BITS)
115 pdata->sgpio_pattern |= sgpio_bit_shift(pdata, port,
116 ECX_FAULT_SHIFT);
117 else
118 pdata->sgpio_pattern &= ~sgpio_bit_shift(pdata, port,
119 ECX_FAULT_SHIFT);
120}
121
122/*
123 * Tell the LED controller that the signal has changed by raising the clock
124 * line for 50 uS and then lowering it for 50 uS.
125 */
126static void ecx_led_cycle_clock(struct ecx_plat_data *pdata)
127{
128 gpio_set_value(pdata->sgpio_gpio[SCLOCK], 1);
129 udelay(50);
130 gpio_set_value(pdata->sgpio_gpio[SCLOCK], 0);
131 udelay(50);
132}
133
134static ssize_t ecx_transmit_led_message(struct ata_port *ap, u32 state,
135 ssize_t size)
136{
137 struct ahci_host_priv *hpriv = ap->host->private_data;
138 struct ecx_plat_data *pdata = (struct ecx_plat_data *) hpriv->plat_data;
139 struct ahci_port_priv *pp = ap->private_data;
140 unsigned long flags;
141 int pmp, i;
142 struct ahci_em_priv *emp;
143 u32 sgpio_out;
144
145 /* get the slot number from the message */
146 pmp = (state & EM_MSG_LED_PMP_SLOT) >> 8;
147 if (pmp < EM_MAX_SLOTS)
148 emp = &pp->em_priv[pmp];
149 else
150 return -EINVAL;
151
152 if (!(hpriv->em_msg_type & EM_MSG_TYPE_LED))
153 return size;
154
155 spin_lock_irqsave(&sgpio_lock, flags);
156 ecx_parse_sgpio(pdata, ap->port_no, state);
157 sgpio_out = pdata->sgpio_pattern;
158 gpio_set_value(pdata->sgpio_gpio[SLOAD], 1);
159 ecx_led_cycle_clock(pdata);
160 gpio_set_value(pdata->sgpio_gpio[SLOAD], 0);
161 /*
162 * bit-bang out the SGPIO pattern, by consuming a bit and then
163 * clocking it out.
164 */
165 for (i = 0; i < (SGPIO_SIGNALS * pdata->n_ports); i++) {
166 gpio_set_value(pdata->sgpio_gpio[SDATA], sgpio_out & 1);
167 sgpio_out >>= 1;
168 ecx_led_cycle_clock(pdata);
169 }
170
171 /* save off new led state for port/slot */
172 emp->led_state = state;
173
174 spin_unlock_irqrestore(&sgpio_lock, flags);
175 return size;
176}
177
178static void highbank_set_em_messages(struct device *dev,
179 struct ahci_host_priv *hpriv,
180 struct ata_port_info *pi)
181{
182 struct device_node *np = dev->of_node;
183 struct ecx_plat_data *pdata = hpriv->plat_data;
184 int i;
185 int err;
186
187 for (i = 0; i < SGPIO_PINS; i++) {
188 err = of_get_named_gpio(np, "calxeda,sgpio-gpio", i);
189 if (IS_ERR_VALUE(err))
190 return;
191
192 pdata->sgpio_gpio[i] = err;
193 err = gpio_request(pdata->sgpio_gpio[i], "CX SGPIO");
194 if (err) {
195 pr_err("sata_highbank gpio_request %d failed: %d\n",
196 i, err);
197 return;
198 }
199 gpio_direction_output(pdata->sgpio_gpio[i], 1);
200 }
201 of_property_read_u32_array(np, "calxeda,led-order",
202 pdata->port_to_sgpio,
203 pdata->n_ports);
204
205 /* store em_loc */
206 hpriv->em_loc = 0;
207 hpriv->em_buf_sz = 4;
208 hpriv->em_msg_type = EM_MSG_TYPE_LED;
209 pi->flags |= ATA_FLAG_EM | ATA_FLAG_SW_ACTIVITY;
210}
211
69static u32 __combo_phy_reg_read(u8 sata_port, u32 addr) 212static u32 __combo_phy_reg_read(u8 sata_port, u32 addr)
70{ 213{
71 u32 data; 214 u32 data;
@@ -196,10 +339,26 @@ static int highbank_initialize_phys(struct device *dev, void __iomem *addr)
196 return 0; 339 return 0;
197} 340}
198 341
342/*
343 * The Calxeda SATA phy intermittently fails to bring up a link with Gen3
344 * Retrying the phy hard reset can work around the issue, but the drive
345 * may fail again. In less than 150 out of 15000 test runs, it took more
346 * than 10 tries for the link to be established (but never more than 35).
347 * Triple the maximum observed retry count to provide plenty of margin for
348 * rare events and to guarantee that the link is established.
349 *
350 * Also, the default 2 second time-out on a failed drive is too long in
351 * this situation. The uboot implementation of the same driver function
352 * uses a much shorter time-out period and never experiences a time out
353 * issue. Reducing the time-out to 500ms improves the responsiveness.
354 * The other timing constants were kept the same as the stock AHCI driver.
355 * This change was also tested 15000 times on 24 drives and none of them
356 * experienced a time out.
357 */
199static int ahci_highbank_hardreset(struct ata_link *link, unsigned int *class, 358static int ahci_highbank_hardreset(struct ata_link *link, unsigned int *class,
200 unsigned long deadline) 359 unsigned long deadline)
201{ 360{
202 const unsigned long *timing = sata_ehc_deb_timing(&link->eh_context); 361 static const unsigned long timing[] = { 5, 100, 500};
203 struct ata_port *ap = link->ap; 362 struct ata_port *ap = link->ap;
204 struct ahci_port_priv *pp = ap->private_data; 363 struct ahci_port_priv *pp = ap->private_data;
205 u8 *d2h_fis = pp->rx_fis + RX_FIS_D2H_REG; 364 u8 *d2h_fis = pp->rx_fis + RX_FIS_D2H_REG;
@@ -207,7 +366,7 @@ static int ahci_highbank_hardreset(struct ata_link *link, unsigned int *class,
207 bool online; 366 bool online;
208 u32 sstatus; 367 u32 sstatus;
209 int rc; 368 int rc;
210 int retry = 10; 369 int retry = 100;
211 370
212 ahci_stop_engine(ap); 371 ahci_stop_engine(ap);
213 372
@@ -241,6 +400,7 @@ static int ahci_highbank_hardreset(struct ata_link *link, unsigned int *class,
241static struct ata_port_operations ahci_highbank_ops = { 400static struct ata_port_operations ahci_highbank_ops = {
242 .inherits = &ahci_ops, 401 .inherits = &ahci_ops,
243 .hardreset = ahci_highbank_hardreset, 402 .hardreset = ahci_highbank_hardreset,
403 .transmit_led_message = ecx_transmit_led_message,
244}; 404};
245 405
246static const struct ata_port_info ahci_highbank_port_info = { 406static const struct ata_port_info ahci_highbank_port_info = {
@@ -264,12 +424,13 @@ static int ahci_highbank_probe(struct platform_device *pdev)
264{ 424{
265 struct device *dev = &pdev->dev; 425 struct device *dev = &pdev->dev;
266 struct ahci_host_priv *hpriv; 426 struct ahci_host_priv *hpriv;
427 struct ecx_plat_data *pdata;
267 struct ata_host *host; 428 struct ata_host *host;
268 struct resource *mem; 429 struct resource *mem;
269 int irq; 430 int irq;
270 int n_ports;
271 int i; 431 int i;
272 int rc; 432 int rc;
433 u32 n_ports;
273 struct ata_port_info pi = ahci_highbank_port_info; 434 struct ata_port_info pi = ahci_highbank_port_info;
274 const struct ata_port_info *ppi[] = { &pi, NULL }; 435 const struct ata_port_info *ppi[] = { &pi, NULL };
275 436
@@ -290,6 +451,11 @@ static int ahci_highbank_probe(struct platform_device *pdev)
290 dev_err(dev, "can't alloc ahci_host_priv\n"); 451 dev_err(dev, "can't alloc ahci_host_priv\n");
291 return -ENOMEM; 452 return -ENOMEM;
292 } 453 }
454 pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
455 if (!pdata) {
456 dev_err(dev, "can't alloc ecx_plat_data\n");
457 return -ENOMEM;
458 }
293 459
294 hpriv->flags |= (unsigned long)pi.private_data; 460 hpriv->flags |= (unsigned long)pi.private_data;
295 461
@@ -313,8 +479,6 @@ static int ahci_highbank_probe(struct platform_device *pdev)
313 if (hpriv->cap & HOST_CAP_PMP) 479 if (hpriv->cap & HOST_CAP_PMP)
314 pi.flags |= ATA_FLAG_PMP; 480 pi.flags |= ATA_FLAG_PMP;
315 481
316 ahci_set_em_messages(hpriv, &pi);
317
318 /* CAP.NP sometimes indicate the index of the last enabled 482 /* CAP.NP sometimes indicate the index of the last enabled
319 * port, at other times, that of the last possible port, so 483 * port, at other times, that of the last possible port, so
320 * determining the maximum port number requires looking at 484 * determining the maximum port number requires looking at
@@ -322,6 +486,10 @@ static int ahci_highbank_probe(struct platform_device *pdev)
322 */ 486 */
323 n_ports = max(ahci_nr_ports(hpriv->cap), fls(hpriv->port_map)); 487 n_ports = max(ahci_nr_ports(hpriv->cap), fls(hpriv->port_map));
324 488
489 pdata->n_ports = n_ports;
490 hpriv->plat_data = pdata;
491 highbank_set_em_messages(dev, hpriv, &pi);
492
325 host = ata_host_alloc_pinfo(dev, ppi, n_ports); 493 host = ata_host_alloc_pinfo(dev, ppi, n_ports);
326 if (!host) { 494 if (!host) {
327 rc = -ENOMEM; 495 rc = -ENOMEM;
@@ -333,9 +501,6 @@ static int ahci_highbank_probe(struct platform_device *pdev)
333 if (!(hpriv->cap & HOST_CAP_SSS) || ahci_ignore_sss) 501 if (!(hpriv->cap & HOST_CAP_SSS) || ahci_ignore_sss)
334 host->flags |= ATA_HOST_PARALLEL_SCAN; 502 host->flags |= ATA_HOST_PARALLEL_SCAN;
335 503
336 if (pi.flags & ATA_FLAG_EM)
337 ahci_reset_em(host);
338
339 for (i = 0; i < host->n_ports; i++) { 504 for (i = 0; i < host->n_ports; i++) {
340 struct ata_port *ap = host->ports[i]; 505 struct ata_port *ap = host->ports[i];
341 506
diff --git a/drivers/ata/sata_inic162x.c b/drivers/ata/sata_inic162x.c
index 1e6827c89429..e45131748248 100644
--- a/drivers/ata/sata_inic162x.c
+++ b/drivers/ata/sata_inic162x.c
@@ -776,7 +776,7 @@ static int init_controller(void __iomem *mmio_base, u16 hctl)
776#ifdef CONFIG_PM 776#ifdef CONFIG_PM
777static int inic_pci_device_resume(struct pci_dev *pdev) 777static int inic_pci_device_resume(struct pci_dev *pdev)
778{ 778{
779 struct ata_host *host = dev_get_drvdata(&pdev->dev); 779 struct ata_host *host = pci_get_drvdata(pdev);
780 struct inic_host_priv *hpriv = host->private_data; 780 struct inic_host_priv *hpriv = host->private_data;
781 int rc; 781 int rc;
782 782
diff --git a/drivers/ata/sata_nv.c b/drivers/ata/sata_nv.c
index 85ee4993ca74..d74def823d3e 100644
--- a/drivers/ata/sata_nv.c
+++ b/drivers/ata/sata_nv.c
@@ -2435,7 +2435,7 @@ static int nv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2435#ifdef CONFIG_PM 2435#ifdef CONFIG_PM
2436static int nv_pci_device_resume(struct pci_dev *pdev) 2436static int nv_pci_device_resume(struct pci_dev *pdev)
2437{ 2437{
2438 struct ata_host *host = dev_get_drvdata(&pdev->dev); 2438 struct ata_host *host = pci_get_drvdata(pdev);
2439 struct nv_host_priv *hpriv = host->private_data; 2439 struct nv_host_priv *hpriv = host->private_data;
2440 int rc; 2440 int rc;
2441 2441
diff --git a/drivers/ata/sata_rcar.c b/drivers/ata/sata_rcar.c
index 249c8a289bfd..8108eb065444 100644
--- a/drivers/ata/sata_rcar.c
+++ b/drivers/ata/sata_rcar.c
@@ -121,6 +121,8 @@
121/* Descriptor table word 0 bit (when DTA32M = 1) */ 121/* Descriptor table word 0 bit (when DTA32M = 1) */
122#define SATA_RCAR_DTEND BIT(0) 122#define SATA_RCAR_DTEND BIT(0)
123 123
124#define SATA_RCAR_DMA_BOUNDARY 0x1FFFFFFEUL
125
124struct sata_rcar_priv { 126struct sata_rcar_priv {
125 void __iomem *base; 127 void __iomem *base;
126 struct clk *clk; 128 struct clk *clk;
@@ -128,41 +130,44 @@ struct sata_rcar_priv {
128 130
129static void sata_rcar_phy_initialize(struct sata_rcar_priv *priv) 131static void sata_rcar_phy_initialize(struct sata_rcar_priv *priv)
130{ 132{
133 void __iomem *base = priv->base;
134
131 /* idle state */ 135 /* idle state */
132 iowrite32(0, priv->base + SATAPHYADDR_REG); 136 iowrite32(0, base + SATAPHYADDR_REG);
133 /* reset */ 137 /* reset */
134 iowrite32(SATAPHYRESET_PHYRST, priv->base + SATAPHYRESET_REG); 138 iowrite32(SATAPHYRESET_PHYRST, base + SATAPHYRESET_REG);
135 udelay(10); 139 udelay(10);
136 /* deassert reset */ 140 /* deassert reset */
137 iowrite32(0, priv->base + SATAPHYRESET_REG); 141 iowrite32(0, base + SATAPHYRESET_REG);
138} 142}
139 143
140static void sata_rcar_phy_write(struct sata_rcar_priv *priv, u16 reg, u32 val, 144static void sata_rcar_phy_write(struct sata_rcar_priv *priv, u16 reg, u32 val,
141 int group) 145 int group)
142{ 146{
147 void __iomem *base = priv->base;
143 int timeout; 148 int timeout;
144 149
145 /* deassert reset */ 150 /* deassert reset */
146 iowrite32(0, priv->base + SATAPHYRESET_REG); 151 iowrite32(0, base + SATAPHYRESET_REG);
147 /* lane 1 */ 152 /* lane 1 */
148 iowrite32(SATAPHYACCEN_PHYLANE, priv->base + SATAPHYACCEN_REG); 153 iowrite32(SATAPHYACCEN_PHYLANE, base + SATAPHYACCEN_REG);
149 /* write phy register value */ 154 /* write phy register value */
150 iowrite32(val, priv->base + SATAPHYWDATA_REG); 155 iowrite32(val, base + SATAPHYWDATA_REG);
151 /* set register group */ 156 /* set register group */
152 if (group) 157 if (group)
153 reg |= SATAPHYADDR_PHYRATEMODE; 158 reg |= SATAPHYADDR_PHYRATEMODE;
154 /* write command */ 159 /* write command */
155 iowrite32(SATAPHYADDR_PHYCMD_WRITE | reg, priv->base + SATAPHYADDR_REG); 160 iowrite32(SATAPHYADDR_PHYCMD_WRITE | reg, base + SATAPHYADDR_REG);
156 /* wait for ack */ 161 /* wait for ack */
157 for (timeout = 0; timeout < 100; timeout++) { 162 for (timeout = 0; timeout < 100; timeout++) {
158 val = ioread32(priv->base + SATAPHYACK_REG); 163 val = ioread32(base + SATAPHYACK_REG);
159 if (val & SATAPHYACK_PHYACK) 164 if (val & SATAPHYACK_PHYACK)
160 break; 165 break;
161 } 166 }
162 if (timeout >= 100) 167 if (timeout >= 100)
163 pr_err("%s timeout\n", __func__); 168 pr_err("%s timeout\n", __func__);
164 /* idle state */ 169 /* idle state */
165 iowrite32(0, priv->base + SATAPHYADDR_REG); 170 iowrite32(0, base + SATAPHYADDR_REG);
166} 171}
167 172
168static void sata_rcar_freeze(struct ata_port *ap) 173static void sata_rcar_freeze(struct ata_port *ap)
@@ -178,14 +183,15 @@ static void sata_rcar_freeze(struct ata_port *ap)
178static void sata_rcar_thaw(struct ata_port *ap) 183static void sata_rcar_thaw(struct ata_port *ap)
179{ 184{
180 struct sata_rcar_priv *priv = ap->host->private_data; 185 struct sata_rcar_priv *priv = ap->host->private_data;
186 void __iomem *base = priv->base;
181 187
182 /* ack */ 188 /* ack */
183 iowrite32(~SATA_RCAR_INT_MASK, priv->base + SATAINTSTAT_REG); 189 iowrite32(~(u32)SATA_RCAR_INT_MASK, base + SATAINTSTAT_REG);
184 190
185 ata_sff_thaw(ap); 191 ata_sff_thaw(ap);
186 192
187 /* unmask */ 193 /* unmask */
188 iowrite32(0x7ff & ~SATA_RCAR_INT_MASK, priv->base + SATAINTMASK_REG); 194 iowrite32(0x7ff & ~SATA_RCAR_INT_MASK, base + SATAINTMASK_REG);
189} 195}
190 196
191static void sata_rcar_ioread16_rep(void __iomem *reg, void *buffer, int count) 197static void sata_rcar_ioread16_rep(void __iomem *reg, void *buffer, int count)
@@ -474,11 +480,10 @@ static void sata_rcar_bmdma_fill_sg(struct ata_queued_cmd *qc)
474 struct ata_port *ap = qc->ap; 480 struct ata_port *ap = qc->ap;
475 struct ata_bmdma_prd *prd = ap->bmdma_prd; 481 struct ata_bmdma_prd *prd = ap->bmdma_prd;
476 struct scatterlist *sg; 482 struct scatterlist *sg;
477 unsigned int si, pi; 483 unsigned int si;
478 484
479 pi = 0;
480 for_each_sg(qc->sg, sg, qc->n_elem, si) { 485 for_each_sg(qc->sg, sg, qc->n_elem, si) {
481 u32 addr, sg_len, len; 486 u32 addr, sg_len;
482 487
483 /* 488 /*
484 * Note: h/w doesn't support 64-bit, so we unconditionally 489 * Note: h/w doesn't support 64-bit, so we unconditionally
@@ -487,24 +492,13 @@ static void sata_rcar_bmdma_fill_sg(struct ata_queued_cmd *qc)
487 addr = (u32)sg_dma_address(sg); 492 addr = (u32)sg_dma_address(sg);
488 sg_len = sg_dma_len(sg); 493 sg_len = sg_dma_len(sg);
489 494
490 /* H/w transfer count is only 29 bits long, let's be careful */ 495 prd[si].addr = cpu_to_le32(addr);
491 while (sg_len) { 496 prd[si].flags_len = cpu_to_le32(sg_len);
492 len = sg_len; 497 VPRINTK("PRD[%u] = (0x%X, 0x%X)\n", si, addr, sg_len);
493 if (len > 0x1ffffffe)
494 len = 0x1ffffffe;
495
496 prd[pi].addr = cpu_to_le32(addr);
497 prd[pi].flags_len = cpu_to_le32(len);
498 VPRINTK("PRD[%u] = (0x%X, 0x%X)\n", pi, addr, len);
499
500 pi++;
501 sg_len -= len;
502 addr += len;
503 }
504 } 498 }
505 499
506 /* end-of-table flag */ 500 /* end-of-table flag */
507 prd[pi - 1].addr |= cpu_to_le32(SATA_RCAR_DTEND); 501 prd[si - 1].addr |= cpu_to_le32(SATA_RCAR_DTEND);
508} 502}
509 503
510static void sata_rcar_qc_prep(struct ata_queued_cmd *qc) 504static void sata_rcar_qc_prep(struct ata_queued_cmd *qc)
@@ -519,15 +513,16 @@ static void sata_rcar_bmdma_setup(struct ata_queued_cmd *qc)
519{ 513{
520 struct ata_port *ap = qc->ap; 514 struct ata_port *ap = qc->ap;
521 unsigned int rw = qc->tf.flags & ATA_TFLAG_WRITE; 515 unsigned int rw = qc->tf.flags & ATA_TFLAG_WRITE;
522 u32 dmactl;
523 struct sata_rcar_priv *priv = ap->host->private_data; 516 struct sata_rcar_priv *priv = ap->host->private_data;
517 void __iomem *base = priv->base;
518 u32 dmactl;
524 519
525 /* load PRD table addr. */ 520 /* load PRD table addr. */
526 mb(); /* make sure PRD table writes are visible to controller */ 521 mb(); /* make sure PRD table writes are visible to controller */
527 iowrite32(ap->bmdma_prd_dma, priv->base + ATAPI_DTB_ADR_REG); 522 iowrite32(ap->bmdma_prd_dma, base + ATAPI_DTB_ADR_REG);
528 523
529 /* specify data direction, triple-check start bit is clear */ 524 /* specify data direction, triple-check start bit is clear */
530 dmactl = ioread32(priv->base + ATAPI_CONTROL1_REG); 525 dmactl = ioread32(base + ATAPI_CONTROL1_REG);
531 dmactl &= ~(ATAPI_CONTROL1_RW | ATAPI_CONTROL1_STOP); 526 dmactl &= ~(ATAPI_CONTROL1_RW | ATAPI_CONTROL1_STOP);
532 if (dmactl & ATAPI_CONTROL1_START) { 527 if (dmactl & ATAPI_CONTROL1_START) {
533 dmactl &= ~ATAPI_CONTROL1_START; 528 dmactl &= ~ATAPI_CONTROL1_START;
@@ -535,7 +530,7 @@ static void sata_rcar_bmdma_setup(struct ata_queued_cmd *qc)
535 } 530 }
536 if (!rw) 531 if (!rw)
537 dmactl |= ATAPI_CONTROL1_RW; 532 dmactl |= ATAPI_CONTROL1_RW;
538 iowrite32(dmactl, priv->base + ATAPI_CONTROL1_REG); 533 iowrite32(dmactl, base + ATAPI_CONTROL1_REG);
539 534
540 /* issue r/w command */ 535 /* issue r/w command */
541 ap->ops->sff_exec_command(ap, &qc->tf); 536 ap->ops->sff_exec_command(ap, &qc->tf);
@@ -544,28 +539,30 @@ static void sata_rcar_bmdma_setup(struct ata_queued_cmd *qc)
544static void sata_rcar_bmdma_start(struct ata_queued_cmd *qc) 539static void sata_rcar_bmdma_start(struct ata_queued_cmd *qc)
545{ 540{
546 struct ata_port *ap = qc->ap; 541 struct ata_port *ap = qc->ap;
547 u32 dmactl;
548 struct sata_rcar_priv *priv = ap->host->private_data; 542 struct sata_rcar_priv *priv = ap->host->private_data;
543 void __iomem *base = priv->base;
544 u32 dmactl;
549 545
550 /* start host DMA transaction */ 546 /* start host DMA transaction */
551 dmactl = ioread32(priv->base + ATAPI_CONTROL1_REG); 547 dmactl = ioread32(base + ATAPI_CONTROL1_REG);
552 dmactl &= ~ATAPI_CONTROL1_STOP; 548 dmactl &= ~ATAPI_CONTROL1_STOP;
553 dmactl |= ATAPI_CONTROL1_START; 549 dmactl |= ATAPI_CONTROL1_START;
554 iowrite32(dmactl, priv->base + ATAPI_CONTROL1_REG); 550 iowrite32(dmactl, base + ATAPI_CONTROL1_REG);
555} 551}
556 552
557static void sata_rcar_bmdma_stop(struct ata_queued_cmd *qc) 553static void sata_rcar_bmdma_stop(struct ata_queued_cmd *qc)
558{ 554{
559 struct ata_port *ap = qc->ap; 555 struct ata_port *ap = qc->ap;
560 struct sata_rcar_priv *priv = ap->host->private_data; 556 struct sata_rcar_priv *priv = ap->host->private_data;
557 void __iomem *base = priv->base;
561 u32 dmactl; 558 u32 dmactl;
562 559
563 /* force termination of DMA transfer if active */ 560 /* force termination of DMA transfer if active */
564 dmactl = ioread32(priv->base + ATAPI_CONTROL1_REG); 561 dmactl = ioread32(base + ATAPI_CONTROL1_REG);
565 if (dmactl & ATAPI_CONTROL1_START) { 562 if (dmactl & ATAPI_CONTROL1_START) {
566 dmactl &= ~ATAPI_CONTROL1_START; 563 dmactl &= ~ATAPI_CONTROL1_START;
567 dmactl |= ATAPI_CONTROL1_STOP; 564 dmactl |= ATAPI_CONTROL1_STOP;
568 iowrite32(dmactl, priv->base + ATAPI_CONTROL1_REG); 565 iowrite32(dmactl, base + ATAPI_CONTROL1_REG);
569 } 566 }
570 567
571 /* one-PIO-cycle guaranteed wait, per spec, for HDMA1:0 transition */ 568 /* one-PIO-cycle guaranteed wait, per spec, for HDMA1:0 transition */
@@ -575,8 +572,8 @@ static void sata_rcar_bmdma_stop(struct ata_queued_cmd *qc)
575static u8 sata_rcar_bmdma_status(struct ata_port *ap) 572static u8 sata_rcar_bmdma_status(struct ata_port *ap)
576{ 573{
577 struct sata_rcar_priv *priv = ap->host->private_data; 574 struct sata_rcar_priv *priv = ap->host->private_data;
578 u32 status;
579 u8 host_stat = 0; 575 u8 host_stat = 0;
576 u32 status;
580 577
581 status = ioread32(priv->base + ATAPI_STATUS_REG); 578 status = ioread32(priv->base + ATAPI_STATUS_REG);
582 if (status & ATAPI_STATUS_DEVINT) 579 if (status & ATAPI_STATUS_DEVINT)
@@ -588,7 +585,14 @@ static u8 sata_rcar_bmdma_status(struct ata_port *ap)
588} 585}
589 586
590static struct scsi_host_template sata_rcar_sht = { 587static struct scsi_host_template sata_rcar_sht = {
591 ATA_BMDMA_SHT(DRV_NAME), 588 ATA_BASE_SHT(DRV_NAME),
589 /*
590 * This controller allows transfer chunks up to 512MB which cross 64KB
591 * boundaries, therefore the DMA limits are more relaxed than standard
592 * ATA SFF.
593 */
594 .sg_tablesize = ATA_MAX_PRD,
595 .dma_boundary = SATA_RCAR_DMA_BOUNDARY,
592}; 596};
593 597
594static struct ata_port_operations sata_rcar_port_ops = { 598static struct ata_port_operations sata_rcar_port_ops = {
@@ -668,19 +672,20 @@ static irqreturn_t sata_rcar_interrupt(int irq, void *dev_instance)
668{ 672{
669 struct ata_host *host = dev_instance; 673 struct ata_host *host = dev_instance;
670 struct sata_rcar_priv *priv = host->private_data; 674 struct sata_rcar_priv *priv = host->private_data;
671 struct ata_port *ap; 675 void __iomem *base = priv->base;
672 unsigned int handled = 0; 676 unsigned int handled = 0;
677 struct ata_port *ap;
673 u32 sataintstat; 678 u32 sataintstat;
674 unsigned long flags; 679 unsigned long flags;
675 680
676 spin_lock_irqsave(&host->lock, flags); 681 spin_lock_irqsave(&host->lock, flags);
677 682
678 sataintstat = ioread32(priv->base + SATAINTSTAT_REG); 683 sataintstat = ioread32(base + SATAINTSTAT_REG);
679 sataintstat &= SATA_RCAR_INT_MASK; 684 sataintstat &= SATA_RCAR_INT_MASK;
680 if (!sataintstat) 685 if (!sataintstat)
681 goto done; 686 goto done;
682 /* ack */ 687 /* ack */
683 iowrite32(~sataintstat & 0x7ff, priv->base + SATAINTSTAT_REG); 688 iowrite32(~sataintstat & 0x7ff, base + SATAINTSTAT_REG);
684 689
685 ap = host->ports[0]; 690 ap = host->ports[0];
686 691
@@ -702,15 +707,16 @@ static void sata_rcar_setup_port(struct ata_host *host)
702 struct ata_port *ap = host->ports[0]; 707 struct ata_port *ap = host->ports[0];
703 struct ata_ioports *ioaddr = &ap->ioaddr; 708 struct ata_ioports *ioaddr = &ap->ioaddr;
704 struct sata_rcar_priv *priv = host->private_data; 709 struct sata_rcar_priv *priv = host->private_data;
710 void __iomem *base = priv->base;
705 711
706 ap->ops = &sata_rcar_port_ops; 712 ap->ops = &sata_rcar_port_ops;
707 ap->pio_mask = ATA_PIO4; 713 ap->pio_mask = ATA_PIO4;
708 ap->udma_mask = ATA_UDMA6; 714 ap->udma_mask = ATA_UDMA6;
709 ap->flags |= ATA_FLAG_SATA; 715 ap->flags |= ATA_FLAG_SATA;
710 716
711 ioaddr->cmd_addr = priv->base + SDATA_REG; 717 ioaddr->cmd_addr = base + SDATA_REG;
712 ioaddr->ctl_addr = priv->base + SSDEVCON_REG; 718 ioaddr->ctl_addr = base + SSDEVCON_REG;
713 ioaddr->scr_addr = priv->base + SCRSSTS_REG; 719 ioaddr->scr_addr = base + SCRSSTS_REG;
714 ioaddr->altstatus_addr = ioaddr->ctl_addr; 720 ioaddr->altstatus_addr = ioaddr->ctl_addr;
715 721
716 ioaddr->data_addr = ioaddr->cmd_addr + (ATA_REG_DATA << 2); 722 ioaddr->data_addr = ioaddr->cmd_addr + (ATA_REG_DATA << 2);
@@ -728,6 +734,7 @@ static void sata_rcar_setup_port(struct ata_host *host)
728static void sata_rcar_init_controller(struct ata_host *host) 734static void sata_rcar_init_controller(struct ata_host *host)
729{ 735{
730 struct sata_rcar_priv *priv = host->private_data; 736 struct sata_rcar_priv *priv = host->private_data;
737 void __iomem *base = priv->base;
731 u32 val; 738 u32 val;
732 739
733 /* reset and setup phy */ 740 /* reset and setup phy */
@@ -740,27 +747,27 @@ static void sata_rcar_init_controller(struct ata_host *host)
740 sata_rcar_phy_write(priv, SATAPCTLR4_REG, 0x28E80000, 0); 747 sata_rcar_phy_write(priv, SATAPCTLR4_REG, 0x28E80000, 0);
741 748
742 /* SATA-IP reset state */ 749 /* SATA-IP reset state */
743 val = ioread32(priv->base + ATAPI_CONTROL1_REG); 750 val = ioread32(base + ATAPI_CONTROL1_REG);
744 val |= ATAPI_CONTROL1_RESET; 751 val |= ATAPI_CONTROL1_RESET;
745 iowrite32(val, priv->base + ATAPI_CONTROL1_REG); 752 iowrite32(val, base + ATAPI_CONTROL1_REG);
746 753
747 /* ISM mode, PRD mode, DTEND flag at bit 0 */ 754 /* ISM mode, PRD mode, DTEND flag at bit 0 */
748 val = ioread32(priv->base + ATAPI_CONTROL1_REG); 755 val = ioread32(base + ATAPI_CONTROL1_REG);
749 val |= ATAPI_CONTROL1_ISM; 756 val |= ATAPI_CONTROL1_ISM;
750 val |= ATAPI_CONTROL1_DESE; 757 val |= ATAPI_CONTROL1_DESE;
751 val |= ATAPI_CONTROL1_DTA32M; 758 val |= ATAPI_CONTROL1_DTA32M;
752 iowrite32(val, priv->base + ATAPI_CONTROL1_REG); 759 iowrite32(val, base + ATAPI_CONTROL1_REG);
753 760
754 /* Release the SATA-IP from the reset state */ 761 /* Release the SATA-IP from the reset state */
755 val = ioread32(priv->base + ATAPI_CONTROL1_REG); 762 val = ioread32(base + ATAPI_CONTROL1_REG);
756 val &= ~ATAPI_CONTROL1_RESET; 763 val &= ~ATAPI_CONTROL1_RESET;
757 iowrite32(val, priv->base + ATAPI_CONTROL1_REG); 764 iowrite32(val, base + ATAPI_CONTROL1_REG);
758 765
759 /* ack and mask */ 766 /* ack and mask */
760 iowrite32(0, priv->base + SATAINTSTAT_REG); 767 iowrite32(0, base + SATAINTSTAT_REG);
761 iowrite32(0x7ff, priv->base + SATAINTMASK_REG); 768 iowrite32(0x7ff, base + SATAINTMASK_REG);
762 /* enable interrupts */ 769 /* enable interrupts */
763 iowrite32(ATAPI_INT_ENABLE_SATAINT, priv->base + ATAPI_INT_ENABLE_REG); 770 iowrite32(ATAPI_INT_ENABLE_SATAINT, base + ATAPI_INT_ENABLE_REG);
764} 771}
765 772
766static int sata_rcar_probe(struct platform_device *pdev) 773static int sata_rcar_probe(struct platform_device *pdev)
@@ -825,16 +832,17 @@ cleanup:
825 832
826static int sata_rcar_remove(struct platform_device *pdev) 833static int sata_rcar_remove(struct platform_device *pdev)
827{ 834{
828 struct ata_host *host = dev_get_drvdata(&pdev->dev); 835 struct ata_host *host = platform_get_drvdata(pdev);
829 struct sata_rcar_priv *priv = host->private_data; 836 struct sata_rcar_priv *priv = host->private_data;
837 void __iomem *base = priv->base;
830 838
831 ata_host_detach(host); 839 ata_host_detach(host);
832 840
833 /* disable interrupts */ 841 /* disable interrupts */
834 iowrite32(0, priv->base + ATAPI_INT_ENABLE_REG); 842 iowrite32(0, base + ATAPI_INT_ENABLE_REG);
835 /* ack and mask */ 843 /* ack and mask */
836 iowrite32(0, priv->base + SATAINTSTAT_REG); 844 iowrite32(0, base + SATAINTSTAT_REG);
837 iowrite32(0x7ff, priv->base + SATAINTMASK_REG); 845 iowrite32(0x7ff, base + SATAINTMASK_REG);
838 846
839 clk_disable(priv->clk); 847 clk_disable(priv->clk);
840 848
@@ -846,14 +854,15 @@ static int sata_rcar_suspend(struct device *dev)
846{ 854{
847 struct ata_host *host = dev_get_drvdata(dev); 855 struct ata_host *host = dev_get_drvdata(dev);
848 struct sata_rcar_priv *priv = host->private_data; 856 struct sata_rcar_priv *priv = host->private_data;
857 void __iomem *base = priv->base;
849 int ret; 858 int ret;
850 859
851 ret = ata_host_suspend(host, PMSG_SUSPEND); 860 ret = ata_host_suspend(host, PMSG_SUSPEND);
852 if (!ret) { 861 if (!ret) {
853 /* disable interrupts */ 862 /* disable interrupts */
854 iowrite32(0, priv->base + ATAPI_INT_ENABLE_REG); 863 iowrite32(0, base + ATAPI_INT_ENABLE_REG);
855 /* mask */ 864 /* mask */
856 iowrite32(0x7ff, priv->base + SATAINTMASK_REG); 865 iowrite32(0x7ff, base + SATAINTMASK_REG);
857 866
858 clk_disable(priv->clk); 867 clk_disable(priv->clk);
859 } 868 }
@@ -865,14 +874,15 @@ static int sata_rcar_resume(struct device *dev)
865{ 874{
866 struct ata_host *host = dev_get_drvdata(dev); 875 struct ata_host *host = dev_get_drvdata(dev);
867 struct sata_rcar_priv *priv = host->private_data; 876 struct sata_rcar_priv *priv = host->private_data;
877 void __iomem *base = priv->base;
868 878
869 clk_enable(priv->clk); 879 clk_enable(priv->clk);
870 880
871 /* ack and mask */ 881 /* ack and mask */
872 iowrite32(0, priv->base + SATAINTSTAT_REG); 882 iowrite32(0, base + SATAINTSTAT_REG);
873 iowrite32(0x7ff, priv->base + SATAINTMASK_REG); 883 iowrite32(0x7ff, base + SATAINTMASK_REG);
874 /* enable interrupts */ 884 /* enable interrupts */
875 iowrite32(ATAPI_INT_ENABLE_SATAINT, priv->base + ATAPI_INT_ENABLE_REG); 885 iowrite32(ATAPI_INT_ENABLE_SATAINT, base + ATAPI_INT_ENABLE_REG);
876 886
877 ata_host_resume(host); 887 ata_host_resume(host);
878 888
diff --git a/drivers/ata/sata_sil.c b/drivers/ata/sata_sil.c
index 0ae3ca4bf5c0..d67fc351343c 100644
--- a/drivers/ata/sata_sil.c
+++ b/drivers/ata/sata_sil.c
@@ -805,7 +805,7 @@ static int sil_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
805#ifdef CONFIG_PM 805#ifdef CONFIG_PM
806static int sil_pci_device_resume(struct pci_dev *pdev) 806static int sil_pci_device_resume(struct pci_dev *pdev)
807{ 807{
808 struct ata_host *host = dev_get_drvdata(&pdev->dev); 808 struct ata_host *host = pci_get_drvdata(pdev);
809 int rc; 809 int rc;
810 810
811 rc = ata_pci_device_do_resume(pdev); 811 rc = ata_pci_device_do_resume(pdev);
diff --git a/drivers/ata/sata_sil24.c b/drivers/ata/sata_sil24.c
index 59f0d630d634..aa1051ba6d13 100644
--- a/drivers/ata/sata_sil24.c
+++ b/drivers/ata/sata_sil24.c
@@ -1353,7 +1353,7 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1353#ifdef CONFIG_PM 1353#ifdef CONFIG_PM
1354static int sil24_pci_device_resume(struct pci_dev *pdev) 1354static int sil24_pci_device_resume(struct pci_dev *pdev)
1355{ 1355{
1356 struct ata_host *host = dev_get_drvdata(&pdev->dev); 1356 struct ata_host *host = pci_get_drvdata(pdev);
1357 void __iomem *host_base = host->iomap[SIL24_HOST_BAR]; 1357 void __iomem *host_base = host->iomap[SIL24_HOST_BAR];
1358 int rc; 1358 int rc;
1359 1359
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index 6c4cedb44c07..168bc7b9f057 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -6662,7 +6662,6 @@ static bool ipr_qc_fill_rtf(struct ata_queued_cmd *qc)
6662 tf->hob_lbal = g->hob_lbal; 6662 tf->hob_lbal = g->hob_lbal;
6663 tf->hob_lbam = g->hob_lbam; 6663 tf->hob_lbam = g->hob_lbam;
6664 tf->hob_lbah = g->hob_lbah; 6664 tf->hob_lbah = g->hob_lbah;
6665 tf->ctl = g->alt_status;
6666 6665
6667 return true; 6666 return true;
6668} 6667}
diff --git a/include/linux/libata.h b/include/linux/libata.h
index eae7a053dc51..4ea55bb45deb 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -399,6 +399,7 @@ enum {
399 ATA_HORKAGE_BROKEN_FPDMA_AA = (1 << 15), /* skip AA */ 399 ATA_HORKAGE_BROKEN_FPDMA_AA = (1 << 15), /* skip AA */
400 ATA_HORKAGE_DUMP_ID = (1 << 16), /* dump IDENTIFY data */ 400 ATA_HORKAGE_DUMP_ID = (1 << 16), /* dump IDENTIFY data */
401 ATA_HORKAGE_MAX_SEC_LBA48 = (1 << 17), /* Set max sects to 65535 */ 401 ATA_HORKAGE_MAX_SEC_LBA48 = (1 << 17), /* Set max sects to 65535 */
402 ATA_HORKAGE_ATAPI_DMADIR = (1 << 18), /* device requires dmadir */
402 403
403 /* DMA mask for user DMA control: User visible values; DO NOT 404 /* DMA mask for user DMA control: User visible values; DO NOT
404 renumber */ 405 renumber */
@@ -746,6 +747,7 @@ struct ata_port {
746 /* Flags that change dynamically, protected by ap->lock */ 747 /* Flags that change dynamically, protected by ap->lock */
747 unsigned int pflags; /* ATA_PFLAG_xxx */ 748 unsigned int pflags; /* ATA_PFLAG_xxx */
748 unsigned int print_id; /* user visible unique port ID */ 749 unsigned int print_id; /* user visible unique port ID */
750 unsigned int local_port_no; /* host local port num */
749 unsigned int port_no; /* 0 based port no. inside the host */ 751 unsigned int port_no; /* 0 based port no. inside the host */
750 752
751#ifdef CONFIG_ATA_SFF 753#ifdef CONFIG_ATA_SFF
@@ -908,6 +910,9 @@ struct ata_port_operations {
908 ssize_t (*sw_activity_show)(struct ata_device *dev, char *buf); 910 ssize_t (*sw_activity_show)(struct ata_device *dev, char *buf);
909 ssize_t (*sw_activity_store)(struct ata_device *dev, 911 ssize_t (*sw_activity_store)(struct ata_device *dev,
910 enum sw_activity val); 912 enum sw_activity val);
913 ssize_t (*transmit_led_message)(struct ata_port *ap, u32 state,
914 ssize_t size);
915
911 /* 916 /*
912 * Obsolete 917 * Obsolete
913 */ 918 */