Commit 5949a7e9ab2db04edaeee7c368eb4c99131f4629

Authored by Mark Brown

Merge remote-tracking branch 'regulator/topic/drivers' into regulator-next

Conflicts:
	drivers/regulator/88pm8607.c (simple overlap with a bugfix in v3.4)

Showing 33 changed files Side-by-side Diff

Documentation/devicetree/bindings/regulator/fixed-regulator.txt
... ... @@ -8,6 +8,8 @@
8 8 - startup-delay-us: startup time in microseconds
9 9 - enable-active-high: Polarity of GPIO is Active high
10 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 14 Any property defined as part of the core regulator
13 15 binding, defined in regulator.txt, can also be used.
... ... @@ -25,6 +27,7 @@
25 27 gpio = <&gpio1 16 0>;
26 28 startup-delay-us = <70000>;
27 29 enable-active-high;
28   - regulator-boot-on
  30 + regulator-boot-on;
  31 + gpio-open-drain;
29 32 };
Documentation/devicetree/bindings/regulator/tps6586x.txt
  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 + };
drivers/mfd/tps6586x.c
... ... @@ -23,6 +23,7 @@
23 23 #include <linux/slab.h>
24 24 #include <linux/gpio.h>
25 25 #include <linux/i2c.h>
  26 +#include <linux/regulator/of_regulator.h>
26 27  
27 28 #include <linux/mfd/core.h>
28 29 #include <linux/mfd/tps6586x.h>
... ... @@ -460,6 +461,7 @@
460 461  
461 462 pdev->dev.parent = tps6586x->dev;
462 463 pdev->dev.platform_data = subdev->platform_data;
  464 + pdev->dev.of_node = subdev->of_node;
