]> git.karo-electronics.de Git - linux-beck.git/commitdiff
extcon: gpio: Add support for active-low presence to detect pins
authorGuenter Roeck <linux@roeck-us.net>
Wed, 11 Sep 2013 23:49:54 +0000 (08:49 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Fri, 27 Sep 2013 00:37:01 +0000 (09:37 +0900)
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>
drivers/extcon/extcon-gpio.c
include/linux/extcon/extcon-gpio.h

index cd7dbb60f60f606573a60ab7c2b2e7a2e7ed1842..b02c670ef01dd8d50d6803cab143cb3853240004 100644 (file)
@@ -34,6 +34,7 @@
 struct gpio_extcon_data {
        struct extcon_dev edev;
        unsigned gpio;
+       bool gpio_active_low;
        const char *state_on;
        const char *state_off;
        int irq;
@@ -49,6 +50,8 @@ static void gpio_extcon_work(struct work_struct *work)
                             work);
 
        state = gpio_get_value(data->gpio);
+       if (data->gpio_active_low)
+               state = !state;
        extcon_set_state(&data->edev, state);
 }
 
@@ -96,6 +99,7 @@ static int gpio_extcon_probe(struct platform_device *pdev)
 
        extcon_data->edev.name = pdata->name;
        extcon_data->gpio = pdata->gpio;
+       extcon_data->gpio_active_low = pdata->gpio_active_low;
        extcon_data->state_on = pdata->state_on;
        extcon_data->state_off = pdata->state_off;
        if (pdata->state_on && pdata->state_off)
index 4ce1aa7d29bde9144e3c8cc684043869c5c3c710..4195810f87fe6a3eda2eaf928b3361cb795626b8 100644 (file)
@@ -27,6 +27,9 @@
  * struct gpio_extcon_platform_data - A simple GPIO-controlled extcon device.
  * @name:              The name of this GPIO extcon device.
  * @gpio:              Corresponding GPIO.
+ * @gpio_active_low:   Boolean describing whether gpio active state is 1 or 0
+ *                     If true, low state of gpio means active.
+ *                     If false, high state of gpio means active.
  * @debounce:          Debounce time for GPIO IRQ in ms.
  * @irq_flags:         IRQ Flags (e.g., IRQF_TRIGGER_LOW).
  * @state_on:          print_state is overriden with state_on if attached.
@@ -41,6 +44,7 @@
 struct gpio_extcon_platform_data {
        const char *name;
        unsigned gpio;
+       bool gpio_active_low;
        unsigned long debounce;
        unsigned long irq_flags;