diff options
author | Laxman Dewangan <ldewangan@nvidia.com> | 2012-03-07 15:58:33 +0530 |
---|---|---|
committer | Simone Willett <swillett@nvidia.com> | 2012-04-03 17:54:47 -0700 |
commit | dd9f72af7f35191551037062aa7a690687b58696 (patch) | |
tree | 945393ea9abf206aedf925816c81693b9d2b3214 /drivers/regulator | |
parent | 55affcc6a7eccfbdd9f1c36787d0f90fc45634ed (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>
cherry picked from mainline commit
a4d9f179cc788b7f4b735d32c2e4a3b2562e8240
Change-Id: I2ee7789db67fdeea77c0d6ac2b44876af36c803e
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-on: http://git-master/r/94150
Reviewed-by: Automatic_Commit_Validation_User
Diffstat (limited to 'drivers/regulator')
-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 2fe9d99c9f23..a3c06f648bae 100644 --- a/drivers/regulator/fixed.c +++ b/drivers/regulator/fixed.c @@ -131,6 +131,7 @@ static int __devinit reg_fixed_voltage_probe(struct platform_device *pdev) drvdata->startup_delay = config->startup_delay; if (gpio_is_valid(config->gpio)) { + int gpio_flag; drvdata->enable_high = config->enable_high; /* FIXME: Remove below print warning @@ -148,27 +149,25 @@ static int __devinit reg_fixed_voltage_probe(struct platform_device *pdev) dev_warn(&pdev->dev, "using GPIO 0 for regulator enable control\n"); - ret = gpio_request(config->gpio, config->supply_name); - if (ret) { - dev_err(&pdev->dev, - "Could not obtain regulator enable GPIO %d: %d\n", - config->gpio, ret); - goto err_name; - } - - /* set output direction without changing state + /* + * set output direction without changing state * to prevent glitch */ drvdata->is_enabled = config->enabled_at_boot; ret = drvdata->is_enabled ? config->enable_high : !config->enable_high; + gpio_flag = ret ? GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW; + + if (config->gpio_is_open_drain) + gpio_flag |= GPIOF_OPEN_DRAIN; - ret = gpio_direction_output(config->gpio, ret); + ret = gpio_request_one(config->gpio, gpio_flag, + config->supply_name); if (ret) { dev_err(&pdev->dev, - "Could not configure regulator enable GPIO %d direction: %d\n", + "Could not obtain regulator enable GPIO %d: %d\n", config->gpio, ret); - goto err_gpio; + goto err_name; } } else { |