summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Troast <ntroast@codeaurora.org>2016-06-02 17:39:48 -0700
committerKyle Yan <kyan@codeaurora.org>2016-06-28 17:01:30 -0700
commitf6f4829b35699ba8cb7532a58953eb498fff80f0 (patch)
tree855f4792217da29b0bc048e267df68b37c89764a
parenta639c08b808979d77bce460226eadfe3228e5536 (diff)
regulator: rpm-smd-regulator: implement set_load
A recent change to regulator framework replaced the regulator_set_optimum_mode API with regulator_set_load. The regulator_set_load API does the following for regulators which have not implemented set_load(). - determines the most optimal mode for the given load by calling get_optimum_mode() - gets the current mode by calling get_mode() - calls set_mode() if the modes are different and expects the mode to be committed to the hardware The rpm-smd-regulator's get_optimum_mode() remembers the load and uses that for the upcoming get_mode() call. This causes the framework to never call the set_mode API, thereby causing rpm-smd-regulator to never send the load to the RPM. The set_load op was introduced for hardware which does not support the set_mode op. This is convenient since the RPM sets the mode according to the aggregated load requirements. In addition the RPM also supports forcing certain modes which fits well with the set_mode op. Implement the set_load op to send the aggregated load vote to RPM, and repurpose the set_mode op to send the aggregated mode vote to RPM. Remove the get_optimum_mode op since it is no longer required with this change. Repurposing of set_mode should not impact consumers since it has the same effect as before. Instead of sending a load vote which would cause the RPM to select the desired mode the mode will be sent directly. Furthermore, the hpm-min-load device tree property is no longer required since the mode is no longer set based on the hpm-min-load threshold. Remove it. Change-Id: I75cf0b4cfc7a6aec3e6d79da9172ce37ec9d91c1 CRs-Fixed: 1023326 Signed-off-by: Nicholas Troast <ntroast@codeaurora.org>
-rw-r--r--Documentation/devicetree/bindings/regulator/rpm-smd-regulator.txt4
-rw-r--r--arch/arm/boot/dts/qcom/msm-pm8994-rpm-regulator.dtsi41
-rw-r--r--arch/arm/boot/dts/qcom/msm-pmcobalt-rpm-regulator.dtsi36
-rw-r--r--drivers/regulator/rpm-smd-regulator.c149
4 files changed, 86 insertions, 144 deletions
diff --git a/Documentation/devicetree/bindings/regulator/rpm-smd-regulator.txt b/Documentation/devicetree/bindings/regulator/rpm-smd-regulator.txt
index ccefc98e51e5..1eb27f4c1c56 100644
--- a/Documentation/devicetree/bindings/regulator/rpm-smd-regulator.txt
+++ b/Documentation/devicetree/bindings/regulator/rpm-smd-regulator.txt
@@ -31,8 +31,6 @@ Optional properties:
0 or not present = mutex locks used
1 = spinlocks used
- qcom,enable-time: Time in us to delay after enabling the regulator
-- qcom,hpm-min-load: Load current in uA which corresponds to the minimum load
- which requires the regulator to be in high power mode.
- qcom,apps-only: Flag which indicates that the regulator only has
consumers on the application processor. If this flag
is specified, then voltage and current updates are
@@ -271,7 +269,6 @@ rpm-regulator-smpb1 {
qcom,resource-name = "smpb";
qcom,resource-id = <1>;
qcom,regulator-type = <1>;
- qcom,hpm-min-load = <100000>;
compatible = "qcom,rpm-smd-regulator-resource";
status = "disabled";
@@ -305,7 +302,6 @@ rpm-regulator-ldoa2 {
qcom,resource-name = "ldoa";
qcom,resource-id = <2>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
compatible = "qcom,rpm-smd-regulator-resource";
regulator-l2 {
diff --git a/arch/arm/boot/dts/qcom/msm-pm8994-rpm-regulator.dtsi b/arch/arm/boot/dts/qcom/msm-pm8994-rpm-regulator.dtsi
index 8c32136aabd4..711ff81d1c3b 100644
--- a/arch/arm/boot/dts/qcom/msm-pm8994-rpm-regulator.dtsi
+++ b/arch/arm/boot/dts/qcom/msm-pm8994-rpm-regulator.dtsi
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2014, 2016, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -16,7 +16,6 @@
qcom,resource-name = "smpa";
qcom,resource-id = <1>;
qcom,regulator-type = <1>;
- qcom,hpm-min-load = <100000>;
status = "disabled";
regulator-s1 {
@@ -32,7 +31,6 @@
qcom,resource-name = "smpa";
qcom,resource-id = <2>;
qcom,regulator-type = <1>;
- qcom,hpm-min-load = <100000>;
status = "disabled";
regulator-s2 {
@@ -48,7 +46,6 @@
qcom,resource-name = "smpa";
qcom,resource-id = <3>;
qcom,regulator-type = <1>;
- qcom,hpm-min-load = <100000>;
status = "disabled";
regulator-s3 {
@@ -64,7 +61,6 @@
qcom,resource-name = "smpa";
qcom,resource-id = <4>;
qcom,regulator-type = <1>;
- qcom,hpm-min-load = <100000>;
status = "disabled";
regulator-s4 {
@@ -80,7 +76,6 @@
qcom,resource-name = "smpa";
qcom,resource-id = <5>;
qcom,regulator-type = <1>;
- qcom,hpm-min-load = <100000>;
status = "disabled";
regulator-s5 {
@@ -96,7 +91,6 @@
qcom,resource-name = "smpa";
qcom,resource-id = <7>;
qcom,regulator-type = <1>;
- qcom,hpm-min-load = <100000>;
status = "disabled";
regulator-s7 {
@@ -112,7 +106,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <1>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l1 {
@@ -128,7 +121,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <2>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l2 {
@@ -144,7 +136,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <3>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l3 {
@@ -160,7 +151,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <4>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l4 {
@@ -176,7 +166,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <6>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l6 {
@@ -192,7 +181,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <8>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <5000>;
status = "disabled";
regulator-l8 {
@@ -208,7 +196,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <9>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l9 {
@@ -224,7 +211,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <10>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l10 {
@@ -240,7 +226,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <11>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l11 {
@@ -256,7 +241,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <12>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l12 {
@@ -272,7 +256,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <13>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l13 {
@@ -288,7 +271,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <14>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l14 {
@@ -304,7 +286,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <15>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l15 {
@@ -320,7 +301,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <16>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l16 {
@@ -336,7 +316,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <17>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l17 {
@@ -352,7 +331,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <18>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l18 {
@@ -368,7 +346,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <19>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l19 {
@@ -384,7 +361,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <20>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l20 {
@@ -400,7 +376,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <21>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l21 {
@@ -416,7 +391,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <22>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l22 {
@@ -432,7 +406,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <23>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l23 {
@@ -448,7 +421,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <24>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l24 {
@@ -464,7 +436,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <25>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l25 {
@@ -480,7 +451,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <26>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l26 {
@@ -496,7 +466,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <27>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l27 {
@@ -512,7 +481,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <28>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l28 {
@@ -528,7 +496,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <29>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l29 {
@@ -544,7 +511,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <30>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <5000>;
status = "disabled";
regulator-l30 {
@@ -560,7 +526,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <31>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l31 {
@@ -576,7 +541,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <32>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <5000>;
status = "disabled";
regulator-l32 {
@@ -622,7 +586,6 @@
qcom,resource-name = "smpb";
qcom,resource-id = <1>;
qcom,regulator-type = <1>;
- qcom,hpm-min-load = <100000>;
status = "disabled";
regulator-s1 {
@@ -638,7 +601,6 @@
qcom,resource-name = "smpb";
qcom,resource-id = <2>;
qcom,regulator-type = <1>;
- qcom,hpm-min-load = <100000>;
status = "disabled";
regulator-s2 {
@@ -684,7 +646,6 @@
qcom,resource-name = "smpc";
qcom,resource-id = <2>;
qcom,regulator-type = <1>;
- qcom,hpm-min-load = <100000>;
status = "disabled";
regulator-s2 {
diff --git a/arch/arm/boot/dts/qcom/msm-pmcobalt-rpm-regulator.dtsi b/arch/arm/boot/dts/qcom/msm-pmcobalt-rpm-regulator.dtsi
index 03173f93ac85..7a8e71d14291 100644
--- a/arch/arm/boot/dts/qcom/msm-pmcobalt-rpm-regulator.dtsi
+++ b/arch/arm/boot/dts/qcom/msm-pmcobalt-rpm-regulator.dtsi
@@ -17,7 +17,6 @@
qcom,resource-name = "rwcx";
qcom,resource-id = <0>;
qcom,regulator-type = <1>;
- qcom,hpm-min-load = <100000>;
status = "disabled";
regulator-s1 {
@@ -33,7 +32,6 @@
qcom,resource-name = "smpa";
qcom,resource-id = <2>;
qcom,regulator-type = <1>;
- qcom,hpm-min-load = <100000>;
status = "disabled";
regulator-s2 {
@@ -49,7 +47,6 @@
qcom,resource-name = "smpa";
qcom,resource-id = <3>;
qcom,regulator-type = <1>;
- qcom,hpm-min-load = <100000>;
status = "disabled";
regulator-s3 {
@@ -65,7 +62,6 @@
qcom,resource-name = "smpa";
qcom,resource-id = <4>;
qcom,regulator-type = <1>;
- qcom,hpm-min-load = <100000>;
status = "disabled";
regulator-s4 {
@@ -81,7 +77,6 @@
qcom,resource-name = "smpa";
qcom,resource-id = <5>;
qcom,regulator-type = <1>;
- qcom,hpm-min-load = <100000>;
status = "disabled";
regulator-s5 {
@@ -97,7 +92,6 @@
qcom,resource-name = "smpa";
qcom,resource-id = <7>;
qcom,regulator-type = <1>;
- qcom,hpm-min-load = <100000>;
status = "disabled";
regulator-s7 {
@@ -113,7 +107,6 @@
qcom,resource-name = "smpa";
qcom,resource-id = <8>;
qcom,regulator-type = <1>;
- qcom,hpm-min-load = <100000>;
status = "disabled";
regulator-s8 {
@@ -130,7 +123,6 @@
qcom,resource-name = "rwmx";
qcom,resource-id = <0>;
qcom,regulator-type = <1>;
- qcom,hpm-min-load = <100000>;
status = "disabled";
regulator-s9 {
@@ -146,7 +138,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <1>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l1 {
@@ -162,7 +153,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <2>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l2 {
@@ -178,7 +168,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <3>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l3 {
@@ -194,7 +183,6 @@
qcom,resource-name = "rwsm";
qcom,resource-id = <0>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l4 {
@@ -210,7 +198,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <5>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l5 {
@@ -226,7 +213,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <6>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l6 {
@@ -242,7 +228,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <7>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l7 {
@@ -258,7 +243,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <8>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l8 {
@@ -274,7 +258,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <9>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l9 {
@@ -290,7 +273,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <10>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l10 {
@@ -306,7 +288,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <11>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l11 {
@@ -322,7 +303,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <12>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l12 {
@@ -338,7 +318,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <13>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l13 {
@@ -354,7 +333,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <14>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l14 {
@@ -370,7 +348,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <15>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l15 {
@@ -386,7 +363,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <16>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l16 {
@@ -402,7 +378,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <17>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l17 {
@@ -418,7 +393,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <18>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l18 {
@@ -434,7 +408,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <19>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l19 {
@@ -450,7 +423,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <20>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l20 {
@@ -466,7 +438,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <21>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l21 {
@@ -482,7 +453,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <22>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l22 {
@@ -498,7 +468,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <23>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l23 {
@@ -514,7 +483,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <24>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l24 {
@@ -530,7 +498,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <25>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l25 {
@@ -546,7 +513,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <26>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l26 {
@@ -562,7 +528,6 @@
qcom,resource-name = "rwsc";
qcom,resource-id = <0>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l27 {
@@ -578,7 +543,6 @@
qcom,resource-name = "ldoa";
qcom,resource-id = <28>;
qcom,regulator-type = <0>;
- qcom,hpm-min-load = <10000>;
status = "disabled";
regulator-l28 {
diff --git a/drivers/regulator/rpm-smd-regulator.c b/drivers/regulator/rpm-smd-regulator.c
index b38db82c0b0b..d26fd3bea788 100644
--- a/drivers/regulator/rpm-smd-regulator.c
+++ b/drivers/regulator/rpm-smd-regulator.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2015, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -182,7 +182,6 @@ struct rpm_vreg {
u32 resource_id;
bool allow_atomic;
int regulator_type;
- int hpm_min_load;
int enable_time;
spinlock_t slock;
struct mutex mlock;
@@ -336,22 +335,6 @@ static void rpm_vreg_check_param_max(struct rpm_regulator *regulator, int index,
rpm_vreg->wait_for_ack_sleep = true;
}
-/*
- * This is used when voting for LPM or HPM by subtracting or adding to the
- * hpm_min_load of a regulator. It has units of uA.
- */
-#define LOAD_THRESHOLD_STEP 1000
-
-static inline int rpm_vreg_hpm_min_uA(struct rpm_vreg *rpm_vreg)
-{
- return rpm_vreg->hpm_min_load;
-}
-
-static inline int rpm_vreg_lpm_max_uA(struct rpm_vreg *rpm_vreg)
-{
- return rpm_vreg->hpm_min_load - LOAD_THRESHOLD_STEP;
-}
-
#define MICRO_TO_MILLI(uV) ((uV) / 1000)
#define MILLI_TO_MICRO(uV) ((uV) * 1000)
@@ -864,47 +847,49 @@ static int rpm_vreg_get_voltage(struct regulator_dev *rdev)
return uV;
}
+static const struct rpm_regulator_mode_map vreg_mode_mapping[] = {
+ [REGULATOR_MODE_NORMAL] = {
+ RPM_REGULATOR_LDO_MODE_HPM,
+ RPM_REGULATOR_SMPS_MODE_PWM,
+ },
+ [REGULATOR_MODE_IDLE] = {
+ RPM_REGULATOR_LDO_MODE_IPEAK,
+ RPM_REGULATOR_SMPS_MODE_AUTO,
+ },
+};
+
static int rpm_vreg_set_mode(struct regulator_dev *rdev, unsigned int mode)
{
struct rpm_regulator *reg = rdev_get_drvdata(rdev);
- int rc = 0;
- u32 prev_current;
- int prev_uA;
-
- rpm_vreg_lock(reg->rpm_vreg);
+ int index = 0;
+ u32 rpm_mode, prev_mode;
+ int rc;
- prev_current = reg->req.param[RPM_REGULATOR_PARAM_CURRENT];
- prev_uA = MILLI_TO_MICRO(prev_current);
-
- if (mode == REGULATOR_MODE_NORMAL) {
- /* Make sure that request current is in HPM range. */
- if (prev_uA < rpm_vreg_hpm_min_uA(reg->rpm_vreg))
- RPM_VREG_SET_PARAM(reg, CURRENT,
- MICRO_TO_MILLI(rpm_vreg_hpm_min_uA(reg->rpm_vreg)));
- } else if (REGULATOR_MODE_IDLE) {
- /* Make sure that request current is in LPM range. */
- if (prev_uA > rpm_vreg_lpm_max_uA(reg->rpm_vreg))
- RPM_VREG_SET_PARAM(reg, CURRENT,
- MICRO_TO_MILLI(rpm_vreg_lpm_max_uA(reg->rpm_vreg)));
- } else {
- vreg_err(reg, "invalid mode: %u\n", mode);
- rpm_vreg_unlock(reg->rpm_vreg);
+ switch (reg->rpm_vreg->regulator_type) {
+ case RPM_REGULATOR_TYPE_SMPS:
+ index = RPM_REGULATOR_PARAM_MODE_SMPS;
+ rpm_mode = vreg_mode_mapping[mode].smps_mode;
+ break;
+ case RPM_REGULATOR_TYPE_LDO:
+ index = RPM_REGULATOR_PARAM_MODE_LDO;
+ rpm_mode = vreg_mode_mapping[mode].ldo_mode;
+ break;
+ default:
+ vreg_err(reg, "unsupported regulator type: %d\n",
+ reg->rpm_vreg->regulator_type);
return -EINVAL;
}
- /*
- * Only send a new load current value if the regulator is currently
- * enabled or if the regulator has been configured to always send
- * current updates.
- */
- if (reg->always_send_current
- || rpm_vreg_active_or_sleep_enabled(reg->rpm_vreg)
- || rpm_vreg_shared_active_or_sleep_enabled_valid(reg->rpm_vreg))
- rc = rpm_vreg_aggregate_requests(reg);
+ rpm_vreg_lock(reg->rpm_vreg);
+ prev_mode = reg->req.param[index];
+ reg->req.param[index] = rpm_mode;
+ reg->req.modified |= BIT(index);
+
+ rc = rpm_vreg_aggregate_requests(reg);
if (rc) {
- vreg_err(reg, "set mode failed, rc=%d\n", rc);
- RPM_VREG_SET_PARAM(reg, CURRENT, prev_current);
+ vreg_err(reg, "set mode failed, rc=%d", rc);
+ reg->req.param[index] = prev_mode;
}
rpm_vreg_unlock(reg->rpm_vreg);
@@ -915,30 +900,68 @@ static int rpm_vreg_set_mode(struct regulator_dev *rdev, unsigned int mode)
static unsigned int rpm_vreg_get_mode(struct regulator_dev *rdev)
{
struct rpm_regulator *reg = rdev_get_drvdata(rdev);
+ unsigned int rpm_mode;
+
+ switch (reg->rpm_vreg->regulator_type) {
+ case RPM_REGULATOR_TYPE_SMPS:
+ rpm_mode = reg->req.param[RPM_REGULATOR_PARAM_MODE_SMPS];
+ if (rpm_mode ==
+ vreg_mode_mapping[REGULATOR_MODE_IDLE].smps_mode)
+ return REGULATOR_MODE_IDLE;
+ else
+ return REGULATOR_MODE_NORMAL;
+ break;
+ case RPM_REGULATOR_TYPE_LDO:
+ rpm_mode = reg->req.param[RPM_REGULATOR_PARAM_MODE_LDO];
+ if (rpm_mode ==
+ vreg_mode_mapping[REGULATOR_MODE_IDLE].ldo_mode)
+ return REGULATOR_MODE_IDLE;
+ else
+ return REGULATOR_MODE_NORMAL;
+ break;
+ default:
+ vreg_err(reg, "unsupported regulator type %d\n",
+ reg->rpm_vreg->regulator_type);
+ break;
+ }
- return (reg->req.param[RPM_REGULATOR_PARAM_CURRENT]
- >= MICRO_TO_MILLI(reg->rpm_vreg->hpm_min_load))
- ? REGULATOR_MODE_NORMAL : REGULATOR_MODE_IDLE;
+ return REGULATOR_MODE_NORMAL;
}
-static unsigned int rpm_vreg_get_optimum_mode(struct regulator_dev *rdev,
- int input_uV, int output_uV, int load_uA)
+static int rpm_vreg_set_load(struct regulator_dev *rdev, int load_uA)
{
struct rpm_regulator *reg = rdev_get_drvdata(rdev);
+ int rc = 0;
u32 load_mA;
+ u32 prev_load_mA;
- load_uA += reg->system_load;
+ rpm_vreg_lock(reg->rpm_vreg);
- load_mA = MICRO_TO_MILLI(load_uA);
+ load_mA = MICRO_TO_MILLI(load_uA + reg->system_load);
if (load_mA > params[RPM_REGULATOR_PARAM_CURRENT].max)
load_mA = params[RPM_REGULATOR_PARAM_CURRENT].max;
- rpm_vreg_lock(reg->rpm_vreg);
+ prev_load_mA = reg->req.param[RPM_REGULATOR_PARAM_CURRENT];
RPM_VREG_SET_PARAM(reg, CURRENT, load_mA);
+
+ /*
+ * Only send a new load current value if the regulator is currently
+ * enabled or if the regulator has been configured to always send
+ * current updates.
+ */
+ if (reg->always_send_current
+ || rpm_vreg_active_or_sleep_enabled(reg->rpm_vreg)
+ || rpm_vreg_shared_active_or_sleep_enabled_valid(reg->rpm_vreg))
+ rc = rpm_vreg_aggregate_requests(reg);
+
+ if (rc) {
+ vreg_err(reg, "set mode failed, rc=%d\n", rc);
+ RPM_VREG_SET_PARAM(reg, CURRENT, prev_load_mA);
+ }
+
rpm_vreg_unlock(reg->rpm_vreg);
- return (load_uA >= reg->rpm_vreg->hpm_min_load)
- ? REGULATOR_MODE_NORMAL : REGULATOR_MODE_IDLE;
+ return rc;
}
static int rpm_vreg_set_bob_mode(struct regulator_dev *rdev, unsigned int mode)
@@ -1363,7 +1386,7 @@ static struct regulator_ops ldo_ops = {
.get_voltage = rpm_vreg_get_voltage,
.set_mode = rpm_vreg_set_mode,
.get_mode = rpm_vreg_get_mode,
- .get_optimum_mode = rpm_vreg_get_optimum_mode,
+ .set_load = rpm_vreg_set_load,
.enable_time = rpm_vreg_enable_time,
};
@@ -1375,7 +1398,7 @@ static struct regulator_ops smps_ops = {
.get_voltage = rpm_vreg_get_voltage,
.set_mode = rpm_vreg_set_mode,
.get_mode = rpm_vreg_get_mode,
- .get_optimum_mode = rpm_vreg_get_optimum_mode,
+ .set_load = rpm_vreg_set_load,
.enable_time = rpm_vreg_enable_time,
};
@@ -1812,8 +1835,6 @@ static int rpm_vreg_resource_probe(struct platform_device *pdev)
of_property_read_u32(node, "qcom,allow-atomic", &val);
rpm_vreg->allow_atomic = !!val;
of_property_read_u32(node, "qcom,enable-time", &rpm_vreg->enable_time);
- of_property_read_u32(node, "qcom,hpm-min-load",
- &rpm_vreg->hpm_min_load);
rpm_vreg->apps_only = of_property_read_bool(node, "qcom,apps-only");
rpm_vreg->always_wait_for_ack
= of_property_read_bool(node, "qcom,always-wait-for-ack");