463 465  
464 466 ret = platform_device_add(pdev);
465 467 if (ret) {
... ... @@ -474,6 +476,86 @@
474 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 559 static int __devinit tps6586x_i2c_probe(struct i2c_client *client,
478 560 const struct i2c_device_id *id)
479 561 {
... ... @@ -481,6 +563,9 @@
481 563 struct tps6586x *tps6586x;
482 564 int ret;
483 565  
  566 + if (!pdata && client->dev.of_node)
  567 + pdata = tps6586x_parse_dt(client);
  568 +
484 569 if (!pdata) {
485 570 dev_err(&client->dev, "tps6586x requires platform data\n");
486 571 return -ENOTSUPP;
... ... @@ -573,6 +658,7 @@
573 658 .driver = {
574 659 .name = "tps6586x",
575 660 .owner = THIS_MODULE,
  661 + .of_match_table = of_match_ptr(tps6586x_of_match),
576 662 },
577 663 .probe = tps6586x_i2c_probe,
578 664 .remove = __devexit_p(tps6586x_i2c_remove),
drivers/mfd/twl-core.c
... ... @@ -224,13 +224,6 @@
224 224 #define HIGH_PERF_SQ (1 << 3)
225 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 229 /* is driver active, bound to a chip? */
drivers/regulator/aat2870-regulator.c
... ... @@ -24,7 +24,6 @@
24 24 #include <linux/err.h>
25 25 #include <linux/module.h>
26 26 #include <linux/slab.h>
27   -#include <linux/delay.h>
28 27 #include <linux/platform_device.h>
29 28 #include <linux/regulator/driver.h>
30 29 #include <linux/regulator/machine.h>
drivers/regulator/ab3100.c
... ... @@ -13,7 +13,6 @@
13 13 #include <linux/kernel.h>
14 14 #include <linux/init.h>
15 15 #include <linux/err.h>
16   -#include <linux/delay.h>
17 16 #include <linux/platform_device.h>
18 17 #include <linux/regulator/driver.h>
19 18 #include <linux/mfd/abx500.h>
drivers/regulator/da9052-regulator.c
... ... @@ -20,6 +20,7 @@
20 20 #include <linux/regulator/driver.h>
21 21 #include <linux/regulator/machine.h>
22 22 #ifdef CONFIG_OF
  23 +#include <linux/of.h>
23 24 #include <linux/regulator/of_regulator.h>
24 25 #endif
25 26  
... ... @@ -393,7 +394,7 @@
393 394 if (!nproot)
394 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 398 np = of_get_next_child(nproot, np)) {
398 399 if (!of_node_cmp(np->name,
399 400 regulator->info->reg_desc.name)) {
drivers/regulator/fixed.c
... ... @@ -25,7 +25,6 @@
25 25 #include <linux/regulator/driver.h>
26 26 #include <linux/regulator/fixed.h>
27 27 #include <linux/gpio.h>
28   -#include <linux/delay.h>
29 28 #include <linux/slab.h>
30 29 #include <linux/of.h>
31 30 #include <linux/of_gpio.h>
... ... @@ -90,6 +89,9 @@
90 89  
91 90 if (of_find_property(np, "enable-active-high", NULL))
92 91 config->enable_high = true;
  92 +
  93 + if (of_find_property(np, "gpio-open-drain", NULL))
  94 + config->gpio_is_open_drain = true;
93 95  
94 96 return config;
95 97 }
drivers/regulator/gpio-regulator.c
... ... @@ -30,7 +30,6 @@
30 30 #include <linux/regulator/machine.h>
31 31 #include <linux/regulator/gpio-regulator.h>
32 32 #include <linux/gpio.h>
33   -#include <linux/delay.h>
34 33 #include <linux/slab.h>
35 34  
36 35 struct gpio_regulator_data {
drivers/regulator/isl6271a-regulator.c
... ... @@ -22,7 +22,6 @@
22 22 #include <linux/platform_device.h>
23 23 #include <linux/regulator/driver.h>
24 24 #include <linux/i2c.h>
25   -#include <linux/delay.h>
26 25 #include <linux/slab.h>
27 26  
28 27 #define ISL6271A_VOLTAGE_MIN 850000
drivers/regulator/max8660.c
... ... @@ -370,7 +370,7 @@
370 370 return -EINVAL;
371 371 }
372 372  
373   - max8660 = kzalloc(sizeof(struct max8660) +
  373 + max8660 = devm_kzalloc(&client->dev, sizeof(struct max8660) +
374 374 sizeof(struct regulator_dev *) * MAX8660_V_END,
375 375 GFP_KERNEL);
376 376 if (!max8660)
drivers/regulator/max8952.c
... ... @@ -69,11 +69,6 @@
69 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 72 static int max8952_list_voltage(struct regulator_dev *rdev,
78 73 unsigned int selector)
79 74 {
... ... @@ -82,7 +77,7 @@
82 77 if (rdev_get_id(rdev) != 0)
83 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 83 static int max8952_is_enabled(struct regulator_dev *rdev)
... ... @@ -117,7 +112,7 @@
117 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 117 struct max8952_data *max8952 = rdev_get_drvdata(rdev);
123 118 u8 vid = 0;
... ... @@ -127,7 +122,7 @@
127 122 if (max8952->vid1)
128 123 vid += 2;
129 124  
130   - return max8952_voltage(max8952, vid);
  125 + return vid;
131 126 }
132 127  
133 128 static int max8952_set_voltage_sel(struct regulator_dev *rdev,
... ... @@ -154,7 +149,7 @@
154 149 .is_enabled = max8952_is_enabled,
155 150 .enable = max8952_enable,
156 151 .disable = max8952_disable,
157   - .get_voltage = max8952_get_voltage,
  152 + .get_voltage_sel = max8952_get_voltage_sel,
158 153 .set_voltage_sel = max8952_set_voltage_sel,
159 154 .set_suspend_disable = max8952_disable,
160 155 };
drivers/regulator/max8997.c
... ... @@ -22,7 +22,6 @@
22 22 */
23 23  
24 24 #include <linux/bug.h>
25   -#include <linux/delay.h>
26 25 #include <linux/err.h>
27 26 #include <linux/gpio.h>
28 27 #include <linux/slab.h>
... ... @@ -278,9 +277,7 @@
278 277 u8 val;
279 278  
280 279 ret = max8997_get_enable_register(rdev, &reg, &mask, &pattern);
281   - if (ret == -EINVAL)
282   - return 1; /* "not controllable" */
283   - else if (ret)
  280 + if (ret)
284 281 return ret;
285 282  
286 283 ret = max8997_read_reg(i2c, reg, &val);
... ... @@ -382,7 +379,7 @@
382 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 384 struct max8997_data *max8997 = rdev_get_drvdata(rdev);
388 385 struct i2c_client *i2c = max8997->iodev->i2c;
... ... @@ -400,15 +397,7 @@
400 397 val >>= shift;
401 398 val &= mask;
402 399  
403   - if (rdev->desc && rdev->desc->ops && rdev->desc->ops->list_voltage)
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);
  400 + return val;
412 401 }
413 402  
414 403 static inline int max8997_get_voltage_proper_val(
... ... @@ -497,9 +486,7 @@
497 486 int min_vol = min_uV / 1000, max_vol = max_uV / 1000;
498 487 const struct voltage_map_desc *desc;
499 488 int rid = rdev_get_id(rdev);
500   - int reg, shift = 0, mask, ret;
501   - int i;
502   - u8 org;
  489 + int i, reg, shift, mask, ret;
503 490  
504 491 switch (rid) {
505 492 case MAX8997_LDO1 ... MAX8997_LDO21:
506 493  
507 494  
... ... @@ -528,21 +515,50 @@
528 515 if (ret)
529 516 return ret;
530 517  
531   - max8997_read_reg(i2c, reg, &org);
532   - org = (org & mask) >> shift;
533   -
534 518 ret = max8997_update_reg(i2c, reg, i << shift, mask << shift);
535 519 *selector = i;
536 520  
537   - if (rid == MAX8997_BUCK1 || rid == MAX8997_BUCK2 ||
538   - rid == MAX8997_BUCK4 || rid == MAX8997_BUCK5) {
539   - /* If the voltage is increasing */
540   - if (org < i)
541   - udelay(DIV_ROUND_UP(desc->step * (i - org),
542   - max8997->ramp_delay));
  521 + return ret;
  522 +}
  523 +
  524 +static int max8997_set_voltage_ldobuck_time_sel(struct regulator_dev *rdev,
  525 + unsigned int old_selector,
  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 @@
749 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 768 static int max8997_reg_disable_suspend(struct regulator_dev *rdev)
758 769 {
759 770 struct max8997_data *max8997 = rdev_get_drvdata(rdev);
760 771  
... ... @@ -786,9 +797,9 @@
786 797 .is_enabled = max8997_reg_is_enabled,
787 798 .enable = max8997_reg_enable,
788 799 .disable = max8997_reg_disable,
789   - .get_voltage = max8997_get_voltage,
  800 + .get_voltage_sel = max8997_get_voltage_sel,
790 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 803 .set_suspend_disable = max8997_reg_disable_suspend,
793 804 };
794 805  
795 806  
... ... @@ -797,9 +808,9 @@
797 808 .is_enabled = max8997_reg_is_enabled,
798 809 .enable = max8997_reg_enable,
799 810 .disable = max8997_reg_disable,
800   - .get_voltage = max8997_get_voltage,
  811 + .get_voltage_sel = max8997_get_voltage_sel,
801 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 814 .set_suspend_disable = max8997_reg_disable_suspend,
804 815 };
805 816  
... ... @@ -808,7 +819,6 @@
808 819 .is_enabled = max8997_reg_is_enabled,
809 820 .enable = max8997_reg_enable,
810 821 .disable = max8997_reg_disable,
811   - .set_suspend_enable = max8997_reg_enable_suspend,
812 822 .set_suspend_disable = max8997_reg_disable_suspend,
813 823 };
814 824  
815 825  
816 826  
817 827  
818 828  
819 829  
820 830  
821 831  
822 832  
823 833  
... ... @@ -817,39 +827,56 @@
817 827 .is_enabled = max8997_reg_is_enabled,
818 828 .enable = max8997_reg_enable,
819 829 .disable = max8997_reg_disable,
820   - .get_voltage = max8997_get_voltage,
  830 + .get_voltage_sel = max8997_get_voltage_sel,
821 831 .set_voltage = max8997_set_voltage_safeout,
822   - .set_suspend_enable = max8997_reg_enable_suspend,
823 832 .set_suspend_disable = max8997_reg_disable_suspend,
824 833 };
825 834  
826 835 static struct regulator_ops max8997_fixedstate_ops = {
827 836 .list_voltage = max8997_list_voltage_charger_cv,
828   - .get_voltage = max8997_get_voltage,
  837 + .get_voltage_sel = max8997_get_voltage_sel,
829 838 .set_voltage = max8997_set_voltage_charger_cv,
830 839 };
831 840  
832   -static int max8997_set_voltage_ldobuck_wrap(struct regulator_dev *rdev,
833   - int min_uV, int max_uV)
  841 +static int max8997_set_current_limit(struct regulator_dev *rdev,
  842 + int min_uA, int max_uA)
834 843 {
835 844 unsigned dummy;
  845 + int rid = rdev_get_id(rdev);
836 846  
837   - return max8997_set_voltage_ldobuck(rdev, min_uV, max_uV, &dummy);
  847 + if (rid != MAX8997_CHARGER && rid != MAX8997_CHARGER_TOPOFF)
  848 + return -EINVAL;
  849 +
  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);
840 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 +}
  868 +
841 869 static struct regulator_ops max8997_charger_ops = {
842 870 .is_enabled = max8997_reg_is_enabled,
843 871 .enable = max8997_reg_enable,
844 872 .disable = max8997_reg_disable,
845   - .get_current_limit = max8997_get_voltage,
846   - .set_current_limit = max8997_set_voltage_ldobuck_wrap,
  873 + .get_current_limit = max8997_get_current_limit,
  874 + .set_current_limit = max8997_set_current_limit,
847 875 };
848 876  
849 877 static struct regulator_ops max8997_charger_fixedstate_ops = {
850   - .is_enabled = max8997_reg_is_enabled,
851   - .get_current_limit = max8997_get_voltage,
852   - .set_current_limit = max8997_set_voltage_ldobuck_wrap,
  878 + .get_current_limit = max8997_get_current_limit,
  879 + .set_current_limit = max8997_set_current_limit,
853 880 };
854 881  
855 882 #define MAX8997_VOLTAGE_REGULATOR(_name, _ops) {\
856 883  
857 884  
... ... @@ -922,16 +949,15 @@
922 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 954 if (!max8997)
927 955 return -ENOMEM;
928 956  
929 957 size = sizeof(struct regulator_dev *) * pdata->num_regulators;
930   - max8997->rdev = kzalloc(size, GFP_KERNEL);
931   - if (!max8997->rdev) {
932   - kfree(max8997);
  958 + max8997->rdev = devm_kzalloc(&pdev->dev, size, GFP_KERNEL);
  959 + if (!max8997->rdev)
933 960 return -ENOMEM;
934   - }
935 961  
936 962 rdev = max8997->rdev;
937 963 max8997->dev = &pdev->dev;
... ... @@ -955,7 +981,7 @@
955 981 pdata->buck1_voltage[i] / 1000 +
956 982 buck1245_voltage_map_desc.step);
957 983 if (ret < 0)
958   - goto err_alloc;
  984 + goto err_out;
959 985  
960 986 max8997->buck2_vol[i] = ret =
961 987 max8997_get_voltage_proper_val(
... ... @@ -964,7 +990,7 @@
964 990 pdata->buck2_voltage[i] / 1000 +
965 991 buck1245_voltage_map_desc.step);
966 992 if (ret < 0)
967   - goto err_alloc;
  993 + goto err_out;
968 994  
969 995 max8997->buck5_vol[i] = ret =
970 996 max8997_get_voltage_proper_val(
... ... @@ -973,7 +999,7 @@
973 999 pdata->buck5_voltage[i] / 1000 +
974 1000 buck1245_voltage_map_desc.step);
975 1001 if (ret < 0)
976   - goto err_alloc;
  1002 + goto err_out;
977 1003  
978 1004 if (max_buck1 < max8997->buck1_vol[i])
979 1005 max_buck1 = max8997->buck1_vol[i];
... ... @@ -1006,7 +1032,7 @@
1006 1032 !gpio_is_valid(pdata->buck125_gpios[2])) {
1007 1033 dev_err(&pdev->dev, "GPIO NOT VALID\n");
1008 1034 ret = -EINVAL;
1009   - goto err_alloc;
  1035 + goto err_out;
1010 1036 }
1011 1037  
1012 1038 ret = gpio_request(pdata->buck125_gpios[0],
... ... @@ -1015,7 +1041,7 @@
1015 1041 dev_warn(&pdev->dev, "Duplicated gpio request"
1016 1042 " on SET1\n");
1017 1043 else if (ret)
1018   - goto err_alloc;
  1044 + goto err_out;
1019 1045 else
1020 1046 gpio1set = true;
1021 1047  
... ... @@ -1027,7 +1053,7 @@
1027 1053 else if (ret) {
1028 1054 if (gpio1set)
1029 1055 gpio_free(pdata->buck125_gpios[0]);
1030   - goto err_alloc;
  1056 + goto err_out;
1031 1057 } else
1032 1058 gpio2set = true;
1033 1059  
... ... @@ -1041,7 +1067,7 @@
1041 1067 gpio_free(pdata->buck125_gpios[0]);
1042 1068 if (gpio2set)
1043 1069 gpio_free(pdata->buck125_gpios[1]);
1044   - goto err_alloc;
  1070 + goto err_out;
1045 1071 }
1046 1072  
1047 1073 gpio_direction_output(pdata->buck125_gpios[0],
... ... @@ -1110,13 +1136,9 @@
1110 1136  
1111 1137 return 0;
1112 1138 err:
1113   - for (i = 0; i < max8997->num_regulators; i++)
1114   - if (rdev[i])
1115   - regulator_unregister(rdev[i]);
1116   -err_alloc:
1117   - kfree(max8997->rdev);
1118   - kfree(max8997);
1119   -
  1139 + while (--i >= 0)
  1140 + regulator_unregister(rdev[i]);
  1141 +err_out:
1120 1142 return ret;
1121 1143 }
1122 1144  
... ... @@ -1127,12 +1149,7 @@
1127 1149 int i;
1128 1150  
1129 1151 for (i = 0; i < max8997->num_regulators; i++)
1130   - if (rdev[i])
1131   - regulator_unregister(rdev[i]);
1132   -
1133   - kfree(max8997->rdev);
1134   - kfree(max8997);
1135   -
  1152 + regulator_unregister(rdev[i]);
1136 1153 return 0;
1137 1154 }
1138 1155  
drivers/regulator/max8998.c
... ... @@ -28,7 +28,6 @@
28 28 #include <linux/slab.h>
29 29 #include <linux/interrupt.h>
30 30 #include <linux/mutex.h>
31   -#include <linux/delay.h>
32 31 #include <linux/platform_device.h>
33 32 #include <linux/regulator/driver.h>
34 33 #include <linux/mfd/max8998.h>
35 34  
36 35  
... ... @@ -719,16 +718,15 @@
719 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 723 if (!max8998)
724 724 return -ENOMEM;
725 725  
726 726 size = sizeof(struct regulator_dev *) * pdata->num_regulators;
727   - max8998->rdev = kzalloc(size, GFP_KERNEL);
728   - if (!max8998->rdev) {
729   - kfree(max8998);
  727 + max8998->rdev = devm_kzalloc(&pdev->dev, size, GFP_KERNEL);
  728 + if (!max8998->rdev)
730 729 return -ENOMEM;
731   - }
732 730  
733 731 rdev = max8998->rdev;
734 732 max8998->dev = &pdev->dev;
735 733  
... ... @@ -752,14 +750,14 @@
752 750 printk(KERN_ERR "MAX8998 SET1 GPIO defined as 0 !\n");
753 751 WARN_ON(!pdata->buck1_set1);
754 752 ret = -EIO;
755   - goto err_free_mem;
  753 + goto err_out;
756 754 }
757 755 /* Check if SET2 is not equal to 0 */
758 756 if (!pdata->buck1_set2) {
759 757 printk(KERN_ERR "MAX8998 SET2 GPIO defined as 0 !\n");
760 758 WARN_ON(!pdata->buck1_set2);
761 759 ret = -EIO;
762   - goto err_free_mem;
  760 + goto err_out;
763 761 }
764 762  
765 763 gpio_request(pdata->buck1_set1, "MAX8998 BUCK1_SET1");
... ... @@ -779,7 +777,7 @@
779 777 max8998->buck1_vol[0] = i;
780 778 ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE1, i);
781 779 if (ret)
782   - goto err_free_mem;
  780 + goto err_out;
