Commit f02a0398 authored by Tony Lindgren's avatar Tony Lindgren Committed by Bartosz Golaszewski

gpio: omap: Add missing PM ops for suspend

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: default avatarTony Lindgren <tony@atomide.com>
Signed-off-by: default avatarBartosz Golaszewski <bgolaszewski@baylibre.com>
parent e4c6a52c
...@@ -60,6 +60,7 @@ struct gpio_bank { ...@@ -60,6 +60,7 @@ struct gpio_bank {
struct clk *dbck; struct clk *dbck;
struct notifier_block nb; struct notifier_block nb;
unsigned int is_suspended:1; unsigned int is_suspended:1;
unsigned int needs_resume:1;
u32 mod_usage; u32 mod_usage;
u32 irq_usage; u32 irq_usage;
u32 dbck_enable_mask; u32 dbck_enable_mask;
...@@ -1504,9 +1505,34 @@ static int __maybe_unused omap_gpio_runtime_resume(struct device *dev) ...@@ -1504,9 +1505,34 @@ static int __maybe_unused omap_gpio_runtime_resume(struct device *dev)
return 0; 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 = { static const struct dev_pm_ops gpio_pm_ops = {
SET_RUNTIME_PM_OPS(omap_gpio_runtime_suspend, omap_gpio_runtime_resume, SET_RUNTIME_PM_OPS(omap_gpio_runtime_suspend, omap_gpio_runtime_resume,
NULL) NULL)
SET_LATE_SYSTEM_SLEEP_PM_OPS(omap_gpio_suspend, omap_gpio_resume)
}; };
static struct platform_driver omap_gpio_driver = { static struct platform_driver omap_gpio_driver = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment