diff options
author | Grygorii Strashko <Grygorii.Strashko@linaro.org> | 2015-01-30 18:21:01 +0200 |
---|---|---|
committer | Grygorii Strashko <Grygorii.Strashko@linaro.org> | 2015-02-09 23:35:36 +0800 |
commit | 91e89153dff46c89f2ff4c5d79d15580ca9b2f73 (patch) | |
tree | 03c04194fdec33af56b441e2858d136deaa4c5b9 | |
parent | b6d72e2e9a9abc0b56baee8d4b3a12b012c9945f (diff) |
[hib-dev] ARM: OMAP2+: enable pltaform hibernation mode
Signed-off-by: Grygorii Strashko <Grygorii.Strashko@linaro.org>
-rw-r--r-- | arch/arm/mach-omap2/pm44xx.c | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/arch/arm/mach-omap2/pm44xx.c b/arch/arm/mach-omap2/pm44xx.c index aea83fd743a..eed2cdaeb4e 100644 --- a/arch/arm/mach-omap2/pm44xx.c +++ b/arch/arm/mach-omap2/pm44xx.c @@ -17,12 +17,19 @@ #include <linux/err.h> #include <linux/slab.h> #include <asm/system_misc.h> +#include <linux/pinctrl/pinctrl.h> +#include <linux/pinctrl/pinmux.h> +#include <linux/gpio.h> +#include <linux/platform_data/gpio-omap.h> +#include <linux/cpu.h> +#include <linux/omap-dma.h> #include "soc.h" #include "common.h" #include "clockdomain.h" #include "powerdomain.h" #include "pm.h" +#include "omap_hwmod.h" u16 pm44xx_errata; @@ -41,6 +48,9 @@ static u32 cpu_suspend_state = PWRDM_POWER_OFF; static LIST_HEAD(pwrst_list); +static struct pinctrl_dev *pmx_dev; + + #ifdef CONFIG_SUSPEND static int omap4_pm_suspend(void) { @@ -231,6 +241,77 @@ int __init omap4_pm_init_early(void) return 0; } +#ifdef CONFIG_HIBERNATION +static int am33xx_hibernation_begin(void) +{ + cpu_idle_poll_ctrl(true); + return 0; +} + +static int am33xx_hibernation_pre_snapshot(void) +{ + pinmux_save_context(pmx_dev, "am33xx_pmx_per"); + omap_dma_global_context_save(); + clks_save_context(); +/* clkdm_save_context();*/ + pwrdms_save_context(); + return 0; +} + +static void am33xx_hibernation_leave(void) +{ + pwrdms_restore_context(); + clkdm_restore_context(); +/* clks_restore_context(); */ + omap_dma_global_context_restore(); + pinmux_restore_context(pmx_dev, "am33xx_pmx_per"); + pwrdms_lost_power(); +} + +static void am33xx_hibernation_finish(void) +{ +} + +static void am33xx_hibernation_end(void) +{ + cpu_idle_poll_ctrl(false); +} + +static int am33xx_hibernation_prepare(void) +{ + return 0; +} + +static int am33xx_hibernation_enter(void) +{ + machine_power_off(); + return 0; +} + +static int am33xx_hibernation_pre_restore(void) +{ +// omap2_gpio_prepare_for_idle(1); + return 0; +} + +static void am33xx_hibernation_restore_cleanup(void) +{ +// omap2_gpio_resume_after_idle(); +} + +static const struct platform_hibernation_ops am33xx_hibernation_ops = { + .begin = am33xx_hibernation_begin, + .end = am33xx_hibernation_end, + .pre_snapshot = am33xx_hibernation_pre_snapshot, + .finish = am33xx_hibernation_finish, + .prepare = am33xx_hibernation_prepare, + .enter = am33xx_hibernation_enter, + .leave = am33xx_hibernation_leave, + .pre_restore = am33xx_hibernation_pre_restore, + .restore_cleanup = am33xx_hibernation_restore_cleanup, +}; +#endif /* CONFIG_HIBERNATION */ + /** * omap4_pm_init - Init routine for OMAP4+ devices * @@ -289,6 +370,10 @@ int __init omap4_pm_init(void) if (cpu_is_omap44xx()) omap4_idle_init(); +#ifdef CONFIG_HIBERNATION + pmx_dev = get_pinctrl_dev_from_devname("4a003400.pinmux"); + hibernation_set_ops(&am33xx_hibernation_ops); +#endif /* CONFIG_HIBERNATION */ err2: return ret; |