[PATCH 03/10] mmc: sdhci-of-k1: add regulator framework support

Yixun Lan dlan at gentoo.org
Sun Mar 8 23:34:16 PDT 2026


Hi IKer,

On 16:13 Mon 02 Mar     , Iker Pedrosa wrote:
> Add regulator framework support for voltage switching operations. This
> enables proper PMIC control for UHS voltage switching between 3.3V and
> 1.8V signaling levels.
> 
> - Add regulator supply parsing
> - Implement voltage switching callback
> - Enable mmc regulator framework integration
> 
> Signed-off-by: Iker Pedrosa <ikerpedrosam at gmail.com>
> ---
>  drivers/mmc/host/sdhci-of-k1.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/drivers/mmc/host/sdhci-of-k1.c b/drivers/mmc/host/sdhci-of-k1.c
> index b703b78282ed8d89183c816477c149c0a565618a..c260cb89704ae7a25bec0f07831d495553405bbd 100644
> --- a/drivers/mmc/host/sdhci-of-k1.c
> +++ b/drivers/mmc/host/sdhci-of-k1.c
> @@ -216,6 +216,12 @@ static void spacemit_sdhci_pre_hs400_to_hs200(struct mmc_host *mmc)
>  			       SPACEMIT_SDHC_PHY_CTRL_REG);
>  }
>  
> +static int spacemit_sdhci_start_signal_voltage_switch(struct mmc_host *mmc,
> +						      struct mmc_ios *ios)
> +{
> +	return sdhci_start_signal_voltage_switch(mmc, ios);
> +}
I'd suggest to implement voltage_switch() instead of start_signal_voltage_switch(),
and put the pinctrl state switch here, which will be called by
start_signal_voltage_switch(), see drivers/mmc/host/sdhci.c for more detail

sdhci_start_signal_voltage_switch() -> voltage_switch()

static const struct sdhci_ops spacemit_sdhci_ops = {
..
	.voltage_switch         = spacemit_sdhci_voltage_switch,
..

> +
>  static inline int spacemit_sdhci_get_clocks(struct device *dev,
>  					    struct sdhci_pltfm_host *pltfm_host)
>  {
> @@ -291,6 +297,12 @@ static int spacemit_sdhci_probe(struct platform_device *pdev)
>  
>  	host->mmc->caps |= MMC_CAP_NEED_RSP_BUSY;
>  
..
> +	ret = mmc_regulator_get_supply(host->mmc);
I think this is unnecessary which already handled in core framework, see
spacemit_sdhci_probbe() -> sdhci_add_host() -> sdhci_setup_host()

https://github.com/torvalds/linux/blob/v7.0-rc3/drivers/mmc/host/sdhci.c#L4289

> +	if (ret)
> +		dev_warn(dev, "Failed to get regulators: %d\n", ret);
> +
> +	host->mmc_host_ops.start_signal_voltage_switch = spacemit_sdhci_start_signal_voltage_switch;
> +
with above, this line can be dropped too

>  	ret = spacemit_sdhci_get_clocks(dev, pltfm_host);
>  	if (ret)
>  		goto err_pltfm;
> 
> -- 
> 2.53.0
> 

-- 
Yixun Lan (dlan)



More information about the linux-riscv mailing list