aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2009-04-03 13:39:20 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-04-03 13:39:20 -0400
commit18b34b9546dc192d978dda940673f40928d2e36e (patch)
treeca396840ed95fc46cd360c68bf2cefe5ab4cbda8 /drivers/regulator
parentca1ee219c070eab755712d50638bbcd1f8630fc1 (diff)
parentd6bb69cfa88b8ac9f952de4fada5b216d5ba8830 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/lrg/voltage-2.6
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/lrg/voltage-2.6: (32 commits) regulator: twl4030 VAUX3 supports 3.0V regulator: Support disabling of unused regulators by machines regulator: Don't increment use_count for boot_on regulators twl4030-regulator: expose VPLL2 regulator: refcount fixes regulator: Don't warn if we failed to get a regulator regulator: Allow boot_on regulators to be disabled by clients regulator: Implement list_voltage for WM835x LDOs and DCDCs twl4030-regulator: list more VAUX4 voltages regulator: Don't warn on omitted voltage constraints regulator: Implement list_voltage() for WM8400 DCDCs and LDOs MMC: regulator utilities regulator: twl4030 voltage enumeration (v2) regulator: twl4030 regulators regulator: get_status() grows kerneldoc regulator: enumerate voltages (v2) regulator: Fix get_mode() for WM835x DCDCs regulator: Allow regulators to set the initial operating mode regulator: Suggest use of datasheet supply or pin names for consumers regulator: email - update email address and regulator webpage. ...
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/Kconfig13
-rw-r--r--drivers/regulator/Makefile1
-rw-r--r--drivers/regulator/bq24022.c3
-rw-r--r--drivers/regulator/core.c386
-rw-r--r--drivers/regulator/da903x.c3
-rw-r--r--drivers/regulator/fixed.c3
-rw-r--r--drivers/regulator/pcf50633-regulator.c3
-rw-r--r--drivers/regulator/twl4030-regulator.c500
-rw-r--r--drivers/regulator/virtual.c14
-rw-r--r--drivers/regulator/wm8350-regulator.c57
-rw-r--r--drivers/regulator/wm8400-regulator.c36
11 files changed, 927 insertions, 92 deletions
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index e7e0cf102d6d..e58c0ce65aa6 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -29,8 +29,12 @@ config REGULATOR_DEBUG
29 Say yes here to enable debugging support. 29 Say yes here to enable debugging support.
30 30
31config REGULATOR_FIXED_VOLTAGE 31config REGULATOR_FIXED_VOLTAGE
32 tristate 32 tristate "Fixed voltage regulator support"
33 default n 33 default n
34 help
35 This driver provides support for fixed voltage regulators,
36 useful for systems which use a combination of software
37 managed regulators and simple non-configurable regulators.
34 38
35config REGULATOR_VIRTUAL_CONSUMER 39config REGULATOR_VIRTUAL_CONSUMER
36 tristate "Virtual regulator consumer support" 40 tristate "Virtual regulator consumer support"
@@ -52,6 +56,13 @@ config REGULATOR_BQ24022
52 charging select between 100 mA and 500 mA charging current 56 charging select between 100 mA and 500 mA charging current
53 limit. 57 limit.
54 58
59config REGULATOR_TWL4030
60 bool "TI TWL4030/TWL5030/TPS695x0 PMIC"
61 depends on TWL4030_CORE
62 help
63 This driver supports the voltage regulators provided by
64 this family of companion chips.
65
55config REGULATOR_WM8350 66config REGULATOR_WM8350
56 tristate "Wolfson Microelectroncis WM8350 AudioPlus PMIC" 67 tristate "Wolfson Microelectroncis WM8350 AudioPlus PMIC"
57 depends on MFD_WM8350 68 depends on MFD_WM8350
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 61b30c6ddecc..bac133afc061 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -8,6 +8,7 @@ obj-$(CONFIG_REGULATOR_FIXED_VOLTAGE) += fixed.o
8obj-$(CONFIG_REGULATOR_VIRTUAL_CONSUMER) += virtual.o 8obj-$(CONFIG_REGULATOR_VIRTUAL_CONSUMER) += virtual.o
9 9
10obj-$(CONFIG_REGULATOR_BQ24022) += bq24022.o 10obj-$(CONFIG_REGULATOR_BQ24022) += bq24022.o
11obj-$(CONFIG_REGULATOR_TWL4030) += twl4030-regulator.o
11obj-$(CONFIG_REGULATOR_WM8350) += wm8350-regulator.o 12obj-$(CONFIG_REGULATOR_WM8350) += wm8350-regulator.o
12obj-$(CONFIG_REGULATOR_WM8400) += wm8400-regulator.o 13obj-$(CONFIG_REGULATOR_WM8400) += wm8400-regulator.o
13obj-$(CONFIG_REGULATOR_DA903X) += da903x.o 14obj-$(CONFIG_REGULATOR_DA903X) += da903x.o
diff --git a/drivers/regulator/bq24022.c b/drivers/regulator/bq24022.c
index c175e38a4cd5..7ecb820ceebc 100644
--- a/drivers/regulator/bq24022.c
+++ b/drivers/regulator/bq24022.c
@@ -105,7 +105,8 @@ static int __init bq24022_probe(struct platform_device *pdev)
105 ret = gpio_direction_output(pdata->gpio_iset2, 0); 105 ret = gpio_direction_output(pdata->gpio_iset2, 0);
106 ret = gpio_direction_output(pdata->gpio_nce, 1); 106 ret = gpio_direction_output(pdata->gpio_nce, 1);
107 107
108 bq24022 = regulator_register(&bq24022_desc, &pdev->dev, pdata); 108 bq24022 = regulator_register(&bq24022_desc, &pdev->dev,
109 pdata->init_data, pdata);
109 if (IS_ERR(bq24022)) { 110 if (IS_ERR(bq24022)) {
110 dev_dbg(&pdev->dev, "couldn't register regulator\n"); 111 dev_dbg(&pdev->dev, "couldn't register regulator\n");
111 ret = PTR_ERR(bq24022); 112 ret = PTR_ERR(bq24022);
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index f511a406fcaa..01f7702a805d 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -28,33 +28,7 @@
28static DEFINE_MUTEX(regulator_list_mutex); 28static DEFINE_MUTEX(regulator_list_mutex);
29static LIST_HEAD(regulator_list); 29static LIST_HEAD(regulator_list);
30static LIST_HEAD(regulator_map_list); 30static LIST_HEAD(regulator_map_list);
31 31static int has_full_constraints;
32/*
33 * struct regulator_dev
34 *
35 * Voltage / Current regulator class device. One for each regulator.
36 */
37struct regulator_dev {
38 struct regulator_desc *desc;
39 int use_count;
40
41 /* lists we belong to */
42 struct list_head list; /* list of all regulators */
43 struct list_head slist; /* list of supplied regulators */
44
45 /* lists we own */
46 struct list_head consumer_list; /* consumers we supply */
47 struct list_head supply_list; /* regulators we supply */
48
49 struct blocking_notifier_head notifier;
50 struct mutex mutex; /* consumer lock */
51 struct module *owner;
52 struct device dev;
53 struct regulation_constraints *constraints;
54 struct regulator_dev *supply; /* for tree */
55
56 void *reg_data; /* regulator_dev data */
57};
58 32
59/* 33/*
60 * struct regulator_map 34 * struct regulator_map
@@ -79,7 +53,6 @@ struct regulator {
79 int uA_load; 53 int uA_load;
80 int min_uV; 54 int min_uV;
81 int max_uV; 55 int max_uV;
82 int enabled; /* count of client enables */
83 char *supply_name; 56 char *supply_name;
84 struct device_attribute dev_attr; 57 struct device_attribute dev_attr;
85 struct regulator_dev *rdev; 58 struct regulator_dev *rdev;
@@ -312,6 +285,47 @@ static ssize_t regulator_state_show(struct device *dev,
312} 285}
313static DEVICE_ATTR(state, 0444, regulator_state_show, NULL); 286static DEVICE_ATTR(state, 0444, regulator_state_show, NULL);
314 287
288static ssize_t regulator_status_show(struct device *dev,
289 struct device_attribute *attr, char *buf)
290{
291 struct regulator_dev *rdev = dev_get_drvdata(dev);
292 int status;
293 char *label;
294
295 status = rdev->desc->ops->get_status(rdev);
296 if (status < 0)
297 return status;
298
299 switch (status) {
300 case REGULATOR_STATUS_OFF:
301 label = "off";
302 break;
303 case REGULATOR_STATUS_ON:
304 label = "on";
305 break;
306 case REGULATOR_STATUS_ERROR:
307 label = "error";
308 break;
309 case REGULATOR_STATUS_FAST:
310 label = "fast";
311 break;
312 case REGULATOR_STATUS_NORMAL:
313 label = "normal";
314 break;
315 case REGULATOR_STATUS_IDLE:
316 label = "idle";
317 break;
318 case REGULATOR_STATUS_STANDBY:
319 label = "standby";
320 break;
321 default:
322 return -ERANGE;
323 }
324
325 return sprintf(buf, "%s\n", label);
326}
327static DEVICE_ATTR(status, 0444, regulator_status_show, NULL);
328
315static ssize_t regulator_min_uA_show(struct device *dev, 329static ssize_t regulator_min_uA_show(struct device *dev,
316 struct device_attribute *attr, char *buf) 330 struct device_attribute *attr, char *buf)
317{ 331{
@@ -678,6 +692,73 @@ static int set_machine_constraints(struct regulator_dev *rdev,
678 else 692 else
679 name = "regulator"; 693 name = "regulator";
680 694
695 /* constrain machine-level voltage specs to fit
696 * the actual range supported by this regulator.
697 */
698 if (ops->list_voltage && rdev->desc->n_voltages) {
699 int count = rdev->desc->n_voltages;
700 int i;
701 int min_uV = INT_MAX;
702 int max_uV = INT_MIN;
703 int cmin = constraints->min_uV;
704 int cmax = constraints->max_uV;
705
706 /* it's safe to autoconfigure fixed-voltage supplies */
707 if (count == 1 && !cmin) {
708 cmin = INT_MIN;
709 cmax = INT_MAX;
710 }
711
712 /* voltage constraints are optional */
713 if ((cmin == 0) && (cmax == 0))
714 goto out;
715
716 /* else require explicit machine-level constraints */
717 if (cmin <= 0 || cmax <= 0 || cmax < cmin) {
718 pr_err("%s: %s '%s' voltage constraints\n",
719 __func__, "invalid", name);
720 ret = -EINVAL;
721 goto out;
722 }
723
724 /* initial: [cmin..cmax] valid, [min_uV..max_uV] not */
725 for (i = 0; i < count; i++) {
726 int value;
727
728 value = ops->list_voltage(rdev, i);
729 if (value <= 0)
730 continue;
731
732 /* maybe adjust [min_uV..max_uV] */
733 if (value >= cmin && value < min_uV)
734 min_uV = value;
735 if (value <= cmax && value > max_uV)
736 max_uV = value;
737 }
738
739 /* final: [min_uV..max_uV] valid iff constraints valid */
740 if (max_uV < min_uV) {
741 pr_err("%s: %s '%s' voltage constraints\n",
742 __func__, "unsupportable", name);
743 ret = -EINVAL;
744 goto out;
745 }
746
747 /* use regulator's subset of machine constraints */
748 if (constraints->min_uV < min_uV) {
749 pr_debug("%s: override '%s' %s, %d -> %d\n",
750 __func__, name, "min_uV",
751 constraints->min_uV, min_uV);
752 constraints->min_uV = min_uV;
753 }
754 if (constraints->max_uV > max_uV) {
755 pr_debug("%s: override '%s' %s, %d -> %d\n",
756 __func__, name, "max_uV",
757 constraints->max_uV, max_uV);
758 constraints->max_uV = max_uV;
759 }
760 }
761
681 rdev->constraints = constraints; 762 rdev->constraints = constraints;
682 763
683 /* do we need to apply the constraint voltage */ 764 /* do we need to apply the constraint voltage */
@@ -695,10 +776,6 @@ static int set_machine_constraints(struct regulator_dev *rdev,
695 } 776 }
696 } 777 }
697 778
698 /* are we enabled at boot time by firmware / bootloader */
699 if (rdev->constraints->boot_on)
700 rdev->use_count = 1;
701
702 /* do we need to setup our suspend state */ 779 /* do we need to setup our suspend state */
703 if (constraints->initial_state) { 780 if (constraints->initial_state) {
704 ret = suspend_prepare(rdev, constraints->initial_state); 781 ret = suspend_prepare(rdev, constraints->initial_state);
@@ -710,11 +787,27 @@ static int set_machine_constraints(struct regulator_dev *rdev,
710 } 787 }
711 } 788 }
712 789
713 /* if always_on is set then turn the regulator on if it's not 790 if (constraints->initial_mode) {
714 * already on. */ 791 if (!ops->set_mode) {
715 if (constraints->always_on && ops->enable && 792 printk(KERN_ERR "%s: no set_mode operation for %s\n",
716 ((ops->is_enabled && !ops->is_enabled(rdev)) || 793 __func__, name);
717 (!ops->is_enabled && !constraints->boot_on))) { 794 ret = -EINVAL;
795 goto out;
796 }
797
798 ret = ops->set_mode(rdev, constraints->initial_mode);
799 if (ret < 0) {
800 printk(KERN_ERR
801 "%s: failed to set initial mode for %s: %d\n",
802 __func__, name, ret);
803 goto out;
804 }
805 }
806
807 /* If the constraints say the regulator should be on at this point
808 * and we have control then make sure it is enabled.
809 */
810 if ((constraints->always_on || constraints->boot_on) && ops->enable) {
718 ret = ops->enable(rdev); 811 ret = ops->enable(rdev);
719 if (ret < 0) { 812 if (ret < 0) {
720 printk(KERN_ERR "%s: failed to enable %s\n", 813 printk(KERN_ERR "%s: failed to enable %s\n",
@@ -817,6 +910,19 @@ static void unset_consumer_device_supply(struct regulator_dev *rdev,
817 } 910 }
818} 911}
819 912
913static void unset_regulator_supplies(struct regulator_dev *rdev)
914{
915 struct regulator_map *node, *n;
916
917 list_for_each_entry_safe(node, n, &regulator_map_list, list) {
918 if (rdev == node->regulator) {
919 list_del(&node->list);
920 kfree(node);
921 return;
922 }
923 }
924}
925
820#define REG_STR_SIZE 32 926#define REG_STR_SIZE 32
821 927
822static struct regulator *create_regulator(struct regulator_dev *rdev, 928static struct regulator *create_regulator(struct regulator_dev *rdev,
@@ -898,9 +1004,12 @@ overflow_err:
898 * @id: Supply name or regulator ID. 1004 * @id: Supply name or regulator ID.
899 * 1005 *
900 * Returns a struct regulator corresponding to the regulator producer, 1006 * Returns a struct regulator corresponding to the regulator producer,
901 * or IS_ERR() condition containing errno. Use of supply names 1007 * or IS_ERR() condition containing errno.
902 * configured via regulator_set_device_supply() is strongly 1008 *
903 * encouraged. 1009 * Use of supply names configured via regulator_set_device_supply() is
1010 * strongly encouraged. It is recommended that the supply name used
1011 * should match the name used for the supply and/or the relevant
1012 * device pins in the datasheet.
904 */ 1013 */
905struct regulator *regulator_get(struct device *dev, const char *id) 1014struct regulator *regulator_get(struct device *dev, const char *id)
906{ 1015{
@@ -922,8 +1031,6 @@ struct regulator *regulator_get(struct device *dev, const char *id)
922 goto found; 1031 goto found;
923 } 1032 }
924 } 1033 }
925 printk(KERN_ERR "regulator: Unable to get requested regulator: %s\n",
926 id);
927 mutex_unlock(&regulator_list_mutex); 1034 mutex_unlock(&regulator_list_mutex);
928 return regulator; 1035 return regulator;
929 1036
@@ -961,10 +1068,6 @@ void regulator_put(struct regulator *regulator)
961 mutex_lock(&regulator_list_mutex); 1068 mutex_lock(&regulator_list_mutex);
962 rdev = regulator->rdev; 1069 rdev = regulator->rdev;
963 1070
964 if (WARN(regulator->enabled, "Releasing supply %s while enabled\n",
965 regulator->supply_name))
966 _regulator_disable(rdev);
967
968 /* remove any sysfs entries */ 1071 /* remove any sysfs entries */
969 if (regulator->dev) { 1072 if (regulator->dev) {
970 sysfs_remove_link(&rdev->dev.kobj, regulator->supply_name); 1073 sysfs_remove_link(&rdev->dev.kobj, regulator->supply_name);
@@ -1039,12 +1142,7 @@ int regulator_enable(struct regulator *regulator)
1039 int ret = 0; 1142 int ret = 0;
1040 1143
1041 mutex_lock(&rdev->mutex); 1144 mutex_lock(&rdev->mutex);
1042 if (regulator->enabled == 0) 1145 ret = _regulator_enable(rdev);
1043 ret = _regulator_enable(rdev);
1044 else if (regulator->enabled < 0)
1045 ret = -EIO;
1046 if (ret == 0)
1047 regulator->enabled++;
1048 mutex_unlock(&rdev->mutex); 1146 mutex_unlock(&rdev->mutex);
1049 return ret; 1147 return ret;
1050} 1148}
@@ -1055,6 +1153,11 @@ static int _regulator_disable(struct regulator_dev *rdev)
1055{ 1153{
1056 int ret = 0; 1154 int ret = 0;
1057 1155
1156 if (WARN(rdev->use_count <= 0,
1157 "unbalanced disables for %s\n",
1158 rdev->desc->name))
1159 return -EIO;
1160
1058 /* are we the last user and permitted to disable ? */ 1161 /* are we the last user and permitted to disable ? */
1059 if (rdev->use_count == 1 && !rdev->constraints->always_on) { 1162 if (rdev->use_count == 1 && !rdev->constraints->always_on) {
1060 1163
@@ -1103,16 +1206,7 @@ int regulator_disable(struct regulator *regulator)
1103 int ret = 0; 1206 int ret = 0;
1104 1207
1105 mutex_lock(&rdev->mutex); 1208 mutex_lock(&rdev->mutex);
1106 if (regulator->enabled == 1) { 1209 ret = _regulator_disable(rdev);
1107 ret = _regulator_disable(rdev);
1108 if (ret == 0)
1109 regulator->uA_load = 0;
1110 } else if (WARN(regulator->enabled <= 0,
1111 "unbalanced disables for supply %s\n",
1112 regulator->supply_name))
1113 ret = -EIO;
1114 if (ret == 0)
1115 regulator->enabled--;
1116 mutex_unlock(&rdev->mutex); 1210 mutex_unlock(&rdev->mutex);
1117 return ret; 1211 return ret;
1118} 1212}
@@ -1159,7 +1253,6 @@ int regulator_force_disable(struct regulator *regulator)
1159 int ret; 1253 int ret;
1160 1254
1161 mutex_lock(&regulator->rdev->mutex); 1255 mutex_lock(&regulator->rdev->mutex);
1162 regulator->enabled = 0;
1163 regulator->uA_load = 0; 1256 regulator->uA_load = 0;
1164 ret = _regulator_force_disable(regulator->rdev); 1257 ret = _regulator_force_disable(regulator->rdev);
1165 mutex_unlock(&regulator->rdev->mutex); 1258 mutex_unlock(&regulator->rdev->mutex);
@@ -1204,6 +1297,56 @@ int regulator_is_enabled(struct regulator *regulator)
1204EXPORT_SYMBOL_GPL(regulator_is_enabled); 1297EXPORT_SYMBOL_GPL(regulator_is_enabled);
1205 1298
1206/** 1299/**
1300 * regulator_count_voltages - count regulator_list_voltage() selectors
1301 * @regulator: regulator source
1302 *
1303 * Returns number of selectors, or negative errno. Selectors are
1304 * numbered starting at zero, and typically correspond to bitfields
1305 * in hardware registers.
1306 */
1307int regulator_count_voltages(struct regulator *regulator)
1308{
1309 struct regulator_dev *rdev = regulator->rdev;
1310
1311 return rdev->desc->n_voltages ? : -EINVAL;
1312}
1313EXPORT_SYMBOL_GPL(regulator_count_voltages);
1314
1315/**
1316 * regulator_list_voltage - enumerate supported voltages
1317 * @regulator: regulator source
1318 * @selector: identify voltage to list
1319 * Context: can sleep
1320 *
1321 * Returns a voltage that can be passed to @regulator_set_voltage(),
1322 * zero if this selector code can't be used on this sytem, or a
1323 * negative errno.
1324 */
1325int regulator_list_voltage(struct regulator *regulator, unsigned selector)
1326{
1327 struct regulator_dev *rdev = regulator->rdev;
1328 struct regulator_ops *ops = rdev->desc->ops;
1329 int ret;
1330
1331 if (!ops->list_voltage || selector >= rdev->desc->n_voltages)
1332 return -EINVAL;
1333
1334 mutex_lock(&rdev->mutex);
1335 ret = ops->list_voltage(rdev, selector);
1336 mutex_unlock(&rdev->mutex);
1337
1338 if (ret > 0) {
1339 if (ret < rdev->constraints->min_uV)
1340 ret = 0;
1341 else if (ret > rdev->constraints->max_uV)
1342 ret = 0;
1343 }
1344
1345 return ret;
1346}
1347EXPORT_SYMBOL_GPL(regulator_list_voltage);
1348
1349/**
1207 * regulator_set_voltage - set regulator output voltage 1350 * regulator_set_voltage - set regulator output voltage
1208 * @regulator: regulator source 1351 * @regulator: regulator source
1209 * @min_uV: Minimum required voltage in uV 1352 * @min_uV: Minimum required voltage in uV
@@ -1243,6 +1386,7 @@ int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV)
1243 ret = rdev->desc->ops->set_voltage(rdev, min_uV, max_uV); 1386 ret = rdev->desc->ops->set_voltage(rdev, min_uV, max_uV);
1244 1387
1245out: 1388out:
1389 _notifier_call_chain(rdev, REGULATOR_EVENT_VOLTAGE_CHANGE, NULL);
1246 mutex_unlock(&rdev->mutex); 1390 mutex_unlock(&rdev->mutex);
1247 return ret; 1391 return ret;
1248} 1392}
@@ -1543,20 +1687,23 @@ int regulator_unregister_notifier(struct regulator *regulator,
1543} 1687}
1544EXPORT_SYMBOL_GPL(regulator_unregister_notifier); 1688EXPORT_SYMBOL_GPL(regulator_unregister_notifier);
1545 1689
1546/* notify regulator consumers and downstream regulator consumers */ 1690/* notify regulator consumers and downstream regulator consumers.
1691 * Note mutex must be held by caller.
1692 */
1547static void _notifier_call_chain(struct regulator_dev *rdev, 1693static void _notifier_call_chain(struct regulator_dev *rdev,
1548 unsigned long event, void *data) 1694 unsigned long event, void *data)
1549{ 1695{
1550 struct regulator_dev *_rdev; 1696 struct regulator_dev *_rdev;
1551 1697
1552 /* call rdev chain first */ 1698 /* call rdev chain first */
1553 mutex_lock(&rdev->mutex);
1554 blocking_notifier_call_chain(&rdev->notifier, event, NULL); 1699 blocking_notifier_call_chain(&rdev->notifier, event, NULL);
1555 mutex_unlock(&rdev->mutex);
1556 1700
1557 /* now notify regulator we supply */ 1701 /* now notify regulator we supply */
1558 list_for_each_entry(_rdev, &rdev->supply_list, slist) 1702 list_for_each_entry(_rdev, &rdev->supply_list, slist) {
1559 _notifier_call_chain(_rdev, event, data); 1703 mutex_lock(&_rdev->mutex);
1704 _notifier_call_chain(_rdev, event, data);
1705 mutex_unlock(&_rdev->mutex);
1706 }
1560} 1707}
1561 1708
1562/** 1709/**
@@ -1703,6 +1850,7 @@ EXPORT_SYMBOL_GPL(regulator_bulk_free);
1703 * 1850 *
1704 * Called by regulator drivers to notify clients a regulator event has 1851 * Called by regulator drivers to notify clients a regulator event has
1705 * occurred. We also notify regulator clients downstream. 1852 * occurred. We also notify regulator clients downstream.
1853 * Note lock must be held by caller.
1706 */ 1854 */
1707int regulator_notifier_call_chain(struct regulator_dev *rdev, 1855int regulator_notifier_call_chain(struct regulator_dev *rdev,
1708 unsigned long event, void *data) 1856 unsigned long event, void *data)
@@ -1744,6 +1892,11 @@ static int add_regulator_attributes(struct regulator_dev *rdev)
1744 if (status < 0) 1892 if (status < 0)
1745 return status; 1893 return status;
1746 } 1894 }
1895 if (ops->get_status) {
1896 status = device_create_file(dev, &dev_attr_status);
1897 if (status < 0)
1898 return status;
1899 }
1747 1900
1748 /* some attributes are type-specific */ 1901 /* some attributes are type-specific */
1749 if (rdev->desc->type == REGULATOR_CURRENT) { 1902 if (rdev->desc->type == REGULATOR_CURRENT) {
@@ -1828,17 +1981,18 @@ static int add_regulator_attributes(struct regulator_dev *rdev)
1828 * regulator_register - register regulator 1981 * regulator_register - register regulator
1829 * @regulator_desc: regulator to register 1982 * @regulator_desc: regulator to register
1830 * @dev: struct device for the regulator 1983 * @dev: struct device for the regulator
1984 * @init_data: platform provided init data, passed through by driver
1831 * @driver_data: private regulator data 1985 * @driver_data: private regulator data
1832 * 1986 *
1833 * Called by regulator drivers to register a regulator. 1987 * Called by regulator drivers to register a regulator.
1834 * Returns 0 on success. 1988 * Returns 0 on success.
1835 */ 1989 */
1836struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc, 1990struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc,
1837 struct device *dev, void *driver_data) 1991 struct device *dev, struct regulator_init_data *init_data,
1992 void *driver_data)
1838{ 1993{
1839 static atomic_t regulator_no = ATOMIC_INIT(0); 1994 static atomic_t regulator_no = ATOMIC_INIT(0);
1840 struct regulator_dev *rdev; 1995 struct regulator_dev *rdev;
1841 struct regulator_init_data *init_data = dev->platform_data;
1842 int ret, i; 1996 int ret, i;
1843 1997
1844 if (regulator_desc == NULL) 1998 if (regulator_desc == NULL)
@@ -1945,6 +2099,7 @@ void regulator_unregister(struct regulator_dev *rdev)
1945 return; 2099 return;
1946 2100
1947 mutex_lock(&regulator_list_mutex); 2101 mutex_lock(&regulator_list_mutex);
2102 unset_regulator_supplies(rdev);
1948 list_del(&rdev->list); 2103 list_del(&rdev->list);
1949 if (rdev->supply) 2104 if (rdev->supply)
1950 sysfs_remove_link(&rdev->dev.kobj, "supply"); 2105 sysfs_remove_link(&rdev->dev.kobj, "supply");
@@ -1989,6 +2144,23 @@ out:
1989EXPORT_SYMBOL_GPL(regulator_suspend_prepare); 2144EXPORT_SYMBOL_GPL(regulator_suspend_prepare);
1990 2145
1991/** 2146/**
2147 * regulator_has_full_constraints - the system has fully specified constraints
2148 *
2149 * Calling this function will cause the regulator API to disable all
2150 * regulators which have a zero use count and don't have an always_on
2151 * constraint in a late_initcall.
2152 *
2153 * The intention is that this will become the default behaviour in a
2154 * future kernel release so users are encouraged to use this facility
2155 * now.
2156 */
2157void regulator_has_full_constraints(void)
2158{
2159 has_full_constraints = 1;
2160}
2161EXPORT_SYMBOL_GPL(regulator_has_full_constraints);
2162
2163/**
1992 * rdev_get_drvdata - get rdev regulator driver data 2164 * rdev_get_drvdata - get rdev regulator driver data
1993 * @rdev: regulator 2165 * @rdev: regulator
1994 * 2166 *
@@ -2055,3 +2227,77 @@ static int __init regulator_init(void)
2055 2227
2056/* init early to allow our consumers to complete system booting */ 2228/* init early to allow our consumers to complete system booting */
2057core_initcall(regulator_init); 2229core_initcall(regulator_init);
2230
2231static int __init regulator_init_complete(void)
2232{
2233 struct regulator_dev *rdev;
2234 struct regulator_ops *ops;
2235 struct regulation_constraints *c;
2236 int enabled, ret;
2237 const char *name;
2238
2239 mutex_lock(&regulator_list_mutex);
2240
2241 /* If we have a full configuration then disable any regulators
2242 * which are not in use or always_on. This will become the
2243 * default behaviour in the future.
2244 */
2245 list_for_each_entry(rdev, &regulator_list, list) {
2246 ops = rdev->desc->ops;
2247 c = rdev->constraints;
2248
2249 if (c->name)
2250 name = c->name;
2251 else if (rdev->desc->name)
2252 name = rdev->desc->name;
2253 else
2254 name = "regulator";
2255
2256 if (!ops->disable || c->always_on)
2257 continue;
2258
2259 mutex_lock(&rdev->mutex);
2260
2261 if (rdev->use_count)
2262 goto unlock;
2263
2264 /* If we can't read the status assume it's on. */
2265 if (ops->is_enabled)
2266 enabled = ops->is_enabled(rdev);
2267 else
2268 enabled = 1;
2269
2270 if (!enabled)
2271 goto unlock;
2272
2273 if (has_full_constraints) {
2274 /* We log since this may kill the system if it
2275 * goes wrong. */
2276 printk(KERN_INFO "%s: disabling %s\n",
2277 __func__, name);
2278 ret = ops->disable(rdev);
2279 if (ret != 0) {
2280 printk(KERN_ERR
2281 "%s: couldn't disable %s: %d\n",
2282 __func__, name, ret);
2283 }
2284 } else {
2285 /* The intention is that in future we will
2286 * assume that full constraints are provided
2287 * so warn even if we aren't going to do
2288 * anything here.
2289 */
2290 printk(KERN_WARNING
2291 "%s: incomplete constraints, leaving %s on\n",
2292 __func__, name);
2293 }
2294
2295unlock:
2296 mutex_unlock(&rdev->mutex);
2297 }
2298
2299 mutex_unlock(&regulator_list_mutex);
2300
2301 return 0;
2302}
2303late_initcall(regulator_init_complete);
diff --git a/drivers/regulator/da903x.c b/drivers/regulator/da903x.c
index fe77730a7edb..72b15495183c 100644
--- a/drivers/regulator/da903x.c
+++ b/drivers/regulator/da903x.c
@@ -471,7 +471,8 @@ static int __devinit da903x_regulator_probe(struct platform_device *pdev)
471 if (ri->desc.id == DA9030_ID_LDO1 || ri->desc.id == DA9030_ID_LDO15) 471 if (ri->desc.id == DA9030_ID_LDO1 || ri->desc.id == DA9030_ID_LDO15)
472 ri->desc.ops = &da9030_regulator_ldo1_15_ops; 472 ri->desc.ops = &da9030_regulator_ldo1_15_ops;
473 473
474 rdev = regulator_register(&ri->desc, &pdev->dev, ri); 474 rdev = regulator_register(&ri->desc, &pdev->dev,
475 pdev->dev.platform_data, ri);
475 if (IS_ERR(rdev)) { 476 if (IS_ERR(rdev)) {
476 dev_err(&pdev->dev, "failed to register regulator %s\n", 477 dev_err(&pdev->dev, "failed to register regulator %s\n",
477 ri->desc.name); 478 ri->desc.name);
diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c
index d31db3e14913..23d554628a76 100644
--- a/drivers/regulator/fixed.c
+++ b/drivers/regulator/fixed.c
@@ -73,7 +73,8 @@ static int regulator_fixed_voltage_probe(struct platform_device *pdev)
73 73
74 drvdata->microvolts = config->microvolts; 74 drvdata->microvolts = config->microvolts;
75 75
76 drvdata->dev = regulator_register(&drvdata->desc, drvdata); 76 drvdata->dev = regulator_register(&drvdata->desc, &pdev->dev,
77 config->init_data, drvdata);
77 if (IS_ERR(drvdata->dev)) { 78 if (IS_ERR(drvdata->dev)) {
78 ret = PTR_ERR(drvdata->dev); 79 ret = PTR_ERR(drvdata->dev);
79 goto err_name; 80 goto err_name;
diff --git a/drivers/regulator/pcf50633-regulator.c b/drivers/regulator/pcf50633-regulator.c
index 4cc85ec6e120..cd761d85c8fd 100644
--- a/drivers/regulator/pcf50633-regulator.c
+++ b/drivers/regulator/pcf50633-regulator.c
@@ -284,7 +284,8 @@ static int __devinit pcf50633_regulator_probe(struct platform_device *pdev)
284 /* Already set by core driver */ 284 /* Already set by core driver */
285 pcf = platform_get_drvdata(pdev); 285 pcf = platform_get_drvdata(pdev);
286 286
287 rdev = regulator_register(&regulators[pdev->id], &pdev->dev, pcf); 287 rdev = regulator_register(&regulators[pdev->id], &pdev->dev,
288 pdev->dev.platform_data, pcf);
288 if (IS_ERR(rdev)) 289 if (IS_ERR(rdev))
289 return PTR_ERR(rdev); 290 return PTR_ERR(rdev);
290 291
diff --git a/drivers/regulator/twl4030-regulator.c b/drivers/regulator/twl4030-regulator.c
new file mode 100644
index 000000000000..e2032fb60b55
--- /dev/null
+++ b/drivers/regulator/twl4030-regulator.c
@@ -0,0 +1,500 @@
1/*
2 * twl4030-regulator.c -- support regulators in twl4030 family chips
3 *
4 * Copyright (C) 2008 David Brownell
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */
11
12#include <linux/module.h>
13#include <linux/init.h>
14#include <linux/err.h>
15#include <linux/platform_device.h>
16#include <linux/regulator/driver.h>
17#include <linux/regulator/machine.h>
18#include <linux/i2c/twl4030.h>
19
20
21/*
22 * The TWL4030/TW5030/TPS659x0 family chips include power management, a
23 * USB OTG transceiver, an RTC, ADC, PWM, and lots more. Some versions
24 * include an audio codec, battery charger, and more voltage regulators.
25 * These chips are often used in OMAP-based systems.
26 *
27 * This driver implements software-based resource control for various
28 * voltage regulators. This is usually augmented with state machine
29 * based control.
30 */
31
32struct twlreg_info {
33 /* start of regulator's PM_RECEIVER control register bank */
34 u8 base;
35
36 /* twl4030 resource ID, for resource control state machine */
37 u8 id;
38
39 /* voltage in mV = table[VSEL]; table_len must be a power-of-two */
40 u8 table_len;
41 const u16 *table;
42
43 /* chip constraints on regulator behavior */
44 u16 min_mV;
45
46 /* used by regulator core */
47 struct regulator_desc desc;
48};
49
50
51/* LDO control registers ... offset is from the base of its register bank.
52 * The first three registers of all power resource banks help hardware to
53 * manage the various resource groups.
54 */
55#define VREG_GRP 0
56#define VREG_TYPE 1
57#define VREG_REMAP 2
58#define VREG_DEDICATED 3 /* LDO control */
59
60
61static inline int
62twl4030reg_read(struct twlreg_info *info, unsigned offset)
63{
64 u8 value;
65 int status;
66
67 status = twl4030_i2c_read_u8(TWL4030_MODULE_PM_RECEIVER,
68 &value, info->base + offset);
69 return (status < 0) ? status : value;
70}
71
72static inline int
73twl4030reg_write(struct twlreg_info *info, unsigned offset, u8 value)
74{
75 return twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
76 value, info->base + offset);
77}
78
79/*----------------------------------------------------------------------*/
80
81/* generic power resource operations, which work on all regulators */
82
83static int twl4030reg_grp(struct regulator_dev *rdev)
84{
85 return twl4030reg_read(rdev_get_drvdata(rdev), VREG_GRP);
86}
87
88/*
89 * Enable/disable regulators by joining/leaving the P1 (processor) group.
90 * We assume nobody else is updating the DEV_GRP registers.
91 */
92
93#define P3_GRP BIT(7) /* "peripherals" */
94#define P2_GRP BIT(6) /* secondary processor, modem, etc */
95#define P1_GRP BIT(5) /* CPU/Linux */
96
97static int twl4030reg_is_enabled(struct regulator_dev *rdev)
98{
99 int state = twl4030reg_grp(rdev);
100
101 if (state < 0)
102 return state;
103
104 return (state & P1_GRP) != 0;
105}
106
107static int twl4030reg_enable(struct regulator_dev *rdev)
108{
109 struct twlreg_info *info = rdev_get_drvdata(rdev);
110 int grp;
111
112 grp = twl4030reg_read(info, VREG_GRP);
113 if (grp < 0)
114 return grp;
115
116 grp |= P1_GRP;
117 return twl4030reg_write(info, VREG_GRP, grp);
118}
119
120static int twl4030reg_disable(struct regulator_dev *rdev)
121{
122 struct twlreg_info *info = rdev_get_drvdata(rdev);
123 int grp;
124
125 grp = twl4030reg_read(info, VREG_GRP);
126 if (grp < 0)
127 return grp;
128
129 grp &= ~P1_GRP;
130 return twl4030reg_write(info, VREG_GRP, grp);
131}
132
133static int twl4030reg_get_status(struct regulator_dev *rdev)
134{
135 int state = twl4030reg_grp(rdev);
136
137 if (state < 0)
138 return state;
139 state &= 0x0f;
140
141 /* assume state != WARM_RESET; we'd not be running... */
142 if (!state)
143 return REGULATOR_STATUS_OFF;
144 return (state & BIT(3))
145 ? REGULATOR_STATUS_NORMAL
146 : REGULATOR_STATUS_STANDBY;
147}
148
149static int twl4030reg_set_mode(struct regulator_dev *rdev, unsigned mode)
150{
151 struct twlreg_info *info = rdev_get_drvdata(rdev);
152 unsigned message;
153 int status;
154
155 /* We can only set the mode through state machine commands... */
156 switch (mode) {
157 case REGULATOR_MODE_NORMAL:
158 message = MSG_SINGULAR(DEV_GRP_P1, info->id, RES_STATE_ACTIVE);
159 break;
160 case REGULATOR_MODE_STANDBY:
161 message = MSG_SINGULAR(DEV_GRP_P1, info->id, RES_STATE_SLEEP);
162 break;
163 default:
164 return -EINVAL;
165 }
166
167 /* Ensure the resource is associated with some group */
168 status = twl4030reg_grp(rdev);
169 if (status < 0)
170 return status;
171 if (!(status & (P3_GRP | P2_GRP | P1_GRP)))
172 return -EACCES;
173
174 status = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER,
175 message >> 8, 0x15 /* PB_WORD_MSB */ );
176 if (status >= 0)
177 return status;
178
179 return twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER,
180 message, 0x16 /* PB_WORD_LSB */ );
181}
182
183/*----------------------------------------------------------------------*/
184
185/*
186 * Support for adjustable-voltage LDOs uses a four bit (or less) voltage
187 * select field in its control register. We use tables indexed by VSEL
188 * to record voltages in milliVolts. (Accuracy is about three percent.)
189 *
190 * Note that VSEL values for VAUX2 changed in twl5030 and newer silicon;
191 * currently handled by listing two slightly different VAUX2 regulators,
192 * only one of which will be configured.
193 *
194 * VSEL values documented as "TI cannot support these values" are flagged
195 * in these tables as UNSUP() values; we normally won't assign them.
196 *
197 * VAUX3 at 3V is incorrectly listed in some TI manuals as unsupported.
198 * TI are revising the twl5030/tps659x0 specs to support that 3.0V setting.
199 */
200#ifdef CONFIG_TWL4030_ALLOW_UNSUPPORTED
201#define UNSUP_MASK 0x0000
202#else
203#define UNSUP_MASK 0x8000
204#endif
205
206#define UNSUP(x) (UNSUP_MASK | (x))
207#define IS_UNSUP(x) (UNSUP_MASK & (x))
208#define LDO_MV(x) (~UNSUP_MASK & (x))
209
210
211static const u16 VAUX1_VSEL_table[] = {
212 UNSUP(1500), UNSUP(1800), 2500, 2800,
213 3000, 3000, 3000, 3000,
214};
215static const u16 VAUX2_4030_VSEL_table[] = {
216 UNSUP(1000), UNSUP(1000), UNSUP(1200), 1300,
217 1500, 1800, UNSUP(1850), 2500,
218 UNSUP(2600), 2800, UNSUP(2850), UNSUP(3000),
219 UNSUP(3150), UNSUP(3150), UNSUP(3150), UNSUP(3150),
220};
221static const u16 VAUX2_VSEL_table[] = {
222 1700, 1700, 1900, 1300,
223 1500, 1800, 2000, 2500,
224 2100, 2800, 2200, 2300,
225 2400, 2400, 2400, 2400,
226};
227static const u16 VAUX3_VSEL_table[] = {
228 1500, 1800, 2500, 2800,
229 3000, 3000, 3000, 3000,
230};
231static const u16 VAUX4_VSEL_table[] = {
232 700, 1000, 1200, UNSUP(1300),
233 1500, 1800, UNSUP(1850), 2500,
234 UNSUP(2600), 2800, UNSUP(2850), UNSUP(3000),
235 UNSUP(3150), UNSUP(3150), UNSUP(3150), UNSUP(3150),
236};
237static const u16 VMMC1_VSEL_table[] = {
238 1850, 2850, 3000, 3150,
239};
240static const u16 VMMC2_VSEL_table[] = {
241 UNSUP(1000), UNSUP(1000), UNSUP(1200), UNSUP(1300),
242 UNSUP(1500), UNSUP(1800), 1850, UNSUP(2500),
243 2600, 2800, 2850, 3000,
244 3150, 3150, 3150, 3150,
245};
246static const u16 VPLL1_VSEL_table[] = {
247 1000, 1200, 1300, 1800,
248 UNSUP(2800), UNSUP(3000), UNSUP(3000), UNSUP(3000),
249};
250static const u16 VPLL2_VSEL_table[] = {
251 700, 1000, 1200, 1300,
252 UNSUP(1500), 1800, UNSUP(1850), UNSUP(2500),
253 UNSUP(2600), UNSUP(2800), UNSUP(2850), UNSUP(3000),
254 UNSUP(3150), UNSUP(3150), UNSUP(3150), UNSUP(3150),
255};
256static const u16 VSIM_VSEL_table[] = {
257 UNSUP(1000), UNSUP(1200), UNSUP(1300), 1800,
258 2800, 3000, 3000, 3000,
259};
260static const u16 VDAC_VSEL_table[] = {
261 1200, 1300, 1800, 1800,
262};
263
264
265static int twl4030ldo_list_voltage(struct regulator_dev *rdev, unsigned index)
266{
267 struct twlreg_info *info = rdev_get_drvdata(rdev);
268 int mV = info->table[index];
269
270 return IS_UNSUP(mV) ? 0 : (LDO_MV(mV) * 1000);
271}
272
273static int
274twl4030ldo_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV)
275{
276 struct twlreg_info *info = rdev_get_drvdata(rdev);
277 int vsel;
278
279 for (vsel = 0; vsel < info->table_len; vsel++) {
280 int mV = info->table[vsel];
281 int uV;
282
283 if (IS_UNSUP(mV))
284 continue;
285 uV = LDO_MV(mV) * 1000;
286
287 /* REVISIT for VAUX2, first match may not be best/lowest */
288
289 /* use the first in-range value */
290 if (min_uV <= uV && uV <= max_uV)
291 return twl4030reg_write(info, VREG_DEDICATED, vsel);
292 }
293
294 return -EDOM;
295}
296
297static int twl4030ldo_get_voltage(struct regulator_dev *rdev)
298{
299 struct twlreg_info *info = rdev_get_drvdata(rdev);
300 int vsel = twl4030reg_read(info, VREG_DEDICATED);
301
302 if (vsel < 0)
303 return vsel;
304
305 vsel &= info->table_len - 1;
306 return LDO_MV(info->table[vsel]) * 1000;
307}
308
309static struct regulator_ops twl4030ldo_ops = {
310 .list_voltage = twl4030ldo_list_voltage,
311
312 .set_voltage = twl4030ldo_set_voltage,
313 .get_voltage = twl4030ldo_get_voltage,
314
315 .enable = twl4030reg_enable,
316 .disable = twl4030reg_disable,
317 .is_enabled = twl4030reg_is_enabled,
318
319 .set_mode = twl4030reg_set_mode,
320
321 .get_status = twl4030reg_get_status,
322};
323
324/*----------------------------------------------------------------------*/
325
326/*
327 * Fixed voltage LDOs don't have a VSEL field to update.
328 */
329static int twl4030fixed_list_voltage(struct regulator_dev *rdev, unsigned index)
330{
331 struct twlreg_info *info = rdev_get_drvdata(rdev);
332
333 return info->min_mV * 1000;
334}
335
336static int twl4030fixed_get_voltage(struct regulator_dev *rdev)
337{
338 struct twlreg_info *info = rdev_get_drvdata(rdev);
339
340 return info->min_mV * 1000;
341}
342
343static struct regulator_ops twl4030fixed_ops = {
344 .list_voltage = twl4030fixed_list_voltage,
345
346 .get_voltage = twl4030fixed_get_voltage,
347
348 .enable = twl4030reg_enable,
349 .disable = twl4030reg_disable,
350 .is_enabled = twl4030reg_is_enabled,
351
352 .set_mode = twl4030reg_set_mode,
353
354 .get_status = twl4030reg_get_status,
355};
356
357/*----------------------------------------------------------------------*/
358
359#define TWL_ADJUSTABLE_LDO(label, offset, num) { \
360 .base = offset, \
361 .id = num, \
362 .table_len = ARRAY_SIZE(label##_VSEL_table), \
363 .table = label##_VSEL_table, \
364 .desc = { \
365 .name = #label, \
366 .id = TWL4030_REG_##label, \
367 .n_voltages = ARRAY_SIZE(label##_VSEL_table), \
368 .ops = &twl4030ldo_ops, \
369 .type = REGULATOR_VOLTAGE, \
370 .owner = THIS_MODULE, \
371 }, \
372 }
373
374#define TWL_FIXED_LDO(label, offset, mVolts, num) { \
375 .base = offset, \
376 .id = num, \
377 .min_mV = mVolts, \
378 .desc = { \
379 .name = #label, \
380 .id = TWL4030_REG_##label, \
381 .n_voltages = 1, \
382 .ops = &twl4030fixed_ops, \
383 .type = REGULATOR_VOLTAGE, \
384 .owner = THIS_MODULE, \
385 }, \
386 }
387
388/*
389 * We list regulators here if systems need some level of
390 * software control over them after boot.
391 */
392static struct twlreg_info twl4030_regs[] = {
393 TWL_ADJUSTABLE_LDO(VAUX1, 0x17, 1),
394 TWL_ADJUSTABLE_LDO(VAUX2_4030, 0x1b, 2),
395 TWL_ADJUSTABLE_LDO(VAUX2, 0x1b, 2),
396 TWL_ADJUSTABLE_LDO(VAUX3, 0x1f, 3),
397 TWL_ADJUSTABLE_LDO(VAUX4, 0x23, 4),
398 TWL_ADJUSTABLE_LDO(VMMC1, 0x27, 5),
399 TWL_ADJUSTABLE_LDO(VMMC2, 0x2b, 6),
400 /*
401 TWL_ADJUSTABLE_LDO(VPLL1, 0x2f, 7),
402 */
403 TWL_ADJUSTABLE_LDO(VPLL2, 0x33, 8),
404 TWL_ADJUSTABLE_LDO(VSIM, 0x37, 9),
405 TWL_ADJUSTABLE_LDO(VDAC, 0x3b, 10),
406 /*
407 TWL_ADJUSTABLE_LDO(VINTANA1, 0x3f, 11),
408 TWL_ADJUSTABLE_LDO(VINTANA2, 0x43, 12),
409 TWL_ADJUSTABLE_LDO(VINTDIG, 0x47, 13),
410 TWL_SMPS(VIO, 0x4b, 14),
411 TWL_SMPS(VDD1, 0x55, 15),
412 TWL_SMPS(VDD2, 0x63, 16),
413 */
414 TWL_FIXED_LDO(VUSB1V5, 0x71, 1500, 17),
415 TWL_FIXED_LDO(VUSB1V8, 0x74, 1800, 18),
416 TWL_FIXED_LDO(VUSB3V1, 0x77, 3100, 19),
417 /* VUSBCP is managed *only* by the USB subchip */
418};
419
420static int twl4030reg_probe(struct platform_device *pdev)
421{
422 int i;
423 struct twlreg_info *info;
424 struct regulator_init_data *initdata;
425 struct regulation_constraints *c;
426 struct regulator_dev *rdev;
427
428 for (i = 0, info = NULL; i < ARRAY_SIZE(twl4030_regs); i++) {
429 if (twl4030_regs[i].desc.id != pdev->id)
430 continue;
431 info = twl4030_regs + i;
432 break;
433 }
434 if (!info)
435 return -ENODEV;
436
437 initdata = pdev->dev.platform_data;
438 if (!initdata)
439 return -EINVAL;
440
441 /* Constrain board-specific capabilities according to what
442 * this driver and the chip itself can actually do.
443 */
444 c = &initdata->constraints;
445 c->valid_modes_mask &= REGULATOR_MODE_NORMAL | REGULATOR_MODE_STANDBY;
446 c->valid_ops_mask &= REGULATOR_CHANGE_VOLTAGE
447 | REGULATOR_CHANGE_MODE
448 | REGULATOR_CHANGE_STATUS;
449
450 rdev = regulator_register(&info->desc, &pdev->dev, initdata, info);
451 if (IS_ERR(rdev)) {
452 dev_err(&pdev->dev, "can't register %s, %ld\n",
453 info->desc.name, PTR_ERR(rdev));
454 return PTR_ERR(rdev);
455 }
456 platform_set_drvdata(pdev, rdev);
457
458 /* NOTE: many regulators support short-circuit IRQs (presentable
459 * as REGULATOR_OVER_CURRENT notifications?) configured via:
460 * - SC_CONFIG
461 * - SC_DETECT1 (vintana2, vmmc1/2, vaux1/2/3/4)
462 * - SC_DETECT2 (vusb, vdac, vio, vdd1/2, vpll2)
463 * - IT_CONFIG
464 */
465
466 return 0;
467}
468
469static int __devexit twl4030reg_remove(struct platform_device *pdev)
470{
471 regulator_unregister(platform_get_drvdata(pdev));
472 return 0;
473}
474
475MODULE_ALIAS("platform:twl4030_reg");
476
477static struct platform_driver twl4030reg_driver = {
478 .probe = twl4030reg_probe,
479 .remove = __devexit_p(twl4030reg_remove),
480 /* NOTE: short name, to work around driver model truncation of
481 * "twl4030_regulator.12" (and friends) to "twl4030_regulator.1".
482 */
483 .driver.name = "twl4030_reg",
484 .driver.owner = THIS_MODULE,
485};
486
487static int __init twl4030reg_init(void)
488{
489 return platform_driver_register(&twl4030reg_driver);
490}
491subsys_initcall(twl4030reg_init);
492
493static void __exit twl4030reg_exit(void)
494{
495 platform_driver_unregister(&twl4030reg_driver);
496}
497module_exit(twl4030reg_exit)
498
499MODULE_DESCRIPTION("TWL4030 regulator driver");
500MODULE_LICENSE("GPL");
diff --git a/drivers/regulator/virtual.c b/drivers/regulator/virtual.c
index 5ddb464b1c3f..3d08348584e1 100644
--- a/drivers/regulator/virtual.c
+++ b/drivers/regulator/virtual.c
@@ -226,13 +226,17 @@ static ssize_t set_mode(struct device *dev, struct device_attribute *attr,
226 unsigned int mode; 226 unsigned int mode;
227 int ret; 227 int ret;
228 228
229 if (strncmp(buf, "fast", strlen("fast")) == 0) 229 /*
230 * sysfs_streq() doesn't need the \n's, but we add them so the strings
231 * will be shared with show_mode(), above.
232 */
233 if (sysfs_streq(buf, "fast\n") == 0)
230 mode = REGULATOR_MODE_FAST; 234 mode = REGULATOR_MODE_FAST;
231 else if (strncmp(buf, "normal", strlen("normal")) == 0) 235 else if (sysfs_streq(buf, "normal\n") == 0)
232 mode = REGULATOR_MODE_NORMAL; 236 mode = REGULATOR_MODE_NORMAL;
233 else if (strncmp(buf, "idle", strlen("idle")) == 0) 237 else if (sysfs_streq(buf, "idle\n") == 0)
234 mode = REGULATOR_MODE_IDLE; 238 mode = REGULATOR_MODE_IDLE;
235 else if (strncmp(buf, "standby", strlen("standby")) == 0) 239 else if (sysfs_streq(buf, "standby\n") == 0)
236 mode = REGULATOR_MODE_STANDBY; 240 mode = REGULATOR_MODE_STANDBY;
237 else { 241 else {
238 dev_err(dev, "Configuring invalid mode\n"); 242 dev_err(dev, "Configuring invalid mode\n");
@@ -256,7 +260,7 @@ static DEVICE_ATTR(min_microamps, 0666, show_min_uA, set_min_uA);
256static DEVICE_ATTR(max_microamps, 0666, show_max_uA, set_max_uA); 260static DEVICE_ATTR(max_microamps, 0666, show_max_uA, set_max_uA);
257static DEVICE_ATTR(mode, 0666, show_mode, set_mode); 261static DEVICE_ATTR(mode, 0666, show_mode, set_mode);
258 262
259struct device_attribute *attributes[] = { 263static struct device_attribute *attributes[] = {
260 &dev_attr_min_microvolts, 264 &dev_attr_min_microvolts,
261 &dev_attr_max_microvolts, 265 &dev_attr_max_microvolts,
262 &dev_attr_min_microamps, 266 &dev_attr_min_microamps,
diff --git a/drivers/regulator/wm8350-regulator.c b/drivers/regulator/wm8350-regulator.c
index 5056e23e4414..771eca1066b5 100644
--- a/drivers/regulator/wm8350-regulator.c
+++ b/drivers/regulator/wm8350-regulator.c
@@ -24,6 +24,9 @@
24#include <linux/regulator/driver.h> 24#include <linux/regulator/driver.h>
25#include <linux/regulator/machine.h> 25#include <linux/regulator/machine.h>
26 26
27/* Maximum value possible for VSEL */
28#define WM8350_DCDC_MAX_VSEL 0x66
29
27/* Microamps */ 30/* Microamps */
28static const int isink_cur[] = { 31static const int isink_cur[] = {
29 4, 32 4,
@@ -385,6 +388,14 @@ static int wm8350_dcdc_get_voltage(struct regulator_dev *rdev)
385 return wm8350_dcdc_val_to_mvolts(val) * 1000; 388 return wm8350_dcdc_val_to_mvolts(val) * 1000;
386} 389}
387 390
391static int wm8350_dcdc_list_voltage(struct regulator_dev *rdev,
392 unsigned selector)
393{
394 if (selector > WM8350_DCDC_MAX_VSEL)
395 return -EINVAL;
396 return wm8350_dcdc_val_to_mvolts(selector) * 1000;
397}
398
388static int wm8350_dcdc_set_suspend_voltage(struct regulator_dev *rdev, int uV) 399static int wm8350_dcdc_set_suspend_voltage(struct regulator_dev *rdev, int uV)
389{ 400{
390 struct wm8350 *wm8350 = rdev_get_drvdata(rdev); 401 struct wm8350 *wm8350 = rdev_get_drvdata(rdev);
@@ -775,6 +786,14 @@ static int wm8350_ldo_get_voltage(struct regulator_dev *rdev)
775 return wm8350_ldo_val_to_mvolts(val) * 1000; 786 return wm8350_ldo_val_to_mvolts(val) * 1000;
776} 787}
777 788
789static int wm8350_ldo_list_voltage(struct regulator_dev *rdev,
790 unsigned selector)
791{
792 if (selector > WM8350_LDO1_VSEL_MASK)
793 return -EINVAL;
794 return wm8350_ldo_val_to_mvolts(selector) * 1000;
795}
796
778int wm8350_dcdc_set_slot(struct wm8350 *wm8350, int dcdc, u16 start, 797int wm8350_dcdc_set_slot(struct wm8350 *wm8350, int dcdc, u16 start,
779 u16 stop, u16 fault) 798 u16 stop, u16 fault)
780{ 799{
@@ -1031,18 +1050,30 @@ static unsigned int wm8350_dcdc_get_mode(struct regulator_dev *rdev)
1031 int dcdc = rdev_get_id(rdev); 1050 int dcdc = rdev_get_id(rdev);
1032 u16 mask, sleep, active, force; 1051 u16 mask, sleep, active, force;
1033 int mode = REGULATOR_MODE_NORMAL; 1052 int mode = REGULATOR_MODE_NORMAL;
1053 int reg;
1034 1054
1035 if (dcdc < WM8350_DCDC_1 || dcdc > WM8350_DCDC_6) 1055 switch (dcdc) {
1036 return -EINVAL; 1056 case WM8350_DCDC_1:
1037 1057 reg = WM8350_DCDC1_FORCE_PWM;
1038 if (dcdc == WM8350_DCDC_2 || dcdc == WM8350_DCDC_5) 1058 break;
1059 case WM8350_DCDC_3:
1060 reg = WM8350_DCDC3_FORCE_PWM;
1061 break;
1062 case WM8350_DCDC_4:
1063 reg = WM8350_DCDC4_FORCE_PWM;
1064 break;
1065 case WM8350_DCDC_6:
1066 reg = WM8350_DCDC6_FORCE_PWM;
1067 break;
1068 default:
1039 return -EINVAL; 1069 return -EINVAL;
1070 }
1040 1071
1041 mask = 1 << (dcdc - WM8350_DCDC_1); 1072 mask = 1 << (dcdc - WM8350_DCDC_1);
1042 active = wm8350_reg_read(wm8350, WM8350_DCDC_ACTIVE_OPTIONS) & mask; 1073 active = wm8350_reg_read(wm8350, WM8350_DCDC_ACTIVE_OPTIONS) & mask;
1074 force = wm8350_reg_read(wm8350, reg) & WM8350_DCDC1_FORCE_PWM_ENA;
1043 sleep = wm8350_reg_read(wm8350, WM8350_DCDC_SLEEP_OPTIONS) & mask; 1075 sleep = wm8350_reg_read(wm8350, WM8350_DCDC_SLEEP_OPTIONS) & mask;
1044 force = wm8350_reg_read(wm8350, WM8350_DCDC1_FORCE_PWM) 1076
1045 & WM8350_DCDC1_FORCE_PWM_ENA;
1046 dev_dbg(wm8350->dev, "mask %x active %x sleep %x force %x", 1077 dev_dbg(wm8350->dev, "mask %x active %x sleep %x force %x",
1047 mask, active, sleep, force); 1078 mask, active, sleep, force);
1048 1079
@@ -1150,6 +1181,7 @@ static int wm8350_ldo_is_enabled(struct regulator_dev *rdev)
1150static struct regulator_ops wm8350_dcdc_ops = { 1181static struct regulator_ops wm8350_dcdc_ops = {
1151 .set_voltage = wm8350_dcdc_set_voltage, 1182 .set_voltage = wm8350_dcdc_set_voltage,
1152 .get_voltage = wm8350_dcdc_get_voltage, 1183 .get_voltage = wm8350_dcdc_get_voltage,
1184 .list_voltage = wm8350_dcdc_list_voltage,
1153 .enable = wm8350_dcdc_enable, 1185 .enable = wm8350_dcdc_enable,
1154 .disable = wm8350_dcdc_disable, 1186 .disable = wm8350_dcdc_disable,
1155 .get_mode = wm8350_dcdc_get_mode, 1187 .get_mode = wm8350_dcdc_get_mode,
@@ -1173,6 +1205,7 @@ static struct regulator_ops wm8350_dcdc2_5_ops = {
1173static struct regulator_ops wm8350_ldo_ops = { 1205static struct regulator_ops wm8350_ldo_ops = {
1174 .set_voltage = wm8350_ldo_set_voltage, 1206 .set_voltage = wm8350_ldo_set_voltage,
1175 .get_voltage = wm8350_ldo_get_voltage, 1207 .get_voltage = wm8350_ldo_get_voltage,
1208 .list_voltage = wm8350_ldo_list_voltage,
1176 .enable = wm8350_ldo_enable, 1209 .enable = wm8350_ldo_enable,
1177 .disable = wm8350_ldo_disable, 1210 .disable = wm8350_ldo_disable,
1178 .is_enabled = wm8350_ldo_is_enabled, 1211 .is_enabled = wm8350_ldo_is_enabled,
@@ -1197,6 +1230,7 @@ static struct regulator_desc wm8350_reg[NUM_WM8350_REGULATORS] = {
1197 .ops = &wm8350_dcdc_ops, 1230 .ops = &wm8350_dcdc_ops,
1198 .irq = WM8350_IRQ_UV_DC1, 1231 .irq = WM8350_IRQ_UV_DC1,
1199 .type = REGULATOR_VOLTAGE, 1232 .type = REGULATOR_VOLTAGE,
1233 .n_voltages = WM8350_DCDC_MAX_VSEL + 1,
1200 .owner = THIS_MODULE, 1234 .owner = THIS_MODULE,
1201 }, 1235 },
1202 { 1236 {
@@ -1213,6 +1247,7 @@ static struct regulator_desc wm8350_reg[NUM_WM8350_REGULATORS] = {
1213 .ops = &wm8350_dcdc_ops, 1247 .ops = &wm8350_dcdc_ops,
1214 .irq = WM8350_IRQ_UV_DC3, 1248 .irq = WM8350_IRQ_UV_DC3,
1215 .type = REGULATOR_VOLTAGE, 1249 .type = REGULATOR_VOLTAGE,
1250 .n_voltages = WM8350_DCDC_MAX_VSEL + 1,
1216 .owner = THIS_MODULE, 1251 .owner = THIS_MODULE,
1217 }, 1252 },
1218 { 1253 {
@@ -1221,6 +1256,7 @@ static struct regulator_desc wm8350_reg[NUM_WM8350_REGULATORS] = {
1221 .ops = &wm8350_dcdc_ops, 1256 .ops = &wm8350_dcdc_ops,
1222 .irq = WM8350_IRQ_UV_DC4, 1257 .irq = WM8350_IRQ_UV_DC4,
1223 .type = REGULATOR_VOLTAGE, 1258 .type = REGULATOR_VOLTAGE,
1259 .n_voltages = WM8350_DCDC_MAX_VSEL + 1,
1224 .owner = THIS_MODULE, 1260 .owner = THIS_MODULE,
1225 }, 1261 },
1226 { 1262 {
@@ -1237,6 +1273,7 @@ static struct regulator_desc wm8350_reg[NUM_WM8350_REGULATORS] = {
1237 .ops = &wm8350_dcdc_ops, 1273 .ops = &wm8350_dcdc_ops,
1238 .irq = WM8350_IRQ_UV_DC6, 1274 .irq = WM8350_IRQ_UV_DC6,
1239 .type = REGULATOR_VOLTAGE, 1275 .type = REGULATOR_VOLTAGE,
1276 .n_voltages = WM8350_DCDC_MAX_VSEL + 1,
1240 .owner = THIS_MODULE, 1277 .owner = THIS_MODULE,
1241 }, 1278 },
1242 { 1279 {
@@ -1245,6 +1282,7 @@ static struct regulator_desc wm8350_reg[NUM_WM8350_REGULATORS] = {
1245 .ops = &wm8350_ldo_ops, 1282 .ops = &wm8350_ldo_ops,
1246 .irq = WM8350_IRQ_UV_LDO1, 1283 .irq = WM8350_IRQ_UV_LDO1,
1247 .type = REGULATOR_VOLTAGE, 1284 .type = REGULATOR_VOLTAGE,
1285 .n_voltages = WM8350_LDO1_VSEL_MASK + 1,
1248 .owner = THIS_MODULE, 1286 .owner = THIS_MODULE,
1249 }, 1287 },
1250 { 1288 {
@@ -1253,6 +1291,7 @@ static struct regulator_desc wm8350_reg[NUM_WM8350_REGULATORS] = {
1253 .ops = &wm8350_ldo_ops, 1291 .ops = &wm8350_ldo_ops,
1254 .irq = WM8350_IRQ_UV_LDO2, 1292 .irq = WM8350_IRQ_UV_LDO2,
1255 .type = REGULATOR_VOLTAGE, 1293 .type = REGULATOR_VOLTAGE,
1294 .n_voltages = WM8350_LDO2_VSEL_MASK + 1,
1256 .owner = THIS_MODULE, 1295 .owner = THIS_MODULE,
1257 }, 1296 },
1258 { 1297 {
@@ -1261,6 +1300,7 @@ static struct regulator_desc wm8350_reg[NUM_WM8350_REGULATORS] = {
1261 .ops = &wm8350_ldo_ops, 1300 .ops = &wm8350_ldo_ops,
1262 .irq = WM8350_IRQ_UV_LDO3, 1301 .irq = WM8350_IRQ_UV_LDO3,
1263 .type = REGULATOR_VOLTAGE, 1302 .type = REGULATOR_VOLTAGE,
1303 .n_voltages = WM8350_LDO3_VSEL_MASK + 1,
1264 .owner = THIS_MODULE, 1304 .owner = THIS_MODULE,
1265 }, 1305 },
1266 { 1306 {
@@ -1269,6 +1309,7 @@ static struct regulator_desc wm8350_reg[NUM_WM8350_REGULATORS] = {
1269 .ops = &wm8350_ldo_ops, 1309 .ops = &wm8350_ldo_ops,
1270 .irq = WM8350_IRQ_UV_LDO4, 1310 .irq = WM8350_IRQ_UV_LDO4,
1271 .type = REGULATOR_VOLTAGE, 1311 .type = REGULATOR_VOLTAGE,
1312 .n_voltages = WM8350_LDO4_VSEL_MASK + 1,
1272 .owner = THIS_MODULE, 1313 .owner = THIS_MODULE,
1273 }, 1314 },
1274 { 1315 {
@@ -1293,6 +1334,7 @@ static void pmic_uv_handler(struct wm8350 *wm8350, int irq, void *data)
1293{ 1334{
1294 struct regulator_dev *rdev = (struct regulator_dev *)data; 1335 struct regulator_dev *rdev = (struct regulator_dev *)data;
1295 1336
1337 mutex_lock(&rdev->mutex);
1296 if (irq == WM8350_IRQ_CS1 || irq == WM8350_IRQ_CS2) 1338 if (irq == WM8350_IRQ_CS1 || irq == WM8350_IRQ_CS2)
1297 regulator_notifier_call_chain(rdev, 1339 regulator_notifier_call_chain(rdev,
1298 REGULATOR_EVENT_REGULATION_OUT, 1340 REGULATOR_EVENT_REGULATION_OUT,
@@ -1301,6 +1343,7 @@ static void pmic_uv_handler(struct wm8350 *wm8350, int irq, void *data)
1301 regulator_notifier_call_chain(rdev, 1343 regulator_notifier_call_chain(rdev,
1302 REGULATOR_EVENT_UNDER_VOLTAGE, 1344 REGULATOR_EVENT_UNDER_VOLTAGE,
1303 wm8350); 1345 wm8350);
1346 mutex_unlock(&rdev->mutex);
1304} 1347}
1305 1348
1306static int wm8350_regulator_probe(struct platform_device *pdev) 1349static int wm8350_regulator_probe(struct platform_device *pdev)
@@ -1333,9 +1376,9 @@ static int wm8350_regulator_probe(struct platform_device *pdev)
1333 break; 1376 break;
1334 } 1377 }
1335 1378
1336
1337 /* register regulator */ 1379 /* register regulator */
1338 rdev = regulator_register(&wm8350_reg[pdev->id], &pdev->dev, 1380 rdev = regulator_register(&wm8350_reg[pdev->id], &pdev->dev,
1381 pdev->dev.platform_data,
1339 dev_get_drvdata(&pdev->dev)); 1382 dev_get_drvdata(&pdev->dev));
1340 if (IS_ERR(rdev)) { 1383 if (IS_ERR(rdev)) {
1341 dev_err(&pdev->dev, "failed to register %s\n", 1384 dev_err(&pdev->dev, "failed to register %s\n",
diff --git a/drivers/regulator/wm8400-regulator.c b/drivers/regulator/wm8400-regulator.c
index 56e23d44ba59..157426029071 100644
--- a/drivers/regulator/wm8400-regulator.c
+++ b/drivers/regulator/wm8400-regulator.c
@@ -43,6 +43,18 @@ static int wm8400_ldo_disable(struct regulator_dev *dev)
43 WM8400_LDO1_ENA, 0); 43 WM8400_LDO1_ENA, 0);
44} 44}
45 45
46static int wm8400_ldo_list_voltage(struct regulator_dev *dev,
47 unsigned selector)
48{
49 if (selector > WM8400_LDO1_VSEL_MASK)
50 return -EINVAL;
51
52 if (selector < 15)
53 return 900000 + (selector * 50000);
54 else
55 return 1600000 + ((selector - 14) * 100000);
56}
57
46static int wm8400_ldo_get_voltage(struct regulator_dev *dev) 58static int wm8400_ldo_get_voltage(struct regulator_dev *dev)
47{ 59{
48 struct wm8400 *wm8400 = rdev_get_drvdata(dev); 60 struct wm8400 *wm8400 = rdev_get_drvdata(dev);
@@ -51,10 +63,7 @@ static int wm8400_ldo_get_voltage(struct regulator_dev *dev)
51 val = wm8400_reg_read(wm8400, WM8400_LDO1_CONTROL + rdev_get_id(dev)); 63 val = wm8400_reg_read(wm8400, WM8400_LDO1_CONTROL + rdev_get_id(dev));
52 val &= WM8400_LDO1_VSEL_MASK; 64 val &= WM8400_LDO1_VSEL_MASK;
53 65
54 if (val < 15) 66 return wm8400_ldo_list_voltage(dev, val);
55 return 900000 + (val * 50000);
56 else
57 return 1600000 + ((val - 14) * 100000);
58} 67}
59 68
60static int wm8400_ldo_set_voltage(struct regulator_dev *dev, 69static int wm8400_ldo_set_voltage(struct regulator_dev *dev,
@@ -92,6 +101,7 @@ static struct regulator_ops wm8400_ldo_ops = {
92 .is_enabled = wm8400_ldo_is_enabled, 101 .is_enabled = wm8400_ldo_is_enabled,
93 .enable = wm8400_ldo_enable, 102 .enable = wm8400_ldo_enable,
94 .disable = wm8400_ldo_disable, 103 .disable = wm8400_ldo_disable,
104 .list_voltage = wm8400_ldo_list_voltage,
95 .get_voltage = wm8400_ldo_get_voltage, 105 .get_voltage = wm8400_ldo_get_voltage,
96 .set_voltage = wm8400_ldo_set_voltage, 106 .set_voltage = wm8400_ldo_set_voltage,
97}; 107};
@@ -124,6 +134,15 @@ static int wm8400_dcdc_disable(struct regulator_dev *dev)
124 WM8400_DC1_ENA, 0); 134 WM8400_DC1_ENA, 0);
125} 135}
126 136
137static int wm8400_dcdc_list_voltage(struct regulator_dev *dev,
138 unsigned selector)
139{
140 if (selector > WM8400_DC1_VSEL_MASK)
141 return -EINVAL;
142
143 return 850000 + (selector * 25000);
144}
145
127static int wm8400_dcdc_get_voltage(struct regulator_dev *dev) 146static int wm8400_dcdc_get_voltage(struct regulator_dev *dev)
128{ 147{
129 struct wm8400 *wm8400 = rdev_get_drvdata(dev); 148 struct wm8400 *wm8400 = rdev_get_drvdata(dev);
@@ -237,6 +256,7 @@ static struct regulator_ops wm8400_dcdc_ops = {
237 .is_enabled = wm8400_dcdc_is_enabled, 256 .is_enabled = wm8400_dcdc_is_enabled,
238 .enable = wm8400_dcdc_enable, 257 .enable = wm8400_dcdc_enable,
239 .disable = wm8400_dcdc_disable, 258 .disable = wm8400_dcdc_disable,
259 .list_voltage = wm8400_dcdc_list_voltage,
240 .get_voltage = wm8400_dcdc_get_voltage, 260 .get_voltage = wm8400_dcdc_get_voltage,
241 .set_voltage = wm8400_dcdc_set_voltage, 261 .set_voltage = wm8400_dcdc_set_voltage,
242 .get_mode = wm8400_dcdc_get_mode, 262 .get_mode = wm8400_dcdc_get_mode,
@@ -249,6 +269,7 @@ static struct regulator_desc regulators[] = {
249 .name = "LDO1", 269 .name = "LDO1",
250 .id = WM8400_LDO1, 270 .id = WM8400_LDO1,
251 .ops = &wm8400_ldo_ops, 271 .ops = &wm8400_ldo_ops,
272 .n_voltages = WM8400_LDO1_VSEL_MASK + 1,
252 .type = REGULATOR_VOLTAGE, 273 .type = REGULATOR_VOLTAGE,
253 .owner = THIS_MODULE, 274 .owner = THIS_MODULE,
254 }, 275 },
@@ -256,6 +277,7 @@ static struct regulator_desc regulators[] = {
256 .name = "LDO2", 277 .name = "LDO2",
257 .id = WM8400_LDO2, 278 .id = WM8400_LDO2,
258 .ops = &wm8400_ldo_ops, 279 .ops = &wm8400_ldo_ops,
280 .n_voltages = WM8400_LDO2_VSEL_MASK + 1,
259 .type = REGULATOR_VOLTAGE, 281 .type = REGULATOR_VOLTAGE,
260 .owner = THIS_MODULE, 282 .owner = THIS_MODULE,
261 }, 283 },
@@ -263,6 +285,7 @@ static struct regulator_desc regulators[] = {
263 .name = "LDO3", 285 .name = "LDO3",
264 .id = WM8400_LDO3, 286 .id = WM8400_LDO3,
265 .ops = &wm8400_ldo_ops, 287 .ops = &wm8400_ldo_ops,
288 .n_voltages = WM8400_LDO3_VSEL_MASK + 1,
266 .type = REGULATOR_VOLTAGE, 289 .type = REGULATOR_VOLTAGE,
267 .owner = THIS_MODULE, 290 .owner = THIS_MODULE,
268 }, 291 },
@@ -270,6 +293,7 @@ static struct regulator_desc regulators[] = {
270 .name = "LDO4", 293 .name = "LDO4",
271 .id = WM8400_LDO4, 294 .id = WM8400_LDO4,
272 .ops = &wm8400_ldo_ops, 295 .ops = &wm8400_ldo_ops,
296 .n_voltages = WM8400_LDO4_VSEL_MASK + 1,
273 .type = REGULATOR_VOLTAGE, 297 .type = REGULATOR_VOLTAGE,
274 .owner = THIS_MODULE, 298 .owner = THIS_MODULE,
275 }, 299 },
@@ -277,6 +301,7 @@ static struct regulator_desc regulators[] = {
277 .name = "DCDC1", 301 .name = "DCDC1",
278 .id = WM8400_DCDC1, 302 .id = WM8400_DCDC1,
279 .ops = &wm8400_dcdc_ops, 303 .ops = &wm8400_dcdc_ops,
304 .n_voltages = WM8400_DC1_VSEL_MASK + 1,
280 .type = REGULATOR_VOLTAGE, 305 .type = REGULATOR_VOLTAGE,
281 .owner = THIS_MODULE, 306 .owner = THIS_MODULE,
282 }, 307 },
@@ -284,6 +309,7 @@ static struct regulator_desc regulators[] = {
284 .name = "DCDC2", 309 .name = "DCDC2",
285 .id = WM8400_DCDC2, 310 .id = WM8400_DCDC2,
286 .ops = &wm8400_dcdc_ops, 311 .ops = &wm8400_dcdc_ops,
312 .n_voltages = WM8400_DC2_VSEL_MASK + 1,
287 .type = REGULATOR_VOLTAGE, 313 .type = REGULATOR_VOLTAGE,
288 .owner = THIS_MODULE, 314 .owner = THIS_MODULE,
289 }, 315 },
@@ -294,7 +320,7 @@ static int __devinit wm8400_regulator_probe(struct platform_device *pdev)
294 struct regulator_dev *rdev; 320 struct regulator_dev *rdev;
295 321
296 rdev = regulator_register(&regulators[pdev->id], &pdev->dev, 322 rdev = regulator_register(&regulators[pdev->id], &pdev->dev,
297 pdev->dev.driver_data); 323 pdev->dev.platform_data, pdev->dev.driver_data);
298 324
299 if (IS_ERR(rdev)) 325 if (IS_ERR(rdev))
300 return PTR_ERR(rdev); 326 return PTR_ERR(rdev);