diff mbox series

[1/4] mmc: tmio: move clk_enable() to each driver's probe function

Message ID 1524215667-32112-2-git-send-email-yamada.masahiro@socionext.com
State Accepted
Commit 30b5d9aa9aee9853b6b51d93ddf16d762d20c538
Headers show
Series ARM: uniphier: decrease the SPL image size to fix uniphier_v7_defconfig | expand

Commit Message

Masahiro Yamada April 20, 2018, 9:14 a.m. UTC
I need to differentiate the clock handling for uniphier-sd.  Move it
to each driver's probe function from the tmio common code so that
renesas-sdhi will not be affected.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 drivers/mmc/renesas-sdhi.c | 23 +++++++++++++++++++++++
 drivers/mmc/tmio-common.c  | 22 ----------------------
 drivers/mmc/uniphier-sd.c  | 25 +++++++++++++++++++++++++
 3 files changed, 48 insertions(+), 22 deletions(-)

Comments

Masahiro Yamada April 20, 2018, 9:23 a.m. UTC | #1
+CC Marek


2018-04-20 18:14 GMT+09:00 Masahiro Yamada <yamada.masahiro@socionext.com>:
> I need to differentiate the clock handling for uniphier-sd.  Move it
> to each driver's probe function from the tmio common code so that
> renesas-sdhi will not be affected.
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
>
>  drivers/mmc/renesas-sdhi.c | 23 +++++++++++++++++++++++
>  drivers/mmc/tmio-common.c  | 22 ----------------------
>  drivers/mmc/uniphier-sd.c  | 25 +++++++++++++++++++++++++
>  3 files changed, 48 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/mmc/renesas-sdhi.c b/drivers/mmc/renesas-sdhi.c
> index 56a43ca..8e49b2f 100644
> --- a/drivers/mmc/renesas-sdhi.c
> +++ b/drivers/mmc/renesas-sdhi.c
> @@ -330,8 +330,10 @@ static const struct udevice_id renesas_sdhi_match[] = {
>
>  static int renesas_sdhi_probe(struct udevice *dev)
>  {
> +       struct tmio_sd_priv *priv = dev_get_priv(dev);
>         u32 quirks = dev_get_driver_data(dev);
>         struct fdt_resource reg_res;
> +       struct clk clk;
>         DECLARE_GLOBAL_DATA_PTR;
>         int ret;
>
> @@ -348,6 +350,27 @@ static int renesas_sdhi_probe(struct udevice *dev)
>                         quirks |= TMIO_SD_CAP_16BIT;
>         }
>
> +       ret = clk_get_by_index(dev, 0, &clk);
> +       if (ret < 0) {
> +               dev_err(dev, "failed to get host clock\n");
> +               return ret;
> +       }
> +
> +       /* set to max rate */
> +       priv->mclk = clk_set_rate(&clk, ULONG_MAX);
> +       if (IS_ERR_VALUE(priv->mclk)) {
> +               dev_err(dev, "failed to set rate for host clock\n");
> +               clk_free(&clk);
> +               return priv->mclk;
> +       }
> +
> +       ret = clk_enable(&clk);
> +       clk_free(&clk);
> +       if (ret) {
> +               dev_err(dev, "failed to enable host clock\n");
> +               return ret;
> +       }
> +
>         ret = tmio_sd_probe(dev, quirks);
>  #if CONFIG_IS_ENABLED(MMC_HS200_SUPPORT)
>         if (!ret)
> diff --git a/drivers/mmc/tmio-common.c b/drivers/mmc/tmio-common.c
> index 5f1c9c0..4ea6612 100644
> --- a/drivers/mmc/tmio-common.c
> +++ b/drivers/mmc/tmio-common.c
> @@ -713,7 +713,6 @@ int tmio_sd_probe(struct udevice *dev, u32 quirks)
>         struct tmio_sd_priv *priv = dev_get_priv(dev);
>         struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
>         fdt_addr_t base;
> -       struct clk clk;
>         int ret;
>
>         base = devfdt_get_addr(dev);
> @@ -728,27 +727,6 @@ int tmio_sd_probe(struct udevice *dev, u32 quirks)
>         device_get_supply_regulator(dev, "vqmmc-supply", &priv->vqmmc_dev);
>  #endif
>
> -       ret = clk_get_by_index(dev, 0, &clk);
> -       if (ret < 0) {
> -               dev_err(dev, "failed to get host clock\n");
> -               return ret;
> -       }
> -
> -       /* set to max rate */
> -       priv->mclk = clk_set_rate(&clk, ULONG_MAX);
> -       if (IS_ERR_VALUE(priv->mclk)) {
> -               dev_err(dev, "failed to set rate for host clock\n");
> -               clk_free(&clk);
> -               return priv->mclk;
> -       }
> -
> -       ret = clk_enable(&clk);
> -       clk_free(&clk);
> -       if (ret) {
> -               dev_err(dev, "failed to enable host clock\n");
> -               return ret;
> -       }
> -
>         ret = mmc_of_parse(dev, &plat->cfg);
>         if (ret < 0) {
>                 dev_err(dev, "failed to parse host caps\n");
> diff --git a/drivers/mmc/uniphier-sd.c b/drivers/mmc/uniphier-sd.c
> index 47379b0..bc6e41d 100644
> --- a/drivers/mmc/uniphier-sd.c
> +++ b/drivers/mmc/uniphier-sd.c
> @@ -32,6 +32,31 @@ static const struct udevice_id uniphier_sd_match[] = {
>
>  static int uniphier_sd_probe(struct udevice *dev)
>  {
> +       struct tmio_sd_priv *priv = dev_get_priv(dev);
> +       struct clk clk;
> +       int ret;
> +
> +       ret = clk_get_by_index(dev, 0, &clk);
> +       if (ret < 0) {
> +               dev_err(dev, "failed to get host clock\n");
> +               return ret;
> +       }
> +
> +       /* set to max rate */
> +       priv->mclk = clk_set_rate(&clk, ULONG_MAX);
> +       if (IS_ERR_VALUE(priv->mclk)) {
> +               dev_err(dev, "failed to set rate for host clock\n");
> +               clk_free(&clk);
> +               return priv->mclk;
> +       }
> +
> +       ret = clk_enable(&clk);
> +       clk_free(&clk);
> +       if (ret) {
> +               dev_err(dev, "failed to enable host clock\n");
> +               return ret;
> +       }
> +
>         return tmio_sd_probe(dev, 0);
>  }
>
> --
> 2.7.4
>
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> https://lists.denx.de/listinfo/u-boot
diff mbox series

Patch

diff --git a/drivers/mmc/renesas-sdhi.c b/drivers/mmc/renesas-sdhi.c
index 56a43ca..8e49b2f 100644
--- a/drivers/mmc/renesas-sdhi.c
+++ b/drivers/mmc/renesas-sdhi.c
@@ -330,8 +330,10 @@  static const struct udevice_id renesas_sdhi_match[] = {
 
 static int renesas_sdhi_probe(struct udevice *dev)
 {
+	struct tmio_sd_priv *priv = dev_get_priv(dev);
 	u32 quirks = dev_get_driver_data(dev);
 	struct fdt_resource reg_res;
+	struct clk clk;
 	DECLARE_GLOBAL_DATA_PTR;
 	int ret;
 
@@ -348,6 +350,27 @@  static int renesas_sdhi_probe(struct udevice *dev)
 			quirks |= TMIO_SD_CAP_16BIT;
 	}
 
+	ret = clk_get_by_index(dev, 0, &clk);
+	if (ret < 0) {
+		dev_err(dev, "failed to get host clock\n");
+		return ret;
+	}
+
+	/* set to max rate */
+	priv->mclk = clk_set_rate(&clk, ULONG_MAX);
+	if (IS_ERR_VALUE(priv->mclk)) {
+		dev_err(dev, "failed to set rate for host clock\n");
+		clk_free(&clk);
+		return priv->mclk;
+	}
+
+	ret = clk_enable(&clk);
+	clk_free(&clk);
+	if (ret) {
+		dev_err(dev, "failed to enable host clock\n");
+		return ret;
+	}
+
 	ret = tmio_sd_probe(dev, quirks);
 #if CONFIG_IS_ENABLED(MMC_HS200_SUPPORT)
 	if (!ret)
diff --git a/drivers/mmc/tmio-common.c b/drivers/mmc/tmio-common.c
index 5f1c9c0..4ea6612 100644
--- a/drivers/mmc/tmio-common.c
+++ b/drivers/mmc/tmio-common.c
@@ -713,7 +713,6 @@  int tmio_sd_probe(struct udevice *dev, u32 quirks)
 	struct tmio_sd_priv *priv = dev_get_priv(dev);
 	struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
 	fdt_addr_t base;
-	struct clk clk;
 	int ret;
 
 	base = devfdt_get_addr(dev);
@@ -728,27 +727,6 @@  int tmio_sd_probe(struct udevice *dev, u32 quirks)
 	device_get_supply_regulator(dev, "vqmmc-supply", &priv->vqmmc_dev);
 #endif
 
-	ret = clk_get_by_index(dev, 0, &clk);
-	if (ret < 0) {
-		dev_err(dev, "failed to get host clock\n");
-		return ret;
-	}
-
-	/* set to max rate */
-	priv->mclk = clk_set_rate(&clk, ULONG_MAX);
-	if (IS_ERR_VALUE(priv->mclk)) {
-		dev_err(dev, "failed to set rate for host clock\n");
-		clk_free(&clk);
-		return priv->mclk;
-	}
-
-	ret = clk_enable(&clk);
-	clk_free(&clk);
-	if (ret) {
-		dev_err(dev, "failed to enable host clock\n");
-		return ret;
-	}
-
 	ret = mmc_of_parse(dev, &plat->cfg);
 	if (ret < 0) {
 		dev_err(dev, "failed to parse host caps\n");
diff --git a/drivers/mmc/uniphier-sd.c b/drivers/mmc/uniphier-sd.c
index 47379b0..bc6e41d 100644
--- a/drivers/mmc/uniphier-sd.c
+++ b/drivers/mmc/uniphier-sd.c
@@ -32,6 +32,31 @@  static const struct udevice_id uniphier_sd_match[] = {
 
 static int uniphier_sd_probe(struct udevice *dev)
 {
+	struct tmio_sd_priv *priv = dev_get_priv(dev);
+	struct clk clk;
+	int ret;
+
+	ret = clk_get_by_index(dev, 0, &clk);
+	if (ret < 0) {
+		dev_err(dev, "failed to get host clock\n");
+		return ret;
+	}
+
+	/* set to max rate */
+	priv->mclk = clk_set_rate(&clk, ULONG_MAX);
+	if (IS_ERR_VALUE(priv->mclk)) {
+		dev_err(dev, "failed to set rate for host clock\n");
+		clk_free(&clk);
+		return priv->mclk;
+	}
+
+	ret = clk_enable(&clk);
+	clk_free(&clk);
+	if (ret) {
+		dev_err(dev, "failed to enable host clock\n");
+		return ret;
+	}
+
 	return tmio_sd_probe(dev, 0);
 }