Skip to content

Commit 07bbfc6

Browse files
committed
Merge tag 'regulator-v6.10' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator
Pull regulator updates from Mark Brown: "There's one API update here, a new API factoring out a common pattern for reference voltage supplies. These are supplies used as a reference by analogue circuits where the consumer requests and enables the supply, reads the voltage to calibrate the user and then never touches it again. This is factored out into a single operation which just returns the voltage and uses devm_ to manage the request and enable portion. Otherwise this has been a very quiet release, we've got some new device support, some small fixes, housekeeping and cleanup work but nothing substantial. There's also some non-regulator changes in here, a number of users for the new reference voltage API were merged along with it and some MFD changes were pulled in as dependencies for new driver work. Highlights: - Add a new API for single operation handling of reference voltages - Support for Allwinner AXP717 and D1, and NXP PCA9561A" * tag 'regulator-v6.10' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator: (33 commits) regulator: sun20i: Add Allwinner D1 LDOs driver regulator: dt-bindings: Add Allwinner D1 system LDOs regulator: Mention regulator id in error message about dummy supplies staging: iio: impedance-analyzer: ad5933: Use devm_regulator_get_enable_read_voltage() iio: frequency: admv1013: Use devm_regulator_get_enable_read_voltage() iio: addac: ad74115: Use devm_regulator_get_enable_read_voltage() hwmon: (adc128d818) simplify final return in probe regulator: devres: fix devm_regulator_get_enable_read_voltage() return hwmon: (da9052) Use devm_regulator_get_enable_read_voltage() hwmon: (adc128d818) Use devm_regulator_get_enable_read_voltage() regulator: devres: add API for reference voltage supplies regulator: rtq2208: Fix LDO discharge register and add vsel setting regulator: dt-bindings: fixed-regulator: Add a preferred node name regulator: axp20x: add support for the AXP717 mfd: axp20x: Add support for AXP717 PMIC dt-bindings: mfd: x-powers,axp152: Document AXP717 regulator: axp20x: fix typo-ed identifier dt-bindings: regulator: qcom,usb-vbus-regulator: Add PM7250B compatible regulator: pca9450: add pca9451a support regulator: dt-bindings: pca9450: add pca9451a support ...
2 parents fffe418 + 4e70b26 commit 07bbfc6

37 files changed

+879
-215
lines changed

Documentation/devicetree/bindings/mfd/x-powers,axp152.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ allOf:
8383
enum:
8484
- x-powers,axp313a
8585
- x-powers,axp15060
86+
- x-powers,axp717
8687

8788
then:
8889
properties:
@@ -99,6 +100,7 @@ properties:
99100
- x-powers,axp221
100101
- x-powers,axp223
101102
- x-powers,axp313a
103+
- x-powers,axp717
102104
- x-powers,axp803
103105
- x-powers,axp806
104106
- x-powers,axp809
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/regulator/allwinner,sun20i-d1-system-ldos.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: Allwinner D1 System LDOs
8+
9+
maintainers:
10+
- Samuel Holland <[email protected]>
11+
12+
description:
13+
Allwinner D1 contains a pair of general-purpose LDOs which are designed to
14+
supply power inside and outside the SoC. They are controlled by a register
15+
within the system control MMIO space.
16+
17+
properties:
18+
compatible:
19+
enum:
20+
- allwinner,sun20i-d1-system-ldos
21+
22+
reg:
23+
maxItems: 1
24+
25+
patternProperties:
26+
"^ldo[ab]$":
27+
type: object
28+
$ref: regulator.yaml#
29+
unevaluatedProperties: false
30+
31+
required:
32+
- compatible
33+
- reg
34+
35+
additionalProperties: false
36+
37+
...

Documentation/devicetree/bindings/regulator/fixed-regulator.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ allOf:
4141
- gpios
4242

4343
properties:
44+
$nodename:
45+
anyOf:
46+
- description: Preferred name is 'regulator-[0-9]v[0-9]'
47+
pattern: '^regulator(-[0-9]+v[0-9]+|-[0-9a-z-]+)?$'
48+
- description: Any name allowed
49+
deprecated: true
50+
4451
compatible:
4552
enum:
4653
- regulator-fixed

