blob: 70ae0b2888ab9979410d882a08b50c0c2a926a79 [file] [log] [blame]
Magnus Damm2ef7f0d2009-03-06 09:47:02 +00001#ifndef _ASM_SH_SUSPEND_H
2#define _ASM_SH_SUSPEND_H
3
Magnus Damm77594912009-03-13 15:23:04 +00004#ifndef __ASSEMBLY__
Magnus Damm49f42642009-10-29 10:51:48 +00005#include <linux/notifier.h>
Magnus Damm2ef7f0d2009-03-06 09:47:02 +00006
7#include <asm/ptrace.h>
8
9struct swsusp_arch_regs {
10 struct pt_regs user_regs;
11 unsigned long bank1_regs[8];
12};
Magnus Damm74263942009-07-03 10:28:00 +000013
14void sh_mobile_call_standby(unsigned long mode);
15
16#ifdef CONFIG_CPU_IDLE
Daniel Lezcano38a94f42013-04-17 13:32:57 +000017int sh_mobile_setup_cpuidle(void);
Magnus Damm74263942009-07-03 10:28:00 +000018#else
Daniel Lezcano38a94f42013-04-17 13:32:57 +000019static inline int sh_mobile_setup_cpuidle(void) { return 0; }
Magnus Damm74263942009-07-03 10:28:00 +000020#endif
21
Magnus Damm49f42642009-10-29 10:51:48 +000022/* notifier chains for pre/post sleep hooks */
23extern struct atomic_notifier_head sh_mobile_pre_sleep_notifier_list;
24extern struct atomic_notifier_head sh_mobile_post_sleep_notifier_list;
25
26/* priority levels for notifiers */
27#define SH_MOBILE_SLEEP_BOARD 0
28#define SH_MOBILE_SLEEP_CPU 1
29#define SH_MOBILE_PRE(x) (x)
30#define SH_MOBILE_POST(x) (-(x))
31
Magnus Damm159f8cd2009-10-29 10:52:06 +000032/* board code registration function for self-refresh assembly snippets */
33void sh_mobile_register_self_refresh(unsigned long flags,
34 void *pre_start, void *pre_end,
35 void *post_start, void *post_end);
Magnus Damm323ef8d2009-10-30 04:24:07 +000036
37/* register structure for address/data information */
38struct sh_sleep_regs {
39 unsigned long stbcr;
Magnus Dammbb3e0ee2009-10-30 04:24:40 +000040 unsigned long bar;
Magnus Damm99675a72009-10-30 04:24:23 +000041
42 /* MMU */
43 unsigned long pteh;
44 unsigned long ptel;
45 unsigned long ttb;
46 unsigned long tea;
47 unsigned long mmucr;
48 unsigned long ptea;
49 unsigned long pascr;
50 unsigned long irmcr;
51
52 /* Cache */
53 unsigned long ccr;
54 unsigned long ramcr;
Magnus Damm323ef8d2009-10-30 04:24:07 +000055};
56
57/* data area for low-level sleep code */
58struct sh_sleep_data {
59 /* current sleep mode (SUSP_SH_...) */
60 unsigned long mode;
61
62 /* addresses of board specific self-refresh snippets */
63 unsigned long sf_pre;
64 unsigned long sf_post;
65
Magnus Dammbb3e0ee2009-10-30 04:24:40 +000066 /* address of resume code */
67 unsigned long resume;
68
Magnus Damm323ef8d2009-10-30 04:24:07 +000069 /* register state saved and restored by the assembly code */
70 unsigned long vbr;
71 unsigned long spc;
72 unsigned long sr;
Magnus Dammbb3e0ee2009-10-30 04:24:40 +000073 unsigned long sp;
Magnus Damm323ef8d2009-10-30 04:24:07 +000074
75 /* structure for keeping register addresses */
76 struct sh_sleep_regs addr;
77
78 /* structure for saving/restoring register state */
79 struct sh_sleep_regs data;
80};
81
Magnus Damm02bf8932009-10-30 04:24:15 +000082/* a bitmap of supported sleep modes (SUSP_SH..) */
83extern unsigned long sh_mobile_sleep_supported;
84
Magnus Damm77594912009-03-13 15:23:04 +000085#endif
86
87/* flags passed to assembly suspend code */
88#define SUSP_SH_SLEEP (1 << 0) /* Regular sleep mode */
89#define SUSP_SH_STANDBY (1 << 1) /* SH-Mobile Software standby mode */
90#define SUSP_SH_RSTANDBY (1 << 2) /* SH-Mobile R-standby mode */
91#define SUSP_SH_USTANDBY (1 << 3) /* SH-Mobile U-standby mode */
92#define SUSP_SH_SF (1 << 4) /* Enable self-refresh */
Magnus Damm99675a72009-10-30 04:24:23 +000093#define SUSP_SH_MMU (1 << 5) /* Save/restore MMU and cache */
Magnus Damm41bfb7d2010-02-25 11:03:24 +000094#define SUSP_SH_REGS (1 << 6) /* Save/restore registers */
Magnus Damm2ef7f0d2009-03-06 09:47:02 +000095
96#endif /* _ASM_SH_SUSPEND_H */