From 70f4293bd36740fd730ab25abe39281d1b312365 Mon Sep 17 00:00:00 2001 From: Russ Dill Date: Wed, 5 Aug 2015 15:30:44 +0530 Subject: [PATCH 09/21] ARM: OMAP2: Drop the concept of certain power domains not being able to lose context. Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.4-rc6-rt1/patches-4.4-rc6-rt1.tar.xz It isn't much of a win, and with hibernation, everything loses context. Signed-off-by: Russ Dill [j-keerthy@ti.com] ported to 4.1 Signed-off-by: Keerthy --- arch/arm/mach-omap2/gpio.c | 1 arch/arm/mach-omap2/powerdomain.c | 40 -------------------------------- arch/arm/mach-omap2/powerdomain.h | 1 drivers/gpio/gpio-omap.c | 36 +++++++++++----------------- include/linux/platform_data/gpio-omap.h | 1 5 files changed, 14 insertions(+), 65 deletions(-) --- a/arch/arm/mach-omap2/gpio.c +++ b/arch/arm/mach-omap2/gpio.c @@ -130,7 +130,6 @@ static int __init omap2_gpio_dev_init(st } pwrdm = omap_hwmod_get_pwrdm(oh); - pdata->loses_context = pwrdm_can_ever_lose_context(pwrdm); pdev = omap_device_build(name, id - 1, oh, pdata, sizeof(*pdata)); kfree(pdata); --- a/arch/arm/mach-omap2/powerdomain.c +++ b/arch/arm/mach-omap2/powerdomain.c @@ -1166,43 +1166,3 @@ int pwrdm_get_context_loss_count(struct return count; } -/** - * pwrdm_can_ever_lose_context - can this powerdomain ever lose context? - * @pwrdm: struct powerdomain * - * - * Given a struct powerdomain * @pwrdm, returns 1 if the powerdomain - * can lose either memory or logic context or if @pwrdm is invalid, or - * returns 0 otherwise. This function is not concerned with how the - * powerdomain registers are programmed (i.e., to go off or not); it's - * concerned with whether it's ever possible for this powerdomain to - * go off while some other part of the chip is active. This function - * assumes that every powerdomain can go to either ON or INACTIVE. - */ -bool pwrdm_can_ever_lose_context(struct powerdomain *pwrdm) -{ - int i; - - if (!pwrdm) { - pr_debug("powerdomain: %s: invalid powerdomain pointer\n", - __func__); - return 1; - } - - if (pwrdm->pwrsts & PWRSTS_OFF) - return 1; - - if (pwrdm->pwrsts & PWRSTS_RET) { - if (pwrdm->pwrsts_logic_ret & PWRSTS_OFF) - return 1; - - for (i = 0; i < pwrdm->banks; i++) - if (pwrdm->pwrsts_mem_ret[i] & PWRSTS_OFF) - return 1; - } - - for (i = 0; i < pwrdm->banks; i++) - if (pwrdm->pwrsts_mem_on[i] & PWRSTS_OFF) - return 1; - - return 0; -} --- a/arch/arm/mach-omap2/powerdomain.h +++ b/arch/arm/mach-omap2/powerdomain.h @@ -244,7 +244,6 @@ int pwrdm_state_switch(struct powerdomai int pwrdm_pre_transition(struct powerdomain *pwrdm); int pwrdm_post_transition(struct powerdomain *pwrdm); int pwrdm_get_context_loss_count(struct powerdomain *pwrdm); -bool pwrdm_can_ever_lose_context(struct powerdomain *pwrdm); extern int omap_set_pwrdm_state(struct powerdomain *pwrdm, u8 state); --- a/drivers/gpio/gpio-omap.c +++ b/drivers/gpio/gpio-omap.c @@ -69,7 +69,7 @@ struct gpio_bank { struct device *dev; bool is_mpuio; bool dbck_flag; - bool loses_context; + bool context_valid; int stride; u32 width; @@ -1208,15 +1208,9 @@ static int omap_gpio_probe(struct platfo #ifdef CONFIG_OF_GPIO bank->chip.of_node = of_node_get(node); #endif - if (node) { - if (!of_property_read_bool(node, "ti,gpio-always-on")) - bank->loses_context = true; - } else { - bank->loses_context = pdata->loses_context; - - if (bank->loses_context) - bank->get_context_loss_count = - pdata->get_context_loss_count; + if (!node) { + bank->get_context_loss_count = + pdata->get_context_loss_count; } if (bank->regs->set_dataout && bank->regs->clr_dataout) @@ -1373,7 +1367,7 @@ static int omap_gpio_runtime_resume(stru * been initialised and so initialise it now. Also initialise * the context loss count. */ - if (bank->loses_context && !bank->context_valid) { + if (!bank->context_valid) { omap_gpio_init_context(bank); if (bank->get_context_loss_count) @@ -1394,17 +1388,15 @@ static int omap_gpio_runtime_resume(stru writel_relaxed(bank->context.risingdetect, bank->base + bank->regs->risingdetect); - if (bank->loses_context) { - if (!bank->get_context_loss_count) { + if (!bank->get_context_loss_count) { + omap_gpio_restore_context(bank); + } else { + c = bank->get_context_loss_count(bank->dev); + if (c != bank->context_loss_count) { omap_gpio_restore_context(bank); } else { - c = bank->get_context_loss_count(bank->dev); - if (c != bank->context_loss_count) { - omap_gpio_restore_context(bank); - } else { - raw_spin_unlock_irqrestore(&bank->lock, flags); - return 0; - } + spin_unlock_irqrestore(&bank->lock, flags); + return 0; } } @@ -1476,7 +1468,7 @@ void omap2_gpio_prepare_for_idle(int pwr struct gpio_bank *bank; list_for_each_entry(bank, &omap_gpio_list, node) { - if (!BANK_USED(bank) || !bank->loses_context) + if (!BANK_USED(bank)) continue; bank->power_mode = pwr_mode; @@ -1490,7 +1482,7 @@ void omap2_gpio_resume_after_idle(void) struct gpio_bank *bank; list_for_each_entry(bank, &omap_gpio_list, node) { - if (!BANK_USED(bank) || !bank->loses_context) + if (!BANK_USED(bank)) continue; pm_runtime_get_sync(bank->dev); --- a/include/linux/platform_data/gpio-omap.h +++ b/include/linux/platform_data/gpio-omap.h @@ -198,7 +198,6 @@ struct omap_gpio_platform_data { int bank_width; /* GPIO bank width */ int bank_stride; /* Only needed for omap1 MPUIO */ bool dbck_flag; /* dbck required or not - True for OMAP3&4 */ - bool loses_context; /* whether the bank would ever lose context */ bool is_mpuio; /* whether the bank is of type MPUIO */ u32 non_wakeup_gpios;