18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Common defines for v7m cpus
48c2ecf20Sopenharmony_ci */
58c2ecf20Sopenharmony_ci#define V7M_SCS_ICTR			IOMEM(0xe000e004)
68c2ecf20Sopenharmony_ci#define V7M_SCS_ICTR_INTLINESNUM_MASK		0x0000000f
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#define BASEADDR_V7M_SCB		IOMEM(0xe000ed00)
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#define V7M_SCB_CPUID			0x00
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#define V7M_SCB_ICSR			0x04
138c2ecf20Sopenharmony_ci#define V7M_SCB_ICSR_PENDSVSET			(1 << 28)
148c2ecf20Sopenharmony_ci#define V7M_SCB_ICSR_PENDSVCLR			(1 << 27)
158c2ecf20Sopenharmony_ci#define V7M_SCB_ICSR_RETTOBASE			(1 << 11)
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci#define V7M_SCB_VTOR			0x08
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci#define V7M_SCB_AIRCR			0x0c
208c2ecf20Sopenharmony_ci#define V7M_SCB_AIRCR_VECTKEY			(0x05fa << 16)
218c2ecf20Sopenharmony_ci#define V7M_SCB_AIRCR_SYSRESETREQ		(1 << 2)
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci#define V7M_SCB_SCR			0x10
248c2ecf20Sopenharmony_ci#define V7M_SCB_SCR_SLEEPDEEP			(1 << 2)
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci#define V7M_SCB_CCR			0x14
278c2ecf20Sopenharmony_ci#define V7M_SCB_CCR_STKALIGN			(1 << 9)
288c2ecf20Sopenharmony_ci#define V7M_SCB_CCR_DC				(1 << 16)
298c2ecf20Sopenharmony_ci#define V7M_SCB_CCR_IC				(1 << 17)
308c2ecf20Sopenharmony_ci#define V7M_SCB_CCR_BP				(1 << 18)
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci#define V7M_SCB_SHPR2			0x1c
338c2ecf20Sopenharmony_ci#define V7M_SCB_SHPR3			0x20
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci#define V7M_SCB_SHCSR			0x24
368c2ecf20Sopenharmony_ci#define V7M_SCB_SHCSR_USGFAULTENA		(1 << 18)
378c2ecf20Sopenharmony_ci#define V7M_SCB_SHCSR_BUSFAULTENA		(1 << 17)
388c2ecf20Sopenharmony_ci#define V7M_SCB_SHCSR_MEMFAULTENA		(1 << 16)
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci#define V7M_xPSR_FRAMEPTRALIGN			0x00000200
418c2ecf20Sopenharmony_ci#define V7M_xPSR_EXCEPTIONNO			0x000001ff
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci/*
448c2ecf20Sopenharmony_ci * When branching to an address that has bits [31:28] == 0xf an exception return
458c2ecf20Sopenharmony_ci * occurs. Bits [27:5] are reserved (SBOP). If the processor implements the FP
468c2ecf20Sopenharmony_ci * extension Bit [4] defines if the exception frame has space allocated for FP
478c2ecf20Sopenharmony_ci * state information, SBOP otherwise. Bit [3] defines the mode that is returned
488c2ecf20Sopenharmony_ci * to (0 -> handler mode; 1 -> thread mode). Bit [2] defines which sp is used
498c2ecf20Sopenharmony_ci * (0 -> msp; 1 -> psp). Bits [1:0] are fixed to 0b01.
508c2ecf20Sopenharmony_ci */
518c2ecf20Sopenharmony_ci#define EXC_RET_STACK_MASK			0x00000004
528c2ecf20Sopenharmony_ci#define EXC_RET_THREADMODE_PROCESSSTACK		(3 << 2)
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci/* Cache related definitions */
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci#define	V7M_SCB_CLIDR		0x78	/* Cache Level ID register */
578c2ecf20Sopenharmony_ci#define	V7M_SCB_CTR		0x7c	/* Cache Type register */
588c2ecf20Sopenharmony_ci#define	V7M_SCB_CCSIDR		0x80	/* Cache size ID register */
598c2ecf20Sopenharmony_ci#define	V7M_SCB_CSSELR		0x84	/* Cache size selection register */
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci/* Memory-mapped MPU registers for M-class */
628c2ecf20Sopenharmony_ci#define MPU_TYPE		0x90
638c2ecf20Sopenharmony_ci#define MPU_CTRL		0x94
648c2ecf20Sopenharmony_ci#define MPU_CTRL_ENABLE		1
658c2ecf20Sopenharmony_ci#define MPU_CTRL_PRIVDEFENA	(1 << 2)
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_ci#define PMSAv7_RNR		0x98
688c2ecf20Sopenharmony_ci#define PMSAv7_RBAR		0x9c
698c2ecf20Sopenharmony_ci#define PMSAv7_RASR		0xa0
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ci#define PMSAv8_RNR		0x98
728c2ecf20Sopenharmony_ci#define PMSAv8_RBAR		0x9c
738c2ecf20Sopenharmony_ci#define PMSAv8_RLAR		0xa0
748c2ecf20Sopenharmony_ci#define PMSAv8_RBAR_A(n)	(PMSAv8_RBAR + 8*(n))
758c2ecf20Sopenharmony_ci#define PMSAv8_RLAR_A(n)	(PMSAv8_RLAR + 8*(n))
768c2ecf20Sopenharmony_ci#define PMSAv8_MAIR0		0xc0
778c2ecf20Sopenharmony_ci#define PMSAv8_MAIR1		0xc4
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ci/* Cache opeartions */
808c2ecf20Sopenharmony_ci#define	V7M_SCB_ICIALLU		0x250	/* I-cache invalidate all to PoU */
818c2ecf20Sopenharmony_ci#define	V7M_SCB_ICIMVAU		0x258	/* I-cache invalidate by MVA to PoU */
828c2ecf20Sopenharmony_ci#define	V7M_SCB_DCIMVAC		0x25c	/* D-cache invalidate by MVA to PoC */
838c2ecf20Sopenharmony_ci#define	V7M_SCB_DCISW		0x260	/* D-cache invalidate by set-way */
848c2ecf20Sopenharmony_ci#define	V7M_SCB_DCCMVAU		0x264	/* D-cache clean by MVA to PoU */
858c2ecf20Sopenharmony_ci#define	V7M_SCB_DCCMVAC		0x268	/* D-cache clean by MVA to PoC */
868c2ecf20Sopenharmony_ci#define	V7M_SCB_DCCSW		0x26c	/* D-cache clean by set-way */
878c2ecf20Sopenharmony_ci#define	V7M_SCB_DCCIMVAC	0x270	/* D-cache clean and invalidate by MVA to PoC */
888c2ecf20Sopenharmony_ci#define	V7M_SCB_DCCISW		0x274	/* D-cache clean and invalidate by set-way */
898c2ecf20Sopenharmony_ci#define	V7M_SCB_BPIALL		0x278	/* D-cache clean and invalidate by set-way */
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_cienum reboot_mode;
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_civoid armv7m_restart(enum reboot_mode mode, const char *cmd);
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_ci#endif /* __ASSEMBLY__ */
98