aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/regulator/of_regulator.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
index 64c09a37ac7f..163946075656 100644
--- a/drivers/regulator/of_regulator.c
+++ b/drivers/regulator/of_regulator.c
@@ -25,7 +25,8 @@ static const char *const regulator_states[PM_SUSPEND_MAX + 1] = {
25}; 25};
26 26
27static void of_get_regulation_constraints(struct device_node *np, 27static void of_get_regulation_constraints(struct device_node *np,
28 struct regulator_init_data **init_data) 28 struct regulator_init_data **init_data,
29 const struct regulator_desc *desc)
29{ 30{
30 const __be32 *min_uV, *max_uV; 31 const __be32 *min_uV, *max_uV;
31 struct regulation_constraints *constraints = &(*init_data)->constraints; 32 struct regulation_constraints *constraints = &(*init_data)->constraints;
@@ -81,6 +82,19 @@ static void of_get_regulation_constraints(struct device_node *np,
81 if (!ret) 82 if (!ret)
82 constraints->enable_time = pval; 83 constraints->enable_time = pval;
83 84
85 if (!of_property_read_u32(np, "regulator-initial-mode", &pval)) {
86 if (desc && desc->of_map_mode) {
87 ret = desc->of_map_mode(pval);
88 if (ret == -EINVAL)
89 pr_err("%s: invalid mode %u\n", np->name, pval);
90 else
91 constraints->initial_mode = ret;
92 } else {
93 pr_warn("%s: mapping for mode %d not defined\n",
94 np->name, pval);
95 }
96 }
97
84 for (i = 0; i < ARRAY_SIZE(regulator_states); i++) { 98 for (i = 0; i < ARRAY_SIZE(regulator_states); i++) {
85 switch (i) { 99 switch (i) {
86 case PM_SUSPEND_MEM: 100 case PM_SUSPEND_MEM:
@@ -100,6 +114,21 @@ static void of_get_regulation_constraints(struct device_node *np,
100 if (!suspend_np || !suspend_state) 114 if (!suspend_np || !suspend_state)
101 continue; 115 continue;
102 116
117 if (!of_property_read_u32(suspend_np, "regulator-mode",
118 &pval)) {
119 if (desc && desc->of_map_mode) {
120 ret = desc->of_map_mode(pval);
121 if (ret == -EINVAL)
122 pr_err("%s: invalid mode %u\n",
123 np->name, pval);
124 else
125 suspend_state->mode = ret;
126 } else {
127 pr_warn("%s: mapping for mode %d not defined\n",
128 np->name, pval);
129 }
130 }
131
103 if (of_property_read_bool(suspend_np, 132 if (of_property_read_bool(suspend_np,
104 "regulator-on-in-suspend")) 133 "regulator-on-in-suspend"))
105 suspend_state->enabled = true; 134 suspend_state->enabled = true;
@@ -140,7 +169,7 @@ struct regulator_init_data *of_get_regulator_init_data(struct device *dev,
140 if (!init_data) 169 if (!init_data)
141 return NULL; /* Out of memory? */ 170 return NULL; /* Out of memory? */
142 171
143 of_get_regulation_constraints(node, &init_data); 172 of_get_regulation_constraints(node, &init_data, desc);
144 return init_data; 173 return init_data;
145} 174}
146EXPORT_SYMBOL_GPL(of_get_regulator_init_data); 175EXPORT_SYMBOL_GPL(of_get_regulator_init_data);