diff options
51 files changed, 516 insertions, 269 deletions
diff --git a/Documentation/devicetree/bindings/regulator/fixed-regulator.txt b/Documentation/devicetree/bindings/regulator/fixed-regulator.txt new file mode 100644 index 000000000000..9cf57fd042d2 --- /dev/null +++ b/Documentation/devicetree/bindings/regulator/fixed-regulator.txt | |||
@@ -0,0 +1,29 @@ | |||
1 | Fixed Voltage regulators | ||
2 | |||
3 | Required properties: | ||
4 | - compatible: Must be "regulator-fixed"; | ||
5 | |||
6 | Optional properties: | ||
7 | - gpio: gpio to use for enable control | ||
8 | - startup-delay-us: startup time in microseconds | ||
9 | - enable-active-high: Polarity of GPIO is Active high | ||
10 | If this property is missing, the default assumed is Active low. | ||
11 | |||
12 | Any property defined as part of the core regulator | ||
13 | binding, defined in regulator.txt, can also be used. | ||
14 | However a fixed voltage regulator is expected to have the | ||
15 | regulator-min-microvolt and regulator-max-microvolt | ||
16 | to be the same. | ||
17 | |||
18 | Example: | ||
19 | |||
20 | abc: fixedregulator@0 { | ||
21 | compatible = "regulator-fixed"; | ||
22 | regulator-name = "fixed-supply"; | ||
23 | regulator-min-microvolt = <1800000>; | ||
24 | regulator-max-microvolt = <1800000>; | ||
25 | gpio = <&gpio1 16 0>; | ||
26 | startup-delay-us = <70000>; | ||
27 | enable-active-high; | ||
28 | regulator-boot-on | ||
29 | }; | ||
diff --git a/Documentation/devicetree/bindings/regulator/regulator.txt b/Documentation/devicetree/bindings/regulator/regulator.txt new file mode 100644 index 000000000000..82bef20d4c49 --- /dev/null +++ b/Documentation/devicetree/bindings/regulator/regulator.txt | |||
@@ -0,0 +1,54 @@ | |||
1 | Voltage/Current Regulators | ||
2 | |||
3 | Optional properties: | ||
4 | - regulator-name: A string used as a descriptive name for regulator outputs | ||
5 | - regulator-min-microvolt: smallest voltage consumers may set | ||
6 | - regulator-max-microvolt: largest voltage consumers may set | ||
7 | - regulator-microvolt-offset: Offset applied to voltages to compensate for voltage drops | ||
8 | - regulator-min-microamp: smallest current consumers may set | ||
9 | - regulator-max-microamp: largest current consumers may set | ||
10 | - regulator-always-on: boolean, regulator should never be disabled | ||
11 | - regulator-boot-on: bootloader/firmware enabled regulator | ||
12 | - <name>-supply: phandle to the parent supply/regulator node | ||
13 | |||
14 | Example: | ||
15 | |||
16 | xyzreg: regulator@0 { | ||
17 | regulator-min-microvolt = <1000000>; | ||
18 | regulator-max-microvolt = <2500000>; | ||
19 | regulator-always-on; | ||
20 | vin-supply = <&vin>; | ||
21 | }; | ||
22 | |||
23 | Regulator Consumers: | ||
24 | Consumer nodes can reference one or more of its supplies/ | ||
25 | regulators using the below bindings. | ||
26 | |||
27 | - <name>-supply: phandle to the regulator node | ||
28 | |||
29 | These are the same bindings that a regulator in the above | ||
30 | example used to reference its own supply, in which case | ||
31 | its just seen as a special case of a regulator being a | ||
32 | consumer itself. | ||
33 | |||
34 | Example of a consumer device node (mmc) referencing two | ||
35 | regulators (twl-reg1 and twl-reg2), | ||
36 | |||
37 | twl-reg1: regulator@0 { | ||
38 | ... | ||
39 | ... | ||
40 | ... | ||
41 | }; | ||
42 | |||
43 | twl-reg2: regulator@1 { | ||
44 | ... | ||
45 | ... | ||
46 | ... | ||
47 | }; | ||
48 | |||
49 | mmc: mmc@0x0 { | ||
50 | ... | ||
51 | ... | ||
52 | vmmc-supply = <&twl-reg1>; | ||
53 | vmmcaux-supply = <&twl-reg2>; | ||
54 | }; | ||
diff --git a/drivers/regulator/88pm8607.c b/drivers/regulator/88pm8607.c index ca0d608f8248..df33530cec4a 100644 --- a/drivers/regulator/88pm8607.c +++ b/drivers/regulator/88pm8607.c | |||
@@ -427,7 +427,7 @@ static int __devinit pm8607_regulator_probe(struct platform_device *pdev) | |||
427 | 427 | ||
428 | /* replace driver_data with info */ | 428 | /* replace driver_data with info */ |
429 | info->regulator = regulator_register(&info->desc, &pdev->dev, | 429 | info->regulator = regulator_register(&info->desc, &pdev->dev, |
430 | pdata, info); | 430 | pdata, info, NULL); |
431 | if (IS_ERR(info->regulator)) { | 431 | if (IS_ERR(info->regulator)) { |
432 | dev_err(&pdev->dev, "failed to register regulator %s\n", | 432 | dev_err(&pdev->dev, "failed to register regulator %s\n", |
433 | info->desc.name); | 433 | info->desc.name); |
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index 9713b1b860cb..4e919b2ac7ee 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig | |||
@@ -93,6 +93,7 @@ config REGULATOR_MAX1586 | |||
93 | config REGULATOR_MAX8649 | 93 | config REGULATOR_MAX8649 |
94 | tristate "Maxim 8649 voltage regulator" | 94 | tristate "Maxim 8649 voltage regulator" |
95 | depends on I2C | 95 | depends on I2C |
96 | select REGMAP_I2C | ||
96 | help | 97 | help |
97 | This driver controls a Maxim 8649 voltage output regulator via | 98 | This driver controls a Maxim 8649 voltage output regulator via |
98 | I2C bus. | 99 | I2C bus. |
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile index 93a6318f5328..c75a5229cb27 100644 --- a/drivers/regulator/Makefile +++ b/drivers/regulator/Makefile | |||
@@ -4,6 +4,7 @@ | |||
4 | 4 | ||
5 | 5 | ||
6 | obj-$(CONFIG_REGULATOR) += core.o dummy.o | 6 | obj-$(CONFIG_REGULATOR) += core.o dummy.o |
7 | obj-$(CONFIG_OF) += of_regulator.o | ||
7 | obj-$(CONFIG_REGULATOR_FIXED_VOLTAGE) += fixed.o | 8 | obj-$(CONFIG_REGULATOR_FIXED_VOLTAGE) += fixed.o |
8 | obj-$(CONFIG_REGULATOR_VIRTUAL_CONSUMER) += virtual.o | 9 | obj-$(CONFIG_REGULATOR_VIRTUAL_CONSUMER) += virtual.o |
9 | obj-$(CONFIG_REGULATOR_USERSPACE_CONSUMER) += userspace-consumer.o | 10 | obj-$(CONFIG_REGULATOR_USERSPACE_CONSUMER) += userspace-consumer.o |
diff --git a/drivers/regulator/aat2870-regulator.c b/drivers/regulator/aat2870-regulator.c index 298c6c6a2795..685ad43b0749 100644 --- a/drivers/regulator/aat2870-regulator.c +++ b/drivers/regulator/aat2870-regulator.c | |||
@@ -63,7 +63,7 @@ static int aat2870_ldo_set_voltage_sel(struct regulator_dev *rdev, | |||
63 | struct aat2870_data *aat2870 = dev_get_drvdata(ri->pdev->dev.parent); | 63 | struct aat2870_data *aat2870 = dev_get_drvdata(ri->pdev->dev.parent); |
64 | 64 | ||
65 | return aat2870->update(aat2870, ri->voltage_addr, ri->voltage_mask, | 65 | return aat2870->update(aat2870, ri->voltage_addr, ri->voltage_mask, |
66 | (selector << ri->voltage_shift) & ri->voltage_mask); | 66 | selector << ri->voltage_shift); |
67 | } | 67 | } |
68 | 68 | ||
69 | static int aat2870_ldo_get_voltage_sel(struct regulator_dev *rdev) | 69 | static int aat2870_ldo_get_voltage_sel(struct regulator_dev *rdev) |
@@ -188,7 +188,7 @@ static int aat2870_regulator_probe(struct platform_device *pdev) | |||
188 | ri->pdev = pdev; | 188 | ri->pdev = pdev; |
189 | 189 | ||
190 | rdev = regulator_register(&ri->desc, &pdev->dev, | 190 | rdev = regulator_register(&ri->desc, &pdev->dev, |
191 | pdev->dev.platform_data, ri); | 191 | pdev->dev.platform_data, ri, NULL); |
192 | if (IS_ERR(rdev)) { | 192 | if (IS_ERR(rdev)) { |
193 | dev_err(&pdev->dev, "Failed to register regulator %s\n", | 193 | dev_err(&pdev->dev, "Failed to register regulator %s\n", |
194 | ri->desc.name); | 194 | ri->desc.name); |
diff --git a/drivers/regulator/ab3100.c b/drivers/regulator/ab3100.c index 585e4946fe0a..042271aace6a 100644 --- a/drivers/regulator/ab3100.c +++ b/drivers/regulator/ab3100.c | |||
@@ -634,7 +634,7 @@ static int __devinit ab3100_regulators_probe(struct platform_device *pdev) | |||
634 | rdev = regulator_register(&ab3100_regulator_desc[i], | 634 | rdev = regulator_register(&ab3100_regulator_desc[i], |
635 | &pdev->dev, | 635 | &pdev->dev, |
636 | &plfdata->reg_constraints[i], | 636 | &plfdata->reg_constraints[i], |
637 | reg); | 637 | reg, NULL); |
638 | 638 | ||
639 | if (IS_ERR(rdev)) { | 639 | if (IS_ERR(rdev)) { |
640 | err = PTR_ERR(rdev); | 640 | err = PTR_ERR(rdev); |
diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c index 6e1ae69646b3..e91b8ddc2793 100644 --- a/drivers/regulator/ab8500.c +++ b/drivers/regulator/ab8500.c | |||
@@ -822,7 +822,7 @@ static __devinit int ab8500_regulator_probe(struct platform_device *pdev) | |||
822 | 822 | ||
823 | /* register regulator with framework */ | 823 | /* register regulator with framework */ |
824 | info->regulator = regulator_register(&info->desc, &pdev->dev, | 824 | info->regulator = regulator_register(&info->desc, &pdev->dev, |
825 | &pdata->regulator[i], info); | 825 | &pdata->regulator[i], info, NULL); |
826 | if (IS_ERR(info->regulator)) { | 826 | if (IS_ERR(info->regulator)) { |
827 | err = PTR_ERR(info->regulator); | 827 | err = PTR_ERR(info->regulator); |
828 | dev_err(&pdev->dev, "failed to register regulator %s\n", | 828 | dev_err(&pdev->dev, "failed to register regulator %s\n", |
diff --git a/drivers/regulator/ad5398.c b/drivers/regulator/ad5398.c index a4be41614eeb..483c80930852 100644 --- a/drivers/regulator/ad5398.c +++ b/drivers/regulator/ad5398.c | |||
@@ -233,7 +233,7 @@ static int __devinit ad5398_probe(struct i2c_client *client, | |||
233 | chip->current_mask = (chip->current_level - 1) << chip->current_offset; | 233 | chip->current_mask = (chip->current_level - 1) << chip->current_offset; |
234 | 234 | ||
235 | chip->rdev = regulator_register(&ad5398_reg, &client->dev, | 235 | chip->rdev = regulator_register(&ad5398_reg, &client->dev, |
236 | init_data, chip); | 236 | init_data, chip, NULL); |
237 | if (IS_ERR(chip->rdev)) { | 237 | if (IS_ERR(chip->rdev)) { |
238 | ret = PTR_ERR(chip->rdev); | 238 | ret = PTR_ERR(chip->rdev); |
239 | dev_err(&client->dev, "failed to register %s %s\n", | 239 | dev_err(&client->dev, "failed to register %s %s\n", |
diff --git a/drivers/regulator/bq24022.c b/drivers/regulator/bq24022.c index e24d1b7d97a8..9fab6d1bbe80 100644 --- a/drivers/regulator/bq24022.c +++ b/drivers/regulator/bq24022.c | |||
@@ -107,7 +107,7 @@ static int __init bq24022_probe(struct platform_device *pdev) | |||
107 | ret = gpio_direction_output(pdata->gpio_nce, 1); | 107 | ret = gpio_direction_output(pdata->gpio_nce, 1); |
108 | 108 | ||
109 | bq24022 = regulator_register(&bq24022_desc, &pdev->dev, | 109 | bq24022 = regulator_register(&bq24022_desc, &pdev->dev, |
110 | pdata->init_data, pdata); | 110 | pdata->init_data, pdata, NULL); |
111 | if (IS_ERR(bq24022)) { | 111 | if (IS_ERR(bq24022)) { |
112 | dev_dbg(&pdev->dev, "couldn't register regulator\n"); | 112 | dev_dbg(&pdev->dev, "couldn't register regulator\n"); |
113 | ret = PTR_ERR(bq24022); | 113 | ret = PTR_ERR(bq24022); |
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 669d02160221..f489bed2d848 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
@@ -25,6 +25,8 @@ | |||
25 | #include <linux/mutex.h> | 25 | #include <linux/mutex.h> |
26 | #include <linux/suspend.h> | 26 | #include <linux/suspend.h> |
27 | #include <linux/delay.h> | 27 | #include <linux/delay.h> |
28 | #include <linux/of.h> | ||
29 | #include <linux/regulator/of_regulator.h> | ||
28 | #include <linux/regulator/consumer.h> | 30 | #include <linux/regulator/consumer.h> |
29 | #include <linux/regulator/driver.h> | 31 | #include <linux/regulator/driver.h> |
30 | #include <linux/regulator/machine.h> | 32 | #include <linux/regulator/machine.h> |
@@ -132,6 +134,33 @@ static struct regulator *get_device_regulator(struct device *dev) | |||
132 | return NULL; | 134 | return NULL; |
133 | } | 135 | } |
134 | 136 | ||
137 | /** | ||
138 | * of_get_regulator - get a regulator device node based on supply name | ||
139 | * @dev: Device pointer for the consumer (of regulator) device | ||
140 | * @supply: regulator supply name | ||
141 | * | ||
142 | * Extract the regulator device node corresponding to the supply name. | ||
143 | * retruns the device node corresponding to the regulator if found, else | ||
144 | * returns NULL. | ||
145 | */ | ||
146 | static struct device_node *of_get_regulator(struct device *dev, const char *supply) | ||
147 | { | ||
148 | struct device_node *regnode = NULL; | ||
149 | char prop_name[32]; /* 32 is max size of property name */ | ||
150 | |||
151 | dev_dbg(dev, "Looking up %s-supply from device tree\n", supply); | ||
152 | |||
153 | snprintf(prop_name, 32, "%s-supply", supply); | ||
154 | regnode = of_parse_phandle(dev->of_node, prop_name, 0); | ||
155 | |||
156 | if (!regnode) { | ||
157 | dev_warn(dev, "%s property in node %s references invalid phandle", | ||
158 | prop_name, dev->of_node->full_name); | ||
159 | return NULL; | ||
160 | } | ||
161 | return regnode; | ||
162 | } | ||
163 | |||
135 | /* Platform voltage constraint check */ | 164 | /* Platform voltage constraint check */ |
136 | static int regulator_check_voltage(struct regulator_dev *rdev, | 165 | static int regulator_check_voltage(struct regulator_dev *rdev, |
137 | int *min_uV, int *max_uV) | 166 | int *min_uV, int *max_uV) |
@@ -1148,6 +1177,30 @@ static int _regulator_get_enable_time(struct regulator_dev *rdev) | |||
1148 | return rdev->desc->ops->enable_time(rdev); | 1177 | return rdev->desc->ops->enable_time(rdev); |
1149 | } | 1178 | } |
1150 | 1179 | ||
1180 | static struct regulator_dev *regulator_dev_lookup(struct device *dev, | ||
1181 | const char *supply) | ||
1182 | { | ||
1183 | struct regulator_dev *r; | ||
1184 | struct device_node *node; | ||
1185 | |||
1186 | /* first do a dt based lookup */ | ||
1187 | if (dev && dev->of_node) { | ||
1188 | node = of_get_regulator(dev, supply); | ||
1189 | if (node) | ||
1190 | list_for_each_entry(r, ®ulator_list, list) | ||
1191 | if (r->dev.parent && | ||
1192 | node == r->dev.of_node) | ||
1193 | return r; | ||
1194 | } | ||
1195 | |||
1196 | /* if not found, try doing it non-dt way */ | ||
1197 | list_for_each_entry(r, ®ulator_list, list) | ||
1198 | if (strcmp(rdev_get_name(r), supply) == 0) | ||
1199 | return r; | ||
1200 | |||
1201 | return NULL; | ||
1202 | } | ||
1203 | |||
1151 | /* Internal regulator request function */ | 1204 | /* Internal regulator request function */ |
1152 | static struct regulator *_regulator_get(struct device *dev, const char *id, | 1205 | static struct regulator *_regulator_get(struct device *dev, const char *id, |
1153 | int exclusive) | 1206 | int exclusive) |
@@ -1168,6 +1221,10 @@ static struct regulator *_regulator_get(struct device *dev, const char *id, | |||
1168 | 1221 | ||
1169 | mutex_lock(®ulator_list_mutex); | 1222 | mutex_lock(®ulator_list_mutex); |
1170 | 1223 | ||
1224 | rdev = regulator_dev_lookup(dev, id); | ||
1225 | if (rdev) | ||
1226 | goto found; | ||
1227 | |||
1171 | list_for_each_entry(map, ®ulator_map_list, list) { | 1228 | list_for_each_entry(map, ®ulator_map_list, list) { |
1172 | /* If the mapping has a device set up it must match */ | 1229 | /* If the mapping has a device set up it must match */ |
1173 | if (map->dev_name && | 1230 | if (map->dev_name && |
@@ -2503,7 +2560,8 @@ static int add_regulator_attributes(struct regulator_dev *rdev) | |||
2503 | int status = 0; | 2560 | int status = 0; |
2504 | 2561 | ||
2505 | /* some attributes need specific methods to be displayed */ | 2562 | /* some attributes need specific methods to be displayed */ |
2506 | if (ops->get_voltage || ops->get_voltage_sel) { | 2563 | if ((ops->get_voltage && ops->get_voltage(rdev) >= 0) || |
2564 | (ops->get_voltage_sel && ops->get_voltage_sel(rdev) >= 0)) { | ||
2507 | status = device_create_file(dev, &dev_attr_microvolts); | 2565 | status = device_create_file(dev, &dev_attr_microvolts); |
2508 | if (status < 0) | 2566 | if (status < 0) |
2509 | return status; | 2567 | return status; |
@@ -2637,11 +2695,12 @@ static void rdev_init_debugfs(struct regulator_dev *rdev) | |||
2637 | */ | 2695 | */ |
2638 | struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc, | 2696 | struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc, |
2639 | struct device *dev, const struct regulator_init_data *init_data, | 2697 | struct device *dev, const struct regulator_init_data *init_data, |
2640 | void *driver_data) | 2698 | void *driver_data, struct device_node *of_node) |
2641 | { | 2699 | { |
2642 | static atomic_t regulator_no = ATOMIC_INIT(0); | 2700 | static atomic_t regulator_no = ATOMIC_INIT(0); |
2643 | struct regulator_dev *rdev; | 2701 | struct regulator_dev *rdev; |
2644 | int ret, i; | 2702 | int ret, i; |
2703 | const char *supply = NULL; | ||
2645 | 2704 | ||
2646 | if (regulator_desc == NULL) | 2705 | if (regulator_desc == NULL) |
2647 | return ERR_PTR(-EINVAL); | 2706 | return ERR_PTR(-EINVAL); |
@@ -2696,6 +2755,7 @@ struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc, | |||
2696 | 2755 | ||
2697 | /* register with sysfs */ | 2756 | /* register with sysfs */ |
2698 | rdev->dev.class = ®ulator_class; | 2757 | rdev->dev.class = ®ulator_class; |
2758 | rdev->dev.of_node = of_node; | ||
2699 | rdev->dev.parent = dev; | 2759 | rdev->dev.parent = dev; |
2700 | dev_set_name(&rdev->dev, "regulator.%d", | 2760 | dev_set_name(&rdev->dev, "regulator.%d", |
2701 | atomic_inc_return(®ulator_no) - 1); | 2761 | atomic_inc_return(®ulator_no) - 1); |
@@ -2717,21 +2777,18 @@ struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc, | |||
2717 | if (ret < 0) | 2777 | if (ret < 0) |
2718 | goto scrub; | 2778 | goto scrub; |
2719 | 2779 | ||
2720 | if (init_data->supply_regulator) { | 2780 | if (init_data->supply_regulator) |
2781 | supply = init_data->supply_regulator; | ||
2782 | else if (regulator_desc->supply_name) | ||
2783 | supply = regulator_desc->supply_name; | ||
2784 | |||
2785 | if (supply) { | ||
2721 | struct regulator_dev *r; | 2786 | struct regulator_dev *r; |
2722 | int found = 0; | ||
2723 | 2787 | ||
2724 | list_for_each_entry(r, ®ulator_list, list) { | 2788 | r = regulator_dev_lookup(dev, supply); |
2725 | if (strcmp(rdev_get_name(r), | ||
2726 | init_data->supply_regulator) == 0) { | ||
2727 | found = 1; | ||
2728 | break; | ||
2729 | } | ||
2730 | } | ||
2731 | 2789 | ||
2732 | if (!found) { | 2790 | if (!r) { |
2733 | dev_err(dev, "Failed to find supply %s\n", | 2791 | dev_err(dev, "Failed to find supply %s\n", supply); |
2734 | init_data->supply_regulator); | ||
2735 | ret = -ENODEV; | 2792 | ret = -ENODEV; |
2736 | goto scrub; | 2793 | goto scrub; |
2737 | } | 2794 | } |
diff --git a/drivers/regulator/da903x.c b/drivers/regulator/da903x.c index e23ddfa8b2c6..8dbc54da7d70 100644 --- a/drivers/regulator/da903x.c +++ b/drivers/regulator/da903x.c | |||
@@ -537,7 +537,7 @@ static int __devinit da903x_regulator_probe(struct platform_device *pdev) | |||
537 | ri->desc.ops = &da9030_regulator_ldo1_15_ops; | 537 | ri->desc.ops = &da9030_regulator_ldo1_15_ops; |
538 | 538 | ||
539 | rdev = regulator_register(&ri->desc, &pdev->dev, | 539 | rdev = regulator_register(&ri->desc, &pdev->dev, |
540 | pdev->dev.platform_data, ri); | 540 | pdev->dev.platform_data, ri, NULL); |
541 | if (IS_ERR(rdev)) { | 541 | if (IS_ERR(rdev)) { |
542 | dev_err(&pdev->dev, "failed to register regulator %s\n", | 542 | dev_err(&pdev->dev, "failed to register regulator %s\n", |
543 | ri->desc.name); | 543 | ri->desc.name); |
diff --git a/drivers/regulator/db8500-prcmu.c b/drivers/regulator/db8500-prcmu.c index 78329751af54..515443fcd26b 100644 --- a/drivers/regulator/db8500-prcmu.c +++ b/drivers/regulator/db8500-prcmu.c | |||
@@ -486,7 +486,7 @@ static int __devinit db8500_regulator_probe(struct platform_device *pdev) | |||
486 | 486 | ||
487 | /* register with the regulator framework */ | 487 | /* register with the regulator framework */ |
488 | info->rdev = regulator_register(&info->desc, &pdev->dev, | 488 | info->rdev = regulator_register(&info->desc, &pdev->dev, |
489 | init_data, info); | 489 | init_data, info, NULL); |
490 | if (IS_ERR(info->rdev)) { | 490 | if (IS_ERR(info->rdev)) { |
491 | err = PTR_ERR(info->rdev); | 491 | err = PTR_ERR(info->rdev); |
492 | dev_err(&pdev->dev, "failed to register %s: err %i\n", | 492 | dev_err(&pdev->dev, "failed to register %s: err %i\n", |
diff --git a/drivers/regulator/dummy.c b/drivers/regulator/dummy.c index b8f520513ce7..0ee00de4be72 100644 --- a/drivers/regulator/dummy.c +++ b/drivers/regulator/dummy.c | |||
@@ -42,7 +42,7 @@ static int __devinit dummy_regulator_probe(struct platform_device *pdev) | |||
42 | int ret; | 42 | int ret; |
43 | 43 | ||
44 | dummy_regulator_rdev = regulator_register(&dummy_desc, NULL, | 44 | dummy_regulator_rdev = regulator_register(&dummy_desc, NULL, |
45 | &dummy_initdata, NULL); | 45 | &dummy_initdata, NULL, NULL); |
46 | if (IS_ERR(dummy_regulator_rdev)) { | 46 | if (IS_ERR(dummy_regulator_rdev)) { |
47 | ret = PTR_ERR(dummy_regulator_rdev); | 47 | ret = PTR_ERR(dummy_regulator_rdev); |
48 | pr_err("Failed to register regulator: %d\n", ret); | 48 | pr_err("Failed to register regulator: %d\n", ret); |
diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c index 21ecf212a522..72abbf5507a6 100644 --- a/drivers/regulator/fixed.c +++ b/drivers/regulator/fixed.c | |||
@@ -27,6 +27,10 @@ | |||
27 | #include <linux/gpio.h> | 27 | #include <linux/gpio.h> |
28 | #include <linux/delay.h> | 28 | #include <linux/delay.h> |
29 | #include <linux/slab.h> | 29 | #include <linux/slab.h> |
30 | #include <linux/of.h> | ||
31 | #include <linux/of_gpio.h> | ||
32 | #include <linux/regulator/of_regulator.h> | ||
33 | #include <linux/regulator/machine.h> | ||
30 | 34 | ||
31 | struct fixed_voltage_data { | 35 | struct fixed_voltage_data { |
32 | struct regulator_desc desc; | 36 | struct regulator_desc desc; |
@@ -38,6 +42,57 @@ struct fixed_voltage_data { | |||
38 | bool is_enabled; | 42 | bool is_enabled; |
39 | }; | 43 | }; |
40 | 44 | ||
45 | |||
46 | /** | ||
47 | * of_get_fixed_voltage_config - extract fixed_voltage_config structure info | ||
48 | * @dev: device requesting for fixed_voltage_config | ||
49 | * | ||
50 | * Populates fixed_voltage_config structure by extracting data from device | ||
51 | * tree node, returns a pointer to the populated structure of NULL if memory | ||
52 | * alloc fails. | ||
53 | */ | ||
54 | static struct fixed_voltage_config * | ||
55 | of_get_fixed_voltage_config(struct device *dev) | ||
56 | { | ||
57 | struct fixed_voltage_config *config; | ||
58 | struct device_node *np = dev->of_node; | ||
59 | const __be32 *delay; | ||
60 | struct regulator_init_data *init_data; | ||
61 | |||
62 | config = devm_kzalloc(dev, sizeof(struct fixed_voltage_config), | ||
63 | GFP_KERNEL); | ||
64 | if (!config) | ||
65 | return NULL; | ||
66 | |||
67 | config->init_data = of_get_regulator_init_data(dev); | ||
68 | if (!config->init_data) | ||
69 | return NULL; | ||
70 | |||
71 | init_data = config->init_data; | ||
72 | |||
73 | config->supply_name = init_data->constraints.name; | ||
74 | if (init_data->constraints.min_uV == init_data->constraints.max_uV) { | ||
75 | config->microvolts = init_data->constraints.min_uV; | ||
76 | } else { | ||
77 | dev_err(dev, | ||
78 | "Fixed regulator specified with variable voltages\n"); | ||
79 | return NULL; | ||
80 | } | ||
81 | |||
82 | if (init_data->constraints.boot_on) | ||
83 | config->enabled_at_boot = true; | ||
84 | |||
85 | config->gpio = of_get_named_gpio(np, "gpio", 0); | ||
86 | delay = of_get_property(np, "startup-delay-us", NULL); | ||
87 | if (delay) | ||
88 | config->startup_delay = be32_to_cpu(*delay); | ||
89 | |||
90 | if (of_find_property(np, "enable-active-high", NULL)) | ||
91 | config->enable_high = true; | ||
92 | |||
93 | return config; | ||
94 | } | ||
95 | |||
41 | static int fixed_voltage_is_enabled(struct regulator_dev *dev) | 96 | static int fixed_voltage_is_enabled(struct regulator_dev *dev) |
42 | { | 97 | { |
43 | struct fixed_voltage_data *data = rdev_get_drvdata(dev); | 98 | struct fixed_voltage_data *data = rdev_get_drvdata(dev); |
@@ -80,7 +135,10 @@ static int fixed_voltage_get_voltage(struct regulator_dev *dev) | |||
80 | { | 135 | { |
81 | struct fixed_voltage_data *data = rdev_get_drvdata(dev); | 136 | struct fixed_voltage_data *data = rdev_get_drvdata(dev); |
82 | 137 | ||
83 | return data->microvolts; | 138 | if (data->microvolts) |
139 | return data->microvolts; | ||
140 | else | ||
141 | return -EINVAL; | ||
84 | } | 142 | } |
85 | 143 | ||
86 | static int fixed_voltage_list_voltage(struct regulator_dev *dev, | 144 | static int fixed_voltage_list_voltage(struct regulator_dev *dev, |
@@ -105,10 +163,18 @@ static struct regulator_ops fixed_voltage_ops = { | |||
105 | 163 | ||
106 | static int __devinit reg_fixed_voltage_probe(struct platform_device *pdev) | 164 | static int __devinit reg_fixed_voltage_probe(struct platform_device *pdev) |
107 | { | 165 | { |
108 | struct fixed_voltage_config *config = pdev->dev.platform_data; | 166 | struct fixed_voltage_config *config; |
109 | struct fixed_voltage_data *drvdata; | 167 | struct fixed_voltage_data *drvdata; |
110 | int ret; | 168 | int ret; |
111 | 169 | ||
170 | if (pdev->dev.of_node) | ||
171 | config = of_get_fixed_voltage_config(&pdev->dev); | ||
172 | else | ||
173 | config = pdev->dev.platform_data; | ||
174 | |||
175 | if (!config) | ||
176 | return -ENOMEM; | ||
177 | |||
112 | drvdata = kzalloc(sizeof(struct fixed_voltage_data), GFP_KERNEL); | 178 | drvdata = kzalloc(sizeof(struct fixed_voltage_data), GFP_KERNEL); |
113 | if (drvdata == NULL) { | 179 | if (drvdata == NULL) { |
114 | dev_err(&pdev->dev, "Failed to allocate device data\n"); | 180 | dev_err(&pdev->dev, "Failed to allocate device data\n"); |
@@ -180,7 +246,7 @@ static int __devinit reg_fixed_voltage_probe(struct platform_device *pdev) | |||
180 | } | 246 | } |
181 | 247 | ||
182 | drvdata->dev = regulator_register(&drvdata->desc, &pdev->dev, | 248 | drvdata->dev = regulator_register(&drvdata->desc, &pdev->dev, |
183 | config->init_data, drvdata); | 249 | config->init_data, drvdata, NULL); |
184 | if (IS_ERR(drvdata->dev)) { | 250 | if (IS_ERR(drvdata->dev)) { |
185 | ret = PTR_ERR(drvdata->dev); | 251 | ret = PTR_ERR(drvdata->dev); |
186 | dev_err(&pdev->dev, "Failed to register regulator: %d\n", ret); | 252 | dev_err(&pdev->dev, "Failed to register regulator: %d\n", ret); |
@@ -217,12 +283,23 @@ static int __devexit reg_fixed_voltage_remove(struct platform_device *pdev) | |||
217 | return 0; | 283 | return 0; |
218 | } | 284 | } |
219 | 285 | ||
286 | #if defined(CONFIG_OF) | ||
287 | static const struct of_device_id fixed_of_match[] __devinitconst = { | ||
288 | { .compatible = "regulator-fixed", }, | ||
289 | {}, | ||
290 | }; | ||
291 | MODULE_DEVICE_TABLE(of, fixed_of_match); | ||
292 | #else | ||
293 | #define fixed_of_match NULL | ||
294 | #endif | ||
295 | |||
220 | static struct platform_driver regulator_fixed_voltage_driver = { | 296 | static struct platform_driver regulator_fixed_voltage_driver = { |
221 | .probe = reg_fixed_voltage_probe, | 297 | .probe = reg_fixed_voltage_probe, |
222 | .remove = __devexit_p(reg_fixed_voltage_remove), | 298 | .remove = __devexit_p(reg_fixed_voltage_remove), |
223 | .driver = { | 299 | .driver = { |
224 | .name = "reg-fixed-voltage", | 300 | .name = "reg-fixed-voltage", |
225 | .owner = THIS_MODULE, | 301 | .owner = THIS_MODULE, |
302 | .of_match_table = fixed_of_match, | ||
226 | }, | 303 | }, |
227 | }; | 304 | }; |
228 | 305 | ||
diff --git a/drivers/regulator/gpio-regulator.c b/drivers/regulator/gpio-regulator.c index f0acf52498bd..42e1cb1835e5 100644 --- a/drivers/regulator/gpio-regulator.c +++ b/drivers/regulator/gpio-regulator.c | |||
@@ -284,7 +284,7 @@ static int __devinit gpio_regulator_probe(struct platform_device *pdev) | |||
284 | drvdata->state = state; | 284 | drvdata->state = state; |
285 | 285 | ||
286 | drvdata->dev = regulator_register(&drvdata->desc, &pdev->dev, | 286 | drvdata->dev = regulator_register(&drvdata->desc, &pdev->dev, |
287 | config->init_data, drvdata); | 287 | config->init_data, drvdata, NULL); |
288 | if (IS_ERR(drvdata->dev)) { | 288 | if (IS_ERR(drvdata->dev)) { |
289 | ret = PTR_ERR(drvdata->dev); | 289 | ret = PTR_ERR(drvdata->dev); |
290 | dev_err(&pdev->dev, "Failed to register regulator: %d\n", ret); | 290 | dev_err(&pdev->dev, "Failed to register regulator: %d\n", ret); |
diff --git a/drivers/regulator/isl6271a-regulator.c b/drivers/regulator/isl6271a-regulator.c index e4b3592e8176..c1a456c4257c 100644 --- a/drivers/regulator/isl6271a-regulator.c +++ b/drivers/regulator/isl6271a-regulator.c | |||
@@ -170,7 +170,7 @@ static int __devinit isl6271a_probe(struct i2c_client *i2c, | |||
170 | 170 | ||
171 | for (i = 0; i < 3; i++) { | 171 | for (i = 0; i < 3; i++) { |
172 | pmic->rdev[i] = regulator_register(&isl_rd[i], &i2c->dev, | 172 | pmic->rdev[i] = regulator_register(&isl_rd[i], &i2c->dev, |
173 | init_data, pmic); | 173 | init_data, pmic, NULL); |
174 | if (IS_ERR(pmic->rdev[i])) { | 174 | if (IS_ERR(pmic->rdev[i])) { |
175 | dev_err(&i2c->dev, "failed to register %s\n", id->name); | 175 | dev_err(&i2c->dev, "failed to register %s\n", id->name); |
176 | err = PTR_ERR(pmic->rdev[i]); | 176 | err = PTR_ERR(pmic->rdev[i]); |
diff --git a/drivers/regulator/lp3971.c b/drivers/regulator/lp3971.c index 72b16b5f3db6..0cfabd318a59 100644 --- a/drivers/regulator/lp3971.c +++ b/drivers/regulator/lp3971.c | |||
@@ -451,7 +451,7 @@ static int __devinit setup_regulators(struct lp3971 *lp3971, | |||
451 | for (i = 0; i < pdata->num_regulators; i++) { | 451 | for (i = 0; i < pdata->num_regulators; i++) { |
452 | struct lp3971_regulator_subdev *reg = &pdata->regulators[i]; | 452 | struct lp3971_regulator_subdev *reg = &pdata->regulators[i]; |
453 | lp3971->rdev[i] = regulator_register(®ulators[reg->id], | 453 | lp3971->rdev[i] = regulator_register(®ulators[reg->id], |
454 | lp3971->dev, reg->initdata, lp3971); | 454 | lp3971->dev, reg->initdata, lp3971, NULL); |
455 | 455 | ||
456 | if (IS_ERR(lp3971->rdev[i])) { | 456 | if (IS_ERR(lp3971->rdev[i])) { |
457 | err = PTR_ERR(lp3971->rdev[i]); | 457 | err = PTR_ERR(lp3971->rdev[i]); |
diff --git a/drivers/regulator/lp3972.c b/drivers/regulator/lp3972.c index fbc5e3741bef..49a15eefe5fe 100644 --- a/drivers/regulator/lp3972.c +++ b/drivers/regulator/lp3972.c | |||
@@ -555,7 +555,7 @@ static int __devinit setup_regulators(struct lp3972 *lp3972, | |||
555 | for (i = 0; i < pdata->num_regulators; i++) { | 555 | for (i = 0; i < pdata->num_regulators; i++) { |
556 | struct lp3972_regulator_subdev *reg = &pdata->regulators[i]; | 556 | struct lp3972_regulator_subdev *reg = &pdata->regulators[i]; |
557 | lp3972->rdev[i] = regulator_register(®ulators[reg->id], | 557 | lp3972->rdev[i] = regulator_register(®ulators[reg->id], |
558 | lp3972->dev, reg->initdata, lp3972); | 558 | lp3972->dev, reg->initdata, lp3972, NULL); |
559 | 559 | ||
560 | if (IS_ERR(lp3972->rdev[i])) { | 560 | if (IS_ERR(lp3972->rdev[i])) { |
561 | err = PTR_ERR(lp3972->rdev[i]); | 561 | err = PTR_ERR(lp3972->rdev[i]); |
diff --git a/drivers/regulator/max1586.c b/drivers/regulator/max1586.c index 3f49512c5134..40e7a4db2853 100644 --- a/drivers/regulator/max1586.c +++ b/drivers/regulator/max1586.c | |||
@@ -214,7 +214,7 @@ static int __devinit max1586_pmic_probe(struct i2c_client *client, | |||
214 | } | 214 | } |
215 | rdev[i] = regulator_register(&max1586_reg[id], &client->dev, | 215 | rdev[i] = regulator_register(&max1586_reg[id], &client->dev, |
216 | pdata->subdevs[i].platform_data, | 216 | pdata->subdevs[i].platform_data, |
217 | max1586); | 217 | max1586, NULL); |
218 | if (IS_ERR(rdev[i])) { | 218 | if (IS_ERR(rdev[i])) { |
219 | ret = PTR_ERR(rdev[i]); | 219 | ret = PTR_ERR(rdev[i]); |
220 | dev_err(&client->dev, "failed to register %s\n", | 220 | dev_err(&client->dev, "failed to register %s\n", |
diff --git a/drivers/regulator/max8649.c b/drivers/regulator/max8649.c index 1062cf9f02dc..b06a2399587c 100644 --- a/drivers/regulator/max8649.c +++ b/drivers/regulator/max8649.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/regulator/driver.h> | 16 | #include <linux/regulator/driver.h> |
17 | #include <linux/slab.h> | 17 | #include <linux/slab.h> |
18 | #include <linux/regulator/max8649.h> | 18 | #include <linux/regulator/max8649.h> |
19 | #include <linux/regmap.h> | ||
19 | 20 | ||
20 | #define MAX8649_DCDC_VMIN 750000 /* uV */ | 21 | #define MAX8649_DCDC_VMIN 750000 /* uV */ |
21 | #define MAX8649_DCDC_VMAX 1380000 /* uV */ | 22 | #define MAX8649_DCDC_VMAX 1380000 /* uV */ |
@@ -49,9 +50,8 @@ | |||
49 | 50 | ||
50 | struct max8649_regulator_info { | 51 | struct max8649_regulator_info { |
51 | struct regulator_dev *regulator; | 52 | struct regulator_dev *regulator; |
52 | struct i2c_client *i2c; | ||
53 | struct device *dev; | 53 | struct device *dev; |
54 | struct mutex io_lock; | 54 | struct regmap *regmap; |
55 | 55 | ||
56 | int vol_reg; | 56 | int vol_reg; |
57 | unsigned mode:2; /* bit[1:0] = VID1, VID0 */ | 57 | unsigned mode:2; /* bit[1:0] = VID1, VID0 */ |
@@ -63,71 +63,6 @@ struct max8649_regulator_info { | |||
63 | 63 | ||
64 | /* I2C operations */ | 64 | /* I2C operations */ |
65 | 65 | ||
66 | static inline int max8649_read_device(struct i2c_client *i2c, | ||
67 | int reg, int bytes, void *dest) | ||
68 | { | ||
69 | unsigned char data; | ||
70 | int ret; | ||
71 | |||
72 | data = (unsigned char)reg; | ||
73 | ret = i2c_master_send(i2c, &data, 1); | ||
74 | if (ret < 0) | ||
75 | return ret; | ||
76 | ret = i2c_master_recv(i2c, dest, bytes); | ||
77 | if (ret < 0) | ||
78 | return ret; | ||
79 | return 0; | ||
80 | } | ||
81 | |||
82 | static inline int max8649_write_device(struct i2c_client *i2c, | ||
83 | int reg, int bytes, void *src) | ||
84 | { | ||
85 | unsigned char buf[bytes + 1]; | ||
86 | int ret; | ||
87 | |||
88 | buf[0] = (unsigned char)reg; | ||
89 | memcpy(&buf[1], src, bytes); | ||
90 | |||
91 | ret = i2c_master_send(i2c, buf, bytes + 1); | ||
92 | if (ret < 0) | ||
93 | return ret; | ||
94 | return 0; | ||
95 | } | ||
96 | |||
97 | static int max8649_reg_read(struct i2c_client *i2c, int reg) | ||
98 | { | ||
99 | struct max8649_regulator_info *info = i2c_get_clientdata(i2c); | ||
100 | unsigned char data; | ||
101 | int ret; | ||
102 | |||
103 | mutex_lock(&info->io_lock); | ||
104 | ret = max8649_read_device(i2c, reg, 1, &data); | ||
105 | mutex_unlock(&info->io_lock); | ||
106 | |||
107 | if (ret < 0) | ||
108 | return ret; | ||
109 | return (int)data; | ||
110 | } | ||
111 | |||
112 | static int max8649_set_bits(struct i2c_client *i2c, int reg, | ||
113 | unsigned char mask, unsigned char data) | ||
114 | { | ||
115 | struct max8649_regulator_info *info = i2c_get_clientdata(i2c); | ||
116 | unsigned char value; | ||
117 | int ret; | ||
118 | |||
119 | mutex_lock(&info->io_lock); | ||
120 | ret = max8649_read_device(i2c, reg, 1, &value); | ||
121 | if (ret < 0) | ||
122 | goto out; | ||
123 | value &= ~mask; | ||
124 | value |= data; | ||
125 | ret = max8649_write_device(i2c, reg, 1, &value); | ||
126 | out: | ||
127 | mutex_unlock(&info->io_lock); | ||
128 | return ret; | ||
129 | } | ||
130 | |||
131 | static inline int check_range(int min_uV, int max_uV) | 66 | static inline int check_range(int min_uV, int max_uV) |
132 | { | 67 | { |
133 | if ((min_uV < MAX8649_DCDC_VMIN) || (max_uV > MAX8649_DCDC_VMAX) | 68 | if ((min_uV < MAX8649_DCDC_VMIN) || (max_uV > MAX8649_DCDC_VMAX) |
@@ -144,13 +79,14 @@ static int max8649_list_voltage(struct regulator_dev *rdev, unsigned index) | |||
144 | static int max8649_get_voltage(struct regulator_dev *rdev) | 79 | static int max8649_get_voltage(struct regulator_dev *rdev) |
145 | { | 80 | { |
146 | struct max8649_regulator_info *info = rdev_get_drvdata(rdev); | 81 | struct max8649_regulator_info *info = rdev_get_drvdata(rdev); |
82 | unsigned int val; | ||
147 | unsigned char data; | 83 | unsigned char data; |
148 | int ret; | 84 | int ret; |
149 | 85 | ||
150 | ret = max8649_reg_read(info->i2c, info->vol_reg); | 86 | ret = regmap_read(info->regmap, info->vol_reg, &val); |
151 | if (ret < 0) | 87 | if (ret != 0) |
152 | return ret; | 88 | return ret; |
153 | data = (unsigned char)ret & MAX8649_VOL_MASK; | 89 | data = (unsigned char)val & MAX8649_VOL_MASK; |
154 | return max8649_list_voltage(rdev, data); | 90 | return max8649_list_voltage(rdev, data); |
155 | } | 91 | } |
156 | 92 | ||
@@ -170,14 +106,14 @@ static int max8649_set_voltage(struct regulator_dev *rdev, | |||
170 | mask = MAX8649_VOL_MASK; | 106 | mask = MAX8649_VOL_MASK; |
171 | *selector = data & mask; | 107 | *selector = data & mask; |
172 | 108 | ||
173 | return max8649_set_bits(info->i2c, info->vol_reg, mask, data); | 109 | return regmap_update_bits(info->regmap, info->vol_reg, mask, data); |
174 | } | 110 | } |
175 | 111 | ||
176 | /* EN_PD means pulldown on EN input */ | 112 | /* EN_PD means pulldown on EN input */ |
177 | static int max8649_enable(struct regulator_dev *rdev) | 113 | static int max8649_enable(struct regulator_dev *rdev) |
178 | { | 114 | { |
179 | struct max8649_regulator_info *info = rdev_get_drvdata(rdev); | 115 | struct max8649_regulator_info *info = rdev_get_drvdata(rdev); |
180 | return max8649_set_bits(info->i2c, MAX8649_CONTROL, MAX8649_EN_PD, 0); | 116 | return regmap_update_bits(info->regmap, MAX8649_CONTROL, MAX8649_EN_PD, 0); |
181 | } | 117 | } |
182 | 118 | ||
183 | /* | 119 | /* |
@@ -187,38 +123,40 @@ static int max8649_enable(struct regulator_dev *rdev) | |||
187 | static int max8649_disable(struct regulator_dev *rdev) | 123 | static int max8649_disable(struct regulator_dev *rdev) |
188 | { | 124 | { |
189 | struct max8649_regulator_info *info = rdev_get_drvdata(rdev); | 125 | struct max8649_regulator_info *info = rdev_get_drvdata(rdev); |
190 | return max8649_set_bits(info->i2c, MAX8649_CONTROL, MAX8649_EN_PD, | 126 | return regmap_update_bits(info->regmap, MAX8649_CONTROL, MAX8649_EN_PD, |
191 | MAX8649_EN_PD); | 127 | MAX8649_EN_PD); |
192 | } | 128 | } |
193 | 129 | ||
194 | static int max8649_is_enabled(struct regulator_dev *rdev) | 130 | static int max8649_is_enabled(struct regulator_dev *rdev) |
195 | { | 131 | { |
196 | struct max8649_regulator_info *info = rdev_get_drvdata(rdev); | 132 | struct max8649_regulator_info *info = rdev_get_drvdata(rdev); |
133 | unsigned int val; | ||
197 | int ret; | 134 | int ret; |
198 | 135 | ||
199 | ret = max8649_reg_read(info->i2c, MAX8649_CONTROL); | 136 | ret = regmap_read(info->regmap, MAX8649_CONTROL, &val); |
200 | if (ret < 0) | 137 | if (ret != 0) |
201 | return ret; | 138 | return ret; |
202 | return !((unsigned char)ret & MAX8649_EN_PD); | 139 | return !((unsigned char)val & MAX8649_EN_PD); |
203 | } | 140 | } |
204 | 141 | ||
205 | static int max8649_enable_time(struct regulator_dev *rdev) | 142 | static int max8649_enable_time(struct regulator_dev *rdev) |
206 | { | 143 | { |
207 | struct max8649_regulator_info *info = rdev_get_drvdata(rdev); | 144 | struct max8649_regulator_info *info = rdev_get_drvdata(rdev); |
208 | int voltage, rate, ret; | 145 | int voltage, rate, ret; |
146 | unsigned int val; | ||
209 | 147 | ||
210 | /* get voltage */ | 148 | /* get voltage */ |
211 | ret = max8649_reg_read(info->i2c, info->vol_reg); | 149 | ret = regmap_read(info->regmap, info->vol_reg, &val); |
212 | if (ret < 0) | 150 | if (ret != 0) |
213 | return ret; | 151 | return ret; |
214 | ret &= MAX8649_VOL_MASK; | 152 | val &= MAX8649_VOL_MASK; |
215 | voltage = max8649_list_voltage(rdev, (unsigned char)ret); /* uV */ | 153 | voltage = max8649_list_voltage(rdev, (unsigned char)ret); /* uV */ |
216 | 154 | ||
217 | /* get rate */ | 155 | /* get rate */ |
218 | ret = max8649_reg_read(info->i2c, MAX8649_RAMP); | 156 | ret = regmap_read(info->regmap, MAX8649_RAMP, &val); |
219 | if (ret < 0) | 157 | if (ret != 0) |
220 | return ret; | 158 | return ret; |
221 | ret = (ret & MAX8649_RAMP_MASK) >> 5; | 159 | ret = (val & MAX8649_RAMP_MASK) >> 5; |
222 | rate = (32 * 1000) >> ret; /* uV/uS */ | 160 | rate = (32 * 1000) >> ret; /* uV/uS */ |
223 | 161 | ||
224 | return DIV_ROUND_UP(voltage, rate); | 162 | return DIV_ROUND_UP(voltage, rate); |
@@ -230,12 +168,12 @@ static int max8649_set_mode(struct regulator_dev *rdev, unsigned int mode) | |||
230 | 168 | ||
231 | switch (mode) { | 169 | switch (mode) { |
232 | case REGULATOR_MODE_FAST: | 170 | case REGULATOR_MODE_FAST: |
233 | max8649_set_bits(info->i2c, info->vol_reg, MAX8649_FORCE_PWM, | 171 | regmap_update_bits(info->regmap, info->vol_reg, MAX8649_FORCE_PWM, |
234 | MAX8649_FORCE_PWM); | 172 | MAX8649_FORCE_PWM); |
235 | break; | 173 | break; |
236 | case REGULATOR_MODE_NORMAL: | 174 | case REGULATOR_MODE_NORMAL: |
237 | max8649_set_bits(info->i2c, info->vol_reg, | 175 | regmap_update_bits(info->regmap, info->vol_reg, |
238 | MAX8649_FORCE_PWM, 0); | 176 | MAX8649_FORCE_PWM, 0); |
239 | break; | 177 | break; |
240 | default: | 178 | default: |
241 | return -EINVAL; | 179 | return -EINVAL; |
@@ -246,10 +184,13 @@ static int max8649_set_mode(struct regulator_dev *rdev, unsigned int mode) | |||
246 | static unsigned int max8649_get_mode(struct regulator_dev *rdev) | 184 | static unsigned int max8649_get_mode(struct regulator_dev *rdev) |
247 | { | 185 | { |
248 | struct max8649_regulator_info *info = rdev_get_drvdata(rdev); | 186 | struct max8649_regulator_info *info = rdev_get_drvdata(rdev); |
187 | unsigned int val; | ||
249 | int ret; | 188 | int ret; |
250 | 189 | ||
251 | ret = max8649_reg_read(info->i2c, info->vol_reg); | 190 | ret = regmap_read(info->regmap, info->vol_reg, &val); |
252 | if (ret & MAX8649_FORCE_PWM) | 191 | if (ret != 0) |
192 | return ret; | ||
193 | if (val & MAX8649_FORCE_PWM) | ||
253 | return REGULATOR_MODE_FAST; | 194 | return REGULATOR_MODE_FAST; |
254 | return REGULATOR_MODE_NORMAL; | 195 | return REGULATOR_MODE_NORMAL; |
255 | } | 196 | } |
@@ -275,11 +216,17 @@ static struct regulator_desc dcdc_desc = { | |||
275 | .owner = THIS_MODULE, | 216 | .owner = THIS_MODULE, |
276 | }; | 217 | }; |
277 | 218 | ||
219 | static struct regmap_config max8649_regmap_config = { | ||
220 | .reg_bits = 8, | ||
221 | .val_bits = 8, | ||
222 | }; | ||
223 | |||
278 | static int __devinit max8649_regulator_probe(struct i2c_client *client, | 224 | static int __devinit max8649_regulator_probe(struct i2c_client *client, |
279 | const struct i2c_device_id *id) | 225 | const struct i2c_device_id *id) |
280 | { | 226 | { |
281 | struct max8649_platform_data *pdata = client->dev.platform_data; | 227 | struct max8649_platform_data *pdata = client->dev.platform_data; |
282 | struct max8649_regulator_info *info = NULL; | 228 | struct max8649_regulator_info *info = NULL; |
229 | unsigned int val; | ||
283 | unsigned char data; | 230 | unsigned char data; |
284 | int ret; | 231 | int ret; |
285 | 232 | ||
@@ -289,9 +236,14 @@ static int __devinit max8649_regulator_probe(struct i2c_client *client, | |||
289 | return -ENOMEM; | 236 | return -ENOMEM; |
290 | } | 237 | } |
291 | 238 | ||
292 | info->i2c = client; | 239 | info->regmap = regmap_init_i2c(client, &max8649_regmap_config); |
240 | if (IS_ERR(info->regmap)) { | ||
241 | ret = PTR_ERR(info->regmap); | ||
242 | dev_err(&client->dev, "Failed to allocate register map: %d\n", ret); | ||
243 | goto fail; | ||
244 | } | ||
245 | |||
293 | info->dev = &client->dev; | 246 | info->dev = &client->dev; |
294 | mutex_init(&info->io_lock); | ||
295 | i2c_set_clientdata(client, info); | 247 | i2c_set_clientdata(client, info); |
296 | 248 | ||
297 | info->mode = pdata->mode; | 249 | info->mode = pdata->mode; |
@@ -312,8 +264,8 @@ static int __devinit max8649_regulator_probe(struct i2c_client *client, | |||
312 | break; | 264 | break; |
313 | } | 265 | } |
314 | 266 | ||
315 | ret = max8649_reg_read(info->i2c, MAX8649_CHIP_ID1); | 267 | ret = regmap_read(info->regmap, MAX8649_CHIP_ID1, &val); |
316 | if (ret < 0) { | 268 | if (ret != 0) { |
317 | dev_err(info->dev, "Failed to detect ID of MAX8649:%d\n", | 269 | dev_err(info->dev, "Failed to detect ID of MAX8649:%d\n", |
318 | ret); | 270 | ret); |
319 | goto out; | 271 | goto out; |
@@ -321,33 +273,33 @@ static int __devinit max8649_regulator_probe(struct i2c_client *client, | |||
321 | dev_info(info->dev, "Detected MAX8649 (ID:%x)\n", ret); | 273 | dev_info(info->dev, "Detected MAX8649 (ID:%x)\n", ret); |
322 | 274 | ||
323 | /* enable VID0 & VID1 */ | 275 | /* enable VID0 & VID1 */ |
324 | max8649_set_bits(info->i2c, MAX8649_CONTROL, MAX8649_VID_MASK, 0); | 276 | regmap_update_bits(info->regmap, MAX8649_CONTROL, MAX8649_VID_MASK, 0); |
325 | 277 | ||
326 | /* enable/disable external clock synchronization */ | 278 | /* enable/disable external clock synchronization */ |
327 | info->extclk = pdata->extclk; | 279 | info->extclk = pdata->extclk; |
328 | data = (info->extclk) ? MAX8649_SYNC_EXTCLK : 0; | 280 | data = (info->extclk) ? MAX8649_SYNC_EXTCLK : 0; |
329 | max8649_set_bits(info->i2c, info->vol_reg, MAX8649_SYNC_EXTCLK, data); | 281 | regmap_update_bits(info->regmap, info->vol_reg, MAX8649_SYNC_EXTCLK, data); |
330 | if (info->extclk) { | 282 | if (info->extclk) { |
331 | /* set external clock frequency */ | 283 | /* set external clock frequency */ |
332 | info->extclk_freq = pdata->extclk_freq; | 284 | info->extclk_freq = pdata->extclk_freq; |
333 | max8649_set_bits(info->i2c, MAX8649_SYNC, MAX8649_EXT_MASK, | 285 | regmap_update_bits(info->regmap, MAX8649_SYNC, MAX8649_EXT_MASK, |
334 | info->extclk_freq << 6); | 286 | info->extclk_freq << 6); |
335 | } | 287 | } |
336 | 288 | ||
337 | if (pdata->ramp_timing) { | 289 | if (pdata->ramp_timing) { |
338 | info->ramp_timing = pdata->ramp_timing; | 290 | info->ramp_timing = pdata->ramp_timing; |
339 | max8649_set_bits(info->i2c, MAX8649_RAMP, MAX8649_RAMP_MASK, | 291 | regmap_update_bits(info->regmap, MAX8649_RAMP, MAX8649_RAMP_MASK, |
340 | info->ramp_timing << 5); | 292 | info->ramp_timing << 5); |
341 | } | 293 | } |
342 | 294 | ||
343 | info->ramp_down = pdata->ramp_down; | 295 | info->ramp_down = pdata->ramp_down; |
344 | if (info->ramp_down) { | 296 | if (info->ramp_down) { |
345 | max8649_set_bits(info->i2c, MAX8649_RAMP, MAX8649_RAMP_DOWN, | 297 | regmap_update_bits(info->regmap, MAX8649_RAMP, MAX8649_RAMP_DOWN, |
346 | MAX8649_RAMP_DOWN); | 298 | MAX8649_RAMP_DOWN); |
347 | } | 299 | } |
348 | 300 | ||
349 | info->regulator = regulator_register(&dcdc_desc, &client->dev, | 301 | info->regulator = regulator_register(&dcdc_desc, &client->dev, |
350 | pdata->regulator, info); | 302 | pdata->regulator, info, NULL); |
351 | if (IS_ERR(info->regulator)) { | 303 | if (IS_ERR(info->regulator)) { |
352 | dev_err(info->dev, "failed to register regulator %s\n", | 304 | dev_err(info->dev, "failed to register regulator %s\n", |
353 | dcdc_desc.name); | 305 | dcdc_desc.name); |
@@ -358,6 +310,8 @@ static int __devinit max8649_regulator_probe(struct i2c_client *client, | |||
358 | dev_info(info->dev, "Max8649 regulator device is detected.\n"); | 310 | dev_info(info->dev, "Max8649 regulator device is detected.\n"); |
359 | return 0; | 311 | return 0; |
360 | out: | 312 | out: |
313 | regmap_exit(info->regmap); | ||
314 | fail: | ||
361 | kfree(info); | 315 | kfree(info); |
362 | return ret; | 316 | return ret; |
363 | } | 317 | } |
@@ -369,6 +323,7 @@ static int __devexit max8649_regulator_remove(struct i2c_client *client) | |||
369 | if (info) { | 323 | if (info) { |
370 | if (info->regulator) | 324 | if (info->regulator) |
371 | regulator_unregister(info->regulator); | 325 | regulator_unregister(info->regulator); |
326 | regmap_exit(info->regmap); | ||
372 | kfree(info); | 327 | kfree(info); |
373 | } | 328 | } |
374 | 329 | ||
diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c index 33f5d9a492ef..a838e664569f 100644 --- a/drivers/regulator/max8660.c +++ b/drivers/regulator/max8660.c | |||
@@ -449,7 +449,7 @@ static int __devinit max8660_probe(struct i2c_client *client, | |||
449 | 449 | ||
450 | rdev[i] = regulator_register(&max8660_reg[id], &client->dev, | 450 | rdev[i] = regulator_register(&max8660_reg[id], &client->dev, |
451 | pdata->subdevs[i].platform_data, | 451 | pdata->subdevs[i].platform_data, |
452 | max8660); | 452 | max8660, NULL); |
453 | if (IS_ERR(rdev[i])) { | 453 | if (IS_ERR(rdev[i])) { |
454 | ret = PTR_ERR(rdev[i]); | 454 | ret = PTR_ERR(rdev[i]); |
455 | dev_err(&client->dev, "failed to register %s\n", | 455 | dev_err(&client->dev, "failed to register %s\n", |
diff --git a/drivers/regulator/max8925-regulator.c b/drivers/regulator/max8925-regulator.c index cc9ec0e03271..f976e5d0867e 100644 --- a/drivers/regulator/max8925-regulator.c +++ b/drivers/regulator/max8925-regulator.c | |||
@@ -266,7 +266,7 @@ static int __devinit max8925_regulator_probe(struct platform_device *pdev) | |||
266 | ri->chip = chip; | 266 | ri->chip = chip; |
267 | 267 | ||
268 | rdev = regulator_register(&ri->desc, &pdev->dev, | 268 | rdev = regulator_register(&ri->desc, &pdev->dev, |
269 | pdata->regulator[pdev->id], ri); | 269 | pdata->regulator[pdev->id], ri, NULL); |
270 | if (IS_ERR(rdev)) { | 270 | if (IS_ERR(rdev)) { |
271 | dev_err(&pdev->dev, "failed to register regulator %s\n", | 271 | dev_err(&pdev->dev, "failed to register regulator %s\n", |
272 | ri->desc.name); | 272 | ri->desc.name); |
diff --git a/drivers/regulator/max8952.c b/drivers/regulator/max8952.c index 3883d85c5b88..75d89400c123 100644 --- a/drivers/regulator/max8952.c +++ b/drivers/regulator/max8952.c | |||
@@ -208,7 +208,7 @@ static int __devinit max8952_pmic_probe(struct i2c_client *client, | |||
208 | max8952->pdata = pdata; | 208 | max8952->pdata = pdata; |
209 | 209 | ||
210 | max8952->rdev = regulator_register(®ulator, max8952->dev, | 210 | max8952->rdev = regulator_register(®ulator, max8952->dev, |
211 | &pdata->reg_data, max8952); | 211 | &pdata->reg_data, max8952, NULL); |
212 | 212 | ||
213 | if (IS_ERR(max8952->rdev)) { | 213 | if (IS_ERR(max8952->rdev)) { |
214 | ret = PTR_ERR(max8952->rdev); | 214 | ret = PTR_ERR(max8952->rdev); |
diff --git a/drivers/regulator/max8997.c b/drivers/regulator/max8997.c index 6176129a27e5..d26e8646277b 100644 --- a/drivers/regulator/max8997.c +++ b/drivers/regulator/max8997.c | |||
@@ -1146,7 +1146,7 @@ static __devinit int max8997_pmic_probe(struct platform_device *pdev) | |||
1146 | regulators[id].n_voltages = 16; | 1146 | regulators[id].n_voltages = 16; |
1147 | 1147 | ||
1148 | rdev[i] = regulator_register(®ulators[id], max8997->dev, | 1148 | rdev[i] = regulator_register(®ulators[id], max8997->dev, |
1149 | pdata->regulators[i].initdata, max8997); | 1149 | pdata->regulators[i].initdata, max8997, NULL); |
1150 | if (IS_ERR(rdev[i])) { | 1150 | if (IS_ERR(rdev[i])) { |
1151 | ret = PTR_ERR(rdev[i]); | 1151 | ret = PTR_ERR(rdev[i]); |
1152 | dev_err(max8997->dev, "regulator init failed for %d\n", | 1152 | dev_err(max8997->dev, "regulator init failed for %d\n", |
diff --git a/drivers/regulator/max8998.c b/drivers/regulator/max8998.c index 41a1495eec2b..2d38c2493a07 100644 --- a/drivers/regulator/max8998.c +++ b/drivers/regulator/max8998.c | |||
@@ -847,7 +847,7 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev) | |||
847 | regulators[index].n_voltages = count; | 847 | regulators[index].n_voltages = count; |
848 | } | 848 | } |
849 | rdev[i] = regulator_register(®ulators[index], max8998->dev, | 849 | rdev[i] = regulator_register(®ulators[index], max8998->dev, |
850 | pdata->regulators[i].initdata, max8998); | 850 | pdata->regulators[i].initdata, max8998, NULL); |
851 | if (IS_ERR(rdev[i])) { | 851 | if (IS_ERR(rdev[i])) { |
852 | ret = PTR_ERR(rdev[i]); | 852 | ret = PTR_ERR(rdev[i]); |
853 | dev_err(max8998->dev, "regulator init failed\n"); | 853 | dev_err(max8998->dev, "regulator init failed\n"); |
diff --git a/drivers/regulator/mc13783-regulator.c b/drivers/regulator/mc13783-regulator.c index 8479082e1aea..56d4a677c404 100644 --- a/drivers/regulator/mc13783-regulator.c +++ b/drivers/regulator/mc13783-regulator.c | |||
@@ -357,7 +357,7 @@ static int __devinit mc13783_regulator_probe(struct platform_device *pdev) | |||
357 | init_data = &pdata->regulators[i]; | 357 | init_data = &pdata->regulators[i]; |
358 | priv->regulators[i] = regulator_register( | 358 | priv->regulators[i] = regulator_register( |
359 | &mc13783_regulators[init_data->id].desc, | 359 | &mc13783_regulators[init_data->id].desc, |
360 | &pdev->dev, init_data->init_data, priv); | 360 | &pdev->dev, init_data->init_data, priv, NULL); |
361 | 361 | ||
362 | if (IS_ERR(priv->regulators[i])) { | 362 | if (IS_ERR(priv->regulators[i])) { |
363 | dev_err(&pdev->dev, "failed to register regulator %s\n", | 363 | dev_err(&pdev->dev, "failed to register regulator %s\n", |
diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c index 023d17d022cf..2824804a2892 100644 --- a/drivers/regulator/mc13892-regulator.c +++ b/drivers/regulator/mc13892-regulator.c | |||
@@ -573,7 +573,7 @@ static int __devinit mc13892_regulator_probe(struct platform_device *pdev) | |||
573 | init_data = &pdata->regulators[i]; | 573 | init_data = &pdata->regulators[i]; |
574 | priv->regulators[i] = regulator_register( | 574 | priv->regulators[i] = regulator_register( |
575 | &mc13892_regulators[init_data->id].desc, | 575 | &mc13892_regulators[init_data->id].desc, |
576 | &pdev->dev, init_data->init_data, priv); | 576 | &pdev->dev, init_data->init_data, priv, NULL); |
577 | 577 | ||
578 | if (IS_ERR(priv->regulators[i])) { | 578 | if (IS_ERR(priv->regulators[i])) { |
579 | dev_err(&pdev->dev, "failed to register regulator %s\n", | 579 | dev_err(&pdev->dev, "failed to register regulator %s\n", |
diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c new file mode 100644 index 000000000000..acd7045d1601 --- /dev/null +++ b/drivers/regulator/of_regulator.c | |||
@@ -0,0 +1,83 @@ | |||
1 | /* | ||
2 | * OF helpers for regulator framework | ||
3 | * | ||
4 | * Copyright (C) 2011 Texas Instruments, Inc. | ||
5 | * Rajendra Nayak <rnayak@ti.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | */ | ||
12 | |||
13 | #include <linux/module.h> | ||
14 | #include <linux/slab.h> | ||
15 | #include <linux/of.h> | ||
16 | #include <linux/regulator/machine.h> | ||
17 | |||
18 | static void of_get_regulation_constraints(struct device_node *np, | ||
19 | struct regulator_init_data **init_data) | ||
20 | { | ||
21 | const __be32 *min_uV, *max_uV, *uV_offset; | ||
22 | const __be32 *min_uA, *max_uA; | ||
23 | struct regulation_constraints *constraints = &(*init_data)->constraints; | ||
24 | |||
25 | constraints->name = of_get_property(np, "regulator-name", NULL); | ||
26 | |||
27 | min_uV = of_get_property(np, "regulator-min-microvolt", NULL); | ||
28 | if (min_uV) | ||
29 | constraints->min_uV = be32_to_cpu(*min_uV); | ||
30 | max_uV = of_get_property(np, "regulator-max-microvolt", NULL); | ||
31 | if (max_uV) | ||
32 | constraints->max_uV = be32_to_cpu(*max_uV); | ||
33 | |||
34 | /* Voltage change possible? */ | ||
35 | if (constraints->min_uV != constraints->max_uV) | ||
36 | constraints->valid_ops_mask |= REGULATOR_CHANGE_VOLTAGE; | ||
37 | |||
38 | uV_offset = of_get_property(np, "regulator-microvolt-offset", NULL); | ||
39 | if (uV_offset) | ||
40 | constraints->uV_offset = be32_to_cpu(*uV_offset); | ||
41 | min_uA = of_get_property(np, "regulator-min-microamp", NULL); | ||
42 | if (min_uA) | ||
43 | constraints->min_uA = be32_to_cpu(*min_uA); | ||
44 | max_uA = of_get_property(np, "regulator-max-microamp", NULL); | ||
45 | if (max_uA) | ||
46 | constraints->max_uA = be32_to_cpu(*max_uA); | ||
47 | |||
48 | /* Current change possible? */ | ||
49 | if (constraints->min_uA != constraints->max_uA) | ||
50 | constraints->valid_ops_mask |= REGULATOR_CHANGE_CURRENT; | ||
51 | |||
52 | if (of_find_property(np, "regulator-boot-on", NULL)) | ||
53 | constraints->boot_on = true; | ||
54 | |||
55 | if (of_find_property(np, "regulator-always-on", NULL)) | ||
56 | constraints->always_on = true; | ||
57 | else /* status change should be possible if not always on. */ | ||
58 | constraints->valid_ops_mask |= REGULATOR_CHANGE_STATUS; | ||
59 | } | ||
60 | |||
61 | /** | ||
62 | * of_get_regulator_init_data - extract regulator_init_data structure info | ||
63 | * @dev: device requesting for regulator_init_data | ||
64 | * | ||
65 | * Populates regulator_init_data structure by extracting data from device | ||
66 | * tree node, returns a pointer to the populated struture or NULL if memory | ||
67 | * alloc fails. | ||
68 | */ | ||
69 | struct regulator_init_data *of_get_regulator_init_data(struct device *dev) | ||
70 | { | ||
71 | struct regulator_init_data *init_data; | ||
72 | |||
73 | if (!dev->of_node) | ||
74 | return NULL; | ||
75 | |||
76 | init_data = devm_kzalloc(dev, sizeof(*init_data), GFP_KERNEL); | ||
77 | if (!init_data) | ||
78 | return NULL; /* Out of memory? */ | ||
79 | |||
80 | of_get_regulation_constraints(dev->of_node, &init_data); | ||
81 | return init_data; | ||
82 | } | ||
83 | EXPORT_SYMBOL_GPL(of_get_regulator_init_data); | ||
diff --git a/drivers/regulator/pcap-regulator.c b/drivers/regulator/pcap-regulator.c index 31f6e11a7f16..a5aab1b08bcf 100644 --- a/drivers/regulator/pcap-regulator.c +++ b/drivers/regulator/pcap-regulator.c | |||
@@ -277,7 +277,7 @@ static int __devinit pcap_regulator_probe(struct platform_device *pdev) | |||
277 | void *pcap = dev_get_drvdata(pdev->dev.parent); | 277 | void *pcap = dev_get_drvdata(pdev->dev.parent); |
278 | 278 | ||
279 | rdev = regulator_register(&pcap_regulators[pdev->id], &pdev->dev, | 279 | rdev = regulator_register(&pcap_regulators[pdev->id], &pdev->dev, |
280 | pdev->dev.platform_data, pcap); | 280 | pdev->dev.platform_data, pcap, NULL); |
281 | if (IS_ERR(rdev)) | 281 | if (IS_ERR(rdev)) |
282 | return PTR_ERR(rdev); | 282 | return PTR_ERR(rdev); |
283 | 283 | ||
diff --git a/drivers/regulator/pcf50633-regulator.c b/drivers/regulator/pcf50633-regulator.c index 69a11d9dd87f..1d1c31056297 100644 --- a/drivers/regulator/pcf50633-regulator.c +++ b/drivers/regulator/pcf50633-regulator.c | |||
@@ -320,7 +320,7 @@ static int __devinit pcf50633_regulator_probe(struct platform_device *pdev) | |||
320 | pcf = dev_to_pcf50633(pdev->dev.parent); | 320 | pcf = dev_to_pcf50633(pdev->dev.parent); |
321 | 321 | ||
322 | rdev = regulator_register(®ulators[pdev->id], &pdev->dev, | 322 | rdev = regulator_register(®ulators[pdev->id], &pdev->dev, |
323 | pdev->dev.platform_data, pcf); | 323 | pdev->dev.platform_data, pcf, NULL); |
324 | if (IS_ERR(rdev)) | 324 | if (IS_ERR(rdev)) |
325 | return PTR_ERR(rdev); | 325 | return PTR_ERR(rdev); |
326 | 326 | ||
diff --git a/drivers/regulator/tps6105x-regulator.c b/drivers/regulator/tps6105x-regulator.c index 1011873896dc..d9278da18a9e 100644 --- a/drivers/regulator/tps6105x-regulator.c +++ b/drivers/regulator/tps6105x-regulator.c | |||
@@ -151,7 +151,8 @@ static int __devinit tps6105x_regulator_probe(struct platform_device *pdev) | |||
151 | /* Register regulator with framework */ | 151 | /* Register regulator with framework */ |
152 | tps6105x->regulator = regulator_register(&tps6105x_regulator_desc, | 152 | tps6105x->regulator = regulator_register(&tps6105x_regulator_desc, |
153 | &tps6105x->client->dev, | 153 | &tps6105x->client->dev, |
154 | pdata->regulator_data, tps6105x); | 154 | pdata->regulator_data, tps6105x, |
155 | NULL); | ||
155 | if (IS_ERR(tps6105x->regulator)) { | 156 | if (IS_ERR(tps6105x->regulator)) { |
156 | ret = PTR_ERR(tps6105x->regulator); | 157 | ret = PTR_ERR(tps6105x->regulator); |
157 | dev_err(&tps6105x->client->dev, | 158 | dev_err(&tps6105x->client->dev, |
diff --git a/drivers/regulator/tps65023-regulator.c b/drivers/regulator/tps65023-regulator.c index 9fb4c7b81753..18d61a0529a9 100644 --- a/drivers/regulator/tps65023-regulator.c +++ b/drivers/regulator/tps65023-regulator.c | |||
@@ -152,48 +152,21 @@ struct tps_driver_data { | |||
152 | u8 core_regulator; | 152 | u8 core_regulator; |
153 | }; | 153 | }; |
154 | 154 | ||
155 | static int tps_65023_set_bits(struct tps_pmic *tps, u8 reg, u8 mask) | ||
156 | { | ||
157 | return regmap_update_bits(tps->regmap, reg, mask, mask); | ||
158 | } | ||
159 | |||
160 | static int tps_65023_clear_bits(struct tps_pmic *tps, u8 reg, u8 mask) | ||
161 | { | ||
162 | return regmap_update_bits(tps->regmap, reg, mask, 0); | ||
163 | } | ||
164 | |||
165 | static int tps_65023_reg_read(struct tps_pmic *tps, u8 reg) | ||
166 | { | ||
167 | unsigned int val; | ||
168 | int ret; | ||
169 | |||
170 | ret = regmap_read(tps->regmap, reg, &val); | ||
171 | |||
172 | if (ret != 0) | ||
173 | return ret; | ||
174 | else | ||
175 | return val; | ||
176 | } | ||
177 | |||
178 | static int tps_65023_reg_write(struct tps_pmic *tps, u8 reg, u8 val) | ||
179 | { | ||
180 | return regmap_write(tps->regmap, reg, val); | ||
181 | } | ||
182 | |||
183 | static int tps65023_dcdc_is_enabled(struct regulator_dev *dev) | 155 | static int tps65023_dcdc_is_enabled(struct regulator_dev *dev) |
184 | { | 156 | { |
185 | struct tps_pmic *tps = rdev_get_drvdata(dev); | 157 | struct tps_pmic *tps = rdev_get_drvdata(dev); |
186 | int data, dcdc = rdev_get_id(dev); | 158 | int data, dcdc = rdev_get_id(dev); |
159 | int ret; | ||
187 | u8 shift; | 160 | u8 shift; |
188 | 161 | ||
189 | if (dcdc < TPS65023_DCDC_1 || dcdc > TPS65023_DCDC_3) | 162 | if (dcdc < TPS65023_DCDC_1 || dcdc > TPS65023_DCDC_3) |
190 | return -EINVAL; | 163 | return -EINVAL; |
191 | 164 | ||
192 | shift = TPS65023_NUM_REGULATOR - dcdc; | 165 | shift = TPS65023_NUM_REGULATOR - dcdc; |
193 | data = tps_65023_reg_read(tps, TPS65023_REG_REG_CTRL); | 166 | ret = regmap_read(tps->regmap, TPS65023_REG_REG_CTRL, &data); |
194 | 167 | ||
195 | if (data < 0) | 168 | if (ret != 0) |
196 | return data; | 169 | return ret; |
197 | else | 170 | else |
198 | return (data & 1<<shift) ? 1 : 0; | 171 | return (data & 1<<shift) ? 1 : 0; |
199 | } | 172 | } |
@@ -202,16 +175,17 @@ static int tps65023_ldo_is_enabled(struct regulator_dev *dev) | |||
202 | { | 175 | { |
203 | struct tps_pmic *tps = rdev_get_drvdata(dev); | 176 | struct tps_pmic *tps = rdev_get_drvdata(dev); |
204 | int data, ldo = rdev_get_id(dev); | 177 | int data, ldo = rdev_get_id(dev); |
178 | int ret; | ||
205 | u8 shift; | 179 | u8 shift; |
206 | 180 | ||
207 | if (ldo < TPS65023_LDO_1 || ldo > TPS65023_LDO_2) | 181 | if (ldo < TPS65023_LDO_1 || ldo > TPS65023_LDO_2) |
208 | return -EINVAL; | 182 | return -EINVAL; |
209 | 183 | ||
210 | shift = (ldo == TPS65023_LDO_1 ? 1 : 2); | 184 | shift = (ldo == TPS65023_LDO_1 ? 1 : 2); |
211 | data = tps_65023_reg_read(tps, TPS65023_REG_REG_CTRL); | 185 | ret = regmap_read(tps->regmap, TPS65023_REG_REG_CTRL, &data); |
212 | 186 | ||
213 | if (data < 0) | 187 | if (ret != 0) |
214 | return data; | 188 | return ret; |
215 | else | 189 | else |
216 | return (data & 1<<shift) ? 1 : 0; | 190 | return (data & 1<<shift) ? 1 : 0; |
217 | } | 191 | } |
@@ -226,7 +200,7 @@ static int tps65023_dcdc_enable(struct regulator_dev *dev) | |||
226 | return -EINVAL; | 200 | return -EINVAL; |
227 | 201 | ||
228 | shift = TPS65023_NUM_REGULATOR - dcdc; | 202 | shift = TPS65023_NUM_REGULATOR - dcdc; |
229 | return tps_65023_set_bits(tps, TPS65023_REG_REG_CTRL, 1 << shift); | 203 | return regmap_update_bits(tps->regmap, TPS65023_REG_REG_CTRL, 1 << shift, 1 << shift); |
230 | } | 204 | } |
231 | 205 | ||
232 | static int tps65023_dcdc_disable(struct regulator_dev *dev) | 206 | static int tps65023_dcdc_disable(struct regulator_dev *dev) |
@@ -239,7 +213,7 @@ static int tps65023_dcdc_disable(struct regulator_dev *dev) | |||
239 | return -EINVAL; | 213 | return -EINVAL; |
240 | 214 | ||
241 | shift = TPS65023_NUM_REGULATOR - dcdc; | 215 | shift = TPS65023_NUM_REGULATOR - dcdc; |
242 | return tps_65023_clear_bits(tps, TPS65023_REG_REG_CTRL, 1 << shift); | 216 | return regmap_update_bits(tps->regmap, TPS65023_REG_REG_CTRL, 1 << shift, 0); |
243 | } | 217 | } |
244 | 218 | ||
245 | static int tps65023_ldo_enable(struct regulator_dev *dev) | 219 | static int tps65023_ldo_enable(struct regulator_dev *dev) |
@@ -252,7 +226,7 @@ static int tps65023_ldo_enable(struct regulator_dev *dev) | |||
252 | return -EINVAL; | 226 | return -EINVAL; |
253 | 227 | ||
254 | shift = (ldo == TPS65023_LDO_1 ? 1 : 2); | 228 | shift = (ldo == TPS65023_LDO_1 ? 1 : 2); |
255 | return tps_65023_set_bits(tps, TPS65023_REG_REG_CTRL, 1 << shift); | 229 | return regmap_update_bits(tps->regmap, TPS65023_REG_REG_CTRL, 1 << shift, 1 << shift); |
256 | } | 230 | } |
257 | 231 | ||
258 | static int tps65023_ldo_disable(struct regulator_dev *dev) | 232 | static int tps65023_ldo_disable(struct regulator_dev *dev) |
@@ -265,21 +239,22 @@ static int tps65023_ldo_disable(struct regulator_dev *dev) | |||
265 | return -EINVAL; | 239 | return -EINVAL; |
266 | 240 | ||
267 | shift = (ldo == TPS65023_LDO_1 ? 1 : 2); | 241 | shift = (ldo == TPS65023_LDO_1 ? 1 : 2); |
268 | return tps_65023_clear_bits(tps, TPS65023_REG_REG_CTRL, 1 << shift); | 242 | return regmap_update_bits(tps->regmap, TPS65023_REG_REG_CTRL, 1 << shift, 0); |
269 | } | 243 | } |
270 | 244 | ||
271 | static int tps65023_dcdc_get_voltage(struct regulator_dev *dev) | 245 | static int tps65023_dcdc_get_voltage(struct regulator_dev *dev) |
272 | { | 246 | { |
273 | struct tps_pmic *tps = rdev_get_drvdata(dev); | 247 | struct tps_pmic *tps = rdev_get_drvdata(dev); |
248 | int ret; | ||
274 | int data, dcdc = rdev_get_id(dev); | 249 | int data, dcdc = rdev_get_id(dev); |
275 | 250 | ||
276 | if (dcdc < TPS65023_DCDC_1 || dcdc > TPS65023_DCDC_3) | 251 | if (dcdc < TPS65023_DCDC_1 || dcdc > TPS65023_DCDC_3) |
277 | return -EINVAL; | 252 | return -EINVAL; |
278 | 253 | ||
279 | if (dcdc == tps->core_regulator) { | 254 | if (dcdc == tps->core_regulator) { |
280 | data = tps_65023_reg_read(tps, TPS65023_REG_DEF_CORE); | 255 | ret = regmap_read(tps->regmap, TPS65023_REG_DEF_CORE, &data); |
281 | if (data < 0) | 256 | if (ret != 0) |
282 | return data; | 257 | return ret; |
283 | data &= (tps->info[dcdc]->table_len - 1); | 258 | data &= (tps->info[dcdc]->table_len - 1); |
284 | return tps->info[dcdc]->table[data] * 1000; | 259 | return tps->info[dcdc]->table[data] * 1000; |
285 | } else | 260 | } else |
@@ -318,13 +293,13 @@ static int tps65023_dcdc_set_voltage(struct regulator_dev *dev, | |||
318 | if (vsel == tps->info[dcdc]->table_len) | 293 | if (vsel == tps->info[dcdc]->table_len) |
319 | goto failed; | 294 | goto failed; |
320 | 295 | ||
321 | ret = tps_65023_reg_write(tps, TPS65023_REG_DEF_CORE, vsel); | 296 | ret = regmap_write(tps->regmap, TPS65023_REG_DEF_CORE, vsel); |
322 | 297 | ||
323 | /* Tell the chip that we have changed the value in DEFCORE | 298 | /* Tell the chip that we have changed the value in DEFCORE |
324 | * and its time to update the core voltage | 299 | * and its time to update the core voltage |
325 | */ | 300 | */ |
326 | tps_65023_set_bits(tps, TPS65023_REG_CON_CTRL2, | 301 | regmap_update_bits(tps->regmap, TPS65023_REG_CON_CTRL2, |
327 | TPS65023_REG_CTRL2_GO); | 302 | TPS65023_REG_CTRL2_GO, TPS65023_REG_CTRL2_GO); |
328 | 303 | ||
329 | return ret; | 304 | return ret; |
330 | 305 | ||
@@ -336,13 +311,14 @@ static int tps65023_ldo_get_voltage(struct regulator_dev *dev) | |||
336 | { | 311 | { |
337 | struct tps_pmic *tps = rdev_get_drvdata(dev); | 312 | struct tps_pmic *tps = rdev_get_drvdata(dev); |
338 | int data, ldo = rdev_get_id(dev); | 313 | int data, ldo = rdev_get_id(dev); |
314 | int ret; | ||
339 | 315 | ||
340 | if (ldo < TPS65023_LDO_1 || ldo > TPS65023_LDO_2) | 316 | if (ldo < TPS65023_LDO_1 || ldo > TPS65023_LDO_2) |
341 | return -EINVAL; | 317 | return -EINVAL; |
342 | 318 | ||
343 | data = tps_65023_reg_read(tps, TPS65023_REG_LDO_CTRL); | 319 | ret = regmap_read(tps->regmap, TPS65023_REG_LDO_CTRL, &data); |
344 | if (data < 0) | 320 | if (ret != 0) |
345 | return data; | 321 | return ret; |
346 | 322 | ||
347 | data >>= (TPS65023_LDO_CTRL_LDOx_SHIFT(ldo - TPS65023_LDO_1)); | 323 | data >>= (TPS65023_LDO_CTRL_LDOx_SHIFT(ldo - TPS65023_LDO_1)); |
348 | data &= (tps->info[ldo]->table_len - 1); | 324 | data &= (tps->info[ldo]->table_len - 1); |
@@ -354,6 +330,7 @@ static int tps65023_ldo_set_voltage(struct regulator_dev *dev, | |||
354 | { | 330 | { |
355 | struct tps_pmic *tps = rdev_get_drvdata(dev); | 331 | struct tps_pmic *tps = rdev_get_drvdata(dev); |
356 | int data, vsel, ldo = rdev_get_id(dev); | 332 | int data, vsel, ldo = rdev_get_id(dev); |
333 | int ret; | ||
357 | 334 | ||
358 | if (ldo < TPS65023_LDO_1 || ldo > TPS65023_LDO_2) | 335 | if (ldo < TPS65023_LDO_1 || ldo > TPS65023_LDO_2) |
359 | return -EINVAL; | 336 | return -EINVAL; |
@@ -377,13 +354,13 @@ static int tps65023_ldo_set_voltage(struct regulator_dev *dev, | |||
377 | 354 | ||
378 | *selector = vsel; | 355 | *selector = vsel; |
379 | 356 | ||
380 | data = tps_65023_reg_read(tps, TPS65023_REG_LDO_CTRL); | 357 | ret = regmap_read(tps->regmap, TPS65023_REG_LDO_CTRL, &data); |
381 | if (data < 0) | 358 | if (ret != 0) |
382 | return data; | 359 | return ret; |
383 | 360 | ||
384 | data &= TPS65023_LDO_CTRL_LDOx_MASK(ldo - TPS65023_LDO_1); | 361 | data &= TPS65023_LDO_CTRL_LDOx_MASK(ldo - TPS65023_LDO_1); |
385 | data |= (vsel << (TPS65023_LDO_CTRL_LDOx_SHIFT(ldo - TPS65023_LDO_1))); | 362 | data |= (vsel << (TPS65023_LDO_CTRL_LDOx_SHIFT(ldo - TPS65023_LDO_1))); |
386 | return tps_65023_reg_write(tps, TPS65023_REG_LDO_CTRL, data); | 363 | return regmap_write(tps->regmap, TPS65023_REG_LDO_CTRL, data); |
387 | } | 364 | } |
388 | 365 | ||
389 | static int tps65023_dcdc_list_voltage(struct regulator_dev *dev, | 366 | static int tps65023_dcdc_list_voltage(struct regulator_dev *dev, |
@@ -496,7 +473,7 @@ static int __devinit tps_65023_probe(struct i2c_client *client, | |||
496 | 473 | ||
497 | /* Register the regulators */ | 474 | /* Register the regulators */ |
498 | rdev = regulator_register(&tps->desc[i], &client->dev, | 475 | rdev = regulator_register(&tps->desc[i], &client->dev, |
499 | init_data, tps); | 476 | init_data, tps, NULL); |
500 | if (IS_ERR(rdev)) { | 477 | if (IS_ERR(rdev)) { |
501 | dev_err(&client->dev, "failed to register %s\n", | 478 | dev_err(&client->dev, "failed to register %s\n", |
502 | id->name); | 479 | id->name); |
@@ -511,12 +488,12 @@ static int __devinit tps_65023_probe(struct i2c_client *client, | |||
511 | i2c_set_clientdata(client, tps); | 488 | i2c_set_clientdata(client, tps); |
512 | 489 | ||
513 | /* Enable setting output voltage by I2C */ | 490 | /* Enable setting output voltage by I2C */ |
514 | tps_65023_clear_bits(tps, TPS65023_REG_CON_CTRL2, | 491 | regmap_update_bits(tps->regmap, TPS65023_REG_CON_CTRL2, |
515 | TPS65023_REG_CTRL2_CORE_ADJ); | 492 | TPS65023_REG_CTRL2_CORE_ADJ, TPS65023_REG_CTRL2_CORE_ADJ); |
516 | 493 | ||
517 | /* Enable setting output voltage by I2C */ | 494 | /* Enable setting output voltage by I2C */ |
518 | tps_65023_clear_bits(tps, TPS65023_REG_CON_CTRL2, | 495 | regmap_update_bits(tps->regmap, TPS65023_REG_CON_CTRL2, |
519 | TPS65023_REG_CTRL2_CORE_ADJ); | 496 | TPS65023_REG_CTRL2_CORE_ADJ, TPS65023_REG_CTRL2_CORE_ADJ); |
520 | 497 | ||
521 | return 0; | 498 | return 0; |
522 | 499 | ||
diff --git a/drivers/regulator/tps6507x-regulator.c b/drivers/regulator/tps6507x-regulator.c index bdef70365f52..0b63ef71a5fe 100644 --- a/drivers/regulator/tps6507x-regulator.c +++ b/drivers/regulator/tps6507x-regulator.c | |||
@@ -599,7 +599,7 @@ int tps6507x_pmic_probe(struct platform_device *pdev) | |||
599 | tps->desc[i].owner = THIS_MODULE; | 599 | tps->desc[i].owner = THIS_MODULE; |
600 | 600 | ||
601 | rdev = regulator_register(&tps->desc[i], | 601 | rdev = regulator_register(&tps->desc[i], |
602 | tps6507x_dev->dev, init_data, tps); | 602 | tps6507x_dev->dev, init_data, tps, NULL); |
603 | if (IS_ERR(rdev)) { | 603 | if (IS_ERR(rdev)) { |
604 | dev_err(tps6507x_dev->dev, | 604 | dev_err(tps6507x_dev->dev, |
605 | "failed to register %s regulator\n", | 605 | "failed to register %s regulator\n", |
diff --git a/drivers/regulator/tps6524x-regulator.c b/drivers/regulator/tps6524x-regulator.c index 9166aa0a9df7..70b7b1f4f000 100644 --- a/drivers/regulator/tps6524x-regulator.c +++ b/drivers/regulator/tps6524x-regulator.c | |||
@@ -651,7 +651,7 @@ static int __devinit pmic_probe(struct spi_device *spi) | |||
651 | hw->desc[i].n_voltages = 1; | 651 | hw->desc[i].n_voltages = 1; |
652 | 652 | ||
653 | hw->rdev[i] = regulator_register(&hw->desc[i], dev, | 653 | hw->rdev[i] = regulator_register(&hw->desc[i], dev, |
654 | init_data, hw); | 654 | init_data, hw, NULL); |
655 | if (IS_ERR(hw->rdev[i])) { | 655 | if (IS_ERR(hw->rdev[i])) { |
656 | ret = PTR_ERR(hw->rdev[i]); | 656 | ret = PTR_ERR(hw->rdev[i]); |
657 | hw->rdev[i] = NULL; | 657 | hw->rdev[i] = NULL; |
diff --git a/drivers/regulator/tps6586x-regulator.c b/drivers/regulator/tps6586x-regulator.c index 14b9389dd52a..c75fb20faa57 100644 --- a/drivers/regulator/tps6586x-regulator.c +++ b/drivers/regulator/tps6586x-regulator.c | |||
@@ -396,7 +396,7 @@ static int __devinit tps6586x_regulator_probe(struct platform_device *pdev) | |||
396 | return err; | 396 | return err; |
397 | 397 | ||
398 | rdev = regulator_register(&ri->desc, &pdev->dev, | 398 | rdev = regulator_register(&ri->desc, &pdev->dev, |
399 | pdev->dev.platform_data, ri); | 399 | pdev->dev.platform_data, ri, NULL); |
400 | if (IS_ERR(rdev)) { | 400 | if (IS_ERR(rdev)) { |
401 | dev_err(&pdev->dev, "failed to register regulator %s\n", | 401 | dev_err(&pdev->dev, "failed to register regulator %s\n", |
402 | ri->desc.name); | 402 | ri->desc.name); |
diff --git a/drivers/regulator/tps65910-regulator.c b/drivers/regulator/tps65910-regulator.c index b552aae55b41..5c15ba01e9c7 100644 --- a/drivers/regulator/tps65910-regulator.c +++ b/drivers/regulator/tps65910-regulator.c | |||
@@ -25,30 +25,6 @@ | |||
25 | #include <linux/gpio.h> | 25 | #include <linux/gpio.h> |
26 | #include <linux/mfd/tps65910.h> | 26 | #include <linux/mfd/tps65910.h> |
27 | 27 | ||
28 | #define TPS65910_REG_VRTC 0 | ||
29 | #define TPS65910_REG_VIO 1 | ||
30 | #define TPS65910_REG_VDD1 2 | ||
31 | #define TPS65910_REG_VDD2 3 | ||
32 | #define TPS65910_REG_VDD3 4 | ||
33 | #define TPS65910_REG_VDIG1 5 | ||
34 | #define TPS65910_REG_VDIG2 6 | ||
35 | #define TPS65910_REG_VPLL 7 | ||
36 | #define TPS65910_REG_VDAC 8 | ||
37 | #define TPS65910_REG_VAUX1 9 | ||
38 | #define TPS65910_REG_VAUX2 10 | ||
39 | #define TPS65910_REG_VAUX33 11 | ||
40 | #define TPS65910_REG_VMMC 12 | ||
41 | |||
42 | #define TPS65911_REG_VDDCTRL 4 | ||
43 | #define TPS65911_REG_LDO1 5 | ||
44 | #define TPS65911_REG_LDO2 6 | ||
45 | #define TPS65911_REG_LDO3 7 | ||
46 | #define TPS65911_REG_LDO4 8 | ||
47 | #define TPS65911_REG_LDO5 9 | ||
48 | #define TPS65911_REG_LDO6 10 | ||
49 | #define TPS65911_REG_LDO7 11 | ||
50 | #define TPS65911_REG_LDO8 12 | ||
51 | |||
52 | #define TPS65910_SUPPLY_STATE_ENABLED 0x1 | 28 | #define TPS65910_SUPPLY_STATE_ENABLED 0x1 |
53 | 29 | ||
54 | /* supported VIO voltages in milivolts */ | 30 | /* supported VIO voltages in milivolts */ |
@@ -885,8 +861,6 @@ static __devinit int tps65910_probe(struct platform_device *pdev) | |||
885 | if (!pmic_plat_data) | 861 | if (!pmic_plat_data) |
886 | return -EINVAL; | 862 | return -EINVAL; |
887 | 863 | ||
888 | reg_data = pmic_plat_data->tps65910_pmic_init_data; | ||
889 | |||
890 | pmic = kzalloc(sizeof(*pmic), GFP_KERNEL); | 864 | pmic = kzalloc(sizeof(*pmic), GFP_KERNEL); |
891 | if (!pmic) | 865 | if (!pmic) |
892 | return -ENOMEM; | 866 | return -ENOMEM; |
@@ -937,7 +911,16 @@ static __devinit int tps65910_probe(struct platform_device *pdev) | |||
937 | goto err_free_info; | 911 | goto err_free_info; |
938 | } | 912 | } |
939 | 913 | ||
940 | for (i = 0; i < pmic->num_regulators; i++, info++, reg_data++) { | 914 | for (i = 0; i < pmic->num_regulators && i < TPS65910_NUM_REGS; |
915 | i++, info++) { | ||
916 | |||
917 | reg_data = pmic_plat_data->tps65910_pmic_init_data[i]; | ||
918 | |||
919 | /* Regulator API handles empty constraints but not NULL | ||
920 | * constraints */ | ||
921 | if (!reg_data) | ||
922 | continue; | ||
923 | |||
941 | /* Register the regulators */ | 924 | /* Register the regulators */ |
942 | pmic->info[i] = info; | 925 | pmic->info[i] = info; |
943 | 926 | ||
@@ -965,7 +948,7 @@ static __devinit int tps65910_probe(struct platform_device *pdev) | |||
965 | pmic->desc[i].owner = THIS_MODULE; | 948 | pmic->desc[i].owner = THIS_MODULE; |
966 | 949 | ||
967 | rdev = regulator_register(&pmic->desc[i], | 950 | rdev = regulator_register(&pmic->desc[i], |
968 | tps65910->dev, reg_data, pmic); | 951 | tps65910->dev, reg_data, pmic, NULL); |
969 | if (IS_ERR(rdev)) { | 952 | if (IS_ERR(rdev)) { |
970 | dev_err(tps65910->dev, | 953 | dev_err(tps65910->dev, |
971 | "failed to register %s regulator\n", | 954 | "failed to register %s regulator\n", |
diff --git a/drivers/regulator/tps65912-regulator.c b/drivers/regulator/tps65912-regulator.c index 39d4a1749e71..da00d88f94b7 100644 --- a/drivers/regulator/tps65912-regulator.c +++ b/drivers/regulator/tps65912-regulator.c | |||
@@ -727,7 +727,7 @@ static __devinit int tps65912_probe(struct platform_device *pdev) | |||
727 | pmic->desc[i].owner = THIS_MODULE; | 727 | pmic->desc[i].owner = THIS_MODULE; |
728 | range = tps65912_get_range(pmic, i); | 728 | range = tps65912_get_range(pmic, i); |
729 | rdev = regulator_register(&pmic->desc[i], | 729 | rdev = regulator_register(&pmic->desc[i], |
730 | tps65912->dev, reg_data, pmic); | 730 | tps65912->dev, reg_data, pmic, NULL); |
731 | if (IS_ERR(rdev)) { | 731 | if (IS_ERR(rdev)) { |
732 | dev_err(tps65912->dev, | 732 | dev_err(tps65912->dev, |
733 | "failed to register %s regulator\n", | 733 | "failed to register %s regulator\n", |
diff --git a/drivers/regulator/twl-regulator.c b/drivers/regulator/twl-regulator.c index ee8747f4fa08..9a2e07a094b3 100644 --- a/drivers/regulator/twl-regulator.c +++ b/drivers/regulator/twl-regulator.c | |||
@@ -1070,7 +1070,7 @@ static int __devinit twlreg_probe(struct platform_device *pdev) | |||
1070 | break; | 1070 | break; |
1071 | } | 1071 | } |
1072 | 1072 | ||
1073 | rdev = regulator_register(&info->desc, &pdev->dev, initdata, info); | 1073 | rdev = regulator_register(&info->desc, &pdev->dev, initdata, info, NULL); |
1074 | if (IS_ERR(rdev)) { | 1074 | if (IS_ERR(rdev)) { |
1075 | dev_err(&pdev->dev, "can't register %s, %ld\n", | 1075 | dev_err(&pdev->dev, "can't register %s, %ld\n", |
1076 | info->desc.name, PTR_ERR(rdev)); | 1076 | info->desc.name, PTR_ERR(rdev)); |
diff --git a/drivers/regulator/userspace-consumer.c b/drivers/regulator/userspace-consumer.c index fc6655146999..518667ef9a0d 100644 --- a/drivers/regulator/userspace-consumer.c +++ b/drivers/regulator/userspace-consumer.c | |||
@@ -185,18 +185,7 @@ static struct platform_driver regulator_userspace_consumer_driver = { | |||
185 | }, | 185 | }, |
186 | }; | 186 | }; |
187 | 187 | ||
188 | 188 | module_platform_driver(regulator_userspace_consumer_driver); | |
189 | static int __init regulator_userspace_consumer_init(void) | ||
190 | { | ||
191 | return platform_driver_register(®ulator_userspace_consumer_driver); | ||
192 | } | ||
193 | module_init(regulator_userspace_consumer_init); | ||
194 | |||
195 | static void __exit regulator_userspace_consumer_exit(void) | ||
196 | { | ||
197 | platform_driver_unregister(®ulator_userspace_consumer_driver); | ||
198 | } | ||
199 | module_exit(regulator_userspace_consumer_exit); | ||
200 | 189 | ||
201 | MODULE_AUTHOR("Mike Rapoport <mike@compulab.co.il>"); | 190 | MODULE_AUTHOR("Mike Rapoport <mike@compulab.co.il>"); |
202 | MODULE_DESCRIPTION("Userspace consumer for voltage and current regulators"); | 191 | MODULE_DESCRIPTION("Userspace consumer for voltage and current regulators"); |
diff --git a/drivers/regulator/virtual.c b/drivers/regulator/virtual.c index 858c1f861ba5..ee0b161c998f 100644 --- a/drivers/regulator/virtual.c +++ b/drivers/regulator/virtual.c | |||
@@ -352,17 +352,7 @@ static struct platform_driver regulator_virtual_consumer_driver = { | |||
352 | }, | 352 | }, |
353 | }; | 353 | }; |
354 | 354 | ||
355 | static int __init regulator_virtual_consumer_init(void) | 355 | module_platform_driver(regulator_virtual_consumer_driver); |
356 | { | ||
357 | return platform_driver_register(®ulator_virtual_consumer_driver); | ||
358 | } | ||
359 | module_init(regulator_virtual_consumer_init); | ||
360 | |||
361 | static void __exit regulator_virtual_consumer_exit(void) | ||
362 | { | ||
363 | platform_driver_unregister(®ulator_virtual_consumer_driver); | ||
364 | } | ||
365 | module_exit(regulator_virtual_consumer_exit); | ||
366 | 356 | ||
367 | MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>"); | 357 | MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>"); |
368 | MODULE_DESCRIPTION("Virtual regulator consumer"); | 358 | MODULE_DESCRIPTION("Virtual regulator consumer"); |
diff --git a/drivers/regulator/wm831x-dcdc.c b/drivers/regulator/wm831x-dcdc.c index bd3531d8b2ac..7558a9666a50 100644 --- a/drivers/regulator/wm831x-dcdc.c +++ b/drivers/regulator/wm831x-dcdc.c | |||
@@ -553,7 +553,7 @@ static __devinit int wm831x_buckv_probe(struct platform_device *pdev) | |||
553 | wm831x_buckv_dvs_init(dcdc, pdata->dcdc[id]->driver_data); | 553 | wm831x_buckv_dvs_init(dcdc, pdata->dcdc[id]->driver_data); |
554 | 554 | ||
555 | dcdc->regulator = regulator_register(&dcdc->desc, &pdev->dev, | 555 | dcdc->regulator = regulator_register(&dcdc->desc, &pdev->dev, |
556 | pdata->dcdc[id], dcdc); | 556 | pdata->dcdc[id], dcdc, NULL); |
557 | if (IS_ERR(dcdc->regulator)) { | 557 | if (IS_ERR(dcdc->regulator)) { |
558 | ret = PTR_ERR(dcdc->regulator); | 558 | ret = PTR_ERR(dcdc->regulator); |
559 | dev_err(wm831x->dev, "Failed to register DCDC%d: %d\n", | 559 | dev_err(wm831x->dev, "Failed to register DCDC%d: %d\n", |
@@ -747,7 +747,7 @@ static __devinit int wm831x_buckp_probe(struct platform_device *pdev) | |||
747 | dcdc->desc.owner = THIS_MODULE; | 747 | dcdc->desc.owner = THIS_MODULE; |
748 | 748 | ||
749 | dcdc->regulator = regulator_register(&dcdc->desc, &pdev->dev, | 749 | dcdc->regulator = regulator_register(&dcdc->desc, &pdev->dev, |
750 | pdata->dcdc[id], dcdc); | 750 | pdata->dcdc[id], dcdc, NULL); |
751 | if (IS_ERR(dcdc->regulator)) { | 751 | if (IS_ERR(dcdc->regulator)) { |
752 | ret = PTR_ERR(dcdc->regulator); | 752 | ret = PTR_ERR(dcdc->regulator); |
753 | dev_err(wm831x->dev, "Failed to register DCDC%d: %d\n", | 753 | dev_err(wm831x->dev, "Failed to register DCDC%d: %d\n", |
@@ -874,7 +874,7 @@ static __devinit int wm831x_boostp_probe(struct platform_device *pdev) | |||
874 | dcdc->desc.owner = THIS_MODULE; | 874 | dcdc->desc.owner = THIS_MODULE; |
875 | 875 | ||
876 | dcdc->regulator = regulator_register(&dcdc->desc, &pdev->dev, | 876 | dcdc->regulator = regulator_register(&dcdc->desc, &pdev->dev, |
877 | pdata->dcdc[id], dcdc); | 877 | pdata->dcdc[id], dcdc, NULL); |
878 | if (IS_ERR(dcdc->regulator)) { | 878 | if (IS_ERR(dcdc->regulator)) { |
879 | ret = PTR_ERR(dcdc->regulator); | 879 | ret = PTR_ERR(dcdc->regulator); |
880 | dev_err(wm831x->dev, "Failed to register DCDC%d: %d\n", | 880 | dev_err(wm831x->dev, "Failed to register DCDC%d: %d\n", |
@@ -973,7 +973,7 @@ static __devinit int wm831x_epe_probe(struct platform_device *pdev) | |||
973 | dcdc->desc.owner = THIS_MODULE; | 973 | dcdc->desc.owner = THIS_MODULE; |
974 | 974 | ||
975 | dcdc->regulator = regulator_register(&dcdc->desc, &pdev->dev, | 975 | dcdc->regulator = regulator_register(&dcdc->desc, &pdev->dev, |
976 | pdata->epe[id], dcdc); | 976 | pdata->epe[id], dcdc, NULL); |
977 | if (IS_ERR(dcdc->regulator)) { | 977 | if (IS_ERR(dcdc->regulator)) { |
978 | ret = PTR_ERR(dcdc->regulator); | 978 | ret = PTR_ERR(dcdc->regulator); |
979 | dev_err(wm831x->dev, "Failed to register EPE%d: %d\n", | 979 | dev_err(wm831x->dev, "Failed to register EPE%d: %d\n", |
diff --git a/drivers/regulator/wm831x-isink.c b/drivers/regulator/wm831x-isink.c index 01f27c7f4236..d3ad3f5cff46 100644 --- a/drivers/regulator/wm831x-isink.c +++ b/drivers/regulator/wm831x-isink.c | |||
@@ -189,7 +189,7 @@ static __devinit int wm831x_isink_probe(struct platform_device *pdev) | |||
189 | isink->desc.owner = THIS_MODULE; | 189 | isink->desc.owner = THIS_MODULE; |
190 | 190 | ||
191 | isink->regulator = regulator_register(&isink->desc, &pdev->dev, | 191 | isink->regulator = regulator_register(&isink->desc, &pdev->dev, |
192 | pdata->isink[id], isink); | 192 | pdata->isink[id], isink, NULL); |
193 | if (IS_ERR(isink->regulator)) { | 193 | if (IS_ERR(isink->regulator)) { |
194 | ret = PTR_ERR(isink->regulator); | 194 | ret = PTR_ERR(isink->regulator); |
195 | dev_err(wm831x->dev, "Failed to register ISINK%d: %d\n", | 195 | dev_err(wm831x->dev, "Failed to register ISINK%d: %d\n", |
diff --git a/drivers/regulator/wm831x-ldo.c b/drivers/regulator/wm831x-ldo.c index 6709710a059e..5e96a2386b1d 100644 --- a/drivers/regulator/wm831x-ldo.c +++ b/drivers/regulator/wm831x-ldo.c | |||
@@ -351,7 +351,7 @@ static __devinit int wm831x_gp_ldo_probe(struct platform_device *pdev) | |||
351 | ldo->desc.owner = THIS_MODULE; | 351 | ldo->desc.owner = THIS_MODULE; |
352 | 352 | ||
353 | ldo->regulator = regulator_register(&ldo->desc, &pdev->dev, | 353 | ldo->regulator = regulator_register(&ldo->desc, &pdev->dev, |
354 | pdata->ldo[id], ldo); | 354 | pdata->ldo[id], ldo, NULL); |
355 | if (IS_ERR(ldo->regulator)) { | 355 | if (IS_ERR(ldo->regulator)) { |
356 | ret = PTR_ERR(ldo->regulator); | 356 | ret = PTR_ERR(ldo->regulator); |
357 | dev_err(wm831x->dev, "Failed to register LDO%d: %d\n", | 357 | dev_err(wm831x->dev, "Failed to register LDO%d: %d\n", |
@@ -621,7 +621,7 @@ static __devinit int wm831x_aldo_probe(struct platform_device *pdev) | |||
621 | ldo->desc.owner = THIS_MODULE; | 621 | ldo->desc.owner = THIS_MODULE; |
622 | 622 | ||
623 | ldo->regulator = regulator_register(&ldo->desc, &pdev->dev, | 623 | ldo->regulator = regulator_register(&ldo->desc, &pdev->dev, |
624 | pdata->ldo[id], ldo); | 624 | pdata->ldo[id], ldo, NULL); |
625 | if (IS_ERR(ldo->regulator)) { | 625 | if (IS_ERR(ldo->regulator)) { |
626 | ret = PTR_ERR(ldo->regulator); | 626 | ret = PTR_ERR(ldo->regulator); |
627 | dev_err(wm831x->dev, "Failed to register LDO%d: %d\n", | 627 | dev_err(wm831x->dev, "Failed to register LDO%d: %d\n", |
@@ -818,7 +818,7 @@ static __devinit int wm831x_alive_ldo_probe(struct platform_device *pdev) | |||
818 | ldo->desc.owner = THIS_MODULE; | 818 | ldo->desc.owner = THIS_MODULE; |
819 | 819 | ||
820 | ldo->regulator = regulator_register(&ldo->desc, &pdev->dev, | 820 | ldo->regulator = regulator_register(&ldo->desc, &pdev->dev, |
821 | pdata->ldo[id], ldo); | 821 | pdata->ldo[id], ldo, NULL); |
822 | if (IS_ERR(ldo->regulator)) { | 822 | if (IS_ERR(ldo->regulator)) { |
823 | ret = PTR_ERR(ldo->regulator); | 823 | ret = PTR_ERR(ldo->regulator); |
824 | dev_err(wm831x->dev, "Failed to register LDO%d: %d\n", | 824 | dev_err(wm831x->dev, "Failed to register LDO%d: %d\n", |
diff --git a/drivers/regulator/wm8350-regulator.c b/drivers/regulator/wm8350-regulator.c index 1bcb22c44095..6894009d815a 100644 --- a/drivers/regulator/wm8350-regulator.c +++ b/drivers/regulator/wm8350-regulator.c | |||
@@ -1428,7 +1428,7 @@ static int wm8350_regulator_probe(struct platform_device *pdev) | |||
1428 | /* register regulator */ | 1428 | /* register regulator */ |
1429 | rdev = regulator_register(&wm8350_reg[pdev->id], &pdev->dev, | 1429 | rdev = regulator_register(&wm8350_reg[pdev->id], &pdev->dev, |
1430 | pdev->dev.platform_data, | 1430 | pdev->dev.platform_data, |
1431 | dev_get_drvdata(&pdev->dev)); | 1431 | dev_get_drvdata(&pdev->dev), NULL); |
1432 | if (IS_ERR(rdev)) { | 1432 | if (IS_ERR(rdev)) { |
1433 | dev_err(&pdev->dev, "failed to register %s\n", | 1433 | dev_err(&pdev->dev, "failed to register %s\n", |
1434 | wm8350_reg[pdev->id].name); | 1434 | wm8350_reg[pdev->id].name); |
diff --git a/drivers/regulator/wm8400-regulator.c b/drivers/regulator/wm8400-regulator.c index 71632ddc3781..706f39563a7b 100644 --- a/drivers/regulator/wm8400-regulator.c +++ b/drivers/regulator/wm8400-regulator.c | |||
@@ -326,7 +326,7 @@ static int __devinit wm8400_regulator_probe(struct platform_device *pdev) | |||
326 | struct regulator_dev *rdev; | 326 | struct regulator_dev *rdev; |
327 | 327 | ||
328 | rdev = regulator_register(®ulators[pdev->id], &pdev->dev, | 328 | rdev = regulator_register(®ulators[pdev->id], &pdev->dev, |
329 | pdev->dev.platform_data, wm8400); | 329 | pdev->dev.platform_data, wm8400, NULL); |
330 | 330 | ||
331 | if (IS_ERR(rdev)) | 331 | if (IS_ERR(rdev)) |
332 | return PTR_ERR(rdev); | 332 | return PTR_ERR(rdev); |
diff --git a/drivers/regulator/wm8994-regulator.c b/drivers/regulator/wm8994-regulator.c index b87bf5c841f8..435e335d6e67 100644 --- a/drivers/regulator/wm8994-regulator.c +++ b/drivers/regulator/wm8994-regulator.c | |||
@@ -269,7 +269,7 @@ static __devinit int wm8994_ldo_probe(struct platform_device *pdev) | |||
269 | ldo->is_enabled = true; | 269 | ldo->is_enabled = true; |
270 | 270 | ||
271 | ldo->regulator = regulator_register(&wm8994_ldo_desc[id], &pdev->dev, | 271 | ldo->regulator = regulator_register(&wm8994_ldo_desc[id], &pdev->dev, |
272 | pdata->ldo[id].init_data, ldo); | 272 | pdata->ldo[id].init_data, ldo, NULL); |
273 | if (IS_ERR(ldo->regulator)) { | 273 | if (IS_ERR(ldo->regulator)) { |
274 | ret = PTR_ERR(ldo->regulator); | 274 | ret = PTR_ERR(ldo->regulator); |
275 | dev_err(wm8994->dev, "Failed to register LDO%d: %d\n", | 275 | dev_err(wm8994->dev, "Failed to register LDO%d: %d\n", |
diff --git a/include/linux/mfd/tps65910.h b/include/linux/mfd/tps65910.h index 8bf2cb9502dd..d0cb12eba402 100644 --- a/include/linux/mfd/tps65910.h +++ b/include/linux/mfd/tps65910.h | |||
@@ -740,6 +740,34 @@ | |||
740 | #define TPS65910_GPIO_STS BIT(1) | 740 | #define TPS65910_GPIO_STS BIT(1) |
741 | #define TPS65910_GPIO_SET BIT(0) | 741 | #define TPS65910_GPIO_SET BIT(0) |
742 | 742 | ||
743 | /* Regulator Index Definitions */ | ||
744 | #define TPS65910_REG_VRTC 0 | ||
745 | #define TPS65910_REG_VIO 1 | ||
746 | #define TPS65910_REG_VDD1 2 | ||
747 | #define TPS65910_REG_VDD2 3 | ||
748 | #define TPS65910_REG_VDD3 4 | ||
749 | #define TPS65910_REG_VDIG1 5 | ||
750 | #define TPS65910_REG_VDIG2 6 | ||
751 | #define TPS65910_REG_VPLL 7 | ||
752 | #define TPS65910_REG_VDAC 8 | ||
753 | #define TPS65910_REG_VAUX1 9 | ||
754 | #define TPS65910_REG_VAUX2 10 | ||
755 | #define TPS65910_REG_VAUX33 11 | ||
756 | #define TPS65910_REG_VMMC 12 | ||
757 | |||
758 | #define TPS65911_REG_VDDCTRL 4 | ||
759 | #define TPS65911_REG_LDO1 5 | ||
760 | #define TPS65911_REG_LDO2 6 | ||
761 | #define TPS65911_REG_LDO3 7 | ||
762 | #define TPS65911_REG_LDO4 8 | ||
763 | #define TPS65911_REG_LDO5 9 | ||
764 | #define TPS65911_REG_LDO6 10 | ||
765 | #define TPS65911_REG_LDO7 11 | ||
766 | #define TPS65911_REG_LDO8 12 | ||
767 | |||
768 | /* Max number of TPS65910/11 regulators */ | ||
769 | #define TPS65910_NUM_REGS 13 | ||
770 | |||
743 | /** | 771 | /** |
744 | * struct tps65910_board | 772 | * struct tps65910_board |
745 | * Board platform data may be used to initialize regulators. | 773 | * Board platform data may be used to initialize regulators. |
@@ -751,7 +779,7 @@ struct tps65910_board { | |||
751 | int irq_base; | 779 | int irq_base; |
752 | int vmbch_threshold; | 780 | int vmbch_threshold; |
753 | int vmbch2_threshold; | 781 | int vmbch2_threshold; |
754 | struct regulator_init_data *tps65910_pmic_init_data; | 782 | struct regulator_init_data *tps65910_pmic_init_data[TPS65910_NUM_REGS]; |
755 | }; | 783 | }; |
756 | 784 | ||
757 | /** | 785 | /** |
diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h index 52c89ae32f64..4214b9a9d1c9 100644 --- a/include/linux/regulator/driver.h +++ b/include/linux/regulator/driver.h | |||
@@ -154,6 +154,7 @@ enum regulator_type { | |||
154 | * this type. | 154 | * this type. |
155 | * | 155 | * |
156 | * @name: Identifying name for the regulator. | 156 | * @name: Identifying name for the regulator. |
157 | * @supply_name: Identifying the regulator supply | ||
157 | * @id: Numerical identifier for the regulator. | 158 | * @id: Numerical identifier for the regulator. |
158 | * @n_voltages: Number of selectors available for ops.list_voltage(). | 159 | * @n_voltages: Number of selectors available for ops.list_voltage(). |
159 | * @ops: Regulator operations table. | 160 | * @ops: Regulator operations table. |
@@ -163,6 +164,7 @@ enum regulator_type { | |||
163 | */ | 164 | */ |
164 | struct regulator_desc { | 165 | struct regulator_desc { |
165 | const char *name; | 166 | const char *name; |
167 | const char *supply_name; | ||
166 | int id; | 168 | int id; |
167 | unsigned n_voltages; | 169 | unsigned n_voltages; |
168 | struct regulator_ops *ops; | 170 | struct regulator_ops *ops; |
@@ -212,7 +214,7 @@ struct regulator_dev { | |||
212 | 214 | ||
213 | struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc, | 215 | struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc, |
214 | struct device *dev, const struct regulator_init_data *init_data, | 216 | struct device *dev, const struct regulator_init_data *init_data, |
215 | void *driver_data); | 217 | void *driver_data, struct device_node *of_node); |
216 | void regulator_unregister(struct regulator_dev *rdev); | 218 | void regulator_unregister(struct regulator_dev *rdev); |
217 | 219 | ||
218 | int regulator_notifier_call_chain(struct regulator_dev *rdev, | 220 | int regulator_notifier_call_chain(struct regulator_dev *rdev, |
diff --git a/include/linux/regulator/of_regulator.h b/include/linux/regulator/of_regulator.h new file mode 100644 index 000000000000..d83a98d3e3fd --- /dev/null +++ b/include/linux/regulator/of_regulator.h | |||
@@ -0,0 +1,20 @@ | |||
1 | /* | ||
2 | * OpenFirmware regulator support routines | ||
3 | * | ||
4 | */ | ||
5 | |||
6 | #ifndef __LINUX_OF_REG_H | ||
7 | #define __LINUX_OF_REG_H | ||
8 | |||
9 | #if defined(CONFIG_OF) | ||
10 | extern struct regulator_init_data | ||
11 | *of_get_regulator_init_data(struct device *dev); | ||
12 | #else | ||
13 | static inline struct regulator_init_data | ||
14 | *of_get_regulator_init_data(struct device *dev) | ||
15 | { | ||
16 | return NULL; | ||
17 | } | ||
18 | #endif /* CONFIG_OF */ | ||
19 | |||
20 | #endif /* __LINUX_OF_REG_H */ | ||
diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c index d15695d1c273..fc7ab30572d0 100644 --- a/sound/soc/codecs/sgtl5000.c +++ b/sound/soc/codecs/sgtl5000.c | |||
@@ -833,7 +833,7 @@ static int ldo_regulator_register(struct snd_soc_codec *codec, | |||
833 | ldo->voltage = voltage; | 833 | ldo->voltage = voltage; |
834 | 834 | ||
835 | ldo->dev = regulator_register(&ldo->desc, codec->dev, | 835 | ldo->dev = regulator_register(&ldo->desc, codec->dev, |
836 | init_data, ldo); | 836 | init_data, ldo, NULL); |
837 | if (IS_ERR(ldo->dev)) { | 837 | if (IS_ERR(ldo->dev)) { |
838 | int ret = PTR_ERR(ldo->dev); | 838 | int ret = PTR_ERR(ldo->dev); |
839 | 839 | ||