Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Jerome Neanne and committed by
Mark Brown
adfdfcbd 947934e3

+17
+15
drivers/regulator/gpio-regulator.c
··· 220 220 regtype); 221 221 } 222 222 223 + if (of_find_property(np, "vin-supply", NULL)) 224 + config->input_supply = "vin"; 225 + 223 226 return config; 224 227 } 225 228 ··· 262 259 263 260 drvdata->gpiods = devm_kzalloc(dev, sizeof(struct gpio_desc *), 264 261 GFP_KERNEL); 262 + 263 + if (config->input_supply) { 264 + drvdata->desc.supply_name = devm_kstrdup(&pdev->dev, 265 + config->input_supply, 266 + GFP_KERNEL); 267 + if (!drvdata->desc.supply_name) { 268 + dev_err(&pdev->dev, 269 + "Failed to allocate input supply\n"); 270 + return -ENOMEM; 271 + } 272 + } 273 + 265 274 if (!drvdata->gpiods) 266 275 return -ENOMEM; 267 276 for (i = 0; i < config->ngpios; i++) {
+2
include/linux/regulator/gpio-regulator.h
··· 42 42 /** 43 43 * struct gpio_regulator_config - config structure 44 44 * @supply_name: Name of the regulator supply 45 + * @input_supply: Name of the input regulator supply 45 46 * @enabled_at_boot: Whether regulator has been enabled at 46 47 * boot or not. 1 = Yes, 0 = No 47 48 * This is used to keep the regulator at ··· 63 62 */ 64 63 struct gpio_regulator_config { 65 64 const char *supply_name; 65 + const char *input_supply; 66 66 67 67 unsigned enabled_at_boot:1; 68 68 unsigned startup_delay;