regulator: Fixes for v5.14
A collection of fixes for the regulator API that have come up since the merge window, including a big batch of fixes from Axel Lin's usual careful and detailed review. The one stand out fix here is Dmitry Baryshkov's fix for an issue where we fail to power on the parents of always on regulators during system startup if they weren't already powered on. -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAmC/ao0ACgkQJNaLcl1U h9AoqQf9GYtljFSON07MAOWwMgnjuMQ+rl0ZadqKKzq74QMMi4bxVKDWkftQ28/5 Ulk2M/mxRE6C1OEpOJl9ZnG9K0fWpOdnTURkYgW0FsJniEDiF7ZkdoFypwu93jOD 0r+3QCw/Ti9i08pOdlpFpUKU5rp/O9HYmouOTzBOCiM1SMb9TkkX5GBoDVw8+cWd 2PZqKQXEsaK1uNzeaXYw6UO8+IdSpVQRzSEILdtVWyHCNmXDDJWfI3vYeeqDbhYr C+E3UdrO1ftNsOoJv33NqhscMnulkZDZ6H6lgbLX2FyFAe2M9N+AildGlkR5H1GD xH3q3EvkOE2Y2X3zHteLdJ3MoI91cQ== =poWJ -----END PGP SIGNATURE----- Merge tag 'regulator-fix-v5.13-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator Pull regulator fixes from Mark Brown: "A collection of fixes for the regulator API that have come up since the merge window, including a big batch of fixes from Axel Lin's usual careful and detailed review. The one stand out fix here is Dmitry Baryshkov's fix for an issue where we fail to power on the parents of always on regulators during system startup if they weren't already powered on" * tag 'regulator-fix-v5.13-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator: (21 commits) regulator: rt4801: Fix NULL pointer dereference if priv->enable_gpios is NULL regulator: hi6421v600: Fix .vsel_mask setting regulator: bd718x7: Fix the BUCK7 voltage setting on BD71837 regulator: atc260x: Fix n_voltages and min_sel for pickable linear ranges regulator: rtmv20: Fix to make regcache value first reading back from HW regulator: mt6315: Fix function prototype for mt6315_map_mode regulator: rtmv20: Add Richtek to Kconfig text regulator: rtmv20: Fix .set_current_limit/.get_current_limit callbacks regulator: hisilicon: use the correct HiSilicon copyright regulator: bd71828: Fix .n_voltages settings regulator: bd70528: Fix off-by-one for buck123 .n_voltages setting regulator: max77620: Silence deferred probe error regulator: max77620: Use device_set_of_node_from_dev() regulator: scmi: Fix off-by-one for linear regulators .n_voltages setting regulator: core: resolve supply for boot-on/always-on regulators regulator: fixed: Ensure enable_counter is correct if reg_domain_disable fails regulator: Check ramp_delay_table for regulator_set_ramp_delay_regmap regulator: fan53880: Fix missing n_voltages setting regulator: da9121: Return REGULATOR_MODE_INVALID for invalid mode regulator: fan53555: fix TCS4525 voltage calulation ...
This commit is contained in:
Коммит
9b1111fa80
|
@ -1031,7 +1031,7 @@ config REGULATOR_RT5033
|
|||
current source, LDO and Buck.
|
||||
|
||||
config REGULATOR_RTMV20
|
||||
tristate "RTMV20 Laser Diode Regulator"
|
||||
tristate "Richtek RTMV20 Laser Diode Regulator"
|
||||
depends on I2C
|
||||
select REGMAP_I2C
|
||||
help
|
||||
|
|
|
@ -28,16 +28,16 @@ static const struct linear_range atc2609a_dcdc_voltage_ranges[] = {
|
|||
|
||||
static const struct linear_range atc2609a_ldo_voltage_ranges0[] = {
|
||||
REGULATOR_LINEAR_RANGE(700000, 0, 15, 100000),
|
||||
REGULATOR_LINEAR_RANGE(2100000, 16, 28, 100000),
|
||||
REGULATOR_LINEAR_RANGE(2100000, 0, 12, 100000),
|
||||
};
|
||||
|
||||
static const struct linear_range atc2609a_ldo_voltage_ranges1[] = {
|
||||
REGULATOR_LINEAR_RANGE(850000, 0, 15, 100000),
|
||||
REGULATOR_LINEAR_RANGE(2100000, 16, 27, 100000),
|
||||
REGULATOR_LINEAR_RANGE(2100000, 0, 11, 100000),
|
||||
};
|
||||
|
||||
static const unsigned int atc260x_ldo_voltage_range_sel[] = {
|
||||
0x0, 0x1,
|
||||
0x0, 0x20,
|
||||
};
|
||||
|
||||
static int atc260x_dcdc_set_voltage_time_sel(struct regulator_dev *rdev,
|
||||
|
@ -411,7 +411,7 @@ enum atc2609a_reg_ids {
|
|||
.owner = THIS_MODULE, \
|
||||
}
|
||||
|
||||
#define atc2609a_reg_desc_ldo_range_pick(num, n_range) { \
|
||||
#define atc2609a_reg_desc_ldo_range_pick(num, n_range, n_volt) { \
|
||||
.name = "LDO"#num, \
|
||||
.supply_name = "ldo"#num, \
|
||||
.of_match = of_match_ptr("ldo"#num), \
|
||||
|
@ -421,6 +421,7 @@ enum atc2609a_reg_ids {
|
|||
.type = REGULATOR_VOLTAGE, \
|
||||
.linear_ranges = atc2609a_ldo_voltage_ranges##n_range, \
|
||||
.n_linear_ranges = ARRAY_SIZE(atc2609a_ldo_voltage_ranges##n_range), \
|
||||
.n_voltages = n_volt, \
|
||||
.vsel_reg = ATC2609A_PMU_LDO##num##_CTL0, \
|
||||
.vsel_mask = GENMASK(4, 1), \
|
||||
.vsel_range_reg = ATC2609A_PMU_LDO##num##_CTL0, \
|
||||
|
@ -458,12 +459,12 @@ static const struct regulator_desc atc2609a_reg[] = {
|
|||
atc2609a_reg_desc_ldo_bypass(0),
|
||||
atc2609a_reg_desc_ldo_bypass(1),
|
||||
atc2609a_reg_desc_ldo_bypass(2),
|
||||
atc2609a_reg_desc_ldo_range_pick(3, 0),
|
||||
atc2609a_reg_desc_ldo_range_pick(4, 0),
|
||||
atc2609a_reg_desc_ldo_range_pick(3, 0, 29),
|
||||
atc2609a_reg_desc_ldo_range_pick(4, 0, 29),
|
||||
atc2609a_reg_desc_ldo(5),
|
||||
atc2609a_reg_desc_ldo_range_pick(6, 1),
|
||||
atc2609a_reg_desc_ldo_range_pick(7, 0),
|
||||
atc2609a_reg_desc_ldo_range_pick(8, 0),
|
||||
atc2609a_reg_desc_ldo_range_pick(6, 1, 28),
|
||||
atc2609a_reg_desc_ldo_range_pick(7, 0, 29),
|
||||
atc2609a_reg_desc_ldo_range_pick(8, 0, 29),
|
||||
atc2609a_reg_desc_ldo_fixed(9),
|
||||
};
|
||||
|
||||
|
|
|
@ -334,7 +334,7 @@ BD718XX_OPS(bd71837_buck_regulator_ops, regulator_list_voltage_linear_range,
|
|||
NULL);
|
||||
|
||||
BD718XX_OPS(bd71837_buck_regulator_nolinear_ops, regulator_list_voltage_table,
|
||||
regulator_map_voltage_ascend, bd718xx_set_voltage_sel_restricted,
|
||||
regulator_map_voltage_ascend, bd71837_set_voltage_sel_restricted,
|
||||
regulator_get_voltage_sel_regmap, regulator_set_voltage_time_sel,
|
||||
NULL);
|
||||
/*
|
||||
|
|
|
@ -1425,6 +1425,12 @@ static int set_machine_constraints(struct regulator_dev *rdev)
|
|||
* and we have control then make sure it is enabled.
|
||||
*/
|
||||
if (rdev->constraints->always_on || rdev->constraints->boot_on) {
|
||||
/* If we want to enable this regulator, make sure that we know
|
||||
* the supplying regulator.
|
||||
*/
|
||||
if (rdev->supply_name && !rdev->supply)
|
||||
return -EPROBE_DEFER;
|
||||
|
||||
if (rdev->supply) {
|
||||
ret = regulator_enable(rdev->supply);
|
||||
if (ret < 0) {
|
||||
|
|
|
@ -225,8 +225,9 @@ static int cros_ec_regulator_probe(struct platform_device *pdev)
|
|||
|
||||
drvdata->dev = devm_regulator_register(dev, &drvdata->desc, &cfg);
|
||||
if (IS_ERR(drvdata->dev)) {
|
||||
ret = PTR_ERR(drvdata->dev);
|
||||
dev_err(&pdev->dev, "Failed to register regulator: %d\n", ret);
|
||||
return PTR_ERR(drvdata->dev);
|
||||
return ret;
|
||||
}
|
||||
|
||||
platform_set_drvdata(pdev, drvdata);
|
||||
|
|
|
@ -280,7 +280,7 @@ static unsigned int da9121_map_mode(unsigned int mode)
|
|||
case DA9121_BUCK_MODE_FORCE_PFM:
|
||||
return REGULATOR_MODE_STANDBY;
|
||||
default:
|
||||
return -EINVAL;
|
||||
return REGULATOR_MODE_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -317,7 +317,7 @@ static unsigned int da9121_buck_get_mode(struct regulator_dev *rdev)
|
|||
{
|
||||
struct da9121 *chip = rdev_get_drvdata(rdev);
|
||||
int id = rdev_get_id(rdev);
|
||||
unsigned int val;
|
||||
unsigned int val, mode;
|
||||
int ret = 0;
|
||||
|
||||
ret = regmap_read(chip->regmap, da9121_mode_field[id].reg, &val);
|
||||
|
@ -326,7 +326,11 @@ static unsigned int da9121_buck_get_mode(struct regulator_dev *rdev)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
return da9121_map_mode(val & da9121_mode_field[id].msk);
|
||||
mode = da9121_map_mode(val & da9121_mode_field[id].msk);
|
||||
if (mode == REGULATOR_MODE_INVALID)
|
||||
return -EINVAL;
|
||||
|
||||
return mode;
|
||||
}
|
||||
|
||||
static const struct regulator_ops da9121_buck_ops = {
|
||||
|
|
|
@ -55,7 +55,6 @@
|
|||
|
||||
#define FAN53555_NVOLTAGES 64 /* Numbers of voltages */
|
||||
#define FAN53526_NVOLTAGES 128
|
||||
#define TCS4525_NVOLTAGES 127 /* Numbers of voltages */
|
||||
|
||||
#define TCS_VSEL_NSEL_MASK 0x7f
|
||||
#define TCS_VSEL0_MODE (1 << 7)
|
||||
|
@ -376,7 +375,7 @@ static int fan53555_voltages_setup_tcs(struct fan53555_device_info *di)
|
|||
/* Init voltage range and step */
|
||||
di->vsel_min = 600000;
|
||||
di->vsel_step = 6250;
|
||||
di->vsel_count = TCS4525_NVOLTAGES;
|
||||
di->vsel_count = FAN53526_NVOLTAGES;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -51,6 +51,7 @@ static const struct regulator_ops fan53880_ops = {
|
|||
REGULATOR_LINEAR_RANGE(800000, 0xf, 0x73, 25000), \
|
||||
}, \
|
||||
.n_linear_ranges = 2, \
|
||||
.n_voltages = 0x74, \
|
||||
.vsel_reg = FAN53880_LDO ## _num ## VOUT, \
|
||||
.vsel_mask = 0x7f, \
|
||||
.enable_reg = FAN53880_ENABLE, \
|
||||
|
@ -76,6 +77,7 @@ static const struct regulator_desc fan53880_regulators[] = {
|
|||
REGULATOR_LINEAR_RANGE(600000, 0x1f, 0xf7, 12500),
|
||||
},
|
||||
.n_linear_ranges = 2,
|
||||
.n_voltages = 0xf8,
|
||||
.vsel_reg = FAN53880_BUCKVOUT,
|
||||
.vsel_mask = 0x7f,
|
||||
.enable_reg = FAN53880_ENABLE,
|
||||
|
@ -95,6 +97,7 @@ static const struct regulator_desc fan53880_regulators[] = {
|
|||
REGULATOR_LINEAR_RANGE(3000000, 0x4, 0x70, 25000),
|
||||
},
|
||||
.n_linear_ranges = 2,
|
||||
.n_voltages = 0x71,
|
||||
.vsel_reg = FAN53880_BOOSTVOUT,
|
||||
.vsel_mask = 0x7f,
|
||||
.enable_reg = FAN53880_ENABLE_BOOST,
|
||||
|
|
|
@ -88,10 +88,15 @@ static int reg_domain_disable(struct regulator_dev *rdev)
|
|||
{
|
||||
struct fixed_voltage_data *priv = rdev_get_drvdata(rdev);
|
||||
struct device *dev = rdev->dev.parent;
|
||||
int ret;
|
||||
|
||||
ret = dev_pm_genpd_set_performance_state(dev, 0);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
priv->enable_counter--;
|
||||
|
||||
return dev_pm_genpd_set_performance_state(dev, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int reg_is_enabled(struct regulator_dev *rdev)
|
||||
|
|
|
@ -948,7 +948,7 @@ int regulator_set_ramp_delay_regmap(struct regulator_dev *rdev, int ramp_delay)
|
|||
int ret;
|
||||
unsigned int sel;
|
||||
|
||||
if (!rdev->desc->n_ramp_values)
|
||||
if (WARN_ON(!rdev->desc->n_ramp_values || !rdev->desc->ramp_delay_table))
|
||||
return -EINVAL;
|
||||
|
||||
ret = find_closest_bigger(ramp_delay, rdev->desc->ramp_delay_table,
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
// Device driver for regulators in Hisi IC
|
||||
//
|
||||
// Copyright (c) 2013 Linaro Ltd.
|
||||
// Copyright (c) 2011 Hisilicon.
|
||||
// Copyright (c) 2011 HiSilicon Ltd.
|
||||
// Copyright (c) 2020-2021 Huawei Technologies Co., Ltd
|
||||
//
|
||||
// Guodong Xu <guodong.xu@linaro.org>
|
||||
|
@ -83,7 +83,7 @@ static const unsigned int ldo34_voltages[] = {
|
|||
.owner = THIS_MODULE, \
|
||||
.volt_table = vtable, \
|
||||
.n_voltages = ARRAY_SIZE(vtable), \
|
||||
.vsel_mask = (1 << (ARRAY_SIZE(vtable) - 1)) - 1, \
|
||||
.vsel_mask = ARRAY_SIZE(vtable) - 1, \
|
||||
.vsel_reg = vreg, \
|
||||
.enable_reg = ereg, \
|
||||
.enable_mask = emask, \
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
//
|
||||
// Device driver for regulators in Hi655x IC
|
||||
//
|
||||
// Copyright (c) 2016 Hisilicon.
|
||||
// Copyright (c) 2016 HiSilicon Ltd.
|
||||
//
|
||||
// Authors:
|
||||
// Chen Feng <puck.chen@hisilicon.com>
|
||||
|
|
|
@ -814,6 +814,13 @@ static int max77620_regulator_probe(struct platform_device *pdev)
|
|||
config.dev = dev;
|
||||
config.driver_data = pmic;
|
||||
|
||||
/*
|
||||
* Set of_node_reuse flag to prevent driver core from attempting to
|
||||
* claim any pinmux resources already claimed by the parent device.
|
||||
* Otherwise PMIC driver will fail to re-probe.
|
||||
*/
|
||||
device_set_of_node_from_dev(&pdev->dev, pdev->dev.parent);
|
||||
|
||||
for (id = 0; id < MAX77620_NUM_REGS; id++) {
|
||||
struct regulator_dev *rdev;
|
||||
struct regulator_desc *rdesc;
|
||||
|
@ -839,12 +846,10 @@ static int max77620_regulator_probe(struct platform_device *pdev)
|
|||
return ret;
|
||||
|
||||
rdev = devm_regulator_register(dev, rdesc, &config);
|
||||
if (IS_ERR(rdev)) {
|
||||
ret = PTR_ERR(rdev);
|
||||
dev_err(dev, "Regulator registration %s failed: %d\n",
|
||||
rdesc->name, ret);
|
||||
return ret;
|
||||
}
|
||||
if (IS_ERR(rdev))
|
||||
return dev_err_probe(dev, PTR_ERR(rdev),
|
||||
"Regulator registration %s failed\n",
|
||||
rdesc->name);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -59,7 +59,7 @@ static const struct linear_range mt_volt_range1[] = {
|
|||
REGULATOR_LINEAR_RANGE(0, 0, 0xbf, 6250),
|
||||
};
|
||||
|
||||
static unsigned int mt6315_map_mode(u32 mode)
|
||||
static unsigned int mt6315_map_mode(unsigned int mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case MT6315_BUCK_MODE_AUTO:
|
||||
|
|
|
@ -66,7 +66,7 @@ static int rt4801_enable(struct regulator_dev *rdev)
|
|||
struct gpio_descs *gpios = priv->enable_gpios;
|
||||
int id = rdev_get_id(rdev), ret;
|
||||
|
||||
if (gpios->ndescs <= id) {
|
||||
if (!gpios || gpios->ndescs <= id) {
|
||||
dev_warn(&rdev->dev, "no dedicated gpio can control\n");
|
||||
goto bypass_gpio;
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ static int rt4801_disable(struct regulator_dev *rdev)
|
|||
struct gpio_descs *gpios = priv->enable_gpios;
|
||||
int id = rdev_get_id(rdev);
|
||||
|
||||
if (gpios->ndescs <= id) {
|
||||
if (!gpios || gpios->ndescs <= id) {
|
||||
dev_warn(&rdev->dev, "no dedicated gpio can control\n");
|
||||
goto bypass_gpio;
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#define RTMV20_REG_LDIRQ 0x30
|
||||
#define RTMV20_REG_LDSTAT 0x40
|
||||
#define RTMV20_REG_LDMASK 0x50
|
||||
#define RTMV20_MAX_REGS (RTMV20_REG_LDMASK + 1)
|
||||
|
||||
#define RTMV20_VID_MASK GENMASK(7, 4)
|
||||
#define RICHTEK_VID 0x80
|
||||
|
@ -103,9 +104,47 @@ static int rtmv20_lsw_disable(struct regulator_dev *rdev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int rtmv20_lsw_set_current_limit(struct regulator_dev *rdev, int min_uA,
|
||||
int max_uA)
|
||||
{
|
||||
int sel;
|
||||
|
||||
if (min_uA > RTMV20_LSW_MAXUA || max_uA < RTMV20_LSW_MINUA)
|
||||
return -EINVAL;
|
||||
|
||||
if (max_uA > RTMV20_LSW_MAXUA)
|
||||
max_uA = RTMV20_LSW_MAXUA;
|
||||
|
||||
sel = (max_uA - RTMV20_LSW_MINUA) / RTMV20_LSW_STEPUA;
|
||||
|
||||
/* Ensure the selected setting is still in range */
|
||||
if ((sel * RTMV20_LSW_STEPUA + RTMV20_LSW_MINUA) < min_uA)
|
||||
return -EINVAL;
|
||||
|
||||
sel <<= ffs(rdev->desc->csel_mask) - 1;
|
||||
|
||||
return regmap_update_bits(rdev->regmap, rdev->desc->csel_reg,
|
||||
rdev->desc->csel_mask, sel);
|
||||
}
|
||||
|
||||
static int rtmv20_lsw_get_current_limit(struct regulator_dev *rdev)
|
||||
{
|
||||
unsigned int val;
|
||||
int ret;
|
||||
|
||||
ret = regmap_read(rdev->regmap, rdev->desc->csel_reg, &val);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
val &= rdev->desc->csel_mask;
|
||||
val >>= ffs(rdev->desc->csel_mask) - 1;
|
||||
|
||||
return val * RTMV20_LSW_STEPUA + RTMV20_LSW_MINUA;
|
||||
}
|
||||
|
||||
static const struct regulator_ops rtmv20_regulator_ops = {
|
||||
.set_current_limit = regulator_set_current_limit_regmap,
|
||||
.get_current_limit = regulator_get_current_limit_regmap,
|
||||
.set_current_limit = rtmv20_lsw_set_current_limit,
|
||||
.get_current_limit = rtmv20_lsw_get_current_limit,
|
||||
.enable = rtmv20_lsw_enable,
|
||||
.disable = rtmv20_lsw_disable,
|
||||
.is_enabled = regulator_is_enabled_regmap,
|
||||
|
@ -275,6 +314,7 @@ static const struct regmap_config rtmv20_regmap_config = {
|
|||
.val_bits = 8,
|
||||
.cache_type = REGCACHE_RBTREE,
|
||||
.max_register = RTMV20_REG_LDMASK,
|
||||
.num_reg_defaults_raw = RTMV20_MAX_REGS,
|
||||
|
||||
.writeable_reg = rtmv20_is_accessible_reg,
|
||||
.readable_reg = rtmv20_is_accessible_reg,
|
||||
|
|
|
@ -173,7 +173,7 @@ scmi_config_linear_regulator_mappings(struct scmi_regulator *sreg,
|
|||
sreg->desc.uV_step =
|
||||
vinfo->levels_uv[SCMI_VOLTAGE_SEGMENT_STEP];
|
||||
sreg->desc.linear_min_sel = 0;
|
||||
sreg->desc.n_voltages = delta_uV / sreg->desc.uV_step;
|
||||
sreg->desc.n_voltages = (delta_uV / sreg->desc.uV_step) + 1;
|
||||
sreg->desc.ops = &scmi_reg_linear_ops;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,9 +26,7 @@ struct bd70528_data {
|
|||
struct mutex rtc_timer_lock;
|
||||
};
|
||||
|
||||
#define BD70528_BUCK_VOLTS 17
|
||||
#define BD70528_BUCK_VOLTS 17
|
||||
#define BD70528_BUCK_VOLTS 17
|
||||
#define BD70528_BUCK_VOLTS 0x10
|
||||
#define BD70528_LDO_VOLTS 0x20
|
||||
|
||||
#define BD70528_REG_BUCK1_EN 0x0F
|
||||
|
|
|
@ -26,11 +26,11 @@ enum {
|
|||
BD71828_REGULATOR_AMOUNT,
|
||||
};
|
||||
|
||||
#define BD71828_BUCK1267_VOLTS 0xEF
|
||||
#define BD71828_BUCK3_VOLTS 0x10
|
||||
#define BD71828_BUCK4_VOLTS 0x20
|
||||
#define BD71828_BUCK5_VOLTS 0x10
|
||||
#define BD71828_LDO_VOLTS 0x32
|
||||
#define BD71828_BUCK1267_VOLTS 0x100
|
||||
#define BD71828_BUCK3_VOLTS 0x20
|
||||
#define BD71828_BUCK4_VOLTS 0x40
|
||||
#define BD71828_BUCK5_VOLTS 0x20
|
||||
#define BD71828_LDO_VOLTS 0x40
|
||||
/* LDO6 is fixed 1.8V voltage */
|
||||
#define BD71828_LDO_6_VOLTAGE 1800000
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче