162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci#ifndef _ASM_SH_SUSPEND_H
362306a36Sopenharmony_ci#define _ASM_SH_SUSPEND_H
462306a36Sopenharmony_ci
562306a36Sopenharmony_ci#ifndef __ASSEMBLY__
662306a36Sopenharmony_ci#include <linux/notifier.h>
762306a36Sopenharmony_ci
862306a36Sopenharmony_ci#include <asm/ptrace.h>
962306a36Sopenharmony_ci
1062306a36Sopenharmony_cistruct swsusp_arch_regs {
1162306a36Sopenharmony_ci	struct pt_regs user_regs;
1262306a36Sopenharmony_ci	unsigned long bank1_regs[8];
1362306a36Sopenharmony_ci};
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_civoid sh_mobile_call_standby(unsigned long mode);
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ci#ifdef CONFIG_CPU_IDLE
1862306a36Sopenharmony_ciint sh_mobile_setup_cpuidle(void);
1962306a36Sopenharmony_ci#else
2062306a36Sopenharmony_cistatic inline int sh_mobile_setup_cpuidle(void) { return 0; }
2162306a36Sopenharmony_ci#endif
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_ci/* notifier chains for pre/post sleep hooks */
2462306a36Sopenharmony_ciextern struct atomic_notifier_head sh_mobile_pre_sleep_notifier_list;
2562306a36Sopenharmony_ciextern struct atomic_notifier_head sh_mobile_post_sleep_notifier_list;
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ci/* priority levels for notifiers */
2862306a36Sopenharmony_ci#define SH_MOBILE_SLEEP_BOARD	0
2962306a36Sopenharmony_ci#define SH_MOBILE_SLEEP_CPU	1
3062306a36Sopenharmony_ci#define SH_MOBILE_PRE(x)	(x)
3162306a36Sopenharmony_ci#define SH_MOBILE_POST(x)	(-(x))
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci/* board code registration function for self-refresh assembly snippets */
3462306a36Sopenharmony_civoid sh_mobile_register_self_refresh(unsigned long flags,
3562306a36Sopenharmony_ci				     void *pre_start, void *pre_end,
3662306a36Sopenharmony_ci				     void *post_start, void *post_end);
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ci/* register structure for address/data information */
3962306a36Sopenharmony_cistruct sh_sleep_regs {
4062306a36Sopenharmony_ci	unsigned long stbcr;
4162306a36Sopenharmony_ci	unsigned long bar;
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_ci	/* MMU */
4462306a36Sopenharmony_ci	unsigned long pteh;
4562306a36Sopenharmony_ci	unsigned long ptel;
4662306a36Sopenharmony_ci	unsigned long ttb;
4762306a36Sopenharmony_ci	unsigned long tea;
4862306a36Sopenharmony_ci	unsigned long mmucr;
4962306a36Sopenharmony_ci	unsigned long ptea;
5062306a36Sopenharmony_ci	unsigned long pascr;
5162306a36Sopenharmony_ci	unsigned long irmcr;
5262306a36Sopenharmony_ci
5362306a36Sopenharmony_ci	/* Cache */
5462306a36Sopenharmony_ci	unsigned long ccr;
5562306a36Sopenharmony_ci	unsigned long ramcr;
5662306a36Sopenharmony_ci};
5762306a36Sopenharmony_ci
5862306a36Sopenharmony_ci/* data area for low-level sleep code */
5962306a36Sopenharmony_cistruct sh_sleep_data {
6062306a36Sopenharmony_ci	/* current sleep mode (SUSP_SH_...) */
6162306a36Sopenharmony_ci	unsigned long mode;
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_ci	/* addresses of board specific self-refresh snippets */
6462306a36Sopenharmony_ci	unsigned long sf_pre;
6562306a36Sopenharmony_ci	unsigned long sf_post;
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_ci	/* address of resume code */
6862306a36Sopenharmony_ci	unsigned long resume;
6962306a36Sopenharmony_ci
7062306a36Sopenharmony_ci	/* register state saved and restored by the assembly code */
7162306a36Sopenharmony_ci	unsigned long vbr;
7262306a36Sopenharmony_ci	unsigned long spc;
7362306a36Sopenharmony_ci	unsigned long sr;
7462306a36Sopenharmony_ci	unsigned long sp;
7562306a36Sopenharmony_ci
7662306a36Sopenharmony_ci	/* structure for keeping register addresses */
7762306a36Sopenharmony_ci	struct sh_sleep_regs addr;
7862306a36Sopenharmony_ci
7962306a36Sopenharmony_ci	/* structure for saving/restoring register state */
8062306a36Sopenharmony_ci	struct sh_sleep_regs data;
8162306a36Sopenharmony_ci};
8262306a36Sopenharmony_ci
8362306a36Sopenharmony_ci/* a bitmap of supported sleep modes (SUSP_SH..) */
8462306a36Sopenharmony_ciextern unsigned long sh_mobile_sleep_supported;
8562306a36Sopenharmony_ci
8662306a36Sopenharmony_ci#endif
8762306a36Sopenharmony_ci
8862306a36Sopenharmony_ci/* flags passed to assembly suspend code */
8962306a36Sopenharmony_ci#define SUSP_SH_SLEEP		(1 << 0) /* Regular sleep mode */
9062306a36Sopenharmony_ci#define SUSP_SH_STANDBY		(1 << 1) /* SH-Mobile Software standby mode */
9162306a36Sopenharmony_ci#define SUSP_SH_RSTANDBY	(1 << 2) /* SH-Mobile R-standby mode */
9262306a36Sopenharmony_ci#define SUSP_SH_USTANDBY	(1 << 3) /* SH-Mobile U-standby mode */
9362306a36Sopenharmony_ci#define SUSP_SH_SF		(1 << 4) /* Enable self-refresh */
9462306a36Sopenharmony_ci#define SUSP_SH_MMU		(1 << 5) /* Save/restore MMU and cache */
9562306a36Sopenharmony_ci#define SUSP_SH_REGS		(1 << 6) /* Save/restore registers */
9662306a36Sopenharmony_ci
9762306a36Sopenharmony_ci#endif /* _ASM_SH_SUSPEND_H */
98