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@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);
+}
+
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);
+ 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;
+
ret = spacemit_sdhci_get_clocks(dev, pltfm_host);
if (ret)
goto err_pltfm;
--
2.53.0
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@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)
On Mon, Mar 02, 2026 at 04:13:24PM +0100, 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@gmail.com> > --- > drivers/mmc/host/sdhci-of-k1.c | 12 ++++++++++++ > 1 file changed, 12 insertions(+) It seems PATCH 4 should be squashed into this one, or the functionality of voltage switching isn't really complete. > 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 ... > @@ -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); > + 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; Why not assign start_signal_voltage_switch in the declaration of spacemit_sdhci_ops? > ret = spacemit_sdhci_get_clocks(dev, pltfm_host); > if (ret) > goto err_pltfm; > > -- > 2.53.0 Best regards, Yao Zi
El mar, 3 mar 2026 a las 5:11, Yao Zi (<me@ziyao.cc>) escribió: > > On Mon, Mar 02, 2026 at 04:13:24PM +0100, 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@gmail.com> > > --- > > drivers/mmc/host/sdhci-of-k1.c | 12 ++++++++++++ > > 1 file changed, 12 insertions(+) > > It seems PATCH 4 should be squashed into this one, or the functionality > of voltage switching isn't really complete. That makes sense. I'm still learning the best way to structure these series for the kernel, so I appreciate the guidance. I'll squash patch 4 into this one for v2 to ensure the voltage switching logic is atomic. > > > 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 > > ... > > > @@ -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); > > + 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; > > Why not assign start_signal_voltage_switch in the declaration of > spacemit_sdhci_ops? You're right, that’s much cleaner. I'll move the assignment into the spacemit_sdhci_ops declaration for v2. Thanks for the suggestion! > > > ret = spacemit_sdhci_get_clocks(dev, pltfm_host); > > if (ret) > > goto err_pltfm; > > > > -- > > 2.53.0 > > Best regards, > Yao Zi >
© 2016 - 2026 Red Hat, Inc.