Merge tag 'mmc-for-2026.04-rc1-2' of https://source.denx.de/u-boot/custodians/u-boot-mmc
CI: https://source.denx.de/u-boot/custodians/u-boot-mmc/-/pipelines/29066 - mmc: Fix sdhci-cadence6 license - mmc: Fix sd_get_capabilities retry logic - mmc: use max-frequency from device tree - Clean up regulator and build fix
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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,14 +1390,14 @@ static int sd_get_capabilities(struct mmc *mmc)
|
||||
return 0;
|
||||
|
||||
/* Read the SCR to find out if this card supports higher speeds */
|
||||
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);
|
||||
|
||||
if (err)
|
||||
return err;
|
||||
continue;
|
||||
|
||||
cmd.cmdidx = SD_CMD_APP_SEND_SCR;
|
||||
cmd.resp_type = MMC_RSP_R1;
|
||||
@@ -1407,7 +1408,8 @@ static int sd_get_capabilities(struct mmc *mmc)
|
||||
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;
|
||||
|
||||
@@ -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 <kuanlim.lee@starfivetech.com>
|
||||
|
||||
@@ -27,6 +27,7 @@ int regulator_common_of_to_plat(struct udevice *dev,
|
||||
|
||||
/* Get optional enable GPIO desc */
|
||||
gpio = &plat->gpio;
|
||||
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",
|
||||
@@ -34,6 +35,7 @@ int regulator_common_of_to_plat(struct udevice *dev,
|
||||
if (ret != -ENOENT)
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
/* Get optional ramp up delay */
|
||||
plat->startup_delay_us = dev_read_u32_default(dev,
|
||||
@@ -51,10 +53,10 @@ int regulator_common_get_enable(const struct udevice *dev,
|
||||
struct regulator_common_plat *plat)
|
||||
{
|
||||
/* Enable GPIO is optional */
|
||||
if (!plat->gpio.dev)
|
||||
return true;
|
||||
|
||||
if (CONFIG_IS_ENABLED(DM_GPIO) && dm_gpio_is_valid(&plat->gpio))
|
||||
return dm_gpio_get_value(&plat->gpio);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int regulator_common_set_enable(const struct udevice *dev,
|
||||
@@ -65,13 +67,9 @@ 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;
|
||||
}
|
||||
|
||||
/* Enable GPIO is optional */
|
||||
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++;
|
||||
@@ -98,7 +96,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);
|
||||
@@ -108,5 +105,9 @@ int regulator_common_set_enable(const struct udevice *dev,
|
||||
else
|
||||
plat->enable_count--;
|
||||
|
||||
return 0;
|
||||
} else {
|
||||
ret = enable ? 0 : -ENOSYS;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user