diff options
author | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 2014-01-31 00:25:14 -0500 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2014-02-04 13:36:48 -0500 |
commit | 0094050d783bbadffe83effef11a0bda901153ce (patch) | |
tree | 7b0518bc8106f4484ce91729e771b241e00773ea | |
parent | 9c25960cbba1fb452adf6a7b9d740fc4358f7d92 (diff) |
regulator: gpio: add gpios-status for DT
config->gpios[x].flags indicates initial pin status,
and it will be used for drvdata->state
on gpio_regulator_probe().
But, current of_get_gpio_regulator_config() doesn't care
about this flags.
This patch adds new gpios-status property in order to
care about initial pin status.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r-- | Documentation/devicetree/bindings/regulator/gpio-regulator.txt | 1 | ||||
-rw-r--r-- | drivers/regulator/gpio-regulator.c | 11 |
2 files changed, 12 insertions, 0 deletions
diff --git a/Documentation/devicetree/bindings/regulator/gpio-regulator.txt b/Documentation/devicetree/bindings/regulator/gpio-regulator.txt index 63c659800c03..3ecb585e786c 100644 --- a/Documentation/devicetree/bindings/regulator/gpio-regulator.txt +++ b/Documentation/devicetree/bindings/regulator/gpio-regulator.txt | |||
@@ -8,6 +8,7 @@ Required properties: | |||
8 | Optional properties: | 8 | Optional properties: |
9 | - enable-gpio : GPIO to use to enable/disable the regulator. | 9 | - enable-gpio : GPIO to use to enable/disable the regulator. |
10 | - gpios : GPIO group used to control voltage. | 10 | - gpios : GPIO group used to control voltage. |
11 | - gpios-states : gpios pin's initial states. 1 means HIGH | ||
11 | - startup-delay-us : Startup time in microseconds. | 12 | - startup-delay-us : Startup time in microseconds. |
12 | - enable-active-high : Polarity of GPIO is active high (default is low). | 13 | - enable-active-high : Polarity of GPIO is active high (default is low). |
13 | 14 | ||
diff --git a/drivers/regulator/gpio-regulator.c b/drivers/regulator/gpio-regulator.c index bad44f366b3f..ac3a8c732dd8 100644 --- a/drivers/regulator/gpio-regulator.c +++ b/drivers/regulator/gpio-regulator.c | |||
@@ -172,11 +172,22 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np) | |||
172 | if (!config->gpios) | 172 | if (!config->gpios) |
173 | return ERR_PTR(-ENOMEM); | 173 | return ERR_PTR(-ENOMEM); |
174 | 174 | ||
175 | prop = of_find_property(np, "gpios-states", NULL); | ||
176 | if (prop) { | ||
177 | proplen = prop->length / sizeof(int); | ||
178 | if (proplen != config->nr_gpios) { | ||
179 | /* gpios <-> gpios-states mismatch */ | ||
180 | prop = NULL; | ||
181 | } | ||
182 | } | ||
183 | |||
175 | for (i = 0; i < config->nr_gpios; i++) { | 184 | for (i = 0; i < config->nr_gpios; i++) { |
176 | gpio = of_get_named_gpio(np, "gpios", i); | 185 | gpio = of_get_named_gpio(np, "gpios", i); |
177 | if (gpio < 0) | 186 | if (gpio < 0) |
178 | break; | 187 | break; |
179 | config->gpios[i].gpio = gpio; | 188 | config->gpios[i].gpio = gpio; |
189 | if (prop && be32_to_cpup((int *)prop->value + i)) | ||
190 | config->gpios[i].flags = GPIOF_OUT_INIT_HIGH; | ||
180 | } | 191 | } |
181 | 192 | ||
182 | /* Fetch states. */ | 193 | /* Fetch states. */ |