^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #ifndef _ASM_SH_SUSPEND_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #define _ASM_SH_SUSPEND_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #ifndef __ASSEMBLY__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <linux/notifier.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <asm/ptrace.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) struct swsusp_arch_regs {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) struct pt_regs user_regs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) unsigned long bank1_regs[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) void sh_mobile_call_standby(unsigned long mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #ifdef CONFIG_CPU_IDLE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) int sh_mobile_setup_cpuidle(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) static inline int sh_mobile_setup_cpuidle(void) { return 0; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) /* notifier chains for pre/post sleep hooks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) extern struct atomic_notifier_head sh_mobile_pre_sleep_notifier_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) extern struct atomic_notifier_head sh_mobile_post_sleep_notifier_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) /* priority levels for notifiers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #define SH_MOBILE_SLEEP_BOARD 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #define SH_MOBILE_SLEEP_CPU 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #define SH_MOBILE_PRE(x) (x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #define SH_MOBILE_POST(x) (-(x))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) /* board code registration function for self-refresh assembly snippets */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) void sh_mobile_register_self_refresh(unsigned long flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) void *pre_start, void *pre_end,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) void *post_start, void *post_end);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) /* register structure for address/data information */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) struct sh_sleep_regs {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) unsigned long stbcr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) unsigned long bar;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) /* MMU */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) unsigned long pteh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) unsigned long ptel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) unsigned long ttb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) unsigned long tea;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) unsigned long mmucr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) unsigned long ptea;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) unsigned long pascr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) unsigned long irmcr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) /* Cache */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) unsigned long ccr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) unsigned long ramcr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) /* data area for low-level sleep code */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) struct sh_sleep_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) /* current sleep mode (SUSP_SH_...) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) unsigned long mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) /* addresses of board specific self-refresh snippets */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) unsigned long sf_pre;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) unsigned long sf_post;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) /* address of resume code */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) unsigned long resume;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) /* register state saved and restored by the assembly code */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) unsigned long vbr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) unsigned long spc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) unsigned long sr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) unsigned long sp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) /* structure for keeping register addresses */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) struct sh_sleep_regs addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) /* structure for saving/restoring register state */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) struct sh_sleep_regs data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) /* a bitmap of supported sleep modes (SUSP_SH..) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) extern unsigned long sh_mobile_sleep_supported;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) /* flags passed to assembly suspend code */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) #define SUSP_SH_SLEEP (1 << 0) /* Regular sleep mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) #define SUSP_SH_STANDBY (1 << 1) /* SH-Mobile Software standby mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) #define SUSP_SH_RSTANDBY (1 << 2) /* SH-Mobile R-standby mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) #define SUSP_SH_USTANDBY (1 << 3) /* SH-Mobile U-standby mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) #define SUSP_SH_SF (1 << 4) /* Enable self-refresh */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) #define SUSP_SH_MMU (1 << 5) /* Save/restore MMU and cache */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) #define SUSP_SH_REGS (1 << 6) /* Save/restore registers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) #endif /* _ASM_SH_SUSPEND_H */