diff options
author | Laxman Dewangan <ldewangan@nvidia.com> | 2012-03-07 05:28:33 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-04-02 18:17:53 -0400 |
commit | a4d9f179cc788b7f4b735d32c2e4a3b2562e8240 (patch) | |
tree | fb4283d9fe5c2aff769e743e30b57ed1b5db1c43 /drivers/regulator/fixed.c | |
parent | d1cf4f65e1eb17bc8768d822755780588e42cf37 (diff) |
regulator: fixed: Support for open drain gpio pin
Adding flag on fixed regulator board configuration structure
to specify whether gpio is open drain type or not.
Passing this information to gpio library when requesting
gpio so that gpio driver can set the pin state accordingly,
for open drain type:
- Pin can be set HIGH as setting as input, PULL UP on
pin make this as HIGH.
- Pin can be set LOW as setting it as output and drive to LOW.
The non-open drain pin can be set HIGH/LOW by setting it to
output and driving it to HIGH/LOW.
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/fixed.c')
-rw-r--r-- | drivers/regulator/fixed.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c index 8a1e22acc202..9a7d70a9c8d7 100644 --- a/drivers/regulator/fixed.c +++ b/drivers/regulator/fixed.c | |||
@@ -202,6 +202,7 @@ static int __devinit reg_fixed_voltage_probe(struct platform_device *pdev) | |||
202 | drvdata->startup_delay = config->startup_delay; | 202 | drvdata->startup_delay = config->startup_delay; |
203 | 203 | ||
204 | if (gpio_is_valid(config->gpio)) { | 204 | if (gpio_is_valid(config->gpio)) { |
205 | int gpio_flag; | ||
205 | drvdata->enable_high = config->enable_high; | 206 | drvdata->enable_high = config->enable_high; |
206 | 207 | ||
207 | /* FIXME: Remove below print warning | 208 | /* FIXME: Remove below print warning |
@@ -219,27 +220,25 @@ static int __devinit reg_fixed_voltage_probe(struct platform_device *pdev) | |||
219 | dev_warn(&pdev->dev, | 220 | dev_warn(&pdev->dev, |
220 | "using GPIO 0 for regulator enable control\n"); | 221 | "using GPIO 0 for regulator enable control\n"); |
221 | 222 | ||
222 | ret = gpio_request(config->gpio, config->supply_name); | 223 | /* |
223 | if (ret) { | 224 | * set output direction without changing state |
224 | dev_err(&pdev->dev, | ||
225 | "Could not obtain regulator enable GPIO %d: %d\n", | ||
226 | config->gpio, ret); | ||
227 | goto err_name; | ||
228 | } | ||
229 | |||
230 | /* set output direction without changing state | ||
231 | * to prevent glitch | 225 | * to prevent glitch |
232 | */ | 226 | */ |
233 | drvdata->is_enabled = config->enabled_at_boot; | 227 | drvdata->is_enabled = config->enabled_at_boot; |
234 | ret = drvdata->is_enabled ? | 228 | ret = drvdata->is_enabled ? |
235 | config->enable_high : !config->enable_high; | 229 | config->enable_high : !config->enable_high; |
230 | gpio_flag = ret ? GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW; | ||
231 | |||
232 | if (config->gpio_is_open_drain) | ||
233 | gpio_flag |= GPIOF_OPEN_DRAIN; | ||
236 | 234 | ||
237 | ret = gpio_direction_output(config->gpio, ret); | 235 | ret = gpio_request_one(config->gpio, gpio_flag, |
236 | config->supply_name); | ||
238 | if (ret) { | 237 | if (ret) { |
239 | dev_err(&pdev->dev, | 238 | dev_err(&pdev->dev, |
240 | "Could not configure regulator enable GPIO %d direction: %d\n", | 239 | "Could not obtain regulator enable GPIO %d: %d\n", |
241 | config->gpio, ret); | 240 | config->gpio, ret); |
242 | goto err_gpio; | 241 | goto err_name; |
243 | } | 242 | } |
244 | 243 | ||
245 | drvdata->desc.ops = &fixed_voltage_gpio_ops; | 244 | drvdata->desc.ops = &fixed_voltage_gpio_ops; |