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

Merge tag 'regulator-v3.13' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator

Pull regulator updates from Mark Brown:
"Lots of driver updates here plus some nice new core features, the main
one being the first:

- Enable support for providing a dummy regulator when we know that
one must exist for the device to be functional. This makes it much
easier to add regulator support to drivers since we don't require
that the machine integration for all systems using the device be
updated to provide regulators.
- Substantial reduction in the amount of busy waiting done while
waiting for enables to complete.
- Allow MFDs to distribute regulator supplies to child devices so we
don't have to expose the internal structure of MFDs outside of the
driver.
- Managed registeration for regulators"

* tag 'regulator-v3.13' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator: (113 commits)
regulator: s5m8767: Modify parsing method of the voltage table of buck2/3/4
regulator: s5m8767: Modify parse_dt function to parse data related to ramp
regulator: da9052: Revert se apply_[reg|bit] with regmap based voltage_sel operations
mfd: arizona: Specify supply mappings for Arizona CODECs
mfd: Allow mapping regulator supplies to MFD device from children
regulator: core: Add ability to create a lookup alias for supply
regulator: tps65910: Fix checkpatch issue
regulator: tps65023: Fix checkpatch issue
regulator: tps6105x: Fix checkpatch issue
regulator: mc13783: Fix checkpatch issue
regulator: max8997: Fix checkpatch issue
regulator: lp3971: Fix checkpatch issue
regulator: fixed: Fix checkpatch issue
regulator: anatop: Fix checkpatch issue
regulator: Add REGULATOR_LINEAR_RANGE macro
regulator: Remove max_uV from struct regulator_linear_range
regulator: ti-abb: Fix operator precedence typo
regulator: tps65910: get regulators node from parent node only
regulator: tps6586x: get regulators node from parent node only
regulator: tps65090: get regulators node from parent node only
...

