Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

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

+559 -304
+4 -1
Documentation/devicetree/bindings/regulator/fixed-regulator.txt
··· 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. ··· 27 25 gpio = <&gpio1 16 0>; 28 26 startup-delay-us = <70000>; 29 27 enable-active-high; 30 - regulator-boot-on 28 + regulator-boot-on; 29 + gpio-open-drain; 31 30 };
+97
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 + };
+86
drivers/mfd/tps6586x.c
··· 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> ··· 461 460 462 461 pdev->dev.parent = tps6586x->dev; 463 462 pdev->dev.platform_data = subdev->platform_data; 463 + pdev->dev.of_node = subdev->of_node; 464 464 465 465 ret = platform_device_add(pdev); 466 466 if (ret) { ··· 476 474 return ret; 477 475 } 478 476 477 + #ifdef CONFIG_OF 478 + static struct of_regulator_match tps6586x_matches[] = { 479 + { .name = "sm0", .driver_data = (void *)TPS6586X_ID_SM_0 }, 480 + { .name = "sm1", .driver_data = (void *)TPS6586X_ID_SM_1 }, 481 + { .name = "sm2", .driver_data = (void *)TPS6586X_ID_SM_2 }, 482 + { .name = "ldo0", .driver_data = (void *)TPS6586X_ID_LDO_0 }, 483 + { .name = "ldo1", .driver_data = (void *)TPS6586X_ID_LDO_1 }, 484 + { .name = "ldo2", .driver_data = (void *)TPS6586X_ID_LDO_2 }, 485 + { .name = "ldo3", .driver_data = (void *)TPS6586X_ID_LDO_3 }, 486 + { .name = "ldo4", .driver_data = (void *)TPS6586X_ID_LDO_4 }, 487 + { .name = "ldo5", .driver_data = (void *)TPS6586X_ID_LDO_5 }, 488 + { .name = "ldo6", .driver_data = (void *)TPS6586X_ID_LDO_6 }, 489 + { .name = "ldo7", .driver_data = (void *)TPS6586X_ID_LDO_7 }, 490 + { .name = "ldo8", .driver_data = (void *)TPS6586X_ID_LDO_8 }, 491 + { .name = "ldo9", .driver_data = (void *)TPS6586X_ID_LDO_9 }, 492 + { .name = "ldo_rtc", .driver_data = (void *)TPS6586X_ID_LDO_RTC }, 493 + }; 494 + 495 + static struct tps6586x_platform_data *tps6586x_parse_dt(struct i2c_client *client) 496 + { 497 + const unsigned int num = ARRAY_SIZE(tps6586x_matches); 498 + struct device_node *np = client->dev.of_node; 499 + struct tps6586x_platform_data *pdata; 500 + struct tps6586x_subdev_info *devs; 501 + struct device_node *regs; 502 + unsigned int count; 503 + unsigned int i, j; 504 + int err; 505 + 506 + regs = of_find_node_by_name(np, "regulators"); 507 + if (!regs) 508 + return NULL; 509 + 510 + err = of_regulator_match(&client->dev, regs, tps6586x_matches, num); 511 + if (err < 0) { 512 + of_node_put(regs); 513 + return NULL; 514 + } 515 + 516 + of_node_put(regs); 517 + count = err; 518 + 519 + devs = devm_kzalloc(&client->dev, count * sizeof(*devs), GFP_KERNEL); 520 + if (!devs) 521 + return NULL; 522 + 523 + for (i = 0, j = 0; i < num && j < count; i++) { 524 + if (!tps6586x_matches[i].init_data) 525 + continue; 526 + 527 + devs[j].name = "tps6586x-regulator"; 528 + devs[j].platform_data = tps6586x_matches[i].init_data; 529 + devs[j].id = (int)tps6586x_matches[i].driver_data; 530 + devs[j].of_node = tps6586x_matches[i].of_node; 531 + j++; 532 + } 533 + 534 + pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL); 535 + if (!pdata) 536 + return NULL; 537 + 538 + pdata->num_subdevs = count; 539 + pdata->subdevs = devs; 540 + pdata->gpio_base = -1; 541 + pdata->irq_base = -1; 542 + 543 + return pdata; 544 + } 545 + 546 + static struct of_device_id tps6586x_of_match[] = { 547 + { .compatible = "ti,tps6586x", }, 548 + { }, 549 + }; 550 + #else 551 + static struct tps6586x_platform_data *tps6586x_parse_dt(struct i2c_client *client) 552 + { 553 + return NULL; 554 + } 555 + #endif 556 + 479 557 static int __devinit tps6586x_i2c_probe(struct i2c_client *client, 480 558 const struct i2c_device_id *id) 481 559 { 482 560 struct tps6586x_platform_data *pdata = client->dev.platform_data; 483 561 struct tps6586x *tps6586x; 484 562 int ret; 563 + 564 + if (!pdata && client->dev.of_node) 565 + pdata = tps6586x_parse_dt(client); 485 566 486 567 if (!pdata) { 487 568 dev_err(&client->dev, "tps6586x requires platform data\n"); ··· 658 573 .driver = { 659 574 .name = "tps6586x", 660 575 .owner = THIS_MODULE, 576 + .of_match_table = of_match_ptr(tps6586x_of_match), 661 577 }, 662 578 .probe = tps6586x_i2c_probe, 663 579 .remove = __devexit_p(tps6586x_i2c_remove),
-7
drivers/mfd/twl-core.c
··· 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? */
-1
drivers/regulator/aat2870-regulator.c
··· 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>
-1
drivers/regulator/ab3100.c
··· 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>
+2 -1
drivers/regulator/da9052-regulator.c
··· 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 ··· 394 393 if (!nproot) 395 394 return -ENODEV; 396 395 397 - for (np = of_get_next_child(nproot, NULL); !np; 396 + for (np = of_get_next_child(nproot, NULL); np; 398 397 np = of_get_next_child(nproot, np)) { 399 398 if (!of_node_cmp(np->name, 400 399 regulator->info->reg_desc.name)) {
+3 -1
drivers/regulator/fixed.c
··· 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> ··· 89 90 90 91 if (of_find_property(np, "enable-active-high", NULL)) 91 92 config->enable_high = true; 93 + 94 + if (of_find_property(np, "gpio-open-drain", NULL)) 95 + config->gpio_is_open_drain = true; 92 96 93 97 return config; 94 98 }
-1
drivers/regulator/gpio-regulator.c
··· 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 {
-1
drivers/regulator/isl6271a-regulator.c
··· 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
+1 -1
drivers/regulator/max8660.c
··· 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)
+4 -9
drivers/regulator/max8952.c
··· 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 { ··· 77 82 if (rdev_get_id(rdev) != 0) 78 83 return -EINVAL; 79 84 80 - return max8952_voltage(max8952, selector); 85 + return (max8952->pdata->dvs_mode[selector] * 10 + 770) * 1000; 81 86 } 82 87 83 88 static int max8952_is_enabled(struct regulator_dev *rdev) ··· 112 117 return 0; 113 118 } 114 119 115 - static int max8952_get_voltage(struct regulator_dev *rdev) 120 + static int max8952_get_voltage_sel(struct regulator_dev *rdev) 116 121 { 117 122 struct max8952_data *max8952 = rdev_get_drvdata(rdev); 118 123 u8 vid = 0; ··· 122 127 if (max8952->vid1) 123 128 vid += 2; 124 129 125 - return max8952_voltage(max8952, vid); 130 + return vid; 126 131 } 127 132 128 133 static int max8952_set_voltage_sel(struct regulator_dev *rdev, ··· 149 154 .is_enabled = max8952_is_enabled, 150 155 .enable = max8952_enable, 151 156 .disable = max8952_disable, 152 - .get_voltage = max8952_get_voltage, 157 + .get_voltage_sel = max8952_get_voltage_sel, 153 158 .set_voltage_sel = max8952_set_voltage_sel, 154 159 .set_suspend_disable = max8952_disable, 155 160 };
+90 -73
drivers/regulator/max8997.c
··· 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> ··· 277 278 u8 val; 278 279 279 280 ret = max8997_get_enable_register(rdev, &reg, &mask, &pattern); 280 - if (ret == -EINVAL) 281 - return 1; /* "not controllable" */ 282 - else if (ret) 281 + if (ret) 283 282 return ret; 284 283 285 284 ret = max8997_read_reg(i2c, reg, &val); ··· 379 382 return 0; 380 383 } 381 384 382 - static int max8997_get_voltage(struct regulator_dev *rdev) 385 + static int max8997_get_voltage_sel(struct regulator_dev *rdev) 383 386 { 384 387 struct max8997_data *max8997 = rdev_get_drvdata(rdev); 385 388 struct i2c_client *i2c = max8997->iodev->i2c; ··· 397 400 val >>= shift; 398 401 val &= mask; 399 402 400 - if (rdev->desc && rdev->desc->ops && rdev->desc->ops->list_voltage) 401 - return rdev->desc->ops->list_voltage(rdev, val); 402 - 403 - /* 404 - * max8997_list_voltage returns value for any rdev with voltage_map, 405 - * which works for "CHARGER" and "CHARGER TOPOFF" that do not have 406 - * list_voltage ops (they are current regulators). 407 - */ 408 - return max8997_list_voltage(rdev, val); 403 + return val; 409 404 } 410 405 411 406 static inline int max8997_get_voltage_proper_val( ··· 486 497 int min_vol = min_uV / 1000, max_vol = max_uV / 1000; 487 498 const struct voltage_map_desc *desc; 488 499 int rid = rdev_get_id(rdev); 489 - int reg, shift = 0, mask, ret; 490 - int i; 491 - u8 org; 500 + int i, reg, shift, mask, ret; 492 501 493 502 switch (rid) { 494 503 case MAX8997_LDO1 ... MAX8997_LDO21: ··· 515 528 if (ret) 516 529 return ret; 517 530 518 - max8997_read_reg(i2c, reg, &org); 519 - org = (org & mask) >> shift; 520 - 521 531 ret = max8997_update_reg(i2c, reg, i << shift, mask << shift); 522 532 *selector = i; 523 533 524 - if (rid == MAX8997_BUCK1 || rid == MAX8997_BUCK2 || 525 - rid == MAX8997_BUCK4 || rid == MAX8997_BUCK5) { 526 - /* If the voltage is increasing */ 527 - if (org < i) 528 - udelay(DIV_ROUND_UP(desc->step * (i - org), 529 - max8997->ramp_delay)); 534 + return ret; 535 + } 536 + 537 + static int max8997_set_voltage_ldobuck_time_sel(struct regulator_dev *rdev, 538 + unsigned int old_selector, 539 + unsigned int new_selector) 540 + { 541 + struct max8997_data *max8997 = rdev_get_drvdata(rdev); 542 + int rid = rdev_get_id(rdev); 543 + const struct voltage_map_desc *desc = reg_voltage_map[rid]; 544 + 545 + /* Delay is required only if the voltage is increasing */ 546 + if (old_selector >= new_selector) 547 + return 0; 548 + 549 + /* No need to delay if gpio_dvs_mode */ 550 + switch (rid) { 551 + case MAX8997_BUCK1: 552 + if (max8997->buck1_gpiodvs) 553 + return 0; 554 + break; 555 + case MAX8997_BUCK2: 556 + if (max8997->buck2_gpiodvs) 557 + return 0; 558 + break; 559 + case MAX8997_BUCK5: 560 + if (max8997->buck5_gpiodvs) 561 + return 0; 562 + break; 530 563 } 531 564 532 - return ret; 565 + switch (rid) { 566 + case MAX8997_BUCK1: 567 + case MAX8997_BUCK2: 568 + case MAX8997_BUCK4: 569 + case MAX8997_BUCK5: 570 + return DIV_ROUND_UP(desc->step * (new_selector - old_selector), 571 + max8997->ramp_delay); 572 + } 573 + 574 + return 0; 533 575 } 534 576 535 577 /* ··· 765 749 return ret; 766 750 } 767 751 768 - static int max8997_reg_enable_suspend(struct regulator_dev *rdev) 769 - { 770 - return 0; 771 - } 772 - 773 752 static int max8997_reg_disable_suspend(struct regulator_dev *rdev) 774 753 { 775 754 struct max8997_data *max8997 = rdev_get_drvdata(rdev); ··· 797 786 .is_enabled = max8997_reg_is_enabled, 798 787 .enable = max8997_reg_enable, 799 788 .disable = max8997_reg_disable, 800 - .get_voltage = max8997_get_voltage, 789 + .get_voltage_sel = max8997_get_voltage_sel, 801 790 .set_voltage = max8997_set_voltage_ldobuck, 802 - .set_suspend_enable = max8997_reg_enable_suspend, 791 + .set_voltage_time_sel = max8997_set_voltage_ldobuck_time_sel, 803 792 .set_suspend_disable = max8997_reg_disable_suspend, 804 793 }; 805 794 ··· 808 797 .is_enabled = max8997_reg_is_enabled, 809 798 .enable = max8997_reg_enable, 810 799 .disable = max8997_reg_disable, 811 - .get_voltage = max8997_get_voltage, 800 + .get_voltage_sel = max8997_get_voltage_sel, 812 801 .set_voltage = max8997_set_voltage_buck, 813 - .set_suspend_enable = max8997_reg_enable_suspend, 802 + .set_voltage_time_sel = max8997_set_voltage_ldobuck_time_sel, 814 803 .set_suspend_disable = max8997_reg_disable_suspend, 815 804 }; 816 805 ··· 819 808 .is_enabled = max8997_reg_is_enabled, 820 809 .enable = max8997_reg_enable, 821 810 .disable = max8997_reg_disable, 822 - .set_suspend_enable = max8997_reg_enable_suspend, 823 811 .set_suspend_disable = max8997_reg_disable_suspend, 824 812 }; 825 813 ··· 827 817 .is_enabled = max8997_reg_is_enabled, 828 818 .enable = max8997_reg_enable, 829 819 .disable = max8997_reg_disable, 830 - .get_voltage = max8997_get_voltage, 820 + .get_voltage_sel = max8997_get_voltage_sel, 831 821 .set_voltage = max8997_set_voltage_safeout, 832 - .set_suspend_enable = max8997_reg_enable_suspend, 833 822 .set_suspend_disable = max8997_reg_disable_suspend, 834 823 }; 835 824 836 825 static struct regulator_ops max8997_fixedstate_ops = { 837 826 .list_voltage = max8997_list_voltage_charger_cv, 838 - .get_voltage = max8997_get_voltage, 827 + .get_voltage_sel = max8997_get_voltage_sel, 839 828 .set_voltage = max8997_set_voltage_charger_cv, 840 829 }; 841 830 842 - static int max8997_set_voltage_ldobuck_wrap(struct regulator_dev *rdev, 843 - int min_uV, int max_uV) 831 + static int max8997_set_current_limit(struct regulator_dev *rdev, 832 + int min_uA, int max_uA) 844 833 { 845 834 unsigned dummy; 835 + int rid = rdev_get_id(rdev); 846 836 847 - return max8997_set_voltage_ldobuck(rdev, min_uV, max_uV, &dummy); 837 + if (rid != MAX8997_CHARGER && rid != MAX8997_CHARGER_TOPOFF) 838 + return -EINVAL; 839 + 840 + /* Reuse max8997_set_voltage_ldobuck to set current_limit. */ 841 + return max8997_set_voltage_ldobuck(rdev, min_uA, max_uA, &dummy); 848 842 } 849 843 844 + static int max8997_get_current_limit(struct regulator_dev *rdev) 845 + { 846 + int sel, rid = rdev_get_id(rdev); 847 + 848 + if (rid != MAX8997_CHARGER && rid != MAX8997_CHARGER_TOPOFF) 849 + return -EINVAL; 850 + 851 + sel = max8997_get_voltage_sel(rdev); 852 + if (sel < 0) 853 + return sel; 854 + 855 + /* Reuse max8997_list_voltage to get current_limit. */ 856 + return max8997_list_voltage(rdev, sel); 857 + } 850 858 851 859 static struct regulator_ops max8997_charger_ops = { 852 860 .is_enabled = max8997_reg_is_enabled, 853 861 .enable = max8997_reg_enable, 854 862 .disable = max8997_reg_disable, 855 - .get_current_limit = max8997_get_voltage, 856 - .set_current_limit = max8997_set_voltage_ldobuck_wrap, 863 + .get_current_limit = max8997_get_current_limit, 864 + .set_current_limit = max8997_set_current_limit, 857 865 }; 858 866 859 867 static struct regulator_ops max8997_charger_fixedstate_ops = { 860 - .is_enabled = max8997_reg_is_enabled, 861 - .get_current_limit = max8997_get_voltage, 862 - .set_current_limit = max8997_set_voltage_ldobuck_wrap, 868 + .get_current_limit = max8997_get_current_limit, 869 + .set_current_limit = max8997_set_current_limit, 863 870 }; 864 871 865 872 #define MAX8997_VOLTAGE_REGULATOR(_name, _ops) {\ ··· 949 922 return -ENODEV; 950 923 } 951 924 952 - max8997 = kzalloc(sizeof(struct max8997_data), GFP_KERNEL); 925 + max8997 = devm_kzalloc(&pdev->dev, sizeof(struct max8997_data), 926 + GFP_KERNEL); 953 927 if (!max8997) 954 928 return -ENOMEM; 955 929 956 930 size = sizeof(struct regulator_dev *) * pdata->num_regulators; 957 - max8997->rdev = kzalloc(size, GFP_KERNEL); 958 - if (!max8997->rdev) { 959 - kfree(max8997); 931 + max8997->rdev = devm_kzalloc(&pdev->dev, size, GFP_KERNEL); 932 + if (!max8997->rdev) 960 933 return -ENOMEM; 961 - } 962 934 963 935 rdev = max8997->rdev; 964 936 max8997->dev = &pdev->dev; ··· 981 955 pdata->buck1_voltage[i] / 1000 + 982 956 buck1245_voltage_map_desc.step); 983 957 if (ret < 0) 984 - goto err_alloc; 958 + goto err_out; 985 959 986 960 max8997->buck2_vol[i] = ret = 987 961 max8997_get_voltage_proper_val( ··· 990 964 pdata->buck2_voltage[i] / 1000 + 991 965 buck1245_voltage_map_desc.step); 992 966 if (ret < 0) 993 - goto err_alloc; 967 + goto err_out; 994 968 995 969 max8997->buck5_vol[i] = ret = 996 970 max8997_get_voltage_proper_val( ··· 999 973 pdata->buck5_voltage[i] / 1000 + 1000 974 buck1245_voltage_map_desc.step); 1001 975 if (ret < 0) 1002 - goto err_alloc; 976 + goto err_out; 1003 977 1004 978 if (max_buck1 < max8997->buck1_vol[i]) 1005 979 max_buck1 = max8997->buck1_vol[i]; ··· 1032 1006 !gpio_is_valid(pdata->buck125_gpios[2])) { 1033 1007 dev_err(&pdev->dev, "GPIO NOT VALID\n"); 1034 1008 ret = -EINVAL; 1035 - goto err_alloc; 1009 + goto err_out; 1036 1010 } 1037 1011 1038 1012 ret = gpio_request(pdata->buck125_gpios[0], ··· 1041 1015 dev_warn(&pdev->dev, "Duplicated gpio request" 1042 1016 " on SET1\n"); 1043 1017 else if (ret) 1044 - goto err_alloc; 1018 + goto err_out; 1045 1019 else 1046 1020 gpio1set = true; 1047 1021 ··· 1053 1027 else if (ret) { 1054 1028 if (gpio1set) 1055 1029 gpio_free(pdata->buck125_gpios[0]); 1056 - goto err_alloc; 1030 + goto err_out; 1057 1031 } else 1058 1032 gpio2set = true; 1059 1033 ··· 1067 1041 gpio_free(pdata->buck125_gpios[0]); 1068 1042 if (gpio2set) 1069 1043 gpio_free(pdata->buck125_gpios[1]); 1070 - goto err_alloc; 1044 + goto err_out; 1071 1045 } 1072 1046 1073 1047 gpio_direction_output(pdata->buck125_gpios[0], ··· 1136 1110 1137 1111 return 0; 1138 1112 err: 1139 - for (i = 0; i < max8997->num_regulators; i++) 1140 - if (rdev[i]) 1141 - regulator_unregister(rdev[i]); 1142 - err_alloc: 1143 - kfree(max8997->rdev); 1144 - kfree(max8997); 1145 - 1113 + while (--i >= 0) 1114 + regulator_unregister(rdev[i]); 1115 + err_out: 1146 1116 return ret; 1147 1117 } 1148 1118 ··· 1149 1127 int i; 1150 1128 1151 1129 for (i = 0; i < max8997->num_regulators; i++) 1152 - if (rdev[i]) 1153 - regulator_unregister(rdev[i]); 1154 - 1155 - kfree(max8997->rdev); 1156 - kfree(max8997); 1157 - 1130 + regulator_unregister(rdev[i]); 1158 1131 return 0; 1159 1132 } 1160 1133
+17 -29
drivers/regulator/max8998.c
··· 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> ··· 718 719 return -ENODEV; 719 720 } 720 721 721 - max8998 = kzalloc(sizeof(struct max8998_data), GFP_KERNEL); 722 + max8998 = devm_kzalloc(&pdev->dev, sizeof(struct max8998_data), 723 + GFP_KERNEL); 722 724 if (!max8998) 723 725 return -ENOMEM; 724 726 725 727 size = sizeof(struct regulator_dev *) * pdata->num_regulators; 726 - max8998->rdev = kzalloc(size, GFP_KERNEL); 727 - if (!max8998->rdev) { 728 - kfree(max8998); 728 + max8998->rdev = devm_kzalloc(&pdev->dev, size, GFP_KERNEL); 729 + if (!max8998->rdev) 729 730 return -ENOMEM; 730 - } 731 731 732 732 rdev = max8998->rdev; 733 733 max8998->dev = &pdev->dev; ··· 750 752 printk(KERN_ERR "MAX8998 SET1 GPIO defined as 0 !\n"); 751 753 WARN_ON(!pdata->buck1_set1); 752 754 ret = -EIO; 753 - goto err_free_mem; 755 + goto err_out; 754 756 } 755 757 /* Check if SET2 is not equal to 0 */ 756 758 if (!pdata->buck1_set2) { 757 759 printk(KERN_ERR "MAX8998 SET2 GPIO defined as 0 !\n"); 758 760 WARN_ON(!pdata->buck1_set2); 759 761 ret = -EIO; 760 - goto err_free_mem; 762 + goto err_out; 761 763 } 762 764 763 765 gpio_request(pdata->buck1_set1, "MAX8998 BUCK1_SET1"); ··· 777 779 max8998->buck1_vol[0] = i; 778 780 ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE1, i); 779 781 if (ret) 780 - goto err_free_mem; 782 + goto err_out; 781 783 782 784 /* Set predefined value for BUCK1 register 2 */ 783 785 i = 0; ··· 789 791 max8998->buck1_vol[1] = i; 790 792 ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE2, i); 791 793 if (ret) 792 - goto err_free_mem; 794 + goto err_out; 793 795 794 796 /* Set predefined value for BUCK1 register 3 */ 795 797 i = 0; ··· 801 803 max8998->buck1_vol[2] = i; 802 804 ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE3, i); 803 805 if (ret) 804 - goto err_free_mem; 806 + goto err_out; 805 807 806 808 /* Set predefined value for BUCK1 register 4 */ 807 809 i = 0; ··· 813 815 max8998->buck1_vol[3] = i; 814 816 ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE4, i); 815 817 if (ret) 816 - goto err_free_mem; 818 + goto err_out; 817 819 818 820 } 819 821 ··· 823 825 printk(KERN_ERR "MAX8998 SET3 GPIO defined as 0 !\n"); 824 826 WARN_ON(!pdata->buck2_set3); 825 827 ret = -EIO; 826 - goto err_free_mem; 828 + goto err_out; 827 829 } 828 830 gpio_request(pdata->buck2_set3, "MAX8998 BUCK2_SET3"); 829 831 gpio_direction_output(pdata->buck2_set3, ··· 838 840 max8998->buck2_vol[0] = i; 839 841 ret = max8998_write_reg(i2c, MAX8998_REG_BUCK2_VOLTAGE1, i); 840 842 if (ret) 841 - goto err_free_mem; 843 + goto err_out; 842 844 843 845 /* BUCK2 register 2 */ 844 846 i = 0; ··· 849 851 max8998->buck2_vol[1] = i; 850 852 ret = max8998_write_reg(i2c, MAX8998_REG_BUCK2_VOLTAGE2, i); 851 853 if (ret) 852 - goto err_free_mem; 854 + goto err_out; 853 855 } 854 856 855 857 for (i = 0; i < pdata->num_regulators; i++) { ··· 879 881 880 882 return 0; 881 883 err: 882 - for (i = 0; i < max8998->num_regulators; i++) 883 - if (rdev[i]) 884 - regulator_unregister(rdev[i]); 885 - 886 - err_free_mem: 887 - kfree(max8998->rdev); 888 - kfree(max8998); 889 - 884 + while (--i >= 0) 885 + regulator_unregister(rdev[i]); 886 + err_out: 890 887 return ret; 891 888 } 892 889 ··· 892 899 int i; 893 900 894 901 for (i = 0; i < max8998->num_regulators; i++) 895 - if (rdev[i]) 896 - regulator_unregister(rdev[i]); 897 - 898 - kfree(max8998->rdev); 899 - kfree(max8998); 900 - 902 + regulator_unregister(rdev[i]); 901 903 return 0; 902 904 } 903 905
+47
drivers/regulator/of_regulator.c
··· 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) ··· 86 85 return init_data; 87 86 } 88 87 EXPORT_SYMBOL_GPL(of_get_regulator_init_data); 88 + 89 + /** 90 + * of_regulator_match - extract regulator init data 91 + * @dev: device requesting the data 92 + * @node: parent device node of the regulators 93 + * @matches: match table for the regulators 94 + * @num_matches: number of entries in match table 95 + * 96 + * This function uses a match table specified by the regulator driver and 97 + * looks up the corresponding init data in the device tree. Note that the 98 + * match table is modified in place. 99 + * 100 + * Returns the number of matches found or a negative error code on failure. 101 + */ 102 + int of_regulator_match(struct device *dev, struct device_node *node, 103 + struct of_regulator_match *matches, 104 + unsigned int num_matches) 105 + { 106 + unsigned int count = 0; 107 + unsigned int i; 108 + 109 + if (!dev || !node) 110 + return -EINVAL; 111 + 112 + for (i = 0; i < num_matches; i++) { 113 + struct of_regulator_match *match = &matches[i]; 114 + struct device_node *child; 115 + 116 + child = of_find_node_by_name(node, match->name); 117 + if (!child) 118 + continue; 119 + 120 + match->init_data = of_get_regulator_init_data(dev, child); 121 + if (!match->init_data) { 122 + dev_err(dev, "failed to parse DT for regulator %s\n", 123 + child->name); 124 + return -EINVAL; 125 + } 126 + 127 + match->of_node = child; 128 + count++; 129 + } 130 + 131 + return count; 132 + } 133 + EXPORT_SYMBOL_GPL(of_regulator_match);
-1
drivers/regulator/rc5t583-regulator.c
··· 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>
+4 -2
drivers/regulator/s5m8767.c
··· 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> ··· 346 347 if (max_vol < desc->min || min_vol > desc->max) 347 348 return -EINVAL; 348 349 349 - selector = (min_vol - desc->min) / desc->step; 350 + if (min_vol < desc->min) 351 + min_vol = desc->min; 352 + 353 + selector = DIV_ROUND_UP(min_vol - desc->min, desc->step); 350 354 351 355 if (desc->min + desc->step * selector > max_vol) 352 356 return -EINVAL;
+102 -78
drivers/regulator/tps62360-regulator.c
··· 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 ··· 47 48 48 49 enum chips {TPS62360, TPS62361, TPS62362, TPS62363}; 49 50 50 - #define TPS62360_BASE_VOLTAGE 770 51 + #define TPS62360_BASE_VOLTAGE 770000 51 52 #define TPS62360_N_VOLTAGES 64 52 53 53 - #define TPS62361_BASE_VOLTAGE 500 54 + #define TPS62361_BASE_VOLTAGE 500000 54 55 #define TPS62361_N_VOLTAGES 128 55 56 56 57 /* tps 62360 chip information */ ··· 71 72 int lru_index[4]; 72 73 int curr_vset_vsel[4]; 73 74 int curr_vset_id; 75 + int change_uv_per_us; 74 76 }; 75 77 76 78 /* ··· 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]; ··· 116 115 return found; 117 116 } 118 117 119 - static int tps62360_dcdc_get_voltage(struct regulator_dev *dev) 118 + static int tps62360_dcdc_get_voltage_sel(struct regulator_dev *dev) 120 119 { 121 120 struct tps62360_chip *tps = rdev_get_drvdata(dev); 122 121 int vsel; ··· 125 124 126 125 ret = regmap_read(tps->regmap, REG_VSET0 + tps->curr_vset_id, &data); 127 126 if (ret < 0) { 128 - dev_err(tps->dev, "%s: Error in reading register %d\n", 129 - __func__, REG_VSET0 + tps->curr_vset_id); 127 + dev_err(tps->dev, "%s(): register %d read failed with err %d\n", 128 + __func__, REG_VSET0 + tps->curr_vset_id, ret); 130 129 return ret; 131 130 } 132 131 vsel = (int)data & tps->voltage_reg_mask; 133 - return (tps->voltage_base + vsel * 10) * 1000; 132 + return vsel; 134 133 } 135 134 136 135 static int tps62360_dcdc_set_voltage(struct regulator_dev *dev, ··· 142 141 bool found = false; 143 142 int new_vset_id = tps->curr_vset_id; 144 143 145 - if (max_uV < min_uV) 144 + if ((max_uV < min_uV) || (max_uV < tps->voltage_base)) 146 145 return -EINVAL; 147 146 148 - if (min_uV > 149 - ((tps->voltage_base + (tps->desc.n_voltages - 1) * 10) * 1000)) 147 + if (min_uV > (tps->voltage_base + (tps->desc.n_voltages - 1) * 10000)) 150 148 return -EINVAL; 151 149 152 - if (max_uV < tps->voltage_base * 1000) 153 - return -EINVAL; 154 - 155 - vsel = DIV_ROUND_UP(min_uV - (tps->voltage_base * 1000), 10000); 150 + vsel = DIV_ROUND_UP(min_uV - tps->voltage_base, 10000); 156 151 if (selector) 157 152 *selector = (vsel & tps->voltage_reg_mask); 158 153 ··· 163 166 ret = regmap_update_bits(tps->regmap, REG_VSET0 + new_vset_id, 164 167 tps->voltage_reg_mask, vsel); 165 168 if (ret < 0) { 166 - dev_err(tps->dev, "%s: Error in updating register %d\n", 167 - __func__, REG_VSET0 + new_vset_id); 169 + dev_err(tps->dev, 170 + "%s(): register %d update failed with err %d\n", 171 + __func__, REG_VSET0 + new_vset_id, ret); 168 172 return ret; 169 173 } 170 174 tps->curr_vset_id = new_vset_id; ··· 174 176 175 177 /* Select proper VSET register vio gpios */ 176 178 if (tps->valid_gpios) { 177 - gpio_set_value_cansleep(tps->vsel0_gpio, 178 - new_vset_id & 0x1); 179 + gpio_set_value_cansleep(tps->vsel0_gpio, new_vset_id & 0x1); 179 180 gpio_set_value_cansleep(tps->vsel1_gpio, 180 181 (new_vset_id >> 1) & 0x1); 181 182 } ··· 188 191 189 192 if (selector >= tps->desc.n_voltages) 190 193 return -EINVAL; 191 - return (tps->voltage_base + selector * 10) * 1000; 194 + 195 + return tps->voltage_base + selector * 10000; 196 + } 197 + 198 + static int tps62360_set_voltage_time_sel(struct regulator_dev *rdev, 199 + unsigned int old_selector, unsigned int new_selector) 200 + { 201 + struct tps62360_chip *tps = rdev_get_drvdata(rdev); 202 + int old_uV, new_uV; 203 + 204 + old_uV = tps62360_dcdc_list_voltage(rdev, old_selector); 205 + if (old_uV < 0) 206 + return old_uV; 207 + 208 + new_uV = tps62360_dcdc_list_voltage(rdev, new_selector); 209 + if (new_uV < 0) 210 + return new_uV; 211 + 212 + return DIV_ROUND_UP(abs(old_uV - new_uV), tps->change_uv_per_us); 192 213 } 193 214 194 215 static struct regulator_ops tps62360_dcdc_ops = { 195 - .get_voltage = tps62360_dcdc_get_voltage, 196 - .set_voltage = tps62360_dcdc_set_voltage, 197 - .list_voltage = tps62360_dcdc_list_voltage, 216 + .get_voltage_sel = tps62360_dcdc_get_voltage_sel, 217 + .set_voltage = tps62360_dcdc_set_voltage, 218 + .list_voltage = tps62360_dcdc_list_voltage, 219 + .set_voltage_time_sel = tps62360_set_voltage_time_sel, 198 220 }; 199 221 200 - static int tps62360_init_force_pwm(struct tps62360_chip *tps, 222 + static int __devinit tps62360_init_force_pwm(struct tps62360_chip *tps, 201 223 struct tps62360_regulator_platform_data *pdata, 202 224 int vset_id) 203 225 { 204 - unsigned int data; 205 226 int ret; 206 - ret = regmap_read(tps->regmap, REG_VSET0 + vset_id, &data); 207 - if (ret < 0) { 208 - dev_err(tps->dev, "%s() fails in writing reg %d\n", 209 - __func__, REG_VSET0 + vset_id); 210 - return ret; 211 - } 212 - tps->curr_vset_vsel[vset_id] = data & tps->voltage_reg_mask; 227 + int bit = 0; 228 + 213 229 if (pdata->en_force_pwm) 214 - data |= BIT(7); 215 - else 216 - data &= ~BIT(7); 217 - ret = regmap_write(tps->regmap, REG_VSET0 + vset_id, data); 230 + bit = BIT(7); 231 + 232 + ret = regmap_update_bits(tps->regmap, REG_VSET0 + vset_id, BIT(7), bit); 218 233 if (ret < 0) 219 - dev_err(tps->dev, "%s() fails in writing reg %d\n", 220 - __func__, REG_VSET0 + vset_id); 234 + dev_err(tps->dev, 235 + "%s(): register %d update failed with err %d\n", 236 + __func__, REG_VSET0 + vset_id, ret); 221 237 return ret; 222 238 } 223 239 224 - static int tps62360_init_dcdc(struct tps62360_chip *tps, 240 + static int __devinit tps62360_init_dcdc(struct tps62360_chip *tps, 225 241 struct tps62360_regulator_platform_data *pdata) 226 242 { 227 243 int ret; 228 244 int i; 245 + unsigned int ramp_ctrl; 229 246 230 - /* Initailize internal pull up/down control */ 247 + /* Initialize internal pull up/down control */ 231 248 if (tps->en_internal_pulldn) 232 249 ret = regmap_write(tps->regmap, REG_CONTROL, 0xE0); 233 250 else 234 251 ret = regmap_write(tps->regmap, REG_CONTROL, 0x0); 235 252 if (ret < 0) { 236 - dev_err(tps->dev, "%s() fails in writing reg %d\n", 237 - __func__, REG_CONTROL); 253 + dev_err(tps->dev, 254 + "%s(): register %d write failed with err %d\n", 255 + __func__, REG_CONTROL, ret); 238 256 return ret; 239 257 } 240 258 241 - /* Initailize force PWM mode */ 259 + /* Initialize force PWM mode */ 242 260 if (tps->valid_gpios) { 243 261 for (i = 0; i < 4; ++i) { 244 262 ret = tps62360_init_force_pwm(tps, pdata, i); ··· 268 256 269 257 /* Reset output discharge path to reduce power consumption */ 270 258 ret = regmap_update_bits(tps->regmap, REG_RAMPCTRL, BIT(2), 0); 271 - if (ret < 0) 272 - dev_err(tps->dev, "%s() fails in updating reg %d\n", 273 - __func__, REG_RAMPCTRL); 259 + if (ret < 0) { 260 + dev_err(tps->dev, 261 + "%s(): register %d update failed with err %d\n", 262 + __func__, REG_RAMPCTRL, ret); 263 + return ret; 264 + } 265 + 266 + /* Get ramp value from ramp control register */ 267 + ret = regmap_read(tps->regmap, REG_RAMPCTRL, &ramp_ctrl); 268 + if (ret < 0) { 269 + dev_err(tps->dev, 270 + "%s(): register %d read failed with err %d\n", 271 + __func__, REG_RAMPCTRL, ret); 272 + return ret; 273 + } 274 + ramp_ctrl = (ramp_ctrl >> 4) & 0x7; 275 + 276 + /* ramp mV/us = 32/(2^ramp_ctrl) */ 277 + tps->change_uv_per_us = DIV_ROUND_UP(32000, BIT(ramp_ctrl)); 274 278 return ret; 275 279 } 276 280 277 281 static const struct regmap_config tps62360_regmap_config = { 278 - .reg_bits = 8, 279 - .val_bits = 8, 282 + .reg_bits = 8, 283 + .val_bits = 8, 284 + .max_register = REG_CHIPID, 285 + .cache_type = REGCACHE_RBTREE, 280 286 }; 281 287 282 288 static int __devinit tps62360_probe(struct i2c_client *client, ··· 309 279 310 280 pdata = client->dev.platform_data; 311 281 if (!pdata) { 312 - dev_err(&client->dev, "%s() Err: Platform data not found\n", 282 + dev_err(&client->dev, "%s(): Platform data not found\n", 313 283 __func__); 314 284 return -EIO; 315 285 } 316 286 317 287 tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL); 318 288 if (!tps) { 319 - dev_err(&client->dev, "%s() Err: Memory allocation fails\n", 289 + dev_err(&client->dev, "%s(): Memory allocation failed\n", 320 290 __func__); 321 291 return -ENOMEM; 322 292 } ··· 353 323 tps->regmap = devm_regmap_init_i2c(client, &tps62360_regmap_config); 354 324 if (IS_ERR(tps->regmap)) { 355 325 ret = PTR_ERR(tps->regmap); 356 - dev_err(&client->dev, "%s() Err: Failed to allocate register" 357 - "map: %d\n", __func__, ret); 326 + dev_err(&client->dev, 327 + "%s(): regmap allocation failed with err %d\n", 328 + __func__, ret); 358 329 return ret; 359 330 } 360 331 i2c_set_clientdata(client, tps); ··· 366 335 tps->valid_gpios = false; 367 336 368 337 if (gpio_is_valid(tps->vsel0_gpio) && gpio_is_valid(tps->vsel1_gpio)) { 369 - ret = gpio_request(tps->vsel0_gpio, "tps62360-vsel0"); 338 + int gpio_flags; 339 + gpio_flags = (pdata->vsel0_def_state) ? 340 + GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW; 341 + ret = gpio_request_one(tps->vsel0_gpio, 342 + gpio_flags, "tps62360-vsel0"); 370 343 if (ret) { 371 344 dev_err(&client->dev, 372 - "Err: Could not obtain vsel0 GPIO %d: %d\n", 373 - tps->vsel0_gpio, ret); 374 - goto err_gpio0; 375 - } 376 - ret = gpio_direction_output(tps->vsel0_gpio, 377 - pdata->vsel0_def_state); 378 - if (ret) { 379 - dev_err(&client->dev, "Err: Could not set direction of" 380 - "vsel0 GPIO %d: %d\n", tps->vsel0_gpio, ret); 381 - gpio_free(tps->vsel0_gpio); 345 + "%s(): Could not obtain vsel0 GPIO %d: %d\n", 346 + __func__, tps->vsel0_gpio, ret); 382 347 goto err_gpio0; 383 348 } 384 349 385 - ret = gpio_request(tps->vsel1_gpio, "tps62360-vsel1"); 350 + gpio_flags = (pdata->vsel1_def_state) ? 351 + GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW; 352 + ret = gpio_request_one(tps->vsel1_gpio, 353 + gpio_flags, "tps62360-vsel1"); 386 354 if (ret) { 387 355 dev_err(&client->dev, 388 - "Err: Could not obtain vsel1 GPIO %d: %d\n", 389 - tps->vsel1_gpio, ret); 390 - goto err_gpio1; 391 - } 392 - ret = gpio_direction_output(tps->vsel1_gpio, 393 - pdata->vsel1_def_state); 394 - if (ret) { 395 - dev_err(&client->dev, "Err: Could not set direction of" 396 - "vsel1 GPIO %d: %d\n", tps->vsel1_gpio, ret); 397 - gpio_free(tps->vsel1_gpio); 356 + "%s(): Could not obtain vsel1 GPIO %d: %d\n", 357 + __func__, tps->vsel1_gpio, ret); 398 358 goto err_gpio1; 399 359 } 400 360 tps->valid_gpios = true; ··· 402 380 403 381 ret = tps62360_init_dcdc(tps, pdata); 404 382 if (ret < 0) { 405 - dev_err(tps->dev, "%s() Err: Init fails with = %d\n", 383 + dev_err(tps->dev, "%s(): Init failed with err = %d\n", 406 384 __func__, ret); 407 385 goto err_init; 408 386 } ··· 414 392 /* Register the regulators */ 415 393 rdev = regulator_register(&tps->desc, &config); 416 394 if (IS_ERR(rdev)) { 417 - dev_err(tps->dev, "%s() Err: Failed to register %s\n", 418 - __func__, id->name); 395 + dev_err(tps->dev, 396 + "%s(): regulator register failed with err %s\n", 397 + __func__, id->name); 419 398 ret = PTR_ERR(rdev); 420 399 goto err_init; 421 400 } ··· 465 442 /* Configure the output discharge path */ 466 443 st = regmap_update_bits(tps->regmap, REG_RAMPCTRL, BIT(2), BIT(2)); 467 444 if (st < 0) 468 - dev_err(tps->dev, "%s() fails in updating reg %d\n", 469 - __func__, REG_RAMPCTRL); 445 + dev_err(tps->dev, 446 + "%s(): register %d update failed with err %d\n", 447 + __func__, REG_RAMPCTRL, st); 470 448 } 471 449 472 450 static const struct i2c_device_id tps62360_id[] = {
-1
drivers/regulator/tps65023-regulator.c
··· 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
+3 -4
drivers/regulator/tps6507x-regulator.c
··· 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 ··· 282 283 1 << shift); 283 284 } 284 285 285 - static int tps6507x_pmic_get_voltage(struct regulator_dev *dev) 286 + static int tps6507x_pmic_get_voltage_sel(struct regulator_dev *dev) 286 287 { 287 288 struct tps6507x_pmic *tps = rdev_get_drvdata(dev); 288 289 int data, rid = rdev_get_id(dev); ··· 324 325 return data; 325 326 326 327 data &= mask; 327 - return tps->info[rid]->table[data] * 1000; 328 + return data; 328 329 } 329 330 330 331 static int tps6507x_pmic_set_voltage_sel(struct regulator_dev *dev, ··· 394 395 .is_enabled = tps6507x_pmic_is_enabled, 395 396 .enable = tps6507x_pmic_enable, 396 397 .disable = tps6507x_pmic_disable, 397 - .get_voltage = tps6507x_pmic_get_voltage, 398 + .get_voltage_sel = tps6507x_pmic_get_voltage_sel, 398 399 .set_voltage_sel = tps6507x_pmic_set_voltage_sel, 399 400 .list_voltage = tps6507x_pmic_list_voltage, 400 401 };
-1
drivers/regulator/tps65090-regulator.c
··· 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>
+1
drivers/regulator/tps6586x-regulator.c
··· 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
+9 -26
drivers/regulator/tps65910-regulator.c
··· 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> ··· 578 579 return -EINVAL; 579 580 } 580 581 581 - static int tps65910_get_voltage(struct regulator_dev *dev) 582 + static int tps65910_get_voltage_sel(struct regulator_dev *dev) 582 583 { 583 584 struct tps65910_reg *pmic = rdev_get_drvdata(dev); 584 - int reg, value, id = rdev_get_id(dev), voltage = 0; 585 + int reg, value, id = rdev_get_id(dev); 585 586 586 587 reg = pmic->get_ctrl_reg(id); 587 588 if (reg < 0) ··· 608 609 return -EINVAL; 609 610 } 610 611 611 - voltage = pmic->info[id]->voltage_table[value] * 1000; 612 - 613 - return voltage; 612 + return value; 614 613 } 615 614 616 615 static int tps65910_get_voltage_vdd3(struct regulator_dev *dev) ··· 616 619 return 5 * 1000 * 1000; 617 620 } 618 621 619 - static int tps65911_get_voltage(struct regulator_dev *dev) 622 + static int tps65911_get_voltage_sel(struct regulator_dev *dev) 620 623 { 621 624 struct tps65910_reg *pmic = rdev_get_drvdata(dev); 622 - int step_mv, id = rdev_get_id(dev); 625 + int id = rdev_get_id(dev); 623 626 u8 value, reg; 624 627 625 628 reg = pmic->get_ctrl_reg(id); ··· 632 635 case TPS65911_REG_LDO4: 633 636 value &= LDO1_SEL_MASK; 634 637 value >>= LDO_SEL_SHIFT; 635 - /* The first 5 values of the selector correspond to 1V */ 636 - if (value < 5) 637 - value = 0; 638 - else 639 - value -= 4; 640 - 641 - step_mv = 50; 642 638 break; 643 639 case TPS65911_REG_LDO3: 644 640 case TPS65911_REG_LDO5: ··· 640 650 case TPS65911_REG_LDO8: 641 651 value &= LDO3_SEL_MASK; 642 652 value >>= LDO_SEL_SHIFT; 643 - /* The first 3 values of the selector correspond to 1V */ 644 - if (value < 3) 645 - value = 0; 646 - else 647 - value -= 2; 648 - 649 - step_mv = 100; 650 653 break; 651 654 case TPS65910_REG_VIO: 652 655 value &= LDO_SEL_MASK; 653 656 value >>= LDO_SEL_SHIFT; 654 - return pmic->info[id]->voltage_table[value] * 1000; 657 + break; 655 658 default: 656 659 return -EINVAL; 657 660 } 658 661 659 - return (LDO_MIN_VOLT + value * step_mv) * 1000; 662 + return value; 660 663 } 661 664 662 665 static int tps65910_set_voltage_dcdc_sel(struct regulator_dev *dev, ··· 885 902 .enable_time = tps65910_enable_time, 886 903 .set_mode = tps65910_set_mode, 887 904 .get_mode = tps65910_get_mode, 888 - .get_voltage = tps65910_get_voltage, 905 + .get_voltage_sel = tps65910_get_voltage_sel, 889 906 .set_voltage_sel = tps65910_set_voltage_sel, 890 907 .list_voltage = tps65910_list_voltage, 891 908 }; ··· 897 914 .enable_time = tps65910_enable_time, 898 915 .set_mode = tps65910_set_mode, 899 916 .get_mode = tps65910_get_mode, 900 - .get_voltage = tps65911_get_voltage, 917 + .get_voltage_sel = tps65911_get_voltage_sel, 901 918 .set_voltage_sel = tps65911_set_voltage_sel, 902 919 .list_voltage = tps65911_list_voltage, 903 920 };
+4 -5
drivers/regulator/tps65912-regulator.c
··· 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> ··· 405 406 return voltage; 406 407 } 407 408 408 - static int tps65912_get_voltage(struct regulator_dev *dev) 409 + static int tps65912_get_voltage_sel(struct regulator_dev *dev) 409 410 { 410 411 struct tps65912_reg *pmic = rdev_get_drvdata(dev); 411 412 struct tps65912 *mfd = pmic->mfd; ··· 419 420 vsel = tps65912_reg_read(mfd, reg); 420 421 vsel &= 0x3F; 421 422 422 - return tps65912_list_voltage(dev, vsel); 423 + return vsel; 423 424 } 424 425 425 426 static int tps65912_set_voltage_sel(struct regulator_dev *dev, ··· 444 445 .disable = tps65912_reg_disable, 445 446 .set_mode = tps65912_set_mode, 446 447 .get_mode = tps65912_get_mode, 447 - .get_voltage = tps65912_get_voltage, 448 + .get_voltage_sel = tps65912_get_voltage_sel, 448 449 .set_voltage_sel = tps65912_set_voltage_sel, 449 450 .list_voltage = tps65912_list_voltage, 450 451 }; ··· 454 455 .is_enabled = tps65912_reg_is_enabled, 455 456 .enable = tps65912_reg_enable, 456 457 .disable = tps65912_reg_disable, 457 - .get_voltage = tps65912_get_voltage, 458 + .get_voltage_sel = tps65912_get_voltage_sel, 458 459 .set_voltage_sel = tps65912_set_voltage_sel, 459 460 .list_voltage = tps65912_list_voltage, 460 461 };
+4 -7
drivers/regulator/twl-regulator.c
··· 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> ··· 395 396 * VAUX3 at 3V is incorrectly listed in some TI manuals as unsupported. 396 397 * TI are revising the twl5030/tps659x0 specs to support that 3.0V setting. 397 398 */ 398 - #ifdef CONFIG_TWL4030_ALLOW_UNSUPPORTED 399 - #define UNSUP_MASK 0x0000 400 - #else 401 399 #define UNSUP_MASK 0x8000 402 - #endif 403 400 404 401 #define UNSUP(x) (UNSUP_MASK | (x)) 405 - #define IS_UNSUP(x) (UNSUP_MASK & (x)) 402 + #define IS_UNSUP(info, x) \ 403 + ((UNSUP_MASK & (x)) && \ 404 + !((info)->features & TWL4030_ALLOW_UNSUPPORTED)) 406 405 #define LDO_MV(x) (~UNSUP_MASK & (x)) 407 406 408 407 ··· 474 477 struct twlreg_info *info = rdev_get_drvdata(rdev); 475 478 int mV = info->table[index]; 476 479 477 - return IS_UNSUP(mV) ? 0 : (LDO_MV(mV) * 1000); 480 + return IS_UNSUP(info, mV) ? 0 : (LDO_MV(mV) * 1000); 478 481 } 479 482 480 483 static int
+7 -13
drivers/regulator/userspace-consumer.c
··· 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 ··· 127 125 128 126 mutex_init(&drvdata->lock); 129 127 130 - ret = regulator_bulk_get(&pdev->dev, drvdata->num_supplies, 131 - drvdata->supplies); 128 + ret = devm_regulator_bulk_get(&pdev->dev, drvdata->num_supplies, 129 + drvdata->supplies); 132 130 if (ret) { 133 131 dev_err(&pdev->dev, "Failed to get supplies: %d\n", ret); 134 - goto err_alloc_supplies; 132 + return ret; 135 133 } 136 134 137 135 ret = sysfs_create_group(&pdev->dev.kobj, &attr_group); 138 136 if (ret != 0) 139 - goto err_create_attrs; 137 + return ret; 140 138 141 139 if (pdata->init_on) { 142 140 ret = regulator_bulk_enable(drvdata->num_supplies, ··· 156 154 err_enable: 157 155 sysfs_remove_group(&pdev->dev.kobj, &attr_group); 158 156 159 - err_create_attrs: 160 - regulator_bulk_free(drvdata->num_supplies, drvdata->supplies); 161 - 162 - err_alloc_supplies: 163 - kfree(drvdata); 164 157 return ret; 165 158 } 166 159 ··· 167 170 168 171 if (data->enabled) 169 172 regulator_bulk_disable(data->num_supplies, data->supplies); 170 - 171 - regulator_bulk_free(data->num_supplies, data->supplies); 172 - kfree(data); 173 173 174 174 return 0; 175 175 }
+9 -17
drivers/regulator/virtual.c
··· 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 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 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 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); ··· 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, ··· 311 310 if (ret != 0) { 312 311 dev_err(&pdev->dev, 313 312 "Failed to create attribute group: %d\n", ret); 314 - goto err_regulator; 313 + return ret; 315 314 } 316 315 317 316 drvdata->mode = regulator_get_mode(drvdata->regulator); ··· 319 318 platform_set_drvdata(pdev, drvdata); 320 319 321 320 return 0; 322 - 323 - err_regulator: 324 - regulator_put(drvdata->regulator); 325 - err: 326 - kfree(drvdata); 327 - return ret; 328 321 } 329 322 330 323 static int __devexit regulator_virtual_remove(struct platform_device *pdev) ··· 329 334 330 335 if (drvdata->enabled) 331 336 regulator_disable(drvdata->regulator); 332 - regulator_put(drvdata->regulator); 333 - 334 - kfree(drvdata); 335 337 336 338 platform_set_drvdata(pdev, NULL); 337 339
+16 -11
drivers/regulator/wm831x-dcdc.c
··· 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 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; ··· 403 402 if (!pdata || !pdata->dvs_gpio) 404 403 return; 405 404 406 - ret = gpio_request(pdata->dvs_gpio, "DCDC DVS"); 407 - if (ret < 0) { 408 - dev_err(wm831x->dev, "Failed to get %s DVS GPIO: %d\n", 409 - dcdc->name, ret); 410 - return; 411 - } 412 - 413 405 /* gpiolib won't let us read the GPIO status so pick the higher 414 406 * of the two existing voltages so we take it as platform data. 415 407 */ 416 408 dcdc->dvs_gpio_state = pdata->dvs_init_state; 417 409 418 - ret = gpio_direction_output(pdata->dvs_gpio, dcdc->dvs_gpio_state); 410 + ret = gpio_request_one(pdata->dvs_gpio, 411 + dcdc->dvs_gpio_state ? GPIOF_INIT_HIGH : 0, 412 + "DCDC DVS"); 419 413 if (ret < 0) { 420 - dev_err(wm831x->dev, "Failed to enable %s DVS GPIO: %d\n", 414 + dev_err(wm831x->dev, "Failed to get %s DVS GPIO: %d\n", 421 415 dcdc->name, ret); 422 - gpio_free(pdata->dvs_gpio); 423 416 return; 424 417 } 425 418 ··· 491 496 492 497 snprintf(dcdc->name, sizeof(dcdc->name), "DCDC%d", id + 1); 493 498 dcdc->desc.name = dcdc->name; 499 + 500 + snprintf(dcdc->supply_name, sizeof(dcdc->supply_name), 501 + "DC%dVDD", id + 1); 502 + dcdc->desc.supply_name = dcdc->supply_name; 503 + 494 504 dcdc->desc.id = id; 495 505 dcdc->desc.type = REGULATOR_VOLTAGE; 496 506 dcdc->desc.n_voltages = WM831X_BUCKV_MAX_SELECTOR + 1; ··· 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;
+17 -1
drivers/regulator/wm831x-ldo.c
··· 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 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; ··· 292 291 293 292 snprintf(ldo->name, sizeof(ldo->name), "LDO%d", id + 1); 294 293 ldo->desc.name = ldo->name; 294 + 295 + snprintf(ldo->supply_name, sizeof(ldo->supply_name), 296 + "LDO%dVDD", id + 1); 297 + ldo->desc.supply_name = ldo->supply_name; 298 + 295 299 ldo->desc.id = id; 296 300 ldo->desc.type = REGULATOR_VOLTAGE; 297 301 ldo->desc.n_voltages = WM831X_GP_LDO_MAX_SELECTOR + 1; ··· 553 547 554 548 snprintf(ldo->name, sizeof(ldo->name), "LDO%d", id + 1); 555 549 ldo->desc.name = ldo->name; 550 + 551 + snprintf(ldo->supply_name, sizeof(ldo->supply_name), 552 + "LDO%dVDD", id + 1); 553 + ldo->desc.supply_name = ldo->supply_name; 554 + 556 555 ldo->desc.id = id; 557 556 ldo->desc.type = REGULATOR_VOLTAGE; 558 557 ldo->desc.n_voltages = WM831X_ALDO_MAX_SELECTOR + 1; ··· 744 733 745 734 snprintf(ldo->name, sizeof(ldo->name), "LDO%d", id + 1); 746 735 ldo->desc.name = ldo->name; 736 + 737 + snprintf(ldo->supply_name, sizeof(ldo->supply_name), 738 + "LDO%dVDD", id + 1); 739 + ldo->desc.supply_name = ldo->supply_name; 740 + 747 741 ldo->desc.id = id; 748 742 ldo->desc.type = REGULATOR_VOLTAGE; 749 743 ldo->desc.n_voltages = WM831X_ALIVE_LDO_MAX_SELECTOR + 1;
+2 -9
drivers/regulator/wm8994-regulator.c
··· 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;
+11 -2
include/linux/i2c/twl.h
··· 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 */ ··· 744 746 void *data; 745 747 unsigned long features; 746 748 }; 749 + /* chip-specific feature flags, for twl_regulator_driver_data.features */ 750 + #define TWL4030_VAUX2 BIT(0) /* pre-5030 voltage ranges */ 751 + #define TPS_SUBSET BIT(1) /* tps659[23]0 have fewer LDOs */ 752 + #define TWL5031 BIT(2) /* twl5031 has different registers */ 753 + #define TWL6030_CLASS BIT(3) /* TWL6030 class */ 754 + #define TWL6025_SUBCLASS BIT(4) /* TWL6025 has changed registers */ 755 + #define TWL4030_ALLOW_UNSUPPORTED BIT(5) /* Some voltages are possible 756 + * but not officially supported. 757 + * This flag is necessary to 758 + * enable them. 759 + */ 747 760 748 761 /*----------------------------------------------------------------------*/ 749 762
+1
include/linux/mfd/tps6586x.h
··· 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 {
+18
include/linux/regulator/of_regulator.h
··· 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