[PATCH 3/6] pmic: pca9450: Fix control register for LDO5
Frieder Schrempf
frieder at fris.de
Mon Aug 11 15:11:59 CEST 2025
From: Frieder Schrempf <frieder.schrempf at kontron.de>
For LDO5 we need to be able to check the status of the SD_VSEL input in
order to know which control register is used. Read the status of the
SD_VSEL signal via GPIO and use the correct register accordingly.
To use this, the LDO5 node in the devicetree needs the sd-vsel-gpios
property to reference the GPIO that is used to read back the SD_VSEL
status internally. Please note that the SION bit in the IOMUX must be
set if the signal is muxed as VSELECT and controlled by the USDHC
controller.
This is equivalent to the following change in Linux:
3ce6f4f943dd ("regulator: pca9450: Fix control register for LDO5")
Signed-off-by: Frieder Schrempf <frieder.schrempf at kontron.de>
---
drivers/power/regulator/pca9450.c | 31 +++++++++++++++++++++++++++++--
1 file changed, 29 insertions(+), 2 deletions(-)
diff --git a/drivers/power/regulator/pca9450.c b/drivers/power/regulator/pca9450.c
index 27db55e688d..9d8d142b464 100644
--- a/drivers/power/regulator/pca9450.c
+++ b/drivers/power/regulator/pca9450.c
@@ -7,9 +7,12 @@
* ROHM BD71837 regulator driver
*/
+#include <asm-generic/gpio.h>
#include <dm.h>
+#include <dm/device_compat.h>
#include <log.h>
#include <linux/bitops.h>
+#include <linux/err.h>
#include <power/pca9450.h>
#include <power/pmic.h>
#include <power/regulator.h>
@@ -52,6 +55,7 @@ struct pca9450_plat {
u8 volt_mask;
struct pca9450_vrange *ranges;
unsigned int numranges;
+ struct gpio_desc *sd_vsel_gpio;
};
#define PCA_RANGE(_min, _vstep, _sel_low, _sel_hi) \
@@ -222,13 +226,23 @@ static int pca9450_set_enable(struct udevice *dev, bool enable)
val);
}
+static u8 pca9450_get_vsel_reg(struct pca9450_plat *plat)
+{
+ if (!strcmp(plat->name, "LDO5") &&
+ (plat->sd_vsel_gpio && !dm_gpio_get_value(plat->sd_vsel_gpio)) {
+ return PCA9450_LDO5CTRL_L;
+ }
+
+ return plat->volt_reg;
+}
+
static int pca9450_get_value(struct udevice *dev)
{
struct pca9450_plat *plat = dev_get_plat(dev);
unsigned int reg, tmp;
int i, ret;
- ret = pmic_reg_read(dev->parent, plat->volt_reg);
+ ret = pmic_reg_read(dev->parent, pca9450_get_vsel_reg(plat));
if (ret < 0)
return ret;
@@ -274,7 +288,7 @@ static int pca9450_set_value(struct udevice *dev, int uvolt)
if (!found)
return -EINVAL;
- return pmic_clrsetbits(dev->parent, plat->volt_reg,
+ return pmic_clrsetbits(dev->parent, pca9450_get_vsel_reg(plat),
plat->volt_mask, sel);
}
@@ -335,6 +349,19 @@ static int pca9450_regulator_probe(struct udevice *dev)
*plat = pca9450_reg_data[i];
+ if (!strcmp(plat->name, "LDO5")) {
+ if (CONFIG_IS_ENABLED(DM_GPIO) && CONFIG_IS_ENABLED(DM_REGULATOR_PCA9450)) {
+ plat->sd_vsel_gpio = devm_gpiod_get_optional(dev, "sd-vsel",
+ GPIOD_IS_IN);
+ if (IS_ERR(plat->sd_vsel_gpio)) {
+ ret = PTR_ERR(plat->sd_vsel_gpio);
+ dev_err(dev, "Failed to request SD_VSEL GPIO: %d\n", ret);
+ if (ret)
+ return ret;
+ }
+ }
+ }
+
return 0;
}
--
2.50.1
More information about the U-Boot
mailing list