Documentation/devicetree/bindings/regulator/nxp,pca9450-regulator.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ properties:
2828
- nxp,pca9450a
2929
- nxp,pca9450b
3030
- nxp,pca9450c
31+
- nxp,pca9451a
3132

3233
reg:
3334
maxItems: 1

Documentation/devicetree/bindings/regulator/qcom,usb-vbus-regulator.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ properties:
2626
- enum:
2727
- qcom,pm4125-vbus-reg
2828
- qcom,pm6150-vbus-reg
29+
- qcom,pm7250b-vbus-reg
2930
- qcom,pmi632-vbus-reg
3031
- const: qcom,pm8150b-vbus-reg
3132

Documentation/driver-api/driver-model/devres.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,7 @@ REGULATOR
433433
devm_regulator_bulk_put()
434434
devm_regulator_get()
435435
devm_regulator_get_enable()
436+
devm_regulator_get_enable_read_voltage()
436437
devm_regulator_get_enable_optional()
437438
devm_regulator_get_exclusive()
438439
devm_regulator_get_optional()

drivers/hwmon/adc128d818.c

Lines changed: 16 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ static const u8 num_inputs[] = { 7, 8, 4, 6 };
5858

5959
struct adc128_data {
6060
struct i2c_client *client;
61-
struct regulator *regulator;
6261
int vref; /* Reference voltage in mV */
6362
struct mutex update_lock;
6463
u8 mode; /* Operation mode */
@@ -389,7 +388,7 @@ static int adc128_detect(struct i2c_client *client, struct i2c_board_info *info)
389388
return 0;
390389
}
391390

