Skip to content

Commit

Permalink
Merge branch 'regulator-5.4' into regulator-5.5
Browse files Browse the repository at this point in the history
  • Loading branch information
broonie committed Oct 8, 2019
2 parents 9306a73 + 77fd66c commit 5bf2a9e
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 104 deletions.
13 changes: 13 additions & 0 deletions drivers/regulator/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -5053,6 +5053,19 @@ regulator_register(const struct regulator_desc *regulator_desc,

init_data = regulator_of_get_init_data(dev, regulator_desc, config,
&rdev->dev.of_node);

/*
* Sometimes not all resources are probed already so we need to take
* that into account. This happens most the time if the ena_gpiod comes
* from a gpio extender or something else.
*/
if (PTR_ERR(init_data) == -EPROBE_DEFER) {
kfree(config);
kfree(rdev);
ret = -EPROBE_DEFER;
goto rinse;
}

/*
* We need to keep track of any GPIO descriptor coming from the
* device tree until we have handled it over to the core. If the
Expand Down
118 changes: 47 additions & 71 deletions drivers/regulator/da9062-regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ static int da9062_buck_set_mode(struct regulator_dev *rdev, unsigned mode)
static unsigned da9062_buck_get_mode(struct regulator_dev *rdev)
{
struct da9062_regulator *regl = rdev_get_drvdata(rdev);
struct regmap_field *field;
unsigned int val, mode = 0;
int ret;

Expand All @@ -158,18 +157,7 @@ static unsigned da9062_buck_get_mode(struct regulator_dev *rdev)
return REGULATOR_MODE_NORMAL;
}

/* Detect current regulator state */
ret = regmap_field_read(regl->suspend, &val);
if (ret < 0)
return 0;

/* Read regulator mode from proper register, depending on state */
if (val)
field = regl->suspend_sleep;
else
field = regl->sleep;

ret = regmap_field_read(field, &val);
ret = regmap_field_read(regl->sleep, &val);
if (ret < 0)
return 0;

Expand Down Expand Up @@ -208,21 +196,9 @@ static int da9062_ldo_set_mode(struct regulator_dev *rdev, unsigned mode)
static unsigned da9062_ldo_get_mode(struct regulator_dev *rdev)
{
struct da9062_regulator *regl = rdev_get_drvdata(rdev);
struct regmap_field *field;
int ret, val;

/* Detect current regulator state */
ret = regmap_field_read(regl->suspend, &val);
if (ret < 0)
return 0;

/* Read regulator mode from proper register, depending on state */
if (val)
field = regl->suspend_sleep;
else
field = regl->sleep;

ret = regmap_field_read(field, &val);
ret = regmap_field_read(regl->sleep, &val);
if (ret < 0)
return 0;

Expand Down Expand Up @@ -408,10 +384,10 @@ static const struct da9062_regulator_info local_da9061_regulator_info[] = {
__builtin_ffs((int)DA9062AA_BUCK1_MODE_MASK) - 1,
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_BUCK1_MODE_MASK)) - 1),
.suspend = REG_FIELD(DA9062AA_DVC_1,
__builtin_ffs((int)DA9062AA_VBUCK1_SEL_MASK) - 1,
.suspend = REG_FIELD(DA9062AA_BUCK1_CONT,
__builtin_ffs((int)DA9062AA_BUCK1_CONF_MASK) - 1,
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_VBUCK1_SEL_MASK)) - 1),
__builtin_clz(DA9062AA_BUCK1_CONF_MASK) - 1),
},
{
.desc.id = DA9061_ID_BUCK2,
Expand Down Expand Up @@ -444,10 +420,10 @@ static const struct da9062_regulator_info local_da9061_regulator_info[] = {
__builtin_ffs((int)DA9062AA_BUCK3_MODE_MASK) - 1,
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_BUCK3_MODE_MASK)) - 1),
.suspend = REG_FIELD(DA9062AA_DVC_1,
__builtin_ffs((int)DA9062AA_VBUCK3_SEL_MASK) - 1,
.suspend = REG_FIELD(DA9062AA_BUCK3_CONT,
__builtin_ffs((int)DA9062AA_BUCK3_CONF_MASK) - 1,
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_VBUCK3_SEL_MASK)) - 1),
__builtin_clz(DA9062AA_BUCK3_CONF_MASK) - 1),
},
{
.desc.id = DA9061_ID_BUCK3,
Expand Down Expand Up @@ -480,10 +456,10 @@ static const struct da9062_regulator_info local_da9061_regulator_info[] = {
__builtin_ffs((int)DA9062AA_BUCK4_MODE_MASK) - 1,
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_BUCK4_MODE_MASK)) - 1),
.suspend = REG_FIELD(DA9062AA_DVC_1,
__builtin_ffs((int)DA9062AA_VBUCK4_SEL_MASK) - 1,
.suspend = REG_FIELD(DA9062AA_BUCK4_CONT,
__builtin_ffs((int)DA9062AA_BUCK4_CONF_MASK) - 1,
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_VBUCK4_SEL_MASK)) - 1),
__builtin_clz(DA9062AA_BUCK4_CONF_MASK) - 1),
},
{
.desc.id = DA9061_ID_LDO1,
Expand All @@ -509,10 +485,10 @@ static const struct da9062_regulator_info local_da9061_regulator_info[] = {
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_LDO1_SL_B_MASK)) - 1),
.suspend_vsel_reg = DA9062AA_VLDO1_B,
.suspend = REG_FIELD(DA9062AA_DVC_1,
__builtin_ffs((int)DA9062AA_VLDO1_SEL_MASK) - 1,
.suspend = REG_FIELD(DA9062AA_LDO1_CONT,
__builtin_ffs((int)DA9062AA_LDO1_CONF_MASK) - 1,
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_VLDO1_SEL_MASK)) - 1),
__builtin_clz(DA9062AA_LDO1_CONF_MASK) - 1),
.oc_event = REG_FIELD(DA9062AA_STATUS_D,
__builtin_ffs((int)DA9062AA_LDO1_ILIM_MASK) - 1,
sizeof(unsigned int) * 8 -
Expand Down Expand Up @@ -542,10 +518,10 @@ static const struct da9062_regulator_info local_da9061_regulator_info[] = {
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_LDO2_SL_B_MASK)) - 1),
.suspend_vsel_reg = DA9062AA_VLDO2_B,
.suspend = REG_FIELD(DA9062AA_DVC_1,
__builtin_ffs((int)DA9062AA_VLDO2_SEL_MASK) - 1,
.suspend = REG_FIELD(DA9062AA_LDO2_CONT,
__builtin_ffs((int)DA9062AA_LDO2_CONF_MASK) - 1,
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_VLDO2_SEL_MASK)) - 1),
__builtin_clz(DA9062AA_LDO2_CONF_MASK) - 1),
.oc_event = REG_FIELD(DA9062AA_STATUS_D,
__builtin_ffs((int)DA9062AA_LDO2_ILIM_MASK) - 1,
sizeof(unsigned int) * 8 -
Expand Down Expand Up @@ -575,10 +551,10 @@ static const struct da9062_regulator_info local_da9061_regulator_info[] = {
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_LDO3_SL_B_MASK)) - 1),
.suspend_vsel_reg = DA9062AA_VLDO3_B,
.suspend = REG_FIELD(DA9062AA_DVC_1,
__builtin_ffs((int)DA9062AA_VLDO3_SEL_MASK) - 1,
.suspend = REG_FIELD(DA9062AA_LDO3_CONT,
__builtin_ffs((int)DA9062AA_LDO3_CONF_MASK) - 1,
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_VLDO3_SEL_MASK)) - 1),
__builtin_clz(DA9062AA_LDO3_CONF_MASK) - 1),
.oc_event = REG_FIELD(DA9062AA_STATUS_D,
__builtin_ffs((int)DA9062AA_LDO3_ILIM_MASK) - 1,
sizeof(unsigned int) * 8 -
Expand Down Expand Up @@ -608,10 +584,10 @@ static const struct da9062_regulator_info local_da9061_regulator_info[] = {
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_LDO4_SL_B_MASK)) - 1),
.suspend_vsel_reg = DA9062AA_VLDO4_B,
.suspend = REG_FIELD(DA9062AA_DVC_1,
__builtin_ffs((int)DA9062AA_VLDO4_SEL_MASK) - 1,
.suspend = REG_FIELD(DA9062AA_LDO4_CONT,
__builtin_ffs((int)DA9062AA_LDO4_CONF_MASK) - 1,
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_VLDO4_SEL_MASK)) - 1),
__builtin_clz(DA9062AA_LDO4_CONF_MASK) - 1),
.oc_event = REG_FIELD(DA9062AA_STATUS_D,
__builtin_ffs((int)DA9062AA_LDO4_ILIM_MASK) - 1,
sizeof(unsigned int) * 8 -
Expand Down Expand Up @@ -652,10 +628,10 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = {
__builtin_ffs((int)DA9062AA_BUCK1_MODE_MASK) - 1,
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_BUCK1_MODE_MASK)) - 1),
.suspend = REG_FIELD(DA9062AA_DVC_1,
__builtin_ffs((int)DA9062AA_VBUCK1_SEL_MASK) - 1,
.suspend = REG_FIELD(DA9062AA_BUCK1_CONT,
__builtin_ffs((int)DA9062AA_BUCK1_CONF_MASK) - 1,
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_VBUCK1_SEL_MASK)) - 1),
__builtin_clz(DA9062AA_BUCK1_CONF_MASK) - 1),
},
{
.desc.id = DA9062_ID_BUCK2,
Expand Down Expand Up @@ -688,10 +664,10 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = {
__builtin_ffs((int)DA9062AA_BUCK2_MODE_MASK) - 1,
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_BUCK2_MODE_MASK)) - 1),
.suspend = REG_FIELD(DA9062AA_DVC_1,
__builtin_ffs((int)DA9062AA_VBUCK2_SEL_MASK) - 1,
.suspend = REG_FIELD(DA9062AA_BUCK2_CONT,
__builtin_ffs((int)DA9062AA_BUCK2_CONF_MASK) - 1,
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_VBUCK2_SEL_MASK)) - 1),
__builtin_clz(DA9062AA_BUCK2_CONF_MASK) - 1),
},
{
.desc.id = DA9062_ID_BUCK3,
Expand Down Expand Up @@ -724,10 +700,10 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = {
__builtin_ffs((int)DA9062AA_BUCK3_MODE_MASK) - 1,
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_BUCK3_MODE_MASK)) - 1),
.suspend = REG_FIELD(DA9062AA_DVC_1,
__builtin_ffs((int)DA9062AA_VBUCK3_SEL_MASK) - 1,
.suspend = REG_FIELD(DA9062AA_BUCK3_CONT,
__builtin_ffs((int)DA9062AA_BUCK3_CONF_MASK) - 1,
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_VBUCK3_SEL_MASK)) - 1),
__builtin_clz(DA9062AA_BUCK3_CONF_MASK) - 1),
},
{
.desc.id = DA9062_ID_BUCK4,
Expand Down Expand Up @@ -760,10 +736,10 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = {
__builtin_ffs((int)DA9062AA_BUCK4_MODE_MASK) - 1,
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_BUCK4_MODE_MASK)) - 1),
.suspend = REG_FIELD(DA9062AA_DVC_1,
__builtin_ffs((int)DA9062AA_VBUCK4_SEL_MASK) - 1,
.suspend = REG_FIELD(DA9062AA_BUCK4_CONT,
__builtin_ffs((int)DA9062AA_BUCK4_CONF_MASK) - 1,
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_VBUCK4_SEL_MASK)) - 1),
__builtin_clz(DA9062AA_BUCK4_CONF_MASK) - 1),
},
{
.desc.id = DA9062_ID_LDO1,
Expand All @@ -789,10 +765,10 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = {
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_LDO1_SL_B_MASK)) - 1),
.suspend_vsel_reg = DA9062AA_VLDO1_B,
.suspend = REG_FIELD(DA9062AA_DVC_1,
__builtin_ffs((int)DA9062AA_VLDO1_SEL_MASK) - 1,
.suspend = REG_FIELD(DA9062AA_LDO1_CONT,
__builtin_ffs((int)DA9062AA_LDO1_CONF_MASK) - 1,
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_VLDO1_SEL_MASK)) - 1),
__builtin_clz(DA9062AA_LDO1_CONF_MASK) - 1),
.oc_event = REG_FIELD(DA9062AA_STATUS_D,
__builtin_ffs((int)DA9062AA_LDO1_ILIM_MASK) - 1,
sizeof(unsigned int) * 8 -
Expand Down Expand Up @@ -822,10 +798,10 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = {
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_LDO2_SL_B_MASK)) - 1),
.suspend_vsel_reg = DA9062AA_VLDO2_B,
.suspend = REG_FIELD(DA9062AA_DVC_1,
__builtin_ffs((int)DA9062AA_VLDO2_SEL_MASK) - 1,
.suspend = REG_FIELD(DA9062AA_LDO2_CONT,
__builtin_ffs((int)DA9062AA_LDO2_CONF_MASK) - 1,
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_VLDO2_SEL_MASK)) - 1),
__builtin_clz(DA9062AA_LDO2_CONF_MASK) - 1),
.oc_event = REG_FIELD(DA9062AA_STATUS_D,
__builtin_ffs((int)DA9062AA_LDO2_ILIM_MASK) - 1,
sizeof(unsigned int) * 8 -
Expand Down Expand Up @@ -855,10 +831,10 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = {
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_LDO3_SL_B_MASK)) - 1),
.suspend_vsel_reg = DA9062AA_VLDO3_B,
.suspend = REG_FIELD(DA9062AA_DVC_1,
__builtin_ffs((int)DA9062AA_VLDO3_SEL_MASK) - 1,
.suspend = REG_FIELD(DA9062AA_LDO3_CONT,
__builtin_ffs((int)DA9062AA_LDO3_CONF_MASK) - 1,
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_VLDO3_SEL_MASK)) - 1),
__builtin_clz(DA9062AA_LDO3_CONF_MASK) - 1),
.oc_event = REG_FIELD(DA9062AA_STATUS_D,
__builtin_ffs((int)DA9062AA_LDO3_ILIM_MASK) - 1,
sizeof(unsigned int) * 8 -
Expand Down Expand Up @@ -888,10 +864,10 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = {
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_LDO4_SL_B_MASK)) - 1),
.suspend_vsel_reg = DA9062AA_VLDO4_B,
.suspend = REG_FIELD(DA9062AA_DVC_1,
__builtin_ffs((int)DA9062AA_VLDO4_SEL_MASK) - 1,
.suspend = REG_FIELD(DA9062AA_LDO4_CONT,
__builtin_ffs((int)DA9062AA_LDO4_CONF_MASK) - 1,
sizeof(unsigned int) * 8 -
__builtin_clz((DA9062AA_VLDO4_SEL_MASK)) - 1),
__builtin_clz(DA9062AA_LDO4_CONF_MASK) - 1),
.oc_event = REG_FIELD(DA9062AA_STATUS_D,
__builtin_ffs((int)DA9062AA_LDO4_ILIM_MASK) - 1,
sizeof(unsigned int) * 8 -
Expand Down
5 changes: 2 additions & 3 deletions drivers/regulator/fixed.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,7 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct fixed_voltage_config *config;
struct fixed_voltage_data *drvdata;
const struct fixed_dev_type *drvtype =
of_match_device(dev->driver->of_match_table, dev)->data;
const struct fixed_dev_type *drvtype = of_device_get_match_data(dev);
struct regulator_config cfg = { };
enum gpiod_flags gflags;
int ret;
Expand Down Expand Up @@ -177,7 +176,7 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev)
drvdata->desc.type = REGULATOR_VOLTAGE;
drvdata->desc.owner = THIS_MODULE;

