Linux-GPIO Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] gpio: omap: Add missing PM ops for suspend
@ 2020-06-29 16:41 Tony Lindgren
  2020-06-30  9:03 ` Bartosz Golaszewski
  0 siblings, 1 reply; 2+ messages in thread
From: Tony Lindgren @ 2020-06-29 16:41 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Grygorii Strashko
  Cc: linux-gpio, linux-omap, linux-arm-kernel

We've had the legacy platform code take care of suspend for us but
this no longer is the case when probed without legacy mode with
ti-sysc. We need to configure PM ops like standard Linux device
drivers do.

As we still have some SoCs booting also the legacy mode, we need to
add omap_gpio_suspend() and omap_gpio_resume(), and check for the
is_suspended flag to avoid legacy _od_suspend_noirq() calling them
on an already suspended GPIO instance.

Once we have no SoCs booting in legacy mode, we can just switch to
using the standard PM ops with pm_runtime_force_suspend() and
pm_runtime_force_resume().

Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 drivers/gpio/gpio-omap.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -60,6 +60,7 @@ struct gpio_bank {
 	struct clk *dbck;
 	struct notifier_block nb;
 	unsigned int is_suspended:1;
+	unsigned int needs_resume:1;
 	u32 mod_usage;
 	u32 irq_usage;
 	u32 dbck_enable_mask;
@@ -1504,9 +1505,34 @@ static int __maybe_unused omap_gpio_runtime_resume(struct device *dev)
 	return 0;
 }
 
+static int omap_gpio_suspend(struct device *dev)
+{
+	struct gpio_bank *bank = dev_get_drvdata(dev);
+
+	if (bank->is_suspended)
+		return 0;
+
+	bank->needs_resume = 1;
+
+	return omap_gpio_runtime_suspend(dev);
+}
+
+static int omap_gpio_resume(struct device *dev)
+{
+	struct gpio_bank *bank = dev_get_drvdata(dev);
+
+	if (!bank->needs_resume)
+		return 0;
+
+	bank->needs_resume = 0;
+
+	return omap_gpio_runtime_resume(dev);
+}
+
 static const struct dev_pm_ops gpio_pm_ops = {
 	SET_RUNTIME_PM_OPS(omap_gpio_runtime_suspend, omap_gpio_runtime_resume,
 									NULL)
+	SET_LATE_SYSTEM_SLEEP_PM_OPS(omap_gpio_suspend, omap_gpio_resume)
 };
 
 static struct platform_driver omap_gpio_driver = {
-- 
2.27.0

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] gpio: omap: Add missing PM ops for suspend
  2020-06-29 16:41 [PATCH] gpio: omap: Add missing PM ops for suspend Tony Lindgren
@ 2020-06-30  9:03 ` Bartosz Golaszewski
  0 siblings, 0 replies; 2+ messages in thread
From: Bartosz Golaszewski @ 2020-06-30  9:03 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Linus Walleij, Grygorii Strashko, linux-gpio, Linux-OMAP, arm-soc

On Mon, Jun 29, 2020 at 6:41 PM Tony Lindgren <tony@atomide.com> wrote:
>
> We've had the legacy platform code take care of suspend for us but
> this no longer is the case when probed without legacy mode with
> ti-sysc. We need to configure PM ops like standard Linux device
> drivers do.
>
> As we still have some SoCs booting also the legacy mode, we need to
> add omap_gpio_suspend() and omap_gpio_resume(), and check for the
> is_suspended flag to avoid legacy _od_suspend_noirq() calling them
> on an already suspended GPIO instance.
>
> Once we have no SoCs booting in legacy mode, we can just switch to
> using the standard PM ops with pm_runtime_force_suspend() and
> pm_runtime_force_resume().
>
> Signed-off-by: Tony Lindgren <tony@atomide.com>
> ---

Applied, thanks!

Bartosz

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-29 16:41 [PATCH] gpio: omap: Add missing PM ops for suspend Tony Lindgren
2020-06-30  9:03 ` Bartosz Golaszewski

Linux-GPIO Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-gpio/0 linux-gpio/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-gpio linux-gpio/ https://lore.kernel.org/linux-gpio \
		linux-gpio@vger.kernel.org
	public-inbox-index linux-gpio

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-gpio


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git