392-
static int adc128_init_client(struct adc128_data *data)
391+
static int adc128_init_client(struct adc128_data *data, bool external_vref)
393392
{
394393
struct i2c_client *client = data->client;
395394
int err;
@@ -408,7 +407,7 @@ static int adc128_init_client(struct adc128_data *data)
408407
regval |= data->mode << 1;
409408

410409
/* If external vref is selected, configure the chip to use it */
411-
if (data->regulator)
410+
if (external_vref)
412411
regval |= 0x01;
413412

414413
/* Write advanced configuration register */
@@ -430,44 +429,38 @@ static int adc128_init_client(struct adc128_data *data)
430429
static int adc128_probe(struct i2c_client *client)
431430
{
432431
struct device *dev = &client->dev;
433-
struct regulator *regulator;
434432
struct device *hwmon_dev;
435433
struct adc128_data *data;
434+
bool external_vref;
436435
int err, vref;
437436

438437
data = devm_kzalloc(dev, sizeof(struct adc128_data), GFP_KERNEL);
439438
if (!data)
440439
return -ENOMEM;
441440

442441
/* vref is optional. If specified, is used as chip reference voltage */
443-
regulator = devm_regulator_get_optional(dev, "vref");
444-
if (!IS_ERR(regulator)) {
445-
data->regulator = regulator;
446-
err = regulator_enable(regulator);
447-
if (err < 0)
448-
return err;
449-
vref = regulator_get_voltage(regulator);
450-
if (vref < 0) {
451-
err = vref;
452-
goto error;
453-
}
454-
data->vref = DIV_ROUND_CLOSEST(vref, 1000);
455-
} else {
442+
vref = devm_regulator_get_enable_read_voltage(dev, "vref");
443+
if (vref == -ENODEV) {
444+
external_vref = false;
456445
data->vref = 2560; /* 2.56V, in mV */
446+
} else if (vref < 0) {
447+
return vref;
448+
} else {
449+
external_vref = true;
450+
data->vref = DIV_ROUND_CLOSEST(vref, 1000);
457451
}
458452

459453
/* Operation mode is optional. If unspecified, keep current mode */
460454
if (of_property_read_u8(dev->of_node, "ti,mode", &data->mode) == 0) {
461455
if (data->mode > 3) {
462456
dev_err(dev, "invalid operation mode %d\n",
463457
data->mode);
464-
err = -EINVAL;
465-
goto error;
458+
return -EINVAL;
466459
}
467460
} else {
468461
err = i2c_smbus_read_byte_data(client, ADC128_REG_CONFIG_ADV);
469462
if (err < 0)
470-
goto error;
463+
return err;
471464
data->mode = (err >> 1) & ADC128_REG_MASK;
472465
}
473466

@@ -476,31 +469,14 @@ static int adc128_probe(struct i2c_client *client)
476469
mutex_init(&data->update_lock);
477470

478471
/* Initialize the chip */
479-
err = adc128_init_client(data);
472+
err = adc128_init_client(data, external_vref);
480473
if (err < 0)
481-
goto error;
474+
return err;
482475

483476
hwmon_dev = devm_hwmon_device_register_with_groups(dev, client->name,
484477
data, adc128_groups);
485-
if (IS_ERR(hwmon_dev)) {
486-
err = PTR_ERR(hwmon_dev);
487-
goto error;
488-
}
489-
490-
return 0;
491-
492-
error:
493-
if (data->regulator)
494-
regulator_disable(data->regulator);
495-
return err;
496-
}
497-
498-
static void adc128_remove(struct i2c_client *client)
499-
{
500-
struct adc128_data *data = i2c_get_clientdata(client);
501478

502-
if (data->regulator)
503-
regulator_disable(data->regulator);
479+
return PTR_ERR_OR_ZERO(hwmon_dev);
504480
}
505481

506482
static const struct i2c_device_id adc128_id[] = {
@@ -522,7 +498,6 @@ static struct i2c_driver adc128_driver = {
522498
.of_match_table = of_match_ptr(adc128_of_match),
523499
},
524500
.probe = adc128_probe,
525-
.remove = adc128_remove,
526501
.id_table = adc128_id,
527502
.detect = adc128_detect,
528503
.address_list = normal_i2c,

drivers/hwmon/da9052-hwmon.c

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ struct da9052_hwmon {
2626
struct mutex hwmon_lock;
2727
bool tsi_as_adc;
2828
int tsiref_mv;
29-
struct regulator *tsiref;
3029
struct completion tsidone;
3130
};
3231

@@ -397,7 +396,7 @@ static int da9052_hwmon_probe(struct platform_device *pdev)
397396
struct device *dev = &pdev->dev;
398397
struct da9052_hwmon *hwmon;
399398
struct device *hwmon_dev;
400-
int err;
399+
int err, tsiref_uv;
401400

402401
hwmon = devm_kzalloc(dev, sizeof(struct da9052_hwmon), GFP_KERNEL);
403402
if (!hwmon)
@@ -414,32 +413,20 @@ static int da9052_hwmon_probe(struct platform_device *pdev)
414413
device_property_read_bool(pdev->dev.parent, "dlg,tsi-as-adc");
415414

416415
if (hwmon->tsi_as_adc) {
417-
hwmon->tsiref = devm_regulator_get(pdev->dev.parent, "tsiref");
418-
if (IS_ERR(hwmon->tsiref)) {
419-
err = PTR_ERR(hwmon->tsiref);
420-
dev_err(&pdev->dev, "failed to get tsiref: %d", err);
421-
return err;
422-
}
423-
424-
err = regulator_enable(hwmon->tsiref);
425-
if (err)
426-
return err;
427-
428-
hwmon->tsiref_mv = regulator_get_voltage(hwmon->tsiref);
429-
if (hwmon->tsiref_mv < 0) {
430-
err = hwmon->tsiref_mv;
431-
goto exit_regulator;
432-
}
416+
tsiref_uv = devm_regulator_get_enable_read_voltage(dev->parent,
417+
"tsiref");
418+
if (tsiref_uv < 0)
419+
return dev_err_probe(dev, tsiref_uv,
420+
"failed to get tsiref voltage\n");
433421

434422
/* convert from microvolt (DT) to millivolt (hwmon) */
435-
hwmon->tsiref_mv /= 1000;
423+
hwmon->tsiref_mv = tsiref_uv / 1000;
436424

437425
/* TSIREF limits from datasheet */
438426
if (hwmon->tsiref_mv < 1800 || hwmon->tsiref_mv > 2600) {
439427
dev_err(hwmon->da9052->dev, "invalid TSIREF voltage: %d",
440428
hwmon->tsiref_mv);
441-
err = -ENXIO;
442-
goto exit_regulator;
429+
return -ENXIO;
443430
}
444431

445432
/* disable touchscreen features */
@@ -456,7 +443,7 @@ static int da9052_hwmon_probe(struct platform_device *pdev)
456443
if (err) {
457444
dev_err(&pdev->dev, "Failed to register TSIRDY IRQ: %d",
458445
err);
459-
goto exit_regulator;
446+
return err;
460447
}
461448
}
462449

@@ -472,9 +459,6 @@ static int da9052_hwmon_probe(struct platform_device *pdev)
472459
exit_irq:
473460
if (hwmon->tsi_as_adc)
474461
da9052_free_irq(hwmon->da9052, DA9052_IRQ_TSIREADY, hwmon);
475-
exit_regulator:
476-
if (hwmon->tsiref)
477-
regulator_disable(hwmon->tsiref);
478462

479463
return err;
480464
}
@@ -483,10 +467,8 @@ static void da9052_hwmon_remove(struct platform_device *pdev)
483467
{
484468
struct da9052_hwmon *hwmon = platform_get_drvdata(pdev);
485469

486-
if (hwmon->tsi_as_adc) {
470+
if (hwmon->tsi_as_adc)
487471
da9052_free_irq(hwmon->da9052, DA9052_IRQ_TSIREADY, hwmon);
488-
regulator_disable(hwmon->tsiref);
489-
}
490472
}
491473

492474
static struct platform_driver da9052_hwmon_driver = {

drivers/iio/addac/ad74115.c

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ struct ad74115_state {
199199
struct spi_device *spi;
200200
struct regmap *regmap;
201201
struct iio_trigger *trig;
202-
struct regulator *avdd;
203202

204203
/*
205204
* Synchronize consecutive operations when doing a one-shot
@@ -1672,13 +1671,9 @@ static int ad74115_setup(struct iio_dev *indio_dev)
16721671
if (ret)
16731672
return ret;
16741673

1675-
if (val == AD74115_DIN_THRESHOLD_MODE_AVDD) {
1676-
ret = regulator_get_voltage(st->avdd);
1677-
if (ret < 0)
1678-
return ret;
1679-
1680-
st->avdd_mv = ret / 1000;
1681-
}
1674+
if (val == AD74115_DIN_THRESHOLD_MODE_AVDD && !st->avdd_mv)
1675+
return dev_err_probe(dev, -EINVAL,
1676+
"AVDD voltage is required for digital input threshold mode AVDD\n");
16821677

16831678
st->din_threshold_mode = val;
16841679

@@ -1788,11 +1783,6 @@ static int ad74115_reset(struct ad74115_state *st)
17881783
return 0;
17891784
}
17901785

1791-
static void ad74115_regulator_disable(void *data)
1792-
{
1793-
regulator_disable(data);
1794-
}
1795-
17961786
static int ad74115_setup_trigger(struct iio_dev *indio_dev)
17971787
{
17981788
struct ad74115_state *st = iio_priv(indio_dev);
@@ -1855,20 +1845,20 @@ static int ad74115_probe(struct spi_device *spi)
18551845
indio_dev->modes = INDIO_DIRECT_MODE;
18561846
indio_dev->info = &ad74115_info;
18571847

1858-
st->avdd = devm_regulator_get(dev, "avdd");
1859-
if (IS_ERR(st->avdd))
1860-
return PTR_ERR(st->avdd);
1861-
1862-
ret = regulator_enable(st->avdd);
1863-
if (ret) {
1864-
dev_err(dev, "Failed to enable avdd regulator\n");
1865-
return ret;
1848+
ret = devm_regulator_get_enable_read_voltage(dev, "avdd");
1849+
if (ret < 0) {
1850+
/*
1851+
* Since this is both a power supply and only optionally a
1852+
* reference voltage, make sure to enable it even when the
1853+
* voltage is not available.
1854+
*/
1855+
ret = devm_regulator_get_enable(dev, "avdd");
1856+
if (ret)
1857+
return dev_err_probe(dev, ret, "failed to enable avdd\n");
1858+
} else {
1859+
st->avdd_mv = ret / 1000;
18661860
}
18671861

1868-
ret = devm_add_action_or_reset(dev, ad74115_regulator_disable, st->avdd);
1869-
if (ret)
1870-
return ret;
1871-
18721862
ret = devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(regulator_names),
18731863
regulator_names);
18741864
if (ret)

0 commit comments

Comments
 (0)