if (drvtype->has_enable_clock) {
if (drvtype && drvtype->has_enable_clock) {
drvdata->desc.ops = &fixed_voltage_clkenabled_ops;

drvdata->enable_clock = devm_clk_get(dev, NULL);
Expand Down
1 change: 1 addition & 0 deletions drivers/regulator/lochnagar-regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ static const struct regulator_desc lochnagar_regulators[] = {

.enable_time = 3000,
.ramp_delay = 1000,
.off_on_delay = 15000,

.owner = THIS_MODULE,
},
Expand Down
27 changes: 18 additions & 9 deletions drivers/regulator/of_regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,12 @@ static int of_get_regulation_constraints(struct device *dev,
"regulator-off-in-suspend"))
suspend_state->enabled = DISABLE_IN_SUSPEND;

if (!of_property_read_u32(np, "regulator-suspend-min-microvolt",
&pval))
if (!of_property_read_u32(suspend_np,
"regulator-suspend-min-microvolt", &pval))
suspend_state->min_uV = pval;

if (!of_property_read_u32(np, "regulator-suspend-max-microvolt",
&pval))
if (!of_property_read_u32(suspend_np,
"regulator-suspend-max-microvolt", &pval))
suspend_state->max_uV = pval;

if (!of_property_read_u32(suspend_np,
Expand Down Expand Up @@ -445,11 +445,20 @@ struct regulator_init_data *regulator_of_get_init_data(struct device *dev,
goto error;
}

if (desc->of_parse_cb && desc->of_parse_cb(child, desc, config)) {
dev_err(dev,
"driver callback failed to parse DT for regulator %pOFn\n",
child);
goto error;
if (desc->of_parse_cb) {
int ret;

ret = desc->of_parse_cb(child, desc, config);
if (ret) {
if (ret == -EPROBE_DEFER) {
of_node_put(child);
return ERR_PTR(-EPROBE_DEFER);
}
dev_err(dev,
"driver callback failed to parse DT for regulator %pOFn\n",
child);
goto error;
}
}

*node = child;
Expand Down
8 changes: 7 additions & 1 deletion drivers/regulator/pfuze100-regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,13 @@ static int pfuze100_regulator_probe(struct i2c_client *client,

/* SW2~SW4 high bit check and modify the voltage value table */
if (i >= sw_check_start && i <= sw_check_end) {
regmap_read(pfuze_chip->regmap, desc->vsel_reg, &val);
ret = regmap_read(pfuze_chip->regmap,
desc->vsel_reg, &val);
if (ret) {
dev_err(&client->dev, "Fails to read from the register.\n");
return ret;
}

if (val & sw_hi) {
if (pfuze_chip->chip_id == PFUZE3000 ||
pfuze_chip->chip_id == PFUZE3001) {
Expand Down
4 changes: 2 additions & 2 deletions drivers/regulator/qcom-rpmh-regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -735,8 +735,8 @@ static const struct rpmh_vreg_hw_data pmic5_hfsmps515 = {
static const struct rpmh_vreg_hw_data pmic5_bob = {
.regulator_type = VRM,
.ops = &rpmh_regulator_vrm_bypass_ops,
.voltage_range = REGULATOR_LINEAR_RANGE(300000, 0, 135, 32000),
.n_voltages = 136,
.voltage_range = REGULATOR_LINEAR_RANGE(3000000, 0, 31, 32000),
.n_voltages = 32,
.pmic_mode_map = pmic_mode_map_pmic5_bob,
.of_map_mode = rpmh_regulator_pmic4_bob_of_map_mode,
};
Expand Down
Loading

0 comments on commit 5bf2a9e

Please sign in to comment.