1 From 91de0e7622eac10f4905731d68e97331ccbd66ae Mon Sep 17 00:00:00 2001
2 From: Tony Lindgren <tony@atomide.com>
3 Date: Mon, 25 Mar 2019 15:43:18 -0700
4 Subject: gpio: gpio-omap: add check for off wake capable gpios
6 [ Upstream commit da38ef3ed10a09248e13ae16530c2c6d448dc47d ]
8 We are currently assuming all GPIOs are non-wakeup capable GPIOs as we
9 not configuring the bank->non_wakeup_gpios like we used to earlier with
12 Let's add omap_gpio_is_off_wakeup_capable() to make the handling clearer
13 while considering that later patches may want to configure SoC specific
14 bank->non_wakeup_gpios for the GPIOs in wakeup domain.
16 Cc: Aaro Koskinen <aaro.koskinen@iki.fi>
17 Cc: Grygorii Strashko <grygorii.strashko@ti.com>
18 Cc: Keerthy <j-keerthy@ti.com>
19 Cc: Peter Ujfalusi <peter.ujfalusi@ti.com>
20 Cc: Russell King <rmk+kernel@armlinux.org.uk>
21 Cc: Tero Kristo <t-kristo@ti.com>
22 Reported-by: Grygorii Strashko <grygorii.strashko@ti.com>
23 Signed-off-by: Tony Lindgren <tony@atomide.com>
24 Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
25 Signed-off-by: Sasha Levin <sashal@kernel.org>
27 drivers/gpio/gpio-omap.c | 25 +++++++++++++++++--------
28 1 file changed, 17 insertions(+), 8 deletions(-)
30 diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
31 index 75f30a0c418a..038882183bdf 100644
32 --- a/drivers/gpio/gpio-omap.c
33 +++ b/drivers/gpio/gpio-omap.c
34 @@ -296,6 +296,22 @@ static void omap_clear_gpio_debounce(struct gpio_bank *bank, unsigned offset)
39 + * Off mode wake-up capable GPIOs in bank(s) that are in the wakeup domain.
40 + * See TRM section for GPIO for "Wake-Up Generation" for the list of GPIOs
41 + * in wakeup domain. If bank->non_wakeup_gpios is not configured, assume none
42 + * are capable waking up the system from off mode.
44 +static bool omap_gpio_is_off_wakeup_capable(struct gpio_bank *bank, u32 gpio_mask)
46 + u32 no_wake = bank->non_wakeup_gpios;
49 + return !!(~no_wake & gpio_mask);
54 static inline void omap_set_gpio_trigger(struct gpio_bank *bank, int gpio,
57 @@ -327,13 +343,7 @@ static inline void omap_set_gpio_trigger(struct gpio_bank *bank, int gpio,
60 /* This part needs to be executed always for OMAP{34xx, 44xx} */
61 - if (!bank->regs->irqctrl) {
62 - /* On omap24xx proceed only when valid GPIO bit is set */
63 - if (bank->non_wakeup_gpios) {
64 - if (!(bank->non_wakeup_gpios & gpio_bit))
68 + if (!bank->regs->irqctrl && !omap_gpio_is_off_wakeup_capable(bank, gpio)) {
70 * Log the edge gpio and manually trigger the IRQ
71 * after resume if the input level changes
72 @@ -346,7 +356,6 @@ static inline void omap_set_gpio_trigger(struct gpio_bank *bank, int gpio,
73 bank->enabled_non_wakeup_gpios &= ~gpio_bit;
78 readl_relaxed(bank->base + bank->regs->leveldetect0) |
79 readl_relaxed(bank->base + bank->regs->leveldetect1);