Skip to content

Commit fd8afa9

Browse files
tmlindgregkh
authored andcommitted
gpio: gpio-omap: add check for off wake capable gpios
[ Upstream commit da38ef3 ] We are currently assuming all GPIOs are non-wakeup capable GPIOs as we not configuring the bank->non_wakeup_gpios like we used to earlier with platform_data. Let's add omap_gpio_is_off_wakeup_capable() to make the handling clearer while considering that later patches may want to configure SoC specific bank->non_wakeup_gpios for the GPIOs in wakeup domain. Cc: Aaro Koskinen <[email protected]> Cc: Grygorii Strashko <[email protected]> Cc: Keerthy <[email protected]> Cc: Peter Ujfalusi <[email protected]> Cc: Russell King <[email protected]> Cc: Tero Kristo <[email protected]> Reported-by: Grygorii Strashko <[email protected]> Signed-off-by: Tony Lindgren <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent d73c419 commit fd8afa9

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

drivers/gpio/gpio-omap.c

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,22 @@ static void omap_clear_gpio_debounce(struct gpio_bank *bank, unsigned offset)
296296
}
297297
}
298298

299+
/*
300+
* Off mode wake-up capable GPIOs in bank(s) that are in the wakeup domain.
301+
* See TRM section for GPIO for "Wake-Up Generation" for the list of GPIOs
302+
* in wakeup domain. If bank->non_wakeup_gpios is not configured, assume none
303+
* are capable waking up the system from off mode.
304+
*/
305+
static bool omap_gpio_is_off_wakeup_capable(struct gpio_bank *bank, u32 gpio_mask)
306+
{
307+
u32 no_wake = bank->non_wakeup_gpios;
308+
309+
if (no_wake)
310+
return !!(~no_wake & gpio_mask);
311+
312+
return false;
313+
}
314+
299315
static inline void omap_set_gpio_trigger(struct gpio_bank *bank, int gpio,
300316
unsigned trigger)
301317
{
@@ -327,13 +343,7 @@ static inline void omap_set_gpio_trigger(struct gpio_bank *bank, int gpio,
327343
}
328344

329345
/* This part needs to be executed always for OMAP{34xx, 44xx} */
330-
if (!bank->regs->irqctrl) {
331-
/* On omap24xx proceed only when valid GPIO bit is set */
332-
if (bank->non_wakeup_gpios) {
333-
if (!(bank->non_wakeup_gpios & gpio_bit))
334-
goto exit;
335-
}
336-
346+
if (!bank->regs->irqctrl && !omap_gpio_is_off_wakeup_capable(bank, gpio)) {
337347
/*
338348
* Log the edge gpio and manually trigger the IRQ
339349
* after resume if the input level changes
@@ -346,7 +356,6 @@ static inline void omap_set_gpio_trigger(struct gpio_bank *bank, int gpio,
346356
bank->enabled_non_wakeup_gpios &= ~gpio_bit;
347357
}
348358

349-
exit:
350359
bank->level_mask =
351360
readl_relaxed(bank->base + bank->regs->leveldetect0) |
352361
readl_relaxed(bank->base + bank->regs->leveldetect1);

0 commit comments

Comments
 (0)