aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator
diff options
context:
space:
mode:
authorChanwoo Choi <cw00.choi@samsung.com>2014-10-10 07:35:33 -0400
committerMark Brown <broonie@kernel.org>2014-10-20 07:24:13 -0400
commit40e20d68bb3fb1ce2704c886d597918988d3321d (patch)
tree7a3cd0364f863068b7f6f76078eebfbea1423596 /drivers/regulator
parentf114040e3ea6e07372334ade75d1ee0775c355e1 (diff)
regulator: of: Add support for parsing regulator_state for suspend state
The regulation_constraints structure includes specific field to support suspend state for global PMIC SUSPEND/HIBERNATE mode. This patch add support for parsing regulator_state for suspend state. Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com> Acked-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/of_regulator.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
index 7a51814abdc5..b375ffe40df1 100644
--- a/drivers/regulator/of_regulator.c
+++ b/drivers/regulator/of_regulator.c
@@ -19,12 +19,19 @@
19 19
20#include "internal.h" 20#include "internal.h"
21 21
22const char *const regulator_states[PM_SUSPEND_MAX + 1] = {
23 [PM_SUSPEND_MEM] = "regulator-state-mem",
24 [PM_SUSPEND_MAX] = "regulator-state-disk",
25};
26
22static void of_get_regulation_constraints(struct device_node *np, 27static void of_get_regulation_constraints(struct device_node *np,
23 struct regulator_init_data **init_data) 28 struct regulator_init_data **init_data)
24{ 29{
25 const __be32 *min_uV, *max_uV; 30 const __be32 *min_uV, *max_uV;
26 struct regulation_constraints *constraints = &(*init_data)->constraints; 31 struct regulation_constraints *constraints = &(*init_data)->constraints;
27 int ret; 32 struct regulator_state *suspend_state;
33 struct device_node *suspend_np;
34 int ret, i;
28 u32 pval; 35 u32 pval;
29 36
30 constraints->name = of_get_property(np, "regulator-name", NULL); 37 constraints->name = of_get_property(np, "regulator-name", NULL);
@@ -73,6 +80,36 @@ static void of_get_regulation_constraints(struct device_node *np,
73 ret = of_property_read_u32(np, "regulator-enable-ramp-delay", &pval); 80 ret = of_property_read_u32(np, "regulator-enable-ramp-delay", &pval);
74 if (!ret) 81 if (!ret)
75 constraints->enable_time = pval; 82 constraints->enable_time = pval;
83
84 for (i = 0; i < ARRAY_SIZE(regulator_states); i++) {
85 switch (i) {
86 case PM_SUSPEND_MEM:
87 suspend_state = &constraints->state_mem;
88 break;
89 case PM_SUSPEND_MAX:
90 suspend_state = &constraints->state_disk;
91 break;
92 case PM_SUSPEND_ON:
93 case PM_SUSPEND_FREEZE:
94 case PM_SUSPEND_STANDBY:
95 default:
96 continue;
97 };
98
99 suspend_np = of_get_child_by_name(np, regulator_states[i]);
100 if (!suspend_np || !suspend_state)
101 continue;
102
103 if (of_property_read_bool(suspend_np,
104 "regulator-on-in-suspend"))
105 suspend_state->enabled = true;
106 else if (of_property_read_bool(suspend_np,
107 "regulator-off-in-suspend"))
108 suspend_state->disabled = true;
109
110 suspend_state = NULL;
111 suspend_np = NULL;
112 }
76} 113}
77 114
78/** 115/**