aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl
diff options
context:
space:
mode:
authorDoug Anderson <dianders@chromium.org>2014-11-19 17:51:32 -0500
committerLinus Walleij <linus.walleij@linaro.org>2014-12-30 07:17:27 -0500
commit68bda47c57c9d671820672badc1cb62211ec4700 (patch)
tree48a76781459d12ee9f6038c1eedf94409058ecf6 /drivers/pinctrl
parentb7392d2247cfe6771f95d256374f1a8e6a6f48d6 (diff)
pinctrl: rockchip: Handle wakeup pins
The rockchip pinctrl driver was using irq_gc_set_wake() as its implementation of irq_set_wake() but was totally ignoring everything that irq_gc_set_wake() did (which is to upkeep gc->wake_active). Let's fix that by setting gc->wake_active as GPIO_INTEN at suspend time and restoring GPIO_INTEN at resume time. NOTE a few quirks when thinking about this patch: - Rockchip pinctrl hardware supports both "disable/enable" and "mask/unmask". Right now we only use "disable/enable" and present those to Linux as "mask/unmask". This should be OK because enable/disable is optional and Linux will implement it in terms of mask/unmask. At the moment we always tell hardware all interrupts are unmasked (the boot default). - At suspend time Linux tries to call "disable" on all interrupts and also enables wakeup on all wakeup interrupts. One would think that since "disable" is implemented as "mask" when "disable" isn't provided and that since we were ignoring gc->wake_active that nothing would have woken us up. That's not the case since Linux "optimizes" things and just leaves interrutps unmasked, assuming it could mask them later when they go off. That meant that at suspend time all interrupts were actually being left enabled. With this patch random non-wakeup interrupts no longer wake the system up. Wakeup interrupts still wake the system up. Signed-off-by: Doug Anderson <dianders@chromium.org> Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Reviewed-by: Heiko Stuebner <heiko@sntech.de> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl')
-rw-r--r--drivers/pinctrl/pinctrl-rockchip.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c
index ba74f0aa60c7..e91e8453aa78 100644
--- a/drivers/pinctrl/pinctrl-rockchip.c
+++ b/drivers/pinctrl/pinctrl-rockchip.c
@@ -89,6 +89,7 @@ struct rockchip_iomux {
89 * @reg_pull: optional separate register for additional pull settings 89 * @reg_pull: optional separate register for additional pull settings
90 * @clk: clock of the gpio bank 90 * @clk: clock of the gpio bank
91 * @irq: interrupt of the gpio bank 91 * @irq: interrupt of the gpio bank
92 * @saved_enables: Saved content of GPIO_INTEN at suspend time.
92 * @pin_base: first pin number 93 * @pin_base: first pin number
93 * @nr_pins: number of pins in this bank 94 * @nr_pins: number of pins in this bank
94 * @name: name of the bank 95 * @name: name of the bank
@@ -107,6 +108,7 @@ struct rockchip_pin_bank {
107 struct regmap *regmap_pull; 108 struct regmap *regmap_pull;
108 struct clk *clk; 109 struct clk *clk;
109 int irq; 110 int irq;
111 u32 saved_enables;
110 u32 pin_base; 112 u32 pin_base;
111 u8 nr_pins; 113 u8 nr_pins;
112 char *name; 114 char *name;
@@ -1543,6 +1545,23 @@ static int rockchip_irq_set_type(struct irq_data *d, unsigned int type)
1543 return 0; 1545 return 0;
1544} 1546}
1545 1547
1548static void rockchip_irq_suspend(struct irq_data *d)
1549{
1550 struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
1551 struct rockchip_pin_bank *bank = gc->private;
1552
1553 bank->saved_enables = irq_reg_readl(gc, GPIO_INTEN);
1554 irq_reg_writel(gc, gc->wake_active, GPIO_INTEN);
1555}
1556
1557static void rockchip_irq_resume(struct irq_data *d)
1558{
1559 struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
1560 struct rockchip_pin_bank *bank = gc->private;
1561
1562 irq_reg_writel(gc, bank->saved_enables, GPIO_INTEN);
1563}
1564
1546static int rockchip_interrupts_register(struct platform_device *pdev, 1565static int rockchip_interrupts_register(struct platform_device *pdev,
1547 struct rockchip_pinctrl *info) 1566 struct rockchip_pinctrl *info)
1548{ 1567{
@@ -1587,6 +1606,8 @@ static int rockchip_interrupts_register(struct platform_device *pdev,
1587 gc->chip_types[0].chip.irq_mask = irq_gc_mask_clr_bit; 1606 gc->chip_types[0].chip.irq_mask = irq_gc_mask_clr_bit;
1588 gc->chip_types[0].chip.irq_unmask = irq_gc_mask_set_bit; 1607 gc->chip_types[0].chip.irq_unmask = irq_gc_mask_set_bit;
1589 gc->chip_types[0].chip.irq_set_wake = irq_gc_set_wake; 1608 gc->chip_types[0].chip.irq_set_wake = irq_gc_set_wake;
1609 gc->chip_types[0].chip.irq_suspend = rockchip_irq_suspend;
1610 gc->chip_types[0].chip.irq_resume = rockchip_irq_resume;
1590 gc->chip_types[0].chip.irq_set_type = rockchip_irq_set_type; 1611 gc->chip_types[0].chip.irq_set_type = rockchip_irq_set_type;
1591 gc->wake_enabled = IRQ_MSK(bank->nr_pins); 1612 gc->wake_enabled = IRQ_MSK(bank->nr_pins);
1592 1613