Commit 065cd795 authored by Tarun Kanti DebBarma's avatar Tarun Kanti DebBarma

gpio/omap: optimize suspend and resume functions

There is no need to operate on all the banks every time the function is called.
Just operate on the current bank passed by the framework.
Signed-off-by: default avatarTarun Kanti DebBarma <tarun.kanti@ti.com>
Reviewed-by: default avatarSantosh Shilimkar <santosh.shilimkar@ti.com>
Reviewed-by: default avatarKevin Hilman <khilman@ti.com>
Signed-off-by: default avatarKevin Hilman <khilman@ti.com>
parent 55b93c32
......@@ -1052,6 +1052,8 @@ static int __devinit omap_gpio_probe(struct platform_device *pdev)
goto err_free;
}
platform_set_drvdata(pdev, bank);
pm_runtime_enable(bank->dev);
pm_runtime_irq_safe(bank->dev);
pm_runtime_get_sync(bank->dev);
......@@ -1080,44 +1082,46 @@ static int __devinit omap_gpio_probe(struct platform_device *pdev)
#if defined(CONFIG_PM_SLEEP)
static int omap_gpio_suspend(struct device *dev)
{
struct gpio_bank *bank;
struct platform_device *pdev = to_platform_device(dev);
struct gpio_bank *bank = platform_get_drvdata(pdev);
void __iomem *base = bank->base;
void __iomem *wakeup_enable;
unsigned long flags;
list_for_each_entry(bank, &omap_gpio_list, node) {
void __iomem *base = bank->base;
void __iomem *wake_status;
unsigned long flags;
if (!bank->mod_usage || !bank->loses_context)
return 0;
if (!bank->regs->wkup_en)
return 0;
if (!bank->regs->wkup_en || !bank->suspend_wakeup)
return 0;
wake_status = bank->base + bank->regs->wkup_en;
wakeup_enable = bank->base + bank->regs->wkup_en;
spin_lock_irqsave(&bank->lock, flags);
bank->saved_wakeup = __raw_readl(wake_status);
_gpio_rmw(base, bank->regs->wkup_en, 0xffffffff, 0);
_gpio_rmw(base, bank->regs->wkup_en, bank->suspend_wakeup, 1);
spin_unlock_irqrestore(&bank->lock, flags);
}
spin_lock_irqsave(&bank->lock, flags);
bank->saved_wakeup = __raw_readl(wakeup_enable);
_gpio_rmw(base, bank->regs->wkup_en, 0xffffffff, 0);
_gpio_rmw(base, bank->regs->wkup_en, bank->suspend_wakeup, 1);
spin_unlock_irqrestore(&bank->lock, flags);
return 0;
}
static int omap_gpio_resume(struct device *dev)
{
struct gpio_bank *bank;
struct platform_device *pdev = to_platform_device(dev);
struct gpio_bank *bank = platform_get_drvdata(pdev);
void __iomem *base = bank->base;
unsigned long flags;
list_for_each_entry(bank, &omap_gpio_list, node) {
void __iomem *base = bank->base;
unsigned long flags;
if (!bank->mod_usage || !bank->loses_context)
return 0;
if (!bank->regs->wkup_en)
return 0;
if (!bank->regs->wkup_en || !bank->saved_wakeup)
return 0;
spin_lock_irqsave(&bank->lock, flags);
_gpio_rmw(base, bank->regs->wkup_en, 0xffffffff, 0);
_gpio_rmw(base, bank->regs->wkup_en, bank->saved_wakeup, 1);
spin_unlock_irqrestore(&bank->lock, flags);
}
spin_lock_irqsave(&bank->lock, flags);
_gpio_rmw(base, bank->regs->wkup_en, 0xffffffff, 0);
_gpio_rmw(base, bank->regs->wkup_en, bank->saved_wakeup, 1);
spin_unlock_irqrestore(&bank->lock, flags);
return 0;
}
......
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