2 * arch/sh/kernel/cpu/sh4a/pm-sh_mobile.c
4 * Power management support code for SuperH Mobile
6 * Copyright (C) 2009 Magnus Damm
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive
12 #include <linux/init.h>
13 #include <linux/kernel.h>
15 #include <linux/suspend.h>
16 #include <asm/suspend.h>
17 #include <asm/uaccess.h>
20 * Sleep modes available on SuperH Mobile:
22 * Sleep mode is just plain "sleep" instruction
23 * Sleep Self-Refresh mode is above plus RAM put in Self-Refresh
24 * Standby Self-Refresh mode is above plus stopped clocks
26 #define SUSP_MODE_SLEEP (SUSP_SH_SLEEP)
27 #define SUSP_MODE_SLEEP_SF (SUSP_SH_SLEEP | SUSP_SH_SF)
28 #define SUSP_MODE_STANDBY_SF (SUSP_SH_STANDBY | SUSP_SH_SF)
31 * The following modes are not there yet:
33 * R-standby mode is unsupported, but will be added in the future
34 * U-standby mode is low priority since it needs bootloader hacks
36 * All modes should be tied in with cpuidle. But before that can
37 * happen we need to keep track of enabled hardware blocks so we
38 * can avoid entering sleep modes that stop clocks to hardware
39 * blocks that are in use even though the cpu core is idle.
42 extern const unsigned char sh_mobile_standby
[];
43 extern const unsigned int sh_mobile_standby_size
;
45 static void sh_mobile_call_standby(unsigned long mode
)
47 extern void *vbr_base
;
48 void *onchip_mem
= (void *)0xe5200000; /* ILRAM */
49 void (*standby_onchip_mem
)(unsigned long) = onchip_mem
;
51 /* Note: Wake up from sleep may generate exceptions!
52 * Setup VBR to point to on-chip ram if self-refresh is
55 if (mode
& SUSP_SH_SF
)
56 asm volatile("ldc %0, vbr" : : "r" (onchip_mem
) : "memory");
58 /* Copy the assembly snippet to the otherwise ununsed ILRAM */
59 memcpy(onchip_mem
, sh_mobile_standby
, sh_mobile_standby_size
);
63 /* Let assembly snippet in on-chip memory handle the rest */
64 standby_onchip_mem(mode
);
66 /* Put VBR back in System RAM again */
67 if (mode
& SUSP_SH_SF
)
68 asm volatile("ldc %0, vbr" : : "r" (&vbr_base
) : "memory");
71 static int sh_pm_enter(suspend_state_t state
)
75 sh_mobile_call_standby(SUSP_MODE_STANDBY_SF
);
81 static struct platform_suspend_ops sh_pm_ops
= {
83 .valid
= suspend_valid_only_mem
,
86 static int __init
sh_pm_init(void)
88 suspend_set_ops(&sh_pm_ops
);
92 late_initcall(sh_pm_init
);