diff options
Diffstat (limited to 'drivers/power/regulator')
-rw-r--r-- | drivers/power/regulator/Kconfig | 2 | ||||
-rw-r--r-- | drivers/power/regulator/lp873x_regulator.c | 8 | ||||
-rw-r--r-- | drivers/power/regulator/lp87565_regulator.c | 4 | ||||
-rw-r--r-- | drivers/power/regulator/palmas_regulator.c | 8 | ||||
-rw-r--r-- | drivers/power/regulator/pca9450.c | 37 | ||||
-rw-r--r-- | drivers/power/regulator/pfuze100.c | 44 | ||||
-rw-r--r-- | drivers/power/regulator/regulator-uclass.c | 2 | ||||
-rw-r--r-- | drivers/power/regulator/regulator_common.c | 10 | ||||
-rw-r--r-- | drivers/power/regulator/regulator_common.h | 1 | ||||
-rw-r--r-- | drivers/power/regulator/rzg2l-usbphy-regulator.c | 2 | ||||
-rw-r--r-- | drivers/power/regulator/tps65941_regulator.c | 8 |
11 files changed, 79 insertions, 47 deletions
diff --git a/drivers/power/regulator/Kconfig b/drivers/power/regulator/Kconfig index 65b99e89656..1875e61967c 100644 --- a/drivers/power/regulator/Kconfig +++ b/drivers/power/regulator/Kconfig @@ -143,7 +143,7 @@ config REGULATOR_PWM config SPL_REGULATOR_PWM bool "Enable Driver for PWM regulators in SPL" - depends on REGULATOR_PWM && SPL + depends on SPL_DM_REGULATOR && SPL && SPL_DM_PWM help This config enables implementation of driver-model regulator uclass features for PWM regulators in SPL. diff --git a/drivers/power/regulator/lp873x_regulator.c b/drivers/power/regulator/lp873x_regulator.c index 271a7e45139..62d91a23f77 100644 --- a/drivers/power/regulator/lp873x_regulator.c +++ b/drivers/power/regulator/lp873x_regulator.c @@ -83,8 +83,8 @@ static int lp873x_buck_hex2volt(int hex) static int lp873x_buck_val(struct udevice *dev, int op, int *uV) { - unsigned int hex, adr; - int ret; + unsigned int adr; + int hex, ret; struct dm_regulator_uclass_plat *uc_pdata; uc_pdata = dev_get_uclass_plat(dev); @@ -177,8 +177,8 @@ static int lp873x_ldo_hex2volt(int hex) static int lp873x_ldo_val(struct udevice *dev, int op, int *uV) { - unsigned int hex, adr; - int ret; + unsigned int adr; + int hex, ret; struct dm_regulator_uclass_plat *uc_pdata; diff --git a/drivers/power/regulator/lp87565_regulator.c b/drivers/power/regulator/lp87565_regulator.c index 2212cb5c651..ea9c7685e9f 100644 --- a/drivers/power/regulator/lp87565_regulator.c +++ b/drivers/power/regulator/lp87565_regulator.c @@ -82,8 +82,8 @@ static int lp87565_buck_val2volt(int val) static int lp87565_buck_val(struct udevice *dev, int op, int *uV) { - unsigned int hex, adr; - int ret; + unsigned int adr; + int hex, ret; struct dm_regulator_uclass_plat *uc_pdata; uc_pdata = dev_get_uclass_plat(dev); diff --git a/drivers/power/regulator/palmas_regulator.c b/drivers/power/regulator/palmas_regulator.c index 2286eac93fb..7212062c8c8 100644 --- a/drivers/power/regulator/palmas_regulator.c +++ b/drivers/power/regulator/palmas_regulator.c @@ -115,8 +115,8 @@ static int palmas_smps_hex2volt(int hex, bool range) static int palmas_smps_val(struct udevice *dev, int op, int *uV) { - unsigned int hex, adr; - int ret; + unsigned int adr; + int hex, ret; bool range; struct dm_regulator_uclass_plat *uc_pdata; @@ -251,8 +251,8 @@ static int palmas_ldo_hex2volt(int hex) static int palmas_ldo_val(struct udevice *dev, int op, int *uV) { - unsigned int hex, adr; - int ret; + unsigned int adr; + int hex, ret; struct dm_regulator_uclass_plat *uc_pdata; diff --git a/drivers/power/regulator/pca9450.c b/drivers/power/regulator/pca9450.c index a2a34244723..3bb0c71dde7 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,8 @@ struct pca9450_plat { u8 volt_mask; struct pca9450_vrange *ranges; unsigned int numranges; + struct gpio_desc *sd_vsel_gpio; + bool sd_vsel_fixed_low; }; #define PCA_RANGE(_min, _vstep, _sel_low, _sel_hi) \ @@ -144,7 +149,7 @@ static struct pca9450_plat pca9450_reg_data[] = { PCA_DATA("LDO4", PCA9450_LDO4CTRL, HW_STATE_CONTROL, PCA9450_LDO4CTRL, PCA9450_LDO34_MASK, pca9450_ldo34_vranges), - PCA_DATA("LDO5", PCA9450_LDO5CTRL_H, HW_STATE_CONTROL, + PCA_DATA("LDO5", PCA9450_LDO5CTRL_L, HW_STATE_CONTROL, PCA9450_LDO5CTRL_H, PCA9450_LDO5_MASK, pca9450_ldo5_vranges), }; @@ -222,13 +227,24 @@ 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)) || + plat->sd_vsel_fixed_low)) { + 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 +290,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 +351,21 @@ 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; + } + } + + plat->sd_vsel_fixed_low = dev_read_bool(dev, "nxp,sd-vsel-fixed-low"); + } + return 0; } diff --git a/drivers/power/regulator/pfuze100.c b/drivers/power/regulator/pfuze100.c index bf3a7019411..f864b1d8834 100644 --- a/drivers/power/regulator/pfuze100.c +++ b/drivers/power/regulator/pfuze100.c @@ -241,56 +241,46 @@ static struct dm_regulator_mode pfuze_ldo_modes[] = { MODE(LDO_MODE_ON, LDO_MODE_ON, "LDO_MODE_ON"), }; -static struct pfuze100_regulator_desc *se_desc(struct pfuze100_regulator_desc *desc, - int size, - const char *name) -{ - int i; - - for (i = 0; i < size; desc++) { - if (!strcmp(desc->name, name)) - return desc; - continue; - } - - return NULL; -} - static int pfuze100_regulator_probe(struct udevice *dev) { struct dm_regulator_uclass_plat *uc_pdata; struct pfuze100_regulator_plat *plat = dev_get_plat(dev); struct pfuze100_regulator_desc *desc; + int i, size; switch (dev_get_driver_data(dev_get_parent(dev))) { case PFUZE100: - desc = se_desc(pfuze100_regulators, - ARRAY_SIZE(pfuze100_regulators), - dev->name); + desc = pfuze100_regulators; + size = ARRAY_SIZE(pfuze100_regulators); break; case PFUZE200: - desc = se_desc(pfuze200_regulators, - ARRAY_SIZE(pfuze200_regulators), - dev->name); + desc = pfuze200_regulators; + size = ARRAY_SIZE(pfuze200_regulators); break; case PFUZE3000: - desc = se_desc(pfuze3000_regulators, - ARRAY_SIZE(pfuze3000_regulators), - dev->name); + desc = pfuze3000_regulators; + size = ARRAY_SIZE(pfuze3000_regulators); break; default: debug("Unsupported PFUZE\n"); return -EINVAL; } - if (!desc) { + + for (i = 0; i < size; i++) { + if (strcmp(desc[i].name, dev->name)) + continue; + break; + } + + if (i == size) { debug("Do not support regulator %s\n", dev->name); return -EINVAL; } - plat->desc = desc; + plat->desc = &desc[i]; uc_pdata = dev_get_uclass_plat(dev); - uc_pdata->type = desc->type; + uc_pdata->type = desc[i].type; if (uc_pdata->type == REGULATOR_TYPE_BUCK) { if (!strcmp(dev->name, "swbst")) { uc_pdata->mode = pfuze_swbst_modes; diff --git a/drivers/power/regulator/regulator-uclass.c b/drivers/power/regulator/regulator-uclass.c index 2a59a1b79c2..94c52cf555b 100644 --- a/drivers/power/regulator/regulator-uclass.c +++ b/drivers/power/regulator/regulator-uclass.c @@ -389,7 +389,7 @@ int regulator_list_autoset(const char *list_platname[], ret = regulator_autoset_by_name(list_platname[i], &dev); if (ret != -EMEDIUMTYPE && verbose) regulator_show(dev, ret); - if (ret & !error) + if (ret && ret != -EALREADY && !error) error = ret; if (list_devp) diff --git a/drivers/power/regulator/regulator_common.c b/drivers/power/regulator/regulator_common.c index e3565d32a01..c80f10c3aa3 100644 --- a/drivers/power/regulator/regulator_common.c +++ b/drivers/power/regulator/regulator_common.c @@ -45,6 +45,16 @@ int regulator_common_of_to_plat(struct udevice *dev, dev_read_u32_default(dev, "u-boot,off-on-delay-us", 0); } + ret = device_get_supply_regulator(dev, "vin-supply", &plat->vin_supply); + if (ret) { + debug("Regulator vin regulator not defined: %d\n", ret); + if (ret != -ENOENT) + return ret; + } + + if (plat->vin_supply) + regulator_set_enable_if_allowed(plat->vin_supply, true); + return 0; } diff --git a/drivers/power/regulator/regulator_common.h b/drivers/power/regulator/regulator_common.h index d4962899d83..799c968d0b6 100644 --- a/drivers/power/regulator/regulator_common.h +++ b/drivers/power/regulator/regulator_common.h @@ -14,6 +14,7 @@ struct regulator_common_plat { unsigned int startup_delay_us; unsigned int off_on_delay_us; unsigned int enable_count; + struct udevice *vin_supply; }; int regulator_common_of_to_plat(struct udevice *dev, diff --git a/drivers/power/regulator/rzg2l-usbphy-regulator.c b/drivers/power/regulator/rzg2l-usbphy-regulator.c index 451f04c140e..0354555d0b5 100644 --- a/drivers/power/regulator/rzg2l-usbphy-regulator.c +++ b/drivers/power/regulator/rzg2l-usbphy-regulator.c @@ -27,7 +27,7 @@ static int rzg2l_usbphy_regulator_get_enable(struct udevice *dev) { struct rzg2l_usbphy_ctrl_priv *priv = dev_get_priv(dev->parent); - return !!readl(priv->regs + VBENCTL) & VBENCTL_VBUS_SEL; + return !!(readl(priv->regs + VBENCTL) & VBENCTL_VBUS_SEL); } static const struct dm_regulator_ops rzg2l_usbphy_regulator_ops = { diff --git a/drivers/power/regulator/tps65941_regulator.c b/drivers/power/regulator/tps65941_regulator.c index 13f94b730d4..2561d6f4c6c 100644 --- a/drivers/power/regulator/tps65941_regulator.c +++ b/drivers/power/regulator/tps65941_regulator.c @@ -277,8 +277,8 @@ static const struct tps65941_reg_conv_ops buck_conv_ops[] = { static int tps65941_buck_val(struct udevice *dev, int op, int *uV) { - unsigned int hex, adr; - int ret, delta, uwait, slew, idx; + unsigned int adr; + int hex, ret, delta, uwait, slew, idx; struct dm_regulator_uclass_plat *uc_pdata; const struct tps65941_reg_conv_ops *conv_ops; ulong chip_id; @@ -479,8 +479,8 @@ static const struct tps65941_reg_conv_ops ldo_conv_ops[] = { static int tps65941_ldo_val(struct udevice *dev, int op, int *uV) { - unsigned int hex, adr; - int ret, ret_volt, idx, ldo_bypass; + unsigned int adr; + int hex, ret, ret_volt, idx, ldo_bypass; struct dm_regulator_uclass_plat *uc_pdata; const struct tps65941_reg_conv_ops *conv_ops; ulong chip_id; |