Skip to content

Commit adfdfcb

Browse files
jneannebroonie
authored andcommitted
regulator: gpio: Add input_supply support in gpio_regulator_config
This is simillar as fixed-regulator. Used to extract regulator parent from the device tree. Without that property used, the parent regulator can be shut down (if not an always on). Thus leading to inappropriate behavior: On am62-SP-SK this fix is required to avoid tps65219 ldo1 (SDMMC rail) to be shut down after boot completion. Signed-off-by: Jerome Neanne <jneanne@baylibre.com> Link: https://lore.kernel.org/r/20220929132526.29427-2-jneanne@baylibre.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 947934e commit adfdfcb

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

drivers/regulator/gpio-regulator.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,9 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np,
220220
regtype);
221221
}
222222

223+
if (of_find_property(np, "vin-supply", NULL))
224+
config->input_supply = "vin";
225+
223226
return config;
224227
}
225228

@@ -259,6 +262,18 @@ static int gpio_regulator_probe(struct platform_device *pdev)
259262

260263
drvdata->gpiods = devm_kzalloc(dev, sizeof(struct gpio_desc *),
261264
GFP_KERNEL);
265+
266+
if (config->input_supply) {
267+
drvdata->desc.supply_name = devm_kstrdup(&pdev->dev,
268+
config->input_supply,
269+
GFP_KERNEL);
270+
if (!drvdata->desc.supply_name) {
271+
dev_err(&pdev->dev,
272+
"Failed to allocate input supply\n");
273+
return -ENOMEM;
274+
}
275+
}
276+
262277
if (!drvdata->gpiods)
263278
return -ENOMEM;
264279
for (i = 0; i < config->ngpios; i++) {

include/linux/regulator/gpio-regulator.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ struct gpio_regulator_state {
4242
/**
4343
* struct gpio_regulator_config - config structure
4444
* @supply_name: Name of the regulator supply
45+
* @input_supply: Name of the input regulator supply
4546
* @enabled_at_boot: Whether regulator has been enabled at
4647
* boot or not. 1 = Yes, 0 = No
4748
* This is used to keep the regulator at
@@ -62,6 +63,7 @@ struct gpio_regulator_state {
6263
*/
6364
struct gpio_regulator_config {
6465
const char *supply_name;
66+
const char *input_supply;
6567

6668
unsigned enabled_at_boot:1;
6769
unsigned startup_delay;

0 commit comments

Comments
 (0)