783 781  
784 782 /* Set predefined value for BUCK1 register 2 */
785 783 i = 0;
... ... @@ -791,7 +789,7 @@
791 789 max8998->buck1_vol[1] = i;
792 790 ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE2, i);
793 791 if (ret)
794   - goto err_free_mem;
  792 + goto err_out;
795 793  
796 794 /* Set predefined value for BUCK1 register 3 */
797 795 i = 0;
... ... @@ -803,7 +801,7 @@
803 801 max8998->buck1_vol[2] = i;
804 802 ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE3, i);
805 803 if (ret)
806   - goto err_free_mem;
  804 + goto err_out;
807 805  
808 806 /* Set predefined value for BUCK1 register 4 */
809 807 i = 0;
... ... @@ -815,7 +813,7 @@
815 813 max8998->buck1_vol[3] = i;
816 814 ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE4, i);
817 815 if (ret)
818   - goto err_free_mem;
  816 + goto err_out;
819 817  
820 818 }
821 819  
... ... @@ -825,7 +823,7 @@
825 823 printk(KERN_ERR "MAX8998 SET3 GPIO defined as 0 !\n");
826 824 WARN_ON(!pdata->buck2_set3);
827 825 ret = -EIO;
828   - goto err_free_mem;
  826 + goto err_out;
829 827 }
830 828 gpio_request(pdata->buck2_set3, "MAX8998 BUCK2_SET3");
831 829 gpio_direction_output(pdata->buck2_set3,
... ... @@ -840,7 +838,7 @@
840 838 max8998->buck2_vol[0] = i;
841 839 ret = max8998_write_reg(i2c, MAX8998_REG_BUCK2_VOLTAGE1, i);
842 840 if (ret)
843   - goto err_free_mem;
  841 + goto err_out;
844 842  
845 843 /* BUCK2 register 2 */
846 844 i = 0;
... ... @@ -851,7 +849,7 @@
851 849 max8998->buck2_vol[1] = i;
852 850 ret = max8998_write_reg(i2c, MAX8998_REG_BUCK2_VOLTAGE2, i);
853 851 if (ret)
854   - goto err_free_mem;
  852 + goto err_out;
855 853 }
856 854  
857 855 for (i = 0; i < pdata->num_regulators; i++) {
... ... @@ -881,14 +879,9 @@
881 879  
882 880 return 0;
883 881 err:
884   - for (i = 0; i < max8998->num_regulators; i++)
885   - if (rdev[i])
886   - regulator_unregister(rdev[i]);
887   -
888   -err_free_mem:
889   - kfree(max8998->rdev);
890   - kfree(max8998);
891   -
  882 + while (--i >= 0)
  883 + regulator_unregister(rdev[i]);
  884 +err_out:
892 885 return ret;
893 886 }
894 887  
... ... @@ -899,12 +892,7 @@
899 892 int i;
900 893  
901 894 for (i = 0; i < max8998->num_regulators; i++)
902   - if (rdev[i])
903   - regulator_unregister(rdev[i]);
904   -
905   - kfree(max8998->rdev);
906   - kfree(max8998);
907   -
  895 + regulator_unregister(rdev[i]);
908 896 return 0;
909 897 }
910 898  
drivers/regulator/of_regulator.c
... ... @@ -14,6 +14,7 @@
14 14 #include <linux/slab.h>
15 15 #include <linux/of.h>
16 16 #include <linux/regulator/machine.h>
  17 +#include <linux/regulator/of_regulator.h>
17 18  
18 19 static void of_get_regulation_constraints(struct device_node *np,
19 20 struct regulator_init_data **init_data)
... ... @@ -85,4 +86,50 @@
85 86 return init_data;
86 87 }
87 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);
drivers/regulator/rc5t583-regulator.c
... ... @@ -23,7 +23,6 @@
23 23 */
24 24  
25 25 #include <linux/module.h>
26   -#include <linux/delay.h>
27 26 #include <linux/init.h>
28 27 #include <linux/slab.h>
29 28 #include <linux/err.h>
drivers/regulator/s5m8767.c
... ... @@ -12,7 +12,6 @@
12 12 */
13 13  
14 14 #include <linux/bug.h>
15   -#include <linux/delay.h>
16 15 #include <linux/err.h>
17 16 #include <linux/gpio.h>
18 17 #include <linux/slab.h>
... ... @@ -347,7 +346,10 @@
347 346 if (max_vol < desc->min || min_vol > desc->max)
348 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 354 if (desc->min + desc->step * selector > max_vol)
353 355 return -EINVAL;
drivers/regulator/tps62360-regulator.c
... ... @@ -32,7 +32,6 @@
32 32 #include <linux/regulator/tps62360.h>
33 33 #include <linux/gpio.h>
34 34 #include <linux/i2c.h>
35   -#include <linux/delay.h>
36 35 #include <linux/slab.h>
37 36 #include <linux/regmap.h>
38 37  
39 38  
... ... @@ -48,10 +47,10 @@
48 47  
49 48 enum chips {TPS62360, TPS62361, TPS62362, TPS62363};
50 49  
51   -#define TPS62360_BASE_VOLTAGE 770
  50 +#define TPS62360_BASE_VOLTAGE 770000
52 51 #define TPS62360_N_VOLTAGES 64
53 52  
54   -#define TPS62361_BASE_VOLTAGE 500
  53 +#define TPS62361_BASE_VOLTAGE 500000
55 54 #define TPS62361_N_VOLTAGES 128
56 55  
57 56 /* tps 62360 chip information */
... ... @@ -72,6 +71,7 @@
72 71 int lru_index[4];
73 72 int curr_vset_vsel[4];
74 73 int curr_vset_id;
  74 + int change_uv_per_us;
