Skip to content

Commit

Permalink
mfd: arizona: Support use of external DCVDD
Browse files Browse the repository at this point in the history
When the device is used with an external DCVDD supply instead of the
internal LDO1 then an extra step is required when suspending and resuming
the device.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
(cherry picked from commit 5927467d0ca274bc3b8eed9fd5db964bbde56e1c)

Change-Id: I19ec545b86012821110b2e6054b7c87a8bd119f8
Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
(cherry picked from commit c626f8c34bfbd3fd6b60944f3fcf351ec8a7dbc7)
  • Loading branch information
broonie authored and Yinjun Chen committed Mar 25, 2015
1 parent 57e53d5 commit 0b6c769
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
43 changes: 43 additions & 0 deletions drivers/mfd/arizona-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <linux/pm_runtime.h>
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>
#include <linux/regulator/machine.h>
#include <linux/slab.h>

#include <linux/mfd/arizona/core.h>
Expand Down Expand Up @@ -347,6 +348,17 @@ static int arizona_runtime_resume(struct device *dev)

switch (arizona->type) {
case WM5102:
if (arizona->external_dcvdd) {
ret = regmap_update_bits(arizona->regmap,
ARIZONA_ISOLATION_CONTROL,
ARIZONA_ISOLATE_DCVDD1, 0);
if (ret != 0) {
dev_err(arizona->dev,
"Failed to connect DCVDD: %d\n", ret);
goto err;
}
}

ret = wm5102_patch(arizona);
if (ret != 0) {
dev_err(arizona->dev, "Failed to apply patch: %d\n",
Expand All @@ -368,6 +380,16 @@ static int arizona_runtime_resume(struct device *dev)
goto err;
}

if (arizona->external_dcvdd) {
ret = regmap_update_bits(arizona->regmap,
ARIZONA_ISOLATION_CONTROL,
ARIZONA_ISOLATE_DCVDD1, 0);
if (ret != 0) {
dev_err(arizona->dev,
"Failed to connect DCVDD: %d\n", ret);
goto err;
}
}
break;
}

Expand All @@ -388,9 +410,22 @@ static int arizona_runtime_resume(struct device *dev)
static int arizona_runtime_suspend(struct device *dev)
{
struct arizona *arizona = dev_get_drvdata(dev);
int ret;

dev_dbg(arizona->dev, "Entering AoD mode\n");

if (arizona->external_dcvdd) {
ret = regmap_update_bits(arizona->regmap,
ARIZONA_ISOLATION_CONTROL,
ARIZONA_ISOLATE_DCVDD1,
ARIZONA_ISOLATE_DCVDD1);
if (ret != 0) {
dev_err(arizona->dev, "Failed to isolate DCVDD: %d\n",
ret);
return ret;
}
}

regulator_disable(arizona->dcvdd);
regcache_cache_only(arizona->regmap, true);
regcache_mark_dirty(arizona->regmap);
Expand Down Expand Up @@ -738,6 +773,14 @@ 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
2 changes: 2 additions & 0 deletions include/linux/mfd/arizona/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ struct arizona {

struct arizona_pdata pdata;

unsigned int external_dcvdd:1;

int irq;
struct irq_domain *virq;
struct regmap_irq_chip_data *aod_irq_chip;
Expand Down

0 comments on commit 0b6c769

Please sign in to comment.