regulator: add QCOM RPMh regulator driver
Subsystems (3)
v6 cover regulator: add QCOM RPMh regulator driver
This patch series adds a driver and device tree binding documentation for PMIC regulator control via Resource Power Manager-hardened (RPMh) on some Qualcomm Technologies, Inc. SoCs such as SDM845. RPMh is a hardware block which contains several accelerators which are used to manage various hardware resources that are shared between the processors of the SoC. The final hardware state of a regulator is determined within RPMh by performing max aggregation of the requests made by all of the processors.
The RPMh regulator driver depends upon the RPMh driver [1] and command DB driver [2] which are both still undergoing review. It also depends upon three recent regulator changes: [3], [4], and [5].
Changes since v5 [6]:
- Removed unused constants
- Added Reviewed-by tag for DT patch 1/2
Changes since v4 [7]:
- Removed support for DT properties qcom,regulator-drms-modes and qcom,drms-mode-max-microamps
- Specified fixed DRMS high power mode minimum limits for LDO type regulators
- Removed DRMS support for SMPS and BOB type regulators
- Simplified voltage caching logic
Changes since v3 [8]:
- Removed support for DT properties qcom,regulator-initial-microvolt and qcom,headroom-microvolt
- Renamed DT property qcom,allowed-drms-modes to be qcom,regulator-drms-modes
- Updated DT binding documentation to mention which common regulator bindings can be used for qcom-rpmh-regulator devices
- Added voltage caching so that voltage requests are only sent to RPMh after the regulator has been enabled at least once
- Changed 'voltage_selector' default value to be -ENOTRECOVERABLE to interact with [5]
- Initialized 'enabled' to -EINVAL so that unused regulators are disabled by regulator_late_cleanup()
- Removed rpmh_regulator_load_default_parameters() as it is no longer needed
- Updated the mode usage description in qcom,rpmh-regulator.h
Changes since v2 [9]:
- Replaced '_' with '-' in device tree supply property names
- Renamed qcom_rpmh-regulator.c to be qcom-rpmh-regulator.c
- Updated various DT property names to use "microvolt" and "microamp"
- Moved allowed modes constraint specification out of the driver [4]
- Replaced rpmh_client with device pointer to match new RPMh API [1]
- Corrected drms mode threshold checking
- Initialized voltage_selector to -EINVAL when not specified in DT
- Added constants for PMIC regulator hardware modes
- Corrected type sign of mode mapping tables
- Made variable names for mode arrays plural
- Simplified Kconfig depends on
- Removed unnecessary constants and struct fields
- Added some descriptive comments
Changes since v1 [10]:
- Addressed review feedback from Doug, Mark, and Stephen
- Replaced set_voltage()/get_voltage() callbacks with set_voltage_sel()/ get_voltage_sel()
- Added set_bypass()/get_bypass() callbacks for BOB pass-through mode control
- Removed top-level PMIC data structures
- Removed initialization variables from structs and passed them as function parameters
- Removed various comments and error messages
- Simplified mode handling
- Refactored per-PMIC rpmh-regulator data specification
- Simplified probe function
- Moved header into DT patch
- Removed redundant property listings from DT binding documentation
[1]: https://lkml.org/lkml/2018/5/9/729
[2]: https://lkml.org/lkml/2018/4/10/714
[3]: https://lkml.org/lkml/2018/4/18/556
[4]: https://lkml.org/lkml/2018/5/11/696
[5]: https://lkml.org/lkml/2018/5/15/1005
[6]: https://lkml.org/lkml/2018/6/1/895
[7]: https://lkml.org/lkml/2018/5/22/1168
[8]: https://lkml.org/lkml/2018/5/11/701
[9]: https://lkml.org/lkml/2018/4/13/687
[10]: https://lkml.org/lkml/2018/3/16/1431
David Collins (2):
regulator: dt-bindings: add QCOM RPMh regulator bindings
regulator: add QCOM RPMh regulator driver
.../bindings/regulator/qcom,rpmh-regulator.txt | 160 +++++ drivers/regulator/Kconfig | 9 + drivers/regulator/Makefile | 1 + drivers/regulator/qcom-rpmh-regulator.c | 767 +++++++++++++++++++++ .../dt-bindings/regulator/qcom,rpmh-regulator.h | 36 + 5 files changed, 973 insertions(+) create mode 100644 Documentation/devicetree/bindings/regulator/qcom,rpmh-regulator.txt create mode 100644 drivers/regulator/qcom-rpmh-regulator.c create mode 100644 include/dt-bindings/regulator/qcom,rpmh-regulator.h
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v6 1/2 regulator: dt-bindings: add QCOM RPMh regulator bindings
Introduce bindings for RPMh regulator devices found on some Qualcomm Technlogies, Inc. SoCs. These devices allow a given processor within the SoC to make PMIC regulator requests which are aggregated within the RPMh hardware block along with requests from other processors in the SoC to determine the final PMIC regulator hardware state.
--- .../bindings/regulator/qcom,rpmh-regulator.txt | 160 +++++++++++++++++++++ .../dt-bindings/regulator/qcom,rpmh-regulator.h | 36 +++++ 2 files changed, 196 insertions(+) create mode 100644 Documentation/devicetree/bindings/regulator/qcom,rpmh-regulator.txt create mode 100644 include/dt-bindings/regulator/qcom,rpmh-regulator.h
Documentation/devicetree/bindings/regulator/qcom,rpmh-regulator.txt new file +160 -0
@@ -0,0 +1,160 @@ +Qualcomm Technologies, Inc. RPMh Regulators + +rpmh-regulator devices support PMIC regulator management via the Voltage +Regulator Manager (VRM) and Oscillator Buffer (XOB) RPMh accelerators. The APPS +processor communicates with these hardware blocks via a Resource State +Coordinator (RSC) using command packets. The VRM allows changing three +parameters for a given regulator: enable state, output voltage, and operating +mode. The XOB allows changing only a single parameter for a given regulator: +its enable state. Despite its name, the XOB is capable of controlling the +enable state of any PMIC peripheral. It is used for clock buffers, low-voltage +switches, and LDO/SMPS regulators which have a fixed voltage and mode. + +======================= +Required Node Structure +======================= + +RPMh regulators must be described in two levels of device nodes. The first +level describes the PMIC containing the regulators and must reside within an +RPMh device node. The second level describes each regulator within the PMIC +which is to be used on the board. Each of these regulators maps to a single +RPMh resource. + +The names used for regulator nodes must match those supported by a given PMIC. +Supported regulator node names: + PM8998: smps1 - smps13, ldo1 - ldo28, lvs1 - lvs2 + PMI8998: bob + PM8005: smps1 - smps4 + +======================== +First Level Nodes - PMIC +======================== + +- compatible + Usage: required + Value type: <string> + Definition: Must be one of: "qcom,pm8998-rpmh-regulators", + "qcom,pmi8998-rpmh-regulators" or + "qcom,pm8005-rpmh-regulators". + +- qcom,pmic-id + Usage: required + Value type: <string> + Definition: RPMh resource name suffix used for the regulators found on + this PMIC. Typical values: "a", "b", "c", "d", "e", "f". + +- vdd-s1-supply +- vdd-s2-supply +- vdd-s3-supply +- vdd-s4-supply + Usage: optional (PM8998 and PM8005 only) + Value type: <phandle> + Definition: phandle of the parent supply regulator of one or more of the + regulators for this PMIC. + +- vdd-s5-supply +- vdd-s6-supply +- vdd-s7-supply +- vdd-s8-supply +- vdd-s9-supply +- vdd-s10-supply +- vdd-s11-supply +- vdd-s12-supply +- vdd-s13-supply +- vdd-l1-l27-supply +- vdd-l2-l8-l17-supply +- vdd-l3-l11-supply +- vdd-l4-l5-supply +- vdd-l6-supply +- vdd-l7-l12-l14-l15-supply +- vdd-l9-supply +- vdd-l10-l23-l25-supply +- vdd-l13-l19-l21-supply +- vdd-l16-l28-supply +- vdd-l18-l22-supply +- vdd-l20-l24-supply +- vdd-l26-supply +- vin-lvs-1-2-supply + Usage: optional (PM8998 only) + Value type: <phandle> + Definition: phandle of the parent supply regulator of one or more of the + regulators for this PMIC. + +- vdd-bob-supply + Usage: optional (PMI8998 only) + Value type: <phandle> + Definition: BOB regulator parent supply phandle + +=============================== +Second Level Nodes - Regulators +=============================== + +- qcom,always-wait-for-ack + Usage: optional + Value type: <empty> + Definition: Boolean flag which indicates that the application processor + must wait for an ACK or a NACK from RPMh for every request + sent for this regulator including those which are for a + strictly lower power state. + +Other properties defined in Documentation/devicetree/bindings/regulator.txt +may also be used. regulator-initial-mode and regulator-allowed-modes may be +specified for VRM regulators using mode values from +include/dt-bindings/regulator/qcom,rpmh-regulator.h. regulator-allow-bypass +may be specified for BOB type regulators managed via VRM. +regulator-allow-set-load may be specified for LDO type regulators managed via +VRM. + +======== +Examples +======== + +#include <dt-bindings/regulator/qcom,rpmh-regulator.h> + +&apps_rsc { + pm8998-rpmh-regulators { + compatible = "qcom,pm8998-rpmh-regulators"; + qcom,pmic-id = "a"; + + vdd-l7-l12-l14-l15-supply = <&pm8998_s5>; + + smps2 { + regulator-min-microvolt = <1100000>; + regulator-max-microvolt = <1100000>; + }; + + pm8998_s5: smps5 { + regulator-min-microvolt = <1904000>; + regulator-max-microvolt = <2040000>; + }; + + ldo7 { + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>; + regulator-allowed-modes = + <RPMH_REGULATOR_MODE_LPM + RPMH_REGULATOR_MODE_HPM>; + regulator-allow-set-load; + }; + + lvs1 { + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + }; + }; + + pmi8998-rpmh-regulators { + compatible = "qcom,pmi8998-rpmh-regulators"; + qcom,pmic-id = "b"; + + bob { + regulator-min-microvolt = <3312000>; + regulator-max-microvolt = <3600000>; + regulator-allowed-modes = + <RPMH_REGULATOR_MODE_AUTO + RPMH_REGULATOR_MODE_HPM>; + regulator-initial-mode = <RPMH_REGULATOR_MODE_AUTO>; + }; + }; +};
include/dt-bindings/regulator/qcom,rpmh-regulator.h new file +36 -0
@@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (c) 2018, The Linux Foundation. All rights reserved. */ + +#ifndef __QCOM_RPMH_REGULATOR_H +#define __QCOM_RPMH_REGULATOR_H + +/* +* These mode constants may be used to specify modes for various RPMh regulator +* device tree properties (e.g. regulator-initial-mode). Each type of regulator +* supports a subset of the possible modes. +* +* %RPMH_REGULATOR_MODE_RET: Retention mode in which only an extremely small +* load current is allowed. This mode is supported +* by LDO and SMPS type regulators. +* %RPMH_REGULATOR_MODE_LPM: Low power mode in which a small load current is +* allowed. This mode corresponds to PFM for SMPS +* and BOB type regulators. This mode is supported +* by LDO, HFSMPS, BOB, and PMIC4 FTSMPS type +* regulators. +* %RPMH_REGULATOR_MODE_AUTO: Auto mode in which the regulator hardware +* automatically switches between LPM and HPM based +* upon the real-time load current. This mode is +* supported by HFSMPS, BOB, and PMIC4 FTSMPS type +* regulators. +* %RPMH_REGULATOR_MODE_HPM: High power mode in which the full rated current +* of the regulator is allowed. This mode +* corresponds to PWM for SMPS and BOB type +* regulators. This mode is supported by all types +* of regulators. +*/ +#define RPMH_REGULATOR_MODE_RET 0 +#define RPMH_REGULATOR_MODE_LPM 1 +#define RPMH_REGULATOR_MODE_AUTO 2 +#define RPMH_REGULATOR_MODE_HPM 3 + +#endif
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH v6 1/2] regulator: dt-bindings: add QCOM RPMh regulator bindings
Hi,
Quoted 7 lines · David Collins
Introduce bindings for RPMh regulator devices found on some Qualcomm Technlogies, Inc. SoCs. These devices allow a given processor within the SoC to make PMIC regulator requests which are aggregated within the RPMh hardware block along with requests from other processors in the SoC to determine the final PMIC regulator hardware state.
Quoted 6 lines
Signed-off-by David Collins <[email protected]>Reviewed-by Rob Herring <[email protected]>--- .../bindings/regulator/qcom,rpmh-regulator.txt | 160 +++++++++++++++++++++ .../dt-bindings/regulator/qcom,rpmh-regulator.h | 36 +++++ 2 files changed, 196 insertions(+)
PATCH v6 2/2 regulator: add QCOM RPMh regulator driver
In reply to David CollinsAdd the QCOM RPMh regulator driver to manage PMIC regulators which are controlled via RPMh on some Qualcomm Technologies, Inc. SoCs. RPMh is a hardware block which contains several accelerators which are used to manage various hardware resources that are shared between the processors of the SoC. The final hardware state of a regulator is determined within RPMh by performing max aggregation of the requests made by all of the processors.
Add support for PMIC regulator control via the voltage regulator manager (VRM) and oscillator buffer (XOB) RPMh accelerators. VRM supports manipulation of enable state, voltage, and mode. XOB supports manipulation of enable state.
--- drivers/regulator/Kconfig | 9 + drivers/regulator/Makefile | 1 + drivers/regulator/qcom-rpmh-regulator.c | 767 ++++++++++++++++++++++++++++++++ 3 files changed, 777 insertions(+) create mode 100644 drivers/regulator/qcom-rpmh-regulator.c
drivers/regulator/Kconfig +9 -0
@@ -671,6 +671,15 @@ config REGULATOR_QCOM_RPM Qualcomm RPM as a module. The module will be named "qcom_rpm-regulator". +config REGULATOR_QCOM_RPMH + tristate "Qualcomm Technologies, Inc. RPMh regulator driver" + depends on QCOM_RPMH || COMPILE_TEST + help + This driver supports control of PMIC regulators via the RPMh hardware + block found on Qualcomm Technologies Inc. SoCs. RPMh regulator + control allows for voting on regulator state between multiple + processors within the SoC. + config REGULATOR_QCOM_SMD_RPM tristate "Qualcomm SMD based RPM regulator driver" depends on QCOM_SMD_RPM
drivers/regulator/Makefile +1 -0
@@ -77,6 +77,7 @@ obj-$(CONFIG_REGULATOR_MT6323) += mt6323-regulator.o obj-$(CONFIG_REGULATOR_MT6380) += mt6380-regulator.o obj-$(CONFIG_REGULATOR_MT6397) += mt6397-regulator.o obj-$(CONFIG_REGULATOR_QCOM_RPM) += qcom_rpm-regulator.o +obj-$(CONFIG_REGULATOR_QCOM_RPMH) += qcom-rpmh-regulator.o obj-$(CONFIG_REGULATOR_QCOM_SMD_RPM) += qcom_smd-regulator.o obj-$(CONFIG_REGULATOR_QCOM_SPMI) += qcom_spmi-regulator.o obj-$(CONFIG_REGULATOR_PALMAS) += palmas-regulator.o
drivers/regulator/qcom-rpmh-regulator.c new file +767 -0
767 lines not on this page · raw message
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Hi,
Quoted 14 lines · David Collins
Add the QCOM RPMh regulator driver to manage PMIC regulators which are controlled via RPMh on some Qualcomm Technologies, Inc. SoCs. RPMh is a hardware block which contains several accelerators which are used to manage various hardware resources that are shared between the processors of the SoC. The final hardware state of a regulator is determined within RPMh by performing max aggregation of the requests made by all of the processors.
Add support for PMIC regulator control via the voltage regulator manager (VRM) and oscillator buffer (XOB) RPMh accelerators. VRM supports manipulation of enable state, voltage, and mode. XOB supports manipulation of enable state.
Quoted 6 lines
Signed-off-by David Collins <[email protected]>--- drivers/regulator/Kconfig | 9 + drivers/regulator/Makefile | 1 + drivers/regulator/qcom-rpmh-regulator.c | 767 ++++++++++++++++++++++++++++++++ 3 files changed, 777 insertions(+)
Assuming Mark is OK with this, it looks good to me now. My previous feedback is resolved and I'm OK with the hardcoded current loads in the driver for now until we come up with something better.
NOTE: Presumably this can't actually land anywhere :( until the RPMh patchset lands somewhere and that's still sitting in limbo waiting for Qualcomm to spin the patches. Presumably once RPMh lands someone will need to put it somewhere that can be pulled into the relevant trees so we don't need to wait for a whole merge window...
-Doug
Hi David,
Quoted 31 lines · David Collins
Add the QCOM RPMh regulator driver to manage PMIC regulators which are controlled via RPMh on some Qualcomm Technologies, Inc. SoCs. RPMh is a hardware block which contains several accelerators which are used to manage various hardware resources that are shared between the processors of the SoC. The final hardware state of a regulator is determined within RPMh by performing max aggregation of the requests made by all of the processors.
Add support for PMIC regulator control via the voltage regulator manager (VRM) and oscillator buffer (XOB) RPMh accelerators. VRM supports manipulation of enable state, voltage, and mode. XOB supports manipulation of enable state.
Signed-off-by David Collins <[email protected]>--- drivers/regulator/Kconfig | 9 + drivers/regulator/Makefile | 1 + drivers/regulator/qcom-rpmh-regulator.c | 767 ++++++++++++++++++++++++++++++++ 3 files changed, 777 insertions(+) create mode 100644 drivers/regulator/qcom-rpmh-regulator.c...
drivers/regulator/qcom-rpmh-regulator.c new file +0
-0
Quoted 3 lines
static int rpmh_regulator_send_request(struct
rpmh_vreg*vreg,
+ structtcs_cmd*cmd, int count, boolwait_for_ack)
nit: as of now this is only called with a single command. If you anticipate that this is unlikely to change consider removing 'count', not having it in the calls slightly improves readability.
Quoted 9 lines
...
drivers/regulator/qcom-rpmh-regulator.c new file +8
-0+static int _rpmh_regulator_vrm_set_voltage_sel (struct regulator_dev *rdev, +unsigned int selector,bool wait_for_ack) +{ +struct rpmh_vreg *vreg =rdev_get_drvdata (rdev); +struct tcs_cmd cmd = { + .addr = vreg->addr +RPMH_REGULATOR_REG_VRM_VOLTAGE , + }; +int ret;
drivers/regulator/qcom-rpmh-regulator.c line 181
Quoted 10 lines
drivers/regulator/qcom-rpmh-regulator.c new file +10
-0+ +/* VRM voltage control register is set with voltage in millivolts. */ + cmd.data =DIV_ROUND_UP (regulator_list_voltage_linear_range (rdev, + selector),1000 ); + + ret =rpmh_regulator_send_request (vreg, &cmd,1 , wait_for_ack); +if (!ret) + vreg->voltage_selector = selector; + +return 0 ;
Shouldn't this return 'ret'?
Quoted 37 lines
drivers/regulator/qcom-rpmh-regulator.c new file +37
-0+static int rpmh_regulator_enable (struct regulator_dev *rdev) +{ +struct rpmh_vreg *vreg =rdev_get_drvdata (rdev); +struct tcs_cmd cmd = { + .addr = vreg->addr +RPMH_REGULATOR_REG_ENABLE , + .data =1 , + }; +int ret; + +if (vreg->enabled == -EINVAL && + vreg->voltage_selector != -ENOTRECOVERABLE ) { + ret =_rpmh_regulator_vrm_set_voltage_sel (rdev, + vreg->voltage_selector, true); +if (ret <0 ) +return ret; + } + + ret =rpmh_regulator_send_request (vreg, &cmd,1 , true); +if (!ret) + vreg->enabled = true; + +return ret; +} + +static int rpmh_regulator_disable (struct regulator_dev *rdev) +{ +struct rpmh_vreg *vreg =rdev_get_drvdata (rdev); +struct tcs_cmd cmd = { + .addr = vreg->addr +RPMH_REGULATOR_REG_ENABLE , + .data =0 , + }; +int ret; + +if (vreg->enabled == -EINVAL && + vreg->voltage_selector != -ENOTRECOVERABLE ) { + ret =_rpmh_regulator_vrm_set_voltage_sel (rdev, + vreg->voltage_selector, true);
drivers/regulator/qcom-rpmh-regulator.c line 262
Quoted 10 lines
drivers/regulator/qcom-rpmh-regulator.c new file +10
-0+if (ret <0 ) +return ret; + } + + ret =rpmh_regulator_send_request (vreg, &cmd,1 , false); +if (!ret) + vreg->enabled = false; + +return ret; +}
nit: rpmh_regulator_enable() and rpmh_regulator_disable() are essentially the same code, consider introducing a helper like _rpmh_regulator_enable(struct regulator_dev *rdev, bool enable).
Quoted 18 lines
drivers/regulator/qcom-rpmh-regulator.c new file +18
-0+/** +* rpmh_regulator_init_vreg() - initialize all attributes of an rpmh-regulator +* vreg: Pointer to the individual rpmh-regulator resource +* dev: Pointer to the top level rpmh-regulator PMIC device +* node: Pointer to the individual rpmh-regulator resource +* device node +* pmic_id: String used to identify the top level rpmh-regulator +* PMIC device on the board +* rpmh_data: Pointer to a null-terminated array of rpmh-regulator +* resources defined for the top level PMIC device +* +* Return: 0 on success, errno on failure +*/ +static int rpmh_regulator_init_vreg (struct rpmh_vreg *vreg,struct device *dev, +struct device_node *node,const char *pmic_id, +const struct rpmh_vreg_init_data *rpmh_data) +{ +struct regulator_config reg_config = {};
drivers/regulator/qcom-rpmh-regulator.c line 426
Quoted 10 lines
drivers/regulator/qcom-rpmh-regulator.c new file +10
-0+char rpmh_resource_name[20 ] ="" ; +struct regulator_dev *rdev; +struct regulator_init_data *init_data; +int ret; + + vreg->dev = dev; + +for (; rpmh_data->name; rpmh_data++) +if (!strcmp (rpmh_data->name, node->name)) +break ;
nit: it's a bit odd to use the parameter itself for iteration, but I guess it's a matter of preferences.
Thanks
Matthias
Hello Matthias,
Quoted 8 lines · Matthias Kaehlcke
Quoted 3 lines · David Collins
static int rpmh_regulator_send_request(struct
rpmh_vreg*vreg,
+ structtcs_cmd*cmd, int count, boolwait_for_ack)nit: as of now this is only called with a single command. If you anticipate that this is unlikely to change consider removing 'count', not having it in the calls slightly improves readability.
The count parameter was needed in the original version of the patch. That need is no longer present after removing features in subsequent versions.
I'll remove this parameter.
Quoted 12 lines
Quoted 12 lines
drivers/regulator/qcom-rpmh-regulator.c new file +12
-0+static int _rpmh_regulator_vrm_set_voltage_sel (struct regulator_dev *rdev, +unsigned int selector,bool wait_for_ack) +{ +struct rpmh_vreg *vreg =rdev_get_drvdata (rdev); +struct tcs_cmd cmd = { + .addr = vreg->addr +RPMH_REGULATOR_REG_VRM_VOLTAGE , + }; +int ret; + +/* VRM voltage control register is set with voltage in millivolts. */ + cmd.data =DIV_ROUND_UP (regulator_list_voltage_linear_range (rdev, + selector),1000 );
Quoted 8 lines
drivers/regulator/qcom-rpmh-regulator.c line 181
Quoted 6 lines
drivers/regulator/qcom-rpmh-regulator.c new file +6
-0+ + ret =rpmh_regulator_send_request (vreg, &cmd,1 , wait_for_ack); +if (!ret) + vreg->voltage_selector = selector; + +return 0 ;Shouldn't this return 'ret'?
Yes; good catch. I'll fix it.
Quoted 43 lines
Quoted 43 lines
drivers/regulator/qcom-rpmh-regulator.c new file +43
-0+static int rpmh_regulator_enable (struct regulator_dev *rdev) +{ +struct rpmh_vreg *vreg =rdev_get_drvdata (rdev); +struct tcs_cmd cmd = { + .addr = vreg->addr +RPMH_REGULATOR_REG_ENABLE , + .data =1 , + }; +int ret; + +if (vreg->enabled == -EINVAL && + vreg->voltage_selector != -ENOTRECOVERABLE ) { + ret =_rpmh_regulator_vrm_set_voltage_sel (rdev, + vreg->voltage_selector, true); +if (ret <0 ) +return ret; + } + + ret =rpmh_regulator_send_request (vreg, &cmd,1 , true); +if (!ret) + vreg->enabled = true; + +return ret; +} + +static int rpmh_regulator_disable (struct regulator_dev *rdev) +{ +struct rpmh_vreg *vreg =rdev_get_drvdata (rdev); +struct tcs_cmd cmd = { + .addr = vreg->addr +RPMH_REGULATOR_REG_ENABLE , + .data =0 , + }; +int ret; + +if (vreg->enabled == -EINVAL && + vreg->voltage_selector != -ENOTRECOVERABLE ) { + ret =_rpmh_regulator_vrm_set_voltage_sel (rdev, + vreg->voltage_selector, true); +if (ret <0 ) +return ret; + } + + ret =rpmh_regulator_send_request (vreg, &cmd,1 , false); +if (!ret)
Quoted 8 lines
drivers/regulator/qcom-rpmh-regulator.c line 262
Quoted 4 lines
drivers/regulator/qcom-rpmh-regulator.c new file +4
-0+ vreg->enabled = false; + +return ret; +}nit:
rpmh_regulator_enable()andrpmh_regulator_disable()are essentially the same code, consider introducing a helper like_rpmh_regulator_enable(struct regulator_dev *rdev, bool enable).
Sure, I'll add a helper function.
Quoted 10 lines
Quoted 10 lines
drivers/regulator/qcom-rpmh-regulator.c new file +10
-0+static int rpmh_regulator_init_vreg (struct rpmh_vreg *vreg,struct device *dev, +struct device_node *node,const char *pmic_id, +const struct rpmh_vreg_init_data *rpmh_data) +{ +struct regulator_config reg_config = {}; +char rpmh_resource_name[20 ] ="" ; +struct regulator_dev *rdev; +struct regulator_init_data *init_data; +int ret; +
Quoted 8 lines
drivers/regulator/qcom-rpmh-regulator.c line 426
Quoted 5 lines
drivers/regulator/qcom-rpmh-regulator.c new file +5
-0+ vreg->dev = dev; + +for (; rpmh_data->name; rpmh_data++) +if (!strcmp (rpmh_data->name, node->name)) +break ;nit: it's a bit odd to use the parameter itself for iteration, but I guess it's a matter of preferences.
I'll change this to add a specific iterator so that it is less surprising.
Thanks,
David
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project