75 75 };
76 76  
77 77 /*
... ... @@ -97,6 +97,7 @@
97 97 bool found = false;
98 98 int new_vset_reg = tps->lru_index[3];
99 99 int found_index = 3;
  100 +
100 101 for (i = 0; i < 4; ++i) {
101 102 if (tps->curr_vset_vsel[tps->lru_index[i]] == req_vsel) {
102 103 new_vset_reg = tps->lru_index[i];
... ... @@ -115,7 +116,7 @@
115 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 121 struct tps62360_chip *tps = rdev_get_drvdata(dev);
121 122 int vsel;
122 123  
... ... @@ -124,12 +125,12 @@
124 125  
125 126 ret = regmap_read(tps->regmap, REG_VSET0 + tps->curr_vset_id, &data);
126 127 if (ret < 0) {
127   - dev_err(tps->dev, "%s: Error in reading register %d\n",
128   - __func__, REG_VSET0 + tps->curr_vset_id);
  128 + dev_err(tps->dev, "%s(): register %d read failed with err %d\n",
  129 + __func__, REG_VSET0 + tps->curr_vset_id, ret);
129 130 return ret;
130 131 }
131 132 vsel = (int)data & tps->voltage_reg_mask;
132   - return (tps->voltage_base + vsel * 10) * 1000;
  133 + return vsel;
133 134 }
134 135  
135 136 static int tps62360_dcdc_set_voltage(struct regulator_dev *dev,
136 137  
137 138  
... ... @@ -141,17 +142,13 @@
141 142 bool found = false;
142 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 146 return -EINVAL;
146 147  
147   - if (min_uV >
148   - ((tps->voltage_base + (tps->desc.n_voltages - 1) * 10) * 1000))
  148 + if (min_uV > (tps->voltage_base + (tps->desc.n_voltages - 1) * 10000))
149 149 return -EINVAL;
150 150  
151   - if (max_uV < tps->voltage_base * 1000)
152   - return -EINVAL;
153   -
154   - vsel = DIV_ROUND_UP(min_uV - (tps->voltage_base * 1000), 10000);
  151 + vsel = DIV_ROUND_UP(min_uV - tps->voltage_base, 10000);
155 152 if (selector)
156 153 *selector = (vsel & tps->voltage_reg_mask);
157 154  
... ... @@ -166,8 +163,9 @@
166 163 ret = regmap_update_bits(tps->regmap, REG_VSET0 + new_vset_id,
167 164 tps->voltage_reg_mask, vsel);
168 165 if (ret < 0) {
169   - dev_err(tps->dev, "%s: Error in updating register %d\n",
170   - __func__, REG_VSET0 + new_vset_id);
  166 + dev_err(tps->dev,
  167 + "%s(): register %d update failed with err %d\n",
  168 + __func__, REG_VSET0 + new_vset_id, ret);
171 169 return ret;
172 170 }
173 171 tps->curr_vset_id = new_vset_id;
... ... @@ -176,8 +174,7 @@
176 174  
177 175 /* Select proper VSET register vio gpios */
178 176 if (tps->valid_gpios) {
179   - gpio_set_value_cansleep(tps->vsel0_gpio,
180   - new_vset_id & 0x1);
  177 + gpio_set_value_cansleep(tps->vsel0_gpio, new_vset_id & 0x1);
181 178 gpio_set_value_cansleep(tps->vsel1_gpio,
182 179 (new_vset_id >> 1) & 0x1);
183 180 }
184 181  
185 182  
186 183  
187 184  
188 185  
189 186  
190 187  
191 188  
192 189  
193 190  
194 191  
195 192  
... ... @@ -191,57 +188,72 @@
191 188  
192 189 if (selector >= tps->desc.n_voltages)
193 190 return -EINVAL;
194   - return (tps->voltage_base + selector * 10) * 1000;
  191 +
  192 + return tps->voltage_base + selector * 10000;
195 193 }
196 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);
  210 +}
  211 +
197 212 static struct regulator_ops tps62360_dcdc_ops = {
198   - .get_voltage = tps62360_dcdc_get_voltage,
199   - .set_voltage = tps62360_dcdc_set_voltage,
200   - .list_voltage = tps62360_dcdc_list_voltage,
  213 + .get_voltage_sel = tps62360_dcdc_get_voltage_sel,
  214 + .set_voltage = tps62360_dcdc_set_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 220 struct tps62360_regulator_platform_data *pdata,
205 221 int vset_id)
206 222 {
207   - unsigned int data;
208 223 int ret;
209   - ret = regmap_read(tps->regmap, REG_VSET0 + vset_id, &data);
210   - if (ret < 0) {
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;
  224 + int bit = 0;
  225 +
216 226 if (pdata->en_force_pwm)
217   - data |= BIT(7);
218   - else
219   - data &= ~BIT(7);
220   - ret = regmap_write(tps->regmap, REG_VSET0 + vset_id, data);
  227 + bit = BIT(7);
  228 +
  229 + ret = regmap_update_bits(tps->regmap, REG_VSET0 + vset_id, BIT(7), bit);
221 230 if (ret < 0)
222   - dev_err(tps->dev, "%s() fails in writing reg %d\n",
223   - __func__, REG_VSET0 + vset_id);
  231 + dev_err(tps->dev,
  232 + "%s(): register %d update failed with err %d\n",
  233 + __func__, REG_VSET0 + vset_id, ret);
224 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 238 struct tps62360_regulator_platform_data *pdata)
229 239 {
230 240 int ret;
231 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 245 if (tps->en_internal_pulldn)
235 246 ret = regmap_write(tps->regmap, REG_CONTROL, 0xE0);
236 247 else
237 248 ret = regmap_write(tps->regmap, REG_CONTROL, 0x0);
238 249 if (ret < 0) {
239   - dev_err(tps->dev, "%s() fails in writing reg %d\n",
240   - __func__, REG_CONTROL);
  250 + dev_err(tps->dev,
  251 + "%s(): register %d write failed with err %d\n",
  252 + __func__, REG_CONTROL, ret);
241 253 return ret;
242 254 }
243 255  
244   - /* Initailize force PWM mode */
  256 + /* Initialize force PWM mode */
245 257 if (tps->valid_gpios) {
246 258 for (i = 0; i < 4; ++i) {
247 259 ret = tps62360_init_force_pwm(tps, pdata, i);
248 260  
... ... @@ -256,15 +268,33 @@
256 268  
257 269 /* Reset output discharge path to reduce power consumption */
258 270 ret = regmap_update_bits(tps->regmap, REG_RAMPCTRL, BIT(2), 0);
259   - if (ret < 0)
260   - dev_err(tps->dev, "%s() fails in updating reg %d\n",
261   - __func__, REG_RAMPCTRL);
  271 + if (ret < 0) {
  272 + dev_err(tps->dev,
  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 290 return ret;
263 291 }
264 292  
265 293 static const struct regmap_config tps62360_regmap_config = {
266   - .reg_bits = 8,
267   - .val_bits = 8,
  294 + .reg_bits = 8,
  295 + .val_bits = 8,
  296 + .max_register = REG_CHIPID,
  297 + .cache_type = REGCACHE_RBTREE,
268 298 };
269 299  
270 300 static int __devinit tps62360_probe(struct i2c_client *client,
271 301  
... ... @@ -279,14 +309,14 @@
279 309  
280 310 pdata = client->dev.platform_data;
281 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 313 __func__);
284 314 return -EIO;
285 315 }
286 316  
287 317 tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL);
288 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 320 __func__);
291 321 return -ENOMEM;
292 322 }
... ... @@ -323,8 +353,9 @@
323 353 tps->regmap = devm_regmap_init_i2c(client, &tps62360_regmap_config);
324 354 if (IS_ERR(tps->regmap)) {
325 355 ret = PTR_ERR(tps->regmap);
326   - dev_err(&client->dev, "%s() Err: Failed to allocate register"
327   - "map: %d\n", __func__, ret);
  356 + dev_err(&client->dev,
  357 + "%s(): regmap allocation failed with err %d\n",
  358 + __func__, ret);
328 359 return ret;
329 360 }
330 361 i2c_set_clientdata(client, tps);
331 362  
332 363  
333 364  
334 365  
335 366  
... ... @@ -335,37 +366,28 @@
335 366 tps->valid_gpios = false;
336 367  
337 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 374 if (ret) {
340 375 dev_err(&client->dev,
341   - "Err: Could not obtain vsel0 GPIO %d: %d\n",
342   - tps->vsel0_gpio, ret);
  376 + "%s(): Could not obtain vsel0 GPIO %d: %d\n",
  377 + __func__, tps->vsel0_gpio, ret);
343 378 goto err_gpio0;
344 379 }
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;
352   - }
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 385 if (ret) {
356 386 dev_err(&client->dev,
357   - "Err: Could not obtain vsel1 GPIO %d: %d\n",
358   - tps->vsel1_gpio, ret);
  387 + "%s(): Could not obtain vsel1 GPIO %d: %d\n",
  388 + __func__, tps->vsel1_gpio, ret);
