diff options
-rw-r--r-- | drivers/regulator/fixed.c | 23 | ||||
-rw-r--r-- | include/linux/regulator/fixed.h | 7 |
2 files changed, 18 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; |
diff --git a/include/linux/regulator/fixed.h b/include/linux/regulator/fixed.h index 936a7d8c11a9..f83f7440b488 100644 --- a/include/linux/regulator/fixed.h +++ b/include/linux/regulator/fixed.h | |||
@@ -26,6 +26,12 @@ struct regulator_init_data; | |||
26 | * @gpio: GPIO to use for enable control | 26 | * @gpio: GPIO to use for enable control |
27 | * set to -EINVAL if not used | 27 | * set to -EINVAL if not used |
28 | * @startup_delay: Start-up time in microseconds | 28 | * @startup_delay: Start-up time in microseconds |
29 | * @gpio_is_open_drain: Gpio pin is open drain or normal type. | ||
30 | * If it is open drain type then HIGH will be set | ||
31 | * through PULL-UP with setting gpio as input | ||
32 | * and low will be set as gpio-output with driven | ||
33 | * to low. For non-open-drain case, the gpio will | ||
34 | * will be in output and drive to low/high accordingly. | ||
29 | * @enable_high: Polarity of enable GPIO | 35 | * @enable_high: Polarity of enable GPIO |
30 | * 1 = Active high, 0 = Active low | 36 | * 1 = Active high, 0 = Active low |
31 | * @enabled_at_boot: Whether regulator has been enabled at | 37 | * @enabled_at_boot: Whether regulator has been enabled at |
@@ -43,6 +49,7 @@ struct fixed_voltage_config { | |||
43 | int microvolts; | 49 | int microvolts; |
44 | int gpio; | 50 | int gpio; |
45 | unsigned startup_delay; | 51 | unsigned startup_delay; |
52 | unsigned gpio_is_open_drain:1; | ||
46 | unsigned enable_high:1; | 53 | unsigned enable_high:1; |
47 | unsigned enabled_at_boot:1; | 54 | unsigned enabled_at_boot:1; |
48 | struct regulator_init_data *init_data; | 55 | struct regulator_init_data *init_data; |