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

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

Pull regulator updates from Mark Brown:
"This has been a fairly quiet release for the regulator API, the main
thing has been the addition of helpers for interrupt handling from
Matti Vaittinen.

We do also have support for quite a few new devices.

Summary:

- Helpers for trivial interrupt notifications, making it easier for
drivers to handle error interrupts.

- Support for Dialog DA914x, Maxim MAX2008x, Qualcomm PM8826,
PMG1100, and PM8450 and TI TPS68470"

* tag 'regulator-v5.17' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator: (30 commits)
regulator: Add MAX20086-MAX20089 driver
dt-bindings: regulators: Add bindings for Maxim MAX20086-MAX20089
regulator: qcom_smd: Align probe function with rpmh-regulator
regulator: remove redundant ret variable
regulator: qcom-labibb: OCP interrupts are not a failure while disabled
regulator: dt-bindings: samsung,s5m8767: Move fixed string BUCK9 to 'properties'
regulator: Introduce tps68470-regulator driver
drivers/regulator: remove redundant ret variable
regulator: fix bullet lists of regulator_ops comment
regulator: Fix type of regulator-coupled-max-spread property
regulator: maxim,max8973: Document interrupts property
regulator: qcom-rpmh: Add support for PM8450 regulators
regulator: qcom,rpmh: Add compatible for PM8450
regulator: da9121: Add DA914x binding info
regulator: da9121: Remove erroneous compatible from binding
regulator: da9121: Add DA914x support
regulator: da9121: Prevent current limit change when enabled
regulator: qcom-rpmh: Add PMG1110 regulators
dt-bindings: regulator: Add compatible for pmg1110
regulator: qcom_spmi: Add pm8226 regulators
...