359 389 goto err_gpio1;
360 390 }
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;
368   - }
369 391 tps->valid_gpios = true;
370 392  
371 393 /*
... ... @@ -380,7 +402,7 @@
380 402  
381 403 ret = tps62360_init_dcdc(tps, pdata);
382 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 406 __func__, ret);
385 407 goto err_init;
386 408 }
... ... @@ -392,8 +414,9 @@
392 414 /* Register the regulators */
393 415 rdev = regulator_register(&tps->desc, &config);
394 416 if (IS_ERR(rdev)) {
395   - dev_err(tps->dev, "%s() Err: Failed to register %s\n",
396   - __func__, id->name);
  417 + dev_err(tps->dev,
  418 + "%s(): regulator register failed with err %s\n",
  419 + __func__, id->name);
397 420 ret = PTR_ERR(rdev);
398 421 goto err_init;
399 422 }
... ... @@ -442,8 +465,9 @@
442 465 /* Configure the output discharge path */
443 466 st = regmap_update_bits(tps->regmap, REG_RAMPCTRL, BIT(2), BIT(2));
444 467 if (st < 0)
445   - dev_err(tps->dev, "%s() fails in updating reg %d\n",
446   - __func__, REG_RAMPCTRL);
  468 + dev_err(tps->dev,
  469 + "%s(): register %d update failed with err %d\n",
  470 + __func__, REG_RAMPCTRL, st);
447 471 }
448 472  
449 473 static const struct i2c_device_id tps62360_id[] = {
drivers/regulator/tps65023-regulator.c
... ... @@ -23,7 +23,6 @@
23 23 #include <linux/regulator/driver.h>
24 24 #include <linux/regulator/machine.h>
25 25 #include <linux/i2c.h>
26   -#include <linux/delay.h>
27 26 #include <linux/slab.h>
28 27 #include <linux/regmap.h>
29 28  
drivers/regulator/tps6507x-regulator.c
... ... @@ -23,7 +23,6 @@
23 23 #include <linux/regulator/driver.h>
24 24 #include <linux/regulator/machine.h>
25 25 #include <linux/regulator/tps6507x.h>
26   -#include <linux/delay.h>
27 26 #include <linux/slab.h>
28 27 #include <linux/mfd/tps6507x.h>
29 28  
... ... @@ -283,7 +282,7 @@
283 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 287 struct tps6507x_pmic *tps = rdev_get_drvdata(dev);
289 288 int data, rid = rdev_get_id(dev);
... ... @@ -325,7 +324,7 @@
325 324 return data;
326 325  
327 326 data &= mask;
328   - return tps->info[rid]->table[data] * 1000;
  327 + return data;
329 328 }
330 329  
331 330 static int tps6507x_pmic_set_voltage_sel(struct regulator_dev *dev,
... ... @@ -395,7 +394,7 @@
395 394 .is_enabled = tps6507x_pmic_is_enabled,
396 395 .enable = tps6507x_pmic_enable,
397 396 .disable = tps6507x_pmic_disable,
398   - .get_voltage = tps6507x_pmic_get_voltage,
  397 + .get_voltage_sel = tps6507x_pmic_get_voltage_sel,
399 398 .set_voltage_sel = tps6507x_pmic_set_voltage_sel,
400 399 .list_voltage = tps6507x_pmic_list_voltage,
401 400 };
drivers/regulator/tps65090-regulator.c
... ... @@ -17,7 +17,6 @@
17 17 */
18 18  
19 19 #include <linux/module.h>
20   -#include <linux/delay.h>
21 20 #include <linux/init.h>
22 21 #include <linux/slab.h>
23 22 #include <linux/err.h>
drivers/regulator/tps6586x-regulator.c
... ... @@ -363,6 +363,7 @@
363 363 return err;
364 364  
365 365 config.dev = &pdev->dev;
  366 + config.of_node = pdev->dev.of_node;
366 367 config.init_data = pdev->dev.platform_data;
367 368 config.driver_data = ri;
368 369  
drivers/regulator/tps65910-regulator.c
... ... @@ -20,7 +20,6 @@
20 20 #include <linux/platform_device.h>
21 21 #include <linux/regulator/driver.h>
22 22 #include <linux/regulator/machine.h>
23   -#include <linux/delay.h>
24 23 #include <linux/slab.h>
25 24 #include <linux/gpio.h>
26 25 #include <linux/mfd/tps65910.h>
27 26  
... ... @@ -579,10 +578,10 @@
579 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 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 586 reg = pmic->get_ctrl_reg(id);
588 587 if (reg < 0)
... ... @@ -609,9 +608,7 @@
609 608 return -EINVAL;
610 609 }
611 610  
612   - voltage = pmic->info[id]->voltage_table[value] * 1000;
613   -
614   - return voltage;
  611 + return value;
615 612 }
616 613  
617 614 static int tps65910_get_voltage_vdd3(struct regulator_dev *dev)
618 615  
... ... @@ -619,10 +616,10 @@
619 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 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 623 u8 value, reg;
627 624  
628 625 reg = pmic->get_ctrl_reg(id);
... ... @@ -635,13 +632,6 @@
635 632 case TPS65911_REG_LDO4:
636 633 value &= LDO1_SEL_MASK;
637 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 635 break;
646 636 case TPS65911_REG_LDO3:
647 637 case TPS65911_REG_LDO5:
648 638  
649 639  
... ... @@ -650,23 +640,16 @@
650 640 case TPS65911_REG_LDO8:
651 641 value &= LDO3_SEL_MASK;
652 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 643 break;
661 644 case TPS65910_REG_VIO:
662 645 value &= LDO_SEL_MASK;
663 646 value >>= LDO_SEL_SHIFT;
664   - return pmic->info[id]->voltage_table[value] * 1000;
  647 + break;
665 648 default:
666 649 return -EINVAL;
667 650 }
668 651  
669   - return (LDO_MIN_VOLT + value * step_mv) * 1000;
  652 + return value;
