[PATCH 3/7] mmc: msm_sdhci: handle bulk clock initialization error
neil.armstrong at linaro.org
neil.armstrong at linaro.org
Mon Apr 7 11:02:54 CEST 2025
On 07/04/2025 10:19, Jorge Ramirez-Ortiz wrote:
> Some boards do not require all clocks to be available (i.e:
> dragonboard820c).
Can you specify which clock isn't available ? Because we have clk-stub for that
Thanks,
Neil
>
> This change provides a fallback to the core clock when the bulk cant be
> retrived.
>
> Signed-off-by: Jorge Ramirez-Ortiz <jorge.ramirez at oss.qualcomm.com>
> ---
> drivers/mmc/msm_sdhci.c | 27 +++++++++++++++++++++++++--
> 1 file changed, 25 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mmc/msm_sdhci.c b/drivers/mmc/msm_sdhci.c
> index 27bb7052fca..8081330bd25 100644
> --- a/drivers/mmc/msm_sdhci.c
> +++ b/drivers/mmc/msm_sdhci.c
> @@ -9,6 +9,7 @@
>
> #include <clk.h>
> #include <dm.h>
> +#include <dm/devres.h>
> #include <malloc.h>
> #include <sdhci.h>
> #include <wait_bit.h>
> @@ -56,6 +57,17 @@ struct msm_sdhc_variant_info {
>
> DECLARE_GLOBAL_DATA_PTR;
>
> +static int get_core_clock(struct udevice *dev, struct clk_bulk *bulk)
> +{
> + bulk->count = 1;
> +
> + bulk->clks = devm_kcalloc(dev, 1, sizeof(struct clk), GFP_KERNEL);
> + if (!bulk->clks)
> + return -ENOMEM;
> +
> + return clk_get_by_name(dev, "core", &bulk->clks[0]);
> +}
> +
> static int msm_sdc_clk_init(struct udevice *dev)
> {
> struct msm_sdhc *prv = dev_get_priv(dev);
> @@ -73,8 +85,15 @@ static int msm_sdc_clk_init(struct udevice *dev)
>
> ret = clk_get_bulk(dev, &prv->clks);
> if (ret) {
> - log_warning("Couldn't get mmc clocks: %d\n", ret);
> - return ret;
> + log_warning("Bulk clocks not available (%d), trying core clock\n", ret);
> +
> + /* Sometimes not all clocks are needed - chainloading uboot */
> + ret = get_core_clock(dev, &prv->clks);
> + if (ret) {
> + log_warning("Core clock not available:(%d)\n", ret);
> + return ret;
> + }
> + n_clks = 1;
> }
>
> ret = clk_enable_bulk(&prv->clks);
> @@ -83,6 +102,9 @@ static int msm_sdc_clk_init(struct udevice *dev)
> return ret;
> }
>
> + if (n_clks == 1)
> + goto set_rate;
> +
> /* If clock-names is unspecified, then the first clock is the core clock */
> if (!ofnode_get_property(node, "clock-names", &n_clks)) {
> if (!clk_set_rate(&prv->clks.clks[0], clk_rate)) {
> @@ -105,6 +127,7 @@ static int msm_sdc_clk_init(struct udevice *dev)
> return -EINVAL;
> }
>
> +set_rate:
> /* The clock is already enabled by the clk_bulk above */
> clk_rate = clk_set_rate(&prv->clks.clks[i], clk_rate);
> /* If we get a rate of 0 then something has probably gone wrong. */
More information about the U-Boot
mailing list