diff options
author | Guenter Roeck <linux@roeck-us.net> | 2013-09-11 19:49:54 -0400 |
---|---|---|
committer | Chanwoo Choi <cw00.choi@samsung.com> | 2013-09-26 20:37:01 -0400 |
commit | 5bfbdc9caa7e16b2a77a62a9f9a63b5693e23716 (patch) | |
tree | c2c38080043b0ae1fba1fe462d691436ba25d9fc /drivers/extcon | |
parent | 7c0f6558f893eb5eddb52ee0fa84c2d43b2c199a (diff) |
extcon: gpio: Add support for active-low presence to detect pins
This patch add 'gpio_active_low' field to 'struct gpio_extcon_data'
to check whether gpio active state is 1(high) or 0(low).
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Diffstat (limited to 'drivers/extcon')
-rw-r--r-- | drivers/extcon/extcon-gpio.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/extcon/extcon-gpio.c b/drivers/extcon/extcon-gpio.c index cd7dbb60f60f..b02c670ef01d 100644 --- a/drivers/extcon/extcon-gpio.c +++ b/drivers/extcon/extcon-gpio.c | |||
@@ -34,6 +34,7 @@ | |||
34 | struct gpio_extcon_data { | 34 | struct gpio_extcon_data { |
35 | struct extcon_dev edev; | 35 | struct extcon_dev edev; |
36 | unsigned gpio; | 36 | unsigned gpio; |
37 | bool gpio_active_low; | ||
37 | const char *state_on; | 38 | const char *state_on; |
38 | const char *state_off; | 39 | const char *state_off; |
39 | int irq; | 40 | int irq; |
@@ -49,6 +50,8 @@ static void gpio_extcon_work(struct work_struct *work) | |||
49 | work); | 50 | work); |
50 | 51 | ||
51 | state = gpio_get_value(data->gpio); | 52 | state = gpio_get_value(data->gpio); |
53 | if (data->gpio_active_low) | ||
54 | state = !state; | ||
52 | extcon_set_state(&data->edev, state); | 55 | extcon_set_state(&data->edev, state); |
53 | } | 56 | } |
54 | 57 | ||
@@ -96,6 +99,7 @@ static int gpio_extcon_probe(struct platform_device *pdev) | |||
96 | 99 | ||
97 | extcon_data->edev.name = pdata->name; | 100 | extcon_data->edev.name = pdata->name; |
98 | extcon_data->gpio = pdata->gpio; | 101 | extcon_data->gpio = pdata->gpio; |
102 | extcon_data->gpio_active_low = pdata->gpio_active_low; | ||
99 | extcon_data->state_on = pdata->state_on; | 103 | extcon_data->state_on = pdata->state_on; |
100 | extcon_data->state_off = pdata->state_off; | 104 | extcon_data->state_off = pdata->state_off; |
101 | if (pdata->state_on && pdata->state_off) | 105 | if (pdata->state_on && pdata->state_off) |