From 7dda06594aea2f29a66793e56f46471871e1b6cd Mon Sep 17 00:00:00 2001 From: Rajeev Kulkarni Date: Fri, 14 Oct 2011 14:29:18 -0500 Subject: OMAP4: Enable/Disable GPIO clocks before/after Regiter access. On 4430 system was crashing in idle path while accessing GPIO regiters w/o its clocks enabled. In Many platforms some banks may not be used at all. Before acessing any GPIO bank register ensure that the clocks are active. Once accessing is done disable the clocks. Signed-off-by: Axel Haslem Signed-off-by: Rajeev Kulkarni --- drivers/gpio/gpio-omap.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) (limited to 'drivers/gpio') diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c index 26231e2..71f4628 100644 --- a/drivers/gpio/gpio-omap.c +++ b/drivers/gpio/gpio-omap.c @@ -1394,6 +1394,12 @@ void omap2_gpio_set_edge_wakeup(void) u32 level_high = 0; u32 wkup_status = 0; + if (IS_ERR_VALUE(pm_runtime_get_sync(bank->dev) < 0)) { + dev_err(bank->dev, "%s: GPIO bank %d pm_runtime_get_sync " + "failed\n", __func__, bank->id); + return; + } + level_low = __raw_readl(bank->base + bank->regs->leveldetect0); level_high = __raw_readl(bank->base + @@ -1411,10 +1417,15 @@ void omap2_gpio_set_edge_wakeup(void) * even if they are set for level detection only. */ __raw_writel(bank->context.edge_falling | (level_low & wkup_status), - (bank->base + bank->regs->fallingdetect)); + (bank->base + bank->regs->fallingdetect)); __raw_writel(bank->context.edge_rising | (level_high & wkup_status), - (bank->base + bank->regs->risingdetect)); + (bank->base + bank->regs->risingdetect)); + if (IS_ERR_VALUE(pm_runtime_put_sync_suspend(bank->dev) < 0)) { + dev_err(bank->dev, "%s: GPIO bank %d pm_runtime_put_sync " + "failed\n", __func__, bank->id); + return; + } } } @@ -1424,10 +1435,22 @@ void omap2_gpio_restore_edge_wakeup(void) list_for_each_entry(bank, &omap_gpio_list, node) { /* restore edge setting */ + if (IS_ERR_VALUE(pm_runtime_get_sync(bank->dev) < 0)) { + dev_err(bank->dev, "%s: GPIO bank %d pm_runtime_get_sync " + "failed\n", __func__, bank->id); + return; + } + __raw_writel(bank->context.edge_falling, - (bank->base + bank->regs->fallingdetect)); + (bank->base + bank->regs->fallingdetect)); __raw_writel(bank->context.edge_rising, - (bank->base + bank->regs->risingdetect)); + (bank->base + bank->regs->risingdetect)); + + if (IS_ERR_VALUE(pm_runtime_put_sync_suspend(bank->dev) < 0)) { + dev_err(bank->dev, "%s: GPIO bank %d pm_runtime_put_sync " + "failed\n", __func__, bank->id); + return; + } } } -- cgit v1.1