xref: /openbmc/linux/arch/sh/include/asm/suspend.h (revision 4f3db074)
1 #ifndef _ASM_SH_SUSPEND_H
2 #define _ASM_SH_SUSPEND_H
3 
4 #ifndef __ASSEMBLY__
5 #include <linux/notifier.h>
6 
7 #include <asm/ptrace.h>
8 
9 struct swsusp_arch_regs {
10 	struct pt_regs user_regs;
11 	unsigned long bank1_regs[8];
12 };
13 
14 void sh_mobile_call_standby(unsigned long mode);
15 
16 #ifdef CONFIG_CPU_IDLE
17 int sh_mobile_setup_cpuidle(void);
18 #else
19 static inline int sh_mobile_setup_cpuidle(void) { return 0; }
20 #endif
21 
22 /* notifier chains for pre/post sleep hooks */
23 extern struct atomic_notifier_head sh_mobile_pre_sleep_notifier_list;
24 extern 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 
32 /* board code registration function for self-refresh assembly snippets */
33 void sh_mobile_register_self_refresh(unsigned long flags,
34 				     void *pre_start, void *pre_end,
35 				     void *post_start, void *post_end);
36 
37 /* register structure for address/data information */
38 struct sh_sleep_regs {
39 	unsigned long stbcr;
40 	unsigned long bar;
41 
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;
55 };
56 
57 /* data area for low-level sleep code */
58 struct 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 
66 	/* address of resume code */
67 	unsigned long resume;
68 
69 	/* register state saved and restored by the assembly code */
70 	unsigned long vbr;
71 	unsigned long spc;
72 	unsigned long sr;
73 	unsigned long sp;
74 
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 
82 /* a bitmap of supported sleep modes (SUSP_SH..) */
83 extern unsigned long sh_mobile_sleep_supported;
84 
85 #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 */
93 #define SUSP_SH_MMU		(1 << 5) /* Save/restore MMU and cache */
94 #define SUSP_SH_REGS		(1 << 6) /* Save/restore registers */
95 
96 #endif /* _ASM_SH_SUSPEND_H */
97