diff options
Diffstat (limited to 'drivers/ata/ahci_imx.c')
-rw-r--r-- | drivers/ata/ahci_imx.c | 333 |
1 files changed, 129 insertions, 204 deletions
diff --git a/drivers/ata/ahci_imx.c b/drivers/ata/ahci_imx.c index dd4d6f74d7bd..497c7abe1c7d 100644 --- a/drivers/ata/ahci_imx.c +++ b/drivers/ata/ahci_imx.c | |||
@@ -42,13 +42,7 @@ enum ahci_imx_type { | |||
42 | struct imx_ahci_priv { | 42 | struct imx_ahci_priv { |
43 | struct platform_device *ahci_pdev; | 43 | struct platform_device *ahci_pdev; |
44 | enum ahci_imx_type type; | 44 | enum ahci_imx_type type; |
45 | |||
46 | /* i.MX53 clock */ | ||
47 | struct clk *sata_gate_clk; | ||
48 | /* Common clock */ | ||
49 | struct clk *sata_ref_clk; | ||
50 | struct clk *ahb_clk; | 45 | struct clk *ahb_clk; |
51 | |||
52 | struct regmap *gpr; | 46 | struct regmap *gpr; |
53 | bool no_device; | 47 | bool no_device; |
54 | bool first_time; | 48 | bool first_time; |
@@ -58,28 +52,52 @@ static int ahci_imx_hotplug; | |||
58 | module_param_named(hotplug, ahci_imx_hotplug, int, 0644); | 52 | module_param_named(hotplug, ahci_imx_hotplug, int, 0644); |
59 | MODULE_PARM_DESC(hotplug, "AHCI IMX hot-plug support (0=Don't support, 1=support)"); | 53 | MODULE_PARM_DESC(hotplug, "AHCI IMX hot-plug support (0=Don't support, 1=support)"); |
60 | 54 | ||
61 | static int imx_sata_clock_enable(struct device *dev) | 55 | static void ahci_imx_host_stop(struct ata_host *host); |
56 | |||
57 | static int imx_sata_enable(struct ahci_host_priv *hpriv) | ||
62 | { | 58 | { |
63 | struct imx_ahci_priv *imxpriv = dev_get_drvdata(dev->parent); | 59 | struct imx_ahci_priv *imxpriv = hpriv->plat_data; |
64 | int ret; | 60 | int ret; |
65 | 61 | ||
66 | if (imxpriv->type == AHCI_IMX53) { | 62 | if (imxpriv->no_device) |
67 | ret = clk_prepare_enable(imxpriv->sata_gate_clk); | 63 | return 0; |
68 | if (ret < 0) { | 64 | |
69 | dev_err(dev, "prepare-enable sata_gate clock err:%d\n", | 65 | if (hpriv->target_pwr) { |
70 | ret); | 66 | ret = regulator_enable(hpriv->target_pwr); |
67 | if (ret) | ||
71 | return ret; | 68 | return ret; |
72 | } | ||
73 | } | 69 | } |
74 | 70 | ||
75 | ret = clk_prepare_enable(imxpriv->sata_ref_clk); | 71 | ret = ahci_platform_enable_clks(hpriv); |
76 | if (ret < 0) { | 72 | if (ret < 0) |
77 | dev_err(dev, "prepare-enable sata_ref clock err:%d\n", | 73 | goto disable_regulator; |
78 | ret); | ||
79 | goto clk_err; | ||
80 | } | ||
81 | 74 | ||
82 | if (imxpriv->type == AHCI_IMX6Q) { | 75 | if (imxpriv->type == AHCI_IMX6Q) { |
76 | /* | ||
77 | * set PHY Paremeters, two steps to configure the GPR13, | ||
78 | * one write for rest of parameters, mask of first write | ||
79 | * is 0x07ffffff, and the other one write for setting | ||
80 | * the mpll_clk_en. | ||
81 | */ | ||
82 | regmap_update_bits(imxpriv->gpr, IOMUXC_GPR13, | ||
83 | IMX6Q_GPR13_SATA_RX_EQ_VAL_MASK | | ||
84 | IMX6Q_GPR13_SATA_RX_LOS_LVL_MASK | | ||
85 | IMX6Q_GPR13_SATA_RX_DPLL_MODE_MASK | | ||
86 | IMX6Q_GPR13_SATA_SPD_MODE_MASK | | ||
87 | IMX6Q_GPR13_SATA_MPLL_SS_EN | | ||
88 | IMX6Q_GPR13_SATA_TX_ATTEN_MASK | | ||
89 | IMX6Q_GPR13_SATA_TX_BOOST_MASK | | ||
90 | IMX6Q_GPR13_SATA_TX_LVL_MASK | | ||
91 | IMX6Q_GPR13_SATA_MPLL_CLK_EN | | ||
92 | IMX6Q_GPR13_SATA_TX_EDGE_RATE, | ||
93 | IMX6Q_GPR13_SATA_RX_EQ_VAL_3_0_DB | | ||
94 | IMX6Q_GPR13_SATA_RX_LOS_LVL_SATA2M | | ||
95 | IMX6Q_GPR13_SATA_RX_DPLL_MODE_2P_4F | | ||
96 | IMX6Q_GPR13_SATA_SPD_MODE_3P0G | | ||
97 | IMX6Q_GPR13_SATA_MPLL_SS_EN | | ||
98 | IMX6Q_GPR13_SATA_TX_ATTEN_9_16 | | ||
99 | IMX6Q_GPR13_SATA_TX_BOOST_3_33_DB | | ||
100 | IMX6Q_GPR13_SATA_TX_LVL_1_025_V); | ||
83 | regmap_update_bits(imxpriv->gpr, IOMUXC_GPR13, | 101 | regmap_update_bits(imxpriv->gpr, IOMUXC_GPR13, |
84 | IMX6Q_GPR13_SATA_MPLL_CLK_EN, | 102 | IMX6Q_GPR13_SATA_MPLL_CLK_EN, |
85 | IMX6Q_GPR13_SATA_MPLL_CLK_EN); | 103 | IMX6Q_GPR13_SATA_MPLL_CLK_EN); |
@@ -89,15 +107,19 @@ static int imx_sata_clock_enable(struct device *dev) | |||
89 | 107 | ||
90 | return 0; | 108 | return 0; |
91 | 109 | ||
92 | clk_err: | 110 | disable_regulator: |
93 | if (imxpriv->type == AHCI_IMX53) | 111 | if (hpriv->target_pwr) |
94 | clk_disable_unprepare(imxpriv->sata_gate_clk); | 112 | regulator_disable(hpriv->target_pwr); |
113 | |||
95 | return ret; | 114 | return ret; |
96 | } | 115 | } |
97 | 116 | ||
98 | static void imx_sata_clock_disable(struct device *dev) | 117 | static void imx_sata_disable(struct ahci_host_priv *hpriv) |
99 | { | 118 | { |
100 | struct imx_ahci_priv *imxpriv = dev_get_drvdata(dev->parent); | 119 | struct imx_ahci_priv *imxpriv = hpriv->plat_data; |
120 | |||
121 | if (imxpriv->no_device) | ||
122 | return; | ||
101 | 123 | ||
102 | if (imxpriv->type == AHCI_IMX6Q) { | 124 | if (imxpriv->type == AHCI_IMX6Q) { |
103 | regmap_update_bits(imxpriv->gpr, IOMUXC_GPR13, | 125 | regmap_update_bits(imxpriv->gpr, IOMUXC_GPR13, |
@@ -105,10 +127,10 @@ static void imx_sata_clock_disable(struct device *dev) | |||
105 | !IMX6Q_GPR13_SATA_MPLL_CLK_EN); | 127 | !IMX6Q_GPR13_SATA_MPLL_CLK_EN); |
106 | } | 128 | } |
107 | 129 | ||
108 | clk_disable_unprepare(imxpriv->sata_ref_clk); | 130 | ahci_platform_disable_clks(hpriv); |
109 | 131 | ||
110 | if (imxpriv->type == AHCI_IMX53) | 132 | if (hpriv->target_pwr) |
111 | clk_disable_unprepare(imxpriv->sata_gate_clk); | 133 | regulator_disable(hpriv->target_pwr); |
112 | } | 134 | } |
113 | 135 | ||
114 | static void ahci_imx_error_handler(struct ata_port *ap) | 136 | static void ahci_imx_error_handler(struct ata_port *ap) |
@@ -118,7 +140,7 @@ static void ahci_imx_error_handler(struct ata_port *ap) | |||
118 | struct ata_host *host = dev_get_drvdata(ap->dev); | 140 | struct ata_host *host = dev_get_drvdata(ap->dev); |
119 | struct ahci_host_priv *hpriv = host->private_data; | 141 | struct ahci_host_priv *hpriv = host->private_data; |
120 | void __iomem *mmio = hpriv->mmio; | 142 | void __iomem *mmio = hpriv->mmio; |
121 | struct imx_ahci_priv *imxpriv = dev_get_drvdata(ap->dev->parent); | 143 | struct imx_ahci_priv *imxpriv = hpriv->plat_data; |
122 | 144 | ||
123 | ahci_error_handler(ap); | 145 | ahci_error_handler(ap); |
124 | 146 | ||
@@ -136,7 +158,7 @@ static void ahci_imx_error_handler(struct ata_port *ap) | |||
136 | */ | 158 | */ |
137 | reg_val = readl(mmio + PORT_PHY_CTL); | 159 | reg_val = readl(mmio + PORT_PHY_CTL); |
138 | writel(reg_val | PORT_PHY_CTL_PDDQ_LOC, mmio + PORT_PHY_CTL); | 160 | writel(reg_val | PORT_PHY_CTL_PDDQ_LOC, mmio + PORT_PHY_CTL); |
139 | imx_sata_clock_disable(ap->dev); | 161 | imx_sata_disable(hpriv); |
140 | imxpriv->no_device = true; | 162 | imxpriv->no_device = true; |
141 | } | 163 | } |
142 | 164 | ||
@@ -144,7 +166,9 @@ static int ahci_imx_softreset(struct ata_link *link, unsigned int *class, | |||
144 | unsigned long deadline) | 166 | unsigned long deadline) |
145 | { | 167 | { |
146 | struct ata_port *ap = link->ap; | 168 | struct ata_port *ap = link->ap; |
147 | struct imx_ahci_priv *imxpriv = dev_get_drvdata(ap->dev->parent); | 169 | struct ata_host *host = dev_get_drvdata(ap->dev); |
170 | struct ahci_host_priv *hpriv = host->private_data; | ||
171 | struct imx_ahci_priv *imxpriv = hpriv->plat_data; | ||
148 | int ret = -EIO; | 172 | int ret = -EIO; |
149 | 173 | ||
150 | if (imxpriv->type == AHCI_IMX53) | 174 | if (imxpriv->type == AHCI_IMX53) |
@@ -156,7 +180,8 @@ static int ahci_imx_softreset(struct ata_link *link, unsigned int *class, | |||
156 | } | 180 | } |
157 | 181 | ||
158 | static struct ata_port_operations ahci_imx_ops = { | 182 | static struct ata_port_operations ahci_imx_ops = { |
159 | .inherits = &ahci_platform_ops, | 183 | .inherits = &ahci_ops, |
184 | .host_stop = ahci_imx_host_stop, | ||
160 | .error_handler = ahci_imx_error_handler, | 185 | .error_handler = ahci_imx_error_handler, |
161 | .softreset = ahci_imx_softreset, | 186 | .softreset = ahci_imx_softreset, |
162 | }; | 187 | }; |
@@ -168,79 +193,6 @@ static const struct ata_port_info ahci_imx_port_info = { | |||
168 | .port_ops = &ahci_imx_ops, | 193 | .port_ops = &ahci_imx_ops, |
169 | }; | 194 | }; |
170 | 195 | ||
171 | static int imx_sata_init(struct device *dev, void __iomem *mmio) | ||
172 | { | ||
173 | int ret = 0; | ||
174 | unsigned int reg_val; | ||
175 | struct imx_ahci_priv *imxpriv = dev_get_drvdata(dev->parent); | ||
176 | |||
177 | ret = imx_sata_clock_enable(dev); | ||
178 | if (ret < 0) | ||
179 | return ret; | ||
180 | |||
181 | /* | ||
182 | * Configure the HWINIT bits of the HOST_CAP and HOST_PORTS_IMPL, | ||
183 | * and IP vendor specific register HOST_TIMER1MS. | ||
184 | * Configure CAP_SSS (support stagered spin up). | ||
185 | * Implement the port0. | ||
186 | * Get the ahb clock rate, and configure the TIMER1MS register. | ||
187 | */ | ||
188 | reg_val = readl(mmio + HOST_CAP); | ||
189 | if (!(reg_val & HOST_CAP_SSS)) { | ||
190 | reg_val |= HOST_CAP_SSS; | ||
191 | writel(reg_val, mmio + HOST_CAP); | ||
192 | } | ||
193 | reg_val = readl(mmio + HOST_PORTS_IMPL); | ||
194 | if (!(reg_val & 0x1)) { | ||
195 | reg_val |= 0x1; | ||
196 | writel(reg_val, mmio + HOST_PORTS_IMPL); | ||
197 | } | ||
198 | |||
199 | reg_val = clk_get_rate(imxpriv->ahb_clk) / 1000; | ||
200 | writel(reg_val, mmio + HOST_TIMER1MS); | ||
201 | |||
202 | return 0; | ||
203 | } | ||
204 | |||
205 | static void imx_sata_exit(struct device *dev) | ||
206 | { | ||
207 | imx_sata_clock_disable(dev); | ||
208 | } | ||
209 | |||
210 | static int imx_ahci_suspend(struct device *dev) | ||
211 | { | ||
212 | struct imx_ahci_priv *imxpriv = dev_get_drvdata(dev->parent); | ||
213 | |||
214 | /* | ||
215 | * If no_device is set, The CLKs had been gated off in the | ||
216 | * initialization so don't do it again here. | ||
217 | */ | ||
218 | if (!imxpriv->no_device) | ||
219 | imx_sata_clock_disable(dev); | ||
220 | |||
221 | return 0; | ||
222 | } | ||
223 | |||
224 | static int imx_ahci_resume(struct device *dev) | ||
225 | { | ||
226 | struct imx_ahci_priv *imxpriv = dev_get_drvdata(dev->parent); | ||
227 | int ret = 0; | ||
228 | |||
229 | if (!imxpriv->no_device) | ||
230 | ret = imx_sata_clock_enable(dev); | ||
231 | |||
232 | return ret; | ||
233 | } | ||
234 | |||
235 | static struct ahci_platform_data imx_sata_pdata = { | ||
236 | .init = imx_sata_init, | ||
237 | .exit = imx_sata_exit, | ||
238 | .ata_port_info = &ahci_imx_port_info, | ||
239 | .suspend = imx_ahci_suspend, | ||
240 | .resume = imx_ahci_resume, | ||
241 | |||
242 | }; | ||
243 | |||
244 | static const struct of_device_id imx_ahci_of_match[] = { | 196 | static const struct of_device_id imx_ahci_of_match[] = { |
245 | { .compatible = "fsl,imx53-ahci", .data = (void *)AHCI_IMX53 }, | 197 | { .compatible = "fsl,imx53-ahci", .data = (void *)AHCI_IMX53 }, |
246 | { .compatible = "fsl,imx6q-ahci", .data = (void *)AHCI_IMX6Q }, | 198 | { .compatible = "fsl,imx6q-ahci", .data = (void *)AHCI_IMX6Q }, |
@@ -251,151 +203,124 @@ MODULE_DEVICE_TABLE(of, imx_ahci_of_match); | |||
251 | static int imx_ahci_probe(struct platform_device *pdev) | 203 | static int imx_ahci_probe(struct platform_device *pdev) |
252 | { | 204 | { |
253 | struct device *dev = &pdev->dev; | 205 | struct device *dev = &pdev->dev; |
254 | struct resource *mem, *irq, res[2]; | ||
255 | const struct of_device_id *of_id; | 206 | const struct of_device_id *of_id; |
256 | enum ahci_imx_type type; | 207 | struct ahci_host_priv *hpriv; |
257 | const struct ahci_platform_data *pdata = NULL; | ||
258 | struct imx_ahci_priv *imxpriv; | 208 | struct imx_ahci_priv *imxpriv; |
259 | struct device *ahci_dev; | 209 | unsigned int reg_val; |
260 | struct platform_device *ahci_pdev; | ||
261 | int ret; | 210 | int ret; |
262 | 211 | ||
263 | of_id = of_match_device(imx_ahci_of_match, dev); | 212 | of_id = of_match_device(imx_ahci_of_match, dev); |
264 | if (!of_id) | 213 | if (!of_id) |
265 | return -EINVAL; | 214 | return -EINVAL; |
266 | 215 | ||
267 | type = (enum ahci_imx_type)of_id->data; | ||
268 | pdata = &imx_sata_pdata; | ||
269 | |||
270 | imxpriv = devm_kzalloc(dev, sizeof(*imxpriv), GFP_KERNEL); | 216 | imxpriv = devm_kzalloc(dev, sizeof(*imxpriv), GFP_KERNEL); |
271 | if (!imxpriv) { | 217 | if (!imxpriv) |
272 | dev_err(dev, "can't alloc ahci_host_priv\n"); | ||
273 | return -ENOMEM; | 218 | return -ENOMEM; |
274 | } | ||
275 | |||
276 | ahci_pdev = platform_device_alloc("ahci", -1); | ||
277 | if (!ahci_pdev) | ||
278 | return -ENODEV; | ||
279 | |||
280 | ahci_dev = &ahci_pdev->dev; | ||
281 | ahci_dev->parent = dev; | ||
282 | 219 | ||
283 | imxpriv->no_device = false; | 220 | imxpriv->no_device = false; |
284 | imxpriv->first_time = true; | 221 | imxpriv->first_time = true; |
285 | imxpriv->type = type; | 222 | imxpriv->type = (enum ahci_imx_type)of_id->data; |
286 | |||
287 | imxpriv->ahb_clk = devm_clk_get(dev, "ahb"); | 223 | imxpriv->ahb_clk = devm_clk_get(dev, "ahb"); |
288 | if (IS_ERR(imxpriv->ahb_clk)) { | 224 | if (IS_ERR(imxpriv->ahb_clk)) { |
289 | dev_err(dev, "can't get ahb clock.\n"); | 225 | dev_err(dev, "can't get ahb clock.\n"); |
290 | ret = PTR_ERR(imxpriv->ahb_clk); | 226 | return PTR_ERR(imxpriv->ahb_clk); |
291 | goto err_out; | ||
292 | } | 227 | } |
293 | 228 | ||
294 | if (type == AHCI_IMX53) { | 229 | if (imxpriv->type == AHCI_IMX6Q) { |
295 | imxpriv->sata_gate_clk = devm_clk_get(dev, "sata_gate"); | 230 | imxpriv->gpr = syscon_regmap_lookup_by_compatible( |
296 | if (IS_ERR(imxpriv->sata_gate_clk)) { | 231 | "fsl,imx6q-iomuxc-gpr"); |
297 | dev_err(dev, "can't get sata_gate clock.\n"); | 232 | if (IS_ERR(imxpriv->gpr)) { |
298 | ret = PTR_ERR(imxpriv->sata_gate_clk); | 233 | dev_err(dev, |
299 | goto err_out; | 234 | "failed to find fsl,imx6q-iomux-gpr regmap\n"); |
235 | return PTR_ERR(imxpriv->gpr); | ||
300 | } | 236 | } |
301 | } | 237 | } |
302 | 238 | ||
303 | imxpriv->sata_ref_clk = devm_clk_get(dev, "sata_ref"); | 239 | hpriv = ahci_platform_get_resources(pdev); |
304 | if (IS_ERR(imxpriv->sata_ref_clk)) { | 240 | if (IS_ERR(hpriv)) |
305 | dev_err(dev, "can't get sata_ref clock.\n"); | 241 | return PTR_ERR(hpriv); |
306 | ret = PTR_ERR(imxpriv->sata_ref_clk); | 242 | |
307 | goto err_out; | 243 | hpriv->plat_data = imxpriv; |
308 | } | ||
309 | 244 | ||
310 | imxpriv->ahci_pdev = ahci_pdev; | 245 | ret = imx_sata_enable(hpriv); |
311 | platform_set_drvdata(pdev, imxpriv); | 246 | if (ret) |
247 | return ret; | ||
312 | 248 | ||
313 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 249 | /* |
314 | irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); | 250 | * Configure the HWINIT bits of the HOST_CAP and HOST_PORTS_IMPL, |
315 | if (!mem || !irq) { | 251 | * and IP vendor specific register HOST_TIMER1MS. |
316 | dev_err(dev, "no mmio/irq resource\n"); | 252 | * Configure CAP_SSS (support stagered spin up). |
317 | ret = -ENOMEM; | 253 | * Implement the port0. |
318 | goto err_out; | 254 | * Get the ahb clock rate, and configure the TIMER1MS register. |
255 | */ | ||
256 | reg_val = readl(hpriv->mmio + HOST_CAP); | ||
257 | if (!(reg_val & HOST_CAP_SSS)) { | ||
258 | reg_val |= HOST_CAP_SSS; | ||
259 | writel(reg_val, hpriv->mmio + HOST_CAP); | ||
260 | } | ||
261 | reg_val = readl(hpriv->mmio + HOST_PORTS_IMPL); | ||
262 | if (!(reg_val & 0x1)) { | ||
263 | reg_val |= 0x1; | ||
264 | writel(reg_val, hpriv->mmio + HOST_PORTS_IMPL); | ||
319 | } | 265 | } |
320 | 266 | ||
321 | res[0] = *mem; | 267 | reg_val = clk_get_rate(imxpriv->ahb_clk) / 1000; |
322 | res[1] = *irq; | 268 | writel(reg_val, hpriv->mmio + HOST_TIMER1MS); |
323 | 269 | ||
324 | ahci_dev->coherent_dma_mask = DMA_BIT_MASK(32); | 270 | ret = ahci_platform_init_host(pdev, hpriv, &ahci_imx_port_info, 0, 0); |
325 | ahci_dev->dma_mask = &ahci_dev->coherent_dma_mask; | 271 | if (ret) |
326 | ahci_dev->of_node = dev->of_node; | 272 | imx_sata_disable(hpriv); |
327 | 273 | ||
328 | if (type == AHCI_IMX6Q) { | 274 | return ret; |
329 | imxpriv->gpr = syscon_regmap_lookup_by_compatible( | 275 | } |
330 | "fsl,imx6q-iomuxc-gpr"); | ||
331 | if (IS_ERR(imxpriv->gpr)) { | ||
332 | dev_err(dev, | ||
333 | "failed to find fsl,imx6q-iomux-gpr regmap\n"); | ||
334 | ret = PTR_ERR(imxpriv->gpr); | ||
335 | goto err_out; | ||
336 | } | ||
337 | 276 | ||
338 | /* | 277 | static void ahci_imx_host_stop(struct ata_host *host) |
339 | * Set PHY Paremeters, two steps to configure the GPR13, | 278 | { |
340 | * one write for rest of parameters, mask of first write | 279 | struct ahci_host_priv *hpriv = host->private_data; |
341 | * is 0x07fffffe, and the other one write for setting | ||
342 | * the mpll_clk_en happens in imx_sata_clock_enable(). | ||
343 | */ | ||
344 | regmap_update_bits(imxpriv->gpr, IOMUXC_GPR13, | ||
345 | IMX6Q_GPR13_SATA_RX_EQ_VAL_MASK | | ||
346 | IMX6Q_GPR13_SATA_RX_LOS_LVL_MASK | | ||
347 | IMX6Q_GPR13_SATA_RX_DPLL_MODE_MASK | | ||
348 | IMX6Q_GPR13_SATA_SPD_MODE_MASK | | ||
349 | IMX6Q_GPR13_SATA_MPLL_SS_EN | | ||
350 | IMX6Q_GPR13_SATA_TX_ATTEN_MASK | | ||
351 | IMX6Q_GPR13_SATA_TX_BOOST_MASK | | ||
352 | IMX6Q_GPR13_SATA_TX_LVL_MASK | | ||
353 | IMX6Q_GPR13_SATA_MPLL_CLK_EN | | ||
354 | IMX6Q_GPR13_SATA_TX_EDGE_RATE, | ||
355 | IMX6Q_GPR13_SATA_RX_EQ_VAL_3_0_DB | | ||
356 | IMX6Q_GPR13_SATA_RX_LOS_LVL_SATA2M | | ||
357 | IMX6Q_GPR13_SATA_RX_DPLL_MODE_2P_4F | | ||
358 | IMX6Q_GPR13_SATA_SPD_MODE_3P0G | | ||
359 | IMX6Q_GPR13_SATA_MPLL_SS_EN | | ||
360 | IMX6Q_GPR13_SATA_TX_ATTEN_9_16 | | ||
361 | IMX6Q_GPR13_SATA_TX_BOOST_3_33_DB | | ||
362 | IMX6Q_GPR13_SATA_TX_LVL_1_025_V); | ||
363 | } | ||
364 | 280 | ||
365 | ret = platform_device_add_resources(ahci_pdev, res, 2); | 281 | imx_sata_disable(hpriv); |
366 | if (ret) | 282 | } |
367 | goto err_out; | ||
368 | 283 | ||
369 | ret = platform_device_add_data(ahci_pdev, pdata, sizeof(*pdata)); | 284 | #ifdef CONFIG_PM_SLEEP |
370 | if (ret) | 285 | static int imx_ahci_suspend(struct device *dev) |
371 | goto err_out; | 286 | { |
287 | struct ata_host *host = dev_get_drvdata(dev); | ||
288 | struct ahci_host_priv *hpriv = host->private_data; | ||
289 | int ret; | ||
372 | 290 | ||
373 | ret = platform_device_add(ahci_pdev); | 291 | ret = ahci_platform_suspend_host(dev); |
374 | if (ret) { | 292 | if (ret) |
375 | err_out: | ||
376 | platform_device_put(ahci_pdev); | ||
377 | return ret; | 293 | return ret; |
378 | } | 294 | |
295 | imx_sata_disable(hpriv); | ||
379 | 296 | ||
380 | return 0; | 297 | return 0; |
381 | } | 298 | } |
382 | 299 | ||
383 | static int imx_ahci_remove(struct platform_device *pdev) | 300 | static int imx_ahci_resume(struct device *dev) |
384 | { | 301 | { |
385 | struct imx_ahci_priv *imxpriv = platform_get_drvdata(pdev); | 302 | struct ata_host *host = dev_get_drvdata(dev); |
386 | struct platform_device *ahci_pdev = imxpriv->ahci_pdev; | 303 | struct ahci_host_priv *hpriv = host->private_data; |
304 | int ret; | ||
387 | 305 | ||
388 | platform_device_unregister(ahci_pdev); | 306 | ret = imx_sata_enable(hpriv); |
389 | return 0; | 307 | if (ret) |
308 | return ret; | ||
309 | |||
310 | return ahci_platform_resume_host(dev); | ||
390 | } | 311 | } |
312 | #endif | ||
313 | |||
314 | static SIMPLE_DEV_PM_OPS(ahci_imx_pm_ops, imx_ahci_suspend, imx_ahci_resume); | ||
391 | 315 | ||
392 | static struct platform_driver imx_ahci_driver = { | 316 | static struct platform_driver imx_ahci_driver = { |
393 | .probe = imx_ahci_probe, | 317 | .probe = imx_ahci_probe, |
394 | .remove = imx_ahci_remove, | 318 | .remove = ata_platform_remove_one, |
395 | .driver = { | 319 | .driver = { |
396 | .name = "ahci-imx", | 320 | .name = "ahci-imx", |
397 | .owner = THIS_MODULE, | 321 | .owner = THIS_MODULE, |
398 | .of_match_table = imx_ahci_of_match, | 322 | .of_match_table = imx_ahci_of_match, |
323 | .pm = &ahci_imx_pm_ops, | ||
399 | }, | 324 | }, |
400 | }; | 325 | }; |
401 | module_platform_driver(imx_ahci_driver); | 326 | module_platform_driver(imx_ahci_driver); |