+2584 -1521
+91
Documentation/devicetree/bindings/regulator/as3722-regulator.txt
··· 1 + Regulator of AMS AS3722 PMIC. 2 + Name of the regulator subnode must be "regulators". 3 + 4 + Optional properties: 5 + -------------------- 6 + The input supply of regulators are the optional properties on the 7 + regulator node. The AS3722 is having 7 DCDC step-down regulators as 8 + sd[0-6], 10 LDOs as ldo[0-7], ldo[9-11]. The input supply of these 9 + regulators are provided through following properties: 10 + vsup-sd2-supply: Input supply for SD2. 11 + vsup-sd3-supply: Input supply for SD3. 12 + vsup-sd4-supply: Input supply for SD4. 13 + vsup-sd5-supply: Input supply for SD5. 14 + vin-ldo0-supply: Input supply for LDO0. 15 + vin-ldo1-6-supply: Input supply for LDO1 and LDO6. 16 + vin-ldo2-5-7-supply: Input supply for LDO2, LDO5 and LDO7. 17 + vin-ldo3-4-supply: Input supply for LDO3 and LDO4. 18 + vin-ldo9-10-supply: Input supply for LDO9 and LDO10. 19 + vin-ldo11-supply: Input supply for LDO11. 20 + 21 + Optional nodes: 22 + -------------- 23 + - regulators : Must contain a sub-node per regulator from the list below. 24 + Each sub-node should contain the constraints and initialization 25 + information for that regulator. See regulator.txt for a 26 + description of standard properties for these sub-nodes. 27 + Additional custom properties are listed below. 28 + sd[0-6], ldo[0-7], ldo[9-11]. 29 + 30 + Optional sub-node properties: 31 + ---------------------------- 32 + ams,ext-control: External control of the rail. The option of 33 + this properties will tell which external input is 34 + controlling this rail. Valid values are 0, 1, 2 ad 3. 35 + 0: There is no external control of this rail. 36 + 1: Rail is controlled by ENABLE1 input pin. 37 + 2: Rail is controlled by ENABLE2 input pin. 38 + 3: Rail is controlled by ENABLE3 input pin. 39 + ams,enable-tracking: Enable tracking with SD1, only supported 40 + by LDO3. 41 + 42 + Example: 43 + ------- 44 + ams3722: ams3722 { 45 + compatible = "ams,as3722"; 46 + reg = <0x40>; 47 + ... 48 + 49 + regulators { 50 + vsup-sd2-supply = <...>; 51 + ... 52 + 53 + sd0 { 54 + regulator-name = "vdd_cpu"; 55 + regulator-min-microvolt = <700000>; 56 + regulator-max-microvolt = <1400000>; 57 + regulator-always-on; 58 + ams,ext-control = <2>; 59 + }; 60 + 61 + sd1 { 62 + regulator-name = "vdd_core"; 63 + regulator-min-microvolt = <700000>; 64 + regulator-max-microvolt = <1400000>; 65 + regulator-always-on; 66 + ams,ext-control = <1>; 67 + }; 68 + 69 + sd2 { 70 + regulator-name = "vddio_ddr"; 71 + regulator-min-microvolt = <1350000>; 72 + regulator-max-microvolt = <1350000>; 73 + regulator-always-on; 74 + }; 75 + 76 + sd4 { 77 + regulator-name = "avdd-hdmi-pex"; 78 + regulator-min-microvolt = <1050000>; 79 + regulator-max-microvolt = <1050000>; 80 + regulator-always-on; 81 + }; 82 + 83 + sd5 { 84 + regulator-name = "vdd-1v8"; 85 + regulator-min-microvolt = <1800000>; 86 + regulator-max-microvolt = <1800000>; 87 + regulator-always-on; 88 + }; 89 + .... 90 + }; 91 + };
+21
Documentation/devicetree/bindings/regulator/da9210.txt
··· 1 + * Dialog Semiconductor DA9210 Voltage Regulator 2 + 3 + Required properties: 4 + 5 + - compatible: must be "diasemi,da9210" 6 + - reg: the i2c slave address of the regulator. It should be 0x68. 7 + 8 + Any standard regulator properties can be used to configure the single da9210 9 + DCDC. 10 + 11 + Example: 12 + 13 + da9210@68 { 14 + compatible = "diasemi,da9210"; 15 + reg = <0x68>; 16 + 17 + regulator-min-microvolt = <900000>; 18 + regulator-max-microvolt = <1000000>; 19 + regulator-boot-on; 20 + regulator-always-on; 21 + };
+9 -3
Documentation/devicetree/bindings/regulator/palmas-pmic.txt
··· 26 26 27 27 For ti,palmas-pmic - smps12, smps123, smps3 depending on OTP, 28 28 smps45, smps457, smps7 depending on variant, smps6, smps[8-9], 29 - smps10_out2, smps10_out1, do[1-9], ldoln, ldousb. 29 + smps10_out2, smps10_out1, ldo[1-9], ldoln, ldousb. 30 30 31 31 Optional sub-node properties: 32 32 ti,warm-reset - maintain voltage during warm reset(boolean) 33 - ti,roof-floor - control voltage selection by pin(boolean) 33 + ti,roof-floor - This takes as optional argument on platform supporting 34 + the rail from desired external control. If there is no argument then 35 + it will be assume that it is controlled by NSLEEP pin. 36 + The valid value for external pins are: 37 + ENABLE1 then 1, 38 + ENABLE2 then 2 or 39 + NSLEEP then 3. 34 40 ti,mode-sleep - mode to adopt in pmic sleep 0 - off, 1 - auto, 35 41 2 - eco, 3 - forced pwm 36 42 ti,smps-range - OTP has the wrong range set for the hardware so override ··· 67 61 regulator-always-on; 68 62 regulator-boot-on; 69 63 ti,warm-reset; 70 - ti,roof-floor; 64 + ti,roof-floor = <1>; /* ENABLE1 control */ 71 65 ti,mode-sleep = <0>; 72 66 ti,smps-range = <1>; 73 67 };
+5
Documentation/devicetree/bindings/regulator/regulator.txt
··· 14 14 - regulator-ramp-delay: ramp delay for regulator(in uV/uS) 15 15 For hardwares which support disabling ramp rate, it should be explicitly 16 16 intialised to zero (regulator-ramp-delay = <0>) for disabling ramp delay. 17 + - regulator-enable-ramp-delay: The time taken, in microseconds, for the supply 18 + rail to reach the target voltage, plus/minus whatever tolerance the board 19 + design requires. This property describes the total system ramp time 20 + required due to the combination of internal ramping of the regulator itself, 21 + and board design issues such as trace capacitance and load on the supply. 17 22 18 23 Deprecated properties: 19 24 - regulator-compatible: If a regulator chip contains multiple
+1
Documentation/driver-model/devres.txt
··· 283 283 devm_regulator_get() 284 284 devm_regulator_put() 285 285 devm_regulator_bulk_get() 286 + devm_regulator_register() 286 287 287 288 CLOCK 288 289 devm_clk_get()
-12
arch/arm/mach-s3c64xx/mach-crag6410.c
··· 310 310 311 311 REGULATOR_SUPPLY("SPKVDDL", "spi0.1"), 312 312 REGULATOR_SUPPLY("SPKVDDR", "spi0.1"), 313 - REGULATOR_SUPPLY("SPKVDDL", "wm5102-codec"), 314 - REGULATOR_SUPPLY("SPKVDDR", "wm5102-codec"), 315 - REGULATOR_SUPPLY("SPKVDDL", "wm5110-codec"), 316 - REGULATOR_SUPPLY("SPKVDDR", "wm5110-codec"), 317 313 318 314 REGULATOR_SUPPLY("DC1VDD", "0-0034"), 319 315 REGULATOR_SUPPLY("DC2VDD", "0-0034"), ··· 649 653 REGULATOR_SUPPLY("DBVDD3", "spi0.1"), 650 654 REGULATOR_SUPPLY("LDOVDD", "spi0.1"), 651 655 REGULATOR_SUPPLY("CPVDD", "spi0.1"), 652 - 653 - REGULATOR_SUPPLY("DBVDD2", "wm5102-codec"), 654 - REGULATOR_SUPPLY("DBVDD3", "wm5102-codec"), 655 - REGULATOR_SUPPLY("CPVDD", "wm5102-codec"), 656 - 657 - REGULATOR_SUPPLY("DBVDD2", "wm5110-codec"), 658 - REGULATOR_SUPPLY("DBVDD3", "wm5110-codec"), 659 - REGULATOR_SUPPLY("CPVDD", "wm5110-codec"), 660 656 }; 661 657 662 658 static struct regulator_init_data pvdd_1v8 = {
+29 -3
drivers/mfd/arizona-core.c
··· 569 569 { .name = "arizona-ldo1" }, 570 570 }; 571 571 572 + static const char *wm5102_supplies[] = { 573 + "DBVDD2", 574 + "DBVDD3", 575 + "CPVDD", 576 + "SPKVDDL", 577 + "SPKVDDR", 578 + }; 579 + 572 580 static struct mfd_cell wm5102_devs[] = { 573 581 { .name = "arizona-micsupp" }, 574 582 { .name = "arizona-extcon" }, 575 583 { .name = "arizona-gpio" }, 576 584 { .name = "arizona-haptics" }, 577 585 { .name = "arizona-pwm" }, 578 - { .name = "wm5102-codec" }, 586 + { 587 + .name = "wm5102-codec", 588 + .parent_supplies = wm5102_supplies, 589 + .num_parent_supplies = ARRAY_SIZE(wm5102_supplies), 590 + }, 579 591 }; 580 592 581 593 static struct mfd_cell wm5110_devs[] = { ··· 596 584 { .name = "arizona-gpio" }, 597 585 { .name = "arizona-haptics" }, 598 586 { .name = "arizona-pwm" }, 599 - { .name = "wm5110-codec" }, 587 + { 588 + .name = "wm5110-codec", 589 + .parent_supplies = wm5102_supplies, 590 + .num_parent_supplies = ARRAY_SIZE(wm5102_supplies), 591 + }, 592 + }; 593 + 594 + static const char *wm8997_supplies[] = { 595 + "DBVDD2", 596 + "CPVDD", 597 + "SPKVDD", 600 598 }; 601 599 602 600 static struct mfd_cell wm8997_devs[] = { ··· 615 593 { .name = "arizona-gpio" }, 616 594 { .name = "arizona-haptics" }, 617 595 { .name = "arizona-pwm" }, 618 - { .name = "wm8997-codec" }, 596 + { 597 + .name = "wm8997-codec", 598 + .parent_supplies = wm8997_supplies, 599 + .num_parent_supplies = ARRAY_SIZE(wm8997_supplies), 600 + }, 619 601 }; 620 602 621 603 int arizona_dev_init(struct arizona *arizona)
+17 -5
drivers/mfd/mfd-core.c
··· 20 20 #include <linux/module.h> 21 21 #include <linux/irqdomain.h> 22 22 #include <linux/of.h> 23 + #include <linux/regulator/consumer.h> 23 24 24 25 static struct device_type mfd_dev_type = { 25 26 .name = "mfd_device", ··· 100 99 pdev->dev.dma_mask = parent->dma_mask; 101 100 pdev->dev.dma_parms = parent->dma_parms; 102 101 102 + ret = devm_regulator_bulk_register_supply_alias( 103 + &pdev->dev, cell->parent_supplies, 104 + parent, cell->parent_supplies, 105 + cell->num_parent_supplies); 106 + if (ret < 0) 107 + goto fail_res; 108 + 103 109 if (parent->of_node && cell->of_compatible) { 104 110 for_each_child_of_node(parent->of_node, np) { 105 111 if (of_device_is_compatible(np, cell->of_compatible)) { ··· 120 112 ret = platform_device_add_data(pdev, 121 113 cell->platform_data, cell->pdata_size); 122 114 if (ret) 123 - goto fail_res; 115 + goto fail_alias; 124 116 } 125 117 126 118 ret = mfd_platform_add_cell(pdev, cell); 127 119 if (ret) 128 - goto fail_res; 120 + goto fail_alias; 129 121 130 122 for (r = 0; r < cell->num_resources; r++) { 131 123 res[r].name = cell->resources[r].name; ··· 160 152 if (!cell->ignore_resource_conflicts) { 161 153 ret = acpi_check_resource_conflict(&res[r]); 162 154 if (ret) 163 - goto fail_res; 155 + goto fail_alias; 164 156 } 165 157 } 166 158 167 159 ret = platform_device_add_resources(pdev, res, cell->num_resources); 168 160 if (ret) 169 - goto fail_res; 161 + goto fail_alias; 170 162 171 163 ret = platform_device_add(pdev); 172 164 if (ret) 173 - goto fail_res; 165 + goto fail_alias; 174 166 175 167 if (cell->pm_runtime_no_callbacks) 176 168 pm_runtime_no_callbacks(&pdev->dev); ··· 179 171 180 172 return 0; 181 173 174 + fail_alias: 175 + devm_regulator_bulk_unregister_supply_alias(&pdev->dev, 176 + cell->parent_supplies, 177 + cell->num_parent_supplies); 182 178 fail_res: 183 179 kfree(res); 184 180 fail_device:
+4 -8
drivers/regulator/88pm800.c
··· 141 141 142 142 /* Ranges are sorted in ascending order. */ 143 143 static const struct regulator_linear_range buck1_volt_range[] = { 144 - { .min_uV = 600000, .max_uV = 1587500, .min_sel = 0, .max_sel = 0x4f, 145 - .uV_step = 12500 }, 146 - { .min_uV = 1600000, .max_uV = 1800000, .min_sel = 0x50, 147 - .max_sel = 0x54, .uV_step = 50000 }, 144 + REGULATOR_LINEAR_RANGE(600000, 0, 0x4f, 12500), 145 + REGULATOR_LINEAR_RANGE(1600000, 0x50, 0x54, 50000), 148 146 }; 149 147 150 148 /* BUCK 2~5 have same ranges. */ 151 149 static const struct regulator_linear_range buck2_5_volt_range[] = { 152 - { .min_uV = 600000, .max_uV = 1587500, .min_sel = 0, .max_sel = 0x4f, 153 - .uV_step = 12500 }, 154 - { .min_uV = 1600000, .max_uV = 3300000, .min_sel = 0x50, 155 - .max_sel = 0x72, .uV_step = 50000 }, 150 + REGULATOR_LINEAR_RANGE(600000, 0, 0x4f, 12500), 151 + REGULATOR_LINEAR_RANGE(1600000, 0x50, 0x72, 50000), 156 152 }; 157 153 158 154 static const unsigned int ldo1_volt_table[] = {
+2 -10
drivers/regulator/88pm8607.c
··· 391 391 else 392 392 config.regmap = chip->regmap_companion; 393 393 394 - info->regulator = regulator_register(&info->desc, &config); 394 + info->regulator = devm_regulator_register(&pdev->dev, &info->desc, 395 + &config); 395 396 if (IS_ERR(info->regulator)) { 396 397 dev_err(&pdev->dev, "failed to register regulator %s\n", 397 398 info->desc.name); ··· 400 399 } 401 400 402 401 platform_set_drvdata(pdev, info); 403 - return 0; 404 - } 405 - 406 - static int pm8607_regulator_remove(struct platform_device *pdev) 407 - { 408 - struct pm8607_regulator_info *info = platform_get_drvdata(pdev); 409 - 410 - regulator_unregister(info->regulator); 411 402 return 0; 412 403 } 413 404 ··· 421 428 .owner = THIS_MODULE, 422 429 }, 423 430 .probe = pm8607_regulator_probe, 424 - .remove = pm8607_regulator_remove, 425 431 .id_table = pm8607_regulator_driver_ids, 426 432 }; 427 433
+16 -10
drivers/regulator/Kconfig
··· 28 28 help 29 29 Say yes here to enable debugging support. 30 30 31 - config REGULATOR_DUMMY 32 - bool "Provide a dummy regulator if regulator lookups fail" 33 - help 34 - If this option is enabled then when a regulator lookup fails 35 - and the board has not specified that it has provided full 36 - constraints the regulator core will provide an always 37 - enabled dummy regulator, allowing consumer drivers to continue. 38 - 39 - A warning will be generated when this substitution is done. 40 - 41 31 config REGULATOR_FIXED_VOLTAGE 42 32 tristate "Fixed voltage regulator support" 43 33 help ··· 122 132 help 123 133 This driver provides support for the voltage regulators on the 124 134 AS3711 PMIC 135 + 136 + config REGULATOR_AS3722 137 + tristate "AMS AS3722 PMIC Regulators" 138 + depends on MFD_AS3722 139 + help 140 + This driver provides support for the voltage regulators on the 141 + AS3722 PMIC. This will enable support for all the software 142 + controllable DCDC/LDO regulators. 125 143 126 144 config REGULATOR_DA903X 127 145 tristate "Dialog Semiconductor DA9030/DA9034 regulators" ··· 426 428 enabled on required TI SoC. Certain Operating Performance Points 427 429 on TI SoCs may be unstable without enabling this as it provides 428 430 device specific optimized bias to allow/optimize functionality. 431 + 432 + config REGULATOR_STW481X_VMMC 433 + bool "ST Microelectronics STW481X VMMC regulator" 434 + depends on MFD_STW481X 435 + default y if MFD_STW481X 436 + help 437 + This driver supports the internal VMMC regulator in the STw481x 438 + PMIC chips. 429 439 430 440 config REGULATOR_TPS51632 431 441 tristate "TI TPS51632 Power Regulator"
+3 -1
drivers/regulator/Makefile
··· 3 3 # 4 4 5 5 6 - obj-$(CONFIG_REGULATOR) += core.o dummy.o fixed-helper.o helpers.o 6 + obj-$(CONFIG_REGULATOR) += core.o dummy.o fixed-helper.o helpers.o devres.o 7 7 obj-$(CONFIG_OF) += of_regulator.o 8 8 obj-$(CONFIG_REGULATOR_FIXED_VOLTAGE) += fixed.o 9 9 obj-$(CONFIG_REGULATOR_VIRTUAL_CONSUMER) += virtual.o ··· 18 18 obj-$(CONFIG_REGULATOR_ANATOP) += anatop-regulator.o 19 19 obj-$(CONFIG_REGULATOR_ARIZONA) += arizona-micsupp.o arizona-ldo1.o 20 20 obj-$(CONFIG_REGULATOR_AS3711) += as3711-regulator.o 21 + obj-$(CONFIG_REGULATOR_AS3722) += as3722-regulator.o 21 22 obj-$(CONFIG_REGULATOR_DA903X) += da903x.o 22 23 obj-$(CONFIG_REGULATOR_DA9052) += da9052-regulator.o 23 24 obj-$(CONFIG_REGULATOR_DA9055) += da9055-regulator.o ··· 57 56 obj-$(CONFIG_REGULATOR_RC5T583) += rc5t583-regulator.o 58 57 obj-$(CONFIG_REGULATOR_S2MPS11) += s2mps11.o 59 58 obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o 59 + obj-$(CONFIG_REGULATOR_STW481X_VMMC) += stw481x-vmmc.o 60 60 obj-$(CONFIG_REGULATOR_TI_ABB) += ti-abb-regulator.o 61 61 obj-$(CONFIG_REGULATOR_TPS6105X) += tps6105x-regulator.o 62 62 obj-$(CONFIG_REGULATOR_TPS62360) += tps62360-regulator.o
+1 -10
drivers/regulator/aat2870-regulator.c
··· 176 176 config.driver_data = ri; 177 177 config.init_data = dev_get_platdata(&pdev->dev); 178 178 179 - rdev = regulator_register(&ri->desc, &config); 179 + rdev = devm_regulator_register(&pdev->dev, &ri->desc, &config); 180 180 if (IS_ERR(rdev)) { 181 181 dev_err(&pdev->dev, "Failed to register regulator %s\n", 182 182 ri->desc.name); ··· 187 187 return 0; 188 188 } 189 189 190 - static int aat2870_regulator_remove(struct platform_device *pdev) 191 - { 192 - struct regulator_dev *rdev = platform_get_drvdata(pdev); 193 - 194 - regulator_unregister(rdev); 195 - return 0; 196 - } 197 - 198 190 static struct platform_driver aat2870_regulator_driver = { 199 191 .driver = { 200 192 .name = "aat2870-regulator", 201 193 .owner = THIS_MODULE, 202 194 }, 203 195 .probe = aat2870_regulator_probe, 204 - .remove = aat2870_regulator_remove, 205 196 }; 206 197 207 198 static int __init aat2870_regulator_init(void)
+1 -2
drivers/regulator/ab3100.c
··· 535 535 config.dev = &pdev->dev; 536 536 config.driver_data = reg; 537 537 538 - rdev = regulator_register(desc, &config); 538 + rdev = devm_regulator_register(&pdev->dev, desc, &config); 539 539 if (IS_ERR(rdev)) { 540 540 err = PTR_ERR(rdev); 541 541 dev_err(&pdev->dev, ··· 616 616 for (i = 0; i < AB3100_NUM_REGULATORS; i++) { 617 617 struct ab3100_regulator *reg = &ab3100_regulators[i]; 618 618 619 - regulator_unregister(reg->rdev); 620 619 reg->rdev = NULL; 621 620 } 622 621 return 0;
+2 -24
drivers/regulator/ab8500-ext.c
··· 413 413 &pdata->ext_regulator[i]; 414 414 415 415 /* register regulator with framework */ 416 - info->rdev = regulator_register(&info->desc, &config); 416 + info->rdev = devm_regulator_register(&pdev->dev, &info->desc, 417 + &config); 417 418 if (IS_ERR(info->rdev)) { 418 419 err = PTR_ERR(info->rdev); 419 420 dev_err(&pdev->dev, "failed to register regulator %s\n", 420 421 info->desc.name); 421 - /* when we fail, un-register all earlier regulators */ 422 - while (--i >= 0) { 423 - info = &ab8500_ext_regulator_info[i]; 424 - regulator_unregister(info->rdev); 425 - } 426 422 return err; 427 423 } 428 424 ··· 429 433 return 0; 430 434 } 431 435 432 - static int ab8500_ext_regulator_remove(struct platform_device *pdev) 433 - { 434 - int i; 435 - 436 - for (i = 0; i < ARRAY_SIZE(ab8500_ext_regulator_info); i++) { 437 - struct ab8500_ext_regulator_info *info = NULL; 438 - info = &ab8500_ext_regulator_info[i]; 439 - 440 - dev_vdbg(rdev_get_dev(info->rdev), 441 - "%s-remove\n", info->desc.name); 442 - 443 - regulator_unregister(info->rdev); 444 - } 445 - 446 - return 0; 447 - } 448 - 449 436 static struct platform_driver ab8500_ext_regulator_driver = { 450 437 .probe = ab8500_ext_regulator_probe, 451 - .remove = ab8500_ext_regulator_remove, 452 438 .driver = { 453 439 .name = "ab8500-ext-regulator", 454 440 .owner = THIS_MODULE,
+3 -16
drivers/regulator/ad5398.c
··· 219 219 struct ad5398_chip_info *chip; 220 220 const struct ad5398_current_data_format *df = 221 221 (struct ad5398_current_data_format *)id->driver_data; 222 - int ret; 223 222 224 223 if (!init_data) 225 224 return -EINVAL; ··· 239 240 chip->current_offset = df->current_offset; 240 241 chip->current_mask = (chip->current_level - 1) << chip->current_offset; 241 242 242 - chip->rdev = regulator_register(&ad5398_reg, &config); 243 + chip->rdev = devm_regulator_register(&client->dev, &ad5398_reg, 244 + &config); 243 245 if (IS_ERR(chip->rdev)) { 244 - ret = PTR_ERR(chip->rdev); 245 246 dev_err(&client->dev, "failed to register %s %s\n", 246 247 id->name, ad5398_reg.name); 247 - goto err; 248 + return PTR_ERR(chip->rdev); 248 249 } 249 250 250 251 i2c_set_clientdata(client, chip); 251 252 dev_dbg(&client->dev, "%s regulator driver is registered.\n", id->name); 252 253 return 0; 253 - 254 - err: 255 - return ret; 256 - } 257 - 258 - static int ad5398_remove(struct i2c_client *client) 259 - { 260 - struct ad5398_chip_info *chip = i2c_get_clientdata(client); 261 - 262 - regulator_unregister(chip->rdev); 263 - return 0; 264 254 } 265 255 266 256 static struct i2c_driver ad5398_driver = { 267 257 .probe = ad5398_probe, 268 - .remove = ad5398_remove, 269 258 .driver = { 270 259 .name = "ad5398", 271 260 },
+3 -4
drivers/regulator/anatop-regulator.c
··· 200 200 config.regmap = sreg->anatop; 201 201 202 202 /* register regulator */ 203 - rdev = regulator_register(rdesc, &config); 203 + rdev = devm_regulator_register(dev, rdesc, &config); 204 204 if (IS_ERR(rdev)) { 205 205 dev_err(dev, "failed to register %s\n", 206 206 rdesc->name); ··· 223 223 struct anatop_regulator *sreg = rdev_get_drvdata(rdev); 224 224 const char *name = sreg->name; 225 225 226 - regulator_unregister(rdev); 227 226 kfree(name); 228 227 229 228 return 0; ··· 255 256 } 256 257 module_exit(anatop_regulator_exit); 257 258 258 - MODULE_AUTHOR("Nancy Chen <Nancy.Chen@freescale.com>, " 259 - "Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>"); 259 + MODULE_AUTHOR("Nancy Chen <Nancy.Chen@freescale.com>"); 260 + MODULE_AUTHOR("Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>"); 260 261 MODULE_DESCRIPTION("ANATOP Regulator driver"); 261 262 MODULE_LICENSE("GPL v2");
+1 -11
drivers/regulator/arizona-ldo1.c
··· 226 226 else 227 227 config.init_data = &ldo1->init_data; 228 228 229 - ldo1->regulator = regulator_register(desc, &config); 229 + ldo1->regulator = devm_regulator_register(&pdev->dev, desc, &config); 230 230 if (IS_ERR(ldo1->regulator)) { 231 231 ret = PTR_ERR(ldo1->regulator); 232 232 dev_err(arizona->dev, "Failed to register LDO1 supply: %d\n", ··· 239 239 return 0; 240 240 } 241 241 242 - static int arizona_ldo1_remove(struct platform_device *pdev) 243 - { 244 - struct arizona_ldo1 *ldo1 = platform_get_drvdata(pdev); 245 - 246 - regulator_unregister(ldo1->regulator); 247 - 248 - return 0; 249 - } 250 - 251 242 static struct platform_driver arizona_ldo1_driver = { 252 243 .probe = arizona_ldo1_probe, 253 - .remove = arizona_ldo1_remove, 254 244 .driver = { 255 245 .name = "arizona-ldo1", 256 246 .owner = THIS_MODULE,
+3 -11
drivers/regulator/arizona-micsupp.c
··· 225 225 regmap_update_bits(arizona->regmap, ARIZONA_MIC_CHARGE_PUMP_1, 226 226 ARIZONA_CPMIC_BYPASS, 0); 227 227 228 - micsupp->regulator = regulator_register(&arizona_micsupp, &config); 228 + micsupp->regulator = devm_regulator_register(&pdev->dev, 229 + &arizona_micsupp, 230 + &config); 229 231 if (IS_ERR(micsupp->regulator)) { 230 232 ret = PTR_ERR(micsupp->regulator); 231 233 dev_err(arizona->dev, "Failed to register mic supply: %d\n", ··· 240 238 return 0; 241 239 } 242 240 243 - static int arizona_micsupp_remove(struct platform_device *pdev) 244 - { 245 - struct arizona_micsupp *micsupp = platform_get_drvdata(pdev); 246 - 247 - regulator_unregister(micsupp->regulator); 248 - 249 - return 0; 250 - } 251 - 252 241 static struct platform_driver arizona_micsupp_driver = { 253 242 .probe = arizona_micsupp_probe, 254 - .remove = arizona_micsupp_remove, 255 243 .driver = { 256 244 .name = "arizona-micsupp", 257 245 .owner = THIS_MODULE,
+9 -34
drivers/regulator/as3711-regulator.c
··· 117 117 }; 118 118 119 119 static const struct regulator_linear_range as3711_sd_ranges[] = { 120 - { .min_uV = 612500, .max_uV = 1400000, 121 - .min_sel = 0x1, .max_sel = 0x40, .uV_step = 12500 }, 122 - { .min_uV = 1425000, .max_uV = 2600000, 123 - .min_sel = 0x41, .max_sel = 0x70, .uV_step = 25000 }, 124 - { .min_uV = 2650000, .max_uV = 3350000, 125 - .min_sel = 0x71, .max_sel = 0x7f, .uV_step = 50000 }, 120 + REGULATOR_LINEAR_RANGE(612500, 0x1, 0x40, 12500), 121 + REGULATOR_LINEAR_RANGE(1425000, 0x41, 0x70, 25000), 122 + REGULATOR_LINEAR_RANGE(2650000, 0x71, 0x7f, 50000), 126 123 }; 127 124 128 125 static const struct regulator_linear_range as3711_aldo_ranges[] = { 129 - { .min_uV = 1200000, .max_uV = 1950000, 130 - .min_sel = 0, .max_sel = 0xf, .uV_step = 50000 }, 131 - { .min_uV = 1800000, .max_uV = 3300000, 132 - .min_sel = 0x10, .max_sel = 0x1f, .uV_step = 100000 }, 126 + REGULATOR_LINEAR_RANGE(1200000, 0, 0xf, 50000), 127 + REGULATOR_LINEAR_RANGE(1800000, 0x10, 0x1f, 100000), 133 128 }; 134 129 135 130 static const struct regulator_linear_range as3711_dldo_ranges[] = { 136 - { .min_uV = 900000, .max_uV = 1700000, 137 - .min_sel = 0, .max_sel = 0x10, .uV_step = 50000 }, 138 - { .min_uV = 1750000, .max_uV = 3300000, 139 - .min_sel = 0x20, .max_sel = 0x3f, .uV_step = 50000 }, 131 + REGULATOR_LINEAR_RANGE(900000, 0, 0x10, 50000), 132 + REGULATOR_LINEAR_RANGE(1750000, 0x20, 0x3f, 50000), 140 133 }; 141 134 142 135 #define AS3711_REG(_id, _en_reg, _en_bit, _vmask, _vshift, _min_uV, _max_uV, _sfx) \ ··· 266 273 config.regmap = as3711->regmap; 267 274 config.of_node = of_node[id]; 268 275 269 - rdev = regulator_register(&ri->desc, &config); 276 + rdev = devm_regulator_register(&pdev->dev, &ri->desc, &config); 270 277 if (IS_ERR(rdev)) { 271 278 dev_err(&pdev->dev, "Failed to register regulator %s\n", 272 279 ri->desc.name); 273 - ret = PTR_ERR(rdev); 274 - goto eregreg; 280 + return PTR_ERR(rdev); 275 281 } 276 282 reg->rdev = rdev; 277 283 } 278 284 platform_set_drvdata(pdev, regs); 279 - return 0; 280 - 281 - eregreg: 282 - while (--id >= 0) 283 - regulator_unregister(regs[id].rdev); 284 - 285 - return ret; 286 - } 287 - 288 - static int as3711_regulator_remove(struct platform_device *pdev) 289 - { 290 - struct as3711_regulator *regs = platform_get_drvdata(pdev); 291 - int id; 292 - 293 - for (id = 0; id < AS3711_REGULATOR_NUM; ++id) 294 - regulator_unregister(regs[id].rdev); 295 285 return 0; 296 286 } 297 287 ··· 284 308 .owner = THIS_MODULE, 285 309 }, 286 310 .probe = as3711_regulator_probe, 287 - .remove = as3711_regulator_remove, 288 311 }; 289 312 290 313 static int __init as3711_regulator_init(void)
+908
drivers/regulator/as3722-regulator.c
··· 1 + /* 2 + * Voltage regulator support for AMS AS3722 PMIC 3 + * 4 + * Copyright (C) 2013 ams 5 + * 6 + * Author: Florian Lobmaier <florian.lobmaier@ams.com> 7 + * Author: Laxman Dewangan <ldewangan@nvidia.com> 8 + * 9 + * This program is free software; you can redistribute it and/or modify 10 + * it under the terms of the GNU General Public License as published by 11 + * the Free Software Foundation; either version 2 of the License, or 12 + * (at your option) any later version. 13 + * 14 + * This program is distributed in the hope that it will be useful, 15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 + * GNU General Public License for more details. 18 + * 19 + * You should have received a copy of the GNU General Public License 20 + * along with this program; if not, write to the Free Software 21 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 + * 23 + */ 24 + 25 + #include <linux/err.h> 26 + #include <linux/kernel.h> 27 + #include <linux/module.h> 28 + #include <linux/mfd/as3722.h> 29 + #include <linux/of.h> 30 + #include <linux/of_platform.h> 31 + #include <linux/platform_device.h> 32 + #include <linux/regulator/driver.h> 33 + #include <linux/regulator/machine.h> 34 + #include <linux/regulator/of_regulator.h> 35 + #include <linux/slab.h> 36 + 37 + /* Regulator IDs */ 38 + enum as3722_regulators_id { 39 + AS3722_REGULATOR_ID_SD0, 40 + AS3722_REGULATOR_ID_SD1, 41 + AS3722_REGULATOR_ID_SD2, 42 + AS3722_REGULATOR_ID_SD3, 43 + AS3722_REGULATOR_ID_SD4, 44 + AS3722_REGULATOR_ID_SD5, 45 + AS3722_REGULATOR_ID_SD6, 46 + AS3722_REGULATOR_ID_LDO0, 47 + AS3722_REGULATOR_ID_LDO1, 48 + AS3722_REGULATOR_ID_LDO2, 49 + AS3722_REGULATOR_ID_LDO3, 50 + AS3722_REGULATOR_ID_LDO4, 51 + AS3722_REGULATOR_ID_LDO5, 52 + AS3722_REGULATOR_ID_LDO6, 53 + AS3722_REGULATOR_ID_LDO7, 54 + AS3722_REGULATOR_ID_LDO9, 55 + AS3722_REGULATOR_ID_LDO10, 56 + AS3722_REGULATOR_ID_LDO11, 57 + AS3722_REGULATOR_ID_MAX, 58 + }; 59 + 60 + struct as3722_register_mapping { 61 + u8 regulator_id; 62 + const char *name; 63 + const char *sname; 64 + u8 vsel_reg; 65 + u8 vsel_mask; 66 + int n_voltages; 67 + u32 enable_reg; 68 + u8 enable_mask; 69 + u32 control_reg; 70 + u8 mode_mask; 71 + u32 sleep_ctrl_reg; 72 + u8 sleep_ctrl_mask; 73 + }; 74 + 75 + struct as3722_regulator_config_data { 76 + struct regulator_init_data *reg_init; 77 + bool enable_tracking; 78 + int ext_control; 79 + }; 80 + 81 + struct as3722_regulators { 82 + struct device *dev; 83 + struct as3722 *as3722; 84 + struct regulator_dev *rdevs[AS3722_REGULATOR_ID_MAX]; 85 + struct regulator_desc desc[AS3722_REGULATOR_ID_MAX]; 86 + struct as3722_regulator_config_data 87 + reg_config_data[AS3722_REGULATOR_ID_MAX]; 88 + }; 89 + 90 + static const struct as3722_register_mapping as3722_reg_lookup[] = { 91 + { 92 + .regulator_id = AS3722_REGULATOR_ID_SD0, 93 + .name = "as3722-sd0", 94 + .vsel_reg = AS3722_SD0_VOLTAGE_REG, 95 + .vsel_mask = AS3722_SD_VSEL_MASK, 96 + .enable_reg = AS3722_SD_CONTROL_REG, 97 + .enable_mask = AS3722_SDn_CTRL(0), 98 + .sleep_ctrl_reg = AS3722_ENABLE_CTRL1_REG, 99 + .sleep_ctrl_mask = AS3722_SD0_EXT_ENABLE_MASK, 100 + .control_reg = AS3722_SD0_CONTROL_REG, 101 + .mode_mask = AS3722_SD0_MODE_FAST, 102 + .n_voltages = AS3722_SD0_VSEL_MAX + 1, 103 + }, 104 + { 105 + .regulator_id = AS3722_REGULATOR_ID_SD1, 106 + .name = "as3722-sd1", 107 + .vsel_reg = AS3722_SD1_VOLTAGE_REG, 108 + .vsel_mask = AS3722_SD_VSEL_MASK, 109 + .enable_reg = AS3722_SD_CONTROL_REG, 110 + .enable_mask = AS3722_SDn_CTRL(1), 111 + .sleep_ctrl_reg = AS3722_ENABLE_CTRL1_REG, 112 + .sleep_ctrl_mask = AS3722_SD1_EXT_ENABLE_MASK, 113 + .control_reg = AS3722_SD1_CONTROL_REG, 114 + .mode_mask = AS3722_SD1_MODE_FAST, 115 + .n_voltages = AS3722_SD0_VSEL_MAX + 1, 116 + }, 117 + { 118 + .regulator_id = AS3722_REGULATOR_ID_SD2, 119 + .name = "as3722-sd2", 120 + .sname = "vsup-sd2", 121 + .vsel_reg = AS3722_SD2_VOLTAGE_REG, 122 + .vsel_mask = AS3722_SD_VSEL_MASK, 123 + .enable_reg = AS3722_SD_CONTROL_REG, 124 + .enable_mask = AS3722_SDn_CTRL(2), 125 + .sleep_ctrl_reg = AS3722_ENABLE_CTRL1_REG, 126 + .sleep_ctrl_mask = AS3722_SD2_EXT_ENABLE_MASK, 127 + .control_reg = AS3722_SD23_CONTROL_REG, 128 + .mode_mask = AS3722_SD2_MODE_FAST, 129 + .n_voltages = AS3722_SD2_VSEL_MAX + 1, 130 + }, 131 + { 132 + .regulator_id = AS3722_REGULATOR_ID_SD3, 133 + .name = "as3722-sd3", 134 + .sname = "vsup-sd3", 135 + .vsel_reg = AS3722_SD3_VOLTAGE_REG, 136 + .vsel_mask = AS3722_SD_VSEL_MASK, 137 + .enable_reg = AS3722_SD_CONTROL_REG, 138 + .enable_mask = AS3722_SDn_CTRL(3), 139 + .sleep_ctrl_reg = AS3722_ENABLE_CTRL1_REG, 140 + .sleep_ctrl_mask = AS3722_SD3_EXT_ENABLE_MASK, 141 + .control_reg = AS3722_SD23_CONTROL_REG, 142 + .mode_mask = AS3722_SD3_MODE_FAST, 143 + .n_voltages = AS3722_SD2_VSEL_MAX + 1, 144 + }, 145 + { 146 + .regulator_id = AS3722_REGULATOR_ID_SD4, 147 + .name = "as3722-sd4", 148 + .sname = "vsup-sd4", 149 + .vsel_reg = AS3722_SD4_VOLTAGE_REG, 150 + .vsel_mask = AS3722_SD_VSEL_MASK, 151 + .enable_reg = AS3722_SD_CONTROL_REG, 152 + .enable_mask = AS3722_SDn_CTRL(4), 153 + .sleep_ctrl_reg = AS3722_ENABLE_CTRL2_REG, 154 + .sleep_ctrl_mask = AS3722_SD4_EXT_ENABLE_MASK, 155 + .control_reg = AS3722_SD4_CONTROL_REG, 156 + .mode_mask = AS3722_SD4_MODE_FAST, 157 + .n_voltages = AS3722_SD2_VSEL_MAX + 1, 158 + }, 159 + { 160 + .regulator_id = AS3722_REGULATOR_ID_SD5, 161 + .name = "as3722-sd5", 162 + .sname = "vsup-sd5", 163 + .vsel_reg = AS3722_SD5_VOLTAGE_REG, 164 + .vsel_mask = AS3722_SD_VSEL_MASK, 165 + .enable_reg = AS3722_SD_CONTROL_REG, 166 + .enable_mask = AS3722_SDn_CTRL(5), 167 + .sleep_ctrl_reg = AS3722_ENABLE_CTRL2_REG, 168 + .sleep_ctrl_mask = AS3722_SD5_EXT_ENABLE_MASK, 169 + .control_reg = AS3722_SD5_CONTROL_REG, 170 + .mode_mask = AS3722_SD5_MODE_FAST, 171 + .n_voltages = AS3722_SD2_VSEL_MAX + 1, 172 + }, 173 + { 174 + .regulator_id = AS3722_REGULATOR_ID_SD6, 175 + .name = "as3722-sd6", 176 + .vsel_reg = AS3722_SD6_VOLTAGE_REG, 177 + .vsel_mask = AS3722_SD_VSEL_MASK, 178 + .enable_reg = AS3722_SD_CONTROL_REG, 179 + .enable_mask = AS3722_SDn_CTRL(6), 180 + .sleep_ctrl_reg = AS3722_ENABLE_CTRL2_REG, 181 + .sleep_ctrl_mask = AS3722_SD6_EXT_ENABLE_MASK, 182 + .control_reg = AS3722_SD6_CONTROL_REG, 183 + .mode_mask = AS3722_SD6_MODE_FAST, 184 + .n_voltages = AS3722_SD0_VSEL_MAX + 1, 185 + }, 186 + { 187 + .regulator_id = AS3722_REGULATOR_ID_LDO0, 188 + .name = "as3722-ldo0", 189 + .sname = "vin-ldo0", 190 + .vsel_reg = AS3722_LDO0_VOLTAGE_REG, 191 + .vsel_mask = AS3722_LDO0_VSEL_MASK, 192 + .enable_reg = AS3722_LDOCONTROL0_REG, 193 + .enable_mask = AS3722_LDO0_CTRL, 194 + .sleep_ctrl_reg = AS3722_ENABLE_CTRL3_REG, 195 + .sleep_ctrl_mask = AS3722_LDO0_EXT_ENABLE_MASK, 196 + .n_voltages = AS3722_LDO0_NUM_VOLT, 197 + }, 198 + { 199 + .regulator_id = AS3722_REGULATOR_ID_LDO1, 200 + .name = "as3722-ldo1", 201 + .sname = "vin-ldo1-6", 202 + .vsel_reg = AS3722_LDO1_VOLTAGE_REG, 203 + .vsel_mask = AS3722_LDO_VSEL_MASK, 204 + .enable_reg = AS3722_LDOCONTROL0_REG, 205 + .enable_mask = AS3722_LDO1_CTRL, 206 + .sleep_ctrl_reg = AS3722_ENABLE_CTRL3_REG, 207 + .sleep_ctrl_mask = AS3722_LDO1_EXT_ENABLE_MASK, 208 + .n_voltages = AS3722_LDO_NUM_VOLT, 209 + }, 210 + { 211 + .regulator_id = AS3722_REGULATOR_ID_LDO2, 212 + .name = "as3722-ldo2", 213 + .sname = "vin-ldo2-5-7", 214 + .vsel_reg = AS3722_LDO2_VOLTAGE_REG, 215 + .vsel_mask = AS3722_LDO_VSEL_MASK, 216 + .enable_reg = AS3722_LDOCONTROL0_REG, 217 + .enable_mask = AS3722_LDO2_CTRL, 218 + .sleep_ctrl_reg = AS3722_ENABLE_CTRL3_REG, 219 + .sleep_ctrl_mask = AS3722_LDO2_EXT_ENABLE_MASK, 220 + .n_voltages = AS3722_LDO_NUM_VOLT, 221 + }, 222 + { 223 + .regulator_id = AS3722_REGULATOR_ID_LDO3, 224 + .name = "as3722-ldo3", 225 + .name = "vin-ldo3-4", 226 + .vsel_reg = AS3722_LDO3_VOLTAGE_REG, 227 + .vsel_mask = AS3722_LDO3_VSEL_MASK, 228 + .enable_reg = AS3722_LDOCONTROL0_REG, 229 + .enable_mask = AS3722_LDO3_CTRL, 230 + .sleep_ctrl_reg = AS3722_ENABLE_CTRL3_REG, 231 + .sleep_ctrl_mask = AS3722_LDO3_EXT_ENABLE_MASK, 232 + .n_voltages = AS3722_LDO3_NUM_VOLT, 233 + }, 234 + { 235 + .regulator_id = AS3722_REGULATOR_ID_LDO4, 236 + .name = "as3722-ldo4", 237 + .name = "vin-ldo3-4", 238 + .vsel_reg = AS3722_LDO4_VOLTAGE_REG, 239 + .vsel_mask = AS3722_LDO_VSEL_MASK, 240 + .enable_reg = AS3722_LDOCONTROL0_REG, 241 + .enable_mask = AS3722_LDO4_CTRL, 242 + .sleep_ctrl_reg = AS3722_ENABLE_CTRL4_REG, 243 + .sleep_ctrl_mask = AS3722_LDO4_EXT_ENABLE_MASK, 244 + .n_voltages = AS3722_LDO_NUM_VOLT, 245 + }, 246 + { 247 + .regulator_id = AS3722_REGULATOR_ID_LDO5, 248 + .name = "as3722-ldo5", 249 + .sname = "vin-ldo2-5-7", 250 + .vsel_reg = AS3722_LDO5_VOLTAGE_REG, 251 + .vsel_mask = AS3722_LDO_VSEL_MASK, 252 + .enable_reg = AS3722_LDOCONTROL0_REG, 253 + .enable_mask = AS3722_LDO5_CTRL, 254 + .sleep_ctrl_reg = AS3722_ENABLE_CTRL4_REG, 255 + .sleep_ctrl_mask = AS3722_LDO5_EXT_ENABLE_MASK, 256 + .n_voltages = AS3722_LDO_NUM_VOLT, 257 + }, 258 + { 259 + .regulator_id = AS3722_REGULATOR_ID_LDO6, 260 + .name = "as3722-ldo6", 261 + .sname = "vin-ldo1-6", 262 + .vsel_reg = AS3722_LDO6_VOLTAGE_REG, 263 + .vsel_mask = AS3722_LDO_VSEL_MASK, 264 + .enable_reg = AS3722_LDOCONTROL0_REG, 265 + .enable_mask = AS3722_LDO6_CTRL, 266 + .sleep_ctrl_reg = AS3722_ENABLE_CTRL4_REG, 267 + .sleep_ctrl_mask = AS3722_LDO6_EXT_ENABLE_MASK, 268 + .n_voltages = AS3722_LDO_NUM_VOLT, 269 + }, 270 + { 271 + .regulator_id = AS3722_REGULATOR_ID_LDO7, 272 + .name = "as3722-ldo7", 273 + .sname = "vin-ldo2-5-7", 274 + .vsel_reg = AS3722_LDO7_VOLTAGE_REG, 275 + .vsel_mask = AS3722_LDO_VSEL_MASK, 276 + .enable_reg = AS3722_LDOCONTROL0_REG, 277 + .enable_mask = AS3722_LDO7_CTRL, 278 + .sleep_ctrl_reg = AS3722_ENABLE_CTRL4_REG, 279 + .sleep_ctrl_mask = AS3722_LDO7_EXT_ENABLE_MASK, 280 + .n_voltages = AS3722_LDO_NUM_VOLT, 281 + }, 282 + { 283 + .regulator_id = AS3722_REGULATOR_ID_LDO9, 284 + .name = "as3722-ldo9", 285 + .sname = "vin-ldo9-10", 286 + .vsel_reg = AS3722_LDO9_VOLTAGE_REG, 287 + .vsel_mask = AS3722_LDO_VSEL_MASK, 288 + .enable_reg = AS3722_LDOCONTROL1_REG, 289 + .enable_mask = AS3722_LDO9_CTRL, 290 + .sleep_ctrl_reg = AS3722_ENABLE_CTRL5_REG, 291 + .sleep_ctrl_mask = AS3722_LDO9_EXT_ENABLE_MASK, 292 + .n_voltages = AS3722_LDO_NUM_VOLT, 293 + }, 294 + { 295 + .regulator_id = AS3722_REGULATOR_ID_LDO10, 296 + .name = "as3722-ldo10", 297 + .sname = "vin-ldo9-10", 298 + .vsel_reg = AS3722_LDO10_VOLTAGE_REG, 299 + .vsel_mask = AS3722_LDO_VSEL_MASK, 300 + .enable_reg = AS3722_LDOCONTROL1_REG, 301 + .enable_mask = AS3722_LDO10_CTRL, 302 + .sleep_ctrl_reg = AS3722_ENABLE_CTRL5_REG, 303 + .sleep_ctrl_mask = AS3722_LDO10_EXT_ENABLE_MASK, 304 + .n_voltages = AS3722_LDO_NUM_VOLT, 305 + }, 306 + { 307 + .regulator_id = AS3722_REGULATOR_ID_LDO11, 308 + .name = "as3722-ldo11", 309 + .sname = "vin-ldo11", 310 + .vsel_reg = AS3722_LDO11_VOLTAGE_REG, 311 + .vsel_mask = AS3722_LDO_VSEL_MASK, 312 + .enable_reg = AS3722_LDOCONTROL1_REG, 313 + .enable_mask = AS3722_LDO11_CTRL, 314 + .sleep_ctrl_reg = AS3722_ENABLE_CTRL5_REG, 315 + .sleep_ctrl_mask = AS3722_LDO11_EXT_ENABLE_MASK, 316 + .n_voltages = AS3722_LDO_NUM_VOLT, 317 + }, 318 + }; 319 + 320 + 321 + static const int as3722_ldo_current[] = { 150000, 300000 }; 322 + static const int as3722_sd016_current[] = { 2500000, 3000000, 3500000 }; 323 + 324 + static int as3722_current_to_index(int min_uA, int max_uA, 325 + const int *curr_table, int n_currents) 326 + { 327 + int i; 328 + 329 + for (i = n_currents - 1; i >= 0; i--) { 330 + if ((min_uA <= curr_table[i]) && (curr_table[i] <= max_uA)) 331 + return i; 332 + } 333 + return -EINVAL; 334 + } 335 + 336 + static int as3722_ldo_get_current_limit(struct regulator_dev *rdev) 337 + { 338 + struct as3722_regulators *as3722_regs = rdev_get_drvdata(rdev); 339 + struct as3722 *as3722 = as3722_regs->as3722; 340 + int id = rdev_get_id(rdev); 341 + u32 val; 342 + int ret; 343 + 344 + ret = as3722_read(as3722, as3722_reg_lookup[id].vsel_reg, &val); 345 + if (ret < 0) { 346 + dev_err(as3722_regs->dev, "Reg 0x%02x read failed: %d\n", 347 + as3722_reg_lookup[id].vsel_reg, ret); 348 + return ret; 349 + } 350 + if (val & AS3722_LDO_ILIMIT_MASK) 351 + return 300000; 352 + return 150000; 353 + } 354 + 355 + static int as3722_ldo_set_current_limit(struct regulator_dev *rdev, 356 + int min_uA, int max_uA) 357 + { 358 + struct as3722_regulators *as3722_regs = rdev_get_drvdata(rdev); 359 + struct as3722 *as3722 = as3722_regs->as3722; 360 + int id = rdev_get_id(rdev); 361 + int ret; 362 + u32 reg = 0; 363 + 364 + ret = as3722_current_to_index(min_uA, max_uA, as3722_ldo_current, 365 + ARRAY_SIZE(as3722_ldo_current)); 366 + if (ret < 0) { 367 + dev_err(as3722_regs->dev, 368 + "Current range min:max = %d:%d does not support\n", 369 + min_uA, max_uA); 370 + return ret; 371 + } 372 + if (ret) 373 + reg = AS3722_LDO_ILIMIT_BIT; 374 + return as3722_update_bits(as3722, as3722_reg_lookup[id].vsel_reg, 375 + AS3722_LDO_ILIMIT_MASK, reg); 376 + } 377 + 378 + static struct regulator_ops as3722_ldo0_ops = { 379 + .is_enabled = regulator_is_enabled_regmap, 380 + .enable = regulator_enable_regmap, 381 + .disable = regulator_disable_regmap, 382 + .list_voltage = regulator_list_voltage_linear, 383 + .get_voltage_sel = regulator_get_voltage_sel_regmap, 384 + .set_voltage_sel = regulator_set_voltage_sel_regmap, 385 + .get_current_limit = as3722_ldo_get_current_limit, 386 + .set_current_limit = as3722_ldo_set_current_limit, 387 + }; 388 + 389 + static struct regulator_ops as3722_ldo0_extcntrl_ops = { 390 + .list_voltage = regulator_list_voltage_linear, 391 + .get_voltage_sel = regulator_get_voltage_sel_regmap, 392 + .set_voltage_sel = regulator_set_voltage_sel_regmap, 393 + .get_current_limit = as3722_ldo_get_current_limit, 394 + .set_current_limit = as3722_ldo_set_current_limit, 395 + }; 396 + 397 + static int as3722_ldo3_set_tracking_mode(struct as3722_regulators *as3722_reg, 398 + int id, u8 mode) 399 + { 400 + struct as3722 *as3722 = as3722_reg->as3722; 401 + 402 + switch (mode) { 403 + case AS3722_LDO3_MODE_PMOS: 404 + case AS3722_LDO3_MODE_PMOS_TRACKING: 405 + case AS3722_LDO3_MODE_NMOS: 406 + case AS3722_LDO3_MODE_SWITCH: 407 + return as3722_update_bits(as3722, 408 + as3722_reg_lookup[id].vsel_reg, 409 + AS3722_LDO3_MODE_MASK, mode); 410 + 411 + default: 412 + return -EINVAL; 413 + } 414 + } 415 + 416 + static int as3722_ldo3_get_current_limit(struct regulator_dev *rdev) 417 + { 418 + return 150000; 419 + } 420 + 421 + static struct regulator_ops as3722_ldo3_ops = { 422 + .is_enabled = regulator_is_enabled_regmap, 423 + .enable = regulator_enable_regmap, 424 + .disable = regulator_disable_regmap, 425 + .list_voltage = regulator_list_voltage_linear, 426 + .get_voltage_sel = regulator_get_voltage_sel_regmap, 427 + .set_voltage_sel = regulator_set_voltage_sel_regmap, 428 + .get_current_limit = as3722_ldo3_get_current_limit, 429 + }; 430 + 431 + static struct regulator_ops as3722_ldo3_extcntrl_ops = { 432 + .list_voltage = regulator_list_voltage_linear, 433 + .get_voltage_sel = regulator_get_voltage_sel_regmap, 434 + .set_voltage_sel = regulator_set_voltage_sel_regmap, 435 + .get_current_limit = as3722_ldo3_get_current_limit, 436 + }; 437 + 438 + static const struct regulator_linear_range as3722_ldo_ranges[] = { 439 + REGULATOR_LINEAR_RANGE(825000, 0x01, 0x24, 25000), 440 + REGULATOR_LINEAR_RANGE(1725000, 0x40, 0x7F, 25000), 441 + }; 442 + 443 + static struct regulator_ops as3722_ldo_ops = { 444 + .is_enabled = regulator_is_enabled_regmap, 445 + .enable = regulator_enable_regmap, 446 + .disable = regulator_disable_regmap, 447 + .map_voltage = regulator_map_voltage_linear_range, 448 + .set_voltage_sel = regulator_set_voltage_sel_regmap, 449 + .get_voltage_sel = regulator_get_voltage_sel_regmap, 450 + .list_voltage = regulator_list_voltage_linear_range, 451 + .get_current_limit = as3722_ldo_get_current_limit, 452 + .set_current_limit = as3722_ldo_set_current_limit, 453 + }; 454 + 455 + static struct regulator_ops as3722_ldo_extcntrl_ops = { 456 + .map_voltage = regulator_map_voltage_linear_range, 457 + .set_voltage_sel = regulator_set_voltage_sel_regmap, 458 + .get_voltage_sel = regulator_get_voltage_sel_regmap, 459 + .list_voltage = regulator_list_voltage_linear_range, 460 + .get_current_limit = as3722_ldo_get_current_limit, 461 + .set_current_limit = as3722_ldo_set_current_limit, 462 + }; 463 + 464 + static unsigned int as3722_sd_get_mode(struct regulator_dev *rdev) 465 + { 466 + struct as3722_regulators *as3722_regs = rdev_get_drvdata(rdev); 467 + struct as3722 *as3722 = as3722_regs->as3722; 468 + int id = rdev_get_id(rdev); 469 + u32 val; 470 + int ret; 471 + 472 + if (!as3722_reg_lookup[id].control_reg) 473 + return -ENOTSUPP; 474 + 475 + ret = as3722_read(as3722, as3722_reg_lookup[id].control_reg, &val); 476 + if (ret < 0) { 477 + dev_err(as3722_regs->dev, "Reg 0x%02x read failed: %d\n", 478 + as3722_reg_lookup[id].control_reg, ret); 479 + return ret; 480 + } 481 + 482 + if (val & as3722_reg_lookup[id].mode_mask) 483 + return REGULATOR_MODE_FAST; 484 + else 485 + return REGULATOR_MODE_NORMAL; 486 + } 487 + 488 + static int as3722_sd_set_mode(struct regulator_dev *rdev, 489 + unsigned int mode) 490 + { 491 + struct as3722_regulators *as3722_regs = rdev_get_drvdata(rdev); 492 + struct as3722 *as3722 = as3722_regs->as3722; 493 + u8 id = rdev_get_id(rdev); 494 + u8 val = 0; 495 + int ret; 496 + 497 + if (!as3722_reg_lookup[id].control_reg) 498 + return -ERANGE; 499 + 500 + switch (mode) { 501 + case REGULATOR_MODE_FAST: 502 + val = as3722_reg_lookup[id].mode_mask; 503 + case REGULATOR_MODE_NORMAL: /* fall down */ 504 + break; 505 + default: 506 + return -EINVAL; 507 + } 508 + 509 + ret = as3722_update_bits(as3722, as3722_reg_lookup[id].control_reg, 510 + as3722_reg_lookup[id].mode_mask, val); 511 + if (ret < 0) { 512 + dev_err(as3722_regs->dev, "Reg 0x%02x update failed: %d\n", 513 + as3722_reg_lookup[id].control_reg, ret); 514 + return ret; 515 + } 516 + return ret; 517 + } 518 + 519 + static int as3722_sd016_get_current_limit(struct regulator_dev *rdev) 520 + { 521 + struct as3722_regulators *as3722_regs = rdev_get_drvdata(rdev); 522 + struct as3722 *as3722 = as3722_regs->as3722; 523 + int id = rdev_get_id(rdev); 524 + u32 val, reg; 525 + int mask; 526 + int ret; 527 + 528 + switch (id) { 529 + case AS3722_REGULATOR_ID_SD0: 530 + reg = AS3722_OVCURRENT_REG; 531 + mask = AS3722_OVCURRENT_SD0_TRIP_MASK; 532 + break; 533 + case AS3722_REGULATOR_ID_SD1: 534 + reg = AS3722_OVCURRENT_REG; 535 + mask = AS3722_OVCURRENT_SD1_TRIP_MASK; 536 + break; 537 + case AS3722_REGULATOR_ID_SD6: 538 + reg = AS3722_OVCURRENT_DEB_REG; 539 + mask = AS3722_OVCURRENT_SD6_TRIP_MASK; 540 + break; 541 + default: 542 + return -EINVAL; 543 + } 544 + ret = as3722_read(as3722, reg, &val); 545 + if (ret < 0) { 546 + dev_err(as3722_regs->dev, "Reg 0x%02x read failed: %d\n", 547 + reg, ret); 548 + return ret; 549 + } 550 + val &= mask; 551 + val >>= ffs(mask) - 1; 552 + if (val == 3) 553 + return -EINVAL; 554 + return as3722_sd016_current[val]; 555 + } 556 + 557 + static int as3722_sd016_set_current_limit(struct regulator_dev *rdev, 558 + int min_uA, int max_uA) 559 + { 560 + struct as3722_regulators *as3722_regs = rdev_get_drvdata(rdev); 561 + struct as3722 *as3722 = as3722_regs->as3722; 562 + int id = rdev_get_id(rdev); 563 + int ret; 564 + int val; 565 + int mask; 566 + u32 reg; 567 + 568 + ret = as3722_current_to_index(min_uA, max_uA, as3722_sd016_current, 569 + ARRAY_SIZE(as3722_sd016_current)); 570 + if (ret < 0) { 571 + dev_err(as3722_regs->dev, 572 + "Current range min:max = %d:%d does not support\n", 573 + min_uA, max_uA); 574 + return ret; 575 + } 576 + 577 + switch (id) { 578 + case AS3722_REGULATOR_ID_SD0: 579 + reg = AS3722_OVCURRENT_REG; 580 + mask = AS3722_OVCURRENT_SD0_TRIP_MASK; 581 + break; 582 + case AS3722_REGULATOR_ID_SD1: 583 + reg = AS3722_OVCURRENT_REG; 584 + mask = AS3722_OVCURRENT_SD1_TRIP_MASK; 585 + break; 586 + case AS3722_REGULATOR_ID_SD6: 587 + reg = AS3722_OVCURRENT_DEB_REG; 588 + mask = AS3722_OVCURRENT_SD6_TRIP_MASK; 589 + break; 590 + default: 591 + return -EINVAL; 592 + } 593 + val = ret & mask; 594 + val <<= ffs(mask) - 1; 595 + return as3722_update_bits(as3722, reg, mask, val); 596 + } 597 + 598 + static const struct regulator_linear_range as3722_sd2345_ranges[] = { 599 + REGULATOR_LINEAR_RANGE(612500, 0x01, 0x40, 12500), 600 + REGULATOR_LINEAR_RANGE(1425000, 0x41, 0x70, 25000), 601 + REGULATOR_LINEAR_RANGE(2650000, 0x71, 0x7F, 50000), 602 + }; 603 + 604 + static struct regulator_ops as3722_sd016_ops = { 605 + .is_enabled = regulator_is_enabled_regmap, 606 + .enable = regulator_enable_regmap, 607 + .disable = regulator_disable_regmap, 608 + .list_voltage = regulator_list_voltage_linear, 609 + .map_voltage = regulator_map_voltage_linear, 610 + .get_voltage_sel = regulator_get_voltage_sel_regmap, 611 + .set_voltage_sel = regulator_set_voltage_sel_regmap, 612 + .get_current_limit = as3722_sd016_get_current_limit, 613 + .set_current_limit = as3722_sd016_set_current_limit, 614 + .get_mode = as3722_sd_get_mode, 615 + .set_mode = as3722_sd_set_mode, 616 + }; 617 + 618 + static struct regulator_ops as3722_sd016_extcntrl_ops = { 619 + .list_voltage = regulator_list_voltage_linear, 620 + .map_voltage = regulator_map_voltage_linear, 621 + .get_voltage_sel = regulator_get_voltage_sel_regmap, 622 + .set_voltage_sel = regulator_set_voltage_sel_regmap, 623 + .get_current_limit = as3722_sd016_get_current_limit, 624 + .set_current_limit = as3722_sd016_set_current_limit, 625 + .get_mode = as3722_sd_get_mode, 626 + .set_mode = as3722_sd_set_mode, 627 + }; 628 + 629 + static struct regulator_ops as3722_sd2345_ops = { 630 + .is_enabled = regulator_is_enabled_regmap, 631 + .enable = regulator_enable_regmap, 632 + .disable = regulator_disable_regmap, 633 + .list_voltage = regulator_list_voltage_linear_range, 634 + .map_voltage = regulator_map_voltage_linear_range, 635 + .set_voltage_sel = regulator_set_voltage_sel_regmap, 636 + .get_voltage_sel = regulator_get_voltage_sel_regmap, 637 + .get_mode = as3722_sd_get_mode, 638 + .set_mode = as3722_sd_set_mode, 639 + }; 640 + 641 + static struct regulator_ops as3722_sd2345_extcntrl_ops = { 642 + .list_voltage = regulator_list_voltage_linear_range, 643 + .map_voltage = regulator_map_voltage_linear_range, 644 + .set_voltage_sel = regulator_set_voltage_sel_regmap, 645 + .get_voltage_sel = regulator_get_voltage_sel_regmap, 646 + .get_mode = as3722_sd_get_mode, 647 + .set_mode = as3722_sd_set_mode, 648 + }; 649 + 650 + static int as3722_extreg_init(struct as3722_regulators *as3722_regs, int id, 651 + int ext_pwr_ctrl) 652 + { 653 + int ret; 654 + unsigned int val; 655 + 656 + if ((ext_pwr_ctrl < AS3722_EXT_CONTROL_ENABLE1) || 657 + (ext_pwr_ctrl > AS3722_EXT_CONTROL_ENABLE3)) 658 + return -EINVAL; 659 + 660 + val = ext_pwr_ctrl << (ffs(as3722_reg_lookup[id].sleep_ctrl_mask) - 1); 661 + ret = as3722_update_bits(as3722_regs->as3722, 662 + as3722_reg_lookup[id].sleep_ctrl_reg, 663 + as3722_reg_lookup[id].sleep_ctrl_mask, val); 664 + if (ret < 0) 665 + dev_err(as3722_regs->dev, "Reg 0x%02x update failed: %d\n", 666 + as3722_reg_lookup[id].sleep_ctrl_reg, ret); 667 + return ret; 668 + } 669 + 670 + static struct of_regulator_match as3722_regulator_matches[] = { 671 + { .name = "sd0", }, 672 + { .name = "sd1", }, 673 + { .name = "sd2", }, 674 + { .name = "sd3", }, 675 + { .name = "sd4", }, 676 + { .name = "sd5", }, 677 + { .name = "sd6", }, 678 + { .name = "ldo0", }, 679 + { .name = "ldo1", }, 680 + { .name = "ldo2", }, 681 + { .name = "ldo3", }, 682 + { .name = "ldo4", }, 683 + { .name = "ldo5", }, 684 + { .name = "ldo6", }, 685 + { .name = "ldo7", }, 686 + { .name = "ldo9", }, 687 + { .name = "ldo10", }, 688 + { .name = "ldo11", }, 689 + }; 690 + 691 + static int as3722_get_regulator_dt_data(struct platform_device *pdev, 692 + struct as3722_regulators *as3722_regs) 693 + { 694 + struct device_node *np; 695 + struct as3722_regulator_config_data *reg_config; 696 + u32 prop; 697 + int id; 698 + int ret; 699 + 700 + np = of_get_child_by_name(pdev->dev.parent->of_node, "regulators"); 701 + if (!np) { 702 + dev_err(&pdev->dev, "Device is not having regulators node\n"); 703 + return -ENODEV; 704 + } 705 + pdev->dev.of_node = np; 706 + 707 + ret = of_regulator_match(&pdev->dev, np, as3722_regulator_matches, 708 + ARRAY_SIZE(as3722_regulator_matches)); 709 + if (ret < 0) { 710 + dev_err(&pdev->dev, "Parsing of regulator node failed: %d\n", 711 + ret); 712 + return ret; 713 + } 714 + 715 + for (id = 0; id < ARRAY_SIZE(as3722_regulator_matches); ++id) { 716 + struct device_node *reg_node; 717 + 718 + reg_config = &as3722_regs->reg_config_data[id]; 719 + reg_config->reg_init = as3722_regulator_matches[id].init_data; 720 + reg_node = as3722_regulator_matches[id].of_node; 721 + 722 + if (!reg_config->reg_init || !reg_node) 723 + continue; 724 + 725 + ret = of_property_read_u32(reg_node, "ams,ext-control", &prop); 726 + if (!ret) { 727 + if (prop < 3) 728 + reg_config->ext_control = prop; 729 + else 730 + dev_warn(&pdev->dev, 731 + "ext-control have invalid option: %u\n", 732 + prop); 733 + } 734 + reg_config->enable_tracking = 735 + of_property_read_bool(reg_node, "ams,enable-tracking"); 736 + } 737 + return 0; 738 + } 739 + 740 + static int as3722_regulator_probe(struct platform_device *pdev) 741 + { 742 + struct as3722 *as3722 = dev_get_drvdata(pdev->dev.parent); 743 + struct as3722_regulators *as3722_regs; 744 + struct as3722_regulator_config_data *reg_config; 745 + struct regulator_dev *rdev; 746 + struct regulator_config config = { }; 747 + struct regulator_ops *ops; 748 + int id; 749 + int ret; 750 + 751 + as3722_regs = devm_kzalloc(&pdev->dev, sizeof(*as3722_regs), 752 + GFP_KERNEL); 753 + if (!as3722_regs) 754 + return -ENOMEM; 755 + 756 + as3722_regs->dev = &pdev->dev; 757 + as3722_regs->as3722 = as3722; 758 + platform_set_drvdata(pdev, as3722_regs); 759 + 760 + ret = as3722_get_regulator_dt_data(pdev, as3722_regs); 761 + if (ret < 0) 762 + return ret; 763 + 764 + config.dev = &pdev->dev; 765 + config.driver_data = as3722_regs; 766 + config.regmap = as3722->regmap; 767 + 768 + for (id = 0; id < AS3722_REGULATOR_ID_MAX; id++) { 769 + reg_config = &as3722_regs->reg_config_data[id]; 770 + 771 + as3722_regs->desc[id].name = as3722_reg_lookup[id].name; 772 + as3722_regs->desc[id].supply_name = as3722_reg_lookup[id].sname; 773 + as3722_regs->desc[id].id = as3722_reg_lookup[id].regulator_id; 774 + as3722_regs->desc[id].n_voltages = 775 + as3722_reg_lookup[id].n_voltages; 776 + as3722_regs->desc[id].type = REGULATOR_VOLTAGE; 777 + as3722_regs->desc[id].owner = THIS_MODULE; 778 + as3722_regs->desc[id].enable_reg = 779 + as3722_reg_lookup[id].enable_reg; 780 + as3722_regs->desc[id].enable_mask = 781 + as3722_reg_lookup[id].enable_mask; 782 + as3722_regs->desc[id].vsel_reg = as3722_reg_lookup[id].vsel_reg; 783 + as3722_regs->desc[id].vsel_mask = 784 + as3722_reg_lookup[id].vsel_mask; 785 + switch (id) { 786 + case AS3722_REGULATOR_ID_LDO0: 787 + if (reg_config->ext_control) 788 + ops = &as3722_ldo0_extcntrl_ops; 789 + else 790 + ops = &as3722_ldo0_ops; 791 + as3722_regs->desc[id].min_uV = 825000; 792 + as3722_regs->desc[id].uV_step = 25000; 793 + as3722_regs->desc[id].linear_min_sel = 1; 794 + as3722_regs->desc[id].enable_time = 500; 795 + break; 796 + case AS3722_REGULATOR_ID_LDO3: 797 + if (reg_config->ext_control) 798 + ops = &as3722_ldo3_extcntrl_ops; 799 + else 800 + ops = &as3722_ldo3_ops; 801 + as3722_regs->desc[id].min_uV = 620000; 802 + as3722_regs->desc[id].uV_step = 20000; 803 + as3722_regs->desc[id].linear_min_sel = 1; 804 + as3722_regs->desc[id].enable_time = 500; 805 + if (reg_config->enable_tracking) { 806 + ret = as3722_ldo3_set_tracking_mode(as3722_regs, 807 + id, AS3722_LDO3_MODE_PMOS_TRACKING); 808 + if (ret < 0) { 809 + dev_err(&pdev->dev, 810 + "LDO3 tracking failed: %d\n", 811 + ret); 812 + return ret; 813 + } 814 + } 815 + break; 816 + case AS3722_REGULATOR_ID_SD0: 817 + case AS3722_REGULATOR_ID_SD1: 818 + case AS3722_REGULATOR_ID_SD6: 819 + if (reg_config->ext_control) 820 + ops = &as3722_sd016_extcntrl_ops; 821 + else 822 + ops = &as3722_sd016_ops; 823 + as3722_regs->desc[id].min_uV = 610000; 824 + as3722_regs->desc[id].uV_step = 10000; 825 + as3722_regs->desc[id].linear_min_sel = 1; 826 + break; 827 + case AS3722_REGULATOR_ID_SD2: 828 + case AS3722_REGULATOR_ID_SD3: 829 + case AS3722_REGULATOR_ID_SD4: 830 + case AS3722_REGULATOR_ID_SD5: 831 + if (reg_config->ext_control) 832 + ops = &as3722_sd2345_extcntrl_ops; 833 + else 834 + ops = &as3722_sd2345_ops; 835 + as3722_regs->desc[id].linear_ranges = 836 + as3722_sd2345_ranges; 837 + as3722_regs->desc[id].n_linear_ranges = 838 + ARRAY_SIZE(as3722_sd2345_ranges); 839 + break; 840 + default: 841 + if (reg_config->ext_control) 842 + ops = &as3722_ldo_extcntrl_ops; 843 + else 844 + ops = &as3722_ldo_ops; 845 + as3722_regs->desc[id].min_uV = 825000; 846 + as3722_regs->desc[id].uV_step = 25000; 847 + as3722_regs->desc[id].linear_min_sel = 1; 848 + as3722_regs->desc[id].enable_time = 500; 849 + as3722_regs->desc[id].linear_ranges = as3722_ldo_ranges; 850 + as3722_regs->desc[id].n_linear_ranges = 851 + ARRAY_SIZE(as3722_ldo_ranges); 852 + break; 853 + } 854 + as3722_regs->desc[id].ops = ops; 855 + config.init_data = reg_config->reg_init; 856 + config.of_node = as3722_regulator_matches[id].of_node; 857 + rdev = devm_regulator_register(&pdev->dev, 858 + &as3722_regs->desc[id], &config); 859 + if (IS_ERR(rdev)) { 860 + ret = PTR_ERR(rdev); 861 + dev_err(&pdev->dev, "regulator %d register failed %d\n", 862 + id, ret); 863 + return ret; 864 + } 865 + 866 + as3722_regs->rdevs[id] = rdev; 867 + if (reg_config->ext_control) { 868 + ret = regulator_enable_regmap(rdev); 869 + if (ret < 0) { 870 + dev_err(&pdev->dev, 871 + "Regulator %d enable failed: %d\n", 872 + id, ret); 873 + return ret; 874 + } 875 + ret = as3722_extreg_init(as3722_regs, id, 876 + reg_config->ext_control); 877 + if (ret < 0) { 878 + dev_err(&pdev->dev, 879 + "AS3722 ext control failed: %d", ret); 880 + return ret; 881 + } 882 + } 883 + } 884 + return 0; 885 + } 886 + 887 + static const struct of_device_id of_as3722_regulator_match[] = { 888 + { .compatible = "ams,as3722-regulator", }, 889 + {}, 890 + }; 891 + MODULE_DEVICE_TABLE(of, of_as3722_regulator_match); 892 + 893 + static struct platform_driver as3722_regulator_driver = { 894 + .driver = { 895 + .name = "as3722-regulator", 896 + .owner = THIS_MODULE, 897 + .of_match_table = of_as3722_regulator_match, 898 + }, 899 + .probe = as3722_regulator_probe, 900 + }; 901 + 902 + module_platform_driver(as3722_regulator_driver); 903 + 904 + MODULE_ALIAS("platform:as3722-regulator"); 905 + MODULE_DESCRIPTION("AS3722 regulator driver"); 906 + MODULE_AUTHOR("Florian Lobmaier <florian.lobmaier@ams.com>"); 907 + MODULE_AUTHOR("Laxman Dewangan <ldewangan@nvidia.com>"); 908 + MODULE_LICENSE("GPL");
+244 -213
drivers/regulator/core.c
··· 36 36 #include <trace/events/regulator.h> 37 37 38 38 #include "dummy.h" 39 + #include "internal.h" 39 40 40 41 #define rdev_crit(rdev, fmt, ...) \ 41 42 pr_crit("%s: " fmt, rdev_get_name(rdev), ##__VA_ARGS__) ··· 53 52 static LIST_HEAD(regulator_list); 54 53 static LIST_HEAD(regulator_map_list); 55 54 static LIST_HEAD(regulator_ena_gpio_list); 55 + static LIST_HEAD(regulator_supply_alias_list); 56 56 static bool has_full_constraints; 57 - static bool board_wants_dummy_regulator; 58 57 59 58 static struct dentry *debugfs_root; 60 59 ··· 84 83 }; 85 84 86 85 /* 87 - * struct regulator 86 + * struct regulator_supply_alias 88 87 * 89 - * One for each consumer device. 88 + * Used to map lookups for a supply onto an alternative device. 90 89 */ 91 - struct regulator { 92 - struct device *dev; 90 + struct regulator_supply_alias { 93 91 struct list_head list; 94 - unsigned int always_on:1; 95 - unsigned int bypass:1; 96 - int uA_load; 97 - int min_uV; 98 - int max_uV; 99 - char *supply_name; 100 - struct device_attribute dev_attr; 101 - struct regulator_dev *rdev; 102 - struct dentry *debugfs; 92 + struct device *src_dev; 93 + const char *src_supply; 94 + struct device *alias_dev; 95 + const char *alias_supply; 103 96 }; 104 97 105 98 static int _regulator_is_enabled(struct regulator_dev *rdev); ··· 918 923 return 0; 919 924 } 920 925 926 + static int machine_constraints_current(struct regulator_dev *rdev, 927 + struct regulation_constraints *constraints) 928 + { 929 + struct regulator_ops *ops = rdev->desc->ops; 930 + int ret; 931 + 932 + if (!constraints->min_uA && !constraints->max_uA) 933 + return 0; 934 + 935 + if (constraints->min_uA > constraints->max_uA) { 936 + rdev_err(rdev, "Invalid current constraints\n"); 937 + return -EINVAL; 938 + } 939 + 940 + if (!ops->set_current_limit || !ops->get_current_limit) { 941 + rdev_warn(rdev, "Operation of current configuration missing\n"); 942 + return 0; 943 + } 944 + 945 + /* Set regulator current in constraints range */ 946 + ret = ops->set_current_limit(rdev, constraints->min_uA, 947 + constraints->max_uA); 948 + if (ret < 0) { 949 + rdev_err(rdev, "Failed to set current constraint, %d\n", ret); 950 + return ret; 951 + } 952 + 953 + return 0; 954 + } 955 + 921 956 /** 922 957 * set_machine_constraints - sets regulator constraints 923 958 * @rdev: regulator source ··· 975 950 return -ENOMEM; 976 951 977 952 ret = machine_constraints_voltage(rdev, rdev->constraints); 953 + if (ret != 0) 954 + goto out; 955 + 956 + ret = machine_constraints_current(rdev, rdev->constraints); 978 957 if (ret != 0) 979 958 goto out; 980 959 ··· 1215 1186 1216 1187 static int _regulator_get_enable_time(struct regulator_dev *rdev) 1217 1188 { 1189 + if (rdev->constraints && rdev->constraints->enable_time) 1190 + return rdev->constraints->enable_time; 1218 1191 if (!rdev->desc->ops->enable_time) 1219 1192 return rdev->desc->enable_time; 1220 1193 return rdev->desc->ops->enable_time(rdev); 1194 + } 1195 + 1196 + static struct regulator_supply_alias *regulator_find_supply_alias( 1197 + struct device *dev, const char *supply) 1198 + { 1199 + struct regulator_supply_alias *map; 1200 + 1201 + list_for_each_entry(map, &regulator_supply_alias_list, list) 1202 + if (map->src_dev == dev && strcmp(map->src_supply, supply) == 0) 1203 + return map; 1204 + 1205 + return NULL; 1206 + } 1207 + 1208 + static void regulator_supply_alias(struct device **dev, const char **supply) 1209 + { 1210 + struct regulator_supply_alias *map; 1211 + 1212 + map = regulator_find_supply_alias(*dev, *supply); 1213 + if (map) { 1214 + dev_dbg(*dev, "Mapping supply %s to %s,%s\n", 1215 + *supply, map->alias_supply, 1216 + dev_name(map->alias_dev)); 1217 + *dev = map->alias_dev; 1218 + *supply = map->alias_supply; 1219 + } 1221 1220 } 1222 1221 1223 1222 static struct regulator_dev *regulator_dev_lookup(struct device *dev, ··· 1256 1199 struct device_node *node; 1257 1200 struct regulator_map *map; 1258 1201 const char *devname = NULL; 1202 + 1203 + regulator_supply_alias(&dev, &supply); 1259 1204 1260 1205 /* first do a dt based lookup */ 1261 1206 if (dev && dev->of_node) { ··· 1302 1243 1303 1244 /* Internal regulator request function */ 1304 1245 static struct regulator *_regulator_get(struct device *dev, const char *id, 1305 - bool exclusive) 1246 + bool exclusive, bool allow_dummy) 1306 1247 { 1307 1248 struct regulator_dev *rdev; 1308 1249 struct regulator *regulator = ERR_PTR(-EPROBE_DEFER); 1309 1250 const char *devname = NULL; 1310 - int ret = 0; 1251 + int ret = -EPROBE_DEFER; 1311 1252 1312 1253 if (id == NULL) { 1313 1254 pr_err("get() with no identifier\n"); 1314 - return regulator; 1255 + return ERR_PTR(-EINVAL); 1315 1256 } 1316 1257 1317 1258 if (dev) ··· 1323 1264 if (rdev) 1324 1265 goto found; 1325 1266 1267 + regulator = ERR_PTR(ret); 1268 + 1326 1269 /* 1327 1270 * If we have return value from dev_lookup fail, we do not expect to 1328 1271 * succeed, so, quit with appropriate error value 1329 1272 */ 1330 - if (ret) { 1331 - regulator = ERR_PTR(ret); 1273 + if (ret && ret != -ENODEV) { 1332 1274 goto out; 1333 1275 } 1334 1276 1335 - if (board_wants_dummy_regulator) { 1336 - rdev = dummy_regulator_rdev; 1337 - goto found; 1338 - } 1339 - 1340 - #ifdef CONFIG_REGULATOR_DUMMY 1341 1277 if (!devname) 1342 1278 devname = "deviceless"; 1343 1279 1344 - /* If the board didn't flag that it was fully constrained then 1345 - * substitute in a dummy regulator so consumers can continue. 1280 + /* 1281 + * Assume that a regulator is physically present and enabled 1282 + * even if it isn't hooked up and just provide a dummy. 1346 1283 */ 1347 - if (!has_full_constraints) { 1284 + if (has_full_constraints && allow_dummy) { 1348 1285 pr_warn("%s supply %s not found, using dummy regulator\n", 1349 1286 devname, id); 1287 + 1350 1288 rdev = dummy_regulator_rdev; 1351 1289 goto found; 1290 + } else { 1291 + dev_err(dev, "dummy supplies not allowed\n"); 1352 1292 } 1353 - #endif 1354 1293 1355 1294 mutex_unlock(&regulator_list_mutex); 1356 1295 return regulator; ··· 1406 1349 */ 1407 1350 struct regulator *regulator_get(struct device *dev, const char *id) 1408 1351 { 1409 - return _regulator_get(dev, id, false); 1352 + return _regulator_get(dev, id, false, true); 1410 1353 } 1411 1354 EXPORT_SYMBOL_GPL(regulator_get); 1412 - 1413 - static void devm_regulator_release(struct device *dev, void *res) 1414 - { 1415 - regulator_put(*(struct regulator **)res); 1416 - } 1417 - 1418 - /** 1419 - * devm_regulator_get - Resource managed regulator_get() 1420 - * @dev: device for regulator "consumer" 1421 - * @id: Supply name or regulator ID. 1422 - * 1423 - * Managed regulator_get(). Regulators returned from this function are 1424 - * automatically regulator_put() on driver detach. See regulator_get() for more 1425 - * information. 1426 - */ 1427 - struct regulator *devm_regulator_get(struct device *dev, const char *id) 1428 - { 1429 - struct regulator **ptr, *regulator; 1430 - 1431 - ptr = devres_alloc(devm_regulator_release, sizeof(*ptr), GFP_KERNEL); 1432 - if (!ptr) 1433 - return ERR_PTR(-ENOMEM); 1434 - 1435 - regulator = regulator_get(dev, id); 1436 - if (!IS_ERR(regulator)) { 1437 - *ptr = regulator; 1438 - devres_add(dev, ptr); 1439 - } else { 1440 - devres_free(ptr); 1441 - } 1442 - 1443 - return regulator; 1444 - } 1445 - EXPORT_SYMBOL_GPL(devm_regulator_get); 1446 1355 1447 1356 /** 1448 1357 * regulator_get_exclusive - obtain exclusive access to a regulator. ··· 1433 1410 */ 1434 1411 struct regulator *regulator_get_exclusive(struct device *dev, const char *id) 1435 1412 { 1436 - return _regulator_get(dev, id, true); 1413 + return _regulator_get(dev, id, true, false); 1437 1414 } 1438 1415 EXPORT_SYMBOL_GPL(regulator_get_exclusive); 1439 1416 ··· 1462 1439 */ 1463 1440 struct regulator *regulator_get_optional(struct device *dev, const char *id) 1464 1441 { 1465 - return _regulator_get(dev, id, 0); 1442 + return _regulator_get(dev, id, false, false); 1466 1443 } 1467 1444 EXPORT_SYMBOL_GPL(regulator_get_optional); 1468 - 1469 - /** 1470 - * devm_regulator_get_optional - Resource managed regulator_get_optional() 1471 - * @dev: device for regulator "consumer" 1472 - * @id: Supply name or regulator ID. 1473 - * 1474 - * Managed regulator_get_optional(). Regulators returned from this 1475 - * function are automatically regulator_put() on driver detach. See 1476 - * regulator_get_optional() for more information. 1477 - */ 1478 - struct regulator *devm_regulator_get_optional(struct device *dev, 1479 - const char *id) 1480 - { 1481 - struct regulator **ptr, *regulator; 1482 - 1483 - ptr = devres_alloc(devm_regulator_release, sizeof(*ptr), GFP_KERNEL); 1484 - if (!ptr) 1485 - return ERR_PTR(-ENOMEM); 1486 - 1487 - regulator = regulator_get_optional(dev, id); 1488 - if (!IS_ERR(regulator)) { 1489 - *ptr = regulator; 1490 - devres_add(dev, ptr); 1491 - } else { 1492 - devres_free(ptr); 1493 - } 1494 - 1495 - return regulator; 1496 - } 1497 - EXPORT_SYMBOL_GPL(devm_regulator_get_optional); 1498 1445 1499 1446 /* Locks held by regulator_put() */ 1500 1447 static void _regulator_put(struct regulator *regulator) ··· 1492 1499 } 1493 1500 1494 1501 /** 1495 - * devm_regulator_get_exclusive - Resource managed regulator_get_exclusive() 1496 - * @dev: device for regulator "consumer" 1497 - * @id: Supply name or regulator ID. 1498 - * 1499 - * Managed regulator_get_exclusive(). Regulators returned from this function 1500 - * are automatically regulator_put() on driver detach. See regulator_get() for 1501 - * more information. 1502 - */ 1503 - struct regulator *devm_regulator_get_exclusive(struct device *dev, 1504 - const char *id) 1505 - { 1506 - struct regulator **ptr, *regulator; 1507 - 1508 - ptr = devres_alloc(devm_regulator_release, sizeof(*ptr), GFP_KERNEL); 1509 - if (!ptr) 1510 - return ERR_PTR(-ENOMEM); 1511 - 1512 - regulator = _regulator_get(dev, id, 1); 1513 - if (!IS_ERR(regulator)) { 1514 - *ptr = regulator; 1515 - devres_add(dev, ptr); 1516 - } else { 1517 - devres_free(ptr); 1518 - } 1519 - 1520 - return regulator; 1521 - } 1522 - EXPORT_SYMBOL_GPL(devm_regulator_get_exclusive); 1523 - 1524 - /** 1525 1502 * regulator_put - "free" the regulator source 1526 1503 * @regulator: regulator source 1527 1504 * ··· 1507 1544 } 1508 1545 EXPORT_SYMBOL_GPL(regulator_put); 1509 1546 1510 - static int devm_regulator_match(struct device *dev, void *res, void *data) 1547 + /** 1548 + * regulator_register_supply_alias - Provide device alias for supply lookup 1549 + * 1550 + * @dev: device that will be given as the regulator "consumer" 1551 + * @id: Supply name or regulator ID 1552 + * @alias_dev: device that should be used to lookup the supply 1553 + * @alias_id: Supply name or regulator ID that should be used to lookup the 1554 + * supply 1555 + * 1556 + * All lookups for id on dev will instead be conducted for alias_id on 1557 + * alias_dev. 1558 + */ 1559 + int regulator_register_supply_alias(struct device *dev, const char *id, 1560 + struct device *alias_dev, 1561 + const char *alias_id) 1511 1562 { 1512 - struct regulator **r = res; 1513 - if (!r || !*r) { 1514 - WARN_ON(!r || !*r); 1515 - return 0; 1516 - } 1517 - return *r == data; 1563 + struct regulator_supply_alias *map; 1564 + 1565 + map = regulator_find_supply_alias(dev, id); 1566 + if (map) 1567 + return -EEXIST; 1568 + 1569 + map = kzalloc(sizeof(struct regulator_supply_alias), GFP_KERNEL); 1570 + if (!map) 1571 + return -ENOMEM; 1572 + 1573 + map->src_dev = dev; 1574 + map->src_supply = id; 1575 + map->alias_dev = alias_dev; 1576 + map->alias_supply = alias_id; 1577 + 1578 + list_add(&map->list, &regulator_supply_alias_list); 1579 + 1580 + pr_info("Adding alias for supply %s,%s -> %s,%s\n", 1581 + id, dev_name(dev), alias_id, dev_name(alias_dev)); 1582 + 1583 + return 0; 1518 1584 } 1585 + EXPORT_SYMBOL_GPL(regulator_register_supply_alias); 1519 1586 1520 1587 /** 1521 - * devm_regulator_put - Resource managed regulator_put() 1522 - * @regulator: regulator to free 1588 + * regulator_unregister_supply_alias - Remove device alias 1523 1589 * 1524 - * Deallocate a regulator allocated with devm_regulator_get(). Normally 1525 - * this function will not need to be called and the resource management 1526 - * code will ensure that the resource is freed. 1590 + * @dev: device that will be given as the regulator "consumer" 1591 + * @id: Supply name or regulator ID 1592 + * 1593 + * Remove a lookup alias if one exists for id on dev. 1527 1594 */ 1528 - void devm_regulator_put(struct regulator *regulator) 1595 + void regulator_unregister_supply_alias(struct device *dev, const char *id) 1529 1596 { 1530 - int rc; 1597 + struct regulator_supply_alias *map; 1531 1598 1532 - rc = devres_release(regulator->dev, devm_regulator_release, 1533 - devm_regulator_match, regulator); 1534 - if (rc != 0) 1535 - WARN_ON(rc); 1599 + map = regulator_find_supply_alias(dev, id); 1600 + if (map) { 1601 + list_del(&map->list); 1602 + kfree(map); 1603 + } 1536 1604 } 1537 - EXPORT_SYMBOL_GPL(devm_regulator_put); 1605 + EXPORT_SYMBOL_GPL(regulator_unregister_supply_alias); 1606 + 1607 + /** 1608 + * regulator_bulk_register_supply_alias - register multiple aliases 1609 + * 1610 + * @dev: device that will be given as the regulator "consumer" 1611 + * @id: List of supply names or regulator IDs 1612 + * @alias_dev: device that should be used to lookup the supply 1613 + * @alias_id: List of supply names or regulator IDs that should be used to 1614 + * lookup the supply 1615 + * @num_id: Number of aliases to register 1616 + * 1617 + * @return 0 on success, an errno on failure. 1618 + * 1619 + * This helper function allows drivers to register several supply 1620 + * aliases in one operation. If any of the aliases cannot be 1621 + * registered any aliases that were registered will be removed 1622 + * before returning to the caller. 1623 + */ 1624 + int regulator_bulk_register_supply_alias(struct device *dev, const char **id, 1625 + struct device *alias_dev, 1626 + const char **alias_id, 1627 + int num_id) 1628 + { 1629 + int i; 1630 + int ret; 1631 + 1632 + for (i = 0; i < num_id; ++i) { 1633 + ret = regulator_register_supply_alias(dev, id[i], alias_dev, 1634 + alias_id[i]); 1635 + if (ret < 0) 1636 + goto err; 1637 + } 1638 + 1639 + return 0; 1640 + 1641 + err: 1642 + dev_err(dev, 1643 + "Failed to create supply alias %s,%s -> %s,%s\n", 1644 + id[i], dev_name(dev), alias_id[i], dev_name(alias_dev)); 1645 + 1646 + while (--i >= 0) 1647 + regulator_unregister_supply_alias(dev, id[i]); 1648 + 1649 + return ret; 1650 + } 1651 + EXPORT_SYMBOL_GPL(regulator_bulk_register_supply_alias); 1652 + 1653 + /** 1654 + * regulator_bulk_unregister_supply_alias - unregister multiple aliases 1655 + * 1656 + * @dev: device that will be given as the regulator "consumer" 1657 + * @id: List of supply names or regulator IDs 1658 + * @num_id: Number of aliases to unregister 1659 + * 1660 + * This helper function allows drivers to unregister several supply 1661 + * aliases in one operation. 1662 + */ 1663 + void regulator_bulk_unregister_supply_alias(struct device *dev, 1664 + const char **id, 1665 + int num_id) 1666 + { 1667 + int i; 1668 + 1669 + for (i = 0; i < num_id; ++i) 1670 + regulator_unregister_supply_alias(dev, id[i]); 1671 + } 1672 + EXPORT_SYMBOL_GPL(regulator_bulk_unregister_supply_alias); 1673 + 1538 1674 1539 1675 /* Manage enable GPIO list. Same GPIO pin can be shared among regulators */ 1540 1676 static int regulator_ena_gpio_request(struct regulator_dev *rdev, ··· 1766 1704 * together. */ 1767 1705 trace_regulator_enable_delay(rdev_get_name(rdev)); 1768 1706 1769 - if (delay >= 1000) { 1770 - mdelay(delay / 1000); 1771 - udelay(delay % 1000); 1772 - } else if (delay) { 1773 - udelay(delay); 1707 + /* 1708 + * Delay for the requested amount of time as per the guidelines in: 1709 + * 1710 + * Documentation/timers/timers-howto.txt 1711 + * 1712 + * The assumption here is that regulators will never be enabled in 1713 + * atomic context and therefore sleeping functions can be used. 1714 + */ 1715 + if (delay) { 1716 + unsigned int ms = delay / 1000; 1717 + unsigned int us = delay % 1000; 1718 + 1719 + if (ms > 0) { 1720 + /* 1721 + * For small enough values, handle super-millisecond 1722 + * delays in the usleep_range() call below. 1723 + */ 1724 + if (ms < 20) 1725 + us += ms * 1000; 1726 + else 1727 + msleep(ms); 1728 + } 1729 + 1730 + /* 1731 + * Give the scheduler some room to coalesce with any other 1732 + * wakeup sources. For delays shorter than 10 us, don't even 1733 + * bother setting up high-resolution timers and just busy- 1734 + * loop. 1735 + */ 1736 + if (us >= 10) 1737 + usleep_range(us, us + 100); 1738 + else 1739 + udelay(us); 1774 1740 } 1775 1741 1776 1742 trace_regulator_enable_complete(rdev_get_name(rdev)); ··· 2579 2489 ret = rdev->desc->ops->get_voltage(rdev); 2580 2490 } else if (rdev->desc->ops->list_voltage) { 2581 2491 ret = rdev->desc->ops->list_voltage(rdev, 0); 2492 + } else if (rdev->desc->fixed_uV && (rdev->desc->n_voltages == 1)) { 2493 + ret = rdev->desc->fixed_uV; 2582 2494 } else { 2583 2495 return -EINVAL; 2584 2496 } ··· 3004 2912 } 3005 2913 EXPORT_SYMBOL_GPL(regulator_bulk_get); 3006 2914 3007 - /** 3008 - * devm_regulator_bulk_get - managed get multiple regulator consumers 3009 - * 3010 - * @dev: Device to supply 3011 - * @num_consumers: Number of consumers to register 3012 - * @consumers: Configuration of consumers; clients are stored here. 3013 - * 3014 - * @return 0 on success, an errno on failure. 3015 - * 3016 - * This helper function allows drivers to get several regulator 3017 - * consumers in one operation with management, the regulators will 3018 - * automatically be freed when the device is unbound. If any of the 3019 - * regulators cannot be acquired then any regulators that were 3020 - * allocated will be freed before returning to the caller. 3021 - */ 3022 - int devm_regulator_bulk_get(struct device *dev, int num_consumers, 3023 - struct regulator_bulk_data *consumers) 3024 - { 3025 - int i; 3026 - int ret; 3027 - 3028 - for (i = 0; i < num_consumers; i++) 3029 - consumers[i].consumer = NULL; 3030 - 3031 - for (i = 0; i < num_consumers; i++) { 3032 - consumers[i].consumer = devm_regulator_get(dev, 3033 - consumers[i].supply); 3034 - if (IS_ERR(consumers[i].consumer)) { 3035 - ret = PTR_ERR(consumers[i].consumer); 3036 - dev_err(dev, "Failed to get supply '%s': %d\n", 3037 - consumers[i].supply, ret); 3038 - consumers[i].consumer = NULL; 3039 - goto err; 3040 - } 3041 - } 3042 - 3043 - return 0; 3044 - 3045 - err: 3046 - for (i = 0; i < num_consumers && consumers[i].consumer; i++) 3047 - devm_regulator_put(consumers[i].consumer); 3048 - 3049 - return ret; 3050 - } 3051 - EXPORT_SYMBOL_GPL(devm_regulator_bulk_get); 3052 - 3053 2915 static void regulator_bulk_enable_async(void *data, async_cookie_t cookie) 3054 2916 { 3055 2917 struct regulator_bulk_data *bulk = data; ··· 3216 3170 /* some attributes need specific methods to be displayed */ 3217 3171 if ((ops->get_voltage && ops->get_voltage(rdev) >= 0) || 3218 3172 (ops->get_voltage_sel && ops->get_voltage_sel(rdev) >= 0) || 3219 - (ops->list_voltage && ops->list_voltage(rdev, 0) >= 0)) { 3173 + (ops->list_voltage && ops->list_voltage(rdev, 0) >= 0) || 3174 + (rdev->desc->fixed_uV && (rdev->desc->n_voltages == 1))) { 3220 3175 status = device_create_file(dev, &dev_attr_microvolts); 3221 3176 if (status < 0) 3222 3177 return status; ··· 3659 3612 has_full_constraints = 1; 3660 3613 } 3661 3614 EXPORT_SYMBOL_GPL(regulator_has_full_constraints); 3662 - 3663 - /** 3664 - * regulator_use_dummy_regulator - Provide a dummy regulator when none is found 3665 - * 3666 - * Calling this function will cause the regulator API to provide a 3667 - * dummy regulator to consumers if no physical regulator is found, 3668 - * allowing most consumers to proceed as though a regulator were 3669 - * configured. This allows systems such as those with software 3670 - * controllable regulators for the CPU core only to be brought up more 3671 - * readily. 3672 - */ 3673 - void regulator_use_dummy_regulator(void) 3674 - { 3675 - board_wants_dummy_regulator = true; 3676 - } 3677 - EXPORT_SYMBOL_GPL(regulator_use_dummy_regulator); 3678 3615 3679 3616 /** 3680 3617 * rdev_get_drvdata - get rdev regulator driver data
+3 -14
drivers/regulator/da903x.c
··· 253 253 } 254 254 255 255 static const struct regulator_linear_range da9034_ldo12_ranges[] = { 256 - { .min_uV = 1700000, .max_uV = 2050000, .min_sel = 0, .max_sel = 7, 257 - .uV_step = 50000 }, 258 - { .min_uV = 2700000, .max_uV = 3050000, .min_sel = 8, .max_sel = 15, 259 - .uV_step = 50000 }, 256 + REGULATOR_LINEAR_RANGE(1700000, 0, 7, 50000), 257 + REGULATOR_LINEAR_RANGE(2700000, 8, 15, 50000), 260 258 }; 261 259 262 260 static struct regulator_ops da903x_regulator_ldo_ops = { ··· 461 463 config.init_data = dev_get_platdata(&pdev->dev); 462 464 config.driver_data = ri; 463 465 464 - rdev = regulator_register(&ri->desc, &config); 466 + rdev = devm_regulator_register(&pdev->dev, &ri->desc, &config); 465 467 if (IS_ERR(rdev)) { 466 468 dev_err(&pdev->dev, "failed to register regulator %s\n", 467 469 ri->desc.name); ··· 472 474 return 0; 473 475 } 474 476 475 - static int da903x_regulator_remove(struct platform_device *pdev) 476 - { 477 - struct regulator_dev *rdev = platform_get_drvdata(pdev); 478 - 479 - regulator_unregister(rdev); 480 - return 0; 481 - } 482 - 483 477 static struct platform_driver da903x_regulator_driver = { 484 478 .driver = { 485 479 .name = "da903x-regulator", 486 480 .owner = THIS_MODULE, 487 481 }, 488 482 .probe = da903x_regulator_probe, 489 - .remove = da903x_regulator_remove, 490 483 }; 491 484 492 485 static int __init da903x_regulator_init(void)
+38 -17
drivers/regulator/da9052-regulator.c
··· 70 70 int step_uV; 71 71 int min_uV; 72 72 int max_uV; 73 + unsigned char activate_bit; 73 74 }; 74 75 75 76 struct da9052_regulator { ··· 210 209 return sel; 211 210 } 212 211 212 + static int da9052_regulator_set_voltage_sel(struct regulator_dev *rdev, 213 + unsigned int selector) 214 + { 215 + struct da9052_regulator *regulator = rdev_get_drvdata(rdev); 216 + struct da9052_regulator_info *info = regulator->info; 217 + int id = rdev_get_id(rdev); 218 + int ret; 219 + 220 + ret = da9052_reg_update(regulator->da9052, rdev->desc->vsel_reg, 221 + rdev->desc->vsel_mask, selector); 222 + if (ret < 0) 223 + return ret; 224 + 225 + /* Some LDOs and DCDCs are DVC controlled which requires enabling of 226 + * the activate bit to implment the changes on the output. 227 + */ 228 + switch (id) { 229 + case DA9052_ID_BUCK1: 230 + case DA9052_ID_BUCK2: 231 + case DA9052_ID_BUCK3: 232 + case DA9052_ID_LDO2: 233 + case DA9052_ID_LDO3: 234 + ret = da9052_reg_update(regulator->da9052, DA9052_SUPPLY_REG, 235 + info->activate_bit, info->activate_bit); 236 + break; 237 + } 238 + 239 + return ret; 240 + } 241 + 213 242 static struct regulator_ops da9052_dcdc_ops = { 214 243 .get_current_limit = da9052_dcdc_get_current_limit, 215 244 .set_current_limit = da9052_dcdc_set_current_limit, ··· 247 216 .list_voltage = da9052_list_voltage, 248 217 .map_voltage = da9052_map_voltage, 249 218 .get_voltage_sel = regulator_get_voltage_sel_regmap, 250 - .set_voltage_sel = regulator_set_voltage_sel_regmap, 219 + .set_voltage_sel = da9052_regulator_set_voltage_sel, 251 220 .is_enabled = regulator_is_enabled_regmap, 252 221 .enable = regulator_enable_regmap, 253 222 .disable = regulator_disable_regmap, ··· 257 226 .list_voltage = da9052_list_voltage, 258 227 .map_voltage = da9052_map_voltage, 259 228 .get_voltage_sel = regulator_get_voltage_sel_regmap, 260 - .set_voltage_sel = regulator_set_voltage_sel_regmap, 229 + .set_voltage_sel = da9052_regulator_set_voltage_sel, 261 230 .is_enabled = regulator_is_enabled_regmap, 262 231 .enable = regulator_enable_regmap, 263 232 .disable = regulator_disable_regmap, ··· 274 243 .owner = THIS_MODULE,\ 275 244 .vsel_reg = DA9052_BUCKCORE_REG + DA9052_ID_##_id, \ 276 245 .vsel_mask = (1 << (sbits)) - 1,\ 277 - .apply_reg = DA9052_SUPPLY_REG, \ 278 - .apply_bit = (abits), \ 279 246 .enable_reg = DA9052_BUCKCORE_REG + DA9052_ID_##_id, \ 280 247 .enable_mask = 1 << (ebits),\ 281 248 },\ 282 249 .min_uV = (min) * 1000,\ 283 250 .max_uV = (max) * 1000,\ 284 251 .step_uV = (step) * 1000,\ 252 + .activate_bit = (abits),\ 285 253 } 286 254 287 255 #define DA9052_DCDC(_id, step, min, max, sbits, ebits, abits) \ ··· 294 264 .owner = THIS_MODULE,\ 295 265 .vsel_reg = DA9052_BUCKCORE_REG + DA9052_ID_##_id, \ 296 266 .vsel_mask = (1 << (sbits)) - 1,\ 297 - .apply_reg = DA9052_SUPPLY_REG, \ 298 - .apply_bit = (abits), \ 299 267 .enable_reg = DA9052_BUCKCORE_REG + DA9052_ID_##_id, \ 300 268 .enable_mask = 1 << (ebits),\ 301 269 },\ 302 270 .min_uV = (min) * 1000,\ 303 271 .max_uV = (max) * 1000,\ 304 272 .step_uV = (step) * 1000,\ 273 + .activate_bit = (abits),\ 305 274 } 306 275 307 276 static struct da9052_regulator_info da9052_regulator_info[] = { ··· 418 389 #endif 419 390 } 420 391 421 - regulator->rdev = regulator_register(&regulator->info->reg_desc, 422 - &config); 392 + regulator->rdev = devm_regulator_register(&pdev->dev, 393 + &regulator->info->reg_desc, 394 + &config); 423 395 if (IS_ERR(regulator->rdev)) { 424 396 dev_err(&pdev->dev, "failed to register regulator %s\n", 425 397 regulator->info->reg_desc.name); ··· 432 402 return 0; 433 403 } 434 404 435 - static int da9052_regulator_remove(struct platform_device *pdev) 436 - { 437 - struct da9052_regulator *regulator = platform_get_drvdata(pdev); 438 - 439 - regulator_unregister(regulator->rdev); 440 - return 0; 441 - } 442 - 443 405 static struct platform_driver da9052_regulator_driver = { 444 406 .probe = da9052_regulator_probe, 445 - .remove = da9052_regulator_remove, 446 407 .driver = { 447 408 .name = "da9052-regulator", 448 409 .owner = THIS_MODULE,
+5 -19
drivers/regulator/da9055-regulator.c
··· 564 564 if (ret < 0) 565 565 return ret; 566 566 567 - regulator->rdev = regulator_register(&regulator->info->reg_desc, 568 - &config); 567 + regulator->rdev = devm_regulator_register(&pdev->dev, 568 + &regulator->info->reg_desc, 569 + &config); 569 570 if (IS_ERR(regulator->rdev)) { 570 571 dev_err(&pdev->dev, "Failed to register regulator %s\n", 571 572 regulator->info->reg_desc.name); 572 - ret = PTR_ERR(regulator->rdev); 573 - return ret; 573 + return PTR_ERR(regulator->rdev); 574 574 } 575 575 576 576 /* Only LDO 5 and 6 has got the over current interrupt */ ··· 588 588 dev_err(&pdev->dev, 589 589 "Failed to request Regulator IRQ %d: %d\n", 590 590 irq, ret); 591 - goto err_regulator; 591 + return ret; 592 592 } 593 593 } 594 594 } ··· 596 596 platform_set_drvdata(pdev, regulator); 597 597 598 598 return 0; 599 - 600 - err_regulator: 601 - regulator_unregister(regulator->rdev); 602 - return ret; 603 - } 604 - 605 - static int da9055_regulator_remove(struct platform_device *pdev) 606 - { 607 - struct da9055_regulator *regulator = platform_get_drvdata(pdev); 608 - 609 - regulator_unregister(regulator->rdev); 610 - 611 - return 0; 612 599 } 613 600 614 601 static struct platform_driver da9055_regulator_driver = { 615 602 .probe = da9055_regulator_probe, 616 - .remove = da9055_regulator_remove, 617 603 .driver = { 618 604 .name = "da9055-regulator", 619 605 .owner = THIS_MODULE,
+5 -18
drivers/regulator/da9063-regulator.c
··· 717 717 { 718 718 struct da9063 *da9063 = dev_get_drvdata(pdev->dev.parent); 719 719 struct da9063_pdata *da9063_pdata = dev_get_platdata(da9063->dev); 720 - struct of_regulator_match *da9063_reg_matches; 720 + struct of_regulator_match *da9063_reg_matches = NULL; 721 721 struct da9063_regulators_pdata *regl_pdata; 722 722 const struct da9063_dev_model *model; 723 723 struct da9063_regulators *regulators; ··· 847 847 if (da9063_reg_matches) 848 848 config.of_node = da9063_reg_matches[id].of_node; 849 849 config.regmap = da9063->regmap; 850 - regl->rdev = regulator_register(&regl->desc, &config); 850 + regl->rdev = devm_regulator_register(&pdev->dev, &regl->desc, 851 + &config); 851 852 if (IS_ERR(regl->rdev)) { 852 853 dev_err(&pdev->dev, 853 854 "Failed to register %s regulator\n", 854 855 regl->desc.name); 855 - ret = PTR_ERR(regl->rdev); 856 - goto err; 856 + return PTR_ERR(regl->rdev); 857 857 } 858 858 id++; 859 859 n++; ··· 862 862 /* LDOs overcurrent event support */ 863 863 irq = platform_get_irq_byname(pdev, "LDO_LIM"); 864 864 if (irq < 0) { 865 - ret = irq; 866 865 dev_err(&pdev->dev, "Failed to get IRQ.\n"); 867 - goto err; 866 + return irq; 868 867 } 869 868 870 869 regulators->irq_ldo_lim = regmap_irq_get_virq(da9063->regmap_irq, irq); ··· 880 881 } 881 882 882 883 return 0; 883 - 884 - err: 885 - /* Wind back regulators registeration */ 886 - while (--n >= 0) 887 - regulator_unregister(regulators->regulator[n].rdev); 888 - 889 - return ret; 890 884 } 891 885 892 886 static int da9063_regulator_remove(struct platform_device *pdev) 893 887 { 894 888 struct da9063_regulators *regulators = platform_get_drvdata(pdev); 895 - struct da9063_regulator *regl; 896 889 897 890 free_irq(regulators->irq_ldo_lim, regulators); 898 891 free_irq(regulators->irq_uvov, regulators); 899 - 900 - for (regl = &regulators->regulator[regulators->n_regulators - 1]; 901 - regl >= &regulators->regulator[0]; regl--) 902 - regulator_unregister(regl->rdev); 903 892 904 893 return 0; 905 894 }
+7 -12
drivers/regulator/da9210-regulator.c
··· 25 25 #include <linux/slab.h> 26 26 #include <linux/regulator/driver.h> 27 27 #include <linux/regulator/machine.h> 28 + #include <linux/regulator/of_regulator.h> 28 29 #include <linux/regmap.h> 29 30 30 31 #include "da9210-regulator.h" ··· 127 126 const struct i2c_device_id *id) 128 127 { 129 128 struct da9210 *chip; 130 - struct da9210_pdata *pdata = i2c->dev.platform_data; 129 + struct device *dev = &i2c->dev; 130 + struct da9210_pdata *pdata = dev_get_platdata(dev); 131 131 struct regulator_dev *rdev = NULL; 132 132 struct regulator_config config = { }; 133 133 int error; ··· 149 147 } 150 148 151 149 config.dev = &i2c->dev; 152 - if (pdata) 153 - config.init_data = &pdata->da9210_constraints; 150 + config.init_data = pdata ? &pdata->da9210_constraints : 151 + of_get_regulator_init_data(dev, dev->of_node); 154 152 config.driver_data = chip; 155 153 config.regmap = chip->regmap; 154 + config.of_node = dev->of_node; 156 155 157 - rdev = regulator_register(&da9210_reg, &config); 156 + rdev = devm_regulator_register(&i2c->dev, &da9210_reg, &config); 158 157 if (IS_ERR(rdev)) { 159 158 dev_err(&i2c->dev, "Failed to register DA9210 regulator\n"); 160 159 return PTR_ERR(rdev); ··· 165 162 166 163 i2c_set_clientdata(i2c, chip); 167 164 168 - return 0; 169 - } 170 - 171 - static int da9210_i2c_remove(struct i2c_client *i2c) 172 - { 173 - struct da9210 *chip = i2c_get_clientdata(i2c); 174 - regulator_unregister(chip->rdev); 175 165 return 0; 176 166 } 177 167 ··· 181 185 .owner = THIS_MODULE, 182 186 }, 183 187 .probe = da9210_i2c_probe, 184 - .remove = da9210_i2c_remove, 185 188 .id_table = da9210_i2c_id, 186 189 }; 187 190
+415
drivers/regulator/devres.c
··· 1 + /* 2 + * devres.c -- Voltage/Current Regulator framework devres implementation. 3 + * 4 + * Copyright 2013 Linaro Ltd 5 + * 6 + * This program is free software; you can redistribute it and/or modify it 7 + * under the terms of the GNU General Public License as published by the 8 + * Free Software Foundation; either version 2 of the License, or (at your 9 + * option) any later version. 10 + * 11 + */ 12 + 13 + #include <linux/kernel.h> 14 + #include <linux/err.h> 15 + #include <linux/regmap.h> 16 + #include <linux/regulator/consumer.h> 17 + #include <linux/regulator/driver.h> 18 + #include <linux/module.h> 19 + 20 + #include "internal.h" 21 + 22 + enum { 23 + NORMAL_GET, 24 + EXCLUSIVE_GET, 25 + OPTIONAL_GET, 26 + }; 27 + 28 + static void devm_regulator_release(struct device *dev, void *res) 29 + { 30 + regulator_put(*(struct regulator **)res); 31 + } 32 + 33 + static struct regulator *_devm_regulator_get(struct device *dev, const char *id, 34 + int get_type) 35 + { 36 + struct regulator **ptr, *regulator; 37 + 38 + ptr = devres_alloc(devm_regulator_release, sizeof(*ptr), GFP_KERNEL); 39 + if (!ptr) 40 + return ERR_PTR(-ENOMEM); 41 + 42 + switch (get_type) { 43 + case NORMAL_GET: 44 + regulator = regulator_get(dev, id); 45 + break; 46 + case EXCLUSIVE_GET: 47 + regulator = regulator_get_exclusive(dev, id); 48 + break; 49 + case OPTIONAL_GET: 50 + regulator = regulator_get_optional(dev, id); 51 + break; 52 + default: 53 + regulator = ERR_PTR(-EINVAL); 54 + } 55 + 56 + if (!IS_ERR(regulator)) { 57 + *ptr = regulator; 58 + devres_add(dev, ptr); 59 + } else { 60 + devres_free(ptr); 61 + } 62 + 63 + return regulator; 64 + } 65 + 66 + /** 67 + * devm_regulator_get - Resource managed regulator_get() 68 + * @dev: device for regulator "consumer" 69 + * @id: Supply name or regulator ID. 70 + * 71 + * Managed regulator_get(). Regulators returned from this function are 72 + * automatically regulator_put() on driver detach. See regulator_get() for more 73 + * information. 74 + */ 75 + struct regulator *devm_regulator_get(struct device *dev, const char *id) 76 + { 77 + return _devm_regulator_get(dev, id, NORMAL_GET); 78 + } 79 + EXPORT_SYMBOL_GPL(devm_regulator_get); 80 + 81 + /** 82 + * devm_regulator_get_exclusive - Resource managed regulator_get_exclusive() 83 + * @dev: device for regulator "consumer" 84 + * @id: Supply name or regulator ID. 85 + * 86 + * Managed regulator_get_exclusive(). Regulators returned from this function 87 + * are automatically regulator_put() on driver detach. See regulator_get() for 88 + * more information. 89 + */ 90 + struct regulator *devm_regulator_get_exclusive(struct device *dev, 91 + const char *id) 92 + { 93 + return _devm_regulator_get(dev, id, EXCLUSIVE_GET); 94 + } 95 + EXPORT_SYMBOL_GPL(devm_regulator_get_exclusive); 96 + 97 + /** 98 + * devm_regulator_get_optional - Resource managed regulator_get_optional() 99 + * @dev: device for regulator "consumer" 100 + * @id: Supply name or regulator ID. 101 + * 102 + * Managed regulator_get_optional(). Regulators returned from this 103 + * function are automatically regulator_put() on driver detach. See 104 + * regulator_get_optional() for more information. 105 + */ 106 + struct regulator *devm_regulator_get_optional(struct device *dev, 107 + const char *id) 108 + { 109 + return _devm_regulator_get(dev, id, OPTIONAL_GET); 110 + } 111 + EXPORT_SYMBOL_GPL(devm_regulator_get_optional); 112 + 113 + static int devm_regulator_match(struct device *dev, void *res, void *data) 114 + { 115 + struct regulator **r = res; 116 + if (!r || !*r) { 117 + WARN_ON(!r || !*r); 118 + return 0; 119 + } 120 + return *r == data; 121 + } 122 + 123 + /** 124 + * devm_regulator_put - Resource managed regulator_put() 125 + * @regulator: regulator to free 126 + * 127 + * Deallocate a regulator allocated with devm_regulator_get(). Normally 128 + * this function will not need to be called and the resource management 129 + * code will ensure that the resource is freed. 130 + */ 131 + void devm_regulator_put(struct regulator *regulator) 132 + { 133 + int rc; 134 + 135 + rc = devres_release(regulator->dev, devm_regulator_release, 136 + devm_regulator_match, regulator); 137 + if (rc != 0) 138 + WARN_ON(rc); 139 + } 140 + EXPORT_SYMBOL_GPL(devm_regulator_put); 141 + 142 + /** 143 + * devm_regulator_bulk_get - managed get multiple regulator consumers 144 + * 145 + * @dev: Device to supply 146 + * @num_consumers: Number of consumers to register 147 + * @consumers: Configuration of consumers; clients are stored here. 148 + * 149 + * @return 0 on success, an errno on failure. 150 + * 151 + * This helper function allows drivers to get several regulator 152 + * consumers in one operation with management, the regulators will 153 + * automatically be freed when the device is unbound. If any of the 154 + * regulators cannot be acquired then any regulators that were 155 + * allocated will be freed before returning to the caller. 156 + */ 157 + int devm_regulator_bulk_get(struct device *dev, int num_consumers, 158 + struct regulator_bulk_data *consumers) 159 + { 160 + int i; 161 + int ret; 162 + 163 + for (i = 0; i < num_consumers; i++) 164 + consumers[i].consumer = NULL; 165 + 166 + for (i = 0; i < num_consumers; i++) { 167 + consumers[i].consumer = devm_regulator_get(dev, 168 + consumers[i].supply); 169 + if (IS_ERR(consumers[i].consumer)) { 170 + ret = PTR_ERR(consumers[i].consumer); 171 + dev_err(dev, "Failed to get supply '%s': %d\n", 172 + consumers[i].supply, ret); 173 + consumers[i].consumer = NULL; 174 + goto err; 175 + } 176 + } 177 + 178 + return 0; 179 + 180 + err: 181 + for (i = 0; i < num_consumers && consumers[i].consumer; i++) 182 + devm_regulator_put(consumers[i].consumer); 183 + 184 + return ret; 185 + } 186 + EXPORT_SYMBOL_GPL(devm_regulator_bulk_get); 187 + 188 + static void devm_rdev_release(struct device *dev, void *res) 189 + { 190 + regulator_unregister(*(struct regulator_dev **)res); 191 + } 192 + 193 + /** 194 + * devm_regulator_register - Resource managed regulator_register() 195 + * @regulator_desc: regulator to register 196 + * @config: runtime configuration for regulator 197 + * 198 + * Called by regulator drivers to register a regulator. Returns a 199 + * valid pointer to struct regulator_dev on success or an ERR_PTR() on 200 + * error. The regulator will automatically be released when the device 201 + * is unbound. 202 + */ 203 + struct regulator_dev *devm_regulator_register(struct device *dev, 204 + const struct regulator_desc *regulator_desc, 205 + const struct regulator_config *config) 206 + { 207 + struct regulator_dev **ptr, *rdev; 208 + 209 + ptr = devres_alloc(devm_rdev_release, sizeof(*ptr), 210 + GFP_KERNEL); 211 + if (!ptr) 212 + return ERR_PTR(-ENOMEM); 213 + 214 + rdev = regulator_register(regulator_desc, config); 215 + if (!IS_ERR(rdev)) { 216 + *ptr = rdev; 217 + devres_add(dev, ptr); 218 + } else { 219 + devres_free(ptr); 220 + } 221 + 222 + return rdev; 223 + } 224 + EXPORT_SYMBOL_GPL(devm_regulator_register); 225 + 226 + static int devm_rdev_match(struct device *dev, void *res, void *data) 227 + { 228 + struct regulator_dev **r = res; 229 + if (!r || !*r) { 230 + WARN_ON(!r || !*r); 231 + return 0; 232 + } 233 + return *r == data; 234 + } 235 + 236 + /** 237 + * devm_regulator_unregister - Resource managed regulator_unregister() 238 + * @regulator: regulator to free 239 + * 240 + * Unregister a regulator registered with devm_regulator_register(). 241 + * Normally this function will not need to be called and the resource 242 + * management code will ensure that the resource is freed. 243 + */ 244 + void devm_regulator_unregister(struct device *dev, struct regulator_dev *rdev) 245 + { 246 + int rc; 247 + 248 + rc = devres_release(dev, devm_rdev_release, devm_rdev_match, rdev); 249 + if (rc != 0) 250 + WARN_ON(rc); 251 + } 252 + EXPORT_SYMBOL_GPL(devm_regulator_unregister); 253 + 254 + struct regulator_supply_alias_match { 255 + struct device *dev; 256 + const char *id; 257 + }; 258 + 259 + static int devm_regulator_match_supply_alias(struct device *dev, void *res, 260 + void *data) 261 + { 262 + struct regulator_supply_alias_match *match = res; 263 + struct regulator_supply_alias_match *target = data; 264 + 265 + return match->dev == target->dev && strcmp(match->id, target->id) == 0; 266 + } 267 + 268 + static void devm_regulator_destroy_supply_alias(struct device *dev, void *res) 269 + { 270 + struct regulator_supply_alias_match *match = res; 271 + 272 + regulator_unregister_supply_alias(match->dev, match->id); 273 + } 274 + 275 + /** 276 + * devm_regulator_register_supply_alias - Resource managed 277 + * regulator_register_supply_alias() 278 + * 279 + * @dev: device that will be given as the regulator "consumer" 280 + * @id: Supply name or regulator ID 281 + * @alias_dev: device that should be used to lookup the supply 282 + * @alias_id: Supply name or regulator ID that should be used to lookup the 283 + * supply 284 + * 285 + * The supply alias will automatically be unregistered when the source 286 + * device is unbound. 287 + */ 288 + int devm_regulator_register_supply_alias(struct device *dev, const char *id, 289 + struct device *alias_dev, 290 + const char *alias_id) 291 + { 292 + struct regulator_supply_alias_match *match; 293 + int ret; 294 + 295 + match = devres_alloc(devm_regulator_destroy_supply_alias, 296 + sizeof(struct regulator_supply_alias_match), 297 + GFP_KERNEL); 298 + if (!match) 299 + return -ENOMEM; 300 + 301 + match->dev = dev; 302 + match->id = id; 303 + 304 + ret = regulator_register_supply_alias(dev, id, alias_dev, alias_id); 305 + if (ret < 0) { 306 + devres_free(match); 307 + return ret; 308 + } 309 + 310 + devres_add(dev, match); 311 + 312 + return 0; 313 + } 314 + EXPORT_SYMBOL_GPL(devm_regulator_register_supply_alias); 315 + 316 + /** 317 + * devm_regulator_unregister_supply_alias - Resource managed 318 + * regulator_unregister_supply_alias() 319 + * 320 + * @dev: device that will be given as the regulator "consumer" 321 + * @id: Supply name or regulator ID 322 + * 323 + * Unregister an alias registered with 324 + * devm_regulator_register_supply_alias(). Normally this function 325 + * will not need to be called and the resource management code 326 + * will ensure that the resource is freed. 327 + */ 328 + void devm_regulator_unregister_supply_alias(struct device *dev, const char *id) 329 + { 330 + struct regulator_supply_alias_match match; 331 + int rc; 332 + 333 + match.dev = dev; 334 + match.id = id; 335 + 336 + rc = devres_release(dev, devm_regulator_destroy_supply_alias, 337 + devm_regulator_match_supply_alias, &match); 338 + if (rc != 0) 339 + WARN_ON(rc); 340 + } 341 + EXPORT_SYMBOL_GPL(devm_regulator_unregister_supply_alias); 342 + 343 + /** 344 + * devm_regulator_bulk_register_supply_alias - Managed register 345 + * multiple aliases 346 + * 347 + * @dev: device that will be given as the regulator "consumer" 348 + * @id: List of supply names or regulator IDs 349 + * @alias_dev: device that should be used to lookup the supply 350 + * @alias_id: List of supply names or regulator IDs that should be used to 351 + * lookup the supply 352 + * @num_id: Number of aliases to register 353 + * 354 + * @return 0 on success, an errno on failure. 355 + * 356 + * This helper function allows drivers to register several supply 357 + * aliases in one operation, the aliases will be automatically 358 + * unregisters when the source device is unbound. If any of the 359 + * aliases cannot be registered any aliases that were registered 360 + * will be removed before returning to the caller. 361 + */ 362 + int devm_regulator_bulk_register_supply_alias(struct device *dev, 363 + const char **id, 364 + struct device *alias_dev, 365 + const char **alias_id, 366 + int num_id) 367 + { 368 + int i; 369 + int ret; 370 + 371 + for (i = 0; i < num_id; ++i) { 372 + ret = devm_regulator_register_supply_alias(dev, id[i], 373 + alias_dev, 374 + alias_id[i]); 375 + if (ret < 0) 376 + goto err; 377 + } 378 + 379 + return 0; 380 + 381 + err: 382 + dev_err(dev, 383 + "Failed to create supply alias %s,%s -> %s,%s\n", 384 + id[i], dev_name(dev), alias_id[i], dev_name(alias_dev)); 385 + 386 + while (--i >= 0) 387 + devm_regulator_unregister_supply_alias(dev, id[i]); 388 + 389 + return ret; 390 + } 391 + EXPORT_SYMBOL_GPL(devm_regulator_bulk_register_supply_alias); 392 + 393 + /** 394 + * devm_regulator_bulk_unregister_supply_alias - Managed unregister 395 + * multiple aliases 396 + * 397 + * @dev: device that will be given as the regulator "consumer" 398 + * @id: List of supply names or regulator IDs 399 + * @num_id: Number of aliases to unregister 400 + * 401 + * Unregister aliases registered with 402 + * devm_regulator_bulk_register_supply_alias(). Normally this function 403 + * will not need to be called and the resource management code 404 + * will ensure that the resource is freed. 405 + */ 406 + void devm_regulator_bulk_unregister_supply_alias(struct device *dev, 407 + const char **id, 408 + int num_id) 409 + { 410 + int i; 411 + 412 + for (i = 0; i < num_id; ++i) 413 + devm_regulator_unregister_supply_alias(dev, id[i]); 414 + } 415 + EXPORT_SYMBOL_GPL(devm_regulator_bulk_unregister_supply_alias);
+1 -11
drivers/regulator/fan53555.c
··· 218 218 rdesc->vsel_mask = VSEL_NSEL_MASK; 219 219 rdesc->owner = THIS_MODULE; 220 220 221 - di->rdev = regulator_register(&di->desc, config); 221 + di->rdev = devm_regulator_register(di->dev, &di->desc, config); 222 222 return PTR_ERR_OR_ZERO(di->rdev); 223 - 224 223 } 225 224 226 225 static struct regmap_config fan53555_regmap_config = { ··· 290 291 291 292 } 292 293 293 - static int fan53555_regulator_remove(struct i2c_client *client) 294 - { 295 - struct fan53555_device_info *di = i2c_get_clientdata(client); 296 - 297 - regulator_unregister(di->rdev); 298 - return 0; 299 - } 300 - 301 294 static const struct i2c_device_id fan53555_id[] = { 302 295 {"fan53555", -1}, 303 296 { }, ··· 300 309 .name = "fan53555-regulator", 301 310 }, 302 311 .probe = fan53555_regulator_probe, 303 - .remove = fan53555_regulator_remove, 304 312 .id_table = fan53555_id, 305 313 }; 306 314
+6 -32
drivers/regulator/fixed.c
··· 34 34 struct fixed_voltage_data { 35 35 struct regulator_desc desc; 36 36 struct regulator_dev *dev; 37 - int microvolts; 38 37 }; 39 38 40 39 ··· 107 108 return config; 108 109 } 109 110 110 - static int fixed_voltage_get_voltage(struct regulator_dev *dev) 111 - { 112 - struct fixed_voltage_data *data = rdev_get_drvdata(dev); 113 - 114 - if (data->microvolts) 115 - return data->microvolts; 116 - else 117 - return -EINVAL; 118 - } 119 - 120 - static int fixed_voltage_list_voltage(struct regulator_dev *dev, 121 - unsigned selector) 122 - { 123 - struct fixed_voltage_data *data = rdev_get_drvdata(dev); 124 - 125 - if (selector != 0) 126 - return -EINVAL; 127 - 128 - return data->microvolts; 129 - } 130 - 131 111 static struct regulator_ops fixed_voltage_ops = { 132 - .get_voltage = fixed_voltage_get_voltage, 133 - .list_voltage = fixed_voltage_list_voltage, 134 112 }; 135 113 136 114 static int reg_fixed_voltage_probe(struct platform_device *pdev) ··· 162 186 if (config->microvolts) 163 187 drvdata->desc.n_voltages = 1; 164 188 165 - drvdata->microvolts = config->microvolts; 189 + drvdata->desc.fixed_uV = config->microvolts; 166 190 167 191 if (config->gpio >= 0) 168 192 cfg.ena_gpio = config->gpio; 169 193 cfg.ena_gpio_invert = !config->enable_high; 170 194 if (config->enabled_at_boot) { 171 - if (config->enable_high) { 195 + if (config->enable_high) 172 196 cfg.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH; 173 - } else { 197 + else 174 198 cfg.ena_gpio_flags |= GPIOF_OUT_INIT_LOW; 175 - } 176 199 } else { 177 - if (config->enable_high) { 200 + if (config->enable_high) 178 201 cfg.ena_gpio_flags |= GPIOF_OUT_INIT_LOW; 179 - } else { 202 + else 180 203 cfg.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH; 181 - } 182 204 } 183 205 if (config->gpio_is_open_drain) 184 206 cfg.ena_gpio_flags |= GPIOF_OPEN_DRAIN; ··· 196 222 platform_set_drvdata(pdev, drvdata); 197 223 198 224 dev_dbg(&pdev->dev, "%s supplying %duV\n", drvdata->desc.name, 199 - drvdata->microvolts); 225 + drvdata->desc.fixed_uV); 200 226 201 227 return 0; 202 228
-1
drivers/regulator/gpio-regulator.c
··· 283 283 dev_err(&pdev->dev, "No regulator type set\n"); 284 284 ret = -EINVAL; 285 285 goto err_memgpio; 286 - break; 287 286 } 288 287 289 288 drvdata->nr_gpios = config->nr_gpios;
+6 -2
drivers/regulator/helpers.c
··· 284 284 } 285 285 286 286 for (i = 0; i < rdev->desc->n_linear_ranges; i++) { 287 - range = &rdev->desc->linear_ranges[i]; 287 + int linear_max_uV; 288 288 289 - if (!(min_uV <= range->max_uV && max_uV >= range->min_uV)) 289 + range = &rdev->desc->linear_ranges[i]; 290 + linear_max_uV = range->min_uV + 291 + (range->max_sel - range->min_sel) * range->uV_step; 292 + 293 + if (!(min_uV <= linear_max_uV && max_uV >= range->min_uV)) 290 294 continue; 291 295 292 296 if (min_uV <= range->min_uV)
+38
drivers/regulator/internal.h
··· 1 + /* 2 + * internal.h -- Voltage/Current Regulator framework internal code 3 + * 4 + * Copyright 2007, 2008 Wolfson Microelectronics PLC. 5 + * Copyright 2008 SlimLogic Ltd. 6 + * 7 + * Author: Liam Girdwood <lrg@slimlogic.co.uk> 8 + * 9 + * This program is free software; you can redistribute it and/or modify it 10 + * under the terms of the GNU General Public License as published by the 11 + * Free Software Foundation; either version 2 of the License, or (at your 12 + * option) any later version. 13 + * 14 + */ 15 + 16 + #ifndef __REGULATOR_INTERNAL_H 17 + #define __REGULATOR_INTERNAL_H 18 + 19 + /* 20 + * struct regulator 21 + * 22 + * One for each consumer device. 23 + */ 24 + struct regulator { 25 + struct device *dev; 26 + struct list_head list; 27 + unsigned int always_on:1; 28 + unsigned int bypass:1; 29 + int uA_load; 30 + int min_uV; 31 + int max_uV; 32 + char *supply_name; 33 + struct device_attribute dev_attr; 34 + struct regulator_dev *rdev; 35 + struct dentry *debugfs; 36 + }; 37 + 38 + #endif
+4 -20
drivers/regulator/isl6271a-regulator.c
··· 112 112 struct regulator_config config = { }; 113 113 struct regulator_init_data *init_data = dev_get_platdata(&i2c->dev); 114 114 struct isl_pmic *pmic; 115 - int err, i; 115 + int i; 116 116 117 117 if (!i2c_check_functionality(i2c->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 118 118 return -EIO; ··· 133 133 config.init_data = NULL; 134 134 config.driver_data = pmic; 135 135 136 - pmic->rdev[i] = regulator_register(&isl_rd[i], &config); 136 + pmic->rdev[i] = devm_regulator_register(&i2c->dev, &isl_rd[i], 137 + &config); 137 138 if (IS_ERR(pmic->rdev[i])) { 138 139 dev_err(&i2c->dev, "failed to register %s\n", id->name); 139 - err = PTR_ERR(pmic->rdev[i]); 140 - goto error; 140 + return PTR_ERR(pmic->rdev[i]); 141 141 } 142 142 } 143 143 144 144 i2c_set_clientdata(i2c, pmic); 145 145 146 - return 0; 147 - 148 - error: 149 - while (--i >= 0) 150 - regulator_unregister(pmic->rdev[i]); 151 - return err; 152 - } 153 - 154 - static int isl6271a_remove(struct i2c_client *i2c) 155 - { 156 - struct isl_pmic *pmic = i2c_get_clientdata(i2c); 157 - int i; 158 - 159 - for (i = 0; i < 3; i++) 160 - regulator_unregister(pmic->rdev[i]); 161 146 return 0; 162 147 } 163 148 ··· 159 174 .owner = THIS_MODULE, 160 175 }, 161 176 .probe = isl6271a_probe, 162 - .remove = isl6271a_remove, 163 177 .id_table = isl6271a_id, 164 178 }; 165 179
+2 -2
drivers/regulator/lp3971.c
··· 474 474 } 475 475 476 476 static const struct i2c_device_id lp3971_i2c_id[] = { 477 - { "lp3971", 0 }, 478 - { } 477 + { "lp3971", 0 }, 478 + { } 479 479 }; 480 480 MODULE_DEVICE_TABLE(i2c, lp3971_i2c_id); 481 481
+3 -30
drivers/regulator/lp872x.c
··· 785 785 struct regulator_desc *desc; 786 786 struct regulator_config cfg = { }; 787 787 struct regulator_dev *rdev; 788 - int i, ret; 788 + int i; 789 789 790 790 for (i = 0; i < lp->num_regulators; i++) { 791 791 desc = (lp->chipid == LP8720) ? &lp8720_regulator_desc[i] : ··· 796 796 cfg.driver_data = lp; 797 797 cfg.regmap = lp->regmap; 798 798 799 - rdev = regulator_register(desc, &cfg); 799 + rdev = devm_regulator_register(lp->dev, desc, &cfg); 800 800 if (IS_ERR(rdev)) { 801 801 dev_err(lp->dev, "regulator register err"); 802 - ret = PTR_ERR(rdev); 803 - goto err; 802 + return PTR_ERR(rdev); 804 803 } 805 804 806 805 *(lp->regulators + i) = rdev; 807 806 } 808 807 809 808 return 0; 810 - err: 811 - while (--i >= 0) { 812 - rdev = *(lp->regulators + i); 813 - regulator_unregister(rdev); 814 - } 815 - return ret; 816 - } 817 - 818 - static void lp872x_regulator_unregister(struct lp872x *lp) 819 - { 820 - struct regulator_dev *rdev; 821 - int i; 822 - 823 - for (i = 0; i < lp->num_regulators; i++) { 824 - rdev = *(lp->regulators + i); 825 - regulator_unregister(rdev); 826 - } 827 809 } 828 810 829 811 static const struct regmap_config lp872x_regmap_config = { ··· 961 979 return ret; 962 980 } 963 981 964 - static int lp872x_remove(struct i2c_client *cl) 965 - { 966 - struct lp872x *lp = i2c_get_clientdata(cl); 967 - 968 - lp872x_regulator_unregister(lp); 969 - return 0; 970 - } 971 - 972 982 static const struct of_device_id lp872x_dt_ids[] = { 973 983 { .compatible = "ti,lp8720", }, 974 984 { .compatible = "ti,lp8725", }, ··· 982 1008 .of_match_table = of_match_ptr(lp872x_dt_ids), 983 1009 }, 984 1010 .probe = lp872x_probe, 985 - .remove = lp872x_remove, 986 1011 .id_table = lp872x_ids, 987 1012 }; 988 1013
+1 -11
drivers/regulator/lp8788-buck.c
··· 515 515 cfg.driver_data = buck; 516 516 cfg.regmap = lp->regmap; 517 517 518 - rdev = regulator_register(&lp8788_buck_desc[id], &cfg); 518 + rdev = devm_regulator_register(&pdev->dev, &lp8788_buck_desc[id], &cfg); 519 519 if (IS_ERR(rdev)) { 520 520 ret = PTR_ERR(rdev); 521 521 dev_err(&pdev->dev, "BUCK%d regulator register err = %d\n", ··· 529 529 return 0; 530 530 } 531 531 532 - static int lp8788_buck_remove(struct platform_device *pdev) 533 - { 534 - struct lp8788_buck *buck = platform_get_drvdata(pdev); 535 - 536 - regulator_unregister(buck->regulator); 537 - 538 - return 0; 539 - } 540 - 541 532 static struct platform_driver lp8788_buck_driver = { 542 533 .probe = lp8788_buck_probe, 543 - .remove = lp8788_buck_remove, 544 534 .driver = { 545 535 .name = LP8788_DEV_BUCK, 546 536 .owner = THIS_MODULE,
+2 -22
drivers/regulator/lp8788-ldo.c
··· 543 543 cfg.driver_data = ldo; 544 544 cfg.regmap = lp->regmap; 545 545 546 - rdev = regulator_register(&lp8788_dldo_desc[id], &cfg); 546 + rdev = devm_regulator_register(&pdev->dev, &lp8788_dldo_desc[id], &cfg); 547 547 if (IS_ERR(rdev)) { 548 548 ret = PTR_ERR(rdev); 549 549 dev_err(&pdev->dev, "DLDO%d regulator register err = %d\n", ··· 557 557 return 0; 558 558 } 559 559 560 - static int lp8788_dldo_remove(struct platform_device *pdev) 561 - { 562 - struct lp8788_ldo *ldo = platform_get_drvdata(pdev); 563 - 564 - regulator_unregister(ldo->regulator); 565 - 566 - return 0; 567 - } 568 - 569 560 static struct platform_driver lp8788_dldo_driver = { 570 561 .probe = lp8788_dldo_probe, 571 - .remove = lp8788_dldo_remove, 572 562 .driver = { 573 563 .name = LP8788_DEV_DLDO, 574 564 .owner = THIS_MODULE, ··· 593 603 cfg.driver_data = ldo; 594 604 cfg.regmap = lp->regmap; 595 605 596 - rdev = regulator_register(&lp8788_aldo_desc[id], &cfg); 606 + rdev = devm_regulator_register(&pdev->dev, &lp8788_aldo_desc[id], &cfg); 597 607 if (IS_ERR(rdev)) { 598 608 ret = PTR_ERR(rdev); 599 609 dev_err(&pdev->dev, "ALDO%d regulator register err = %d\n", ··· 607 617 return 0; 608 618 } 609 619 610 - static int lp8788_aldo_remove(struct platform_device *pdev) 611 - { 612 - struct lp8788_ldo *ldo = platform_get_drvdata(pdev); 613 - 614 - regulator_unregister(ldo->regulator); 615 - 616 - return 0; 617 - } 618 - 619 620 static struct platform_driver lp8788_aldo_driver = { 620 621 .probe = lp8788_aldo_probe, 621 - .remove = lp8788_aldo_remove, 622 622 .driver = { 623 623 .name = LP8788_DEV_ALDO, 624 624 .owner = THIS_MODULE,
+5 -21
drivers/regulator/max1586.c
··· 166 166 struct max1586_platform_data *pdata = dev_get_platdata(&client->dev); 167 167 struct regulator_config config = { }; 168 168 struct max1586_data *max1586; 169 - int i, id, ret = -ENOMEM; 169 + int i, id; 170 170 171 171 max1586 = devm_kzalloc(&client->dev, sizeof(struct max1586_data) + 172 172 sizeof(struct regulator_dev *) * (MAX1586_V6 + 1), ··· 193 193 continue; 194 194 if (id < MAX1586_V3 || id > MAX1586_V6) { 195 195 dev_err(&client->dev, "invalid regulator id %d\n", id); 196 - goto err; 196 + return -EINVAL; 197 197 } 198 198 199 199 if (id == MAX1586_V3) { ··· 207 207 config.init_data = pdata->subdevs[i].platform_data; 208 208 config.driver_data = max1586; 209 209 210 - rdev[i] = regulator_register(&max1586_reg[id], &config); 210 + rdev[i] = devm_regulator_register(&client->dev, 211 + &max1586_reg[id], &config); 211 212 if (IS_ERR(rdev[i])) { 212 - ret = PTR_ERR(rdev[i]); 213 213 dev_err(&client->dev, "failed to register %s\n", 214 214 max1586_reg[id].name); 215 - goto err; 215 + return PTR_ERR(rdev[i]); 216 216 } 217 217 } 218 218 219 219 i2c_set_clientdata(client, max1586); 220 220 dev_info(&client->dev, "Maxim 1586 regulator driver loaded\n"); 221 - return 0; 222 - 223 - err: 224 - while (--i >= 0) 225 - regulator_unregister(rdev[i]); 226 - return ret; 227 - } 228 - 229 - static int max1586_pmic_remove(struct i2c_client *client) 230 - { 231 - struct max1586_data *max1586 = i2c_get_clientdata(client); 232 - int i; 233 - 234 - for (i = 0; i <= MAX1586_V6; i++) 235 - regulator_unregister(max1586->rdev[i]); 236 221 return 0; 237 222 } 238 223 ··· 229 244 230 245 static struct i2c_driver max1586_pmic_driver = { 231 246 .probe = max1586_pmic_probe, 232 - .remove = max1586_pmic_remove, 233 247 .driver = { 234 248 .name = "max1586", 235 249 .owner = THIS_MODULE,
+3 -20
drivers/regulator/max77686.c
··· 478 478 config.of_node = pdata->regulators[i].of_node; 479 479 480 480 max77686->opmode[i] = regulators[i].enable_mask; 481 - max77686->rdev[i] = regulator_register(&regulators[i], &config); 481 + max77686->rdev[i] = devm_regulator_register(&pdev->dev, 482 + &regulators[i], &config); 482 483 if (IS_ERR(max77686->rdev[i])) { 483 - ret = PTR_ERR(max77686->rdev[i]); 484 484 dev_err(&pdev->dev, 485 485 "regulator init failed for %d\n", i); 486 - max77686->rdev[i] = NULL; 487 - goto err; 486 + return PTR_ERR(max77686->rdev[i]); 488 487 } 489 488 } 490 - 491 - return 0; 492 - err: 493 - while (--i >= 0) 494 - regulator_unregister(max77686->rdev[i]); 495 - return ret; 496 - } 497 - 498 - static int max77686_pmic_remove(struct platform_device *pdev) 499 - { 500 - struct max77686_data *max77686 = platform_get_drvdata(pdev); 501 - int i; 502 - 503 - for (i = 0; i < MAX77686_REGULATORS; i++) 504 - regulator_unregister(max77686->rdev[i]); 505 489 506 490 return 0; 507 491 } ··· 502 518 .owner = THIS_MODULE, 503 519 }, 504 520 .probe = max77686_pmic_probe, 505 - .remove = max77686_pmic_remove, 506 521 .id_table = max77686_pmic_id, 507 522 }; 508 523
+4 -25
drivers/regulator/max77693.c
··· 230 230 struct max77693_dev *iodev = dev_get_drvdata(pdev->dev.parent); 231 231 struct max77693_pmic_dev *max77693_pmic; 232 232 struct max77693_regulator_data *rdata = NULL; 233 - int num_rdata, i, ret; 233 + int num_rdata, i; 234 234 struct regulator_config config; 235 235 236 236 num_rdata = max77693_pmic_init_rdata(&pdev->dev, &rdata); ··· 266 266 config.init_data = rdata[i].initdata; 267 267 config.of_node = rdata[i].of_node; 268 268 269 - max77693_pmic->rdev[i] = regulator_register(&regulators[id], 270 - &config); 269 + max77693_pmic->rdev[i] = devm_regulator_register(&pdev->dev, 270 + &regulators[id], &config); 271 271 if (IS_ERR(max77693_pmic->rdev[i])) { 272 - ret = PTR_ERR(max77693_pmic->rdev[i]); 273 272 dev_err(max77693_pmic->dev, 274 273 "Failed to initialize regulator-%d\n", id); 275 - max77693_pmic->rdev[i] = NULL; 276 - goto err; 274 + return PTR_ERR(max77693_pmic->rdev[i]); 277 275 } 278 276 } 279 - 280 - return 0; 281 - err: 282 - while (--i >= 0) 283 - regulator_unregister(max77693_pmic->rdev[i]); 284 - 285 - return ret; 286 - } 287 - 288 - static int max77693_pmic_remove(struct platform_device *pdev) 289 - { 290 - struct max77693_pmic_dev *max77693_pmic = platform_get_drvdata(pdev); 291 - struct regulator_dev **rdev = max77693_pmic->rdev; 292 - int i; 293 - 294 - for (i = 0; i < max77693_pmic->num_regulators; i++) 295 - if (rdev[i]) 296 - regulator_unregister(rdev[i]); 297 277 298 278 return 0; 299 279 } ··· 291 311 .owner = THIS_MODULE, 292 312 }, 293 313 .probe = max77693_pmic_probe, 294 - .remove = max77693_pmic_remove, 295 314 .id_table = max77693_pmic_id, 296 315 }; 297 316
+2 -12
drivers/regulator/max8649.c
··· 234 234 config.driver_data = info; 235 235 config.regmap = info->regmap; 236 236 237 - info->regulator = regulator_register(&dcdc_desc, &config); 237 + info->regulator = devm_regulator_register(&client->dev, &dcdc_desc, 238 + &config); 238 239 if (IS_ERR(info->regulator)) { 239 240 dev_err(info->dev, "failed to register regulator %s\n", 240 241 dcdc_desc.name); 241 242 return PTR_ERR(info->regulator); 242 243 } 243 - 244 - return 0; 245 - } 246 - 247 - static int max8649_regulator_remove(struct i2c_client *client) 248 - { 249 - struct max8649_regulator_info *info = i2c_get_clientdata(client); 250 - 251 - if (info) 252 - regulator_unregister(info->regulator); 253 244 254 245 return 0; 255 246 } ··· 253 262 254 263 static struct i2c_driver max8649_driver = { 255 264 .probe = max8649_regulator_probe, 256 - .remove = max8649_regulator_remove, 257 265 .driver = { 258 266 .name = "max8649", 259 267 },
+7 -23
drivers/regulator/max8660.c
··· 439 439 for (i = 0; i < pdata->num_subdevs; i++) { 440 440 441 441 if (!pdata->subdevs[i].platform_data) 442 - goto err_out; 442 + return ret; 443 443 444 444 boot_on = pdata->subdevs[i].platform_data->constraints.boot_on; 445 445 ··· 465 465 case MAX8660_V7: 466 466 if (type == MAX8661) { 467 467 dev_err(dev, "Regulator not on this chip!\n"); 468 - goto err_out; 468 + return -EINVAL; 469 469 } 470 470 471 471 if (boot_on) ··· 475 475 default: 476 476 dev_err(dev, "invalid regulator %s\n", 477 477 pdata->subdevs[i].name); 478 - goto err_out; 478 + return ret; 479 479 } 480 480 } 481 481 ··· 489 489 config.of_node = of_node[i]; 490 490 config.driver_data = max8660; 491 491 492 - rdev[i] = regulator_register(&max8660_reg[id], &config); 492 + rdev[i] = devm_regulator_register(&client->dev, 493 + &max8660_reg[id], &config); 493 494 if (IS_ERR(rdev[i])) { 494 495 ret = PTR_ERR(rdev[i]); 495 - dev_err(dev, "failed to register %s\n", 496 + dev_err(&client->dev, "failed to register %s\n", 496 497 max8660_reg[id].name); 497 - goto err_unregister; 498 + return PTR_ERR(rdev[i]); 498 499 } 499 500 } 500 501 501 502 i2c_set_clientdata(client, max8660); 502 - return 0; 503 - 504 - err_unregister: 505 - while (--i >= 0) 506 - regulator_unregister(rdev[i]); 507 - err_out: 508 - return ret; 509 - } 510 - 511 - static int max8660_remove(struct i2c_client *client) 512 - { 513 - struct max8660 *max8660 = i2c_get_clientdata(client); 514 - int i; 515 - 516 - for (i = 0; i < MAX8660_V_END; i++) 517 - regulator_unregister(max8660->rdev[i]); 518 503 return 0; 519 504 } 520 505 ··· 512 527 513 528 static struct i2c_driver max8660_driver = { 514 529 .probe = max8660_probe, 515 - .remove = max8660_remove, 516 530 .driver = { 517 531 .name = "max8660", 518 532 .owner = THIS_MODULE,
+3 -20
drivers/regulator/max8907-regulator.c
··· 350 350 pmic->desc[i].ops = &max8907_out5v_hwctl_ops; 351 351 } 352 352 353 - pmic->rdev[i] = regulator_register(&pmic->desc[i], &config); 353 + pmic->rdev[i] = devm_regulator_register(&pdev->dev, 354 + &pmic->desc[i], &config); 354 355 if (IS_ERR(pmic->rdev[i])) { 355 356 dev_err(&pdev->dev, 356 357 "failed to register %s regulator\n", 357 358 pmic->desc[i].name); 358 - ret = PTR_ERR(pmic->rdev[i]); 359 - goto err_unregister_regulator; 359 + return PTR_ERR(pmic->rdev[i]); 360 360 } 361 361 } 362 - 363 - return 0; 364 - 365 - err_unregister_regulator: 366 - while (--i >= 0) 367 - regulator_unregister(pmic->rdev[i]); 368 - return ret; 369 - } 370 - 371 - static int max8907_regulator_remove(struct platform_device *pdev) 372 - { 373 - struct max8907_regulator *pmic = platform_get_drvdata(pdev); 374 - int i; 375 - 376 - for (i = 0; i < MAX8907_NUM_REGULATORS; i++) 377 - regulator_unregister(pmic->rdev[i]); 378 362 379 363 return 0; 380 364 } ··· 369 385 .owner = THIS_MODULE, 370 386 }, 371 387 .probe = max8907_regulator_probe, 372 - .remove = max8907_regulator_remove, 373 388 }; 374 389 375 390 static int __init max8907_regulator_init(void)
+1 -11
drivers/regulator/max8925-regulator.c
··· 312 312 if (pdata) 313 313 config.init_data = pdata; 314 314 315 - rdev = regulator_register(&ri->desc, &config); 315 + rdev = devm_regulator_register(&pdev->dev, &ri->desc, &config); 316 316 if (IS_ERR(rdev)) { 317 317 dev_err(&pdev->dev, "failed to register regulator %s\n", 318 318 ri->desc.name); ··· 323 323 return 0; 324 324 } 325 325 326 - static int max8925_regulator_remove(struct platform_device *pdev) 327 - { 328 - struct regulator_dev *rdev = platform_get_drvdata(pdev); 329 - 330 - regulator_unregister(rdev); 331 - 332 - return 0; 333 - } 334 - 335 326 static struct platform_driver max8925_regulator_driver = { 336 327 .driver = { 337 328 .name = "max8925-regulator", 338 329 .owner = THIS_MODULE, 339 330 }, 340 331 .probe = max8925_regulator_probe, 341 - .remove = max8925_regulator_remove, 342 332 }; 343 333 344 334 static int __init max8925_regulator_init(void)
+1 -10
drivers/regulator/max8973-regulator.c
··· 467 467 config.regmap = max->regmap; 468 468 469 469 /* Register the regulators */ 470 - rdev = regulator_register(&max->desc, &config); 470 + rdev = devm_regulator_register(&client->dev, &max->desc, &config); 471 471 if (IS_ERR(rdev)) { 472 472 ret = PTR_ERR(rdev); 473 473 dev_err(max->dev, "regulator register failed, err %d\n", ret); ··· 475 475 } 476 476 477 477 max->rdev = rdev; 478 - return 0; 479 - } 480 - 481 - static int max8973_remove(struct i2c_client *client) 482 - { 483 - struct max8973_chip *max = i2c_get_clientdata(client); 484 - 485 - regulator_unregister(max->rdev); 486 478 return 0; 487 479 } 488 480 ··· 491 499 .owner = THIS_MODULE, 492 500 }, 493 501 .probe = max8973_probe, 494 - .remove = max8973_remove, 495 502 .id_table = max8973_id, 496 503 }; 497 504
+13 -31
drivers/regulator/max8997.c
··· 690 690 if (max8997->ignore_gpiodvs_side_effect == false) 691 691 return -EINVAL; 692 692 693 - dev_warn(&rdev->dev, "MAX8997 GPIO-DVS Side Effect Warning: GPIO SET:" 694 - " %d -> %d\n", max8997->buck125_gpioindex, tmp_idx); 693 + dev_warn(&rdev->dev, 694 + "MAX8997 GPIO-DVS Side Effect Warning: GPIO SET: %d -> %d\n", 695 + max8997->buck125_gpioindex, tmp_idx); 695 696 696 697 out: 697 698 if (new_idx < 0 || new_val < 0) ··· 1082 1081 pdata->buck1_voltage[i] + 1083 1082 buck1245_voltage_map_desc.step); 1084 1083 if (ret < 0) 1085 - goto err_out; 1084 + return ret; 1086 1085 1087 1086 max8997->buck2_vol[i] = ret = 1088 1087 max8997_get_voltage_proper_val( ··· 1091 1090 pdata->buck2_voltage[i] + 1092 1091 buck1245_voltage_map_desc.step); 1093 1092 if (ret < 0) 1094 - goto err_out; 1093 + return ret; 1095 1094 1096 1095 max8997->buck5_vol[i] = ret = 1097 1096 max8997_get_voltage_proper_val( ··· 1100 1099 pdata->buck5_voltage[i] + 1101 1100 buck1245_voltage_map_desc.step); 1102 1101 if (ret < 0) 1103 - goto err_out; 1102 + return ret; 1104 1103 1105 1104 if (max_buck1 < max8997->buck1_vol[i]) 1106 1105 max_buck1 = max8997->buck1_vol[i]; ··· 1144 1143 !gpio_is_valid(pdata->buck125_gpios[1]) || 1145 1144 !gpio_is_valid(pdata->buck125_gpios[2])) { 1146 1145 dev_err(&pdev->dev, "GPIO NOT VALID\n"); 1147 - ret = -EINVAL; 1148 - goto err_out; 1146 + return -EINVAL; 1149 1147 } 1150 1148 1151 1149 ret = devm_gpio_request(&pdev->dev, pdata->buck125_gpios[0], 1152 1150 "MAX8997 SET1"); 1153 1151 if (ret) 1154 - goto err_out; 1152 + return ret; 1155 1153 1156 1154 ret = devm_gpio_request(&pdev->dev, pdata->buck125_gpios[1], 1157 1155 "MAX8997 SET2"); 1158 1156 if (ret) 1159 - goto err_out; 1157 + return ret; 1160 1158 1161 1159 ret = devm_gpio_request(&pdev->dev, pdata->buck125_gpios[2], 1162 1160 "MAX8997 SET3"); 1163 1161 if (ret) 1164 - goto err_out; 1162 + return ret; 1165 1163 1166 1164 gpio_direction_output(pdata->buck125_gpios[0], 1167 1165 (max8997->buck125_gpioindex >> 2) ··· 1205 1205 config.driver_data = max8997; 1206 1206 config.of_node = pdata->regulators[i].reg_node; 1207 1207 1208 - rdev[i] = regulator_register(&regulators[id], &config); 1208 + rdev[i] = devm_regulator_register(&pdev->dev, &regulators[id], 1209 + &config); 1209 1210 if (IS_ERR(rdev[i])) { 1210 - ret = PTR_ERR(rdev[i]); 1211 1211 dev_err(max8997->dev, "regulator init failed for %d\n", 1212 1212 id); 1213 - rdev[i] = NULL; 1214 - goto err; 1213 + return PTR_ERR(rdev[i]); 1215 1214 } 1216 1215 } 1217 1216 1218 - return 0; 1219 - err: 1220 - while (--i >= 0) 1221 - regulator_unregister(rdev[i]); 1222 - err_out: 1223 - return ret; 1224 - } 1225 - 1226 - static int max8997_pmic_remove(struct platform_device *pdev) 1227 - { 1228 - struct max8997_data *max8997 = platform_get_drvdata(pdev); 1229 - struct regulator_dev **rdev = max8997->rdev; 1230 - int i; 1231 - 1232 - for (i = 0; i < max8997->num_regulators; i++) 1233 - regulator_unregister(rdev[i]); 1234 1217 return 0; 1235 1218 } 1236 1219 ··· 1229 1246 .owner = THIS_MODULE, 1230 1247 }, 1231 1248 .probe = max8997_pmic_probe, 1232 - .remove = max8997_pmic_remove, 1233 1249 .id_table = max8997_pmic_id, 1234 1250 }; 1235 1251
+8 -27
drivers/regulator/max8998.c
··· 790 790 dev_err(&pdev->dev, 791 791 "MAX8998 SET1 GPIO defined as 0 !\n"); 792 792 WARN_ON(!pdata->buck1_set1); 793 - ret = -EIO; 794 - goto err_out; 793 + return -EIO; 795 794 } 796 795 /* Check if SET2 is not equal to 0 */ 797 796 if (!pdata->buck1_set2) { 798 797 dev_err(&pdev->dev, 799 798 "MAX8998 SET2 GPIO defined as 0 !\n"); 800 799 WARN_ON(!pdata->buck1_set2); 801 - ret = -EIO; 802 - goto err_out; 800 + return -EIO; 803 801 } 804 802 805 803 gpio_request(pdata->buck1_set1, "MAX8998 BUCK1_SET1"); ··· 821 823 ret = max8998_write_reg(i2c, 822 824 MAX8998_REG_BUCK1_VOLTAGE1 + v, i); 823 825 if (ret) 824 - goto err_out; 826 + return ret; 825 827 } 826 828 } 827 829 ··· 831 833 dev_err(&pdev->dev, 832 834 "MAX8998 SET3 GPIO defined as 0 !\n"); 833 835 WARN_ON(!pdata->buck2_set3); 834 - ret = -EIO; 835 - goto err_out; 836 + return -EIO; 836 837 } 837 838 gpio_request(pdata->buck2_set3, "MAX8998 BUCK2_SET3"); 838 839 gpio_direction_output(pdata->buck2_set3, ··· 849 852 ret = max8998_write_reg(i2c, 850 853 MAX8998_REG_BUCK2_VOLTAGE1 + v, i); 851 854 if (ret) 852 - goto err_out; 855 + return ret; 853 856 } 854 857 } 855 858 ··· 872 875 config.init_data = pdata->regulators[i].initdata; 873 876 config.driver_data = max8998; 874 877 875 - rdev[i] = regulator_register(&regulators[index], &config); 878 + rdev[i] = devm_regulator_register(&pdev->dev, 879 + &regulators[index], &config); 876 880 if (IS_ERR(rdev[i])) { 877 881 ret = PTR_ERR(rdev[i]); 878 882 dev_err(max8998->dev, "regulator %s init failed (%d)\n", 879 883 regulators[index].name, ret); 880 884 rdev[i] = NULL; 881 - goto err; 885 + return ret; 882 886 } 883 887 } 884 888 885 889 886 - return 0; 887 - err: 888 - while (--i >= 0) 889 - regulator_unregister(rdev[i]); 890 - err_out: 891 - return ret; 892 - } 893 - 894 - static int max8998_pmic_remove(struct platform_device *pdev) 895 - { 896 - struct max8998_data *max8998 = platform_get_drvdata(pdev); 897 - struct regulator_dev **rdev = max8998->rdev; 898 - int i; 899 - 900 - for (i = 0; i < max8998->num_regulators; i++) 901 - regulator_unregister(rdev[i]); 902 890 return 0; 903 891 } 904 892 ··· 900 918 .owner = THIS_MODULE, 901 919 }, 902 920 .probe = max8998_pmic_probe, 903 - .remove = max8998_pmic_remove, 904 921 .id_table = max8998_pmic_id, 905 922 }; 906 923
+18 -35
drivers/regulator/mc13783-regulator.c
··· 258 258 259 259 MC13783_FIXED_DEFINE(REG, VAUDIO, REGULATORMODE0, mc13783_vaudio_val), 260 260 MC13783_FIXED_DEFINE(REG, VIOHI, REGULATORMODE0, mc13783_viohi_val), 261 - MC13783_DEFINE_REGU(VIOLO, REGULATORMODE0, REGULATORSETTING0, \ 261 + MC13783_DEFINE_REGU(VIOLO, REGULATORMODE0, REGULATORSETTING0, 262 262 mc13783_violo_val), 263 - MC13783_DEFINE_REGU(VDIG, REGULATORMODE0, REGULATORSETTING0, \ 263 + MC13783_DEFINE_REGU(VDIG, REGULATORMODE0, REGULATORSETTING0, 264 264 mc13783_vdig_val), 265 - MC13783_DEFINE_REGU(VGEN, REGULATORMODE0, REGULATORSETTING0, \ 265 + MC13783_DEFINE_REGU(VGEN, REGULATORMODE0, REGULATORSETTING0, 266 266 mc13783_vgen_val), 267 - MC13783_DEFINE_REGU(VRFDIG, REGULATORMODE0, REGULATORSETTING0, \ 267 + MC13783_DEFINE_REGU(VRFDIG, REGULATORMODE0, REGULATORSETTING0, 268 268 mc13783_vrfdig_val), 269 - MC13783_DEFINE_REGU(VRFREF, REGULATORMODE0, REGULATORSETTING0, \ 269 + MC13783_DEFINE_REGU(VRFREF, REGULATORMODE0, REGULATORSETTING0, 270 270 mc13783_vrfref_val), 271 - MC13783_DEFINE_REGU(VRFCP, REGULATORMODE0, REGULATORSETTING0, \ 271 + MC13783_DEFINE_REGU(VRFCP, REGULATORMODE0, REGULATORSETTING0, 272 272 mc13783_vrfcp_val), 273 - MC13783_DEFINE_REGU(VSIM, REGULATORMODE1, REGULATORSETTING0, \ 273 + MC13783_DEFINE_REGU(VSIM, REGULATORMODE1, REGULATORSETTING0, 274 274 mc13783_vsim_val), 275 - MC13783_DEFINE_REGU(VESIM, REGULATORMODE1, REGULATORSETTING0, \ 275 + MC13783_DEFINE_REGU(VESIM, REGULATORMODE1, REGULATORSETTING0, 276 276 mc13783_vesim_val), 277 - MC13783_DEFINE_REGU(VCAM, REGULATORMODE1, REGULATORSETTING0, \ 277 + MC13783_DEFINE_REGU(VCAM, REGULATORMODE1, REGULATORSETTING0, 278 278 mc13783_vcam_val), 279 279 MC13783_FIXED_DEFINE(REG, VRFBG, REGULATORMODE1, mc13783_vrfbg_val), 280 - MC13783_DEFINE_REGU(VVIB, REGULATORMODE1, REGULATORSETTING1, \ 280 + MC13783_DEFINE_REGU(VVIB, REGULATORMODE1, REGULATORSETTING1, 281 281 mc13783_vvib_val), 282 - MC13783_DEFINE_REGU(VRF1, REGULATORMODE1, REGULATORSETTING1, \ 282 + MC13783_DEFINE_REGU(VRF1, REGULATORMODE1, REGULATORSETTING1, 283 283 mc13783_vrf_val), 284 - MC13783_DEFINE_REGU(VRF2, REGULATORMODE1, REGULATORSETTING1, \ 284 + MC13783_DEFINE_REGU(VRF2, REGULATORMODE1, REGULATORSETTING1, 285 285 mc13783_vrf_val), 286 - MC13783_DEFINE_REGU(VMMC1, REGULATORMODE1, REGULATORSETTING1, \ 286 + MC13783_DEFINE_REGU(VMMC1, REGULATORMODE1, REGULATORSETTING1, 287 287 mc13783_vmmc_val), 288 - MC13783_DEFINE_REGU(VMMC2, REGULATORMODE1, REGULATORSETTING1, \ 288 + MC13783_DEFINE_REGU(VMMC2, REGULATORMODE1, REGULATORSETTING1, 289 289 mc13783_vmmc_val), 290 290 MC13783_GPO_DEFINE(REG, GPO1, POWERMISC, mc13783_gpo_val), 291 291 MC13783_GPO_DEFINE(REG, GPO2, POWERMISC, mc13783_gpo_val), ··· 400 400 dev_get_platdata(&pdev->dev); 401 401 struct mc13xxx_regulator_init_data *mc13xxx_data; 402 402 struct regulator_config config = { }; 403 - int i, ret, num_regulators; 403 + int i, num_regulators; 404 404 405 405 num_regulators = mc13xxx_get_num_regulators_dt(pdev); 406 406 ··· 444 444 config.driver_data = priv; 445 445 config.of_node = node; 446 446 447 - priv->regulators[i] = regulator_register(desc, &config); 447 + priv->regulators[i] = devm_regulator_register(&pdev->dev, desc, 448 + &config); 448 449 if (IS_ERR(priv->regulators[i])) { 449 450 dev_err(&pdev->dev, "failed to register regulator %s\n", 450 451 mc13783_regulators[i].desc.name); 451 - ret = PTR_ERR(priv->regulators[i]); 452 - goto err; 452 + return PTR_ERR(priv->regulators[i]); 453 453 } 454 454 } 455 - 456 - return 0; 457 - err: 458 - while (--i >= 0) 459 - regulator_unregister(priv->regulators[i]); 460 - 461 - return ret; 462 - } 463 - 464 - static int mc13783_regulator_remove(struct platform_device *pdev) 465 - { 466 - struct mc13xxx_regulator_priv *priv = platform_get_drvdata(pdev); 467 - int i; 468 - 469 - for (i = 0; i < priv->num_regulators; i++) 470 - regulator_unregister(priv->regulators[i]); 471 455 472 456 return 0; 473 457 } ··· 461 477 .name = "mc13783-regulator", 462 478 .owner = THIS_MODULE, 463 479 }, 464 - .remove = mc13783_regulator_remove, 465 480 .probe = mc13783_regulator_probe, 466 481 }; 467 482
+3 -19
drivers/regulator/mc13892-regulator.c
··· 611 611 config.driver_data = priv; 612 612 config.of_node = node; 613 613 614 - priv->regulators[i] = regulator_register(desc, &config); 614 + priv->regulators[i] = devm_regulator_register(&pdev->dev, desc, 615 + &config); 615 616 if (IS_ERR(priv->regulators[i])) { 616 617 dev_err(&pdev->dev, "failed to register regulator %s\n", 617 618 mc13892_regulators[i].desc.name); 618 - ret = PTR_ERR(priv->regulators[i]); 619 - goto err; 619 + return PTR_ERR(priv->regulators[i]); 620 620 } 621 621 } 622 622 623 623 return 0; 624 - err: 625 - while (--i >= 0) 626 - regulator_unregister(priv->regulators[i]); 627 - return ret; 628 624 629 625 err_unlock: 630 626 mc13xxx_unlock(mc13892); 631 627 return ret; 632 - } 633 - 634 - static int mc13892_regulator_remove(struct platform_device *pdev) 635 - { 636 - struct mc13xxx_regulator_priv *priv = platform_get_drvdata(pdev); 637 - int i; 638 - 639 - for (i = 0; i < priv->num_regulators; i++) 640 - regulator_unregister(priv->regulators[i]); 641 - 642 - return 0; 643 628 } 644 629 645 630 static struct platform_driver mc13892_regulator_driver = { ··· 632 647 .name = "mc13892-regulator", 633 648 .owner = THIS_MODULE, 634 649 }, 635 - .remove = mc13892_regulator_remove, 636 650 .probe = mc13892_regulator_probe, 637 651 }; 638 652
+6
drivers/regulator/of_regulator.c
··· 23 23 const __be32 *min_uA, *max_uA, *ramp_delay; 24 24 struct property *prop; 25 25 struct regulation_constraints *constraints = &(*init_data)->constraints; 26 + int ret; 27 + u32 pval; 26 28 27 29 constraints->name = of_get_property(np, "regulator-name", NULL); 28 30 ··· 75 73 else 76 74 constraints->ramp_disable = true; 77 75 } 76 + 77 + ret = of_property_read_u32(np, "regulator-enable-ramp-delay", &pval); 78 + if (!ret) 79 + constraints->enable_time = pval; 78 80 } 79 81 80 82 /**
+171 -37
drivers/regulator/palmas-regulator.c
··· 33 33 u8 vsel_addr; 34 34 u8 ctrl_addr; 35 35 u8 tstep_addr; 36 + int sleep_id; 36 37 }; 37 38 38 39 static const struct regs_info palmas_regs_info[] = { ··· 43 42 .vsel_addr = PALMAS_SMPS12_VOLTAGE, 44 43 .ctrl_addr = PALMAS_SMPS12_CTRL, 45 44 .tstep_addr = PALMAS_SMPS12_TSTEP, 45 + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SMPS12, 46 46 }, 47 47 { 48 48 .name = "SMPS123", ··· 51 49 .vsel_addr = PALMAS_SMPS12_VOLTAGE, 52 50 .ctrl_addr = PALMAS_SMPS12_CTRL, 53 51 .tstep_addr = PALMAS_SMPS12_TSTEP, 52 + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SMPS12, 54 53 }, 55 54 { 56 55 .name = "SMPS3", 57 56 .sname = "smps3-in", 58 57 .vsel_addr = PALMAS_SMPS3_VOLTAGE, 59 58 .ctrl_addr = PALMAS_SMPS3_CTRL, 59 + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SMPS3, 60 60 }, 61 61 { 62 62 .name = "SMPS45", ··· 66 62 .vsel_addr = PALMAS_SMPS45_VOLTAGE, 67 63 .ctrl_addr = PALMAS_SMPS45_CTRL, 68 64 .tstep_addr = PALMAS_SMPS45_TSTEP, 65 + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SMPS45, 69 66 }, 70 67 { 71 68 .name = "SMPS457", ··· 74 69 .vsel_addr = PALMAS_SMPS45_VOLTAGE, 75 70 .ctrl_addr = PALMAS_SMPS45_CTRL, 76 71 .tstep_addr = PALMAS_SMPS45_TSTEP, 72 + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SMPS45, 77 73 }, 78 74 { 79 75 .name = "SMPS6", ··· 82 76 .vsel_addr = PALMAS_SMPS6_VOLTAGE, 83 77 .ctrl_addr = PALMAS_SMPS6_CTRL, 84 78 .tstep_addr = PALMAS_SMPS6_TSTEP, 79 + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SMPS6, 85 80 }, 86 81 { 87 82 .name = "SMPS7", 88 83 .sname = "smps7-in", 89 84 .vsel_addr = PALMAS_SMPS7_VOLTAGE, 90 85 .ctrl_addr = PALMAS_SMPS7_CTRL, 86 + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SMPS7, 91 87 }, 92 88 { 93 89 .name = "SMPS8", ··· 97 89 .vsel_addr = PALMAS_SMPS8_VOLTAGE, 98 90 .ctrl_addr = PALMAS_SMPS8_CTRL, 99 91 .tstep_addr = PALMAS_SMPS8_TSTEP, 92 + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SMPS8, 100 93 }, 101 94 { 102 95 .name = "SMPS9", 103 96 .sname = "smps9-in", 104 97 .vsel_addr = PALMAS_SMPS9_VOLTAGE, 105 98 .ctrl_addr = PALMAS_SMPS9_CTRL, 99 + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SMPS9, 106 100 }, 107 101 { 108 102 .name = "SMPS10_OUT2", 109 103 .sname = "smps10-in", 110 104 .ctrl_addr = PALMAS_SMPS10_CTRL, 105 + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SMPS10, 111 106 }, 112 107 { 113 108 .name = "SMPS10_OUT1", 114 109 .sname = "smps10-out2", 115 110 .ctrl_addr = PALMAS_SMPS10_CTRL, 111 + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SMPS10, 116 112 }, 117 113 { 118 114 .name = "LDO1", 119 115 .sname = "ldo1-in", 120 116 .vsel_addr = PALMAS_LDO1_VOLTAGE, 121 117 .ctrl_addr = PALMAS_LDO1_CTRL, 118 + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_LDO1, 122 119 }, 123 120 { 124 121 .name = "LDO2", 125 122 .sname = "ldo2-in", 126 123 .vsel_addr = PALMAS_LDO2_VOLTAGE, 127 124 .ctrl_addr = PALMAS_LDO2_CTRL, 125 + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_LDO2, 128 126 }, 129 127 { 130 128 .name = "LDO3", 131 129 .sname = "ldo3-in", 132 130 .vsel_addr = PALMAS_LDO3_VOLTAGE, 133 131 .ctrl_addr = PALMAS_LDO3_CTRL, 132 + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_LDO3, 134 133 }, 135 134 { 136 135 .name = "LDO4", 137 136 .sname = "ldo4-in", 138 137 .vsel_addr = PALMAS_LDO4_VOLTAGE, 139 138 .ctrl_addr = PALMAS_LDO4_CTRL, 139 + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_LDO4, 140 140 }, 141 141 { 142 142 .name = "LDO5", 143 143 .sname = "ldo5-in", 144 144 .vsel_addr = PALMAS_LDO5_VOLTAGE, 145 145 .ctrl_addr = PALMAS_LDO5_CTRL, 146 + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_LDO5, 146 147 }, 147 148 { 148 149 .name = "LDO6", 149 150 .sname = "ldo6-in", 150 151 .vsel_addr = PALMAS_LDO6_VOLTAGE, 151 152 .ctrl_addr = PALMAS_LDO6_CTRL, 153 + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_LDO6, 152 154 }, 153 155 { 154 156 .name = "LDO7", 155 157 .sname = "ldo7-in", 156 158 .vsel_addr = PALMAS_LDO7_VOLTAGE, 157 159 .ctrl_addr = PALMAS_LDO7_CTRL, 160 + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_LDO7, 158 161 }, 159 162 { 160 163 .name = "LDO8", 161 164 .sname = "ldo8-in", 162 165 .vsel_addr = PALMAS_LDO8_VOLTAGE, 163 166 .ctrl_addr = PALMAS_LDO8_CTRL, 167 + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_LDO8, 164 168 }, 165 169 { 166 170 .name = "LDO9", 167 171 .sname = "ldo9-in", 168 172 .vsel_addr = PALMAS_LDO9_VOLTAGE, 169 173 .ctrl_addr = PALMAS_LDO9_CTRL, 174 + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_LDO9, 170 175 }, 171 176 { 172 177 .name = "LDOLN", 173 178 .sname = "ldoln-in", 174 179 .vsel_addr = PALMAS_LDOLN_VOLTAGE, 175 180 .ctrl_addr = PALMAS_LDOLN_CTRL, 181 + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_LDOLN, 176 182 }, 177 183 { 178 184 .name = "LDOUSB", 179 185 .sname = "ldousb-in", 180 186 .vsel_addr = PALMAS_LDOUSB_VOLTAGE, 181 187 .ctrl_addr = PALMAS_LDOUSB_CTRL, 188 + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_LDOUSB, 182 189 }, 183 190 { 184 191 .name = "REGEN1", 185 192 .ctrl_addr = PALMAS_REGEN1_CTRL, 193 + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_REGEN1, 186 194 }, 187 195 { 188 196 .name = "REGEN2", 189 197 .ctrl_addr = PALMAS_REGEN2_CTRL, 198 + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_REGEN2, 190 199 }, 191 200 { 192 201 .name = "REGEN3", 193 202 .ctrl_addr = PALMAS_REGEN3_CTRL, 203 + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_REGEN3, 194 204 }, 195 205 { 196 206 .name = "SYSEN1", 197 207 .ctrl_addr = PALMAS_SYSEN1_CTRL, 208 + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SYSEN1, 198 209 }, 199 210 { 200 211 .name = "SYSEN2", 201 212 .ctrl_addr = PALMAS_SYSEN2_CTRL, 213 + .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SYSEN2, 202 214 }, 203 215 }; 204 216 ··· 506 478 .set_ramp_delay = palmas_smps_set_ramp_delay, 507 479 }; 508 480 481 + static struct regulator_ops palmas_ops_ext_control_smps = { 482 + .set_mode = palmas_set_mode_smps, 483 + .get_mode = palmas_get_mode_smps, 484 + .get_voltage_sel = regulator_get_voltage_sel_regmap, 485 + .set_voltage_sel = regulator_set_voltage_sel_regmap, 486 + .list_voltage = palmas_list_voltage_smps, 487 + .map_voltage = palmas_map_voltage_smps, 488 + .set_voltage_time_sel = palma_smps_set_voltage_smps_time_sel, 489 + .set_ramp_delay = palmas_smps_set_ramp_delay, 490 + }; 491 + 509 492 static struct regulator_ops palmas_ops_smps10 = { 510 493 .is_enabled = regulator_is_enabled_regmap, 511 494 .enable = regulator_enable_regmap, ··· 552 513 .map_voltage = regulator_map_voltage_linear, 553 514 }; 554 515 516 + static struct regulator_ops palmas_ops_ext_control_ldo = { 517 + .get_voltage_sel = regulator_get_voltage_sel_regmap, 518 + .set_voltage_sel = regulator_set_voltage_sel_regmap, 519 + .list_voltage = regulator_list_voltage_linear, 520 + .map_voltage = regulator_map_voltage_linear, 521 + }; 522 + 555 523 static struct regulator_ops palmas_ops_extreg = { 556 524 .is_enabled = regulator_is_enabled_regmap, 557 525 .enable = regulator_enable_regmap, 558 526 .disable = regulator_disable_regmap, 559 527 }; 528 + 529 + static struct regulator_ops palmas_ops_ext_control_extreg = { 530 + }; 531 + 532 + static int palmas_regulator_config_external(struct palmas *palmas, int id, 533 + struct palmas_reg_init *reg_init) 534 + { 535 + int sleep_id = palmas_regs_info[id].sleep_id; 536 + int ret; 537 + 538 + ret = palmas_ext_control_req_config(palmas, sleep_id, 539 + reg_init->roof_floor, true); 540 + if (ret < 0) 541 + dev_err(palmas->dev, 542 + "Ext control config for regulator %d failed %d\n", 543 + id, ret); 544 + return ret; 545 + } 560 546 561 547 /* 562 548 * setup the hardware based sleep configuration of the SMPS/LDO regulators ··· 641 577 return ret; 642 578 } 643 579 580 + if (reg_init->roof_floor && (id != PALMAS_REG_SMPS10_OUT1) && 581 + (id != PALMAS_REG_SMPS10_OUT2)) { 582 + /* Enable externally controlled regulator */ 583 + addr = palmas_regs_info[id].ctrl_addr; 584 + ret = palmas_smps_read(palmas, addr, &reg); 585 + if (ret < 0) 586 + return ret; 644 587 588 + if (!(reg & PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK)) { 589 + reg |= SMPS_CTRL_MODE_ON; 590 + ret = palmas_smps_write(palmas, addr, reg); 591 + if (ret < 0) 592 + return ret; 593 + } 594 + return palmas_regulator_config_external(palmas, id, reg_init); 595 + } 645 596 return 0; 646 597 } 647 598 ··· 687 608 if (ret) 688 609 return ret; 689 610 611 + if (reg_init->roof_floor) { 612 + /* Enable externally controlled regulator */ 613 + addr = palmas_regs_info[id].ctrl_addr; 614 + ret = palmas_update_bits(palmas, PALMAS_LDO_BASE, 615 + addr, PALMAS_LDO1_CTRL_MODE_ACTIVE, 616 + PALMAS_LDO1_CTRL_MODE_ACTIVE); 617 + if (ret < 0) { 618 + dev_err(palmas->dev, 619 + "LDO Register 0x%02x update failed %d\n", 620 + addr, ret); 621 + return ret; 622 + } 623 + return palmas_regulator_config_external(palmas, id, reg_init); 624 + } 690 625 return 0; 691 626 } 692 627 ··· 722 629 dev_err(palmas->dev, "Resource reg 0x%02x update failed %d\n", 723 630 addr, ret); 724 631 return ret; 632 + } 633 + 634 + if (reg_init->roof_floor) { 635 + /* Enable externally controlled regulator */ 636 + addr = palmas_regs_info[id].ctrl_addr; 637 + ret = palmas_update_bits(palmas, PALMAS_RESOURCE_BASE, 638 + addr, PALMAS_REGEN1_CTRL_MODE_ACTIVE, 639 + PALMAS_REGEN1_CTRL_MODE_ACTIVE); 640 + if (ret < 0) { 641 + dev_err(palmas->dev, 642 + "Resource Register 0x%02x update failed %d\n", 643 + addr, ret); 644 + return ret; 645 + } 646 + return palmas_regulator_config_external(palmas, id, reg_init); 725 647 } 726 648 return 0; 727 649 } ··· 820 712 int idx, ret; 821 713 822 714 node = of_node_get(node); 823 - regulators = of_find_node_by_name(node, "regulators"); 715 + regulators = of_get_child_by_name(node, "regulators"); 824 716 if (!regulators) { 825 717 dev_info(dev, "regulator node not found\n"); 826 718 return; ··· 848 740 of_property_read_bool(palmas_matches[idx].of_node, 849 741 "ti,warm-reset"); 850 742 851 - pdata->reg_init[idx]->roof_floor = 852 - of_property_read_bool(palmas_matches[idx].of_node, 853 - "ti,roof-floor"); 743 + ret = of_property_read_u32(palmas_matches[idx].of_node, 744 + "ti,roof-floor", &prop); 745 + /* EINVAL: Property not found */ 746 + if (ret != -EINVAL) { 747 + int econtrol; 748 + 749 + /* use default value, when no value is specified */ 750 + econtrol = PALMAS_EXT_CONTROL_NSLEEP; 751 + if (!ret) { 752 + switch (prop) { 753 + case 1: 754 + econtrol = PALMAS_EXT_CONTROL_ENABLE1; 755 + break; 756 + case 2: 757 + econtrol = PALMAS_EXT_CONTROL_ENABLE2; 758 + break; 759 + case 3: 760 + econtrol = PALMAS_EXT_CONTROL_NSLEEP; 761 + break; 762 + default: 763 + WARN_ON(1); 764 + dev_warn(dev, 765 + "%s: Invalid roof-floor option: %u\n", 766 + palmas_matches[idx].name, prop); 767 + break; 768 + } 769 + } 770 + pdata->reg_init[idx]->roof_floor = econtrol; 771 + } 854 772 855 773 ret = of_property_read_u32(palmas_matches[idx].of_node, 856 774 "ti,mode-sleep", &prop); ··· 990 856 if (ret < 0) { 991 857 dev_err(&pdev->dev, 992 858 "reading TSTEP reg failed: %d\n", ret); 993 - goto err_unregister_regulator; 859 + return ret; 994 860 } 995 861 pmic->desc[id].ramp_delay = 996 862 palmas_smps_ramp_delay[reg & 0x3]; ··· 1002 868 reg_init = pdata->reg_init[id]; 1003 869 ret = palmas_smps_init(palmas, id, reg_init); 1004 870 if (ret) 1005 - goto err_unregister_regulator; 871 + return ret; 872 + } else { 873 + reg_init = NULL; 1006 874 } 1007 875 1008 876 /* Register the regulators */ ··· 1045 909 1046 910 ret = palmas_smps_read(pmic->palmas, addr, &reg); 1047 911 if (ret) 1048 - goto err_unregister_regulator; 912 + return ret; 1049 913 if (reg & PALMAS_SMPS12_VOLTAGE_RANGE) 1050 914 pmic->range[id] = 1; 1051 915 1052 - pmic->desc[id].ops = &palmas_ops_smps; 916 + if (reg_init && reg_init->roof_floor) 917 + pmic->desc[id].ops = 918 + &palmas_ops_ext_control_smps; 919 + else 920 + pmic->desc[id].ops = &palmas_ops_smps; 1053 921 pmic->desc[id].n_voltages = PALMAS_SMPS_NUM_VOLTAGES; 1054 922 pmic->desc[id].vsel_reg = 1055 923 PALMAS_BASE_TO_REG(PALMAS_SMPS_BASE, ··· 1065 925 addr = palmas_regs_info[id].ctrl_addr; 1066 926 ret = palmas_smps_read(pmic->palmas, addr, &reg); 1067 927 if (ret) 1068 - goto err_unregister_regulator; 928 + return ret; 1069 929 pmic->current_reg_mode[id] = reg & 1070 930 PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK; 1071 931 } ··· 1081 941 pmic->desc[id].supply_name = palmas_regs_info[id].sname; 1082 942 config.of_node = palmas_matches[id].of_node; 1083 943 1084 - rdev = regulator_register(&pmic->desc[id], &config); 944 + rdev = devm_regulator_register(&pdev->dev, &pmic->desc[id], 945 + &config); 1085 946 if (IS_ERR(rdev)) { 1086 947 dev_err(&pdev->dev, 1087 948 "failed to register %s regulator\n", 1088 949 pdev->name); 1089 - ret = PTR_ERR(rdev); 1090 - goto err_unregister_regulator; 950 + return PTR_ERR(rdev); 1091 951 } 1092 952 1093 953 /* Save regulator for cleanup */ ··· 1096 956 1097 957 /* Start this loop from the id left from previous loop */ 1098 958 for (; id < PALMAS_NUM_REGS; id++) { 959 + if (pdata && pdata->reg_init[id]) 960 + reg_init = pdata->reg_init[id]; 961 + else 962 + reg_init = NULL; 1099 963 1100 964 /* Miss out regulators which are not available due 1101 965 * to alternate functions. ··· 1113 969 1114 970 if (id < PALMAS_REG_REGEN1) { 1115 971 pmic->desc[id].n_voltages = PALMAS_LDO_NUM_VOLTAGES; 1116 - pmic->desc[id].ops = &palmas_ops_ldo; 972 + if (reg_init && reg_init->roof_floor) 973 + pmic->desc[id].ops = 974 + &palmas_ops_ext_control_ldo; 975 + else 976 + pmic->desc[id].ops = &palmas_ops_ldo; 1117 977 pmic->desc[id].min_uV = 900000; 1118 978 pmic->desc[id].uV_step = 50000; 1119 979 pmic->desc[id].linear_min_sel = 1; ··· 1147 999 pmic->desc[id].enable_time = 2000; 1148 1000 } else { 1149 1001 pmic->desc[id].n_voltages = 1; 1150 - pmic->desc[id].ops = &palmas_ops_extreg; 1002 + if (reg_init && reg_init->roof_floor) 1003 + pmic->desc[id].ops = 1004 + &palmas_ops_ext_control_extreg; 1005 + else 1006 + pmic->desc[id].ops = &palmas_ops_extreg; 1151 1007 pmic->desc[id].enable_reg = 1152 1008 PALMAS_BASE_TO_REG(PALMAS_RESOURCE_BASE, 1153 1009 palmas_regs_info[id].ctrl_addr); ··· 1167 1015 pmic->desc[id].supply_name = palmas_regs_info[id].sname; 1168 1016 config.of_node = palmas_matches[id].of_node; 1169 1017 1170 - rdev = regulator_register(&pmic->desc[id], &config); 1018 + rdev = devm_regulator_register(&pdev->dev, &pmic->desc[id], 1019 + &config); 1171 1020 if (IS_ERR(rdev)) { 1172 1021 dev_err(&pdev->dev, 1173 1022 "failed to register %s regulator\n", 1174 1023 pdev->name); 1175 - ret = PTR_ERR(rdev); 1176 - goto err_unregister_regulator; 1024 + return PTR_ERR(rdev); 1177 1025 } 1178 1026 1179 1027 /* Save regulator for cleanup */ ··· 1189 1037 else 1190 1038 ret = palmas_extreg_init(palmas, 1191 1039 id, reg_init); 1192 - if (ret) { 1193 - regulator_unregister(pmic->rdev[id]); 1194 - goto err_unregister_regulator; 1195 - } 1040 + if (ret) 1041 + return ret; 1196 1042 } 1197 1043 } 1198 1044 } 1199 1045 1200 1046 1201 - return 0; 1202 - 1203 - err_unregister_regulator: 1204 - while (--id >= 0) 1205 - regulator_unregister(pmic->rdev[id]); 1206 - return ret; 1207 - } 1208 - 1209 - static int palmas_regulators_remove(struct platform_device *pdev) 1210 - { 1211 - struct palmas_pmic *pmic = platform_get_drvdata(pdev); 1212 - int id; 1213 - 1214 - for (id = 0; id < PALMAS_NUM_REGS; id++) 1215 - regulator_unregister(pmic->rdev[id]); 1216 1047 return 0; 1217 1048 } 1218 1049 ··· 1218 1083 .owner = THIS_MODULE, 1219 1084 }, 1220 1085 .probe = palmas_regulators_probe, 1221 - .remove = palmas_regulators_remove, 1222 1086 }; 1223 1087 1224 1088 static int __init palmas_init(void)
+2 -11
drivers/regulator/pcap-regulator.c
··· 246 246 config.init_data = dev_get_platdata(&pdev->dev); 247 247 config.driver_data = pcap; 248 248 249 - rdev = regulator_register(&pcap_regulators[pdev->id], &config); 249 + rdev = devm_regulator_register(&pdev->dev, &pcap_regulators[pdev->id], 250 + &config); 250 251 if (IS_ERR(rdev)) 251 252 return PTR_ERR(rdev); 252 253 253 254 platform_set_drvdata(pdev, rdev); 254 - 255 - return 0; 256 - } 257 - 258 - static int pcap_regulator_remove(struct platform_device *pdev) 259 - { 260 - struct regulator_dev *rdev = platform_get_drvdata(pdev); 261 - 262 - regulator_unregister(rdev); 263 255 264 256 return 0; 265 257 } ··· 262 270 .owner = THIS_MODULE, 263 271 }, 264 272 .probe = pcap_regulator_probe, 265 - .remove = pcap_regulator_remove, 266 273 }; 267 274 268 275 static int __init pcap_regulator_init(void)
+2 -11
drivers/regulator/pcf50633-regulator.c
··· 90 90 config.driver_data = pcf; 91 91 config.regmap = pcf->regmap; 92 92 93 - rdev = regulator_register(&regulators[pdev->id], &config); 93 + rdev = devm_regulator_register(&pdev->dev, &regulators[pdev->id], 94 + &config); 94 95 if (IS_ERR(rdev)) 95 96 return PTR_ERR(rdev); 96 97 ··· 103 102 return 0; 104 103 } 105 104 106 - static int pcf50633_regulator_remove(struct platform_device *pdev) 107 - { 108 - struct regulator_dev *rdev = platform_get_drvdata(pdev); 109 - 110 - regulator_unregister(rdev); 111 - 112 - return 0; 113 - } 114 - 115 105 static struct platform_driver pcf50633_regulator_driver = { 116 106 .driver = { 117 107 .name = "pcf50633-regltr", 118 108 }, 119 109 .probe = pcf50633_regulator_probe, 120 - .remove = pcf50633_regulator_remove, 121 110 }; 122 111 123 112 static int __init pcf50633_regulator_init(void)
+2 -20
drivers/regulator/rc5t583-regulator.c
··· 173 173 config.driver_data = reg; 174 174 config.regmap = rc5t583->regmap; 175 175 176 - rdev = regulator_register(&ri->desc, &config); 176 + rdev = devm_regulator_register(&pdev->dev, &ri->desc, &config); 177 177 if (IS_ERR(rdev)) { 178 178 dev_err(&pdev->dev, "Failed to register regulator %s\n", 179 179 ri->desc.name); 180 - ret = PTR_ERR(rdev); 181 - goto clean_exit; 180 + return PTR_ERR(rdev); 182 181 } 183 182 reg->rdev = rdev; 184 183 } 185 184 platform_set_drvdata(pdev, regs); 186 - return 0; 187 - 188 - clean_exit: 189 - while (--id >= 0) 190 - regulator_unregister(regs[id].rdev); 191 - 192 - return ret; 193 - } 194 - 195 - static int rc5t583_regulator_remove(struct platform_device *pdev) 196 - { 197 - struct rc5t583_regulator *regs = platform_get_drvdata(pdev); 198 - int id; 199 - 200 - for (id = 0; id < RC5T583_REGULATOR_MAX; ++id) 201 - regulator_unregister(regs[id].rdev); 202 185 return 0; 203 186 } 204 187 ··· 191 208 .owner = THIS_MODULE, 192 209 }, 193 210 .probe = rc5t583_regulator_probe, 194 - .remove = rc5t583_regulator_remove, 195 211 }; 196 212 197 213 static int __init rc5t583_regulator_init(void)
+3 -20
drivers/regulator/s2mps11.c
··· 448 448 config.of_node = rdata[i].of_node; 449 449 } 450 450 451 - s2mps11->rdev[i] = regulator_register(&regulators[i], &config); 451 + s2mps11->rdev[i] = devm_regulator_register(&pdev->dev, 452 + &regulators[i], &config); 452 453 if (IS_ERR(s2mps11->rdev[i])) { 453 454 ret = PTR_ERR(s2mps11->rdev[i]); 454 455 dev_err(&pdev->dev, "regulator init failed for %d\n", 455 456 i); 456 - s2mps11->rdev[i] = NULL; 457 - goto err; 457 + return ret; 458 458 } 459 459 } 460 - 461 - return 0; 462 - err: 463 - for (i = 0; i < S2MPS11_REGULATOR_MAX; i++) 464 - regulator_unregister(s2mps11->rdev[i]); 465 - 466 - return ret; 467 - } 468 - 469 - static int s2mps11_pmic_remove(struct platform_device *pdev) 470 - { 471 - struct s2mps11_info *s2mps11 = platform_get_drvdata(pdev); 472 - int i; 473 - 474 - for (i = 0; i < S2MPS11_REGULATOR_MAX; i++) 475 - regulator_unregister(s2mps11->rdev[i]); 476 460 477 461 return 0; 478 462 } ··· 473 489 .owner = THIS_MODULE, 474 490 }, 475 491 .probe = s2mps11_pmic_probe, 476 - .remove = s2mps11_pmic_remove, 477 492 .id_table = s2mps11_pmic_id, 478 493 }; 479 494
+43 -43
drivers/regulator/s5m8767.c
··· 522 522 struct device_node *pmic_np, *regulators_np, *reg_np; 523 523 struct sec_regulator_data *rdata; 524 524 struct sec_opmode_data *rmode; 525 - unsigned int i, dvs_voltage_nr = 1, ret; 525 + unsigned int i, dvs_voltage_nr = 8, ret; 526 526 527 527 pmic_np = iodev->dev->of_node; 528 528 if (!pmic_np) { ··· 586 586 rmode++; 587 587 } 588 588 589 - if (of_get_property(pmic_np, "s5m8767,pmic-buck2-uses-gpio-dvs", NULL)) 589 + if (of_get_property(pmic_np, "s5m8767,pmic-buck2-uses-gpio-dvs", NULL)) { 590 590 pdata->buck2_gpiodvs = true; 591 591 592 - if (of_get_property(pmic_np, "s5m8767,pmic-buck3-uses-gpio-dvs", NULL)) 592 + if (of_property_read_u32_array(pmic_np, 593 + "s5m8767,pmic-buck2-dvs-voltage", 594 + pdata->buck2_voltage, dvs_voltage_nr)) { 595 + dev_err(iodev->dev, "buck2 voltages not specified\n"); 596 + return -EINVAL; 597 + } 598 + } 599 + 600 + if (of_get_property(pmic_np, "s5m8767,pmic-buck3-uses-gpio-dvs", NULL)) { 593 601 pdata->buck3_gpiodvs = true; 594 602 595 - if (of_get_property(pmic_np, "s5m8767,pmic-buck4-uses-gpio-dvs", NULL)) 603 + if (of_property_read_u32_array(pmic_np, 604 + "s5m8767,pmic-buck3-dvs-voltage", 605 + pdata->buck3_voltage, dvs_voltage_nr)) { 606 + dev_err(iodev->dev, "buck3 voltages not specified\n"); 607 + return -EINVAL; 608 + } 609 + } 610 + 611 + if (of_get_property(pmic_np, "s5m8767,pmic-buck4-uses-gpio-dvs", NULL)) { 596 612 pdata->buck4_gpiodvs = true; 613 + 614 + if (of_property_read_u32_array(pmic_np, 615 + "s5m8767,pmic-buck4-dvs-voltage", 616 + pdata->buck4_voltage, dvs_voltage_nr)) { 617 + dev_err(iodev->dev, "buck4 voltages not specified\n"); 618 + return -EINVAL; 619 + } 620 + } 597 621 598 622 if (pdata->buck2_gpiodvs || pdata->buck3_gpiodvs || 599 623 pdata->buck4_gpiodvs) { ··· 636 612 "invalid value for default dvs index, use 0\n"); 637 613 } 638 614 } 639 - dvs_voltage_nr = 8; 640 615 } 641 616 642 617 ret = s5m8767_pmic_dt_parse_ds_gpio(iodev, pdata, pmic_np); 643 618 if (ret) 644 619 return -EINVAL; 645 620 646 - if (of_property_read_u32_array(pmic_np, 647 - "s5m8767,pmic-buck2-dvs-voltage", 648 - pdata->buck2_voltage, dvs_voltage_nr)) { 649 - dev_err(iodev->dev, "buck2 voltages not specified\n"); 650 - return -EINVAL; 651 - } 621 + if (of_get_property(pmic_np, "s5m8767,pmic-buck2-ramp-enable", NULL)) 622 + pdata->buck2_ramp_enable = true; 652 623 653 - if (of_property_read_u32_array(pmic_np, 654 - "s5m8767,pmic-buck3-dvs-voltage", 655 - pdata->buck3_voltage, dvs_voltage_nr)) { 656 - dev_err(iodev->dev, "buck3 voltages not specified\n"); 657 - return -EINVAL; 658 - } 624 + if (of_get_property(pmic_np, "s5m8767,pmic-buck3-ramp-enable", NULL)) 625 + pdata->buck3_ramp_enable = true; 659 626 660 - if (of_property_read_u32_array(pmic_np, 661 - "s5m8767,pmic-buck4-dvs-voltage", 662 - pdata->buck4_voltage, dvs_voltage_nr)) { 663 - dev_err(iodev->dev, "buck4 voltages not specified\n"); 664 - return -EINVAL; 627 + if (of_get_property(pmic_np, "s5m8767,pmic-buck4-ramp-enable", NULL)) 628 + pdata->buck4_ramp_enable = true; 629 + 630 + if (pdata->buck2_ramp_enable || pdata->buck3_ramp_enable 631 + || pdata->buck4_ramp_enable) { 632 + if (of_property_read_u32(pmic_np, "s5m8767,pmic-buck-ramp-delay", 633 + &pdata->buck_ramp_delay)) 634 + pdata->buck_ramp_delay = 0; 665 635 } 666 636 667 637 return 0; ··· 928 910 config.regmap = iodev->regmap; 929 911 config.of_node = pdata->regulators[i].reg_node; 930 912 931 - rdev[i] = regulator_register(&regulators[id], &config); 913 + rdev[i] = devm_regulator_register(&pdev->dev, &regulators[id], 914 + &config); 932 915 if (IS_ERR(rdev[i])) { 933 916 ret = PTR_ERR(rdev[i]); 934 917 dev_err(s5m8767->dev, "regulator init failed for %d\n", 935 918 id); 936 - rdev[i] = NULL; 937 - goto err; 919 + return ret; 938 920 } 939 921 } 940 - 941 - return 0; 942 - err: 943 - for (i = 0; i < s5m8767->num_regulators; i++) 944 - regulator_unregister(rdev[i]); 945 - 946 - return ret; 947 - } 948 - 949 - static int s5m8767_pmic_remove(struct platform_device *pdev) 950 - { 951 - struct s5m8767_info *s5m8767 = platform_get_drvdata(pdev); 952 - struct regulator_dev **rdev = s5m8767->rdev; 953 - int i; 954 - 955 - for (i = 0; i < s5m8767->num_regulators; i++) 956 - regulator_unregister(rdev[i]); 957 922 958 923 return 0; 959 924 } ··· 953 952 .owner = THIS_MODULE, 954 953 }, 955 954 .probe = s5m8767_pmic_probe, 956 - .remove = s5m8767_pmic_remove, 957 955 .id_table = s5m8767_pmic_id, 958 956 }; 959 957
+111
drivers/regulator/stw481x-vmmc.c
··· 1 + /* 2 + * Regulator driver for STw4810/STw4811 VMMC regulator. 3 + * 4 + * Copyright (C) 2013 ST-Ericsson SA 5 + * Written on behalf of Linaro for ST-Ericsson 6 + * 7 + * Author: Linus Walleij <linus.walleij@linaro.org> 8 + * 9 + * License terms: GNU General Public License (GPL) version 2 10 + */ 11 + 12 + #include <linux/err.h> 13 + #include <linux/init.h> 14 + #include <linux/mfd/stw481x.h> 15 + #include <linux/module.h> 16 + #include <linux/platform_device.h> 17 + #include <linux/regulator/driver.h> 18 + #include <linux/regulator/of_regulator.h> 19 + 20 + static const unsigned int stw481x_vmmc_voltages[] = { 21 + 1800000, 22 + 1800000, 23 + 2850000, 24 + 3000000, 25 + 1850000, 26 + 2600000, 27 + 2700000, 28 + 3300000, 29 + }; 30 + 31 + static struct regulator_ops stw481x_vmmc_ops = { 32 + .list_voltage = regulator_list_voltage_table, 33 + .enable = regulator_enable_regmap, 34 + .disable = regulator_disable_regmap, 35 + .is_enabled = regulator_is_enabled_regmap, 36 + .get_voltage_sel = regulator_get_voltage_sel_regmap, 37 + .set_voltage_sel = regulator_set_voltage_sel_regmap, 38 + }; 39 + 40 + static struct regulator_desc vmmc_regulator = { 41 + .name = "VMMC", 42 + .id = 0, 43 + .ops = &stw481x_vmmc_ops, 44 + .type = REGULATOR_VOLTAGE, 45 + .owner = THIS_MODULE, 46 + .n_voltages = ARRAY_SIZE(stw481x_vmmc_voltages), 47 + .volt_table = stw481x_vmmc_voltages, 48 + .enable_time = 200, /* FIXME: look this up */ 49 + .enable_reg = STW_CONF1, 50 + .enable_mask = STW_CONF1_PDN_VMMC, 51 + .vsel_reg = STW_CONF1, 52 + .vsel_mask = STW_CONF1_VMMC_MASK, 53 + }; 54 + 55 + static int stw481x_vmmc_regulator_probe(struct platform_device *pdev) 56 + { 57 + struct stw481x *stw481x = dev_get_platdata(&pdev->dev); 58 + struct regulator_config config = { }; 59 + int ret; 60 + 61 + /* First disable the external VMMC if it's active */ 62 + ret = regmap_update_bits(stw481x->map, STW_CONF2, 63 + STW_CONF2_VMMC_EXT, 0); 64 + if (ret) { 65 + dev_err(&pdev->dev, "could not disable external VMMC\n"); 66 + return ret; 67 + } 68 + 69 + /* Register VMMC regulator */ 70 + config.dev = &pdev->dev; 71 + config.driver_data = stw481x; 72 + config.regmap = stw481x->map; 73 + config.of_node = pdev->dev.of_node; 74 + config.init_data = of_get_regulator_init_data(&pdev->dev, 75 + pdev->dev.of_node); 76 + 77 + stw481x->vmmc_regulator = regulator_register(&vmmc_regulator, &config); 78 + if (IS_ERR(stw481x->vmmc_regulator)) { 79 + dev_err(&pdev->dev, 80 + "error initializing STw481x VMMC regulator\n"); 81 + return PTR_ERR(stw481x->vmmc_regulator); 82 + } 83 + 84 + dev_info(&pdev->dev, "initialized STw481x VMMC regulator\n"); 85 + return 0; 86 + } 87 + 88 + static int stw481x_vmmc_regulator_remove(struct platform_device *pdev) 89 + { 90 + struct stw481x *stw481x = dev_get_platdata(&pdev->dev); 91 + 92 + regulator_unregister(stw481x->vmmc_regulator); 93 + return 0; 94 + } 95 + 96 + static const struct of_device_id stw481x_vmmc_match[] = { 97 + { .compatible = "st,stw481x-vmmc", }, 98 + {}, 99 + }; 100 + 101 + static struct platform_driver stw481x_vmmc_regulator_driver = { 102 + .driver = { 103 + .name = "stw481x-vmmc-regulator", 104 + .owner = THIS_MODULE, 105 + .of_match_table = stw481x_vmmc_match, 106 + }, 107 + .probe = stw481x_vmmc_regulator_probe, 108 + .remove = stw481x_vmmc_regulator_remove, 109 + }; 110 + 111 + module_platform_driver(stw481x_vmmc_regulator_driver);
+28 -58
drivers/regulator/ti-abb-regulator.c
··· 615 615 pname, *volt_table, vset_mask); 616 616 continue; 617 617 } 618 - info->vset = efuse_val & vset_mask >> __ffs(vset_mask); 618 + info->vset = (efuse_val & vset_mask) >> __ffs(vset_mask); 619 619 dev_dbg(dev, "[%d]v=%d vset=%x\n", i, *volt_table, info->vset); 620 620 check_abb: 621 621 switch (info->opp_sel) { ··· 708 708 match = of_match_device(ti_abb_of_match, dev); 709 709 if (!match) { 710 710 /* We do not expect this to happen */ 711 - ret = -ENODEV; 712 711 dev_err(dev, "%s: Unable to match device\n", __func__); 713 - goto err; 712 + return -ENODEV; 714 713 } 715 714 if (!match->data) { 716 - ret = -EINVAL; 717 715 dev_err(dev, "%s: Bad data in match\n", __func__); 718 - goto err; 716 + return -EINVAL; 719 717 } 720 718 721 719 abb = devm_kzalloc(dev, sizeof(struct ti_abb), GFP_KERNEL); 722 - if (!abb) { 723 - dev_err(dev, "%s: Unable to allocate ABB struct\n", __func__); 724 - ret = -ENOMEM; 725 - goto err; 726 - } 720 + if (!abb) 721 + return -ENOMEM; 727 722 abb->regs = match->data; 728 723 729 724 /* Map ABB resources */ 730 725 pname = "base-address"; 731 726 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, pname); 732 727 abb->base = devm_ioremap_resource(dev, res); 733 - if (IS_ERR(abb->base)) { 734 - ret = PTR_ERR(abb->base); 735 - goto err; 736 - } 728 + if (IS_ERR(abb->base)) 729 + return PTR_ERR(abb->base); 737 730 738 731 pname = "int-address"; 739 732 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, pname); 740 733 if (!res) { 741 734 dev_err(dev, "Missing '%s' IO resource\n", pname); 742 - ret = -ENODEV; 743 - goto err; 735 + return -ENODEV; 744 736 } 745 737 /* 746 738 * We may have shared interrupt register offsets which are ··· 742 750 resource_size(res)); 743 751 if (!abb->int_base) { 744 752 dev_err(dev, "Unable to map '%s'\n", pname); 745 - ret = -ENOMEM; 746 - goto err; 753 + return -ENOMEM; 747 754 } 748 755 749 756 /* Map Optional resources */ ··· 762 771 resource_size(res)); 763 772 if (!abb->efuse_base) { 764 773 dev_err(dev, "Unable to map '%s'\n", pname); 765 - ret = -ENOMEM; 766 - goto err; 774 + return -ENOMEM; 767 775 } 768 776 769 777 pname = "ldo-address"; 770 778 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, pname); 771 - abb->ldo_base = devm_ioremap_resource(dev, res); 772 - if (IS_ERR(abb->ldo_base)) { 773 - ret = PTR_ERR(abb->ldo_base); 774 - goto err; 779 + if (!res) { 780 + dev_dbg(dev, "Missing '%s' IO resource\n", pname); 781 + ret = -ENODEV; 782 + goto skip_opt; 775 783 } 784 + abb->ldo_base = devm_ioremap_resource(dev, res); 785 + if (IS_ERR(abb->ldo_base)) 786 + return PTR_ERR(abb->ldo_base); 776 787 777 788 /* IF ldo_base is set, the following are mandatory */ 778 789 pname = "ti,ldovbb-override-mask"; ··· 783 790 &abb->ldovbb_override_mask); 784 791 if (ret) { 785 792 dev_err(dev, "Missing '%s' (%d)\n", pname, ret); 786 - goto err; 793 + return ret; 787 794 } 788 795 if (!abb->ldovbb_override_mask) { 789 796 dev_err(dev, "Invalid property:'%s' set as 0!\n", pname); 790 - ret = -EINVAL; 791 - goto err; 797 + return -EINVAL; 792 798 } 793 799 794 800 pname = "ti,ldovbb-vset-mask"; ··· 796 804 &abb->ldovbb_vset_mask); 797 805 if (ret) { 798 806 dev_err(dev, "Missing '%s' (%d)\n", pname, ret); 799 - goto err; 807 + return ret; 800 808 } 801 809 if (!abb->ldovbb_vset_mask) { 802 810 dev_err(dev, "Invalid property:'%s' set as 0!\n", pname); 803 - ret = -EINVAL; 804 - goto err; 811 + return -EINVAL; 805 812 } 806 813 807 814 skip_opt: ··· 810 819 &abb->txdone_mask); 811 820 if (ret) { 812 821 dev_err(dev, "Missing '%s' (%d)\n", pname, ret); 813 - goto err; 822 + return ret; 814 823 } 815 824 if (!abb->txdone_mask) { 816 825 dev_err(dev, "Invalid property:'%s' set as 0!\n", pname); 817 - ret = -EINVAL; 818 - goto err; 826 + return -EINVAL; 819 827 } 820 828 821 829 initdata = of_get_regulator_init_data(dev, pdev->dev.of_node); 822 830 if (!initdata) { 823 - ret = -ENOMEM; 824 831 dev_err(dev, "%s: Unable to alloc regulator init data\n", 825 832 __func__); 826 - goto err; 833 + return -ENOMEM; 827 834 } 828 835 829 836 /* init ABB opp_sel table */ 830 837 ret = ti_abb_init_table(dev, abb, initdata); 831 838 if (ret) 832 - goto err; 839 + return ret; 833 840 834 841 /* init ABB timing */ 835 842 ret = ti_abb_init_timings(dev, abb); 836 843 if (ret) 837 - goto err; 844 + return ret; 838 845 839 846 desc = &abb->rdesc; 840 847 desc->name = dev_name(dev); ··· 850 861 config.driver_data = abb; 851 862 config.of_node = pdev->dev.of_node; 852 863 853 - rdev = regulator_register(desc, &config); 864 + rdev = devm_regulator_register(dev, desc, &config); 854 865 if (IS_ERR(rdev)) { 855 866 ret = PTR_ERR(rdev); 856 867 dev_err(dev, "%s: failed to register regulator(%d)\n", 857 868 __func__, ret); 858 - goto err; 869 + return ret; 859 870 } 860 871 platform_set_drvdata(pdev, rdev); 861 872 ··· 863 874 ti_abb_rmw(abb->regs->sr2_en_mask, 1, abb->regs->setup_reg, abb->base); 864 875 865 876 return 0; 866 - 867 - err: 868 - dev_err(dev, "%s: Failed to initialize(%d)\n", __func__, ret); 869 - return ret; 870 - } 871 - 872 - /** 873 - * ti_abb_remove() - cleanups 874 - * @pdev: ABB platform device 875 - * 876 - * Return: 0 877 - */ 878 - static int ti_abb_remove(struct platform_device *pdev) 879 - { 880 - struct regulator_dev *rdev = platform_get_drvdata(pdev); 881 - 882 - regulator_unregister(rdev); 883 - return 0; 884 877 } 885 878 886 879 MODULE_ALIAS("platform:ti_abb"); 887 880 888 881 static struct platform_driver ti_abb_driver = { 889 882 .probe = ti_abb_probe, 890 - .remove = ti_abb_remove, 891 883 .driver = { 892 884 .name = "ti_abb", 893 885 .owner = THIS_MODULE,
+1 -10
drivers/regulator/tps51632-regulator.c
··· 343 343 config.regmap = tps->regmap; 344 344 config.of_node = client->dev.of_node; 345 345 346 - rdev = regulator_register(&tps->desc, &config); 346 + rdev = devm_regulator_register(&client->dev, &tps->desc, &config); 347 347 if (IS_ERR(rdev)) { 348 348 dev_err(tps->dev, "regulator register failed\n"); 349 349 return PTR_ERR(rdev); 350 350 } 351 351 352 352 tps->rdev = rdev; 353 - return 0; 354 - } 355 - 356 - static int tps51632_remove(struct i2c_client *client) 357 - { 358 - struct tps51632_chip *tps = i2c_get_clientdata(client); 359 - 360 - regulator_unregister(tps->rdev); 361 353 return 0; 362 354 } 363 355 ··· 367 375 .of_match_table = of_match_ptr(tps51632_of_match), 368 376 }, 369 377 .probe = tps51632_probe, 370 - .remove = tps51632_remove, 371 378 .id_table = tps51632_id, 372 379 }; 373 380
+4 -11
drivers/regulator/tps6105x-regulator.c
··· 137 137 /* This instance is not set for regulator mode so bail out */ 138 138 if (pdata->mode != TPS6105X_MODE_VOLTAGE) { 139 139 dev_info(&pdev->dev, 140 - "chip not in voltage mode mode, exit probe \n"); 140 + "chip not in voltage mode mode, exit probe\n"); 141 141 return 0; 142 142 } 143 143 ··· 146 146 config.driver_data = tps6105x; 147 147 148 148 /* Register regulator with framework */ 149 - tps6105x->regulator = regulator_register(&tps6105x_regulator_desc, 150 - &config); 149 + tps6105x->regulator = devm_regulator_register(&pdev->dev, 150 + &tps6105x_regulator_desc, 151 + &config); 151 152 if (IS_ERR(tps6105x->regulator)) { 152 153 ret = PTR_ERR(tps6105x->regulator); 153 154 dev_err(&tps6105x->client->dev, ··· 160 159 return 0; 161 160 } 162 161 163 - static int tps6105x_regulator_remove(struct platform_device *pdev) 164 - { 165 - struct tps6105x *tps6105x = dev_get_platdata(&pdev->dev); 166 - regulator_unregister(tps6105x->regulator); 167 - return 0; 168 - } 169 - 170 162 static struct platform_driver tps6105x_regulator_driver = { 171 163 .driver = { 172 164 .name = "tps6105x-regulator", 173 165 .owner = THIS_MODULE, 174 166 }, 175 167 .probe = tps6105x_regulator_probe, 176 - .remove = tps6105x_regulator_remove, 177 168 }; 178 169 179 170 static __init int tps6105x_regulator_init(void)
+1 -16
drivers/regulator/tps62360-regulator.c
··· 476 476 config.of_node = client->dev.of_node; 477 477 478 478 /* Register the regulators */ 479 - rdev = regulator_register(&tps->desc, &config); 479 + rdev = devm_regulator_register(&client->dev, &tps->desc, &config); 480 480 if (IS_ERR(rdev)) { 481 481 dev_err(tps->dev, 482 482 "%s(): regulator register failed with err %s\n", ··· 485 485 } 486 486 487 487 tps->rdev = rdev; 488 - return 0; 489 - } 490 - 491 - /** 492 - * tps62360_remove - tps62360 driver i2c remove handler 493 - * @client: i2c driver client device structure 494 - * 495 - * Unregister TPS driver as an i2c client device driver 496 - */ 497 - static int tps62360_remove(struct i2c_client *client) 498 - { 499 - struct tps62360_chip *tps = i2c_get_clientdata(client); 500 - 501 - regulator_unregister(tps->rdev); 502 488 return 0; 503 489 } 504 490 ··· 521 535 .of_match_table = of_match_ptr(tps62360_of_match), 522 536 }, 523 537 .probe = tps62360_probe, 524 - .remove = tps62360_remove, 525 538 .shutdown = tps62360_shutdown, 526 539 .id_table = tps62360_id, 527 540 };
+5 -20
drivers/regulator/tps65023-regulator.c
··· 277 277 config.regmap = tps->regmap; 278 278 279 279 /* Register the regulators */ 280 - rdev = regulator_register(&tps->desc[i], &config); 280 + rdev = devm_regulator_register(&client->dev, &tps->desc[i], 281 + &config); 281 282 if (IS_ERR(rdev)) { 282 283 dev_err(&client->dev, "failed to register %s\n", 283 284 id->name); 284 - error = PTR_ERR(rdev); 285 - goto fail; 285 + return PTR_ERR(rdev); 286 286 } 287 287 288 288 /* Save regulator for cleanup */ ··· 293 293 294 294 /* Enable setting output voltage by I2C */ 295 295 regmap_update_bits(tps->regmap, TPS65023_REG_CON_CTRL2, 296 - TPS65023_REG_CTRL2_CORE_ADJ, TPS65023_REG_CTRL2_CORE_ADJ); 296 + TPS65023_REG_CTRL2_CORE_ADJ, 297 + TPS65023_REG_CTRL2_CORE_ADJ); 297 298 298 - return 0; 299 - 300 - fail: 301 - while (--i >= 0) 302 - regulator_unregister(tps->rdev[i]); 303 - return error; 304 - } 305 - 306 - static int tps_65023_remove(struct i2c_client *client) 307 - { 308 - struct tps_pmic *tps = i2c_get_clientdata(client); 309 - int i; 310 - 311 - for (i = 0; i < TPS65023_NUM_REGULATOR; i++) 312 - regulator_unregister(tps->rdev[i]); 313 299 return 0; 314 300 } 315 301 ··· 416 430 .owner = THIS_MODULE, 417 431 }, 418 432 .probe = tps_65023_probe, 419 - .remove = tps_65023_remove, 420 433 .id_table = tps_65023_id, 421 434 }; 422 435
+3 -20
drivers/regulator/tps6507x-regulator.c
··· 508 508 config.of_node = tps6507x_reg_matches[i].of_node; 509 509 } 510 510 511 - rdev = regulator_register(&tps->desc[i], &config); 511 + rdev = devm_regulator_register(&pdev->dev, &tps->desc[i], 512 + &config); 512 513 if (IS_ERR(rdev)) { 513 514 dev_err(tps6507x_dev->dev, 514 515 "failed to register %s regulator\n", 515 516 pdev->name); 516 - error = PTR_ERR(rdev); 517 - goto fail; 517 + return PTR_ERR(rdev); 518 518 } 519 519 520 520 /* Save regulator for cleanup */ ··· 525 525 platform_set_drvdata(pdev, tps6507x_dev); 526 526 527 527 return 0; 528 - 529 - fail: 530 - while (--i >= 0) 531 - regulator_unregister(tps->rdev[i]); 532 - return error; 533 - } 534 - 535 - static int tps6507x_pmic_remove(struct platform_device *pdev) 536 - { 537 - struct tps6507x_dev *tps6507x_dev = platform_get_drvdata(pdev); 538 - struct tps6507x_pmic *tps = tps6507x_dev->pmic; 539 - int i; 540 - 541 - for (i = 0; i < TPS6507X_NUM_REGULATOR; i++) 542 - regulator_unregister(tps->rdev[i]); 543 - return 0; 544 528 } 545 529 546 530 static struct platform_driver tps6507x_pmic_driver = { ··· 533 549 .owner = THIS_MODULE, 534 550 }, 535 551 .probe = tps6507x_pmic_probe, 536 - .remove = tps6507x_pmic_remove, 537 552 }; 538 553 539 554 static int __init tps6507x_pmic_init(void)
+6 -31
drivers/regulator/tps65090-regulator.c
··· 180 180 return ERR_PTR(-ENOMEM); 181 181 } 182 182 183 - regulators = of_find_node_by_name(np, "regulators"); 183 + regulators = of_get_child_by_name(np, "regulators"); 184 184 if (!regulators) { 185 185 dev_err(&pdev->dev, "regulator node not found\n"); 186 186 return ERR_PTR(-ENODEV); ··· 279 279 if (ret < 0) { 280 280 dev_err(&pdev->dev, 281 281 "failed disable ext control\n"); 282 - goto scrub; 282 + return ret; 283 283 } 284 284 } 285 285 } ··· 296 296 else 297 297 config.of_node = NULL; 298 298 299 - rdev = regulator_register(ri->desc, &config); 299 + rdev = devm_regulator_register(&pdev->dev, ri->desc, &config); 300 300 if (IS_ERR(rdev)) { 301 301 dev_err(&pdev->dev, "failed to register regulator %s\n", 302 302 ri->desc->name); 303 - ret = PTR_ERR(rdev); 304 - goto scrub; 303 + return PTR_ERR(rdev); 305 304 } 306 305 ri->rdev = rdev; 307 306 ··· 308 309 if (tps_pdata && is_dcdc(num) && tps_pdata->reg_init_data && 309 310 tps_pdata->enable_ext_control) { 310 311 ret = tps65090_config_ext_control(ri, true); 311 - if (ret < 0) { 312 - /* Increment num to get unregister rdev */ 313 - num++; 314 - goto scrub; 315 - } 312 + if (ret < 0) 313 + return ret; 316 314 } 317 315 } 318 316 319 317 platform_set_drvdata(pdev, pmic); 320 - return 0; 321 - 322 - scrub: 323 - while (--num >= 0) { 324 - ri = &pmic[num]; 325 - regulator_unregister(ri->rdev); 326 - } 327 - return ret; 328 - } 329 - 330 - static int tps65090_regulator_remove(struct platform_device *pdev) 331 - { 332 - struct tps65090_regulator *pmic = platform_get_drvdata(pdev); 333 - struct tps65090_regulator *ri; 334 - int num; 335 - 336 - for (num = 0; num < TPS65090_REGULATOR_MAX; ++num) { 337 - ri = &pmic[num]; 338 - regulator_unregister(ri->rdev); 339 - } 340 318 return 0; 341 319 } 342 320 ··· 323 347 .owner = THIS_MODULE, 324 348 }, 325 349 .probe = tps65090_regulator_probe, 326 - .remove = tps65090_regulator_remove, 327 350 }; 328 351 329 352 static int __init tps65090_regulator_init(void)
+12 -38
drivers/regulator/tps65217-regulator.c
··· 52 52 }; 53 53 54 54 static const struct regulator_linear_range tps65217_uv1_ranges[] = { 55 - { .min_uV = 900000, .max_uV = 1500000, .min_sel = 0, .max_sel = 24, 56 - .uV_step = 25000 }, 57 - { .min_uV = 1550000, .max_uV = 1800000, .min_sel = 25, .max_sel = 30, 58 - .uV_step = 50000 }, 59 - { .min_uV = 1850000, .max_uV = 2900000, .min_sel = 31, .max_sel = 52, 60 - .uV_step = 50000 }, 61 - { .min_uV = 3000000, .max_uV = 3200000, .min_sel = 53, .max_sel = 55, 62 - .uV_step = 100000 }, 63 - { .min_uV = 3300000, .max_uV = 3300000, .min_sel = 56, .max_sel = 62, 64 - .uV_step = 0 }, 55 + REGULATOR_LINEAR_RANGE(900000, 0, 24, 25000), 56 + REGULATOR_LINEAR_RANGE(1550000, 25, 30, 50000), 57 + REGULATOR_LINEAR_RANGE(1850000, 31, 52, 50000), 58 + REGULATOR_LINEAR_RANGE(3000000, 53, 55, 100000), 59 + REGULATOR_LINEAR_RANGE(3300000, 56, 62, 0), 65 60 }; 66 61 67 62 static const struct regulator_linear_range tps65217_uv2_ranges[] = { 68 - { .min_uV = 1500000, .max_uV = 1900000, .min_sel = 0, .max_sel = 8, 69 - .uV_step = 50000 }, 70 - { .min_uV = 2000000, .max_uV = 2400000, .min_sel = 9, .max_sel = 13, 71 - .uV_step = 100000 }, 72 - { .min_uV = 2450000, .max_uV = 3300000, .min_sel = 14, .max_sel = 31, 73 - .uV_step = 50000 }, 63 + REGULATOR_LINEAR_RANGE(1500000, 0, 8, 50000), 64 + REGULATOR_LINEAR_RANGE(2000000, 9, 13, 100000), 65 + REGULATOR_LINEAR_RANGE(2450000, 14, 31, 50000), 74 66 }; 75 67 76 68 static int tps65217_pmic_enable(struct regulator_dev *dev) ··· 225 233 struct regulator_init_data *reg_data; 226 234 struct regulator_dev *rdev; 227 235 struct regulator_config config = { }; 228 - int i, ret; 236 + int i; 229 237 230 238 if (tps->dev->of_node) 231 239 pdata = tps65217_parse_dt(pdev); ··· 261 269 if (tps->dev->of_node) 262 270 config.of_node = pdata->of_node[i]; 263 271 264 - rdev = regulator_register(&regulators[i], &config); 272 + rdev = devm_regulator_register(&pdev->dev, &regulators[i], 273 + &config); 265 274 if (IS_ERR(rdev)) { 266 275 dev_err(tps->dev, "failed to register %s regulator\n", 267 276 pdev->name); 268 - ret = PTR_ERR(rdev); 269 - goto err_unregister_regulator; 277 + return PTR_ERR(rdev); 270 278 } 271 279 272 280 /* Save regulator for cleanup */ 273 281 tps->rdev[i] = rdev; 274 282 } 275 - return 0; 276 - 277 - err_unregister_regulator: 278 - while (--i >= 0) 279 - regulator_unregister(tps->rdev[i]); 280 - 281 - return ret; 282 - } 283 - 284 - static int tps65217_regulator_remove(struct platform_device *pdev) 285 - { 286 - struct tps65217 *tps = platform_get_drvdata(pdev); 287 - unsigned int i; 288 - 289 - for (i = 0; i < TPS65217_NUM_REGULATOR; i++) 290 - regulator_unregister(tps->rdev[i]); 291 - 292 283 return 0; 293 284 } 294 285 ··· 280 305 .name = "tps65217-pmic", 281 306 }, 282 307 .probe = tps65217_regulator_probe, 283 - .remove = tps65217_regulator_remove, 284 308 }; 285 309 286 310 static int __init tps65217_regulator_init(void)
+5 -27
drivers/regulator/tps6524x-regulator.c
··· 577 577 .get_current_limit = get_current_limit, 578 578 }; 579 579 580 - static int pmic_remove(struct spi_device *spi) 581 - { 582 - struct tps6524x *hw = spi_get_drvdata(spi); 583 - int i; 584 - 585 - if (!hw) 586 - return 0; 587 - for (i = 0; i < N_REGULATORS; i++) { 588 - regulator_unregister(hw->rdev[i]); 589 - hw->rdev[i] = NULL; 590 - } 591 - spi_set_drvdata(spi, NULL); 592 - return 0; 593 - } 594 - 595 580 static int pmic_probe(struct spi_device *spi) 596 581 { 597 582 struct tps6524x *hw; ··· 584 599 const struct supply_info *info = supply_info; 585 600 struct regulator_init_data *init_data; 586 601 struct regulator_config config = { }; 587 - int ret = 0, i; 602 + int i; 588 603 589 604 init_data = dev_get_platdata(dev); 590 605 if (!init_data) { ··· 617 632 config.init_data = init_data; 618 633 config.driver_data = hw; 619 634 620 - hw->rdev[i] = regulator_register(&hw->desc[i], &config); 621 - if (IS_ERR(hw->rdev[i])) { 622 - ret = PTR_ERR(hw->rdev[i]); 623 - hw->rdev[i] = NULL; 624 - goto fail; 625 - } 635 + hw->rdev[i] = devm_regulator_register(dev, &hw->desc[i], 636 + &config); 637 + if (IS_ERR(hw->rdev[i])) 638 + return PTR_ERR(hw->rdev[i]); 626 639 } 627 640 628 641 return 0; 629 - 630 - fail: 631 - pmic_remove(spi); 632 - return ret; 633 642 } 634 643 635 644 static struct spi_driver pmic_driver = { 636 645 .probe = pmic_probe, 637 - .remove = pmic_remove, 638 646 .driver = { 639 647 .name = "tps6524x", 640 648 .owner = THIS_MODULE,
+7 -26
drivers/regulator/tps6586x-regulator.c
··· 298 298 struct tps6586x_platform_data *pdata; 299 299 int err; 300 300 301 - regs = of_find_node_by_name(np, "regulators"); 301 + regs = of_get_child_by_name(np, "regulators"); 302 302 if (!regs) { 303 303 dev_err(&pdev->dev, "regulator node not found\n"); 304 304 return NULL; ··· 379 379 ri = find_regulator_info(id); 380 380 if (!ri) { 381 381 dev_err(&pdev->dev, "invalid regulator ID specified\n"); 382 - err = -EINVAL; 383 - goto fail; 382 + return -EINVAL; 384 383 } 385 384 386 385 err = tps6586x_regulator_preinit(pdev->dev.parent, ri); 387 386 if (err) { 388 387 dev_err(&pdev->dev, 389 388 "regulator %d preinit failed, e %d\n", id, err); 390 - goto fail; 389 + return err; 391 390 } 392 391 393 392 config.dev = pdev->dev.parent; ··· 396 397 if (tps6586x_reg_matches) 397 398 config.of_node = tps6586x_reg_matches[id].of_node; 398 399 399 - rdev[id] = regulator_register(&ri->desc, &config); 400 + rdev[id] = devm_regulator_register(&pdev->dev, &ri->desc, 401 + &config); 400 402 if (IS_ERR(rdev[id])) { 401 403 dev_err(&pdev->dev, "failed to register regulator %s\n", 402 404 ri->desc.name); 403 - err = PTR_ERR(rdev[id]); 404 - goto fail; 405 + return PTR_ERR(rdev[id]); 405 406 } 406 407 407 408 if (reg_data) { ··· 410 411 if (err < 0) { 411 412 dev_err(&pdev->dev, 412 413 "Slew rate config failed, e %d\n", err); 413 - regulator_unregister(rdev[id]); 414 - goto fail; 414 + return err; 415 415 } 416 416 } 417 417 } 418 418 419 419 platform_set_drvdata(pdev, rdev); 420 - return 0; 421 - 422 - fail: 423 - while (--id >= 0) 424 - regulator_unregister(rdev[id]); 425 - return err; 426 - } 427 - 428 - static int tps6586x_regulator_remove(struct platform_device *pdev) 429 - { 430 - struct regulator_dev **rdev = platform_get_drvdata(pdev); 431 - int id = TPS6586X_ID_MAX_REGULATOR; 432 - 433 - while (--id >= 0) 434 - regulator_unregister(rdev[id]); 435 - 436 420 return 0; 437 421 } 438 422 ··· 425 443 .owner = THIS_MODULE, 426 444 }, 427 445 .probe = tps6586x_regulator_probe, 428 - .remove = tps6586x_regulator_remove, 429 446 }; 430 447 431 448 static int __init tps6586x_regulator_init(void)
+8 -25
drivers/regulator/tps65910-regulator.c
··· 481 481 482 482 /* multiplier 0 == 1 but 2,3 normal */ 483 483 if (!mult) 484 - mult=1; 484 + mult = 1; 485 485 486 486 if (sr) { 487 487 /* normalise to valid range */ ··· 685 685 case TPS65910_REG_VDD2: 686 686 mult = (selector / VDD1_2_NUM_VOLT_FINE) + 1; 687 687 volt = VDD1_2_MIN_VOLT + 688 - (selector % VDD1_2_NUM_VOLT_FINE) * VDD1_2_OFFSET; 688 + (selector % VDD1_2_NUM_VOLT_FINE) * VDD1_2_OFFSET; 689 689 break; 690 690 case TPS65911_REG_VDDCTRL: 691 691 volt = VDDCTRL_MIN_VOLT + (selector * VDDCTRL_OFFSET); ··· 703 703 struct tps65910_reg *pmic = rdev_get_drvdata(dev); 704 704 int step_mv = 0, id = rdev_get_id(dev); 705 705 706 - switch(id) { 706 + switch (id) { 707 707 case TPS65911_REG_LDO1: 708 708 case TPS65911_REG_LDO2: 709 709 case TPS65911_REG_LDO4: ··· 982 982 } 983 983 984 984 np = of_node_get(pdev->dev.parent->of_node); 985 - regulators = of_find_node_by_name(np, "regulators"); 985 + regulators = of_get_child_by_name(np, "regulators"); 986 986 if (!regulators) { 987 987 dev_err(&pdev->dev, "regulator node not found\n"); 988 988 return NULL; ··· 1074 1074 tps65910_reg_set_bits(pmic->mfd, TPS65910_DEVCTRL, 1075 1075 DEVCTRL_SR_CTL_I2C_SEL_MASK); 1076 1076 1077 - switch(tps65910_chip_id(tps65910)) { 1077 + switch (tps65910_chip_id(tps65910)) { 1078 1078 case TPS65910: 1079 1079 pmic->get_ctrl_reg = &tps65910_get_ctrl_register; 1080 1080 pmic->num_regulators = ARRAY_SIZE(tps65910_regs); ··· 1177 1177 if (tps65910_reg_matches) 1178 1178 config.of_node = tps65910_reg_matches[i].of_node; 1179 1179 1180 - rdev = regulator_register(&pmic->desc[i], &config); 1180 + rdev = devm_regulator_register(&pdev->dev, &pmic->desc[i], 1181 + &config); 1181 1182 if (IS_ERR(rdev)) { 1182 1183 dev_err(tps65910->dev, 1183 1184 "failed to register %s regulator\n", 1184 1185 pdev->name); 1185 - err = PTR_ERR(rdev); 1186 - goto err_unregister_regulator; 1186 + return PTR_ERR(rdev); 1187 1187 } 1188 1188 1189 1189 /* Save regulator for cleanup */ 1190 1190 pmic->rdev[i] = rdev; 1191 1191 } 1192 - return 0; 1193 - 1194 - err_unregister_regulator: 1195 - while (--i >= 0) 1196 - regulator_unregister(pmic->rdev[i]); 1197 - return err; 1198 - } 1199 - 1200 - static int tps65910_remove(struct platform_device *pdev) 1201 - { 1202 - struct tps65910_reg *pmic = platform_get_drvdata(pdev); 1203 - int i; 1204 - 1205 - for (i = 0; i < pmic->num_regulators; i++) 1206 - regulator_unregister(pmic->rdev[i]); 1207 - 1208 1192 return 0; 1209 1193 } 1210 1194 ··· 1228 1244 .owner = THIS_MODULE, 1229 1245 }, 1230 1246 .probe = tps65910_probe, 1231 - .remove = tps65910_remove, 1232 1247 .shutdown = tps65910_shutdown, 1233 1248 }; 1234 1249
+7 -26
drivers/regulator/tps65912-regulator.c
··· 119 119 }; 120 120 121 121 static const struct regulator_linear_range tps65912_ldo_ranges[] = { 122 - { .min_uV = 800000, .max_uV = 1600000, .min_sel = 0, .max_sel = 32, 123 - .uV_step = 25000 }, 124 - { .min_uV = 1650000, .max_uV = 3000000, .min_sel = 33, .max_sel = 60, 125 - .uV_step = 50000 }, 126 - { .min_uV = 3100000, .max_uV = 3300000, .min_sel = 61, .max_sel = 63, 127 - .uV_step = 100000 }, 122 + REGULATOR_LINEAR_RANGE(800000, 0, 32, 25000), 123 + REGULATOR_LINEAR_RANGE(1650000, 33, 60, 50000), 124 + REGULATOR_LINEAR_RANGE(3100000, 61, 63, 100000), 128 125 }; 129 126 130 127 static int tps65912_get_range(struct tps65912_reg *pmic, int id) ··· 458 461 struct regulator_dev *rdev; 459 462 struct tps65912_reg *pmic; 460 463 struct tps65912_board *pmic_plat_data; 461 - int i, err; 464 + int i; 462 465 463 466 pmic_plat_data = dev_get_platdata(tps65912->dev); 464 467 if (!pmic_plat_data) ··· 501 504 config.init_data = reg_data; 502 505 config.driver_data = pmic; 503 506 504 - rdev = regulator_register(&pmic->desc[i], &config); 507 + rdev = devm_regulator_register(&pdev->dev, &pmic->desc[i], 508 + &config); 505 509 if (IS_ERR(rdev)) { 506 510 dev_err(tps65912->dev, 507 511 "failed to register %s regulator\n", 508 512 pdev->name); 509 - err = PTR_ERR(rdev); 510 - goto err; 513 + return PTR_ERR(rdev); 511 514 } 512 515 513 516 /* Save regulator for cleanup */ 514 517 pmic->rdev[i] = rdev; 515 518 } 516 - return 0; 517 - 518 - err: 519 - while (--i >= 0) 520 - regulator_unregister(pmic->rdev[i]); 521 - return err; 522 - } 523 - 524 - static int tps65912_remove(struct platform_device *pdev) 525 - { 526 - struct tps65912_reg *tps65912_reg = platform_get_drvdata(pdev); 527 - int i; 528 - 529 - for (i = 0; i < TPS65912_NUM_REGULATOR; i++) 530 - regulator_unregister(tps65912_reg->rdev[i]); 531 519 return 0; 532 520 } 533 521 ··· 522 540 .owner = THIS_MODULE, 523 541 }, 524 542 .probe = tps65912_probe, 525 - .remove = tps65912_remove, 526 543 }; 527 544 528 545 static int __init tps65912_init(void)
+5 -25
drivers/regulator/tps80031-regulator.c
··· 719 719 if (ret < 0) { 720 720 dev_err(&pdev->dev, 721 721 "regulator config failed, e %d\n", ret); 722 - goto fail; 722 + return ret; 723 723 } 724 724 725 725 ret = tps80031_power_req_config(pdev->dev.parent, ··· 727 727 if (ret < 0) { 728 728 dev_err(&pdev->dev, 729 729 "pwr_req config failed, err %d\n", ret); 730 - goto fail; 730 + return ret; 731 731 } 732 732 } 733 - rdev = regulator_register(&ri->rinfo->desc, &config); 733 + rdev = devm_regulator_register(&pdev->dev, &ri->rinfo->desc, 734 + &config); 734 735 if (IS_ERR(rdev)) { 735 736 dev_err(&pdev->dev, 736 737 "register regulator failed %s\n", 737 738 ri->rinfo->desc.name); 738 - ret = PTR_ERR(rdev); 739 - goto fail; 739 + return PTR_ERR(rdev); 740 740 } 741 741 ri->rdev = rdev; 742 742 } 743 743 744 744 platform_set_drvdata(pdev, pmic); 745 - return 0; 746 - fail: 747 - while (--num >= 0) { 748 - ri = &pmic[num]; 749 - regulator_unregister(ri->rdev); 750 - } 751 - return ret; 752 - } 753 - 754 - static int tps80031_regulator_remove(struct platform_device *pdev) 755 - { 756 - struct tps80031_regulator *pmic = platform_get_drvdata(pdev); 757 - struct tps80031_regulator *ri = NULL; 758 - int num; 759 - 760 - for (num = 0; num < TPS80031_REGULATOR_MAX; ++num) { 761 - ri = &pmic[num]; 762 - regulator_unregister(ri->rdev); 763 - } 764 745 return 0; 765 746 } 766 747 ··· 751 770 .owner = THIS_MODULE, 752 771 }, 753 772 .probe = tps80031_regulator_probe, 754 - .remove = tps80031_regulator_remove, 755 773 }; 756 774 757 775 static int __init tps80031_regulator_init(void)
+1 -2
drivers/regulator/twl-regulator.c
··· 1188 1188 config.driver_data = info; 1189 1189 config.of_node = pdev->dev.of_node; 1190 1190 1191 - rdev = regulator_register(&info->desc, &config); 1191 + rdev = devm_regulator_register(&pdev->dev, &info->desc, &config); 1192 1192 if (IS_ERR(rdev)) { 1193 1193 dev_err(&pdev->dev, "can't register %s, %ld\n", 1194 1194 info->desc.name, PTR_ERR(rdev)); ··· 1217 1217 struct regulator_dev *rdev = platform_get_drvdata(pdev); 1218 1218 struct twlreg_info *info = rdev->reg_data; 1219 1219 1220 - regulator_unregister(rdev); 1221 1220 kfree(info); 1222 1221 return 0; 1223 1222 }
+1 -2
drivers/regulator/vexpress.c
··· 96 96 config.driver_data = reg; 97 97 config.of_node = pdev->dev.of_node; 98 98 99 - reg->regdev = regulator_register(&reg->desc, &config); 99 + reg->regdev = devm_regulator_register(&pdev->dev, &reg->desc, &config); 100 100 if (IS_ERR(reg->regdev)) { 101 101 err = PTR_ERR(reg->regdev); 102 102 goto error_regulator_register; ··· 119 119 struct vexpress_regulator *reg = platform_get_drvdata(pdev); 120 120 121 121 vexpress_config_func_put(reg->func); 122 - regulator_unregister(reg->regdev); 123 122 124 123 return 0; 125 124 }
+33 -85
drivers/regulator/wm831x-dcdc.c
··· 387 387 * Set up DVS control. We just log errors since we can still run 388 388 * (with reduced performance) if we fail. 389 389 */ 390 - static void wm831x_buckv_dvs_init(struct wm831x_dcdc *dcdc, 391 - struct wm831x_buckv_pdata *pdata) 390 + static void wm831x_buckv_dvs_init(struct platform_device *pdev, 391 + struct wm831x_dcdc *dcdc, 392 + struct wm831x_buckv_pdata *pdata) 392 393 { 393 394 struct wm831x *wm831x = dcdc->wm831x; 394 395 int ret; ··· 403 402 */ 404 403 dcdc->dvs_gpio_state = pdata->dvs_init_state; 405 404 406 - ret = gpio_request_one(pdata->dvs_gpio, 407 - dcdc->dvs_gpio_state ? GPIOF_INIT_HIGH : 0, 408 - "DCDC DVS"); 405 + ret = devm_gpio_request_one(&pdev->dev, pdata->dvs_gpio, 406 + dcdc->dvs_gpio_state ? GPIOF_INIT_HIGH : 0, 407 + "DCDC DVS"); 409 408 if (ret < 0) { 410 409 dev_err(wm831x->dev, "Failed to get %s DVS GPIO: %d\n", 411 410 dcdc->name, ret); ··· 514 513 dcdc->dvs_vsel = ret & WM831X_DC1_DVS_VSEL_MASK; 515 514 516 515 if (pdata && pdata->dcdc[id]) 517 - wm831x_buckv_dvs_init(dcdc, pdata->dcdc[id]->driver_data); 516 + wm831x_buckv_dvs_init(pdev, dcdc, 517 + pdata->dcdc[id]->driver_data); 518 518 519 519 config.dev = pdev->dev.parent; 520 520 if (pdata) ··· 523 521 config.driver_data = dcdc; 524 522 config.regmap = wm831x->regmap; 525 523 526 - dcdc->regulator = regulator_register(&dcdc->desc, &config); 524 + dcdc->regulator = devm_regulator_register(&pdev->dev, &dcdc->desc, 525 + &config); 527 526 if (IS_ERR(dcdc->regulator)) { 528 527 ret = PTR_ERR(dcdc->regulator); 529 528 dev_err(wm831x->dev, "Failed to register DCDC%d: %d\n", ··· 533 530 } 534 531 535 532 irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV")); 536 - ret = request_threaded_irq(irq, NULL, wm831x_dcdc_uv_irq, 537 - IRQF_TRIGGER_RISING, dcdc->name, dcdc); 533 + ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, 534 + wm831x_dcdc_uv_irq, 535 + IRQF_TRIGGER_RISING, dcdc->name, dcdc); 538 536 if (ret != 0) { 539 537 dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", 540 538 irq, ret); 541 - goto err_regulator; 539 + goto err; 542 540 } 543 541 544 542 irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "HC")); 545 - ret = request_threaded_irq(irq, NULL, wm831x_dcdc_oc_irq, 546 - IRQF_TRIGGER_RISING, dcdc->name, dcdc); 543 + ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, 544 + wm831x_dcdc_oc_irq, 545 + IRQF_TRIGGER_RISING, dcdc->name, dcdc); 547 546 if (ret != 0) { 548 547 dev_err(&pdev->dev, "Failed to request HC IRQ %d: %d\n", 549 548 irq, ret); 550 - goto err_uv; 549 + goto err; 551 550 } 552 551 553 552 platform_set_drvdata(pdev, dcdc); 554 553 555 554 return 0; 556 555 557 - err_uv: 558 - free_irq(wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV")), 559 - dcdc); 560 - err_regulator: 561 - regulator_unregister(dcdc->regulator); 562 556 err: 563 - if (dcdc->dvs_gpio) 564 - gpio_free(dcdc->dvs_gpio); 565 557 return ret; 566 - } 567 - 568 - static int wm831x_buckv_remove(struct platform_device *pdev) 569 - { 570 - struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev); 571 - struct wm831x *wm831x = dcdc->wm831x; 572 - 573 - free_irq(wm831x_irq(wm831x, platform_get_irq_byname(pdev, "HC")), 574 - dcdc); 575 - free_irq(wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV")), 576 - dcdc); 577 - regulator_unregister(dcdc->regulator); 578 - if (dcdc->dvs_gpio) 579 - gpio_free(dcdc->dvs_gpio); 580 - 581 - return 0; 582 558 } 583 559 584 560 static struct platform_driver wm831x_buckv_driver = { 585 561 .probe = wm831x_buckv_probe, 586 - .remove = wm831x_buckv_remove, 587 562 .driver = { 588 563 .name = "wm831x-buckv", 589 564 .owner = THIS_MODULE, ··· 662 681 config.driver_data = dcdc; 663 682 config.regmap = wm831x->regmap; 664 683 665 - dcdc->regulator = regulator_register(&dcdc->desc, &config); 684 + dcdc->regulator = devm_regulator_register(&pdev->dev, &dcdc->desc, 685 + &config); 666 686 if (IS_ERR(dcdc->regulator)) { 667 687 ret = PTR_ERR(dcdc->regulator); 668 688 dev_err(wm831x->dev, "Failed to register DCDC%d: %d\n", ··· 672 690 } 673 691 674 692 irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV")); 675 - ret = request_threaded_irq(irq, NULL, wm831x_dcdc_uv_irq, 676 - IRQF_TRIGGER_RISING, dcdc->name, dcdc); 693 + ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, 694 + wm831x_dcdc_uv_irq, 695 + IRQF_TRIGGER_RISING, dcdc->name, dcdc); 677 696 if (ret != 0) { 678 697 dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", 679 698 irq, ret); 680 - goto err_regulator; 699 + goto err; 681 700 } 682 701 683 702 platform_set_drvdata(pdev, dcdc); 684 703 685 704 return 0; 686 705 687 - err_regulator: 688 - regulator_unregister(dcdc->regulator); 689 706 err: 690 707 return ret; 691 708 } 692 709 693 - static int wm831x_buckp_remove(struct platform_device *pdev) 694 - { 695 - struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev); 696 - 697 - free_irq(wm831x_irq(dcdc->wm831x, platform_get_irq_byname(pdev, "UV")), 698 - dcdc); 699 - regulator_unregister(dcdc->regulator); 700 - 701 - return 0; 702 - } 703 - 704 710 static struct platform_driver wm831x_buckp_driver = { 705 711 .probe = wm831x_buckp_probe, 706 - .remove = wm831x_buckp_remove, 707 712 .driver = { 708 713 .name = "wm831x-buckp", 709 714 .owner = THIS_MODULE, ··· 782 813 config.driver_data = dcdc; 783 814 config.regmap = wm831x->regmap; 784 815 785 - dcdc->regulator = regulator_register(&dcdc->desc, &config); 816 + dcdc->regulator = devm_regulator_register(&pdev->dev, &dcdc->desc, 817 + &config); 786 818 if (IS_ERR(dcdc->regulator)) { 787 819 ret = PTR_ERR(dcdc->regulator); 788 820 dev_err(wm831x->dev, "Failed to register DCDC%d: %d\n", ··· 792 822 } 793 823 794 824 irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV")); 795 - ret = request_threaded_irq(irq, NULL, wm831x_dcdc_uv_irq, 796 - IRQF_TRIGGER_RISING, dcdc->name, 797 - dcdc); 825 + ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, 826 + wm831x_dcdc_uv_irq, 827 + IRQF_TRIGGER_RISING, dcdc->name, 828 + dcdc); 798 829 if (ret != 0) { 799 830 dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", 800 831 irq, ret); 801 - goto err_regulator; 832 + goto err; 802 833 } 803 834 804 835 platform_set_drvdata(pdev, dcdc); 805 836 806 837 return 0; 807 838 808 - err_regulator: 809 - regulator_unregister(dcdc->regulator); 810 839 err: 811 840 return ret; 812 841 } 813 842 814 - static int wm831x_boostp_remove(struct platform_device *pdev) 815 - { 816 - struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev); 817 - 818 - free_irq(wm831x_irq(dcdc->wm831x, platform_get_irq_byname(pdev, "UV")), 819 - dcdc); 820 - regulator_unregister(dcdc->regulator); 821 - 822 - return 0; 823 - } 824 - 825 843 static struct platform_driver wm831x_boostp_driver = { 826 844 .probe = wm831x_boostp_probe, 827 - .remove = wm831x_boostp_remove, 828 845 .driver = { 829 846 .name = "wm831x-boostp", 830 847 .owner = THIS_MODULE, ··· 871 914 config.driver_data = dcdc; 872 915 config.regmap = wm831x->regmap; 873 916 874 - dcdc->regulator = regulator_register(&dcdc->desc, &config); 917 + dcdc->regulator = devm_regulator_register(&pdev->dev, &dcdc->desc, 918 + &config); 875 919 if (IS_ERR(dcdc->regulator)) { 876 920 ret = PTR_ERR(dcdc->regulator); 877 921 dev_err(wm831x->dev, "Failed to register EPE%d: %d\n", ··· 888 930 return ret; 889 931 } 890 932 891 - static int wm831x_epe_remove(struct platform_device *pdev) 892 - { 893 - struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev); 894 - 895 - regulator_unregister(dcdc->regulator); 896 - 897 - return 0; 898 - } 899 - 900 933 static struct platform_driver wm831x_epe_driver = { 901 934 .probe = wm831x_epe_probe, 902 - .remove = wm831x_epe_remove, 903 935 .driver = { 904 936 .name = "wm831x-epe", 905 937 .owner = THIS_MODULE,
+7 -18
drivers/regulator/wm831x-isink.c
··· 194 194 config.init_data = pdata->isink[id]; 195 195 config.driver_data = isink; 196 196 197 - isink->regulator = regulator_register(&isink->desc, &config); 197 + isink->regulator = devm_regulator_register(&pdev->dev, &isink->desc, 198 + &config); 198 199 if (IS_ERR(isink->regulator)) { 199 200 ret = PTR_ERR(isink->regulator); 200 201 dev_err(wm831x->dev, "Failed to register ISINK%d: %d\n", ··· 204 203 } 205 204 206 205 irq = wm831x_irq(wm831x, platform_get_irq(pdev, 0)); 207 - ret = request_threaded_irq(irq, NULL, wm831x_isink_irq, 208 - IRQF_TRIGGER_RISING, isink->name, isink); 206 + ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, 207 + wm831x_isink_irq, 208 + IRQF_TRIGGER_RISING, isink->name, 209 + isink); 209 210 if (ret != 0) { 210 211 dev_err(&pdev->dev, "Failed to request ISINK IRQ %d: %d\n", 211 212 irq, ret); 212 - goto err_regulator; 213 + goto err; 213 214 } 214 215 215 216 platform_set_drvdata(pdev, isink); 216 217 217 218 return 0; 218 219 219 - err_regulator: 220 - regulator_unregister(isink->regulator); 221 220 err: 222 221 return ret; 223 222 } 224 223 225 - static int wm831x_isink_remove(struct platform_device *pdev) 226 - { 227 - struct wm831x_isink *isink = platform_get_drvdata(pdev); 228 - 229 - free_irq(wm831x_irq(isink->wm831x, platform_get_irq(pdev, 0)), isink); 230 - 231 - regulator_unregister(isink->regulator); 232 - 233 - return 0; 234 - } 235 - 236 224 static struct platform_driver wm831x_isink_driver = { 237 225 .probe = wm831x_isink_probe, 238 - .remove = wm831x_isink_remove, 239 226 .driver = { 240 227 .name = "wm831x-isink", 241 228 .owner = THIS_MODULE,
+19 -56
drivers/regulator/wm831x-ldo.c
··· 63 63 */ 64 64 65 65 static const struct regulator_linear_range wm831x_gp_ldo_ranges[] = { 66 - { .min_uV = 900000, .max_uV = 1600000, .min_sel = 0, .max_sel = 14, 67 - .uV_step = 50000 }, 68 - { .min_uV = 1700000, .max_uV = 3300000, .min_sel = 15, .max_sel = 31, 69 - .uV_step = 100000 }, 66 + REGULATOR_LINEAR_RANGE(900000, 0, 14, 50000), 67 + REGULATOR_LINEAR_RANGE(1700000, 15, 31, 100000), 70 68 }; 71 69 72 70 static int wm831x_gp_ldo_set_suspend_voltage(struct regulator_dev *rdev, ··· 277 279 config.driver_data = ldo; 278 280 config.regmap = wm831x->regmap; 279 281 280 - ldo->regulator = regulator_register(&ldo->desc, &config); 282 + ldo->regulator = devm_regulator_register(&pdev->dev, &ldo->desc, 283 + &config); 281 284 if (IS_ERR(ldo->regulator)) { 282 285 ret = PTR_ERR(ldo->regulator); 283 286 dev_err(wm831x->dev, "Failed to register LDO%d: %d\n", ··· 287 288 } 288 289 289 290 irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV")); 290 - ret = request_threaded_irq(irq, NULL, wm831x_ldo_uv_irq, 291 - IRQF_TRIGGER_RISING, ldo->name, 292 - ldo); 291 + ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, 292 + wm831x_ldo_uv_irq, 293 + IRQF_TRIGGER_RISING, ldo->name, 294 + ldo); 293 295 if (ret != 0) { 294 296 dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", 295 297 irq, ret); 296 - goto err_regulator; 298 + goto err; 297 299 } 298 300 299 301 platform_set_drvdata(pdev, ldo); 300 302 301 303 return 0; 302 304 303 - err_regulator: 304 - regulator_unregister(ldo->regulator); 305 305 err: 306 306 return ret; 307 307 } 308 308 309 - static int wm831x_gp_ldo_remove(struct platform_device *pdev) 310 - { 311 - struct wm831x_ldo *ldo = platform_get_drvdata(pdev); 312 - 313 - free_irq(wm831x_irq(ldo->wm831x, 314 - platform_get_irq_byname(pdev, "UV")), ldo); 315 - regulator_unregister(ldo->regulator); 316 - 317 - return 0; 318 - } 319 - 320 309 static struct platform_driver wm831x_gp_ldo_driver = { 321 310 .probe = wm831x_gp_ldo_probe, 322 - .remove = wm831x_gp_ldo_remove, 323 311 .driver = { 324 312 .name = "wm831x-ldo", 325 313 .owner = THIS_MODULE, ··· 318 332 */ 319 333 320 334 static const struct regulator_linear_range wm831x_aldo_ranges[] = { 321 - { .min_uV = 1000000, .max_uV = 1600000, .min_sel = 0, .max_sel = 12, 322 - .uV_step = 50000 }, 323 - { .min_uV = 1700000, .max_uV = 3500000, .min_sel = 13, .max_sel = 31, 324 - .uV_step = 100000 }, 335 + REGULATOR_LINEAR_RANGE(1000000, 0, 12, 50000), 336 + REGULATOR_LINEAR_RANGE(1700000, 13, 31, 100000), 325 337 }; 326 338 327 339 static int wm831x_aldo_set_suspend_voltage(struct regulator_dev *rdev, ··· 489 505 config.driver_data = ldo; 490 506 config.regmap = wm831x->regmap; 491 507 492 - ldo->regulator = regulator_register(&ldo->desc, &config); 508 + ldo->regulator = devm_regulator_register(&pdev->dev, &ldo->desc, 509 + &config); 493 510 if (IS_ERR(ldo->regulator)) { 494 511 ret = PTR_ERR(ldo->regulator); 495 512 dev_err(wm831x->dev, "Failed to register LDO%d: %d\n", ··· 499 514 } 500 515 501 516 irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV")); 502 - ret = request_threaded_irq(irq, NULL, wm831x_ldo_uv_irq, 503 - IRQF_TRIGGER_RISING, ldo->name, ldo); 517 + ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, 518 + wm831x_ldo_uv_irq, 519 + IRQF_TRIGGER_RISING, ldo->name, ldo); 504 520 if (ret != 0) { 505 521 dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", 506 522 irq, ret); 507 - goto err_regulator; 523 + goto err; 508 524 } 509 525 510 526 platform_set_drvdata(pdev, ldo); 511 527 512 528 return 0; 513 529 514 - err_regulator: 515 - regulator_unregister(ldo->regulator); 516 530 err: 517 531 return ret; 518 532 } 519 533 520 - static int wm831x_aldo_remove(struct platform_device *pdev) 521 - { 522 - struct wm831x_ldo *ldo = platform_get_drvdata(pdev); 523 - 524 - free_irq(wm831x_irq(ldo->wm831x, platform_get_irq_byname(pdev, "UV")), 525 - ldo); 526 - regulator_unregister(ldo->regulator); 527 - 528 - return 0; 529 - } 530 - 531 534 static struct platform_driver wm831x_aldo_driver = { 532 535 .probe = wm831x_aldo_probe, 533 - .remove = wm831x_aldo_remove, 534 536 .driver = { 535 537 .name = "wm831x-aldo", 536 538 .owner = THIS_MODULE, ··· 635 663 config.driver_data = ldo; 636 664 config.regmap = wm831x->regmap; 637 665 638 - ldo->regulator = regulator_register(&ldo->desc, &config); 666 + ldo->regulator = devm_regulator_register(&pdev->dev, &ldo->desc, 667 + &config); 639 668 if (IS_ERR(ldo->regulator)) { 640 669 ret = PTR_ERR(ldo->regulator); 641 670 dev_err(wm831x->dev, "Failed to register LDO%d: %d\n", ··· 652 679 return ret; 653 680 } 654 681 655 - static int wm831x_alive_ldo_remove(struct platform_device *pdev) 656 - { 657 - struct wm831x_ldo *ldo = platform_get_drvdata(pdev); 658 - 659 - regulator_unregister(ldo->regulator); 660 - 661 - return 0; 662 - } 663 - 664 682 static struct platform_driver wm831x_alive_ldo_driver = { 665 683 .probe = wm831x_alive_ldo_probe, 666 - .remove = wm831x_alive_ldo_remove, 667 684 .driver = { 668 685 .name = "wm831x-alive-ldo", 669 686 .owner = THIS_MODULE,
+4 -8
drivers/regulator/wm8350-regulator.c
··· 543 543 } 544 544 545 545 static const struct regulator_linear_range wm8350_ldo_ranges[] = { 546 - { .min_uV = 900000, .max_uV = 1650000, .min_sel = 0, .max_sel = 15, 547 - .uV_step = 50000 }, 548 - { .min_uV = 1800000, .max_uV = 3300000, .min_sel = 16, .max_sel = 31, 549 - .uV_step = 100000 }, 546 + REGULATOR_LINEAR_RANGE(900000, 0, 15, 50000), 547 + REGULATOR_LINEAR_RANGE(1800000, 16, 31, 100000), 550 548 }; 551 549 552 550 static int wm8350_ldo_set_suspend_voltage(struct regulator_dev *rdev, int uV) ··· 1204 1206 config.regmap = wm8350->regmap; 1205 1207 1206 1208 /* register regulator */ 1207 - rdev = regulator_register(&wm8350_reg[pdev->id], &config); 1209 + rdev = devm_regulator_register(&pdev->dev, &wm8350_reg[pdev->id], 1210 + &config); 1208 1211 if (IS_ERR(rdev)) { 1209 1212 dev_err(&pdev->dev, "failed to register %s\n", 1210 1213 wm8350_reg[pdev->id].name); ··· 1216 1217 ret = wm8350_register_irq(wm8350, wm8350_reg[pdev->id].irq, 1217 1218 pmic_uv_handler, 0, "UV", rdev); 1218 1219 if (ret < 0) { 1219 - regulator_unregister(rdev); 1220 1220 dev_err(&pdev->dev, "failed to register regulator %s IRQ\n", 1221 1221 wm8350_reg[pdev->id].name); 1222 1222 return ret; ··· 1230 1232 struct wm8350 *wm8350 = rdev_get_drvdata(rdev); 1231 1233 1232 1234 wm8350_free_irq(wm8350, wm8350_reg[pdev->id].irq, rdev); 1233 - 1234 - regulator_unregister(rdev); 1235 1235 1236 1236 return 0; 1237 1237 }
+4 -15
drivers/regulator/wm8400-regulator.c
··· 20 20 #include <linux/mfd/wm8400-private.h> 21 21 22 22 static const struct regulator_linear_range wm8400_ldo_ranges[] = { 23 - { .min_uV = 900000, .max_uV = 1600000, .min_sel = 0, .max_sel = 14, 24 - .uV_step = 50000 }, 25 - { .min_uV = 1700000, .max_uV = 3300000, .min_sel = 15, .max_sel = 31, 26 - .uV_step = 100000 }, 23 + REGULATOR_LINEAR_RANGE(900000, 0, 14, 50000), 24 + REGULATOR_LINEAR_RANGE(1700000, 15, 31, 100000), 27 25 }; 28 26 29 27 static struct regulator_ops wm8400_ldo_ops = { ··· 217 219 config.driver_data = wm8400; 218 220 config.regmap = wm8400->regmap; 219 221 220 - rdev = regulator_register(&regulators[pdev->id], &config); 222 + rdev = devm_regulator_register(&pdev->dev, &regulators[pdev->id], 223 + &config); 221 224 if (IS_ERR(rdev)) 222 225 return PTR_ERR(rdev); 223 226 224 227 platform_set_drvdata(pdev, rdev); 225 - 226 - return 0; 227 - } 228 - 229 - static int wm8400_regulator_remove(struct platform_device *pdev) 230 - { 231 - struct regulator_dev *rdev = platform_get_drvdata(pdev); 232 - 233 - regulator_unregister(rdev); 234 228 235 229 return 0; 236 230 } ··· 232 242 .name = "wm8400-regulator", 233 243 }, 234 244 .probe = wm8400_regulator_probe, 235 - .remove = wm8400_regulator_remove, 236 245 }; 237 246 238 247 /**
+3 -11
drivers/regulator/wm8994-regulator.c
··· 165 165 ldo->init_data = *pdata->ldo[id].init_data; 166 166 } 167 167 168 - ldo->regulator = regulator_register(&wm8994_ldo_desc[id], &config); 168 + ldo->regulator = devm_regulator_register(&pdev->dev, 169 + &wm8994_ldo_desc[id], 170 + &config); 169 171 if (IS_ERR(ldo->regulator)) { 170 172 ret = PTR_ERR(ldo->regulator); 171 173 dev_err(wm8994->dev, "Failed to register LDO%d: %d\n", ··· 183 181 return ret; 184 182 } 185 183 186 - static int wm8994_ldo_remove(struct platform_device *pdev) 187 - { 188 - struct wm8994_ldo *ldo = platform_get_drvdata(pdev); 189 - 190 - regulator_unregister(ldo->regulator); 191 - 192 - return 0; 193 - } 194 - 195 184 static struct platform_driver wm8994_ldo_driver = { 196 185 .probe = wm8994_ldo_probe, 197 - .remove = wm8994_ldo_remove, 198 186 .driver = { 199 187 .name = "wm8994-ldo", 200 188 .owner = THIS_MODULE,
+6
include/linux/mfd/core.h
··· 59 59 * pm_runtime_no_callbacks(). 60 60 */ 61 61 bool pm_runtime_no_callbacks; 62 + 63 + /* A list of regulator supplies that should be mapped to the MFD 64 + * device rather than the child device when requested 65 + */ 66 + const char **parent_supplies; 67 + int num_parent_supplies; 62 68 }; 63 69 64 70 /*
+79
include/linux/regulator/consumer.h
··· 146 146 void regulator_put(struct regulator *regulator); 147 147 void devm_regulator_put(struct regulator *regulator); 148 148 149 + int regulator_register_supply_alias(struct device *dev, const char *id, 150 + struct device *alias_dev, 151 + const char *alias_id); 152 + void regulator_unregister_supply_alias(struct device *dev, const char *id); 153 + 154 + int regulator_bulk_register_supply_alias(struct device *dev, const char **id, 155 + struct device *alias_dev, 156 + const char **alias_id, int num_id); 157 + void regulator_bulk_unregister_supply_alias(struct device *dev, 158 + const char **id, int num_id); 159 + 160 + int devm_regulator_register_supply_alias(struct device *dev, const char *id, 161 + struct device *alias_dev, 162 + const char *alias_id); 163 + void devm_regulator_unregister_supply_alias(struct device *dev, 164 + const char *id); 165 + 166 + int devm_regulator_bulk_register_supply_alias(struct device *dev, 167 + const char **id, 168 + struct device *alias_dev, 169 + const char **alias_id, 170 + int num_id); 171 + void devm_regulator_bulk_unregister_supply_alias(struct device *dev, 172 + const char **id, 173 + int num_id); 174 + 149 175 /* regulator output control and status */ 150 176 int __must_check regulator_enable(struct regulator *regulator); 151 177 int regulator_disable(struct regulator *regulator); ··· 273 247 } 274 248 275 249 static inline void devm_regulator_put(struct regulator *regulator) 250 + { 251 + } 252 + 253 + static inline int regulator_register_supply_alias(struct device *dev, 254 + const char *id, 255 + struct device *alias_dev, 256 + const char *alias_id) 257 + { 258 + return 0; 259 + } 260 + 261 + static inline void regulator_unregister_supply_alias(struct device *dev, 262 + const char *id) 263 + { 264 + } 265 + 266 + static inline int regulator_bulk_register_supply_alias(struct device *dev, 267 + const char **id, 268 + struct device *alias_dev, 269 + const char **alias_id, 270 + int num_id) 271 + { 272 + return 0; 273 + } 274 + 275 + static inline void regulator_bulk_unregister_supply_alias(struct device *dev, 276 + const char **id, 277 + int num_id) 278 + { 279 + } 280 + 281 + static inline int devm_regulator_register_supply_alias(struct device *dev, 282 + const char *id, 283 + struct device *alias_dev, 284 + const char *alias_id) 285 + { 286 + return 0; 287 + } 288 + 289 + static inline void devm_regulator_unregister_supply_alias(struct device *dev, 290 + const char *id) 291 + { 292 + } 293 + 294 + static inline int devm_regulator_bulk_register_supply_alias( 295 + struct device *dev, const char **id, struct device *alias_dev, 296 + const char **alias_id, int num_id) 297 + { 298 + return 0; 299 + } 300 + 301 + static inline void devm_regulator_bulk_unregister_supply_alias( 302 + struct device *dev, const char **id, int num_id) 276 303 { 277 304 } 278 305
+16 -2
include/linux/regulator/driver.h
··· 46 46 * regulator_list_linear_range(). 47 47 * 48 48 * @min_uV: Lowest voltage in range 49 - * @max_uV: Highest voltage in range 50 49 * @min_sel: Lowest selector for range 51 50 * @max_sel: Highest selector for range 52 51 * @uV_step: Step size 53 52 */ 54 53 struct regulator_linear_range { 55 54 unsigned int min_uV; 56 - unsigned int max_uV; 57 55 unsigned int min_sel; 58 56 unsigned int max_sel; 59 57 unsigned int uV_step; 60 58 }; 59 + 60 + /* Initialize struct regulator_linear_range */ 61 + #define REGULATOR_LINEAR_RANGE(_min_uV, _min_sel, _max_sel, _step_uV) \ 62 + { \ 63 + .min_uV = _min_uV, \ 64 + .min_sel = _min_sel, \ 65 + .max_sel = _max_sel, \ 66 + .uV_step = _step_uV, \ 67 + } 61 68 62 69 /** 63 70 * struct regulator_ops - regulator operations. ··· 216 209 * @min_uV: Voltage given by the lowest selector (if linear mapping) 217 210 * @uV_step: Voltage increase with each selector (if linear mapping) 218 211 * @linear_min_sel: Minimal selector for starting linear mapping 212 + * @fixed_uV: Fixed voltage of rails. 219 213 * @ramp_delay: Time to settle down after voltage change (unit: uV/us) 220 214 * @volt_table: Voltage mapping table (if table based mapping) 221 215 * ··· 249 241 unsigned int min_uV; 250 242 unsigned int uV_step; 251 243 unsigned int linear_min_sel; 244 + int fixed_uV; 252 245 unsigned int ramp_delay; 253 246 254 247 const struct regulator_linear_range *linear_ranges; ··· 345 336 struct regulator_dev * 346 337 regulator_register(const struct regulator_desc *regulator_desc, 347 338 const struct regulator_config *config); 339 + struct regulator_dev * 340 + devm_regulator_register(struct device *dev, 341 + const struct regulator_desc *regulator_desc, 342 + const struct regulator_config *config); 348 343 void regulator_unregister(struct regulator_dev *rdev); 344 + void devm_regulator_unregister(struct device *dev, struct regulator_dev *rdev); 349 345 350 346 int regulator_notifier_call_chain(struct regulator_dev *rdev, 351 347 unsigned long event, void *data);
+2 -5
include/linux/regulator/machine.h
··· 95 95 * @initial_state: Suspend state to set by default. 96 96 * @initial_mode: Mode to set at startup. 97 97 * @ramp_delay: Time to settle down after voltage change (unit: uV/us) 98 + * @enable_time: Turn-on time of the rails (unit: microseconds) 98 99 */ 99 100 struct regulation_constraints { 100 101 ··· 130 129 unsigned int initial_mode; 131 130 132 131 unsigned int ramp_delay; 132 + unsigned int enable_time; 133 133 134 134 /* constraint flags */ 135 135 unsigned always_on:1; /* regulator never off when system is on */ ··· 195 193 196 194 #ifdef CONFIG_REGULATOR 197 195 void regulator_has_full_constraints(void); 198 - void regulator_use_dummy_regulator(void); 199 196 #else 200 197 static inline void regulator_has_full_constraints(void) 201 - { 202 - } 203 - 204 - static inline void regulator_use_dummy_regulator(void) 205 198 { 206 199 } 207 200 #endif