670 653 }
671 654  
672 655 static int tps65910_set_voltage_dcdc_sel(struct regulator_dev *dev,
... ... @@ -902,7 +885,7 @@
902 885 .enable_time = tps65910_enable_time,
903 886 .set_mode = tps65910_set_mode,
904 887 .get_mode = tps65910_get_mode,
905   - .get_voltage = tps65910_get_voltage,
  888 + .get_voltage_sel = tps65910_get_voltage_sel,
906 889 .set_voltage_sel = tps65910_set_voltage_sel,
907 890 .list_voltage = tps65910_list_voltage,
908 891 };
... ... @@ -914,7 +897,7 @@
914 897 .enable_time = tps65910_enable_time,
915 898 .set_mode = tps65910_set_mode,
916 899 .get_mode = tps65910_get_mode,
917   - .get_voltage = tps65911_get_voltage,
  900 + .get_voltage_sel = tps65911_get_voltage_sel,
918 901 .set_voltage_sel = tps65911_set_voltage_sel,
919 902 .list_voltage = tps65911_list_voltage,
920 903 };
drivers/regulator/tps65912-regulator.c
... ... @@ -20,7 +20,6 @@
20 20 #include <linux/platform_device.h>
21 21 #include <linux/regulator/driver.h>
22 22 #include <linux/regulator/machine.h>
23   -#include <linux/delay.h>
24 23 #include <linux/slab.h>
25 24 #include <linux/gpio.h>
26 25 #include <linux/mfd/tps65912.h>
... ... @@ -406,7 +405,7 @@
406 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 410 struct tps65912_reg *pmic = rdev_get_drvdata(dev);
412 411 struct tps65912 *mfd = pmic->mfd;
... ... @@ -420,7 +419,7 @@
420 419 vsel = tps65912_reg_read(mfd, reg);
421 420 vsel &= 0x3F;
422 421  
423   - return tps65912_list_voltage(dev, vsel);
  422 + return vsel;
424 423 }
425 424  
426 425 static int tps65912_set_voltage_sel(struct regulator_dev *dev,
... ... @@ -445,7 +444,7 @@
445 444 .disable = tps65912_reg_disable,
446 445 .set_mode = tps65912_set_mode,
447 446 .get_mode = tps65912_get_mode,
448   - .get_voltage = tps65912_get_voltage,
  447 + .get_voltage_sel = tps65912_get_voltage_sel,
449 448 .set_voltage_sel = tps65912_set_voltage_sel,
450 449 .list_voltage = tps65912_list_voltage,
451 450 };
... ... @@ -455,7 +454,7 @@
455 454 .is_enabled = tps65912_reg_is_enabled,
456 455 .enable = tps65912_reg_enable,
457 456 .disable = tps65912_reg_disable,
458   - .get_voltage = tps65912_get_voltage,
  457 + .get_voltage_sel = tps65912_get_voltage_sel,
459 458 .set_voltage_sel = tps65912_set_voltage_sel,
460 459 .list_voltage = tps65912_list_voltage,
461 460 };
drivers/regulator/twl-regulator.c
... ... @@ -12,7 +12,6 @@
12 12 #include <linux/module.h>
13 13 #include <linux/init.h>
14 14 #include <linux/err.h>
15   -#include <linux/delay.h>
16 15 #include <linux/platform_device.h>
17 16 #include <linux/of.h>
18 17 #include <linux/of_device.h>
19 18  
20 19  
... ... @@ -396,14 +395,12 @@
396 395 * VAUX3 at 3V is incorrectly listed in some TI manuals as unsupported.
397 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 398 #define UNSUP_MASK 0x8000
403   -#endif
404 399  
405 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 404 #define LDO_MV(x) (~UNSUP_MASK & (x))
408 405  
409 406  
... ... @@ -477,7 +474,7 @@
477 474 struct twlreg_info *info = rdev_get_drvdata(rdev);
478 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 480 static int
drivers/regulator/userspace-consumer.c
... ... @@ -115,7 +115,9 @@
115 115 if (!pdata)
116 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 121 if (drvdata == NULL)
120 122 return -ENOMEM;
121 123  
122 124  
123 125  
... ... @@ -125,16 +127,16 @@
125 127  
126 128 mutex_init(&drvdata->lock);
127 129  
128   - ret = regulator_bulk_get(&pdev->dev, drvdata->num_supplies,
129   - drvdata->supplies);
  130 + ret = devm_regulator_bulk_get(&pdev->dev, drvdata->num_supplies,
  131 + drvdata->supplies);
