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

Merge remote-tracking branches 'regulator/topic/qcom-smd', 'regulator/topic/qcom-spmi', 'regulator/topic/rk808', 'regulator/topic/stub' and 'regulator/topic/tol' into regulator-next

+838 -24
+7 -1
Documentation/devicetree/bindings/mfd/rk808.txt
··· 24 24 - vcc10-supply: The input supply for LDO_REG6 25 25 - vcc11-supply: The input supply for LDO_REG8 26 26 - vcc12-supply: The input supply for SWITCH_REG2 27 + - dvs-gpios: buck1/2 can be controlled by gpio dvs, this is GPIO specifiers 28 + for 2 host gpio's used for dvs. The format of the gpio specifier depends in 29 + the gpio controller. If DVS GPIOs aren't present, voltage changes will happen 30 + very quickly with no slow ramp time. 27 31 28 32 Regulators: All the regulators of RK808 to be instantiated shall be 29 33 listed in a child node named 'regulators'. Each regulator is represented ··· 59 55 interrupt-parent = <&gpio0>; 60 56 interrupts = <4 IRQ_TYPE_LEVEL_LOW>; 61 57 pinctrl-names = "default"; 62 - pinctrl-0 = <&pmic_int>; 58 + pinctrl-0 = <&pmic_int &dvs_1 &dvs_2>; 59 + dvs-gpios = <&gpio7 11 GPIO_ACTIVE_HIGH>, 60 + <&gpio7 15 GPIO_ACTIVE_HIGH>; 63 61 reg = <0x1b>; 64 62 rockchip,system-power-controller; 65 63 wakeup-source;
+56 -4
Documentation/devicetree/bindings/regulator/qcom,spmi-regulator.txt
··· 91 91 - regulator-initial-mode: 92 92 Usage: optional 93 93 Value type: <u32> 94 - Descrption: 1 = Set initial mode to high power mode (HPM), also referred 95 - to as NPM. HPM consumes more ground current than LPM, but 94 + Description: 2 = Set initial mode to auto mode (automatically select 95 + between HPM and LPM); not available on boost type 96 + regulators. 97 + 98 + 1 = Set initial mode to high power mode (HPM), also referred 99 + to as NPM. HPM consumes more ground current than LPM, but 96 100 it can source significantly higher load current. HPM is not 97 101 available on boost type regulators. For voltage switch type 98 102 regulators, HPM implies that over current protection and 99 - soft start are active all the time. 0 = Set initial mode to 100 - low power mode (LPM). 103 + soft start are active all the time. 104 + 105 + 0 = Set initial mode to low power mode (LPM). 106 + 107 + - qcom,ocp-max-retries: 108 + Usage: optional 109 + Value type: <u32> 110 + Description: Maximum number of times to try toggling a voltage switch 111 + off and back on as a result of consecutive over current 112 + events. 113 + 114 + - qcom,ocp-retry-delay: 115 + Usage: optional 116 + Value type: <u32> 117 + Description: Time to delay in milliseconds between each voltage switch 118 + toggle after an over current event takes place. 119 + 120 + - qcom,pin-ctrl-enable: 121 + Usage: optional 122 + Value type: <u32> 123 + Description: Bit mask specifying which hardware pins should be used to 124 + enable the regulator, if any; supported bits are: 125 + 0 = ignore all hardware enable signals 126 + BIT(0) = follow HW0_EN signal 127 + BIT(1) = follow HW1_EN signal 128 + BIT(2) = follow HW2_EN signal 129 + BIT(3) = follow HW3_EN signal 130 + 131 + - qcom,pin-ctrl-hpm: 132 + Usage: optional 133 + Value type: <u32> 134 + Description: Bit mask specifying which hardware pins should be used to 135 + force the regulator into high power mode, if any; 136 + supported bits are: 137 + 0 = ignore all hardware enable signals 138 + BIT(0) = follow HW0_EN signal 139 + BIT(1) = follow HW1_EN signal 140 + BIT(2) = follow HW2_EN signal 141 + BIT(3) = follow HW3_EN signal 142 + BIT(4) = follow PMIC awake state 143 + 144 + - qcom,vs-soft-start-strength: 145 + Usage: optional 146 + Value type: <u32> 147 + Description: This property sets the soft start strength for voltage 148 + switch type regulators; supported values are: 149 + 0 = 0.05 uA 150 + 1 = 0.25 uA 151 + 2 = 0.55 uA 152 + 3 = 0.75 uA 101 153 102 154 Example: 103 155
+12
drivers/regulator/Kconfig
··· 523 523 Qualcomm RPM as a module. The module will be named 524 524 "qcom_rpm-regulator". 525 525 526 + config REGULATOR_QCOM_SMD_RPM 527 + tristate "Qualcomm SMD based RPM regulator driver" 528 + depends on QCOM_SMD_RPM 529 + help 530 + If you say yes to this option, support will be included for the 531 + regulators exposed by the Resource Power Manager found in Qualcomm 532 + 8974 based devices. 533 + 534 + Say M here if you want to include support for the regulators on the 535 + Qualcomm RPM as a module. The module will be named 536 + "qcom_smd-regulator". 537 + 526 538 config REGULATOR_QCOM_SPMI 527 539 tristate "Qualcomm SPMI regulator driver" 528 540 depends on SPMI || COMPILE_TEST
+1
drivers/regulator/Makefile
··· 62 62 obj-$(CONFIG_REGULATOR_MT6311) += mt6311-regulator.o 63 63 obj-$(CONFIG_REGULATOR_MT6397) += mt6397-regulator.o 64 64 obj-$(CONFIG_REGULATOR_QCOM_RPM) += qcom_rpm-regulator.o 65 + obj-$(CONFIG_REGULATOR_QCOM_SMD_RPM) += qcom_smd-regulator.o 65 66 obj-$(CONFIG_REGULATOR_QCOM_SPMI) += qcom_spmi-regulator.o 66 67 obj-$(CONFIG_REGULATOR_PALMAS) += palmas-regulator.o 67 68 obj-$(CONFIG_REGULATOR_PFUZE100) += pfuze100-regulator.o
+350
drivers/regulator/qcom_smd-regulator.c
··· 1 + /* 2 + * Copyright (c) 2015, Sony Mobile Communications AB. 3 + * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. 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 and 7 + * only version 2 as 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 + */ 14 + 15 + #include <linux/module.h> 16 + #include <linux/of.h> 17 + #include <linux/of_device.h> 18 + #include <linux/platform_device.h> 19 + #include <linux/regulator/driver.h> 20 + #include <linux/regulator/machine.h> 21 + #include <linux/regulator/of_regulator.h> 22 + #include <linux/soc/qcom/smd-rpm.h> 23 + 24 + struct qcom_rpm_reg { 25 + struct device *dev; 26 + 27 + struct qcom_smd_rpm *rpm; 28 + 29 + u32 type; 30 + u32 id; 31 + 32 + struct regulator_desc desc; 33 + 34 + int is_enabled; 35 + int uV; 36 + }; 37 + 38 + struct rpm_regulator_req { 39 + u32 key; 40 + u32 nbytes; 41 + u32 value; 42 + }; 43 + 44 + #define RPM_KEY_SWEN 0x6e657773 /* "swen" */ 45 + #define RPM_KEY_UV 0x00007675 /* "uv" */ 46 + #define RPM_KEY_MA 0x0000616d /* "ma" */ 47 + 48 + static int rpm_reg_write_active(struct qcom_rpm_reg *vreg, 49 + struct rpm_regulator_req *req, 50 + size_t size) 51 + { 52 + return qcom_rpm_smd_write(vreg->rpm, 53 + QCOM_SMD_RPM_ACTIVE_STATE, 54 + vreg->type, 55 + vreg->id, 56 + req, size); 57 + } 58 + 59 + static int rpm_reg_enable(struct regulator_dev *rdev) 60 + { 61 + struct qcom_rpm_reg *vreg = rdev_get_drvdata(rdev); 62 + struct rpm_regulator_req req; 63 + int ret; 64 + 65 + req.key = RPM_KEY_SWEN; 66 + req.nbytes = sizeof(u32); 67 + req.value = 1; 68 + 69 + ret = rpm_reg_write_active(vreg, &req, sizeof(req)); 70 + if (!ret) 71 + vreg->is_enabled = 1; 72 + 73 + return ret; 74 + } 75 + 76 + static int rpm_reg_is_enabled(struct regulator_dev *rdev) 77 + { 78 + struct qcom_rpm_reg *vreg = rdev_get_drvdata(rdev); 79 + 80 + return vreg->is_enabled; 81 + } 82 + 83 + static int rpm_reg_disable(struct regulator_dev *rdev) 84 + { 85 + struct qcom_rpm_reg *vreg = rdev_get_drvdata(rdev); 86 + struct rpm_regulator_req req; 87 + int ret; 88 + 89 + req.key = RPM_KEY_SWEN; 90 + req.nbytes = sizeof(u32); 91 + req.value = 0; 92 + 93 + ret = rpm_reg_write_active(vreg, &req, sizeof(req)); 94 + if (!ret) 95 + vreg->is_enabled = 0; 96 + 97 + return ret; 98 + } 99 + 100 + static int rpm_reg_get_voltage(struct regulator_dev *rdev) 101 + { 102 + struct qcom_rpm_reg *vreg = rdev_get_drvdata(rdev); 103 + 104 + return vreg->uV; 105 + } 106 + 107 + static int rpm_reg_set_voltage(struct regulator_dev *rdev, 108 + int min_uV, 109 + int max_uV, 110 + unsigned *selector) 111 + { 112 + struct qcom_rpm_reg *vreg = rdev_get_drvdata(rdev); 113 + struct rpm_regulator_req req; 114 + int ret = 0; 115 + 116 + req.key = RPM_KEY_UV; 117 + req.nbytes = sizeof(u32); 118 + req.value = min_uV; 119 + 120 + ret = rpm_reg_write_active(vreg, &req, sizeof(req)); 121 + if (!ret) 122 + vreg->uV = min_uV; 123 + 124 + return ret; 125 + } 126 + 127 + static int rpm_reg_set_load(struct regulator_dev *rdev, int load_uA) 128 + { 129 + struct qcom_rpm_reg *vreg = rdev_get_drvdata(rdev); 130 + struct rpm_regulator_req req; 131 + 132 + req.key = RPM_KEY_MA; 133 + req.nbytes = sizeof(u32); 134 + req.value = load_uA; 135 + 136 + return rpm_reg_write_active(vreg, &req, sizeof(req)); 137 + } 138 + 139 + static const struct regulator_ops rpm_smps_ldo_ops = { 140 + .enable = rpm_reg_enable, 141 + .disable = rpm_reg_disable, 142 + .is_enabled = rpm_reg_is_enabled, 143 + 144 + .get_voltage = rpm_reg_get_voltage, 145 + .set_voltage = rpm_reg_set_voltage, 146 + 147 + .set_load = rpm_reg_set_load, 148 + }; 149 + 150 + static const struct regulator_ops rpm_switch_ops = { 151 + .enable = rpm_reg_enable, 152 + .disable = rpm_reg_disable, 153 + .is_enabled = rpm_reg_is_enabled, 154 + }; 155 + 156 + static const struct regulator_desc pm8x41_hfsmps = { 157 + .linear_ranges = (struct regulator_linear_range[]) { 158 + REGULATOR_LINEAR_RANGE( 375000, 0, 95, 12500), 159 + REGULATOR_LINEAR_RANGE(1550000, 96, 158, 25000), 160 + }, 161 + .n_linear_ranges = 2, 162 + .n_voltages = 159, 163 + .ops = &rpm_smps_ldo_ops, 164 + }; 165 + 166 + static const struct regulator_desc pm8841_ftsmps = { 167 + .linear_ranges = (struct regulator_linear_range[]) { 168 + REGULATOR_LINEAR_RANGE(350000, 0, 184, 5000), 169 + REGULATOR_LINEAR_RANGE(700000, 185, 339, 10000), 170 + }, 171 + .n_linear_ranges = 2, 172 + .n_voltages = 340, 173 + .ops = &rpm_smps_ldo_ops, 174 + }; 175 + 176 + static const struct regulator_desc pm8941_boost = { 177 + .linear_ranges = (struct regulator_linear_range[]) { 178 + REGULATOR_LINEAR_RANGE(4000000, 0, 15, 100000), 179 + }, 180 + .n_linear_ranges = 1, 181 + .n_voltages = 16, 182 + .ops = &rpm_smps_ldo_ops, 183 + }; 184 + 185 + static const struct regulator_desc pm8941_pldo = { 186 + .linear_ranges = (struct regulator_linear_range[]) { 187 + REGULATOR_LINEAR_RANGE( 750000, 0, 30, 25000), 188 + REGULATOR_LINEAR_RANGE(1500000, 31, 99, 50000), 189 + }, 190 + .n_linear_ranges = 2, 191 + .n_voltages = 100, 192 + .ops = &rpm_smps_ldo_ops, 193 + }; 194 + 195 + static const struct regulator_desc pm8941_nldo = { 196 + .linear_ranges = (struct regulator_linear_range[]) { 197 + REGULATOR_LINEAR_RANGE(750000, 0, 63, 12500), 198 + }, 199 + .n_linear_ranges = 1, 200 + .n_voltages = 64, 201 + .ops = &rpm_smps_ldo_ops, 202 + }; 203 + 204 + static const struct regulator_desc pm8941_lnldo = { 205 + .fixed_uV = 1740000, 206 + .n_voltages = 1, 207 + .ops = &rpm_smps_ldo_ops, 208 + }; 209 + 210 + static const struct regulator_desc pm8941_switch = { 211 + .ops = &rpm_switch_ops, 212 + }; 213 + 214 + struct rpm_regulator_data { 215 + const char *name; 216 + u32 type; 217 + u32 id; 218 + const struct regulator_desc *desc; 219 + const char *supply; 220 + }; 221 + 222 + static const struct rpm_regulator_data rpm_pm8841_regulators[] = { 223 + { "s1", QCOM_SMD_RPM_SMPB, 1, &pm8x41_hfsmps, "vdd_s1" }, 224 + { "s2", QCOM_SMD_RPM_SMPB, 2, &pm8841_ftsmps, "vdd_s2" }, 225 + { "s3", QCOM_SMD_RPM_SMPB, 3, &pm8x41_hfsmps, "vdd_s3" }, 226 + { "s4", QCOM_SMD_RPM_SMPB, 4, &pm8841_ftsmps, "vdd_s4" }, 227 + { "s5", QCOM_SMD_RPM_SMPB, 5, &pm8841_ftsmps, "vdd_s5" }, 228 + { "s6", QCOM_SMD_RPM_SMPB, 6, &pm8841_ftsmps, "vdd_s6" }, 229 + { "s7", QCOM_SMD_RPM_SMPB, 7, &pm8841_ftsmps, "vdd_s7" }, 230 + { "s8", QCOM_SMD_RPM_SMPB, 8, &pm8841_ftsmps, "vdd_s8" }, 231 + {} 232 + }; 233 + 234 + static const struct rpm_regulator_data rpm_pm8941_regulators[] = { 235 + { "s1", QCOM_SMD_RPM_SMPA, 1, &pm8x41_hfsmps, "vdd_s1" }, 236 + { "s2", QCOM_SMD_RPM_SMPA, 2, &pm8x41_hfsmps, "vdd_s2" }, 237 + { "s3", QCOM_SMD_RPM_SMPA, 3, &pm8x41_hfsmps, "vdd_s3" }, 238 + { "s4", QCOM_SMD_RPM_BOOST, 1, &pm8941_boost }, 239 + 240 + { "l1", QCOM_SMD_RPM_LDOA, 1, &pm8941_nldo, "vdd_l1_l3" }, 241 + { "l2", QCOM_SMD_RPM_LDOA, 2, &pm8941_nldo, "vdd_l2_lvs1_2_3" }, 242 + { "l3", QCOM_SMD_RPM_LDOA, 3, &pm8941_nldo, "vdd_l1_l3" }, 243 + { "l4", QCOM_SMD_RPM_LDOA, 4, &pm8941_nldo, "vdd_l4_l11" }, 244 + { "l5", QCOM_SMD_RPM_LDOA, 5, &pm8941_lnldo, "vdd_l5_l7" }, 245 + { "l6", QCOM_SMD_RPM_LDOA, 6, &pm8941_pldo, "vdd_l6_l12_l14_l15" }, 246 + { "l7", QCOM_SMD_RPM_LDOA, 7, &pm8941_lnldo, "vdd_l5_l7" }, 247 + { "l8", QCOM_SMD_RPM_LDOA, 8, &pm8941_pldo, "vdd_l8_l16_l18_l19" }, 248 + { "l9", QCOM_SMD_RPM_LDOA, 9, &pm8941_pldo, "vdd_l9_l10_l17_l22" }, 249 + { "l10", QCOM_SMD_RPM_LDOA, 10, &pm8941_pldo, "vdd_l9_l10_l17_l22" }, 250 + { "l11", QCOM_SMD_RPM_LDOA, 11, &pm8941_nldo, "vdd_l4_l11" }, 251 + { "l12", QCOM_SMD_RPM_LDOA, 12, &pm8941_pldo, "vdd_l6_l12_l14_l15" }, 252 + { "l13", QCOM_SMD_RPM_LDOA, 13, &pm8941_pldo, "vdd_l13_l20_l23_l24" }, 253 + { "l14", QCOM_SMD_RPM_LDOA, 14, &pm8941_pldo, "vdd_l6_l12_l14_l15" }, 254 + { "l15", QCOM_SMD_RPM_LDOA, 15, &pm8941_pldo, "vdd_l6_l12_l14_l15" }, 255 + { "l16", QCOM_SMD_RPM_LDOA, 16, &pm8941_pldo, "vdd_l8_l16_l18_l19" }, 256 + { "l17", QCOM_SMD_RPM_LDOA, 17, &pm8941_pldo, "vdd_l9_l10_l17_l22" }, 257 + { "l18", QCOM_SMD_RPM_LDOA, 18, &pm8941_pldo, "vdd_l8_l16_l18_l19" }, 258 + { "l19", QCOM_SMD_RPM_LDOA, 19, &pm8941_pldo, "vdd_l8_l16_l18_l19" }, 259 + { "l20", QCOM_SMD_RPM_LDOA, 20, &pm8941_pldo, "vdd_l13_l20_l23_l24" }, 260 + { "l21", QCOM_SMD_RPM_LDOA, 21, &pm8941_pldo, "vdd_l21" }, 261 + { "l22", QCOM_SMD_RPM_LDOA, 22, &pm8941_pldo, "vdd_l9_l10_l17_l22" }, 262 + { "l23", QCOM_SMD_RPM_LDOA, 23, &pm8941_pldo, "vdd_l13_l20_l23_l24" }, 263 + { "l24", QCOM_SMD_RPM_LDOA, 24, &pm8941_pldo, "vdd_l13_l20_l23_l24" }, 264 + 265 + { "lvs1", QCOM_SMD_RPM_VSA, 1, &pm8941_switch, "vdd_l2_lvs1_2_3" }, 266 + { "lvs2", QCOM_SMD_RPM_VSA, 2, &pm8941_switch, "vdd_l2_lvs1_2_3" }, 267 + { "lvs3", QCOM_SMD_RPM_VSA, 3, &pm8941_switch, "vdd_l2_lvs1_2_3" }, 268 + 269 + { "5vs1", QCOM_SMD_RPM_VSA, 4, &pm8941_switch, "vin_5vs" }, 270 + { "5vs2", QCOM_SMD_RPM_VSA, 5, &pm8941_switch, "vin_5vs" }, 271 + 272 + {} 273 + }; 274 + 275 + static const struct of_device_id rpm_of_match[] = { 276 + { .compatible = "qcom,rpm-pm8841-regulators", .data = &rpm_pm8841_regulators }, 277 + { .compatible = "qcom,rpm-pm8941-regulators", .data = &rpm_pm8941_regulators }, 278 + {} 279 + }; 280 + MODULE_DEVICE_TABLE(of, rpm_of_match); 281 + 282 + static int rpm_reg_probe(struct platform_device *pdev) 283 + { 284 + const struct rpm_regulator_data *reg; 285 + const struct of_device_id *match; 286 + struct regulator_config config = { }; 287 + struct regulator_dev *rdev; 288 + struct qcom_rpm_reg *vreg; 289 + struct qcom_smd_rpm *rpm; 290 + 291 + rpm = dev_get_drvdata(pdev->dev.parent); 292 + if (!rpm) { 293 + dev_err(&pdev->dev, "unable to retrieve handle to rpm\n"); 294 + return -ENODEV; 295 + } 296 + 297 + match = of_match_device(rpm_of_match, &pdev->dev); 298 + for (reg = match->data; reg->name; reg++) { 299 + vreg = devm_kzalloc(&pdev->dev, sizeof(*vreg), GFP_KERNEL); 300 + if (!vreg) 301 + return -ENOMEM; 302 + 303 + vreg->dev = &pdev->dev; 304 + vreg->type = reg->type; 305 + vreg->id = reg->id; 306 + vreg->rpm = rpm; 307 + 308 + memcpy(&vreg->desc, reg->desc, sizeof(vreg->desc)); 309 + 310 + vreg->desc.id = -1; 311 + vreg->desc.owner = THIS_MODULE; 312 + vreg->desc.type = REGULATOR_VOLTAGE; 313 + vreg->desc.name = reg->name; 314 + vreg->desc.supply_name = reg->supply; 315 + vreg->desc.of_match = reg->name; 316 + 317 + config.dev = &pdev->dev; 318 + config.driver_data = vreg; 319 + rdev = devm_regulator_register(&pdev->dev, &vreg->desc, &config); 320 + if (IS_ERR(rdev)) { 321 + dev_err(&pdev->dev, "failed to register %s\n", reg->name); 322 + return PTR_ERR(rdev); 323 + } 324 + } 325 + 326 + return 0; 327 + } 328 + 329 + static struct platform_driver rpm_reg_driver = { 330 + .probe = rpm_reg_probe, 331 + .driver = { 332 + .name = "qcom_rpm_smd_regulator", 333 + .of_match_table = rpm_of_match, 334 + }, 335 + }; 336 + 337 + static int __init rpm_reg_init(void) 338 + { 339 + return platform_driver_register(&rpm_reg_driver); 340 + } 341 + subsys_initcall(rpm_reg_init); 342 + 343 + static void __exit rpm_reg_exit(void) 344 + { 345 + platform_driver_unregister(&rpm_reg_driver); 346 + } 347 + module_exit(rpm_reg_exit) 348 + 349 + MODULE_DESCRIPTION("Qualcomm RPM regulator driver"); 350 + MODULE_LICENSE("GPL v2");
+196 -7
drivers/regulator/qcom_spmi-regulator.c
··· 26 26 #include <linux/regmap.h> 27 27 #include <linux/list.h> 28 28 29 + /* Pin control enable input pins. */ 30 + #define SPMI_REGULATOR_PIN_CTRL_ENABLE_NONE 0x00 31 + #define SPMI_REGULATOR_PIN_CTRL_ENABLE_EN0 0x01 32 + #define SPMI_REGULATOR_PIN_CTRL_ENABLE_EN1 0x02 33 + #define SPMI_REGULATOR_PIN_CTRL_ENABLE_EN2 0x04 34 + #define SPMI_REGULATOR_PIN_CTRL_ENABLE_EN3 0x08 35 + #define SPMI_REGULATOR_PIN_CTRL_ENABLE_HW_DEFAULT 0x10 36 + 37 + /* Pin control high power mode input pins. */ 38 + #define SPMI_REGULATOR_PIN_CTRL_HPM_NONE 0x00 39 + #define SPMI_REGULATOR_PIN_CTRL_HPM_EN0 0x01 40 + #define SPMI_REGULATOR_PIN_CTRL_HPM_EN1 0x02 41 + #define SPMI_REGULATOR_PIN_CTRL_HPM_EN2 0x04 42 + #define SPMI_REGULATOR_PIN_CTRL_HPM_EN3 0x08 43 + #define SPMI_REGULATOR_PIN_CTRL_HPM_SLEEP_B 0x10 44 + #define SPMI_REGULATOR_PIN_CTRL_HPM_HW_DEFAULT 0x20 45 + 46 + /* 47 + * Used with enable parameters to specify that hardware default register values 48 + * should be left unaltered. 49 + */ 50 + #define SPMI_REGULATOR_USE_HW_DEFAULT 2 51 + 52 + /* Soft start strength of a voltage switch type regulator */ 53 + enum spmi_vs_soft_start_str { 54 + SPMI_VS_SOFT_START_STR_0P05_UA = 0, 55 + SPMI_VS_SOFT_START_STR_0P25_UA, 56 + SPMI_VS_SOFT_START_STR_0P55_UA, 57 + SPMI_VS_SOFT_START_STR_0P75_UA, 58 + SPMI_VS_SOFT_START_STR_HW_DEFAULT, 59 + }; 60 + 61 + /** 62 + * struct spmi_regulator_init_data - spmi-regulator initialization data 63 + * @pin_ctrl_enable: Bit mask specifying which hardware pins should be 64 + * used to enable the regulator, if any 65 + * Value should be an ORing of 66 + * SPMI_REGULATOR_PIN_CTRL_ENABLE_* constants. If 67 + * the bit specified by 68 + * SPMI_REGULATOR_PIN_CTRL_ENABLE_HW_DEFAULT is 69 + * set, then pin control enable hardware registers 70 + * will not be modified. 71 + * @pin_ctrl_hpm: Bit mask specifying which hardware pins should be 72 + * used to force the regulator into high power 73 + * mode, if any 74 + * Value should be an ORing of 75 + * SPMI_REGULATOR_PIN_CTRL_HPM_* constants. If 76 + * the bit specified by 77 + * SPMI_REGULATOR_PIN_CTRL_HPM_HW_DEFAULT is 78 + * set, then pin control mode hardware registers 79 + * will not be modified. 80 + * @vs_soft_start_strength: This parameter sets the soft start strength for 81 + * voltage switch type regulators. Its value 82 + * should be one of SPMI_VS_SOFT_START_STR_*. If 83 + * its value is SPMI_VS_SOFT_START_STR_HW_DEFAULT, 84 + * then the soft start strength will be left at its 85 + * default hardware value. 86 + */ 87 + struct spmi_regulator_init_data { 88 + unsigned pin_ctrl_enable; 89 + unsigned pin_ctrl_hpm; 90 + enum spmi_vs_soft_start_str vs_soft_start_strength; 91 + }; 92 + 29 93 /* These types correspond to unique register layouts. */ 30 94 enum spmi_regulator_logical_type { 31 95 SPMI_REGULATOR_LOGICAL_TYPE_SMPS, ··· 522 458 return spmi_regulator_common_enable(rdev); 523 459 } 524 460 461 + static int spmi_regulator_vs_ocp(struct regulator_dev *rdev) 462 + { 463 + struct spmi_regulator *vreg = rdev_get_drvdata(rdev); 464 + u8 reg = SPMI_VS_OCP_OVERRIDE; 465 + 466 + return spmi_vreg_write(vreg, SPMI_VS_REG_OCP, &reg, 1); 467 + } 468 + 525 469 static int spmi_regulator_common_disable(struct regulator_dev *rdev) 526 470 { 527 471 struct spmi_regulator *vreg = rdev_get_drvdata(rdev); ··· 576 504 * Force uV to be an allowed set point by applying a ceiling function to 577 505 * the uV value. 578 506 */ 579 - *voltage_sel = (uV - range->min_uV + range->step_uV - 1) 580 - / range->step_uV; 507 + *voltage_sel = DIV_ROUND_UP(uV - range->min_uV, range->step_uV); 581 508 uV = *voltage_sel * range->step_uV + range->min_uV; 582 509 583 510 if (uV > max_uV) { ··· 863 792 if (reg & SPMI_COMMON_MODE_HPM_MASK) 864 793 return REGULATOR_MODE_NORMAL; 865 794 795 + if (reg & SPMI_COMMON_MODE_AUTO_MASK) 796 + return REGULATOR_MODE_FAST; 797 + 866 798 return REGULATOR_MODE_IDLE; 867 799 } 868 800 ··· 873 799 spmi_regulator_common_set_mode(struct regulator_dev *rdev, unsigned int mode) 874 800 { 875 801 struct spmi_regulator *vreg = rdev_get_drvdata(rdev); 876 - u8 mask = SPMI_COMMON_MODE_HPM_MASK; 802 + u8 mask = SPMI_COMMON_MODE_HPM_MASK | SPMI_COMMON_MODE_AUTO_MASK; 877 803 u8 val = 0; 878 804 879 805 if (mode == REGULATOR_MODE_NORMAL) 880 - val = mask; 806 + val = SPMI_COMMON_MODE_HPM_MASK; 807 + else if (mode == REGULATOR_MODE_FAST) 808 + val = SPMI_COMMON_MODE_AUTO_MASK; 881 809 882 810 return spmi_vreg_update_bits(vreg, SPMI_COMMON_REG_MODE, val, mask); 883 811 } ··· 1049 973 .is_enabled = spmi_regulator_common_is_enabled, 1050 974 .set_pull_down = spmi_regulator_common_set_pull_down, 1051 975 .set_soft_start = spmi_regulator_common_set_soft_start, 976 + .set_over_current_protection = spmi_regulator_vs_ocp, 1052 977 }; 1053 978 1054 979 static struct regulator_ops spmi_boost_ops = { ··· 1280 1203 return ret; 1281 1204 } 1282 1205 1206 + static int spmi_regulator_init_registers(struct spmi_regulator *vreg, 1207 + const struct spmi_regulator_init_data *data) 1208 + { 1209 + int ret; 1210 + enum spmi_regulator_logical_type type; 1211 + u8 ctrl_reg[8], reg, mask; 1212 + 1213 + type = vreg->logical_type; 1214 + 1215 + ret = spmi_vreg_read(vreg, SPMI_COMMON_REG_VOLTAGE_RANGE, ctrl_reg, 8); 1216 + if (ret) 1217 + return ret; 1218 + 1219 + /* Set up enable pin control. */ 1220 + if ((type == SPMI_REGULATOR_LOGICAL_TYPE_SMPS 1221 + || type == SPMI_REGULATOR_LOGICAL_TYPE_LDO 1222 + || type == SPMI_REGULATOR_LOGICAL_TYPE_VS) 1223 + && !(data->pin_ctrl_enable 1224 + & SPMI_REGULATOR_PIN_CTRL_ENABLE_HW_DEFAULT)) { 1225 + ctrl_reg[SPMI_COMMON_IDX_ENABLE] &= 1226 + ~SPMI_COMMON_ENABLE_FOLLOW_ALL_MASK; 1227 + ctrl_reg[SPMI_COMMON_IDX_ENABLE] |= 1228 + data->pin_ctrl_enable & SPMI_COMMON_ENABLE_FOLLOW_ALL_MASK; 1229 + } 1230 + 1231 + /* Set up mode pin control. */ 1232 + if ((type == SPMI_REGULATOR_LOGICAL_TYPE_SMPS 1233 + || type == SPMI_REGULATOR_LOGICAL_TYPE_LDO) 1234 + && !(data->pin_ctrl_hpm 1235 + & SPMI_REGULATOR_PIN_CTRL_HPM_HW_DEFAULT)) { 1236 + ctrl_reg[SPMI_COMMON_IDX_MODE] &= 1237 + ~SPMI_COMMON_MODE_FOLLOW_ALL_MASK; 1238 + ctrl_reg[SPMI_COMMON_IDX_MODE] |= 1239 + data->pin_ctrl_hpm & SPMI_COMMON_MODE_FOLLOW_ALL_MASK; 1240 + } 1241 + 1242 + if (type == SPMI_REGULATOR_LOGICAL_TYPE_VS 1243 + && !(data->pin_ctrl_hpm & SPMI_REGULATOR_PIN_CTRL_HPM_HW_DEFAULT)) { 1244 + ctrl_reg[SPMI_COMMON_IDX_MODE] &= 1245 + ~SPMI_COMMON_MODE_FOLLOW_AWAKE_MASK; 1246 + ctrl_reg[SPMI_COMMON_IDX_MODE] |= 1247 + data->pin_ctrl_hpm & SPMI_COMMON_MODE_FOLLOW_AWAKE_MASK; 1248 + } 1249 + 1250 + if ((type == SPMI_REGULATOR_LOGICAL_TYPE_ULT_LO_SMPS 1251 + || type == SPMI_REGULATOR_LOGICAL_TYPE_ULT_HO_SMPS 1252 + || type == SPMI_REGULATOR_LOGICAL_TYPE_ULT_LDO) 1253 + && !(data->pin_ctrl_hpm 1254 + & SPMI_REGULATOR_PIN_CTRL_HPM_HW_DEFAULT)) { 1255 + ctrl_reg[SPMI_COMMON_IDX_MODE] &= 1256 + ~SPMI_COMMON_MODE_FOLLOW_AWAKE_MASK; 1257 + ctrl_reg[SPMI_COMMON_IDX_MODE] |= 1258 + data->pin_ctrl_hpm & SPMI_COMMON_MODE_FOLLOW_AWAKE_MASK; 1259 + } 1260 + 1261 + /* Write back any control register values that were modified. */ 1262 + ret = spmi_vreg_write(vreg, SPMI_COMMON_REG_VOLTAGE_RANGE, ctrl_reg, 8); 1263 + if (ret) 1264 + return ret; 1265 + 1266 + /* Set soft start strength and over current protection for VS. */ 1267 + if (type == SPMI_REGULATOR_LOGICAL_TYPE_VS) { 1268 + if (data->vs_soft_start_strength 1269 + != SPMI_VS_SOFT_START_STR_HW_DEFAULT) { 1270 + reg = data->vs_soft_start_strength 1271 + & SPMI_VS_SOFT_START_SEL_MASK; 1272 + mask = SPMI_VS_SOFT_START_SEL_MASK; 1273 + return spmi_vreg_update_bits(vreg, 1274 + SPMI_VS_REG_SOFT_START, 1275 + reg, mask); 1276 + } 1277 + } 1278 + 1279 + return 0; 1280 + } 1281 + 1282 + static void spmi_regulator_get_dt_config(struct spmi_regulator *vreg, 1283 + struct device_node *node, struct spmi_regulator_init_data *data) 1284 + { 1285 + /* 1286 + * Initialize configuration parameters to use hardware default in case 1287 + * no value is specified via device tree. 1288 + */ 1289 + data->pin_ctrl_enable = SPMI_REGULATOR_PIN_CTRL_ENABLE_HW_DEFAULT; 1290 + data->pin_ctrl_hpm = SPMI_REGULATOR_PIN_CTRL_HPM_HW_DEFAULT; 1291 + data->vs_soft_start_strength = SPMI_VS_SOFT_START_STR_HW_DEFAULT; 1292 + 1293 + /* These bindings are optional, so it is okay if they aren't found. */ 1294 + of_property_read_u32(node, "qcom,ocp-max-retries", 1295 + &vreg->ocp_max_retries); 1296 + of_property_read_u32(node, "qcom,ocp-retry-delay", 1297 + &vreg->ocp_retry_delay_ms); 1298 + of_property_read_u32(node, "qcom,pin-ctrl-enable", 1299 + &data->pin_ctrl_enable); 1300 + of_property_read_u32(node, "qcom,pin-ctrl-hpm", &data->pin_ctrl_hpm); 1301 + of_property_read_u32(node, "qcom,vs-soft-start-strength", 1302 + &data->vs_soft_start_strength); 1303 + } 1304 + 1283 1305 static unsigned int spmi_regulator_of_map_mode(unsigned int mode) 1284 1306 { 1285 - if (mode) 1307 + if (mode == 1) 1286 1308 return REGULATOR_MODE_NORMAL; 1309 + if (mode == 2) 1310 + return REGULATOR_MODE_FAST; 1287 1311 1288 1312 return REGULATOR_MODE_IDLE; 1289 1313 } ··· 1393 1215 const struct regulator_desc *desc, 1394 1216 struct regulator_config *config) 1395 1217 { 1218 + struct spmi_regulator_init_data data = { }; 1396 1219 struct spmi_regulator *vreg = config->driver_data; 1397 1220 struct device *dev = config->dev; 1398 1221 int ret; 1399 1222 1400 - vreg->ocp_max_retries = SPMI_VS_OCP_DEFAULT_MAX_RETRIES; 1401 - vreg->ocp_retry_delay_ms = SPMI_VS_OCP_DEFAULT_RETRY_DELAY_MS; 1223 + spmi_regulator_get_dt_config(vreg, node, &data); 1224 + 1225 + if (!vreg->ocp_max_retries) 1226 + vreg->ocp_max_retries = SPMI_VS_OCP_DEFAULT_MAX_RETRIES; 1227 + if (!vreg->ocp_retry_delay_ms) 1228 + vreg->ocp_retry_delay_ms = SPMI_VS_OCP_DEFAULT_RETRY_DELAY_MS; 1229 + 1230 + ret = spmi_regulator_init_registers(vreg, &data); 1231 + if (ret) { 1232 + dev_err(dev, "common initialization failed, ret=%d\n", ret); 1233 + return ret; 1234 + } 1402 1235 1403 1236 if (vreg->logical_type == SPMI_REGULATOR_LOGICAL_TYPE_FTSMPS) { 1404 1237 ret = spmi_regulator_ftsmps_init_slew_rate(vreg);
+200 -12
drivers/regulator/rk808-regulator.c
··· 16 16 * more details. 17 17 */ 18 18 19 - #include <linux/module.h> 19 + #include <linux/delay.h> 20 + #include <linux/gpio.h> 20 21 #include <linux/i2c.h> 21 - #include <linux/mfd/rk808.h> 22 + #include <linux/module.h> 22 23 #include <linux/of_device.h> 24 + #include <linux/of_gpio.h> 25 + #include <linux/mfd/rk808.h> 23 26 #include <linux/regulator/driver.h> 24 27 #include <linux/regulator/of_regulator.h> 28 + #include <linux/gpio/consumer.h> 25 29 26 30 /* Field Definitions */ 27 31 #define RK808_BUCK_VSEL_MASK 0x3f ··· 40 36 #define RK808_RAMP_RATE_6MV_PER_US (2 << RK808_RAMP_RATE_OFFSET) 41 37 #define RK808_RAMP_RATE_10MV_PER_US (3 << RK808_RAMP_RATE_OFFSET) 42 38 39 + #define RK808_DVS2_POL BIT(2) 40 + #define RK808_DVS1_POL BIT(1) 41 + 43 42 /* Offset from XXX_ON_VSEL to XXX_SLP_VSEL */ 44 43 #define RK808_SLP_REG_OFFSET 1 45 44 45 + /* Offset from XXX_ON_VSEL to XXX_DVS_VSEL */ 46 + #define RK808_DVS_REG_OFFSET 2 47 + 46 48 /* Offset from XXX_EN_REG to SLEEP_SET_OFF_XXX */ 47 49 #define RK808_SLP_SET_OFF_REG_OFFSET 2 50 + 51 + /* max steps for increase voltage of Buck1/2, equal 100mv*/ 52 + #define MAX_STEPS_ONE_TIME 8 53 + 54 + struct rk808_regulator_data { 55 + struct gpio_desc *dvs_gpio[2]; 56 + }; 48 57 49 58 static const int rk808_buck_config_regs[] = { 50 59 RK808_BUCK1_CONFIG_REG, ··· 86 69 static const struct regulator_linear_range rk808_ldo6_voltage_ranges[] = { 87 70 REGULATOR_LINEAR_RANGE(800000, 0, 17, 100000), 88 71 }; 72 + 73 + static int rk808_buck1_2_get_voltage_sel_regmap(struct regulator_dev *rdev) 74 + { 75 + struct rk808_regulator_data *pdata = rdev_get_drvdata(rdev); 76 + int id = rdev->desc->id - RK808_ID_DCDC1; 77 + struct gpio_desc *gpio = pdata->dvs_gpio[id]; 78 + unsigned int val; 79 + int ret; 80 + 81 + if (!gpio || gpiod_get_value(gpio) == 0) 82 + return regulator_get_voltage_sel_regmap(rdev); 83 + 84 + ret = regmap_read(rdev->regmap, 85 + rdev->desc->vsel_reg + RK808_DVS_REG_OFFSET, 86 + &val); 87 + if (ret != 0) 88 + return ret; 89 + 90 + val &= rdev->desc->vsel_mask; 91 + val >>= ffs(rdev->desc->vsel_mask) - 1; 92 + 93 + return val; 94 + } 95 + 96 + static int rk808_buck1_2_i2c_set_voltage_sel(struct regulator_dev *rdev, 97 + unsigned sel) 98 + { 99 + int ret, delta_sel; 100 + unsigned int old_sel, tmp, val, mask = rdev->desc->vsel_mask; 101 + 102 + ret = regmap_read(rdev->regmap, rdev->desc->vsel_reg, &val); 103 + if (ret != 0) 104 + return ret; 105 + 106 + tmp = val & ~mask; 107 + old_sel = val & mask; 108 + old_sel >>= ffs(mask) - 1; 109 + delta_sel = sel - old_sel; 110 + 111 + /* 112 + * If directly modify the register to change the voltage, we will face 113 + * the risk of overshoot. Put it into a multi-step, can effectively 114 + * avoid this problem, a step is 100mv here. 115 + */ 116 + while (delta_sel > MAX_STEPS_ONE_TIME) { 117 + old_sel += MAX_STEPS_ONE_TIME; 118 + val = old_sel << (ffs(mask) - 1); 119 + val |= tmp; 120 + 121 + /* 122 + * i2c is 400kHz (2.5us per bit) and we must transmit _at least_ 123 + * 3 bytes (24 bits) plus start and stop so 26 bits. So we've 124 + * got more than 65 us between each voltage change and thus 125 + * won't ramp faster than ~1500 uV / us. 126 + */ 127 + ret = regmap_write(rdev->regmap, rdev->desc->vsel_reg, val); 128 + delta_sel = sel - old_sel; 129 + } 130 + 131 + sel <<= ffs(mask) - 1; 132 + val = tmp | sel; 133 + ret = regmap_write(rdev->regmap, rdev->desc->vsel_reg, val); 134 + 135 + /* 136 + * When we change the voltage register directly, the ramp rate is about 137 + * 100000uv/us, wait 1us to make sure the target voltage to be stable, 138 + * so we needn't wait extra time after that. 139 + */ 140 + udelay(1); 141 + 142 + return ret; 143 + } 144 + 145 + static int rk808_buck1_2_set_voltage_sel(struct regulator_dev *rdev, 146 + unsigned sel) 147 + { 148 + struct rk808_regulator_data *pdata = rdev_get_drvdata(rdev); 149 + int id = rdev->desc->id - RK808_ID_DCDC1; 150 + struct gpio_desc *gpio = pdata->dvs_gpio[id]; 151 + unsigned int reg = rdev->desc->vsel_reg; 152 + unsigned old_sel; 153 + int ret, gpio_level; 154 + 155 + if (!gpio) 156 + return rk808_buck1_2_i2c_set_voltage_sel(rdev, sel); 157 + 158 + gpio_level = gpiod_get_value(gpio); 159 + if (gpio_level == 0) { 160 + reg += RK808_DVS_REG_OFFSET; 161 + ret = regmap_read(rdev->regmap, rdev->desc->vsel_reg, &old_sel); 162 + } else { 163 + ret = regmap_read(rdev->regmap, 164 + reg + RK808_DVS_REG_OFFSET, 165 + &old_sel); 166 + } 167 + 168 + if (ret != 0) 169 + return ret; 170 + 171 + sel <<= ffs(rdev->desc->vsel_mask) - 1; 172 + sel |= old_sel & ~rdev->desc->vsel_mask; 173 + 174 + ret = regmap_write(rdev->regmap, reg, sel); 175 + if (ret) 176 + return ret; 177 + 178 + gpiod_set_value(gpio, !gpio_level); 179 + 180 + return ret; 181 + } 182 + 183 + static int rk808_buck1_2_set_voltage_time_sel(struct regulator_dev *rdev, 184 + unsigned int old_selector, 185 + unsigned int new_selector) 186 + { 187 + struct rk808_regulator_data *pdata = rdev_get_drvdata(rdev); 188 + int id = rdev->desc->id - RK808_ID_DCDC1; 189 + struct gpio_desc *gpio = pdata->dvs_gpio[id]; 190 + 191 + /* if there is no dvs1/2 pin, we don't need wait extra time here. */ 192 + if (!gpio) 193 + return 0; 194 + 195 + return regulator_set_voltage_time_sel(rdev, old_selector, new_selector); 196 + } 89 197 90 198 static int rk808_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay) 91 199 { ··· 279 137 static struct regulator_ops rk808_buck1_2_ops = { 280 138 .list_voltage = regulator_list_voltage_linear_range, 281 139 .map_voltage = regulator_map_voltage_linear_range, 282 - .get_voltage_sel = regulator_get_voltage_sel_regmap, 283 - .set_voltage_sel = regulator_set_voltage_sel_regmap, 140 + .get_voltage_sel = rk808_buck1_2_get_voltage_sel_regmap, 141 + .set_voltage_sel = rk808_buck1_2_set_voltage_sel, 142 + .set_voltage_time_sel = rk808_buck1_2_set_voltage_time_sel, 284 143 .enable = regulator_enable_regmap, 285 144 .disable = regulator_disable_regmap, 286 145 .is_enabled = regulator_is_enabled_regmap, ··· 523 380 [RK808_ID_SWITCH2] = { .name = "SWITCH_REG2" }, 524 381 }; 525 382 383 + static int rk808_regulator_dt_parse_pdata(struct device *dev, 384 + struct device *client_dev, 385 + struct regmap *map, 386 + struct rk808_regulator_data *pdata) 387 + { 388 + struct device_node *np; 389 + int tmp, ret, i; 390 + 391 + np = of_get_child_by_name(client_dev->of_node, "regulators"); 392 + if (!np) 393 + return -ENXIO; 394 + 395 + ret = of_regulator_match(dev, np, rk808_reg_matches, 396 + RK808_NUM_REGULATORS); 397 + if (ret < 0) 398 + goto dt_parse_end; 399 + 400 + for (i = 0; i < ARRAY_SIZE(pdata->dvs_gpio); i++) { 401 + pdata->dvs_gpio[i] = 402 + devm_gpiod_get_index_optional(client_dev, "dvs", i, 403 + GPIOD_OUT_LOW); 404 + if (IS_ERR(pdata->dvs_gpio[i])) { 405 + ret = PTR_ERR(pdata->dvs_gpio[i]); 406 + dev_err(dev, "failed to get dvs%d gpio (%d)\n", i, ret); 407 + goto dt_parse_end; 408 + } 409 + 410 + if (!pdata->dvs_gpio[i]) { 411 + dev_warn(dev, "there is no dvs%d gpio\n", i); 412 + continue; 413 + } 414 + 415 + tmp = i ? RK808_DVS2_POL : RK808_DVS1_POL; 416 + ret = regmap_update_bits(map, RK808_IO_POL_REG, tmp, 417 + gpiod_is_active_low(pdata->dvs_gpio[i]) ? 418 + 0 : tmp); 419 + } 420 + 421 + dt_parse_end: 422 + of_node_put(np); 423 + return ret; 424 + } 425 + 526 426 static int rk808_regulator_probe(struct platform_device *pdev) 527 427 { 528 428 struct rk808 *rk808 = dev_get_drvdata(pdev->dev.parent); 529 429 struct i2c_client *client = rk808->i2c; 530 - struct device_node *reg_np; 531 430 struct regulator_config config = {}; 532 431 struct regulator_dev *rk808_rdev; 432 + struct rk808_regulator_data *pdata; 533 433 int ret, i; 534 434 535 - reg_np = of_get_child_by_name(client->dev.of_node, "regulators"); 536 - if (!reg_np) 537 - return -ENXIO; 435 + pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); 436 + if (!pdata) 437 + return -ENOMEM; 538 438 539 - ret = of_regulator_match(&pdev->dev, reg_np, rk808_reg_matches, 540 - RK808_NUM_REGULATORS); 541 - of_node_put(reg_np); 439 + ret = rk808_regulator_dt_parse_pdata(&pdev->dev, &client->dev, 440 + rk808->regmap, pdata); 542 441 if (ret < 0) 543 442 return ret; 443 + 444 + platform_set_drvdata(pdev, pdata); 544 445 545 446 /* Instantiate the regulators */ 546 447 for (i = 0; i < RK808_NUM_REGULATORS; i++) { ··· 593 406 continue; 594 407 595 408 config.dev = &client->dev; 596 - config.driver_data = rk808; 409 + config.driver_data = pdata; 597 410 config.regmap = rk808->regmap; 598 411 config.of_node = rk808_reg_matches[i].of_node; 599 412 config.init_data = rk808_reg_matches[i].init_data; ··· 614 427 .probe = rk808_regulator_probe, 615 428 .driver = { 616 429 .name = "rk808-regulator", 430 + .owner = THIS_MODULE, 617 431 }, 618 432 }; 619 433
+16
include/linux/regulator/consumer.h
··· 550 550 { 551 551 return 0; 552 552 } 553 + 554 + static inline int regulator_list_voltage(struct regulator *regulator, unsigned selector) 555 + { 556 + return -EINVAL; 557 + } 558 + 553 559 #endif 560 + 561 + static inline int regulator_set_voltage_triplet(struct regulator *regulator, 562 + int min_uV, int target_uV, 563 + int max_uV) 564 + { 565 + if (regulator_set_voltage(regulator, target_uV, max_uV) == 0) 566 + return 0; 567 + 568 + return regulator_set_voltage(regulator, min_uV, max_uV); 569 + } 554 570 555 571 static inline int regulator_set_voltage_tol(struct regulator *regulator, 556 572 int new_uV, int tol_uV)