History

Merge branch 'regulator-5.2' into regulator-next

Mark Brown committed 7 years ago

Commit e2a23af2 parents c7b5128 498209489 files · +1323 −2770Browse files

Unified · Split

89 files
  1. Documentation/devicetree/bindings/regulator/gpio-regulator.txt +22 −8
  2. Documentation/devicetree/bindings/regulator/st,stm32mp1-pwr-reg.txt +43 −0
  3. drivers/mfd/wm831x-core.c +1 −1
  4. drivers/mfd/wm8400-core.c +0 −6
  5. drivers/regulator/88pm800.c +1 −17
  6. drivers/regulator/88pm8607.c +9 −34
  7. drivers/regulator/Kconfig +10 −1
  8. drivers/regulator/Makefile +1 −0
  9. drivers/regulator/ab3100.c +12 −33
  10. drivers/regulator/ab8500-ext.c +14 −35
  11. drivers/regulator/ab8500.c +9 −11
  12. drivers/regulator/act8865-regulator.c +21 −126
  13. drivers/regulator/anatop-regulator.c +27 −36
  14. drivers/regulator/arizona-ldo1.c +7 −12
  15. drivers/regulator/arizona-micsupp.c +7 −12
  16. drivers/regulator/as3711-regulator.c +7 −30
  17. drivers/regulator/as3722-regulator.c +86 −201
  18. drivers/regulator/axp20x-regulator.c +8 −15
  19. drivers/regulator/bcm590xx-regulator.c +2 −103
  20. drivers/regulator/bd718x7-regulator.c +2 −2
  21. drivers/regulator/core.c +9 −6
  22. drivers/regulator/cpcap-regulator.c +4 −11
  23. drivers/regulator/da903x.c +6 −10
  24. drivers/regulator/da9052-regulator.c +13 −42
  25. drivers/regulator/da9055-regulator.c +15 −74
  26. drivers/regulator/da9062-regulator.c +39 −107
  27. drivers/regulator/da9063-regulator.c +40 −94
  28. drivers/regulator/da9210-regulator.c +4 −19
  29. drivers/regulator/da9210-regulator.h +1 −16
  30. drivers/regulator/da9211-regulator.c +9 −15
  31. drivers/regulator/da9211-regulator.h +1 −10
  32. drivers/regulator/db8500-prcmu.c +44 −99
  33. drivers/regulator/dbx500-prcmu.h +0 −4
  34. drivers/regulator/fan53555.c +27 −33
  35. drivers/regulator/gpio-regulator.c +6 −16
  36. drivers/regulator/hi6421-regulator.c +88 −144
  37. drivers/regulator/hi6421v530-regulator.c +11 −15
  38. drivers/regulator/hi655x-regulator.c +13 −24
  39. drivers/regulator/lm363x-regulator.c +4 −4
  40. drivers/regulator/lp8755.c +12 −3
  41. drivers/regulator/lp87565-regulator.c +8 −41
  42. drivers/regulator/ltc3589.c +89 −180
  43. drivers/regulator/ltc3676.c +8 −2
  44. drivers/regulator/max14577-regulator.c +0 −55
  45. drivers/regulator/max77650-regulator.c +1 −1
  46. drivers/regulator/max8925-regulator.c +9 −67
  47. drivers/regulator/max8998.c +59 −241
  48. drivers/regulator/mcp16502.c +22 −45
  49. drivers/regulator/mt6311-regulator.c +4 −13
  50. drivers/regulator/mt6311-regulator.h +1 −9
  51. drivers/regulator/mt6323-regulator.c +14 −18
  52. drivers/regulator/mt6380-regulator.c +8 −17
  53. drivers/regulator/mt6397-regulator.c +12 −21
  54. drivers/regulator/of_regulator.c +3 −2
  55. drivers/regulator/palmas-regulator.c +0 −12
  56. drivers/regulator/pv88060-regulator.c +8 −14
  57. drivers/regulator/pv88060-regulator.h +1 −10
  58. drivers/regulator/pv88080-regulator.c +8 −14
  59. drivers/regulator/pv88080-regulator.h +1 −10
  60. drivers/regulator/pv88090-regulator.c +8 −14
  61. drivers/regulator/pv88090-regulator.h +1 −10
  62. drivers/regulator/rc5t583-regulator.c +3 −22
  63. drivers/regulator/rn5t618-regulator.c +4 −4
  64. drivers/regulator/s2mpa01.c +10 −31
  65. drivers/regulator/sc2731-regulator.c +1 −1
  66. drivers/regulator/sky81452-regulator.c +7 −19
  67. drivers/regulator/stm32-pwr.c +186 −0
  68. drivers/regulator/sy8106a-regulator.c +13 −27
  69. drivers/regulator/tps6507x-regulator.c +20 −93
  70. drivers/regulator/tps65086-regulator.c +2 −2
  71. drivers/regulator/tps65132-regulator.c +13 −16
  72. drivers/regulator/tps65217-regulator.c +3 −4
  73. drivers/regulator/tps65218-regulator.c +23 −33
  74. drivers/regulator/tps6524x-regulator.c +5 −6
  75. drivers/regulator/tps80031-regulator.c +16 −32
  76. drivers/regulator/twl-regulator.c +3 −3
  77. drivers/regulator/vctrl-regulator.c +1 −3
  78. drivers/regulator/vexpress-regulator.c +27 −45
  79. drivers/regulator/wm831x-dcdc.c +11 −12
  80. drivers/regulator/wm831x-isink.c +16 −50
  81. drivers/regulator/wm831x-ldo.c +9 −12
  82. drivers/regulator/wm8350-regulator.c +19 −83
  83. drivers/regulator/wm8400-regulator.c +16 −23
  84. drivers/regulator/wm8994-regulator.c +7 −12
  85. include/linux/mfd/palmas.h +0 −1
  86. include/linux/mfd/wm831x/regulator.h +1 −1
  87. include/linux/mfd/wm8400-private.h +0 −8
  88. include/linux/regulator/consumer.h +5 −0
  89. sound/soc/codecs/ab8500-codec.c +2 −2
Documentation/devicetree/bindings/regulator/gpio-regulator.txt+22−8
@@ -4,16 +4,30 @@ Required properties: · 3 unmodified lines
44 - compatible : Must be "regulator-gpio".
55 - regulator-name : Defined in regulator.txt as optional, but required
66 here.
7−- states : Selection of available voltages and GPIO configs.
8− if there are no states, then use a fixed regulator
7+- gpios : Array of one or more GPIO pins used to select the
8+ regulator voltage/current listed in "states".
9+- states : Selection of available voltages/currents provided by
10+ this regulator and matching GPIO configurations to
11+ achieve them. If there are no states in the "states"
12+ array, use a fixed regulator instead.
913
1014 Optional properties:
11−- enable-gpio : GPIO to use to enable/disable the regulator.
12−- gpios : GPIO group used to control voltage.
13−- gpios-states : gpios pin's initial states array. 0: LOW, 1: HIGH.
14− defualt is LOW if nothing is specified.
15+- enable-gpios : GPIO used to enable/disable the regulator.
16+ Warning, the GPIO phandle flags are ignored and the
17+ GPIO polarity is controlled solely by the presence
18+ of "enable-active-high" DT property. This is due to
19+ compatibility with old DTs.
20+- enable-active-high : Polarity of "enable-gpio" GPIO is active HIGH.
21+ Default is active LOW.
22+- gpios-states : On operating systems, that don't support reading back
23+ gpio values in output mode (most notably linux), this
24+ array provides the state of GPIO pins set when
25+ requesting them from the gpio controller. Systems,
26+ that are capable of preserving state when requesting
27+ the lines, are free to ignore this property.
28+ 0: LOW, 1: HIGH. Default is LOW if nothing else
29+ is specified.
1530 - startup-delay-us : Startup time in microseconds.
16−- enable-active-high : Polarity of GPIO is active high (default is low).
1731 - regulator-type : Specifies what is being regulated, must be either
1832 "voltage" or "current", defaults to voltage.
1933
@@ -30,7 +44,7 @@ Example: · 10 unmodified lines
3044 regulator-max-microvolt = <2600000>;
3145 regulator-boot-on;
3246
33− enable-gpio = <&gpio0 23 0x4>;
47+ enable-gpios = <&gpio0 23 0x4>;
3448 gpios = <&gpio0 24 0x4
3549 &gpio0 25 0x4>;
3650 states = <1800000 0x3
Documentation/devicetree/bindings/regulator/st,stm32mp1-pwr-reg.txt+43−0
@@ -0,0 +1,43 @@
1+STM32MP1 PWR Regulators
2+-----------------------
3+
4+Available Regulators in STM32MP1 PWR block are:
5+ - reg11 for regulator 1V1
6+ - reg18 for regulator 1V8
7+ - usb33 for the swtich USB3V3
8+
9+Required properties:
10+- compatible: Must be "st,stm32mp1,pwr-reg"
11+- list of child nodes that specify the regulator reg11, reg18 or usb33
12+ initialization data for defined regulators. The definition for each of
13+ these nodes is defined using the standard binding for regulators found at
14+ Documentation/devicetree/bindings/regulator/regulator.txt.
15+- vdd-supply: phandle to the parent supply/regulator node for vdd input
16+- vdd_3v3_usbfs-supply: phandle to the parent supply/regulator node for usb33
17+
18+Example:
19+
20+pwr_regulators: pwr@50001000 {
21+ compatible = "st,stm32mp1,pwr-reg";
22+ reg = <0x50001000 0x10>;
23+ vdd-supply = <&vdd>;
24+ vdd_3v3_usbfs-supply = <&vdd_usb>;
25+
26+ reg11: reg11 {
27+ regulator-name = "reg11";
28+ regulator-min-microvolt = <1100000>;
29+ regulator-max-microvolt = <1100000>;
30+ };
31+
32+ reg18: reg18 {
33+ regulator-name = "reg18";
34+ regulator-min-microvolt = <1800000>;
35+ regulator-max-microvolt = <1800000>;
36+ };
37+
38+ usb33: usb33 {
39+ regulator-name = "usb33";
40+ regulator-min-microvolt = <3300000>;
41+ regulator-max-microvolt = <3300000>;
42+ };
43+};
drivers/mfd/wm831x-core.c+1−1
@@ -34,7 +34,7 @@ · 33 unmodified lines
3434 /* Current settings - values are 2*2^(reg_val/4) microamps. These are
3535 * exported since they are used by multiple drivers.
3636 */
37−int wm831x_isinkv_values[WM831X_ISINK_MAX_ISEL + 1] = {
37+const unsigned int wm831x_isinkv_values[WM831X_ISINK_MAX_ISEL + 1] = {
3838 2,
3939 2,
4040 3,
drivers/mfd/wm8400-core.c+0−6
@@ -35,12 +35,6 @@ static bool wm8400_volatile(struct device *dev, unsigned int reg) · 34 unmodified lines
3535 }
3636 }
3737
38−int wm8400_block_read(struct wm8400 *wm8400, u8 reg, int count, u16 *data)
39−{
40− return regmap_bulk_read(wm8400->regmap, reg, data, count);
41−}
42−EXPORT_SYMBOL_GPL(wm8400_block_read);
43−
4438 static int wm8400_register_codec(struct wm8400 *wm8400)
4539 {
4640 const struct mfd_cell cell = {
drivers/regulator/88pm800.c+1−17
@@ -77,11 +77,6 @@ struct pm800_regulator_info { · 76 unmodified lines
7777 int max_ua;
7878 };
7979
80−struct pm800_regulators {
81− struct pm80x_chip *chip;
82− struct regmap *map;
83−};
84−
8580 /*
8681 * vreg - the buck regs string.
8782 * ereg - the string for the enable register.
@@ -235,7 +230,6 @@ static int pm800_regulator_probe(struct platform_device *pdev) · 147 unmodified lines
235230 {
236231 struct pm80x_chip *chip = dev_get_drvdata(pdev->dev.parent);
237232 struct pm80x_platform_data *pdata = dev_get_platdata(pdev->dev.parent);
238− struct pm800_regulators *pm800_data;
239233 struct regulator_config config = { };
240234 struct regulator_init_data *init_data;
241235 int i, ret;
@@ -252,18 +246,8 @@ static int pm800_regulator_probe(struct platform_device *pdev) · 10 unmodified lines
252246 return -EINVAL;
253247 }
254248
255− pm800_data = devm_kzalloc(&pdev->dev, sizeof(*pm800_data),
256− GFP_KERNEL);
257− if (!pm800_data)
258− return -ENOMEM;
259−
260− pm800_data->map = chip->subchip->regmap_power;
261− pm800_data->chip = chip;
262−
263− platform_set_drvdata(pdev, pm800_data);
264−
265249 config.dev = chip->dev;
266− config.regmap = pm800_data->map;
250+ config.regmap = chip->subchip->regmap_power;
267251 for (i = 0; i < PM800_ID_RG_MAX; i++) {
268252 struct regulator_dev *regulator;
269253
drivers/regulator/88pm8607.c+9−34
@@ -235,6 +235,8 @@ static const struct regulator_ops pm8606_preg_ops = { · 234 unmodified lines
235235 { \
236236 .desc = { \
237237 .name = "PREG", \
238+ .of_match = of_match_ptr("PREG"), \
239+ .regulators_node = of_match_ptr("regulators"), \
238240 .ops = &pm8606_preg_ops, \
239241 .type = REGULATOR_CURRENT, \
240242 .id = PM8606_ID_PREG, \
@@ -249,6 +251,8 @@ static const struct regulator_ops pm8606_preg_ops = { · 8 unmodified lines
249251 { \
250252 .desc = { \
251253 .name = #vreg, \
254+ .of_match = of_match_ptr(#vreg), \
255+ .regulators_node = of_match_ptr("regulators"), \
252256 .ops = &pm8607_regulator_ops, \
253257 .type = REGULATOR_VOLTAGE, \
254258 .id = PM8607_ID_##vreg, \
@@ -270,6 +274,8 @@ static const struct regulator_ops pm8606_preg_ops = { · 15 unmodified lines
270274 { \
271275 .desc = { \
272276 .name = "LDO" #_id, \
277+ .of_match = of_match_ptr("LDO" #_id), \
278+ .regulators_node = of_match_ptr("regulators"), \
273279 .ops = &pm8607_regulator_ops, \
274280 .type = REGULATOR_VOLTAGE, \
275281 .id = PM8607_ID_LDO##_id, \
@@ -309,36 +315,6 @@ static struct pm8607_regulator_info pm8606_regulator_info[] = { · 33 unmodified lines
309315 PM8606_PREG(PREREGULATORB, 5),
310316 };
311317
312−#ifdef CONFIG_OF
313−static int pm8607_regulator_dt_init(struct platform_device *pdev,
314− struct pm8607_regulator_info *info,
315− struct regulator_config *config)
316−{
317− struct device_node *nproot, *np;
318− nproot = pdev->dev.parent->of_node;
319− if (!nproot)
320− return -ENODEV;
321− nproot = of_get_child_by_name(nproot, "regulators");
322− if (!nproot) {
323− dev_err(&pdev->dev, "failed to find regulators node\n");
324− return -ENODEV;
325− }
326− for_each_child_of_node(nproot, np) {
327− if (of_node_name_eq(np, info->desc.name)) {
328− config->init_data =
329− of_get_regulator_init_data(&pdev->dev, np,
330− &info->desc);
331− config->of_node = np;
332− break;
333− }
334− }
335− of_node_put(nproot);
336− return 0;
337−}
338−#else
339−#define pm8607_regulator_dt_init(x, y, z) (-1)
340−#endif
341−
342318 static int pm8607_regulator_probe(struct platform_device *pdev)
343319 {
344320 struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent);
@@ -373,12 +349,11 @@ static int pm8607_regulator_probe(struct platform_device *pdev) · 28 unmodified lines
373349 if ((i == PM8607_ID_BUCK3) && chip->buck3_double)
374350 info->slope_double = 1;
375351
376− config.dev = &pdev->dev;
352+ config.dev = chip->dev;
377353 config.driver_data = info;
378354
379− if (pm8607_regulator_dt_init(pdev, info, &config))
380− if (pdata)
381− config.init_data = pdata;
355+ if (pdata)
356+ config.init_data = pdata;
382357
383358 if (chip->id == CHIP_PM8607)
384359 config.regmap = chip->regmap;
drivers/regulator/Kconfig+10−1
@@ -223,6 +223,7 @@ config REGULATOR_CPCAP · 222 unmodified lines
223223 config REGULATOR_DA903X
224224 tristate "Dialog Semiconductor DA9030/DA9034 regulators"
225225 depends on PMIC_DA903X
226+ depends on !CC_IS_CLANG # https://bugs.llvm.org/show_bug.cgi?id=38789
226227 help
227228 Say y here to support the BUCKs and LDOs regulators found on
228229 Dialog Semiconductor DA9030/DA9034 PMIC.
@@ -839,6 +840,13 @@ config REGULATOR_STM32_VREFBUF · 610 unmodified lines
839840 This driver can also be built as a module. If so, the module
840841 will be called stm32-vrefbuf.
841842
843+config REGULATOR_STM32_PWR
844+ bool "STMicroelectronics STM32 PWR"
845+ depends on ARCH_STM32 || COMPILE_TEST
846+ help
847+ This driver supports internal regulators (1V1, 1V8, 3V3) in the
848+ STMicroelectronics STM32 chips.
849+
842850 config REGULATOR_STPMIC1
843851 tristate "STMicroelectronics STPMIC1 PMIC Regulators"
844852 depends on MFD_STPMIC1
@@ -1010,7 +1018,8 @@ config REGULATOR_TWL4030 · 165 unmodified lines
10101018 config REGULATOR_UNIPHIER
10111019 tristate "UniPhier regulator driver"
10121020 depends on ARCH_UNIPHIER || COMPILE_TEST
1013− depends on OF && MFD_SYSCON
1021+ depends on OF
1022+ select REGMAP_MMIO
10141023 default ARCH_UNIPHIER
10151024 help
10161025 Support for regulators implemented on Socionext UniPhier SoCs.
drivers/regulator/Makefile+1−0
@@ -105,6 +105,7 @@ obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o · 104 unmodified lines
105105 obj-$(CONFIG_REGULATOR_SC2731) += sc2731-regulator.o
106106 obj-$(CONFIG_REGULATOR_SKY81452) += sky81452-regulator.o
107107 obj-$(CONFIG_REGULATOR_STM32_VREFBUF) += stm32-vrefbuf.o
108+obj-$(CONFIG_REGULATOR_STM32_PWR) += stm32-pwr.o
108109 obj-$(CONFIG_REGULATOR_STPMIC1) += stpmic1_regulator.o
109110 obj-$(CONFIG_REGULATOR_STW481X_VMMC) += stw481x-vmmc.o
110111 obj-$(CONFIG_REGULATOR_SY8106A) += sy8106a-regulator.o
drivers/regulator/ab3100.c+12−33
@@ -48,7 +48,6 @@ · 47 unmodified lines
4848 * @regreg: regulator register number in the AB3100
4949 */
5050 struct ab3100_regulator {
51− struct regulator_dev *rdev;
5251 struct device *dev;
5352 struct ab3100_platform_data *plfdata;
5453 u8 regreg;
@@ -354,14 +353,13 @@ static int ab3100_get_voltage_regulator_external(struct regulator_dev *reg) · 299 unmodified lines
354353 return 0;
355354 }
356355
357−static struct regulator_ops regulator_ops_fixed = {
358− .list_voltage = regulator_list_voltage_linear,
356+static const struct regulator_ops regulator_ops_fixed = {
359357 .enable = ab3100_enable_regulator,
360358 .disable = ab3100_disable_regulator,
361359 .is_enabled = ab3100_is_enabled_regulator,
362360 };
363361
364−static struct regulator_ops regulator_ops_variable = {
362+static const struct regulator_ops regulator_ops_variable = {
365363 .enable = ab3100_enable_regulator,
366364 .disable = ab3100_disable_regulator,
367365 .is_enabled = ab3100_is_enabled_regulator,
@@ -370,7 +368,7 @@ static struct regulator_ops regulator_ops_variable = { · 2 unmodified lines
370368 .list_voltage = regulator_list_voltage_table,
371369 };
372370
373−static struct regulator_ops regulator_ops_variable_sleepable = {
371+static const struct regulator_ops regulator_ops_variable_sleepable = {
374372 .enable = ab3100_enable_regulator,
375373 .disable = ab3100_disable_regulator,
376374 .is_enabled = ab3100_is_enabled_regulator,
@@ -386,14 +384,14 @@ static struct regulator_ops regulator_ops_variable_sleepable = { · 9 unmodified lines
386384 * is an on/off switch plain an simple. The external
387385 * voltage is defined in the board set-up if any.
388386 */
389−static struct regulator_ops regulator_ops_external = {
387+static const struct regulator_ops regulator_ops_external = {
390388 .enable = ab3100_enable_regulator,
391389 .disable = ab3100_disable_regulator,
392390 .is_enabled = ab3100_is_enabled_regulator,
393391 .get_voltage = ab3100_get_voltage_regulator_external,
394392 };
395393
396−static struct regulator_desc
394+static const struct regulator_desc
397395 ab3100_regulator_desc[AB3100_NUM_REGULATORS] = {
398396 {
399397 .name = "LDO_A",
@@ -402,7 +400,7 @@ ab3100_regulator_desc[AB3100_NUM_REGULATORS] = { · 2 unmodified lines
402400 .n_voltages = 1,
403401 .type = REGULATOR_VOLTAGE,
404402 .owner = THIS_MODULE,
405− .min_uV = LDO_A_VOLTAGE,
403+ .fixed_uV = LDO_A_VOLTAGE,
406404 .enable_time = 200,
407405 },
408406 {
@@ -412,7 +410,7 @@ ab3100_regulator_desc[AB3100_NUM_REGULATORS] = { · 3 unmodified lines
412410 .n_voltages = 1,
413411 .type = REGULATOR_VOLTAGE,
414412 .owner = THIS_MODULE,
415− .min_uV = LDO_C_VOLTAGE,
413+ .fixed_uV = LDO_C_VOLTAGE,
416414 .enable_time = 200,
417415 },
418416 {
@@ -422,7 +420,7 @@ ab3100_regulator_desc[AB3100_NUM_REGULATORS] = { · 3 unmodified lines
422420 .n_voltages = 1,
423421 .type = REGULATOR_VOLTAGE,
424422 .owner = THIS_MODULE,
425− .min_uV = LDO_D_VOLTAGE,
423+ .fixed_uV = LDO_D_VOLTAGE,
426424 .enable_time = 200,
427425 },
428426 {
@@ -500,7 +498,7 @@ static int ab3100_regulator_register(struct platform_device *pdev, · 71 unmodified lines
500498 struct device_node *np,
501499 unsigned long id)
502500 {
503− struct regulator_desc *desc;
501+ const struct regulator_desc *desc;
504502 struct ab3100_regulator *reg;
505503 struct regulator_dev *rdev;
506504 struct regulator_config config = { };
@@ -545,8 +543,6 @@ static int ab3100_regulator_register(struct platform_device *pdev, · 38 unmodified lines
545543 return err;
546544 }
547545
548− /* Then set a pointer back to the registered regulator */
549− reg->rdev = rdev;
550546 return 0;
551547 }
552548
@@ -609,18 +605,6 @@ static const u8 ab3100_reg_initvals[] = { · 56 unmodified lines
609605 LDO_D_SETTING,
610606 };
611607
612−static int ab3100_regulators_remove(struct platform_device *pdev)
613−{
614− int i;
615−
616− for (i = 0; i < AB3100_NUM_REGULATORS; i++) {
617− struct ab3100_regulator *reg = &ab3100_regulators[i];
618−
619− reg->rdev = NULL;
620− }
621− return 0;
622−}
623−
624608 static int
625609 ab3100_regulator_of_probe(struct platform_device *pdev, struct device_node *np)
626610 {
@@ -647,10 +631,8 @@ ab3100_regulator_of_probe(struct platform_device *pdev, struct device_node *np) · 20 unmodified lines
647631 pdev, NULL, ab3100_regulator_matches[i].init_data,
648632 ab3100_regulator_matches[i].of_node,
649633 (unsigned long)ab3100_regulator_matches[i].driver_data);
650− if (err) {
651− ab3100_regulators_remove(pdev);
634+ if (err)
652635 return err;
653− }
654636 }
655637
656638 return 0;
@@ -705,14 +687,12 @@ static int ab3100_regulators_probe(struct platform_device *pdev) · 48 unmodified lines
705687
706688 /* Register the regulators */
707689 for (i = 0; i < AB3100_NUM_REGULATORS; i++) {
708− struct regulator_desc *desc = &ab3100_regulator_desc[i];
690+ const struct regulator_desc *desc = &ab3100_regulator_desc[i];
709691
710692 err = ab3100_regulator_register(pdev, plfdata, NULL, NULL,
711693 desc->id);
712− if (err) {
713− ab3100_regulators_remove(pdev);
694+ if (err)
714695 return err;
715− }
716696 }
717697
718698 return 0;
@@ -723,7 +703,6 @@ static struct platform_driver ab3100_regulators_driver = { · 4 unmodified lines
723703 .name = "ab3100-regulators",
724704 },
725705 .probe = ab3100_regulators_probe,
726− .remove = ab3100_regulators_remove,
727706 };
728707
729708 static __init int ab3100_regulators_init(void)
drivers/regulator/ab8500-ext.c+14−35
@@ -479,7 +479,6 @@ static struct ab8500_regulator_platform_data ab8500_regulator_plat_data = { · 478 unmodified lines
479479 * struct ab8500_ext_regulator_info - ab8500 regulator information
480480 * @dev: device pointer
481481 * @desc: regulator description
482− * @rdev: regulator device
483482 * @cfg: regulator configuration (extension of regulator FW configuration)
484483 * @update_bank: bank to control on/off
485484 * @update_reg: register to control on/off
@@ -495,7 +494,6 @@ static struct ab8500_regulator_platform_data ab8500_regulator_plat_data = { · 9 unmodified lines
495494 struct ab8500_ext_regulator_info {
496495 struct device *dev;
497496 struct regulator_desc desc;
498− struct regulator_dev *rdev;
499497 struct ab8500_ext_regulator_cfg *cfg;
500498 u8 update_bank;
501499 u8 update_reg;
@@ -530,7 +528,7 @@ static int ab8500_ext_regulator_enable(struct regulator_dev *rdev) · 28 unmodified lines
530528 info->update_bank, info->update_reg,
531529 info->update_mask, regval);
532530 if (ret < 0) {
533− dev_err(rdev_get_dev(info->rdev),
531+ dev_err(rdev_get_dev(rdev),
534532 "couldn't set enable bits for regulator\n");
535533 return ret;
536534 }
@@ -566,7 +564,7 @@ static int ab8500_ext_regulator_disable(struct regulator_dev *rdev) · 29 unmodified lines
566564 info->update_bank, info->update_reg,
567565 info->update_mask, regval);
568566 if (ret < 0) {
569− dev_err(rdev_get_dev(info->rdev),
567+ dev_err(rdev_get_dev(rdev),
570568 "couldn't set disable bits for regulator\n");
571569 return ret;
572570 }
@@ -720,7 +718,7 @@ static int ab8500_ext_list_voltage(struct regulator_dev *rdev, · 147 unmodified lines
720718 return -EINVAL;
721719 }
722720
723−static struct regulator_ops ab8500_ext_regulator_ops = {
721+static const struct regulator_ops ab8500_ext_regulator_ops = {
724722 .enable = ab8500_ext_regulator_enable,
725723 .disable = ab8500_ext_regulator_disable,
726724 .is_enabled = ab8500_ext_regulator_is_enabled,
@@ -735,6 +733,7 @@ static struct ab8500_ext_regulator_info · 8 unmodified lines
735733 [AB8500_EXT_SUPPLY1] = {
736734 .desc = {
737735 .name = "VEXTSUPPLY1",
736+ .of_match = of_match_ptr("ab8500_ext1"),
738737 .ops = &ab8500_ext_regulator_ops,
739738 .type = REGULATOR_VOLTAGE,
740739 .id = AB8500_EXT_SUPPLY1,
@@ -752,6 +751,7 @@ static struct ab8500_ext_regulator_info · 11 unmodified lines
752751 [AB8500_EXT_SUPPLY2] = {
753752 .desc = {
754753 .name = "VEXTSUPPLY2",
754+ .of_match = of_match_ptr("ab8500_ext2"),
755755 .ops = &ab8500_ext_regulator_ops,
756756 .type = REGULATOR_VOLTAGE,
757757 .id = AB8500_EXT_SUPPLY2,
@@ -769,6 +769,7 @@ static struct ab8500_ext_regulator_info · 11 unmodified lines
769769 [AB8500_EXT_SUPPLY3] = {
770770 .desc = {
771771 .name = "VEXTSUPPLY3",
772+ .of_match = of_match_ptr("ab8500_ext3"),
772773 .ops = &ab8500_ext_regulator_ops,
773774 .type = REGULATOR_VOLTAGE,
774775 .id = AB8500_EXT_SUPPLY3,
@@ -785,30 +786,13 @@ static struct ab8500_ext_regulator_info · 10 unmodified lines
785786 },
786787 };
787788
788−static struct of_regulator_match ab8500_ext_regulator_match[] = {
789− { .name = "ab8500_ext1", .driver_data = (void *) AB8500_EXT_SUPPLY1, },
790− { .name = "ab8500_ext2", .driver_data = (void *) AB8500_EXT_SUPPLY2, },
791− { .name = "ab8500_ext3", .driver_data = (void *) AB8500_EXT_SUPPLY3, },
792−};
793−
794789 static int ab8500_ext_regulator_probe(struct platform_device *pdev)
795790 {
796791 struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
797792 struct ab8500_regulator_platform_data *pdata = &ab8500_regulator_plat_data;
798− struct device_node *np = pdev->dev.of_node;
799793 struct regulator_config config = { };
800− int i, err;
801−
802− if (np) {
803− err = of_regulator_match(&pdev->dev, np,
804− ab8500_ext_regulator_match,
805− ARRAY_SIZE(ab8500_ext_regulator_match));
806− if (err < 0) {
807− dev_err(&pdev->dev,
808− "Error parsing regulator init data: %d\n", err);
809− return err;
810− }
811− }
794+ struct regulator_dev *rdev;
795+ int i;
812796
813797 if (!ab8500) {
814798 dev_err(&pdev->dev, "null mfd parent\n");
@@ -844,23 +828,18 @@ static int ab8500_ext_regulator_probe(struct platform_device *pdev) · 29 unmodified lines
844828
845829 config.dev = &pdev->dev;
846830 config.driver_data = info;
847− config.of_node = ab8500_ext_regulator_match[i].of_node;
848− config.init_data = (np) ?
849− ab8500_ext_regulator_match[i].init_data :
850− &pdata->ext_regulator[i];
831+ config.init_data = &pdata->ext_regulator[i];
851832
852833 /* register regulator with framework */
853− info->rdev = devm_regulator_register(&pdev->dev, &info->desc,
854− &config);
855− if (IS_ERR(info->rdev)) {
856− err = PTR_ERR(info->rdev);
834+ rdev = devm_regulator_register(&pdev->dev, &info->desc,
835+ &config);
836+ if (IS_ERR(rdev)) {
857837 dev_err(&pdev->dev, "failed to register regulator %s\n",
858838 info->desc.name);
859− return err;
839+ return PTR_ERR(rdev);
860840 }
861841
862− dev_dbg(rdev_get_dev(info->rdev),
863− "%s-probed\n", info->desc.name);
842+ dev_dbg(&pdev->dev, "%s-probed\n", info->desc.name);
864843 }
865844
866845 return 0;
drivers/regulator/ab8500.c+9−11
@@ -44,7 +44,6 @@ struct ab8500_shared_mode { · 43 unmodified lines
4444 * struct ab8500_regulator_info - ab8500 regulator information
4545 * @dev: device pointer
4646 * @desc: regulator description
47− * @regulator_dev: regulator device
4847 * @shared_mode: used when mode is shared between two regulators
4948 * @load_lp_uA: maximum load in idle (low power) mode
5049 * @update_bank: bank to control on/off
@@ -65,7 +64,6 @@ struct ab8500_shared_mode { · 14 unmodified lines
6564 struct ab8500_regulator_info {
6665 struct device *dev;
6766 struct regulator_desc desc;
68− struct regulator_dev *regulator;
6967 struct ab8500_shared_mode *shared_mode;
7068 int load_lp_uA;
7169 u8 update_bank;
@@ -510,7 +508,7 @@ static int ab8500_regulator_set_voltage_sel(struct regulator_dev *rdev, · 438 unmodified lines
510508 return ret;
511509 }
512510
513−static struct regulator_ops ab8500_regulator_volt_mode_ops = {
511+static const struct regulator_ops ab8500_regulator_volt_mode_ops = {
514512 .enable = ab8500_regulator_enable,
515513 .disable = ab8500_regulator_disable,
516514 .is_enabled = ab8500_regulator_is_enabled,
@@ -522,7 +520,7 @@ static struct regulator_ops ab8500_regulator_volt_mode_ops = { · 5 unmodified lines
522520 .list_voltage = regulator_list_voltage_table,
523521 };
524522
525−static struct regulator_ops ab8500_regulator_volt_ops = {
523+static const struct regulator_ops ab8500_regulator_volt_ops = {
526524 .enable = ab8500_regulator_enable,
527525 .disable = ab8500_regulator_disable,
528526 .is_enabled = ab8500_regulator_is_enabled,
@@ -531,7 +529,7 @@ static struct regulator_ops ab8500_regulator_volt_ops = { · 2 unmodified lines
531529 .list_voltage = regulator_list_voltage_table,
532530 };
533531
534−static struct regulator_ops ab8500_regulator_mode_ops = {
532+static const struct regulator_ops ab8500_regulator_mode_ops = {
535533 .enable = ab8500_regulator_enable,
536534 .disable = ab8500_regulator_disable,
537535 .is_enabled = ab8500_regulator_is_enabled,
@@ -541,14 +539,14 @@ static struct regulator_ops ab8500_regulator_mode_ops = { · 3 unmodified lines
541539 .list_voltage = regulator_list_voltage_table,
542540 };
543541
544−static struct regulator_ops ab8500_regulator_ops = {
542+static const struct regulator_ops ab8500_regulator_ops = {
545543 .enable = ab8500_regulator_enable,
546544 .disable = ab8500_regulator_disable,
547545 .is_enabled = ab8500_regulator_is_enabled,
548546 .list_voltage = regulator_list_voltage_table,
549547 };
550548
551−static struct regulator_ops ab8500_regulator_anamic_mode_ops = {
549+static const struct regulator_ops ab8500_regulator_anamic_mode_ops = {
552550 .enable = ab8500_regulator_enable,
553551 .disable = ab8500_regulator_disable,
554552 .is_enabled = ab8500_regulator_is_enabled,
@@ -1600,6 +1598,7 @@ static int ab8500_regulator_register(struct platform_device *pdev, · 1045 unmodified lines
16001598 struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
16011599 struct ab8500_regulator_info *info = NULL;
16021600 struct regulator_config config = { };
1601+ struct regulator_dev *rdev;
16031602
16041603 /* assign per-regulator data */
16051604 info = &abx500_regulator.info[id];
@@ -1621,12 +1620,11 @@ static int ab8500_regulator_register(struct platform_device *pdev, · 15 unmodified lines
16211620 }
16221621
16231622 /* register regulator with framework */
1624− info->regulator = devm_regulator_register(&pdev->dev, &info->desc,
1625− &config);
1626− if (IS_ERR(info->regulator)) {
1623+ rdev = devm_regulator_register(&pdev->dev, &info->desc, &config);
1624+ if (IS_ERR(rdev)) {
16271625 dev_err(&pdev->dev, "failed to register regulator %s\n",
16281626 info->desc.name);
1629− return PTR_ERR(info->regulator);
1627+ return PTR_ERR(rdev);
16301628 }
16311629
16321630 return 0;
drivers/regulator/act8865-regulator.c+21−126
@@ -226,7 +226,7 @@ static const struct regulator_linear_range act8600_sudcdc_voltage_ranges[] = { · 225 unmodified lines
226226 REGULATOR_LINEAR_RANGE(41400000, 248, 255, 0),
227227 };
228228
229−static struct regulator_ops act8865_ops = {
229+static const struct regulator_ops act8865_ops = {
230230 .list_voltage = regulator_list_voltage_linear_range,
231231 .map_voltage = regulator_map_voltage_linear_range,
232232 .get_voltage_sel = regulator_get_voltage_sel_regmap,
@@ -236,7 +236,7 @@ static struct regulator_ops act8865_ops = { · 3 unmodified lines
236236 .is_enabled = regulator_is_enabled_regmap,
237237 };
238238
239−static struct regulator_ops act8865_ldo_ops = {
239+static const struct regulator_ops act8865_ldo_ops = {
240240 .enable = regulator_enable_regmap,
241241 .disable = regulator_disable_regmap,
242242 .is_enabled = regulator_is_enabled_regmap,
@@ -245,6 +245,8 @@ static struct regulator_ops act8865_ldo_ops = { · 2 unmodified lines
245245 #define ACT88xx_REG(_name, _family, _id, _vsel_reg, _supply) \
246246 [_family##_ID_##_id] = { \
247247 .name = _name, \
248+ .of_match = of_match_ptr(_name), \
249+ .regulators_node = of_match_ptr("regulators"), \
248250 .supply_name = _supply, \
249251 .id = _family##_ID_##_id, \
250252 .type = REGULATOR_VOLTAGE, \
@@ -265,6 +267,8 @@ static const struct regulator_desc act8600_regulators[] = { · 14 unmodified lines
265267 ACT88xx_REG("DCDC3", ACT8600, DCDC3, VSET, "vp3"),
266268 {
267269 .name = "SUDCDC_REG4",
270+ .of_match = of_match_ptr("SUDCDC_REG4"),
271+ .regulators_node = of_match_ptr("regulators"),
268272 .id = ACT8600_ID_SUDCDC4,
269273 .ops = &act8865_ops,
270274 .type = REGULATOR_VOLTAGE,
@@ -283,6 +287,8 @@ static const struct regulator_desc act8600_regulators[] = { · 12 unmodified lines
283287 ACT88xx_REG("LDO8", ACT8600, LDO8, VSET, "inl"),
284288 {
285289 .name = "LDO_REG9",
290+ .of_match = of_match_ptr("LDO_REG9"),
291+ .regulators_node = of_match_ptr("regulators"),
286292 .id = ACT8600_ID_LDO9,
287293 .ops = &act8865_ldo_ops,
288294 .type = REGULATOR_VOLTAGE,
@@ -294,6 +300,8 @@ static const struct regulator_desc act8600_regulators[] = { · 5 unmodified lines
294300 },
295301 {
296302 .name = "LDO_REG10",
303+ .of_match = of_match_ptr("LDO_REG10"),
304+ .regulators_node = of_match_ptr("regulators"),
297305 .id = ACT8600_ID_LDO10,
298306 .ops = &act8865_ldo_ops,
299307 .type = REGULATOR_VOLTAGE,
@@ -348,110 +356,6 @@ static const struct of_device_id act8865_dt_ids[] = { · 48 unmodified lines
348356 { }
349357 };
350358 MODULE_DEVICE_TABLE(of, act8865_dt_ids);
351−
352−static struct of_regulator_match act8846_matches[] = {
353− [ACT8846_ID_REG1] = { .name = "REG1" },
354− [ACT8846_ID_REG2] = { .name = "REG2" },
355− [ACT8846_ID_REG3] = { .name = "REG3" },
356− [ACT8846_ID_REG4] = { .name = "REG4" },
357− [ACT8846_ID_REG5] = { .name = "REG5" },
358− [ACT8846_ID_REG6] = { .name = "REG6" },
359− [ACT8846_ID_REG7] = { .name = "REG7" },
360− [ACT8846_ID_REG8] = { .name = "REG8" },
361− [ACT8846_ID_REG9] = { .name = "REG9" },
362− [ACT8846_ID_REG10] = { .name = "REG10" },
363− [ACT8846_ID_REG11] = { .name = "REG11" },
364− [ACT8846_ID_REG12] = { .name = "REG12" },
365−};
366−
367−static struct of_regulator_match act8865_matches[] = {
368− [ACT8865_ID_DCDC1] = { .name = "DCDC_REG1"},
369− [ACT8865_ID_DCDC2] = { .name = "DCDC_REG2"},
370− [ACT8865_ID_DCDC3] = { .name = "DCDC_REG3"},
371− [ACT8865_ID_LDO1] = { .name = "LDO_REG1"},
372− [ACT8865_ID_LDO2] = { .name = "LDO_REG2"},
373− [ACT8865_ID_LDO3] = { .name = "LDO_REG3"},
374− [ACT8865_ID_LDO4] = { .name = "LDO_REG4"},
375−};
376−
377−static struct of_regulator_match act8600_matches[] = {
378− [ACT8600_ID_DCDC1] = { .name = "DCDC_REG1"},
379− [ACT8600_ID_DCDC2] = { .name = "DCDC_REG2"},
380− [ACT8600_ID_DCDC3] = { .name = "DCDC_REG3"},
381− [ACT8600_ID_SUDCDC4] = { .name = "SUDCDC_REG4"},
382− [ACT8600_ID_LDO5] = { .name = "LDO_REG5"},
383− [ACT8600_ID_LDO6] = { .name = "LDO_REG6"},
384− [ACT8600_ID_LDO7] = { .name = "LDO_REG7"},
385− [ACT8600_ID_LDO8] = { .name = "LDO_REG8"},
386− [ACT8600_ID_LDO9] = { .name = "LDO_REG9"},
387− [ACT8600_ID_LDO10] = { .name = "LDO_REG10"},
388−};
389−
390−static int act8865_pdata_from_dt(struct device *dev,
391− struct act8865_platform_data *pdata,
392− unsigned long type)
393−{
394− int matched, i, num_matches;
395− struct device_node *np;
396− struct act8865_regulator_data *regulator;
397− struct of_regulator_match *matches;
398−
399− switch (type) {
400− case ACT8600:
401− matches = act8600_matches;
402− num_matches = ARRAY_SIZE(act8600_matches);
403− break;
404− case ACT8846:
405− matches = act8846_matches;
406− num_matches = ARRAY_SIZE(act8846_matches);
407− break;
408− case ACT8865:
409− matches = act8865_matches;
410− num_matches = ARRAY_SIZE(act8865_matches);
411− break;
412− default:
413− dev_err(dev, "invalid device id %lu\n", type);
414− return -EINVAL;
415− }
416−
417− np = of_get_child_by_name(dev->of_node, "regulators");
418− if (!np) {
419− dev_err(dev, "missing 'regulators' subnode in DT\n");
420− return -EINVAL;
421− }
422−
423− matched = of_regulator_match(dev, np, matches, num_matches);
424− of_node_put(np);
425− if (matched <= 0)
426− return matched;
427−
428− pdata->regulators = devm_kcalloc(dev,
429− num_matches,
430− sizeof(struct act8865_regulator_data),
431− GFP_KERNEL);
432− if (!pdata->regulators)
433− return -ENOMEM;
434−
435− pdata->num_regulators = num_matches;
436− regulator = pdata->regulators;
437−
438− for (i = 0; i < num_matches; i++) {
439− regulator->id = i;
440− regulator->name = matches[i].name;
441− regulator->init_data = matches[i].init_data;
442− regulator->of_node = matches[i].of_node;
443− regulator++;
444− }
445−
446− return 0;
447−}
448−#else
449−static inline int act8865_pdata_from_dt(struct device *dev,
450− struct act8865_platform_data *pdata,
451− unsigned long type)
452−{
453− return 0;
454−}
455359 #endif
456360
457361 static struct act8865_regulator_data *act8865_get_regulator_data(
@@ -459,9 +363,6 @@ static struct act8865_regulator_data *act8865_get_regulator_data( · 1 unmodified line
459363 {
460364 int i;
461365
462− if (!pdata)
463− return NULL;
464−
465366 for (i = 0; i < pdata->num_regulators; i++) {
466367 if (pdata->regulators[i].id == id)
467368 return &pdata->regulators[i];
@@ -484,7 +385,7 @@ static int act8865_pmic_probe(struct i2c_client *client, · 16 unmodified lines
484385 const struct i2c_device_id *i2c_id)
485386 {
486387 const struct regulator_desc *regulators;
487− struct act8865_platform_data pdata_of, *pdata;
388+ struct act8865_platform_data *pdata = NULL;
488389 struct device *dev = &client->dev;
489390 int i, ret, num_regulators;
490391 struct act8865 *act8865;
@@ -493,9 +394,7 @@ static int act8865_pmic_probe(struct i2c_client *client, · 2 unmodified lines
493394 int off_reg, off_mask;
494395 int voltage_select = 0;
495396
496− pdata = dev_get_platdata(dev);
497−
498− if (dev->of_node && !pdata) {
397+ if (dev->of_node) {
499398 const struct of_device_id *id;
500399
501400 id = of_match_device(of_match_ptr(act8865_dt_ids), dev);
@@ -509,6 +408,7 @@ static int act8865_pmic_probe(struct i2c_client *client, · 7 unmodified lines
509408 NULL);
510409 } else {
511410 type = i2c_id->driver_data;
411+ pdata = dev_get_platdata(dev);
512412 }
513413
514414 switch (type) {
@@ -543,14 +443,6 @@ static int act8865_pmic_probe(struct i2c_client *client, · 28 unmodified lines
543443 return -EINVAL;
544444 }
545445
546− if (dev->of_node && !pdata) {
547− ret = act8865_pdata_from_dt(dev, &pdata_of, type);
548− if (ret < 0)
549− return ret;
550−
551− pdata = &pdata_of;
552− }
553−
554446 act8865 = devm_kzalloc(dev, sizeof(struct act8865), GFP_KERNEL);
555447 if (!act8865)
556448 return -ENOMEM;
@@ -577,17 +469,20 @@ static int act8865_pmic_probe(struct i2c_client *client, · 20 unmodified lines
577469 for (i = 0; i < num_regulators; i++) {
578470 const struct regulator_desc *desc = &regulators[i];
579471 struct regulator_config config = { };
580− struct act8865_regulator_data *rdata;
581472 struct regulator_dev *rdev;
582473
583474 config.dev = dev;
584475 config.driver_data = act8865;
585476 config.regmap = act8865->regmap;
586477
587− rdata = act8865_get_regulator_data(desc->id, pdata);
588− if (rdata) {
589− config.init_data = rdata->init_data;
590− config.of_node = rdata->of_node;
478+ if (pdata) {
479+ struct act8865_regulator_data *rdata;
480+
481+ rdata = act8865_get_regulator_data(desc->id, pdata);
482+ if (rdata) {
483+ config.init_data = rdata->init_data;
484+ config.of_node = rdata->of_node;
485+ }
591486 }
592487
593488 rdev = devm_regulator_register(dev, desc, &config);
drivers/regulator/anatop-regulator.c+27−36
@@ -23,18 +23,10 @@ · 22 unmodified lines
2323 #define LDO_FET_FULL_ON 0x1f
2424
2525 struct anatop_regulator {
26− u32 control_reg;
27− struct regmap *anatop;
28− int vol_bit_shift;
29− int vol_bit_width;
3026 u32 delay_reg;
3127 int delay_bit_shift;
3228 int delay_bit_width;
33− int min_bit_val;
34− int min_voltage;
35− int max_voltage;
3629 struct regulator_desc rdesc;
37− struct regulator_init_data *initdata;
3830 bool bypass;
3931 int sel;
4032 };
@@ -55,7 +47,7 @@ static int anatop_regmap_set_voltage_time_sel(struct regulator_dev *reg, · 14 unmodified lines
5547 * to calculate how many steps LDO need to
5648 * ramp up, and how much delay needed. (us)
5749 */
58− regmap_read(anatop_reg->anatop, anatop_reg->delay_reg, &val);
50+ regmap_read(reg->regmap, anatop_reg->delay_reg, &val);
5951 val = (val >> anatop_reg->delay_bit_shift) &
6052 ((1 << anatop_reg->delay_bit_width) - 1);
6153 ret = (new_sel - old_sel) * (LDO_RAMP_UP_UNIT_IN_CYCLES <<
@@ -170,6 +162,13 @@ static int anatop_regulator_probe(struct platform_device *pdev) · 108 unmodified lines
170162 struct anatop_regulator *sreg;
171163 struct regulator_init_data *initdata;
172164 struct regulator_config config = { };
165+ struct regmap *regmap;
166+ u32 control_reg;
167+ u32 vol_bit_shift;
168+ u32 vol_bit_width;
169+ u32 min_bit_val;
170+ u32 min_voltage;
171+ u32 max_voltage;
173172 int ret = 0;
174173 u32 val;
175174
@@ -192,48 +191,41 @@ static int anatop_regulator_probe(struct platform_device *pdev) · 16 unmodified lines
192191 return -ENOMEM;
193192
194193 initdata->supply_regulator = "vin";
195− sreg->initdata = initdata;
196194
197195 anatop_np = of_get_parent(np);
198196 if (!anatop_np)
199197 return -ENODEV;
200− sreg->anatop = syscon_node_to_regmap(anatop_np);
198+ regmap = syscon_node_to_regmap(anatop_np);
201199 of_node_put(anatop_np);
202− if (IS_ERR(sreg->anatop))
203− return PTR_ERR(sreg->anatop);
200+ if (IS_ERR(regmap))
201+ return PTR_ERR(regmap);
204202
205− ret = of_property_read_u32(np, "anatop-reg-offset",
206− &sreg->control_reg);
203+ ret = of_property_read_u32(np, "anatop-reg-offset", &control_reg);
207204 if (ret) {
208205 dev_err(dev, "no anatop-reg-offset property set\n");
209206 return ret;
210207 }
211− ret = of_property_read_u32(np, "anatop-vol-bit-width",
212− &sreg->vol_bit_width);
208+ ret = of_property_read_u32(np, "anatop-vol-bit-width", &vol_bit_width);
213209 if (ret) {
214210 dev_err(dev, "no anatop-vol-bit-width property set\n");
215211 return ret;
216212 }
217− ret = of_property_read_u32(np, "anatop-vol-bit-shift",
218− &sreg->vol_bit_shift);
213+ ret = of_property_read_u32(np, "anatop-vol-bit-shift", &vol_bit_shift);
219214 if (ret) {
220215 dev_err(dev, "no anatop-vol-bit-shift property set\n");
221216 return ret;
222217 }
223− ret = of_property_read_u32(np, "anatop-min-bit-val",
224− &sreg->min_bit_val);
218+ ret = of_property_read_u32(np, "anatop-min-bit-val", &min_bit_val);
225219 if (ret) {
226220 dev_err(dev, "no anatop-min-bit-val property set\n");
227221 return ret;
228222 }
229− ret = of_property_read_u32(np, "anatop-min-voltage",
230− &sreg->min_voltage);
223+ ret = of_property_read_u32(np, "anatop-min-voltage", &min_voltage);
231224 if (ret) {
232225 dev_err(dev, "no anatop-min-voltage property set\n");
233226 return ret;
234227 }
235− ret = of_property_read_u32(np, "anatop-max-voltage",
236− &sreg->max_voltage);
228+ ret = of_property_read_u32(np, "anatop-max-voltage", &max_voltage);
237229 if (ret) {
238230 dev_err(dev, "no anatop-max-voltage property set\n");
239231 return ret;
@@ -247,24 +239,23 @@ static int anatop_regulator_probe(struct platform_device *pdev) · 7 unmodified lines
247239 of_property_read_u32(np, "anatop-delay-bit-shift",
248240 &sreg->delay_bit_shift);
249241
250− rdesc->n_voltages = (sreg->max_voltage - sreg->min_voltage) / 25000 + 1
251− + sreg->min_bit_val;
252− rdesc->min_uV = sreg->min_voltage;
242+ rdesc->n_voltages = (max_voltage - min_voltage) / 25000 + 1
243+ + min_bit_val;
244+ rdesc->min_uV = min_voltage;
253245 rdesc->uV_step = 25000;
254− rdesc->linear_min_sel = sreg->min_bit_val;
255− rdesc->vsel_reg = sreg->control_reg;
256− rdesc->vsel_mask = ((1 << sreg->vol_bit_width) - 1) <<
257− sreg->vol_bit_shift;
246+ rdesc->linear_min_sel = min_bit_val;
247+ rdesc->vsel_reg = control_reg;
248+ rdesc->vsel_mask = ((1 << vol_bit_width) - 1) << vol_bit_shift;
258249 rdesc->min_dropout_uV = 125000;
259250
260251 config.dev = &pdev->dev;
261252 config.init_data = initdata;
262253 config.driver_data = sreg;
263254 config.of_node = pdev->dev.of_node;
264− config.regmap = sreg->anatop;
255+ config.regmap = regmap;
265256
266257 /* Only core regulators have the ramp up delay configuration. */
267− if (sreg->control_reg && sreg->delay_bit_width) {
258+ if (control_reg && sreg->delay_bit_width) {
268259 rdesc->ops = &anatop_core_rops;
269260
270261 ret = regmap_read(config.regmap, rdesc->vsel_reg, &val);
@@ -273,7 +264,7 @@ static int anatop_regulator_probe(struct platform_device *pdev) · 2 unmodified lines
273264 return ret;
274265 }
275266
276− sreg->sel = (val & rdesc->vsel_mask) >> sreg->vol_bit_shift;
267+ sreg->sel = (val & rdesc->vsel_mask) >> vol_bit_shift;
277268 if (sreg->sel == LDO_FET_FULL_ON) {
278269 sreg->sel = 0;
279270 sreg->bypass = true;
@@ -306,7 +297,7 @@ static int anatop_regulator_probe(struct platform_device *pdev) · 26 unmodified lines
306297 anatop_rops.disable = regulator_disable_regmap;
307298 anatop_rops.is_enabled = regulator_is_enabled_regmap;
308299
309− rdesc->enable_reg = sreg->control_reg;
300+ rdesc->enable_reg = control_reg;
310301 rdesc->enable_mask = BIT(enable_bit);
311302 }
312303 }
drivers/regulator/arizona-ldo1.c+7−12
@@ -1,15 +1,10 @@
1−/*
2− * arizona-ldo1.c -- LDO1 supply for Arizona devices
3− *
4− * Copyright 2012 Wolfson Microelectronics PLC.
5− *
6− * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
7− *
8− * This program is free software; you can redistribute it and/or modify it
9− * under the terms of the GNU General Public License as published by the
10− * Free Software Foundation; either version 2 of the License, or (at your
11− * option) any later version.
12− */
1+// SPDX-License-Identifier: GPL-2.0+
2+//
3+// arizona-ldo1.c -- LDO1 supply for Arizona devices
4+//
5+// Copyright 2012 Wolfson Microelectronics PLC.
6+//
7+// Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
138
149 #include <linux/module.h>
1510 #include <linux/moduleparam.h>
drivers/regulator/arizona-micsupp.c+7−12
@@ -1,15 +1,10 @@
1−/*
2− * arizona-micsupp.c -- Microphone supply for Arizona devices
3− *
4− * Copyright 2012 Wolfson Microelectronics PLC.
5− *
6− * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
7− *
8− * This program is free software; you can redistribute it and/or modify it
9− * under the terms of the GNU General Public License as published by the
10− * Free Software Foundation; either version 2 of the License, or (at your
11− * option) any later version.
12− */
1+// SPDX-License-Identifier: GPL-2.0+
2+//
3+// arizona-micsupp.c -- Microphone supply for Arizona devices
4+//
5+// Copyright 2012 Wolfson Microelectronics PLC.
6+//
7+// Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
138
149 #include <linux/module.h>
1510 #include <linux/moduleparam.h>
drivers/regulator/as3711-regulator.c+7−30
@@ -17,14 +17,6 @@ · 16 unmodified lines
1717 #include <linux/regulator/of_regulator.h>
1818 #include <linux/slab.h>
1919
20−struct as3711_regulator_info {
21− struct regulator_desc desc;
22−};
23−
24−struct as3711_regulator {
25− struct as3711_regulator_info *reg_info;
26−};
27−
2820 /*
2921 * The regulator API supports 4 modes of operataion: FAST, NORMAL, IDLE and
3022 * STANDBY. We map them in the following way to AS3711 SD1-4 DCDC modes:
@@ -129,7 +121,6 @@ static const struct regulator_linear_range as3711_dldo_ranges[] = { · 98 unmodified lines
129121
130122 #define AS3711_REG(_id, _en_reg, _en_bit, _vmask, _sfx) \
131123 [AS3711_REGULATOR_ ## _id] = { \
132− .desc = { \
133124 .name = "as3711-regulator-" # _id, \
134125 .id = AS3711_REGULATOR_ ## _id, \
135126 .n_voltages = (_vmask + 1), \
@@ -142,10 +133,9 @@ static const struct regulator_linear_range as3711_dldo_ranges[] = { · 6 unmodified lines
142133 .enable_mask = BIT(_en_bit), \
143134 .linear_ranges = as3711_ ## _sfx ## _ranges, \
144135 .n_linear_ranges = ARRAY_SIZE(as3711_ ## _sfx ## _ranges), \
145− }, \
146136 }
147137
148−static struct as3711_regulator_info as3711_reg_info[] = {
138+static const struct regulator_desc as3711_reg_desc[] = {
149139 AS3711_REG(SD_1, SD_CONTROL, 0, 0x7f, sd),
150140 AS3711_REG(SD_2, SD_CONTROL, 1, 0x7f, sd),
151141 AS3711_REG(SD_3, SD_CONTROL, 2, 0x7f, sd),
@@ -161,7 +151,7 @@ static struct as3711_regulator_info as3711_reg_info[] = { · 9 unmodified lines
161151 /* StepUp output voltage depends on supplying regulator */
162152 };
163153
164−#define AS3711_REGULATOR_NUM ARRAY_SIZE(as3711_reg_info)
154+#define AS3711_REGULATOR_NUM ARRAY_SIZE(as3711_reg_desc)
165155
166156 static struct of_regulator_match
167157 as3711_regulator_matches[AS3711_REGULATOR_NUM] = {
@@ -215,11 +205,8 @@ static int as3711_regulator_probe(struct platform_device *pdev) · 47 unmodified lines
215205 struct as3711_regulator_pdata *pdata = dev_get_platdata(&pdev->dev);
216206 struct as3711 *as3711 = dev_get_drvdata(pdev->dev.parent);
217207 struct regulator_config config = {.dev = &pdev->dev,};
218− struct as3711_regulator *reg = NULL;
219− struct as3711_regulator *regs;
220208 struct device_node *of_node[AS3711_REGULATOR_NUM] = {};
221209 struct regulator_dev *rdev;
222− struct as3711_regulator_info *ri;
223210 int ret;
224211 int id;
225212
@@ -236,30 +223,20 @@ static int as3711_regulator_probe(struct platform_device *pdev) · 10 unmodified lines
236223 }
237224 }
238225
239− regs = devm_kcalloc(&pdev->dev,
240− AS3711_REGULATOR_NUM,
241− sizeof(struct as3711_regulator),
242− GFP_KERNEL);
243− if (!regs)
244− return -ENOMEM;
245−
246− for (id = 0, ri = as3711_reg_info; id < AS3711_REGULATOR_NUM; ++id, ri++) {
247− reg = &regs[id];
248− reg->reg_info = ri;
249−
226+ for (id = 0; id < AS3711_REGULATOR_NUM; id++) {
250227 config.init_data = pdata->init_data[id];
251− config.driver_data = reg;
252228 config.regmap = as3711->regmap;
253229 config.of_node = of_node[id];
254230
255− rdev = devm_regulator_register(&pdev->dev, &ri->desc, &config);
231+ rdev = devm_regulator_register(&pdev->dev, &as3711_reg_desc[id],
232+ &config);
256233 if (IS_ERR(rdev)) {
257234 dev_err(&pdev->dev, "Failed to register regulator %s\n",
258− ri->desc.name);
235+ as3711_reg_desc[id].name);
259236 return PTR_ERR(rdev);
260237 }
261238 }
262− platform_set_drvdata(pdev, regs);
239+
263240 return 0;
264241 }
265242
drivers/regulator/as3722-regulator.c+86−201
@@ -81,7 +81,6 @@ struct as3722_regulator_config_data { · 80 unmodified lines
8181 struct as3722_regulators {
8282 struct device *dev;
8383 struct as3722 *as3722;
84− struct regulator_dev *rdevs[AS3722_REGULATOR_ID_MAX];
8584 struct regulator_desc desc[AS3722_REGULATOR_ID_MAX];
8685 struct as3722_regulator_config_data
8786 reg_config_data[AS3722_REGULATOR_ID_MAX];
@@ -314,63 +313,10 @@ static const struct as3722_register_mapping as3722_reg_lookup[] = { · 226 unmodified lines
314313 },
315314 };
316315
317−
318−static const int as3722_ldo_current[] = { 150000, 300000 };
319−static const int as3722_sd016_current[] = { 2500000, 3000000, 3500000 };
320−
321−static int as3722_current_to_index(int min_uA, int max_uA,
322− const int *curr_table, int n_currents)
323−{
324− int i;
325−
326− for (i = n_currents - 1; i >= 0; i--) {
327− if ((min_uA <= curr_table[i]) && (curr_table[i] <= max_uA))
328− return i;
329− }
330− return -EINVAL;
331−}
332−
333−static int as3722_ldo_get_current_limit(struct regulator_dev *rdev)
334−{
335− struct as3722_regulators *as3722_regs = rdev_get_drvdata(rdev);
336− struct as3722 *as3722 = as3722_regs->as3722;
337− int id = rdev_get_id(rdev);
338− u32 val;
339− int ret;
340−
341− ret = as3722_read(as3722, as3722_reg_lookup[id].vsel_reg, &val);
342− if (ret < 0) {
343− dev_err(as3722_regs->dev, "Reg 0x%02x read failed: %d\n",
344− as3722_reg_lookup[id].vsel_reg, ret);
345− return ret;
346− }
347− if (val & AS3722_LDO_ILIMIT_MASK)
348− return 300000;
349− return 150000;
350−}
351−
352−static int as3722_ldo_set_current_limit(struct regulator_dev *rdev,
353− int min_uA, int max_uA)
354−{
355− struct as3722_regulators *as3722_regs = rdev_get_drvdata(rdev);
356− struct as3722 *as3722 = as3722_regs->as3722;
357− int id = rdev_get_id(rdev);
358− int ret;
359− u32 reg = 0;
360−
361− ret = as3722_current_to_index(min_uA, max_uA, as3722_ldo_current,
362− ARRAY_SIZE(as3722_ldo_current));
363− if (ret < 0) {
364− dev_err(as3722_regs->dev,
365− "Current range min:max = %d:%d does not support\n",
366− min_uA, max_uA);
367− return ret;
368− }
369− if (ret)
370− reg = AS3722_LDO_ILIMIT_BIT;
371− return as3722_update_bits(as3722, as3722_reg_lookup[id].vsel_reg,
372− AS3722_LDO_ILIMIT_MASK, reg);
373−}
316+static const unsigned int as3722_ldo_current[] = { 150000, 300000 };
317+static const unsigned int as3722_sd016_current[] = {
318+ 2500000, 3000000, 3500000
319+};
374320
375321 static const struct regulator_ops as3722_ldo0_ops = {
376322 .is_enabled = regulator_is_enabled_regmap,
@@ -379,16 +325,16 @@ static const struct regulator_ops as3722_ldo0_ops = { · 2 unmodified lines
379325 .list_voltage = regulator_list_voltage_linear,
380326 .get_voltage_sel = regulator_get_voltage_sel_regmap,
381327 .set_voltage_sel = regulator_set_voltage_sel_regmap,
382− .get_current_limit = as3722_ldo_get_current_limit,
383− .set_current_limit = as3722_ldo_set_current_limit,
328+ .get_current_limit = regulator_get_current_limit_regmap,
329+ .set_current_limit = regulator_set_current_limit_regmap,
384330 };
385331
386332 static const struct regulator_ops as3722_ldo0_extcntrl_ops = {
387333 .list_voltage = regulator_list_voltage_linear,
388334 .get_voltage_sel = regulator_get_voltage_sel_regmap,
389335 .set_voltage_sel = regulator_set_voltage_sel_regmap,
390− .get_current_limit = as3722_ldo_get_current_limit,
391− .set_current_limit = as3722_ldo_set_current_limit,
336+ .get_current_limit = regulator_get_current_limit_regmap,
337+ .set_current_limit = regulator_set_current_limit_regmap,
392338 };
393339
394340 static int as3722_ldo3_set_tracking_mode(struct as3722_regulators *as3722_reg,
@@ -440,8 +386,8 @@ static const struct regulator_ops as3722_ldo6_ops = { · 45 unmodified lines
440386 .set_voltage_sel = regulator_set_voltage_sel_regmap,
441387 .get_voltage_sel = regulator_get_voltage_sel_regmap,
442388 .list_voltage = regulator_list_voltage_linear_range,
443− .get_current_limit = as3722_ldo_get_current_limit,
444− .set_current_limit = as3722_ldo_set_current_limit,
389+ .get_current_limit = regulator_get_current_limit_regmap,
390+ .set_current_limit = regulator_set_current_limit_regmap,
445391 .get_bypass = regulator_get_bypass_regmap,
446392 .set_bypass = regulator_set_bypass_regmap,
447393 };
@@ -451,8 +397,8 @@ static const struct regulator_ops as3722_ldo6_extcntrl_ops = { · 3 unmodified lines
451397 .set_voltage_sel = regulator_set_voltage_sel_regmap,
452398 .get_voltage_sel = regulator_get_voltage_sel_regmap,
453399 .list_voltage = regulator_list_voltage_linear_range,
454− .get_current_limit = as3722_ldo_get_current_limit,
455− .set_current_limit = as3722_ldo_set_current_limit,
400+ .get_current_limit = regulator_get_current_limit_regmap,
401+ .set_current_limit = regulator_set_current_limit_regmap,
456402 .get_bypass = regulator_get_bypass_regmap,
457403 .set_bypass = regulator_set_bypass_regmap,
458404 };
@@ -471,8 +417,8 @@ static const struct regulator_ops as3722_ldo_ops = { · 12 unmodified lines
471417 .set_voltage_sel = regulator_set_voltage_sel_regmap,
472418 .get_voltage_sel = regulator_get_voltage_sel_regmap,
473419 .list_voltage = regulator_list_voltage_linear_range,
474− .get_current_limit = as3722_ldo_get_current_limit,
475− .set_current_limit = as3722_ldo_set_current_limit,
420+ .get_current_limit = regulator_get_current_limit_regmap,
421+ .set_current_limit = regulator_set_current_limit_regmap,
476422 };
477423
478424 static const struct regulator_ops as3722_ldo_extcntrl_ops = {
@@ -480,8 +426,8 @@ static const struct regulator_ops as3722_ldo_extcntrl_ops = { · 1 unmodified line
480426 .set_voltage_sel = regulator_set_voltage_sel_regmap,
481427 .get_voltage_sel = regulator_get_voltage_sel_regmap,
482428 .list_voltage = regulator_list_voltage_linear_range,
483− .get_current_limit = as3722_ldo_get_current_limit,
484− .set_current_limit = as3722_ldo_set_current_limit,
429+ .get_current_limit = regulator_get_current_limit_regmap,
430+ .set_current_limit = regulator_set_current_limit_regmap,
485431 };
486432
487433 static unsigned int as3722_sd_get_mode(struct regulator_dev *rdev)
@@ -539,85 +485,6 @@ static int as3722_sd_set_mode(struct regulator_dev *rdev, · 51 unmodified lines
539485 return ret;
540486 }
541487
542−static int as3722_sd016_get_current_limit(struct regulator_dev *rdev)
543−{
544− struct as3722_regulators *as3722_regs = rdev_get_drvdata(rdev);
545− struct as3722 *as3722 = as3722_regs->as3722;
546− int id = rdev_get_id(rdev);
547− u32 val, reg;
548− int mask;
549− int ret;
550−
551− switch (id) {
552− case AS3722_REGULATOR_ID_SD0:
553− reg = AS3722_OVCURRENT_REG;
554− mask = AS3722_OVCURRENT_SD0_TRIP_MASK;
555− break;
556− case AS3722_REGULATOR_ID_SD1:
557− reg = AS3722_OVCURRENT_REG;
558− mask = AS3722_OVCURRENT_SD1_TRIP_MASK;
559− break;
560− case AS3722_REGULATOR_ID_SD6:
561− reg = AS3722_OVCURRENT_DEB_REG;
562− mask = AS3722_OVCURRENT_SD6_TRIP_MASK;
563− break;
564− default:
565− return -EINVAL;
566− }
567− ret = as3722_read(as3722, reg, &val);
568− if (ret < 0) {
569− dev_err(as3722_regs->dev, "Reg 0x%02x read failed: %d\n",
570− reg, ret);
571− return ret;
572− }
573− val &= mask;
574− val >>= ffs(mask) - 1;
575− if (val == 3)
576− return -EINVAL;
577− return as3722_sd016_current[val];
578−}
579−
580−static int as3722_sd016_set_current_limit(struct regulator_dev *rdev,
581− int min_uA, int max_uA)
582−{
583− struct as3722_regulators *as3722_regs = rdev_get_drvdata(rdev);
584− struct as3722 *as3722 = as3722_regs->as3722;
585− int id = rdev_get_id(rdev);
586− int ret;
587− int val;
588− int mask;
589− u32 reg;
590−
591− ret = as3722_current_to_index(min_uA, max_uA, as3722_sd016_current,
592− ARRAY_SIZE(as3722_sd016_current));
593− if (ret < 0) {
594− dev_err(as3722_regs->dev,
595− "Current range min:max = %d:%d does not support\n",
596− min_uA, max_uA);
597− return ret;
598− }
599−
600− switch (id) {
601− case AS3722_REGULATOR_ID_SD0:
602− reg = AS3722_OVCURRENT_REG;
603− mask = AS3722_OVCURRENT_SD0_TRIP_MASK;
604− break;
605− case AS3722_REGULATOR_ID_SD1:
606− reg = AS3722_OVCURRENT_REG;
607− mask = AS3722_OVCURRENT_SD1_TRIP_MASK;
608− break;
609− case AS3722_REGULATOR_ID_SD6:
610− reg = AS3722_OVCURRENT_DEB_REG;
611− mask = AS3722_OVCURRENT_SD6_TRIP_MASK;
612− break;
613− default:
614− return -EINVAL;
615− }
616− ret <<= ffs(mask) - 1;
617− val = ret & mask;
618− return as3722_update_bits(as3722, reg, mask, val);
619−}
620−
621488 static bool as3722_sd0_is_low_voltage(struct as3722_regulators *as3722_regs)
622489 {
623490 int err;
@@ -649,8 +516,8 @@ static const struct regulator_ops as3722_sd016_ops = { · 25 unmodified lines
649516 .map_voltage = regulator_map_voltage_linear,
650517 .get_voltage_sel = regulator_get_voltage_sel_regmap,
651518 .set_voltage_sel = regulator_set_voltage_sel_regmap,
652− .get_current_limit = as3722_sd016_get_current_limit,
653− .set_current_limit = as3722_sd016_set_current_limit,
519+ .get_current_limit = regulator_get_current_limit_regmap,
520+ .set_current_limit = regulator_set_current_limit_regmap,
654521 .get_mode = as3722_sd_get_mode,
655522 .set_mode = as3722_sd_set_mode,
656523 };
@@ -660,8 +527,8 @@ static const struct regulator_ops as3722_sd016_extcntrl_ops = { · 3 unmodified lines
660527 .map_voltage = regulator_map_voltage_linear,
661528 .get_voltage_sel = regulator_get_voltage_sel_regmap,
662529 .set_voltage_sel = regulator_set_voltage_sel_regmap,
663− .get_current_limit = as3722_sd016_get_current_limit,
664− .set_current_limit = as3722_sd016_set_current_limit,
530+ .get_current_limit = regulator_get_current_limit_regmap,
531+ .set_current_limit = regulator_set_current_limit_regmap,
665532 .get_mode = as3722_sd_get_mode,
666533 .set_mode = as3722_sd_set_mode,
667534 };
@@ -807,42 +674,45 @@ static int as3722_regulator_probe(struct platform_device *pdev) · 139 unmodified lines
807674 config.regmap = as3722->regmap;
808675
809676 for (id = 0; id < AS3722_REGULATOR_ID_MAX; id++) {
677+ struct regulator_desc *desc;
678+
679+ desc = &as3722_regs->desc[id];
810680 reg_config = &as3722_regs->reg_config_data[id];
811681
812− as3722_regs->desc[id].name = as3722_reg_lookup[id].name;
813− as3722_regs->desc[id].supply_name = as3722_reg_lookup[id].sname;
814− as3722_regs->desc[id].id = as3722_reg_lookup[id].regulator_id;
815− as3722_regs->desc[id].n_voltages =
816− as3722_reg_lookup[id].n_voltages;
817− as3722_regs->desc[id].type = REGULATOR_VOLTAGE;
818− as3722_regs->desc[id].owner = THIS_MODULE;
819− as3722_regs->desc[id].enable_reg =
820− as3722_reg_lookup[id].enable_reg;
821− as3722_regs->desc[id].enable_mask =
822− as3722_reg_lookup[id].enable_mask;
823− as3722_regs->desc[id].vsel_reg = as3722_reg_lookup[id].vsel_reg;
824− as3722_regs->desc[id].vsel_mask =
825− as3722_reg_lookup[id].vsel_mask;
682+ desc->name = as3722_reg_lookup[id].name;
683+ desc->supply_name = as3722_reg_lookup[id].sname;
684+ desc->id = as3722_reg_lookup[id].regulator_id;
685+ desc->n_voltages = as3722_reg_lookup[id].n_voltages;
686+ desc->type = REGULATOR_VOLTAGE;
687+ desc->owner = THIS_MODULE;
688+ desc->enable_reg = as3722_reg_lookup[id].enable_reg;
689+ desc->enable_mask = as3722_reg_lookup[id].enable_mask;
690+ desc->vsel_reg = as3722_reg_lookup[id].vsel_reg;
691+ desc->vsel_mask = as3722_reg_lookup[id].vsel_mask;
826692 switch (id) {
827693 case AS3722_REGULATOR_ID_LDO0:
828694 if (reg_config->ext_control)
829695 ops = &as3722_ldo0_extcntrl_ops;
830696 else
831697 ops = &as3722_ldo0_ops;
832− as3722_regs->desc[id].min_uV = 825000;
833− as3722_regs->desc[id].uV_step = 25000;
834− as3722_regs->desc[id].linear_min_sel = 1;
835− as3722_regs->desc[id].enable_time = 500;
698+ desc->min_uV = 825000;
699+ desc->uV_step = 25000;
700+ desc->linear_min_sel = 1;
701+ desc->enable_time = 500;
702+ desc->curr_table = as3722_ldo_current;
703+ desc->n_current_limits = ARRAY_SIZE(as3722_ldo_current);
704+ desc->csel_reg = as3722_reg_lookup[id].vsel_reg;
705+ desc->csel_mask = AS3722_LDO_ILIMIT_MASK;
836706 break;
837707 case AS3722_REGULATOR_ID_LDO3:
838708 if (reg_config->ext_control)
839709 ops = &as3722_ldo3_extcntrl_ops;
840710 else
841711 ops = &as3722_ldo3_ops;
842− as3722_regs->desc[id].min_uV = 620000;
843− as3722_regs->desc[id].uV_step = 20000;
844− as3722_regs->desc[id].linear_min_sel = 1;
845− as3722_regs->desc[id].enable_time = 500;
712+ desc->min_uV = 620000;
713+ desc->uV_step = 20000;
714+ desc->linear_min_sel = 1;
715+ desc->enable_time = 500;
846716 if (reg_config->enable_tracking) {
847717 ret = as3722_ldo3_set_tracking_mode(as3722_regs,
848718 id, AS3722_LDO3_MODE_PMOS_TRACKING);
@@ -859,18 +729,17 @@ static int as3722_regulator_probe(struct platform_device *pdev) · 10 unmodified lines
859729 ops = &as3722_ldo6_extcntrl_ops;
860730 else
861731 ops = &as3722_ldo6_ops;
862− as3722_regs->desc[id].enable_time = 500;
863− as3722_regs->desc[id].bypass_reg =
864− AS3722_LDO6_VOLTAGE_REG;
865− as3722_regs->desc[id].bypass_mask =
866− AS3722_LDO_VSEL_MASK;
867− as3722_regs->desc[id].bypass_val_on =
868− AS3722_LDO6_VSEL_BYPASS;
869− as3722_regs->desc[id].bypass_val_off =
870− AS3722_LDO6_VSEL_BYPASS;
871− as3722_regs->desc[id].linear_ranges = as3722_ldo_ranges;
872− as3722_regs->desc[id].n_linear_ranges =
873− ARRAY_SIZE(as3722_ldo_ranges);
732+ desc->enable_time = 500;
733+ desc->bypass_reg = AS3722_LDO6_VOLTAGE_REG;
734+ desc->bypass_mask = AS3722_LDO_VSEL_MASK;
735+ desc->bypass_val_on = AS3722_LDO6_VSEL_BYPASS;
736+ desc->bypass_val_off = AS3722_LDO6_VSEL_BYPASS;
737+ desc->linear_ranges = as3722_ldo_ranges;
738+ desc->n_linear_ranges = ARRAY_SIZE(as3722_ldo_ranges);
739+ desc->curr_table = as3722_ldo_current;
740+ desc->n_current_limits = ARRAY_SIZE(as3722_ldo_current);
741+ desc->csel_reg = as3722_reg_lookup[id].vsel_reg;
742+ desc->csel_mask = AS3722_LDO_ILIMIT_MASK;
874743 break;
875744 case AS3722_REGULATOR_ID_SD0:
876745 case AS3722_REGULATOR_ID_SD1:
@@ -889,9 +758,25 @@ static int as3722_regulator_probe(struct platform_device *pdev) · 12 unmodified lines
889758 AS3722_SD0_VSEL_MAX + 1;
890759 as3722_regs->desc[id].min_uV = 610000;
891760 }
892− as3722_regs->desc[id].uV_step = 10000;
893− as3722_regs->desc[id].linear_min_sel = 1;
894− as3722_regs->desc[id].enable_time = 600;
761+ desc->uV_step = 10000;
762+ desc->linear_min_sel = 1;
763+ desc->enable_time = 600;
764+ desc->curr_table = as3722_sd016_current;
765+ desc->n_current_limits =
766+ ARRAY_SIZE(as3722_sd016_current);
767+ if (id == AS3722_REGULATOR_ID_SD0) {
768+ desc->csel_reg = AS3722_OVCURRENT_REG;
769+ desc->csel_mask =
770+ AS3722_OVCURRENT_SD0_TRIP_MASK;
771+ } else if (id == AS3722_REGULATOR_ID_SD1) {
772+ desc->csel_reg = AS3722_OVCURRENT_REG;
773+ desc->csel_mask =
774+ AS3722_OVCURRENT_SD1_TRIP_MASK;
775+ } else if (id == AS3722_REGULATOR_ID_SD6) {
776+ desc->csel_reg = AS3722_OVCURRENT_DEB_REG;
777+ desc->csel_mask =
778+ AS3722_OVCURRENT_SD6_TRIP_MASK;
779+ }
895780 break;
896781 case AS3722_REGULATOR_ID_SD2:
897782 case AS3722_REGULATOR_ID_SD3:
@@ -901,9 +786,8 @@ static int as3722_regulator_probe(struct platform_device *pdev) · 3 unmodified lines
901786 ops = &as3722_sd2345_extcntrl_ops;
902787 else
903788 ops = &as3722_sd2345_ops;
904− as3722_regs->desc[id].linear_ranges =
905− as3722_sd2345_ranges;
906− as3722_regs->desc[id].n_linear_ranges =
789+ desc->linear_ranges = as3722_sd2345_ranges;
790+ desc->n_linear_ranges =
907791 ARRAY_SIZE(as3722_sd2345_ranges);
908792 break;
909793 default:
@@ -911,17 +795,19 @@ static int as3722_regulator_probe(struct platform_device *pdev) · 1 unmodified line
911795 ops = &as3722_ldo_extcntrl_ops;
912796 else
913797 ops = &as3722_ldo_ops;
914− as3722_regs->desc[id].enable_time = 500;
915− as3722_regs->desc[id].linear_ranges = as3722_ldo_ranges;
916− as3722_regs->desc[id].n_linear_ranges =
917− ARRAY_SIZE(as3722_ldo_ranges);
798+ desc->enable_time = 500;
799+ desc->linear_ranges = as3722_ldo_ranges;
800+ desc->n_linear_ranges = ARRAY_SIZE(as3722_ldo_ranges);
801+ desc->curr_table = as3722_ldo_current;
802+ desc->n_current_limits = ARRAY_SIZE(as3722_ldo_current);
803+ desc->csel_reg = as3722_reg_lookup[id].vsel_reg;
804+ desc->csel_mask = AS3722_LDO_ILIMIT_MASK;
918805 break;
919806 }
920− as3722_regs->desc[id].ops = ops;
807+ desc->ops = ops;
921808 config.init_data = reg_config->reg_init;
922809 config.of_node = as3722_regulator_matches[id].of_node;
923− rdev = devm_regulator_register(&pdev->dev,
924− &as3722_regs->desc[id], &config);
810+ rdev = devm_regulator_register(&pdev->dev, desc, &config);
925811 if (IS_ERR(rdev)) {
926812 ret = PTR_ERR(rdev);
927813 dev_err(&pdev->dev, "regulator %d register failed %d\n",
@@ -929,7 +815,6 @@ static int as3722_regulator_probe(struct platform_device *pdev) · 1 unmodified line
929815 return ret;
930816 }
931817
932− as3722_regs->rdevs[id] = rdev;
933818 if (reg_config->ext_control) {
934819 ret = regulator_enable_regmap(rdev);
935820 if (ret < 0) {
drivers/regulator/axp20x-regulator.c+8−15
@@ -367,16 +367,14 @@ static const int axp209_dcdc2_ldo3_slew_rates[] = { · 366 unmodified lines
367367 static int axp20x_set_ramp_delay(struct regulator_dev *rdev, int ramp)
368368 {
369369 struct axp20x_dev *axp20x = rdev_get_drvdata(rdev);
370− const struct regulator_desc *desc;
370+ int id = rdev_get_id(rdev);
371371 u8 reg, mask, enable, cfg = 0xff;
372372 const int *slew_rates;
373373 int rate_count = 0;
374374
375− desc = rdev->desc;
376−
377375 switch (axp20x->variant) {
378376 case AXP209_ID:
379− if (desc->id == AXP20X_DCDC2) {
377+ if (id == AXP20X_DCDC2) {
380378 slew_rates = axp209_dcdc2_ldo3_slew_rates;
381379 rate_count = ARRAY_SIZE(axp209_dcdc2_ldo3_slew_rates);
382380 reg = AXP20X_DCDC2_LDO3_V_RAMP;
@@ -388,7 +386,7 @@ static int axp20x_set_ramp_delay(struct regulator_dev *rdev, int ramp) · 5 unmodified lines
388386 break;
389387 }
390388
391− if (desc->id == AXP20X_LDO3) {
389+ if (id == AXP20X_LDO3) {
392390 slew_rates = axp209_dcdc2_ldo3_slew_rates;
393391 rate_count = ARRAY_SIZE(axp209_dcdc2_ldo3_slew_rates);
394392 reg = AXP20X_DCDC2_LDO3_V_RAMP;
@@ -435,16 +433,11 @@ static int axp20x_set_ramp_delay(struct regulator_dev *rdev, int ramp) · 40 unmodified lines
435433 static int axp20x_regulator_enable_regmap(struct regulator_dev *rdev)
436434 {
437435 struct axp20x_dev *axp20x = rdev_get_drvdata(rdev);
438− const struct regulator_desc *desc;
439−
440− if (!rdev)
441− return -EINVAL;
442−
443− desc = rdev->desc;
436+ int id = rdev_get_id(rdev);
444437
445438 switch (axp20x->variant) {
446439 case AXP209_ID:
447− if ((desc->id == AXP20X_LDO3) &&
440+ if ((id == AXP20X_LDO3) &&
448441 rdev->constraints && rdev->constraints->soft_start) {
449442 int v_out;
450443 int ret;
@@ -1028,7 +1021,7 @@ static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq) · 577 unmodified lines
10281021 * (See include/linux/mfd/axp20x.h)
10291022 */
10301023 reg = AXP803_DCDC_FREQ_CTRL;
1031− /* Fall through to the check below.*/
1024+ /* Fall through - to the check below.*/
10321025 case AXP806_ID:
10331026 /*
10341027 * AXP806 also have DCDC work frequency setting register at a
@@ -1119,12 +1112,12 @@ static int axp20x_set_dcdc_workmode(struct regulator_dev *rdev, int id, u32 work · 84 unmodified lines
11191112 break;
11201113
11211114 case AXP806_ID:
1122− reg = AXP806_DCDC_MODE_CTRL2;
11231115 /*
11241116 * AXP806 DCDC regulator IDs have the same range as AXP22X.
1125− * Fall through to the check below.
11261117 * (See include/linux/mfd/axp20x.h)
11271118 */
1119+ reg = AXP806_DCDC_MODE_CTRL2;
1120+ /* Fall through - to the check below. */
11281121 case AXP221_ID:
11291122 case AXP223_ID:
11301123 case AXP809_ID:
drivers/regulator/bcm590xx-regulator.c+2−103
@@ -103,10 +103,6 @@ · 102 unmodified lines
103103 ((n > BCM590XX_REG_VSR) && (n < BCM590XX_REG_VBUS))
104104 #define BCM590XX_REG_IS_VBUS(n) (n == BCM590XX_REG_VBUS)
105105
106−struct bcm590xx_board {
107− struct regulator_init_data *bcm590xx_pmu_init_data[BCM590XX_NUM_REGS];
108−};
109−
110106 /* LDO group A: supported voltages in microvolts */
111107 static const unsigned int ldo_a_table[] = {
112108 1200000, 1800000, 2500000, 2700000, 2800000,
@@ -280,105 +276,15 @@ static const struct regulator_ops bcm590xx_ops_vbus = { · 167 unmodified lines
280276 .disable = regulator_disable_regmap,
281277 };
282278
283−#define BCM590XX_MATCH(_name, _id) \
284− { \
285− .name = #_name, \
286− .driver_data = (void *)&bcm590xx_regs[BCM590XX_REG_##_id], \
287− }
288−
289−static struct of_regulator_match bcm590xx_matches[] = {
290− BCM590XX_MATCH(rfldo, RFLDO),
291− BCM590XX_MATCH(camldo1, CAMLDO1),
292− BCM590XX_MATCH(camldo2, CAMLDO2),
293− BCM590XX_MATCH(simldo1, SIMLDO1),
294− BCM590XX_MATCH(simldo2, SIMLDO2),
295− BCM590XX_MATCH(sdldo, SDLDO),
296− BCM590XX_MATCH(sdxldo, SDXLDO),
297− BCM590XX_MATCH(mmcldo1, MMCLDO1),
298− BCM590XX_MATCH(mmcldo2, MMCLDO2),
299− BCM590XX_MATCH(audldo, AUDLDO),
300− BCM590XX_MATCH(micldo, MICLDO),
301− BCM590XX_MATCH(usbldo, USBLDO),
302− BCM590XX_MATCH(vibldo, VIBLDO),
303− BCM590XX_MATCH(csr, CSR),
304− BCM590XX_MATCH(iosr1, IOSR1),
305− BCM590XX_MATCH(iosr2, IOSR2),
306− BCM590XX_MATCH(msr, MSR),
307− BCM590XX_MATCH(sdsr1, SDSR1),
308− BCM590XX_MATCH(sdsr2, SDSR2),
309− BCM590XX_MATCH(vsr, VSR),
310− BCM590XX_MATCH(gpldo1, GPLDO1),
311− BCM590XX_MATCH(gpldo2, GPLDO2),
312− BCM590XX_MATCH(gpldo3, GPLDO3),
313− BCM590XX_MATCH(gpldo4, GPLDO4),
314− BCM590XX_MATCH(gpldo5, GPLDO5),
315− BCM590XX_MATCH(gpldo6, GPLDO6),
316− BCM590XX_MATCH(vbus, VBUS),
317−};
318−
319−static struct bcm590xx_board *bcm590xx_parse_dt_reg_data(
320− struct platform_device *pdev,
321− struct of_regulator_match **bcm590xx_reg_matches)
322−{
323− struct bcm590xx_board *data;
324− struct device_node *np = pdev->dev.parent->of_node;
325− struct device_node *regulators;
326− struct of_regulator_match *matches = bcm590xx_matches;
327− int count = ARRAY_SIZE(bcm590xx_matches);
328− int idx = 0;
329− int ret;
330−
331− if (!np) {
332− dev_err(&pdev->dev, "of node not found\n");
333− return NULL;
334− }
335−
336− data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
337− if (!data)
338− return NULL;
339−
340− np = of_node_get(np);
341− regulators = of_get_child_by_name(np, "regulators");
342− if (!regulators) {
343− dev_warn(&pdev->dev, "regulator node not found\n");
344− return NULL;
345− }
346−
347− ret = of_regulator_match(&pdev->dev, regulators, matches, count);
348− of_node_put(regulators);
349− if (ret < 0) {
350− dev_err(&pdev->dev, "Error parsing regulator init data: %d\n",
351− ret);
352− return NULL;
353− }
354−
355− *bcm590xx_reg_matches = matches;
356−
357− for (idx = 0; idx < count; idx++) {
358− if (!matches[idx].init_data || !matches[idx].of_node)
359− continue;
360−
361− data->bcm590xx_pmu_init_data[idx] = matches[idx].init_data;
362− }
363−
364− return data;
365−}
366−
367279 static int bcm590xx_probe(struct platform_device *pdev)
368280 {
369281 struct bcm590xx *bcm590xx = dev_get_drvdata(pdev->dev.parent);
370− struct bcm590xx_board *pmu_data = NULL;
371282 struct bcm590xx_reg *pmu;
372283 struct regulator_config config = { };
373284 struct bcm590xx_info *info;
374− struct regulator_init_data *reg_data;
375285 struct regulator_dev *rdev;
376− struct of_regulator_match *bcm590xx_reg_matches = NULL;
377286 int i;
378287
379− pmu_data = bcm590xx_parse_dt_reg_data(pdev,
380− &bcm590xx_reg_matches);
381−
382288 pmu = devm_kzalloc(&pdev->dev, sizeof(*pmu), GFP_KERNEL);
383289 if (!pmu)
384290 return -ENOMEM;
@@ -397,13 +303,10 @@ static int bcm590xx_probe(struct platform_device *pdev) · 12 unmodified lines
397303 info = bcm590xx_regs;
398304
399305 for (i = 0; i < BCM590XX_NUM_REGS; i++, info++) {
400− if (pmu_data)
401− reg_data = pmu_data->bcm590xx_pmu_init_data[i];
402− else
403− reg_data = NULL;
404−
405306 /* Register the regulators */
406307 pmu->desc[i].name = info->name;
308+ pmu->desc[i].of_match = of_match_ptr(info->name);
309+ pmu->desc[i].regulators_node = of_match_ptr("regulators");
407310 pmu->desc[i].supply_name = info->vin_name;
408311 pmu->desc[i].id = i;
409312 pmu->desc[i].volt_table = info->volt_table;
@@ -433,16 +336,12 @@ static int bcm590xx_probe(struct platform_device *pdev) · 23 unmodified lines
433336 pmu->desc[i].owner = THIS_MODULE;
434337
435338 config.dev = bcm590xx->dev;
436− config.init_data = reg_data;
437339 config.driver_data = pmu;
438340 if (BCM590XX_REG_IS_GPLDO(i) || BCM590XX_REG_IS_VBUS(i))
439341 config.regmap = bcm590xx->regmap_sec;
440342 else
441343 config.regmap = bcm590xx->regmap_pri;
442344
443− if (bcm590xx_reg_matches)
444− config.of_node = bcm590xx_reg_matches[i].of_node;
445−
446345 rdev = devm_regulator_register(&pdev->dev, &pmu->desc[i],
447346 &config);
448347 if (IS_ERR(rdev)) {
drivers/regulator/bd718x7-regulator.c+2−2
@@ -27,8 +27,8 @@ · 26 unmodified lines
2727 static int bd718xx_buck1234_set_ramp_delay(struct regulator_dev *rdev,
2828 int ramp_delay)
2929 {
30− int id = rdev->desc->id;
31− unsigned int ramp_value = BUCK_RAMPRATE_10P00MV;
30+ int id = rdev_get_id(rdev);
31+ unsigned int ramp_value;
3232
3333 dev_dbg(&rdev->dev, "Buck[%d] Set Ramp = %d\n", id + 1,
3434 ramp_delay);
drivers/regulator/core.c+9−6
@@ -1339,9 +1339,7 @@ static int set_machine_constraints(struct regulator_dev *rdev, · 1338 unmodified lines
13391339 * We'll only apply the initial system load if an
13401340 * initial mode wasn't specified.
13411341 */
1342− regulator_lock(rdev);
13431342 drms_uA_update(rdev);
1344− regulator_unlock(rdev);
13451343 }
13461344
13471345 if ((rdev->constraints->ramp_delay || rdev->constraints->ramp_disable)
@@ -3005,7 +3003,7 @@ EXPORT_SYMBOL_GPL(regulator_get_linear_step); · 1657 unmodified lines
30053003 * @min_uV: Minimum required voltage in uV.
30063004 * @max_uV: Maximum required voltage in uV.
30073005 *
3008− * Returns a boolean or a negative error code.
3006+ * Returns a boolean.
30093007 */
30103008 int regulator_is_supported_voltage(struct regulator *regulator,
30113009 int min_uV, int max_uV)
@@ -3029,7 +3027,7 @@ int regulator_is_supported_voltage(struct regulator *regulator, · 17 unmodified lines
30293027
30303028 ret = regulator_count_voltages(regulator);
30313029 if (ret < 0)
3032− return ret;
3030+ return 0;
30333031 voltages = ret;
30343032
30353033 for (i = 0; i < voltages; i++) {
@@ -4345,8 +4343,6 @@ int regulator_bulk_get(struct device *dev, int num_consumers, · 1309 unmodified lines
43454343 consumers[i].supply);
43464344 if (IS_ERR(consumers[i].consumer)) {
43474345 ret = PTR_ERR(consumers[i].consumer);
4348− dev_err(dev, "Failed to get supply '%s': %d\n",
4349− consumers[i].supply, ret);
43504346 consumers[i].consumer = NULL;
43514347 goto err;
43524348 }
@@ -4355,6 +4351,13 @@ int regulator_bulk_get(struct device *dev, int num_consumers, · 2 unmodified lines
43554351 return 0;
43564352
43574353 err:
4354+ if (ret != -EPROBE_DEFER)
4355+ dev_err(dev, "Failed to get supply '%s': %d\n",
4356+ consumers[i].supply, ret);
4357+ else
4358+ dev_dbg(dev, "Failed to get supply '%s', deferring\n",
4359+ consumers[i].supply);
4360+
43584361 while (--i >= 0)
43594362 regulator_put(consumers[i].consumer);
43604363
drivers/regulator/cpcap-regulator.c+4−11
@@ -505,17 +505,12 @@ MODULE_DEVICE_TABLE(of, cpcap_regulator_id_table); · 504 unmodified lines
505505 static int cpcap_regulator_probe(struct platform_device *pdev)
506506 {
507507 struct cpcap_ddata *ddata;
508− const struct of_device_id *match;
508+ const struct cpcap_regulator *match_data;
509509 struct regulator_config config;
510− struct regulator_init_data init_data;
511510 int i;
512511
513− match = of_match_device(of_match_ptr(cpcap_regulator_id_table),
514− &pdev->dev);
515− if (!match)
516− return -EINVAL;
517−
518− if (!match->data) {
512+ match_data = of_device_get_match_data(&pdev->dev);
513+ if (!match_data) {
519514 dev_err(&pdev->dev, "no configuration data found\n");
520515
521516 return -ENODEV;
@@ -530,14 +525,12 @@ static int cpcap_regulator_probe(struct platform_device *pdev) · 8 unmodified lines
530525 return -ENODEV;
531526
532527 ddata->dev = &pdev->dev;
533− ddata->soc = match->data;
528+ ddata->soc = match_data;
534529 platform_set_drvdata(pdev, ddata);
535530
536531 memset(&config, 0, sizeof(config));
537− memset(&init_data, 0, sizeof(init_data));
538532 config.dev = &pdev->dev;
539533 config.regmap = ddata->reg;
540− config.init_data = &init_data;
541534
542535 for (i = 0; i < CPCAP_NR_REGULATORS; i++) {
543536 const struct cpcap_regulator *regulator = &ddata->soc[i];
drivers/regulator/da903x.c+6−10
@@ -1,13 +1,9 @@
1−/*
2− * Regulators driver for Dialog Semiconductor DA903x
3− *
4− * Copyright (C) 2006-2008 Marvell International Ltd.
5− * Copyright (C) 2008 Compulab Ltd.
6− *
7− * This program is free software; you can redistribute it and/or modify
8− * it under the terms of the GNU General Public License version 2 as
9− * published by the Free Software Foundation.
10− */
1+// SPDX-License-Identifier: GPL-2.0
2+//
3+// Regulators driver for Dialog Semiconductor DA903x
4+//
5+// Copyright (C) 2006-2008 Marvell International Ltd.
6+// Copyright (C) 2008 Compulab Ltd.
117
128 #include <linux/kernel.h>
139 #include <linux/init.h>
drivers/regulator/da9052-regulator.c+13−42
@@ -1,16 +1,10 @@
1−/*
2−* da9052-regulator.c: Regulator driver for DA9052
3−*
4−* Copyright(c) 2011 Dialog Semiconductor Ltd.
5−*
6−* Author: David Dajun Chen <dchen@diasemi.com>
7−*
8−* This program is free software; you can redistribute it and/or modify
9−* it under the terms of the GNU General Public License as published by
10−* the Free Software Foundation; either version 2 of the License, or
11−* (at your option) any later version.
12−*
13−*/
1+// SPDX-License-Identifier: GPL-2.0+
2+//
3+// da9052-regulator.c: Regulator driver for DA9052
4+//
5+// Copyright(c) 2011 Dialog Semiconductor Ltd.
6+//
7+// Author: David Dajun Chen <dchen@diasemi.com>
148
159 #include <linux/module.h>
1610 #include <linux/moduleparam.h>
@@ -19,10 +13,8 @@ · 2 unmodified lines
1913 #include <linux/platform_device.h>
2014 #include <linux/regulator/driver.h>
2115 #include <linux/regulator/machine.h>
22−#ifdef CONFIG_OF
2316 #include <linux/of.h>
2417 #include <linux/regulator/of_regulator.h>
25−#endif
2618
2719 #include <linux/mfd/da9052/da9052.h>
2820 #include <linux/mfd/da9052/reg.h>
@@ -294,6 +286,8 @@ static const struct regulator_ops da9052_ldo_ops = { · 265 unmodified lines
294286 {\
295287 .reg_desc = {\
296288 .name = #_name,\
289+ .of_match = of_match_ptr(#_name),\
290+ .regulators_node = of_match_ptr("regulators"),\
297291 .ops = &da9052_ldo_ops,\
298292 .type = REGULATOR_VOLTAGE,\
299293 .id = DA9052_ID_##_id,\
@@ -314,6 +308,8 @@ static const struct regulator_ops da9052_ldo_ops = { · 14 unmodified lines
314308 {\
315309 .reg_desc = {\
316310 .name = #_name,\
311+ .of_match = of_match_ptr(#_name),\
312+ .regulators_node = of_match_ptr("regulators"),\
317313 .ops = &da9052_dcdc_ops,\
318314 .type = REGULATOR_VOLTAGE,\
319315 .id = DA9052_ID_##_id,\
@@ -417,36 +413,11 @@ static int da9052_regulator_probe(struct platform_device *pdev) · 97 unmodified lines
417413 return -EINVAL;
418414 }
419415
420− config.dev = &pdev->dev;
416+ config.dev = da9052->dev;
421417 config.driver_data = regulator;
422418 config.regmap = da9052->regmap;
423− if (pdata) {
419+ if (pdata)
424420 config.init_data = pdata->regulators[cell->id];
425− } else {
426−#ifdef CONFIG_OF
427− struct device_node *nproot = da9052->dev->of_node;
428− struct device_node *np;
429−
430− if (!nproot)
431− return -ENODEV;
432−
433− nproot = of_get_child_by_name(nproot, "regulators");
434− if (!nproot)
435− return -ENODEV;
436−
437− for_each_child_of_node(nproot, np) {
438− if (of_node_name_eq(np,
439− regulator->info->reg_desc.name)) {
440− config.init_data = of_get_regulator_init_data(
441− &pdev->dev, np,
442− &regulator->info->reg_desc);
443− config.of_node = np;
444− break;
445− }
446− }
447− of_node_put(nproot);
448−#endif
449− }
450421
451422 regulator->rdev = devm_regulator_register(&pdev->dev,
452423 &regulator->info->reg_desc,
drivers/regulator/da9055-regulator.c+15−74
@@ -1,16 +1,10 @@
1−/*
2−* Regulator driver for DA9055 PMIC
3−*
4−* Copyright(c) 2012 Dialog Semiconductor Ltd.
5−*
6−* Author: David Dajun Chen <dchen@diasemi.com>
7−*
8−* This program is free software; you can redistribute it and/or modify
9−* it under the terms of the GNU General Public License as published by
10−* the Free Software Foundation; either version 2 of the License, or
11−* (at your option) any later version.
12−*
13−*/
1+// SPDX-License-Identifier: GPL-2.0+
2+//
3+// Regulator driver for DA9055 PMIC
4+//
5+// Copyright(c) 2012 Dialog Semiconductor Ltd.
6+//
7+// Author: David Dajun Chen <dchen@diasemi.com>
148
159 #include <linux/module.h>
1610 #include <linux/init.h>
@@ -338,6 +332,8 @@ static const struct regulator_ops da9055_ldo_ops = { · 321 unmodified lines
338332 {\
339333 .reg_desc = {\
340334 .name = #_id,\
335+ .of_match = of_match_ptr(#_id),\
336+ .regulators_node = of_match_ptr("regulators"),\
341337 .ops = &da9055_ldo_ops,\
342338 .type = REGULATOR_VOLTAGE,\
343339 .id = DA9055_ID_##_id,\
@@ -366,6 +362,8 @@ static const struct regulator_ops da9055_ldo_ops = { · 22 unmodified lines
366362 {\
367363 .reg_desc = {\
368364 .name = #_id,\
365+ .of_match = of_match_ptr(#_id),\
366+ .regulators_node = of_match_ptr("regulators"),\
369367 .ops = &da9055_buck_ops,\
370368 .type = REGULATOR_VOLTAGE,\
371369 .id = DA9055_ID_##_id,\
@@ -487,8 +485,10 @@ static irqreturn_t da9055_ldo5_6_oc_irq(int irq, void *data) · 115 unmodified lines
487485 {
488486 struct da9055_regulator *regulator = data;
489487
488+ regulator_lock(regulator->rdev);
490489 regulator_notifier_call_chain(regulator->rdev,
491490 REGULATOR_EVENT_OVER_CURRENT, NULL);
491+ regulator_unlock(regulator->rdev);
492492
493493 return IRQ_HANDLED;
494494 }
@@ -507,59 +507,6 @@ static inline struct da9055_regulator_info *find_regulator_info(int id) · 12 unmodified lines
507507 return NULL;
508508 }
509509
510−#ifdef CONFIG_OF
511−static struct of_regulator_match da9055_reg_matches[] = {
512− { .name = "BUCK1", },
513− { .name = "BUCK2", },
514− { .name = "LDO1", },
515− { .name = "LDO2", },
516− { .name = "LDO3", },
517− { .name = "LDO4", },
518− { .name = "LDO5", },
519− { .name = "LDO6", },
520−};
521−
522−static int da9055_regulator_dt_init(struct platform_device *pdev,
523− struct da9055_regulator *regulator,
524− struct regulator_config *config,
525− int regid)
526−{
527− struct device_node *nproot, *np;
528− int ret;
529−
530− nproot = of_node_get(pdev->dev.parent->of_node);
531− if (!nproot)
532− return -ENODEV;
533−
534− np = of_get_child_by_name(nproot, "regulators");
535− if (!np)
536− return -ENODEV;
537−
538− ret = of_regulator_match(&pdev->dev, np, &da9055_reg_matches[regid], 1);
539− of_node_put(nproot);
540− if (ret < 0) {
541− dev_err(&pdev->dev, "Error matching regulator: %d\n", ret);
542− return ret;
543− }
544−
545− config->init_data = da9055_reg_matches[regid].init_data;
546− config->of_node = da9055_reg_matches[regid].of_node;
547−
548− if (!config->of_node)
549− return -ENODEV;
550−
551− return 0;
552−}
553−#else
554−static inline int da9055_regulator_dt_init(struct platform_device *pdev,
555− struct da9055_regulator *regulator,
556− struct regulator_config *config,
557− int regid)
558−{
559− return -ENODEV;
560−}
561−#endif /* CONFIG_OF */
562−
563510 static int da9055_regulator_probe(struct platform_device *pdev)
564511 {
565512 struct regulator_config config = { };
@@ -580,18 +527,12 @@ static int da9055_regulator_probe(struct platform_device *pdev) · 14 unmodified lines
580527 }
581528
582529 regulator->da9055 = da9055;
583− config.dev = &pdev->dev;
530+ config.dev = da9055->dev;
584531 config.driver_data = regulator;
585532 config.regmap = da9055->regmap;
586533
587− if (pdata) {
534+ if (pdata)
588535 config.init_data = pdata->regulators[pdev->id];
589− } else {
590− ret = da9055_regulator_dt_init(pdev, regulator, &config,
591− pdev->id);
592− if (ret < 0)
593− return ret;
594− }
595536
596537 ret = da9055_gpio_init(regulator, &config, pdata, pdev->id);
597538 if (ret < 0)
drivers/regulator/da9062-regulator.c+39−107
@@ -1,17 +1,8 @@
1−/*
2− * Regulator device driver for DA9061 and DA9062.
3− * Copyright (C) 2015-2017 Dialog Semiconductor
4− *
5− * This program is free software; you can redistribute it and/or
6− * modify it under the terms of the GNU General Public License
7− * as published by the Free Software Foundation; either version 2
8− * of the License, or (at your option) any later version.
9− *
10− * This program is distributed in the hope that it will be useful,
11− * but WITHOUT ANY WARRANTY; without even the implied warranty of
12− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13− * GNU General Public License for more details.
14− */
1+// SPDX-License-Identifier: GPL-2.0+
2+//
3+// Regulator device driver for DA9061 and DA9062.
4+// Copyright (C) 2015-2017 Dialog Semiconductor
5+
156 #include <linux/kernel.h>
167 #include <linux/module.h>
178 #include <linux/init.h>
@@ -53,16 +44,12 @@ enum { · 35 unmodified lines
5344 /* Regulator capabilities and registers description */
5445 struct da9062_regulator_info {
5546 struct regulator_desc desc;
56− /* Current limiting */
57− unsigned int n_current_limits;
58− const int *current_limits;
5947 /* Main register fields */
6048 struct reg_field mode;
6149 struct reg_field suspend;
6250 struct reg_field sleep;
6351 struct reg_field suspend_sleep;
6452 unsigned int suspend_vsel_reg;
65− struct reg_field ilimit;
6653 /* Event detection bit */
6754 struct reg_field oc_event;
6855 };
@@ -78,7 +65,6 @@ struct da9062_regulator { · 9 unmodified lines
7865 struct regmap_field *suspend;
7966 struct regmap_field *sleep;
8067 struct regmap_field *suspend_sleep;
81− struct regmap_field *ilimit;
8268 };
8369
8470 /* Encapsulates all information for the regulators driver */
@@ -104,7 +90,7 @@ enum { · 19 unmodified lines
10490 * - DA9062_ID_[BUCK1|BUCK2|BUCK4]
10591 * Entry indexes corresponds to register values.
10692 */
107−static const int da9062_buck_a_limits[] = {
93+static const unsigned int da9062_buck_a_limits[] = {
10894 500000, 600000, 700000, 800000, 900000, 1000000, 1100000, 1200000,
10995 1300000, 1400000, 1500000, 1600000, 1700000, 1800000, 1900000, 2000000
11096 };
@@ -114,44 +100,11 @@ static const int da9062_buck_a_limits[] = { · 3 unmodified lines
114100 * - DA9062_ID_BUCK3
115101 * Entry indexes corresponds to register values.
116102 */
117−static const int da9062_buck_b_limits[] = {
103+static const unsigned int da9062_buck_b_limits[] = {
118104 1500000, 1600000, 1700000, 1800000, 1900000, 2000000, 2100000, 2200000,
119105 2300000, 2400000, 2500000, 2600000, 2700000, 2800000, 2900000, 3000000
120106 };
121107
122−static int da9062_set_current_limit(struct regulator_dev *rdev,
123− int min_ua, int max_ua)
124−{
125− struct da9062_regulator *regl = rdev_get_drvdata(rdev);
126− const struct da9062_regulator_info *rinfo = regl->info;
127− int n, tval;
128−
129− for (n = rinfo->n_current_limits - 1; n >= 0; n--) {
130− tval = rinfo->current_limits[n];
131− if (tval >= min_ua && tval <= max_ua)
132− return regmap_field_write(regl->ilimit, n);
133− }
134−
135− return -EINVAL;
136−}
137−
138−static int da9062_get_current_limit(struct regulator_dev *rdev)
139−{
140− struct da9062_regulator *regl = rdev_get_drvdata(rdev);
141− const struct da9062_regulator_info *rinfo = regl->info;
142− unsigned int sel;
143− int ret;
144−
145− ret = regmap_field_read(regl->ilimit, &sel);
146− if (ret < 0)
147− return ret;
148−
149− if (sel >= rinfo->n_current_limits)
150− sel = rinfo->n_current_limits - 1;
151−
152− return rinfo->current_limits[sel];
153−}
154−
155108 static int da9062_buck_set_mode(struct regulator_dev *rdev, unsigned mode)
156109 {
157110 struct da9062_regulator *regl = rdev_get_drvdata(rdev);
@@ -395,8 +348,8 @@ static const struct regulator_ops da9062_buck_ops = { · 237 unmodified lines
395348 .get_voltage_sel = regulator_get_voltage_sel_regmap,
396349 .set_voltage_sel = regulator_set_voltage_sel_regmap,
397350 .list_voltage = regulator_list_voltage_linear,
398− .set_current_limit = da9062_set_current_limit,
399− .get_current_limit = da9062_get_current_limit,
351+ .set_current_limit = regulator_set_current_limit_regmap,
352+ .get_current_limit = regulator_get_current_limit_regmap,
400353 .set_mode = da9062_buck_set_mode,
401354 .get_mode = da9062_buck_get_mode,
402355 .get_status = da9062_buck_get_status,
@@ -433,8 +386,10 @@ static const struct da9062_regulator_info local_da9061_regulator_info[] = { · 30 unmodified lines
433386 .desc.min_uV = (300) * 1000,
434387 .desc.uV_step = (10) * 1000,
435388 .desc.n_voltages = ((1570) - (300))/(10) + 1,
436− .current_limits = da9062_buck_a_limits,
437− .n_current_limits = ARRAY_SIZE(da9062_buck_a_limits),
389+ .desc.curr_table = da9062_buck_a_limits,
390+ .desc.n_current_limits = ARRAY_SIZE(da9062_buck_a_limits),
391+ .desc.csel_reg = DA9062AA_BUCK_ILIM_C,
392+ .desc.csel_mask = DA9062AA_BUCK1_ILIM_MASK,
438393 .desc.enable_reg = DA9062AA_BUCK1_CONT,
439394 .desc.enable_mask = DA9062AA_BUCK1_EN_MASK,
440395 .desc.vsel_reg = DA9062AA_VBUCK1_A,
@@ -457,10 +412,6 @@ static const struct da9062_regulator_info local_da9061_regulator_info[] = { · 16 unmodified lines
457412 __builtin_ffs((int)DA9062AA_VBUCK1_SEL_MASK) - 1,
458413 sizeof(unsigned int) * 8 -
459414 __builtin_clz((DA9062AA_VBUCK1_SEL_MASK)) - 1),
460− .ilimit = REG_FIELD(DA9062AA_BUCK_ILIM_C,
461− __builtin_ffs((int)DA9062AA_BUCK1_ILIM_MASK) - 1,
462− sizeof(unsigned int) * 8 -
463− __builtin_clz((DA9062AA_BUCK1_ILIM_MASK)) - 1),
464415 },
465416 {
466417 .desc.id = DA9061_ID_BUCK2,
@@ -471,8 +422,10 @@ static const struct da9062_regulator_info local_da9061_regulator_info[] = { · 4 unmodified lines
471422 .desc.min_uV = (800) * 1000,
472423 .desc.uV_step = (20) * 1000,
473424 .desc.n_voltages = ((3340) - (800))/(20) + 1,
474− .current_limits = da9062_buck_b_limits,
475− .n_current_limits = ARRAY_SIZE(da9062_buck_b_limits),
425+ .desc.curr_table = da9062_buck_b_limits,
426+ .desc.n_current_limits = ARRAY_SIZE(da9062_buck_b_limits),
427+ .desc.csel_reg = DA9062AA_BUCK_ILIM_A,
428+ .desc.csel_mask = DA9062AA_BUCK3_ILIM_MASK,
476429 .desc.enable_reg = DA9062AA_BUCK3_CONT,
477430 .desc.enable_mask = DA9062AA_BUCK3_EN_MASK,
478431 .desc.vsel_reg = DA9062AA_VBUCK3_A,
@@ -495,10 +448,6 @@ static const struct da9062_regulator_info local_da9061_regulator_info[] = { · 16 unmodified lines
495448 __builtin_ffs((int)DA9062AA_VBUCK3_SEL_MASK) - 1,
496449 sizeof(unsigned int) * 8 -
497450 __builtin_clz((DA9062AA_VBUCK3_SEL_MASK)) - 1),
498− .ilimit = REG_FIELD(DA9062AA_BUCK_ILIM_A,
499− __builtin_ffs((int)DA9062AA_BUCK3_ILIM_MASK) - 1,
500− sizeof(unsigned int) * 8 -
501− __builtin_clz((DA9062AA_BUCK3_ILIM_MASK)) - 1),
502451 },
503452 {
504453 .desc.id = DA9061_ID_BUCK3,
@@ -509,8 +458,10 @@ static const struct da9062_regulator_info local_da9061_regulator_info[] = { · 4 unmodified lines
509458 .desc.min_uV = (530) * 1000,
510459 .desc.uV_step = (10) * 1000,
511460 .desc.n_voltages = ((1800) - (530))/(10) + 1,
512− .current_limits = da9062_buck_a_limits,
513− .n_current_limits = ARRAY_SIZE(da9062_buck_a_limits),
461+ .desc.curr_table = da9062_buck_a_limits,
462+ .desc.n_current_limits = ARRAY_SIZE(da9062_buck_a_limits),
463+ .desc.csel_reg = DA9062AA_BUCK_ILIM_B,
464+ .desc.csel_mask = DA9062AA_BUCK4_ILIM_MASK,
514465 .desc.enable_reg = DA9062AA_BUCK4_CONT,
515466 .desc.enable_mask = DA9062AA_BUCK4_EN_MASK,
516467 .desc.vsel_reg = DA9062AA_VBUCK4_A,
@@ -533,10 +484,6 @@ static const struct da9062_regulator_info local_da9061_regulator_info[] = { · 16 unmodified lines
533484 __builtin_ffs((int)DA9062AA_VBUCK4_SEL_MASK) - 1,
534485 sizeof(unsigned int) * 8 -
535486 __builtin_clz((DA9062AA_VBUCK4_SEL_MASK)) - 1),
536− .ilimit = REG_FIELD(DA9062AA_BUCK_ILIM_B,
537− __builtin_ffs((int)DA9062AA_BUCK4_ILIM_MASK) - 1,
538− sizeof(unsigned int) * 8 -
539− __builtin_clz((DA9062AA_BUCK4_ILIM_MASK)) - 1),
540487 },
541488 {
542489 .desc.id = DA9061_ID_LDO1,
@@ -679,8 +626,10 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = { · 136 unmodified lines
679626 .desc.min_uV = (300) * 1000,
680627 .desc.uV_step = (10) * 1000,
681628 .desc.n_voltages = ((1570) - (300))/(10) + 1,
682− .current_limits = da9062_buck_a_limits,
683− .n_current_limits = ARRAY_SIZE(da9062_buck_a_limits),
629+ .desc.curr_table = da9062_buck_a_limits,
630+ .desc.n_current_limits = ARRAY_SIZE(da9062_buck_a_limits),
631+ .desc.csel_reg = DA9062AA_BUCK_ILIM_C,
632+ .desc.csel_mask = DA9062AA_BUCK1_ILIM_MASK,
684633 .desc.enable_reg = DA9062AA_BUCK1_CONT,
685634 .desc.enable_mask = DA9062AA_BUCK1_EN_MASK,
686635 .desc.vsel_reg = DA9062AA_VBUCK1_A,
@@ -703,10 +652,6 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = { · 16 unmodified lines
703652 __builtin_ffs((int)DA9062AA_VBUCK1_SEL_MASK) - 1,
704653 sizeof(unsigned int) * 8 -
705654 __builtin_clz((DA9062AA_VBUCK1_SEL_MASK)) - 1),
706− .ilimit = REG_FIELD(DA9062AA_BUCK_ILIM_C,
707− __builtin_ffs((int)DA9062AA_BUCK1_ILIM_MASK) - 1,
708− sizeof(unsigned int) * 8 -
709− __builtin_clz((DA9062AA_BUCK1_ILIM_MASK)) - 1),
710655 },
711656 {
712657 .desc.id = DA9062_ID_BUCK2,
@@ -717,8 +662,10 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = { · 4 unmodified lines
717662 .desc.min_uV = (300) * 1000,
718663 .desc.uV_step = (10) * 1000,
719664 .desc.n_voltages = ((1570) - (300))/(10) + 1,
720− .current_limits = da9062_buck_a_limits,
721− .n_current_limits = ARRAY_SIZE(da9062_buck_a_limits),
665+ .desc.curr_table = da9062_buck_a_limits,
666+ .desc.n_current_limits = ARRAY_SIZE(da9062_buck_a_limits),
667+ .desc.csel_reg = DA9062AA_BUCK_ILIM_C,
668+ .desc.csel_mask = DA9062AA_BUCK2_ILIM_MASK,
722669 .desc.enable_reg = DA9062AA_BUCK2_CONT,
723670 .desc.enable_mask = DA9062AA_BUCK2_EN_MASK,
724671 .desc.vsel_reg = DA9062AA_VBUCK2_A,
@@ -741,10 +688,6 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = { · 16 unmodified lines
741688 __builtin_ffs((int)DA9062AA_VBUCK2_SEL_MASK) - 1,
742689 sizeof(unsigned int) * 8 -
743690 __builtin_clz((DA9062AA_VBUCK2_SEL_MASK)) - 1),
744− .ilimit = REG_FIELD(DA9062AA_BUCK_ILIM_C,
745− __builtin_ffs((int)DA9062AA_BUCK2_ILIM_MASK) - 1,
746− sizeof(unsigned int) * 8 -
747− __builtin_clz((DA9062AA_BUCK2_ILIM_MASK)) - 1),
748691 },
749692 {
750693 .desc.id = DA9062_ID_BUCK3,
@@ -755,8 +698,10 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = { · 4 unmodified lines
755698 .desc.min_uV = (800) * 1000,
756699 .desc.uV_step = (20) * 1000,
757700 .desc.n_voltages = ((3340) - (800))/(20) + 1,
758− .current_limits = da9062_buck_b_limits,
759− .n_current_limits = ARRAY_SIZE(da9062_buck_b_limits),
701+ .desc.curr_table = da9062_buck_b_limits,
702+ .desc.n_current_limits = ARRAY_SIZE(da9062_buck_b_limits),
703+ .desc.csel_reg = DA9062AA_BUCK_ILIM_A,
704+ .desc.csel_mask = DA9062AA_BUCK3_ILIM_MASK,
760705 .desc.enable_reg = DA9062AA_BUCK3_CONT,
761706 .desc.enable_mask = DA9062AA_BUCK3_EN_MASK,
762707 .desc.vsel_reg = DA9062AA_VBUCK3_A,
@@ -779,10 +724,6 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = { · 16 unmodified lines
779724 __builtin_ffs((int)DA9062AA_VBUCK3_SEL_MASK) - 1,
780725 sizeof(unsigned int) * 8 -
781726 __builtin_clz((DA9062AA_VBUCK3_SEL_MASK)) - 1),
782− .ilimit = REG_FIELD(DA9062AA_BUCK_ILIM_A,
783− __builtin_ffs((int)DA9062AA_BUCK3_ILIM_MASK) - 1,
784− sizeof(unsigned int) * 8 -
785− __builtin_clz((DA9062AA_BUCK3_ILIM_MASK)) - 1),
786727 },
787728 {
788729 .desc.id = DA9062_ID_BUCK4,
@@ -793,8 +734,10 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = { · 4 unmodified lines
793734 .desc.min_uV = (530) * 1000,
794735 .desc.uV_step = (10) * 1000,
795736 .desc.n_voltages = ((1800) - (530))/(10) + 1,
796− .current_limits = da9062_buck_a_limits,
797− .n_current_limits = ARRAY_SIZE(da9062_buck_a_limits),
737+ .desc.curr_table = da9062_buck_a_limits,
738+ .desc.n_current_limits = ARRAY_SIZE(da9062_buck_a_limits),
739+ .desc.csel_reg = DA9062AA_BUCK_ILIM_B,
740+ .desc.csel_mask = DA9062AA_BUCK4_ILIM_MASK,
798741 .desc.enable_reg = DA9062AA_BUCK4_CONT,
799742 .desc.enable_mask = DA9062AA_BUCK4_EN_MASK,
800743 .desc.vsel_reg = DA9062AA_VBUCK4_A,
@@ -817,10 +760,6 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = { · 16 unmodified lines
817760 __builtin_ffs((int)DA9062AA_VBUCK4_SEL_MASK) - 1,
818761 sizeof(unsigned int) * 8 -
819762 __builtin_clz((DA9062AA_VBUCK4_SEL_MASK)) - 1),
820− .ilimit = REG_FIELD(DA9062AA_BUCK_ILIM_B,
821− __builtin_ffs((int)DA9062AA_BUCK4_ILIM_MASK) - 1,
822− sizeof(unsigned int) * 8 -
823− __builtin_clz((DA9062AA_BUCK4_ILIM_MASK)) - 1),
824763 },
825764 {
826765 .desc.id = DA9062_ID_LDO1,
@@ -974,8 +913,10 @@ static irqreturn_t da9062_ldo_lim_event(int irq, void *data) · 147 unmodified lines
974913 continue;
975914
976915 if (BIT(regl->info->oc_event.lsb) & bits) {
916+ regulator_lock(regl->rdev);
977917 regulator_notifier_call_chain(regl->rdev,
978918 REGULATOR_EVENT_OVER_CURRENT, NULL);
919+ regulator_unlock(regl->rdev);
979920 handled = IRQ_HANDLED;
980921 }
981922 }
@@ -1063,15 +1004,6 @@ static int da9062_regulator_probe(struct platform_device *pdev) · 81 unmodified lines
10631004 return PTR_ERR(regl->suspend_sleep);
10641005 }
10651006
1066− if (regl->info->ilimit.reg) {
1067− regl->ilimit = devm_regmap_field_alloc(
1068− &pdev->dev,
1069− chip->regmap,
1070− regl->info->ilimit);
1071− if (IS_ERR(regl->ilimit))
1072− return PTR_ERR(regl->ilimit);
1073− }
1074−
10751007 /* Register regulator */
10761008 memset(&config, 0, sizeof(config));
10771009 config.dev = chip->dev;
drivers/regulator/da9063-regulator.c+40−94
@@ -1,18 +1,12 @@
1+// SPDX-License-Identifier: GPL-2.0+
2+//
3+// Regulator driver for DA9063 PMIC series
4+//
5+// Copyright 2012 Dialog Semiconductors Ltd.
6+// Copyright 2013 Philipp Zabel, Pengutronix
7+//
8+// Author: Krystian Garbaciak <krystian.garbaciak@diasemi.com>
19
2−/*
3− * Regulator driver for DA9063 PMIC series
4− *
5− * Copyright 2012 Dialog Semiconductors Ltd.
6− * Copyright 2013 Philipp Zabel, Pengutronix
7− *
8− * Author: Krystian Garbaciak <krystian.garbaciak@diasemi.com>
9− *
10− * This program is free software; you can redistribute it and/or modify it
11− * under the terms of the GNU General Public License as published by the
12− * Free Software Foundation; either version 2 of the License, or (at your
13− * option) any later version.
14− *
15− */
1610 #include <linux/kernel.h>
1711 #include <linux/module.h>
1812 #include <linux/init.h>
@@ -38,17 +32,12 @@ · 19 unmodified lines
3832 struct da9063_regulator_info {
3933 struct regulator_desc desc;
4034
41− /* Current limiting */
42− unsigned n_current_limits;
43− const int *current_limits;
44−
4535 /* DA9063 main register fields */
4636 struct reg_field mode; /* buck mode of operation */
4737 struct reg_field suspend;
4838 struct reg_field sleep;
4939 struct reg_field suspend_sleep;
5040 unsigned int suspend_vsel_reg;
51− struct reg_field ilimit;
5241
5342 /* DA9063 event detection bit */
5443 struct reg_field oc_event;
@@ -73,15 +62,18 @@ struct da9063_regulator_info { · 18 unmodified lines
7362 .suspend_vsel_reg = DA9063_REG_V##regl_name##_B
7463
7564 /* Macros for voltage DC/DC converters (BUCKs) */
76−#define DA9063_BUCK(chip, regl_name, min_mV, step_mV, max_mV, limits_array) \
65+#define DA9063_BUCK(chip, regl_name, min_mV, step_mV, max_mV, limits_array, \
66+ creg, cmask) \
7767 .desc.id = chip##_ID_##regl_name, \
7868 .desc.name = __stringify(chip##_##regl_name), \
7969 .desc.ops = &da9063_buck_ops, \
8070 .desc.min_uV = (min_mV) * 1000, \
8171 .desc.uV_step = (step_mV) * 1000, \
8272 .desc.n_voltages = ((max_mV) - (min_mV))/(step_mV) + 1, \
83− .current_limits = limits_array, \
84− .n_current_limits = ARRAY_SIZE(limits_array)
73+ .desc.csel_reg = (creg), \
74+ .desc.csel_mask = (cmask), \
75+ .desc.curr_table = limits_array, \
76+ .desc.n_current_limits = ARRAY_SIZE(limits_array)
8577
8678 #define DA9063_BUCK_COMMON_FIELDS(regl_name) \
8779 .desc.enable_reg = DA9063_REG_##regl_name##_CONT, \
@@ -112,7 +104,6 @@ struct da9063_regulator { · 24 unmodified lines
112104 struct regmap_field *suspend;
113105 struct regmap_field *sleep;
114106 struct regmap_field *suspend_sleep;
115− struct regmap_field *ilimit;
116107 };
117108
118109 /* Encapsulates all information for the regulators driver */
@@ -134,65 +125,32 @@ enum { · 15 unmodified lines
134125
135126 /* Current limits array (in uA) for BCORE1, BCORE2, BPRO.
136127 Entry indexes corresponds to register values. */
137−static const int da9063_buck_a_limits[] = {
128+static const unsigned int da9063_buck_a_limits[] = {
138129 500000, 600000, 700000, 800000, 900000, 1000000, 1100000, 1200000,
139130 1300000, 1400000, 1500000, 1600000, 1700000, 1800000, 1900000, 2000000
140131 };
141132
142133 /* Current limits array (in uA) for BMEM, BIO, BPERI.
143134 Entry indexes corresponds to register values. */
144−static const int da9063_buck_b_limits[] = {
135+static const unsigned int da9063_buck_b_limits[] = {
145136 1500000, 1600000, 1700000, 1800000, 1900000, 2000000, 2100000, 2200000,
146137 2300000, 2400000, 2500000, 2600000, 2700000, 2800000, 2900000, 3000000
147138 };
148139
149140 /* Current limits array (in uA) for merged BCORE1 and BCORE2.
150141 Entry indexes corresponds to register values. */
151−static const int da9063_bcores_merged_limits[] = {
142+static const unsigned int da9063_bcores_merged_limits[] = {
152143 1000000, 1200000, 1400000, 1600000, 1800000, 2000000, 2200000, 2400000,
153144 2600000, 2800000, 3000000, 3200000, 3400000, 3600000, 3800000, 4000000
154145 };
155146
156147 /* Current limits array (in uA) for merged BMEM and BIO.
157148 Entry indexes corresponds to register values. */
158−static const int da9063_bmem_bio_merged_limits[] = {
149+static const unsigned int da9063_bmem_bio_merged_limits[] = {
159150 3000000, 3200000, 3400000, 3600000, 3800000, 4000000, 4200000, 4400000,
160151 4600000, 4800000, 5000000, 5200000, 5400000, 5600000, 5800000, 6000000
161152 };
162153
163−static int da9063_set_current_limit(struct regulator_dev *rdev,
164− int min_uA, int max_uA)
165−{
166− struct da9063_regulator *regl = rdev_get_drvdata(rdev);
167− const struct da9063_regulator_info *rinfo = regl->info;
168− int n, tval;
169−
170− for (n = rinfo->n_current_limits - 1; n >= 0; n--) {
171− tval = rinfo->current_limits[n];
172− if (tval >= min_uA && tval <= max_uA)
173− return regmap_field_write(regl->ilimit, n);
174− }
175−
176− return -EINVAL;
177−}
178−
179−static int da9063_get_current_limit(struct regulator_dev *rdev)
180−{
181− struct da9063_regulator *regl = rdev_get_drvdata(rdev);
182− const struct da9063_regulator_info *rinfo = regl->info;
183− unsigned int sel;
184− int ret;
185−
186− ret = regmap_field_read(regl->ilimit, &sel);
187− if (ret < 0)
188− return ret;
189−
190− if (sel >= rinfo->n_current_limits)
191− sel = rinfo->n_current_limits - 1;
192−
193− return rinfo->current_limits[sel];
194−}
195−
196154 static int da9063_buck_set_mode(struct regulator_dev *rdev, unsigned mode)
197155 {
198156 struct da9063_regulator *regl = rdev_get_drvdata(rdev);
@@ -434,8 +392,8 @@ static const struct regulator_ops da9063_buck_ops = { · 235 unmodified lines
434392 .get_voltage_sel = regulator_get_voltage_sel_regmap,
435393 .set_voltage_sel = regulator_set_voltage_sel_regmap,
436394 .list_voltage = regulator_list_voltage_linear,
437− .set_current_limit = da9063_set_current_limit,
438− .get_current_limit = da9063_get_current_limit,
395+ .set_current_limit = regulator_set_current_limit_regmap,
396+ .get_current_limit = regulator_get_current_limit_regmap,
439397 .set_mode = da9063_buck_set_mode,
440398 .get_mode = da9063_buck_get_mode,
441399 .get_status = da9063_buck_get_status,
@@ -465,69 +423,61 @@ static const struct regulator_ops da9063_ldo_ops = { · 23 unmodified lines
465423 static const struct da9063_regulator_info da9063_regulator_info[] = {
466424 {
467425 DA9063_BUCK(DA9063, BCORE1, 300, 10, 1570,
468− da9063_buck_a_limits),
426+ da9063_buck_a_limits,
427+ DA9063_REG_BUCK_ILIM_C, DA9063_BCORE1_ILIM_MASK),
469428 DA9063_BUCK_COMMON_FIELDS(BCORE1),
470429 .suspend = BFIELD(DA9063_REG_DVC_1, DA9063_VBCORE1_SEL),
471− .ilimit = BFIELD(DA9063_REG_BUCK_ILIM_C,
472− DA9063_BCORE1_ILIM_MASK),
473430 },
474431 {
475432 DA9063_BUCK(DA9063, BCORE2, 300, 10, 1570,
476− da9063_buck_a_limits),
433+ da9063_buck_a_limits,
434+ DA9063_REG_BUCK_ILIM_C, DA9063_BCORE2_ILIM_MASK),
477435 DA9063_BUCK_COMMON_FIELDS(BCORE2),
478436 .suspend = BFIELD(DA9063_REG_DVC_1, DA9063_VBCORE2_SEL),
479− .ilimit = BFIELD(DA9063_REG_BUCK_ILIM_C,
480− DA9063_BCORE2_ILIM_MASK),
481437 },
482438 {
483439 DA9063_BUCK(DA9063, BPRO, 530, 10, 1800,
484− da9063_buck_a_limits),
440+ da9063_buck_a_limits,
441+ DA9063_REG_BUCK_ILIM_B, DA9063_BPRO_ILIM_MASK),
485442 DA9063_BUCK_COMMON_FIELDS(BPRO),
486443 .suspend = BFIELD(DA9063_REG_DVC_1, DA9063_VBPRO_SEL),
487− .ilimit = BFIELD(DA9063_REG_BUCK_ILIM_B,
488− DA9063_BPRO_ILIM_MASK),
489444 },
490445 {
491446 DA9063_BUCK(DA9063, BMEM, 800, 20, 3340,
492− da9063_buck_b_limits),
447+ da9063_buck_b_limits,
448+ DA9063_REG_BUCK_ILIM_A, DA9063_BMEM_ILIM_MASK),
493449 DA9063_BUCK_COMMON_FIELDS(BMEM),
494450 .suspend = BFIELD(DA9063_REG_DVC_1, DA9063_VBMEM_SEL),
495− .ilimit = BFIELD(DA9063_REG_BUCK_ILIM_A,
496− DA9063_BMEM_ILIM_MASK),
497451 },
498452 {
499453 DA9063_BUCK(DA9063, BIO, 800, 20, 3340,
500− da9063_buck_b_limits),
454+ da9063_buck_b_limits,
455+ DA9063_REG_BUCK_ILIM_A, DA9063_BIO_ILIM_MASK),
501456 DA9063_BUCK_COMMON_FIELDS(BIO),
502457 .suspend = BFIELD(DA9063_REG_DVC_2, DA9063_VBIO_SEL),
503− .ilimit = BFIELD(DA9063_REG_BUCK_ILIM_A,
504− DA9063_BIO_ILIM_MASK),
505458 },
506459 {
507460 DA9063_BUCK(DA9063, BPERI, 800, 20, 3340,
508− da9063_buck_b_limits),
461+ da9063_buck_b_limits,
462+ DA9063_REG_BUCK_ILIM_B, DA9063_BPERI_ILIM_MASK),
509463 DA9063_BUCK_COMMON_FIELDS(BPERI),
510464 .suspend = BFIELD(DA9063_REG_DVC_1, DA9063_VBPERI_SEL),
511− .ilimit = BFIELD(DA9063_REG_BUCK_ILIM_B,
512− DA9063_BPERI_ILIM_MASK),
513465 },
514466 {
515467 DA9063_BUCK(DA9063, BCORES_MERGED, 300, 10, 1570,
516− da9063_bcores_merged_limits),
468+ da9063_bcores_merged_limits,
469+ DA9063_REG_BUCK_ILIM_C, DA9063_BCORE1_ILIM_MASK),
517470 /* BCORES_MERGED uses the same register fields as BCORE1 */
518471 DA9063_BUCK_COMMON_FIELDS(BCORE1),
519472 .suspend = BFIELD(DA9063_REG_DVC_1, DA9063_VBCORE1_SEL),
520− .ilimit = BFIELD(DA9063_REG_BUCK_ILIM_C,
521− DA9063_BCORE1_ILIM_MASK),
522473 },
523474 {
524475 DA9063_BUCK(DA9063, BMEM_BIO_MERGED, 800, 20, 3340,
525− da9063_bmem_bio_merged_limits),
476+ da9063_bmem_bio_merged_limits,
477+ DA9063_REG_BUCK_ILIM_A, DA9063_BMEM_ILIM_MASK),
526478 /* BMEM_BIO_MERGED uses the same register fields as BMEM */
527479 DA9063_BUCK_COMMON_FIELDS(BMEM),
528480 .suspend = BFIELD(DA9063_REG_DVC_1, DA9063_VBMEM_SEL),
529− .ilimit = BFIELD(DA9063_REG_BUCK_ILIM_A,
530− DA9063_BMEM_ILIM_MASK),
531481 },
532482 {
533483 DA9063_LDO(DA9063, LDO3, 900, 20, 3440),
@@ -615,9 +565,12 @@ static irqreturn_t da9063_ldo_lim_event(int irq, void *data) · 81 unmodified lines
615565 if (regl->info->oc_event.reg != DA9063_REG_STATUS_D)
616566 continue;
617567
618− if (BIT(regl->info->oc_event.lsb) & bits)
568+ if (BIT(regl->info->oc_event.lsb) & bits) {
569+ regulator_lock(regl->rdev);
619570 regulator_notifier_call_chain(regl->rdev,
620571 REGULATOR_EVENT_OVER_CURRENT, NULL);
572+ regulator_unlock(regl->rdev);
573+ }
621574 }
622575
623576 return IRQ_HANDLED;
@@ -861,13 +814,6 @@ static int da9063_regulator_probe(struct platform_device *pdev) · 237 unmodified lines
861814 return PTR_ERR(regl->suspend_sleep);
862815 }
863816
864− if (regl->info->ilimit.reg) {
865− regl->ilimit = devm_regmap_field_alloc(&pdev->dev,
866− da9063->regmap, regl->info->ilimit);
867− if (IS_ERR(regl->ilimit))
868− return PTR_ERR(regl->ilimit);
869− }
870−
871817 /* Register regulator */
872818 memset(&config, 0, sizeof(config));
873819 config.dev = &pdev->dev;
drivers/regulator/da9210-regulator.c+4−19
@@ -1,22 +1,7 @@
1−/*
2− * da9210-regulator.c - Regulator device driver for DA9210
3− * Copyright (C) 2013 Dialog Semiconductor Ltd.
4− *
5− * This library is free software; you can redistribute it and/or
6− * modify it under the terms of the GNU Library General Public
7− * License as published by the Free Software Foundation; either
8− * version 2 of the License, or (at your option) any later version.
9− *
10− * This library is distributed in the hope that it will be useful,
11− * but WITHOUT ANY WARRANTY; without even the implied warranty of
12− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13− * Library General Public License for more details.
14− *
15− * You should have received a copy of the GNU Library General Public
16− * License along with this library; if not, write to the
17− * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18− * Boston, MA 02110-1301, USA.
19− */
1+// SPDX-License-Identifier: GPL-2.0+
2+//
3+// da9210-regulator.c - Regulator device driver for DA9210
4+// Copyright (C) 2013 Dialog Semiconductor Ltd.
205
216 #include <linux/err.h>
227 #include <linux/i2c.h>
drivers/regulator/da9210-regulator.h+1−16
@@ -1,22 +1,7 @@
1−
1+/* SPDX-License-Identifier: GPL-2.0+ */
22 /*
33 * da9210-regulator.h - Regulator definitions for DA9210
44 * Copyright (C) 2013 Dialog Semiconductor Ltd.
5− *
6− * This library is free software; you can redistribute it and/or
7− * modify it under the terms of the GNU Library General Public
8− * License as published by the Free Software Foundation; either
9− * version 2 of the License, or (at your option) any later version.
10− *
11− * This library is distributed in the hope that it will be useful,
12− * but WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14− * Library General Public License for more details.
15− *
16− * You should have received a copy of the GNU Library General Public
17− * License along with this library; if not, write to the
18− * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19− * Boston, MA 02110-1301, USA.
205 */
216
227 #ifndef __DA9210_REGISTERS_H__
drivers/regulator/da9211-regulator.c+9−15
@@ -1,18 +1,8 @@
1−/*
2− * da9211-regulator.c - Regulator device driver for DA9211/DA9212
3− * /DA9213/DA9223/DA9214/DA9224/DA9215/DA9225
4− * Copyright (C) 2015 Dialog Semiconductor Ltd.
5− *
6− * This library is free software; you can redistribute it and/or
7− * modify it under the terms of the GNU Library General Public
8− * License as published by the Free Software Foundation; either
9− * version 2 of the License, or (at your option) any later version.
10− *
11− * This library is distributed in the hope that it will be useful,
12− * but WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14− * Library General Public License for more details.
15− */
1+// SPDX-License-Identifier: GPL-2.0+
2+//
3+// da9211-regulator.c - Regulator device driver for DA9211/DA9212
4+// /DA9213/DA9223/DA9214/DA9224/DA9215/DA9225
5+// Copyright (C) 2015 Dialog Semiconductor Ltd.
166
177 #include <linux/err.h>
188 #include <linux/i2c.h>
@@ -322,8 +312,10 @@ static irqreturn_t da9211_irq_handler(int irq, void *data) · 303 unmodified lines
322312 goto error_i2c;
323313
324314 if (reg_val & DA9211_E_OV_CURR_A) {
315+ regulator_lock(chip->rdev[0]);
325316 regulator_notifier_call_chain(chip->rdev[0],
326317 REGULATOR_EVENT_OVER_CURRENT, NULL);
318+ regulator_unlock(chip->rdev[0]);
327319
328320 err = regmap_write(chip->regmap, DA9211_REG_EVENT_B,
329321 DA9211_E_OV_CURR_A);
@@ -334,8 +326,10 @@ static irqreturn_t da9211_irq_handler(int irq, void *data) · 4 unmodified lines
334326 }
335327
336328 if (reg_val & DA9211_E_OV_CURR_B) {
329+ regulator_lock(chip->rdev[1]);
337330 regulator_notifier_call_chain(chip->rdev[1],
338331 REGULATOR_EVENT_OVER_CURRENT, NULL);
332+ regulator_unlock(chip->rdev[1]);
339333
340334 err = regmap_write(chip->regmap, DA9211_REG_EVENT_B,
341335 DA9211_E_OV_CURR_B);
drivers/regulator/da9211-regulator.h+1−10
@@ -1,17 +1,8 @@
1+/* SPDX-License-Identifier: GPL-2.0+ */
12 /*
23 * da9211-regulator.h - Regulator definitions for DA9211/DA9212
34 * /DA9213/DA9223/DA9214/DA9224/DA9215/DA9225
45 * Copyright (C) 2015 Dialog Semiconductor Ltd.
5− *
6− * This program is free software; you can redistribute it and/or
7− * modify it under the terms of the GNU General Public License
8− * as published by the Free Software Foundation; either version 2
9− * of the License, or (at your option) any later version.
10− *
11− * This program is distributed in the hope that it will be useful,
12− * but WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14− * GNU General Public License for more details.
156 */
167
178 #ifndef __DA9211_REGISTERS_H__
drivers/regulator/db8500-prcmu.c+44−99
@@ -75,7 +75,7 @@ static int db8500_regulator_is_enabled(struct regulator_dev *rdev) · 74 unmodified lines
7575 }
7676
7777 /* db8500 regulator operations */
78−static struct regulator_ops db8500_regulator_ops = {
78+static const struct regulator_ops db8500_regulator_ops = {
7979 .enable = db8500_regulator_enable,
8080 .disable = db8500_regulator_disable,
8181 .is_enabled = db8500_regulator_is_enabled,
@@ -200,7 +200,7 @@ static int db8500_regulator_switch_is_enabled(struct regulator_dev *rdev) · 118 unmodified lines
200200 return info->is_enabled;
201201 }
202202
203−static struct regulator_ops db8500_regulator_switch_ops = {
203+static const struct regulator_ops db8500_regulator_switch_ops = {
204204 .enable = db8500_regulator_switch_enable,
205205 .disable = db8500_regulator_switch_disable,
206206 .is_enabled = db8500_regulator_switch_is_enabled,
@@ -214,6 +214,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = { · 7 unmodified lines
214214 [DB8500_REGULATOR_VAPE] = {
215215 .desc = {
216216 .name = "db8500-vape",
217+ .of_match = of_match_ptr("db8500_vape"),
217218 .id = DB8500_REGULATOR_VAPE,
218219 .ops = &db8500_regulator_ops,
219220 .type = REGULATOR_VOLTAGE,
@@ -223,6 +224,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = { · 3 unmodified lines
223224 [DB8500_REGULATOR_VARM] = {
224225 .desc = {
225226 .name = "db8500-varm",
227+ .of_match = of_match_ptr("db8500_varm"),
226228 .id = DB8500_REGULATOR_VARM,
227229 .ops = &db8500_regulator_ops,
228230 .type = REGULATOR_VOLTAGE,
@@ -232,6 +234,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = { · 3 unmodified lines
232234 [DB8500_REGULATOR_VMODEM] = {
233235 .desc = {
234236 .name = "db8500-vmodem",
237+ .of_match = of_match_ptr("db8500_vmodem"),
235238 .id = DB8500_REGULATOR_VMODEM,
236239 .ops = &db8500_regulator_ops,
237240 .type = REGULATOR_VOLTAGE,
@@ -241,6 +244,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = { · 3 unmodified lines
241244 [DB8500_REGULATOR_VPLL] = {
242245 .desc = {
243246 .name = "db8500-vpll",
247+ .of_match = of_match_ptr("db8500_vpll"),
244248 .id = DB8500_REGULATOR_VPLL,
245249 .ops = &db8500_regulator_ops,
246250 .type = REGULATOR_VOLTAGE,
@@ -250,6 +254,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = { · 3 unmodified lines
250254 [DB8500_REGULATOR_VSMPS1] = {
251255 .desc = {
252256 .name = "db8500-vsmps1",
257+ .of_match = of_match_ptr("db8500_vsmps1"),
253258 .id = DB8500_REGULATOR_VSMPS1,
254259 .ops = &db8500_regulator_ops,
255260 .type = REGULATOR_VOLTAGE,
@@ -259,6 +264,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = { · 3 unmodified lines
259264 [DB8500_REGULATOR_VSMPS2] = {
260265 .desc = {
261266 .name = "db8500-vsmps2",
267+ .of_match = of_match_ptr("db8500_vsmps2"),
262268 .id = DB8500_REGULATOR_VSMPS2,
263269 .ops = &db8500_regulator_ops,
264270 .type = REGULATOR_VOLTAGE,
@@ -271,6 +277,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = { · 6 unmodified lines
271277 [DB8500_REGULATOR_VSMPS3] = {
272278 .desc = {
273279 .name = "db8500-vsmps3",
280+ .of_match = of_match_ptr("db8500_vsmps3"),
274281 .id = DB8500_REGULATOR_VSMPS3,
275282 .ops = &db8500_regulator_ops,
276283 .type = REGULATOR_VOLTAGE,
@@ -280,6 +287,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = { · 3 unmodified lines
280287 [DB8500_REGULATOR_VRF1] = {
281288 .desc = {
282289 .name = "db8500-vrf1",
290+ .of_match = of_match_ptr("db8500_vrf1"),
283291 .id = DB8500_REGULATOR_VRF1,
284292 .ops = &db8500_regulator_ops,
285293 .type = REGULATOR_VOLTAGE,
@@ -289,6 +297,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = { · 3 unmodified lines
289297 [DB8500_REGULATOR_SWITCH_SVAMMDSP] = {
290298 .desc = {
291299 .name = "db8500-sva-mmdsp",
300+ .of_match = of_match_ptr("db8500_sva_mmdsp"),
292301 .id = DB8500_REGULATOR_SWITCH_SVAMMDSP,
293302 .ops = &db8500_regulator_switch_ops,
294303 .type = REGULATOR_VOLTAGE,
@@ -299,6 +308,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = { · 4 unmodified lines
299308 [DB8500_REGULATOR_SWITCH_SVAMMDSPRET] = {
300309 .desc = {
301310 .name = "db8500-sva-mmdsp-ret",
311+ .of_match = of_match_ptr("db8500_sva_mmdsp_ret"),
302312 .id = DB8500_REGULATOR_SWITCH_SVAMMDSPRET,
303313 .ops = &db8500_regulator_switch_ops,
304314 .type = REGULATOR_VOLTAGE,
@@ -310,6 +320,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = { · 5 unmodified lines
310320 [DB8500_REGULATOR_SWITCH_SVAPIPE] = {
311321 .desc = {
312322 .name = "db8500-sva-pipe",
323+ .of_match = of_match_ptr("db8500_sva_pipe"),
313324 .id = DB8500_REGULATOR_SWITCH_SVAPIPE,
314325 .ops = &db8500_regulator_switch_ops,
315326 .type = REGULATOR_VOLTAGE,
@@ -320,6 +331,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = { · 4 unmodified lines
320331 [DB8500_REGULATOR_SWITCH_SIAMMDSP] = {
321332 .desc = {
322333 .name = "db8500-sia-mmdsp",
334+ .of_match = of_match_ptr("db8500_sia_mmdsp"),
323335 .id = DB8500_REGULATOR_SWITCH_SIAMMDSP,
324336 .ops = &db8500_regulator_switch_ops,
325337 .type = REGULATOR_VOLTAGE,
@@ -330,6 +342,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = { · 4 unmodified lines
330342 [DB8500_REGULATOR_SWITCH_SIAMMDSPRET] = {
331343 .desc = {
332344 .name = "db8500-sia-mmdsp-ret",
345+ .of_match = of_match_ptr("db8500_sia_mmdsp_ret"),
333346 .id = DB8500_REGULATOR_SWITCH_SIAMMDSPRET,
334347 .ops = &db8500_regulator_switch_ops,
335348 .type = REGULATOR_VOLTAGE,
@@ -341,6 +354,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = { · 5 unmodified lines
341354 [DB8500_REGULATOR_SWITCH_SIAPIPE] = {
342355 .desc = {
343356 .name = "db8500-sia-pipe",
357+ .of_match = of_match_ptr("db8500_sia_pipe"),
344358 .id = DB8500_REGULATOR_SWITCH_SIAPIPE,
345359 .ops = &db8500_regulator_switch_ops,
346360 .type = REGULATOR_VOLTAGE,
@@ -351,6 +365,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = { · 4 unmodified lines
351365 [DB8500_REGULATOR_SWITCH_SGA] = {
352366 .desc = {
353367 .name = "db8500-sga",
368+ .of_match = of_match_ptr("db8500_sga"),
354369 .id = DB8500_REGULATOR_SWITCH_SGA,
355370 .ops = &db8500_regulator_switch_ops,
356371 .type = REGULATOR_VOLTAGE,
@@ -361,6 +376,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = { · 4 unmodified lines
361376 [DB8500_REGULATOR_SWITCH_B2R2_MCDE] = {
362377 .desc = {
363378 .name = "db8500-b2r2-mcde",
379+ .of_match = of_match_ptr("db8500_b2r2_mcde"),
364380 .id = DB8500_REGULATOR_SWITCH_B2R2_MCDE,
365381 .ops = &db8500_regulator_switch_ops,
366382 .type = REGULATOR_VOLTAGE,
@@ -371,6 +387,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = { · 4 unmodified lines
371387 [DB8500_REGULATOR_SWITCH_ESRAM12] = {
372388 .desc = {
373389 .name = "db8500-esram12",
390+ .of_match = of_match_ptr("db8500_esram12"),
374391 .id = DB8500_REGULATOR_SWITCH_ESRAM12,
375392 .ops = &db8500_regulator_switch_ops,
376393 .type = REGULATOR_VOLTAGE,
@@ -382,6 +399,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = { · 5 unmodified lines
382399 [DB8500_REGULATOR_SWITCH_ESRAM12RET] = {
383400 .desc = {
384401 .name = "db8500-esram12-ret",
402+ .of_match = of_match_ptr("db8500_esram12_ret"),
385403 .id = DB8500_REGULATOR_SWITCH_ESRAM12RET,
386404 .ops = &db8500_regulator_switch_ops,
387405 .type = REGULATOR_VOLTAGE,
@@ -393,6 +411,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = { · 5 unmodified lines
393411 [DB8500_REGULATOR_SWITCH_ESRAM34] = {
394412 .desc = {
395413 .name = "db8500-esram34",
414+ .of_match = of_match_ptr("db8500_esram34"),
396415 .id = DB8500_REGULATOR_SWITCH_ESRAM34,
397416 .ops = &db8500_regulator_switch_ops,
398417 .type = REGULATOR_VOLTAGE,
@@ -404,6 +423,7 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = { · 5 unmodified lines
404423 [DB8500_REGULATOR_SWITCH_ESRAM34RET] = {
405424 .desc = {
406425 .name = "db8500-esram34-ret",
426+ .of_match = of_match_ptr("db8500_esram34_ret"),
407427 .id = DB8500_REGULATOR_SWITCH_ESRAM34RET,
408428 .ops = &db8500_regulator_switch_ops,
409429 .type = REGULATOR_VOLTAGE,
@@ -414,113 +434,38 @@ dbx500_regulator_info[DB8500_NUM_REGULATORS] = { · 4 unmodified lines
414434 },
415435 };
416436
417−static int db8500_regulator_register(struct platform_device *pdev,
418− struct regulator_init_data *init_data,
419− int id,
420− struct device_node *np)
437+static int db8500_regulator_probe(struct platform_device *pdev)
421438 {
439+ struct regulator_init_data *db8500_init_data;
422440 struct dbx500_regulator_info *info;
423441 struct regulator_config config = { };
424− int err;
425−
426− /* assign per-regulator data */
427− info = &dbx500_regulator_info[id];
428− info->dev = &pdev->dev;
429−
430− config.dev = &pdev->dev;
431− config.init_data = init_data;
432− config.driver_data = info;
433− config.of_node = np;
434−
435− /* register with the regulator framework */
436− info->rdev = devm_regulator_register(&pdev->dev, &info->desc, &config);
437− if (IS_ERR(info->rdev)) {
438− err = PTR_ERR(info->rdev);
439− dev_err(&pdev->dev, "failed to register %s: err %i\n",
440− info->desc.name, err);
441− return err;
442− }
443−
444− dev_dbg(rdev_get_dev(info->rdev),
445− "regulator-%s-probed\n", info->desc.name);
442+ struct regulator_dev *rdev;
443+ int err, i;
446444
447− return 0;
448−}
449−
450−static struct of_regulator_match db8500_regulator_matches[] = {
451− { .name = "db8500_vape", .driver_data = (void *) DB8500_REGULATOR_VAPE, },
452− { .name = "db8500_varm", .driver_data = (void *) DB8500_REGULATOR_VARM, },
453− { .name = "db8500_vmodem", .driver_data = (void *) DB8500_REGULATOR_VMODEM, },
454− { .name = "db8500_vpll", .driver_data = (void *) DB8500_REGULATOR_VPLL, },
455− { .name = "db8500_vsmps1", .driver_data = (void *) DB8500_REGULATOR_VSMPS1, },
456− { .name = "db8500_vsmps2", .driver_data = (void *) DB8500_REGULATOR_VSMPS2, },
457− { .name = "db8500_vsmps3", .driver_data = (void *) DB8500_REGULATOR_VSMPS3, },
458− { .name = "db8500_vrf1", .driver_data = (void *) DB8500_REGULATOR_VRF1, },
459− { .name = "db8500_sva_mmdsp", .driver_data = (void *) DB8500_REGULATOR_SWITCH_SVAMMDSP, },
460− { .name = "db8500_sva_mmdsp_ret", .driver_data = (void *) DB8500_REGULATOR_SWITCH_SVAMMDSPRET, },
461− { .name = "db8500_sva_pipe", .driver_data = (void *) DB8500_REGULATOR_SWITCH_SVAPIPE, },
462− { .name = "db8500_sia_mmdsp", .driver_data = (void *) DB8500_REGULATOR_SWITCH_SIAMMDSP, },
463− { .name = "db8500_sia_mmdsp_ret", .driver_data = (void *) DB8500_REGULATOR_SWITCH_SIAMMDSPRET, },
464− { .name = "db8500_sia_pipe", .driver_data = (void *) DB8500_REGULATOR_SWITCH_SIAPIPE, },
465− { .name = "db8500_sga", .driver_data = (void *) DB8500_REGULATOR_SWITCH_SGA, },
466− { .name = "db8500_b2r2_mcde", .driver_data = (void *) DB8500_REGULATOR_SWITCH_B2R2_MCDE, },
467− { .name = "db8500_esram12", .driver_data = (void *) DB8500_REGULATOR_SWITCH_ESRAM12, },
468− { .name = "db8500_esram12_ret", .driver_data = (void *) DB8500_REGULATOR_SWITCH_ESRAM12RET, },
469− { .name = "db8500_esram34", .driver_data = (void *) DB8500_REGULATOR_SWITCH_ESRAM34, },
470− { .name = "db8500_esram34_ret", .driver_data = (void *) DB8500_REGULATOR_SWITCH_ESRAM34RET, },
471−};
472−
473−static int
474−db8500_regulator_of_probe(struct platform_device *pdev,
475− struct device_node *np)
476−{
477− int i, err;
445+ db8500_init_data = dev_get_platdata(&pdev->dev);
478446
479447 for (i = 0; i < ARRAY_SIZE(dbx500_regulator_info); i++) {
480− err = db8500_regulator_register(
481− pdev, db8500_regulator_matches[i].init_data,
482− i, db8500_regulator_matches[i].of_node);
483− if (err)
448+ /* assign per-regulator data */
449+ info = &dbx500_regulator_info[i];
450+
451+ config.driver_data = info;
452+ config.dev = &pdev->dev;
453+ if (db8500_init_data)
454+ config.init_data = &db8500_init_data[i];
455+
456+ rdev = devm_regulator_register(&pdev->dev, &info->desc,
457+ &config);
458+ if (IS_ERR(rdev)) {
459+ err = PTR_ERR(rdev);
460+ dev_err(&pdev->dev, "failed to register %s: err %i\n",
461+ info->desc.name, err);
484462 return err;
485− }
486−
487− return 0;
488−}
489−
490−static int db8500_regulator_probe(struct platform_device *pdev)
491−{
492− struct regulator_init_data *db8500_init_data =
493− dev_get_platdata(&pdev->dev);
494− struct device_node *np = pdev->dev.of_node;
495− int i, err;
496−
497− /* register all regulators */
498− if (np) {
499− err = of_regulator_match(&pdev->dev, np,
500− db8500_regulator_matches,
501− ARRAY_SIZE(db8500_regulator_matches));
502− if (err < 0) {
503− dev_err(&pdev->dev,
504− "Error parsing regulator init data: %d\n", err);
505− return err;
506− }
507−
508− err = db8500_regulator_of_probe(pdev, np);
509− if (err)
510− return err;
511− } else {
512− for (i = 0; i < ARRAY_SIZE(dbx500_regulator_info); i++) {
513− err = db8500_regulator_register(pdev,
514− &db8500_init_data[i],
515− i, NULL);
516− if (err)
517− return err;
518463 }
464+ dev_dbg(&pdev->dev, "regulator-%s-probed\n", info->desc.name);
519465 }
520466
521− err = ux500_regulator_debug_init(pdev,
522− dbx500_regulator_info,
523− ARRAY_SIZE(dbx500_regulator_info));
467+ ux500_regulator_debug_init(pdev, dbx500_regulator_info,
468+ ARRAY_SIZE(dbx500_regulator_info));
524469 return 0;
525470 }
526471
drivers/regulator/dbx500-prcmu.h+0−4
@@ -15,18 +15,14 @@ · 14 unmodified lines
1515
1616 /**
1717 * struct dbx500_regulator_info - dbx500 regulator information
18− * @dev: device pointer
1918 * @desc: regulator description
20− * @rdev: regulator device pointer
2119 * @is_enabled: status of the regulator
2220 * @epod_id: id for EPOD (power domain)
2321 * @is_ramret: RAM retention switch for EPOD (power domain)
2422 *
2523 */
2624 struct dbx500_regulator_info {
27− struct device *dev;
2825 struct regulator_desc desc;
29− struct regulator_dev *rdev;
3026 bool is_enabled;
3127 u16 epod_id;
3228 bool is_ramret;
drivers/regulator/fan53555.c+27−33
@@ -1,17 +1,13 @@
1−/*
2− * FAN53555 Fairchild Digitally Programmable TinyBuck Regulator Driver.
3− *
4− * Supported Part Numbers:
5− * FAN53555UC00X/01X/03X/04X/05X
6− *
7− * Copyright (c) 2012 Marvell Technology Ltd.
8− * Yunfan Zhang <yfzhang@marvell.com>
9− *
10− * This package is free software; you can redistribute it and/or modify
11− * it under the terms of the GNU General Public License version 2 as
12− * published by the Free Software Foundation.
13− *
14− */
1+// SPDX-License-Identifier: GPL-2.0
2+//
3+// FAN53555 Fairchild Digitally Programmable TinyBuck Regulator Driver.
4+//
5+// Supported Part Numbers:
6+// FAN53555UC00X/01X/03X/04X/05X
7+//
8+// Copyright (c) 2012 Marvell Technology Ltd.
9+// Yunfan Zhang <yfzhang@marvell.com>
10+
1511 #include <linux/module.h>
1612 #include <linux/param.h>
1713 #include <linux/err.h>
@@ -91,10 +87,8 @@ enum { · 73 unmodified lines
9187
9288 struct fan53555_device_info {
9389 enum fan53555_vendor vendor;
94− struct regmap *regmap;
9590 struct device *dev;
9691 struct regulator_desc desc;
97− struct regulator_dev *rdev;
9892 struct regulator_init_data *regulator;
9993 /* IC Type and Rev */
10094 int chip_id;
@@ -106,8 +100,6 @@ struct fan53555_device_info { · 5 unmodified lines
106100 unsigned int vsel_min;
107101 unsigned int vsel_step;
108102 unsigned int vsel_count;
109− /* Voltage slew rate limiting */
110− unsigned int slew_rate;
111103 /* Mode */
112104 unsigned int mode_reg;
113105 unsigned int mode_mask;
@@ -125,7 +117,7 @@ static int fan53555_set_suspend_voltage(struct regulator_dev *rdev, int uV) · 11 unmodified lines
125117 ret = regulator_map_voltage_linear(rdev, uV, uV);
126118 if (ret < 0)
127119 return ret;
128− ret = regmap_update_bits(di->regmap, di->sleep_reg,
120+ ret = regmap_update_bits(rdev->regmap, di->sleep_reg,
129121 di->desc.vsel_mask, ret);
130122 if (ret < 0)
131123 return ret;
@@ -140,7 +132,7 @@ static int fan53555_set_suspend_enable(struct regulator_dev *rdev) · 8 unmodified lines
140132 {
141133 struct fan53555_device_info *di = rdev_get_drvdata(rdev);
142134
143− return regmap_update_bits(di->regmap, di->sleep_reg,
135+ return regmap_update_bits(rdev->regmap, di->sleep_reg,
144136 VSEL_BUCK_EN, VSEL_BUCK_EN);
145137 }
146138
@@ -148,7 +140,7 @@ static int fan53555_set_suspend_disable(struct regulator_dev *rdev) · 1 unmodified line
148140 {
149141 struct fan53555_device_info *di = rdev_get_drvdata(rdev);
150142
151− return regmap_update_bits(di->regmap, di->sleep_reg,
143+ return regmap_update_bits(rdev->regmap, di->sleep_reg,
152144 VSEL_BUCK_EN, 0);
153145 }
154146
@@ -158,11 +150,11 @@ static int fan53555_set_mode(struct regulator_dev *rdev, unsigned int mode) · 3 unmodified lines
158150
159151 switch (mode) {
160152 case REGULATOR_MODE_FAST:
161− regmap_update_bits(di->regmap, di->mode_reg,
153+ regmap_update_bits(rdev->regmap, di->mode_reg,
162154 di->mode_mask, di->mode_mask);
163155 break;
164156 case REGULATOR_MODE_NORMAL:
165− regmap_update_bits(di->regmap, di->vol_reg, di->mode_mask, 0);
157+ regmap_update_bits(rdev->regmap, di->vol_reg, di->mode_mask, 0);
166158 break;
167159 default:
168160 return -EINVAL;
@@ -176,7 +168,7 @@ static unsigned int fan53555_get_mode(struct regulator_dev *rdev) · 7 unmodified lines
176168 unsigned int val;
177169 int ret = 0;
178170
179− ret = regmap_read(di->regmap, di->mode_reg, &val);
171+ ret = regmap_read(rdev->regmap, di->mode_reg, &val);
180172 if (ret < 0)
181173 return ret;
182174 if (val & di->mode_mask)
@@ -213,7 +205,7 @@ static int fan53555_set_ramp(struct regulator_dev *rdev, int ramp) · 30 unmodified lines
213205 return -EINVAL;
214206 }
215207
216− return regmap_update_bits(di->regmap, FAN53555_CONTROL,
208+ return regmap_update_bits(rdev->regmap, FAN53555_CONTROL,
217209 CTL_SLEW_MASK, regval << CTL_SLEW_SHIFT);
218210 }
219211
@@ -396,6 +388,7 @@ static int fan53555_regulator_register(struct fan53555_device_info *di, · 176 unmodified lines
396388 struct regulator_config *config)
397389 {
398390 struct regulator_desc *rdesc = &di->desc;
391+ struct regulator_dev *rdev;
399392
400393 rdesc->name = "fan53555-reg";
401394 rdesc->supply_name = "vin";
@@ -410,8 +403,8 @@ static int fan53555_regulator_register(struct fan53555_device_info *di, · 8 unmodified lines
410403 rdesc->vsel_mask = di->vsel_count - 1;
411404 rdesc->owner = THIS_MODULE;
412405
413− di->rdev = devm_regulator_register(di->dev, &di->desc, config);
414− return PTR_ERR_OR_ZERO(di->rdev);
406+ rdev = devm_regulator_register(di->dev, &di->desc, config);
407+ return PTR_ERR_OR_ZERO(rdev);
415408 }
416409
417410 static const struct regmap_config fan53555_regmap_config = {
@@ -466,6 +459,7 @@ static int fan53555_regulator_probe(struct i2c_client *client, · 48 unmodified lines
466459 struct fan53555_device_info *di;
467460 struct fan53555_platform_data *pdata;
468461 struct regulator_config config = { };
462+ struct regmap *regmap;
469463 unsigned int val;
470464 int ret;
471465
@@ -502,22 +496,22 @@ static int fan53555_regulator_probe(struct i2c_client *client, · 30 unmodified lines
502496 di->vendor = id->driver_data;
503497 }
504498
505− di->regmap = devm_regmap_init_i2c(client, &fan53555_regmap_config);
506− if (IS_ERR(di->regmap)) {
499+ regmap = devm_regmap_init_i2c(client, &fan53555_regmap_config);
500+ if (IS_ERR(regmap)) {
507501 dev_err(&client->dev, "Failed to allocate regmap!\n");
508− return PTR_ERR(di->regmap);
502+ return PTR_ERR(regmap);
509503 }
510504 di->dev = &client->dev;
511505 i2c_set_clientdata(client, di);
512506 /* Get chip ID */
513− ret = regmap_read(di->regmap, FAN53555_ID1, &val);
507+ ret = regmap_read(regmap, FAN53555_ID1, &val);
514508 if (ret < 0) {
515509 dev_err(&client->dev, "Failed to get chip ID!\n");
516510 return ret;
517511 }
518512 di->chip_id = val & DIE_ID;
519513 /* Get chip revision */
520− ret = regmap_read(di->regmap, FAN53555_ID2, &val);
514+ ret = regmap_read(regmap, FAN53555_ID2, &val);
521515 if (ret < 0) {
522516 dev_err(&client->dev, "Failed to get chip Rev!\n");
523517 return ret;
@@ -534,7 +528,7 @@ static int fan53555_regulator_probe(struct i2c_client *client, · 10 unmodified lines
534528 /* Register regulator */
535529 config.dev = di->dev;
536530 config.init_data = di->regulator;
537− config.regmap = di->regmap;
531+ config.regmap = regmap;
538532 config.driver_data = di;
539533 config.of_node = np;
540534
drivers/regulator/gpio-regulator.c+6−16
@@ -36,7 +36,6 @@ · 35 unmodified lines
3636
3737 struct gpio_regulator_data {
3838 struct regulator_desc desc;
39− struct regulator_dev *dev;
4039
4140 struct gpio_desc **gpiods;
4241 int nr_gpios;
@@ -125,7 +124,7 @@ static int gpio_regulator_set_current_limit(struct regulator_dev *dev, · 82 unmodified lines
125124 return 0;
126125 }
127126
128−static struct regulator_ops gpio_regulator_voltage_ops = {
127+static const struct regulator_ops gpio_regulator_voltage_ops = {
129128 .get_voltage = gpio_regulator_get_value,
130129 .set_voltage = gpio_regulator_set_voltage,
131130 .list_voltage = gpio_regulator_list_voltage,
@@ -221,7 +220,7 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np, · 89 unmodified lines
221220 return config;
222221 }
223222
224−static struct regulator_ops gpio_regulator_current_ops = {
223+static const struct regulator_ops gpio_regulator_current_ops = {
225224 .get_current_limit = gpio_regulator_get_value,
226225 .set_current_limit = gpio_regulator_set_current_limit,
227226 };
@@ -233,6 +232,7 @@ static int gpio_regulator_probe(struct platform_device *pdev) · 5 unmodified lines
233232 struct device_node *np = dev->of_node;
234233 struct gpio_regulator_data *drvdata;
235234 struct regulator_config cfg = { };
235+ struct regulator_dev *rdev;
236236 enum gpiod_flags gflags;
237237 int ptr, ret, state, i;
238238
@@ -326,9 +326,9 @@ static int gpio_regulator_probe(struct platform_device *pdev) · 87 unmodified lines
326326 if (IS_ERR(cfg.ena_gpiod))
327327 return PTR_ERR(cfg.ena_gpiod);
328328
329− drvdata->dev = regulator_register(&drvdata->desc, &cfg);
330− if (IS_ERR(drvdata->dev)) {
331− ret = PTR_ERR(drvdata->dev);
329+ rdev = devm_regulator_register(dev, &drvdata->desc, &cfg);
330+ if (IS_ERR(rdev)) {
331+ ret = PTR_ERR(rdev);
332332 dev_err(dev, "Failed to register regulator: %d\n", ret);
333333 return ret;
334334 }
@@ -338,15 +338,6 @@ static int gpio_regulator_probe(struct platform_device *pdev) · 3 unmodified lines
338338 return 0;
339339 }
340340
341−static int gpio_regulator_remove(struct platform_device *pdev)
342−{
343− struct gpio_regulator_data *drvdata = platform_get_drvdata(pdev);
344−
345− regulator_unregister(drvdata->dev);
346−
347− return 0;
348−}
349−
350341 #if defined(CONFIG_OF)
351342 static const struct of_device_id regulator_gpio_of_match[] = {
352343 { .compatible = "regulator-gpio", },
@@ -357,7 +348,6 @@ MODULE_DEVICE_TABLE(of, regulator_gpio_of_match); · 4 unmodified lines
357348
358349 static struct platform_driver gpio_regulator_driver = {
359350 .probe = gpio_regulator_probe,
360− .remove = gpio_regulator_remove,
361351 .driver = {
362352 .name = "gpio-regulator",
363353 .of_match_table = of_match_ptr(regulator_gpio_of_match),
drivers/regulator/hi6421-regulator.c+88−144
@@ -1,17 +1,13 @@
1−/*
2− * Device driver for regulators in Hi6421 IC
3− *
4− * Copyright (c) <2011-2014> HiSilicon Technologies Co., Ltd.
5− * http://www.hisilicon.com
6− * Copyright (c) <2013-2014> Linaro Ltd.
7− * http://www.linaro.org
8− *
9− * Author: Guodong Xu <guodong.xu@linaro.org>
10− *
11− * This program is free software; you can redistribute it and/or modify
12− * it under the terms of the GNU General Public License version 2 as
13− * published by the Free Software Foundation.
14− */
1+// SPDX-License-Identifier: GPL-2.0
2+//
3+// Device driver for regulators in Hi6421 IC
4+//
5+// Copyright (c) <2011-2014> HiSilicon Technologies Co., Ltd.
6+// http://www.hisilicon.com
7+// Copyright (c) <2013-2014> Linaro Ltd.
8+// http://www.linaro.org
9+//
10+// Author: Guodong Xu <guodong.xu@linaro.org>
1511
1612 #include <linux/slab.h>
1713 #include <linux/device.h>
@@ -78,43 +74,6 @@ enum hi6421_regulator_id { · 60 unmodified lines
7874 HI6421_NUM_REGULATORS,
7975 };
8076
81−#define HI6421_REGULATOR_OF_MATCH(_name, id) \
82−{ \
83− .name = #_name, \
84− .driver_data = (void *) HI6421_##id, \
85−}
86−
87−static struct of_regulator_match hi6421_regulator_match[] = {
88− HI6421_REGULATOR_OF_MATCH(hi6421_vout0, LDO0),
89− HI6421_REGULATOR_OF_MATCH(hi6421_vout1, LDO1),
90− HI6421_REGULATOR_OF_MATCH(hi6421_vout2, LDO2),
91− HI6421_REGULATOR_OF_MATCH(hi6421_vout3, LDO3),
92− HI6421_REGULATOR_OF_MATCH(hi6421_vout4, LDO4),
93− HI6421_REGULATOR_OF_MATCH(hi6421_vout5, LDO5),
94− HI6421_REGULATOR_OF_MATCH(hi6421_vout6, LDO6),
95− HI6421_REGULATOR_OF_MATCH(hi6421_vout7, LDO7),
96− HI6421_REGULATOR_OF_MATCH(hi6421_vout8, LDO8),
97− HI6421_REGULATOR_OF_MATCH(hi6421_vout9, LDO9),
98− HI6421_REGULATOR_OF_MATCH(hi6421_vout10, LDO10),
99− HI6421_REGULATOR_OF_MATCH(hi6421_vout11, LDO11),
100− HI6421_REGULATOR_OF_MATCH(hi6421_vout12, LDO12),
101− HI6421_REGULATOR_OF_MATCH(hi6421_vout13, LDO13),
102− HI6421_REGULATOR_OF_MATCH(hi6421_vout14, LDO14),
103− HI6421_REGULATOR_OF_MATCH(hi6421_vout15, LDO15),
104− HI6421_REGULATOR_OF_MATCH(hi6421_vout16, LDO16),
105− HI6421_REGULATOR_OF_MATCH(hi6421_vout17, LDO17),
106− HI6421_REGULATOR_OF_MATCH(hi6421_vout18, LDO18),
107− HI6421_REGULATOR_OF_MATCH(hi6421_vout19, LDO19),
108− HI6421_REGULATOR_OF_MATCH(hi6421_vout20, LDO20),
109− HI6421_REGULATOR_OF_MATCH(hi6421_vout_audio, LDOAUDIO),
110− HI6421_REGULATOR_OF_MATCH(hi6421_buck0, BUCK0),
111− HI6421_REGULATOR_OF_MATCH(hi6421_buck1, BUCK1),
112− HI6421_REGULATOR_OF_MATCH(hi6421_buck2, BUCK2),
113− HI6421_REGULATOR_OF_MATCH(hi6421_buck3, BUCK3),
114− HI6421_REGULATOR_OF_MATCH(hi6421_buck4, BUCK4),
115− HI6421_REGULATOR_OF_MATCH(hi6421_buck5, BUCK5),
116−};
117−
11877 /* LDO 0, 4~7, 9~14, 16~20 have same voltage table. */
11978 static const unsigned int ldo_0_voltages[] = {
12079 1500000, 1800000, 2400000, 2500000,
@@ -157,6 +116,7 @@ static const struct regulator_ops hi6421_buck345_ops; · 36 unmodified lines
157116 #define HI6421_LDO_ENABLE_TIME (350)
158117 /*
159118 * _id - LDO id name string
119+ * _match - of match name string
160120 * v_table - voltage table
161121 * vreg - voltage select register
162122 * vmask - voltage select mask
@@ -166,11 +126,13 @@ static const struct regulator_ops hi6421_buck345_ops; · 3 unmodified lines
166126 * ecomask - eco mode mask
167127 * ecoamp - eco mode load uppler limit in uA
168128 */
169−#define HI6421_LDO(_id, v_table, vreg, vmask, ereg, emask, \
129+#define HI6421_LDO(_id, _match, v_table, vreg, vmask, ereg, emask, \
170130 odelay, ecomask, ecoamp) \
171131 [HI6421_##_id] = { \
172132 .desc = { \
173133 .name = #_id, \
134+ .of_match = of_match_ptr(#_match), \
135+ .regulators_node = of_match_ptr("regulators"), \
174136 .ops = &hi6421_ldo_ops, \
175137 .type = REGULATOR_VOLTAGE, \
176138 .id = HI6421_##_id, \
@@ -191,6 +153,7 @@ static const struct regulator_ops hi6421_buck345_ops; · 14 unmodified lines
191153 /* HI6421 LDO1~3 are linear voltage regulators at fixed uV_step
192154 *
193155 * _id - LDO id name string
156+ * _match - of match name string
194157 * _min_uV - minimum voltage supported in uV
195158 * n_volt - number of votages available
196159 * vstep - voltage increase in each linear step in uV
@@ -202,11 +165,13 @@ static const struct regulator_ops hi6421_buck345_ops; · 5 unmodified lines
202165 * ecomask - eco mode mask
203166 * ecoamp - eco mode load uppler limit in uA
204167 */
205−#define HI6421_LDO_LINEAR(_id, _min_uV, n_volt, vstep, vreg, vmask, \
168+#define HI6421_LDO_LINEAR(_id, _match, _min_uV, n_volt, vstep, vreg, vmask,\
206169 ereg, emask, odelay, ecomask, ecoamp) \
207170 [HI6421_##_id] = { \
208171 .desc = { \
209172 .name = #_id, \
173+ .of_match = of_match_ptr(#_match), \
174+ .regulators_node = of_match_ptr("regulators"), \
210175 .ops = &hi6421_ldo_linear_ops, \
211176 .type = REGULATOR_VOLTAGE, \
212177 .id = HI6421_##_id, \
@@ -228,6 +193,7 @@ static const struct regulator_ops hi6421_buck345_ops; · 15 unmodified lines
228193 /* HI6421 LDOAUDIO is a linear voltage regulator with two 4-step ranges
229194 *
230195 * _id - LDO id name string
196+ * _match - of match name string
231197 * n_volt - number of votages available
232198 * volt_ranges - array of regulator_linear_range
233199 * vstep - voltage increase in each linear step in uV
@@ -239,11 +205,13 @@ static const struct regulator_ops hi6421_buck345_ops; · 5 unmodified lines
239205 * ecomask - eco mode mask
240206 * ecoamp - eco mode load uppler limit in uA
241207 */
242−#define HI6421_LDO_LINEAR_RANGE(_id, n_volt, volt_ranges, vreg, vmask, \
208+#define HI6421_LDO_LINEAR_RANGE(_id, _match, n_volt, volt_ranges, vreg, vmask,\
243209 ereg, emask, odelay, ecomask, ecoamp) \
244210 [HI6421_##_id] = { \
245211 .desc = { \
246212 .name = #_id, \
213+ .of_match = of_match_ptr(#_match), \
214+ .regulators_node = of_match_ptr("regulators"), \
247215 .ops = &hi6421_ldo_linear_range_ops, \
248216 .type = REGULATOR_VOLTAGE, \
249217 .id = HI6421_##_id, \
@@ -265,6 +233,7 @@ static const struct regulator_ops hi6421_buck345_ops; · 15 unmodified lines
265233 /* HI6421 BUCK0/1/2 are linear voltage regulators at fixed uV_step
266234 *
267235 * _id - BUCK0/1/2 id name string
236+ * _match - of match name string
268237 * vreg - voltage select register
269238 * vmask - voltage select mask
270239 * ereg - enable register
@@ -273,11 +242,13 @@ static const struct regulator_ops hi6421_buck345_ops; · 2 unmodified lines
273242 * etime - enable time
274243 * odelay - off/on delay time in uS
275244 */
276−#define HI6421_BUCK012(_id, vreg, vmask, ereg, emask, sleepmask, \
245+#define HI6421_BUCK012(_id, _match, vreg, vmask, ereg, emask, sleepmask,\
277246 etime, odelay) \
278247 [HI6421_##_id] = { \
279248 .desc = { \
280249 .name = #_id, \
250+ .of_match = of_match_ptr(#_match), \
251+ .regulators_node = of_match_ptr("regulators"), \
281252 .ops = &hi6421_buck012_ops, \
282253 .type = REGULATOR_VOLTAGE, \
283254 .id = HI6421_##_id, \
@@ -299,6 +270,7 @@ static const struct regulator_ops hi6421_buck345_ops; · 15 unmodified lines
299270 * that it supports SLEEP mode, so has different .ops.
300271 *
301272 * _id - LDO id name string
273+ * _match - of match name string
302274 * v_table - voltage table
303275 * vreg - voltage select register
304276 * vmask - voltage select mask
@@ -307,11 +279,13 @@ static const struct regulator_ops hi6421_buck345_ops; · 2 unmodified lines
307279 * odelay - off/on delay time in uS
308280 * sleepmask - mask of sleep mode
309281 */
310−#define HI6421_BUCK345(_id, v_table, vreg, vmask, ereg, emask, \
282+#define HI6421_BUCK345(_id, _match, v_table, vreg, vmask, ereg, emask, \
311283 odelay, sleepmask) \
312284 [HI6421_##_id] = { \
313285 .desc = { \
314286 .name = #_id, \
287+ .of_match = of_match_ptr(#_match), \
288+ .regulators_node = of_match_ptr("regulators"), \
315289 .ops = &hi6421_buck345_ops, \
316290 .type = REGULATOR_VOLTAGE, \
317291 .id = HI6421_##_id, \
@@ -331,59 +305,63 @@ static const struct regulator_ops hi6421_buck345_ops; · 13 unmodified lines
331305 /* HI6421 regulator information */
332306 static struct hi6421_regulator_info
333307 hi6421_regulator_info[HI6421_NUM_REGULATORS] = {
334− HI6421_LDO(LDO0, ldo_0_voltages, 0x20, 0x07, 0x20, 0x10,
308+ HI6421_LDO(LDO0, hi6421_vout0, ldo_0_voltages, 0x20, 0x07, 0x20, 0x10,
335309 10000, 0x20, 8000),
336− HI6421_LDO_LINEAR(LDO1, 1700000, 4, 100000, 0x21, 0x03, 0x21, 0x10,
337− 10000, 0x20, 5000),
338− HI6421_LDO_LINEAR(LDO2, 1050000, 8, 50000, 0x22, 0x07, 0x22, 0x10,
339− 20000, 0x20, 8000),
340− HI6421_LDO_LINEAR(LDO3, 1050000, 8, 50000, 0x23, 0x07, 0x23, 0x10,
341− 20000, 0x20, 8000),
342− HI6421_LDO(LDO4, ldo_0_voltages, 0x24, 0x07, 0x24, 0x10,
310+ HI6421_LDO_LINEAR(LDO1, hi6421_vout1, 1700000, 4, 100000, 0x21, 0x03,
311+ 0x21, 0x10, 10000, 0x20, 5000),
312+ HI6421_LDO_LINEAR(LDO2, hi6421_vout2, 1050000, 8, 50000, 0x22, 0x07,
313+ 0x22, 0x10, 20000, 0x20, 8000),
314+ HI6421_LDO_LINEAR(LDO3, hi6421_vout3, 1050000, 8, 50000, 0x23, 0x07,
315+ 0x23, 0x10, 20000, 0x20, 8000),
316+ HI6421_LDO(LDO4, hi6421_vout4, ldo_0_voltages, 0x24, 0x07, 0x24, 0x10,
343317 20000, 0x20, 8000),
344− HI6421_LDO(LDO5, ldo_0_voltages, 0x25, 0x07, 0x25, 0x10,
318+ HI6421_LDO(LDO5, hi6421_vout5, ldo_0_voltages, 0x25, 0x07, 0x25, 0x10,
345319 20000, 0x20, 8000),
346− HI6421_LDO(LDO6, ldo_0_voltages, 0x26, 0x07, 0x26, 0x10,
320+ HI6421_LDO(LDO6, hi6421_vout6, ldo_0_voltages, 0x26, 0x07, 0x26, 0x10,
347321 20000, 0x20, 8000),
348− HI6421_LDO(LDO7, ldo_0_voltages, 0x27, 0x07, 0x27, 0x10,
322+ HI6421_LDO(LDO7, hi6421_vout7, ldo_0_voltages, 0x27, 0x07, 0x27, 0x10,
349323 20000, 0x20, 5000),
350− HI6421_LDO(LDO8, ldo_8_voltages, 0x28, 0x07, 0x28, 0x10,
324+ HI6421_LDO(LDO8, hi6421_vout8, ldo_8_voltages, 0x28, 0x07, 0x28, 0x10,
351325 20000, 0x20, 8000),
352− HI6421_LDO(LDO9, ldo_0_voltages, 0x29, 0x07, 0x29, 0x10,
326+ HI6421_LDO(LDO9, hi6421_vout9, ldo_0_voltages, 0x29, 0x07, 0x29, 0x10,
353327 40000, 0x20, 8000),
354− HI6421_LDO(LDO10, ldo_0_voltages, 0x2a, 0x07, 0x2a, 0x10,
328+ HI6421_LDO(LDO10, hi6421_vout10, ldo_0_voltages, 0x2a, 0x07, 0x2a, 0x10,
355329 40000, 0x20, 8000),
356− HI6421_LDO(LDO11, ldo_0_voltages, 0x2b, 0x07, 0x2b, 0x10,
330+ HI6421_LDO(LDO11, hi6421_vout11, ldo_0_voltages, 0x2b, 0x07, 0x2b, 0x10,
357331 40000, 0x20, 8000),
358− HI6421_LDO(LDO12, ldo_0_voltages, 0x2c, 0x07, 0x2c, 0x10,
332+ HI6421_LDO(LDO12, hi6421_vout12, ldo_0_voltages, 0x2c, 0x07, 0x2c, 0x10,
359333 40000, 0x20, 8000),
360− HI6421_LDO(LDO13, ldo_0_voltages, 0x2d, 0x07, 0x2d, 0x10,
334+ HI6421_LDO(LDO13, hi6421_vout13, ldo_0_voltages, 0x2d, 0x07, 0x2d, 0x10,
361335 40000, 0x20, 8000),
362− HI6421_LDO(LDO14, ldo_0_voltages, 0x2e, 0x07, 0x2e, 0x10,
336+ HI6421_LDO(LDO14, hi6421_vout14, ldo_0_voltages, 0x2e, 0x07, 0x2e, 0x10,
363337 40000, 0x20, 8000),
364− HI6421_LDO(LDO15, ldo_8_voltages, 0x2f, 0x07, 0x2f, 0x10,
338+ HI6421_LDO(LDO15, hi6421_vout15, ldo_8_voltages, 0x2f, 0x07, 0x2f, 0x10,
365339 40000, 0x20, 8000),
366− HI6421_LDO(LDO16, ldo_0_voltages, 0x30, 0x07, 0x30, 0x10,
340+ HI6421_LDO(LDO16, hi6421_vout16, ldo_0_voltages, 0x30, 0x07, 0x30, 0x10,
367341 40000, 0x20, 8000),
368− HI6421_LDO(LDO17, ldo_0_voltages, 0x31, 0x07, 0x31, 0x10,
342+ HI6421_LDO(LDO17, hi6421_vout17, ldo_0_voltages, 0x31, 0x07, 0x31, 0x10,
369343 40000, 0x20, 8000),
370− HI6421_LDO(LDO18, ldo_0_voltages, 0x32, 0x07, 0x32, 0x10,
344+ HI6421_LDO(LDO18, hi6421_vout18, ldo_0_voltages, 0x32, 0x07, 0x32, 0x10,
371345 40000, 0x20, 8000),
372− HI6421_LDO(LDO19, ldo_0_voltages, 0x33, 0x07, 0x33, 0x10,
346+ HI6421_LDO(LDO19, hi6421_vout19, ldo_0_voltages, 0x33, 0x07, 0x33, 0x10,
373347 40000, 0x20, 8000),
374− HI6421_LDO(LDO20, ldo_0_voltages, 0x34, 0x07, 0x34, 0x10,
348+ HI6421_LDO(LDO20, hi6421_vout20, ldo_0_voltages, 0x34, 0x07, 0x34, 0x10,
375349 40000, 0x20, 8000),
376− HI6421_LDO_LINEAR_RANGE(LDOAUDIO, 8, ldo_audio_volt_range, 0x36,
377− 0x70, 0x36, 0x01, 40000, 0x02, 5000),
378− HI6421_BUCK012(BUCK0, 0x0d, 0x7f, 0x0c, 0x01, 0x10, 400, 20000),
379− HI6421_BUCK012(BUCK1, 0x0f, 0x7f, 0x0e, 0x01, 0x10, 400, 20000),
380− HI6421_BUCK012(BUCK2, 0x11, 0x7f, 0x10, 0x01, 0x10, 350, 100),
381− HI6421_BUCK345(BUCK3, buck_3_voltages, 0x13, 0x07, 0x12, 0x01,
382− 20000, 0x10),
383− HI6421_BUCK345(BUCK4, buck_4_voltages, 0x15, 0x07, 0x14, 0x01,
384− 20000, 0x10),
385− HI6421_BUCK345(BUCK5, buck_5_voltages, 0x17, 0x07, 0x16, 0x01,
386− 20000, 0x10),
350+ HI6421_LDO_LINEAR_RANGE(LDOAUDIO, hi6421_vout_audio, 8,
351+ ldo_audio_volt_range, 0x36, 0x70, 0x36, 0x01,
352+ 40000, 0x02, 5000),
353+ HI6421_BUCK012(BUCK0, hi6421_buck0, 0x0d, 0x7f, 0x0c, 0x01, 0x10, 400,
354+ 20000),
355+ HI6421_BUCK012(BUCK1, hi6421_buck1, 0x0f, 0x7f, 0x0e, 0x01, 0x10, 400,
356+ 20000),
357+ HI6421_BUCK012(BUCK2, hi6421_buck2, 0x11, 0x7f, 0x10, 0x01, 0x10, 350,
358+ 100),
359+ HI6421_BUCK345(BUCK3, hi6421_buck3, buck_3_voltages, 0x13, 0x07, 0x12,
360+ 0x01, 20000, 0x10),
361+ HI6421_BUCK345(BUCK4, hi6421_buck4, buck_4_voltages, 0x15, 0x07, 0x14,
362+ 0x01, 20000, 0x10),
363+ HI6421_BUCK345(BUCK5, hi6421_buck5, buck_5_voltages, 0x17, 0x07, 0x16,
364+ 0x01, 20000, 0x10),
387365 };
388366
389367 static int hi6421_regulator_enable(struct regulator_dev *rdev)
@@ -552,42 +530,14 @@ static const struct regulator_ops hi6421_buck345_ops = { · 162 unmodified lines
552530 .set_mode = hi6421_regulator_buck_set_mode,
553531 };
554532
555−static int hi6421_regulator_register(struct platform_device *pdev,
556− struct regmap *rmap,
557− struct regulator_init_data *init_data,
558− int id, struct device_node *np)
559−{
560− struct hi6421_regulator_info *info = NULL;
561− struct regulator_config config = { };
562− struct regulator_dev *rdev;
563−
564− /* assign per-regulator data */
565− info = &hi6421_regulator_info[id];
566−
567− config.dev = &pdev->dev;
568− config.init_data = init_data;
569− config.driver_data = info;
570− config.regmap = rmap;
571− config.of_node = np;
572−
573− /* register regulator with framework */
574− rdev = devm_regulator_register(&pdev->dev, &info->desc, &config);
575− if (IS_ERR(rdev)) {
576− dev_err(&pdev->dev, "failed to register regulator %s\n",
577− info->desc.name);
578− return PTR_ERR(rdev);
579− }
580−
581− return 0;
582−}
583−
584533 static int hi6421_regulator_probe(struct platform_device *pdev)
585534 {
586− struct device *dev = &pdev->dev;
587− struct device_node *np;
588− struct hi6421_pmic *pmic;
535+ struct hi6421_pmic *pmic = dev_get_drvdata(pdev->dev.parent);
589536 struct hi6421_regulator_pdata *pdata;
590− int i, ret = 0;
537+ struct hi6421_regulator_info *info;
538+ struct regulator_config config = { };
539+ struct regulator_dev *rdev;
540+ int i;
591541
592542 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
593543 if (!pdata)
@@ -595,27 +545,21 @@ static int hi6421_regulator_probe(struct platform_device *pdev) · 1 unmodified line
595545 mutex_init(&pdata->lock);
596546 platform_set_drvdata(pdev, pdata);
597547
598− np = of_get_child_by_name(dev->parent->of_node, "regulators");
599− if (!np)
600− return -ENODEV;
601−
602− ret = of_regulator_match(dev, np,
603− hi6421_regulator_match,
604− ARRAY_SIZE(hi6421_regulator_match));
605− of_node_put(np);
606− if (ret < 0) {
607− dev_err(dev, "Error parsing regulator init data: %d\n", ret);
608− return ret;
609− }
610−
611− pmic = dev_get_drvdata(dev->parent);
612−
613548 for (i = 0; i < ARRAY_SIZE(hi6421_regulator_info); i++) {
614− ret = hi6421_regulator_register(pdev, pmic->regmap,
615− hi6421_regulator_match[i].init_data, i,
616− hi6421_regulator_match[i].of_node);
617− if (ret)
618− return ret;
549+ /* assign per-regulator data */
550+ info = &hi6421_regulator_info[i];
551+
552+ config.dev = pdev->dev.parent;
553+ config.driver_data = info;
554+ config.regmap = pmic->regmap;
555+
556+ rdev = devm_regulator_register(&pdev->dev, &info->desc,
557+ &config);
558+ if (IS_ERR(rdev)) {
559+ dev_err(&pdev->dev, "failed to register regulator %s\n",
560+ info->desc.name);
561+ return PTR_ERR(rdev);
562+ }
619563 }
620564
621565 return 0;
drivers/regulator/hi6421v530-regulator.c+11−15
@@ -1,18 +1,14 @@
1−/*
2− * Device driver for regulators in Hi6421V530 IC
3− *
4− * Copyright (c) <2017> HiSilicon Technologies Co., Ltd.
5− * http://www.hisilicon.com
6− * Copyright (c) <2017> Linaro Ltd.
7− * http://www.linaro.org
8− *
9− * Author: Wang Xiaoyin <hw.wangxiaoyin@hisilicon.com>
10− * Guodong Xu <guodong.xu@linaro.org>
11− *
12− * This program is free software; you can redistribute it and/or modify
13− * it under the terms of the GNU General Public License version 2 as
14− * published by the Free Software Foundation.
15− */
1+// SPDX-License-Identifier: GPL-2.0
2+//
3+// Device driver for regulators in Hi6421V530 IC
4+//
5+// Copyright (c) <2017> HiSilicon Technologies Co., Ltd.
6+// http://www.hisilicon.com
7+// Copyright (c) <2017> Linaro Ltd.
8+// http://www.linaro.org
9+//
10+// Author: Wang Xiaoyin <hw.wangxiaoyin@hisilicon.com>
11+// Guodong Xu <guodong.xu@linaro.org>
1612
1713 #include <linux/mfd/hi6421-pmic.h>
1814 #include <linux/module.h>
drivers/regulator/hi655x-regulator.c+13−24
@@ -1,16 +1,12 @@
1−/*
2− * Device driver for regulators in Hi655x IC
3− *
4− * Copyright (c) 2016 Hisilicon.
5− *
6− * Authors:
7− * Chen Feng <puck.chen@hisilicon.com>
8− * Fei Wang <w.f@huawei.com>
9− *
10− * This program is free software; you can redistribute it and/or modify
11− * it under the terms of the GNU General Public License version 2 as
12− * published by the Free Software Foundation.
13− */
1+// SPDX-License-Identifier: GPL-2.0
2+//
3+// Device driver for regulators in Hi655x IC
4+//
5+// Copyright (c) 2016 Hisilicon.
6+//
7+// Authors:
8+// Chen Feng <puck.chen@hisilicon.com>
9+// Fei Wang <w.f@huawei.com>
1410
1511 #include <linux/bitops.h>
1612 #include <linux/device.h>
@@ -28,7 +24,6 @@ · 11 unmodified lines
2824 struct hi655x_regulator {
2925 unsigned int disable_reg;
3026 unsigned int status_reg;
31− unsigned int ctrl_mask;
3227 struct regulator_desc rdesc;
3328 };
3429
@@ -77,22 +72,18 @@ enum hi655x_regulator_id { · 42 unmodified lines
7772 static int hi655x_is_enabled(struct regulator_dev *rdev)
7873 {
7974 unsigned int value = 0;
80−
8175 struct hi655x_regulator *regulator = rdev_get_drvdata(rdev);
8276
8377 regmap_read(rdev->regmap, regulator->status_reg, &value);
84− return (value & BIT(regulator->ctrl_mask));
78+ return (value & rdev->desc->enable_mask);
8579 }
8680
8781 static int hi655x_disable(struct regulator_dev *rdev)
8882 {
89− int ret = 0;
90−
9183 struct hi655x_regulator *regulator = rdev_get_drvdata(rdev);
9284
93− ret = regmap_write(rdev->regmap, regulator->disable_reg,
94− BIT(regulator->ctrl_mask));
95− return ret;
85+ return regmap_write(rdev->regmap, regulator->disable_reg,
86+ rdev->desc->enable_mask);
9687 }
9788
9889 static const struct regulator_ops hi655x_regulator_ops = {
@@ -132,7 +123,6 @@ static const struct regulator_ops hi655x_ldo_linear_ops = { · 33 unmodified lines
132123 }, \
133124 .disable_reg = HI655X_BUS_ADDR(dreg), \
134125 .status_reg = HI655X_BUS_ADDR(sreg), \
135− .ctrl_mask = cmask, \
136126 }
137127
138128 #define HI655X_LDO_LINEAR(_ID, vreg, vmask, ereg, dreg, \
@@ -155,10 +145,9 @@ static const struct regulator_ops hi655x_ldo_linear_ops = { · 16 unmodified lines
155145 }, \
156146 .disable_reg = HI655X_BUS_ADDR(dreg), \
157147 .status_reg = HI655X_BUS_ADDR(sreg), \
158− .ctrl_mask = cmask, \
159148 }
160149
161−static struct hi655x_regulator regulators[] = {
150+static const struct hi655x_regulator regulators[] = {
162151 HI655X_LDO_LINEAR(LDO2, 0x72, 0x07, 0x29, 0x2a, 0x2b, 0x01,
163152 2500000, 8, 100000),
164153 HI655X_LDO(LDO7, 0x78, 0x07, 0x29, 0x2a, 0x2b, 0x06, ldo7_voltages),
drivers/regulator/lm363x-regulator.c+4−4
@@ -48,7 +48,7 @@ static const int ldo_cont_enable_time[] = { · 47 unmodified lines
4848 static int lm363x_regulator_enable_time(struct regulator_dev *rdev)
4949 {
5050 enum lm363x_regulator_id id = rdev_get_id(rdev);
51− u8 val, addr, mask;
51+ unsigned int val, addr, mask;
5252
5353 switch (id) {
5454 case LM3631_LDO_CONT:
@@ -71,7 +71,7 @@ static int lm363x_regulator_enable_time(struct regulator_dev *rdev) · 16 unmodified lines
7171 return 0;
7272 }
7373
74− if (regmap_read(rdev->regmap, addr, (unsigned int *)&val))
74+ if (regmap_read(rdev->regmap, addr, &val))
7575 return -EINVAL;
7676
7777 val = (val & mask) >> LM3631_ENTIME_SHIFT;
@@ -82,13 +82,13 @@ static int lm363x_regulator_enable_time(struct regulator_dev *rdev) · 4 unmodified lines
8282 return ENABLE_TIME_USEC * val;
8383 }
8484
85−static struct regulator_ops lm363x_boost_voltage_table_ops = {
85+static const struct regulator_ops lm363x_boost_voltage_table_ops = {
8686 .list_voltage = regulator_list_voltage_linear,
8787 .set_voltage_sel = regulator_set_voltage_sel_regmap,
8888 .get_voltage_sel = regulator_get_voltage_sel_regmap,
8989 };
9090
91−static struct regulator_ops lm363x_regulator_voltage_table_ops = {
91+static const struct regulator_ops lm363x_regulator_voltage_table_ops = {
9292 .list_voltage = regulator_list_voltage_linear,
9393 .set_voltage_sel = regulator_set_voltage_sel_regmap,
9494 .get_voltage_sel = regulator_get_voltage_sel_regmap,
drivers/regulator/lp8755.c+12−3
@@ -372,10 +372,13 @@ static irqreturn_t lp8755_irq_handler(int irq, void *data) · 371 unmodified lines
372372 for (icnt = 0; icnt < LP8755_BUCK_MAX; icnt++)
373373 if ((flag0 & (0x4 << icnt))
374374 && (pchip->irqmask & (0x04 << icnt))
375− && (pchip->rdev[icnt] != NULL))
375+ && (pchip->rdev[icnt] != NULL)) {
376+ regulator_lock(pchip->rdev[icnt]);
376377 regulator_notifier_call_chain(pchip->rdev[icnt],
377378 LP8755_EVENT_PWR_FAULT,
378379 NULL);
380+ regulator_unlock(pchip->rdev[icnt]);
381+ }
379382
380383 /* read flag1 register */
381384 ret = lp8755_read(pchip, 0x0E, &flag1);
@@ -389,18 +392,24 @@ static irqreturn_t lp8755_irq_handler(int irq, void *data) · 7 unmodified lines
389392 /* send OCP event to all regulator devices */
390393 if ((flag1 & 0x01) && (pchip->irqmask & 0x01))
391394 for (icnt = 0; icnt < LP8755_BUCK_MAX; icnt++)
392− if (pchip->rdev[icnt] != NULL)
395+ if (pchip->rdev[icnt] != NULL) {
396+ regulator_lock(pchip->rdev[icnt]);
393397 regulator_notifier_call_chain(pchip->rdev[icnt],
394398 LP8755_EVENT_OCP,
395399 NULL);
400+ regulator_unlock(pchip->rdev[icnt]);
401+ }
396402
397403 /* send OVP event to all regulator devices */
398404 if ((flag1 & 0x02) && (pchip->irqmask & 0x02))
399405 for (icnt = 0; icnt < LP8755_BUCK_MAX; icnt++)
400− if (pchip->rdev[icnt] != NULL)
406+ if (pchip->rdev[icnt] != NULL) {
407+ regulator_lock(pchip->rdev[icnt]);
401408 regulator_notifier_call_chain(pchip->rdev[icnt],
402409 LP8755_EVENT_OVP,
403410 NULL);
411+ regulator_unlock(pchip->rdev[icnt]);
412+ }
404413 return IRQ_HANDLED;
405414
406415 err_i2c:
drivers/regulator/lp87565-regulator.c+8−41
@@ -34,6 +34,10 @@ · 33 unmodified lines
3434 .ramp_delay = _delay, \
3535 .linear_ranges = _lr, \
3636 .n_linear_ranges = ARRAY_SIZE(_lr), \
37+ .curr_table = lp87565_buck_uA, \
38+ .n_current_limits = ARRAY_SIZE(lp87565_buck_uA),\
39+ .csel_reg = (_cr), \
40+ .csel_mask = LP87565_BUCK_CTRL_2_ILIM, \
3741 }, \
3842 .ctrl2_reg = _cr, \
3943 }
@@ -102,44 +106,7 @@ static int lp87565_buck_set_ramp_delay(struct regulator_dev *rdev, · 62 unmodified lines
102106 return 0;
103107 }
104108
105−static int lp87565_buck_set_current_limit(struct regulator_dev *rdev,
106− int min_uA, int max_uA)
107−{
108− int id = rdev_get_id(rdev);
109− struct lp87565 *lp87565 = rdev_get_drvdata(rdev);
110− int i;
111−
112− for (i = ARRAY_SIZE(lp87565_buck_uA) - 1; i >= 0; i--) {
113− if (lp87565_buck_uA[i] >= min_uA &&
114− lp87565_buck_uA[i] <= max_uA)
115− return regmap_update_bits(lp87565->regmap,
116− regulators[id].ctrl2_reg,
117− LP87565_BUCK_CTRL_2_ILIM,
118− i << __ffs(LP87565_BUCK_CTRL_2_ILIM));
119− }
120−
121− return -EINVAL;
122−}
123−
124−static int lp87565_buck_get_current_limit(struct regulator_dev *rdev)
125−{
126− int id = rdev_get_id(rdev);
127− struct lp87565 *lp87565 = rdev_get_drvdata(rdev);
128− int ret;
129− unsigned int val;
130−
131− ret = regmap_read(lp87565->regmap, regulators[id].ctrl2_reg, &val);
132− if (ret)
133− return ret;
134−
135− val = (val & LP87565_BUCK_CTRL_2_ILIM) >>
136− __ffs(LP87565_BUCK_CTRL_2_ILIM);
137−
138− return (val < ARRAY_SIZE(lp87565_buck_uA)) ?
139− lp87565_buck_uA[val] : -EINVAL;
140−}
141−
142−/* Operations permitted on BUCK0, BUCK1 */
109+/* Operations permitted on BUCKs */
143110 static const struct regulator_ops lp87565_buck_ops = {
144111 .is_enabled = regulator_is_enabled_regmap,
145112 .enable = regulator_enable_regmap,
@@ -150,8 +117,8 @@ static const struct regulator_ops lp87565_buck_ops = { · 4 unmodified lines
150117 .map_voltage = regulator_map_voltage_linear_range,
151118 .set_voltage_time_sel = regulator_set_voltage_time_sel,
152119 .set_ramp_delay = lp87565_buck_set_ramp_delay,
153− .set_current_limit = lp87565_buck_set_current_limit,
154− .get_current_limit = lp87565_buck_get_current_limit,
120+ .set_current_limit = regulator_set_current_limit_regmap,
121+ .get_current_limit = regulator_get_current_limit_regmap,
155122 };
156123
157124 static const struct lp87565_regulator regulators[] = {
@@ -193,7 +160,7 @@ static int lp87565_regulator_probe(struct platform_device *pdev) · 35 unmodified lines
193160 struct lp87565 *lp87565 = dev_get_drvdata(pdev->dev.parent);
194161 struct regulator_config config = { };
195162 struct regulator_dev *rdev;
196− int i, min_idx = LP87565_BUCK_1, max_idx = LP87565_BUCK_3;
163+ int i, min_idx = LP87565_BUCK_0, max_idx = LP87565_BUCK_3;
197164
198165 platform_set_drvdata(pdev, lp87565);
199166
drivers/regulator/ltc3589.c+89−180
@@ -1,21 +1,9 @@
1−/*
2− * Linear Technology LTC3589,LTC3589-1 regulator support
3− *
4− * Copyright (c) 2014 Philipp Zabel <p.zabel@pengutronix.de>, Pengutronix
5− *
6− * See file CREDITS for list of people who contributed to this
7− * project.
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 version 2
11− * as published by the Free Software Foundation.
12− *
13− * This program is distributed in the hope that it will be useful,
14− * but WITHOUT ANY WARRANTY; without even the implied warranty of
15− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16− * GNU General Public License for more details.
17− *
18− */
1+// SPDX-License-Identifier: GPL-2.0
2+//
3+// Linear Technology LTC3589,LTC3589-1 regulator support
4+//
5+// Copyright (c) 2014 Philipp Zabel <p.zabel@pengutronix.de>, Pengutronix
6+
197 #include <linux/i2c.h>
208 #include <linux/init.h>
219 #include <linux/interrupt.h>
@@ -84,19 +72,11 @@ enum ltc3589_reg { · 62 unmodified lines
8472 LTC3589_NUM_REGULATORS,
8573 };
8674
87−struct ltc3589_regulator {
88− struct regulator_desc desc;
89−
90− /* External feedback voltage divider */
91− unsigned int r1;
92− unsigned int r2;
93−};
94−
9575 struct ltc3589 {
9676 struct regmap *regmap;
9777 struct device *dev;
9878 enum ltc3589_variant variant;
99− struct ltc3589_regulator regulator_descs[LTC3589_NUM_REGULATORS];
79+ struct regulator_desc regulator_descs[LTC3589_NUM_REGULATORS];
10080 struct regulator_dev *regulators[LTC3589_NUM_REGULATORS];
10181 };
10282
@@ -196,131 +176,90 @@ static const struct regulator_ops ltc3589_table_regulator_ops = { · 93 unmodified lines
196176 .get_voltage_sel = regulator_get_voltage_sel_regmap,
197177 };
198178
179+static inline unsigned int ltc3589_scale(unsigned int uV, u32 r1, u32 r2)
180+{
181+ uint64_t tmp;
199182
200−#define LTC3589_REG(_name, _ops, en_bit, dtv1_reg, dtv_mask, go_bit) \
201− [LTC3589_ ## _name] = { \
202− .desc = { \
203− .name = #_name, \
204− .n_voltages = (dtv_mask) + 1, \
205− .min_uV = (go_bit) ? 362500 : 0, \
206− .uV_step = (go_bit) ? 12500 : 0, \
207− .ramp_delay = (go_bit) ? 1750 : 0, \
208− .fixed_uV = (dtv_mask) ? 0 : 800000, \
209− .ops = &ltc3589_ ## _ops ## _regulator_ops, \
210− .type = REGULATOR_VOLTAGE, \
211− .id = LTC3589_ ## _name, \
212− .owner = THIS_MODULE, \
213− .vsel_reg = (dtv1_reg), \
214− .vsel_mask = (dtv_mask), \
215− .apply_reg = (go_bit) ? LTC3589_VCCR : 0, \
216− .apply_bit = (go_bit), \
217− .enable_reg = (en_bit) ? LTC3589_OVEN : 0, \
218− .enable_mask = (en_bit), \
219− }, \
220− }
221−
222−#define LTC3589_LINEAR_REG(_name, _dtv1) \
223− LTC3589_REG(_name, linear, LTC3589_OVEN_ ## _name, \
224− LTC3589_ ## _dtv1, 0x1f, \
225− LTC3589_VCCR_ ## _name ## _GO)
226−
227−#define LTC3589_FIXED_REG(_name) \
228− LTC3589_REG(_name, fixed, LTC3589_OVEN_ ## _name, 0, 0, 0)
229−
230−static struct ltc3589_regulator ltc3589_regulators[LTC3589_NUM_REGULATORS] = {
231− LTC3589_LINEAR_REG(SW1, B1DTV1),
232− LTC3589_LINEAR_REG(SW2, B2DTV1),
233− LTC3589_LINEAR_REG(SW3, B3DTV1),
234− LTC3589_FIXED_REG(BB_OUT),
235− LTC3589_REG(LDO1, fixed_standby, 0, 0, 0, 0),
236− LTC3589_LINEAR_REG(LDO2, L2DTV1),
237− LTC3589_FIXED_REG(LDO3),
238− LTC3589_REG(LDO4, table, LTC3589_OVEN_LDO4, LTC3589_L2DTV2, 0x60, 0),
239−};
183+ if (uV == 0)
184+ return 0;
240185
241−#ifdef CONFIG_OF
242−static struct of_regulator_match ltc3589_matches[LTC3589_NUM_REGULATORS] = {
243− { .name = "sw1", },
244− { .name = "sw2", },
245− { .name = "sw3", },
246− { .name = "bb-out", },
247− { .name = "ldo1", }, /* standby */
248− { .name = "ldo2", },
249− { .name = "ldo3", },
250− { .name = "ldo4", },
251−};
186+ tmp = (uint64_t)uV * r1;
187+ do_div(tmp, r2);
188+ return uV + (unsigned int)tmp;
189+}
252190
253−static int ltc3589_parse_regulators_dt(struct ltc3589 *ltc3589)
191+static int ltc3589_of_parse_cb(struct device_node *np,
192+ const struct regulator_desc *desc,
193+ struct regulator_config *config)
254194 {
255− struct device *dev = ltc3589->dev;
256− struct device_node *node;
257− int i, ret;
195+ struct ltc3589 *ltc3589 = config->driver_data;
196+ struct regulator_desc *rdesc = &ltc3589->regulator_descs[desc->id];
197+ u32 r[2];
198+ int ret;
258199
259− node = of_get_child_by_name(dev->of_node, "regulators");
260− if (!node) {
261− dev_err(dev, "regulators node not found\n");
262− return -EINVAL;
263− }
200+ /* Parse feedback voltage dividers. LDO3 and LDO4 don't have them */
201+ if (desc->id >= LTC3589_LDO3)
202+ return 0;
264203
265− ret = of_regulator_match(dev, node, ltc3589_matches,
266− ARRAY_SIZE(ltc3589_matches));
267− of_node_put(node);
268− if (ret < 0) {
269− dev_err(dev, "Error parsing regulator init data: %d\n", ret);
270− return ret;
271− }
272− if (ret != LTC3589_NUM_REGULATORS) {
273− dev_err(dev, "Only %d regulators described in device tree\n",
204+ ret = of_property_read_u32_array(np, "lltc,fb-voltage-divider", r, 2);
205+ if (ret) {
206+ dev_err(ltc3589->dev, "Failed to parse voltage divider: %d\n",
274207 ret);
275− return -EINVAL;
208+ return ret;
276209 }
277210
278− /* Parse feedback voltage dividers. LDO3 and LDO4 don't have them */
279− for (i = 0; i < LTC3589_LDO3; i++) {
280− struct ltc3589_regulator *desc = &ltc3589->regulator_descs[i];
281− struct device_node *np = ltc3589_matches[i].of_node;
282− u32 vdiv[2];
283−
284− ret = of_property_read_u32_array(np, "lltc,fb-voltage-divider",
285− vdiv, 2);
286− if (ret) {
287− dev_err(dev, "Failed to parse voltage divider: %d\n",
288− ret);
289− return ret;
290− }
211+ if (!r[0] || !r[1])
212+ return 0;
291213
292− desc->r1 = vdiv[0];
293− desc->r2 = vdiv[1];
294− }
214+ rdesc->min_uV = ltc3589_scale(desc->min_uV, r[0], r[1]);
215+ rdesc->uV_step = ltc3589_scale(desc->uV_step, r[0], r[1]);
216+ rdesc->fixed_uV = ltc3589_scale(desc->fixed_uV, r[0], r[1]);
295217
296218 return 0;
297219 }
298220
299−static inline struct regulator_init_data *match_init_data(int index)
300−{
301− return ltc3589_matches[index].init_data;
302−}
303−
304−static inline struct device_node *match_of_node(int index)
305−{
306− return ltc3589_matches[index].of_node;
307−}
308−#else
309−static inline int ltc3589_parse_regulators_dt(struct ltc3589 *ltc3589)
310−{
311− return 0;
312−}
221+#define LTC3589_REG(_name, _of_name, _ops, en_bit, dtv1_reg, dtv_mask, go_bit)\
222+ [LTC3589_ ## _name] = { \
223+ .name = #_name, \
224+ .of_match = of_match_ptr(#_of_name), \
225+ .regulators_node = of_match_ptr("regulators"), \
226+ .of_parse_cb = ltc3589_of_parse_cb, \
227+ .n_voltages = (dtv_mask) + 1, \
228+ .min_uV = (go_bit) ? 362500 : 0, \
229+ .uV_step = (go_bit) ? 12500 : 0, \
230+ .ramp_delay = (go_bit) ? 1750 : 0, \
231+ .fixed_uV = (dtv_mask) ? 0 : 800000, \
232+ .ops = &ltc3589_ ## _ops ## _regulator_ops, \
233+ .type = REGULATOR_VOLTAGE, \
234+ .id = LTC3589_ ## _name, \
235+ .owner = THIS_MODULE, \
236+ .vsel_reg = (dtv1_reg), \
237+ .vsel_mask = (dtv_mask), \
238+ .apply_reg = (go_bit) ? LTC3589_VCCR : 0, \
239+ .apply_bit = (go_bit), \
240+ .enable_reg = (en_bit) ? LTC3589_OVEN : 0, \
241+ .enable_mask = (en_bit), \
242+ }
313243
314−static inline struct regulator_init_data *match_init_data(int index)
315−{
316− return NULL;
317−}
244+#define LTC3589_LINEAR_REG(_name, _of_name, _dtv1) \
245+ LTC3589_REG(_name, _of_name, linear, LTC3589_OVEN_ ## _name, \
246+ LTC3589_ ## _dtv1, 0x1f, \
247+ LTC3589_VCCR_ ## _name ## _GO)
318248
319−static inline struct device_node *match_of_node(int index)
320−{
321− return NULL;
322−}
323−#endif
249+#define LTC3589_FIXED_REG(_name, _of_name) \
250+ LTC3589_REG(_name, _of_name, fixed, LTC3589_OVEN_ ## _name, 0, 0, 0)
251+
252+static const struct regulator_desc ltc3589_regulators[] = {
253+ LTC3589_LINEAR_REG(SW1, sw1, B1DTV1),
254+ LTC3589_LINEAR_REG(SW2, sw2, B2DTV1),
255+ LTC3589_LINEAR_REG(SW3, sw3, B3DTV1),
256+ LTC3589_FIXED_REG(BB_OUT, bb-out),
257+ LTC3589_REG(LDO1, ldo1, fixed_standby, 0, 0, 0, 0),
258+ LTC3589_LINEAR_REG(LDO2, ldo2, L2DTV1),
259+ LTC3589_FIXED_REG(LDO3, ldo3),
260+ LTC3589_REG(LDO4, ldo4, table, LTC3589_OVEN_LDO4, LTC3589_L2DTV2,
261+ 0x60, 0),
262+};
324263
325264 static bool ltc3589_writeable_reg(struct device *dev, unsigned int reg)
326265 {
@@ -409,7 +348,6 @@ static const struct regmap_config ltc3589_regmap_config = { · 82 unmodified lines
409348 .cache_type = REGCACHE_RBTREE,
410349 };
411350
412−
413351 static irqreturn_t ltc3589_isr(int irq, void *dev_id)
414352 {
415353 struct ltc3589 *ltc3589 = dev_id;
@@ -419,16 +357,22 @@ static irqreturn_t ltc3589_isr(int irq, void *dev_id) · 3 unmodified lines
419357
420358 if (irqstat & LTC3589_IRQSTAT_THERMAL_WARN) {
421359 event = REGULATOR_EVENT_OVER_TEMP;
422− for (i = 0; i < LTC3589_NUM_REGULATORS; i++)
360+ for (i = 0; i < LTC3589_NUM_REGULATORS; i++) {
361+ regulator_lock(ltc3589->regulators[i]);
423362 regulator_notifier_call_chain(ltc3589->regulators[i],
424363 event, NULL);
364+ regulator_unlock(ltc3589->regulators[i]);
365+ }
425366 }
426367
427368 if (irqstat & LTC3589_IRQSTAT_UNDERVOLT_WARN) {
428369 event = REGULATOR_EVENT_UNDER_VOLTAGE;
429− for (i = 0; i < LTC3589_NUM_REGULATORS; i++)
370+ for (i = 0; i < LTC3589_NUM_REGULATORS; i++) {
371+ regulator_lock(ltc3589->regulators[i]);
430372 regulator_notifier_call_chain(ltc3589->regulators[i],
431373 event, NULL);
374+ regulator_unlock(ltc3589->regulators[i]);
375+ }
432376 }
433377
434378 /* Clear warning condition */
@@ -437,33 +381,11 @@ static irqreturn_t ltc3589_isr(int irq, void *dev_id) · 2 unmodified lines
437381 return IRQ_HANDLED;
438382 }
439383
440−static inline unsigned int ltc3589_scale(unsigned int uV, u32 r1, u32 r2)
441−{
442− uint64_t tmp;
443− if (uV == 0)
444− return 0;
445− tmp = (uint64_t)uV * r1;
446− do_div(tmp, r2);
447− return uV + (unsigned int)tmp;
448−}
449−
450−static void ltc3589_apply_fb_voltage_divider(struct ltc3589_regulator *rdesc)
451−{
452− struct regulator_desc *desc = &rdesc->desc;
453−
454− if (!rdesc->r1 || !rdesc->r2)
455− return;
456−
457− desc->min_uV = ltc3589_scale(desc->min_uV, rdesc->r1, rdesc->r2);
458− desc->uV_step = ltc3589_scale(desc->uV_step, rdesc->r1, rdesc->r2);
459− desc->fixed_uV = ltc3589_scale(desc->fixed_uV, rdesc->r1, rdesc->r2);
460−}
461−
462384 static int ltc3589_probe(struct i2c_client *client,
463385 const struct i2c_device_id *id)
464386 {
465387 struct device *dev = &client->dev;
466− struct ltc3589_regulator *descs;
388+ struct regulator_desc *descs;
467389 struct ltc3589 *ltc3589;
468390 int i, ret;
469391
@@ -482,11 +404,11 @@ static int ltc3589_probe(struct i2c_client *client, · 12 unmodified lines
482404 descs = ltc3589->regulator_descs;
483405 memcpy(descs, ltc3589_regulators, sizeof(ltc3589_regulators));
484406 if (ltc3589->variant == LTC3589) {
485− descs[LTC3589_LDO3].desc.fixed_uV = 1800000;
486− descs[LTC3589_LDO4].desc.volt_table = ltc3589_ldo4;
407+ descs[LTC3589_LDO3].fixed_uV = 1800000;
408+ descs[LTC3589_LDO4].volt_table = ltc3589_ldo4;
487409 } else {
488− descs[LTC3589_LDO3].desc.fixed_uV = 2800000;
489− descs[LTC3589_LDO4].desc.volt_table = ltc3589_12_ldo4;
410+ descs[LTC3589_LDO3].fixed_uV = 2800000;
411+ descs[LTC3589_LDO4].volt_table = ltc3589_12_ldo4;
490412 }
491413
492414 ltc3589->regmap = devm_regmap_init_i2c(client, &ltc3589_regmap_config);
@@ -496,25 +418,12 @@ static int ltc3589_probe(struct i2c_client *client, · 3 unmodified lines
496418 return ret;
497419 }
498420
499− ret = ltc3589_parse_regulators_dt(ltc3589);
500− if (ret)
501− return ret;
502−
503421 for (i = 0; i < LTC3589_NUM_REGULATORS; i++) {
504− struct ltc3589_regulator *rdesc = &ltc3589->regulator_descs[i];
505− struct regulator_desc *desc = &rdesc->desc;
506− struct regulator_init_data *init_data;
422+ struct regulator_desc *desc = &ltc3589->regulator_descs[i];
507423 struct regulator_config config = { };
508424
509− init_data = match_init_data(i);
510−
511− if (i < LTC3589_LDO3)
512− ltc3589_apply_fb_voltage_divider(rdesc);
513−
514425 config.dev = dev;
515− config.init_data = init_data;
516426 config.driver_data = ltc3589;
517− config.of_node = match_of_node(i);
518427
519428 ltc3589->regulators[i] = devm_regulator_register(dev, desc,
520429 &config);
drivers/regulator/ltc3676.c+8−2
@@ -285,17 +285,23 @@ static irqreturn_t ltc3676_isr(int irq, void *dev_id) · 284 unmodified lines
285285 if (irqstat & LTC3676_IRQSTAT_THERMAL_WARN) {
286286 dev_warn(dev, "Over-temperature Warning\n");
287287 event = REGULATOR_EVENT_OVER_TEMP;
288− for (i = 0; i < LTC3676_NUM_REGULATORS; i++)
288+ for (i = 0; i < LTC3676_NUM_REGULATORS; i++) {
289+ regulator_lock(ltc3676->regulators[i]);
289290 regulator_notifier_call_chain(ltc3676->regulators[i],
290291 event, NULL);
292+ regulator_unlock(ltc3676->regulators[i]);
293+ }
291294 }
292295
293296 if (irqstat & LTC3676_IRQSTAT_UNDERVOLT_WARN) {
294297 dev_info(dev, "Undervoltage Warning\n");
295298 event = REGULATOR_EVENT_UNDER_VOLTAGE;
296− for (i = 0; i < LTC3676_NUM_REGULATORS; i++)
299+ for (i = 0; i < LTC3676_NUM_REGULATORS; i++) {
300+ regulator_lock(ltc3676->regulators[i]);
297301 regulator_notifier_call_chain(ltc3676->regulators[i],
298302 event, NULL);
303+ regulator_unlock(ltc3676->regulators[i]);
304+ }
299305 }
300306
301307 /* Clear warning condition */
drivers/regulator/max14577-regulator.c+0−55
@@ -155,58 +155,6 @@ static const struct regulator_desc max77836_supported_regulators[] = { · 154 unmodified lines
155155 [MAX77836_LDO2] = MAX77836_LDO_REG(2),
156156 };
157157
158−#ifdef CONFIG_OF
159−static struct of_regulator_match max14577_regulator_matches[] = {
160− { .name = "SAFEOUT", },
161− { .name = "CHARGER", },
162−};
163−
164−static struct of_regulator_match max77836_regulator_matches[] = {
165− { .name = "SAFEOUT", },
166− { .name = "CHARGER", },
167− { .name = "LDO1", },
168− { .name = "LDO2", },
169−};
170−
171−static inline struct regulator_init_data *match_init_data(int index,
172− enum maxim_device_type dev_type)
173−{
174− switch (dev_type) {
175− case MAXIM_DEVICE_TYPE_MAX77836:
176− return max77836_regulator_matches[index].init_data;
177−
178− case MAXIM_DEVICE_TYPE_MAX14577:
179− default:
180− return max14577_regulator_matches[index].init_data;
181− }
182−}
183−
184−static inline struct device_node *match_of_node(int index,
185− enum maxim_device_type dev_type)
186−{
187− switch (dev_type) {
188− case MAXIM_DEVICE_TYPE_MAX77836:
189− return max77836_regulator_matches[index].of_node;
190−
191− case MAXIM_DEVICE_TYPE_MAX14577:
192− default:
193− return max14577_regulator_matches[index].of_node;
194− }
195−}
196−#else /* CONFIG_OF */
197−static inline struct regulator_init_data *match_init_data(int index,
198− enum maxim_device_type dev_type)
199−{
200− return NULL;
201−}
202−
203−static inline struct device_node *match_of_node(int index,
204− enum maxim_device_type dev_type)
205−{
206− return NULL;
207−}
208−#endif /* CONFIG_OF */
209−
210158 /**
211159 * Registers for regulators of max77836 use different I2C slave addresses so
212160 * different regmaps must be used for them.
@@ -265,9 +213,6 @@ static int max14577_regulator_probe(struct platform_device *pdev) · 52 unmodified lines
265213 if (pdata && pdata->regulators) {
266214 config.init_data = pdata->regulators[i].initdata;
267215 config.of_node = pdata->regulators[i].of_node;
268− } else {
269− config.init_data = match_init_data(i, dev_type);
270− config.of_node = match_of_node(i, dev_type);
271216 }
272217 config.regmap = max14577_get_regmap(max14577,
273218 supported_regulators[i].id);
drivers/regulator/max77650-regulator.c+1−1
@@ -41,7 +41,7 @@ struct max77650_regulator_desc { · 40 unmodified lines
4141 unsigned int regB;
4242 };
4343
44−static const u32 max77651_sbb1_regulator_volt_table[] = {
44+static const unsigned int max77651_sbb1_regulator_volt_table[] = {
4545 2400000, 3200000, 4000000, 4800000,
4646 2450000, 3250000, 4050000, 4850000,
4747 2500000, 3300000, 4100000, 4900000,
drivers/regulator/max8925-regulator.c+9−67
@@ -159,6 +159,8 @@ static const struct regulator_ops max8925_regulator_ldo_ops = { · 158 unmodified lines
159159 { \
160160 .desc = { \
161161 .name = "SDV" #_id, \
162+ .of_match = of_match_ptr("SDV" #_id), \
163+ .regulators_node = of_match_ptr("regulators"), \
162164 .ops = &max8925_regulator_sdv_ops, \
163165 .type = REGULATOR_VOLTAGE, \
164166 .id = MAX8925_ID_SD##_id, \
@@ -175,6 +177,8 @@ static const struct regulator_ops max8925_regulator_ldo_ops = { · 10 unmodified lines
175177 { \
176178 .desc = { \
177179 .name = "LDO" #_id, \
180+ .of_match = of_match_ptr("LDO" #_id), \
181+ .regulators_node = of_match_ptr("regulators"), \
178182 .ops = &max8925_regulator_ldo_ops, \
179183 .type = REGULATOR_VOLTAGE, \
180184 .id = MAX8925_ID_LDO##_id, \
@@ -187,34 +191,6 @@ static const struct regulator_ops max8925_regulator_ldo_ops = { · 6 unmodified lines
187191 .enable_reg = MAX8925_LDOCTL##_id, \
188192 }
189193
190−#ifdef CONFIG_OF
191−static struct of_regulator_match max8925_regulator_matches[] = {
192− { .name = "SDV1",},
193− { .name = "SDV2",},
194− { .name = "SDV3",},
195− { .name = "LDO1",},
196− { .name = "LDO2",},
197− { .name = "LDO3",},
198− { .name = "LDO4",},
199− { .name = "LDO5",},
200− { .name = "LDO6",},
201− { .name = "LDO7",},
202− { .name = "LDO8",},
203− { .name = "LDO9",},
204− { .name = "LDO10",},
205− { .name = "LDO11",},
206− { .name = "LDO12",},
207− { .name = "LDO13",},
208− { .name = "LDO14",},
209− { .name = "LDO15",},
210− { .name = "LDO16",},
211− { .name = "LDO17",},
212− { .name = "LDO18",},
213− { .name = "LDO19",},
214− { .name = "LDO20",},
215−};
216−#endif
217−
218194 static struct max8925_regulator_info max8925_regulator_info[] = {
219195 MAX8925_SDV(1, 637.5, 1425, 12.5),
220196 MAX8925_SDV(2, 650, 2225, 25),
@@ -242,37 +218,6 @@ static struct max8925_regulator_info max8925_regulator_info[] = { · 21 unmodified lines
242218 MAX8925_LDO(20, 750, 3900, 50),
243219 };
244220
245−#ifdef CONFIG_OF
246−static int max8925_regulator_dt_init(struct platform_device *pdev,
247− struct regulator_config *config,
248− int ridx)
249−{
250− struct device_node *nproot, *np;
251− int rcount;
252−
253− nproot = pdev->dev.parent->of_node;
254− if (!nproot)
255− return -ENODEV;
256− np = of_get_child_by_name(nproot, "regulators");
257− if (!np) {
258− dev_err(&pdev->dev, "failed to find regulators node\n");
259− return -ENODEV;
260− }
261−
262− rcount = of_regulator_match(&pdev->dev, np,
263− &max8925_regulator_matches[ridx], 1);
264− of_node_put(np);
265− if (rcount < 0)
266− return rcount;
267− config->init_data = max8925_regulator_matches[ridx].init_data;
268− config->of_node = max8925_regulator_matches[ridx].of_node;
269−
270− return 0;
271−}
272−#else
273−#define max8925_regulator_dt_init(x, y, z) (-1)
274−#endif
275−
276221 static int max8925_regulator_probe(struct platform_device *pdev)
277222 {
278223 struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent);
@@ -281,7 +226,7 @@ static int max8925_regulator_probe(struct platform_device *pdev) · 2 unmodified lines
281226 struct max8925_regulator_info *ri;
282227 struct resource *res;
283228 struct regulator_dev *rdev;
284− int i, regulator_idx;
229+ int i;
285230
286231 res = platform_get_resource(pdev, IORESOURCE_REG, 0);
287232 if (!res) {
@@ -290,10 +235,8 @@ static int max8925_regulator_probe(struct platform_device *pdev) · 2 unmodified lines
290235 }
291236 for (i = 0; i < ARRAY_SIZE(max8925_regulator_info); i++) {
292237 ri = &max8925_regulator_info[i];
293− if (ri->vol_reg == res->start) {
294− regulator_idx = i;
238+ if (ri->vol_reg == res->start)
295239 break;
296− }
297240 }
298241
299242 if (i == ARRAY_SIZE(max8925_regulator_info)) {
@@ -303,12 +246,11 @@ static int max8925_regulator_probe(struct platform_device *pdev) · 3 unmodified lines
303246 }
304247 ri->i2c = chip->i2c;
305248
306− config.dev = &pdev->dev;
249+ config.dev = chip->dev;
307250 config.driver_data = ri;
308251
309− if (max8925_regulator_dt_init(pdev, &config, regulator_idx))
310− if (pdata)
311− config.init_data = pdata;
252+ if (pdata)
253+ config.init_data = pdata;
312254
313255 rdev = devm_regulator_register(&pdev->dev, &ri->desc, &config);
314256 if (IS_ERR(rdev)) {
drivers/regulator/max8998.c+59−241
@@ -33,72 +33,6 @@ struct max8998_data { · 32 unmodified lines
3333 unsigned int buck2_idx;
3434 };
3535
36−struct voltage_map_desc {
37− int min;
38− int max;
39− int step;
40−};
41−
42−/* Voltage maps in uV*/
43−static const struct voltage_map_desc ldo23_voltage_map_desc = {
44− .min = 800000, .step = 50000, .max = 1300000,
45−};
46−static const struct voltage_map_desc ldo456711_voltage_map_desc = {
47− .min = 1600000, .step = 100000, .max = 3600000,
48−};
49−static const struct voltage_map_desc ldo8_voltage_map_desc = {
50− .min = 3000000, .step = 100000, .max = 3600000,
51−};
52−static const struct voltage_map_desc ldo9_voltage_map_desc = {
53− .min = 2800000, .step = 100000, .max = 3100000,
54−};
55−static const struct voltage_map_desc ldo10_voltage_map_desc = {
56− .min = 950000, .step = 50000, .max = 1300000,
57−};
58−static const struct voltage_map_desc ldo1213_voltage_map_desc = {
59− .min = 800000, .step = 100000, .max = 3300000,
60−};
61−static const struct voltage_map_desc ldo1415_voltage_map_desc = {
62− .min = 1200000, .step = 100000, .max = 3300000,
63−};
64−static const struct voltage_map_desc ldo1617_voltage_map_desc = {
65− .min = 1600000, .step = 100000, .max = 3600000,
66−};
67−static const struct voltage_map_desc buck12_voltage_map_desc = {
68− .min = 750000, .step = 25000, .max = 1525000,
69−};
70−static const struct voltage_map_desc buck3_voltage_map_desc = {
71− .min = 1600000, .step = 100000, .max = 3600000,
72−};
73−static const struct voltage_map_desc buck4_voltage_map_desc = {
74− .min = 800000, .step = 100000, .max = 2300000,
75−};
76−
77−static const struct voltage_map_desc *ldo_voltage_map[] = {
78− NULL,
79− NULL,
80− &ldo23_voltage_map_desc, /* LDO2 */
81− &ldo23_voltage_map_desc, /* LDO3 */
82− &ldo456711_voltage_map_desc, /* LDO4 */
83− &ldo456711_voltage_map_desc, /* LDO5 */
84− &ldo456711_voltage_map_desc, /* LDO6 */
85− &ldo456711_voltage_map_desc, /* LDO7 */
86− &ldo8_voltage_map_desc, /* LDO8 */
87− &ldo9_voltage_map_desc, /* LDO9 */
88− &ldo10_voltage_map_desc, /* LDO10 */
89− &ldo456711_voltage_map_desc, /* LDO11 */
90− &ldo1213_voltage_map_desc, /* LDO12 */
91− &ldo1213_voltage_map_desc, /* LDO13 */
92− &ldo1415_voltage_map_desc, /* LDO14 */
93− &ldo1415_voltage_map_desc, /* LDO15 */
94− &ldo1617_voltage_map_desc, /* LDO16 */
95− &ldo1617_voltage_map_desc, /* LDO17 */
96− &buck12_voltage_map_desc, /* BUCK1 */
97− &buck12_voltage_map_desc, /* BUCK2 */
98− &buck3_voltage_map_desc, /* BUCK3 */
99− &buck4_voltage_map_desc, /* BUCK4 */
100−};
101−
10236 static int max8998_get_enable_register(struct regulator_dev *rdev,
10337 int *reg, int *shift)
10438 {
@@ -400,7 +334,6 @@ static int max8998_set_voltage_buck_time_sel(struct regulator_dev *rdev, · 295 unmodified lines
400334 {
401335 struct max8998_data *max8998 = rdev_get_drvdata(rdev);
402336 struct i2c_client *i2c = max8998->iodev->i2c;
403− const struct voltage_map_desc *desc;
404337 int buck = rdev_get_id(rdev);
405338 u8 val = 0;
406339 int difference, ret;
@@ -408,8 +341,6 @@ static int max8998_set_voltage_buck_time_sel(struct regulator_dev *rdev, · 1 unmodified line
408341 if (buck < MAX8998_BUCK1 || buck > MAX8998_BUCK4)
409342 return -EINVAL;
410343
411− desc = ldo_voltage_map[buck];
412−
413344 /* Voltage stabilization */
414345 ret = max8998_read_reg(i2c, MAX8998_REG_ONOFF4, &val);
415346 if (ret)
@@ -420,14 +351,14 @@ static int max8998_set_voltage_buck_time_sel(struct regulator_dev *rdev, · 4 unmodified lines
420351 if (max8998->iodev->type == TYPE_MAX8998 && !(val & MAX8998_ENRAMP))
421352 return 0;
422353
423− difference = (new_selector - old_selector) * desc->step / 1000;
354+ difference = (new_selector - old_selector) * rdev->desc->uV_step / 1000;
424355 if (difference > 0)
425356 return DIV_ROUND_UP(difference, (val & 0x0f) + 1);
426357
427358 return 0;
428359 }
429360
430−static struct regulator_ops max8998_ldo_ops = {
361+static const struct regulator_ops max8998_ldo_ops = {
431362 .list_voltage = regulator_list_voltage_linear,
432363 .map_voltage = regulator_map_voltage_linear,
433364 .is_enabled = max8998_ldo_is_enabled,
@@ -437,7 +368,7 @@ static struct regulator_ops max8998_ldo_ops = { · 3 unmodified lines
437368 .set_voltage_sel = max8998_set_voltage_ldo_sel,
438369 };
439370
440−static struct regulator_ops max8998_buck_ops = {
371+static const struct regulator_ops max8998_buck_ops = {
441372 .list_voltage = regulator_list_voltage_linear,
442373 .map_voltage = regulator_map_voltage_linear,
443374 .is_enabled = max8998_ldo_is_enabled,
@@ -448,164 +379,59 @@ static struct regulator_ops max8998_buck_ops = { · 4 unmodified lines
448379 .set_voltage_time_sel = max8998_set_voltage_buck_time_sel,
449380 };
450381
451−static struct regulator_ops max8998_others_ops = {
382+static const struct regulator_ops max8998_others_ops = {
452383 .is_enabled = max8998_ldo_is_enabled,
453384 .enable = max8998_ldo_enable,
454385 .disable = max8998_ldo_disable,
455386 };
456387
457−static struct regulator_desc regulators[] = {
458− {
459− .name = "LDO2",
460− .id = MAX8998_LDO2,
461− .ops = &max8998_ldo_ops,
462− .type = REGULATOR_VOLTAGE,
463− .owner = THIS_MODULE,
464− }, {
465− .name = "LDO3",
466− .id = MAX8998_LDO3,
467− .ops = &max8998_ldo_ops,
468− .type = REGULATOR_VOLTAGE,
469− .owner = THIS_MODULE,
470− }, {
471− .name = "LDO4",
472− .id = MAX8998_LDO4,
473− .ops = &max8998_ldo_ops,
474− .type = REGULATOR_VOLTAGE,
475− .owner = THIS_MODULE,
476− }, {
477− .name = "LDO5",
478− .id = MAX8998_LDO5,
479− .ops = &max8998_ldo_ops,
480− .type = REGULATOR_VOLTAGE,
481− .owner = THIS_MODULE,
482− }, {
483− .name = "LDO6",
484− .id = MAX8998_LDO6,
485− .ops = &max8998_ldo_ops,
486− .type = REGULATOR_VOLTAGE,
487− .owner = THIS_MODULE,
488− }, {
489− .name = "LDO7",
490− .id = MAX8998_LDO7,
491− .ops = &max8998_ldo_ops,
492− .type = REGULATOR_VOLTAGE,
493− .owner = THIS_MODULE,
494− }, {
495− .name = "LDO8",
496− .id = MAX8998_LDO8,
497− .ops = &max8998_ldo_ops,
498− .type = REGULATOR_VOLTAGE,
499− .owner = THIS_MODULE,
500− }, {
501− .name = "LDO9",
502− .id = MAX8998_LDO9,
503− .ops = &max8998_ldo_ops,
504− .type = REGULATOR_VOLTAGE,
505− .owner = THIS_MODULE,
506− }, {
507− .name = "LDO10",
508− .id = MAX8998_LDO10,
509− .ops = &max8998_ldo_ops,
510− .type = REGULATOR_VOLTAGE,
511− .owner = THIS_MODULE,
512− }, {
513− .name = "LDO11",
514− .id = MAX8998_LDO11,
515− .ops = &max8998_ldo_ops,
516− .type = REGULATOR_VOLTAGE,
517− .owner = THIS_MODULE,
518− }, {
519− .name = "LDO12",
520− .id = MAX8998_LDO12,
521− .ops = &max8998_ldo_ops,
522− .type = REGULATOR_VOLTAGE,
523− .owner = THIS_MODULE,
524− }, {
525− .name = "LDO13",
526− .id = MAX8998_LDO13,
527− .ops = &max8998_ldo_ops,
528− .type = REGULATOR_VOLTAGE,
529− .owner = THIS_MODULE,
530− }, {
531− .name = "LDO14",
532− .id = MAX8998_LDO14,
533− .ops = &max8998_ldo_ops,
534− .type = REGULATOR_VOLTAGE,
535− .owner = THIS_MODULE,
536− }, {
537− .name = "LDO15",
538− .id = MAX8998_LDO15,
539− .ops = &max8998_ldo_ops,
540− .type = REGULATOR_VOLTAGE,
541− .owner = THIS_MODULE,
542− }, {
543− .name = "LDO16",
544− .id = MAX8998_LDO16,
545− .ops = &max8998_ldo_ops,
546− .type = REGULATOR_VOLTAGE,
547− .owner = THIS_MODULE,
548− }, {
549− .name = "LDO17",
550− .id = MAX8998_LDO17,
551− .ops = &max8998_ldo_ops,
552− .type = REGULATOR_VOLTAGE,
553− .owner = THIS_MODULE,
554− }, {
555− .name = "BUCK1",
556− .id = MAX8998_BUCK1,
557− .ops = &max8998_buck_ops,
558− .type = REGULATOR_VOLTAGE,
559− .owner = THIS_MODULE,
560− }, {
561− .name = "BUCK2",
562− .id = MAX8998_BUCK2,
563− .ops = &max8998_buck_ops,
564− .type = REGULATOR_VOLTAGE,
565− .owner = THIS_MODULE,
566− }, {
567− .name = "BUCK3",
568− .id = MAX8998_BUCK3,
569− .ops = &max8998_buck_ops,
570− .type = REGULATOR_VOLTAGE,
571− .owner = THIS_MODULE,
572− }, {
573− .name = "BUCK4",
574− .id = MAX8998_BUCK4,
575− .ops = &max8998_buck_ops,
576− .type = REGULATOR_VOLTAGE,
577− .owner = THIS_MODULE,
578− }, {
579− .name = "EN32KHz-AP",
580− .id = MAX8998_EN32KHZ_AP,
581− .ops = &max8998_others_ops,
582− .type = REGULATOR_VOLTAGE,
583− .owner = THIS_MODULE,
584− }, {
585− .name = "EN32KHz-CP",
586− .id = MAX8998_EN32KHZ_CP,
587− .ops = &max8998_others_ops,
588− .type = REGULATOR_VOLTAGE,
589− .owner = THIS_MODULE,
590− }, {
591− .name = "ENVICHG",
592− .id = MAX8998_ENVICHG,
593− .ops = &max8998_others_ops,
594− .type = REGULATOR_VOLTAGE,
595− .owner = THIS_MODULE,
596− }, {
597− .name = "ESAFEOUT1",
598− .id = MAX8998_ESAFEOUT1,
599− .ops = &max8998_others_ops,
600− .type = REGULATOR_VOLTAGE,
601− .owner = THIS_MODULE,
602− }, {
603− .name = "ESAFEOUT2",
604− .id = MAX8998_ESAFEOUT2,
605− .ops = &max8998_others_ops,
606− .type = REGULATOR_VOLTAGE,
607− .owner = THIS_MODULE,
388+#define MAX8998_LINEAR_REG(_name, _ops, _min, _step, _max) \
389+ { \
390+ .name = #_name, \
391+ .id = MAX8998_##_name, \
392+ .ops = _ops, \
393+ .min_uV = (_min), \
394+ .uV_step = (_step), \
395+ .n_voltages = ((_max) - (_min)) / (_step) + 1, \
396+ .type = REGULATOR_VOLTAGE, \
397+ .owner = THIS_MODULE, \
608398 }
399+
400+#define MAX8998_OTHERS_REG(_name, _id) \
401+ { \
402+ .name = #_name, \
403+ .id = _id, \
404+ .ops = &max8998_others_ops, \
405+ .type = REGULATOR_VOLTAGE, \
406+ .owner = THIS_MODULE, \
407+ }
408+
409+static const struct regulator_desc regulators[] = {
410+ MAX8998_LINEAR_REG(LDO2, &max8998_ldo_ops, 800000, 50000, 1300000),
411+ MAX8998_LINEAR_REG(LDO3, &max8998_ldo_ops, 800000, 50000, 1300000),
412+ MAX8998_LINEAR_REG(LDO4, &max8998_ldo_ops, 1600000, 100000, 3600000),
413+ MAX8998_LINEAR_REG(LDO5, &max8998_ldo_ops, 1600000, 100000, 3600000),
414+ MAX8998_LINEAR_REG(LDO6, &max8998_ldo_ops, 1600000, 100000, 3600000),
415+ MAX8998_LINEAR_REG(LDO7, &max8998_ldo_ops, 1600000, 100000, 3600000),
416+ MAX8998_LINEAR_REG(LDO8, &max8998_ldo_ops, 3000000, 100000, 3600000),
417+ MAX8998_LINEAR_REG(LDO9, &max8998_ldo_ops, 2800000, 100000, 3100000),
418+ MAX8998_LINEAR_REG(LDO10, &max8998_ldo_ops, 950000, 50000, 1300000),
419+ MAX8998_LINEAR_REG(LDO11, &max8998_ldo_ops, 1600000, 100000, 3600000),
420+ MAX8998_LINEAR_REG(LDO12, &max8998_ldo_ops, 800000, 100000, 3300000),
421+ MAX8998_LINEAR_REG(LDO13, &max8998_ldo_ops, 800000, 100000, 3300000),
422+ MAX8998_LINEAR_REG(LDO14, &max8998_ldo_ops, 1200000, 100000, 3300000),
423+ MAX8998_LINEAR_REG(LDO15, &max8998_ldo_ops, 1200000, 100000, 3300000),
424+ MAX8998_LINEAR_REG(LDO16, &max8998_ldo_ops, 1600000, 100000, 3600000),
425+ MAX8998_LINEAR_REG(LDO17, &max8998_ldo_ops, 1600000, 100000, 3600000),
426+ MAX8998_LINEAR_REG(BUCK1, &max8998_buck_ops, 750000, 25000, 1525000),
427+ MAX8998_LINEAR_REG(BUCK2, &max8998_buck_ops, 750000, 25000, 1525000),
428+ MAX8998_LINEAR_REG(BUCK3, &max8998_buck_ops, 1600000, 100000, 3600000),
429+ MAX8998_LINEAR_REG(BUCK4, &max8998_buck_ops, 800000, 100000, 2300000),
430+ MAX8998_OTHERS_REG(EN32KHz-AP, MAX8998_EN32KHZ_AP),
431+ MAX8998_OTHERS_REG(EN32KHz-CP, MAX8998_EN32KHZ_CP),
432+ MAX8998_OTHERS_REG(ENVICHG, MAX8998_ENVICHG),
433+ MAX8998_OTHERS_REG(ESAFEOUT1, MAX8998_ESAFEOUT1),
434+ MAX8998_OTHERS_REG(ESAFEOUT2, MAX8998_ESAFEOUT2),
609435 };
610436
611437 static int max8998_pmic_dt_parse_dvs_gpio(struct max8998_dev *iodev,
@@ -796,9 +622,11 @@ static int max8998_pmic_probe(struct platform_device *pdev) · 184 unmodified lines
796622
797623 /* Set predefined values for BUCK1 registers */
798624 for (v = 0; v < ARRAY_SIZE(pdata->buck1_voltage); ++v) {
625+ int index = MAX8998_BUCK1 - MAX8998_LDO2;
626+
799627 i = 0;
800− while (buck12_voltage_map_desc.min +
801− buck12_voltage_map_desc.step*i
628+ while (regulators[index].min_uV +
629+ regulators[index].uV_step * i
802630 < pdata->buck1_voltage[v])
803631 i++;
804632
@@ -824,9 +652,11 @@ static int max8998_pmic_probe(struct platform_device *pdev) · 19 unmodified lines
824652
825653 /* Set predefined values for BUCK2 registers */
826654 for (v = 0; v < ARRAY_SIZE(pdata->buck2_voltage); ++v) {
655+ int index = MAX8998_BUCK2 - MAX8998_LDO2;
656+
827657 i = 0;
828− while (buck12_voltage_map_desc.min +
829− buck12_voltage_map_desc.step*i
658+ while (regulators[index].min_uV +
659+ regulators[index].uV_step * i
830660 < pdata->buck2_voltage[v])
831661 i++;
832662
@@ -839,18 +669,7 @@ static int max8998_pmic_probe(struct platform_device *pdev) · 6 unmodified lines
839669 }
840670
841671 for (i = 0; i < pdata->num_regulators; i++) {
842− const struct voltage_map_desc *desc;
843− int id = pdata->regulators[i].id;
844− int index = id - MAX8998_LDO2;
845−
846− desc = ldo_voltage_map[id];
847− if (desc && regulators[index].ops != &max8998_others_ops) {
848− int count = (desc->max - desc->min) / desc->step + 1;
849−
850− regulators[index].n_voltages = count;
851− regulators[index].min_uV = desc->min;
852− regulators[index].uV_step = desc->step;
853− }
672+ int index = pdata->regulators[i].id - MAX8998_LDO2;
854673
855674 config.dev = max8998->dev;
856675 config.of_node = pdata->regulators[i].reg_node;
@@ -867,7 +686,6 @@ static int max8998_pmic_probe(struct platform_device *pdev) · 10 unmodified lines
867686 }
868687 }
869688
870−
871689 return 0;
872690 }
873691
drivers/regulator/mcp16502.c+22−45
@@ -119,8 +119,6 @@ enum { · 118 unmodified lines
119119 * @lpm: LPM GPIO descriptor
120120 */
121121 struct mcp16502 {
122− struct regulator_dev *rdev[NUM_REGULATORS];
123− struct regmap *rmap;
124122 struct gpio_desc *lpm;
125123 };
126124
@@ -179,13 +177,12 @@ static unsigned int mcp16502_get_mode(struct regulator_dev *rdev) · 52 unmodified lines
179177 {
180178 unsigned int val;
181179 int ret, reg;
182− struct mcp16502 *mcp = rdev_get_drvdata(rdev);
183180
184181 reg = mcp16502_get_reg(rdev, MCP16502_OPMODE_ACTIVE);
185182 if (reg < 0)
186183 return reg;
187184
188− ret = regmap_read(mcp->rmap, reg, &val);
185+ ret = regmap_read(rdev->regmap, reg, &val);
189186 if (ret)
190187 return ret;
191188
@@ -211,7 +208,6 @@ static int _mcp16502_set_mode(struct regulator_dev *rdev, unsigned int mode, · 19 unmodified lines
211208 {
212209 int val;
213210 int reg;
214− struct mcp16502 *mcp = rdev_get_drvdata(rdev);
215211
216212 reg = mcp16502_get_reg(rdev, op_mode);
217213 if (reg < 0)
@@ -228,7 +224,7 @@ static int _mcp16502_set_mode(struct regulator_dev *rdev, unsigned int mode, · 10 unmodified lines
228224 return -EINVAL;
229225 }
230226
231− reg = regmap_update_bits(mcp->rmap, reg, MCP16502_MODE, val);
227+ reg = regmap_update_bits(rdev->regmap, reg, MCP16502_MODE, val);
232228 return reg;
233229 }
234230
@@ -247,9 +243,8 @@ static int mcp16502_get_status(struct regulator_dev *rdev) · 12 unmodified lines
247243 {
248244 int ret;
249245 unsigned int val;
250− struct mcp16502 *mcp = rdev_get_drvdata(rdev);
251246
252− ret = regmap_read(mcp->rmap, MCP16502_STAT_BASE(rdev_get_id(rdev)),
247+ ret = regmap_read(rdev->regmap, MCP16502_STAT_BASE(rdev_get_id(rdev)),
253248 &val);
254249 if (ret)
255250 return ret;
@@ -290,7 +285,6 @@ static int mcp16502_suspend_get_target_reg(struct regulator_dev *rdev) · 34 unmodified lines
290285 */
291286 static int mcp16502_set_suspend_voltage(struct regulator_dev *rdev, int uV)
292287 {
293− struct mcp16502 *mcp = rdev_get_drvdata(rdev);
294288 int sel = regulator_map_voltage_linear_range(rdev, uV, uV);
295289 int reg = mcp16502_suspend_get_target_reg(rdev);
296290
@@ -300,7 +294,7 @@ static int mcp16502_set_suspend_voltage(struct regulator_dev *rdev, int uV) · 3 unmodified lines
300294 if (reg < 0)
301295 return reg;
302296
303− return regmap_update_bits(mcp->rmap, reg, MCP16502_VSEL, sel);
297+ return regmap_update_bits(rdev->regmap, reg, MCP16502_VSEL, sel);
304298 }
305299
306300 /*
@@ -328,13 +322,12 @@ static int mcp16502_set_suspend_mode(struct regulator_dev *rdev, · 21 unmodified lines
328322 */
329323 static int mcp16502_set_suspend_enable(struct regulator_dev *rdev)
330324 {
331− struct mcp16502 *mcp = rdev_get_drvdata(rdev);
332325 int reg = mcp16502_suspend_get_target_reg(rdev);
333326
334327 if (reg < 0)
335328 return reg;
336329
337− return regmap_update_bits(mcp->rmap, reg, MCP16502_EN, MCP16502_EN);
330+ return regmap_update_bits(rdev->regmap, reg, MCP16502_EN, MCP16502_EN);
338331 }
339332
340333 /*
@@ -342,13 +335,12 @@ static int mcp16502_set_suspend_enable(struct regulator_dev *rdev) · 1 unmodified line
342335 */
343336 static int mcp16502_set_suspend_disable(struct regulator_dev *rdev)
344337 {
345− struct mcp16502 *mcp = rdev_get_drvdata(rdev);
346338 int reg = mcp16502_suspend_get_target_reg(rdev);
347339
348340 if (reg < 0)
349341 return reg;
350342
351− return regmap_update_bits(mcp->rmap, reg, MCP16502_EN, 0);
343+ return regmap_update_bits(rdev->regmap, reg, MCP16502_EN, 0);
352344 }
353345 #endif /* CONFIG_SUSPEND */
354346
@@ -435,36 +427,15 @@ static const struct regmap_config mcp16502_regmap_config = { · 80 unmodified lines
435427 .wr_table = &mcp16502_yes_reg_table,
436428 };
437429
438−/*
439− * set_up_regulators() - initialize all regulators
440− */
441−static int setup_regulators(struct mcp16502 *mcp, struct device *dev,
442− struct regulator_config config)
443−{
444− int i;
445−
446− for (i = 0; i < NUM_REGULATORS; i++) {
447− mcp->rdev[i] = devm_regulator_register(dev,
448− &mcp16502_desc[i],
449− &config);
450− if (IS_ERR(mcp->rdev[i])) {
451− dev_err(dev,
452− "failed to register %s regulator %ld\n",
453− mcp16502_desc[i].name, PTR_ERR(mcp->rdev[i]));
454− return PTR_ERR(mcp->rdev[i]);
455− }
456− }
457−
458− return 0;
459−}
460−
461430 static int mcp16502_probe(struct i2c_client *client,
462431 const struct i2c_device_id *id)
463432 {
464433 struct regulator_config config = { };
434+ struct regulator_dev *rdev;
465435 struct device *dev;
466436 struct mcp16502 *mcp;
467− int ret = 0;
437+ struct regmap *rmap;
438+ int i, ret;
468439
469440 dev = &client->dev;
470441 config.dev = dev;
@@ -473,15 +444,15 @@ static int mcp16502_probe(struct i2c_client *client, · 2 unmodified lines
473444 if (!mcp)
474445 return -ENOMEM;
475446
476− mcp->rmap = devm_regmap_init_i2c(client, &mcp16502_regmap_config);
477− if (IS_ERR(mcp->rmap)) {
478− ret = PTR_ERR(mcp->rmap);
447+ rmap = devm_regmap_init_i2c(client, &mcp16502_regmap_config);
448+ if (IS_ERR(rmap)) {
449+ ret = PTR_ERR(rmap);
479450 dev_err(dev, "regmap init failed: %d\n", ret);
480451 return ret;
481452 }
482453
483454 i2c_set_clientdata(client, mcp);
484− config.regmap = mcp->rmap;
455+ config.regmap = rmap;
485456 config.driver_data = mcp;
486457
487458 mcp->lpm = devm_gpiod_get(dev, "lpm", GPIOD_OUT_LOW);
@@ -490,9 +461,15 @@ static int mcp16502_probe(struct i2c_client *client, · 2 unmodified lines
490461 return PTR_ERR(mcp->lpm);
491462 }
492463
493− ret = setup_regulators(mcp, dev, config);
494− if (ret != 0)
495− return ret;
464+ for (i = 0; i < NUM_REGULATORS; i++) {
465+ rdev = devm_regulator_register(dev, &mcp16502_desc[i], &config);
466+ if (IS_ERR(rdev)) {
467+ dev_err(dev,
468+ "failed to register %s regulator %ld\n",
469+ mcp16502_desc[i].name, PTR_ERR(rdev));
470+ return PTR_ERR(rdev);
471+ }
472+ }
496473
497474 mcp16502_gpio_set_mode(mcp, MCP16502_OPMODE_ACTIVE);
498475
drivers/regulator/mt6311-regulator.c+4−13
@@ -1,16 +1,7 @@
1−/*
2− * Copyright (c) 2015 MediaTek Inc.
3− * Author: Henry Chen <henryc.chen@mediatek.com>
4− *
5− * This program is free software; you can redistribute it and/or modify
6− * it under the terms of the GNU General Public License version 2 as
7− * published by the Free Software Foundation.
8− *
9− * This program is distributed in the hope that it will be useful,
10− * but WITHOUT ANY WARRANTY; without even the implied warranty of
11− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12− * GNU General Public License for more details.
13− */
1+// SPDX-License-Identifier: GPL-2.0
2+//
3+// Copyright (c) 2015 MediaTek Inc.
4+// Author: Henry Chen <henryc.chen@mediatek.com>
145
156 #include <linux/err.h>
167 #include <linux/gpio.h>
drivers/regulator/mt6311-regulator.h+1−9
@@ -1,15 +1,7 @@
1+/* SPDX-License-Identifier: GPL-2.0 */
12 /*
23 * Copyright (c) 2015 MediaTek Inc.
34 * Author: Henry Chen <henryc.chen@mediatek.com>
4− *
5− * This program is free software; you can redistribute it and/or modify
6− * it under the terms of the GNU General Public License version 2 as
7− * published by the Free Software Foundation.
8− *
9− * This program is distributed in the hope that it will be useful,
10− * but WITHOUT ANY WARRANTY; without even the implied warranty of
11− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12− * GNU General Public License for more details.
135 */
146
157 #ifndef __MT6311_REGULATOR_H__
drivers/regulator/mt6323-regulator.c+14−18
@@ -1,11 +1,7 @@
1−/*
2− * Copyright (c) 2016 MediaTek Inc.
3− * Author: Chen Zhong <chen.zhong@mediatek.com>
4− *
5− * This program is free software; you can redistribute it and/or modify
6− * it under the terms of the GNU General Public License version 2 as
7− * published by the Free Software Foundation.
8− */
1+// SPDX-License-Identifier: GPL-2.0
2+//
3+// Copyright (c) 2016 MediaTek Inc.
4+// Author: Chen Zhong <chen.zhong@mediatek.com>
95
106 #include <linux/module.h>
117 #include <linux/of.h>
@@ -118,43 +114,43 @@ static const struct regulator_linear_range buck_volt_range3[] = { · 106 unmodified lines
118114 REGULATOR_LINEAR_RANGE(500000, 0, 0x3f, 50000),
119115 };
120116
121−static const u32 ldo_volt_table1[] = {
117+static const unsigned int ldo_volt_table1[] = {
122118 3300000, 3400000, 3500000, 3600000,
123119 };
124120
125−static const u32 ldo_volt_table2[] = {
121+static const unsigned int ldo_volt_table2[] = {
126122 1500000, 1800000, 2500000, 2800000,
127123 };
128124
129−static const u32 ldo_volt_table3[] = {
125+static const unsigned int ldo_volt_table3[] = {
130126 1800000, 3300000,
131127 };
132128
133−static const u32 ldo_volt_table4[] = {
129+static const unsigned int ldo_volt_table4[] = {
134130 3000000, 3300000,
135131 };
136132
137−static const u32 ldo_volt_table5[] = {
133+static const unsigned int ldo_volt_table5[] = {
138134 1200000, 1300000, 1500000, 1800000, 2000000, 2800000, 3000000, 3300000,
139135 };
140136
141−static const u32 ldo_volt_table6[] = {
137+static const unsigned int ldo_volt_table6[] = {
142138 1200000, 1300000, 1500000, 1800000, 2500000, 2800000, 3000000, 2000000,
143139 };
144140
145−static const u32 ldo_volt_table7[] = {
141+static const unsigned int ldo_volt_table7[] = {
146142 1200000, 1300000, 1500000, 1800000,
147143 };
148144
149−static const u32 ldo_volt_table8[] = {
145+static const unsigned int ldo_volt_table8[] = {
150146 1800000, 3000000,
151147 };
152148
153−static const u32 ldo_volt_table9[] = {
149+static const unsigned int ldo_volt_table9[] = {
154150 1200000, 1350000, 1500000, 1800000,
155151 };
156152
157−static const u32 ldo_volt_table10[] = {
153+static const unsigned int ldo_volt_table10[] = {
158154 1200000, 1300000, 1500000, 1800000,
159155 };
160156
drivers/regulator/mt6380-regulator.c+8−17
@@ -1,16 +1,7 @@
1−/*
2− * Copyright (c) 2017 MediaTek Inc.
3− * Author: Chenglin Xu <chenglin.xu@mediatek.com>
4− *
5− * This program is free software; you can redistribute it and/or modify
6− * it under the terms of the GNU General Public License version 2 as
7− * published by the Free Software Foundation.
8− *
9− * This program is distributed in the hope that it will be useful,
10− * but WITHOUT ANY WARRANTY; without even the implied warranty of
11− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12− * GNU General Public License for more details.
13− */
1+// SPDX-License-Identifier: GPL-2.0
2+//
3+// Copyright (c) 2017 MediaTek Inc.
4+// Author: Chenglin Xu <chenglin.xu@mediatek.com>
145
156 #include <linux/module.h>
167 #include <linux/of.h>
@@ -173,19 +164,19 @@ static const struct regulator_linear_range buck_volt_range3[] = { · 156 unmodified lines
173164 REGULATOR_LINEAR_RANGE(1200000, 0, 0x3c, 25000),
174165 };
175166
176−static const u32 ldo_volt_table1[] = {
167+static const unsigned int ldo_volt_table1[] = {
177168 1400000, 1350000, 1300000, 1250000, 1200000, 1150000, 1100000, 1050000,
178169 };
179170
180−static const u32 ldo_volt_table2[] = {
171+static const unsigned int ldo_volt_table2[] = {
181172 2200000, 3300000,
182173 };
183174
184−static const u32 ldo_volt_table3[] = {
175+static const unsigned int ldo_volt_table3[] = {
185176 1240000, 1390000, 1540000, 1840000,
186177 };
187178
188−static const u32 ldo_volt_table4[] = {
179+static const unsigned int ldo_volt_table4[] = {
189180 2200000, 3300000,
190181 };
191182
drivers/regulator/mt6397-regulator.c+12−21
@@ -1,16 +1,7 @@
1−/*
2− * Copyright (c) 2014 MediaTek Inc.
3− * Author: Flora Fu <flora.fu@mediatek.com>
4− *
5− * This program is free software; you can redistribute it and/or modify
6− * it under the terms of the GNU General Public License version 2 as
7− * published by the Free Software Foundation.
8− *
9− * This program is distributed in the hope that it will be useful,
10− * but WITHOUT ANY WARRANTY; without even the implied warranty of
11− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12− * GNU General Public License for more details.
13− */
1+// SPDX-License-Identifier: GPL-2.0
2+//
3+// Copyright (c) 2014 MediaTek Inc.
4+// Author: Flora Fu <flora.fu@mediatek.com>
145
156 #include <linux/module.h>
167 #include <linux/of.h>
@@ -123,35 +114,35 @@ static const struct regulator_linear_range buck_volt_range3[] = { · 106 unmodified lines
123114 REGULATOR_LINEAR_RANGE(1500000, 0, 0x1f, 20000),
124115 };
125116
126−static const u32 ldo_volt_table1[] = {
117+static const unsigned int ldo_volt_table1[] = {
127118 1500000, 1800000, 2500000, 2800000,
128119 };
129120
130−static const u32 ldo_volt_table2[] = {
121+static const unsigned int ldo_volt_table2[] = {
131122 1800000, 3300000,
132123 };
133124
134−static const u32 ldo_volt_table3[] = {
125+static const unsigned int ldo_volt_table3[] = {
135126 3000000, 3300000,
136127 };
137128
138−static const u32 ldo_volt_table4[] = {
129+static const unsigned int ldo_volt_table4[] = {
139130 1220000, 1300000, 1500000, 1800000, 2500000, 2800000, 3000000, 3300000,
140131 };
141132
142−static const u32 ldo_volt_table5[] = {
133+static const unsigned int ldo_volt_table5[] = {
143134 1200000, 1300000, 1500000, 1800000, 2500000, 2800000, 3000000, 3300000,
144135 };
145136
146−static const u32 ldo_volt_table5_v2[] = {
137+static const unsigned int ldo_volt_table5_v2[] = {
147138 1200000, 1000000, 1500000, 1800000, 2500000, 2800000, 3000000, 3300000,
148139 };
149140
150−static const u32 ldo_volt_table6[] = {
141+static const unsigned int ldo_volt_table6[] = {
151142 1200000, 1300000, 1500000, 1800000, 2500000, 2800000, 3000000, 2000000,
152143 };
153144
154−static const u32 ldo_volt_table7[] = {
145+static const unsigned int ldo_volt_table7[] = {
155146 1300000, 1500000, 1800000, 2000000, 2500000, 2800000, 3000000, 3300000,
156147 };
157148
drivers/regulator/of_regulator.c+3−2
@@ -371,8 +371,9 @@ int of_regulator_match(struct device *dev, struct device_node *node, · 370 unmodified lines
371371 }
372372 EXPORT_SYMBOL_GPL(of_regulator_match);
373373
374−struct device_node *regulator_of_get_init_node(struct device *dev,
375− const struct regulator_desc *desc)
374+static struct
375+device_node *regulator_of_get_init_node(struct device *dev,
376+ const struct regulator_desc *desc)
376377 {
377378 struct device_node *search, *child;
378379 const char *name;
drivers/regulator/palmas-regulator.c+0−12
@@ -991,9 +991,6 @@ static int palmas_ldo_registration(struct palmas_pmic *pmic, · 990 unmodified lines
991991 return PTR_ERR(rdev);
992992 }
993993
994− /* Save regulator for cleanup */
995− pmic->rdev[id] = rdev;
996−
997994 /* Initialise sleep/init values from platform data */
998995 if (pdata) {
999996 reg_init = pdata->reg_init[id];
@@ -1101,9 +1098,6 @@ static int tps65917_ldo_registration(struct palmas_pmic *pmic, · 101 unmodified lines
11011098 return PTR_ERR(rdev);
11021099 }
11031100
1104− /* Save regulator for cleanup */
1105− pmic->rdev[id] = rdev;
1106−
11071101 /* Initialise sleep/init values from platform data */
11081102 if (pdata) {
11091103 reg_init = pdata->reg_init[id];
@@ -1288,9 +1282,6 @@ static int palmas_smps_registration(struct palmas_pmic *pmic, · 178 unmodified lines
12881282 pdev_name);
12891283 return PTR_ERR(rdev);
12901284 }
1291−
1292− /* Save regulator for cleanup */
1293− pmic->rdev[id] = rdev;
12941285 }
12951286
12961287 return 0;
@@ -1395,9 +1386,6 @@ static int tps65917_smps_registration(struct palmas_pmic *pmic, · 98 unmodified lines
13951386 pdev_name);
13961387 return PTR_ERR(rdev);
13971388 }
1398−
1399− /* Save regulator for cleanup */
1400− pmic->rdev[id] = rdev;
14011389 }
14021390
14031391 return 0;
drivers/regulator/pv88060-regulator.c+8−14
@@ -1,17 +1,7 @@
1−/*
2− * pv88060-regulator.c - Regulator device driver for PV88060
3− * Copyright (C) 2015 Powerventure Semiconductor Ltd.
4− *
5− * This program is free software; you can redistribute it and/or
6− * modify it under the terms of the GNU General Public License
7− * as published by the Free Software Foundation; either version 2
8− * of the License, or (at your option) any later version.
9− *
10− * This program is distributed in the hope that it will be useful,
11− * but WITHOUT ANY WARRANTY; without even the implied warranty of
12− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13− * GNU General Public License for more details.
14− */
1+// SPDX-License-Identifier: GPL-2.0+
2+//
3+// pv88060-regulator.c - Regulator device driver for PV88060
4+// Copyright (C) 2015 Powerventure Semiconductor Ltd.
155
166 #include <linux/err.h>
177 #include <linux/i2c.h>
@@ -244,9 +234,11 @@ static irqreturn_t pv88060_irq_handler(int irq, void *data) · 226 unmodified lines
244234 if (reg_val & PV88060_E_VDD_FLT) {
245235 for (i = 0; i < PV88060_MAX_REGULATORS; i++) {
246236 if (chip->rdev[i] != NULL) {
237+ regulator_lock(chip->rdev[i]);
247238 regulator_notifier_call_chain(chip->rdev[i],
248239 REGULATOR_EVENT_UNDER_VOLTAGE,
249240 NULL);
241+ regulator_unlock(chip->rdev[i]);
250242 }
251243 }
252244
@@ -261,9 +253,11 @@ static irqreturn_t pv88060_irq_handler(int irq, void *data) · 8 unmodified lines
261253 if (reg_val & PV88060_E_OVER_TEMP) {
262254 for (i = 0; i < PV88060_MAX_REGULATORS; i++) {
263255 if (chip->rdev[i] != NULL) {
256+ regulator_lock(chip->rdev[i]);
264257 regulator_notifier_call_chain(chip->rdev[i],
265258 REGULATOR_EVENT_OVER_TEMP,
266259 NULL);
260+ regulator_unlock(chip->rdev[i]);
267261 }
268262 }
269263
drivers/regulator/pv88060-regulator.h+1−10
@@ -1,16 +1,7 @@
1+/* SPDX-License-Identifier: GPL-2.0+ */
12 /*
23 * pv88060-regulator.h - Regulator definitions for PV88060
34 * Copyright (C) 2015 Powerventure Semiconductor Ltd.
4− *
5− * This program is free software; you can redistribute it and/or
6− * modify it under the terms of the GNU General Public License
7− * as published by the Free Software Foundation; either version 2
8− * of the License, or (at your option) any later version.
9− *
10− * This program is distributed in the hope that it will be useful,
11− * but WITHOUT ANY WARRANTY; without even the implied warranty of
12− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13− * GNU General Public License for more details.
145 */
156
167 #ifndef __PV88060_REGISTERS_H__
drivers/regulator/pv88080-regulator.c+8−14
@@ -1,17 +1,7 @@
1−/*
2− * pv88080-regulator.c - Regulator device driver for PV88080
3− * Copyright (C) 2016 Powerventure Semiconductor Ltd.
4− *
5− * This program is free software; you can redistribute it and/or
6− * modify it under the terms of the GNU General Public License
7− * as published by the Free Software Foundation; either version 2
8− * of the License, or (at your option) any later version.
9− *
10− * This program is distributed in the hope that it will be useful,
11− * but WITHOUT ANY WARRANTY; without even the implied warranty of
12− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13− * GNU General Public License for more details.
14− */
1+// SPDX-License-Identifier: GPL-2.0+
2+//
3+// pv88080-regulator.c - Regulator device driver for PV88080
4+// Copyright (C) 2016 Powerventure Semiconductor Ltd.
155
166 #include <linux/err.h>
177 #include <linux/i2c.h>
@@ -345,9 +335,11 @@ static irqreturn_t pv88080_irq_handler(int irq, void *data) · 327 unmodified lines
345335 if (reg_val & PV88080_E_VDD_FLT) {
346336 for (i = 0; i < PV88080_MAX_REGULATORS; i++) {
347337 if (chip->rdev[i] != NULL) {
338+ regulator_lock(chip->rdev[i]);
348339 regulator_notifier_call_chain(chip->rdev[i],
349340 REGULATOR_EVENT_UNDER_VOLTAGE,
350341 NULL);
342+ regulator_unlock(chip->rdev[i]);
351343 }
352344 }
353345
@@ -362,9 +354,11 @@ static irqreturn_t pv88080_irq_handler(int irq, void *data) · 8 unmodified lines
362354 if (reg_val & PV88080_E_OVER_TEMP) {
363355 for (i = 0; i < PV88080_MAX_REGULATORS; i++) {
364356 if (chip->rdev[i] != NULL) {
357+ regulator_lock(chip->rdev[i]);
365358 regulator_notifier_call_chain(chip->rdev[i],
366359 REGULATOR_EVENT_OVER_TEMP,
367360 NULL);
361+ regulator_unlock(chip->rdev[i]);
368362 }
369363 }
370364
drivers/regulator/pv88080-regulator.h+1−10
@@ -1,16 +1,7 @@
1+/* SPDX-License-Identifier: GPL-2.0+ */
12 /*
23 * pv88080-regulator.h - Regulator definitions for PV88080
34 * Copyright (C) 2016 Powerventure Semiconductor Ltd.
4− *
5− * This program is free software; you can redistribute it and/or
6− * modify it under the terms of the GNU General Public License
7− * as published by the Free Software Foundation; either version 2
8− * of the License, or (at your option) any later version.
9− *
10− * This program is distributed in the hope that it will be useful,
11− * but WITHOUT ANY WARRANTY; without even the implied warranty of
12− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13− * GNU General Public License for more details.
145 */
156
167 #ifndef __PV88080_REGISTERS_H__
drivers/regulator/pv88090-regulator.c+8−14
@@ -1,17 +1,7 @@
1−/*
2− * pv88090-regulator.c - Regulator device driver for PV88090
3− * Copyright (C) 2015 Powerventure Semiconductor Ltd.
4− *
5− * This program is free software; you can redistribute it and/or
6− * modify it under the terms of the GNU General Public License
7− * as published by the Free Software Foundation; either version 2
8− * of the License, or (at your option) any later version.
9− *
10− * This program is distributed in the hope that it will be useful,
11− * but WITHOUT ANY WARRANTY; without even the implied warranty of
12− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13− * GNU General Public License for more details.
14− */
1+// SPDX-License-Identifier: GPL-2.0+
2+//
3+// pv88090-regulator.c - Regulator device driver for PV88090
4+// Copyright (C) 2015 Powerventure Semiconductor Ltd.
155
166 #include <linux/err.h>
177 #include <linux/i2c.h>
@@ -237,9 +227,11 @@ static irqreturn_t pv88090_irq_handler(int irq, void *data) · 219 unmodified lines
237227 if (reg_val & PV88090_E_VDD_FLT) {
238228 for (i = 0; i < PV88090_MAX_REGULATORS; i++) {
239229 if (chip->rdev[i] != NULL) {
230+ regulator_lock(chip->rdev[i]);
240231 regulator_notifier_call_chain(chip->rdev[i],
241232 REGULATOR_EVENT_UNDER_VOLTAGE,
242233 NULL);
234+ regulator_unlock(chip->rdev[i]);
243235 }
244236 }
245237
@@ -254,9 +246,11 @@ static irqreturn_t pv88090_irq_handler(int irq, void *data) · 8 unmodified lines
254246 if (reg_val & PV88090_E_OVER_TEMP) {
255247 for (i = 0; i < PV88090_MAX_REGULATORS; i++) {
256248 if (chip->rdev[i] != NULL) {
249+ regulator_lock(chip->rdev[i]);
257250 regulator_notifier_call_chain(chip->rdev[i],
258251 REGULATOR_EVENT_OVER_TEMP,
259252 NULL);
253+ regulator_unlock(chip->rdev[i]);
260254 }
261255 }
262256
drivers/regulator/pv88090-regulator.h+1−10
@@ -1,16 +1,7 @@
1+/* SPDX-License-Identifier: GPL-2.0+ */
12 /*
23 * pv88090-regulator.h - Regulator definitions for PV88090
34 * Copyright (C) 2015 Powerventure Semiconductor Ltd.
4− *
5− * This program is free software; you can redistribute it and/or
6− * modify it under the terms of the GNU General Public License
7− * as published by the Free Software Foundation; either version 2
8− * of the License, or (at your option) any later version.
9− *
10− * This program is distributed in the hope that it will be useful,
11− * but WITHOUT ANY WARRANTY; without even the implied warranty of
12− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13− * GNU General Public License for more details.
145 */
156
167 #ifndef __PV88090_REGISTERS_H__
drivers/regulator/rc5t583-regulator.c+3−22
@@ -47,18 +47,13 @@ struct rc5t583_regulator_info { · 46 unmodified lines
4747 struct regulator_desc desc;
4848 };
4949
50−struct rc5t583_regulator {
51− struct rc5t583_regulator_info *reg_info;
52− struct regulator_dev *rdev;
53−};
54−
5550 static int rc5t583_regulator_enable_time(struct regulator_dev *rdev)
5651 {
57− struct rc5t583_regulator *reg = rdev_get_drvdata(rdev);
52+ struct rc5t583_regulator_info *reg_info = rdev_get_drvdata(rdev);
5853 int vsel = regulator_get_voltage_sel_regmap(rdev);
5954 int curr_uV = regulator_list_voltage_linear(rdev, vsel);
6055
61− return DIV_ROUND_UP(curr_uV, reg->reg_info->enable_uv_per_us);
56+ return DIV_ROUND_UP(curr_uV, reg_info->enable_uv_per_us);
6257 }
6358
6459 static const struct regulator_ops rc5t583_ops = {
@@ -120,8 +115,6 @@ static int rc5t583_regulator_probe(struct platform_device *pdev) · 55 unmodified lines
120115 struct rc5t583 *rc5t583 = dev_get_drvdata(pdev->dev.parent);
121116 struct rc5t583_platform_data *pdata = dev_get_platdata(rc5t583->dev);
122117 struct regulator_config config = { };
123− struct rc5t583_regulator *reg = NULL;
124− struct rc5t583_regulator *regs;
125118 struct regulator_dev *rdev;
126119 struct rc5t583_regulator_info *ri;
127120 int ret;
@@ -132,18 +125,8 @@ static int rc5t583_regulator_probe(struct platform_device *pdev) · 4 unmodified lines
132125 return -ENODEV;
133126 }
134127
135− regs = devm_kcalloc(&pdev->dev,
136− RC5T583_REGULATOR_MAX,
137− sizeof(struct rc5t583_regulator),
138− GFP_KERNEL);
139− if (!regs)
140− return -ENOMEM;
141−
142−
143128 for (id = 0; id < RC5T583_REGULATOR_MAX; ++id) {
144− reg = &regs[id];
145129 ri = &rc5t583_reg_info[id];
146− reg->reg_info = ri;
147130
148131 if (ri->deepsleep_id == RC5T583_DS_NONE)
149132 goto skip_ext_pwr_config;
@@ -163,7 +146,7 @@ static int rc5t583_regulator_probe(struct platform_device *pdev) · 13 unmodified lines
163146 skip_ext_pwr_config:
164147 config.dev = &pdev->dev;
165148 config.init_data = pdata->reg_init_data[id];
166− config.driver_data = reg;
149+ config.driver_data = ri;
167150 config.regmap = rc5t583->regmap;
168151
169152 rdev = devm_regulator_register(&pdev->dev, &ri->desc, &config);
@@ -172,9 +155,7 @@ skip_ext_pwr_config: · 2 unmodified lines
172155 ri->desc.name);
173156 return PTR_ERR(rdev);
174157 }
175− reg->rdev = rdev;
176158 }
177− platform_set_drvdata(pdev, regs);
178159 return 0;
179160 }
180161
drivers/regulator/rn5t618-regulator.c+4−4
@@ -46,7 +46,7 @@ static const struct regulator_ops rn5t618_reg_ops = { · 45 unmodified lines
4646 .vsel_mask = (vmask), \
4747 }
4848
49−static struct regulator_desc rn5t567_regulators[] = {
49+static const struct regulator_desc rn5t567_regulators[] = {
5050 /* DCDC */
5151 REG(DCDC1, DC1CTL, BIT(0), DC1DAC, 0xff, 600000, 3500000, 12500),
5252 REG(DCDC2, DC2CTL, BIT(0), DC2DAC, 0xff, 600000, 3500000, 12500),
@@ -63,7 +63,7 @@ static struct regulator_desc rn5t567_regulators[] = { · 10 unmodified lines
6363 REG(LDORTC2, LDOEN2, BIT(5), LDORTC2DAC, 0x7f, 900000, 3500000, 25000),
6464 };
6565
66−static struct regulator_desc rn5t618_regulators[] = {
66+static const struct regulator_desc rn5t618_regulators[] = {
6767 /* DCDC */
6868 REG(DCDC1, DC1CTL, BIT(0), DC1DAC, 0xff, 600000, 3500000, 12500),
6969 REG(DCDC2, DC2CTL, BIT(0), DC2DAC, 0xff, 600000, 3500000, 12500),
@@ -79,7 +79,7 @@ static struct regulator_desc rn5t618_regulators[] = { · 9 unmodified lines
7979 REG(LDORTC2, LDOEN2, BIT(5), LDORTC2DAC, 0x7f, 900000, 3500000, 25000),
8080 };
8181
82−static struct regulator_desc rc5t619_regulators[] = {
82+static const struct regulator_desc rc5t619_regulators[] = {
8383 /* DCDC */
8484 REG(DCDC1, DC1CTL, BIT(0), DC1DAC, 0xff, 600000, 3500000, 12500),
8585 REG(DCDC2, DC2CTL, BIT(0), DC2DAC, 0xff, 600000, 3500000, 12500),
@@ -107,7 +107,7 @@ static int rn5t618_regulator_probe(struct platform_device *pdev) · 21 unmodified lines
107107 struct rn5t618 *rn5t618 = dev_get_drvdata(pdev->dev.parent);
108108 struct regulator_config config = { };
109109 struct regulator_dev *rdev;
110− struct regulator_desc *regulators;
110+ const struct regulator_desc *regulators;
111111 int i;
112112 int num_regulators = 0;
113113
drivers/regulator/s2mpa01.c+10−31
@@ -17,10 +17,7 @@ · 16 unmodified lines
1717 #include <linux/mfd/samsung/core.h>
1818 #include <linux/mfd/samsung/s2mpa01.h>
1919
20−#define S2MPA01_REGULATOR_CNT ARRAY_SIZE(regulators)
21−
2220 struct s2mpa01_info {
23− struct of_regulator_match rdata[S2MPA01_REGULATOR_MAX];
2421 int ramp_delay24;
2522 int ramp_delay3;
2623 int ramp_delay5;
@@ -232,6 +229,8 @@ static const struct regulator_ops s2mpa01_buck_ops = { · 205 unmodified lines
232229
233230 #define regulator_desc_ldo(num, step) { \
234231 .name = "LDO"#num, \
232+ .of_match = of_match_ptr("LDO"#num), \
233+ .regulators_node = of_match_ptr("regulators"), \
235234 .id = S2MPA01_LDO##num, \
236235 .ops = &s2mpa01_ldo_ops, \
237236 .type = REGULATOR_VOLTAGE, \
@@ -247,6 +246,8 @@ static const struct regulator_ops s2mpa01_buck_ops = { · 9 unmodified lines
247246
248247 #define regulator_desc_buck1_4(num) { \
249248 .name = "BUCK"#num, \
249+ .of_match = of_match_ptr("BUCK"#num), \
250+ .regulators_node = of_match_ptr("regulators"), \
250251 .id = S2MPA01_BUCK##num, \
251252 .ops = &s2mpa01_buck_ops, \
252253 .type = REGULATOR_VOLTAGE, \
@@ -263,6 +264,8 @@ static const struct regulator_ops s2mpa01_buck_ops = { · 10 unmodified lines
263264
264265 #define regulator_desc_buck5 { \
265266 .name = "BUCK5", \
267+ .of_match = of_match_ptr("BUCK5"), \
268+ .regulators_node = of_match_ptr("regulators"), \
266269 .id = S2MPA01_BUCK5, \
267270 .ops = &s2mpa01_buck_ops, \
268271 .type = REGULATOR_VOLTAGE, \
@@ -279,6 +282,8 @@ static const struct regulator_ops s2mpa01_buck_ops = { · 10 unmodified lines
279282
280283 #define regulator_desc_buck6_10(num, min, step) { \
281284 .name = "BUCK"#num, \
285+ .of_match = of_match_ptr("BUCK"#num), \
286+ .regulators_node = of_match_ptr("regulators"), \
282287 .id = S2MPA01_BUCK##num, \
283288 .ops = &s2mpa01_buck_ops, \
284289 .type = REGULATOR_VOLTAGE, \
@@ -336,9 +341,7 @@ static int s2mpa01_pmic_probe(struct platform_device *pdev) · 51 unmodified lines
336341 {
337342 struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent);
338343 struct sec_platform_data *pdata = dev_get_platdata(iodev->dev);
339− struct device_node *reg_np = NULL;
340344 struct regulator_config config = { };
341− struct of_regulator_match *rdata;
342345 struct s2mpa01_info *s2mpa01;
343346 int i;
344347
@@ -346,39 +349,15 @@ static int s2mpa01_pmic_probe(struct platform_device *pdev) · 1 unmodified line
346349 if (!s2mpa01)
347350 return -ENOMEM;
348351
349− rdata = s2mpa01->rdata;
350− for (i = 0; i < S2MPA01_REGULATOR_CNT; i++)
351− rdata[i].name = regulators[i].name;
352−
353− if (iodev->dev->of_node) {
354− reg_np = of_get_child_by_name(iodev->dev->of_node,
355− "regulators");
356− if (!reg_np) {
357− dev_err(&pdev->dev,
358− "could not find regulators sub-node\n");
359− return -EINVAL;
360− }
361−
362− of_regulator_match(&pdev->dev, reg_np, rdata,
363− S2MPA01_REGULATOR_MAX);
364− of_node_put(reg_np);
365− }
366−
367− platform_set_drvdata(pdev, s2mpa01);
368−
369− config.dev = &pdev->dev;
352+ config.dev = iodev->dev;
370353 config.regmap = iodev->regmap_pmic;
371354 config.driver_data = s2mpa01;
372355
373356 for (i = 0; i < S2MPA01_REGULATOR_MAX; i++) {
374357 struct regulator_dev *rdev;
358+
375359 if (pdata)
376360 config.init_data = pdata->regulators[i].initdata;
377− else
378− config.init_data = rdata[i].init_data;
379−
380− if (reg_np)
381− config.of_node = rdata[i].of_node;
382361
383362 rdev = devm_regulator_register(&pdev->dev,
384363 &regulators[i], &config);
drivers/regulator/sc2731-regulator.c+1−1
@@ -146,7 +146,7 @@ static const struct regulator_ops sc2731_regu_linear_ops = { · 145 unmodified lines
146146 .vsel_mask = vmask, \
147147 }
148148
149−static struct regulator_desc regulators[] = {
149+static const struct regulator_desc regulators[] = {
150150 SC2731_REGU_LINEAR(BUCK_CPU0, SC2731_POWER_PD_SW,
151151 SC2731_DCDC_CPU0_PD_MASK, SC2731_DCDC_CPU0_VOL,
152152 SC2731_DCDC_CPU0_VOL_MASK, 3125, 400000, 1996875),
drivers/regulator/sky81452-regulator.c+7−19
@@ -1,21 +1,9 @@
1−/*
2− * sky81452-regulator.c SKY81452 regulator driver
3− *
4− * Copyright 2014 Skyworks Solutions Inc.
5− * Author : Gyungoh Yoo <jack.yoo@skyworksinc.com>
6− *
7− * This program is free software; you can redistribute it and/or modify it
8− * under the terms of the GNU General Public License version 2
9− * as published by the Free Software Foundation.
10− *
11− * This program is distributed in the hope that it will be useful, but
12− * WITHOUT ANY WARRANTY; without even the implied warranty of
13− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14− * General Public License for more details.
15− *
16− * You should have received a copy of the GNU General Public License along
17− * with this program; if not, see <http://www.gnu.org/licenses/>.
18− */
1+// SPDX-License-Identifier: GPL-2.0
2+//
3+// sky81452-regulator.c SKY81452 regulator driver
4+//
5+// Copyright 2014 Skyworks Solutions Inc.
6+// Author : Gyungoh Yoo <jack.yoo@skyworksinc.com>
197
208 #include <linux/module.h>
219 #include <linux/kernel.h>
@@ -34,7 +22,7 @@ · 12 unmodified lines
3422 #define SKY81452_LEN 0x40
3523 #define SKY81452_LOUT 0x1F
3624
37−static struct regulator_ops sky81452_reg_ops = {
25+static const struct regulator_ops sky81452_reg_ops = {
3826 .list_voltage = regulator_list_voltage_linear_range,
3927 .map_voltage = regulator_map_voltage_linear_range,
4028 .get_voltage_sel = regulator_get_voltage_sel_regmap,
drivers/regulator/stm32-pwr.c+186−0
@@ -0,0 +1,186 @@
1+// SPDX-License-Identifier: GPL-2.0
2+// Copyright (C) STMicroelectronics 2019
3+// Authors: Gabriel Fernandez <gabriel.fernandez@st.com>
4+// Pascal Paillet <p.paillet@st.com>.
5+
6+#include <linux/io.h>
7+#include <linux/iopoll.h>
8+#include <linux/module.h>
9+#include <linux/of_address.h>
10+#include <linux/of_device.h>
11+#include <linux/platform_device.h>
12+#include <linux/regulator/driver.h>
13+#include <linux/regulator/of_regulator.h>
14+
15+/*
16+ * Registers description
17+ */
18+#define REG_PWR_CR3 0x0C
19+
20+#define USB_3_3_EN BIT(24)
21+#define USB_3_3_RDY BIT(26)
22+#define REG_1_8_EN BIT(28)
23+#define REG_1_8_RDY BIT(29)
24+#define REG_1_1_EN BIT(30)
25+#define REG_1_1_RDY BIT(31)
26+
27+/* list of supported regulators */
28+enum {
29+ PWR_REG11,
30+ PWR_REG18,
31+ PWR_USB33,
32+ STM32PWR_REG_NUM_REGS
33+};
34+
35+static u32 ready_mask_table[STM32PWR_REG_NUM_REGS] = {
36+ [PWR_REG11] = REG_1_1_RDY,
37+ [PWR_REG18] = REG_1_8_RDY,
38+ [PWR_USB33] = USB_3_3_RDY,
39+};
40+
41+struct stm32_pwr_reg {
42+ void __iomem *base;
43+ u32 ready_mask;
44+};
45+
46+static int stm32_pwr_reg_is_ready(struct regulator_dev *rdev)
47+{
48+ struct stm32_pwr_reg *priv = rdev_get_drvdata(rdev);
49+ u32 val;
50+
51+ val = readl_relaxed(priv->base + REG_PWR_CR3);
52+
53+ return (val & priv->ready_mask);
54+}
55+
56+static int stm32_pwr_reg_is_enabled(struct regulator_dev *rdev)
57+{
58+ struct stm32_pwr_reg *priv = rdev_get_drvdata(rdev);
59+ u32 val;
60+
61+ val = readl_relaxed(priv->base + REG_PWR_CR3);
62+
63+ return (val & rdev->desc->enable_mask);
64+}
65+
66+static int stm32_pwr_reg_enable(struct regulator_dev *rdev)
67+{
68+ struct stm32_pwr_reg *priv = rdev_get_drvdata(rdev);
69+ int ret;
70+ u32 val;
71+
72+ val = readl_relaxed(priv->base + REG_PWR_CR3);
73+ val |= rdev->desc->enable_mask;
74+ writel_relaxed(val, priv->base + REG_PWR_CR3);
75+
76+ /* use an arbitrary timeout of 20ms */
77+ ret = readx_poll_timeout(stm32_pwr_reg_is_ready, rdev, val, val,
78+ 100, 20 * 1000);
79+ if (ret)
80+ dev_err(&rdev->dev, "regulator enable timed out!\n");
81+
82+ return ret;
83+}
84+
85+static int stm32_pwr_reg_disable(struct regulator_dev *rdev)
86+{
87+ struct stm32_pwr_reg *priv = rdev_get_drvdata(rdev);
88+ int ret;
89+ u32 val;
90+
91+ val = readl_relaxed(priv->base + REG_PWR_CR3);
92+ val &= ~rdev->desc->enable_mask;
93+ writel_relaxed(val, priv->base + REG_PWR_CR3);
94+
95+ /* use an arbitrary timeout of 20ms */
96+ ret = readx_poll_timeout(stm32_pwr_reg_is_ready, rdev, val, !val,
97+ 100, 20 * 1000);
98+ if (ret)
99+ dev_err(&rdev->dev, "regulator disable timed out!\n");
100+
101+ return ret;
102+}
103+
104+static const struct regulator_ops stm32_pwr_reg_ops = {
105+ .enable = stm32_pwr_reg_enable,
106+ .disable = stm32_pwr_reg_disable,
107+ .is_enabled = stm32_pwr_reg_is_enabled,
108+};
109+
110+#define PWR_REG(_id, _name, _volt, _en, _supply) \
111+ [_id] = { \
112+ .id = _id, \
113+ .name = _name, \
114+ .of_match = of_match_ptr(_name), \
115+ .n_voltages = 1, \
116+ .type = REGULATOR_VOLTAGE, \
117+ .fixed_uV = _volt, \
118+ .ops = &stm32_pwr_reg_ops, \
119+ .enable_mask = _en, \
120+ .owner = THIS_MODULE, \
121+ .supply_name = _supply, \
122+ } \
123+
124+static const struct regulator_desc stm32_pwr_desc[] = {
125+ PWR_REG(PWR_REG11, "reg11", 1100000, REG_1_1_EN, "vdd"),
126+ PWR_REG(PWR_REG18, "reg18", 1800000, REG_1_8_EN, "vdd"),
127+ PWR_REG(PWR_USB33, "usb33", 3300000, USB_3_3_EN, "vdd_3v3_usbfs"),
128+};
129+
130+static int stm32_pwr_regulator_probe(struct platform_device *pdev)
131+{
132+ struct device_node *np = pdev->dev.of_node;
133+ struct stm32_pwr_reg *priv;
134+ void __iomem *base;
135+ struct regulator_dev *rdev;
136+ struct regulator_config config = { };
137+ int i, ret = 0;
138+
139+ base = of_iomap(np, 0);
140+ if (!base) {
141+ dev_err(&pdev->dev, "Unable to map IO memory\n");
142+ return -ENOMEM;
143+ }
144+
145+ config.dev = &pdev->dev;
146+
147+ for (i = 0; i < STM32PWR_REG_NUM_REGS; i++) {
148+ priv = devm_kzalloc(&pdev->dev, sizeof(struct stm32_pwr_reg),
149+ GFP_KERNEL);
150+ if (!priv)
151+ return -ENOMEM;
152+ priv->base = base;
153+ priv->ready_mask = ready_mask_table[i];
154+ config.driver_data = priv;
155+
156+ rdev = devm_regulator_register(&pdev->dev,
157+ &stm32_pwr_desc[i],
158+ &config);
159+ if (IS_ERR(rdev)) {
160+ ret = PTR_ERR(rdev);
161+ dev_err(&pdev->dev,
162+ "Failed to register regulator: %d\n", ret);
163+ break;
164+ }
165+ }
166+ return ret;
167+}
168+
169+static const struct of_device_id stm32_pwr_of_match[] = {
170+ { .compatible = "st,stm32mp1,pwr-reg", },
171+ {},
172+};
173+MODULE_DEVICE_TABLE(of, stm32_pwr_of_match);
174+
175+static struct platform_driver stm32_pwr_driver = {
176+ .probe = stm32_pwr_regulator_probe,
177+ .driver = {
178+ .name = "stm32-pwr-regulator",
179+ .of_match_table = of_match_ptr(stm32_pwr_of_match),
180+ },
181+};
182+module_platform_driver(stm32_pwr_driver);
183+
184+MODULE_DESCRIPTION("STM32MP1 PWR voltage regulator driver");
185+MODULE_AUTHOR("Pascal Paillet <p.paillet@st.com>");
186+MODULE_LICENSE("GPL v2");
drivers/regulator/sy8106a-regulator.c+13−27
@@ -22,12 +22,6 @@ · 21 unmodified lines
2222 */
2323 #define SY8106A_GO_BIT BIT(7)
2424
25−struct sy8106a {
26− struct regulator_dev *rdev;
27− struct regmap *regmap;
28− u32 fixed_voltage;
29−};
30−
3125 static const struct regmap_config sy8106a_regmap_config = {
3226 .reg_bits = 8,
3327 .val_bits = 8,
@@ -70,36 +64,32 @@ static const struct regulator_desc sy8106a_reg = { · 36 unmodified lines
7064 static int sy8106a_i2c_probe(struct i2c_client *i2c,
7165 const struct i2c_device_id *id)
7266 {
73− struct sy8106a *chip;
7467 struct device *dev = &i2c->dev;
75− struct regulator_dev *rdev = NULL;
68+ struct regulator_dev *rdev;
7669 struct regulator_config config = { };
70+ struct regmap *regmap;
7771 unsigned int reg, vsel;
72+ u32 fixed_voltage;
7873 int error;
7974
80− chip = devm_kzalloc(&i2c->dev, sizeof(struct sy8106a), GFP_KERNEL);
81− if (!chip)
82− return -ENOMEM;
83−
8475 error = of_property_read_u32(dev->of_node, "silergy,fixed-microvolt",
85− &chip->fixed_voltage);
76+ &fixed_voltage);
8677 if (error)
8778 return error;
8879
89− if (chip->fixed_voltage < SY8106A_MIN_MV * 1000 ||
90− chip->fixed_voltage > SY8106A_MAX_MV * 1000)
80+ if (fixed_voltage < SY8106A_MIN_MV * 1000 ||
81+ fixed_voltage > SY8106A_MAX_MV * 1000)
9182 return -EINVAL;
9283
93− chip->regmap = devm_regmap_init_i2c(i2c, &sy8106a_regmap_config);
94− if (IS_ERR(chip->regmap)) {
95− error = PTR_ERR(chip->regmap);
84+ regmap = devm_regmap_init_i2c(i2c, &sy8106a_regmap_config);
85+ if (IS_ERR(regmap)) {
86+ error = PTR_ERR(regmap);
9687 dev_err(dev, "Failed to allocate register map: %d\n", error);
9788 return error;
9889 }
9990
10091 config.dev = &i2c->dev;
101− config.regmap = chip->regmap;
102− config.driver_data = chip;
92+ config.regmap = regmap;
10393
10494 config.of_node = dev->of_node;
10595 config.init_data = of_get_regulator_init_data(dev, dev->of_node,
@@ -109,15 +99,15 @@ static int sy8106a_i2c_probe(struct i2c_client *i2c, · 3 unmodified lines
10999 return -ENOMEM;
110100
111101 /* Ensure GO_BIT is enabled when probing */
112− error = regmap_read(chip->regmap, SY8106A_REG_VOUT1_SEL, &reg);
102+ error = regmap_read(regmap, SY8106A_REG_VOUT1_SEL, &reg);
113103 if (error)
114104 return error;
115105
116106 if (!(reg & SY8106A_GO_BIT)) {
117− vsel = (chip->fixed_voltage / 1000 - SY8106A_MIN_MV) /
107+ vsel = (fixed_voltage / 1000 - SY8106A_MIN_MV) /
118108 SY8106A_STEP_MV;
119109
120− error = regmap_write(chip->regmap, SY8106A_REG_VOUT1_SEL,
110+ error = regmap_write(regmap, SY8106A_REG_VOUT1_SEL,
121111 vsel | SY8106A_GO_BIT);
122112 if (error)
123113 return error;
@@ -131,10 +121,6 @@ static int sy8106a_i2c_probe(struct i2c_client *i2c, · 7 unmodified lines
131121 return error;
132122 }
133123
134− chip->rdev = rdev;
135−
136− i2c_set_clientdata(i2c, chip);
137−
138124 return 0;
139125 }
140126
drivers/regulator/tps6507x-regulator.c+20−93
@@ -115,7 +115,6 @@ static struct tps_info tps6507x_pmic_regs[] = { · 114 unmodified lines
115115 struct tps6507x_pmic {
116116 struct regulator_desc desc[TPS6507X_NUM_REGULATOR];
117117 struct tps6507x_dev *mfd;
118− struct regulator_dev *rdev[TPS6507X_NUM_REGULATOR];
119118 struct tps_info *info[TPS6507X_NUM_REGULATOR];
120119 struct mutex io_lock;
121120 };
@@ -349,7 +348,7 @@ static int tps6507x_pmic_set_voltage_sel(struct regulator_dev *dev, · 227 unmodified lines
349348 return tps6507x_pmic_reg_write(tps, reg, data);
350349 }
351350
352−static struct regulator_ops tps6507x_pmic_ops = {
351+static const struct regulator_ops tps6507x_pmic_ops = {
353352 .is_enabled = tps6507x_pmic_is_enabled,
354353 .enable = tps6507x_pmic_enable,
355354 .disable = tps6507x_pmic_disable,
@@ -359,66 +358,20 @@ static struct regulator_ops tps6507x_pmic_ops = { · 3 unmodified lines
359358 .map_voltage = regulator_map_voltage_ascend,
360359 };
361360
362−static struct of_regulator_match tps6507x_matches[] = {
363− { .name = "VDCDC1"},
364− { .name = "VDCDC2"},
365− { .name = "VDCDC3"},
366− { .name = "LDO1"},
367− { .name = "LDO2"},
368−};
369−
370−static struct tps6507x_board *tps6507x_parse_dt_reg_data(
371− struct platform_device *pdev,
372− struct of_regulator_match **tps6507x_reg_matches)
361+static int tps6507x_pmic_of_parse_cb(struct device_node *np,
362+ const struct regulator_desc *desc,
363+ struct regulator_config *config)
373364 {
374− struct tps6507x_board *tps_board;
375− struct device_node *np = pdev->dev.parent->of_node;
376− struct device_node *regulators;
377− struct of_regulator_match *matches;
378− struct regulator_init_data *reg_data;
379− int idx = 0, count, ret;
380−
381− tps_board = devm_kzalloc(&pdev->dev, sizeof(*tps_board),
382− GFP_KERNEL);
383− if (!tps_board)
384− return NULL;
385−
386− regulators = of_get_child_by_name(np, "regulators");
387− if (!regulators) {
388− dev_err(&pdev->dev, "regulator node not found\n");
389− return NULL;
390− }
391−
392− count = ARRAY_SIZE(tps6507x_matches);
393− matches = tps6507x_matches;
394−
395− ret = of_regulator_match(&pdev->dev, regulators, matches, count);
396− of_node_put(regulators);
397− if (ret < 0) {
398− dev_err(&pdev->dev, "Error parsing regulator init data: %d\n",
399− ret);
400− return NULL;
401− }
365+ struct tps6507x_pmic *tps = config->driver_data;
366+ struct tps_info *info = tps->info[desc->id];
367+ u32 prop;
368+ int ret;
402369
403− *tps6507x_reg_matches = matches;
404−
405− reg_data = devm_kzalloc(&pdev->dev, (sizeof(struct regulator_init_data)
406− * TPS6507X_NUM_REGULATOR), GFP_KERNEL);
407− if (!reg_data)
408− return NULL;
409−
410− tps_board->tps6507x_pmic_init_data = reg_data;
411−
412− for (idx = 0; idx < count; idx++) {
413− if (!matches[idx].init_data || !matches[idx].of_node)
414− continue;
415−
416− memcpy(&reg_data[idx], matches[idx].init_data,
417− sizeof(struct regulator_init_data));
418−
419− }
370+ ret = of_property_read_u32(np, "ti,defdcdc_default", &prop);
371+ if (!ret)
372+ info->defdcdc_default = prop;
420373
421− return tps_board;
374+ return 0;
422375 }
423376
424377 static int tps6507x_pmic_probe(struct platform_device *pdev)
@@ -426,14 +379,11 @@ static int tps6507x_pmic_probe(struct platform_device *pdev) · 1 unmodified line
426379 struct tps6507x_dev *tps6507x_dev = dev_get_drvdata(pdev->dev.parent);
427380 struct tps_info *info = &tps6507x_pmic_regs[0];
428381 struct regulator_config config = { };
429− struct regulator_init_data *init_data;
382+ struct regulator_init_data *init_data = NULL;
430383 struct regulator_dev *rdev;
431384 struct tps6507x_pmic *tps;
432385 struct tps6507x_board *tps_board;
433− struct of_regulator_match *tps6507x_reg_matches = NULL;
434386 int i;
435− int error;
436− unsigned int prop;
437387
438388 /**
439389 * tps_board points to pmic related constants
@@ -441,20 +391,8 @@ static int tps6507x_pmic_probe(struct platform_device *pdev) · 1 unmodified line
441391 */
442392
443393 tps_board = dev_get_platdata(tps6507x_dev->dev);
444− if (IS_ENABLED(CONFIG_OF) && !tps_board &&
445− tps6507x_dev->dev->of_node)
446− tps_board = tps6507x_parse_dt_reg_data(pdev,
447− &tps6507x_reg_matches);
448− if (!tps_board)
449− return -EINVAL;
450−
451− /**
452− * init_data points to array of regulator_init structures
453− * coming from the board-evm file.
454− */
455− init_data = tps_board->tps6507x_pmic_init_data;
456− if (!init_data)
457− return -EINVAL;
394+ if (tps_board)
395+ init_data = tps_board->tps6507x_pmic_init_data;
458396
459397 tps = devm_kzalloc(&pdev->dev, sizeof(*tps), GFP_KERNEL);
460398 if (!tps)
@@ -468,13 +406,16 @@ static int tps6507x_pmic_probe(struct platform_device *pdev) · 7 unmodified lines
468406 for (i = 0; i < TPS6507X_NUM_REGULATOR; i++, info++, init_data++) {
469407 /* Register the regulators */
470408 tps->info[i] = info;
471− if (init_data->driver_data) {
409+ if (init_data && init_data->driver_data) {
472410 struct tps6507x_reg_platform_data *data =
473411 init_data->driver_data;
474− tps->info[i]->defdcdc_default = data->defdcdc_default;
412+ info->defdcdc_default = data->defdcdc_default;
475413 }
476414
477415 tps->desc[i].name = info->name;
416+ tps->desc[i].of_match = of_match_ptr(info->name);
417+ tps->desc[i].regulators_node = of_match_ptr("regulators");
418+ tps->desc[i].of_parse_cb = tps6507x_pmic_of_parse_cb;
478419 tps->desc[i].id = i;
479420 tps->desc[i].n_voltages = info->table_len;
480421 tps->desc[i].volt_table = info->table;
@@ -486,17 +427,6 @@ static int tps6507x_pmic_probe(struct platform_device *pdev) · 5 unmodified lines
486427 config.init_data = init_data;
487428 config.driver_data = tps;
488429
489− if (tps6507x_reg_matches) {
490− error = of_property_read_u32(
491− tps6507x_reg_matches[i].of_node,
492− "ti,defdcdc_default", &prop);
493−
494− if (!error)
495− tps->info[i]->defdcdc_default = prop;
496−
497− config.of_node = tps6507x_reg_matches[i].of_node;
498− }
499−
500430 rdev = devm_regulator_register(&pdev->dev, &tps->desc[i],
501431 &config);
502432 if (IS_ERR(rdev)) {
@@ -505,9 +435,6 @@ static int tps6507x_pmic_probe(struct platform_device *pdev) · 2 unmodified lines
505435 pdev->name);
506436 return PTR_ERR(rdev);
507437 }
508−
509− /* Save regulator for cleanup */
510− tps->rdev[i] = rdev;
511438 }
512439
513440 tps6507x_dev->pmic = tps;
drivers/regulator/tps65086-regulator.c+2−2
@@ -90,8 +90,8 @@ static const struct regulator_linear_range tps65086_buck345_25mv_ranges[] = { · 89 unmodified lines
9090 static const struct regulator_linear_range tps65086_ldoa1_ranges[] = {
9191 REGULATOR_LINEAR_RANGE(1350000, 0x0, 0x0, 0),
9292 REGULATOR_LINEAR_RANGE(1500000, 0x1, 0x7, 100000),
93− REGULATOR_LINEAR_RANGE(2300000, 0x8, 0xA, 100000),
94− REGULATOR_LINEAR_RANGE(2700000, 0xB, 0xD, 150000),
93+ REGULATOR_LINEAR_RANGE(2300000, 0x8, 0xB, 100000),
94+ REGULATOR_LINEAR_RANGE(2850000, 0xC, 0xD, 150000),
9595 REGULATOR_LINEAR_RANGE(3300000, 0xE, 0xE, 0),
9696 };
9797
drivers/regulator/tps65132-regulator.c+13−16
@@ -55,10 +55,7 @@ struct tps65132_reg_pdata { · 54 unmodified lines
5555
5656 struct tps65132_regulator {
5757 struct device *dev;
58− struct regmap *rmap;
59− struct regulator_desc *rdesc[TPS65132_MAX_REGULATORS];
6058 struct tps65132_reg_pdata reg_pdata[TPS65132_MAX_REGULATORS];
61− struct regulator_dev *rdev[TPS65132_MAX_REGULATORS];
6259 };
6360
6461 static int tps65132_regulator_enable(struct regulator_dev *rdev)
@@ -120,7 +117,7 @@ static int tps65132_regulator_is_enabled(struct regulator_dev *rdev) · 55 unmodified lines
120117 return 1;
121118 }
122119
123−static struct regulator_ops tps65132_regulator_ops = {
120+static const struct regulator_ops tps65132_regulator_ops = {
124121 .enable = tps65132_regulator_enable,
125122 .disable = tps65132_regulator_disable,
126123 .is_enabled = tps65132_regulator_is_enabled,
@@ -196,7 +193,7 @@ static int tps65132_of_parse_cb(struct device_node *np, · 69 unmodified lines
196193 .owner = THIS_MODULE, \
197194 }
198195
199−static struct regulator_desc tps_regs_desc[TPS65132_MAX_REGULATORS] = {
196+static const struct regulator_desc tps_regs_desc[TPS65132_MAX_REGULATORS] = {
200197 TPS65132_REGULATOR_DESC(VPOS, outp),
201198 TPS65132_REGULATOR_DESC(VNEG, outn),
202199 };
@@ -225,6 +222,8 @@ static int tps65132_probe(struct i2c_client *client, · 22 unmodified lines
225222 {
226223 struct device *dev = &client->dev;
227224 struct tps65132_regulator *tps;
225+ struct regulator_dev *rdev;
226+ struct regmap *rmap;
228227 struct regulator_config config = { };
229228 int id;
230229 int ret;
@@ -233,9 +232,9 @@ static int tps65132_probe(struct i2c_client *client, · 2 unmodified lines
233232 if (!tps)
234233 return -ENOMEM;
235234
236− tps->rmap = devm_regmap_init_i2c(client, &tps65132_regmap_config);
237− if (IS_ERR(tps->rmap)) {
238− ret = PTR_ERR(tps->rmap);
235+ rmap = devm_regmap_init_i2c(client, &tps65132_regmap_config);
236+ if (IS_ERR(rmap)) {
237+ ret = PTR_ERR(rmap);
239238 dev_err(dev, "regmap init failed: %d\n", ret);
240239 return ret;
241240 }
@@ -244,18 +243,16 @@ static int tps65132_probe(struct i2c_client *client, · 2 unmodified lines
244243 tps->dev = dev;
245244
246245 for (id = 0; id < TPS65132_MAX_REGULATORS; ++id) {
247− tps->rdesc[id] = &tps_regs_desc[id];
248−
249− config.regmap = tps->rmap;
246+ config.regmap = rmap;
250247 config.dev = dev;
251248 config.driver_data = tps;
252249
253− tps->rdev[id] = devm_regulator_register(dev,
254− tps->rdesc[id], &config);
255− if (IS_ERR(tps->rdev[id])) {
256− ret = PTR_ERR(tps->rdev[id]);
250+ rdev = devm_regulator_register(dev, &tps_regs_desc[id],
251+ &config);
252+ if (IS_ERR(rdev)) {
253+ ret = PTR_ERR(rdev);
257254 dev_err(dev, "regulator %s register failed: %d\n",
258− tps->rdesc[id]->name, ret);
255+ tps_regs_desc[id].name, ret);
259256 return ret;
260257 }
261258 }
drivers/regulator/tps65217-regulator.c+3−4
@@ -58,8 +58,7 @@ static const unsigned int LDO1_VSEL_table[] = { · 57 unmodified lines
5858
5959 static const struct regulator_linear_range tps65217_uv1_ranges[] = {
6060 REGULATOR_LINEAR_RANGE(900000, 0, 24, 25000),
61− REGULATOR_LINEAR_RANGE(1550000, 25, 30, 50000),
62− REGULATOR_LINEAR_RANGE(1850000, 31, 52, 50000),
61+ REGULATOR_LINEAR_RANGE(1550000, 25, 52, 50000),
6362 REGULATOR_LINEAR_RANGE(3000000, 53, 55, 100000),
6463 REGULATOR_LINEAR_RANGE(3300000, 56, 63, 0),
6564 };
@@ -150,7 +149,7 @@ static int tps65217_pmic_set_suspend_disable(struct regulator_dev *dev) · 84 unmodified lines
150149 }
151150
152151 /* Operations permitted on DCDCx, LDO2, LDO3 and LDO4 */
153−static struct regulator_ops tps65217_pmic_ops = {
152+static const struct regulator_ops tps65217_pmic_ops = {
154153 .is_enabled = regulator_is_enabled_regmap,
155154 .enable = tps65217_pmic_enable,
156155 .disable = tps65217_pmic_disable,
@@ -163,7 +162,7 @@ static struct regulator_ops tps65217_pmic_ops = { · 6 unmodified lines
163162 };
164163
165164 /* Operations permitted on LDO1 */
166−static struct regulator_ops tps65217_pmic_ldo1_ops = {
165+static const struct regulator_ops tps65217_pmic_ldo1_ops = {
167166 .is_enabled = regulator_is_enabled_regmap,
168167 .enable = tps65217_pmic_enable,
169168 .disable = tps65217_pmic_disable,
drivers/regulator/tps65218-regulator.c+23−33
@@ -29,7 +29,8 @@ · 28 unmodified lines
2929 #include <linux/mfd/tps65218.h>
3030
3131 #define TPS65218_REGULATOR(_name, _of, _id, _type, _ops, _n, _vr, _vm, _er, \
32− _em, _cr, _cm, _lr, _nlr, _delay, _fuv, _sr, _sm) \
32+ _em, _cr, _cm, _lr, _nlr, _delay, _fuv, _sr, _sm, \
33+ _ct, _ncl) \
3334 { \
3435 .name = _name, \
3536 .of_match = _of, \
@@ -42,6 +43,8 @@ · 6 unmodified lines
4243 .vsel_mask = _vm, \
4344 .csel_reg = _cr, \
4445 .csel_mask = _cm, \
46+ .curr_table = _ct, \
47+ .n_current_limits = _ncl, \
4548 .enable_reg = _er, \
4649 .enable_mask = _em, \
4750 .volt_table = NULL, \
@@ -162,7 +165,7 @@ static int tps65218_pmic_set_suspend_disable(struct regulator_dev *dev) · 114 unmodified lines
162165 }
163166
164167 /* Operations permitted on DCDC1, DCDC2 */
165−static struct regulator_ops tps65218_dcdc12_ops = {
168+static const struct regulator_ops tps65218_dcdc12_ops = {
166169 .is_enabled = regulator_is_enabled_regmap,
167170 .enable = tps65218_pmic_enable,
168171 .disable = tps65218_pmic_disable,
@@ -176,7 +179,7 @@ static struct regulator_ops tps65218_dcdc12_ops = { · 7 unmodified lines
176179 };
177180
178181 /* Operations permitted on DCDC3, DCDC4 and LDO1 */
179−static struct regulator_ops tps65218_ldo1_dcdc34_ops = {
182+static const struct regulator_ops tps65218_ldo1_dcdc34_ops = {
180183 .is_enabled = regulator_is_enabled_regmap,
181184 .enable = tps65218_pmic_enable,
182185 .disable = tps65218_pmic_disable,
@@ -188,8 +191,7 @@ static struct regulator_ops tps65218_ldo1_dcdc34_ops = { · 5 unmodified lines
188191 .set_suspend_disable = tps65218_pmic_set_suspend_disable,
189192 };
190193
191−static const int ls3_currents[] = { 100000, 200000, 500000, 1000000 };
192−
194+static const unsigned int ls3_currents[] = { 100000, 200000, 500000, 1000000 };
193195
194196 static int tps65218_pmic_set_input_current_lim(struct regulator_dev *dev,
195197 int lim_uA)
@@ -229,33 +231,17 @@ static int tps65218_pmic_set_current_limit(struct regulator_dev *dev, · 33 unmodified lines
229231 TPS65218_PROTECT_L1);
230232 }
231233
232−static int tps65218_pmic_get_current_limit(struct regulator_dev *dev)
233−{
234− int retval;
235− unsigned int index;
236− struct tps65218 *tps = rdev_get_drvdata(dev);
237−
238− retval = regmap_read(tps->regmap, dev->desc->csel_reg, &index);
239− if (retval < 0)
240− return retval;
241−
242− index = (index & dev->desc->csel_mask) >>
243− __builtin_ctz(dev->desc->csel_mask);
244−
245− return ls3_currents[index];
246−}
247−
248−static struct regulator_ops tps65218_ls23_ops = {
234+static const struct regulator_ops tps65218_ls23_ops = {
249235 .is_enabled = regulator_is_enabled_regmap,
250236 .enable = tps65218_pmic_enable,
251237 .disable = tps65218_pmic_disable,
252238 .set_input_current_limit = tps65218_pmic_set_input_current_lim,
253239 .set_current_limit = tps65218_pmic_set_current_limit,
254− .get_current_limit = tps65218_pmic_get_current_limit,
240+ .get_current_limit = regulator_get_current_limit_regmap,
255241 };
256242
257243 /* Operations permitted on DCDC5, DCDC6 */
258−static struct regulator_ops tps65218_dcdc56_pmic_ops = {
244+static const struct regulator_ops tps65218_dcdc56_pmic_ops = {
259245 .is_enabled = regulator_is_enabled_regmap,
260246 .enable = tps65218_pmic_enable,
261247 .disable = tps65218_pmic_disable,
@@ -270,53 +256,57 @@ static const struct regulator_desc regulators[] = { · 8 unmodified lines
270256 TPS65218_CONTROL_DCDC1_MASK, TPS65218_REG_ENABLE1,
271257 TPS65218_ENABLE1_DC1_EN, 0, 0, dcdc1_dcdc2_ranges,
272258 2, 4000, 0, TPS65218_REG_SEQ3,
273− TPS65218_SEQ3_DC1_SEQ_MASK),
259+ TPS65218_SEQ3_DC1_SEQ_MASK, NULL, 0),
274260 TPS65218_REGULATOR("DCDC2", "regulator-dcdc2", TPS65218_DCDC_2,
275261 REGULATOR_VOLTAGE, tps65218_dcdc12_ops, 64,
276262 TPS65218_REG_CONTROL_DCDC2,
277263 TPS65218_CONTROL_DCDC2_MASK, TPS65218_REG_ENABLE1,
278264 TPS65218_ENABLE1_DC2_EN, 0, 0, dcdc1_dcdc2_ranges,
279265 2, 4000, 0, TPS65218_REG_SEQ3,
280− TPS65218_SEQ3_DC2_SEQ_MASK),
266+ TPS65218_SEQ3_DC2_SEQ_MASK, NULL, 0),
281267 TPS65218_REGULATOR("DCDC3", "regulator-dcdc3", TPS65218_DCDC_3,
282268 REGULATOR_VOLTAGE, tps65218_ldo1_dcdc34_ops, 64,
283269 TPS65218_REG_CONTROL_DCDC3,
284270 TPS65218_CONTROL_DCDC3_MASK, TPS65218_REG_ENABLE1,
285271 TPS65218_ENABLE1_DC3_EN, 0, 0, ldo1_dcdc3_ranges, 2,
286− 0, 0, TPS65218_REG_SEQ4, TPS65218_SEQ4_DC3_SEQ_MASK),
272+ 0, 0, TPS65218_REG_SEQ4, TPS65218_SEQ4_DC3_SEQ_MASK,
273+ NULL, 0),
287274 TPS65218_REGULATOR("DCDC4", "regulator-dcdc4", TPS65218_DCDC_4,
288275 REGULATOR_VOLTAGE, tps65218_ldo1_dcdc34_ops, 53,
289276 TPS65218_REG_CONTROL_DCDC4,
290277 TPS65218_CONTROL_DCDC4_MASK, TPS65218_REG_ENABLE1,
291278 TPS65218_ENABLE1_DC4_EN, 0, 0, dcdc4_ranges, 2,
292− 0, 0, TPS65218_REG_SEQ4, TPS65218_SEQ4_DC4_SEQ_MASK),
279+ 0, 0, TPS65218_REG_SEQ4, TPS65218_SEQ4_DC4_SEQ_MASK,
280+ NULL, 0),
293281 TPS65218_REGULATOR("DCDC5", "regulator-dcdc5", TPS65218_DCDC_5,
294282 REGULATOR_VOLTAGE, tps65218_dcdc56_pmic_ops, 1, -1,
295283 -1, TPS65218_REG_ENABLE1, TPS65218_ENABLE1_DC5_EN, 0,
296284 0, NULL, 0, 0, 1000000, TPS65218_REG_SEQ5,
297− TPS65218_SEQ5_DC5_SEQ_MASK),
285+ TPS65218_SEQ5_DC5_SEQ_MASK, NULL, 0),
298286 TPS65218_REGULATOR("DCDC6", "regulator-dcdc6", TPS65218_DCDC_6,
299287 REGULATOR_VOLTAGE, tps65218_dcdc56_pmic_ops, 1, -1,
300288 -1, TPS65218_REG_ENABLE1, TPS65218_ENABLE1_DC6_EN, 0,
301289 0, NULL, 0, 0, 1800000, TPS65218_REG_SEQ5,
302− TPS65218_SEQ5_DC6_SEQ_MASK),
290+ TPS65218_SEQ5_DC6_SEQ_MASK, NULL, 0),
303291 TPS65218_REGULATOR("LDO1", "regulator-ldo1", TPS65218_LDO_1,
304292 REGULATOR_VOLTAGE, tps65218_ldo1_dcdc34_ops, 64,
305293 TPS65218_REG_CONTROL_LDO1,
306294 TPS65218_CONTROL_LDO1_MASK, TPS65218_REG_ENABLE2,
307295 TPS65218_ENABLE2_LDO1_EN, 0, 0, ldo1_dcdc3_ranges,
308296 2, 0, 0, TPS65218_REG_SEQ6,
309− TPS65218_SEQ6_LDO1_SEQ_MASK),
297+ TPS65218_SEQ6_LDO1_SEQ_MASK, NULL, 0),
310298 TPS65218_REGULATOR("LS2", "regulator-ls2", TPS65218_LS_2,
311299 REGULATOR_CURRENT, tps65218_ls23_ops, 0, 0, 0,
312300 TPS65218_REG_ENABLE2, TPS65218_ENABLE2_LS2_EN,
313301 TPS65218_REG_CONFIG2, TPS65218_CONFIG2_LS2ILIM_MASK,
314− NULL, 0, 0, 0, 0, 0),
302+ NULL, 0, 0, 0, 0, 0, ls3_currents,
303+ ARRAY_SIZE(ls3_currents)),
315304 TPS65218_REGULATOR("LS3", "regulator-ls3", TPS65218_LS_3,
316305 REGULATOR_CURRENT, tps65218_ls23_ops, 0, 0, 0,
317306 TPS65218_REG_ENABLE2, TPS65218_ENABLE2_LS3_EN,
318307 TPS65218_REG_CONFIG2, TPS65218_CONFIG2_LS3ILIM_MASK,
319− NULL, 0, 0, 0, 0, 0),
308+ NULL, 0, 0, 0, 0, 0, ls3_currents,
309+ ARRAY_SIZE(ls3_currents)),
320310 };
321311
322312 static int tps65218_regulator_probe(struct platform_device *pdev)
drivers/regulator/tps6524x-regulator.c+5−6
@@ -137,7 +137,6 @@ struct tps6524x { · 136 unmodified lines
137137 struct spi_device *spi;
138138 struct mutex lock;
139139 struct regulator_desc desc[N_REGULATORS];
140− struct regulator_dev *rdev[N_REGULATORS];
141140 };
142141
143142 static int __read_reg(struct tps6524x *hw, int reg)
@@ -565,7 +564,7 @@ static int is_supply_enabled(struct regulator_dev *rdev) · 421 unmodified lines
565564 return read_field(hw, &info->enable);
566565 }
567566
568−static struct regulator_ops regulator_ops = {
567+static const struct regulator_ops regulator_ops = {
569568 .is_enabled = is_supply_enabled,
570569 .enable = enable_supply,
571570 .disable = disable_supply,
@@ -584,6 +583,7 @@ static int pmic_probe(struct spi_device *spi) · 12 unmodified lines
584583 const struct supply_info *info = supply_info;
585584 struct regulator_init_data *init_data;
586585 struct regulator_config config = { };
586+ struct regulator_dev *rdev;
587587 int i;
588588
589589 init_data = dev_get_platdata(dev);
@@ -616,10 +616,9 @@ static int pmic_probe(struct spi_device *spi) · 26 unmodified lines
616616 config.init_data = init_data;
617617 config.driver_data = hw;
618618
619− hw->rdev[i] = devm_regulator_register(dev, &hw->desc[i],
620− &config);
621− if (IS_ERR(hw->rdev[i]))
622− return PTR_ERR(hw->rdev[i]);
619+ rdev = devm_regulator_register(dev, &hw->desc[i], &config);
620+ if (IS_ERR(rdev))
621+ return PTR_ERR(rdev);
623622 }
624623
625624 return 0;
drivers/regulator/tps80031-regulator.c+16−32
@@ -1,27 +1,13 @@
1−/*
2− * tps80031-regulator.c -- TI TPS80031 regulator driver.
3− *
4− * Regulator driver for TI TPS80031/TPS80032 Fully Integrated Power
5− * Management with Power Path and Battery Charger.
6− *
7− * Copyright (c) 2012, NVIDIA Corporation.
8− *
9− * Author: Laxman Dewangan <ldewangan@nvidia.com>
10− *
11− * This program is free software; you can redistribute it and/or
12− * modify it under the terms of the GNU General Public License as
13− * published by the Free Software Foundation version 2.
14− *
15− * This program is distributed "as is" WITHOUT ANY WARRANTY of any kind,
16− * whether express or implied; without even the implied warranty of
17− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18− * General Public License for more details.
19− *
20− * You should have received a copy of the GNU General Public License
21− * along with this program; if not, write to the Free Software
22− * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
23− * 02111-1307, USA
24− */
1+// SPDX-License-Identifier: GPL-2.0
2+//
3+// tps80031-regulator.c -- TI TPS80031 regulator driver.
4+//
5+// Regulator driver for TI TPS80031/TPS80032 Fully Integrated Power
6+// Management with Power Path and Battery Charger.
7+//
8+// Copyright (c) 2012, NVIDIA Corporation.
9+//
10+// Author: Laxman Dewangan <ldewangan@nvidia.com>
2511
2612 #include <linux/delay.h>
2713 #include <linux/err.h>
@@ -85,7 +71,6 @@ struct tps80031_regulator_info { · 57 unmodified lines
8571
8672 struct tps80031_regulator {
8773 struct device *dev;
88− struct regulator_dev *rdev;
8974 struct tps80031_regulator_info *rinfo;
9075
9176 u8 device_flags;
@@ -155,7 +140,7 @@ static int tps80031_reg_disable(struct regulator_dev *rdev) · 63 unmodified lines
155140 }
156141
157142 /* DCDC voltages for the selector of 58 to 63 */
158−static int tps80031_dcdc_voltages[4][5] = {
143+static const int tps80031_dcdc_voltages[4][5] = {
159144 { 1350, 1500, 1800, 1900, 2100},
160145 { 1350, 1500, 1800, 1900, 2100},
161146 { 2084, 2315, 2778, 2932, 3241},
@@ -378,7 +363,7 @@ static int tps80031_vbus_disable(struct regulator_dev *rdev) · 216 unmodified lines
378363 return ret;
379364 }
380365
381−static struct regulator_ops tps80031_dcdc_ops = {
366+static const struct regulator_ops tps80031_dcdc_ops = {
382367 .list_voltage = tps80031_dcdc_list_voltage,
383368 .set_voltage_sel = tps80031_dcdc_set_voltage_sel,
384369 .get_voltage_sel = tps80031_dcdc_get_voltage_sel,
@@ -387,7 +372,7 @@ static struct regulator_ops tps80031_dcdc_ops = { · 2 unmodified lines
387372 .is_enabled = tps80031_reg_is_enabled,
388373 };
389374
390−static struct regulator_ops tps80031_ldo_ops = {
375+static const struct regulator_ops tps80031_ldo_ops = {
391376 .list_voltage = tps80031_ldo_list_voltage,
392377 .map_voltage = tps80031_ldo_map_voltage,
393378 .set_voltage_sel = regulator_set_voltage_sel_regmap,
@@ -397,18 +382,18 @@ static struct regulator_ops tps80031_ldo_ops = { · 3 unmodified lines
397382 .is_enabled = tps80031_reg_is_enabled,
398383 };
399384
400−static struct regulator_ops tps80031_vbus_sw_ops = {
385+static const struct regulator_ops tps80031_vbus_sw_ops = {
401386 .list_voltage = regulator_list_voltage_linear,
402387 .enable = tps80031_vbus_enable,
403388 .disable = tps80031_vbus_disable,
404389 .is_enabled = tps80031_vbus_is_enabled,
405390 };
406391
407−static struct regulator_ops tps80031_vbus_hw_ops = {
392+static const struct regulator_ops tps80031_vbus_hw_ops = {
408393 .list_voltage = regulator_list_voltage_linear,
409394 };
410395
411−static struct regulator_ops tps80031_ext_reg_ops = {
396+static const struct regulator_ops tps80031_ext_reg_ops = {
412397 .list_voltage = regulator_list_voltage_linear,
413398 .enable = tps80031_reg_enable,
414399 .disable = tps80031_reg_disable,
@@ -736,7 +721,6 @@ static int tps80031_regulator_probe(struct platform_device *pdev) · 321 unmodified lines
736721 ri->rinfo->desc.name);
737722 return PTR_ERR(rdev);
738723 }
739− ri->rdev = rdev;
740724 }
741725
742726 platform_set_drvdata(pdev, pmic);
drivers/regulator/twl-regulator.c+3−3
@@ -392,7 +392,7 @@ static int twl4030ldo_get_voltage_sel(struct regulator_dev *rdev) · 391 unmodified lines
392392 return vsel;
393393 }
394394
395−static struct regulator_ops twl4030ldo_ops = {
395+static const struct regulator_ops twl4030ldo_ops = {
396396 .list_voltage = twl4030ldo_list_voltage,
397397
398398 .set_voltage_sel = twl4030ldo_set_voltage_sel,
@@ -430,14 +430,14 @@ static int twl4030smps_get_voltage(struct regulator_dev *rdev) · 31 unmodified lines
430430 return vsel * 12500 + 600000;
431431 }
432432
433−static struct regulator_ops twl4030smps_ops = {
433+static const struct regulator_ops twl4030smps_ops = {
434434 .set_voltage = twl4030smps_set_voltage,
435435 .get_voltage = twl4030smps_get_voltage,
436436 };
437437
438438 /*----------------------------------------------------------------------*/
439439
440−static struct regulator_ops twl4030fixed_ops = {
440+static const struct regulator_ops twl4030fixed_ops = {
441441 .list_voltage = regulator_list_voltage_linear,
442442
443443 .enable = twl4030reg_enable,
drivers/regulator/vctrl-regulator.c+1−3
@@ -334,10 +334,8 @@ static int vctrl_init_vtable(struct platform_device *pdev) · 333 unmodified lines
334334 ctrl_uV = regulator_list_voltage(ctrl_reg, i);
335335
336336 if (ctrl_uV < vrange_ctrl->min_uV ||
337− ctrl_uV > vrange_ctrl->max_uV) {
337+ ctrl_uV > vrange_ctrl->max_uV)
338338 rdesc->n_voltages--;
339− continue;
340− }
341339 }
342340
343341 if (rdesc->n_voltages == 0) {
drivers/regulator/vexpress-regulator.c+27−45
@@ -1,15 +1,6 @@
1−/*
2− * This program is free software; you can redistribute it and/or modify
3− * it under the terms of the GNU General Public License version 2 as
4− * published by the Free Software Foundation.
5− *
6− * This program is distributed in the hope that it will be useful,
7− * but WITHOUT ANY WARRANTY; without even the implied warranty of
8− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9− * GNU General Public License for more details.
10− *
11− * Copyright (C) 2012 ARM Limited
12− */
1+// SPDX-License-Identifier: GPL-2.0
2+//
3+// Copyright (C) 2012 ARM Limited
134
145 #define DRVNAME "vexpress-regulator"
156 #define pr_fmt(fmt) DRVNAME ": " fmt
@@ -23,17 +14,10 @@ · 7 unmodified lines
2314 #include <linux/regulator/of_regulator.h>
2415 #include <linux/vexpress.h>
2516
26−struct vexpress_regulator {
27− struct regulator_desc desc;
28− struct regulator_dev *regdev;
29− struct regmap *regmap;
30−};
31−
3217 static int vexpress_regulator_get_voltage(struct regulator_dev *regdev)
3318 {
34− struct vexpress_regulator *reg = rdev_get_drvdata(regdev);
35− u32 uV;
36− int err = regmap_read(reg->regmap, 0, &uV);
19+ unsigned int uV;
20+ int err = regmap_read(regdev->regmap, 0, &uV);
3721
3822 return err ? err : uV;
3923 }
@@ -41,60 +25,58 @@ static int vexpress_regulator_get_voltage(struct regulator_dev *regdev) · 1 unmodified line
4125 static int vexpress_regulator_set_voltage(struct regulator_dev *regdev,
4226 int min_uV, int max_uV, unsigned *selector)
4327 {
44− struct vexpress_regulator *reg = rdev_get_drvdata(regdev);
45−
46− return regmap_write(reg->regmap, 0, min_uV);
28+ return regmap_write(regdev->regmap, 0, min_uV);
4729 }
4830
49−static struct regulator_ops vexpress_regulator_ops_ro = {
31+static const struct regulator_ops vexpress_regulator_ops_ro = {
5032 .get_voltage = vexpress_regulator_get_voltage,
5133 };
5234
53−static struct regulator_ops vexpress_regulator_ops = {
35+static const struct regulator_ops vexpress_regulator_ops = {
5436 .get_voltage = vexpress_regulator_get_voltage,
5537 .set_voltage = vexpress_regulator_set_voltage,
5638 };
5739
5840 static int vexpress_regulator_probe(struct platform_device *pdev)
5941 {
60− struct vexpress_regulator *reg;
42+ struct regulator_desc *desc;
6143 struct regulator_init_data *init_data;
6244 struct regulator_config config = { };
45+ struct regulator_dev *rdev;
46+ struct regmap *regmap;
6347
64− reg = devm_kzalloc(&pdev->dev, sizeof(*reg), GFP_KERNEL);
65− if (!reg)
48+ desc = devm_kzalloc(&pdev->dev, sizeof(*desc), GFP_KERNEL);
49+ if (!desc)
6650 return -ENOMEM;
6751
68− reg->regmap = devm_regmap_init_vexpress_config(&pdev->dev);
69− if (IS_ERR(reg->regmap))
70− return PTR_ERR(reg->regmap);
52+ regmap = devm_regmap_init_vexpress_config(&pdev->dev);
53+ if (IS_ERR(regmap))
54+ return PTR_ERR(regmap);
7155
72− reg->desc.name = dev_name(&pdev->dev);
73− reg->desc.type = REGULATOR_VOLTAGE;
74− reg->desc.owner = THIS_MODULE;
75− reg->desc.continuous_voltage_range = true;
56+ desc->name = dev_name(&pdev->dev);
57+ desc->type = REGULATOR_VOLTAGE;
58+ desc->owner = THIS_MODULE;
59+ desc->continuous_voltage_range = true;
7660
7761 init_data = of_get_regulator_init_data(&pdev->dev, pdev->dev.of_node,
78− &reg->desc);
62+ desc);
7963 if (!init_data)
8064 return -EINVAL;
8165
8266 init_data->constraints.apply_uV = 0;
8367 if (init_data->constraints.min_uV && init_data->constraints.max_uV)
84− reg->desc.ops = &vexpress_regulator_ops;
68+ desc->ops = &vexpress_regulator_ops;
8569 else
86− reg->desc.ops = &vexpress_regulator_ops_ro;
70+ desc->ops = &vexpress_regulator_ops_ro;
8771
72+ config.regmap = regmap;
8873 config.dev = &pdev->dev;
8974 config.init_data = init_data;
90− config.driver_data = reg;
9175 config.of_node = pdev->dev.of_node;
9276
93− reg->regdev = devm_regulator_register(&pdev->dev, &reg->desc, &config);
94− if (IS_ERR(reg->regdev))
95− return PTR_ERR(reg->regdev);
96−
97− platform_set_drvdata(pdev, reg);
77+ rdev = devm_regulator_register(&pdev->dev, desc, &config);
78+ if (IS_ERR(rdev))
79+ return PTR_ERR(rdev);
9880
9981 return 0;
10082 }
drivers/regulator/wm831x-dcdc.c+11−12
@@ -1,15 +1,10 @@
1−/*
2− * wm831x-dcdc.c -- DC-DC buck convertor driver for the WM831x series
3− *
4− * Copyright 2009 Wolfson Microelectronics PLC.
5− *
6− * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
7− *
8− * This program is free software; you can redistribute it and/or modify it
9− * under the terms of the GNU General Public License as published by the
10− * Free Software Foundation; either version 2 of the License, or (at your
11− * option) any later version.
12− */
1+// SPDX-License-Identifier: GPL-2.0+
2+//
3+// wm831x-dcdc.c -- DC-DC buck converter driver for the WM831x series
4+//
5+// Copyright 2009 Wolfson Microelectronics PLC.
6+//
7+// Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
138
149 #include <linux/module.h>
1510 #include <linux/moduleparam.h>
@@ -183,9 +178,11 @@ static irqreturn_t wm831x_dcdc_uv_irq(int irq, void *data) · 167 unmodified lines
183178 {
184179 struct wm831x_dcdc *dcdc = data;
185180
181+ regulator_lock(dcdc->regulator);
186182 regulator_notifier_call_chain(dcdc->regulator,
187183 REGULATOR_EVENT_UNDER_VOLTAGE,
188184 NULL);
185+ regulator_unlock(dcdc->regulator);
189186
190187 return IRQ_HANDLED;
191188 }
@@ -194,9 +191,11 @@ static irqreturn_t wm831x_dcdc_oc_irq(int irq, void *data) · 2 unmodified lines
194191 {
195192 struct wm831x_dcdc *dcdc = data;
196193
194+ regulator_lock(dcdc->regulator);
197195 regulator_notifier_call_chain(dcdc->regulator,
198196 REGULATOR_EVENT_OVER_CURRENT,
199197 NULL);
198+ regulator_unlock(dcdc->regulator);
200199
201200 return IRQ_HANDLED;
202201 }
drivers/regulator/wm831x-isink.c+16−50
@@ -1,15 +1,10 @@
1−/*
2− * wm831x-isink.c -- Current sink driver for the WM831x series
3− *
4− * Copyright 2009 Wolfson Microelectronics PLC.
5− *
6− * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
7− *
8− * This program is free software; you can redistribute it and/or modify it
9− * under the terms of the GNU General Public License as published by the
10− * Free Software Foundation; either version 2 of the License, or (at your
11− * option) any later version.
12− */
1+// SPDX-License-Identifier: GPL-2.0+
2+//
3+// wm831x-isink.c -- Current sink driver for the WM831x series
4+//
5+// Copyright 2009 Wolfson Microelectronics PLC.
6+//
7+// Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
138
149 #include <linux/module.h>
1510 #include <linux/moduleparam.h>
@@ -92,57 +87,23 @@ static int wm831x_isink_is_enabled(struct regulator_dev *rdev) · 76 unmodified lines
9287 return 0;
9388 }
9489
95−static int wm831x_isink_set_current(struct regulator_dev *rdev,
96− int min_uA, int max_uA)
97−{
98− struct wm831x_isink *isink = rdev_get_drvdata(rdev);
99− struct wm831x *wm831x = isink->wm831x;
100− int ret, i;
101−
102− for (i = 0; i < ARRAY_SIZE(wm831x_isinkv_values); i++) {
103− int val = wm831x_isinkv_values[i];
104− if (min_uA <= val && val <= max_uA) {
105− ret = wm831x_set_bits(wm831x, isink->reg,
106− WM831X_CS1_ISEL_MASK, i);
107− return ret;
108− }
109− }
110−
111− return -EINVAL;
112−}
113−
114−static int wm831x_isink_get_current(struct regulator_dev *rdev)
115−{
116− struct wm831x_isink *isink = rdev_get_drvdata(rdev);
117− struct wm831x *wm831x = isink->wm831x;
118− int ret;
119−
120− ret = wm831x_reg_read(wm831x, isink->reg);
121− if (ret < 0)
122− return ret;
123−
124− ret &= WM831X_CS1_ISEL_MASK;
125− if (ret > WM831X_ISINK_MAX_ISEL)
126− ret = WM831X_ISINK_MAX_ISEL;
127−
128− return wm831x_isinkv_values[ret];
129−}
130−
13190 static const struct regulator_ops wm831x_isink_ops = {
13291 .is_enabled = wm831x_isink_is_enabled,
13392 .enable = wm831x_isink_enable,
13493 .disable = wm831x_isink_disable,
135− .set_current_limit = wm831x_isink_set_current,
136− .get_current_limit = wm831x_isink_get_current,
94+ .set_current_limit = regulator_set_current_limit_regmap,
95+ .get_current_limit = regulator_get_current_limit_regmap,
13796 };
13897
13998 static irqreturn_t wm831x_isink_irq(int irq, void *data)
14099 {
141100 struct wm831x_isink *isink = data;
142101
102+ regulator_lock(isink->regulator);
143103 regulator_notifier_call_chain(isink->regulator,
144104 REGULATOR_EVENT_OVER_CURRENT,
145105 NULL);
106+ regulator_unlock(isink->regulator);
146107
147108 return IRQ_HANDLED;
148109 }
@@ -187,10 +148,15 @@ static int wm831x_isink_probe(struct platform_device *pdev) · 38 unmodified lines
187148 isink->desc.ops = &wm831x_isink_ops;
188149 isink->desc.type = REGULATOR_CURRENT;
189150 isink->desc.owner = THIS_MODULE;
151+ isink->desc.curr_table = wm831x_isinkv_values,
152+ isink->desc.n_current_limits = ARRAY_SIZE(wm831x_isinkv_values),
153+ isink->desc.csel_reg = isink->reg,
154+ isink->desc.csel_mask = WM831X_CS1_ISEL_MASK,
190155
191156 config.dev = pdev->dev.parent;
192157 config.init_data = pdata->isink[id];
193158 config.driver_data = isink;
159+ config.regmap = wm831x->regmap;
194160
195161 isink->regulator = devm_regulator_register(&pdev->dev, &isink->desc,
196162 &config);
drivers/regulator/wm831x-ldo.c+9−12
@@ -1,15 +1,10 @@
1−/*
2− * wm831x-ldo.c -- LDO driver for the WM831x series
3− *
4− * Copyright 2009 Wolfson Microelectronics PLC.
5− *
6− * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
7− *
8− * This program is free software; you can redistribute it and/or modify it
9− * under the terms of the GNU General Public License as published by the
10− * Free Software Foundation; either version 2 of the License, or (at your
11− * option) any later version.
12− */
1+// SPDX-License-Identifier: GPL-2.0+
2+//
3+// wm831x-ldo.c -- LDO driver for the WM831x series
4+//
5+// Copyright 2009 Wolfson Microelectronics PLC.
6+//
7+// Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
138
149 #include <linux/module.h>
1510 #include <linux/moduleparam.h>
@@ -51,9 +46,11 @@ static irqreturn_t wm831x_ldo_uv_irq(int irq, void *data) · 35 unmodified lines
5146 {
5247 struct wm831x_ldo *ldo = data;
5348
49+ regulator_lock(ldo->regulator);
5450 regulator_notifier_call_chain(ldo->regulator,
5551 REGULATOR_EVENT_UNDER_VOLTAGE,
5652 NULL);
53+ regulator_unlock(ldo->regulator);
5754
5855 return IRQ_HANDLED;
5956 }
drivers/regulator/wm8350-regulator.c+19−83
@@ -1,16 +1,11 @@
1−/*
2− * wm8350.c -- Voltage and current regulation for the Wolfson WM8350 PMIC
3− *
4− * Copyright 2007, 2008 Wolfson Microelectronics PLC.
5− *
6− * Author: Liam Girdwood
7− * linux@wolfsonmicro.com
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− */
1+// SPDX-License-Identifier: GPL-2.0+
2+//
3+// wm8350.c -- Voltage and current regulation for the Wolfson WM8350 PMIC
4+//
5+// Copyright 2007, 2008 Wolfson Microelectronics PLC.
6+//
7+// Author: Liam Girdwood
8+// linux@wolfsonmicro.com
149
1510 #include <linux/module.h>
1611 #include <linux/moduleparam.h>
@@ -28,7 +23,7 @@ · 11 unmodified lines
2823 #define WM8350_DCDC_MAX_VSEL 0x66
2924
3025 /* Microamps */
31−static const int isink_cur[] = {
26+static const unsigned int isink_cur[] = {
3227 4,
3328 5,
3429 6,
@@ -95,73 +90,6 @@ static const int isink_cur[] = { · 60 unmodified lines
9590 223191
9691 };
9792
98−static int get_isink_val(int min_uA, int max_uA, u16 *setting)
99−{
100− int i;
101−
102− for (i = 0; i < ARRAY_SIZE(isink_cur); i++) {
103− if (min_uA <= isink_cur[i] && max_uA >= isink_cur[i]) {
104− *setting = i;
105− return 0;
106− }
107− }
108− return -EINVAL;
109−}
110−
111−static int wm8350_isink_set_current(struct regulator_dev *rdev, int min_uA,
112− int max_uA)
113−{
114− struct wm8350 *wm8350 = rdev_get_drvdata(rdev);
115− int isink = rdev_get_id(rdev);
116− u16 val, setting;
117− int ret;
118−
119− ret = get_isink_val(min_uA, max_uA, &setting);
120− if (ret != 0)
121− return ret;
122−
123− switch (isink) {
124− case WM8350_ISINK_A:
125− val = wm8350_reg_read(wm8350, WM8350_CURRENT_SINK_DRIVER_A) &
126− ~WM8350_CS1_ISEL_MASK;
127− wm8350_reg_write(wm8350, WM8350_CURRENT_SINK_DRIVER_A,
128− val | setting);
129− break;
130− case WM8350_ISINK_B:
131− val = wm8350_reg_read(wm8350, WM8350_CURRENT_SINK_DRIVER_B) &
132− ~WM8350_CS1_ISEL_MASK;
133− wm8350_reg_write(wm8350, WM8350_CURRENT_SINK_DRIVER_B,
134− val | setting);
135− break;
136− default:
137− return -EINVAL;
138− }
139−
140− return 0;
141−}
142−
143−static int wm8350_isink_get_current(struct regulator_dev *rdev)
144−{
145− struct wm8350 *wm8350 = rdev_get_drvdata(rdev);
146− int isink = rdev_get_id(rdev);
147− u16 val;
148−
149− switch (isink) {
150− case WM8350_ISINK_A:
151− val = wm8350_reg_read(wm8350, WM8350_CURRENT_SINK_DRIVER_A) &
152− WM8350_CS1_ISEL_MASK;
153− break;
154− case WM8350_ISINK_B:
155− val = wm8350_reg_read(wm8350, WM8350_CURRENT_SINK_DRIVER_B) &
156− WM8350_CS1_ISEL_MASK;
157− break;
158− default:
159− return 0;
160− }
161−
162− return isink_cur[val];
163−}
164−
16593 /* turn on ISINK followed by DCDC */
16694 static int wm8350_isink_enable(struct regulator_dev *rdev)
16795 {
@@ -982,8 +910,8 @@ static const struct regulator_ops wm8350_ldo_ops = { · 814 unmodified lines
982910 };
983911
984912 static const struct regulator_ops wm8350_isink_ops = {
985− .set_current_limit = wm8350_isink_set_current,
986− .get_current_limit = wm8350_isink_get_current,
913+ .set_current_limit = regulator_set_current_limit_regmap,
914+ .get_current_limit = regulator_get_current_limit_regmap,
987915 .enable = wm8350_isink_enable,
988916 .disable = wm8350_isink_disable,
989917 .is_enabled = wm8350_isink_is_enabled,
@@ -1138,6 +1066,10 @@ static const struct regulator_desc wm8350_reg[NUM_WM8350_REGULATORS] = { · 148 unmodified lines
11381066 .irq = WM8350_IRQ_CS1,
11391067 .type = REGULATOR_CURRENT,
11401068 .owner = THIS_MODULE,
1069+ .curr_table = isink_cur,
1070+ .n_current_limits = ARRAY_SIZE(isink_cur),
1071+ .csel_reg = WM8350_CURRENT_SINK_DRIVER_A,
1072+ .csel_mask = WM8350_CS1_ISEL_MASK,
11411073 },
11421074 {
11431075 .name = "ISINKB",
@@ -1146,6 +1078,10 @@ static const struct regulator_desc wm8350_reg[NUM_WM8350_REGULATORS] = { · 2 unmodified lines
11461078 .irq = WM8350_IRQ_CS2,
11471079 .type = REGULATOR_CURRENT,
11481080 .owner = THIS_MODULE,
1081+ .curr_table = isink_cur,
1082+ .n_current_limits = ARRAY_SIZE(isink_cur),
1083+ .csel_reg = WM8350_CURRENT_SINK_DRIVER_B,
1084+ .csel_mask = WM8350_CS2_ISEL_MASK,
11491085 },
11501086 };
11511087
drivers/regulator/wm8400-regulator.c+16−23
@@ -1,16 +1,10 @@
1−/*
2− * Regulator support for WM8400
3− *
4− * Copyright 2008 Wolfson Microelectronics PLC.
5− *
6− * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
7− *
8− * This program is free software; you can redistribute it and/or
9− * modify it under the terms of the GNU General Public License as
10− * published by the Free Software Foundation; either version 2 of the
11− * License, or (at your option) any later version.
12− *
13− */
1+// SPDX-License-Identifier: GPL-2.0+
2+//
3+// Regulator support for WM8400
4+//
5+// Copyright 2008 Wolfson Microelectronics PLC.
6+//
7+// Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
148
159 #include <linux/bug.h>
1610 #include <linux/err.h>
@@ -36,13 +30,12 @@ static const struct regulator_ops wm8400_ldo_ops = { · 19 unmodified lines
3630
3731 static unsigned int wm8400_dcdc_get_mode(struct regulator_dev *dev)
3832 {
39− struct wm8400 *wm8400 = rdev_get_drvdata(dev);
33+ struct regmap *rmap = rdev_get_regmap(dev);
4034 int offset = (rdev_get_id(dev) - WM8400_DCDC1) * 2;
4135 u16 data[2];
4236 int ret;
4337
44− ret = wm8400_block_read(wm8400, WM8400_DCDC1_CONTROL_1 + offset, 2,
45− data);
38+ ret = regmap_bulk_read(rmap, WM8400_DCDC1_CONTROL_1 + offset, data, 2);
4639 if (ret != 0)
4740 return 0;
4841
@@ -63,36 +56,36 @@ static unsigned int wm8400_dcdc_get_mode(struct regulator_dev *dev) · 14 unmodified lines
6356
6457 static int wm8400_dcdc_set_mode(struct regulator_dev *dev, unsigned int mode)
6558 {
66− struct wm8400 *wm8400 = rdev_get_drvdata(dev);
59+ struct regmap *rmap = rdev_get_regmap(dev);
6760 int offset = (rdev_get_id(dev) - WM8400_DCDC1) * 2;
6861 int ret;
6962
7063 switch (mode) {
7164 case REGULATOR_MODE_FAST:
7265 /* Datasheet: active with force PWM */
73− ret = wm8400_set_bits(wm8400, WM8400_DCDC1_CONTROL_2 + offset,
66+ ret = regmap_update_bits(rmap, WM8400_DCDC1_CONTROL_2 + offset,
7467 WM8400_DC1_FRC_PWM, WM8400_DC1_FRC_PWM);
7568 if (ret != 0)
7669 return ret;
7770
78− return wm8400_set_bits(wm8400, WM8400_DCDC1_CONTROL_1 + offset,
71+ return regmap_update_bits(rmap, WM8400_DCDC1_CONTROL_1 + offset,
7972 WM8400_DC1_ACTIVE | WM8400_DC1_SLEEP,
8073 WM8400_DC1_ACTIVE);
8174
8275 case REGULATOR_MODE_NORMAL:
8376 /* Datasheet: active */
84− ret = wm8400_set_bits(wm8400, WM8400_DCDC1_CONTROL_2 + offset,
77+ ret = regmap_update_bits(rmap, WM8400_DCDC1_CONTROL_2 + offset,
8578 WM8400_DC1_FRC_PWM, 0);
8679 if (ret != 0)
8780 return ret;
8881
89− return wm8400_set_bits(wm8400, WM8400_DCDC1_CONTROL_1 + offset,
82+ return regmap_update_bits(rmap, WM8400_DCDC1_CONTROL_1 + offset,
9083 WM8400_DC1_ACTIVE | WM8400_DC1_SLEEP,
9184 WM8400_DC1_ACTIVE);
9285
9386 case REGULATOR_MODE_IDLE:
9487 /* Datasheet: standby */
95− return wm8400_set_bits(wm8400, WM8400_DCDC1_CONTROL_1 + offset,
88+ return regmap_update_bits(rmap, WM8400_DCDC1_CONTROL_1 + offset,
9689 WM8400_DC1_ACTIVE | WM8400_DC1_SLEEP, 0);
9790 default:
9891 return -EINVAL;
@@ -195,7 +188,7 @@ static struct regulator_desc regulators[] = { · 96 unmodified lines
195188 .id = WM8400_DCDC2,
196189 .ops = &wm8400_dcdc_ops,
197190 .enable_reg = WM8400_DCDC2_CONTROL_1,
198− .enable_mask = WM8400_DC1_ENA_MASK,
191+ .enable_mask = WM8400_DC2_ENA_MASK,
199192 .n_voltages = WM8400_DC2_VSEL_MASK + 1,
200193 .vsel_reg = WM8400_DCDC2_CONTROL_1,
201194 .vsel_mask = WM8400_DC2_VSEL_MASK,
drivers/regulator/wm8994-regulator.c+7−12
@@ -1,15 +1,10 @@
1−/*
2− * wm8994-regulator.c -- Regulator driver for the WM8994
3− *
4− * Copyright 2009 Wolfson Microelectronics PLC.
5− *
6− * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
7− *
8− * This program is free software; you can redistribute it and/or modify it
9− * under the terms of the GNU General Public License as published by the
10− * Free Software Foundation; either version 2 of the License, or (at your
11− * option) any later version.
12− */
1+// SPDX-License-Identifier: GPL-2.0+
2+//
3+// wm8994-regulator.c -- Regulator driver for the WM8994
4+//
5+// Copyright 2009 Wolfson Microelectronics PLC.
6+//
7+// Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
138
149 #include <linux/module.h>
1510 #include <linux/moduleparam.h>
include/linux/mfd/palmas.h+0−1
@@ -553,7 +553,6 @@ struct palmas_pmic { · 552 unmodified lines
553553 struct palmas *palmas;
554554 struct device *dev;
555555 struct regulator_desc desc[PALMAS_NUM_REGS];
556− struct regulator_dev *rdev[PALMAS_NUM_REGS];
557556 struct mutex mutex;
558557
559558 int smps123;
include/linux/mfd/wm831x/regulator.h+1−1
@@ -1213,6 +1213,6 @@ · 1212 unmodified lines
12131213 #define WM831X_LDO1_OK_WIDTH 1 /* LDO1_OK */
12141214
12151215 #define WM831X_ISINK_MAX_ISEL 55
1216−extern int wm831x_isinkv_values[WM831X_ISINK_MAX_ISEL + 1];
1216+extern const unsigned int wm831x_isinkv_values[WM831X_ISINK_MAX_ISEL + 1];
12171217
12181218 #endif
include/linux/mfd/wm8400-private.h+0−8
@@ -923,12 +923,4 @@ struct wm8400 { · 922 unmodified lines
923923 #define WM8400_LINE_CMP_VTHD_SHIFT 0 /* LINE_CMP_VTHD - [3:0] */
924924 #define WM8400_LINE_CMP_VTHD_WIDTH 4 /* LINE_CMP_VTHD - [3:0] */
925925
926−int wm8400_block_read(struct wm8400 *wm8400, u8 reg, int count, u16 *data);
927−
928−static inline int wm8400_set_bits(struct wm8400 *wm8400, u8 reg,
929− u16 mask, u16 val)
930−{
931− return regmap_update_bits(wm8400->regmap, reg, mask, val);
932−}
933−
934926 #endif
include/linux/regulator/consumer.h+5−0
@@ -478,6 +478,11 @@ static inline int regulator_is_supported_voltage(struct regulator *regulator, · 477 unmodified lines
478478 return 0;
479479 }
480480
481+static inline unsigned int regulator_get_linear_step(struct regulator *regulator)
482+{
483+ return 0;
484+}
485+
481486 static inline int regulator_set_current_limit(struct regulator *regulator,
482487 int min_uA, int max_uA)
483488 {
sound/soc/codecs/ab8500-codec.c+2−2
@@ -1062,10 +1062,10 @@ static void anc_iir(struct snd_soc_component *component, unsigned int bnk, · 1061 unmodified lines
10621062 snd_soc_component_update_bits(component, AB8500_ANCCONF1,
10631063 BIT(AB8500_ANCCONF1_ANCIIRINIT),
10641064 BIT(AB8500_ANCCONF1_ANCIIRINIT));
1065− usleep_range(AB8500_ANC_SM_DELAY, AB8500_ANC_SM_DELAY);
1065+ usleep_range(AB8500_ANC_SM_DELAY, AB8500_ANC_SM_DELAY*2);
10661066 snd_soc_component_update_bits(component, AB8500_ANCCONF1,
10671067 BIT(AB8500_ANCCONF1_ANCIIRINIT), 0);
1068− usleep_range(AB8500_ANC_SM_DELAY, AB8500_ANC_SM_DELAY);
1068+ usleep_range(AB8500_ANC_SM_DELAY, AB8500_ANC_SM_DELAY*2);
10691069 } else {
10701070 snd_soc_component_update_bits(component, AB8500_ANCCONF1,
10711071 BIT(AB8500_ANCCONF1_ANCIIRUPDATE),

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t