+1104 -128
+41 -29
Documentation/devicetree/bindings/regulator/dlg,da9121.yaml
··· 17 17 Dialog Semiconductor DA9130 Single-channel 10A double-phase buck converter 18 18 Dialog Semiconductor DA9131 Double-channel 5A single-phase buck converter 19 19 Dialog Semiconductor DA9132 Double-channel 3A single-phase buck converter 20 + Dialog Semiconductor DA9141 Single-channel 40A quad-phase buck converter 21 + Dialog Semiconductor DA9142 Single-channel 20A double-phase buck converter 20 22 21 - Current limits 23 + Device parameter ranges 22 24 23 - This is PER PHASE, and the current limit setting in the devices reflect 24 - that with a maximum 10A limit. Allowing for transients at/near double 25 - the rated current, this translates across the device range to per 26 - channel figures as so... 25 + The current limits can be set to at/near double the rated current per channel 26 + to allow for transient peaks. 27 + Current limit changes when the output is enabled are not supported, as a 28 + precaution against undefined behaviour. 27 29 28 - | DA9121 DA9122 DA9220 DA9217 DA9140 29 - | /DA9130 /DA9131 /DA9132 30 - ----------------------------------------------------------------------------- 31 - Output current / channel | 10000000 5000000 3000000 6000000 40000000 32 - Output current / phase | 5000000 5000000 3000000 3000000 9500000 33 - ----------------------------------------------------------------------------- 34 - Min regulator-min-microvolt| 300000 300000 300000 300000 500000 35 - Max regulator-max-microvolt| 1900000 1900000 1900000 1900000 1000000 36 - Device hardware default | 1000000 1000000 1000000 1000000 1000000 37 - ----------------------------------------------------------------------------- 38 - Min regulator-min-microamp | 7000000 3500000 3500000 7000000 26000000 39 - Max regulator-max-microamp | 20000000 10000000 6000000 12000000 78000000 40 - Device hardware default | 15000000 7500000 5500000 11000000 58000000 30 + |----------------------------------------------| 31 + | | range & reset default value | 32 + | Device |------------------------------| 33 + | | microvolt | microamp | 34 + |----------------------------------------------| 35 + | DA9121/DA9130 | Min: 300000 | Min: 7000000 | 36 + | | Max: 1900000 | Max: 20000000 | 37 + |----------------------------------------------| 38 + | DA9121/DA9131 | Min: 300000 | Min: 3500000 | 39 + | | Max: 1900000 | Max: 10000000 | 40 + |----------------------------------------------| 41 + | DA9121/DA9131 | Min: 300000 | Min: 3500000 | 42 + | | Max: 1900000 | Max: 6000000 | 43 + |----------------------------------------------| 44 + | DA9217 | Min: 300000 | Min: 7000000 | 45 + | | Max: 1900000 | Max: 12000000 | 46 + |----------------------------------------------| 47 + | DA9141 | Min: 300000 | Min: 26000000 | 48 + | | Max: 1300000 | Max: 78000000 | 49 + |----------------------------------------------| 50 + | DA9142 | Min: 300000 | Min: 13000000 | 51 + | | Max: 1300000 | Max: 39000000 | 52 + |----------------------------------------------| 41 53 42 54 properties: 43 55 $nodename: ··· 63 51 - dlg,da9130 64 52 - dlg,da9131 65 53 - dlg,da9132 66 - - dlg,da9140 54 + - dlg,da9141 55 + - dlg,da9142 67 56 68 57 reg: 69 58 maxItems: 1 ··· 83 70 84 71 regulators: 85 72 type: object 86 - $ref: regulator.yaml# 87 73 description: | 88 - This node defines the settings for the BUCK. The content of the 89 - sub-node is defined by the standard binding for regulators; see regulator.yaml. 90 - The DA9121 regulator is bound using their names listed below 91 - buck1 - BUCK1 92 - buck2 - BUCK2 //DA9122, DA9220, DA9131, DA9132 only 74 + List of regulators provided by the device 93 75 94 76 patternProperties: 95 77 "^buck([1-2])$": 96 78 type: object 97 79 $ref: regulator.yaml# 80 + description: | 81 + Properties for a single BUCK regulator 98 82 99 83 properties: 100 - regulator-mode: 101 - maxItems: 1 102 - description: Defined in include/dt-bindings/regulator/dlg,da9121-regulator.h 84 + regulator-name: 85 + pattern: "^BUCK([1-2])$" 86 + description: | 87 + BUCK2 present in DA9122, DA9220, DA9131, DA9132 only 103 88 104 89 regulator-initial-mode: 105 - maxItems: 1 90 + enum: [ 0, 1, 2, 3 ] 106 91 description: Defined in include/dt-bindings/regulator/dlg,da9121-regulator.h 107 92 108 93 enable-gpios: ··· 109 98 110 99 dlg,ripple-cancel: 111 100 $ref: "/schemas/types.yaml#/definitions/uint32" 101 + enum: [ 0, 1, 2, 3 ] 112 102 description: | 113 103 Defined in include/dt-bindings/regulator/dlg,da9121-regulator.h 114 104 Only present on multi-channel devices (DA9122, DA9220, DA9131, DA9132)
+106
Documentation/devicetree/bindings/regulator/maxim,max20086.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/regulator/maxim,max20086.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Maxim Integrated MAX20086-MAX20089 Camera Power Protector 8 + 9 + maintainers: 10 + - Laurent Pinchart <laurent.pinchart@ideasonboard.com> 11 + 12 + description: | 13 + The MAX20086-MAX20089 are dual/quad camera power protectors, designed to 14 + deliver power over coax for radar and camera modules. They support 15 + software-configurable output switching and monitoring. The output voltage and 16 + current limit are fixed by the hardware design. 17 + 18 + properties: 19 + compatible: 20 + enum: 21 + - maxim,max20086 22 + - maxim,max20087 23 + - maxim,max20088 24 + - maxim,max20089 25 + 26 + reg: 27 + maxItems: 1 28 + 29 + enable-gpios: 30 + maxItems: 1 31 + description: GPIO connected to the EN pin, active high 32 + 33 + in-supply: 34 + description: Input supply for the camera outputs (IN pin, 3.0V to 15.0V) 35 + 36 + vdd-supply: 37 + description: Input supply for the device (VDD pin, 3.0V to 5.5V) 38 + 39 + regulators: 40 + type: object 41 + 42 + patternProperties: 43 + "^OUT[1-4]$": 44 + type: object 45 + $ref: regulator.yaml# 46 + 47 + additionalProperties: false 48 + 49 + required: 50 + - compatible 51 + - reg 52 + - in-supply 53 + - vdd-supply 54 + - regulators 55 + 56 + allOf: 57 + - if: 58 + properties: 59 + compatible: 60 + contains: 61 + enum: 62 + - maxim,max20088 63 + - maxim,max20089 64 + then: 65 + properties: 66 + regulators: 67 + properties: 68 + OUT3: false 69 + OUT4: false 70 + 71 + additionalProperties: false 72 + 73 + examples: 74 + - | 75 + #include <dt-bindings/gpio/gpio.h> 76 + 77 + i2c { 78 + #address-cells = <1>; 79 + #size-cells = <0>; 80 + 81 + regulator@28 { 82 + compatible = "maxim,max20087"; 83 + reg = <0x28>; 84 + 85 + in-supply = <&reg_12v0>; 86 + vdd-supply = <&reg_3v3>; 87 + 88 + enable-gpios = <&gpio 108 GPIO_ACTIVE_HIGH>; 89 + 90 + regulators { 91 + OUT1 { 92 + regulator-name = "VOUT1"; 93 + }; 94 + OUT2 { 95 + regulator-name = "VOUT2"; 96 + }; 97 + OUT3 { 98 + regulator-name = "VOUT3"; 99 + }; 100 + OUT4 { 101 + regulator-name = "VOUT4"; 102 + }; 103 + }; 104 + }; 105 + }; 106 + ...
+3
Documentation/devicetree/bindings/regulator/maxim,max8973.yaml
··· 86 86 reg: 87 87 maxItems: 1 88 88 89 + interrupts: 90 + maxItems: 1 91 + 89 92 required: 90 93 - compatible 91 94 - reg
+3
Documentation/devicetree/bindings/regulator/qcom,rpmh-regulator.yaml
··· 43 43 For PM8150L, smps1 - smps8, ldo1 - ldo11, bob, flash, rgb 44 44 For PM8350, smps1 - smps12, ldo1 - ldo10 45 45 For PM8350C, smps1 - smps10, ldo1 - ldo13, bob 46 + For PM8450, smps1 - smps6, ldo1 - ldo4 46 47 For PM8998, smps1 - smps13, ldo1 - ldo28, lvs1 - lvs2 47 48 For PMI8998, bob 48 49 For PMR735A, smps1 - smps3, ldo1 - ldo7 ··· 63 62 - qcom,pm8150l-rpmh-regulators 64 63 - qcom,pm8350-rpmh-regulators 65 64 - qcom,pm8350c-rpmh-regulators 65 + - qcom,pm8450-rpmh-regulators 66 66 - qcom,pm8998-rpmh-regulators 67 + - qcom,pmg1110-rpmh-regulators 67 68 - qcom,pmi8998-rpmh-regulators 68 69 - qcom,pmm8155au-rpmh-regulators 69 70 - qcom,pmr735a-rpmh-regulators
+1
Documentation/devicetree/bindings/regulator/qcom,spmi-regulator.txt
··· 6 6 Definition: must be one of: 7 7 "qcom,pm8004-regulators" 8 8 "qcom,pm8005-regulators" 9 + "qcom,pm8226-regulators" 9 10 "qcom,pm8841-regulators" 10 11 "qcom,pm8916-regulators" 11 12 "qcom,pm8941-regulators"
+1 -1
Documentation/devicetree/bindings/regulator/regulator.yaml
··· 218 218 description: Array of maximum spread between voltages of coupled regulators 219 219 in microvolts, each value in the array relates to the corresponding 220 220 couple specified by the regulator-coupled-with property. 221 - $ref: "/schemas/types.yaml#/definitions/uint32" 221 + $ref: "/schemas/types.yaml#/definitions/uint32-array" 222 222 223 223 regulator-max-step-microvolt: 224 224 description: Maximum difference between current and target voltages
+2 -1
Documentation/devicetree/bindings/regulator/samsung,s5m8767.yaml
··· 67 67 required: 68 68 - regulator-name 69 69 70 + properties: 70 71 # 9 buck 71 - "^BUCK9$": 72 + BUCK9: 72 73 type: object 73 74 $ref: regulator.yaml# 74 75 unevaluatedProperties: false
+7
MAINTAINERS
··· 11653 11653 F: Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml 11654 11654 F: drivers/power/supply/max17042_battery.c 11655 11655 11656 + MAXIM MAX20086 CAMERA POWER PROTECTOR DRIVER 11657 + M: Laurent Pinchart <laurent.pinchart@ideasonboard.com> 11658 + L: linux-kernel@vger.kernel.org 11659 + S: Maintained 11660 + F: Documentation/devicetree/bindings/regulator/maxim,max20086.yaml 11661 + F: drivers/regulator/max20086-regulator.c 11662 + 11656 11663 MAXIM MAX77650 PMIC MFD DRIVER 11657 11664 M: Bartosz Golaszewski <brgl@bgdev.pl> 11658 11665 L: linux-kernel@vger.kernel.org
+18 -1
drivers/regulator/Kconfig
··· 636 636 via I2C bus. The provided regulator is suitable for S3C6410 637 637 and S5PC1XX chips to control VCC_CORE and VCC_USIM voltages. 638 638 639 + config REGULATOR_MAX20086 640 + tristate "Maxim MAX20086-MAX20089 Camera Power Protectors" 641 + depends on I2C 642 + select REGMAP_I2C 643 + help 644 + This driver controls a Maxim MAX20086-MAX20089 camera power 645 + protectorvia I2C bus. The regulator has 2 or 4 outputs depending on 646 + the device model. This driver is only capable to turn on/off them. 647 + 639 648 config REGULATOR_MAX77686 640 649 tristate "Maxim 77686 regulator" 641 650 depends on MFD_MAX77686 || COMPILE_TEST ··· 1348 1339 help 1349 1340 This driver supports TPS65912 voltage regulator chip. 1350 1341 1342 + config REGULATOR_TPS68470 1343 + tristate "TI TPS68470 PMIC Regulators Driver" 1344 + depends on INTEL_SKL_INT3472 || COMPILE_TEST 1345 + help 1346 + This driver adds support for the TPS68470 PMIC to register 1347 + regulators against the usual framework. 1348 + 1349 + The module will be called "tps68470-regulator". 1350 + 1351 1351 config REGULATOR_TWL4030 1352 1352 tristate "TI TWL4030/TWL5030/TWL6030/TPS659x0 PMIC" 1353 1353 depends on TWL4030_CORE ··· 1433 1415 for LCD display panel. 1434 1416 1435 1417 endif 1436 -
+2
drivers/regulator/Makefile
··· 78 78 obj-$(CONFIG_REGULATOR_MAX8973) += max8973-regulator.o 79 79 obj-$(CONFIG_REGULATOR_MAX8997) += max8997-regulator.o 80 80 obj-$(CONFIG_REGULATOR_MAX8998) += max8998.o 81 + obj-$(CONFIG_REGULATOR_MAX20086) += max20086-regulator.o 81 82 obj-$(CONFIG_REGULATOR_MAX77686) += max77686-regulator.o 82 83 obj-$(CONFIG_REGULATOR_MAX77693) += max77693-regulator.o 83 84 obj-$(CONFIG_REGULATOR_MAX77802) += max77802-regulator.o ··· 160 159 obj-$(CONFIG_REGULATOR_TPS65910) += tps65910-regulator.o 161 160 obj-$(CONFIG_REGULATOR_TPS65912) += tps65912-regulator.o 162 161 obj-$(CONFIG_REGULATOR_TPS65132) += tps65132-regulator.o 162 + obj-$(CONFIG_REGULATOR_TPS68470) += tps68470-regulator.o 163 163 obj-$(CONFIG_REGULATOR_TWL4030) += twl-regulator.o twl6030-regulator.o 164 164 obj-$(CONFIG_REGULATOR_UNIPHIER) += uniphier-regulator.o 165 165 obj-$(CONFIG_REGULATOR_VCTRL) += vctrl-regulator.o
+4 -25
drivers/regulator/bd718x7-regulator.c
··· 125 125 126 126 return !!(BD718XX_BUCK_RUN_ON & val); 127 127 } 128 - /* 129 - * On BD71837 (not on BD71847, BD71850, ...) 130 - * Bucks 1 to 4 support DVS. PWM mode is used when voltage is changed. 131 - * Bucks 5 to 8 and LDOs can use PFM and must be disabled when voltage 132 - * is changed. Hence we return -EBUSY for these if voltage is changed 133 - * when BUCK/LDO is enabled. 134 - * 135 - * On BD71847, BD71850, ... The LDO voltage can be changed when LDO is 136 - * enabled. But if voltage is increased the LDO power-good monitoring 137 - * must be disabled for the duration of changing + 1mS to ensure voltage 138 - * has reached the higher level before HW does next under voltage detection 139 - * cycle. 140 - */ 141 - static int bd71837_set_voltage_sel_restricted(struct regulator_dev *rdev, 142 - unsigned int sel) 143 - { 144 - if (rdev->desc->ops->is_enabled(rdev)) 145 - return -EBUSY; 146 - 147 - return regulator_set_voltage_sel_regmap(rdev, sel); 148 - } 149 128 150 129 static void voltage_change_done(struct regulator_dev *rdev, unsigned int sel, 151 130 unsigned int *mask) ··· 621 642 bd718x7_set_buck_ovp); 622 643 623 644 BD718XX_OPS(bd71837_ldo_regulator_ops, regulator_list_voltage_linear_range, 624 - NULL, bd71837_set_voltage_sel_restricted, 645 + NULL, rohm_regulator_set_voltage_sel_restricted, 625 646 regulator_get_voltage_sel_regmap, NULL, NULL, bd718x7_set_ldo_uvp, 626 647 NULL); 627 648 628 649 BD718XX_OPS(bd71837_ldo_regulator_nolinear_ops, regulator_list_voltage_table, 629 - NULL, bd71837_set_voltage_sel_restricted, 650 + NULL, rohm_regulator_set_voltage_sel_restricted, 630 651 regulator_get_voltage_sel_regmap, NULL, NULL, bd718x7_set_ldo_uvp, 631 652 NULL); 632 653 633 654 BD718XX_OPS(bd71837_buck_regulator_ops, regulator_list_voltage_linear_range, 634 - NULL, bd71837_set_voltage_sel_restricted, 655 + NULL, rohm_regulator_set_voltage_sel_restricted, 635 656 regulator_get_voltage_sel_regmap, regulator_set_voltage_time_sel, 636 657 NULL, bd718x7_set_buck_uvp, bd718x7_set_buck_ovp); 637 658 638 659 BD718XX_OPS(bd71837_buck_regulator_nolinear_ops, regulator_list_voltage_table, 639 - regulator_map_voltage_ascend, bd71837_set_voltage_sel_restricted, 660 + regulator_map_voltage_ascend, rohm_regulator_set_voltage_sel_restricted, 640 661 regulator_get_voltage_sel_regmap, regulator_set_voltage_time_sel, 641 662 NULL, bd718x7_set_buck_uvp, bd718x7_set_buck_ovp); 642 663 /*
+112 -5
drivers/regulator/da9121-regulator.c
··· 86 86 .reg_max = 6, 87 87 }; 88 88 89 + static struct da9121_range da914x_40A_4phase_current = { 90 + .val_min = 14000000, 91 + .val_max = 80000000, 92 + .val_stp = 2000000, 93 + .reg_min = 1, 94 + .reg_max = 14, 95 + }; 96 + 97 + static struct da9121_range da914x_20A_2phase_current = { 98 + .val_min = 7000000, 99 + .val_max = 40000000, 100 + .val_stp = 2000000, 101 + .reg_min = 1, 102 + .reg_max = 14, 103 + }; 104 + 89 105 struct da9121_variant_info { 90 106 int num_bucks; 91 107 int num_phases; ··· 113 97 { 2, 1, &da9121_3A_1phase_current }, //DA9121_TYPE_DA9220_DA9132 114 98 { 2, 1, &da9121_5A_1phase_current }, //DA9121_TYPE_DA9122_DA9131 115 99 { 1, 2, &da9121_6A_2phase_current }, //DA9121_TYPE_DA9217 100 + { 1, 4, &da914x_40A_4phase_current }, //DA9121_TYPE_DA9141 101 + { 1, 2, &da914x_20A_2phase_current }, //DA9121_TYPE_DA9142 116 102 }; 117 103 118 104 struct da9121_field { ··· 268 250 if (min_ua < range->val_min || 269 251 max_ua > range->val_max) { 270 252 ret = -EINVAL; 253 + goto error; 254 + } 255 + 256 + if (rdev->desc->ops->is_enabled(rdev)) { 257 + ret = -EBUSY; 271 258 goto error; 272 259 } 273 260 ··· 560 537 .vsel_mask = DA9121_MASK_BUCK_BUCKx_5_CHx_A_VOUT, 561 538 }; 562 539 540 + #define DA914X_MIN_MV 500 541 + #define DA914X_MAX_MV 1000 542 + #define DA914X_STEP_MV 10 543 + #define DA914X_MIN_SEL (DA914X_MIN_MV / DA914X_STEP_MV) 544 + #define DA914X_N_VOLTAGES (((DA914X_MAX_MV - DA914X_MIN_MV) / DA914X_STEP_MV) \ 545 + + 1 + DA914X_MIN_SEL) 546 + 547 + static const struct regulator_desc da9141_reg = { 548 + .id = DA9121_IDX_BUCK1, 549 + .name = "DA9141", 550 + .of_match = "buck1", 551 + .of_parse_cb = da9121_of_parse_cb, 552 + .owner = THIS_MODULE, 553 + .regulators_node = of_match_ptr("regulators"), 554 + .of_map_mode = da9121_map_mode, 555 + .ops = &da9121_buck_ops, 556 + .type = REGULATOR_VOLTAGE, 557 + .n_voltages = DA914X_N_VOLTAGES, 558 + .min_uV = DA914X_MIN_MV * 1000, 559 + .uV_step = DA914X_STEP_MV * 1000, 560 + .linear_min_sel = DA914X_MIN_SEL, 561 + .vsel_reg = DA9121_REG_BUCK_BUCK1_5, 562 + .vsel_mask = DA9121_MASK_BUCK_BUCKx_5_CHx_A_VOUT, 563 + .enable_reg = DA9121_REG_BUCK_BUCK1_0, 564 + .enable_mask = DA9121_MASK_BUCK_BUCKx_0_CHx_EN, 565 + /* Default value of BUCK_BUCK1_0.CH1_SRC_DVC_UP */ 566 + .ramp_delay = 20000, 567 + /* tBUCK_EN */ 568 + .enable_time = 20, 569 + }; 570 + 571 + static const struct regulator_desc da9142_reg = { 572 + .id = DA9121_IDX_BUCK1, 573 + .name = "DA9142 BUCK1", 574 + .of_match = "buck1", 575 + .of_parse_cb = da9121_of_parse_cb, 576 + .owner = THIS_MODULE, 577 + .regulators_node = of_match_ptr("regulators"), 578 + .of_map_mode = da9121_map_mode, 579 + .ops = &da9121_buck_ops, 580 + .type = REGULATOR_VOLTAGE, 581 + .n_voltages = DA914X_N_VOLTAGES, 582 + .min_uV = DA914X_MIN_MV * 1000, 583 + .uV_step = DA914X_STEP_MV * 1000, 584 + .linear_min_sel = DA914X_MIN_SEL, 585 + .enable_reg = DA9121_REG_BUCK_BUCK1_0, 586 + .enable_mask = DA9121_MASK_BUCK_BUCKx_0_CHx_EN, 587 + .vsel_reg = DA9121_REG_BUCK_BUCK1_5, 588 + .vsel_mask = DA9121_MASK_BUCK_BUCKx_5_CHx_A_VOUT, 589 + }; 590 + 591 + 563 592 static const struct regulator_desc *local_da9121_regulators[][DA9121_IDX_MAX] = { 564 593 [DA9121_TYPE_DA9121_DA9130] = { &da9121_reg, NULL }, 565 594 [DA9121_TYPE_DA9220_DA9132] = { &da9220_reg[0], &da9220_reg[1] }, 566 595 [DA9121_TYPE_DA9122_DA9131] = { &da9122_reg[0], &da9122_reg[1] }, 567 596 [DA9121_TYPE_DA9217] = { &da9217_reg, NULL }, 597 + [DA9121_TYPE_DA9141] = { &da9141_reg, NULL }, 598 + [DA9121_TYPE_DA9142] = { &da9142_reg, NULL }, 568 599 }; 569 600 570 601 static void da9121_status_poll_on(struct work_struct *work) ··· 912 835 goto error; 913 836 } 914 837 915 - if (device_id != DA9121_DEVICE_ID) { 838 + if ((device_id != DA9121_DEVICE_ID) && (device_id != DA914x_DEVICE_ID)) { 916 839 dev_err(chip->dev, "Invalid device ID: 0x%02x\n", device_id); 917 840 ret = -ENODEV; 918 841 goto error; ··· 954 877 break; 955 878 } 956 879 880 + if (device_id == DA914x_DEVICE_ID) { 881 + switch (chip->subvariant_id) { 882 + case DA9121_SUBTYPE_DA9141: 883 + type = "DA9141"; 884 + config_match = (variant_vrc == DA9141_VARIANT_VRC); 885 + break; 886 + case DA9121_SUBTYPE_DA9142: 887 + type = "DA9142"; 888 + config_match = (variant_vrc == DA9142_VARIANT_VRC); 889 + break; 890 + default: 891 + type = "Unknown"; 892 + break; 893 + } 894 + } 895 + 957 896 dev_info(chip->dev, 958 897 "Device detected (device-ID: 0x%02X, var-ID: 0x%02X, %s)\n", 959 898 device_id, variant_id, type); ··· 983 890 variant_mrc = (variant_id & DA9121_MASK_OTP_VARIANT_ID_MRC) 984 891 >> DA9121_SHIFT_OTP_VARIANT_ID_MRC; 985 892 986 - if ((device_id == DA9121_DEVICE_ID) && 987 - (variant_mrc < DA9121_VARIANT_MRC_BASE)) { 893 + if (((device_id == DA9121_DEVICE_ID) && 894 + (variant_mrc < DA9121_VARIANT_MRC_BASE)) || 895 + ((device_id == DA914x_DEVICE_ID) && 896 + (variant_mrc != DA914x_VARIANT_MRC_BASE))) { 988 897 dev_err(chip->dev, 989 898 "Cannot support variant MRC: 0x%02X\n", variant_mrc); 990 899 ret = -EINVAL; ··· 1024 929 case DA9121_SUBTYPE_DA9220: 1025 930 case DA9121_SUBTYPE_DA9132: 1026 931 chip->variant_id = DA9121_TYPE_DA9220_DA9132; 932 + regmap = &da9121_2ch_regmap_config; 933 + break; 934 + case DA9121_SUBTYPE_DA9141: 935 + chip->variant_id = DA9121_TYPE_DA9141; 936 + regmap = &da9121_1ch_regmap_config; 937 + break; 938 + case DA9121_SUBTYPE_DA9142: 939 + chip->variant_id = DA9121_TYPE_DA9142; 1027 940 regmap = &da9121_2ch_regmap_config; 1028 941 break; 1029 942 } ··· 1113 1010 { .compatible = "dlg,da9131", .data = (void *) DA9121_SUBTYPE_DA9131 }, 1114 1011 { .compatible = "dlg,da9220", .data = (void *) DA9121_SUBTYPE_DA9220 }, 1115 1012 { .compatible = "dlg,da9132", .data = (void *) DA9121_SUBTYPE_DA9132 }, 1013 + { .compatible = "dlg,da9141", .data = (void *) DA9121_SUBTYPE_DA9141 }, 1014 + { .compatible = "dlg,da9142", .data = (void *) DA9121_SUBTYPE_DA9142 }, 1116 1015 { } 1117 1016 }; 1118 1017 MODULE_DEVICE_TABLE(of, da9121_dt_ids); ··· 1170 1065 { 1171 1066 struct da9121 *chip = i2c_get_clientdata(i2c); 1172 1067 const int mask_all[4] = { 0xFF, 0xFF, 0xFF, 0xFF }; 1173 - int ret = 0; 1068 + int ret; 1174 1069 1175 1070 free_irq(chip->chip_irq, chip); 1176 1071 cancel_delayed_work_sync(&chip->work); ··· 1178 1073 ret = regmap_bulk_write(chip->regmap, DA9121_REG_SYS_MASK_0, mask_all, 4); 1179 1074 if (ret != 0) 1180 1075 dev_err(chip->dev, "Failed to set IRQ masks: %d\n", ret); 1181 - return ret; 1076 + return 0; 1182 1077 } 1183 1078 1184 1079 static const struct i2c_device_id da9121_i2c_id[] = { ··· 1189 1084 {"da9131", DA9121_TYPE_DA9122_DA9131}, 1190 1085 {"da9220", DA9121_TYPE_DA9220_DA9132}, 1191 1086 {"da9132", DA9121_TYPE_DA9220_DA9132}, 1087 + {"da9141", DA9121_TYPE_DA9141}, 1088 + {"da9142", DA9121_TYPE_DA9142}, 1192 1089 {}, 1193 1090 }; 1194 1091 MODULE_DEVICE_TABLE(i2c, da9121_i2c_id);
+19 -2
drivers/regulator/da9121-regulator.h
··· 26 26 DA9121_TYPE_DA9121_DA9130, 27 27 DA9121_TYPE_DA9220_DA9132, 28 28 DA9121_TYPE_DA9122_DA9131, 29 - DA9121_TYPE_DA9217 29 + DA9121_TYPE_DA9217, 30 + DA9121_TYPE_DA9141, 31 + DA9121_TYPE_DA9142 30 32 }; 31 33 32 34 enum da9121_subvariant { ··· 38 36 DA9121_SUBTYPE_DA9132, 39 37 DA9121_SUBTYPE_DA9122, 40 38 DA9121_SUBTYPE_DA9131, 41 - DA9121_SUBTYPE_DA9217 39 + DA9121_SUBTYPE_DA9217, 40 + DA9121_SUBTYPE_DA9141, 41 + DA9121_SUBTYPE_DA9142 42 42 }; 43 43 44 44 /* Minimum, maximum and default polling millisecond periods are provided ··· 74 70 #define DA9121_REG_SYS_GPIO1_1 0x13 75 71 #define DA9121_REG_SYS_GPIO2_0 0x14 76 72 #define DA9121_REG_SYS_GPIO2_1 0x15 73 + #define DA914x_REG_SYS_GPIO3_0 0x16 74 + #define DA914x_REG_SYS_GPIO3_1 0x17 75 + #define DA914x_REG_SYS_GPIO4_0 0x18 76 + #define DA914x_REG_SYS_GPIO4_1 0x19 77 + #define DA914x_REG_SYS_ADMUX1_0 0x1A 78 + #define DA914x_REG_SYS_ADMUX1_1 0x1B 79 + #define DA914x_REG_SYS_ADMUX2_0 0x1C 80 + #define DA914x_REG_SYS_ADMUX2_1 0x1D 77 81 #define DA9121_REG_BUCK_BUCK1_0 0x20 78 82 #define DA9121_REG_BUCK_BUCK1_1 0x21 79 83 #define DA9121_REG_BUCK_BUCK1_2 0x22 ··· 288 276 #define DA9121_MASK_OTP_DEVICE_ID_DEV_ID 0xFF 289 277 290 278 #define DA9121_DEVICE_ID 0x05 279 + #define DA914x_DEVICE_ID 0x26 291 280 292 281 /* DA9121_REG_OTP_VARIANT_ID */ 293 282 ··· 305 292 #define DA9130_VARIANT_VRC 0x0 306 293 #define DA9131_VARIANT_VRC 0x1 307 294 #define DA9132_VARIANT_VRC 0x2 295 + 296 + #define DA914x_VARIANT_MRC_BASE 0x0 297 + #define DA9141_VARIANT_VRC 0x1 298 + #define DA9142_VARIANT_VRC 0x2 308 299 309 300 /* DA9121_REG_OTP_CUSTOMER_ID */ 310 301
+40 -1
drivers/regulator/irq_helpers.c
··· 320 320 * IRQF_ONESHOT when requesting the (threaded) irq. 321 321 * @common_errs: Errors which can be flagged by this IRQ for all rdevs. 322 322 * When IRQ is re-enabled these errors will be cleared 323 - * from all associated regulators 323 + * from all associated regulators. Use this instead of the 324 + * per_rdev_errs if you use 325 + * regulator_irq_map_event_simple() for event mapping. 324 326 * @per_rdev_errs: Optional error flag array describing errors specific 325 327 * for only some of the regulators. These errors will be 326 328 * or'ed with common errors. If this is given the array ··· 397 395 } 398 396 } 399 397 EXPORT_SYMBOL_GPL(regulator_irq_helper_cancel); 398 + 399 + /** 400 + * regulator_irq_map_event_simple - regulator IRQ notification for trivial IRQs 401 + * 402 + * @irq: Number of IRQ that occurred 403 + * @rid: Information about the event IRQ indicates 404 + * @dev_mask: mask indicating the regulator originating the IRQ 405 + * 406 + * Regulators whose IRQ has single, well defined purpose (always indicate 407 + * exactly one event, and are relevant to exactly one regulator device) can 408 + * use this function as their map_event callbac for their regulator IRQ 409 + * notification helperk. Exactly one rdev and exactly one error (in 410 + * "common_errs"-field) can be given at IRQ helper registration for 411 + * regulator_irq_map_event_simple() to be viable. 412 + */ 413 + int regulator_irq_map_event_simple(int irq, struct regulator_irq_data *rid, 414 + unsigned long *dev_mask) 415 + { 416 + int err = rid->states[0].possible_errs; 417 + 418 + *dev_mask = 1; 419 + /* 420 + * This helper should only be used in a situation where the IRQ 421 + * can indicate only one type of problem for one specific rdev. 422 + * Something fishy is going on if we are having multiple rdevs or ERROR 423 + * flags here. 424 + */ 425 + if (WARN_ON(rid->num_states != 1 || hweight32(err) != 1)) 426 + return 0; 427 + 428 + rid->states[0].errors = err; 429 + rid->states[0].notifs = regulator_err2notif(err); 430 + 431 + return 0; 432 + } 433 + EXPORT_SYMBOL_GPL(regulator_irq_map_event_simple); 434 +
+332
drivers/regulator/max20086-regulator.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-or-later 2 + // 3 + // max20086-regulator.c - MAX20086-MAX20089 camera power protector driver 4 + // 5 + // Copyright (C) 2022 Laurent Pinchart <laurent.pinchart@idesonboard.com> 6 + // Copyright (C) 2018 Avnet, Inc. 7 + 8 + #include <linux/err.h> 9 + #include <linux/gpio.h> 10 + #include <linux/i2c.h> 11 + #include <linux/module.h> 12 + #include <linux/regmap.h> 13 + #include <linux/regulator/driver.h> 14 + #include <linux/regulator/machine.h> 15 + #include <linux/regulator/of_regulator.h> 16 + #include <linux/slab.h> 17 + 18 + /* Register Offset */ 19 + #define MAX20086_REG_MASK 0x00 20 + #define MAX20086_REG_CONFIG 0x01 21 + #define MAX20086_REG_ID 0x02 22 + #define MAX20086_REG_STAT1 0x03 23 + #define MAX20086_REG_STAT2_L 0x04 24 + #define MAX20086_REG_STAT2_H 0x05 25 + #define MAX20086_REG_ADC1 0x06 26 + #define MAX20086_REG_ADC2 0x07 27 + #define MAX20086_REG_ADC3 0x08 28 + #define MAX20086_REG_ADC4 0x09 29 + 30 + /* DEVICE IDs */ 31 + #define MAX20086_DEVICE_ID_MAX20086 0x40 32 + #define MAX20086_DEVICE_ID_MAX20087 0x20 33 + #define MAX20086_DEVICE_ID_MAX20088 0x10 34 + #define MAX20086_DEVICE_ID_MAX20089 0x00 35 + #define DEVICE_ID_MASK 0xf0 36 + 37 + /* Register bits */ 38 + #define MAX20086_EN_MASK 0x0f 39 + #define MAX20086_EN_OUT1 0x01 40 + #define MAX20086_EN_OUT2 0x02 41 + #define MAX20086_EN_OUT3 0x04 42 + #define MAX20086_EN_OUT4 0x08 43 + #define MAX20086_INT_DISABLE_ALL 0x3f 44 + 45 + #define MAX20086_MAX_REGULATORS 4 46 + 47 + struct max20086_chip_info { 48 + u8 id; 49 + unsigned int num_outputs; 50 + }; 51 + 52 + struct max20086_regulator { 53 + struct device_node *of_node; 54 + struct regulator_init_data *init_data; 55 + const struct regulator_desc *desc; 56 + struct regulator_dev *rdev; 57 + }; 58 + 59 + struct max20086 { 60 + struct device *dev; 61 + struct regmap *regmap; 62 + struct gpio_desc *ena_gpiod; 63 + 64 + const struct max20086_chip_info *info; 65 + 66 + struct max20086_regulator regulators[MAX20086_MAX_REGULATORS]; 67 + }; 68 + 69 + static const struct regulator_ops max20086_buck_ops = { 70 + .enable = regulator_enable_regmap, 71 + .disable = regulator_disable_regmap, 72 + .is_enabled = regulator_is_enabled_regmap, 73 + }; 74 + 75 + #define MAX20086_REGULATOR_DESC(n) \ 76 + { \ 77 + .name = "OUT"#n, \ 78 + .supply_name = "in", \ 79 + .id = (n) - 1, \ 80 + .ops = &max20086_buck_ops, \ 81 + .type = REGULATOR_VOLTAGE, \ 82 + .owner = THIS_MODULE, \ 83 + .enable_reg = MAX20086_REG_CONFIG, \ 84 + .enable_mask = 1 << ((n) - 1), \ 85 + .enable_val = 1 << ((n) - 1), \ 86 + .disable_val = 0, \ 87 + } 88 + 89 + static const char * const max20086_output_names[] = { 90 + "OUT1", 91 + "OUT2", 92 + "OUT3", 93 + "OUT4", 94 + }; 95 + 96 + static const struct regulator_desc max20086_regulators[] = { 97 + MAX20086_REGULATOR_DESC(1), 98 + MAX20086_REGULATOR_DESC(2), 99 + MAX20086_REGULATOR_DESC(3), 100 + MAX20086_REGULATOR_DESC(4), 101 + }; 102 + 103 + static int max20086_regulators_register(struct max20086 *chip) 104 + { 105 + unsigned int i; 106 + 107 + for (i = 0; i < chip->info->num_outputs; i++) { 108 + struct max20086_regulator *reg = &chip->regulators[i]; 109 + struct regulator_config config = { }; 110 + struct regulator_dev *rdev; 111 + 112 + config.dev = chip->dev; 113 + config.init_data = reg->init_data; 114 + config.driver_data = chip; 115 + config.of_node = reg->of_node; 116 + config.regmap = chip->regmap; 117 + config.ena_gpiod = chip->ena_gpiod; 118 + 119 + rdev = devm_regulator_register(chip->dev, reg->desc, &config); 120 + if (IS_ERR(rdev)) { 121 + dev_err(chip->dev, 122 + "Failed to register regulator output %s\n", 123 + reg->desc->name); 124 + return PTR_ERR(rdev); 125 + } 126 + 127 + reg->rdev = rdev; 128 + } 129 + 130 + return 0; 131 + } 132 + 133 + static int max20086_parse_regulators_dt(struct max20086 *chip, bool *boot_on) 134 + { 135 + struct of_regulator_match matches[MAX20086_MAX_REGULATORS] = { }; 136 + struct device_node *node; 137 + unsigned int i; 138 + int ret; 139 + 140 + node = of_get_child_by_name(chip->dev->of_node, "regulators"); 141 + if (!node) { 142 + dev_err(chip->dev, "regulators node not found\n"); 143 + return PTR_ERR(node); 144 + } 145 + 146 + for (i = 0; i < chip->info->num_outputs; ++i) 147 + matches[i].name = max20086_output_names[i]; 148 + 149 + ret = of_regulator_match(chip->dev, node, matches, 150 + chip->info->num_outputs); 151 + of_node_put(node); 152 + if (ret < 0) { 153 + dev_err(chip->dev, "Failed to match regulators\n"); 154 + return -EINVAL; 155 + } 156 + 157 + *boot_on = false; 158 + 159 + for (i = 0; i < chip->info->num_outputs; i++) { 160 + struct max20086_regulator *reg = &chip->regulators[i]; 161 + 162 + reg->init_data = matches[i].init_data; 163 + reg->of_node = matches[i].of_node; 164 + reg->desc = &max20086_regulators[i]; 165 + 166 + if (reg->init_data) { 167 + if (reg->init_data->constraints.always_on || 168 + reg->init_data->constraints.boot_on) 169 + *boot_on = true; 170 + } 171 + } 172 + 173 + return 0; 174 + } 175 + 176 + static int max20086_detect(struct max20086 *chip) 177 + { 178 + unsigned int data; 179 + int ret; 180 + 181 + ret = regmap_read(chip->regmap, MAX20086_REG_ID, &data); 182 + if (ret < 0) { 183 + dev_err(chip->dev, "Failed to read DEVICE_ID reg: %d\n", ret); 184 + return ret; 185 + } 186 + 187 + if ((data & DEVICE_ID_MASK) != chip->info->id) { 188 + dev_err(chip->dev, "Invalid device ID 0x%02x\n", data); 189 + return -ENXIO; 190 + } 191 + 192 + return 0; 193 + } 194 + 195 + static bool max20086_gen_is_writeable_reg(struct device *dev, unsigned int reg) 196 + { 197 + switch (reg) { 198 + case MAX20086_REG_MASK: 199 + case MAX20086_REG_CONFIG: 200 + return true; 201 + default: 202 + return false; 203 + } 204 + } 205 + 206 + static const struct regmap_config max20086_regmap_config = { 207 + .reg_bits = 8, 208 + .val_bits = 8, 209 + .writeable_reg = max20086_gen_is_writeable_reg, 210 + .max_register = 0x9, 211 + .cache_type = REGCACHE_NONE, 212 + }; 213 + 214 + static int max20086_i2c_probe(struct i2c_client *i2c) 215 + { 216 + struct max20086 *chip; 217 + enum gpiod_flags flags; 218 + bool boot_on; 219 + int ret; 220 + 221 + chip = devm_kzalloc(&i2c->dev, sizeof(*chip), GFP_KERNEL); 222 + if (!chip) 223 + return -ENOMEM; 224 + 225 + chip->dev = &i2c->dev; 226 + chip->info = device_get_match_data(chip->dev); 227 + 228 + i2c_set_clientdata(i2c, chip); 229 + 230 + chip->regmap = devm_regmap_init_i2c(i2c, &max20086_regmap_config); 231 + if (IS_ERR(chip->regmap)) { 232 + ret = PTR_ERR(chip->regmap); 233 + dev_err(chip->dev, "Failed to allocate register map: %d\n", ret); 234 + return ret; 235 + } 236 + 237 + ret = max20086_parse_regulators_dt(chip, &boot_on); 238 + if (ret < 0) 239 + return ret; 240 + 241 + ret = max20086_detect(chip); 242 + if (ret < 0) 243 + return ret; 244 + 245 + /* Until IRQ support is added, just disable all interrupts. */ 246 + ret = regmap_update_bits(chip->regmap, MAX20086_REG_MASK, 247 + MAX20086_INT_DISABLE_ALL, 248 + MAX20086_INT_DISABLE_ALL); 249 + if (ret < 0) { 250 + dev_err(chip->dev, "Failed to disable interrupts: %d\n", ret); 251 + return ret; 252 + } 253 + 254 + /* 255 + * Get the enable GPIO. If any of the outputs is marked as being 256 + * enabled at boot, request the GPIO with an initial high state to 257 + * avoid disabling outputs that may have been turned on by the boot 258 + * loader. Otherwise, request it with a low state to enter lower-power 259 + * shutdown. 260 + */ 261 + flags = boot_on ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW; 262 + chip->ena_gpiod = devm_gpiod_get(chip->dev, "enable", flags); 263 + if (IS_ERR(chip->ena_gpiod)) { 264 + ret = PTR_ERR(chip->ena_gpiod); 265 + dev_err(chip->dev, "Failed to get enable GPIO: %d\n", ret); 266 + return ret; 267 + } 268 + 269 + ret = max20086_regulators_register(chip); 270 + if (ret < 0) { 271 + dev_err(chip->dev, "Failed to register regulators: %d\n", ret); 272 + return ret; 273 + } 274 + 275 + return 0; 276 + } 277 + 278 + static const struct i2c_device_id max20086_i2c_id[] = { 279 + { "max20086" }, 280 + { "max20087" }, 281 + { "max20088" }, 282 + { "max20089" }, 283 + { /* Sentinel */ }, 284 + }; 285 + 286 + MODULE_DEVICE_TABLE(i2c, max20086_i2c_id); 287 + 288 + static const struct of_device_id max20086_dt_ids[] = { 289 + { 290 + .compatible = "maxim,max20086", 291 + .data = &(const struct max20086_chip_info) { 292 + .id = MAX20086_DEVICE_ID_MAX20086, 293 + .num_outputs = 4, 294 + } 295 + }, { 296 + .compatible = "maxim,max20087", 297 + .data = &(const struct max20086_chip_info) { 298 + .id = MAX20086_DEVICE_ID_MAX20087, 299 + .num_outputs = 4, 300 + } 301 + }, { 302 + .compatible = "maxim,max20088", 303 + .data = &(const struct max20086_chip_info) { 304 + .id = MAX20086_DEVICE_ID_MAX20088, 305 + .num_outputs = 2, 306 + } 307 + }, { 308 + .compatible = "maxim,max20089", 309 + .data = &(const struct max20086_chip_info) { 310 + .id = MAX20086_DEVICE_ID_MAX20089, 311 + .num_outputs = 2, 312 + } 313 + }, 314 + { /* Sentinel */ }, 315 + }; 316 + 317 + MODULE_DEVICE_TABLE(of, max20086_dt_ids); 318 + 319 + static struct i2c_driver max20086_regulator_driver = { 320 + .driver = { 321 + .name = "max20086", 322 + .of_match_table = of_match_ptr(max20086_dt_ids), 323 + }, 324 + .probe_new = max20086_i2c_probe, 325 + .id_table = max20086_i2c_id, 326 + }; 327 + 328 + module_i2c_driver(max20086_regulator_driver); 329 + 330 + MODULE_AUTHOR("Watson Chow <watson.chow@avnet.com>"); 331 + MODULE_DESCRIPTION("MAX20086-MAX20089 Camera Power Protector Driver"); 332 + MODULE_LICENSE("GPL");
+2 -4
drivers/regulator/mt6380-regulator.c
··· 183 183 static int mt6380_regulator_set_mode(struct regulator_dev *rdev, 184 184 unsigned int mode) 185 185 { 186 - int ret, val = 0; 186 + int val = 0; 187 187 struct mt6380_regulator_info *info = rdev_get_drvdata(rdev); 188 188 189 189 switch (mode) { ··· 199 199 200 200 val <<= ffs(info->modeset_mask) - 1; 201 201 202 - ret = regmap_update_bits(rdev->regmap, info->modeset_reg, 202 + return regmap_update_bits(rdev->regmap, info->modeset_reg, 203 203 info->modeset_mask, val); 204 - 205 - return ret; 206 204 } 207 205 208 206 static unsigned int mt6380_regulator_get_mode(struct regulator_dev *rdev)
+1 -1
drivers/regulator/qcom-labibb-regulator.c
··· 260 260 261 261 /* If the regulator is not enabled, this is a fake event */ 262 262 if (!ops->is_enabled(vreg->rdev)) 263 - return 0; 263 + return IRQ_HANDLED; 264 264 265 265 /* If we tried to recover for too many times it's not getting better */ 266 266 if (vreg->ocp_irq_count > LABIBB_MAX_OCP_COUNT)
+27
drivers/regulator/qcom-rpmh-regulator.c
··· 814 814 {} 815 815 }; 816 816 817 + static const struct rpmh_vreg_init_data pmg1110_vreg_data[] = { 818 + RPMH_VREG("smps1", "smp%s1", &pmic5_ftsmps510, "vdd-s1"), 819 + {} 820 + }; 821 + 817 822 static const struct rpmh_vreg_init_data pmi8998_vreg_data[] = { 818 823 RPMH_VREG("bob", "bob%s1", &pmic4_bob, "vdd-bob"), 819 824 {} ··· 971 966 RPMH_VREG("ldo12", "ldo%s12", &pmic5_pldo_lv, "vdd-l1-l12"), 972 967 RPMH_VREG("ldo13", "ldo%s13", &pmic5_pldo, "vdd-l3-l4-l5-l7-l13"), 973 968 RPMH_VREG("bob", "bob%s1", &pmic5_bob, "vdd-bob"), 969 + {} 970 + }; 971 + 972 + static const struct rpmh_vreg_init_data pm8450_vreg_data[] = { 973 + RPMH_VREG("smps1", "smp%s1", &pmic5_ftsmps520, "vdd-s1"), 974 + RPMH_VREG("smps2", "smp%s2", &pmic5_ftsmps520, "vdd-s2"), 975 + RPMH_VREG("smps3", "smp%s3", &pmic5_ftsmps520, "vdd-s3"), 976 + RPMH_VREG("smps4", "smp%s4", &pmic5_ftsmps520, "vdd-s4"), 977 + RPMH_VREG("smps5", "smp%s5", &pmic5_ftsmps520, "vdd-s5"), 978 + RPMH_VREG("smps6", "smp%s6", &pmic5_ftsmps520, "vdd-s6"), 979 + RPMH_VREG("ldo1", "ldo%s1", &pmic5_nldo, "vdd-l1"), 980 + RPMH_VREG("ldo2", "ldo%s2", &pmic5_nldo, "vdd-l2"), 981 + RPMH_VREG("ldo3", "ldo%s3", &pmic5_nldo, "vdd-l3"), 982 + RPMH_VREG("ldo4", "ldo%s4", &pmic5_pldo_lv, "vdd-l4"), 974 983 {} 975 984 }; 976 985 ··· 1233 1214 .data = pm8350c_vreg_data, 1234 1215 }, 1235 1216 { 1217 + .compatible = "qcom,pm8450-rpmh-regulators", 1218 + .data = pm8450_vreg_data, 1219 + }, 1220 + { 1236 1221 .compatible = "qcom,pm8998-rpmh-regulators", 1237 1222 .data = pm8998_vreg_data, 1223 + }, 1224 + { 1225 + .compatible = "qcom,pmg1110-rpmh-regulators", 1226 + .data = pmg1110_vreg_data, 1238 1227 }, 1239 1228 { 1240 1229 .compatible = "qcom,pmi8998-rpmh-regulators",
+69 -29
drivers/regulator/qcom_smd-regulator.c
··· 9 9 #include <linux/of_device.h> 10 10 #include <linux/platform_device.h> 11 11 #include <linux/regulator/driver.h> 12 + #include <linux/regulator/of_regulator.h> 12 13 #include <linux/soc/qcom/smd-rpm.h> 13 14 14 15 struct qcom_rpm_reg { ··· 1240 1239 }; 1241 1240 MODULE_DEVICE_TABLE(of, rpm_of_match); 1242 1241 1242 + /** 1243 + * rpm_regulator_init_vreg() - initialize all attributes of a qcom_smd-regulator 1244 + * @vreg: Pointer to the individual qcom_smd-regulator resource 1245 + * @dev: Pointer to the top level qcom_smd-regulator PMIC device 1246 + * @node: Pointer to the individual qcom_smd-regulator resource 1247 + * device node 1248 + * @rpm: Pointer to the rpm bus node 1249 + * @pmic_rpm_data: Pointer to a null-terminated array of qcom_smd-regulator 1250 + * resources defined for the top level PMIC device 1251 + * 1252 + * Return: 0 on success, errno on failure 1253 + */ 1254 + static int rpm_regulator_init_vreg(struct qcom_rpm_reg *vreg, struct device *dev, 1255 + struct device_node *node, struct qcom_smd_rpm *rpm, 1256 + const struct rpm_regulator_data *pmic_rpm_data) 1257 + { 1258 + struct regulator_config config = {}; 1259 + const struct rpm_regulator_data *rpm_data; 1260 + struct regulator_dev *rdev; 1261 + int ret; 1262 + 1263 + for (rpm_data = pmic_rpm_data; rpm_data->name; rpm_data++) 1264 + if (of_node_name_eq(node, rpm_data->name)) 1265 + break; 1266 + 1267 + if (!rpm_data->name) { 1268 + dev_err(dev, "Unknown regulator %pOFn\n", node); 1269 + return -EINVAL; 1270 + } 1271 + 1272 + vreg->dev = dev; 1273 + vreg->rpm = rpm; 1274 + vreg->type = rpm_data->type; 1275 + vreg->id = rpm_data->id; 1276 + 1277 + memcpy(&vreg->desc, rpm_data->desc, sizeof(vreg->desc)); 1278 + vreg->desc.name = rpm_data->name; 1279 + vreg->desc.supply_name = rpm_data->supply; 1280 + vreg->desc.owner = THIS_MODULE; 1281 + vreg->desc.type = REGULATOR_VOLTAGE; 1282 + vreg->desc.of_match = rpm_data->name; 1283 + 1284 + config.dev = dev; 1285 + config.of_node = node; 1286 + config.driver_data = vreg; 1287 + 1288 + rdev = devm_regulator_register(dev, &vreg->desc, &config); 1289 + if (IS_ERR(rdev)) { 1290 + ret = PTR_ERR(rdev); 1291 + dev_err(dev, "%pOFn: devm_regulator_register() failed, ret=%d\n", node, ret); 1292 + return ret; 1293 + } 1294 + 1295 + return 0; 1296 + } 1297 + 1243 1298 static int rpm_reg_probe(struct platform_device *pdev) 1244 1299 { 1245 - const struct rpm_regulator_data *reg; 1246 - const struct of_device_id *match; 1247 - struct regulator_config config = { }; 1248 - struct regulator_dev *rdev; 1300 + struct device *dev = &pdev->dev; 1301 + const struct rpm_regulator_data *vreg_data; 1302 + struct device_node *node; 1249 1303 struct qcom_rpm_reg *vreg; 1250 1304 struct qcom_smd_rpm *rpm; 1305 + int ret; 1251 1306 1252 1307 rpm = dev_get_drvdata(pdev->dev.parent); 1253 1308 if (!rpm) { 1254 - dev_err(&pdev->dev, "unable to retrieve handle to rpm\n"); 1309 + dev_err(&pdev->dev, "Unable to retrieve handle to rpm\n"); 1255 1310 return -ENODEV; 1256 1311 } 1257 1312 1258 - match = of_match_device(rpm_of_match, &pdev->dev); 1259 - if (!match) { 1260 - dev_err(&pdev->dev, "failed to match device\n"); 1313 + vreg_data = of_device_get_match_data(dev); 1314 + if (!vreg_data) 1261 1315 return -ENODEV; 1262 - } 1263 1316 1264 - for (reg = match->data; reg->name; reg++) { 1317 + for_each_available_child_of_node(dev->of_node, node) { 1265 1318 vreg = devm_kzalloc(&pdev->dev, sizeof(*vreg), GFP_KERNEL); 1266 1319 if (!vreg) 1267 1320 return -ENOMEM; 1268 1321 1269 - vreg->dev = &pdev->dev; 1270 - vreg->type = reg->type; 1271 - vreg->id = reg->id; 1272 - vreg->rpm = rpm; 1322 + ret = rpm_regulator_init_vreg(vreg, dev, node, rpm, vreg_data); 1273 1323 1274 - memcpy(&vreg->desc, reg->desc, sizeof(vreg->desc)); 1275 - 1276 - vreg->desc.id = -1; 1277 - vreg->desc.owner = THIS_MODULE; 1278 - vreg->desc.type = REGULATOR_VOLTAGE; 1279 - vreg->desc.name = reg->name; 1280 - vreg->desc.supply_name = reg->supply; 1281 - vreg->desc.of_match = reg->name; 1282 - 1283 - config.dev = &pdev->dev; 1284 - config.driver_data = vreg; 1285 - rdev = devm_regulator_register(&pdev->dev, &vreg->desc, &config); 1286 - if (IS_ERR(rdev)) { 1287 - dev_err(&pdev->dev, "failed to register %s\n", reg->name); 1288 - return PTR_ERR(rdev); 1324 + if (ret < 0) { 1325 + of_node_put(node); 1326 + return ret; 1289 1327 } 1290 1328 } 1291 1329
+39
drivers/regulator/qcom_spmi-regulator.c
··· 1895 1895 { } 1896 1896 }; 1897 1897 1898 + static const struct spmi_regulator_data pm8226_regulators[] = { 1899 + { "s1", 0x1400, "vdd_s1", }, 1900 + { "s2", 0x1700, "vdd_s2", }, 1901 + { "s3", 0x1a00, "vdd_s3", }, 1902 + { "s4", 0x1d00, "vdd_s4", }, 1903 + { "s5", 0x2000, "vdd_s5", }, 1904 + { "l1", 0x4000, "vdd_l1_l2_l4_l5", }, 1905 + { "l2", 0x4100, "vdd_l1_l2_l4_l5", }, 1906 + { "l3", 0x4200, "vdd_l3_l24_l26", }, 1907 + { "l4", 0x4300, "vdd_l1_l2_l4_l5", }, 1908 + { "l5", 0x4400, "vdd_l1_l2_l4_l5", }, 1909 + { "l6", 0x4500, "vdd_l6_l7_l8_l9_l27", }, 1910 + { "l7", 0x4600, "vdd_l6_l7_l8_l9_l27", }, 1911 + { "l8", 0x4700, "vdd_l6_l7_l8_l9_l27", }, 1912 + { "l9", 0x4800, "vdd_l6_l7_l8_l9_l27", }, 1913 + { "l10", 0x4900, "vdd_l10_l11_l13", }, 1914 + { "l11", 0x4a00, "vdd_l10_l11_l13", }, 1915 + { "l12", 0x4b00, "vdd_l12_l14", }, 1916 + { "l13", 0x4c00, "vdd_l10_l11_l13", }, 1917 + { "l14", 0x4d00, "vdd_l12_l14", }, 1918 + { "l15", 0x4e00, "vdd_l15_l16_l17_l18", }, 1919 + { "l16", 0x4f00, "vdd_l15_l16_l17_l18", }, 1920 + { "l17", 0x5000, "vdd_l15_l16_l17_l18", }, 1921 + { "l18", 0x5100, "vdd_l15_l16_l17_l18", }, 1922 + { "l19", 0x5200, "vdd_l19_l20_l21_l22_l23_l28", }, 1923 + { "l20", 0x5300, "vdd_l19_l20_l21_l22_l23_l28", }, 1924 + { "l21", 0x5400, "vdd_l19_l20_l21_l22_l23_l28", }, 1925 + { "l22", 0x5500, "vdd_l19_l20_l21_l22_l23_l28", }, 1926 + { "l23", 0x5600, "vdd_l19_l20_l21_l22_l23_l28", }, 1927 + { "l24", 0x5700, "vdd_l3_l24_l26", }, 1928 + { "l25", 0x5800, "vdd_l25", }, 1929 + { "l26", 0x5900, "vdd_l3_l24_l26", }, 1930 + { "l27", 0x5a00, "vdd_l6_l7_l8_l9_l27", }, 1931 + { "l28", 0x5b00, "vdd_l19_l20_l21_l22_l23_l28", }, 1932 + { "lvs1", 0x8000, "vdd_lvs1", }, 1933 + { } 1934 + }; 1935 + 1898 1936 static const struct spmi_regulator_data pm8841_regulators[] = { 1899 1937 { "s1", 0x1400, "vdd_s1", }, 1900 1938 { "s2", 0x1700, "vdd_s2", NULL, 0x1c08 }, ··· 2133 2095 static const struct of_device_id qcom_spmi_regulator_match[] = { 2134 2096 { .compatible = "qcom,pm8004-regulators", .data = &pm8004_regulators }, 2135 2097 { .compatible = "qcom,pm8005-regulators", .data = &pm8005_regulators }, 2098 + { .compatible = "qcom,pm8226-regulators", .data = &pm8226_regulators }, 2136 2099 { .compatible = "qcom,pm8841-regulators", .data = &pm8841_regulators }, 2137 2100 { .compatible = "qcom,pm8916-regulators", .data = &pm8916_regulators }, 2138 2101 { .compatible = "qcom,pm8941-regulators", .data = &pm8941_regulators },
+16
drivers/regulator/rohm-regulator.c
··· 112 112 } 113 113 EXPORT_SYMBOL(rohm_regulator_set_dvs_levels); 114 114 115 + /* 116 + * Few ROHM PMIC ICs have constrains on voltage changing: 117 + * BD71837 - only buck 1-4 voltages can be changed when they are enabled. 118 + * Other bucks and all LDOs must be disabled when voltage is changed. 119 + * BD96801 - LDO voltage levels can be changed when LDOs are disabled. 120 + */ 121 + int rohm_regulator_set_voltage_sel_restricted(struct regulator_dev *rdev, 122 + unsigned int sel) 123 + { 124 + if (rdev->desc->ops->is_enabled(rdev)) 125 + return -EBUSY; 126 + 127 + return regulator_set_voltage_sel_regmap(rdev, sel); 128 + } 129 + EXPORT_SYMBOL_GPL(rohm_regulator_set_voltage_sel_restricted); 130 + 115 131 MODULE_LICENSE("GPL v2"); 116 132 MODULE_AUTHOR("Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>"); 117 133 MODULE_DESCRIPTION("Generic helpers for ROHM PMIC regulator drivers");
+201
drivers/regulator/tps68470-regulator.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + // 3 + // Regulator driver for TPS68470 PMIC 4 + // 5 + // Copyright (c) 2021 Red Hat Inc. 6 + // Copyright (C) 2018 Intel Corporation 7 + // 8 + // Authors: 9 + // Hans de Goede <hdegoede@redhat.com> 10 + // Zaikuo Wang <zaikuo.wang@intel.com> 11 + // Tianshu Qiu <tian.shu.qiu@intel.com> 12 + // Jian Xu Zheng <jian.xu.zheng@intel.com> 13 + // Yuning Pu <yuning.pu@intel.com> 14 + // Rajmohan Mani <rajmohan.mani@intel.com> 15 + 16 + #include <linux/clk.h> 17 + #include <linux/device.h> 18 + #include <linux/err.h> 19 + #include <linux/init.h> 20 + #include <linux/kernel.h> 21 + #include <linux/mfd/tps68470.h> 22 + #include <linux/module.h> 23 + #include <linux/platform_data/tps68470.h> 24 + #include <linux/platform_device.h> 25 + #include <linux/regulator/driver.h> 26 + #include <linux/regulator/machine.h> 27 + 28 + struct tps68470_regulator_data { 29 + struct clk *clk; 30 + }; 31 + 32 + #define TPS68470_REGULATOR(_name, _id, _ops, _n, \ 33 + _vr, _vm, _er, _em, _lr, _nlr) \ 34 + [TPS68470_ ## _name] = { \ 35 + .name = # _name, \ 36 + .id = _id, \ 37 + .ops = &_ops, \ 38 + .n_voltages = _n, \ 39 + .type = REGULATOR_VOLTAGE, \ 40 + .owner = THIS_MODULE, \ 41 + .vsel_reg = _vr, \ 42 + .vsel_mask = _vm, \ 43 + .enable_reg = _er, \ 44 + .enable_mask = _em, \ 45 + .linear_ranges = _lr, \ 46 + .n_linear_ranges = _nlr, \ 47 + } 48 + 49 + static const struct linear_range tps68470_ldo_ranges[] = { 50 + REGULATOR_LINEAR_RANGE(875000, 0, 125, 17800), 51 + }; 52 + 53 + static const struct linear_range tps68470_core_ranges[] = { 54 + REGULATOR_LINEAR_RANGE(900000, 0, 42, 25000), 55 + }; 56 + 57 + static int tps68470_regulator_enable(struct regulator_dev *rdev) 58 + { 59 + struct tps68470_regulator_data *data = rdev->reg_data; 60 + int ret; 61 + 62 + /* The Core buck regulator needs the PMIC's PLL to be enabled */ 63 + if (rdev->desc->id == TPS68470_CORE) { 64 + ret = clk_prepare_enable(data->clk); 65 + if (ret) { 66 + dev_err(&rdev->dev, "Error enabling TPS68470 clock\n"); 67 + return ret; 68 + } 69 + } 70 + 71 + return regulator_enable_regmap(rdev); 72 + } 73 + 74 + static int tps68470_regulator_disable(struct regulator_dev *rdev) 75 + { 76 + struct tps68470_regulator_data *data = rdev->reg_data; 77 + 78 + if (rdev->desc->id == TPS68470_CORE) 79 + clk_disable_unprepare(data->clk); 80 + 81 + return regulator_disable_regmap(rdev); 82 + } 83 + 84 + /* Operations permitted on DCDCx, LDO2, LDO3 and LDO4 */ 85 + static const struct regulator_ops tps68470_regulator_ops = { 86 + .is_enabled = regulator_is_enabled_regmap, 87 + .enable = tps68470_regulator_enable, 88 + .disable = tps68470_regulator_disable, 89 + .get_voltage_sel = regulator_get_voltage_sel_regmap, 90 + .set_voltage_sel = regulator_set_voltage_sel_regmap, 91 + .list_voltage = regulator_list_voltage_linear_range, 92 + .map_voltage = regulator_map_voltage_linear_range, 93 + }; 94 + 95 + static const struct regulator_ops tps68470_always_on_reg_ops = { 96 + .get_voltage_sel = regulator_get_voltage_sel_regmap, 97 + .set_voltage_sel = regulator_set_voltage_sel_regmap, 98 + .list_voltage = regulator_list_voltage_linear_range, 99 + .map_voltage = regulator_map_voltage_linear_range, 100 + }; 101 + 102 + static const struct regulator_desc regulators[] = { 103 + TPS68470_REGULATOR(CORE, TPS68470_CORE, tps68470_regulator_ops, 43, 104 + TPS68470_REG_VDVAL, TPS68470_VDVAL_DVOLT_MASK, 105 + TPS68470_REG_VDCTL, TPS68470_VDCTL_EN_MASK, 106 + tps68470_core_ranges, ARRAY_SIZE(tps68470_core_ranges)), 107 + TPS68470_REGULATOR(ANA, TPS68470_ANA, tps68470_regulator_ops, 126, 108 + TPS68470_REG_VAVAL, TPS68470_VAVAL_AVOLT_MASK, 109 + TPS68470_REG_VACTL, TPS68470_VACTL_EN_MASK, 110 + tps68470_ldo_ranges, ARRAY_SIZE(tps68470_ldo_ranges)), 111 + TPS68470_REGULATOR(VCM, TPS68470_VCM, tps68470_regulator_ops, 126, 112 + TPS68470_REG_VCMVAL, TPS68470_VCMVAL_VCVOLT_MASK, 113 + TPS68470_REG_VCMCTL, TPS68470_VCMCTL_EN_MASK, 114 + tps68470_ldo_ranges, ARRAY_SIZE(tps68470_ldo_ranges)), 115 + TPS68470_REGULATOR(VIO, TPS68470_VIO, tps68470_always_on_reg_ops, 126, 116 + TPS68470_REG_VIOVAL, TPS68470_VIOVAL_IOVOLT_MASK, 117 + 0, 0, 118 + tps68470_ldo_ranges, ARRAY_SIZE(tps68470_ldo_ranges)), 119 + /* 120 + * (1) This regulator must have the same voltage as VIO if S_IO LDO is used to 121 + * power a sensor/VCM which I2C is daisy chained behind the PMIC. 122 + * (2) If there is no I2C daisy chain it can be set freely. 123 + */ 124 + TPS68470_REGULATOR(VSIO, TPS68470_VSIO, tps68470_regulator_ops, 126, 125 + TPS68470_REG_VSIOVAL, TPS68470_VSIOVAL_IOVOLT_MASK, 126 + TPS68470_REG_S_I2C_CTL, TPS68470_S_I2C_CTL_EN_MASK, 127 + tps68470_ldo_ranges, ARRAY_SIZE(tps68470_ldo_ranges)), 128 + TPS68470_REGULATOR(AUX1, TPS68470_AUX1, tps68470_regulator_ops, 126, 129 + TPS68470_REG_VAUX1VAL, TPS68470_VAUX1VAL_AUX1VOLT_MASK, 130 + TPS68470_REG_VAUX1CTL, TPS68470_VAUX1CTL_EN_MASK, 131 + tps68470_ldo_ranges, ARRAY_SIZE(tps68470_ldo_ranges)), 132 + TPS68470_REGULATOR(AUX2, TPS68470_AUX2, tps68470_regulator_ops, 126, 133 + TPS68470_REG_VAUX2VAL, TPS68470_VAUX2VAL_AUX2VOLT_MASK, 134 + TPS68470_REG_VAUX2CTL, TPS68470_VAUX2CTL_EN_MASK, 135 + tps68470_ldo_ranges, ARRAY_SIZE(tps68470_ldo_ranges)), 136 + }; 137 + 138 + static int tps68470_regulator_probe(struct platform_device *pdev) 139 + { 140 + struct device *dev = &pdev->dev; 141 + struct tps68470_regulator_platform_data *pdata = dev_get_platdata(dev); 142 + struct tps68470_regulator_data *data; 143 + struct regulator_config config = { }; 144 + struct regulator_dev *rdev; 145 + int i; 146 + 147 + data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); 148 + if (!data) 149 + return -ENOMEM; 150 + 151 + data->clk = devm_clk_get(dev, "tps68470-clk"); 152 + if (IS_ERR(data->clk)) 153 + return dev_err_probe(dev, PTR_ERR(data->clk), "getting tps68470-clk\n"); 154 + 155 + config.dev = dev->parent; 156 + config.regmap = dev_get_drvdata(dev->parent); 157 + config.driver_data = data; 158 + 159 + for (i = 0; i < TPS68470_NUM_REGULATORS; i++) { 160 + if (pdata) 161 + config.init_data = pdata->reg_init_data[i]; 162 + else 163 + config.init_data = NULL; 164 + 165 + rdev = devm_regulator_register(dev, &regulators[i], &config); 166 + if (IS_ERR(rdev)) 167 + return dev_err_probe(dev, PTR_ERR(rdev), 168 + "registering %s regulator\n", 169 + regulators[i].name); 170 + } 171 + 172 + return 0; 173 + } 174 + 175 + static struct platform_driver tps68470_regulator_driver = { 176 + .driver = { 177 + .name = "tps68470-regulator", 178 + }, 179 + .probe = tps68470_regulator_probe, 180 + }; 181 + 182 + /* 183 + * The ACPI tps68470 probe-ordering depends on the clk/gpio/regulator drivers 184 + * registering before the drivers for the camera-sensors which use them bind. 185 + * subsys_initcall() ensures this when the drivers are builtin. 186 + */ 187 + static int __init tps68470_regulator_init(void) 188 + { 189 + return platform_driver_register(&tps68470_regulator_driver); 190 + } 191 + subsys_initcall(tps68470_regulator_init); 192 + 193 + static void __exit tps68470_regulator_exit(void) 194 + { 195 + platform_driver_unregister(&tps68470_regulator_driver); 196 + } 197 + module_exit(tps68470_regulator_exit); 198 + 199 + MODULE_ALIAS("platform:tps68470-regulator"); 200 + MODULE_DESCRIPTION("TPS68470 voltage regulator driver"); 201 + MODULE_LICENSE("GPL v2");
+2 -8
drivers/regulator/twl-regulator.c
··· 196 196 { 197 197 struct twlreg_info *info = rdev_get_drvdata(rdev); 198 198 int grp; 199 - int ret; 200 199 201 200 grp = twlreg_grp(rdev); 202 201 if (grp < 0) ··· 203 204 204 205 grp |= P1_GRP_4030; 205 206 206 - ret = twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_GRP, grp); 207 - 208 - return ret; 207 + return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_GRP, grp); 209 208 } 210 209 211 210 static int twl4030reg_disable(struct regulator_dev *rdev) 212 211 { 213 212 struct twlreg_info *info = rdev_get_drvdata(rdev); 214 213 int grp; 215 - int ret; 216 214 217 215 grp = twlreg_grp(rdev); 218 216 if (grp < 0) ··· 217 221 218 222 grp &= ~(P1_GRP_4030 | P2_GRP_4030 | P3_GRP_4030); 219 223 220 - ret = twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_GRP, grp); 221 - 222 - return ret; 224 + return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_GRP, grp); 223 225 } 224 226 225 227 static int twl4030reg_get_status(struct regulator_dev *rdev)
+2 -8
include/linux/mfd/rohm-generic.h
··· 80 80 const struct regulator_desc *desc, 81 81 struct regmap *regmap); 82 82 83 - #else 84 - static inline int rohm_regulator_set_dvs_levels(const struct rohm_dvs_config *dvs, 85 - struct device_node *np, 86 - const struct regulator_desc *desc, 87 - struct regmap *regmap) 88 - { 89 - return 0; 90 - } 83 + int rohm_regulator_set_voltage_sel_restricted(struct regulator_dev *rdev, 84 + unsigned int sel); 91 85 #endif 92 86 93 87 #endif
+54 -13
include/linux/regulator/driver.h
··· 90 90 * @set_over_current_protection: Support enabling of and setting limits for over 91 91 * current situation detection. Detection can be configured for three 92 92 * levels of severity. 93 - * REGULATOR_SEVERITY_PROT should automatically shut down the regulator(s). 94 - * REGULATOR_SEVERITY_ERR should indicate that over-current situation is 95 - * caused by an unrecoverable error but HW does not perform 96 - * automatic shut down. 97 - * REGULATOR_SEVERITY_WARN should indicate situation where hardware is 98 - * still believed to not be damaged but that a board sepcific 99 - * recovery action is needed. If lim_uA is 0 the limit should not 100 - * be changed but the detection should just be enabled/disabled as 101 - * is requested. 93 + * 94 + * - REGULATOR_SEVERITY_PROT should automatically shut down the regulator(s). 95 + * 96 + * - REGULATOR_SEVERITY_ERR should indicate that over-current situation is 97 + * caused by an unrecoverable error but HW does not perform 98 + * automatic shut down. 99 + * 100 + * - REGULATOR_SEVERITY_WARN should indicate situation where hardware is 101 + * still believed to not be damaged but that a board sepcific 102 + * recovery action is needed. If lim_uA is 0 the limit should not 103 + * be changed but the detection should just be enabled/disabled as 104 + * is requested. 105 + * 102 106 * @set_over_voltage_protection: Support enabling of and setting limits for over 103 107 * voltage situation detection. Detection can be configured for same 104 - * severities as over current protection. 108 + * severities as over current protection. Units of uV. 105 109 * @set_under_voltage_protection: Support enabling of and setting limits for 106 - * under situation detection. 110 + * under voltage situation detection. Detection can be configured for same 111 + * severities as over current protection. Units of uV. 107 112 * @set_thermal_protection: Support enabling of and setting limits for over 108 - * temperature situation detection. 113 + * temperature situation detection.Detection can be configured for same 114 + * severities as over current protection. Units of degree Kelvin. 109 115 * 110 116 * @set_active_discharge: Set active discharge enable/disable of regulators. 111 117 * ··· 560 554 */ 561 555 struct regulator_irq_desc { 562 556 const char *name; 563 - int irq_flags; 564 557 int fatal_cnt; 565 558 int reread_ms; 566 559 int irq_off_ms; ··· 651 646 spinlock_t err_lock; 652 647 }; 653 648 649 + /* 650 + * Convert error flags to corresponding notifications. 651 + * 652 + * Can be used by drivers which use the notification helpers to 653 + * find out correct notification flags based on the error flags. Drivers 654 + * can avoid storing both supported notification and error flags which 655 + * may save few bytes. 656 + */ 657 + static inline int regulator_err2notif(int err) 658 + { 659 + switch (err) { 660 + case REGULATOR_ERROR_UNDER_VOLTAGE: 661 + return REGULATOR_EVENT_UNDER_VOLTAGE; 662 + case REGULATOR_ERROR_OVER_CURRENT: 663 + return REGULATOR_EVENT_OVER_CURRENT; 664 + case REGULATOR_ERROR_REGULATION_OUT: 665 + return REGULATOR_EVENT_REGULATION_OUT; 666 + case REGULATOR_ERROR_FAIL: 667 + return REGULATOR_EVENT_FAIL; 668 + case REGULATOR_ERROR_OVER_TEMP: 669 + return REGULATOR_EVENT_OVER_TEMP; 670 + case REGULATOR_ERROR_UNDER_VOLTAGE_WARN: 671 + return REGULATOR_EVENT_UNDER_VOLTAGE_WARN; 672 + case REGULATOR_ERROR_OVER_CURRENT_WARN: 673 + return REGULATOR_EVENT_OVER_CURRENT_WARN; 674 + case REGULATOR_ERROR_OVER_VOLTAGE_WARN: 675 + return REGULATOR_EVENT_OVER_VOLTAGE_WARN; 676 + case REGULATOR_ERROR_OVER_TEMP_WARN: 677 + return REGULATOR_EVENT_OVER_TEMP_WARN; 678 + } 679 + return 0; 680 + } 681 + 682 + 654 683 struct regulator_dev * 655 684 regulator_register(const struct regulator_desc *regulator_desc, 656 685 const struct regulator_config *config); ··· 706 667 int irq_flags, int common_errs, int *per_rdev_errs, 707 668 struct regulator_dev **rdev, int rdev_amount); 708 669 void regulator_irq_helper_cancel(void **handle); 670 + int regulator_irq_map_event_simple(int irq, struct regulator_irq_data *rid, 671 + unsigned long *dev_mask); 709 672 710 673 void *rdev_get_drvdata(struct regulator_dev *rdev); 711 674 struct device *rdev_get_dev(struct regulator_dev *rdev);