]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
extcon: gpio-state: add dt property for wait timeout for gpio scan
authorLaxman Dewangan <ldewangan@nvidia.com>
Wed, 20 Jan 2016 10:05:21 +0000 (15:35 +0530)
committermobile promotions <svcmobile_promotions@nvidia.com>
Fri, 19 Feb 2016 02:06:58 +0000 (18:06 -0800)
Add wait timeout for all gpio scan after gpio settled down.
This wait timeout time helps to appear all gpio interrupt
and serve before all gpios states are scanned for cable.

Change-Id: I86853e758f1b04d1b290b79bc20115dca0ee5f27
Reviewed-on: http://git-master/r/935029
(cherry picked from commit 9ae6861da16ab0ae73dd52d94c24ff3010934c99)
Signed-off-by: Venkat Reddy Talla <vreddytalla@nvidia.com>
Reviewed-on: http://git-master/r/1011843
GVS: Gerrit_Virtual_Submit
Reviewed-by: Bitan Biswas <bbiswas@nvidia.com>
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Documentation/devicetree/bindings/extcon/extcon-gpio-states.txt [new file with mode: 0644]
drivers/extcon/extcon-gpio-states.c

diff --git a/Documentation/devicetree/bindings/extcon/extcon-gpio-states.txt b/Documentation/devicetree/bindings/extcon/extcon-gpio-states.txt
new file mode 100644 (file)
index 0000000..10f43b4
--- /dev/null
@@ -0,0 +1,25 @@
+EXTCON FOR GPIO-STATES
+
+Required Properties:
+ - compatible : Should be "extcon-gpio-states";
+
+Optional Properties:
+ - extcon-gpio,name: Name of extcon device.
+ - gpios: List of teh gpios.
+ - extcon-gpio,irq-flags: IRQ flags for GPIO.
+ - extcon-gpio,debounce: Debounce time in ms.
+ - extcon-gpio,wait-for-gpio-scan: Wait timeout for scanning all gpio states
+       after chnage found in gpio and debounce timeof gpio is completed.
+ - extcon-gpio,out-cable-names: Output cable names.
+ - extcon-gpio,cable-states: GPIO states and ther corresponding output cable
+       state. This is array of the data for table as
+               gpio-state <-> output cable-state
+extcon-gpio {
+       compatible = "extcon-gpio-states";
+               gpio = <&gpio 20 0 &gpio 30 0>;
+       extcon-gpio,cable-states = <0x00 0x00
+                                   0x01 0x01
+                                   0x02 0x02
+                                   0x03 0x4>;
+       extcon-gpio,out-cable-names = "vbus", "host", "otg-y-cable";
+};
index d0e5ba990ac21b258dfdd1bd2bb5d5ee30aa11d6..1f466228a2d28b587863c637ebfb213ab4bdd757 100644 (file)
@@ -48,6 +48,7 @@ struct gpio_info {
 struct gpio_extcon_platform_data {
        const char *name;
        unsigned long debounce;
+       unsigned long wait_for_gpio_scan;
        unsigned long irq_flags;
        struct gpio_info *gpios;
        int n_gpio;
@@ -64,7 +65,7 @@ struct gpio_extcon_info {
        struct delayed_work work;
        unsigned long debounce_jiffies;
        struct timer_list timer;
-       int timer_to_work_jiffies;
+       int gpio_scan_work_jiffies;
        spinlock_t lock;
        int *gpio_curr_state;
        struct gpio_extcon_platform_data *pdata;
@@ -72,7 +73,7 @@ struct gpio_extcon_info {
        int cable_detect_jiffies;
 };
 
-static void gpio_extcon_work(struct work_struct *work)
+static void gpio_extcon_scan_work(struct work_struct *work)
 {
        int state = 0;
        int cstate = -1;
@@ -111,7 +112,7 @@ static void gpio_extcon_notifier_timer(unsigned long _data)
        if (!wake_lock_active(&gpex->wake_lock))
                wake_lock_timeout(&gpex->wake_lock, gpex->cable_detect_jiffies);
 
-       schedule_delayed_work(&gpex->work, gpex->timer_to_work_jiffies);
+       schedule_delayed_work(&gpex->work, gpex->gpio_scan_work_jiffies);
 }
 
 static irqreturn_t gpio_irq_handler(int irq, void *dev_id)
@@ -184,6 +185,13 @@ static struct gpio_extcon_platform_data *of_get_platform_data(
        else
                pdata->cable_detect_delay = EXTCON_GPIO_STATE_WAKEUP_TIME;
 
+       ret = of_property_read_u32(np, "extcon-gpio,wait-for-gpio-scan", &pval);
+       if (!ret)
+               pdata->wait_for_gpio_scan = pval;
+       else
+               pdata->wait_for_gpio_scan = 100;
+
+
        pdata->n_out_cables = of_property_count_strings(np,
                                        "extcon-gpio,out-cable-names");
        if (pdata->n_out_cables <= 0) {
@@ -258,7 +266,8 @@ static int gpio_extcon_probe(struct platform_device *pdev)
        gpex->edev.name = pdata->name;
        gpex->edev.dev.parent = &pdev->dev;
        gpex->debounce_jiffies = msecs_to_jiffies(pdata->debounce);
-       gpex->timer_to_work_jiffies = msecs_to_jiffies(100);
+       gpex->gpio_scan_work_jiffies = msecs_to_jiffies(
+                                               pdata->wait_for_gpio_scan);
        gpex->edev.supported_cable = pdata->out_cable_name;
        gpex->cable_detect_jiffies =
                        msecs_to_jiffies(pdata->cable_detect_delay);
@@ -284,7 +293,7 @@ static int gpio_extcon_probe(struct platform_device *pdev)
        if (ret < 0)
                return ret;
 
-       INIT_DELAYED_WORK(&gpex->work, gpio_extcon_work);
+       INIT_DELAYED_WORK(&gpex->work, gpio_extcon_scan_work);
        setup_timer(&gpex->timer, gpio_extcon_notifier_timer,
                        (unsigned long)gpex);
 
@@ -311,7 +320,7 @@ static int gpio_extcon_probe(struct platform_device *pdev)
        device_wakeup_enable(gpex->dev);
 
        /* Perform initial detection */
-       gpio_extcon_work(&gpex->work.work);
+       gpio_extcon_scan_work(&gpex->work.work);
        return 0;
 
 err:
@@ -353,7 +362,7 @@ static int gpio_extcon_resume(struct device *dev)
                for (i = 0; i < gpex->pdata->n_gpio; ++i)
                        disable_irq_wake(gpex->pdata->gpios[i].irq);
        }
-       gpio_extcon_work(&gpex->work.work);
+       gpio_extcon_scan_work(&gpex->work.work);
 
        return 0;
 }