Skip to content

Commit baca986

Browse files
bolilingmeng89006lag-linaro
authored andcommitted
leds: aw2013: Enable pull-up supply for interrupt and I2C
Request and enable the "vio" regulator that represents the power supply that is needed for the pull-up resistors of the interrupt and I2C lines of AW2013. While this regulator is not wired directly to the AW2013 chip it is best managed as part of the AW2013 driver since it decides when AW2013 is powered on and when the interrupt is enabled or disabled. This regulator should always be enabled in conjunction with the main VCC power supply, so use the bulk regulator functions to enable both at the same time. Signed-off-by: Lin, Meng-Bo <[email protected]> [rewrite commit message based on discussion] Signed-off-by: Stephan Gerhold <[email protected]> Reviewed-by: Nikita Travkin <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lee Jones <[email protected]>
1 parent 2cccb17 commit baca986

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

drivers/leds/leds-aw2013.c

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ struct aw2013_led {
6262

6363
struct aw2013 {
6464
struct mutex mutex; /* held when writing to registers */
65-
struct regulator *vcc_regulator;
65+
struct regulator_bulk_data regulators[2];
6666
struct i2c_client *client;
6767
struct aw2013_led leds[AW2013_MAX_LEDS];
6868
struct regmap *regmap;
@@ -106,10 +106,11 @@ static void aw2013_chip_disable(struct aw2013 *chip)
106106

107107
regmap_write(chip->regmap, AW2013_GCR, 0);
108108

109-
ret = regulator_disable(chip->vcc_regulator);
109+
ret = regulator_bulk_disable(ARRAY_SIZE(chip->regulators),
110+
chip->regulators);
110111
if (ret) {
111112
dev_err(&chip->client->dev,
112-
"Failed to disable regulator: %d\n", ret);
113+
"Failed to disable regulators: %d\n", ret);
113114
return;
114115
}
115116

@@ -123,10 +124,11 @@ static int aw2013_chip_enable(struct aw2013 *chip)
123124
if (chip->enabled)
124125
return 0;
125126

126-
ret = regulator_enable(chip->vcc_regulator);
127+
ret = regulator_bulk_enable(ARRAY_SIZE(chip->regulators),
128+
chip->regulators);
127129
if (ret) {
128130
dev_err(&chip->client->dev,
129-
"Failed to enable regulator: %d\n", ret);
131+
"Failed to enable regulators: %d\n", ret);
130132
return ret;
131133
}
132134
chip->enabled = true;
@@ -348,19 +350,23 @@ static int aw2013_probe(struct i2c_client *client)
348350
goto error;
349351
}
350352

351-
chip->vcc_regulator = devm_regulator_get(&client->dev, "vcc");
352-
ret = PTR_ERR_OR_ZERO(chip->vcc_regulator);
353-
if (ret) {
353+
chip->regulators[0].supply = "vcc";
354+
chip->regulators[1].supply = "vio";
355+
ret = devm_regulator_bulk_get(&client->dev,
356+
ARRAY_SIZE(chip->regulators),
357+
chip->regulators);
358+
if (ret < 0) {
354359
if (ret != -EPROBE_DEFER)
355360
dev_err(&client->dev,
356-
"Failed to request regulator: %d\n", ret);
361+
"Failed to request regulators: %d\n", ret);
357362
goto error;
358363
}
359364

360-
ret = regulator_enable(chip->vcc_regulator);
365+
ret = regulator_bulk_enable(ARRAY_SIZE(chip->regulators),
366+
chip->regulators);
361367
if (ret) {
362368
dev_err(&client->dev,
363-
"Failed to enable regulator: %d\n", ret);
369+
"Failed to enable regulators: %d\n", ret);
364370
goto error;
365371
}
366372

@@ -382,10 +388,11 @@ static int aw2013_probe(struct i2c_client *client)
382388
if (ret < 0)
383389
goto error_reg;
384390

385-
ret = regulator_disable(chip->vcc_regulator);
391+
ret = regulator_bulk_disable(ARRAY_SIZE(chip->regulators),
392+
chip->regulators);
386393
if (ret) {
387394
dev_err(&client->dev,
388-
"Failed to disable regulator: %d\n", ret);
395+
"Failed to disable regulators: %d\n", ret);
389396
goto error;
390397
}
391398

@@ -394,7 +401,8 @@ static int aw2013_probe(struct i2c_client *client)
394401
return 0;
395402

396403
error_reg:
397-
regulator_disable(chip->vcc_regulator);
404+
regulator_bulk_disable(ARRAY_SIZE(chip->regulators),
405+
chip->regulators);
398406

399407
error:
400408
mutex_destroy(&chip->mutex);

0 commit comments

Comments
 (0)