18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef _ASM_SH_SUSPEND_H 38c2ecf20Sopenharmony_ci#define _ASM_SH_SUSPEND_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__ 68c2ecf20Sopenharmony_ci#include <linux/notifier.h> 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#include <asm/ptrace.h> 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_cistruct swsusp_arch_regs { 118c2ecf20Sopenharmony_ci struct pt_regs user_regs; 128c2ecf20Sopenharmony_ci unsigned long bank1_regs[8]; 138c2ecf20Sopenharmony_ci}; 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_civoid sh_mobile_call_standby(unsigned long mode); 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci#ifdef CONFIG_CPU_IDLE 188c2ecf20Sopenharmony_ciint sh_mobile_setup_cpuidle(void); 198c2ecf20Sopenharmony_ci#else 208c2ecf20Sopenharmony_cistatic inline int sh_mobile_setup_cpuidle(void) { return 0; } 218c2ecf20Sopenharmony_ci#endif 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci/* notifier chains for pre/post sleep hooks */ 248c2ecf20Sopenharmony_ciextern struct atomic_notifier_head sh_mobile_pre_sleep_notifier_list; 258c2ecf20Sopenharmony_ciextern struct atomic_notifier_head sh_mobile_post_sleep_notifier_list; 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci/* priority levels for notifiers */ 288c2ecf20Sopenharmony_ci#define SH_MOBILE_SLEEP_BOARD 0 298c2ecf20Sopenharmony_ci#define SH_MOBILE_SLEEP_CPU 1 308c2ecf20Sopenharmony_ci#define SH_MOBILE_PRE(x) (x) 318c2ecf20Sopenharmony_ci#define SH_MOBILE_POST(x) (-(x)) 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci/* board code registration function for self-refresh assembly snippets */ 348c2ecf20Sopenharmony_civoid sh_mobile_register_self_refresh(unsigned long flags, 358c2ecf20Sopenharmony_ci void *pre_start, void *pre_end, 368c2ecf20Sopenharmony_ci void *post_start, void *post_end); 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci/* register structure for address/data information */ 398c2ecf20Sopenharmony_cistruct sh_sleep_regs { 408c2ecf20Sopenharmony_ci unsigned long stbcr; 418c2ecf20Sopenharmony_ci unsigned long bar; 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci /* MMU */ 448c2ecf20Sopenharmony_ci unsigned long pteh; 458c2ecf20Sopenharmony_ci unsigned long ptel; 468c2ecf20Sopenharmony_ci unsigned long ttb; 478c2ecf20Sopenharmony_ci unsigned long tea; 488c2ecf20Sopenharmony_ci unsigned long mmucr; 498c2ecf20Sopenharmony_ci unsigned long ptea; 508c2ecf20Sopenharmony_ci unsigned long pascr; 518c2ecf20Sopenharmony_ci unsigned long irmcr; 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci /* Cache */ 548c2ecf20Sopenharmony_ci unsigned long ccr; 558c2ecf20Sopenharmony_ci unsigned long ramcr; 568c2ecf20Sopenharmony_ci}; 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci/* data area for low-level sleep code */ 598c2ecf20Sopenharmony_cistruct sh_sleep_data { 608c2ecf20Sopenharmony_ci /* current sleep mode (SUSP_SH_...) */ 618c2ecf20Sopenharmony_ci unsigned long mode; 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci /* addresses of board specific self-refresh snippets */ 648c2ecf20Sopenharmony_ci unsigned long sf_pre; 658c2ecf20Sopenharmony_ci unsigned long sf_post; 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ci /* address of resume code */ 688c2ecf20Sopenharmony_ci unsigned long resume; 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci /* register state saved and restored by the assembly code */ 718c2ecf20Sopenharmony_ci unsigned long vbr; 728c2ecf20Sopenharmony_ci unsigned long spc; 738c2ecf20Sopenharmony_ci unsigned long sr; 748c2ecf20Sopenharmony_ci unsigned long sp; 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ci /* structure for keeping register addresses */ 778c2ecf20Sopenharmony_ci struct sh_sleep_regs addr; 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci /* structure for saving/restoring register state */ 808c2ecf20Sopenharmony_ci struct sh_sleep_regs data; 818c2ecf20Sopenharmony_ci}; 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci/* a bitmap of supported sleep modes (SUSP_SH..) */ 848c2ecf20Sopenharmony_ciextern unsigned long sh_mobile_sleep_supported; 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_ci#endif 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci/* flags passed to assembly suspend code */ 898c2ecf20Sopenharmony_ci#define SUSP_SH_SLEEP (1 << 0) /* Regular sleep mode */ 908c2ecf20Sopenharmony_ci#define SUSP_SH_STANDBY (1 << 1) /* SH-Mobile Software standby mode */ 918c2ecf20Sopenharmony_ci#define SUSP_SH_RSTANDBY (1 << 2) /* SH-Mobile R-standby mode */ 928c2ecf20Sopenharmony_ci#define SUSP_SH_USTANDBY (1 << 3) /* SH-Mobile U-standby mode */ 938c2ecf20Sopenharmony_ci#define SUSP_SH_SF (1 << 4) /* Enable self-refresh */ 948c2ecf20Sopenharmony_ci#define SUSP_SH_MMU (1 << 5) /* Save/restore MMU and cache */ 958c2ecf20Sopenharmony_ci#define SUSP_SH_REGS (1 << 6) /* Save/restore registers */ 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_ci#endif /* _ASM_SH_SUSPEND_H */ 98