From 6637a098eabb13d068c66e83e5bb0954a5266486 Mon Sep 17 00:00:00 2001 From: Matthieu Crapet Date: Sun, 4 Jan 2009 14:36:38 +0100 Subject: [PATCH] EP93xx Power Management Routines MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Signed-off-by: Petr Štetiar --- arch/arm/mach-ep93xx/Makefile | 3 + arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h | 1 + arch/arm/mach-ep93xx/pm.c | 77 +++++++++++++++++++++++ 3 files changed, 81 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-ep93xx/pm.c diff --git a/arch/arm/mach-ep93xx/Makefile b/arch/arm/mach-ep93xx/Makefile index bbf8f9a..2f65745 100644 --- a/arch/arm/mach-ep93xx/Makefile +++ b/arch/arm/mach-ep93xx/Makefile @@ -17,3 +17,6 @@ obj-$(CONFIG_MACH_GESBC9312) += gesbc9312.o obj-$(CONFIG_MACH_MICRO9) += micro9.o obj-$(CONFIG_MACH_TS72XX) += ts72xx.o obj-$(CONFIG_MACH_TS72XX_SBCINFO) += ts72xx_sbcinfo.o + +# Power Management +obj-$(CONFIG_PM) += pm.o diff --git a/arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h b/arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h index c0a8a95..f5218de 100644 --- a/arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h +++ b/arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h @@ -135,6 +135,7 @@ #define EP93XX_SYSCON_CLOCK_SET2 EP93XX_SYSCON_REG(0x24) #define EP93XX_SYSCON_DEVICE_CONFIG EP93XX_SYSCON_REG(0x80) #define EP93XX_SYSCON_DEVICE_CONFIG_CRUNCH_ENABLE 0x00800000 +#define EP93XX_SYSCON_DEVICE_CONFIG_SHENA 0x00000001 #define EP93XX_SYSCON_SWLOCK EP93XX_SYSCON_REG(0xc0) #define EP93XX_SYSCON_CHIPID EP93XX_SYSCON_REG(0x94) diff --git a/arch/arm/mach-ep93xx/pm.c b/arch/arm/mach-ep93xx/pm.c new file mode 100644 index 0000000..0c4ba53 --- /dev/null +++ b/arch/arm/mach-ep93xx/pm.c @@ -0,0 +1,77 @@ +/* + * arch/arm/mach-ep93xx/pm.c + * + * EP93xx Power Management Routines + * + * Based on pm.c from Andre Renaud, Bluewater Systems Ltd. + * + * (c) Copyright 2008 Matthieu Crapet + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + */ + +#include +#include +#include +#include +#include +#include +#include + + +static inline void ep93xx_standby(void) +{ + u32 v; + v = __raw_readl(EP93XX_SYSCON_DEVICE_CONFIG); + v |= EP93XX_SYSCON_DEVICE_CONFIG_SHENA; + __raw_writel(0xaa, EP93XX_SYSCON_SWLOCK); + __raw_writel(v, EP93XX_SYSCON_DEVICE_CONFIG); + + v = __raw_readl(EP93XX_SYSCON_STANDBY); + + asm("nop; nop; nop; nop; nop"); +} + +static inline void ep93xx_resume(void) +{ + u32 v; + + v = __raw_readl(EP93XX_SYSCON_DEVICE_CONFIG); + v &= ~EP93XX_SYSCON_DEVICE_CONFIG_SHENA; + __raw_writel(0xaa, EP93XX_SYSCON_SWLOCK); + __raw_writel(v, EP93XX_SYSCON_DEVICE_CONFIG); +} + +static int suspend_ep93xx_enter(suspend_state_t state) +{ + switch (state) { + case PM_SUSPEND_STANDBY: + case PM_SUSPEND_MEM: + ep93xx_standby(); /* go zzz */ + ep93xx_resume(); + } + return 0; +} + +static int suspend_ep93xx_valid(suspend_state_t state) +{ + return (state == PM_SUSPEND_STANDBY) || + (state == PM_SUSPEND_MEM); +} + + +static struct platform_suspend_ops ep93xx_suspend_ops = { + .enter = suspend_ep93xx_enter, + .valid = suspend_ep93xx_valid, +}; + +static int __init ep93xx_pm_init(void) +{ + pr_info("ep93xx: Power Management\n"); + suspend_set_ops(&ep93xx_suspend_ops); + return 0; +} +__initcall(ep93xx_pm_init); -- 1.6.0.4