Skip to content

Commit

Permalink
regulator: wm8994: Provide default init data
Browse files Browse the repository at this point in the history
Almost all systems use the regulators on the WM8994 series devices to
provide DCVDD and AVDD1 so if no init data is supplied then set up the
supplies for the user. This simplifies integration of the device into
systems, especially when device tree is supported.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
  • Loading branch information
Mark Brown committed Apr 7, 2013
1 parent 0565021 commit e3d2777
Showing 1 changed file with 39 additions and 2 deletions.
41 changes: 39 additions & 2 deletions drivers/regulator/wm8994-regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <linux/err.h>
#include <linux/platform_device.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/machine.h>
#include <linux/gpio.h>
#include <linux/slab.h>

Expand All @@ -28,6 +29,8 @@
struct wm8994_ldo {
struct regulator_dev *regulator;
struct wm8994 *wm8994;
struct regulator_consumer_supply supply;
struct regulator_init_data init_data;
};

#define WM8994_LDO1_MAX_SELECTOR 0x7
Expand Down Expand Up @@ -99,6 +102,26 @@ static const struct regulator_desc wm8994_ldo_desc[] = {
},
};

static const struct regulator_consumer_supply wm8994_ldo_consumer[] = {
{ .supply = "AVDD1" },
{ .supply = "DCVDD" },
};

static const struct regulator_init_data wm8994_ldo_default[] = {
{
.constraints = {
.valid_ops_mask = REGULATOR_CHANGE_STATUS,
},
.num_consumer_supplies = 1,
},
{
.constraints = {
.valid_ops_mask = REGULATOR_CHANGE_STATUS,
},
.num_consumer_supplies = 1,
},
};

static int wm8994_ldo_probe(struct platform_device *pdev)
{
struct wm8994 *wm8994 = dev_get_drvdata(pdev->dev.parent);
Expand All @@ -117,13 +140,27 @@ static int wm8994_ldo_probe(struct platform_device *pdev)
}

ldo->wm8994 = wm8994;
ldo->supply = wm8994_ldo_consumer[id];
ldo->supply.dev_name = dev_name(wm8994->dev);

config.dev = wm8994->dev;
config.driver_data = ldo;
config.regmap = wm8994->regmap;
if (pdata) {
config.init_data = pdata->ldo[id].init_data;
config.init_data = &ldo->init_data;
if (pdata)
config.ena_gpio = pdata->ldo[id].enable;

/* Use default constraints if none set up */
if (!pdata || !pdata->ldo[id].init_data) {
dev_dbg(wm8994->dev, "Using default init data, supply %s %s\n",
ldo->supply.dev_name, ldo->supply.supply);

ldo->init_data = wm8994_ldo_default[id];
ldo->init_data.consumer_supplies = &ldo->supply;
if (!config.ena_gpio)
ldo->init_data.constraints.valid_ops_mask = 0;
} else {
ldo->init_data = *pdata->ldo[id].init_data;
}

ldo->regulator = regulator_register(&wm8994_ldo_desc[id], &config);
Expand Down

0 comments on commit e3d2777

Please sign in to comment.