From 7dbec4f77c907c20c1ae707bfdd8ac356b0e0986 Mon Sep 17 00:00:00 2001 From: Julien Stephan Date: Thu, 15 Jan 2026 15:30:43 +0100 Subject: [PATCH 1/6] power: regulator: common: remove unnecessary debug trace Drop the ftrace like debug() that checkpatch --strict complains about: WARNING: Unnecessary ftrace-like logging - prefer using ftrace Reviewed-by: Peng Fan Reviewed-by: Tanmay Kathpalia Reviewed-by: Neil Armstrong Signed-off-by: Julien Stephan Signed-off-by: Peng Fan --- drivers/power/regulator/regulator_common.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/power/regulator/regulator_common.c b/drivers/power/regulator/regulator_common.c index 685d8735fa5..ce3d80670de 100644 --- a/drivers/power/regulator/regulator_common.c +++ b/drivers/power/regulator/regulator_common.c @@ -98,7 +98,6 @@ int regulator_common_set_enable(const struct udevice *dev, if (enable && plat->startup_delay_us) udelay(plat->startup_delay_us); - debug("%s: done\n", __func__); if (!enable && plat->off_on_delay_us) udelay(plat->off_on_delay_us); From 0411cac1616c5ac3223367e054f4e8eb3ad524bc Mon Sep 17 00:00:00 2001 From: Julien Stephan Date: Thu, 15 Jan 2026 15:30:44 +0100 Subject: [PATCH 2/6] power: regulator: common: use dm_gpio_is_valid helper Use dm_gpio_is_valid() helper function instead of manually checking the gpio. Reviewed-by: Peng Fan Reviewed-by: Tanmay Kathpalia Reviewed-by: Neil Armstrong Signed-off-by: Julien Stephan Signed-off-by: Peng Fan --- drivers/power/regulator/regulator_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/power/regulator/regulator_common.c b/drivers/power/regulator/regulator_common.c index ce3d80670de..cf98998579a 100644 --- a/drivers/power/regulator/regulator_common.c +++ b/drivers/power/regulator/regulator_common.c @@ -51,7 +51,7 @@ int regulator_common_get_enable(const struct udevice *dev, struct regulator_common_plat *plat) { /* Enable GPIO is optional */ - if (!plat->gpio.dev) + if (!dm_gpio_is_valid(&plat->gpio)) return true; return dm_gpio_get_value(&plat->gpio); From dab2c154f605b2f6742aa107dab2b55b9824fdf5 Mon Sep 17 00:00:00 2001 From: Julien Stephan Date: Thu, 15 Jan 2026 15:30:45 +0100 Subject: [PATCH 3/6] power: regulator: common: fix compilation issue If CONFIG_DM_GPIO is not enabled, compilation fails with the following errors: aarch64-none-linux-gnu-ld: drivers/power/regulator/regulator_common.o: in function `regulator_common_of_to_plat': <...>/u-boot/drivers/power/regulator/regulator_common.c:30: undefined reference to `gpio_request_by_name' aarch64-none-linux-gnu-ld: drivers/power/regulator/regulator_common.o: in function `regulator_common_get_enable': <...>/u-boot/drivers/power/regulator/regulator_common.c:57: undefined reference to `dm_gpio_get_value' aarch64-none-linux-gnu-ld: drivers/power/regulator/regulator_common.o: in function `regulator_common_set_enable': <...>/u-boot/drivers/power/regulator/regulator_common.c:92: undefined reference to `dm_gpio_set_value' make: *** [Makefile:2029: u-boot] Error 139 Since the enable gpio is optional we can conditionally skip these calls. Reviewed-by: Tanmay Kathpalia Reviewed-by: Peng Fan Signed-off-by: Julien Stephan Reviewed-by: Quentin Schulz Signed-off-by: Peng Fan --- drivers/power/regulator/regulator_common.c | 96 +++++++++++----------- 1 file changed, 49 insertions(+), 47 deletions(-) diff --git a/drivers/power/regulator/regulator_common.c b/drivers/power/regulator/regulator_common.c index cf98998579a..85af8d599ad 100644 --- a/drivers/power/regulator/regulator_common.c +++ b/drivers/power/regulator/regulator_common.c @@ -27,12 +27,14 @@ int regulator_common_of_to_plat(struct udevice *dev, /* Get optional enable GPIO desc */ gpio = &plat->gpio; - ret = gpio_request_by_name(dev, enable_gpio_name, 0, gpio, flags); - if (ret) { - debug("Regulator '%s' optional enable GPIO - not found! Error: %d\n", - dev->name, ret); - if (ret != -ENOENT) - return ret; + if (CONFIG_IS_ENABLED(DM_GPIO)) { + ret = gpio_request_by_name(dev, enable_gpio_name, 0, gpio, flags); + if (ret) { + debug("Regulator '%s' optional enable GPIO - not found! Error: %d\n", + dev->name, ret); + if (ret != -ENOENT) + return ret; + } } /* Get optional ramp up delay */ @@ -51,10 +53,10 @@ int regulator_common_get_enable(const struct udevice *dev, struct regulator_common_plat *plat) { /* Enable GPIO is optional */ - if (!dm_gpio_is_valid(&plat->gpio)) - return true; + if (CONFIG_IS_ENABLED(DM_GPIO) && dm_gpio_is_valid(&plat->gpio)) + return dm_gpio_get_value(&plat->gpio); - return dm_gpio_get_value(&plat->gpio); + return true; } int regulator_common_set_enable(const struct udevice *dev, @@ -65,47 +67,47 @@ int regulator_common_set_enable(const struct udevice *dev, debug("%s: dev='%s', enable=%d, delay=%d, has_gpio=%d\n", __func__, dev->name, enable, plat->startup_delay_us, dm_gpio_is_valid(&plat->gpio)); + /* Enable GPIO is optional */ - if (!dm_gpio_is_valid(&plat->gpio)) { - if (!enable) - return -ENOSYS; - return 0; - } - - /* If previously enabled, increase count */ - if (enable && plat->enable_count > 0) { - plat->enable_count++; - return -EALREADY; - } - - if (!enable) { - if (plat->enable_count > 1) { - /* If enabled multiple times, decrease count */ - plat->enable_count--; - return -EBUSY; - } else if (!plat->enable_count) { - /* If already disabled, do nothing */ + if (CONFIG_IS_ENABLED(DM_GPIO) && dm_gpio_is_valid(&plat->gpio)) { + /* If previously enabled, increase count */ + if (enable && plat->enable_count > 0) { + plat->enable_count++; return -EALREADY; } + + if (!enable) { + if (plat->enable_count > 1) { + /* If enabled multiple times, decrease count */ + plat->enable_count--; + return -EBUSY; + } else if (!plat->enable_count) { + /* If already disabled, do nothing */ + return -EALREADY; + } + } + + ret = dm_gpio_set_value(&plat->gpio, enable); + if (ret) { + pr_err("Can't set regulator : %s gpio to: %d\n", dev->name, + enable); + return ret; + } + + if (enable && plat->startup_delay_us) + udelay(plat->startup_delay_us); + + if (!enable && plat->off_on_delay_us) + udelay(plat->off_on_delay_us); + + if (enable) + plat->enable_count++; + else + plat->enable_count--; + + } else { + ret = enable ? 0 : -ENOSYS; } - ret = dm_gpio_set_value(&plat->gpio, enable); - if (ret) { - pr_err("Can't set regulator : %s gpio to: %d\n", dev->name, - enable); - return ret; - } - - if (enable && plat->startup_delay_us) - udelay(plat->startup_delay_us); - - if (!enable && plat->off_on_delay_us) - udelay(plat->off_on_delay_us); - - if (enable) - plat->enable_count++; - else - plat->enable_count--; - - return 0; + return ret; } From efc26685682987e1bea06bd821d7960501326edf Mon Sep 17 00:00:00 2001 From: Tanmay Kathpalia Date: Fri, 16 Jan 2026 04:50:31 -0800 Subject: [PATCH 4/6] mmc: mmc-uclass: Use max-frequency from device tree with driver default fallback Use dev_read_u32_default() instead of dev_read_u32() to read the "max-frequency" property from device tree. This preserves the driver-set cfg->f_max value when the optional "max-frequency" property is not present, ensuring the controller's default frequency is used as fallback rather than being overwritten. Suggested-by: Marek Vasut Signed-off-by: Tanmay Kathpalia Signed-off-by: Peng Fan --- drivers/mmc/mmc-uclass.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c index 2f4dc5bd887..698530088fe 100644 --- a/drivers/mmc/mmc-uclass.c +++ b/drivers/mmc/mmc-uclass.c @@ -243,8 +243,12 @@ int mmc_of_parse(struct udevice *dev, struct mmc_config *cfg) return -EINVAL; } - /* f_max is obtained from the optional "max-frequency" property */ - dev_read_u32(dev, "max-frequency", &cfg->f_max); + /* + * Maximum frequency is obtained from the optional "max-frequency" DT property. + * Use dev_read_u32_default() to preserve the driver-set f_max value when + * "max-frequency" is not present, ensuring the controller's default is used. + */ + cfg->f_max = dev_read_u32_default(dev, "max-frequency", cfg->f_max); if (dev_read_bool(dev, "cap-sd-highspeed")) cfg->host_caps |= MMC_CAP(SD_HS); From 0e6ed6117552e6b0ba8675980ef9580fea2ae3ac Mon Sep 17 00:00:00 2001 From: Hal Feng Date: Mon, 12 Jan 2026 10:39:47 +0800 Subject: [PATCH 5/6] mmc: sdhci-cadence6: Fix the license to GPL-2.0+ The license of the file is not valid. Fix it to GPL-2.0+. Fixes: fe11aa0b8ca3 ("mmc: sdhci-cadence: Add support for Cadence sdmmc v6") Reported-by: Quentin Schulz Reported-by: oliver Fendt Closes: https://lore.kernel.org/all/CAFoF8fC4foffYJgYm9CkViET83gDu05noVRxLxgs+KWXN_-LBQ@mail.gmail.com/ Signed-off-by: Hal Feng Reviewed-by: Quentin Schulz Reviewed-by: Tanmay Kathpalia Acked-by: Peng Fan Signed-off-by: Peng Fan --- drivers/mmc/sdhci-cadence6.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mmc/sdhci-cadence6.c b/drivers/mmc/sdhci-cadence6.c index 91a245aa490..ca1086e2359 100644 --- a/drivers/mmc/sdhci-cadence6.c +++ b/drivers/mmc/sdhci-cadence6.c @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0-or-platform_driver +// SPDX-License-Identifier: GPL-2.0+ /* * Copyright (C) 2023 Starfive. * Author: Kuan Lim Lee From 124aeeff837d20374ec00e292c31444b67b7a971 Mon Sep 17 00:00:00 2001 From: Yanir Levin Date: Thu, 22 Jan 2026 10:32:06 +0800 Subject: [PATCH 6/6] mmc: Fix retry logic in sd_get_capabilities In sd_get_capabilities an ACMD is sent (SD_CMD_APP_SEND_SCR), which requires sending APP_CMD (MMC_CMD_APP_CMD) before. Currently, the ACMD is retried on error, however APP_CMD isn't. In this case, when the ACMD fails and it is tried again, the retry attempts will not be handled as ACMD, which is wrong. The fix performs the retry attempts on the sequence of APP_CMD and the ACMD together. Signed-off-by: Yanir Levin Reviewed-by: Eran Moshe Signed-off-by: Peng Fan --- drivers/mmc/mmc.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 71664173016..7dadff27abe 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -1382,6 +1382,7 @@ static int sd_get_capabilities(struct mmc *mmc) ALLOC_CACHE_ALIGN_BUFFER(__be32, switch_status, 16); struct mmc_data data; int timeout; + uint retries = 3; mmc->card_caps = MMC_MODE_1BIT | MMC_CAP(MMC_LEGACY); @@ -1389,25 +1390,26 @@ static int sd_get_capabilities(struct mmc *mmc) return 0; /* Read the SCR to find out if this card supports higher speeds */ - cmd.cmdidx = MMC_CMD_APP_CMD; - cmd.resp_type = MMC_RSP_R1; - cmd.cmdarg = mmc->rca << 16; + do { + cmd.cmdidx = MMC_CMD_APP_CMD; + cmd.resp_type = MMC_RSP_R1; + cmd.cmdarg = mmc->rca << 16; - err = mmc_send_cmd(mmc, &cmd, NULL); + err = mmc_send_cmd(mmc, &cmd, NULL); + if (err) + continue; - if (err) - return err; + cmd.cmdidx = SD_CMD_APP_SEND_SCR; + cmd.resp_type = MMC_RSP_R1; + cmd.cmdarg = 0; - cmd.cmdidx = SD_CMD_APP_SEND_SCR; - cmd.resp_type = MMC_RSP_R1; - cmd.cmdarg = 0; + data.dest = (char *)scr; + data.blocksize = 8; + data.blocks = 1; + data.flags = MMC_DATA_READ; - data.dest = (char *)scr; - data.blocksize = 8; - data.blocks = 1; - data.flags = MMC_DATA_READ; - - err = mmc_send_cmd_retry(mmc, &cmd, &data, 3); + err = mmc_send_cmd(mmc, &cmd, &data); + } while (err && retries--); if (err) return err;