]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.19.51/gpio-gpio-omap-add-check-for-off-wake-capable-gpios.patch
Linux 4.19.51
[thirdparty/kernel/stable-queue.git] / releases / 4.19.51 / gpio-gpio-omap-add-check-for-off-wake-capable-gpios.patch
CommitLineData
37554d48
SL
1From f2fe7acc3b8bc1ba4fa7d0586c454b3107adb1f0 Mon Sep 17 00:00:00 2001
2From: Tony Lindgren <tony@atomide.com>
3Date: Mon, 25 Mar 2019 15:43:18 -0700
4Subject: gpio: gpio-omap: add check for off wake capable gpios
5
6[ Upstream commit da38ef3ed10a09248e13ae16530c2c6d448dc47d ]
7
8We are currently assuming all GPIOs are non-wakeup capable GPIOs as we
9not configuring the bank->non_wakeup_gpios like we used to earlier with
10platform_data.
11
12Let's add omap_gpio_is_off_wakeup_capable() to make the handling clearer
13while considering that later patches may want to configure SoC specific
14bank->non_wakeup_gpios for the GPIOs in wakeup domain.
15
16Cc: Aaro Koskinen <aaro.koskinen@iki.fi>
17Cc: Grygorii Strashko <grygorii.strashko@ti.com>
18Cc: Keerthy <j-keerthy@ti.com>
19Cc: Peter Ujfalusi <peter.ujfalusi@ti.com>
20Cc: Russell King <rmk+kernel@armlinux.org.uk>
21Cc: Tero Kristo <t-kristo@ti.com>
22Reported-by: Grygorii Strashko <grygorii.strashko@ti.com>
23Signed-off-by: Tony Lindgren <tony@atomide.com>
24Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
25Signed-off-by: Sasha Levin <sashal@kernel.org>
26---
27 drivers/gpio/gpio-omap.c | 25 +++++++++++++++++--------
28 1 file changed, 17 insertions(+), 8 deletions(-)
29
30diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
31index 6c1acf642c8e..6fa430d98517 100644
32--- a/drivers/gpio/gpio-omap.c
33+++ b/drivers/gpio/gpio-omap.c
34@@ -343,6 +343,22 @@ static void omap_clear_gpio_debounce(struct gpio_bank *bank, unsigned offset)
35 }
36 }
37
38+/*
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.
43+ */
44+static bool omap_gpio_is_off_wakeup_capable(struct gpio_bank *bank, u32 gpio_mask)
45+{
46+ u32 no_wake = bank->non_wakeup_gpios;
47+
48+ if (no_wake)
49+ return !!(~no_wake & gpio_mask);
50+
51+ return false;
52+}
53+
54 static inline void omap_set_gpio_trigger(struct gpio_bank *bank, int gpio,
55 unsigned trigger)
56 {
57@@ -374,13 +390,7 @@ static inline void omap_set_gpio_trigger(struct gpio_bank *bank, int gpio,
58 }
59
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))
65- goto exit;
66- }
67-
68+ if (!bank->regs->irqctrl && !omap_gpio_is_off_wakeup_capable(bank, gpio)) {
69 /*
70 * Log the edge gpio and manually trigger the IRQ
71 * after resume if the input level changes
72@@ -393,7 +403,6 @@ static inline void omap_set_gpio_trigger(struct gpio_bank *bank, int gpio,
73 bank->enabled_non_wakeup_gpios &= ~gpio_bit;
74 }
75
76-exit:
77 bank->level_mask =
78 readl_relaxed(bank->base + bank->regs->leveldetect0) |
79 readl_relaxed(bank->base + bank->regs->leveldetect1);
80--
812.20.1
82