Context is now saved dynamically in respective functions whenever and
whichever registers are modified. This avoid overhead of saving all
registers context in the runtime callback.
Signed-off-by: Tarun Kanti DebBarma
Reviewed-by: Santosh Shilimkar
---
drivers/gpio/gpio-omap.c | 62 ++---
1 files changed, 36 insertions(+), 26 deletions(-)
diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 67c5a96..dc382f6 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -97,6 +97,7 @@ static void _set_gpio_direction(struct gpio_bank *bank, int
gpio, int is_input)
else
l &= ~(1 << gpio);
__raw_writel(l, reg);
+ bank->context.oe = l;
}
@@ -127,6 +128,7 @@ static void _set_gpio_dataout_mask(struct gpio_bank *bank,
int gpio, int enable)
else
l &= ~gpio_bit;
__raw_writel(l, reg);
+ bank->context.dataout = l;
}
static int _get_gpio_datain(struct gpio_bank *bank, int gpio)
@@ -212,9 +214,20 @@ static inline void set_gpio_trigger(struct gpio_bank
*bank, int gpio,
MOD_REG_BIT(bank->regs->fallingdetect, gpio_bit,
trigger & IRQ_TYPE_EDGE_FALLING);
- if (likely(!(bank->non_wakeup_gpios & gpio_bit)))
+ bank->context.leveldetect0 =
+ __raw_readl(bank->base + bank->regs->leveldetect0);
+ bank->context.leveldetect1 =
+ __raw_readl(bank->base + bank->regs->leveldetect1);
+ bank->context.risingdetect =
+ __raw_readl(bank->base + bank->regs->risingdetect);
+ bank->context.fallingdetect =
+ __raw_readl(bank->base + bank->regs->fallingdetect);
+ if (likely(!(bank->non_wakeup_gpios & gpio_bit))) {
MOD_REG_BIT(bank->regs->wkup_en, gpio_bit,
trigger != 0);
+ bank->context.wake_en =
+ __raw_readl(bank->base + bank->regs->wkup_en);
+ }
/* This part needs to be executed always for OMAP{34xx, 44xx} */
if (cpu_is_omap34xx() || cpu_is_omap44xx() ||
@@ -301,6 +314,8 @@ static int _set_gpio_triggering(struct gpio_bank *bank, int
gpio, int trigger)
/* Enable wake-up during idle for dynamic tick */
MOD_REG_BIT(bank->regs->wkup_en, 1 << gpio, trigger);
+ bank->context.wake_en =
+ __raw_readl(bank->base + bank->regs->wkup_en);
__raw_writel(l, reg);
}
return 0;
@@ -393,6 +408,7 @@ static void _enable_gpio_irqbank(struct gpio_bank *bank,
int gpio_mask)
}
__raw_writel(l, reg);
+ bank->context.irqenable1 = l;
}
static void _disable_gpio_irqbank(struct gpio_bank *bank, int gpio_mask)
@@ -413,6 +429,7 @@ static void _disable_gpio_irqbank(struct gpio_bank *bank,
int gpio_mask)
}
__raw_writel(l, reg);
+ bank->context.irqenable1 = l;
}
static inline void _set_gpio_irqenable(struct gpio_bank *bank, int gpio, int
enable)
@@ -511,6 +528,7 @@ static int omap_gpio_request(struct gpio_chip *chip,
unsigned offset)
/* Module is enabled, clocks are not gated */
ctrl &= ~GPIO_MOD_CTRL_BIT;
__raw_writel(ctrl, reg);
+ bank->context.ctrl = ctrl;
}
bank->mod_usage |= 1 << offset;
@@ -528,9 +546,12 @@ static void omap_gpio_free(struct gpio_chip *chip,
unsigned offset)
spin_lock_irqsave(&bank->lock, flags);
- if (bank->regs->wkup_en)
+ if (bank->regs->wkup_en) {
/* Disable wake-up during idle for dynamic tick */
MOD_REG_BIT(bank->regs->wkup_en, 1 << offset, 0);
+ bank->context.wake_en =
+ __raw_readl(bank->base + bank->regs->wkup_en);
+ }
bank->mod_usage &= ~(1 << offset);
@@ -542,6 +563,7 @@ static void omap_gpio_free(struct gpio_chip *chip, unsigned
offset)
/* Module is disabled, clocks are gated */
ctrl |= GPIO_MOD_CTRL_BIT;
__raw_writel(ctrl, reg);
+ bank->context.ctrl = ctrl;
}
_reset_gpio(bank, bank->chip.base + offset);
@@ -908,6 +930,8 @@ static void omap_gpio_mod_init(struct gpio_bank *bank)
bank->regs->irqenable_inv == false);
MOD_REG_BIT(bank->regs->irqenable, l, bank->regs->debounce_en != 0);
MOD_REG_BIT(bank->regs->irqenable, l, bank->regs->ctrl != 0);
+ bank->context.irqenable1 =
+ __raw_readl(bank->base + bank->regs->irqenable);
}
static __init void
@@ -1098,6 +1122,7 @@ static int omap_gpio_suspend(struct device *dev)
spin_lock_irqsave(&bank->lock, flags);
bank->saved_wakeup = __raw_readl(wake_status);
MOD_REG_BIT(bank->regs->wkup_en, bank->suspend_wakeup, 1);
+ bank->context.wake_en = __raw_readl(bank->