diff options
| author | Tom Rini <[email protected]> | 2025-07-02 07:51:57 -0600 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2025-07-02 07:51:57 -0600 |
| commit | c405bab7661dd60420e97a4edeb3162e9d7e02c5 (patch) | |
| tree | eea5c8418fe6b89c92aabd7c7153f27cdcc9198f | |
| parent | cbb5672790d400e9ec6e9fceaf89ece2660c0117 (diff) | |
| parent | be7fc8f331d5da68f54a241f08206e49236649d9 (diff) | |
Merge tag 'mmc-next-2025-07-02' of https://source.denx.de/u-boot/custodians/u-boot-mmc into next
CI: https://source.denx.de/u-boot/custodians/u-boot-mmc/-/pipelines/26911
- Get clock manager address via DT for socfpga_dw_mmc
- Revert "drivers: mmc: rpmb: Use R1 response"
- Fix offsets relative to the end of the partition for mmc env
| -rw-r--r-- | drivers/mmc/rpmb.c | 6 | ||||
| -rw-r--r-- | drivers/mmc/socfpga_dw_mmc.c | 22 | ||||
| -rw-r--r-- | env/Kconfig | 42 | ||||
| -rw-r--r-- | env/mmc.c | 8 |
4 files changed, 52 insertions, 26 deletions
diff --git a/drivers/mmc/rpmb.c b/drivers/mmc/rpmb.c index fa3ac2d9e37..8bfdffd56f5 100644 --- a/drivers/mmc/rpmb.c +++ b/drivers/mmc/rpmb.c @@ -11,7 +11,7 @@ #include <log.h> #include <memalign.h> #include <mmc.h> -#include <sdhci.h> +#include <asm/byteorder.h> #include <u-boot/sha256.h> #include "mmc_private.h" @@ -91,7 +91,6 @@ static int mmc_rpmb_request(struct mmc *mmc, const struct s_rpmb *s, { struct mmc_cmd cmd = {0}; struct mmc_data data; - struct sdhci_host *host = mmc->priv; int ret; ret = mmc_set_blockcount(mmc, count, is_rel_write); @@ -106,9 +105,6 @@ static int mmc_rpmb_request(struct mmc *mmc, const struct s_rpmb *s, cmd.cmdarg = 0; cmd.resp_type = MMC_RSP_R1; - if (host->quirks & SDHCI_QUIRK_BROKEN_R1B) - cmd.resp_type = MMC_RSP_R1; - data.src = (const char *)s; data.blocks = 1; data.blocksize = MMC_MAX_BLOCK_LEN; diff --git a/drivers/mmc/socfpga_dw_mmc.c b/drivers/mmc/socfpga_dw_mmc.c index 9dc1ceaa09b..3b86bc9b18c 100644 --- a/drivers/mmc/socfpga_dw_mmc.c +++ b/drivers/mmc/socfpga_dw_mmc.c @@ -54,16 +54,30 @@ static int socfpga_dwmci_clksel(struct dwmci_host *host) u32 sdmmc_mask = ((priv->smplsel & 0x7) << SYSMGR_SDMMC_SMPLSEL_SHIFT) | ((priv->drvsel & 0x7) << SYSMGR_SDMMC_DRVSEL_SHIFT); + /* Get clock manager base address */ + struct udevice *clkmgr_dev; + int ret = uclass_get_device_by_name(UCLASS_CLK, "clock-controller@ffd10000", &clkmgr_dev); + + if (ret) { + printf("Failed to get clkmgr device: %d\n", ret); + return ret; + } + + fdt_addr_t clkmgr_base = dev_read_addr(clkmgr_dev); + + if (clkmgr_base == FDT_ADDR_T_NONE) { + printf("Failed to read base address from clkmgr DT node\n"); + return -EINVAL; + } + /* Disable SDMMC clock. */ - clrbits_le32(socfpga_get_clkmgr_addr() + CLKMGR_PERPLL_EN, + clrbits_le32(clkmgr_base + CLKMGR_PERPLL_EN, CLKMGR_PERPLLGRP_EN_SDMMCCLK_MASK); debug("%s: drvsel %d smplsel %d\n", __func__, priv->drvsel, priv->smplsel); #if !defined(CONFIG_XPL_BUILD) && defined(CONFIG_SPL_ATF) - int ret; - ret = socfpga_secure_reg_write32(SOCFPGA_SECURE_REG_SYSMGR_SOC64_SDMMC, sdmmc_mask); if (ret) { @@ -78,7 +92,7 @@ static int socfpga_dwmci_clksel(struct dwmci_host *host) #endif /* Enable SDMMC clock */ - setbits_le32(socfpga_get_clkmgr_addr() + CLKMGR_PERPLL_EN, + setbits_le32(clkmgr_base + CLKMGR_PERPLL_EN, CLKMGR_PERPLLGRP_EN_SDMMCCLK_MASK); return 0; diff --git a/env/Kconfig b/env/Kconfig index 58a0666cd49..c30785de48b 100644 --- a/env/Kconfig +++ b/env/Kconfig @@ -231,14 +231,6 @@ config ENV_IS_IN_MMC These two #defines specify the offset and size of the environment area within the specified MMC device. - If offset is positive (the usual case), it is treated as relative to - the start of the MMC partition. If offset is negative, it is treated - as relative to the end of the MMC partition. This can be useful if - your board may be fitted with different MMC devices, which have - different sizes for the MMC partitions, and you always want the - environment placed at the very end of the partition, to leave the - maximum possible space before it, to store other data. - These two values are in units of bytes, but must be aligned to an MMC sector boundary. @@ -249,9 +241,6 @@ config ENV_IS_IN_MMC valid backup copy in case the other copy is corrupted, e.g. due to a power failure during a "saveenv" operation. - This value may also be positive or negative; this is handled in the - same way as CONFIG_ENV_OFFSET. - In case CONFIG_ENV_MMC_EMMC_HW_PARTITION is 1 (i.e. environment in eMMC boot partition) then setting CONFIG_ENV_OFFSET_REDUND to the same value as CONFIG_ENV_OFFSET makes use of the second eMMC boot partition for @@ -618,9 +607,18 @@ config ENV_OFFSET Offset from the start of the device (or partition). This offset may be interpreted differently depending on the chosen - ENV_IS_IN_* options. For example, for ENV_IS_IN_MMC=y, this offset may - be negative to indicate an offset backwards from the end of the - partition. See the relevant help messages for more details. + ENV_IS_IN_* options. See the relevant help messages for more details. + +config ENV_OFFSET_RELATIVE_END + bool "Offset is relative to the end of the partition" + depends on ENV_IS_IN_MMC + help + Treat the environment offset as relative to the end of the MMC + hardware partition. This can be useful if your board may be fitted + with different MMC devices, which have different sizes for the MMC + hardware partitions, and you always want the environment placed at the + very end of the partition, to leave the maximum possible space before + it, to store other data. config ENV_OFFSET_REDUND hex "Redundant environment offset" @@ -633,9 +631,19 @@ config ENV_OFFSET_REDUND environment location. This offset may be interpreted differently depending on the chosen - ENV_IS_IN_* options. For example, for ENV_IS_IN_MMC=y, this offset may - be negative to indicate an offset backwards from the end of the - partition. See the relevant help messages for more details. + ENV_IS_IN_* options. See the relevant help messages for more details. + +config ENV_OFFSET_REDUND_RELATIVE_END + bool "Offset is relative to the end of the partition" + depends on SYS_REDUNDAND_ENVIRONMENT + depends on ENV_IS_IN_MMC + help + Treat the redundant environment offset as relative to the end of the + MMC hardware partition. This can be useful if your board may be + fitted with different MMC devices, which have different sizes for the + MMC hardware partitions, and you always want the environment placed at + the very end of the partition, to leave the maximum possible space + before it, to store other data. config ENV_SIZE hex "Environment Size" diff --git a/env/mmc.c b/env/mmc.c index 11375bd4464..46ffa6386d6 100644 --- a/env/mmc.c +++ b/env/mmc.c @@ -29,11 +29,19 @@ #else /* Default ENV offset when not defined in Device Tree */ +#if !defined(CONFIG_ENV_OFFSET_RELATIVE_END) #define ENV_MMC_OFFSET CONFIG_ENV_OFFSET +#else +#define ENV_MMC_OFFSET (-(CONFIG_ENV_OFFSET)) +#endif #if defined(CONFIG_ENV_OFFSET_REDUND) +#if !defined(CONFIG_ENV_OFFSET_REDUND_RELATIVE_END) #define ENV_MMC_OFFSET_REDUND CONFIG_ENV_OFFSET_REDUND #else +#define ENV_MMC_OFFSET_REDUND (-(CONFIG_ENV_OFFSET_REDUND)) +#endif +#else #define ENV_MMC_OFFSET_REDUND ENV_MMC_INVALID_OFFSET #endif #endif |
