diff options
author | Mark Brown <broonie@sirena.org.uk> | 2013-04-28 02:13:50 +0100 |
---|---|---|
committer | Mark Brown <broonie@sirena.org.uk> | 2013-04-28 02:13:50 +0100 |
commit | bee546581424b5514ec6a034fb83fd4e95b804da (patch) | |
tree | a7ea259aaedb63025eb7e7db8789c21ef53d9f36 /drivers/regulator | |
parent | bcd5d1d978c70841d68c7a3725269df9d5a4abf8 (diff) | |
parent | 3ea9389656ddf8beb1b5b52b8db6333fa4a7c00e (diff) | |
download | linux-3.10-bee546581424b5514ec6a034fb83fd4e95b804da.tar.gz linux-3.10-bee546581424b5514ec6a034fb83fd4e95b804da.tar.bz2 linux-3.10-bee546581424b5514ec6a034fb83fd4e95b804da.zip |
Merge remote-tracking branch 'regulator/topic/wm8994' into v3.9-rc8
Diffstat (limited to 'drivers/regulator')
-rw-r--r-- | drivers/regulator/wm8994-regulator.c | 61 |
1 files changed, 42 insertions, 19 deletions
diff --git a/drivers/regulator/wm8994-regulator.c b/drivers/regulator/wm8994-regulator.c index 6ff87234264..a612c356a69 100644 --- a/drivers/regulator/wm8994-regulator.c +++ b/drivers/regulator/wm8994-regulator.c @@ -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> @@ -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 @@ -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); @@ -117,13 +140,29 @@ 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; + else if (wm8994->dev->of_node) + config.ena_gpio = wm8994->pdata.ldo[id].enable; + + /* Use default constraints if none set up */ + if (!pdata || !pdata->ldo[id].init_data || wm8994->dev->of_node) { + 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); @@ -162,23 +201,7 @@ static struct platform_driver wm8994_ldo_driver = { }, }; -static int __init wm8994_ldo_init(void) -{ - int ret; - - ret = platform_driver_register(&wm8994_ldo_driver); - if (ret != 0) - pr_err("Failed to register Wm8994 GP LDO driver: %d\n", ret); - - return ret; -} -subsys_initcall(wm8994_ldo_init); - -static void __exit wm8994_ldo_exit(void) -{ - platform_driver_unregister(&wm8994_ldo_driver); -} -module_exit(wm8994_ldo_exit); +module_platform_driver(wm8994_ldo_driver); /* Module information */ MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>"); |