|
@@ -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);
|
|
@@ -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;
|
|
@@ -216,6 +227,15 @@ 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)
|
|
@@ -223,6 +243,13 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
|
|
|
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);
|