gpio: add wakeup source trace in GPIO driver
authorLi, Ning <ning.li@intel.com>
Wed, 15 Feb 2012 07:13:47 +0000 (15:13 +0800)
committerbuildbot <buildbot@intel.com>
Thu, 16 Feb 2012 09:34:27 +0000 (01:34 -0800)
BZ: 23641

Add logs to trace the wakeup source at each time the langwell-gpio
device resumes.

Change-Id: I8774526d1a529205c8c4681a20ba6a4beac6065f
Signed-off-by: Li, Ning <ning.li@intel.com>
Reviewed-on: http://android.intel.com:8080/35387
Reviewed-by: Yang, Bin <bin.yang@intel.com>
Reviewed-by: Du, Alek <alek.du@intel.com>
Reviewed-by: Mansoor, Illyas <illyas.mansoor@intel.com>
Tested-by: Wang, Zhifeng <zhifeng.wang@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
drivers/gpio/langwell_gpio.c

index 6ddf3bd..12bb49e 100644 (file)
@@ -66,6 +66,7 @@ struct lnw_gpio {
        void                            *reg_base;
        spinlock_t                      lock;
        unsigned                        irq_base;
+       int                             wakeup;
        struct pci_dev                  *pdev;
 };
 
@@ -295,6 +296,9 @@ static void lnw_irq_handler(unsigned irq, struct irq_desc *desc)
                pending = readl(gedr);
                while (pending) {
                        gpio = __ffs(pending);
+                       if (!lnw->wakeup)
+                               dev_info(&lnw->pdev->dev,
+                               "wakeup source: gpio %d\n", base + gpio);
                        mask = BIT(gpio);
                        pending &= ~mask;
                        /* Clear before handling so we can't lose an edge */
@@ -307,6 +311,26 @@ static void lnw_irq_handler(unsigned irq, struct irq_desc *desc)
 }
 
 #ifdef CONFIG_PM
+static int lnw_gpio_suspend_noirq(struct device *dev)
+{
+       struct pci_dev *pdev = container_of(dev, struct pci_dev, dev);
+       struct lnw_gpio *lnw = pci_get_drvdata(pdev);
+
+       lnw->wakeup = 0;
+
+       return 0;
+}
+
+static int lnw_gpio_resume_noirq(struct device *dev)
+{
+       struct pci_dev *pdev = container_of(dev, struct pci_dev, dev);
+       struct lnw_gpio *lnw = pci_get_drvdata(pdev);
+
+       lnw->wakeup = 1;
+
+       return 0;
+}
+
 static int lnw_gpio_runtime_resume(struct device *dev)
 {
        return 0;
@@ -328,12 +352,16 @@ static int lnw_gpio_runtime_idle(struct device *dev)
 }
 
 #else
+#define lnw_gpio_suspend_noirq         NULL
+#define lnw_gpio_resume_noirq          NULL
 #define lnw_gpio_runtime_suspend       NULL
 #define lnw_gpio_runtime_resume                NULL
 #define lnw_gpio_runtime_idle          NULL
 #endif
 
 static const struct dev_pm_ops lnw_gpio_pm_ops = {
+       .suspend_noirq = lnw_gpio_suspend_noirq,
+       .resume_noirq = lnw_gpio_resume_noirq,
        .runtime_suspend = lnw_gpio_runtime_suspend,
        .runtime_resume = lnw_gpio_runtime_resume,
        .runtime_idle = lnw_gpio_runtime_idle,
@@ -389,6 +417,7 @@ static int __devinit lnw_gpio_probe(struct pci_dev *pdev,
        }
        lnw->reg_base = base;
        lnw->irq_base = irq_base;
+       lnw->wakeup = 1;
        lnw->chip.label = dev_name(&pdev->dev);
        lnw->chip.direction_input = lnw_gpio_direction_input;
        lnw->chip.direction_output = lnw_gpio_direction_output;