Skip to content

Commit

Permalink
regulator: arizona-ldo1: Move setup processing from arizona-core
Browse files Browse the repository at this point in the history
It is more idiomatic to process things relating to the regulator in its
driver. This patch moves both processing of device tree relating to the
regulator and checking if the regulator is external from arizona-core
into the regulator driver.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
  • Loading branch information
Charles Keepax authored and Mark Brown committed Apr 18, 2014
1 parent 36bcdf1 commit 4a8c475
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 9 deletions.
12 changes: 3 additions & 9 deletions drivers/mfd/arizona-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,6 @@ static int arizona_of_get_core_pdata(struct arizona *arizona)
int ret, i;

pdata->reset = arizona_of_get_named_gpio(arizona, "wlf,reset", true);
pdata->ldoena = arizona_of_get_named_gpio(arizona, "wlf,ldoena", true);

ret = of_property_read_u32_array(arizona->dev->of_node,
"wlf,gpio-defaults",
Expand Down Expand Up @@ -665,6 +664,9 @@ int arizona_dev_init(struct arizona *arizona)
return -EINVAL;
}

/* Mark DCVDD as external, LDO1 driver will clear if internal */
arizona->external_dcvdd = true;

ret = mfd_add_devices(arizona->dev, -1, early_devs,
ARRAY_SIZE(early_devs), NULL, 0, NULL);
if (ret != 0) {
Expand Down Expand Up @@ -864,14 +866,6 @@ int arizona_dev_init(struct arizona *arizona)
arizona->pdata.gpio_defaults[i]);
}

/*
* LDO1 can only be used to supply DCVDD so if it has no
* consumers then DCVDD is supplied externally.
*/
if (arizona->pdata.ldo1 &&
arizona->pdata.ldo1->num_consumer_supplies == 0)
arizona->external_dcvdd = true;

pm_runtime_set_autosuspend_delay(arizona->dev, 100);
pm_runtime_use_autosuspend(arizona->dev);
pm_runtime_enable(arizona->dev);
Expand Down
27 changes: 27 additions & 0 deletions drivers/regulator/arizona-ldo1.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,15 @@ static const struct regulator_init_data arizona_ldo1_default = {
.num_consumer_supplies = 1,
};

static int arizona_ldo1_of_get_pdata(struct arizona *arizona)
{
struct arizona_pdata *pdata = &arizona->pdata;

pdata->ldoena = arizona_of_get_named_gpio(arizona, "wlf,ldoena", true);

return 0;
}

static int arizona_ldo1_probe(struct platform_device *pdev)
{
struct arizona *arizona = dev_get_drvdata(pdev->dev.parent);
Expand All @@ -186,6 +195,8 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
struct arizona_ldo1 *ldo1;
int ret;

arizona->external_dcvdd = false;

ldo1 = devm_kzalloc(&pdev->dev, sizeof(*ldo1), GFP_KERNEL);
if (!ldo1)
return -ENOMEM;
Expand Down Expand Up @@ -216,13 +227,29 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
config.dev = arizona->dev;
config.driver_data = ldo1;
config.regmap = arizona->regmap;

if (IS_ENABLED(CONFIG_OF)) {
if (!dev_get_platdata(arizona->dev)) {
ret = arizona_ldo1_of_get_pdata(arizona);
if (ret < 0)
return ret;
}
}

config.ena_gpio = arizona->pdata.ldoena;

if (arizona->pdata.ldo1)
config.init_data = arizona->pdata.ldo1;
else
config.init_data = &ldo1->init_data;

/*
* LDO1 can only be used to supply DCVDD so if it has no
* consumers then DCVDD is supplied externally.
*/
if (config.init_data->num_consumer_supplies == 0)
arizona->external_dcvdd = true;

ldo1->regulator = devm_regulator_register(&pdev->dev, desc, &config);
if (IS_ERR(ldo1->regulator)) {
ret = PTR_ERR(ldo1->regulator);
Expand Down

0 comments on commit 4a8c475

Please sign in to comment.