diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-02-09 22:40:42 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-02-09 22:40:42 -0500 |
commit | 3e8c04eb117445d67ae2b83e08bec4005129356a (patch) | |
tree | bef05c66adb15c581a5d08ac89103f4ff9867cd8 | |
parent | 44dbf058de9f46cf112518c99bb1352e8350ceb3 (diff) | |
parent | b12aa1f25e1da7e23fa44f646ac46e41366cfc6c (diff) |
Merge branch 'for-3.20' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata
Pull libata changes from Tejun Heo:
"Mostly driver-specific changes. Nothing too noteworthy.
This pull request contains three merges from for-3.19-fixes. The
first two are to pull ahci_xgene and sata_dwc_460ex fix commits which
are depended upon by later changes. The last one is to pull in a fix
patch which missed the v3.19-rc window"
* 'for-3.20' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata: (24 commits)
ahci_xgene: Fix the dma state machine lockup for the ATA_CMD_SMART PIO mode command.
ata: libahci: Use of_platform_device_create only if supported
sata_mv: Delete unnecessary checks before the function call "phy_power_off"
ata: Delete unnecessary checks before the function call "pci_dev_put"
ata: pata_platform: fix owner module reference mismatch for scsi host
ata: ahci_platform: fix owner module reference mismatch for scsi host
pata_pdc2027x: Use 64-bit timekeeping
ata: libahci: Fix devres cleanup on failure
ata: libahci: Allow using multiple regulators
Documentation: bindings: Add the regulator property to the sub-nodes AHCI bindings
ata: libahci: Clean-up the ahci_platform_en/disable_phys functions
sata_rcar: extend PM methods
sata_dwc_460ex: disable compilation on ARM and ARM64
ata: libata-core: Remove unused function
sata_dwc_460ex: convert to devm_kzalloc in ->probe()
sata_dwc_460ex: remove extra message
sata_dwc_460ex: use np local variable in ->probe()
sata_dwc_460ex: fix most of the sparse warnings
sata_dwc_460ex: enable COMPILE_TEST for the driver
sata_dwc_460ex: remove redundant dev_set_drvdata
...
27 files changed, 563 insertions, 230 deletions
diff --git a/Documentation/devicetree/bindings/ata/ahci-platform.txt b/Documentation/devicetree/bindings/ata/ahci-platform.txt index 4ab09f2202d4..c2340eeeb97f 100644 --- a/Documentation/devicetree/bindings/ata/ahci-platform.txt +++ b/Documentation/devicetree/bindings/ata/ahci-platform.txt | |||
@@ -37,9 +37,10 @@ Required properties when using sub-nodes: | |||
37 | 37 | ||
38 | 38 | ||
39 | Sub-nodes required properties: | 39 | Sub-nodes required properties: |
40 | - reg : the port number | 40 | - reg : the port number |
41 | - phys : reference to the SATA PHY node | 41 | And at least one of the following properties: |
42 | 42 | - phys : reference to the SATA PHY node | |
43 | - target-supply : regulator for SATA target power | ||
43 | 44 | ||
44 | Examples: | 45 | Examples: |
45 | sata@ffe08000 { | 46 | sata@ffe08000 { |
@@ -68,10 +69,12 @@ With sub-nodes: | |||
68 | sata0: sata-port@0 { | 69 | sata0: sata-port@0 { |
69 | reg = <0>; | 70 | reg = <0>; |
70 | phys = <&sata_phy 0>; | 71 | phys = <&sata_phy 0>; |
72 | target-supply = <®_sata0>; | ||
71 | }; | 73 | }; |
72 | 74 | ||
73 | sata1: sata-port@1 { | 75 | sata1: sata-port@1 { |
74 | reg = <1>; | 76 | reg = <1>; |
75 | phys = <&sata_phy 1>; | 77 | phys = <&sata_phy 1>; |
78 | target-supply = <®_sata1>;; | ||
76 | }; | 79 | }; |
77 | }; | 80 | }; |
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig index 5f601553b9b0..e7f338a3a3c2 100644 --- a/drivers/ata/Kconfig +++ b/drivers/ata/Kconfig | |||
@@ -269,7 +269,7 @@ config ATA_PIIX | |||
269 | 269 | ||
270 | config SATA_DWC | 270 | config SATA_DWC |
271 | tristate "DesignWare Cores SATA support" | 271 | tristate "DesignWare Cores SATA support" |
272 | depends on 460EX | 272 | depends on 460EX || (COMPILE_TEST && !(ARM || ARM64)) |
273 | help | 273 | help |
274 | This option enables support for the on-chip SATA controller of the | 274 | This option enables support for the on-chip SATA controller of the |
275 | AppliedMicro processor 460EX. | 275 | AppliedMicro processor 460EX. |
diff --git a/drivers/ata/ahci.h b/drivers/ata/ahci.h index 40f0e34f17af..71262e08648e 100644 --- a/drivers/ata/ahci.h +++ b/drivers/ata/ahci.h | |||
@@ -333,7 +333,7 @@ struct ahci_host_priv { | |||
333 | u32 em_msg_type; /* EM message type */ | 333 | u32 em_msg_type; /* EM message type */ |
334 | bool got_runtime_pm; /* Did we do pm_runtime_get? */ | 334 | bool got_runtime_pm; /* Did we do pm_runtime_get? */ |
335 | struct clk *clks[AHCI_MAX_CLKS]; /* Optional */ | 335 | struct clk *clks[AHCI_MAX_CLKS]; /* Optional */ |
336 | struct regulator *target_pwr; /* Optional */ | 336 | struct regulator **target_pwrs; /* Optional */ |
337 | /* | 337 | /* |
338 | * If platform uses PHYs. There is a 1:1 relation between the port number and | 338 | * If platform uses PHYs. There is a 1:1 relation between the port number and |
339 | * the PHY position in this array. | 339 | * the PHY position in this array. |
@@ -354,6 +354,10 @@ extern int ahci_ignore_sss; | |||
354 | extern struct device_attribute *ahci_shost_attrs[]; | 354 | extern struct device_attribute *ahci_shost_attrs[]; |
355 | extern struct device_attribute *ahci_sdev_attrs[]; | 355 | extern struct device_attribute *ahci_sdev_attrs[]; |
356 | 356 | ||
357 | /* | ||
358 | * This must be instantiated by the edge drivers. Read the comments | ||
359 | * for ATA_BASE_SHT | ||
360 | */ | ||
357 | #define AHCI_SHT(drv_name) \ | 361 | #define AHCI_SHT(drv_name) \ |
358 | ATA_NCQ_SHT(drv_name), \ | 362 | ATA_NCQ_SHT(drv_name), \ |
359 | .can_queue = AHCI_MAX_CMDS - 1, \ | 363 | .can_queue = AHCI_MAX_CMDS - 1, \ |
diff --git a/drivers/ata/ahci_da850.c b/drivers/ata/ahci_da850.c index ce8a7a6d6c7f..267a3d3e79f4 100644 --- a/drivers/ata/ahci_da850.c +++ b/drivers/ata/ahci_da850.c | |||
@@ -16,6 +16,8 @@ | |||
16 | #include <linux/ahci_platform.h> | 16 | #include <linux/ahci_platform.h> |
17 | #include "ahci.h" | 17 | #include "ahci.h" |
18 | 18 | ||
19 | #define DRV_NAME "ahci_da850" | ||
20 | |||
19 | /* SATA PHY Control Register offset from AHCI base */ | 21 | /* SATA PHY Control Register offset from AHCI base */ |
20 | #define SATA_P0PHYCR_REG 0x178 | 22 | #define SATA_P0PHYCR_REG 0x178 |
21 | 23 | ||
@@ -59,6 +61,10 @@ static const struct ata_port_info ahci_da850_port_info = { | |||
59 | .port_ops = &ahci_platform_ops, | 61 | .port_ops = &ahci_platform_ops, |
60 | }; | 62 | }; |
61 | 63 | ||
64 | static struct scsi_host_template ahci_platform_sht = { | ||
65 | AHCI_SHT(DRV_NAME), | ||
66 | }; | ||
67 | |||
62 | static int ahci_da850_probe(struct platform_device *pdev) | 68 | static int ahci_da850_probe(struct platform_device *pdev) |
63 | { | 69 | { |
64 | struct device *dev = &pdev->dev; | 70 | struct device *dev = &pdev->dev; |
@@ -85,7 +91,8 @@ static int ahci_da850_probe(struct platform_device *pdev) | |||
85 | 91 | ||
86 | da850_sata_init(dev, pwrdn_reg, hpriv->mmio); | 92 | da850_sata_init(dev, pwrdn_reg, hpriv->mmio); |
87 | 93 | ||
88 | rc = ahci_platform_init_host(pdev, hpriv, &ahci_da850_port_info); | 94 | rc = ahci_platform_init_host(pdev, hpriv, &ahci_da850_port_info, |
95 | &ahci_platform_sht); | ||
89 | if (rc) | 96 | if (rc) |
90 | goto disable_resources; | 97 | goto disable_resources; |
91 | 98 | ||
@@ -102,7 +109,7 @@ static struct platform_driver ahci_da850_driver = { | |||
102 | .probe = ahci_da850_probe, | 109 | .probe = ahci_da850_probe, |
103 | .remove = ata_platform_remove_one, | 110 | .remove = ata_platform_remove_one, |
104 | .driver = { | 111 | .driver = { |
105 | .name = "ahci_da850", | 112 | .name = DRV_NAME, |
106 | .pm = &ahci_da850_pm_ops, | 113 | .pm = &ahci_da850_pm_ops, |
107 | }, | 114 | }, |
108 | }; | 115 | }; |
diff --git a/drivers/ata/ahci_imx.c b/drivers/ata/ahci_imx.c index 35d51c59a370..3f3a7db208ae 100644 --- a/drivers/ata/ahci_imx.c +++ b/drivers/ata/ahci_imx.c | |||
@@ -28,6 +28,8 @@ | |||
28 | #include <linux/libata.h> | 28 | #include <linux/libata.h> |
29 | #include "ahci.h" | 29 | #include "ahci.h" |
30 | 30 | ||
31 | #define DRV_NAME "ahci-imx" | ||
32 | |||
31 | enum { | 33 | enum { |
32 | /* Timer 1-ms Register */ | 34 | /* Timer 1-ms Register */ |
33 | IMX_TIMER1MS = 0x00e0, | 35 | IMX_TIMER1MS = 0x00e0, |
@@ -221,11 +223,9 @@ static int imx_sata_enable(struct ahci_host_priv *hpriv) | |||
221 | if (imxpriv->no_device) | 223 | if (imxpriv->no_device) |
222 | return 0; | 224 | return 0; |
223 | 225 | ||
224 | if (hpriv->target_pwr) { | 226 | ret = ahci_platform_enable_regulators(hpriv); |
225 | ret = regulator_enable(hpriv->target_pwr); | 227 | if (ret) |
226 | if (ret) | 228 | return ret; |
227 | return ret; | ||
228 | } | ||
229 | 229 | ||
230 | ret = clk_prepare_enable(imxpriv->sata_ref_clk); | 230 | ret = clk_prepare_enable(imxpriv->sata_ref_clk); |
231 | if (ret < 0) | 231 | if (ret < 0) |
@@ -270,8 +270,7 @@ static int imx_sata_enable(struct ahci_host_priv *hpriv) | |||
270 | disable_clk: | 270 | disable_clk: |
271 | clk_disable_unprepare(imxpriv->sata_ref_clk); | 271 | clk_disable_unprepare(imxpriv->sata_ref_clk); |
272 | disable_regulator: | 272 | disable_regulator: |
273 | if (hpriv->target_pwr) | 273 | ahci_platform_disable_regulators(hpriv); |
274 | regulator_disable(hpriv->target_pwr); | ||
275 | 274 | ||
276 | return ret; | 275 | return ret; |
277 | } | 276 | } |
@@ -291,8 +290,7 @@ static void imx_sata_disable(struct ahci_host_priv *hpriv) | |||
291 | 290 | ||
292 | clk_disable_unprepare(imxpriv->sata_ref_clk); | 291 | clk_disable_unprepare(imxpriv->sata_ref_clk); |
293 | 292 | ||
294 | if (hpriv->target_pwr) | 293 | ahci_platform_disable_regulators(hpriv); |
295 | regulator_disable(hpriv->target_pwr); | ||
296 | } | 294 | } |
297 | 295 | ||
298 | static void ahci_imx_error_handler(struct ata_port *ap) | 296 | static void ahci_imx_error_handler(struct ata_port *ap) |
@@ -524,6 +522,10 @@ static u32 imx_ahci_parse_props(struct device *dev, | |||
524 | return reg_value; | 522 | return reg_value; |
525 | } | 523 | } |
526 | 524 | ||
525 | static struct scsi_host_template ahci_platform_sht = { | ||
526 | AHCI_SHT(DRV_NAME), | ||
527 | }; | ||
528 | |||
527 | static int imx_ahci_probe(struct platform_device *pdev) | 529 | static int imx_ahci_probe(struct platform_device *pdev) |
528 | { | 530 | { |
529 | struct device *dev = &pdev->dev; | 531 | struct device *dev = &pdev->dev; |
@@ -620,7 +622,8 @@ static int imx_ahci_probe(struct platform_device *pdev) | |||
620 | reg_val = clk_get_rate(imxpriv->ahb_clk) / 1000; | 622 | reg_val = clk_get_rate(imxpriv->ahb_clk) / 1000; |
621 | writel(reg_val, hpriv->mmio + IMX_TIMER1MS); | 623 | writel(reg_val, hpriv->mmio + IMX_TIMER1MS); |
622 | 624 | ||
623 | ret = ahci_platform_init_host(pdev, hpriv, &ahci_imx_port_info); | 625 | ret = ahci_platform_init_host(pdev, hpriv, &ahci_imx_port_info, |
626 | &ahci_platform_sht); | ||
624 | if (ret) | 627 | if (ret) |
625 | goto disable_sata; | 628 | goto disable_sata; |
626 | 629 | ||
@@ -678,7 +681,7 @@ static struct platform_driver imx_ahci_driver = { | |||
678 | .probe = imx_ahci_probe, | 681 | .probe = imx_ahci_probe, |
679 | .remove = ata_platform_remove_one, | 682 | .remove = ata_platform_remove_one, |
680 | .driver = { | 683 | .driver = { |
681 | .name = "ahci-imx", | 684 | .name = DRV_NAME, |
682 | .of_match_table = imx_ahci_of_match, | 685 | .of_match_table = imx_ahci_of_match, |
683 | .pm = &ahci_imx_pm_ops, | 686 | .pm = &ahci_imx_pm_ops, |
684 | }, | 687 | }, |
diff --git a/drivers/ata/ahci_mvebu.c b/drivers/ata/ahci_mvebu.c index 64bb08432b69..23716dd8a7ec 100644 --- a/drivers/ata/ahci_mvebu.c +++ b/drivers/ata/ahci_mvebu.c | |||
@@ -19,6 +19,8 @@ | |||
19 | #include <linux/platform_device.h> | 19 | #include <linux/platform_device.h> |
20 | #include "ahci.h" | 20 | #include "ahci.h" |
21 | 21 | ||
22 | #define DRV_NAME "ahci-mvebu" | ||
23 | |||
22 | #define AHCI_VENDOR_SPECIFIC_0_ADDR 0xa0 | 24 | #define AHCI_VENDOR_SPECIFIC_0_ADDR 0xa0 |
23 | #define AHCI_VENDOR_SPECIFIC_0_DATA 0xa4 | 25 | #define AHCI_VENDOR_SPECIFIC_0_DATA 0xa4 |
24 | 26 | ||
@@ -67,6 +69,10 @@ static const struct ata_port_info ahci_mvebu_port_info = { | |||
67 | .port_ops = &ahci_platform_ops, | 69 | .port_ops = &ahci_platform_ops, |
68 | }; | 70 | }; |
69 | 71 | ||
72 | static struct scsi_host_template ahci_platform_sht = { | ||
73 | AHCI_SHT(DRV_NAME), | ||
74 | }; | ||
75 | |||
70 | static int ahci_mvebu_probe(struct platform_device *pdev) | 76 | static int ahci_mvebu_probe(struct platform_device *pdev) |
71 | { | 77 | { |
72 | struct ahci_host_priv *hpriv; | 78 | struct ahci_host_priv *hpriv; |
@@ -88,7 +94,8 @@ static int ahci_mvebu_probe(struct platform_device *pdev) | |||
88 | ahci_mvebu_mbus_config(hpriv, dram); | 94 | ahci_mvebu_mbus_config(hpriv, dram); |
89 | ahci_mvebu_regret_option(hpriv); | 95 | ahci_mvebu_regret_option(hpriv); |
90 | 96 | ||
91 | rc = ahci_platform_init_host(pdev, hpriv, &ahci_mvebu_port_info); | 97 | rc = ahci_platform_init_host(pdev, hpriv, &ahci_mvebu_port_info, |
98 | &ahci_platform_sht); | ||
92 | if (rc) | 99 | if (rc) |
93 | goto disable_resources; | 100 | goto disable_resources; |
94 | 101 | ||
@@ -114,7 +121,7 @@ static struct platform_driver ahci_mvebu_driver = { | |||
114 | .probe = ahci_mvebu_probe, | 121 | .probe = ahci_mvebu_probe, |
115 | .remove = ata_platform_remove_one, | 122 | .remove = ata_platform_remove_one, |
116 | .driver = { | 123 | .driver = { |
117 | .name = "ahci-mvebu", | 124 | .name = DRV_NAME, |
118 | .of_match_table = ahci_mvebu_of_match, | 125 | .of_match_table = ahci_mvebu_of_match, |
119 | }, | 126 | }, |
120 | }; | 127 | }; |
diff --git a/drivers/ata/ahci_platform.c b/drivers/ata/ahci_platform.c index 18d539837045..78d6ae0b90c4 100644 --- a/drivers/ata/ahci_platform.c +++ b/drivers/ata/ahci_platform.c | |||
@@ -22,6 +22,8 @@ | |||
22 | #include <linux/ahci_platform.h> | 22 | #include <linux/ahci_platform.h> |
23 | #include "ahci.h" | 23 | #include "ahci.h" |
24 | 24 | ||
25 | #define DRV_NAME "ahci" | ||
26 | |||
25 | static const struct ata_port_info ahci_port_info = { | 27 | static const struct ata_port_info ahci_port_info = { |
26 | .flags = AHCI_FLAG_COMMON, | 28 | .flags = AHCI_FLAG_COMMON, |
27 | .pio_mask = ATA_PIO4, | 29 | .pio_mask = ATA_PIO4, |
@@ -29,6 +31,10 @@ static const struct ata_port_info ahci_port_info = { | |||
29 | .port_ops = &ahci_platform_ops, | 31 | .port_ops = &ahci_platform_ops, |
30 | }; | 32 | }; |
31 | 33 | ||
34 | static struct scsi_host_template ahci_platform_sht = { | ||
35 | AHCI_SHT(DRV_NAME), | ||
36 | }; | ||
37 | |||
32 | static int ahci_probe(struct platform_device *pdev) | 38 | static int ahci_probe(struct platform_device *pdev) |
33 | { | 39 | { |
34 | struct device *dev = &pdev->dev; | 40 | struct device *dev = &pdev->dev; |
@@ -46,7 +52,8 @@ static int ahci_probe(struct platform_device *pdev) | |||
46 | if (of_device_is_compatible(dev->of_node, "hisilicon,hisi-ahci")) | 52 | if (of_device_is_compatible(dev->of_node, "hisilicon,hisi-ahci")) |
47 | hpriv->flags |= AHCI_HFLAG_NO_FBS | AHCI_HFLAG_NO_NCQ; | 53 | hpriv->flags |= AHCI_HFLAG_NO_FBS | AHCI_HFLAG_NO_NCQ; |
48 | 54 | ||
49 | rc = ahci_platform_init_host(pdev, hpriv, &ahci_port_info); | 55 | rc = ahci_platform_init_host(pdev, hpriv, &ahci_port_info, |
56 | &ahci_platform_sht); | ||
50 | if (rc) | 57 | if (rc) |
51 | goto disable_resources; | 58 | goto disable_resources; |
52 | 59 | ||
@@ -75,7 +82,7 @@ static struct platform_driver ahci_driver = { | |||
75 | .probe = ahci_probe, | 82 | .probe = ahci_probe, |
76 | .remove = ata_platform_remove_one, | 83 | .remove = ata_platform_remove_one, |
77 | .driver = { | 84 | .driver = { |
78 | .name = "ahci", | 85 | .name = DRV_NAME, |
79 | .of_match_table = ahci_of_match, | 86 | .of_match_table = ahci_of_match, |
80 | .pm = &ahci_pm_ops, | 87 | .pm = &ahci_pm_ops, |
81 | }, | 88 | }, |
diff --git a/drivers/ata/ahci_st.c b/drivers/ata/ahci_st.c index 2f9e8317cc16..bc971af262e7 100644 --- a/drivers/ata/ahci_st.c +++ b/drivers/ata/ahci_st.c | |||
@@ -23,6 +23,8 @@ | |||
23 | 23 | ||
24 | #include "ahci.h" | 24 | #include "ahci.h" |
25 | 25 | ||
26 | #define DRV_NAME "st_ahci" | ||
27 | |||
26 | #define ST_AHCI_OOBR 0xbc | 28 | #define ST_AHCI_OOBR 0xbc |
27 | #define ST_AHCI_OOBR_WE BIT(31) | 29 | #define ST_AHCI_OOBR_WE BIT(31) |
28 | #define ST_AHCI_OOBR_CWMIN_SHIFT 24 | 30 | #define ST_AHCI_OOBR_CWMIN_SHIFT 24 |
@@ -140,6 +142,10 @@ static const struct ata_port_info st_ahci_port_info = { | |||
140 | .port_ops = &st_ahci_port_ops, | 142 | .port_ops = &st_ahci_port_ops, |
141 | }; | 143 | }; |
142 | 144 | ||
145 | static struct scsi_host_template ahci_platform_sht = { | ||
146 | AHCI_SHT(DRV_NAME), | ||
147 | }; | ||
148 | |||
143 | static int st_ahci_probe(struct platform_device *pdev) | 149 | static int st_ahci_probe(struct platform_device *pdev) |
144 | { | 150 | { |
145 | struct st_ahci_drv_data *drv_data; | 151 | struct st_ahci_drv_data *drv_data; |
@@ -166,7 +172,8 @@ static int st_ahci_probe(struct platform_device *pdev) | |||
166 | if (err) | 172 | if (err) |
167 | return err; | 173 | return err; |
168 | 174 | ||
169 | err = ahci_platform_init_host(pdev, hpriv, &st_ahci_port_info); | 175 | err = ahci_platform_init_host(pdev, hpriv, &st_ahci_port_info, |
176 | &ahci_platform_sht); | ||
170 | if (err) { | 177 | if (err) { |
171 | ahci_platform_disable_resources(hpriv); | 178 | ahci_platform_disable_resources(hpriv); |
172 | return err; | 179 | return err; |
@@ -229,7 +236,7 @@ MODULE_DEVICE_TABLE(of, st_ahci_match); | |||
229 | 236 | ||
230 | static struct platform_driver st_ahci_driver = { | 237 | static struct platform_driver st_ahci_driver = { |
231 | .driver = { | 238 | .driver = { |
232 | .name = "st_ahci", | 239 | .name = DRV_NAME, |
233 | .pm = &st_ahci_pm_ops, | 240 | .pm = &st_ahci_pm_ops, |
234 | .of_match_table = of_match_ptr(st_ahci_match), | 241 | .of_match_table = of_match_ptr(st_ahci_match), |
235 | }, | 242 | }, |
diff --git a/drivers/ata/ahci_sunxi.c b/drivers/ata/ahci_sunxi.c index e2e0da539a2f..b26437430163 100644 --- a/drivers/ata/ahci_sunxi.c +++ b/drivers/ata/ahci_sunxi.c | |||
@@ -27,6 +27,8 @@ | |||
27 | #include <linux/regulator/consumer.h> | 27 | #include <linux/regulator/consumer.h> |
28 | #include "ahci.h" | 28 | #include "ahci.h" |
29 | 29 | ||
30 | #define DRV_NAME "ahci-sunxi" | ||
31 | |||
30 | /* Insmod parameters */ | 32 | /* Insmod parameters */ |
31 | static bool enable_pmp; | 33 | static bool enable_pmp; |
32 | module_param(enable_pmp, bool, 0); | 34 | module_param(enable_pmp, bool, 0); |
@@ -169,6 +171,10 @@ static const struct ata_port_info ahci_sunxi_port_info = { | |||
169 | .port_ops = &ahci_platform_ops, | 171 | .port_ops = &ahci_platform_ops, |
170 | }; | 172 | }; |
171 | 173 | ||
174 | static struct scsi_host_template ahci_platform_sht = { | ||
175 | AHCI_SHT(DRV_NAME), | ||
176 | }; | ||
177 | |||
172 | static int ahci_sunxi_probe(struct platform_device *pdev) | 178 | static int ahci_sunxi_probe(struct platform_device *pdev) |
173 | { | 179 | { |
174 | struct device *dev = &pdev->dev; | 180 | struct device *dev = &pdev->dev; |
@@ -200,7 +206,8 @@ static int ahci_sunxi_probe(struct platform_device *pdev) | |||
200 | if (!enable_pmp) | 206 | if (!enable_pmp) |
201 | hpriv->flags |= AHCI_HFLAG_NO_PMP; | 207 | hpriv->flags |= AHCI_HFLAG_NO_PMP; |
202 | 208 | ||
203 | rc = ahci_platform_init_host(pdev, hpriv, &ahci_sunxi_port_info); | 209 | rc = ahci_platform_init_host(pdev, hpriv, &ahci_sunxi_port_info, |
210 | &ahci_platform_sht); | ||
204 | if (rc) | 211 | if (rc) |
205 | goto disable_resources; | 212 | goto disable_resources; |
206 | 213 | ||
@@ -251,7 +258,7 @@ static struct platform_driver ahci_sunxi_driver = { | |||
251 | .probe = ahci_sunxi_probe, | 258 | .probe = ahci_sunxi_probe, |
252 | .remove = ata_platform_remove_one, | 259 | .remove = ata_platform_remove_one, |
253 | .driver = { | 260 | .driver = { |
254 | .name = "ahci-sunxi", | 261 | .name = DRV_NAME, |
255 | .of_match_table = ahci_sunxi_of_match, | 262 | .of_match_table = ahci_sunxi_of_match, |
256 | .pm = &ahci_sunxi_pm_ops, | 263 | .pm = &ahci_sunxi_pm_ops, |
257 | }, | 264 | }, |
diff --git a/drivers/ata/ahci_tegra.c b/drivers/ata/ahci_tegra.c index 032904402c95..3a62eb246d80 100644 --- a/drivers/ata/ahci_tegra.c +++ b/drivers/ata/ahci_tegra.c | |||
@@ -31,6 +31,8 @@ | |||
31 | 31 | ||
32 | #include "ahci.h" | 32 | #include "ahci.h" |
33 | 33 | ||
34 | #define DRV_NAME "tegra-ahci" | ||
35 | |||
34 | #define SATA_CONFIGURATION_0 0x180 | 36 | #define SATA_CONFIGURATION_0 0x180 |
35 | #define SATA_CONFIGURATION_EN_FPCI BIT(0) | 37 | #define SATA_CONFIGURATION_EN_FPCI BIT(0) |
36 | 38 | ||
@@ -289,6 +291,10 @@ static const struct of_device_id tegra_ahci_of_match[] = { | |||
289 | }; | 291 | }; |
290 | MODULE_DEVICE_TABLE(of, tegra_ahci_of_match); | 292 | MODULE_DEVICE_TABLE(of, tegra_ahci_of_match); |
291 | 293 | ||
294 | static struct scsi_host_template ahci_platform_sht = { | ||
295 | AHCI_SHT(DRV_NAME), | ||
296 | }; | ||
297 | |||
292 | static int tegra_ahci_probe(struct platform_device *pdev) | 298 | static int tegra_ahci_probe(struct platform_device *pdev) |
293 | { | 299 | { |
294 | struct ahci_host_priv *hpriv; | 300 | struct ahci_host_priv *hpriv; |
@@ -354,7 +360,8 @@ static int tegra_ahci_probe(struct platform_device *pdev) | |||
354 | if (ret) | 360 | if (ret) |
355 | return ret; | 361 | return ret; |
356 | 362 | ||
357 | ret = ahci_platform_init_host(pdev, hpriv, &ahci_tegra_port_info); | 363 | ret = ahci_platform_init_host(pdev, hpriv, &ahci_tegra_port_info, |
364 | &ahci_platform_sht); | ||
358 | if (ret) | 365 | if (ret) |
359 | goto deinit_controller; | 366 | goto deinit_controller; |
360 | 367 | ||
@@ -370,7 +377,7 @@ static struct platform_driver tegra_ahci_driver = { | |||
370 | .probe = tegra_ahci_probe, | 377 | .probe = tegra_ahci_probe, |
371 | .remove = ata_platform_remove_one, | 378 | .remove = ata_platform_remove_one, |
372 | .driver = { | 379 | .driver = { |
373 | .name = "tegra-ahci", | 380 | .name = DRV_NAME, |
374 | .of_match_table = tegra_ahci_of_match, | 381 | .of_match_table = tegra_ahci_of_match, |
375 | }, | 382 | }, |
376 | /* LP0 suspend support not implemented */ | 383 | /* LP0 suspend support not implemented */ |
diff --git a/drivers/ata/ahci_xgene.c b/drivers/ata/ahci_xgene.c index cbcd20810355..2e8bb603e447 100644 --- a/drivers/ata/ahci_xgene.c +++ b/drivers/ata/ahci_xgene.c | |||
@@ -30,6 +30,8 @@ | |||
30 | #include <linux/phy/phy.h> | 30 | #include <linux/phy/phy.h> |
31 | #include "ahci.h" | 31 | #include "ahci.h" |
32 | 32 | ||
33 | #define DRV_NAME "xgene-ahci" | ||
34 | |||
33 | /* Max # of disk per a controller */ | 35 | /* Max # of disk per a controller */ |
34 | #define MAX_AHCI_CHN_PERCTR 2 | 36 | #define MAX_AHCI_CHN_PERCTR 2 |
35 | 37 | ||
@@ -85,6 +87,7 @@ struct xgene_ahci_context { | |||
85 | struct ahci_host_priv *hpriv; | 87 | struct ahci_host_priv *hpriv; |
86 | struct device *dev; | 88 | struct device *dev; |
87 | u8 last_cmd[MAX_AHCI_CHN_PERCTR]; /* tracking the last command issued*/ | 89 | u8 last_cmd[MAX_AHCI_CHN_PERCTR]; /* tracking the last command issued*/ |
90 | u32 class[MAX_AHCI_CHN_PERCTR]; /* tracking the class of device */ | ||
88 | void __iomem *csr_core; /* Core CSR address of IP */ | 91 | void __iomem *csr_core; /* Core CSR address of IP */ |
89 | void __iomem *csr_diag; /* Diag CSR address of IP */ | 92 | void __iomem *csr_diag; /* Diag CSR address of IP */ |
90 | void __iomem *csr_axi; /* AXI CSR address of IP */ | 93 | void __iomem *csr_axi; /* AXI CSR address of IP */ |
@@ -105,17 +108,69 @@ static int xgene_ahci_init_memram(struct xgene_ahci_context *ctx) | |||
105 | } | 108 | } |
106 | 109 | ||
107 | /** | 110 | /** |
111 | * xgene_ahci_poll_reg_val- Poll a register on a specific value. | ||
112 | * @ap : ATA port of interest. | ||
113 | * @reg : Register of interest. | ||
114 | * @val : Value to be attained. | ||
115 | * @interval : waiting interval for polling. | ||
116 | * @timeout : timeout for achieving the value. | ||
117 | */ | ||
118 | static int xgene_ahci_poll_reg_val(struct ata_port *ap, | ||
119 | void __iomem *reg, unsigned | ||
120 | int val, unsigned long interval, | ||
121 | unsigned long timeout) | ||
122 | { | ||
123 | unsigned long deadline; | ||
124 | unsigned int tmp; | ||
125 | |||
126 | tmp = ioread32(reg); | ||
127 | deadline = ata_deadline(jiffies, timeout); | ||
128 | |||
129 | while (tmp != val && time_before(jiffies, deadline)) { | ||
130 | ata_msleep(ap, interval); | ||
131 | tmp = ioread32(reg); | ||
132 | } | ||
133 | |||
134 | return tmp; | ||
135 | } | ||
136 | |||
137 | /** | ||
108 | * xgene_ahci_restart_engine - Restart the dma engine. | 138 | * xgene_ahci_restart_engine - Restart the dma engine. |
109 | * @ap : ATA port of interest | 139 | * @ap : ATA port of interest |
110 | * | 140 | * |
111 | * Restarts the dma engine inside the controller. | 141 | * Waits for completion of multiple commands and restarts |
142 | * the DMA engine inside the controller. | ||
112 | */ | 143 | */ |
113 | static int xgene_ahci_restart_engine(struct ata_port *ap) | 144 | static int xgene_ahci_restart_engine(struct ata_port *ap) |
114 | { | 145 | { |
115 | struct ahci_host_priv *hpriv = ap->host->private_data; | 146 | struct ahci_host_priv *hpriv = ap->host->private_data; |
147 | struct ahci_port_priv *pp = ap->private_data; | ||
148 | void __iomem *port_mmio = ahci_port_base(ap); | ||
149 | u32 fbs; | ||
150 | |||
151 | /* | ||
152 | * In case of PMP multiple IDENTIFY DEVICE commands can be | ||
153 | * issued inside PxCI. So need to poll PxCI for the | ||
154 | * completion of outstanding IDENTIFY DEVICE commands before | ||
155 | * we restart the DMA engine. | ||
156 | */ | ||
157 | if (xgene_ahci_poll_reg_val(ap, port_mmio + | ||
158 | PORT_CMD_ISSUE, 0x0, 1, 100)) | ||
159 | return -EBUSY; | ||
116 | 160 | ||
117 | ahci_stop_engine(ap); | 161 | ahci_stop_engine(ap); |
118 | ahci_start_fis_rx(ap); | 162 | ahci_start_fis_rx(ap); |
163 | |||
164 | /* | ||
165 | * Enable the PxFBS.FBS_EN bit as it | ||
166 | * gets cleared due to stopping the engine. | ||
167 | */ | ||
168 | if (pp->fbs_supported) { | ||
169 | fbs = readl(port_mmio + PORT_FBS); | ||
170 | writel(fbs | PORT_FBS_EN, port_mmio + PORT_FBS); | ||
171 | fbs = readl(port_mmio + PORT_FBS); | ||
172 | } | ||
173 | |||
119 | hpriv->start_engine(ap); | 174 | hpriv->start_engine(ap); |
120 | 175 | ||
121 | return 0; | 176 | return 0; |
@@ -125,11 +180,17 @@ static int xgene_ahci_restart_engine(struct ata_port *ap) | |||
125 | * xgene_ahci_qc_issue - Issue commands to the device | 180 | * xgene_ahci_qc_issue - Issue commands to the device |
126 | * @qc: Command to issue | 181 | * @qc: Command to issue |
127 | * | 182 | * |
128 | * Due to Hardware errata for IDENTIFY DEVICE command and PACKET | 183 | * Due to Hardware errata for IDENTIFY DEVICE command, the controller cannot |
129 | * command of ATAPI protocol set, the controller cannot clear the BSY bit | 184 | * clear the BSY bit after receiving the PIO setup FIS. This results in the dma |
130 | * after receiving the PIO setup FIS. This results in the DMA state machine | 185 | * state machine goes into the CMFatalErrorUpdate state and locks up. By |
131 | * going into the CMFatalErrorUpdate state and locks up. By restarting the | 186 | * restarting the dma engine, it removes the controller out of lock up state. |
132 | * DMA engine, it removes the controller out of lock up state. | 187 | * |
188 | * Due to H/W errata, the controller is unable to save the PMP | ||
189 | * field fetched from command header before sending the H2D FIS. | ||
190 | * When the device returns the PMP port field in the D2H FIS, there is | ||
191 | * a mismatch and results in command completion failure. The | ||
192 | * workaround is to write the pmp value to PxFBS.DEV field before issuing | ||
193 | * any command to PMP. | ||
133 | */ | 194 | */ |
134 | static unsigned int xgene_ahci_qc_issue(struct ata_queued_cmd *qc) | 195 | static unsigned int xgene_ahci_qc_issue(struct ata_queued_cmd *qc) |
135 | { | 196 | { |
@@ -137,9 +198,23 @@ static unsigned int xgene_ahci_qc_issue(struct ata_queued_cmd *qc) | |||
137 | struct ahci_host_priv *hpriv = ap->host->private_data; | 198 | struct ahci_host_priv *hpriv = ap->host->private_data; |
138 | struct xgene_ahci_context *ctx = hpriv->plat_data; | 199 | struct xgene_ahci_context *ctx = hpriv->plat_data; |
139 | int rc = 0; | 200 | int rc = 0; |
201 | u32 port_fbs; | ||
202 | void *port_mmio = ahci_port_base(ap); | ||
203 | |||
204 | /* | ||
205 | * Write the pmp value to PxFBS.DEV | ||
206 | * for case of Port Mulitplier. | ||
207 | */ | ||
208 | if (ctx->class[ap->port_no] == ATA_DEV_PMP) { | ||
209 | port_fbs = readl(port_mmio + PORT_FBS); | ||
210 | port_fbs &= ~PORT_FBS_DEV_MASK; | ||
211 | port_fbs |= qc->dev->link->pmp << PORT_FBS_DEV_OFFSET; | ||
212 | writel(port_fbs, port_mmio + PORT_FBS); | ||
213 | } | ||
140 | 214 | ||
141 | if (unlikely((ctx->last_cmd[ap->port_no] == ATA_CMD_ID_ATA) || | 215 | if (unlikely((ctx->last_cmd[ap->port_no] == ATA_CMD_ID_ATA) || |
142 | (ctx->last_cmd[ap->port_no] == ATA_CMD_PACKET))) | 216 | (ctx->last_cmd[ap->port_no] == ATA_CMD_PACKET) || |
217 | (ctx->last_cmd[ap->port_no] == ATA_CMD_SMART))) | ||
143 | xgene_ahci_restart_engine(ap); | 218 | xgene_ahci_restart_engine(ap); |
144 | 219 | ||
145 | rc = ahci_qc_issue(qc); | 220 | rc = ahci_qc_issue(qc); |
@@ -365,16 +440,119 @@ static void xgene_ahci_host_stop(struct ata_host *host) | |||
365 | ahci_platform_disable_resources(hpriv); | 440 | ahci_platform_disable_resources(hpriv); |
366 | } | 441 | } |
367 | 442 | ||
443 | /** | ||
444 | * xgene_ahci_pmp_softreset - Issue the softreset to the drives connected | ||
445 | * to Port Multiplier. | ||
446 | * @link: link to reset | ||
447 | * @class: Return value to indicate class of device | ||
448 | * @deadline: deadline jiffies for the operation | ||
449 | * | ||
450 | * Due to H/W errata, the controller is unable to save the PMP | ||
451 | * field fetched from command header before sending the H2D FIS. | ||
452 | * When the device returns the PMP port field in the D2H FIS, there is | ||
453 | * a mismatch and results in command completion failure. The workaround | ||
454 | * is to write the pmp value to PxFBS.DEV field before issuing any command | ||
455 | * to PMP. | ||
456 | */ | ||
457 | static int xgene_ahci_pmp_softreset(struct ata_link *link, unsigned int *class, | ||
458 | unsigned long deadline) | ||
459 | { | ||
460 | int pmp = sata_srst_pmp(link); | ||
461 | struct ata_port *ap = link->ap; | ||
462 | u32 rc; | ||
463 | void *port_mmio = ahci_port_base(ap); | ||
464 | u32 port_fbs; | ||
465 | |||
466 | /* | ||
467 | * Set PxFBS.DEV field with pmp | ||
468 | * value. | ||
469 | */ | ||
470 | port_fbs = readl(port_mmio + PORT_FBS); | ||
471 | port_fbs &= ~PORT_FBS_DEV_MASK; | ||
472 | port_fbs |= pmp << PORT_FBS_DEV_OFFSET; | ||
473 | writel(port_fbs, port_mmio + PORT_FBS); | ||
474 | |||
475 | rc = ahci_do_softreset(link, class, pmp, deadline, ahci_check_ready); | ||
476 | |||
477 | return rc; | ||
478 | } | ||
479 | |||
480 | /** | ||
481 | * xgene_ahci_softreset - Issue the softreset to the drive. | ||
482 | * @link: link to reset | ||
483 | * @class: Return value to indicate class of device | ||
484 | * @deadline: deadline jiffies for the operation | ||
485 | * | ||
486 | * Due to H/W errata, the controller is unable to save the PMP | ||
487 | * field fetched from command header before sending the H2D FIS. | ||
488 | * When the device returns the PMP port field in the D2H FIS, there is | ||
489 | * a mismatch and results in command completion failure. The workaround | ||
490 | * is to write the pmp value to PxFBS.DEV field before issuing any command | ||
491 | * to PMP. Here is the algorithm to detect PMP : | ||
492 | * | ||
493 | * 1. Save the PxFBS value | ||
494 | * 2. Program PxFBS.DEV with pmp value send by framework. Framework sends | ||
495 | * 0xF for both PMP/NON-PMP initially | ||
496 | * 3. Issue softreset | ||
497 | * 4. If signature class is PMP goto 6 | ||
498 | * 5. restore the original PxFBS and goto 3 | ||
499 | * 6. return | ||
500 | */ | ||
501 | static int xgene_ahci_softreset(struct ata_link *link, unsigned int *class, | ||
502 | unsigned long deadline) | ||
503 | { | ||
504 | int pmp = sata_srst_pmp(link); | ||
505 | struct ata_port *ap = link->ap; | ||
506 | struct ahci_host_priv *hpriv = ap->host->private_data; | ||
507 | struct xgene_ahci_context *ctx = hpriv->plat_data; | ||
508 | void *port_mmio = ahci_port_base(ap); | ||
509 | u32 port_fbs; | ||
510 | u32 port_fbs_save; | ||
511 | u32 retry = 1; | ||
512 | u32 rc; | ||
513 | |||
514 | port_fbs_save = readl(port_mmio + PORT_FBS); | ||
515 | |||
516 | /* | ||
517 | * Set PxFBS.DEV field with pmp | ||
518 | * value. | ||
519 | */ | ||
520 | port_fbs = readl(port_mmio + PORT_FBS); | ||
521 | port_fbs &= ~PORT_FBS_DEV_MASK; | ||
522 | port_fbs |= pmp << PORT_FBS_DEV_OFFSET; | ||
523 | writel(port_fbs, port_mmio + PORT_FBS); | ||
524 | |||
525 | softreset_retry: | ||
526 | rc = ahci_do_softreset(link, class, pmp, | ||
527 | deadline, ahci_check_ready); | ||
528 | |||
529 | ctx->class[ap->port_no] = *class; | ||
530 | if (*class != ATA_DEV_PMP) { | ||
531 | /* | ||
532 | * Retry for normal drives without | ||
533 | * setting PxFBS.DEV field with pmp value. | ||
534 | */ | ||
535 | if (retry--) { | ||
536 | writel(port_fbs_save, port_mmio + PORT_FBS); | ||
537 | goto softreset_retry; | ||
538 | } | ||
539 | } | ||
540 | |||
541 | return rc; | ||
542 | } | ||
543 | |||
368 | static struct ata_port_operations xgene_ahci_ops = { | 544 | static struct ata_port_operations xgene_ahci_ops = { |
369 | .inherits = &ahci_ops, | 545 | .inherits = &ahci_ops, |
370 | .host_stop = xgene_ahci_host_stop, | 546 | .host_stop = xgene_ahci_host_stop, |
371 | .hardreset = xgene_ahci_hardreset, | 547 | .hardreset = xgene_ahci_hardreset, |
372 | .read_id = xgene_ahci_read_id, | 548 | .read_id = xgene_ahci_read_id, |
373 | .qc_issue = xgene_ahci_qc_issue, | 549 | .qc_issue = xgene_ahci_qc_issue, |
550 | .softreset = xgene_ahci_softreset, | ||
551 | .pmp_softreset = xgene_ahci_pmp_softreset | ||
374 | }; | 552 | }; |
375 | 553 | ||
376 | static const struct ata_port_info xgene_ahci_port_info = { | 554 | static const struct ata_port_info xgene_ahci_port_info = { |
377 | .flags = AHCI_FLAG_COMMON, | 555 | .flags = AHCI_FLAG_COMMON | ATA_FLAG_PMP, |
378 | .pio_mask = ATA_PIO4, | 556 | .pio_mask = ATA_PIO4, |
379 | .udma_mask = ATA_UDMA6, | 557 | .udma_mask = ATA_UDMA6, |
380 | .port_ops = &xgene_ahci_ops, | 558 | .port_ops = &xgene_ahci_ops, |
@@ -446,6 +624,10 @@ static int xgene_ahci_mux_select(struct xgene_ahci_context *ctx) | |||
446 | return val & CFG_SATA_ENET_SELECT_MASK ? -1 : 0; | 624 | return val & CFG_SATA_ENET_SELECT_MASK ? -1 : 0; |
447 | } | 625 | } |
448 | 626 | ||
627 | static struct scsi_host_template ahci_platform_sht = { | ||
628 | AHCI_SHT(DRV_NAME), | ||
629 | }; | ||
630 | |||
449 | static int xgene_ahci_probe(struct platform_device *pdev) | 631 | static int xgene_ahci_probe(struct platform_device *pdev) |
450 | { | 632 | { |
451 | struct device *dev = &pdev->dev; | 633 | struct device *dev = &pdev->dev; |
@@ -523,7 +705,8 @@ static int xgene_ahci_probe(struct platform_device *pdev) | |||
523 | skip_clk_phy: | 705 | skip_clk_phy: |
524 | hpriv->flags = AHCI_HFLAG_NO_PMP | AHCI_HFLAG_NO_NCQ; | 706 | hpriv->flags = AHCI_HFLAG_NO_PMP | AHCI_HFLAG_NO_NCQ; |
525 | 707 | ||
526 | rc = ahci_platform_init_host(pdev, hpriv, &xgene_ahci_port_info); | 708 | rc = ahci_platform_init_host(pdev, hpriv, &xgene_ahci_port_info, |
709 | &ahci_platform_sht); | ||
527 | if (rc) | 710 | if (rc) |
528 | goto disable_resources; | 711 | goto disable_resources; |
529 | 712 | ||
@@ -545,7 +728,7 @@ static struct platform_driver xgene_ahci_driver = { | |||
545 | .probe = xgene_ahci_probe, | 728 | .probe = xgene_ahci_probe, |
546 | .remove = ata_platform_remove_one, | 729 | .remove = ata_platform_remove_one, |
547 | .driver = { | 730 | .driver = { |
548 | .name = "xgene-ahci", | 731 | .name = DRV_NAME, |
549 | .of_match_table = xgene_ahci_of_match, | 732 | .of_match_table = xgene_ahci_of_match, |
550 | }, | 733 | }, |
551 | }; | 734 | }; |
diff --git a/drivers/ata/libahci_platform.c b/drivers/ata/libahci_platform.c index 0b03f9056692..d89305d289f6 100644 --- a/drivers/ata/libahci_platform.c +++ b/drivers/ata/libahci_platform.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/ahci_platform.h> | 24 | #include <linux/ahci_platform.h> |
25 | #include <linux/phy/phy.h> | 25 | #include <linux/phy/phy.h> |
26 | #include <linux/pm_runtime.h> | 26 | #include <linux/pm_runtime.h> |
27 | #include <linux/of_platform.h> | ||
27 | #include "ahci.h" | 28 | #include "ahci.h" |
28 | 29 | ||
29 | static void ahci_host_stop(struct ata_host *host); | 30 | static void ahci_host_stop(struct ata_host *host); |
@@ -34,10 +35,6 @@ struct ata_port_operations ahci_platform_ops = { | |||
34 | }; | 35 | }; |
35 | EXPORT_SYMBOL_GPL(ahci_platform_ops); | 36 | EXPORT_SYMBOL_GPL(ahci_platform_ops); |
36 | 37 | ||
37 | static struct scsi_host_template ahci_platform_sht = { | ||
38 | AHCI_SHT("ahci_platform"), | ||
39 | }; | ||
40 | |||
41 | /** | 38 | /** |
42 | * ahci_platform_enable_phys - Enable PHYs | 39 | * ahci_platform_enable_phys - Enable PHYs |
43 | * @hpriv: host private area to store config values | 40 | * @hpriv: host private area to store config values |
@@ -54,9 +51,6 @@ static int ahci_platform_enable_phys(struct ahci_host_priv *hpriv) | |||
54 | int rc, i; | 51 | int rc, i; |
55 | 52 | ||
56 | for (i = 0; i < hpriv->nports; i++) { | 53 | for (i = 0; i < hpriv->nports; i++) { |
57 | if (!hpriv->phys[i]) | ||
58 | continue; | ||
59 | |||
60 | rc = phy_init(hpriv->phys[i]); | 54 | rc = phy_init(hpriv->phys[i]); |
61 | if (rc) | 55 | if (rc) |
62 | goto disable_phys; | 56 | goto disable_phys; |
@@ -89,9 +83,6 @@ static void ahci_platform_disable_phys(struct ahci_host_priv *hpriv) | |||
89 | int i; | 83 | int i; |
90 | 84 | ||
91 | for (i = 0; i < hpriv->nports; i++) { | 85 | for (i = 0; i < hpriv->nports; i++) { |
92 | if (!hpriv->phys[i]) | ||
93 | continue; | ||
94 | |||
95 | phy_power_off(hpriv->phys[i]); | 86 | phy_power_off(hpriv->phys[i]); |
96 | phy_exit(hpriv->phys[i]); | 87 | phy_exit(hpriv->phys[i]); |
97 | } | 88 | } |
@@ -144,6 +135,59 @@ void ahci_platform_disable_clks(struct ahci_host_priv *hpriv) | |||
144 | EXPORT_SYMBOL_GPL(ahci_platform_disable_clks); | 135 | EXPORT_SYMBOL_GPL(ahci_platform_disable_clks); |
145 | 136 | ||
146 | /** | 137 | /** |
138 | * ahci_platform_enable_regulators - Enable regulators | ||
139 | * @hpriv: host private area to store config values | ||
140 | * | ||
141 | * This function enables all the regulators found in | ||
142 | * hpriv->target_pwrs, if any. If a regulator fails to be enabled, it | ||
143 | * disables all the regulators already enabled in reverse order and | ||
144 | * returns an error. | ||
145 | * | ||
146 | * RETURNS: | ||
147 | * 0 on success otherwise a negative error code | ||
148 | */ | ||
149 | int ahci_platform_enable_regulators(struct ahci_host_priv *hpriv) | ||
150 | { | ||
151 | int rc, i; | ||
152 | |||
153 | for (i = 0; i < hpriv->nports; i++) { | ||
154 | if (!hpriv->target_pwrs[i]) | ||
155 | continue; | ||
156 | |||
157 | rc = regulator_enable(hpriv->target_pwrs[i]); | ||
158 | if (rc) | ||
159 | goto disable_target_pwrs; | ||
160 | } | ||
161 | |||
162 | return 0; | ||
163 | |||
164 | disable_target_pwrs: | ||
165 | while (--i >= 0) | ||
166 | if (hpriv->target_pwrs[i]) | ||
167 | regulator_disable(hpriv->target_pwrs[i]); | ||
168 | |||
169 | return rc; | ||
170 | } | ||
171 | EXPORT_SYMBOL_GPL(ahci_platform_enable_regulators); | ||
172 | |||
173 | /** | ||
174 | * ahci_platform_disable_regulators - Disable regulators | ||
175 | * @hpriv: host private area to store config values | ||
176 | * | ||
177 | * This function disables all regulators found in hpriv->target_pwrs. | ||
178 | */ | ||
179 | void ahci_platform_disable_regulators(struct ahci_host_priv *hpriv) | ||
180 | { | ||
181 | int i; | ||
182 | |||
183 | for (i = 0; i < hpriv->nports; i++) { | ||
184 | if (!hpriv->target_pwrs[i]) | ||
185 | continue; | ||
186 | regulator_disable(hpriv->target_pwrs[i]); | ||
187 | } | ||
188 | } | ||
189 | EXPORT_SYMBOL_GPL(ahci_platform_disable_regulators); | ||
190 | /** | ||
147 | * ahci_platform_enable_resources - Enable platform resources | 191 | * ahci_platform_enable_resources - Enable platform resources |
148 | * @hpriv: host private area to store config values | 192 | * @hpriv: host private area to store config values |
149 | * | 193 | * |
@@ -163,11 +207,9 @@ int ahci_platform_enable_resources(struct ahci_host_priv *hpriv) | |||
163 | { | 207 | { |
164 | int rc; | 208 | int rc; |
165 | 209 | ||
166 | if (hpriv->target_pwr) { | 210 | rc = ahci_platform_enable_regulators(hpriv); |
167 | rc = regulator_enable(hpriv->target_pwr); | 211 | if (rc) |
168 | if (rc) | 212 | return rc; |
169 | return rc; | ||
170 | } | ||
171 | 213 | ||
172 | rc = ahci_platform_enable_clks(hpriv); | 214 | rc = ahci_platform_enable_clks(hpriv); |
173 | if (rc) | 215 | if (rc) |
@@ -183,8 +225,8 @@ disable_clks: | |||
183 | ahci_platform_disable_clks(hpriv); | 225 | ahci_platform_disable_clks(hpriv); |
184 | 226 | ||
185 | disable_regulator: | 227 | disable_regulator: |
186 | if (hpriv->target_pwr) | 228 | ahci_platform_disable_regulators(hpriv); |
187 | regulator_disable(hpriv->target_pwr); | 229 | |
188 | return rc; | 230 | return rc; |
189 | } | 231 | } |
190 | EXPORT_SYMBOL_GPL(ahci_platform_enable_resources); | 232 | EXPORT_SYMBOL_GPL(ahci_platform_enable_resources); |
@@ -205,8 +247,7 @@ void ahci_platform_disable_resources(struct ahci_host_priv *hpriv) | |||
205 | 247 | ||
206 | ahci_platform_disable_clks(hpriv); | 248 | ahci_platform_disable_clks(hpriv); |
207 | 249 | ||
208 | if (hpriv->target_pwr) | 250 | ahci_platform_disable_regulators(hpriv); |
209 | regulator_disable(hpriv->target_pwr); | ||
210 | } | 251 | } |
211 | EXPORT_SYMBOL_GPL(ahci_platform_disable_resources); | 252 | EXPORT_SYMBOL_GPL(ahci_platform_disable_resources); |
212 | 253 | ||
@@ -222,6 +263,69 @@ static void ahci_platform_put_resources(struct device *dev, void *res) | |||
222 | 263 | ||
223 | for (c = 0; c < AHCI_MAX_CLKS && hpriv->clks[c]; c++) | 264 | for (c = 0; c < AHCI_MAX_CLKS && hpriv->clks[c]; c++) |
224 | clk_put(hpriv->clks[c]); | 265 | clk_put(hpriv->clks[c]); |
266 | /* | ||
267 | * The regulators are tied to child node device and not to the | ||
268 | * SATA device itself. So we can't use devm for automatically | ||
269 | * releasing them. We have to do it manually here. | ||
270 | */ | ||
271 | for (c = 0; c < hpriv->nports; c++) | ||
272 | if (hpriv->target_pwrs && hpriv->target_pwrs[c]) | ||
273 | regulator_put(hpriv->target_pwrs[c]); | ||
274 | |||
275 | kfree(hpriv->target_pwrs); | ||
276 | } | ||
277 | |||
278 | static int ahci_platform_get_phy(struct ahci_host_priv *hpriv, u32 port, | ||
279 | struct device *dev, struct device_node *node) | ||
280 | { | ||
281 | int rc; | ||
282 | |||
283 | hpriv->phys[port] = devm_of_phy_get(dev, node, NULL); | ||
284 | |||
285 | if (!IS_ERR(hpriv->phys[port])) | ||
286 | return 0; | ||
287 | |||
288 | rc = PTR_ERR(hpriv->phys[port]); | ||
289 | switch (rc) { | ||
290 | case -ENOSYS: | ||
291 | /* No PHY support. Check if PHY is required. */ | ||
292 | if (of_find_property(node, "phys", NULL)) { | ||
293 | dev_err(dev, | ||
294 | "couldn't get PHY in node %s: ENOSYS\n", | ||
295 | node->name); | ||
296 | break; | ||
297 | } | ||
298 | case -ENODEV: | ||
299 | /* continue normally */ | ||
300 | hpriv->phys[port] = NULL; | ||
301 | rc = 0; | ||
302 | break; | ||
303 | |||
304 | default: | ||
305 | dev_err(dev, | ||
306 | "couldn't get PHY in node %s: %d\n", | ||
307 | node->name, rc); | ||
308 | |||
309 | break; | ||
310 | } | ||
311 | |||
312 | return rc; | ||
313 | } | ||
314 | |||
315 | static int ahci_platform_get_regulator(struct ahci_host_priv *hpriv, u32 port, | ||
316 | struct device *dev) | ||
317 | { | ||
318 | struct regulator *target_pwr; | ||
319 | int rc = 0; | ||
320 | |||
321 | target_pwr = regulator_get_optional(dev, "target"); | ||
322 | |||
323 | if (!IS_ERR(target_pwr)) | ||
324 | hpriv->target_pwrs[port] = target_pwr; | ||
325 | else | ||
326 | rc = PTR_ERR(target_pwr); | ||
327 | |||
328 | return rc; | ||
225 | } | 329 | } |
226 | 330 | ||
227 | /** | 331 | /** |
@@ -246,7 +350,7 @@ struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev) | |||
246 | struct ahci_host_priv *hpriv; | 350 | struct ahci_host_priv *hpriv; |
247 | struct clk *clk; | 351 | struct clk *clk; |
248 | struct device_node *child; | 352 | struct device_node *child; |
249 | int i, enabled_ports = 0, rc = -ENOMEM; | 353 | int i, sz, enabled_ports = 0, rc = -ENOMEM, child_nodes; |
250 | u32 mask_port_map = 0; | 354 | u32 mask_port_map = 0; |
251 | 355 | ||
252 | if (!devres_open_group(dev, NULL, GFP_KERNEL)) | 356 | if (!devres_open_group(dev, NULL, GFP_KERNEL)) |
@@ -267,14 +371,6 @@ struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev) | |||
267 | goto err_out; | 371 | goto err_out; |
268 | } | 372 | } |
269 | 373 | ||
270 | hpriv->target_pwr = devm_regulator_get_optional(dev, "target"); | ||
271 | if (IS_ERR(hpriv->target_pwr)) { | ||
272 | rc = PTR_ERR(hpriv->target_pwr); | ||
273 | if (rc == -EPROBE_DEFER) | ||
274 | goto err_out; | ||
275 | hpriv->target_pwr = NULL; | ||
276 | } | ||
277 | |||
278 | for (i = 0; i < AHCI_MAX_CLKS; i++) { | 374 | for (i = 0; i < AHCI_MAX_CLKS; i++) { |
279 | /* | 375 | /* |
280 | * For now we must use clk_get(dev, NULL) for the first clock, | 376 | * For now we must use clk_get(dev, NULL) for the first clock, |
@@ -296,19 +392,33 @@ struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev) | |||
296 | hpriv->clks[i] = clk; | 392 | hpriv->clks[i] = clk; |
297 | } | 393 | } |
298 | 394 | ||
299 | hpriv->nports = of_get_child_count(dev->of_node); | 395 | hpriv->nports = child_nodes = of_get_child_count(dev->of_node); |
300 | 396 | ||
301 | if (hpriv->nports) { | 397 | /* |
302 | hpriv->phys = devm_kzalloc(dev, | 398 | * If no sub-node was found, we still need to set nports to |
303 | hpriv->nports * sizeof(*hpriv->phys), | 399 | * one in order to be able to use the |
304 | GFP_KERNEL); | 400 | * ahci_platform_[en|dis]able_[phys|regulators] functions. |
305 | if (!hpriv->phys) { | 401 | */ |
306 | rc = -ENOMEM; | 402 | if (!child_nodes) |
307 | goto err_out; | 403 | hpriv->nports = 1; |
308 | } | ||
309 | 404 | ||
405 | sz = hpriv->nports * sizeof(*hpriv->phys); | ||
406 | hpriv->phys = devm_kzalloc(dev, sz, GFP_KERNEL); | ||
407 | if (!hpriv->phys) { | ||
408 | rc = -ENOMEM; | ||
409 | goto err_out; | ||
410 | } | ||
411 | sz = hpriv->nports * sizeof(*hpriv->target_pwrs); | ||
412 | hpriv->target_pwrs = kzalloc(sz, GFP_KERNEL); | ||
413 | if (!hpriv->target_pwrs) { | ||
414 | rc = -ENOMEM; | ||
415 | goto err_out; | ||
416 | } | ||
417 | |||
418 | if (child_nodes) { | ||
310 | for_each_child_of_node(dev->of_node, child) { | 419 | for_each_child_of_node(dev->of_node, child) { |
311 | u32 port; | 420 | u32 port; |
421 | struct platform_device *port_dev __maybe_unused; | ||
312 | 422 | ||
313 | if (!of_device_is_available(child)) | 423 | if (!of_device_is_available(child)) |
314 | continue; | 424 | continue; |
@@ -322,17 +432,24 @@ struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev) | |||
322 | dev_warn(dev, "invalid port number %d\n", port); | 432 | dev_warn(dev, "invalid port number %d\n", port); |
323 | continue; | 433 | continue; |
324 | } | 434 | } |
325 | |||
326 | mask_port_map |= BIT(port); | 435 | mask_port_map |= BIT(port); |
327 | 436 | ||
328 | hpriv->phys[port] = devm_of_phy_get(dev, child, NULL); | 437 | #ifdef CONFIG_OF_ADDRESS |
329 | if (IS_ERR(hpriv->phys[port])) { | 438 | of_platform_device_create(child, NULL, NULL); |
330 | rc = PTR_ERR(hpriv->phys[port]); | 439 | |
331 | dev_err(dev, | 440 | port_dev = of_find_device_by_node(child); |
332 | "couldn't get PHY in node %s: %d\n", | 441 | |
333 | child->name, rc); | 442 | if (port_dev) { |
334 | goto err_out; | 443 | rc = ahci_platform_get_regulator(hpriv, port, |
444 | &port_dev->dev); | ||
445 | if (rc == -EPROBE_DEFER) | ||
446 | goto err_out; | ||
335 | } | 447 | } |
448 | #endif | ||
449 | |||
450 | rc = ahci_platform_get_phy(hpriv, port, dev, child); | ||
451 | if (rc) | ||
452 | goto err_out; | ||
336 | 453 | ||
337 | enabled_ports++; | 454 | enabled_ports++; |
338 | } | 455 | } |
@@ -349,38 +466,14 @@ struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev) | |||
349 | * If no sub-node was found, keep this for device tree | 466 | * If no sub-node was found, keep this for device tree |
350 | * compatibility | 467 | * compatibility |
351 | */ | 468 | */ |
352 | struct phy *phy = devm_phy_get(dev, "sata-phy"); | 469 | rc = ahci_platform_get_phy(hpriv, 0, dev, dev->of_node); |
353 | if (!IS_ERR(phy)) { | 470 | if (rc) |
354 | hpriv->phys = devm_kzalloc(dev, sizeof(*hpriv->phys), | 471 | goto err_out; |
355 | GFP_KERNEL); | ||
356 | if (!hpriv->phys) { | ||
357 | rc = -ENOMEM; | ||
358 | goto err_out; | ||
359 | } | ||
360 | |||
361 | hpriv->phys[0] = phy; | ||
362 | hpriv->nports = 1; | ||
363 | } else { | ||
364 | rc = PTR_ERR(phy); | ||
365 | switch (rc) { | ||
366 | case -ENOSYS: | ||
367 | /* No PHY support. Check if PHY is required. */ | ||
368 | if (of_find_property(dev->of_node, "phys", NULL)) { | ||
369 | dev_err(dev, "couldn't get sata-phy: ENOSYS\n"); | ||
370 | goto err_out; | ||
371 | } | ||
372 | case -ENODEV: | ||
373 | /* continue normally */ | ||
374 | hpriv->phys = NULL; | ||
375 | break; | ||
376 | |||
377 | default: | ||
378 | goto err_out; | ||
379 | 472 | ||
380 | } | 473 | rc = ahci_platform_get_regulator(hpriv, 0, dev); |
381 | } | 474 | if (rc == -EPROBE_DEFER) |
475 | goto err_out; | ||
382 | } | 476 | } |
383 | |||
384 | pm_runtime_enable(dev); | 477 | pm_runtime_enable(dev); |
385 | pm_runtime_get_sync(dev); | 478 | pm_runtime_get_sync(dev); |
386 | hpriv->got_runtime_pm = true; | 479 | hpriv->got_runtime_pm = true; |
@@ -399,6 +492,7 @@ EXPORT_SYMBOL_GPL(ahci_platform_get_resources); | |||
399 | * @pdev: platform device pointer for the host | 492 | * @pdev: platform device pointer for the host |
400 | * @hpriv: ahci-host private data for the host | 493 | * @hpriv: ahci-host private data for the host |
401 | * @pi_template: template for the ata_port_info to use | 494 | * @pi_template: template for the ata_port_info to use |
495 | * @sht: scsi_host_template to use when registering | ||
402 | * | 496 | * |
403 | * This function does all the usual steps needed to bring up an | 497 | * This function does all the usual steps needed to bring up an |
404 | * ahci-platform host, note any necessary resources (ie clks, phys, etc.) | 498 | * ahci-platform host, note any necessary resources (ie clks, phys, etc.) |
@@ -409,7 +503,8 @@ EXPORT_SYMBOL_GPL(ahci_platform_get_resources); | |||
409 | */ | 503 | */ |
410 | int ahci_platform_init_host(struct platform_device *pdev, | 504 | int ahci_platform_init_host(struct platform_device *pdev, |
411 | struct ahci_host_priv *hpriv, | 505 | struct ahci_host_priv *hpriv, |
412 | const struct ata_port_info *pi_template) | 506 | const struct ata_port_info *pi_template, |
507 | struct scsi_host_template *sht) | ||
413 | { | 508 | { |
414 | struct device *dev = &pdev->dev; | 509 | struct device *dev = &pdev->dev; |
415 | struct ata_port_info pi = *pi_template; | 510 | struct ata_port_info pi = *pi_template; |
@@ -493,7 +588,7 @@ int ahci_platform_init_host(struct platform_device *pdev, | |||
493 | ahci_init_controller(host); | 588 | ahci_init_controller(host); |
494 | ahci_print_info(host, "platform"); | 589 | ahci_print_info(host, "platform"); |
495 | 590 | ||
496 | return ahci_host_activate(host, irq, &ahci_platform_sht); | 591 | return ahci_host_activate(host, irq, sht); |
497 | } | 592 | } |
498 | EXPORT_SYMBOL_GPL(ahci_platform_init_host); | 593 | EXPORT_SYMBOL_GPL(ahci_platform_init_host); |
499 | 594 | ||
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index d1a05f9bb91f..4b0d5e71858e 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
@@ -1752,33 +1752,6 @@ unsigned ata_exec_internal(struct ata_device *dev, | |||
1752 | } | 1752 | } |
1753 | 1753 | ||
1754 | /** | 1754 | /** |
1755 | * ata_do_simple_cmd - execute simple internal command | ||
1756 | * @dev: Device to which the command is sent | ||
1757 | * @cmd: Opcode to execute | ||
1758 | * | ||
1759 | * Execute a 'simple' command, that only consists of the opcode | ||
1760 | * 'cmd' itself, without filling any other registers | ||
1761 | * | ||
1762 | * LOCKING: | ||
1763 | * Kernel thread context (may sleep). | ||
1764 | * | ||
1765 | * RETURNS: | ||
1766 | * Zero on success, AC_ERR_* mask on failure | ||
1767 | */ | ||
1768 | unsigned int ata_do_simple_cmd(struct ata_device *dev, u8 cmd) | ||
1769 | { | ||
1770 | struct ata_taskfile tf; | ||
1771 | |||
1772 | ata_tf_init(dev, &tf); | ||
1773 | |||
1774 | tf.command = cmd; | ||
1775 | tf.flags |= ATA_TFLAG_DEVICE; | ||
1776 | tf.protocol = ATA_PROT_NODATA; | ||
1777 | |||
1778 | return ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0); | ||
1779 | } | ||
1780 | |||
1781 | /** | ||
1782 | * ata_pio_need_iordy - check if iordy needed | 1755 | * ata_pio_need_iordy - check if iordy needed |
1783 | * @adev: ATA device | 1756 | * @adev: ATA device |
1784 | * | 1757 | * |
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c index 8d00c2638bed..a9f5aed32d39 100644 --- a/drivers/ata/libata-eh.c +++ b/drivers/ata/libata-eh.c | |||
@@ -1635,7 +1635,6 @@ unsigned int atapi_eh_request_sense(struct ata_device *dev, | |||
1635 | 1635 | ||
1636 | DPRINTK("ATAPI request sense\n"); | 1636 | DPRINTK("ATAPI request sense\n"); |
1637 | 1637 | ||
1638 | /* FIXME: is this needed? */ | ||
1639 | memset(sense_buf, 0, SCSI_SENSE_BUFFERSIZE); | 1638 | memset(sense_buf, 0, SCSI_SENSE_BUFFERSIZE); |
1640 | 1639 | ||
1641 | /* initialize sense_buf with the error register, | 1640 | /* initialize sense_buf with the error register, |
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 6abd17a85b13..280729325ebd 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c | |||
@@ -1995,8 +1995,8 @@ static unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf) | |||
1995 | 1995 | ||
1996 | VPRINTK("ENTER\n"); | 1996 | VPRINTK("ENTER\n"); |
1997 | 1997 | ||
1998 | /* set scsi removeable (RMB) bit per ata bit */ | 1998 | /* set scsi removable (RMB) bit per ata bit */ |
1999 | if (ata_id_removeable(args->id)) | 1999 | if (ata_id_removable(args->id)) |
2000 | hdr[1] |= (1 << 7); | 2000 | hdr[1] |= (1 << 7); |
2001 | 2001 | ||
2002 | if (args->dev->class == ATA_DEV_ZAC) { | 2002 | if (args->dev->class == ATA_DEV_ZAC) { |
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h index 5f4e0cca56ec..82ebe263d2f1 100644 --- a/drivers/ata/libata.h +++ b/drivers/ata/libata.h | |||
@@ -76,7 +76,6 @@ extern unsigned ata_exec_internal_sg(struct ata_device *dev, | |||
76 | struct ata_taskfile *tf, const u8 *cdb, | 76 | struct ata_taskfile *tf, const u8 *cdb, |
77 | int dma_dir, struct scatterlist *sg, | 77 | int dma_dir, struct scatterlist *sg, |
78 | unsigned int n_elem, unsigned long timeout); | 78 | unsigned int n_elem, unsigned long timeout); |
79 | extern unsigned int ata_do_simple_cmd(struct ata_device *dev, u8 cmd); | ||
80 | extern int ata_wait_ready(struct ata_link *link, unsigned long deadline, | 79 | extern int ata_wait_ready(struct ata_link *link, unsigned long deadline, |
81 | int (*check_ready)(struct ata_link *link)); | 80 | int (*check_ready)(struct ata_link *link)); |
82 | extern int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class, | 81 | extern int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class, |
diff --git a/drivers/ata/pata_cs5530.c b/drivers/ata/pata_cs5530.c index 48ae4b434474..f9ca72e937ee 100644 --- a/drivers/ata/pata_cs5530.c +++ b/drivers/ata/pata_cs5530.c | |||
@@ -276,10 +276,8 @@ static int cs5530_init_chip(void) | |||
276 | pci_dev_put(cs5530_0); | 276 | pci_dev_put(cs5530_0); |
277 | return 0; | 277 | return 0; |
278 | fail_put: | 278 | fail_put: |
279 | if (master_0) | 279 | pci_dev_put(master_0); |
280 | pci_dev_put(master_0); | 280 | pci_dev_put(cs5530_0); |
281 | if (cs5530_0) | ||
282 | pci_dev_put(cs5530_0); | ||
283 | return -ENODEV; | 281 | return -ENODEV; |
284 | } | 282 | } |
285 | 283 | ||
diff --git a/drivers/ata/pata_of_platform.c b/drivers/ata/pata_of_platform.c index dcc408abe171..b6b7af894d9d 100644 --- a/drivers/ata/pata_of_platform.c +++ b/drivers/ata/pata_of_platform.c | |||
@@ -16,6 +16,12 @@ | |||
16 | #include <linux/ata_platform.h> | 16 | #include <linux/ata_platform.h> |
17 | #include <linux/libata.h> | 17 | #include <linux/libata.h> |
18 | 18 | ||
19 | #define DRV_NAME "pata_of_platform" | ||
20 | |||
21 | static struct scsi_host_template pata_platform_sht = { | ||
22 | ATA_PIO_SHT(DRV_NAME), | ||
23 | }; | ||
24 | |||
19 | static int pata_of_platform_probe(struct platform_device *ofdev) | 25 | static int pata_of_platform_probe(struct platform_device *ofdev) |
20 | { | 26 | { |
21 | int ret; | 27 | int ret; |
@@ -63,7 +69,7 @@ static int pata_of_platform_probe(struct platform_device *ofdev) | |||
63 | pio_mask |= (1 << pio_mode) - 1; | 69 | pio_mask |= (1 << pio_mode) - 1; |
64 | 70 | ||
65 | return __pata_platform_probe(&ofdev->dev, &io_res, &ctl_res, irq_res, | 71 | return __pata_platform_probe(&ofdev->dev, &io_res, &ctl_res, irq_res, |
66 | reg_shift, pio_mask); | 72 | reg_shift, pio_mask, &pata_platform_sht); |
67 | } | 73 | } |
68 | 74 | ||
69 | static struct of_device_id pata_of_platform_match[] = { | 75 | static struct of_device_id pata_of_platform_match[] = { |
@@ -74,7 +80,7 @@ MODULE_DEVICE_TABLE(of, pata_of_platform_match); | |||
74 | 80 | ||
75 | static struct platform_driver pata_of_platform_driver = { | 81 | static struct platform_driver pata_of_platform_driver = { |
76 | .driver = { | 82 | .driver = { |
77 | .name = "pata_of_platform", | 83 | .name = DRV_NAME, |
78 | .of_match_table = pata_of_platform_match, | 84 | .of_match_table = pata_of_platform_match, |
79 | }, | 85 | }, |
80 | .probe = pata_of_platform_probe, | 86 | .probe = pata_of_platform_probe, |
diff --git a/drivers/ata/pata_pdc2027x.c b/drivers/ata/pata_pdc2027x.c index 4d06a5cda987..dca8251b1aea 100644 --- a/drivers/ata/pata_pdc2027x.c +++ b/drivers/ata/pata_pdc2027x.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/blkdev.h> | 28 | #include <linux/blkdev.h> |
29 | #include <linux/delay.h> | 29 | #include <linux/delay.h> |
30 | #include <linux/device.h> | 30 | #include <linux/device.h> |
31 | #include <linux/ktime.h> | ||
31 | #include <scsi/scsi.h> | 32 | #include <scsi/scsi.h> |
32 | #include <scsi/scsi_host.h> | 33 | #include <scsi/scsi_host.h> |
33 | #include <scsi/scsi_cmnd.h> | 34 | #include <scsi/scsi_cmnd.h> |
@@ -605,7 +606,7 @@ static long pdc_detect_pll_input_clock(struct ata_host *host) | |||
605 | void __iomem *mmio_base = host->iomap[PDC_MMIO_BAR]; | 606 | void __iomem *mmio_base = host->iomap[PDC_MMIO_BAR]; |
606 | u32 scr; | 607 | u32 scr; |
607 | long start_count, end_count; | 608 | long start_count, end_count; |
608 | struct timeval start_time, end_time; | 609 | ktime_t start_time, end_time; |
609 | long pll_clock, usec_elapsed; | 610 | long pll_clock, usec_elapsed; |
610 | 611 | ||
611 | /* Start the test mode */ | 612 | /* Start the test mode */ |
@@ -616,14 +617,14 @@ static long pdc_detect_pll_input_clock(struct ata_host *host) | |||
616 | 617 | ||
617 | /* Read current counter value */ | 618 | /* Read current counter value */ |
618 | start_count = pdc_read_counter(host); | 619 | start_count = pdc_read_counter(host); |
619 | do_gettimeofday(&start_time); | 620 | start_time = ktime_get(); |
620 | 621 | ||
621 | /* Let the counter run for 100 ms. */ | 622 | /* Let the counter run for 100 ms. */ |
622 | mdelay(100); | 623 | mdelay(100); |
623 | 624 | ||
624 | /* Read the counter values again */ | 625 | /* Read the counter values again */ |
625 | end_count = pdc_read_counter(host); | 626 | end_count = pdc_read_counter(host); |
626 | do_gettimeofday(&end_time); | 627 | end_time = ktime_get(); |
627 | 628 | ||
628 | /* Stop the test mode */ | 629 | /* Stop the test mode */ |
629 | scr = ioread32(mmio_base + PDC_SYS_CTL); | 630 | scr = ioread32(mmio_base + PDC_SYS_CTL); |
@@ -632,8 +633,7 @@ static long pdc_detect_pll_input_clock(struct ata_host *host) | |||
632 | ioread32(mmio_base + PDC_SYS_CTL); /* flush */ | 633 | ioread32(mmio_base + PDC_SYS_CTL); /* flush */ |
633 | 634 | ||
634 | /* calculate the input clock in Hz */ | 635 | /* calculate the input clock in Hz */ |
635 | usec_elapsed = (end_time.tv_sec - start_time.tv_sec) * 1000000 + | 636 | usec_elapsed = (long) ktime_us_delta(end_time, start_time); |
636 | (end_time.tv_usec - start_time.tv_usec); | ||
637 | 637 | ||
638 | pll_clock = ((start_count - end_count) & 0x3fffffff) / 100 * | 638 | pll_clock = ((start_count - end_count) & 0x3fffffff) / 100 * |
639 | (100000000 / usec_elapsed); | 639 | (100000000 / usec_elapsed); |
diff --git a/drivers/ata/pata_platform.c b/drivers/ata/pata_platform.c index 1eedfe46d7c8..c503ded87bb8 100644 --- a/drivers/ata/pata_platform.c +++ b/drivers/ata/pata_platform.c | |||
@@ -78,6 +78,7 @@ static void pata_platform_setup_port(struct ata_ioports *ioaddr, | |||
78 | * @irq_res: Resource representing IRQ and its flags | 78 | * @irq_res: Resource representing IRQ and its flags |
79 | * @ioport_shift: I/O port shift | 79 | * @ioport_shift: I/O port shift |
80 | * @__pio_mask: PIO mask | 80 | * @__pio_mask: PIO mask |
81 | * @sht: scsi_host_template to use when registering | ||
81 | * | 82 | * |
82 | * Register a platform bus IDE interface. Such interfaces are PIO and we | 83 | * Register a platform bus IDE interface. Such interfaces are PIO and we |
83 | * assume do not support IRQ sharing. | 84 | * assume do not support IRQ sharing. |
@@ -99,7 +100,8 @@ static void pata_platform_setup_port(struct ata_ioports *ioaddr, | |||
99 | */ | 100 | */ |
100 | int __pata_platform_probe(struct device *dev, struct resource *io_res, | 101 | int __pata_platform_probe(struct device *dev, struct resource *io_res, |
101 | struct resource *ctl_res, struct resource *irq_res, | 102 | struct resource *ctl_res, struct resource *irq_res, |
102 | unsigned int ioport_shift, int __pio_mask) | 103 | unsigned int ioport_shift, int __pio_mask, |
104 | struct scsi_host_template *sht) | ||
103 | { | 105 | { |
104 | struct ata_host *host; | 106 | struct ata_host *host; |
105 | struct ata_port *ap; | 107 | struct ata_port *ap; |
@@ -170,7 +172,7 @@ int __pata_platform_probe(struct device *dev, struct resource *io_res, | |||
170 | 172 | ||
171 | /* activate */ | 173 | /* activate */ |
172 | return ata_host_activate(host, irq, irq ? ata_sff_interrupt : NULL, | 174 | return ata_host_activate(host, irq, irq ? ata_sff_interrupt : NULL, |
173 | irq_flags, &pata_platform_sht); | 175 | irq_flags, sht); |
174 | } | 176 | } |
175 | EXPORT_SYMBOL_GPL(__pata_platform_probe); | 177 | EXPORT_SYMBOL_GPL(__pata_platform_probe); |
176 | 178 | ||
@@ -216,7 +218,7 @@ static int pata_platform_probe(struct platform_device *pdev) | |||
216 | 218 | ||
217 | return __pata_platform_probe(&pdev->dev, io_res, ctl_res, irq_res, | 219 | return __pata_platform_probe(&pdev->dev, io_res, ctl_res, irq_res, |
218 | pp_info ? pp_info->ioport_shift : 0, | 220 | pp_info ? pp_info->ioport_shift : 0, |
219 | pio_mask); | 221 | pio_mask, &pata_platform_sht); |
220 | } | 222 | } |
221 | 223 | ||
222 | static struct platform_driver pata_platform_driver = { | 224 | static struct platform_driver pata_platform_driver = { |
diff --git a/drivers/ata/sata_dwc_460ex.c b/drivers/ata/sata_dwc_460ex.c index 8e8248179d20..fdb0f2879ea7 100644 --- a/drivers/ata/sata_dwc_460ex.c +++ b/drivers/ata/sata_dwc_460ex.c | |||
@@ -48,6 +48,18 @@ | |||
48 | #define DRV_NAME "sata-dwc" | 48 | #define DRV_NAME "sata-dwc" |
49 | #define DRV_VERSION "1.3" | 49 | #define DRV_VERSION "1.3" |
50 | 50 | ||
51 | #ifndef out_le32 | ||
52 | #define out_le32(a, v) __raw_writel(__cpu_to_le32(v), (void __iomem *)(a)) | ||
53 | #endif | ||
54 | |||
55 | #ifndef in_le32 | ||
56 | #define in_le32(a) __le32_to_cpu(__raw_readl((void __iomem *)(a))) | ||
57 | #endif | ||
58 | |||
59 | #ifndef NO_IRQ | ||
60 | #define NO_IRQ 0 | ||
61 | #endif | ||
62 | |||
51 | /* SATA DMA driver Globals */ | 63 | /* SATA DMA driver Globals */ |
52 | #define DMA_NUM_CHANS 1 | 64 | #define DMA_NUM_CHANS 1 |
53 | #define DMA_NUM_CHAN_REGS 8 | 65 | #define DMA_NUM_CHAN_REGS 8 |
@@ -273,7 +285,7 @@ struct sata_dwc_device { | |||
273 | struct device *dev; /* generic device struct */ | 285 | struct device *dev; /* generic device struct */ |
274 | struct ata_probe_ent *pe; /* ptr to probe-ent */ | 286 | struct ata_probe_ent *pe; /* ptr to probe-ent */ |
275 | struct ata_host *host; | 287 | struct ata_host *host; |
276 | u8 *reg_base; | 288 | u8 __iomem *reg_base; |
277 | struct sata_dwc_regs *sata_dwc_regs; /* DW Synopsys SATA specific */ | 289 | struct sata_dwc_regs *sata_dwc_regs; /* DW Synopsys SATA specific */ |
278 | int irq_dma; | 290 | int irq_dma; |
279 | }; | 291 | }; |
@@ -323,7 +335,9 @@ struct sata_dwc_host_priv { | |||
323 | struct device *dwc_dev; | 335 | struct device *dwc_dev; |
324 | int dma_channel; | 336 | int dma_channel; |
325 | }; | 337 | }; |
326 | struct sata_dwc_host_priv host_pvt; | 338 | |
339 | static struct sata_dwc_host_priv host_pvt; | ||
340 | |||
327 | /* | 341 | /* |
328 | * Prototypes | 342 | * Prototypes |
329 | */ | 343 | */ |
@@ -580,9 +594,9 @@ static int map_sg_to_lli(struct scatterlist *sg, int num_elems, | |||
580 | 594 | ||
581 | sms_val = 0; | 595 | sms_val = 0; |
582 | dms_val = 1 + host_pvt.dma_channel; | 596 | dms_val = 1 + host_pvt.dma_channel; |
583 | dev_dbg(host_pvt.dwc_dev, "%s: sg=%p nelem=%d lli=%p dma_lli=0x%08x" | 597 | dev_dbg(host_pvt.dwc_dev, |
584 | " dmadr=0x%08x\n", __func__, sg, num_elems, lli, (u32)dma_lli, | 598 | "%s: sg=%p nelem=%d lli=%p dma_lli=0x%pad dmadr=0x%p\n", |
585 | (u32)dmadr_addr); | 599 | __func__, sg, num_elems, lli, &dma_lli, dmadr_addr); |
586 | 600 | ||
587 | bl = get_burst_length_encode(AHB_DMA_BRST_DFLT); | 601 | bl = get_burst_length_encode(AHB_DMA_BRST_DFLT); |
588 | 602 | ||
@@ -773,7 +787,7 @@ static void dma_dwc_exit(struct sata_dwc_device *hsdev) | |||
773 | { | 787 | { |
774 | dev_dbg(host_pvt.dwc_dev, "%s:\n", __func__); | 788 | dev_dbg(host_pvt.dwc_dev, "%s:\n", __func__); |
775 | if (host_pvt.sata_dma_regs) { | 789 | if (host_pvt.sata_dma_regs) { |
776 | iounmap(host_pvt.sata_dma_regs); | 790 | iounmap((void __iomem *)host_pvt.sata_dma_regs); |
777 | host_pvt.sata_dma_regs = NULL; | 791 | host_pvt.sata_dma_regs = NULL; |
778 | } | 792 | } |
779 | 793 | ||
@@ -818,7 +832,7 @@ static int sata_dwc_scr_read(struct ata_link *link, unsigned int scr, u32 *val) | |||
818 | return -EINVAL; | 832 | return -EINVAL; |
819 | } | 833 | } |
820 | 834 | ||
821 | *val = in_le32((void *)link->ap->ioaddr.scr_addr + (scr * 4)); | 835 | *val = in_le32(link->ap->ioaddr.scr_addr + (scr * 4)); |
822 | dev_dbg(link->ap->dev, "%s: id=%d reg=%d val=val=0x%08x\n", | 836 | dev_dbg(link->ap->dev, "%s: id=%d reg=%d val=val=0x%08x\n", |
823 | __func__, link->ap->print_id, scr, *val); | 837 | __func__, link->ap->print_id, scr, *val); |
824 | 838 | ||
@@ -834,21 +848,19 @@ static int sata_dwc_scr_write(struct ata_link *link, unsigned int scr, u32 val) | |||
834 | __func__, scr); | 848 | __func__, scr); |
835 | return -EINVAL; | 849 | return -EINVAL; |
836 | } | 850 | } |
837 | out_le32((void *)link->ap->ioaddr.scr_addr + (scr * 4), val); | 851 | out_le32(link->ap->ioaddr.scr_addr + (scr * 4), val); |
838 | 852 | ||
839 | return 0; | 853 | return 0; |
840 | } | 854 | } |
841 | 855 | ||
842 | static u32 core_scr_read(unsigned int scr) | 856 | static u32 core_scr_read(unsigned int scr) |
843 | { | 857 | { |
844 | return in_le32((void __iomem *)(host_pvt.scr_addr_sstatus) +\ | 858 | return in_le32(host_pvt.scr_addr_sstatus + (scr * 4)); |
845 | (scr * 4)); | ||
846 | } | 859 | } |
847 | 860 | ||
848 | static void core_scr_write(unsigned int scr, u32 val) | 861 | static void core_scr_write(unsigned int scr, u32 val) |
849 | { | 862 | { |
850 | out_le32((void __iomem *)(host_pvt.scr_addr_sstatus) + (scr * 4), | 863 | out_le32(host_pvt.scr_addr_sstatus + (scr * 4), val); |
851 | val); | ||
852 | } | 864 | } |
853 | 865 | ||
854 | static void clear_serror(void) | 866 | static void clear_serror(void) |
@@ -856,7 +868,6 @@ static void clear_serror(void) | |||
856 | u32 val; | 868 | u32 val; |
857 | val = core_scr_read(SCR_ERROR); | 869 | val = core_scr_read(SCR_ERROR); |
858 | core_scr_write(SCR_ERROR, val); | 870 | core_scr_write(SCR_ERROR, val); |
859 | |||
860 | } | 871 | } |
861 | 872 | ||
862 | static void clear_interrupt_bit(struct sata_dwc_device *hsdev, u32 bit) | 873 | static void clear_interrupt_bit(struct sata_dwc_device *hsdev, u32 bit) |
@@ -1256,24 +1267,24 @@ static void sata_dwc_enable_interrupts(struct sata_dwc_device *hsdev) | |||
1256 | 1267 | ||
1257 | static void sata_dwc_setup_port(struct ata_ioports *port, unsigned long base) | 1268 | static void sata_dwc_setup_port(struct ata_ioports *port, unsigned long base) |
1258 | { | 1269 | { |
1259 | port->cmd_addr = (void *)base + 0x00; | 1270 | port->cmd_addr = (void __iomem *)base + 0x00; |
1260 | port->data_addr = (void *)base + 0x00; | 1271 | port->data_addr = (void __iomem *)base + 0x00; |
1261 | 1272 | ||
1262 | port->error_addr = (void *)base + 0x04; | 1273 | port->error_addr = (void __iomem *)base + 0x04; |
1263 | port->feature_addr = (void *)base + 0x04; | 1274 | port->feature_addr = (void __iomem *)base + 0x04; |
1264 | 1275 | ||
1265 | port->nsect_addr = (void *)base + 0x08; | 1276 | port->nsect_addr = (void __iomem *)base + 0x08; |
1266 | 1277 | ||
1267 | port->lbal_addr = (void *)base + 0x0c; | 1278 | port->lbal_addr = (void __iomem *)base + 0x0c; |
1268 | port->lbam_addr = (void *)base + 0x10; | 1279 | port->lbam_addr = (void __iomem *)base + 0x10; |
1269 | port->lbah_addr = (void *)base + 0x14; | 1280 | port->lbah_addr = (void __iomem *)base + 0x14; |
1270 | 1281 | ||
1271 | port->device_addr = (void *)base + 0x18; | 1282 | port->device_addr = (void __iomem *)base + 0x18; |
1272 | port->command_addr = (void *)base + 0x1c; | 1283 | port->command_addr = (void __iomem *)base + 0x1c; |
1273 | port->status_addr = (void *)base + 0x1c; | 1284 | port->status_addr = (void __iomem *)base + 0x1c; |
1274 | 1285 | ||
1275 | port->altstatus_addr = (void *)base + 0x20; | 1286 | port->altstatus_addr = (void __iomem *)base + 0x20; |
1276 | port->ctl_addr = (void *)base + 0x20; | 1287 | port->ctl_addr = (void __iomem *)base + 0x20; |
1277 | } | 1288 | } |
1278 | 1289 | ||
1279 | /* | 1290 | /* |
@@ -1314,7 +1325,7 @@ static int sata_dwc_port_start(struct ata_port *ap) | |||
1314 | for (i = 0; i < SATA_DWC_QCMD_MAX; i++) | 1325 | for (i = 0; i < SATA_DWC_QCMD_MAX; i++) |
1315 | hsdevp->cmd_issued[i] = SATA_DWC_CMD_ISSUED_NOT; | 1326 | hsdevp->cmd_issued[i] = SATA_DWC_CMD_ISSUED_NOT; |
1316 | 1327 | ||
1317 | ap->bmdma_prd = 0; /* set these so libata doesn't use them */ | 1328 | ap->bmdma_prd = NULL; /* set these so libata doesn't use them */ |
1318 | ap->bmdma_prd_dma = 0; | 1329 | ap->bmdma_prd_dma = 0; |
1319 | 1330 | ||
1320 | /* | 1331 | /* |
@@ -1511,8 +1522,8 @@ static void sata_dwc_qc_prep_by_tag(struct ata_queued_cmd *qc, u8 tag) | |||
1511 | 1522 | ||
1512 | dma_chan = dma_dwc_xfer_setup(sg, qc->n_elem, hsdevp->llit[tag], | 1523 | dma_chan = dma_dwc_xfer_setup(sg, qc->n_elem, hsdevp->llit[tag], |
1513 | hsdevp->llit_dma[tag], | 1524 | hsdevp->llit_dma[tag], |
1514 | (void *__iomem)(&hsdev->sata_dwc_regs->\ | 1525 | (void __iomem *)&hsdev->sata_dwc_regs->dmadr, |
1515 | dmadr), qc->dma_dir); | 1526 | qc->dma_dir); |
1516 | if (dma_chan < 0) { | 1527 | if (dma_chan < 0) { |
1517 | dev_err(ap->dev, "%s: dma_dwc_xfer_setup returns err %d\n", | 1528 | dev_err(ap->dev, "%s: dma_dwc_xfer_setup returns err %d\n", |
1518 | __func__, dma_chan); | 1529 | __func__, dma_chan); |
@@ -1585,8 +1596,8 @@ static void sata_dwc_error_handler(struct ata_port *ap) | |||
1585 | ata_sff_error_handler(ap); | 1596 | ata_sff_error_handler(ap); |
1586 | } | 1597 | } |
1587 | 1598 | ||
1588 | int sata_dwc_hardreset(struct ata_link *link, unsigned int *class, | 1599 | static int sata_dwc_hardreset(struct ata_link *link, unsigned int *class, |
1589 | unsigned long deadline) | 1600 | unsigned long deadline) |
1590 | { | 1601 | { |
1591 | struct sata_dwc_device *hsdev = HSDEV_FROM_AP(link->ap); | 1602 | struct sata_dwc_device *hsdev = HSDEV_FROM_AP(link->ap); |
1592 | int ret; | 1603 | int ret; |
@@ -1618,7 +1629,7 @@ static struct scsi_host_template sata_dwc_sht = { | |||
1618 | * max of 1. This will get fixed in in a future release. | 1629 | * max of 1. This will get fixed in in a future release. |
1619 | */ | 1630 | */ |
1620 | .sg_tablesize = LIBATA_MAX_PRD, | 1631 | .sg_tablesize = LIBATA_MAX_PRD, |
1621 | .can_queue = ATA_DEF_QUEUE, /* ATA_MAX_QUEUE */ | 1632 | /* .can_queue = ATA_MAX_QUEUE, */ |
1622 | .dma_boundary = ATA_DMA_BOUNDARY, | 1633 | .dma_boundary = ATA_DMA_BOUNDARY, |
1623 | }; | 1634 | }; |
1624 | 1635 | ||
@@ -1655,7 +1666,7 @@ static int sata_dwc_probe(struct platform_device *ofdev) | |||
1655 | struct sata_dwc_device *hsdev; | 1666 | struct sata_dwc_device *hsdev; |
1656 | u32 idr, versionr; | 1667 | u32 idr, versionr; |
1657 | char *ver = (char *)&versionr; | 1668 | char *ver = (char *)&versionr; |
1658 | u8 *base = NULL; | 1669 | u8 __iomem *base; |
1659 | int err = 0; | 1670 | int err = 0; |
1660 | int irq; | 1671 | int irq; |
1661 | struct ata_host *host; | 1672 | struct ata_host *host; |
@@ -1665,12 +1676,12 @@ static int sata_dwc_probe(struct platform_device *ofdev) | |||
1665 | u32 dma_chan; | 1676 | u32 dma_chan; |
1666 | 1677 | ||
1667 | /* Allocate DWC SATA device */ | 1678 | /* Allocate DWC SATA device */ |
1668 | hsdev = kzalloc(sizeof(*hsdev), GFP_KERNEL); | 1679 | host = ata_host_alloc_pinfo(&ofdev->dev, ppi, SATA_DWC_MAX_PORTS); |
1669 | if (hsdev == NULL) { | 1680 | hsdev = devm_kzalloc(&ofdev->dev, sizeof(*hsdev), GFP_KERNEL); |
1670 | dev_err(&ofdev->dev, "kmalloc failed for hsdev\n"); | 1681 | if (!host || !hsdev) |
1671 | err = -ENOMEM; | 1682 | return -ENOMEM; |
1672 | goto error; | 1683 | |
1673 | } | 1684 | host->private_data = hsdev; |
1674 | 1685 | ||
1675 | if (of_property_read_u32(np, "dma-channel", &dma_chan)) { | 1686 | if (of_property_read_u32(np, "dma-channel", &dma_chan)) { |
1676 | dev_warn(&ofdev->dev, "no dma-channel property set." | 1687 | dev_warn(&ofdev->dev, "no dma-channel property set." |
@@ -1680,12 +1691,11 @@ static int sata_dwc_probe(struct platform_device *ofdev) | |||
1680 | host_pvt.dma_channel = dma_chan; | 1691 | host_pvt.dma_channel = dma_chan; |
1681 | 1692 | ||
1682 | /* Ioremap SATA registers */ | 1693 | /* Ioremap SATA registers */ |
1683 | base = of_iomap(ofdev->dev.of_node, 0); | 1694 | base = of_iomap(np, 0); |
1684 | if (!base) { | 1695 | if (!base) { |
1685 | dev_err(&ofdev->dev, "ioremap failed for SATA register" | 1696 | dev_err(&ofdev->dev, "ioremap failed for SATA register" |
1686 | " address\n"); | 1697 | " address\n"); |
1687 | err = -ENODEV; | 1698 | return -ENODEV; |
1688 | goto error_kmalloc; | ||
1689 | } | 1699 | } |
1690 | hsdev->reg_base = base; | 1700 | hsdev->reg_base = base; |
1691 | dev_dbg(&ofdev->dev, "ioremap done for SATA register address\n"); | 1701 | dev_dbg(&ofdev->dev, "ioremap done for SATA register address\n"); |
@@ -1693,16 +1703,6 @@ static int sata_dwc_probe(struct platform_device *ofdev) | |||
1693 | /* Synopsys DWC SATA specific Registers */ | 1703 | /* Synopsys DWC SATA specific Registers */ |
1694 | hsdev->sata_dwc_regs = (void *__iomem)(base + SATA_DWC_REG_OFFSET); | 1704 | hsdev->sata_dwc_regs = (void *__iomem)(base + SATA_DWC_REG_OFFSET); |
1695 | 1705 | ||
1696 | /* Allocate and fill host */ | ||
1697 | host = ata_host_alloc_pinfo(&ofdev->dev, ppi, SATA_DWC_MAX_PORTS); | ||
1698 | if (!host) { | ||
1699 | dev_err(&ofdev->dev, "ata_host_alloc_pinfo failed\n"); | ||
1700 | err = -ENOMEM; | ||
1701 | goto error_iomap; | ||
1702 | } | ||
1703 | |||
1704 | host->private_data = hsdev; | ||
1705 | |||
1706 | /* Setup port */ | 1706 | /* Setup port */ |
1707 | host->ports[0]->ioaddr.cmd_addr = base; | 1707 | host->ports[0]->ioaddr.cmd_addr = base; |
1708 | host->ports[0]->ioaddr.scr_addr = base + SATA_DWC_SCR_OFFSET; | 1708 | host->ports[0]->ioaddr.scr_addr = base + SATA_DWC_SCR_OFFSET; |
@@ -1716,7 +1716,7 @@ static int sata_dwc_probe(struct platform_device *ofdev) | |||
1716 | idr, ver[0], ver[1], ver[2]); | 1716 | idr, ver[0], ver[1], ver[2]); |
1717 | 1717 | ||
1718 | /* Get SATA DMA interrupt number */ | 1718 | /* Get SATA DMA interrupt number */ |
1719 | irq = irq_of_parse_and_map(ofdev->dev.of_node, 1); | 1719 | irq = irq_of_parse_and_map(np, 1); |
1720 | if (irq == NO_IRQ) { | 1720 | if (irq == NO_IRQ) { |
1721 | dev_err(&ofdev->dev, "no SATA DMA irq\n"); | 1721 | dev_err(&ofdev->dev, "no SATA DMA irq\n"); |
1722 | err = -ENODEV; | 1722 | err = -ENODEV; |
@@ -1724,7 +1724,7 @@ static int sata_dwc_probe(struct platform_device *ofdev) | |||
1724 | } | 1724 | } |
1725 | 1725 | ||
1726 | /* Get physical SATA DMA register base address */ | 1726 | /* Get physical SATA DMA register base address */ |
1727 | host_pvt.sata_dma_regs = of_iomap(ofdev->dev.of_node, 1); | 1727 | host_pvt.sata_dma_regs = (void *)of_iomap(np, 1); |
1728 | if (!(host_pvt.sata_dma_regs)) { | 1728 | if (!(host_pvt.sata_dma_regs)) { |
1729 | dev_err(&ofdev->dev, "ioremap failed for AHBDMA register" | 1729 | dev_err(&ofdev->dev, "ioremap failed for AHBDMA register" |
1730 | " address\n"); | 1730 | " address\n"); |
@@ -1744,7 +1744,7 @@ static int sata_dwc_probe(struct platform_device *ofdev) | |||
1744 | sata_dwc_enable_interrupts(hsdev); | 1744 | sata_dwc_enable_interrupts(hsdev); |
1745 | 1745 | ||
1746 | /* Get SATA interrupt number */ | 1746 | /* Get SATA interrupt number */ |
1747 | irq = irq_of_parse_and_map(ofdev->dev.of_node, 0); | 1747 | irq = irq_of_parse_and_map(np, 0); |
1748 | if (irq == NO_IRQ) { | 1748 | if (irq == NO_IRQ) { |
1749 | dev_err(&ofdev->dev, "no SATA DMA irq\n"); | 1749 | dev_err(&ofdev->dev, "no SATA DMA irq\n"); |
1750 | err = -ENODEV; | 1750 | err = -ENODEV; |
@@ -1770,9 +1770,6 @@ error_dma_iomap: | |||
1770 | iounmap((void __iomem *)host_pvt.sata_dma_regs); | 1770 | iounmap((void __iomem *)host_pvt.sata_dma_regs); |
1771 | error_iomap: | 1771 | error_iomap: |
1772 | iounmap(base); | 1772 | iounmap(base); |
1773 | error_kmalloc: | ||
1774 | kfree(hsdev); | ||
1775 | error: | ||
1776 | return err; | 1773 | return err; |
1777 | } | 1774 | } |
1778 | 1775 | ||
@@ -1783,15 +1780,12 @@ static int sata_dwc_remove(struct platform_device *ofdev) | |||
1783 | struct sata_dwc_device *hsdev = host->private_data; | 1780 | struct sata_dwc_device *hsdev = host->private_data; |
1784 | 1781 | ||
1785 | ata_host_detach(host); | 1782 | ata_host_detach(host); |
1786 | dev_set_drvdata(dev, NULL); | ||
1787 | 1783 | ||
1788 | /* Free SATA DMA resources */ | 1784 | /* Free SATA DMA resources */ |
1789 | dma_dwc_exit(hsdev); | 1785 | dma_dwc_exit(hsdev); |
1790 | 1786 | ||
1791 | iounmap((void __iomem *)host_pvt.sata_dma_regs); | 1787 | iounmap((void __iomem *)host_pvt.sata_dma_regs); |
1792 | iounmap(hsdev->reg_base); | 1788 | iounmap(hsdev->reg_base); |
1793 | kfree(hsdev); | ||
1794 | kfree(host); | ||
1795 | dev_dbg(&ofdev->dev, "done\n"); | 1789 | dev_dbg(&ofdev->dev, "done\n"); |
1796 | return 0; | 1790 | return 0; |
1797 | } | 1791 | } |
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c index f9a0e34eb111..f8c33e3772b8 100644 --- a/drivers/ata/sata_mv.c +++ b/drivers/ata/sata_mv.c | |||
@@ -4185,8 +4185,7 @@ err: | |||
4185 | clk_disable_unprepare(hpriv->port_clks[port]); | 4185 | clk_disable_unprepare(hpriv->port_clks[port]); |
4186 | clk_put(hpriv->port_clks[port]); | 4186 | clk_put(hpriv->port_clks[port]); |
4187 | } | 4187 | } |
4188 | if (hpriv->port_phys[port]) | 4188 | phy_power_off(hpriv->port_phys[port]); |
4189 | phy_power_off(hpriv->port_phys[port]); | ||
4190 | } | 4189 | } |
4191 | 4190 | ||
4192 | return rc; | 4191 | return rc; |
@@ -4216,8 +4215,7 @@ static int mv_platform_remove(struct platform_device *pdev) | |||
4216 | clk_disable_unprepare(hpriv->port_clks[port]); | 4215 | clk_disable_unprepare(hpriv->port_clks[port]); |
4217 | clk_put(hpriv->port_clks[port]); | 4216 | clk_put(hpriv->port_clks[port]); |
4218 | } | 4217 | } |
4219 | if (hpriv->port_phys[port]) | 4218 | phy_power_off(hpriv->port_phys[port]); |
4220 | phy_power_off(hpriv->port_phys[port]); | ||
4221 | } | 4219 | } |
4222 | return 0; | 4220 | return 0; |
4223 | } | 4221 | } |
diff --git a/drivers/ata/sata_rcar.c b/drivers/ata/sata_rcar.c index cb0d2e644af5..d49a5193b7de 100644 --- a/drivers/ata/sata_rcar.c +++ b/drivers/ata/sata_rcar.c | |||
@@ -2,8 +2,8 @@ | |||
2 | * Renesas R-Car SATA driver | 2 | * Renesas R-Car SATA driver |
3 | * | 3 | * |
4 | * Author: Vladimir Barinov <source@cogentembedded.com> | 4 | * Author: Vladimir Barinov <source@cogentembedded.com> |
5 | * Copyright (C) 2013 Cogent Embedded, Inc. | 5 | * Copyright (C) 2013-2015 Cogent Embedded, Inc. |
6 | * Copyright (C) 2013 Renesas Solutions Corp. | 6 | * Copyright (C) 2013-2015 Renesas Solutions Corp. |
7 | * | 7 | * |
8 | * This program is free software; you can redistribute it and/or modify it | 8 | * This program is free software; you can redistribute it and/or modify it |
9 | * under the terms of the GNU General Public License as published by the | 9 | * under the terms of the GNU General Public License as published by the |
@@ -992,9 +992,30 @@ static int sata_rcar_resume(struct device *dev) | |||
992 | return 0; | 992 | return 0; |
993 | } | 993 | } |
994 | 994 | ||
995 | static int sata_rcar_restore(struct device *dev) | ||
996 | { | ||
997 | struct ata_host *host = dev_get_drvdata(dev); | ||
998 | struct sata_rcar_priv *priv = host->private_data; | ||
999 | |||
1000 | clk_prepare_enable(priv->clk); | ||
1001 | |||
1002 | sata_rcar_setup_port(host); | ||
1003 | |||
1004 | /* initialize host controller */ | ||
1005 | sata_rcar_init_controller(host); | ||
1006 | |||
1007 | ata_host_resume(host); | ||
1008 | |||
1009 | return 0; | ||
1010 | } | ||
1011 | |||
995 | static const struct dev_pm_ops sata_rcar_pm_ops = { | 1012 | static const struct dev_pm_ops sata_rcar_pm_ops = { |
996 | .suspend = sata_rcar_suspend, | 1013 | .suspend = sata_rcar_suspend, |
997 | .resume = sata_rcar_resume, | 1014 | .resume = sata_rcar_resume, |
1015 | .freeze = sata_rcar_suspend, | ||
1016 | .thaw = sata_rcar_resume, | ||
1017 | .poweroff = sata_rcar_suspend, | ||
1018 | .restore = sata_rcar_restore, | ||
998 | }; | 1019 | }; |
999 | #endif | 1020 | #endif |
1000 | 1021 | ||
diff --git a/include/linux/ahci_platform.h b/include/linux/ahci_platform.h index 642d6ae4030c..a270f25ee7c7 100644 --- a/include/linux/ahci_platform.h +++ b/include/linux/ahci_platform.h | |||
@@ -21,16 +21,20 @@ struct device; | |||
21 | struct ata_port_info; | 21 | struct ata_port_info; |
22 | struct ahci_host_priv; | 22 | struct ahci_host_priv; |
23 | struct platform_device; | 23 | struct platform_device; |
24 | struct scsi_host_template; | ||
24 | 25 | ||
25 | int ahci_platform_enable_clks(struct ahci_host_priv *hpriv); | 26 | int ahci_platform_enable_clks(struct ahci_host_priv *hpriv); |
26 | void ahci_platform_disable_clks(struct ahci_host_priv *hpriv); | 27 | void ahci_platform_disable_clks(struct ahci_host_priv *hpriv); |
28 | int ahci_platform_enable_regulators(struct ahci_host_priv *hpriv); | ||
29 | void ahci_platform_disable_regulators(struct ahci_host_priv *hpriv); | ||
27 | int ahci_platform_enable_resources(struct ahci_host_priv *hpriv); | 30 | int ahci_platform_enable_resources(struct ahci_host_priv *hpriv); |
28 | void ahci_platform_disable_resources(struct ahci_host_priv *hpriv); | 31 | void ahci_platform_disable_resources(struct ahci_host_priv *hpriv); |
29 | struct ahci_host_priv *ahci_platform_get_resources( | 32 | struct ahci_host_priv *ahci_platform_get_resources( |
30 | struct platform_device *pdev); | 33 | struct platform_device *pdev); |
31 | int ahci_platform_init_host(struct platform_device *pdev, | 34 | int ahci_platform_init_host(struct platform_device *pdev, |
32 | struct ahci_host_priv *hpriv, | 35 | struct ahci_host_priv *hpriv, |
33 | const struct ata_port_info *pi_template); | 36 | const struct ata_port_info *pi_template, |
37 | struct scsi_host_template *sht); | ||
34 | 38 | ||
35 | int ahci_platform_suspend_host(struct device *dev); | 39 | int ahci_platform_suspend_host(struct device *dev); |
36 | int ahci_platform_resume_host(struct device *dev); | 40 | int ahci_platform_resume_host(struct device *dev); |
diff --git a/include/linux/ata.h b/include/linux/ata.h index f2f4d8da97c0..1648026e06b4 100644 --- a/include/linux/ata.h +++ b/include/linux/ata.h | |||
@@ -503,7 +503,7 @@ struct ata_bmdma_prd { | |||
503 | #define ata_id_has_dma(id) ((id)[ATA_ID_CAPABILITY] & (1 << 8)) | 503 | #define ata_id_has_dma(id) ((id)[ATA_ID_CAPABILITY] & (1 << 8)) |
504 | #define ata_id_has_ncq(id) ((id)[ATA_ID_SATA_CAPABILITY] & (1 << 8)) | 504 | #define ata_id_has_ncq(id) ((id)[ATA_ID_SATA_CAPABILITY] & (1 << 8)) |
505 | #define ata_id_queue_depth(id) (((id)[ATA_ID_QUEUE_DEPTH] & 0x1f) + 1) | 505 | #define ata_id_queue_depth(id) (((id)[ATA_ID_QUEUE_DEPTH] & 0x1f) + 1) |
506 | #define ata_id_removeable(id) ((id)[ATA_ID_CONFIG] & (1 << 7)) | 506 | #define ata_id_removable(id) ((id)[ATA_ID_CONFIG] & (1 << 7)) |
507 | #define ata_id_has_atapi_AN(id) \ | 507 | #define ata_id_has_atapi_AN(id) \ |
508 | ((((id)[ATA_ID_SATA_CAPABILITY] != 0x0000) && \ | 508 | ((((id)[ATA_ID_SATA_CAPABILITY] != 0x0000) && \ |
509 | ((id)[ATA_ID_SATA_CAPABILITY] != 0xffff)) && \ | 509 | ((id)[ATA_ID_SATA_CAPABILITY] != 0xffff)) && \ |
diff --git a/include/linux/ata_platform.h b/include/linux/ata_platform.h index 5c618a084225..619d9e78e644 100644 --- a/include/linux/ata_platform.h +++ b/include/linux/ata_platform.h | |||
@@ -10,12 +10,15 @@ struct pata_platform_info { | |||
10 | unsigned int ioport_shift; | 10 | unsigned int ioport_shift; |
11 | }; | 11 | }; |
12 | 12 | ||
13 | struct scsi_host_template; | ||
14 | |||
13 | extern int __pata_platform_probe(struct device *dev, | 15 | extern int __pata_platform_probe(struct device *dev, |
14 | struct resource *io_res, | 16 | struct resource *io_res, |
15 | struct resource *ctl_res, | 17 | struct resource *ctl_res, |
16 | struct resource *irq_res, | 18 | struct resource *irq_res, |
17 | unsigned int ioport_shift, | 19 | unsigned int ioport_shift, |
18 | int __pio_mask); | 20 | int __pio_mask, |
21 | struct scsi_host_template *sht); | ||
19 | 22 | ||
20 | /* | 23 | /* |
21 | * Marvell SATA private data | 24 | * Marvell SATA private data |
diff --git a/include/linux/libata.h b/include/linux/libata.h index 91f705de2c0b..61df823ac86a 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h | |||
@@ -1340,6 +1340,12 @@ extern const struct ata_port_operations ata_base_port_ops; | |||
1340 | extern const struct ata_port_operations sata_port_ops; | 1340 | extern const struct ata_port_operations sata_port_ops; |
1341 | extern struct device_attribute *ata_common_sdev_attrs[]; | 1341 | extern struct device_attribute *ata_common_sdev_attrs[]; |
1342 | 1342 | ||
1343 | /* | ||
1344 | * All sht initializers (BASE, PIO, BMDMA, NCQ) must be instantiated | ||
1345 | * by the edge drivers. Because the 'module' field of sht must be the | ||
1346 | * edge driver's module reference, otherwise the driver can be unloaded | ||
1347 | * even if the scsi_device is being accessed. | ||
1348 | */ | ||
1343 | #define ATA_BASE_SHT(drv_name) \ | 1349 | #define ATA_BASE_SHT(drv_name) \ |
1344 | .module = THIS_MODULE, \ | 1350 | .module = THIS_MODULE, \ |
1345 | .name = drv_name, \ | 1351 | .name = drv_name, \ |