diff options
-rw-r--r-- | drivers/ata/ahci_imx.c | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/drivers/ata/ahci_imx.c b/drivers/ata/ahci_imx.c index 3a901520c62b..4384a7d72133 100644 --- a/drivers/ata/ahci_imx.c +++ b/drivers/ata/ahci_imx.c | |||
@@ -58,6 +58,8 @@ enum ahci_imx_type { | |||
58 | struct imx_ahci_priv { | 58 | struct imx_ahci_priv { |
59 | struct platform_device *ahci_pdev; | 59 | struct platform_device *ahci_pdev; |
60 | enum ahci_imx_type type; | 60 | enum ahci_imx_type type; |
61 | struct clk *sata_clk; | ||
62 | struct clk *sata_ref_clk; | ||
61 | struct clk *ahb_clk; | 63 | struct clk *ahb_clk; |
62 | struct regmap *gpr; | 64 | struct regmap *gpr; |
63 | bool no_device; | 65 | bool no_device; |
@@ -224,7 +226,7 @@ static int imx_sata_enable(struct ahci_host_priv *hpriv) | |||
224 | return ret; | 226 | return ret; |
225 | } | 227 | } |
226 | 228 | ||
227 | ret = ahci_platform_enable_clks(hpriv); | 229 | ret = clk_prepare_enable(imxpriv->sata_ref_clk); |
228 | if (ret < 0) | 230 | if (ret < 0) |
229 | goto disable_regulator; | 231 | goto disable_regulator; |
230 | 232 | ||
@@ -291,7 +293,7 @@ static void imx_sata_disable(struct ahci_host_priv *hpriv) | |||
291 | !IMX6Q_GPR13_SATA_MPLL_CLK_EN); | 293 | !IMX6Q_GPR13_SATA_MPLL_CLK_EN); |
292 | } | 294 | } |
293 | 295 | ||
294 | ahci_platform_disable_clks(hpriv); | 296 | clk_disable_unprepare(imxpriv->sata_ref_clk); |
295 | 297 | ||
296 | if (hpriv->target_pwr) | 298 | if (hpriv->target_pwr) |
297 | regulator_disable(hpriv->target_pwr); | 299 | regulator_disable(hpriv->target_pwr); |
@@ -385,6 +387,19 @@ static int imx_ahci_probe(struct platform_device *pdev) | |||
385 | imxpriv->no_device = false; | 387 | imxpriv->no_device = false; |
386 | imxpriv->first_time = true; | 388 | imxpriv->first_time = true; |
387 | imxpriv->type = (enum ahci_imx_type)of_id->data; | 389 | imxpriv->type = (enum ahci_imx_type)of_id->data; |
390 | |||
391 | imxpriv->sata_clk = devm_clk_get(dev, "sata"); | ||
392 | if (IS_ERR(imxpriv->sata_clk)) { | ||
393 | dev_err(dev, "can't get sata clock.\n"); | ||
394 | return PTR_ERR(imxpriv->sata_clk); | ||
395 | } | ||
396 | |||
397 | imxpriv->sata_ref_clk = devm_clk_get(dev, "sata_ref"); | ||
398 | if (IS_ERR(imxpriv->sata_ref_clk)) { | ||
399 | dev_err(dev, "can't get sata_ref clock.\n"); | ||
400 | return PTR_ERR(imxpriv->sata_ref_clk); | ||
401 | } | ||
402 | |||
388 | imxpriv->ahb_clk = devm_clk_get(dev, "ahb"); | 403 | imxpriv->ahb_clk = devm_clk_get(dev, "ahb"); |
389 | if (IS_ERR(imxpriv->ahb_clk)) { | 404 | if (IS_ERR(imxpriv->ahb_clk)) { |
390 | dev_err(dev, "can't get ahb clock.\n"); | 405 | dev_err(dev, "can't get ahb clock.\n"); |
@@ -407,10 +422,14 @@ static int imx_ahci_probe(struct platform_device *pdev) | |||
407 | 422 | ||
408 | hpriv->plat_data = imxpriv; | 423 | hpriv->plat_data = imxpriv; |
409 | 424 | ||
410 | ret = imx_sata_enable(hpriv); | 425 | ret = clk_prepare_enable(imxpriv->sata_clk); |
411 | if (ret) | 426 | if (ret) |
412 | return ret; | 427 | return ret; |
413 | 428 | ||
429 | ret = imx_sata_enable(hpriv); | ||
430 | if (ret) | ||
431 | goto disable_clk; | ||
432 | |||
414 | /* | 433 | /* |
415 | * Configure the HWINIT bits of the HOST_CAP and HOST_PORTS_IMPL, | 434 | * Configure the HWINIT bits of the HOST_CAP and HOST_PORTS_IMPL, |
416 | * and IP vendor specific register IMX_TIMER1MS. | 435 | * and IP vendor specific register IMX_TIMER1MS. |
@@ -435,16 +454,24 @@ static int imx_ahci_probe(struct platform_device *pdev) | |||
435 | ret = ahci_platform_init_host(pdev, hpriv, &ahci_imx_port_info, | 454 | ret = ahci_platform_init_host(pdev, hpriv, &ahci_imx_port_info, |
436 | 0, 0, 0); | 455 | 0, 0, 0); |
437 | if (ret) | 456 | if (ret) |
438 | imx_sata_disable(hpriv); | 457 | goto disable_sata; |
458 | |||
459 | return 0; | ||
439 | 460 | ||
461 | disable_sata: | ||
462 | imx_sata_disable(hpriv); | ||
463 | disable_clk: | ||
464 | clk_disable_unprepare(imxpriv->sata_clk); | ||
440 | return ret; | 465 | return ret; |
441 | } | 466 | } |
442 | 467 | ||
443 | static void ahci_imx_host_stop(struct ata_host *host) | 468 | static void ahci_imx_host_stop(struct ata_host *host) |
444 | { | 469 | { |
445 | struct ahci_host_priv *hpriv = host->private_data; | 470 | struct ahci_host_priv *hpriv = host->private_data; |
471 | struct imx_ahci_priv *imxpriv = hpriv->plat_data; | ||
446 | 472 | ||
447 | imx_sata_disable(hpriv); | 473 | imx_sata_disable(hpriv); |
474 | clk_disable_unprepare(imxpriv->sata_clk); | ||
448 | } | 475 | } |
449 | 476 | ||
450 | #ifdef CONFIG_PM_SLEEP | 477 | #ifdef CONFIG_PM_SLEEP |