Skip to content

Commit 4b561d1

Browse files
committed
Merge tag 'regulator-fix-v6.8-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator
Pull regulator fixes from Mark Brown: "The main set of fixes here are for the PWM regulator, fixing bootstrapping issues on some platforms where the hardware setup looked like it was out of spec for the constraints we have for the regulator causing us to make spurious and unhelpful changes to try to bring things in line with the constraints. There's also a couple of other driver specific fixes" * tag 'regulator-fix-v6.8-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator: regulator (max5970): Fix IRQ handler regulator: ti-abb: don't use devm_platform_ioremap_resource_byname for shared interrupt register regulator: pwm-regulator: Manage boot-on with disabled PWM channels regulator: pwm-regulator: Calculate the output voltage for disabled PWMs regulator: pwm-regulator: Add validity checks in continuous .get_voltage
2 parents 8a2514c + a3fa983 commit 4b561d1

File tree

3 files changed

+63
-4
lines changed

3 files changed

+63
-4
lines changed

drivers/regulator/max5970-regulator.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ static int max597x_regmap_read_clear(struct regmap *map, unsigned int reg,
392392
return ret;
393393

394394
if (*val)
395-
return regmap_write(map, reg, *val);
395+
return regmap_write(map, reg, 0);
396396

397397
return 0;
398398
}

drivers/regulator/pwm-regulator.c

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,17 @@ static int pwm_regulator_get_voltage(struct regulator_dev *rdev)
157157

158158
pwm_get_state(drvdata->pwm, &pstate);
159159

160+
if (!pstate.enabled) {
161+
if (pstate.polarity == PWM_POLARITY_INVERSED)
162+
pstate.duty_cycle = pstate.period;
163+
else
164+
pstate.duty_cycle = 0;
165+
}
166+
160167
voltage = pwm_get_relative_duty_cycle(&pstate, duty_unit);
168+
if (voltage < min(max_uV_duty, min_uV_duty) ||
169+
voltage > max(max_uV_duty, min_uV_duty))
170+
return -ENOTRECOVERABLE;
161171

162172
/*
163173
* The dutycycle for min_uV might be greater than the one for max_uV.
@@ -313,6 +323,32 @@ static int pwm_regulator_init_continuous(struct platform_device *pdev,
313323
return 0;
314324
}
315325

326+
static int pwm_regulator_init_boot_on(struct platform_device *pdev,
327+
struct pwm_regulator_data *drvdata,
328+
const struct regulator_init_data *init_data)
329+
{
330+
struct pwm_state pstate;
331+
332+
if (!init_data->constraints.boot_on || drvdata->enb_gpio)
333+
return 0;
334+
335+
pwm_get_state(drvdata->pwm, &pstate);
336+
if (pstate.enabled)
337+
return 0;
338+
339+
/*
340+
* Update the duty cycle so the output does not change
341+
* when the regulator core enables the regulator (and
342+
* thus the PWM channel).
343+
*/
344+
if (pstate.polarity == PWM_POLARITY_INVERSED)
345+
pstate.duty_cycle = pstate.period;
346+
else
347+
pstate.duty_cycle = 0;
348+
349+
return pwm_apply_might_sleep(drvdata->pwm, &pstate);
350+
}
351+
316352
static int pwm_regulator_probe(struct platform_device *pdev)
317353
{
318354
const struct regulator_init_data *init_data;
@@ -372,6 +408,13 @@ static int pwm_regulator_probe(struct platform_device *pdev)
372408
if (ret)
373409
return ret;
374410

411+
ret = pwm_regulator_init_boot_on(pdev, drvdata, init_data);
412+
if (ret) {
413+
dev_err(&pdev->dev, "Failed to apply boot_on settings: %d\n",
414+
ret);
415+
return ret;
416+
}
417+
375418
regulator = devm_regulator_register(&pdev->dev,
376419
&drvdata->desc, &config);
377420
if (IS_ERR(regulator)) {

drivers/regulator/ti-abb-regulator.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -726,9 +726,25 @@ static int ti_abb_probe(struct platform_device *pdev)
726726
return PTR_ERR(abb->setup_reg);
727727
}
728728

729-
abb->int_base = devm_platform_ioremap_resource_byname(pdev, "int-address");
730-
if (IS_ERR(abb->int_base))
731-
return PTR_ERR(abb->int_base);
729+
pname = "int-address";
730+
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, pname);
731+
if (!res) {
732+
dev_err(dev, "Missing '%s' IO resource\n", pname);
733+
return -ENODEV;
734+
}
735+
/*
736+
* The MPU interrupt status register (PRM_IRQSTATUS_MPU) is
737+
* shared between regulator-abb-{ivahd,dspeve,gpu} driver
738+
* instances. Therefore use devm_ioremap() rather than
739+
* devm_platform_ioremap_resource_byname() to avoid busy
740+
* resource region conflicts.
741+
*/
742+
abb->int_base = devm_ioremap(dev, res->start,
743+
resource_size(res));
744+
if (!abb->int_base) {
745+
dev_err(dev, "Unable to map '%s'\n", pname);
746+
return -ENOMEM;
747+
}
732748

733749
/* Map Optional resources */
734750
pname = "efuse-address";

0 commit comments

Comments
 (0)