diff mbox series

[v3,2/6] mmc: meson-gx: enable input clocks

Message ID 20200305111240.129010-3-jbrunet@baylibre.com
State Accepted, archived
Commit 0392416fb1f2d8ff91ca6ec0471fc891445406e5
Delegated to: Neil Armstrong
Headers show
Series arm64: meson: add libretech-pc support | expand

Commit Message

Jerome Brunet March 5, 2020, 11:12 a.m. UTC
Until now, the mmc clock was left in a good enough state by the ROM
code to be used by the controller. However on some SoC, if the ROM
code finds a bootloader on USB or SPI, it might leave the MMC clock
in state the controller cannot work with.

Enable the input clocks provided to the mmc controller. While the
u-boot mmc controller driver is not doing fancy settings like the Linux,
it at least needs to make these clocks are running.

Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
---
 drivers/mmc/meson_gx_mmc.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

Comments

Anand Moon March 5, 2020, 12:15 p.m. UTC | #1
Hi Jerome,

On Thu, 5 Mar 2020 at 16:43, Jerome Brunet <jbrunet@baylibre.com> wrote:
>
> Until now, the mmc clock was left in a good enough state by the ROM
> code to be used by the controller. However on some SoC, if the ROM
> code finds a bootloader on USB or SPI, it might leave the MMC clock
> in state the controller cannot work with.
>
> Enable the input clocks provided to the mmc controller. While the
> u-boot mmc controller driver is not doing fancy settings like the Linux,
> it at least needs to make these clocks are running.
>

Please add my
Reviewed-by: Anand Moon <linux.amoon@gmail.com>

-Anand

> Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>
> Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
> ---
>  drivers/mmc/meson_gx_mmc.c | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/meson_gx_mmc.c b/drivers/mmc/meson_gx_mmc.c
> index b5f5122b1b7b..86c1a7164a93 100644
> --- a/drivers/mmc/meson_gx_mmc.c
> +++ b/drivers/mmc/meson_gx_mmc.c
> @@ -4,6 +4,7 @@
>   */
>
>  #include <common.h>
> +#include <clk.h>
>  #include <cpu_func.h>
>  #include <dm.h>
>  #include <fdtdec.h>
> @@ -241,12 +242,23 @@ static int meson_mmc_probe(struct udevice *dev)
>         struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
>         struct mmc *mmc = &pdata->mmc;
>         struct mmc_config *cfg = &pdata->cfg;
> +       struct clk_bulk clocks;
>         uint32_t val;
> +       int ret;
> +
>  #ifdef CONFIG_PWRSEQ
>         struct udevice *pwr_dev;
> -       int ret;
>  #endif
>
> +       /* Enable the clocks feeding the MMC controller */
> +       ret = clk_get_bulk(dev, &clocks);
> +       if (ret)
> +               return ret;
> +
> +       ret = clk_enable_bulk(&clocks);
> +       if (ret)
> +               return ret;
> +
>         cfg->voltages = MMC_VDD_33_34 | MMC_VDD_32_33 |
>                         MMC_VDD_31_32 | MMC_VDD_165_195;
>         cfg->host_caps = MMC_MODE_8BIT | MMC_MODE_4BIT |
> --
> 2.24.1
>
diff mbox series

Patch

diff --git a/drivers/mmc/meson_gx_mmc.c b/drivers/mmc/meson_gx_mmc.c
index b5f5122b1b7b..86c1a7164a93 100644
--- a/drivers/mmc/meson_gx_mmc.c
+++ b/drivers/mmc/meson_gx_mmc.c
@@ -4,6 +4,7 @@ 
  */
 
 #include <common.h>
+#include <clk.h>
 #include <cpu_func.h>
 #include <dm.h>
 #include <fdtdec.h>
@@ -241,12 +242,23 @@  static int meson_mmc_probe(struct udevice *dev)
 	struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
 	struct mmc *mmc = &pdata->mmc;
 	struct mmc_config *cfg = &pdata->cfg;
+	struct clk_bulk clocks;
 	uint32_t val;
+	int ret;
+
 #ifdef CONFIG_PWRSEQ
 	struct udevice *pwr_dev;
-	int ret;
 #endif
 
+	/* Enable the clocks feeding the MMC controller */
+	ret = clk_get_bulk(dev, &clocks);
+	if (ret)
+		return ret;
+
+	ret = clk_enable_bulk(&clocks);
+	if (ret)
+		return ret;
+
 	cfg->voltages = MMC_VDD_33_34 | MMC_VDD_32_33 |
 			MMC_VDD_31_32 | MMC_VDD_165_195;
 	cfg->host_caps = MMC_MODE_8BIT | MMC_MODE_4BIT |