130 132 if (ret) {
131 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 137 ret = sysfs_create_group(&pdev->dev.kobj, &attr_group);
136 138 if (ret != 0)
137   - goto err_create_attrs;
  139 + return ret;
138 140  
139 141 if (pdata->init_on) {
140 142 ret = regulator_bulk_enable(drvdata->num_supplies,
... ... @@ -154,11 +156,6 @@
154 156 err_enable:
155 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 159 return ret;
163 160 }
164 161  
... ... @@ -170,9 +167,6 @@
170 167  
171 168 if (data->enabled)
172 169 regulator_bulk_disable(data->num_supplies, data->supplies);
173   -
174   - regulator_bulk_free(data->num_supplies, data->supplies);
175   - kfree(data);
176 170  
177 171 return 0;
178 172 }
drivers/regulator/virtual.c
... ... @@ -121,7 +121,7 @@
121 121 struct virtual_consumer_data *data = dev_get_drvdata(dev);
122 122 long val;
123 123  
124   - if (strict_strtol(buf, 10, &val) != 0)
  124 + if (kstrtol(buf, 10, &val) != 0)
125 125 return count;
126 126  
127 127 mutex_lock(&data->lock);
... ... @@ -147,7 +147,7 @@
147 147 struct virtual_consumer_data *data = dev_get_drvdata(dev);
148 148 long val;
149 149  
150   - if (strict_strtol(buf, 10, &val) != 0)
  150 + if (kstrtol(buf, 10, &val) != 0)
151 151 return count;
152 152  
153 153 mutex_lock(&data->lock);
... ... @@ -173,7 +173,7 @@
173 173 struct virtual_consumer_data *data = dev_get_drvdata(dev);
174 174 long val;
175 175  
176   - if (strict_strtol(buf, 10, &val) != 0)
  176 + if (kstrtol(buf, 10, &val) != 0)
177 177 return count;
178 178  
179 179 mutex_lock(&data->lock);
... ... @@ -199,7 +199,7 @@
199 199 struct virtual_consumer_data *data = dev_get_drvdata(dev);
200 200 long val;
201 201  
202   - if (strict_strtol(buf, 10, &val) != 0)
  202 + if (kstrtol(buf, 10, &val) != 0)
203 203 return count;
204 204  
205 205 mutex_lock(&data->lock);
206 206  
207 207  
... ... @@ -291,18 +291,19 @@
291 291 struct virtual_consumer_data *drvdata;
292 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 296 if (drvdata == NULL)
296 297 return -ENOMEM;
297 298  
298 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 302 if (IS_ERR(drvdata->regulator)) {
302 303 ret = PTR_ERR(drvdata->regulator);
303 304 dev_err(&pdev->dev, "Failed to obtain supply '%s': %d\n",
304 305 reg_id, ret);
305   - goto err;
  306 + return ret;
306 307 }
307 308  
308 309 ret = sysfs_create_group(&pdev->dev.kobj,
... ... @@ -310,7 +311,7 @@
310 311 if (ret != 0) {
311 312 dev_err(&pdev->dev,
312 313 "Failed to create attribute group: %d\n", ret);
313   - goto err_regulator;
  314 + return ret;
314 315 }
315 316  
316 317 drvdata->mode = regulator_get_mode(drvdata->regulator);
... ... @@ -318,12 +319,6 @@
318 319 platform_set_drvdata(pdev, drvdata);
319 320  
320 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 324 static int __devexit regulator_virtual_remove(struct platform_device *pdev)
... ... @@ -334,9 +329,6 @@
334 329  
335 330 if (drvdata->enabled)
336 331 regulator_disable(drvdata->regulator);
337   - regulator_put(drvdata->regulator);
338   -
339   - kfree(drvdata);
340 332  
341 333 platform_set_drvdata(pdev, NULL);
342 334  
drivers/regulator/wm831x-dcdc.c
... ... @@ -35,7 +35,7 @@
35 35 #define WM831X_DCDC_MODE_IDLE 2
36 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 40 /* Register offsets in control block */
41 41 #define WM831X_DCDC_CONTROL_1 0
... ... @@ -50,6 +50,7 @@
50 50  
51 51 struct wm831x_dcdc {
52 52 char name[WM831X_DCDC_MAX_NAME];
  53 + char supply_name[WM831X_DCDC_MAX_NAME];
53 54 struct regulator_desc desc;
54 55 int base;
55 56 struct wm831x *wm831x;
56 57  
57 58  
58 59  
... ... @@ -402,23 +403,17 @@
402 403 if (!pdata || !pdata->dvs_gpio)
403 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 406 /* gpiolib won't let us read the GPIO status so pick the higher
413 407 * of the two existing voltages so we take it as platform data.
414 408 */
415 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 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 416 dcdc->name, ret);
421   - gpio_free(pdata->dvs_gpio);
422 417 return;
423 418 }
424 419  
... ... @@ -496,6 +491,11 @@
496 491  
497 492 snprintf(dcdc->name, sizeof(dcdc->name), "DCDC%d", id + 1);
498 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 499 dcdc->desc.id = id;
500 500 dcdc->desc.type = REGULATOR_VOLTAGE;
501 501 dcdc->desc.n_voltages = WM831X_BUCKV_MAX_SELECTOR + 1;
... ... @@ -697,6 +697,11 @@
697 697  
698 698 snprintf(dcdc->name, sizeof(dcdc->name), "DCDC%d", id + 1);
699 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 705 dcdc->desc.id = id;
701 706 dcdc->desc.type = REGULATOR_VOLTAGE;
702 707 dcdc->desc.n_voltages = WM831X_BUCKP_MAX_SELECTOR + 1;
drivers/regulator/wm831x-ldo.c
... ... @@ -25,7 +25,7 @@
25 25 #include <linux/mfd/wm831x/regulator.h>
26 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 30 #define WM831X_LDO_CONTROL 0
31 31 #define WM831X_LDO_ON_CONTROL 1
... ... @@ -36,6 +36,7 @@
36 36  
37 37 struct wm831x_ldo {
38 38 char name[WM831X_LDO_MAX_NAME];
  39 + char supply_name[WM831X_LDO_MAX_NAME];
39 40 struct regulator_desc desc;
40 41 int base;
41 42 struct wm831x *wm831x;
... ... @@ -291,6 +292,11 @@
291 292  
292 293 snprintf(ldo->name, sizeof(ldo->name), "LDO%d", id + 1);
293 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 300 ldo->desc.id = id;
295 301 ldo->desc.type = REGULATOR_VOLTAGE;
296 302 ldo->desc.n_voltages = WM831X_GP_LDO_MAX_SELECTOR + 1;
... ... @@ -547,6 +553,11 @@
547 553  
548 554 snprintf(ldo->name, sizeof(ldo->name), "LDO%d", id + 1);
549 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 561 ldo->desc.id = id;
551 562 ldo->desc.type = REGULATOR_VOLTAGE;
552 563 ldo->desc.n_voltages = WM831X_ALDO_MAX_SELECTOR + 1;
... ... @@ -733,6 +744,11 @@
733 744  
734 745 snprintf(ldo->name, sizeof(ldo->name), "LDO%d", id + 1);
735 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 752 ldo->desc.id = id;
737 753 ldo->desc.type = REGULATOR_VOLTAGE;
738 754 ldo->desc.n_voltages = WM831X_ALIVE_LDO_MAX_SELECTOR + 1;
drivers/regulator/wm8994-regulator.c
... ... @@ -182,23 +182,16 @@
182 182 if (pdata->ldo[id].enable && gpio_is_valid(pdata->ldo[id].enable)) {
183 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 186 if (ret < 0) {
187 187 dev_err(&pdev->dev, "Failed to get enable GPIO: %d\n",
188 188 ret);
189 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 191 } else
199 192 ldo->is_enabled = true;
200 193  
201   - config.dev = &pdev->dev;
  194 + config.dev = wm8994->dev;
202 195 config.init_data = pdata->ldo[id].init_data;
203 196 config.driver_data = ldo;
204 197 config.regmap = wm8994->regmap;
include/linux/i2c/twl.h
... ... @@ -171,8 +171,6 @@
171 171 TWL_CLASS_IS(4030, TWL4030_CLASS_ID)
172 172 TWL_CLASS_IS(6030, TWL6030_CLASS_ID)
173 173  
174   -#define TWL6025_SUBCLASS BIT(4) /* TWL6025 has changed registers */
175   -
176 174 /*
177 175 * Read and write single 8-bit registers
178 176 */
... ... @@ -746,6 +744,17 @@
746 744 void *data;
747 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  
include/linux/mfd/tps6586x.h
... ... @@ -68,6 +68,7 @@
68 68 int id;
69 69 const char *name;
70 70 void *platform_data;
  71 + struct device_node *of_node;
71 72 };
72 73  
73 74 struct tps6586x_platform_data {
include/linux/regulator/of_regulator.h
... ... @@ -6,16 +6,34 @@
6 6 #ifndef __LINUX_OF_REG_H
7 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 16 #if defined(CONFIG_OF)
10 17 extern struct regulator_init_data
11 18 *of_get_regulator_init_data(struct device *dev,
12 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 23 #else
14 24 static inline struct regulator_init_data
15 25 *of_get_regulator_init_data(struct device *dev,
16 26 struct device_node *node)
17 27 {
18 28 return NULL;
  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;
19 37 }
20 38 #endif /* CONFIG_OF */
21 39