diff options
-rw-r--r-- | Documentation/devicetree/bindings/ata/ahci-fsl-qoriq.txt | 21 | ||||
-rw-r--r-- | Documentation/devicetree/bindings/ata/ahci-platform.txt | 2 | ||||
-rw-r--r-- | drivers/ata/Kconfig | 9 | ||||
-rw-r--r-- | drivers/ata/Makefile | 1 | ||||
-rw-r--r-- | drivers/ata/ahci.c | 12 | ||||
-rw-r--r-- | drivers/ata/ahci.h | 2 | ||||
-rw-r--r-- | drivers/ata/ahci_platform.c | 1 | ||||
-rw-r--r-- | drivers/ata/ahci_qoriq.c | 279 | ||||
-rw-r--r-- | drivers/ata/libahci.c | 30 | ||||
-rw-r--r-- | drivers/ata/libata-scsi.c | 59 | ||||
-rw-r--r-- | drivers/ata/pata_it821x.c | 6 | ||||
-rw-r--r-- | drivers/ata/pata_macio.c | 1 | ||||
-rw-r--r-- | drivers/ata/pata_pxa.c | 171 | ||||
-rw-r--r-- | drivers/ata/pata_samsung_cf.c | 2 | ||||
-rw-r--r-- | include/linux/libata.h | 1 |
15 files changed, 433 insertions, 164 deletions
diff --git a/Documentation/devicetree/bindings/ata/ahci-fsl-qoriq.txt b/Documentation/devicetree/bindings/ata/ahci-fsl-qoriq.txt new file mode 100644 index 000000000000..032a7606b862 --- /dev/null +++ b/Documentation/devicetree/bindings/ata/ahci-fsl-qoriq.txt | |||
@@ -0,0 +1,21 @@ | |||
1 | Binding for Freescale QorIQ AHCI SATA Controller | ||
2 | |||
3 | Required properties: | ||
4 | - reg: Physical base address and size of the controller's register area. | ||
5 | - compatible: Compatibility string. Must be 'fsl,<chip>-ahci', where | ||
6 | chip could be ls1021a, ls2080a, ls1043a etc. | ||
7 | - clocks: Input clock specifier. Refer to common clock bindings. | ||
8 | - interrupts: Interrupt specifier. Refer to interrupt binding. | ||
9 | |||
10 | Optional properties: | ||
11 | - dma-coherent: Enable AHCI coherent DMA operation. | ||
12 | - reg-names: register area names when there are more than 1 register area. | ||
13 | |||
14 | Examples: | ||
15 | sata@3200000 { | ||
16 | compatible = "fsl,ls1021a-ahci"; | ||
17 | reg = <0x0 0x3200000 0x0 0x10000>; | ||
18 | interrupts = <GIC_SPI 101 IRQ_TYPE_LEVEL_HIGH>; | ||
19 | clocks = <&platform_clk 1>; | ||
20 | dma-coherent; | ||
21 | }; | ||
diff --git a/Documentation/devicetree/bindings/ata/ahci-platform.txt b/Documentation/devicetree/bindings/ata/ahci-platform.txt index a2321819e7f5..c2340eeeb97f 100644 --- a/Documentation/devicetree/bindings/ata/ahci-platform.txt +++ b/Documentation/devicetree/bindings/ata/ahci-platform.txt | |||
@@ -16,8 +16,6 @@ Required properties: | |||
16 | - "snps,dwc-ahci" | 16 | - "snps,dwc-ahci" |
17 | - "snps,exynos5440-ahci" | 17 | - "snps,exynos5440-ahci" |
18 | - "snps,spear-ahci" | 18 | - "snps,spear-ahci" |
19 | - "fsl,qoriq-ahci" : for qoriq series socs which include ls1021, ls2085, etc. | ||
20 | - "fsl,<chip>-ahci" : chip could be ls1021, ls2085 etc. | ||
21 | - "generic-ahci" | 19 | - "generic-ahci" |
22 | - interrupts : <interrupt mapping for SATA IRQ> | 20 | - interrupts : <interrupt mapping for SATA IRQ> |
23 | - reg : <registers mapping> | 21 | - reg : <registers mapping> |
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig index 15e40ee62a94..6aaa3f81755b 100644 --- a/drivers/ata/Kconfig +++ b/drivers/ata/Kconfig | |||
@@ -175,6 +175,15 @@ config AHCI_XGENE | |||
175 | help | 175 | help |
176 | This option enables support for APM X-Gene SoC SATA host controller. | 176 | This option enables support for APM X-Gene SoC SATA host controller. |
177 | 177 | ||
178 | config AHCI_QORIQ | ||
179 | tristate "Freescale QorIQ AHCI SATA support" | ||
180 | depends on OF | ||
181 | help | ||
182 | This option enables support for the Freescale QorIQ AHCI SoC's | ||
183 | onboard AHCI SATA. | ||
184 | |||
185 | If unsure, say N. | ||
186 | |||
178 | config SATA_FSL | 187 | config SATA_FSL |
179 | tristate "Freescale 3.0Gbps SATA support" | 188 | tristate "Freescale 3.0Gbps SATA support" |
180 | depends on FSL_SOC | 189 | depends on FSL_SOC |
diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile index af70919f7dde..af45effac18c 100644 --- a/drivers/ata/Makefile +++ b/drivers/ata/Makefile | |||
@@ -19,6 +19,7 @@ obj-$(CONFIG_AHCI_SUNXI) += ahci_sunxi.o libahci.o libahci_platform.o | |||
19 | obj-$(CONFIG_AHCI_ST) += ahci_st.o libahci.o libahci_platform.o | 19 | obj-$(CONFIG_AHCI_ST) += ahci_st.o libahci.o libahci_platform.o |
20 | obj-$(CONFIG_AHCI_TEGRA) += ahci_tegra.o libahci.o libahci_platform.o | 20 | obj-$(CONFIG_AHCI_TEGRA) += ahci_tegra.o libahci.o libahci_platform.o |
21 | obj-$(CONFIG_AHCI_XGENE) += ahci_xgene.o libahci.o libahci_platform.o | 21 | obj-$(CONFIG_AHCI_XGENE) += ahci_xgene.o libahci.o libahci_platform.o |
22 | obj-$(CONFIG_AHCI_QORIQ) += ahci_qoriq.o libahci.o libahci_platform.o | ||
22 | 23 | ||
23 | # SFF w/ custom DMA | 24 | # SFF w/ custom DMA |
24 | obj-$(CONFIG_PDC_ADMA) += pdc_adma.o | 25 | obj-$(CONFIG_PDC_ADMA) += pdc_adma.o |
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index a46660204e3a..ff02bb4218fc 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c | |||
@@ -314,6 +314,16 @@ static const struct pci_device_id ahci_pci_tbl[] = { | |||
314 | { PCI_VDEVICE(INTEL, 0x1f37), board_ahci_avn }, /* Avoton RAID */ | 314 | { PCI_VDEVICE(INTEL, 0x1f37), board_ahci_avn }, /* Avoton RAID */ |
315 | { PCI_VDEVICE(INTEL, 0x1f3e), board_ahci_avn }, /* Avoton RAID */ | 315 | { PCI_VDEVICE(INTEL, 0x1f3e), board_ahci_avn }, /* Avoton RAID */ |
316 | { PCI_VDEVICE(INTEL, 0x1f3f), board_ahci_avn }, /* Avoton RAID */ | 316 | { PCI_VDEVICE(INTEL, 0x1f3f), board_ahci_avn }, /* Avoton RAID */ |
317 | { PCI_VDEVICE(INTEL, 0xa182), board_ahci }, /* Lewisburg AHCI*/ | ||
318 | { PCI_VDEVICE(INTEL, 0xa202), board_ahci }, /* Lewisburg AHCI*/ | ||
319 | { PCI_VDEVICE(INTEL, 0xa184), board_ahci }, /* Lewisburg RAID*/ | ||
320 | { PCI_VDEVICE(INTEL, 0xa204), board_ahci }, /* Lewisburg RAID*/ | ||
321 | { PCI_VDEVICE(INTEL, 0xa186), board_ahci }, /* Lewisburg RAID*/ | ||
322 | { PCI_VDEVICE(INTEL, 0xa206), board_ahci }, /* Lewisburg RAID*/ | ||
323 | { PCI_VDEVICE(INTEL, 0x2822), board_ahci }, /* Lewisburg RAID*/ | ||
324 | { PCI_VDEVICE(INTEL, 0x2826), board_ahci }, /* Lewisburg RAID*/ | ||
325 | { PCI_VDEVICE(INTEL, 0xa18e), board_ahci }, /* Lewisburg RAID*/ | ||
326 | { PCI_VDEVICE(INTEL, 0xa20e), board_ahci }, /* Lewisburg RAID*/ | ||
317 | { PCI_VDEVICE(INTEL, 0x2823), board_ahci }, /* Wellsburg RAID */ | 327 | { PCI_VDEVICE(INTEL, 0x2823), board_ahci }, /* Wellsburg RAID */ |
318 | { PCI_VDEVICE(INTEL, 0x2827), board_ahci }, /* Wellsburg RAID */ | 328 | { PCI_VDEVICE(INTEL, 0x2827), board_ahci }, /* Wellsburg RAID */ |
319 | { PCI_VDEVICE(INTEL, 0x8d02), board_ahci }, /* Wellsburg AHCI */ | 329 | { PCI_VDEVICE(INTEL, 0x8d02), board_ahci }, /* Wellsburg AHCI */ |
@@ -489,6 +499,8 @@ static const struct pci_device_id ahci_pci_tbl[] = { | |||
489 | .driver_data = board_ahci_yes_fbs }, /* 88se9172 on some Gigabyte */ | 499 | .driver_data = board_ahci_yes_fbs }, /* 88se9172 on some Gigabyte */ |
490 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x91a0), | 500 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x91a0), |
491 | .driver_data = board_ahci_yes_fbs }, | 501 | .driver_data = board_ahci_yes_fbs }, |
502 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x91a2), /* 88se91a2 */ | ||
503 | .driver_data = board_ahci_yes_fbs }, | ||
492 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x91a3), | 504 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x91a3), |
493 | .driver_data = board_ahci_yes_fbs }, | 505 | .driver_data = board_ahci_yes_fbs }, |
494 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x9230), | 506 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x9230), |
diff --git a/drivers/ata/ahci.h b/drivers/ata/ahci.h index 5b8e8a0fab48..45586c1dbbdc 100644 --- a/drivers/ata/ahci.h +++ b/drivers/ata/ahci.h | |||
@@ -181,6 +181,8 @@ enum { | |||
181 | PORT_CMD_ALPE = (1 << 26), /* Aggressive Link PM enable */ | 181 | PORT_CMD_ALPE = (1 << 26), /* Aggressive Link PM enable */ |
182 | PORT_CMD_ATAPI = (1 << 24), /* Device is ATAPI */ | 182 | PORT_CMD_ATAPI = (1 << 24), /* Device is ATAPI */ |
183 | PORT_CMD_FBSCP = (1 << 22), /* FBS Capable Port */ | 183 | PORT_CMD_FBSCP = (1 << 22), /* FBS Capable Port */ |
184 | PORT_CMD_ESP = (1 << 21), /* External Sata Port */ | ||
185 | PORT_CMD_HPCP = (1 << 18), /* HotPlug Capable Port */ | ||
184 | PORT_CMD_PMP = (1 << 17), /* PMP attached */ | 186 | PORT_CMD_PMP = (1 << 17), /* PMP attached */ |
185 | PORT_CMD_LIST_ON = (1 << 15), /* cmd list DMA engine running */ | 187 | PORT_CMD_LIST_ON = (1 << 15), /* cmd list DMA engine running */ |
186 | PORT_CMD_FIS_ON = (1 << 14), /* FIS DMA engine running */ | 188 | PORT_CMD_FIS_ON = (1 << 14), /* FIS DMA engine running */ |
diff --git a/drivers/ata/ahci_platform.c b/drivers/ata/ahci_platform.c index 1befb114c384..04975b851c23 100644 --- a/drivers/ata/ahci_platform.c +++ b/drivers/ata/ahci_platform.c | |||
@@ -76,7 +76,6 @@ static const struct of_device_id ahci_of_match[] = { | |||
76 | { .compatible = "ibm,476gtr-ahci", }, | 76 | { .compatible = "ibm,476gtr-ahci", }, |
77 | { .compatible = "snps,dwc-ahci", }, | 77 | { .compatible = "snps,dwc-ahci", }, |
78 | { .compatible = "hisilicon,hisi-ahci", }, | 78 | { .compatible = "hisilicon,hisi-ahci", }, |
79 | { .compatible = "fsl,qoriq-ahci", }, | ||
80 | {}, | 79 | {}, |
81 | }; | 80 | }; |
82 | MODULE_DEVICE_TABLE(of, ahci_of_match); | 81 | MODULE_DEVICE_TABLE(of, ahci_of_match); |
diff --git a/drivers/ata/ahci_qoriq.c b/drivers/ata/ahci_qoriq.c new file mode 100644 index 000000000000..d0f9de96e4ea --- /dev/null +++ b/drivers/ata/ahci_qoriq.c | |||
@@ -0,0 +1,279 @@ | |||
1 | /* | ||
2 | * Freescale QorIQ AHCI SATA platform driver | ||
3 | * | ||
4 | * Copyright 2015 Freescale, Inc. | ||
5 | * Tang Yuantian <Yuantian.Tang@freescale.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2, or (at your option) | ||
10 | * any later version. | ||
11 | */ | ||
12 | |||
13 | #include <linux/kernel.h> | ||
14 | #include <linux/module.h> | ||
15 | #include <linux/pm.h> | ||
16 | #include <linux/ahci_platform.h> | ||
17 | #include <linux/device.h> | ||
18 | #include <linux/of_address.h> | ||
19 | #include <linux/of.h> | ||
20 | #include <linux/of_device.h> | ||
21 | #include <linux/platform_device.h> | ||
22 | #include <linux/libata.h> | ||
23 | #include "ahci.h" | ||
24 | |||
25 | #define DRV_NAME "ahci-qoriq" | ||
26 | |||
27 | /* port register definition */ | ||
28 | #define PORT_PHY1 0xA8 | ||
29 | #define PORT_PHY2 0xAC | ||
30 | #define PORT_PHY3 0xB0 | ||
31 | #define PORT_PHY4 0xB4 | ||
32 | #define PORT_PHY5 0xB8 | ||
33 | #define PORT_TRANS 0xC8 | ||
34 | |||
35 | /* port register default value */ | ||
36 | #define AHCI_PORT_PHY_1_CFG 0xa003fffe | ||
37 | #define AHCI_PORT_PHY_2_CFG 0x28183411 | ||
38 | #define AHCI_PORT_PHY_3_CFG 0x0e081004 | ||
39 | #define AHCI_PORT_PHY_4_CFG 0x00480811 | ||
40 | #define AHCI_PORT_PHY_5_CFG 0x192c96a4 | ||
41 | #define AHCI_PORT_TRANS_CFG 0x08000025 | ||
42 | |||
43 | #define SATA_ECC_DISABLE 0x00020000 | ||
44 | |||
45 | enum ahci_qoriq_type { | ||
46 | AHCI_LS1021A, | ||
47 | AHCI_LS1043A, | ||
48 | AHCI_LS2080A, | ||
49 | }; | ||
50 | |||
51 | struct ahci_qoriq_priv { | ||
52 | struct ccsr_ahci *reg_base; | ||
53 | enum ahci_qoriq_type type; | ||
54 | void __iomem *ecc_addr; | ||
55 | }; | ||
56 | |||
57 | static const struct of_device_id ahci_qoriq_of_match[] = { | ||
58 | { .compatible = "fsl,ls1021a-ahci", .data = (void *)AHCI_LS1021A}, | ||
59 | { .compatible = "fsl,ls1043a-ahci", .data = (void *)AHCI_LS1043A}, | ||
60 | { .compatible = "fsl,ls2080a-ahci", .data = (void *)AHCI_LS2080A}, | ||
61 | {}, | ||
62 | }; | ||
63 | MODULE_DEVICE_TABLE(of, ahci_qoriq_of_match); | ||
64 | |||
65 | static int ahci_qoriq_hardreset(struct ata_link *link, unsigned int *class, | ||
66 | unsigned long deadline) | ||
67 | { | ||
68 | const unsigned long *timing = sata_ehc_deb_timing(&link->eh_context); | ||
69 | void __iomem *port_mmio = ahci_port_base(link->ap); | ||
70 | u32 px_cmd, px_is, px_val; | ||
71 | struct ata_port *ap = link->ap; | ||
72 | struct ahci_port_priv *pp = ap->private_data; | ||
73 | struct ahci_host_priv *hpriv = ap->host->private_data; | ||
74 | struct ahci_qoriq_priv *qoriq_priv = hpriv->plat_data; | ||
75 | u8 *d2h_fis = pp->rx_fis + RX_FIS_D2H_REG; | ||
76 | struct ata_taskfile tf; | ||
77 | bool online; | ||
78 | int rc; | ||
79 | bool ls1021a_workaround = (qoriq_priv->type == AHCI_LS1021A); | ||
80 | |||
81 | DPRINTK("ENTER\n"); | ||
82 | |||
83 | ahci_stop_engine(ap); | ||
84 | |||
85 | /* | ||
86 | * There is a errata on ls1021a Rev1.0 and Rev2.0 which is: | ||
87 | * A-009042: The device detection initialization sequence | ||
88 | * mistakenly resets some registers. | ||
89 | * | ||
90 | * Workaround for this is: | ||
91 | * The software should read and store PxCMD and PxIS values | ||
92 | * before issuing the device detection initialization sequence. | ||
93 | * After the sequence is complete, software should restore the | ||
94 | * PxCMD and PxIS with the stored values. | ||
95 | */ | ||
96 | if (ls1021a_workaround) { | ||
97 | px_cmd = readl(port_mmio + PORT_CMD); | ||
98 | px_is = readl(port_mmio + PORT_IRQ_STAT); | ||
99 | } | ||
100 | |||
101 | /* clear D2H reception area to properly wait for D2H FIS */ | ||
102 | ata_tf_init(link->device, &tf); | ||
103 | tf.command = ATA_BUSY; | ||
104 | ata_tf_to_fis(&tf, 0, 0, d2h_fis); | ||
105 | |||
106 | rc = sata_link_hardreset(link, timing, deadline, &online, | ||
107 | ahci_check_ready); | ||
108 | |||
109 | /* restore the PxCMD and PxIS on ls1021 */ | ||
110 | if (ls1021a_workaround) { | ||
111 | px_val = readl(port_mmio + PORT_CMD); | ||
112 | if (px_val != px_cmd) | ||
113 | writel(px_cmd, port_mmio + PORT_CMD); | ||
114 | |||
115 | px_val = readl(port_mmio + PORT_IRQ_STAT); | ||
116 | if (px_val != px_is) | ||
117 | writel(px_is, port_mmio + PORT_IRQ_STAT); | ||
118 | } | ||
119 | |||
120 | hpriv->start_engine(ap); | ||
121 | |||
122 | if (online) | ||
123 | *class = ahci_dev_classify(ap); | ||
124 | |||
125 | DPRINTK("EXIT, rc=%d, class=%u\n", rc, *class); | ||
126 | return rc; | ||
127 | } | ||
128 | |||
129 | static struct ata_port_operations ahci_qoriq_ops = { | ||
130 | .inherits = &ahci_ops, | ||
131 | .hardreset = ahci_qoriq_hardreset, | ||
132 | }; | ||
133 | |||
134 | static struct ata_port_info ahci_qoriq_port_info = { | ||
135 | .flags = AHCI_FLAG_COMMON | ATA_FLAG_NCQ, | ||
136 | .pio_mask = ATA_PIO4, | ||
137 | .udma_mask = ATA_UDMA6, | ||
138 | .port_ops = &ahci_qoriq_ops, | ||
139 | }; | ||
140 | |||
141 | static struct scsi_host_template ahci_qoriq_sht = { | ||
142 | AHCI_SHT(DRV_NAME), | ||
143 | }; | ||
144 | |||
145 | static int ahci_qoriq_phy_init(struct ahci_host_priv *hpriv) | ||
146 | { | ||
147 | struct ahci_qoriq_priv *qpriv = hpriv->plat_data; | ||
148 | void __iomem *reg_base = hpriv->mmio; | ||
149 | |||
150 | switch (qpriv->type) { | ||
151 | case AHCI_LS1021A: | ||
152 | writel(SATA_ECC_DISABLE, qpriv->ecc_addr); | ||
153 | writel(AHCI_PORT_PHY_1_CFG, reg_base + PORT_PHY1); | ||
154 | writel(AHCI_PORT_PHY_2_CFG, reg_base + PORT_PHY2); | ||
155 | writel(AHCI_PORT_PHY_3_CFG, reg_base + PORT_PHY3); | ||
156 | writel(AHCI_PORT_PHY_4_CFG, reg_base + PORT_PHY4); | ||
157 | writel(AHCI_PORT_PHY_5_CFG, reg_base + PORT_PHY5); | ||
158 | writel(AHCI_PORT_TRANS_CFG, reg_base + PORT_TRANS); | ||
159 | break; | ||
160 | |||
161 | case AHCI_LS1043A: | ||
162 | case AHCI_LS2080A: | ||
163 | writel(AHCI_PORT_PHY_1_CFG, reg_base + PORT_PHY1); | ||
164 | break; | ||
165 | } | ||
166 | |||
167 | return 0; | ||
168 | } | ||
169 | |||
170 | static int ahci_qoriq_probe(struct platform_device *pdev) | ||
171 | { | ||
172 | struct device_node *np = pdev->dev.of_node; | ||
173 | struct device *dev = &pdev->dev; | ||
174 | struct ahci_host_priv *hpriv; | ||
175 | struct ahci_qoriq_priv *qoriq_priv; | ||
176 | const struct of_device_id *of_id; | ||
177 | struct resource *res; | ||
178 | int rc; | ||
179 | |||
180 | hpriv = ahci_platform_get_resources(pdev); | ||
181 | if (IS_ERR(hpriv)) | ||
182 | return PTR_ERR(hpriv); | ||
183 | |||
184 | of_id = of_match_node(ahci_qoriq_of_match, np); | ||
185 | if (!of_id) | ||
186 | return -ENODEV; | ||
187 | |||
188 | qoriq_priv = devm_kzalloc(dev, sizeof(*qoriq_priv), GFP_KERNEL); | ||
189 | if (!qoriq_priv) | ||
190 | return -ENOMEM; | ||
191 | |||
192 | qoriq_priv->type = (enum ahci_qoriq_type)of_id->data; | ||
193 | |||
194 | if (qoriq_priv->type == AHCI_LS1021A) { | ||
195 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, | ||
196 | "sata-ecc"); | ||
197 | qoriq_priv->ecc_addr = devm_ioremap_resource(dev, res); | ||
198 | if (IS_ERR(qoriq_priv->ecc_addr)) | ||
199 | return PTR_ERR(qoriq_priv->ecc_addr); | ||
200 | } | ||
201 | |||
202 | rc = ahci_platform_enable_resources(hpriv); | ||
203 | if (rc) | ||
204 | return rc; | ||
205 | |||
206 | hpriv->plat_data = qoriq_priv; | ||
207 | rc = ahci_qoriq_phy_init(hpriv); | ||
208 | if (rc) | ||
209 | goto disable_resources; | ||
210 | |||
211 | /* Workaround for ls2080a */ | ||
212 | if (qoriq_priv->type == AHCI_LS2080A) { | ||
213 | hpriv->flags |= AHCI_HFLAG_NO_NCQ; | ||
214 | ahci_qoriq_port_info.flags &= ~ATA_FLAG_NCQ; | ||
215 | } | ||
216 | |||
217 | rc = ahci_platform_init_host(pdev, hpriv, &ahci_qoriq_port_info, | ||
218 | &ahci_qoriq_sht); | ||
219 | if (rc) | ||
220 | goto disable_resources; | ||
221 | |||
222 | return 0; | ||
223 | |||
224 | disable_resources: | ||
225 | ahci_platform_disable_resources(hpriv); | ||
226 | |||
227 | return rc; | ||
228 | } | ||
229 | |||
230 | #ifdef CONFIG_PM_SLEEP | ||
231 | static int ahci_qoriq_resume(struct device *dev) | ||
232 | { | ||
233 | struct ata_host *host = dev_get_drvdata(dev); | ||
234 | struct ahci_host_priv *hpriv = host->private_data; | ||
235 | int rc; | ||
236 | |||
237 | rc = ahci_platform_enable_resources(hpriv); | ||
238 | if (rc) | ||
239 | return rc; | ||
240 | |||
241 | rc = ahci_qoriq_phy_init(hpriv); | ||
242 | if (rc) | ||
243 | goto disable_resources; | ||
244 | |||
245 | rc = ahci_platform_resume_host(dev); | ||
246 | if (rc) | ||
247 | goto disable_resources; | ||
248 | |||
249 | /* We resumed so update PM runtime state */ | ||
250 | pm_runtime_disable(dev); | ||
251 | pm_runtime_set_active(dev); | ||
252 | pm_runtime_enable(dev); | ||
253 | |||
254 | return 0; | ||
255 | |||
256 | disable_resources: | ||
257 | ahci_platform_disable_resources(hpriv); | ||
258 | |||
259 | return rc; | ||
260 | } | ||
261 | #endif | ||
262 | |||
263 | static SIMPLE_DEV_PM_OPS(ahci_qoriq_pm_ops, ahci_platform_suspend, | ||
264 | ahci_qoriq_resume); | ||
265 | |||
266 | static struct platform_driver ahci_qoriq_driver = { | ||
267 | .probe = ahci_qoriq_probe, | ||
268 | .remove = ata_platform_remove_one, | ||
269 | .driver = { | ||
270 | .name = DRV_NAME, | ||
271 | .of_match_table = ahci_qoriq_of_match, | ||
272 | .pm = &ahci_qoriq_pm_ops, | ||
273 | }, | ||
274 | }; | ||
275 | module_platform_driver(ahci_qoriq_driver); | ||
276 | |||
277 | MODULE_DESCRIPTION("Freescale QorIQ AHCI SATA platform driver"); | ||
278 | MODULE_AUTHOR("Tang Yuantian <Yuantian.Tang@freescale.com>"); | ||
279 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c index d256a66158be..096064cd6c52 100644 --- a/drivers/ata/libahci.c +++ b/drivers/ata/libahci.c | |||
@@ -1117,6 +1117,7 @@ static void ahci_port_init(struct device *dev, struct ata_port *ap, | |||
1117 | int port_no, void __iomem *mmio, | 1117 | int port_no, void __iomem *mmio, |
1118 | void __iomem *port_mmio) | 1118 | void __iomem *port_mmio) |
1119 | { | 1119 | { |
1120 | struct ahci_host_priv *hpriv = ap->host->private_data; | ||
1120 | const char *emsg = NULL; | 1121 | const char *emsg = NULL; |
1121 | int rc; | 1122 | int rc; |
1122 | u32 tmp; | 1123 | u32 tmp; |
@@ -1138,6 +1139,12 @@ static void ahci_port_init(struct device *dev, struct ata_port *ap, | |||
1138 | writel(tmp, port_mmio + PORT_IRQ_STAT); | 1139 | writel(tmp, port_mmio + PORT_IRQ_STAT); |
1139 | 1140 | ||
1140 | writel(1 << port_no, mmio + HOST_IRQ_STAT); | 1141 | writel(1 << port_no, mmio + HOST_IRQ_STAT); |
1142 | |||
1143 | /* mark esata ports */ | ||
1144 | tmp = readl(port_mmio + PORT_CMD); | ||
1145 | if ((tmp & PORT_CMD_HPCP) || | ||
1146 | ((tmp & PORT_CMD_ESP) && (hpriv->cap & HOST_CAP_SXS))) | ||
1147 | ap->pflags |= ATA_PFLAG_EXTERNAL; | ||
1141 | } | 1148 | } |
1142 | 1149 | ||
1143 | void ahci_init_controller(struct ata_host *host) | 1150 | void ahci_init_controller(struct ata_host *host) |
@@ -2486,28 +2493,13 @@ static int ahci_host_activate_multi_irqs(struct ata_host *host, int irq, | |||
2486 | 2493 | ||
2487 | rc = devm_request_threaded_irq(host->dev, irq + i, | 2494 | rc = devm_request_threaded_irq(host->dev, irq + i, |
2488 | ahci_multi_irqs_intr, | 2495 | ahci_multi_irqs_intr, |
2489 | ahci_port_thread_fn, IRQF_SHARED, | 2496 | ahci_port_thread_fn, 0, |
2490 | pp->irq_desc, host->ports[i]); | 2497 | pp->irq_desc, host->ports[i]); |
2491 | if (rc) | 2498 | if (rc) |
2492 | goto out_free_irqs; | 2499 | return rc; |
2493 | } | ||
2494 | |||
2495 | for (i = 0; i < host->n_ports; i++) | ||
2496 | ata_port_desc(host->ports[i], "irq %d", irq + i); | 2500 | ata_port_desc(host->ports[i], "irq %d", irq + i); |
2497 | 2501 | } | |
2498 | rc = ata_host_register(host, sht); | 2502 | return ata_host_register(host, sht); |
2499 | if (rc) | ||
2500 | goto out_free_all_irqs; | ||
2501 | |||
2502 | return 0; | ||
2503 | |||
2504 | out_free_all_irqs: | ||
2505 | i = host->n_ports; | ||
2506 | out_free_irqs: | ||
2507 | for (i--; i >= 0; i--) | ||
2508 | devm_free_irq(host->dev, irq + i, host->ports[i]); | ||
2509 | |||
2510 | return rc; | ||
2511 | } | 2503 | } |
2512 | 2504 | ||
2513 | /** | 2505 | /** |
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 0d7f0da3a269..8b3a7861fa44 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c | |||
@@ -1757,6 +1757,15 @@ nothing_to_do: | |||
1757 | return 1; | 1757 | return 1; |
1758 | } | 1758 | } |
1759 | 1759 | ||
1760 | static void ata_qc_done(struct ata_queued_cmd *qc) | ||
1761 | { | ||
1762 | struct scsi_cmnd *cmd = qc->scsicmd; | ||
1763 | void (*done)(struct scsi_cmnd *) = qc->scsidone; | ||
1764 | |||
1765 | ata_qc_free(qc); | ||
1766 | done(cmd); | ||
1767 | } | ||
1768 | |||
1760 | static void ata_scsi_qc_complete(struct ata_queued_cmd *qc) | 1769 | static void ata_scsi_qc_complete(struct ata_queued_cmd *qc) |
1761 | { | 1770 | { |
1762 | struct ata_port *ap = qc->ap; | 1771 | struct ata_port *ap = qc->ap; |
@@ -1774,28 +1783,17 @@ static void ata_scsi_qc_complete(struct ata_queued_cmd *qc) | |||
1774 | * asc,ascq = ATA PASS-THROUGH INFORMATION AVAILABLE | 1783 | * asc,ascq = ATA PASS-THROUGH INFORMATION AVAILABLE |
1775 | */ | 1784 | */ |
1776 | if (((cdb[0] == ATA_16) || (cdb[0] == ATA_12)) && | 1785 | if (((cdb[0] == ATA_16) || (cdb[0] == ATA_12)) && |
1777 | ((cdb[2] & 0x20) || need_sense)) { | 1786 | ((cdb[2] & 0x20) || need_sense)) |
1778 | ata_gen_passthru_sense(qc); | 1787 | ata_gen_passthru_sense(qc); |
1779 | } else { | 1788 | else if (need_sense) |
1780 | if (!need_sense) { | 1789 | ata_gen_ata_sense(qc); |
1781 | cmd->result = SAM_STAT_GOOD; | 1790 | else |
1782 | } else { | 1791 | cmd->result = SAM_STAT_GOOD; |
1783 | /* TODO: decide which descriptor format to use | ||
1784 | * for 48b LBA devices and call that here | ||
1785 | * instead of the fixed desc, which is only | ||
1786 | * good for smaller LBA (and maybe CHS?) | ||
1787 | * devices. | ||
1788 | */ | ||
1789 | ata_gen_ata_sense(qc); | ||
1790 | } | ||
1791 | } | ||
1792 | 1792 | ||
1793 | if (need_sense && !ap->ops->error_handler) | 1793 | if (need_sense && !ap->ops->error_handler) |
1794 | ata_dump_status(ap->print_id, &qc->result_tf); | 1794 | ata_dump_status(ap->print_id, &qc->result_tf); |
1795 | 1795 | ||
1796 | qc->scsidone(cmd); | 1796 | ata_qc_done(qc); |
1797 | |||
1798 | ata_qc_free(qc); | ||
1799 | } | 1797 | } |
1800 | 1798 | ||
1801 | /** | 1799 | /** |
@@ -2015,8 +2013,11 @@ static unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf) | |||
2015 | 2013 | ||
2016 | VPRINTK("ENTER\n"); | 2014 | VPRINTK("ENTER\n"); |
2017 | 2015 | ||
2018 | /* set scsi removable (RMB) bit per ata bit */ | 2016 | /* set scsi removable (RMB) bit per ata bit, or if the |
2019 | if (ata_id_removable(args->id)) | 2017 | * AHCI port says it's external (Hotplug-capable, eSATA). |
2018 | */ | ||
2019 | if (ata_id_removable(args->id) || | ||
2020 | (args->dev->link->ap->pflags & ATA_PFLAG_EXTERNAL)) | ||
2020 | hdr[1] |= (1 << 7); | 2021 | hdr[1] |= (1 << 7); |
2021 | 2022 | ||
2022 | if (args->dev->class == ATA_DEV_ZAC) { | 2023 | if (args->dev->class == ATA_DEV_ZAC) { |
@@ -2594,8 +2595,7 @@ static void atapi_sense_complete(struct ata_queued_cmd *qc) | |||
2594 | ata_gen_passthru_sense(qc); | 2595 | ata_gen_passthru_sense(qc); |
2595 | } | 2596 | } |
2596 | 2597 | ||
2597 | qc->scsidone(qc->scsicmd); | 2598 | ata_qc_done(qc); |
2598 | ata_qc_free(qc); | ||
2599 | } | 2599 | } |
2600 | 2600 | ||
2601 | /* is it pointless to prefer PIO for "safety reasons"? */ | 2601 | /* is it pointless to prefer PIO for "safety reasons"? */ |
@@ -2690,8 +2690,7 @@ static void atapi_qc_complete(struct ata_queued_cmd *qc) | |||
2690 | qc->dev->sdev->locked = 0; | 2690 | qc->dev->sdev->locked = 0; |
2691 | 2691 | ||
2692 | qc->scsicmd->result = SAM_STAT_CHECK_CONDITION; | 2692 | qc->scsicmd->result = SAM_STAT_CHECK_CONDITION; |
2693 | qc->scsidone(cmd); | 2693 | ata_qc_done(qc); |
2694 | ata_qc_free(qc); | ||
2695 | return; | 2694 | return; |
2696 | } | 2695 | } |
2697 | 2696 | ||
@@ -2735,8 +2734,7 @@ static void atapi_qc_complete(struct ata_queued_cmd *qc) | |||
2735 | cmd->result = SAM_STAT_GOOD; | 2734 | cmd->result = SAM_STAT_GOOD; |
2736 | } | 2735 | } |
2737 | 2736 | ||
2738 | qc->scsidone(cmd); | 2737 | ata_qc_done(qc); |
2739 | ata_qc_free(qc); | ||
2740 | } | 2738 | } |
2741 | /** | 2739 | /** |
2742 | * atapi_xlat - Initialize PACKET taskfile | 2740 | * atapi_xlat - Initialize PACKET taskfile |
@@ -2914,12 +2912,14 @@ ata_scsi_map_proto(u8 byte1) | |||
2914 | case 5: /* PIO Data-out */ | 2912 | case 5: /* PIO Data-out */ |
2915 | return ATA_PROT_PIO; | 2913 | return ATA_PROT_PIO; |
2916 | 2914 | ||
2915 | case 12: /* FPDMA */ | ||
2916 | return ATA_PROT_NCQ; | ||
2917 | |||
2917 | case 0: /* Hard Reset */ | 2918 | case 0: /* Hard Reset */ |
2918 | case 1: /* SRST */ | 2919 | case 1: /* SRST */ |
2919 | case 8: /* Device Diagnostic */ | 2920 | case 8: /* Device Diagnostic */ |
2920 | case 9: /* Device Reset */ | 2921 | case 9: /* Device Reset */ |
2921 | case 7: /* DMA Queued */ | 2922 | case 7: /* DMA Queued */ |
2922 | case 12: /* FPDMA */ | ||
2923 | case 15: /* Return Response Info */ | 2923 | case 15: /* Return Response Info */ |
2924 | default: /* Reserved */ | 2924 | default: /* Reserved */ |
2925 | break; | 2925 | break; |
@@ -2947,6 +2947,9 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc) | |||
2947 | if ((tf->protocol = ata_scsi_map_proto(cdb[1])) == ATA_PROT_UNKNOWN) | 2947 | if ((tf->protocol = ata_scsi_map_proto(cdb[1])) == ATA_PROT_UNKNOWN) |
2948 | goto invalid_fld; | 2948 | goto invalid_fld; |
2949 | 2949 | ||
2950 | /* enable LBA */ | ||
2951 | tf->flags |= ATA_TFLAG_LBA; | ||
2952 | |||
2950 | /* | 2953 | /* |
2951 | * 12 and 16 byte CDBs use different offsets to | 2954 | * 12 and 16 byte CDBs use different offsets to |
2952 | * provide the various register values. | 2955 | * provide the various register values. |
@@ -2992,6 +2995,10 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc) | |||
2992 | tf->command = cdb[9]; | 2995 | tf->command = cdb[9]; |
2993 | } | 2996 | } |
2994 | 2997 | ||
2998 | /* For NCQ commands with FPDMA protocol, copy the tag value */ | ||
2999 | if (tf->protocol == ATA_PROT_NCQ) | ||
3000 | tf->nsect = qc->tag << 3; | ||
3001 | |||
2995 | /* enforce correct master/slave bit */ | 3002 | /* enforce correct master/slave bit */ |
2996 | tf->device = dev->devno ? | 3003 | tf->device = dev->devno ? |
2997 | tf->device | ATA_DEV1 : tf->device & ~ATA_DEV1; | 3004 | tf->device | ATA_DEV1 : tf->device & ~ATA_DEV1; |
diff --git a/drivers/ata/pata_it821x.c b/drivers/ata/pata_it821x.c index a5088ecb349f..7a21edf89e72 100644 --- a/drivers/ata/pata_it821x.c +++ b/drivers/ata/pata_it821x.c | |||
@@ -604,9 +604,9 @@ static void it821x_display_disk(int n, u8 *buf) | |||
604 | { | 604 | { |
605 | unsigned char id[41]; | 605 | unsigned char id[41]; |
606 | int mode = 0; | 606 | int mode = 0; |
607 | char *mtype = ""; | 607 | const char *mtype = ""; |
608 | char mbuf[8]; | 608 | char mbuf[8]; |
609 | char *cbl = "(40 wire cable)"; | 609 | const char *cbl = "(40 wire cable)"; |
610 | 610 | ||
611 | static const char *types[5] = { | 611 | static const char *types[5] = { |
612 | "RAID0", "RAID1", "RAID 0+1", "JBOD", "DISK" | 612 | "RAID0", "RAID1", "RAID 0+1", "JBOD", "DISK" |
@@ -903,7 +903,7 @@ static int it821x_init_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
903 | }; | 903 | }; |
904 | 904 | ||
905 | const struct ata_port_info *ppi[] = { NULL, NULL }; | 905 | const struct ata_port_info *ppi[] = { NULL, NULL }; |
906 | static char *mode[2] = { "pass through", "smart" }; | 906 | static const char *mode[2] = { "pass through", "smart" }; |
907 | int rc; | 907 | int rc; |
908 | 908 | ||
909 | rc = pcim_enable_device(pdev); | 909 | rc = pcim_enable_device(pdev); |
diff --git a/drivers/ata/pata_macio.c b/drivers/ata/pata_macio.c index b0028588ff1c..e3d4b059fcd1 100644 --- a/drivers/ata/pata_macio.c +++ b/drivers/ata/pata_macio.c | |||
@@ -1344,6 +1344,7 @@ static struct of_device_id pata_macio_match[] = | |||
1344 | }, | 1344 | }, |
1345 | {}, | 1345 | {}, |
1346 | }; | 1346 | }; |
1347 | MODULE_DEVICE_TABLE(of, pata_macio_match); | ||
1347 | 1348 | ||
1348 | static struct macio_driver pata_macio_driver = | 1349 | static struct macio_driver pata_macio_driver = |
1349 | { | 1350 | { |
diff --git a/drivers/ata/pata_pxa.c b/drivers/ata/pata_pxa.c index c36b3e6531d8..f6c46e9a4dc0 100644 --- a/drivers/ata/pata_pxa.c +++ b/drivers/ata/pata_pxa.c | |||
@@ -24,79 +24,36 @@ | |||
24 | #include <linux/ata.h> | 24 | #include <linux/ata.h> |
25 | #include <linux/libata.h> | 25 | #include <linux/libata.h> |
26 | #include <linux/platform_device.h> | 26 | #include <linux/platform_device.h> |
27 | #include <linux/dmaengine.h> | ||
28 | #include <linux/dma/pxa-dma.h> | ||
27 | #include <linux/gpio.h> | 29 | #include <linux/gpio.h> |
28 | #include <linux/slab.h> | 30 | #include <linux/slab.h> |
29 | #include <linux/completion.h> | 31 | #include <linux/completion.h> |
30 | 32 | ||
31 | #include <scsi/scsi_host.h> | 33 | #include <scsi/scsi_host.h> |
32 | 34 | ||
33 | #include <mach/pxa2xx-regs.h> | ||
34 | #include <linux/platform_data/ata-pxa.h> | 35 | #include <linux/platform_data/ata-pxa.h> |
35 | #include <mach/dma.h> | ||
36 | 36 | ||
37 | #define DRV_NAME "pata_pxa" | 37 | #define DRV_NAME "pata_pxa" |
38 | #define DRV_VERSION "0.1" | 38 | #define DRV_VERSION "0.1" |
39 | 39 | ||
40 | struct pata_pxa_data { | 40 | struct pata_pxa_data { |
41 | uint32_t dma_channel; | 41 | struct dma_chan *dma_chan; |
42 | struct pxa_dma_desc *dma_desc; | 42 | dma_cookie_t dma_cookie; |
43 | dma_addr_t dma_desc_addr; | ||
44 | uint32_t dma_desc_id; | ||
45 | |||
46 | /* DMA IO physical address */ | ||
47 | uint32_t dma_io_addr; | ||
48 | /* PXA DREQ<0:2> pin selector */ | ||
49 | uint32_t dma_dreq; | ||
50 | /* DMA DCSR register value */ | ||
51 | uint32_t dma_dcsr; | ||
52 | |||
53 | struct completion dma_done; | 43 | struct completion dma_done; |
54 | }; | 44 | }; |
55 | 45 | ||
56 | /* | 46 | /* |
57 | * Setup the DMA descriptors. The size is transfer capped at 4k per descriptor, | 47 | * DMA interrupt handler. |
58 | * if the transfer is longer, it is split into multiple chained descriptors. | ||
59 | */ | 48 | */ |
60 | static void pxa_load_dmac(struct scatterlist *sg, struct ata_queued_cmd *qc) | 49 | static void pxa_ata_dma_irq(void *d) |
61 | { | 50 | { |
62 | struct pata_pxa_data *pd = qc->ap->private_data; | 51 | struct pata_pxa_data *pd = d; |
63 | 52 | enum dma_status status; | |
64 | uint32_t cpu_len, seg_len; | ||
65 | dma_addr_t cpu_addr; | ||
66 | |||
67 | cpu_addr = sg_dma_address(sg); | ||
68 | cpu_len = sg_dma_len(sg); | ||
69 | |||
70 | do { | ||
71 | seg_len = (cpu_len > 0x1000) ? 0x1000 : cpu_len; | ||
72 | |||
73 | pd->dma_desc[pd->dma_desc_id].ddadr = pd->dma_desc_addr + | ||
74 | ((pd->dma_desc_id + 1) * sizeof(struct pxa_dma_desc)); | ||
75 | |||
76 | pd->dma_desc[pd->dma_desc_id].dcmd = DCMD_BURST32 | | ||
77 | DCMD_WIDTH2 | (DCMD_LENGTH & seg_len); | ||
78 | |||
79 | if (qc->tf.flags & ATA_TFLAG_WRITE) { | ||
80 | pd->dma_desc[pd->dma_desc_id].dsadr = cpu_addr; | ||
81 | pd->dma_desc[pd->dma_desc_id].dtadr = pd->dma_io_addr; | ||
82 | pd->dma_desc[pd->dma_desc_id].dcmd |= DCMD_INCSRCADDR | | ||
83 | DCMD_FLOWTRG; | ||
84 | } else { | ||
85 | pd->dma_desc[pd->dma_desc_id].dsadr = pd->dma_io_addr; | ||
86 | pd->dma_desc[pd->dma_desc_id].dtadr = cpu_addr; | ||
87 | pd->dma_desc[pd->dma_desc_id].dcmd |= DCMD_INCTRGADDR | | ||
88 | DCMD_FLOWSRC; | ||
89 | } | ||
90 | |||
91 | cpu_len -= seg_len; | ||
92 | cpu_addr += seg_len; | ||
93 | pd->dma_desc_id++; | ||
94 | 53 | ||
95 | } while (cpu_len); | 54 | status = dmaengine_tx_status(pd->dma_chan, pd->dma_cookie, NULL); |
96 | 55 | if (status == DMA_ERROR || status == DMA_COMPLETE) | |
97 | /* Should not happen */ | 56 | complete(&pd->dma_done); |
98 | if (seg_len & 0x1f) | ||
99 | DALGN |= (1 << pd->dma_dreq); | ||
100 | } | 57 | } |
101 | 58 | ||
102 | /* | 59 | /* |
@@ -105,28 +62,22 @@ static void pxa_load_dmac(struct scatterlist *sg, struct ata_queued_cmd *qc) | |||
105 | static void pxa_qc_prep(struct ata_queued_cmd *qc) | 62 | static void pxa_qc_prep(struct ata_queued_cmd *qc) |
106 | { | 63 | { |
107 | struct pata_pxa_data *pd = qc->ap->private_data; | 64 | struct pata_pxa_data *pd = qc->ap->private_data; |
108 | int si = 0; | 65 | struct dma_async_tx_descriptor *tx; |
109 | struct scatterlist *sg; | 66 | enum dma_transfer_direction dir; |
110 | 67 | ||
111 | if (!(qc->flags & ATA_QCFLAG_DMAMAP)) | 68 | if (!(qc->flags & ATA_QCFLAG_DMAMAP)) |
112 | return; | 69 | return; |
113 | 70 | ||
114 | pd->dma_desc_id = 0; | 71 | dir = (qc->dma_dir == DMA_TO_DEVICE ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM); |
115 | 72 | tx = dmaengine_prep_slave_sg(pd->dma_chan, qc->sg, qc->n_elem, dir, | |
116 | DCSR(pd->dma_channel) = 0; | 73 | DMA_PREP_INTERRUPT); |
117 | DALGN &= ~(1 << pd->dma_dreq); | 74 | if (!tx) { |
118 | 75 | ata_dev_err(qc->dev, "prep_slave_sg() failed\n"); | |
119 | for_each_sg(qc->sg, sg, qc->n_elem, si) | 76 | return; |
120 | pxa_load_dmac(sg, qc); | 77 | } |
121 | 78 | tx->callback = pxa_ata_dma_irq; | |
122 | pd->dma_desc[pd->dma_desc_id - 1].ddadr = DDADR_STOP; | 79 | tx->callback_param = pd; |
123 | 80 | pd->dma_cookie = dmaengine_submit(tx); | |
124 | /* Fire IRQ only at the end of last block */ | ||
125 | pd->dma_desc[pd->dma_desc_id - 1].dcmd |= DCMD_ENDIRQEN; | ||
126 | |||
127 | DDADR(pd->dma_channel) = pd->dma_desc_addr; | ||
128 | DRCMR(pd->dma_dreq) = DRCMR_MAPVLD | pd->dma_channel; | ||
129 | |||
130 | } | 81 | } |
131 | 82 | ||
132 | /* | 83 | /* |
@@ -145,7 +96,7 @@ static void pxa_bmdma_start(struct ata_queued_cmd *qc) | |||
145 | { | 96 | { |
146 | struct pata_pxa_data *pd = qc->ap->private_data; | 97 | struct pata_pxa_data *pd = qc->ap->private_data; |
147 | init_completion(&pd->dma_done); | 98 | init_completion(&pd->dma_done); |
148 | DCSR(pd->dma_channel) = DCSR_RUN; | 99 | dma_async_issue_pending(pd->dma_chan); |
149 | } | 100 | } |
150 | 101 | ||
151 | /* | 102 | /* |
@@ -154,12 +105,14 @@ static void pxa_bmdma_start(struct ata_queued_cmd *qc) | |||
154 | static void pxa_bmdma_stop(struct ata_queued_cmd *qc) | 105 | static void pxa_bmdma_stop(struct ata_queued_cmd *qc) |
155 | { | 106 | { |
156 | struct pata_pxa_data *pd = qc->ap->private_data; | 107 | struct pata_pxa_data *pd = qc->ap->private_data; |
108 | enum dma_status status; | ||
157 | 109 | ||
158 | if ((DCSR(pd->dma_channel) & DCSR_RUN) && | 110 | status = dmaengine_tx_status(pd->dma_chan, pd->dma_cookie, NULL); |
159 | wait_for_completion_timeout(&pd->dma_done, HZ)) | 111 | if (status != DMA_ERROR && status != DMA_COMPLETE && |
160 | dev_err(qc->ap->dev, "Timeout waiting for DMA completion!"); | 112 | wait_for_completion_timeout(&pd->dma_done, HZ)) |
113 | ata_dev_err(qc->dev, "Timeout waiting for DMA completion!"); | ||
161 | 114 | ||
162 | DCSR(pd->dma_channel) = 0; | 115 | dmaengine_terminate_all(pd->dma_chan); |
163 | } | 116 | } |
164 | 117 | ||
165 | /* | 118 | /* |
@@ -170,8 +123,11 @@ static unsigned char pxa_bmdma_status(struct ata_port *ap) | |||
170 | { | 123 | { |
171 | struct pata_pxa_data *pd = ap->private_data; | 124 | struct pata_pxa_data *pd = ap->private_data; |
172 | unsigned char ret = ATA_DMA_INTR; | 125 | unsigned char ret = ATA_DMA_INTR; |
126 | struct dma_tx_state state; | ||
127 | enum dma_status status; | ||
173 | 128 | ||
174 | if (pd->dma_dcsr & DCSR_BUSERR) | 129 | status = dmaengine_tx_status(pd->dma_chan, pd->dma_cookie, &state); |
130 | if (status != DMA_COMPLETE) | ||
175 | ret |= ATA_DMA_ERR; | 131 | ret |= ATA_DMA_ERR; |
176 | 132 | ||
177 | return ret; | 133 | return ret; |
@@ -213,21 +169,6 @@ static struct ata_port_operations pxa_ata_port_ops = { | |||
213 | .qc_prep = pxa_qc_prep, | 169 | .qc_prep = pxa_qc_prep, |
214 | }; | 170 | }; |
215 | 171 | ||
216 | /* | ||
217 | * DMA interrupt handler. | ||
218 | */ | ||
219 | static void pxa_ata_dma_irq(int dma, void *port) | ||
220 | { | ||
221 | struct ata_port *ap = port; | ||
222 | struct pata_pxa_data *pd = ap->private_data; | ||
223 | |||
224 | pd->dma_dcsr = DCSR(dma); | ||
225 | DCSR(dma) = pd->dma_dcsr; | ||
226 | |||
227 | if (pd->dma_dcsr & DCSR_STOPSTATE) | ||
228 | complete(&pd->dma_done); | ||
229 | } | ||
230 | |||
231 | static int pxa_ata_probe(struct platform_device *pdev) | 172 | static int pxa_ata_probe(struct platform_device *pdev) |
232 | { | 173 | { |
233 | struct ata_host *host; | 174 | struct ata_host *host; |
@@ -238,6 +179,9 @@ static int pxa_ata_probe(struct platform_device *pdev) | |||
238 | struct resource *dma_res; | 179 | struct resource *dma_res; |
239 | struct resource *irq_res; | 180 | struct resource *irq_res; |
240 | struct pata_pxa_pdata *pdata = dev_get_platdata(&pdev->dev); | 181 | struct pata_pxa_pdata *pdata = dev_get_platdata(&pdev->dev); |
182 | struct dma_slave_config config; | ||
183 | dma_cap_mask_t mask; | ||
184 | struct pxad_param param; | ||
241 | int ret = 0; | 185 | int ret = 0; |
242 | 186 | ||
243 | /* | 187 | /* |
@@ -333,29 +277,32 @@ static int pxa_ata_probe(struct platform_device *pdev) | |||
333 | return -ENOMEM; | 277 | return -ENOMEM; |
334 | 278 | ||
335 | ap->private_data = data; | 279 | ap->private_data = data; |
336 | data->dma_dreq = pdata->dma_dreq; | ||
337 | data->dma_io_addr = dma_res->start; | ||
338 | 280 | ||
339 | /* | 281 | dma_cap_zero(mask); |
340 | * Allocate space for the DMA descriptors | 282 | dma_cap_set(DMA_SLAVE, mask); |
341 | */ | 283 | param.prio = PXAD_PRIO_LOWEST; |
342 | data->dma_desc = dmam_alloc_coherent(&pdev->dev, PAGE_SIZE, | 284 | param.drcmr = pdata->dma_dreq; |
343 | &data->dma_desc_addr, GFP_KERNEL); | 285 | memset(&config, 0, sizeof(config)); |
344 | if (!data->dma_desc) | 286 | config.src_addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES; |
345 | return -EINVAL; | 287 | config.dst_addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES; |
288 | config.src_addr = dma_res->start; | ||
289 | config.dst_addr = dma_res->start; | ||
290 | config.src_maxburst = 32; | ||
291 | config.dst_maxburst = 32; | ||
346 | 292 | ||
347 | /* | 293 | /* |
348 | * Request the DMA channel | 294 | * Request the DMA channel |
349 | */ | 295 | */ |
350 | data->dma_channel = pxa_request_dma(DRV_NAME, DMA_PRIO_LOW, | 296 | data->dma_chan = |
351 | pxa_ata_dma_irq, ap); | 297 | dma_request_slave_channel_compat(mask, pxad_filter_fn, |
352 | if (data->dma_channel < 0) | 298 | ¶m, &pdev->dev, "data"); |
299 | if (!data->dma_chan) | ||
353 | return -EBUSY; | 300 | return -EBUSY; |
354 | 301 | ret = dmaengine_slave_config(data->dma_chan, &config); | |
355 | /* | 302 | if (ret < 0) { |
356 | * Stop and clear the DMA channel | 303 | dev_err(&pdev->dev, "dma configuration failed: %d\n", ret); |
357 | */ | 304 | return ret; |
358 | DCSR(data->dma_channel) = 0; | 305 | } |
359 | 306 | ||
360 | /* | 307 | /* |
361 | * Activate the ATA host | 308 | * Activate the ATA host |
@@ -363,7 +310,7 @@ static int pxa_ata_probe(struct platform_device *pdev) | |||
363 | ret = ata_host_activate(host, irq_res->start, ata_sff_interrupt, | 310 | ret = ata_host_activate(host, irq_res->start, ata_sff_interrupt, |
364 | pdata->irq_flags, &pxa_ata_sht); | 311 | pdata->irq_flags, &pxa_ata_sht); |
365 | if (ret) | 312 | if (ret) |
366 | pxa_free_dma(data->dma_channel); | 313 | dma_release_channel(data->dma_chan); |
367 | 314 | ||
368 | return ret; | 315 | return ret; |
369 | } | 316 | } |
@@ -373,7 +320,7 @@ static int pxa_ata_remove(struct platform_device *pdev) | |||
373 | struct ata_host *host = platform_get_drvdata(pdev); | 320 | struct ata_host *host = platform_get_drvdata(pdev); |
374 | struct pata_pxa_data *data = host->ports[0]->private_data; | 321 | struct pata_pxa_data *data = host->ports[0]->private_data; |
375 | 322 | ||
376 | pxa_free_dma(data->dma_channel); | 323 | dma_release_channel(data->dma_chan); |
377 | 324 | ||
378 | ata_host_detach(host); | 325 | ata_host_detach(host); |
379 | 326 | ||
diff --git a/drivers/ata/pata_samsung_cf.c b/drivers/ata/pata_samsung_cf.c index cbb5a471eb9d..f6facd686f94 100644 --- a/drivers/ata/pata_samsung_cf.c +++ b/drivers/ata/pata_samsung_cf.c | |||
@@ -70,7 +70,7 @@ struct s3c_ide_info { | |||
70 | struct clk *clk; | 70 | struct clk *clk; |
71 | void __iomem *ide_addr; | 71 | void __iomem *ide_addr; |
72 | void __iomem *sfr_addr; | 72 | void __iomem *sfr_addr; |
73 | unsigned int irq; | 73 | int irq; |
74 | enum s3c_cpu_type cpu_type; | 74 | enum s3c_cpu_type cpu_type; |
75 | unsigned int fifo_status_reg; | 75 | unsigned int fifo_status_reg; |
76 | }; | 76 | }; |
diff --git a/include/linux/libata.h b/include/linux/libata.h index c9cfbcdb8d14..83577f8fd15b 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h | |||
@@ -254,6 +254,7 @@ enum { | |||
254 | 254 | ||
255 | ATA_PFLAG_PIO32 = (1 << 20), /* 32bit PIO */ | 255 | ATA_PFLAG_PIO32 = (1 << 20), /* 32bit PIO */ |
256 | ATA_PFLAG_PIO32CHANGE = (1 << 21), /* 32bit PIO can be turned on/off */ | 256 | ATA_PFLAG_PIO32CHANGE = (1 << 21), /* 32bit PIO can be turned on/off */ |
257 | ATA_PFLAG_EXTERNAL = (1 << 22), /* eSATA/external port */ | ||
257 | 258 | ||
258 | /* struct ata_queued_cmd flags */ | 259 | /* struct ata_queued_cmd flags */ |
259 | ATA_QCFLAG_ACTIVE = (1 << 0), /* cmd not yet ack'd to scsi lyer */ | 260 | ATA_QCFLAG_ACTIVE = (1 << 0), /* cmd not yet ack'd to scsi lyer */ |