diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-05-12 06:10:25 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-05-12 06:10:25 -0400 |
commit | 5949a7e9ab2db04edaeee7c368eb4c99131f4629 (patch) | |
tree | 13e8da5dc42cc62b9721659c41045d2c27c31cc3 | |
parent | 178e43aef2979525d7864daefd9499614e13800e (diff) | |
parent | 411a2df5090ccb88f4c3726e4951ebed579fec11 (diff) |
Merge remote-tracking branch 'regulator/topic/drivers' into regulator-next
Conflicts:
drivers/regulator/88pm8607.c (simple overlap with a bugfix in v3.4)
33 files changed, 559 insertions, 304 deletions
diff --git a/Documentation/devicetree/bindings/regulator/fixed-regulator.txt b/Documentation/devicetree/bindings/regulator/fixed-regulator.txt index 9cf57fd042d2..2f5b6b1ba15f 100644 --- a/Documentation/devicetree/bindings/regulator/fixed-regulator.txt +++ b/Documentation/devicetree/bindings/regulator/fixed-regulator.txt | |||
@@ -8,6 +8,8 @@ Optional properties: | |||
8 | - startup-delay-us: startup time in microseconds | 8 | - startup-delay-us: startup time in microseconds |
9 | - enable-active-high: Polarity of GPIO is Active high | 9 | - enable-active-high: Polarity of GPIO is Active high |
10 | If this property is missing, the default assumed is Active low. | 10 | If this property is missing, the default assumed is Active low. |
11 | - gpio-open-drain: GPIO is open drain type. | ||
12 | If this property is missing then default assumption is false. | ||
11 | 13 | ||
12 | Any property defined as part of the core regulator | 14 | Any property defined as part of the core regulator |
13 | binding, defined in regulator.txt, can also be used. | 15 | binding, defined in regulator.txt, can also be used. |
@@ -25,5 +27,6 @@ Example: | |||
25 | gpio = <&gpio1 16 0>; | 27 | gpio = <&gpio1 16 0>; |
26 | startup-delay-us = <70000>; | 28 | startup-delay-us = <70000>; |
27 | enable-active-high; | 29 | enable-active-high; |
28 | regulator-boot-on | 30 | regulator-boot-on; |
31 | gpio-open-drain; | ||
29 | }; | 32 | }; |
diff --git a/Documentation/devicetree/bindings/regulator/tps6586x.txt b/Documentation/devicetree/bindings/regulator/tps6586x.txt new file mode 100644 index 000000000000..0fcabaa3baa3 --- /dev/null +++ b/Documentation/devicetree/bindings/regulator/tps6586x.txt | |||
@@ -0,0 +1,97 @@ | |||
1 | TPS6586x family of regulators | ||
2 | |||
3 | Required properties: | ||
4 | - compatible: "ti,tps6586x" | ||
5 | - reg: I2C slave address | ||
6 | - interrupts: the interrupt outputs of the controller | ||
7 | - #gpio-cells: number of cells to describe a GPIO | ||
8 | - gpio-controller: mark the device as a GPIO controller | ||
9 | - regulators: list of regulators provided by this controller, must be named | ||
10 | after their hardware counterparts: sm[0-2], ldo[0-9] and ldo_rtc | ||
11 | |||
12 | Each regulator is defined using the standard binding for regulators. | ||
13 | |||
14 | Example: | ||
15 | |||
16 | pmu: tps6586x@34 { | ||
17 | compatible = "ti,tps6586x"; | ||
18 | reg = <0x34>; | ||
19 | interrupts = <0 88 0x4>; | ||
20 | |||
21 | #gpio-cells = <2>; | ||
22 | gpio-controller; | ||
23 | |||
24 | regulators { | ||
25 | sm0_reg: sm0 { | ||
26 | regulator-min-microvolt = < 725000>; | ||
27 | regulator-max-microvolt = <1500000>; | ||
28 | regulator-boot-on; | ||
29 | regulator-always-on; | ||
30 | }; | ||
31 | |||
32 | sm1_reg: sm1 { | ||
33 | regulator-min-microvolt = < 725000>; | ||
34 | regulator-max-microvolt = <1500000>; | ||
35 | regulator-boot-on; | ||
36 | regulator-always-on; | ||
37 | }; | ||
38 | |||
39 | sm2_reg: sm2 { | ||
40 | regulator-min-microvolt = <3000000>; | ||
41 | regulator-max-microvolt = <4550000>; | ||
42 | regulator-boot-on; | ||
43 | regulator-always-on; | ||
44 | }; | ||
45 | |||
46 | ldo0_reg: ldo0 { | ||
47 | regulator-name = "PCIE CLK"; | ||
48 | regulator-min-microvolt = <3300000>; | ||
49 | regulator-max-microvolt = <3300000>; | ||
50 | }; | ||
51 | |||
52 | ldo1_reg: ldo1 { | ||
53 | regulator-min-microvolt = < 725000>; | ||
54 | regulator-max-microvolt = <1500000>; | ||
55 | }; | ||
56 | |||
57 | ldo2_reg: ldo2 { | ||
58 | regulator-min-microvolt = < 725000>; | ||
59 | regulator-max-microvolt = <1500000>; | ||
60 | }; | ||
61 | |||
62 | ldo3_reg: ldo3 { | ||
63 | regulator-min-microvolt = <1250000>; | ||
64 | regulator-max-microvolt = <3300000>; | ||
65 | }; | ||
66 | |||
67 | ldo4_reg: ldo4 { | ||
68 | regulator-min-microvolt = <1700000>; | ||
69 | regulator-max-microvolt = <2475000>; | ||
70 | }; | ||
71 | |||
72 | ldo5_reg: ldo5 { | ||
73 | regulator-min-microvolt = <1250000>; | ||
74 | regulator-max-microvolt = <3300000>; | ||
75 | }; | ||
76 | |||
77 | ldo6_reg: ldo6 { | ||
78 | regulator-min-microvolt = <1250000>; | ||
79 | regulator-max-microvolt = <3300000>; | ||
80 | }; | ||
81 | |||
82 | ldo7_reg: ldo7 { | ||
83 | regulator-min-microvolt = <1250000>; | ||
84 | regulator-max-microvolt = <3300000>; | ||
85 | }; | ||
86 | |||
87 | ldo8_reg: ldo8 { | ||
88 | regulator-min-microvolt = <1250000>; | ||
89 | regulator-max-microvolt = <3300000>; | ||
90 | }; | ||
91 | |||
92 | ldo9_reg: ldo9 { | ||
93 | regulator-min-microvolt = <1250000>; | ||
94 | regulator-max-microvolt = <3300000>; | ||
95 | }; | ||
96 | }; | ||
97 | }; | ||
diff --git a/drivers/mfd/tps6586x.c b/drivers/mfd/tps6586x.c index a5ddf31b60ca..c84b5506d5fb 100644 --- a/drivers/mfd/tps6586x.c +++ b/drivers/mfd/tps6586x.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/slab.h> | 23 | #include <linux/slab.h> |
24 | #include <linux/gpio.h> | 24 | #include <linux/gpio.h> |
25 | #include <linux/i2c.h> | 25 | #include <linux/i2c.h> |
26 | #include <linux/regulator/of_regulator.h> | ||
26 | 27 | ||
27 | #include <linux/mfd/core.h> | 28 | #include <linux/mfd/core.h> |
28 | #include <linux/mfd/tps6586x.h> | 29 | #include <linux/mfd/tps6586x.h> |
@@ -460,6 +461,7 @@ static int __devinit tps6586x_add_subdevs(struct tps6586x *tps6586x, | |||
460 | 461 | ||
461 | pdev->dev.parent = tps6586x->dev; | 462 | pdev->dev.parent = tps6586x->dev; |
462 | pdev->dev.platform_data = subdev->platform_data; | 463 | pdev->dev.platform_data = subdev->platform_data; |
464 | pdev->dev.of_node = subdev->of_node; | ||
463 | 465 | ||
464 | ret = platform_device_add(pdev); | 466 | ret = platform_device_add(pdev); |
465 | if (ret) { | 467 | if (ret) { |
@@ -474,6 +476,86 @@ failed: | |||
474 | return ret; | 476 | return ret; |
475 | } | 477 | } |
476 | 478 | ||
479 | #ifdef CONFIG_OF | ||
480 | static struct of_regulator_match tps6586x_matches[] = { | ||
481 | { .name = "sm0", .driver_data = (void *)TPS6586X_ID_SM_0 }, | ||
482 | { .name = "sm1", .driver_data = (void *)TPS6586X_ID_SM_1 }, | ||
483 | { .name = "sm2", .driver_data = (void *)TPS6586X_ID_SM_2 }, | ||
484 | { .name = "ldo0", .driver_data = (void *)TPS6586X_ID_LDO_0 }, | ||
485 | { .name = "ldo1", .driver_data = (void *)TPS6586X_ID_LDO_1 }, | ||
486 | { .name = "ldo2", .driver_data = (void *)TPS6586X_ID_LDO_2 }, | ||
487 | { .name = "ldo3", .driver_data = (void *)TPS6586X_ID_LDO_3 }, | ||
488 | { .name = "ldo4", .driver_data = (void *)TPS6586X_ID_LDO_4 }, | ||
489 | { .name = "ldo5", .driver_data = (void *)TPS6586X_ID_LDO_5 }, | ||
490 | { .name = "ldo6", .driver_data = (void *)TPS6586X_ID_LDO_6 }, | ||
491 | { .name = "ldo7", .driver_data = (void *)TPS6586X_ID_LDO_7 }, | ||
492 | { .name = "ldo8", .driver_data = (void *)TPS6586X_ID_LDO_8 }, | ||
493 | { .name = "ldo9", .driver_data = (void *)TPS6586X_ID_LDO_9 }, | ||
494 | { .name = "ldo_rtc", .driver_data = (void *)TPS6586X_ID_LDO_RTC }, | ||
495 | }; | ||
496 | |||
497 | static struct tps6586x_platform_data *tps6586x_parse_dt(struct i2c_client *client) | ||
498 | { | ||
499 | const unsigned int num = ARRAY_SIZE(tps6586x_matches); | ||
500 | struct device_node *np = client->dev.of_node; | ||
501 | struct tps6586x_platform_data *pdata; | ||
502 | struct tps6586x_subdev_info *devs; | ||
503 | struct device_node *regs; | ||
504 | unsigned int count; | ||
505 | unsigned int i, j; | ||
506 | int err; | ||
507 | |||
508 | regs = of_find_node_by_name(np, "regulators"); | ||
509 | if (!regs) | ||
510 | return NULL; | ||
511 | |||
512 | err = of_regulator_match(&client->dev, regs, tps6586x_matches, num); | ||
513 | if (err < 0) { | ||
514 | of_node_put(regs); | ||
515 | return NULL; | ||
516 | } | ||
517 | |||
518 | of_node_put(regs); | ||
519 | count = err; | ||
520 | |||
521 | devs = devm_kzalloc(&client->dev, count * sizeof(*devs), GFP_KERNEL); | ||
522 | if (!devs) | ||
523 | return NULL; | ||
524 | |||
525 | for (i = 0, j = 0; i < num && j < count; i++) { | ||
526 | if (!tps6586x_matches[i].init_data) | ||
527 | continue; | ||
528 | |||
529 | devs[j].name = "tps6586x-regulator"; | ||
530 | devs[j].platform_data = tps6586x_matches[i].init_data; | ||
531 | devs[j].id = (int)tps6586x_matches[i].driver_data; | ||
532 | devs[j].of_node = tps6586x_matches[i].of_node; | ||
533 | j++; | ||
534 | } | ||
535 | |||
536 | pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL); | ||
537 | if (!pdata) | ||
538 | return NULL; | ||
539 | |||
540 | pdata->num_subdevs = count; | ||
541 | pdata->subdevs = devs; | ||
542 | pdata->gpio_base = -1; | ||
543 | pdata->irq_base = -1; | ||
544 | |||
545 | return pdata; | ||
546 | } | ||
547 | |||
548 | static struct of_device_id tps6586x_of_match[] = { | ||
549 | { .compatible = "ti,tps6586x", }, | ||
550 | { }, | ||
551 | }; | ||
552 | #else | ||
553 | static struct tps6586x_platform_data *tps6586x_parse_dt(struct i2c_client *client) | ||
554 | { | ||
555 | return NULL; | ||
556 | } | ||
557 | #endif | ||
558 | |||
477 | static int __devinit tps6586x_i2c_probe(struct i2c_client *client, | 559 | static int __devinit tps6586x_i2c_probe(struct i2c_client *client, |
478 | const struct i2c_device_id *id) | 560 | const struct i2c_device_id *id) |
479 | { | 561 | { |
@@ -481,6 +563,9 @@ static int __devinit tps6586x_i2c_probe(struct i2c_client *client, | |||
481 | struct tps6586x *tps6586x; | 563 | struct tps6586x *tps6586x; |
482 | int ret; | 564 | int ret; |
483 | 565 | ||
566 | if (!pdata && client->dev.of_node) | ||
567 | pdata = tps6586x_parse_dt(client); | ||
568 | |||
484 | if (!pdata) { | 569 | if (!pdata) { |
485 | dev_err(&client->dev, "tps6586x requires platform data\n"); | 570 | dev_err(&client->dev, "tps6586x requires platform data\n"); |
486 | return -ENOTSUPP; | 571 | return -ENOTSUPP; |
@@ -573,6 +658,7 @@ static struct i2c_driver tps6586x_driver = { | |||
573 | .driver = { | 658 | .driver = { |
574 | .name = "tps6586x", | 659 | .name = "tps6586x", |
575 | .owner = THIS_MODULE, | 660 | .owner = THIS_MODULE, |
661 | .of_match_table = of_match_ptr(tps6586x_of_match), | ||
576 | }, | 662 | }, |
577 | .probe = tps6586x_i2c_probe, | 663 | .probe = tps6586x_i2c_probe, |
578 | .remove = __devexit_p(tps6586x_i2c_remove), | 664 | .remove = __devexit_p(tps6586x_i2c_remove), |
diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c index 7c2267e71f8b..6fc90befa79e 100644 --- a/drivers/mfd/twl-core.c +++ b/drivers/mfd/twl-core.c | |||
@@ -224,13 +224,6 @@ | |||
224 | #define HIGH_PERF_SQ (1 << 3) | 224 | #define HIGH_PERF_SQ (1 << 3) |
225 | #define CK32K_LOWPWR_EN (1 << 7) | 225 | #define CK32K_LOWPWR_EN (1 << 7) |
226 | 226 | ||
227 | |||
228 | /* chip-specific feature flags, for i2c_device_id.driver_data */ | ||
229 | #define TWL4030_VAUX2 BIT(0) /* pre-5030 voltage ranges */ | ||
230 | #define TPS_SUBSET BIT(1) /* tps659[23]0 have fewer LDOs */ | ||
231 | #define TWL5031 BIT(2) /* twl5031 has different registers */ | ||
232 | #define TWL6030_CLASS BIT(3) /* TWL6030 class */ | ||
233 | |||
234 | /*----------------------------------------------------------------------*/ | 227 | /*----------------------------------------------------------------------*/ |
235 | 228 | ||
236 | /* is driver active, bound to a chip? */ | 229 | /* is driver active, bound to a chip? */ |
diff --git a/drivers/regulator/aat2870-regulator.c b/drivers/regulator/aat2870-regulator.c index 7f000d6bb984..06776ca945f2 100644 --- a/drivers/regulator/aat2870-regulator.c +++ b/drivers/regulator/aat2870-regulator.c | |||
@@ -24,7 +24,6 @@ | |||
24 | #include <linux/err.h> | 24 | #include <linux/err.h> |
25 | #include <linux/module.h> | 25 | #include <linux/module.h> |
26 | #include <linux/slab.h> | 26 | #include <linux/slab.h> |
27 | #include <linux/delay.h> | ||
28 | #include <linux/platform_device.h> | 27 | #include <linux/platform_device.h> |
29 | #include <linux/regulator/driver.h> | 28 | #include <linux/regulator/driver.h> |
30 | #include <linux/regulator/machine.h> | 29 | #include <linux/regulator/machine.h> |
diff --git a/drivers/regulator/ab3100.c b/drivers/regulator/ab3100.c index ce6192592ca2..e2062ad74e5d 100644 --- a/drivers/regulator/ab3100.c +++ b/drivers/regulator/ab3100.c | |||
@@ -13,7 +13,6 @@ | |||
13 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
14 | #include <linux/init.h> | 14 | #include <linux/init.h> |
15 | #include <linux/err.h> | 15 | #include <linux/err.h> |
16 | #include <linux/delay.h> | ||
17 | #include <linux/platform_device.h> | 16 | #include <linux/platform_device.h> |
18 | #include <linux/regulator/driver.h> | 17 | #include <linux/regulator/driver.h> |
19 | #include <linux/mfd/abx500.h> | 18 | #include <linux/mfd/abx500.h> |
diff --git a/drivers/regulator/da9052-regulator.c b/drivers/regulator/da9052-regulator.c index 2943ef6bdf45..d2de7fc98080 100644 --- a/drivers/regulator/da9052-regulator.c +++ b/drivers/regulator/da9052-regulator.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/regulator/driver.h> | 20 | #include <linux/regulator/driver.h> |
21 | #include <linux/regulator/machine.h> | 21 | #include <linux/regulator/machine.h> |
22 | #ifdef CONFIG_OF | 22 | #ifdef CONFIG_OF |
23 | #include <linux/of.h> | ||
23 | #include <linux/regulator/of_regulator.h> | 24 | #include <linux/regulator/of_regulator.h> |
24 | #endif | 25 | #endif |
25 | 26 | ||
@@ -393,7 +394,7 @@ static int __devinit da9052_regulator_probe(struct platform_device *pdev) | |||
393 | if (!nproot) | 394 | if (!nproot) |
394 | return -ENODEV; | 395 | return -ENODEV; |
395 | 396 | ||
396 | for (np = of_get_next_child(nproot, NULL); !np; | 397 | for (np = of_get_next_child(nproot, NULL); np; |
397 | np = of_get_next_child(nproot, np)) { | 398 | np = of_get_next_child(nproot, np)) { |
398 | if (!of_node_cmp(np->name, | 399 | if (!of_node_cmp(np->name, |
399 | regulator->info->reg_desc.name)) { | 400 | regulator->info->reg_desc.name)) { |
diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c index b47b005a8d28..f09fe7b20e82 100644 --- a/drivers/regulator/fixed.c +++ b/drivers/regulator/fixed.c | |||
@@ -25,7 +25,6 @@ | |||
25 | #include <linux/regulator/driver.h> | 25 | #include <linux/regulator/driver.h> |
26 | #include <linux/regulator/fixed.h> | 26 | #include <linux/regulator/fixed.h> |
27 | #include <linux/gpio.h> | 27 | #include <linux/gpio.h> |
28 | #include <linux/delay.h> | ||
29 | #include <linux/slab.h> | 28 | #include <linux/slab.h> |
30 | #include <linux/of.h> | 29 | #include <linux/of.h> |
31 | #include <linux/of_gpio.h> | 30 | #include <linux/of_gpio.h> |
@@ -91,6 +90,9 @@ of_get_fixed_voltage_config(struct device *dev) | |||
91 | if (of_find_property(np, "enable-active-high", NULL)) | 90 | if (of_find_property(np, "enable-active-high", NULL)) |
92 | config->enable_high = true; | 91 | config->enable_high = true; |
93 | 92 | ||
93 | if (of_find_property(np, "gpio-open-drain", NULL)) | ||
94 | config->gpio_is_open_drain = true; | ||
95 | |||
94 | return config; | 96 | return config; |
95 | } | 97 | } |
96 | 98 | ||
diff --git a/drivers/regulator/gpio-regulator.c b/drivers/regulator/gpio-regulator.c index f93b06b1e7ec..9997d7aaca84 100644 --- a/drivers/regulator/gpio-regulator.c +++ b/drivers/regulator/gpio-regulator.c | |||
@@ -30,7 +30,6 @@ | |||
30 | #include <linux/regulator/machine.h> | 30 | #include <linux/regulator/machine.h> |
31 | #include <linux/regulator/gpio-regulator.h> | 31 | #include <linux/regulator/gpio-regulator.h> |
32 | #include <linux/gpio.h> | 32 | #include <linux/gpio.h> |
33 | #include <linux/delay.h> | ||
34 | #include <linux/slab.h> | 33 | #include <linux/slab.h> |
35 | 34 | ||
36 | struct gpio_regulator_data { | 35 | struct gpio_regulator_data { |
diff --git a/drivers/regulator/isl6271a-regulator.c b/drivers/regulator/isl6271a-regulator.c index 60044c362eb5..5caaf1f77541 100644 --- a/drivers/regulator/isl6271a-regulator.c +++ b/drivers/regulator/isl6271a-regulator.c | |||
@@ -22,7 +22,6 @@ | |||
22 | #include <linux/platform_device.h> | 22 | #include <linux/platform_device.h> |
23 | #include <linux/regulator/driver.h> | 23 | #include <linux/regulator/driver.h> |
24 | #include <linux/i2c.h> | 24 | #include <linux/i2c.h> |
25 | #include <linux/delay.h> | ||
26 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
27 | 26 | ||
28 | #define ISL6271A_VOLTAGE_MIN 850000 | 27 | #define ISL6271A_VOLTAGE_MIN 850000 |
diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c index 9997cfbc3471..5d568175cc27 100644 --- a/drivers/regulator/max8660.c +++ b/drivers/regulator/max8660.c | |||
@@ -370,7 +370,7 @@ static int __devinit max8660_probe(struct i2c_client *client, | |||
370 | return -EINVAL; | 370 | return -EINVAL; |
371 | } | 371 | } |
372 | 372 | ||
373 | max8660 = kzalloc(sizeof(struct max8660) + | 373 | max8660 = devm_kzalloc(&client->dev, sizeof(struct max8660) + |
374 | sizeof(struct regulator_dev *) * MAX8660_V_END, | 374 | sizeof(struct regulator_dev *) * MAX8660_V_END, |
375 | GFP_KERNEL); | 375 | GFP_KERNEL); |
376 | if (!max8660) | 376 | if (!max8660) |
diff --git a/drivers/regulator/max8952.c b/drivers/regulator/max8952.c index c0ab4ddc1023..62ae140d8d9f 100644 --- a/drivers/regulator/max8952.c +++ b/drivers/regulator/max8952.c | |||
@@ -69,11 +69,6 @@ static int max8952_write_reg(struct max8952_data *max8952, | |||
69 | return i2c_smbus_write_byte_data(max8952->client, reg, value); | 69 | return i2c_smbus_write_byte_data(max8952->client, reg, value); |
70 | } | 70 | } |
71 | 71 | ||
72 | static int max8952_voltage(struct max8952_data *max8952, u8 mode) | ||
73 | { | ||
74 | return (max8952->pdata->dvs_mode[mode] * 10 + 770) * 1000; | ||
75 | } | ||
76 | |||
77 | static int max8952_list_voltage(struct regulator_dev *rdev, | 72 | static int max8952_list_voltage(struct regulator_dev *rdev, |
78 | unsigned int selector) | 73 | unsigned int selector) |
79 | { | 74 | { |
@@ -82,7 +77,7 @@ static int max8952_list_voltage(struct regulator_dev *rdev, | |||
82 | if (rdev_get_id(rdev) != 0) | 77 | if (rdev_get_id(rdev) != 0) |
83 | return -EINVAL; | 78 | return -EINVAL; |
84 | 79 | ||
85 | return max8952_voltage(max8952, selector); | 80 | return (max8952->pdata->dvs_mode[selector] * 10 + 770) * 1000; |
86 | } | 81 | } |
87 | 82 | ||
88 | static int max8952_is_enabled(struct regulator_dev *rdev) | 83 | static int max8952_is_enabled(struct regulator_dev *rdev) |
@@ -117,7 +112,7 @@ static int max8952_disable(struct regulator_dev *rdev) | |||
117 | return 0; | 112 | return 0; |
118 | } | 113 | } |
119 | 114 | ||
120 | static int max8952_get_voltage(struct regulator_dev *rdev) | 115 | static int max8952_get_voltage_sel(struct regulator_dev *rdev) |
121 | { | 116 | { |
122 | struct max8952_data *max8952 = rdev_get_drvdata(rdev); | 117 | struct max8952_data *max8952 = rdev_get_drvdata(rdev); |
123 | u8 vid = 0; | 118 | u8 vid = 0; |
@@ -127,7 +122,7 @@ static int max8952_get_voltage(struct regulator_dev *rdev) | |||
127 | if (max8952->vid1) | 122 | if (max8952->vid1) |
128 | vid += 2; | 123 | vid += 2; |
129 | 124 | ||
130 | return max8952_voltage(max8952, vid); | 125 | return vid; |
131 | } | 126 | } |
132 | 127 | ||
133 | static int max8952_set_voltage_sel(struct regulator_dev *rdev, | 128 | static int max8952_set_voltage_sel(struct regulator_dev *rdev, |
@@ -154,7 +149,7 @@ static struct regulator_ops max8952_ops = { | |||
154 | .is_enabled = max8952_is_enabled, | 149 | .is_enabled = max8952_is_enabled, |
155 | .enable = max8952_enable, | 150 | .enable = max8952_enable, |
156 | .disable = max8952_disable, | 151 | .disable = max8952_disable, |
157 | .get_voltage = max8952_get_voltage, | 152 | .get_voltage_sel = max8952_get_voltage_sel, |
158 | .set_voltage_sel = max8952_set_voltage_sel, | 153 | .set_voltage_sel = max8952_set_voltage_sel, |
159 | .set_suspend_disable = max8952_disable, | 154 | .set_suspend_disable = max8952_disable, |
160 | }; | 155 | }; |
diff --git a/drivers/regulator/max8997.c b/drivers/regulator/max8997.c index db09244bb3ed..b88551be4521 100644 --- a/drivers/regulator/max8997.c +++ b/drivers/regulator/max8997.c | |||
@@ -22,7 +22,6 @@ | |||
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <linux/bug.h> | 24 | #include <linux/bug.h> |
25 | #include <linux/delay.h> | ||
26 | #include <linux/err.h> | 25 | #include <linux/err.h> |
27 | #include <linux/gpio.h> | 26 | #include <linux/gpio.h> |
28 | #include <linux/slab.h> | 27 | #include <linux/slab.h> |
@@ -278,9 +277,7 @@ static int max8997_reg_is_enabled(struct regulator_dev *rdev) | |||
278 | u8 val; | 277 | u8 val; |
279 | 278 | ||
280 | ret = max8997_get_enable_register(rdev, ®, &mask, &pattern); | 279 | ret = max8997_get_enable_register(rdev, ®, &mask, &pattern); |
281 | if (ret == -EINVAL) | 280 | if (ret) |
282 | return 1; /* "not controllable" */ | ||
283 | else if (ret) | ||
284 | return ret; | 281 | return ret; |
285 | 282 | ||
286 | ret = max8997_read_reg(i2c, reg, &val); | 283 | ret = max8997_read_reg(i2c, reg, &val); |
@@ -382,7 +379,7 @@ static int max8997_get_voltage_register(struct regulator_dev *rdev, | |||
382 | return 0; | 379 | return 0; |
383 | } | 380 | } |
384 | 381 | ||
385 | static int max8997_get_voltage(struct regulator_dev *rdev) | 382 | static int max8997_get_voltage_sel(struct regulator_dev *rdev) |
386 | { | 383 | { |
387 | struct max8997_data *max8997 = rdev_get_drvdata(rdev); | 384 | struct max8997_data *max8997 = rdev_get_drvdata(rdev); |
388 | struct i2c_client *i2c = max8997->iodev->i2c; | 385 | struct i2c_client *i2c = max8997->iodev->i2c; |
@@ -400,15 +397,7 @@ static int max8997_get_voltage(struct regulator_dev *rdev) | |||
400 | val >>= shift; | 397 | val >>= shift; |
401 | val &= mask; | 398 | val &= mask; |
402 | 399 | ||
403 | if (rdev->desc && rdev->desc->ops && rdev->desc->ops->list_voltage) | 400 | return val; |
404 | return rdev->desc->ops->list_voltage(rdev, val); | ||
405 | |||
406 | /* | ||
407 | * max8997_list_voltage returns value for any rdev with voltage_map, | ||
408 | * which works for "CHARGER" and "CHARGER TOPOFF" that do not have | ||
409 | * list_voltage ops (they are current regulators). | ||
410 | */ | ||
411 | return max8997_list_voltage(rdev, val); | ||
412 | } | 401 | } |
413 | 402 | ||
414 | static inline int max8997_get_voltage_proper_val( | 403 | static inline int max8997_get_voltage_proper_val( |
@@ -497,9 +486,7 @@ static int max8997_set_voltage_ldobuck(struct regulator_dev *rdev, | |||
497 | int min_vol = min_uV / 1000, max_vol = max_uV / 1000; | 486 | int min_vol = min_uV / 1000, max_vol = max_uV / 1000; |
498 | const struct voltage_map_desc *desc; | 487 | const struct voltage_map_desc *desc; |
499 | int rid = rdev_get_id(rdev); | 488 | int rid = rdev_get_id(rdev); |
500 | int reg, shift = 0, mask, ret; | 489 | int i, reg, shift, mask, ret; |
501 | int i; | ||
502 | u8 org; | ||
503 | 490 | ||
504 | switch (rid) { | 491 | switch (rid) { |
505 | case MAX8997_LDO1 ... MAX8997_LDO21: | 492 | case MAX8997_LDO1 ... MAX8997_LDO21: |
@@ -528,21 +515,50 @@ static int max8997_set_voltage_ldobuck(struct regulator_dev *rdev, | |||
528 | if (ret) | 515 | if (ret) |
529 | return ret; | 516 | return ret; |
530 | 517 | ||
531 | max8997_read_reg(i2c, reg, &org); | ||
532 | org = (org & mask) >> shift; | ||
533 | |||
534 | ret = max8997_update_reg(i2c, reg, i << shift, mask << shift); | 518 | ret = max8997_update_reg(i2c, reg, i << shift, mask << shift); |
535 | *selector = i; | 519 | *selector = i; |
536 | 520 | ||
537 | if (rid == MAX8997_BUCK1 || rid == MAX8997_BUCK2 || | 521 | return ret; |
538 | rid == MAX8997_BUCK4 || rid == MAX8997_BUCK5) { | 522 | } |
539 | /* If the voltage is increasing */ | 523 | |
540 | if (org < i) | 524 | static int max8997_set_voltage_ldobuck_time_sel(struct regulator_dev *rdev, |
541 | udelay(DIV_ROUND_UP(desc->step * (i - org), | 525 | unsigned int old_selector, |
542 | max8997->ramp_delay)); | 526 | unsigned int new_selector) |
527 | { | ||
528 | struct max8997_data *max8997 = rdev_get_drvdata(rdev); | ||
529 | int rid = rdev_get_id(rdev); | ||
530 | const struct voltage_map_desc *desc = reg_voltage_map[rid]; | ||
531 | |||
532 | /* Delay is required only if the voltage is increasing */ | ||
533 | if (old_selector >= new_selector) | ||
534 | return 0; | ||
535 | |||
536 | /* No need to delay if gpio_dvs_mode */ | ||
537 | switch (rid) { | ||
538 | case MAX8997_BUCK1: | ||
539 | if (max8997->buck1_gpiodvs) | ||
540 | return 0; | ||
541 | break; | ||
542 | case MAX8997_BUCK2: | ||
543 | if (max8997->buck2_gpiodvs) | ||
544 | return 0; | ||
545 | break; | ||
546 | case MAX8997_BUCK5: | ||
547 | if (max8997->buck5_gpiodvs) | ||
548 | return 0; | ||
549 | break; | ||
543 | } | 550 | } |
544 | 551 | ||
545 | return ret; | 552 | switch (rid) { |
553 | case MAX8997_BUCK1: | ||
554 | case MAX8997_BUCK2: | ||
555 | case MAX8997_BUCK4: | ||
556 | case MAX8997_BUCK5: | ||
557 | return DIV_ROUND_UP(desc->step * (new_selector - old_selector), | ||
558 | max8997->ramp_delay); | ||
559 | } | ||
560 | |||
561 | return 0; | ||
546 | } | 562 | } |
547 | 563 | ||
548 | /* | 564 | /* |
@@ -749,11 +765,6 @@ static int max8997_set_voltage_safeout(struct regulator_dev *rdev, | |||
749 | return ret; | 765 | return ret; |
750 | } | 766 | } |
751 | 767 | ||
752 | static int max8997_reg_enable_suspend(struct regulator_dev *rdev) | ||
753 | { | ||
754 | return 0; | ||
755 | } | ||
756 | |||
757 | static int max8997_reg_disable_suspend(struct regulator_dev *rdev) | 768 | static int max8997_reg_disable_suspend(struct regulator_dev *rdev) |
758 | { | 769 | { |
759 | struct max8997_data *max8997 = rdev_get_drvdata(rdev); | 770 | struct max8997_data *max8997 = rdev_get_drvdata(rdev); |
@@ -786,9 +797,9 @@ static struct regulator_ops max8997_ldo_ops = { | |||
786 | .is_enabled = max8997_reg_is_enabled, | 797 | .is_enabled = max8997_reg_is_enabled, |
787 | .enable = max8997_reg_enable, | 798 | .enable = max8997_reg_enable, |
788 | .disable = max8997_reg_disable, | 799 | .disable = max8997_reg_disable, |
789 | .get_voltage = max8997_get_voltage, | 800 | .get_voltage_sel = max8997_get_voltage_sel, |
790 | .set_voltage = max8997_set_voltage_ldobuck, | 801 | .set_voltage = max8997_set_voltage_ldobuck, |
791 | .set_suspend_enable = max8997_reg_enable_suspend, | 802 | .set_voltage_time_sel = max8997_set_voltage_ldobuck_time_sel, |
792 | .set_suspend_disable = max8997_reg_disable_suspend, | 803 | .set_suspend_disable = max8997_reg_disable_suspend, |
793 | }; | 804 | }; |
794 | 805 | ||
@@ -797,9 +808,9 @@ static struct regulator_ops max8997_buck_ops = { | |||
797 | .is_enabled = max8997_reg_is_enabled, | 808 | .is_enabled = max8997_reg_is_enabled, |
798 | .enable = max8997_reg_enable, | 809 | .enable = max8997_reg_enable, |
799 | .disable = max8997_reg_disable, | 810 | .disable = max8997_reg_disable, |
800 | .get_voltage = max8997_get_voltage, | 811 | .get_voltage_sel = max8997_get_voltage_sel, |
801 | .set_voltage = max8997_set_voltage_buck, | 812 | .set_voltage = max8997_set_voltage_buck, |
802 | .set_suspend_enable = max8997_reg_enable_suspend, | 813 | .set_voltage_time_sel = max8997_set_voltage_ldobuck_time_sel, |
803 | .set_suspend_disable = max8997_reg_disable_suspend, | 814 | .set_suspend_disable = max8997_reg_disable_suspend, |
804 | }; | 815 | }; |
805 | 816 | ||
@@ -808,7 +819,6 @@ static struct regulator_ops max8997_fixedvolt_ops = { | |||
808 | .is_enabled = max8997_reg_is_enabled, | 819 | .is_enabled = max8997_reg_is_enabled, |
809 | .enable = max8997_reg_enable, | 820 | .enable = max8997_reg_enable, |
810 | .disable = max8997_reg_disable, | 821 | .disable = max8997_reg_disable, |
811 | .set_suspend_enable = max8997_reg_enable_suspend, | ||
812 | .set_suspend_disable = max8997_reg_disable_suspend, | 822 | .set_suspend_disable = max8997_reg_disable_suspend, |
813 | }; | 823 | }; |
814 | 824 | ||
@@ -817,39 +827,56 @@ static struct regulator_ops max8997_safeout_ops = { | |||
817 | .is_enabled = max8997_reg_is_enabled, | 827 | .is_enabled = max8997_reg_is_enabled, |
818 | .enable = max8997_reg_enable, | 828 | .enable = max8997_reg_enable, |
819 | .disable = max8997_reg_disable, | 829 | .disable = max8997_reg_disable, |
820 | .get_voltage = max8997_get_voltage, | 830 | .get_voltage_sel = max8997_get_voltage_sel, |
821 | .set_voltage = max8997_set_voltage_safeout, | 831 | .set_voltage = max8997_set_voltage_safeout, |
822 | .set_suspend_enable = max8997_reg_enable_suspend, | ||
823 | .set_suspend_disable = max8997_reg_disable_suspend, | 832 | .set_suspend_disable = max8997_reg_disable_suspend, |
824 | }; | 833 | }; |
825 | 834 | ||
826 | static struct regulator_ops max8997_fixedstate_ops = { | 835 | static struct regulator_ops max8997_fixedstate_ops = { |
827 | .list_voltage = max8997_list_voltage_charger_cv, | 836 | .list_voltage = max8997_list_voltage_charger_cv, |
828 | .get_voltage = max8997_get_voltage, | 837 | .get_voltage_sel = max8997_get_voltage_sel, |
829 | .set_voltage = max8997_set_voltage_charger_cv, | 838 | .set_voltage = max8997_set_voltage_charger_cv, |
830 | }; | 839 | }; |
831 | 840 | ||
832 | static int max8997_set_voltage_ldobuck_wrap(struct regulator_dev *rdev, | 841 | static int max8997_set_current_limit(struct regulator_dev *rdev, |
833 | int min_uV, int max_uV) | 842 | int min_uA, int max_uA) |
834 | { | 843 | { |
835 | unsigned dummy; | 844 | unsigned dummy; |
845 | int rid = rdev_get_id(rdev); | ||
846 | |||
847 | if (rid != MAX8997_CHARGER && rid != MAX8997_CHARGER_TOPOFF) | ||
848 | return -EINVAL; | ||
836 | 849 | ||
837 | return max8997_set_voltage_ldobuck(rdev, min_uV, max_uV, &dummy); | 850 | /* Reuse max8997_set_voltage_ldobuck to set current_limit. */ |
851 | return max8997_set_voltage_ldobuck(rdev, min_uA, max_uA, &dummy); | ||
838 | } | 852 | } |
839 | 853 | ||
854 | static int max8997_get_current_limit(struct regulator_dev *rdev) | ||
855 | { | ||
856 | int sel, rid = rdev_get_id(rdev); | ||
857 | |||
858 | if (rid != MAX8997_CHARGER && rid != MAX8997_CHARGER_TOPOFF) | ||
859 | return -EINVAL; | ||
860 | |||
861 | sel = max8997_get_voltage_sel(rdev); | ||
862 | if (sel < 0) | ||
863 | return sel; | ||
864 | |||
865 | /* Reuse max8997_list_voltage to get current_limit. */ | ||
866 | return max8997_list_voltage(rdev, sel); | ||
867 | } | ||
840 | 868 | ||
841 | static struct regulator_ops max8997_charger_ops = { | 869 | static struct regulator_ops max8997_charger_ops = { |
842 | .is_enabled = max8997_reg_is_enabled, | 870 | .is_enabled = max8997_reg_is_enabled, |
843 | .enable = max8997_reg_enable, | 871 | .enable = max8997_reg_enable, |
844 | .disable = max8997_reg_disable, | 872 | .disable = max8997_reg_disable, |
845 | .get_current_limit = max8997_get_voltage, | 873 | .get_current_limit = max8997_get_current_limit, |
846 | .set_current_limit = max8997_set_voltage_ldobuck_wrap, | 874 | .set_current_limit = max8997_set_current_limit, |
847 | }; | 875 | }; |
848 | 876 | ||
849 | static struct regulator_ops max8997_charger_fixedstate_ops = { | 877 | static struct regulator_ops max8997_charger_fixedstate_ops = { |
850 | .is_enabled = max8997_reg_is_enabled, | 878 | .get_current_limit = max8997_get_current_limit, |
851 | .get_current_limit = max8997_get_voltage, | 879 | .set_current_limit = max8997_set_current_limit, |
852 | .set_current_limit = max8997_set_voltage_ldobuck_wrap, | ||
853 | }; | 880 | }; |
854 | 881 | ||
855 | #define MAX8997_VOLTAGE_REGULATOR(_name, _ops) {\ | 882 | #define MAX8997_VOLTAGE_REGULATOR(_name, _ops) {\ |
@@ -922,16 +949,15 @@ static __devinit int max8997_pmic_probe(struct platform_device *pdev) | |||
922 | return -ENODEV; | 949 | return -ENODEV; |
923 | } | 950 | } |
924 | 951 | ||
925 | max8997 = kzalloc(sizeof(struct max8997_data), GFP_KERNEL); | 952 | max8997 = devm_kzalloc(&pdev->dev, sizeof(struct max8997_data), |
953 | GFP_KERNEL); | ||
926 | if (!max8997) | 954 | if (!max8997) |
927 | return -ENOMEM; | 955 | return -ENOMEM; |
928 | 956 | ||
929 | size = sizeof(struct regulator_dev *) * pdata->num_regulators; | 957 | size = sizeof(struct regulator_dev *) * pdata->num_regulators; |
930 | max8997->rdev = kzalloc(size, GFP_KERNEL); | 958 | max8997->rdev = devm_kzalloc(&pdev->dev, size, GFP_KERNEL); |
931 | if (!max8997->rdev) { | 959 | if (!max8997->rdev) |
932 | kfree(max8997); | ||
933 | return -ENOMEM; | 960 | return -ENOMEM; |
934 | } | ||
935 | 961 | ||
936 | rdev = max8997->rdev; | 962 | rdev = max8997->rdev; |
937 | max8997->dev = &pdev->dev; | 963 | max8997->dev = &pdev->dev; |
@@ -955,7 +981,7 @@ static __devinit int max8997_pmic_probe(struct platform_device *pdev) | |||
955 | pdata->buck1_voltage[i] / 1000 + | 981 | pdata->buck1_voltage[i] / 1000 + |
956 | buck1245_voltage_map_desc.step); | 982 | buck1245_voltage_map_desc.step); |
957 | if (ret < 0) | 983 | if (ret < 0) |
958 | goto err_alloc; | 984 | goto err_out; |
959 | 985 | ||
960 | max8997->buck2_vol[i] = ret = | 986 | max8997->buck2_vol[i] = ret = |
961 | max8997_get_voltage_proper_val( | 987 | max8997_get_voltage_proper_val( |
@@ -964,7 +990,7 @@ static __devinit int max8997_pmic_probe(struct platform_device *pdev) | |||
964 | pdata->buck2_voltage[i] / 1000 + | 990 | pdata->buck2_voltage[i] / 1000 + |
965 | buck1245_voltage_map_desc.step); | 991 | buck1245_voltage_map_desc.step); |
966 | if (ret < 0) | 992 | if (ret < 0) |
967 | goto err_alloc; | 993 | goto err_out; |
968 | 994 | ||
969 | max8997->buck5_vol[i] = ret = | 995 | max8997->buck5_vol[i] = ret = |
970 | max8997_get_voltage_proper_val( | 996 | max8997_get_voltage_proper_val( |
@@ -973,7 +999,7 @@ static __devinit int max8997_pmic_probe(struct platform_device *pdev) | |||
973 | pdata->buck5_voltage[i] / 1000 + | 999 | pdata->buck5_voltage[i] / 1000 + |
974 | buck1245_voltage_map_desc.step); | 1000 | buck1245_voltage_map_desc.step); |
975 | if (ret < 0) | 1001 | if (ret < 0) |
976 | goto err_alloc; | 1002 | goto err_out; |
977 | 1003 | ||
978 | if (max_buck1 < max8997->buck1_vol[i]) | 1004 | if (max_buck1 < max8997->buck1_vol[i]) |
979 | max_buck1 = max8997->buck1_vol[i]; | 1005 | max_buck1 = max8997->buck1_vol[i]; |
@@ -1006,7 +1032,7 @@ static __devinit int max8997_pmic_probe(struct platform_device *pdev) | |||
1006 | !gpio_is_valid(pdata->buck125_gpios[2])) { | 1032 | !gpio_is_valid(pdata->buck125_gpios[2])) { |
1007 | dev_err(&pdev->dev, "GPIO NOT VALID\n"); | 1033 | dev_err(&pdev->dev, "GPIO NOT VALID\n"); |
1008 | ret = -EINVAL; | 1034 | ret = -EINVAL; |
1009 | goto err_alloc; | 1035 | goto err_out; |
1010 | } | 1036 | } |
1011 | 1037 | ||
1012 | ret = gpio_request(pdata->buck125_gpios[0], | 1038 | ret = gpio_request(pdata->buck125_gpios[0], |
@@ -1015,7 +1041,7 @@ static __devinit int max8997_pmic_probe(struct platform_device *pdev) | |||
1015 | dev_warn(&pdev->dev, "Duplicated gpio request" | 1041 | dev_warn(&pdev->dev, "Duplicated gpio request" |
1016 | " on SET1\n"); | 1042 | " on SET1\n"); |
1017 | else if (ret) | 1043 | else if (ret) |
1018 | goto err_alloc; | 1044 | goto err_out; |
1019 | else | 1045 | else |
1020 | gpio1set = true; | 1046 | gpio1set = true; |
1021 | 1047 | ||
@@ -1027,7 +1053,7 @@ static __devinit int max8997_pmic_probe(struct platform_device *pdev) | |||
1027 | else if (ret) { | 1053 | else if (ret) { |
1028 | if (gpio1set) | 1054 | if (gpio1set) |
1029 | gpio_free(pdata->buck125_gpios[0]); | 1055 | gpio_free(pdata->buck125_gpios[0]); |
1030 | goto err_alloc; | 1056 | goto err_out; |
1031 | } else | 1057 | } else |
1032 | gpio2set = true; | 1058 | gpio2set = true; |
1033 | 1059 | ||
@@ -1041,7 +1067,7 @@ static __devinit int max8997_pmic_probe(struct platform_device *pdev) | |||
1041 | gpio_free(pdata->buck125_gpios[0]); | 1067 | gpio_free(pdata->buck125_gpios[0]); |
1042 | if (gpio2set) | 1068 | if (gpio2set) |
1043 | gpio_free(pdata->buck125_gpios[1]); | 1069 | gpio_free(pdata->buck125_gpios[1]); |
1044 | goto err_alloc; | 1070 | goto err_out; |
1045 | } | 1071 | } |
1046 | 1072 | ||
1047 | gpio_direction_output(pdata->buck125_gpios[0], | 1073 | gpio_direction_output(pdata->buck125_gpios[0], |
@@ -1110,13 +1136,9 @@ static __devinit int max8997_pmic_probe(struct platform_device *pdev) | |||
1110 | 1136 | ||
1111 | return 0; | 1137 | return 0; |
1112 | err: | 1138 | err: |
1113 | for (i = 0; i < max8997->num_regulators; i++) | 1139 | while (--i >= 0) |
1114 | if (rdev[i]) | 1140 | regulator_unregister(rdev[i]); |
1115 | regulator_unregister(rdev[i]); | 1141 | err_out: |
1116 | err_alloc: | ||
1117 | kfree(max8997->rdev); | ||
1118 | kfree(max8997); | ||
1119 | |||
1120 | return ret; | 1142 | return ret; |
1121 | } | 1143 | } |
1122 | 1144 | ||
@@ -1127,12 +1149,7 @@ static int __devexit max8997_pmic_remove(struct platform_device *pdev) | |||
1127 | int i; | 1149 | int i; |
1128 | 1150 | ||
1129 | for (i = 0; i < max8997->num_regulators; i++) | 1151 | for (i = 0; i < max8997->num_regulators; i++) |
1130 | if (rdev[i]) | 1152 | regulator_unregister(rdev[i]); |
1131 | regulator_unregister(rdev[i]); | ||
1132 | |||
1133 | kfree(max8997->rdev); | ||
1134 | kfree(max8997); | ||
1135 | |||
1136 | return 0; | 1153 | return 0; |
1137 | } | 1154 | } |
1138 | 1155 | ||
diff --git a/drivers/regulator/max8998.c b/drivers/regulator/max8998.c index 4ca22f9b52e3..18bb58b9b96e 100644 --- a/drivers/regulator/max8998.c +++ b/drivers/regulator/max8998.c | |||
@@ -28,7 +28,6 @@ | |||
28 | #include <linux/slab.h> | 28 | #include <linux/slab.h> |
29 | #include <linux/interrupt.h> | 29 | #include <linux/interrupt.h> |
30 | #include <linux/mutex.h> | 30 | #include <linux/mutex.h> |
31 | #include <linux/delay.h> | ||
32 | #include <linux/platform_device.h> | 31 | #include <linux/platform_device.h> |
33 | #include <linux/regulator/driver.h> | 32 | #include <linux/regulator/driver.h> |
34 | #include <linux/mfd/max8998.h> | 33 | #include <linux/mfd/max8998.h> |
@@ -719,16 +718,15 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev) | |||
719 | return -ENODEV; | 718 | return -ENODEV; |
720 | } | 719 | } |
721 | 720 | ||
722 | max8998 = kzalloc(sizeof(struct max8998_data), GFP_KERNEL); | 721 | max8998 = devm_kzalloc(&pdev->dev, sizeof(struct max8998_data), |
722 | GFP_KERNEL); | ||
723 | if (!max8998) | 723 | if (!max8998) |
724 | return -ENOMEM; | 724 | return -ENOMEM; |
725 | 725 | ||
726 | size = sizeof(struct regulator_dev *) * pdata->num_regulators; | 726 | size = sizeof(struct regulator_dev *) * pdata->num_regulators; |
727 | max8998->rdev = kzalloc(size, GFP_KERNEL); | 727 | max8998->rdev = devm_kzalloc(&pdev->dev, size, GFP_KERNEL); |
728 | if (!max8998->rdev) { | 728 | if (!max8998->rdev) |
729 | kfree(max8998); | ||
730 | return -ENOMEM; | 729 | return -ENOMEM; |
731 | } | ||
732 | 730 | ||
733 | rdev = max8998->rdev; | 731 | rdev = max8998->rdev; |
734 | max8998->dev = &pdev->dev; | 732 | max8998->dev = &pdev->dev; |
@@ -752,14 +750,14 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev) | |||
752 | printk(KERN_ERR "MAX8998 SET1 GPIO defined as 0 !\n"); | 750 | printk(KERN_ERR "MAX8998 SET1 GPIO defined as 0 !\n"); |
753 | WARN_ON(!pdata->buck1_set1); | 751 | WARN_ON(!pdata->buck1_set1); |
754 | ret = -EIO; | 752 | ret = -EIO; |
755 | goto err_free_mem; | 753 | goto err_out; |
756 | } | 754 | } |
757 | /* Check if SET2 is not equal to 0 */ | 755 | /* Check if SET2 is not equal to 0 */ |
758 | if (!pdata->buck1_set2) { | 756 | if (!pdata->buck1_set2) { |
759 | printk(KERN_ERR "MAX8998 SET2 GPIO defined as 0 !\n"); | 757 | printk(KERN_ERR "MAX8998 SET2 GPIO defined as 0 !\n"); |
760 | WARN_ON(!pdata->buck1_set2); | 758 | WARN_ON(!pdata->buck1_set2); |
761 | ret = -EIO; | 759 | ret = -EIO; |
762 | goto err_free_mem; | 760 | goto err_out; |
763 | } | 761 | } |
764 | 762 | ||
765 | gpio_request(pdata->buck1_set1, "MAX8998 BUCK1_SET1"); | 763 | gpio_request(pdata->buck1_set1, "MAX8998 BUCK1_SET1"); |
@@ -779,7 +777,7 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev) | |||
779 | max8998->buck1_vol[0] = i; | 777 | max8998->buck1_vol[0] = i; |
780 | ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE1, i); | 778 | ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE1, i); |
781 | if (ret) | 779 | if (ret) |
782 | goto err_free_mem; | 780 | goto err_out; |
783 | 781 | ||
784 | /* Set predefined value for BUCK1 register 2 */ | 782 | /* Set predefined value for BUCK1 register 2 */ |
785 | i = 0; | 783 | i = 0; |
@@ -791,7 +789,7 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev) | |||
791 | max8998->buck1_vol[1] = i; | 789 | max8998->buck1_vol[1] = i; |
792 | ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE2, i); | 790 | ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE2, i); |
793 | if (ret) | 791 | if (ret) |
794 | goto err_free_mem; | 792 | goto err_out; |
795 | 793 | ||
796 | /* Set predefined value for BUCK1 register 3 */ | 794 | /* Set predefined value for BUCK1 register 3 */ |
797 | i = 0; | 795 | i = 0; |
@@ -803,7 +801,7 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev) | |||
803 | max8998->buck1_vol[2] = i; | 801 | max8998->buck1_vol[2] = i; |
804 | ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE3, i); | 802 | ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE3, i); |
805 | if (ret) | 803 | if (ret) |
806 | goto err_free_mem; | 804 | goto err_out; |
807 | 805 | ||
808 | /* Set predefined value for BUCK1 register 4 */ | 806 | /* Set predefined value for BUCK1 register 4 */ |
809 | i = 0; | 807 | i = 0; |
@@ -815,7 +813,7 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev) | |||
815 | max8998->buck1_vol[3] = i; | 813 | max8998->buck1_vol[3] = i; |
816 | ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE4, i); | 814 | ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE4, i); |
817 | if (ret) | 815 | if (ret) |
818 | goto err_free_mem; | 816 | goto err_out; |
819 | 817 | ||
820 | } | 818 | } |
821 | 819 | ||
@@ -825,7 +823,7 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev) | |||
825 | printk(KERN_ERR "MAX8998 SET3 GPIO defined as 0 !\n"); | 823 | printk(KERN_ERR "MAX8998 SET3 GPIO defined as 0 !\n"); |
826 | WARN_ON(!pdata->buck2_set3); | 824 | WARN_ON(!pdata->buck2_set3); |
827 | ret = -EIO; | 825 | ret = -EIO; |
828 | goto err_free_mem; | 826 | goto err_out; |
829 | } | 827 | } |
830 | gpio_request(pdata->buck2_set3, "MAX8998 BUCK2_SET3"); | 828 | gpio_request(pdata->buck2_set3, "MAX8998 BUCK2_SET3"); |
831 | gpio_direction_output(pdata->buck2_set3, | 829 | gpio_direction_output(pdata->buck2_set3, |
@@ -840,7 +838,7 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev) | |||
840 | max8998->buck2_vol[0] = i; | 838 | max8998->buck2_vol[0] = i; |
841 | ret = max8998_write_reg(i2c, MAX8998_REG_BUCK2_VOLTAGE1, i); | 839 | ret = max8998_write_reg(i2c, MAX8998_REG_BUCK2_VOLTAGE1, i); |
842 | if (ret) | 840 | if (ret) |
843 | goto err_free_mem; | 841 | goto err_out; |
844 | 842 | ||
845 | /* BUCK2 register 2 */ | 843 | /* BUCK2 register 2 */ |
846 | i = 0; | 844 | i = 0; |
@@ -851,7 +849,7 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev) | |||
851 | max8998->buck2_vol[1] = i; | 849 | max8998->buck2_vol[1] = i; |
852 | ret = max8998_write_reg(i2c, MAX8998_REG_BUCK2_VOLTAGE2, i); | 850 | ret = max8998_write_reg(i2c, MAX8998_REG_BUCK2_VOLTAGE2, i); |
853 | if (ret) | 851 | if (ret) |
854 | goto err_free_mem; | 852 | goto err_out; |
855 | } | 853 | } |
856 | 854 | ||
857 | for (i = 0; i < pdata->num_regulators; i++) { | 855 | for (i = 0; i < pdata->num_regulators; i++) { |
@@ -881,14 +879,9 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev) | |||
881 | 879 | ||
882 | return 0; | 880 | return 0; |
883 | err: | 881 | err: |
884 | for (i = 0; i < max8998->num_regulators; i++) | 882 | while (--i >= 0) |
885 | if (rdev[i]) | 883 | regulator_unregister(rdev[i]); |
886 | regulator_unregister(rdev[i]); | 884 | err_out: |
887 | |||
888 | err_free_mem: | ||
889 | kfree(max8998->rdev); | ||
890 | kfree(max8998); | ||
891 | |||
892 | return ret; | 885 | return ret; |
893 | } | 886 | } |
894 | 887 | ||
@@ -899,12 +892,7 @@ static int __devexit max8998_pmic_remove(struct platform_device *pdev) | |||
899 | int i; | 892 | int i; |
900 | 893 | ||
901 | for (i = 0; i < max8998->num_regulators; i++) | 894 | for (i = 0; i < max8998->num_regulators; i++) |
902 | if (rdev[i]) | 895 | regulator_unregister(rdev[i]); |
903 | regulator_unregister(rdev[i]); | ||
904 | |||
905 | kfree(max8998->rdev); | ||
906 | kfree(max8998); | ||
907 | |||
908 | return 0; | 896 | return 0; |
909 | } | 897 | } |
910 | 898 | ||
diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c index 679734d26a16..56593b75168a 100644 --- a/drivers/regulator/of_regulator.c +++ b/drivers/regulator/of_regulator.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/slab.h> | 14 | #include <linux/slab.h> |
15 | #include <linux/of.h> | 15 | #include <linux/of.h> |
16 | #include <linux/regulator/machine.h> | 16 | #include <linux/regulator/machine.h> |
17 | #include <linux/regulator/of_regulator.h> | ||
17 | 18 | ||
18 | static void of_get_regulation_constraints(struct device_node *np, | 19 | static void of_get_regulation_constraints(struct device_node *np, |
19 | struct regulator_init_data **init_data) | 20 | struct regulator_init_data **init_data) |
@@ -85,3 +86,49 @@ struct regulator_init_data *of_get_regulator_init_data(struct device *dev, | |||
85 | return init_data; | 86 | return init_data; |
86 | } | 87 | } |
87 | EXPORT_SYMBOL_GPL(of_get_regulator_init_data); | 88 | EXPORT_SYMBOL_GPL(of_get_regulator_init_data); |
89 | |||
90 | /** | ||
91 | * of_regulator_match - extract regulator init data | ||
92 | * @dev: device requesting the data | ||
93 | * @node: parent device node of the regulators | ||
94 | * @matches: match table for the regulators | ||
95 | * @num_matches: number of entries in match table | ||
96 | * | ||
97 | * This function uses a match table specified by the regulator driver and | ||
98 | * looks up the corresponding init data in the device tree. Note that the | ||
99 | * match table is modified in place. | ||
100 | * | ||
101 | * Returns the number of matches found or a negative error code on failure. | ||
102 | */ | ||
103 | int of_regulator_match(struct device *dev, struct device_node *node, | ||
104 | struct of_regulator_match *matches, | ||
105 | unsigned int num_matches) | ||
106 | { | ||
107 | unsigned int count = 0; | ||
108 | unsigned int i; | ||
109 | |||
110 | if (!dev || !node) | ||
111 | return -EINVAL; | ||
112 | |||
113 | for (i = 0; i < num_matches; i++) { | ||
114 | struct of_regulator_match *match = &matches[i]; | ||
115 | struct device_node *child; | ||
116 | |||
117 | child = of_find_node_by_name(node, match->name); | ||
118 | if (!child) | ||
119 | continue; | ||
120 | |||
121 | match->init_data = of_get_regulator_init_data(dev, child); | ||
122 | if (!match->init_data) { | ||
123 | dev_err(dev, "failed to parse DT for regulator %s\n", | ||
124 | child->name); | ||
125 | return -EINVAL; | ||
126 | } | ||
127 | |||
128 | match->of_node = child; | ||
129 | count++; | ||
130 | } | ||
131 | |||
132 | return count; | ||
133 | } | ||
134 | EXPORT_SYMBOL_GPL(of_regulator_match); | ||
diff --git a/drivers/regulator/rc5t583-regulator.c b/drivers/regulator/rc5t583-regulator.c index c4adefe973ae..7951260e4cd4 100644 --- a/drivers/regulator/rc5t583-regulator.c +++ b/drivers/regulator/rc5t583-regulator.c | |||
@@ -23,7 +23,6 @@ | |||
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <linux/module.h> | 25 | #include <linux/module.h> |
26 | #include <linux/delay.h> | ||
27 | #include <linux/init.h> | 26 | #include <linux/init.h> |
28 | #include <linux/slab.h> | 27 | #include <linux/slab.h> |
29 | #include <linux/err.h> | 28 | #include <linux/err.h> |
diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c index cb53187a60d3..cf12e6351542 100644 --- a/drivers/regulator/s5m8767.c +++ b/drivers/regulator/s5m8767.c | |||
@@ -12,7 +12,6 @@ | |||
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include <linux/bug.h> | 14 | #include <linux/bug.h> |
15 | #include <linux/delay.h> | ||
16 | #include <linux/err.h> | 15 | #include <linux/err.h> |
17 | #include <linux/gpio.h> | 16 | #include <linux/gpio.h> |
18 | #include <linux/slab.h> | 17 | #include <linux/slab.h> |
@@ -347,7 +346,10 @@ static int s5m8767_convert_voltage_to_sel( | |||
347 | if (max_vol < desc->min || min_vol > desc->max) | 346 | if (max_vol < desc->min || min_vol > desc->max) |
348 | return -EINVAL; | 347 | return -EINVAL; |
349 | 348 | ||
350 | selector = (min_vol - desc->min) / desc->step; | 349 | if (min_vol < desc->min) |
350 | min_vol = desc->min; | ||
351 | |||
352 | selector = DIV_ROUND_UP(min_vol - desc->min, desc->step); | ||
351 | 353 | ||
352 | if (desc->min + desc->step * selector > max_vol) | 354 | if (desc->min + desc->step * selector > max_vol) |
353 | return -EINVAL; | 355 | return -EINVAL; |
diff --git a/drivers/regulator/tps62360-regulator.c b/drivers/regulator/tps62360-regulator.c index 0657c98352de..97fd98bad823 100644 --- a/drivers/regulator/tps62360-regulator.c +++ b/drivers/regulator/tps62360-regulator.c | |||
@@ -32,7 +32,6 @@ | |||
32 | #include <linux/regulator/tps62360.h> | 32 | #include <linux/regulator/tps62360.h> |
33 | #include <linux/gpio.h> | 33 | #include <linux/gpio.h> |
34 | #include <linux/i2c.h> | 34 | #include <linux/i2c.h> |
35 | #include <linux/delay.h> | ||
36 | #include <linux/slab.h> | 35 | #include <linux/slab.h> |
37 | #include <linux/regmap.h> | 36 | #include <linux/regmap.h> |
38 | 37 | ||
@@ -48,10 +47,10 @@ | |||
48 | 47 | ||
49 | enum chips {TPS62360, TPS62361, TPS62362, TPS62363}; | 48 | enum chips {TPS62360, TPS62361, TPS62362, TPS62363}; |
50 | 49 | ||
51 | #define TPS62360_BASE_VOLTAGE 770 | 50 | #define TPS62360_BASE_VOLTAGE 770000 |
52 | #define TPS62360_N_VOLTAGES 64 | 51 | #define TPS62360_N_VOLTAGES 64 |
53 | 52 | ||
54 | #define TPS62361_BASE_VOLTAGE 500 | 53 | #define TPS62361_BASE_VOLTAGE 500000 |
55 | #define TPS62361_N_VOLTAGES 128 | 54 | #define TPS62361_N_VOLTAGES 128 |
56 | 55 | ||
57 | /* tps 62360 chip information */ | 56 | /* tps 62360 chip information */ |
@@ -72,6 +71,7 @@ struct tps62360_chip { | |||
72 | int lru_index[4]; | 71 | int lru_index[4]; |
73 | int curr_vset_vsel[4]; | 72 | int curr_vset_vsel[4]; |
74 | int curr_vset_id; | 73 | int curr_vset_id; |
74 | int change_uv_per_us; | ||
75 | }; | 75 | }; |
76 | 76 | ||
77 | /* | 77 | /* |
@@ -97,6 +97,7 @@ static bool find_voltage_set_register(struct tps62360_chip *tps, | |||
97 | bool found = false; | 97 | bool found = false; |
98 | int new_vset_reg = tps->lru_index[3]; | 98 | int new_vset_reg = tps->lru_index[3]; |
99 | int found_index = 3; | 99 | int found_index = 3; |
100 | |||
100 | for (i = 0; i < 4; ++i) { | 101 | for (i = 0; i < 4; ++i) { |
101 | if (tps->curr_vset_vsel[tps->lru_index[i]] == req_vsel) { | 102 | if (tps->curr_vset_vsel[tps->lru_index[i]] == req_vsel) { |
102 | new_vset_reg = tps->lru_index[i]; | 103 | new_vset_reg = tps->lru_index[i]; |
@@ -115,7 +116,7 @@ update_lru_index: | |||
115 | return found; | 116 | return found; |
116 | } | 117 | } |
117 | 118 | ||
118 | static int tps62360_dcdc_get_voltage(struct regulator_dev *dev) | 119 | static int tps62360_dcdc_get_voltage_sel(struct regulator_dev *dev) |
119 | { | 120 | { |
120 | struct tps62360_chip *tps = rdev_get_drvdata(dev); | 121 | struct tps62360_chip *tps = rdev_get_drvdata(dev); |
121 | int vsel; | 122 | int vsel; |
@@ -124,12 +125,12 @@ static int tps62360_dcdc_get_voltage(struct regulator_dev *dev) | |||
124 | 125 | ||
125 | ret = regmap_read(tps->regmap, REG_VSET0 + tps->curr_vset_id, &data); | 126 | ret = regmap_read(tps->regmap, REG_VSET0 + tps->curr_vset_id, &data); |
126 | if (ret < 0) { | 127 | if (ret < 0) { |
127 | dev_err(tps->dev, "%s: Error in reading register %d\n", | 128 | dev_err(tps->dev, "%s(): register %d read failed with err %d\n", |
128 | __func__, REG_VSET0 + tps->curr_vset_id); | 129 | __func__, REG_VSET0 + tps->curr_vset_id, ret); |
129 | return ret; | 130 | return ret; |
130 | } | 131 | } |
131 | vsel = (int)data & tps->voltage_reg_mask; | 132 | vsel = (int)data & tps->voltage_reg_mask; |
132 | return (tps->voltage_base + vsel * 10) * 1000; | 133 | return vsel; |
133 | } | 134 | } |
134 | 135 | ||
135 | static int tps62360_dcdc_set_voltage(struct regulator_dev *dev, | 136 | static int tps62360_dcdc_set_voltage(struct regulator_dev *dev, |
@@ -141,17 +142,13 @@ static int tps62360_dcdc_set_voltage(struct regulator_dev *dev, | |||
141 | bool found = false; | 142 | bool found = false; |
142 | int new_vset_id = tps->curr_vset_id; | 143 | int new_vset_id = tps->curr_vset_id; |
143 | 144 | ||
144 | if (max_uV < min_uV) | 145 | if ((max_uV < min_uV) || (max_uV < tps->voltage_base)) |
145 | return -EINVAL; | ||
146 | |||
147 | if (min_uV > | ||
148 | ((tps->voltage_base + (tps->desc.n_voltages - 1) * 10) * 1000)) | ||
149 | return -EINVAL; | 146 | return -EINVAL; |
150 | 147 | ||
151 | if (max_uV < tps->voltage_base * 1000) | 148 | if (min_uV > (tps->voltage_base + (tps->desc.n_voltages - 1) * 10000)) |
152 | return -EINVAL; | 149 | return -EINVAL; |
153 | 150 | ||
154 | vsel = DIV_ROUND_UP(min_uV - (tps->voltage_base * 1000), 10000); | 151 | vsel = DIV_ROUND_UP(min_uV - tps->voltage_base, 10000); |
155 | if (selector) | 152 | if (selector) |
156 | *selector = (vsel & tps->voltage_reg_mask); | 153 | *selector = (vsel & tps->voltage_reg_mask); |
157 | 154 | ||
@@ -166,8 +163,9 @@ static int tps62360_dcdc_set_voltage(struct regulator_dev *dev, | |||
166 | ret = regmap_update_bits(tps->regmap, REG_VSET0 + new_vset_id, | 163 | ret = regmap_update_bits(tps->regmap, REG_VSET0 + new_vset_id, |
167 | tps->voltage_reg_mask, vsel); | 164 | tps->voltage_reg_mask, vsel); |
168 | if (ret < 0) { | 165 | if (ret < 0) { |
169 | dev_err(tps->dev, "%s: Error in updating register %d\n", | 166 | dev_err(tps->dev, |
170 | __func__, REG_VSET0 + new_vset_id); | 167 | "%s(): register %d update failed with err %d\n", |
168 | __func__, REG_VSET0 + new_vset_id, ret); | ||
171 | return ret; | 169 | return ret; |
172 | } | 170 | } |
173 | tps->curr_vset_id = new_vset_id; | 171 | tps->curr_vset_id = new_vset_id; |
@@ -176,8 +174,7 @@ static int tps62360_dcdc_set_voltage(struct regulator_dev *dev, | |||
176 | 174 | ||
177 | /* Select proper VSET register vio gpios */ | 175 | /* Select proper VSET register vio gpios */ |
178 | if (tps->valid_gpios) { | 176 | if (tps->valid_gpios) { |
179 | gpio_set_value_cansleep(tps->vsel0_gpio, | 177 | gpio_set_value_cansleep(tps->vsel0_gpio, new_vset_id & 0x1); |
180 | new_vset_id & 0x1); | ||
181 | gpio_set_value_cansleep(tps->vsel1_gpio, | 178 | gpio_set_value_cansleep(tps->vsel1_gpio, |
182 | (new_vset_id >> 1) & 0x1); | 179 | (new_vset_id >> 1) & 0x1); |
183 | } | 180 | } |
@@ -191,57 +188,72 @@ static int tps62360_dcdc_list_voltage(struct regulator_dev *dev, | |||
191 | 188 | ||
192 | if (selector >= tps->desc.n_voltages) | 189 | if (selector >= tps->desc.n_voltages) |
193 | return -EINVAL; | 190 | return -EINVAL; |
194 | return (tps->voltage_base + selector * 10) * 1000; | 191 | |
192 | return tps->voltage_base + selector * 10000; | ||
193 | } | ||
194 | |||
195 | static int tps62360_set_voltage_time_sel(struct regulator_dev *rdev, | ||
196 | unsigned int old_selector, unsigned int new_selector) | ||
197 | { | ||
198 | struct tps62360_chip *tps = rdev_get_drvdata(rdev); | ||
199 | int old_uV, new_uV; | ||
200 | |||
201 | old_uV = tps62360_dcdc_list_voltage(rdev, old_selector); | ||
202 | if (old_uV < 0) | ||
203 | return old_uV; | ||
204 | |||
205 | new_uV = tps62360_dcdc_list_voltage(rdev, new_selector); | ||
206 | if (new_uV < 0) | ||
207 | return new_uV; | ||
208 | |||
209 | return DIV_ROUND_UP(abs(old_uV - new_uV), tps->change_uv_per_us); | ||
195 | } | 210 | } |
196 | 211 | ||
197 | static struct regulator_ops tps62360_dcdc_ops = { | 212 | static struct regulator_ops tps62360_dcdc_ops = { |
198 | .get_voltage = tps62360_dcdc_get_voltage, | 213 | .get_voltage_sel = tps62360_dcdc_get_voltage_sel, |
199 | .set_voltage = tps62360_dcdc_set_voltage, | 214 | .set_voltage = tps62360_dcdc_set_voltage, |
200 | .list_voltage = tps62360_dcdc_list_voltage, | 215 | .list_voltage = tps62360_dcdc_list_voltage, |
216 | .set_voltage_time_sel = tps62360_set_voltage_time_sel, | ||
201 | }; | 217 | }; |
202 | 218 | ||
203 | static int tps62360_init_force_pwm(struct tps62360_chip *tps, | 219 | static int __devinit tps62360_init_force_pwm(struct tps62360_chip *tps, |
204 | struct tps62360_regulator_platform_data *pdata, | 220 | struct tps62360_regulator_platform_data *pdata, |
205 | int vset_id) | 221 | int vset_id) |
206 | { | 222 | { |
207 | unsigned int data; | ||
208 | int ret; | 223 | int ret; |
209 | ret = regmap_read(tps->regmap, REG_VSET0 + vset_id, &data); | 224 | int bit = 0; |
210 | if (ret < 0) { | 225 | |
211 | dev_err(tps->dev, "%s() fails in writing reg %d\n", | ||
212 | __func__, REG_VSET0 + vset_id); | ||
213 | return ret; | ||
214 | } | ||
215 | tps->curr_vset_vsel[vset_id] = data & tps->voltage_reg_mask; | ||
216 | if (pdata->en_force_pwm) | 226 | if (pdata->en_force_pwm) |
217 | data |= BIT(7); | 227 | bit = BIT(7); |
218 | else | 228 | |
219 | data &= ~BIT(7); | 229 | ret = regmap_update_bits(tps->regmap, REG_VSET0 + vset_id, BIT(7), bit); |
220 | ret = regmap_write(tps->regmap, REG_VSET0 + vset_id, data); | ||
221 | if (ret < 0) | 230 | if (ret < 0) |
222 | dev_err(tps->dev, "%s() fails in writing reg %d\n", | 231 | dev_err(tps->dev, |
223 | __func__, REG_VSET0 + vset_id); | 232 | "%s(): register %d update failed with err %d\n", |
233 | __func__, REG_VSET0 + vset_id, ret); | ||
224 | return ret; | 234 | return ret; |
225 | } | 235 | } |
226 | 236 | ||
227 | static int tps62360_init_dcdc(struct tps62360_chip *tps, | 237 | static int __devinit tps62360_init_dcdc(struct tps62360_chip *tps, |
228 | struct tps62360_regulator_platform_data *pdata) | 238 | struct tps62360_regulator_platform_data *pdata) |
229 | { | 239 | { |
230 | int ret; | 240 | int ret; |
231 | int i; | 241 | int i; |
242 | unsigned int ramp_ctrl; | ||
232 | 243 | ||
233 | /* Initailize internal pull up/down control */ | 244 | /* Initialize internal pull up/down control */ |
234 | if (tps->en_internal_pulldn) | 245 | if (tps->en_internal_pulldn) |
235 | ret = regmap_write(tps->regmap, REG_CONTROL, 0xE0); | 246 | ret = regmap_write(tps->regmap, REG_CONTROL, 0xE0); |
236 | else | 247 | else |
237 | ret = regmap_write(tps->regmap, REG_CONTROL, 0x0); | 248 | ret = regmap_write(tps->regmap, REG_CONTROL, 0x0); |
238 | if (ret < 0) { | 249 | if (ret < 0) { |
239 | dev_err(tps->dev, "%s() fails in writing reg %d\n", | 250 | dev_err(tps->dev, |
240 | __func__, REG_CONTROL); | 251 | "%s(): register %d write failed with err %d\n", |
252 | __func__, REG_CONTROL, ret); | ||
241 | return ret; | 253 | return ret; |
242 | } | 254 | } |
243 | 255 | ||
244 | /* Initailize force PWM mode */ | 256 | /* Initialize force PWM mode */ |
245 | if (tps->valid_gpios) { | 257 | if (tps->valid_gpios) { |
246 | for (i = 0; i < 4; ++i) { | 258 | for (i = 0; i < 4; ++i) { |
247 | ret = tps62360_init_force_pwm(tps, pdata, i); | 259 | ret = tps62360_init_force_pwm(tps, pdata, i); |
@@ -256,15 +268,33 @@ static int tps62360_init_dcdc(struct tps62360_chip *tps, | |||
256 | 268 | ||
257 | /* Reset output discharge path to reduce power consumption */ | 269 | /* Reset output discharge path to reduce power consumption */ |
258 | ret = regmap_update_bits(tps->regmap, REG_RAMPCTRL, BIT(2), 0); | 270 | ret = regmap_update_bits(tps->regmap, REG_RAMPCTRL, BIT(2), 0); |
259 | if (ret < 0) | 271 | if (ret < 0) { |
260 | dev_err(tps->dev, "%s() fails in updating reg %d\n", | 272 | dev_err(tps->dev, |
261 | __func__, REG_RAMPCTRL); | 273 | "%s(): register %d update failed with err %d\n", |
274 | __func__, REG_RAMPCTRL, ret); | ||
275 | return ret; | ||
276 | } | ||
277 | |||
278 | /* Get ramp value from ramp control register */ | ||
279 | ret = regmap_read(tps->regmap, REG_RAMPCTRL, &ramp_ctrl); | ||
280 | if (ret < 0) { | ||
281 | dev_err(tps->dev, | ||
282 | "%s(): register %d read failed with err %d\n", | ||
283 | __func__, REG_RAMPCTRL, ret); | ||
284 | return ret; | ||
285 | } | ||
286 | ramp_ctrl = (ramp_ctrl >> 4) & 0x7; | ||
287 | |||
288 | /* ramp mV/us = 32/(2^ramp_ctrl) */ | ||
289 | tps->change_uv_per_us = DIV_ROUND_UP(32000, BIT(ramp_ctrl)); | ||
262 | return ret; | 290 | return ret; |
263 | } | 291 | } |
264 | 292 | ||
265 | static const struct regmap_config tps62360_regmap_config = { | 293 | static const struct regmap_config tps62360_regmap_config = { |
266 | .reg_bits = 8, | 294 | .reg_bits = 8, |
267 | .val_bits = 8, | 295 | .val_bits = 8, |
296 | .max_register = REG_CHIPID, | ||
297 | .cache_type = REGCACHE_RBTREE, | ||
268 | }; | 298 | }; |
269 | 299 | ||
270 | static int __devinit tps62360_probe(struct i2c_client *client, | 300 | static int __devinit tps62360_probe(struct i2c_client *client, |
@@ -279,14 +309,14 @@ static int __devinit tps62360_probe(struct i2c_client *client, | |||
279 | 309 | ||
280 | pdata = client->dev.platform_data; | 310 | pdata = client->dev.platform_data; |
281 | if (!pdata) { | 311 | if (!pdata) { |
282 | dev_err(&client->dev, "%s() Err: Platform data not found\n", | 312 | dev_err(&client->dev, "%s(): Platform data not found\n", |
283 | __func__); | 313 | __func__); |
284 | return -EIO; | 314 | return -EIO; |
285 | } | 315 | } |
286 | 316 | ||
287 | tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL); | 317 | tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL); |
288 | if (!tps) { | 318 | if (!tps) { |
289 | dev_err(&client->dev, "%s() Err: Memory allocation fails\n", | 319 | dev_err(&client->dev, "%s(): Memory allocation failed\n", |
290 | __func__); | 320 | __func__); |
291 | return -ENOMEM; | 321 | return -ENOMEM; |
292 | } | 322 | } |
@@ -323,8 +353,9 @@ static int __devinit tps62360_probe(struct i2c_client *client, | |||
323 | tps->regmap = devm_regmap_init_i2c(client, &tps62360_regmap_config); | 353 | tps->regmap = devm_regmap_init_i2c(client, &tps62360_regmap_config); |
324 | if (IS_ERR(tps->regmap)) { | 354 | if (IS_ERR(tps->regmap)) { |
325 | ret = PTR_ERR(tps->regmap); | 355 | ret = PTR_ERR(tps->regmap); |
326 | dev_err(&client->dev, "%s() Err: Failed to allocate register" | 356 | dev_err(&client->dev, |
327 | "map: %d\n", __func__, ret); | 357 | "%s(): regmap allocation failed with err %d\n", |
358 | __func__, ret); | ||
328 | return ret; | 359 | return ret; |
329 | } | 360 | } |
330 | i2c_set_clientdata(client, tps); | 361 | i2c_set_clientdata(client, tps); |
@@ -335,35 +366,26 @@ static int __devinit tps62360_probe(struct i2c_client *client, | |||
335 | tps->valid_gpios = false; | 366 | tps->valid_gpios = false; |
336 | 367 | ||
337 | if (gpio_is_valid(tps->vsel0_gpio) && gpio_is_valid(tps->vsel1_gpio)) { | 368 | if (gpio_is_valid(tps->vsel0_gpio) && gpio_is_valid(tps->vsel1_gpio)) { |
338 | ret = gpio_request(tps->vsel0_gpio, "tps62360-vsel0"); | 369 | int gpio_flags; |
370 | gpio_flags = (pdata->vsel0_def_state) ? | ||
371 | GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW; | ||
372 | ret = gpio_request_one(tps->vsel0_gpio, | ||
373 | gpio_flags, "tps62360-vsel0"); | ||
339 | if (ret) { | 374 | if (ret) { |
340 | dev_err(&client->dev, | 375 | dev_err(&client->dev, |
341 | "Err: Could not obtain vsel0 GPIO %d: %d\n", | 376 | "%s(): Could not obtain vsel0 GPIO %d: %d\n", |
342 | tps->vsel0_gpio, ret); | 377 | __func__, tps->vsel0_gpio, ret); |
343 | goto err_gpio0; | ||
344 | } | ||
345 | ret = gpio_direction_output(tps->vsel0_gpio, | ||
346 | pdata->vsel0_def_state); | ||
347 | if (ret) { | ||
348 | dev_err(&client->dev, "Err: Could not set direction of" | ||
349 | "vsel0 GPIO %d: %d\n", tps->vsel0_gpio, ret); | ||
350 | gpio_free(tps->vsel0_gpio); | ||
351 | goto err_gpio0; | 378 | goto err_gpio0; |
352 | } | 379 | } |
353 | 380 | ||
354 | ret = gpio_request(tps->vsel1_gpio, "tps62360-vsel1"); | 381 | gpio_flags = (pdata->vsel1_def_state) ? |
382 | GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW; | ||
383 | ret = gpio_request_one(tps->vsel1_gpio, | ||
384 | gpio_flags, "tps62360-vsel1"); | ||
355 | if (ret) { | 385 | if (ret) { |
356 | dev_err(&client->dev, | 386 | dev_err(&client->dev, |
357 | "Err: Could not obtain vsel1 GPIO %d: %d\n", | 387 | "%s(): Could not obtain vsel1 GPIO %d: %d\n", |
358 | tps->vsel1_gpio, ret); | 388 | __func__, tps->vsel1_gpio, ret); |
359 | goto err_gpio1; | ||
360 | } | ||
361 | ret = gpio_direction_output(tps->vsel1_gpio, | ||
362 | pdata->vsel1_def_state); | ||
363 | if (ret) { | ||
364 | dev_err(&client->dev, "Err: Could not set direction of" | ||
365 | "vsel1 GPIO %d: %d\n", tps->vsel1_gpio, ret); | ||
366 | gpio_free(tps->vsel1_gpio); | ||
367 | goto err_gpio1; | 389 | goto err_gpio1; |
368 | } | 390 | } |
369 | tps->valid_gpios = true; | 391 | tps->valid_gpios = true; |
@@ -380,7 +402,7 @@ static int __devinit tps62360_probe(struct i2c_client *client, | |||
380 | 402 | ||
381 | ret = tps62360_init_dcdc(tps, pdata); | 403 | ret = tps62360_init_dcdc(tps, pdata); |
382 | if (ret < 0) { | 404 | if (ret < 0) { |
383 | dev_err(tps->dev, "%s() Err: Init fails with = %d\n", | 405 | dev_err(tps->dev, "%s(): Init failed with err = %d\n", |
384 | __func__, ret); | 406 | __func__, ret); |
385 | goto err_init; | 407 | goto err_init; |
386 | } | 408 | } |
@@ -392,8 +414,9 @@ static int __devinit tps62360_probe(struct i2c_client *client, | |||
392 | /* Register the regulators */ | 414 | /* Register the regulators */ |
393 | rdev = regulator_register(&tps->desc, &config); | 415 | rdev = regulator_register(&tps->desc, &config); |
394 | if (IS_ERR(rdev)) { | 416 | if (IS_ERR(rdev)) { |
395 | dev_err(tps->dev, "%s() Err: Failed to register %s\n", | 417 | dev_err(tps->dev, |
396 | __func__, id->name); | 418 | "%s(): regulator register failed with err %s\n", |
419 | __func__, id->name); | ||
397 | ret = PTR_ERR(rdev); | 420 | ret = PTR_ERR(rdev); |
398 | goto err_init; | 421 | goto err_init; |
399 | } | 422 | } |
@@ -442,8 +465,9 @@ static void tps62360_shutdown(struct i2c_client *client) | |||
442 | /* Configure the output discharge path */ | 465 | /* Configure the output discharge path */ |
443 | st = regmap_update_bits(tps->regmap, REG_RAMPCTRL, BIT(2), BIT(2)); | 466 | st = regmap_update_bits(tps->regmap, REG_RAMPCTRL, BIT(2), BIT(2)); |
444 | if (st < 0) | 467 | if (st < 0) |
445 | dev_err(tps->dev, "%s() fails in updating reg %d\n", | 468 | dev_err(tps->dev, |
446 | __func__, REG_RAMPCTRL); | 469 | "%s(): register %d update failed with err %d\n", |
470 | __func__, REG_RAMPCTRL, st); | ||
447 | } | 471 | } |
448 | 472 | ||
449 | static const struct i2c_device_id tps62360_id[] = { | 473 | static const struct i2c_device_id tps62360_id[] = { |
diff --git a/drivers/regulator/tps65023-regulator.c b/drivers/regulator/tps65023-regulator.c index a1fd65682f4c..f841bd0db6aa 100644 --- a/drivers/regulator/tps65023-regulator.c +++ b/drivers/regulator/tps65023-regulator.c | |||
@@ -23,7 +23,6 @@ | |||
23 | #include <linux/regulator/driver.h> | 23 | #include <linux/regulator/driver.h> |
24 | #include <linux/regulator/machine.h> | 24 | #include <linux/regulator/machine.h> |
25 | #include <linux/i2c.h> | 25 | #include <linux/i2c.h> |
26 | #include <linux/delay.h> | ||
27 | #include <linux/slab.h> | 26 | #include <linux/slab.h> |
28 | #include <linux/regmap.h> | 27 | #include <linux/regmap.h> |
29 | 28 | ||
diff --git a/drivers/regulator/tps6507x-regulator.c b/drivers/regulator/tps6507x-regulator.c index 8e432004b949..da38be1016aa 100644 --- a/drivers/regulator/tps6507x-regulator.c +++ b/drivers/regulator/tps6507x-regulator.c | |||
@@ -23,7 +23,6 @@ | |||
23 | #include <linux/regulator/driver.h> | 23 | #include <linux/regulator/driver.h> |
24 | #include <linux/regulator/machine.h> | 24 | #include <linux/regulator/machine.h> |
25 | #include <linux/regulator/tps6507x.h> | 25 | #include <linux/regulator/tps6507x.h> |
26 | #include <linux/delay.h> | ||
27 | #include <linux/slab.h> | 26 | #include <linux/slab.h> |
28 | #include <linux/mfd/tps6507x.h> | 27 | #include <linux/mfd/tps6507x.h> |
29 | 28 | ||
@@ -283,7 +282,7 @@ static int tps6507x_pmic_disable(struct regulator_dev *dev) | |||
283 | 1 << shift); | 282 | 1 << shift); |
284 | } | 283 | } |
285 | 284 | ||
286 | static int tps6507x_pmic_get_voltage(struct regulator_dev *dev) | 285 | static int tps6507x_pmic_get_voltage_sel(struct regulator_dev *dev) |
287 | { | 286 | { |
288 | struct tps6507x_pmic *tps = rdev_get_drvdata(dev); | 287 | struct tps6507x_pmic *tps = rdev_get_drvdata(dev); |
289 | int data, rid = rdev_get_id(dev); | 288 | int data, rid = rdev_get_id(dev); |
@@ -325,7 +324,7 @@ static int tps6507x_pmic_get_voltage(struct regulator_dev *dev) | |||
325 | return data; | 324 | return data; |
326 | 325 | ||
327 | data &= mask; | 326 | data &= mask; |
328 | return tps->info[rid]->table[data] * 1000; | 327 | return data; |
329 | } | 328 | } |
330 | 329 | ||
331 | static int tps6507x_pmic_set_voltage_sel(struct regulator_dev *dev, | 330 | static int tps6507x_pmic_set_voltage_sel(struct regulator_dev *dev, |
@@ -395,7 +394,7 @@ static struct regulator_ops tps6507x_pmic_ops = { | |||
395 | .is_enabled = tps6507x_pmic_is_enabled, | 394 | .is_enabled = tps6507x_pmic_is_enabled, |
396 | .enable = tps6507x_pmic_enable, | 395 | .enable = tps6507x_pmic_enable, |
397 | .disable = tps6507x_pmic_disable, | 396 | .disable = tps6507x_pmic_disable, |
398 | .get_voltage = tps6507x_pmic_get_voltage, | 397 | .get_voltage_sel = tps6507x_pmic_get_voltage_sel, |
399 | .set_voltage_sel = tps6507x_pmic_set_voltage_sel, | 398 | .set_voltage_sel = tps6507x_pmic_set_voltage_sel, |
400 | .list_voltage = tps6507x_pmic_list_voltage, | 399 | .list_voltage = tps6507x_pmic_list_voltage, |
401 | }; | 400 | }; |
diff --git a/drivers/regulator/tps65090-regulator.c b/drivers/regulator/tps65090-regulator.c index 661fcecd1cec..001ad554ac62 100644 --- a/drivers/regulator/tps65090-regulator.c +++ b/drivers/regulator/tps65090-regulator.c | |||
@@ -17,7 +17,6 @@ | |||
17 | */ | 17 | */ |
18 | 18 | ||
19 | #include <linux/module.h> | 19 | #include <linux/module.h> |
20 | #include <linux/delay.h> | ||
21 | #include <linux/init.h> | 20 | #include <linux/init.h> |
22 | #include <linux/slab.h> | 21 | #include <linux/slab.h> |
23 | #include <linux/err.h> | 22 | #include <linux/err.h> |
diff --git a/drivers/regulator/tps6586x-regulator.c b/drivers/regulator/tps6586x-regulator.c index 9a4029a446d3..c0a214575380 100644 --- a/drivers/regulator/tps6586x-regulator.c +++ b/drivers/regulator/tps6586x-regulator.c | |||
@@ -363,6 +363,7 @@ static int __devinit tps6586x_regulator_probe(struct platform_device *pdev) | |||
363 | return err; | 363 | return err; |
364 | 364 | ||
365 | config.dev = &pdev->dev; | 365 | config.dev = &pdev->dev; |
366 | config.of_node = pdev->dev.of_node; | ||
366 | config.init_data = pdev->dev.platform_data; | 367 | config.init_data = pdev->dev.platform_data; |
367 | config.driver_data = ri; | 368 | config.driver_data = ri; |
368 | 369 | ||
diff --git a/drivers/regulator/tps65910-regulator.c b/drivers/regulator/tps65910-regulator.c index 43bc6c6bc8f8..5ee7e4bd8b58 100644 --- a/drivers/regulator/tps65910-regulator.c +++ b/drivers/regulator/tps65910-regulator.c | |||
@@ -20,7 +20,6 @@ | |||
20 | #include <linux/platform_device.h> | 20 | #include <linux/platform_device.h> |
21 | #include <linux/regulator/driver.h> | 21 | #include <linux/regulator/driver.h> |
22 | #include <linux/regulator/machine.h> | 22 | #include <linux/regulator/machine.h> |
23 | #include <linux/delay.h> | ||
24 | #include <linux/slab.h> | 23 | #include <linux/slab.h> |
25 | #include <linux/gpio.h> | 24 | #include <linux/gpio.h> |
26 | #include <linux/mfd/tps65910.h> | 25 | #include <linux/mfd/tps65910.h> |
@@ -579,10 +578,10 @@ static int tps65910_get_voltage_dcdc_sel(struct regulator_dev *dev) | |||
579 | return -EINVAL; | 578 | return -EINVAL; |
580 | } | 579 | } |
581 | 580 | ||
582 | static int tps65910_get_voltage(struct regulator_dev *dev) | 581 | static int tps65910_get_voltage_sel(struct regulator_dev *dev) |
583 | { | 582 | { |
584 | struct tps65910_reg *pmic = rdev_get_drvdata(dev); | 583 | struct tps65910_reg *pmic = rdev_get_drvdata(dev); |
585 | int reg, value, id = rdev_get_id(dev), voltage = 0; | 584 | int reg, value, id = rdev_get_id(dev); |
586 | 585 | ||
587 | reg = pmic->get_ctrl_reg(id); | 586 | reg = pmic->get_ctrl_reg(id); |
588 | if (reg < 0) | 587 | if (reg < 0) |
@@ -609,9 +608,7 @@ static int tps65910_get_voltage(struct regulator_dev *dev) | |||
609 | return -EINVAL; | 608 | return -EINVAL; |
610 | } | 609 | } |
611 | 610 | ||
612 | voltage = pmic->info[id]->voltage_table[value] * 1000; | 611 | return value; |
613 | |||
614 | return voltage; | ||
615 | } | 612 | } |
616 | 613 | ||
617 | static int tps65910_get_voltage_vdd3(struct regulator_dev *dev) | 614 | static int tps65910_get_voltage_vdd3(struct regulator_dev *dev) |
@@ -619,10 +616,10 @@ static int tps65910_get_voltage_vdd3(struct regulator_dev *dev) | |||
619 | return 5 * 1000 * 1000; | 616 | return 5 * 1000 * 1000; |
620 | } | 617 | } |
621 | 618 | ||
622 | static int tps65911_get_voltage(struct regulator_dev *dev) | 619 | static int tps65911_get_voltage_sel(struct regulator_dev *dev) |
623 | { | 620 | { |
624 | struct tps65910_reg *pmic = rdev_get_drvdata(dev); | 621 | struct tps65910_reg *pmic = rdev_get_drvdata(dev); |
625 | int step_mv, id = rdev_get_id(dev); | 622 | int id = rdev_get_id(dev); |
626 | u8 value, reg; | 623 | u8 value, reg; |
627 | 624 | ||
628 | reg = pmic->get_ctrl_reg(id); | 625 | reg = pmic->get_ctrl_reg(id); |
@@ -635,13 +632,6 @@ static int tps65911_get_voltage(struct regulator_dev *dev) | |||
635 | case TPS65911_REG_LDO4: | 632 | case TPS65911_REG_LDO4: |
636 | value &= LDO1_SEL_MASK; | 633 | value &= LDO1_SEL_MASK; |
637 | value >>= LDO_SEL_SHIFT; | 634 | value >>= LDO_SEL_SHIFT; |
638 | /* The first 5 values of the selector correspond to 1V */ | ||
639 | if (value < 5) | ||
640 | value = 0; | ||
641 | else | ||
642 | value -= 4; | ||
643 | |||
644 | step_mv = 50; | ||
645 | break; | 635 | break; |
646 | case TPS65911_REG_LDO3: | 636 | case TPS65911_REG_LDO3: |
647 | case TPS65911_REG_LDO5: | 637 | case TPS65911_REG_LDO5: |
@@ -650,23 +640,16 @@ static int tps65911_get_voltage(struct regulator_dev *dev) | |||
650 | case TPS65911_REG_LDO8: | 640 | case TPS65911_REG_LDO8: |
651 | value &= LDO3_SEL_MASK; | 641 | value &= LDO3_SEL_MASK; |
652 | value >>= LDO_SEL_SHIFT; | 642 | value >>= LDO_SEL_SHIFT; |
653 | /* The first 3 values of the selector correspond to 1V */ | ||
654 | if (value < 3) | ||
655 | value = 0; | ||
656 | else | ||
657 | value -= 2; | ||
658 | |||
659 | step_mv = 100; | ||
660 | break; | 643 | break; |
661 | case TPS65910_REG_VIO: | 644 | case TPS65910_REG_VIO: |
662 | value &= LDO_SEL_MASK; | 645 | value &= LDO_SEL_MASK; |
663 | value >>= LDO_SEL_SHIFT; | 646 | value >>= LDO_SEL_SHIFT; |
664 | return pmic->info[id]->voltage_table[value] * 1000; | 647 | break; |
665 | default: | 648 | default: |
666 | return -EINVAL; | 649 | return -EINVAL; |
667 | } | 650 | } |
668 | 651 | ||
669 | return (LDO_MIN_VOLT + value * step_mv) * 1000; | 652 | return value; |
670 | } | 653 | } |
671 | 654 | ||
672 | static int tps65910_set_voltage_dcdc_sel(struct regulator_dev *dev, | 655 | static int tps65910_set_voltage_dcdc_sel(struct regulator_dev *dev, |
@@ -902,7 +885,7 @@ static struct regulator_ops tps65910_ops = { | |||
902 | .enable_time = tps65910_enable_time, | 885 | .enable_time = tps65910_enable_time, |
903 | .set_mode = tps65910_set_mode, | 886 | .set_mode = tps65910_set_mode, |
904 | .get_mode = tps65910_get_mode, | 887 | .get_mode = tps65910_get_mode, |
905 | .get_voltage = tps65910_get_voltage, | 888 | .get_voltage_sel = tps65910_get_voltage_sel, |
906 | .set_voltage_sel = tps65910_set_voltage_sel, | 889 | .set_voltage_sel = tps65910_set_voltage_sel, |
907 | .list_voltage = tps65910_list_voltage, | 890 | .list_voltage = tps65910_list_voltage, |
908 | }; | 891 | }; |
@@ -914,7 +897,7 @@ static struct regulator_ops tps65911_ops = { | |||
914 | .enable_time = tps65910_enable_time, | 897 | .enable_time = tps65910_enable_time, |
915 | .set_mode = tps65910_set_mode, | 898 | .set_mode = tps65910_set_mode, |
916 | .get_mode = tps65910_get_mode, | 899 | .get_mode = tps65910_get_mode, |
917 | .get_voltage = tps65911_get_voltage, | 900 | .get_voltage_sel = tps65911_get_voltage_sel, |
918 | .set_voltage_sel = tps65911_set_voltage_sel, | 901 | .set_voltage_sel = tps65911_set_voltage_sel, |
919 | .list_voltage = tps65911_list_voltage, | 902 | .list_voltage = tps65911_list_voltage, |
920 | }; | 903 | }; |
diff --git a/drivers/regulator/tps65912-regulator.c b/drivers/regulator/tps65912-regulator.c index af335dd35903..18b2a1dcb4b5 100644 --- a/drivers/regulator/tps65912-regulator.c +++ b/drivers/regulator/tps65912-regulator.c | |||
@@ -20,7 +20,6 @@ | |||
20 | #include <linux/platform_device.h> | 20 | #include <linux/platform_device.h> |
21 | #include <linux/regulator/driver.h> | 21 | #include <linux/regulator/driver.h> |
22 | #include <linux/regulator/machine.h> | 22 | #include <linux/regulator/machine.h> |
23 | #include <linux/delay.h> | ||
24 | #include <linux/slab.h> | 23 | #include <linux/slab.h> |
25 | #include <linux/gpio.h> | 24 | #include <linux/gpio.h> |
26 | #include <linux/mfd/tps65912.h> | 25 | #include <linux/mfd/tps65912.h> |
@@ -406,7 +405,7 @@ static int tps65912_list_voltage(struct regulator_dev *dev, unsigned selector) | |||
406 | return voltage; | 405 | return voltage; |
407 | } | 406 | } |
408 | 407 | ||
409 | static int tps65912_get_voltage(struct regulator_dev *dev) | 408 | static int tps65912_get_voltage_sel(struct regulator_dev *dev) |
410 | { | 409 | { |
411 | struct tps65912_reg *pmic = rdev_get_drvdata(dev); | 410 | struct tps65912_reg *pmic = rdev_get_drvdata(dev); |
412 | struct tps65912 *mfd = pmic->mfd; | 411 | struct tps65912 *mfd = pmic->mfd; |
@@ -420,7 +419,7 @@ static int tps65912_get_voltage(struct regulator_dev *dev) | |||
420 | vsel = tps65912_reg_read(mfd, reg); | 419 | vsel = tps65912_reg_read(mfd, reg); |
421 | vsel &= 0x3F; | 420 | vsel &= 0x3F; |
422 | 421 | ||
423 | return tps65912_list_voltage(dev, vsel); | 422 | return vsel; |
424 | } | 423 | } |
425 | 424 | ||
426 | static int tps65912_set_voltage_sel(struct regulator_dev *dev, | 425 | static int tps65912_set_voltage_sel(struct regulator_dev *dev, |
@@ -445,7 +444,7 @@ static struct regulator_ops tps65912_ops_dcdc = { | |||
445 | .disable = tps65912_reg_disable, | 444 | .disable = tps65912_reg_disable, |
446 | .set_mode = tps65912_set_mode, | 445 | .set_mode = tps65912_set_mode, |
447 | .get_mode = tps65912_get_mode, | 446 | .get_mode = tps65912_get_mode, |
448 | .get_voltage = tps65912_get_voltage, | 447 | .get_voltage_sel = tps65912_get_voltage_sel, |
449 | .set_voltage_sel = tps65912_set_voltage_sel, | 448 | .set_voltage_sel = tps65912_set_voltage_sel, |
450 | .list_voltage = tps65912_list_voltage, | 449 | .list_voltage = tps65912_list_voltage, |
451 | }; | 450 | }; |
@@ -455,7 +454,7 @@ static struct regulator_ops tps65912_ops_ldo = { | |||
455 | .is_enabled = tps65912_reg_is_enabled, | 454 | .is_enabled = tps65912_reg_is_enabled, |
456 | .enable = tps65912_reg_enable, | 455 | .enable = tps65912_reg_enable, |
457 | .disable = tps65912_reg_disable, | 456 | .disable = tps65912_reg_disable, |
458 | .get_voltage = tps65912_get_voltage, | 457 | .get_voltage_sel = tps65912_get_voltage_sel, |
459 | .set_voltage_sel = tps65912_set_voltage_sel, | 458 | .set_voltage_sel = tps65912_set_voltage_sel, |
460 | .list_voltage = tps65912_list_voltage, | 459 | .list_voltage = tps65912_list_voltage, |
461 | }; | 460 | }; |
diff --git a/drivers/regulator/twl-regulator.c b/drivers/regulator/twl-regulator.c index 7385b273a10f..c7390711d954 100644 --- a/drivers/regulator/twl-regulator.c +++ b/drivers/regulator/twl-regulator.c | |||
@@ -12,7 +12,6 @@ | |||
12 | #include <linux/module.h> | 12 | #include <linux/module.h> |
13 | #include <linux/init.h> | 13 | #include <linux/init.h> |
14 | #include <linux/err.h> | 14 | #include <linux/err.h> |
15 | #include <linux/delay.h> | ||
16 | #include <linux/platform_device.h> | 15 | #include <linux/platform_device.h> |
17 | #include <linux/of.h> | 16 | #include <linux/of.h> |
18 | #include <linux/of_device.h> | 17 | #include <linux/of_device.h> |
@@ -396,14 +395,12 @@ static int twl6030reg_set_mode(struct regulator_dev *rdev, unsigned mode) | |||
396 | * VAUX3 at 3V is incorrectly listed in some TI manuals as unsupported. | 395 | * VAUX3 at 3V is incorrectly listed in some TI manuals as unsupported. |
397 | * TI are revising the twl5030/tps659x0 specs to support that 3.0V setting. | 396 | * TI are revising the twl5030/tps659x0 specs to support that 3.0V setting. |
398 | */ | 397 | */ |
399 | #ifdef CONFIG_TWL4030_ALLOW_UNSUPPORTED | ||
400 | #define UNSUP_MASK 0x0000 | ||
401 | #else | ||
402 | #define UNSUP_MASK 0x8000 | 398 | #define UNSUP_MASK 0x8000 |
403 | #endif | ||
404 | 399 | ||
405 | #define UNSUP(x) (UNSUP_MASK | (x)) | 400 | #define UNSUP(x) (UNSUP_MASK | (x)) |
406 | #define IS_UNSUP(x) (UNSUP_MASK & (x)) | 401 | #define IS_UNSUP(info, x) \ |
402 | ((UNSUP_MASK & (x)) && \ | ||
403 | !((info)->features & TWL4030_ALLOW_UNSUPPORTED)) | ||
407 | #define LDO_MV(x) (~UNSUP_MASK & (x)) | 404 | #define LDO_MV(x) (~UNSUP_MASK & (x)) |
408 | 405 | ||
409 | 406 | ||
@@ -477,7 +474,7 @@ static int twl4030ldo_list_voltage(struct regulator_dev *rdev, unsigned index) | |||
477 | struct twlreg_info *info = rdev_get_drvdata(rdev); | 474 | struct twlreg_info *info = rdev_get_drvdata(rdev); |
478 | int mV = info->table[index]; | 475 | int mV = info->table[index]; |
479 | 476 | ||
480 | return IS_UNSUP(mV) ? 0 : (LDO_MV(mV) * 1000); | 477 | return IS_UNSUP(info, mV) ? 0 : (LDO_MV(mV) * 1000); |
481 | } | 478 | } |
482 | 479 | ||
483 | static int | 480 | static int |
diff --git a/drivers/regulator/userspace-consumer.c b/drivers/regulator/userspace-consumer.c index 518667ef9a0d..a7c8deb5f28f 100644 --- a/drivers/regulator/userspace-consumer.c +++ b/drivers/regulator/userspace-consumer.c | |||
@@ -115,7 +115,9 @@ static int regulator_userspace_consumer_probe(struct platform_device *pdev) | |||
115 | if (!pdata) | 115 | if (!pdata) |
116 | return -EINVAL; | 116 | return -EINVAL; |
117 | 117 | ||
118 | drvdata = kzalloc(sizeof(struct userspace_consumer_data), GFP_KERNEL); | 118 | drvdata = devm_kzalloc(&pdev->dev, |
119 | sizeof(struct userspace_consumer_data), | ||
120 | GFP_KERNEL); | ||
119 | if (drvdata == NULL) | 121 | if (drvdata == NULL) |
120 | return -ENOMEM; | 122 | return -ENOMEM; |
121 | 123 | ||
@@ -125,16 +127,16 @@ static int regulator_userspace_consumer_probe(struct platform_device *pdev) | |||
125 | 127 | ||
126 | mutex_init(&drvdata->lock); | 128 | mutex_init(&drvdata->lock); |
127 | 129 | ||
128 | ret = regulator_bulk_get(&pdev->dev, drvdata->num_supplies, | 130 | ret = devm_regulator_bulk_get(&pdev->dev, drvdata->num_supplies, |
129 | drvdata->supplies); | 131 | drvdata->supplies); |
130 | if (ret) { | 132 | if (ret) { |
131 | dev_err(&pdev->dev, "Failed to get supplies: %d\n", ret); | 133 | dev_err(&pdev->dev, "Failed to get supplies: %d\n", ret); |
132 | goto err_alloc_supplies; | 134 | return ret; |
133 | } | 135 | } |
134 | 136 | ||
135 | ret = sysfs_create_group(&pdev->dev.kobj, &attr_group); | 137 | ret = sysfs_create_group(&pdev->dev.kobj, &attr_group); |
136 | if (ret != 0) | 138 | if (ret != 0) |
137 | goto err_create_attrs; | 139 | return ret; |
138 | 140 | ||
139 | if (pdata->init_on) { | 141 | if (pdata->init_on) { |
140 | ret = regulator_bulk_enable(drvdata->num_supplies, | 142 | ret = regulator_bulk_enable(drvdata->num_supplies, |
@@ -154,11 +156,6 @@ static int regulator_userspace_consumer_probe(struct platform_device *pdev) | |||
154 | err_enable: | 156 | err_enable: |
155 | sysfs_remove_group(&pdev->dev.kobj, &attr_group); | 157 | sysfs_remove_group(&pdev->dev.kobj, &attr_group); |
156 | 158 | ||
157 | err_create_attrs: | ||
158 | regulator_bulk_free(drvdata->num_supplies, drvdata->supplies); | ||
159 | |||
160 | err_alloc_supplies: | ||
161 | kfree(drvdata); | ||
162 | return ret; | 159 | return ret; |
163 | } | 160 | } |
164 | 161 | ||
@@ -171,9 +168,6 @@ static int regulator_userspace_consumer_remove(struct platform_device *pdev) | |||
171 | if (data->enabled) | 168 | if (data->enabled) |
172 | regulator_bulk_disable(data->num_supplies, data->supplies); | 169 | regulator_bulk_disable(data->num_supplies, data->supplies); |
173 | 170 | ||
174 | regulator_bulk_free(data->num_supplies, data->supplies); | ||
175 | kfree(data); | ||
176 | |||
177 | return 0; | 171 | return 0; |
178 | } | 172 | } |
179 | 173 | ||
diff --git a/drivers/regulator/virtual.c b/drivers/regulator/virtual.c index ee0b161c998f..c038e7422538 100644 --- a/drivers/regulator/virtual.c +++ b/drivers/regulator/virtual.c | |||
@@ -121,7 +121,7 @@ static ssize_t set_min_uV(struct device *dev, struct device_attribute *attr, | |||
121 | struct virtual_consumer_data *data = dev_get_drvdata(dev); | 121 | struct virtual_consumer_data *data = dev_get_drvdata(dev); |
122 | long val; | 122 | long val; |
123 | 123 | ||
124 | if (strict_strtol(buf, 10, &val) != 0) | 124 | if (kstrtol(buf, 10, &val) != 0) |
125 | return count; | 125 | return count; |
126 | 126 | ||
127 | mutex_lock(&data->lock); | 127 | mutex_lock(&data->lock); |
@@ -147,7 +147,7 @@ static ssize_t set_max_uV(struct device *dev, struct device_attribute *attr, | |||
147 | struct virtual_consumer_data *data = dev_get_drvdata(dev); | 147 | struct virtual_consumer_data *data = dev_get_drvdata(dev); |
148 | long val; | 148 | long val; |
149 | 149 | ||
150 | if (strict_strtol(buf, 10, &val) != 0) | 150 | if (kstrtol(buf, 10, &val) != 0) |
151 | return count; | 151 | return count; |
152 | 152 | ||
153 | mutex_lock(&data->lock); | 153 | mutex_lock(&data->lock); |
@@ -173,7 +173,7 @@ static ssize_t set_min_uA(struct device *dev, struct device_attribute *attr, | |||
173 | struct virtual_consumer_data *data = dev_get_drvdata(dev); | 173 | struct virtual_consumer_data *data = dev_get_drvdata(dev); |
174 | long val; | 174 | long val; |
175 | 175 | ||
176 | if (strict_strtol(buf, 10, &val) != 0) | 176 | if (kstrtol(buf, 10, &val) != 0) |
177 | return count; | 177 | return count; |
178 | 178 | ||
179 | mutex_lock(&data->lock); | 179 | mutex_lock(&data->lock); |
@@ -199,7 +199,7 @@ static ssize_t set_max_uA(struct device *dev, struct device_attribute *attr, | |||
199 | struct virtual_consumer_data *data = dev_get_drvdata(dev); | 199 | struct virtual_consumer_data *data = dev_get_drvdata(dev); |
200 | long val; | 200 | long val; |
201 | 201 | ||
202 | if (strict_strtol(buf, 10, &val) != 0) | 202 | if (kstrtol(buf, 10, &val) != 0) |
203 | return count; | 203 | return count; |
204 | 204 | ||
205 | mutex_lock(&data->lock); | 205 | mutex_lock(&data->lock); |
@@ -291,18 +291,19 @@ static int __devinit regulator_virtual_probe(struct platform_device *pdev) | |||
291 | struct virtual_consumer_data *drvdata; | 291 | struct virtual_consumer_data *drvdata; |
292 | int ret; | 292 | int ret; |
293 | 293 | ||
294 | drvdata = kzalloc(sizeof(struct virtual_consumer_data), GFP_KERNEL); | 294 | drvdata = devm_kzalloc(&pdev->dev, sizeof(struct virtual_consumer_data), |
295 | GFP_KERNEL); | ||
295 | if (drvdata == NULL) | 296 | if (drvdata == NULL) |
296 | return -ENOMEM; | 297 | return -ENOMEM; |
297 | 298 | ||
298 | mutex_init(&drvdata->lock); | 299 | mutex_init(&drvdata->lock); |
299 | 300 | ||
300 | drvdata->regulator = regulator_get(&pdev->dev, reg_id); | 301 | drvdata->regulator = devm_regulator_get(&pdev->dev, reg_id); |
301 | if (IS_ERR(drvdata->regulator)) { | 302 | if (IS_ERR(drvdata->regulator)) { |
302 | ret = PTR_ERR(drvdata->regulator); | 303 | ret = PTR_ERR(drvdata->regulator); |
303 | dev_err(&pdev->dev, "Failed to obtain supply '%s': %d\n", | 304 | dev_err(&pdev->dev, "Failed to obtain supply '%s': %d\n", |
304 | reg_id, ret); | 305 | reg_id, ret); |
305 | goto err; | 306 | return ret; |
306 | } | 307 | } |
307 | 308 | ||
308 | ret = sysfs_create_group(&pdev->dev.kobj, | 309 | ret = sysfs_create_group(&pdev->dev.kobj, |
@@ -310,7 +311,7 @@ static int __devinit regulator_virtual_probe(struct platform_device *pdev) | |||
310 | if (ret != 0) { | 311 | if (ret != 0) { |
311 | dev_err(&pdev->dev, | 312 | dev_err(&pdev->dev, |
312 | "Failed to create attribute group: %d\n", ret); | 313 | "Failed to create attribute group: %d\n", ret); |
313 | goto err_regulator; | 314 | return ret; |
314 | } | 315 | } |
315 | 316 | ||
316 | drvdata->mode = regulator_get_mode(drvdata->regulator); | 317 | drvdata->mode = regulator_get_mode(drvdata->regulator); |
@@ -318,12 +319,6 @@ static int __devinit regulator_virtual_probe(struct platform_device *pdev) | |||
318 | platform_set_drvdata(pdev, drvdata); | 319 | platform_set_drvdata(pdev, drvdata); |
319 | 320 | ||
320 | return 0; | 321 | return 0; |
321 | |||
322 | err_regulator: | ||
323 | regulator_put(drvdata->regulator); | ||
324 | err: | ||
325 | kfree(drvdata); | ||
326 | return ret; | ||
327 | } | 322 | } |
328 | 323 | ||
329 | static int __devexit regulator_virtual_remove(struct platform_device *pdev) | 324 | static int __devexit regulator_virtual_remove(struct platform_device *pdev) |
@@ -334,9 +329,6 @@ static int __devexit regulator_virtual_remove(struct platform_device *pdev) | |||
334 | 329 | ||
335 | if (drvdata->enabled) | 330 | if (drvdata->enabled) |
336 | regulator_disable(drvdata->regulator); | 331 | regulator_disable(drvdata->regulator); |
337 | regulator_put(drvdata->regulator); | ||
338 | |||
339 | kfree(drvdata); | ||
340 | 332 | ||
341 | platform_set_drvdata(pdev, NULL); | 333 | platform_set_drvdata(pdev, NULL); |
342 | 334 | ||
diff --git a/drivers/regulator/wm831x-dcdc.c b/drivers/regulator/wm831x-dcdc.c index 318b9631155c..8710cfb0c19b 100644 --- a/drivers/regulator/wm831x-dcdc.c +++ b/drivers/regulator/wm831x-dcdc.c | |||
@@ -35,7 +35,7 @@ | |||
35 | #define WM831X_DCDC_MODE_IDLE 2 | 35 | #define WM831X_DCDC_MODE_IDLE 2 |
36 | #define WM831X_DCDC_MODE_STANDBY 3 | 36 | #define WM831X_DCDC_MODE_STANDBY 3 |
37 | 37 | ||
38 | #define WM831X_DCDC_MAX_NAME 6 | 38 | #define WM831X_DCDC_MAX_NAME 9 |
39 | 39 | ||
40 | /* Register offsets in control block */ | 40 | /* Register offsets in control block */ |
41 | #define WM831X_DCDC_CONTROL_1 0 | 41 | #define WM831X_DCDC_CONTROL_1 0 |
@@ -50,6 +50,7 @@ | |||
50 | 50 | ||
51 | struct wm831x_dcdc { | 51 | struct wm831x_dcdc { |
52 | char name[WM831X_DCDC_MAX_NAME]; | 52 | char name[WM831X_DCDC_MAX_NAME]; |
53 | char supply_name[WM831X_DCDC_MAX_NAME]; | ||
53 | struct regulator_desc desc; | 54 | struct regulator_desc desc; |
54 | int base; | 55 | int base; |
55 | struct wm831x *wm831x; | 56 | struct wm831x *wm831x; |
@@ -402,23 +403,17 @@ static __devinit void wm831x_buckv_dvs_init(struct wm831x_dcdc *dcdc, | |||
402 | if (!pdata || !pdata->dvs_gpio) | 403 | if (!pdata || !pdata->dvs_gpio) |
403 | return; | 404 | return; |
404 | 405 | ||
405 | ret = gpio_request(pdata->dvs_gpio, "DCDC DVS"); | ||
406 | if (ret < 0) { | ||
407 | dev_err(wm831x->dev, "Failed to get %s DVS GPIO: %d\n", | ||
408 | dcdc->name, ret); | ||
409 | return; | ||
410 | } | ||
411 | |||
412 | /* gpiolib won't let us read the GPIO status so pick the higher | 406 | /* gpiolib won't let us read the GPIO status so pick the higher |
413 | * of the two existing voltages so we take it as platform data. | 407 | * of the two existing voltages so we take it as platform data. |
414 | */ | 408 | */ |
415 | dcdc->dvs_gpio_state = pdata->dvs_init_state; | 409 | dcdc->dvs_gpio_state = pdata->dvs_init_state; |
416 | 410 | ||
417 | ret = gpio_direction_output(pdata->dvs_gpio, dcdc->dvs_gpio_state); | 411 | ret = gpio_request_one(pdata->dvs_gpio, |
412 | dcdc->dvs_gpio_state ? GPIOF_INIT_HIGH : 0, | ||
413 | "DCDC DVS"); | ||
418 | if (ret < 0) { | 414 | if (ret < 0) { |
419 | dev_err(wm831x->dev, "Failed to enable %s DVS GPIO: %d\n", | 415 | dev_err(wm831x->dev, "Failed to get %s DVS GPIO: %d\n", |
420 | dcdc->name, ret); | 416 | dcdc->name, ret); |
421 | gpio_free(pdata->dvs_gpio); | ||
422 | return; | 417 | return; |
423 | } | 418 | } |
424 | 419 | ||
@@ -496,6 +491,11 @@ static __devinit int wm831x_buckv_probe(struct platform_device *pdev) | |||
496 | 491 | ||
497 | snprintf(dcdc->name, sizeof(dcdc->name), "DCDC%d", id + 1); | 492 | snprintf(dcdc->name, sizeof(dcdc->name), "DCDC%d", id + 1); |
498 | dcdc->desc.name = dcdc->name; | 493 | dcdc->desc.name = dcdc->name; |
494 | |||
495 | snprintf(dcdc->supply_name, sizeof(dcdc->supply_name), | ||
496 | "DC%dVDD", id + 1); | ||
497 | dcdc->desc.supply_name = dcdc->supply_name; | ||
498 | |||
499 | dcdc->desc.id = id; | 499 | dcdc->desc.id = id; |
500 | dcdc->desc.type = REGULATOR_VOLTAGE; | 500 | dcdc->desc.type = REGULATOR_VOLTAGE; |
501 | dcdc->desc.n_voltages = WM831X_BUCKV_MAX_SELECTOR + 1; | 501 | dcdc->desc.n_voltages = WM831X_BUCKV_MAX_SELECTOR + 1; |
@@ -697,6 +697,11 @@ static __devinit int wm831x_buckp_probe(struct platform_device *pdev) | |||
697 | 697 | ||
698 | snprintf(dcdc->name, sizeof(dcdc->name), "DCDC%d", id + 1); | 698 | snprintf(dcdc->name, sizeof(dcdc->name), "DCDC%d", id + 1); |
699 | dcdc->desc.name = dcdc->name; | 699 | dcdc->desc.name = dcdc->name; |
700 | |||
701 | snprintf(dcdc->supply_name, sizeof(dcdc->supply_name), | ||
702 | "DC%dVDD", id + 1); | ||
703 | dcdc->desc.supply_name = dcdc->supply_name; | ||
704 | |||
700 | dcdc->desc.id = id; | 705 | dcdc->desc.id = id; |
701 | dcdc->desc.type = REGULATOR_VOLTAGE; | 706 | dcdc->desc.type = REGULATOR_VOLTAGE; |
702 | dcdc->desc.n_voltages = WM831X_BUCKP_MAX_SELECTOR + 1; | 707 | dcdc->desc.n_voltages = WM831X_BUCKP_MAX_SELECTOR + 1; |
diff --git a/drivers/regulator/wm831x-ldo.c b/drivers/regulator/wm831x-ldo.c index 74cd1f24b892..9fe71dc20c3f 100644 --- a/drivers/regulator/wm831x-ldo.c +++ b/drivers/regulator/wm831x-ldo.c | |||
@@ -25,7 +25,7 @@ | |||
25 | #include <linux/mfd/wm831x/regulator.h> | 25 | #include <linux/mfd/wm831x/regulator.h> |
26 | #include <linux/mfd/wm831x/pdata.h> | 26 | #include <linux/mfd/wm831x/pdata.h> |
27 | 27 | ||
28 | #define WM831X_LDO_MAX_NAME 6 | 28 | #define WM831X_LDO_MAX_NAME 9 |
29 | 29 | ||
30 | #define WM831X_LDO_CONTROL 0 | 30 | #define WM831X_LDO_CONTROL 0 |
31 | #define WM831X_LDO_ON_CONTROL 1 | 31 | #define WM831X_LDO_ON_CONTROL 1 |
@@ -36,6 +36,7 @@ | |||
36 | 36 | ||
37 | struct wm831x_ldo { | 37 | struct wm831x_ldo { |
38 | char name[WM831X_LDO_MAX_NAME]; | 38 | char name[WM831X_LDO_MAX_NAME]; |
39 | char supply_name[WM831X_LDO_MAX_NAME]; | ||
39 | struct regulator_desc desc; | 40 | struct regulator_desc desc; |
40 | int base; | 41 | int base; |
41 | struct wm831x *wm831x; | 42 | struct wm831x *wm831x; |
@@ -291,6 +292,11 @@ static __devinit int wm831x_gp_ldo_probe(struct platform_device *pdev) | |||
291 | 292 | ||
292 | snprintf(ldo->name, sizeof(ldo->name), "LDO%d", id + 1); | 293 | snprintf(ldo->name, sizeof(ldo->name), "LDO%d", id + 1); |
293 | ldo->desc.name = ldo->name; | 294 | ldo->desc.name = ldo->name; |
295 | |||
296 | snprintf(ldo->supply_name, sizeof(ldo->supply_name), | ||
297 | "LDO%dVDD", id + 1); | ||
298 | ldo->desc.supply_name = ldo->supply_name; | ||
299 | |||
294 | ldo->desc.id = id; | 300 | ldo->desc.id = id; |
295 | ldo->desc.type = REGULATOR_VOLTAGE; | 301 | ldo->desc.type = REGULATOR_VOLTAGE; |
296 | ldo->desc.n_voltages = WM831X_GP_LDO_MAX_SELECTOR + 1; | 302 | ldo->desc.n_voltages = WM831X_GP_LDO_MAX_SELECTOR + 1; |
@@ -547,6 +553,11 @@ static __devinit int wm831x_aldo_probe(struct platform_device *pdev) | |||
547 | 553 | ||
548 | snprintf(ldo->name, sizeof(ldo->name), "LDO%d", id + 1); | 554 | snprintf(ldo->name, sizeof(ldo->name), "LDO%d", id + 1); |
549 | ldo->desc.name = ldo->name; | 555 | ldo->desc.name = ldo->name; |
556 | |||
557 | snprintf(ldo->supply_name, sizeof(ldo->supply_name), | ||
558 | "LDO%dVDD", id + 1); | ||
559 | ldo->desc.supply_name = ldo->supply_name; | ||
560 | |||
550 | ldo->desc.id = id; | 561 | ldo->desc.id = id; |
551 | ldo->desc.type = REGULATOR_VOLTAGE; | 562 | ldo->desc.type = REGULATOR_VOLTAGE; |
552 | ldo->desc.n_voltages = WM831X_ALDO_MAX_SELECTOR + 1; | 563 | ldo->desc.n_voltages = WM831X_ALDO_MAX_SELECTOR + 1; |
@@ -733,6 +744,11 @@ static __devinit int wm831x_alive_ldo_probe(struct platform_device *pdev) | |||
733 | 744 | ||
734 | snprintf(ldo->name, sizeof(ldo->name), "LDO%d", id + 1); | 745 | snprintf(ldo->name, sizeof(ldo->name), "LDO%d", id + 1); |
735 | ldo->desc.name = ldo->name; | 746 | ldo->desc.name = ldo->name; |
747 | |||
748 | snprintf(ldo->supply_name, sizeof(ldo->supply_name), | ||
749 | "LDO%dVDD", id + 1); | ||
750 | ldo->desc.supply_name = ldo->supply_name; | ||
751 | |||
736 | ldo->desc.id = id; | 752 | ldo->desc.id = id; |
737 | ldo->desc.type = REGULATOR_VOLTAGE; | 753 | ldo->desc.type = REGULATOR_VOLTAGE; |
738 | ldo->desc.n_voltages = WM831X_ALIVE_LDO_MAX_SELECTOR + 1; | 754 | ldo->desc.n_voltages = WM831X_ALIVE_LDO_MAX_SELECTOR + 1; |
diff --git a/drivers/regulator/wm8994-regulator.c b/drivers/regulator/wm8994-regulator.c index e07972fbf44f..7c64ce599d2a 100644 --- a/drivers/regulator/wm8994-regulator.c +++ b/drivers/regulator/wm8994-regulator.c | |||
@@ -182,23 +182,16 @@ static __devinit int wm8994_ldo_probe(struct platform_device *pdev) | |||
182 | if (pdata->ldo[id].enable && gpio_is_valid(pdata->ldo[id].enable)) { | 182 | if (pdata->ldo[id].enable && gpio_is_valid(pdata->ldo[id].enable)) { |
183 | ldo->enable = pdata->ldo[id].enable; | 183 | ldo->enable = pdata->ldo[id].enable; |
184 | 184 | ||
185 | ret = gpio_request(ldo->enable, "WM8994 LDO enable"); | 185 | ret = gpio_request_one(ldo->enable, 0, "WM8994 LDO enable"); |
186 | if (ret < 0) { | 186 | if (ret < 0) { |
187 | dev_err(&pdev->dev, "Failed to get enable GPIO: %d\n", | 187 | dev_err(&pdev->dev, "Failed to get enable GPIO: %d\n", |
188 | ret); | 188 | ret); |
189 | goto err; | 189 | goto err; |
190 | } | 190 | } |
191 | |||
192 | ret = gpio_direction_output(ldo->enable, ldo->is_enabled); | ||
193 | if (ret < 0) { | ||
194 | dev_err(&pdev->dev, "Failed to set GPIO up: %d\n", | ||
195 | ret); | ||
196 | goto err_gpio; | ||
197 | } | ||
198 | } else | 191 | } else |
199 | ldo->is_enabled = true; | 192 | ldo->is_enabled = true; |
200 | 193 | ||
201 | config.dev = &pdev->dev; | 194 | config.dev = wm8994->dev; |
202 | config.init_data = pdata->ldo[id].init_data; | 195 | config.init_data = pdata->ldo[id].init_data; |
203 | config.driver_data = ldo; | 196 | config.driver_data = ldo; |
204 | config.regmap = wm8994->regmap; | 197 | config.regmap = wm8994->regmap; |
diff --git a/include/linux/i2c/twl.h b/include/linux/i2c/twl.h index 1f90de0cfdbe..3993477103a5 100644 --- a/include/linux/i2c/twl.h +++ b/include/linux/i2c/twl.h | |||
@@ -171,8 +171,6 @@ static inline int twl_class_is_ ##class(void) \ | |||
171 | TWL_CLASS_IS(4030, TWL4030_CLASS_ID) | 171 | TWL_CLASS_IS(4030, TWL4030_CLASS_ID) |
172 | TWL_CLASS_IS(6030, TWL6030_CLASS_ID) | 172 | TWL_CLASS_IS(6030, TWL6030_CLASS_ID) |
173 | 173 | ||
174 | #define TWL6025_SUBCLASS BIT(4) /* TWL6025 has changed registers */ | ||
175 | |||
176 | /* | 174 | /* |
177 | * Read and write single 8-bit registers | 175 | * Read and write single 8-bit registers |
178 | */ | 176 | */ |
@@ -746,6 +744,17 @@ struct twl_regulator_driver_data { | |||
746 | void *data; | 744 | void *data; |
747 | unsigned long features; | 745 | unsigned long features; |
748 | }; | 746 | }; |
747 | /* chip-specific feature flags, for twl_regulator_driver_data.features */ | ||
748 | #define TWL4030_VAUX2 BIT(0) /* pre-5030 voltage ranges */ | ||
749 | #define TPS_SUBSET BIT(1) /* tps659[23]0 have fewer LDOs */ | ||
750 | #define TWL5031 BIT(2) /* twl5031 has different registers */ | ||
751 | #define TWL6030_CLASS BIT(3) /* TWL6030 class */ | ||
752 | #define TWL6025_SUBCLASS BIT(4) /* TWL6025 has changed registers */ | ||
753 | #define TWL4030_ALLOW_UNSUPPORTED BIT(5) /* Some voltages are possible | ||
754 | * but not officially supported. | ||
755 | * This flag is necessary to | ||
756 | * enable them. | ||
757 | */ | ||
749 | 758 | ||
750 | /*----------------------------------------------------------------------*/ | 759 | /*----------------------------------------------------------------------*/ |
751 | 760 | ||
diff --git a/include/linux/mfd/tps6586x.h b/include/linux/mfd/tps6586x.h index b19176eab44d..f350fd0ba1df 100644 --- a/include/linux/mfd/tps6586x.h +++ b/include/linux/mfd/tps6586x.h | |||
@@ -68,6 +68,7 @@ struct tps6586x_subdev_info { | |||
68 | int id; | 68 | int id; |
69 | const char *name; | 69 | const char *name; |
70 | void *platform_data; | 70 | void *platform_data; |
71 | struct device_node *of_node; | ||
71 | }; | 72 | }; |
72 | 73 | ||
73 | struct tps6586x_platform_data { | 74 | struct tps6586x_platform_data { |
diff --git a/include/linux/regulator/of_regulator.h b/include/linux/regulator/of_regulator.h index 769704f296e5..f9217965aaa3 100644 --- a/include/linux/regulator/of_regulator.h +++ b/include/linux/regulator/of_regulator.h | |||
@@ -6,10 +6,20 @@ | |||
6 | #ifndef __LINUX_OF_REG_H | 6 | #ifndef __LINUX_OF_REG_H |
7 | #define __LINUX_OF_REG_H | 7 | #define __LINUX_OF_REG_H |
8 | 8 | ||
9 | struct of_regulator_match { | ||
10 | const char *name; | ||
11 | void *driver_data; | ||
12 | struct regulator_init_data *init_data; | ||
13 | struct device_node *of_node; | ||
14 | }; | ||
15 | |||
9 | #if defined(CONFIG_OF) | 16 | #if defined(CONFIG_OF) |
10 | extern struct regulator_init_data | 17 | extern struct regulator_init_data |
11 | *of_get_regulator_init_data(struct device *dev, | 18 | *of_get_regulator_init_data(struct device *dev, |
12 | struct device_node *node); | 19 | struct device_node *node); |
20 | extern int of_regulator_match(struct device *dev, struct device_node *node, | ||
21 | struct of_regulator_match *matches, | ||
22 | unsigned int num_matches); | ||
13 | #else | 23 | #else |
14 | static inline struct regulator_init_data | 24 | static inline struct regulator_init_data |
15 | *of_get_regulator_init_data(struct device *dev, | 25 | *of_get_regulator_init_data(struct device *dev, |
@@ -17,6 +27,14 @@ static inline struct regulator_init_data | |||
17 | { | 27 | { |
18 | return NULL; | 28 | return NULL; |
19 | } | 29 | } |
30 | |||
31 | static inline int of_regulator_match(struct device *dev, | ||
32 | struct device_node *node, | ||
33 | struct of_regulator_match *matches, | ||
34 | unsigned int num_matches) | ||
35 | { | ||
36 | return 0; | ||
37 | } | ||
20 | #endif /* CONFIG_OF */ | 38 | #endif /* CONFIG_OF */ |
21 | 39 | ||
22 | #endif /* __LINUX_OF_REG_H */ | 40 | #endif /* __LINUX_OF_REG_H */ |