2 * (C) Copyright 2010,2011
3 * Vladimir Khusainov, Emcraft Systems, vlad@emcraft.com
6 * Kamil Lulko, <kamil.lulko@gmail.com>
8 * SPDX-License-Identifier: GPL-2.0+
14 #if defined(__ASSEMBLY__)
19 /* armv7m fixed base addresses */
20 #define V7M_SCS_BASE 0xE000E000
21 #define V7M_NVIC_BASE (V7M_SCS_BASE + 0x0100)
22 #define V7M_SCB_BASE (V7M_SCS_BASE + 0x0D00)
23 #define V7M_PROC_FTR_BASE (V7M_SCS_BASE + 0x0D78)
24 #define V7M_MPU_BASE (V7M_SCS_BASE + 0x0D90)
25 #define V7M_FPU_BASE (V7M_SCS_BASE + 0x0F30)
26 #define V7M_CACHE_MAINT_BASE (V7M_SCS_BASE + 0x0F50)
27 #define V7M_ACCESS_CNTL_BASE (V7M_SCS_BASE + 0x0F90)
29 #define V7M_SCB_VTOR 0x08
31 #if !defined(__ASSEMBLY__)
33 uint32_t cpuid; /* CPUID Base Register */
34 uint32_t icsr; /* Interrupt Control and State Register */
35 uint32_t vtor; /* Vector Table Offset Register */
36 uint32_t aircr; /* App Interrupt and Reset Control Register */
37 uint32_t scr; /* offset 0x10: System Control Register */
38 uint32_t ccr; /* offset 0x14: Config and Control Register */
39 uint32_t shpr1; /* offset 0x18: System Handler Priority Reg 1 */
40 uint32_t shpr2; /* offset 0x1c: System Handler Priority Reg 2 */
41 uint32_t shpr3; /* offset 0x20: System Handler Priority Reg 3 */
42 uint32_t shcrs; /* offset 0x24: System Handler Control State */
43 uint32_t cfsr; /* offset 0x28: Configurable Fault Status Reg */
44 uint32_t hfsr; /* offset 0x2C: HardFault Status Register */
45 uint32_t res; /* offset 0x30: reserved */
46 uint32_t mmar; /* offset 0x34: MemManage Fault Address Reg */
47 uint32_t bfar; /* offset 0x38: BusFault Address Reg */
48 uint32_t afsr; /* offset 0x3C: Auxiliary Fault Status Reg */
50 #define V7M_SCB ((struct v7m_scb *)V7M_SCB_BASE)
52 #define V7M_AIRCR_VECTKEY 0x5fa
53 #define V7M_AIRCR_VECTKEY_SHIFT 16
54 #define V7M_AIRCR_ENDIAN (1 << 15)
55 #define V7M_AIRCR_PRIGROUP_SHIFT 8
56 #define V7M_AIRCR_PRIGROUP_MSK (0x7 << V7M_AIRCR_PRIGROUP_SHIFT)
57 #define V7M_AIRCR_SYSRESET (1 << 2)
59 #define V7M_ICSR_VECTACT_MSK 0xFF
61 #define V7M_CCR_DCACHE 16
62 #define V7M_CCR_ICACHE 17
65 uint32_t type; /* Type Register */
66 uint32_t ctrl; /* Control Register */
67 uint32_t rnr; /* Region Number Register */
68 uint32_t rbar; /* Region Base Address Register */
69 uint32_t rasr; /* Region Attribute and Size Register */
71 #define V7M_MPU ((struct v7m_mpu *)V7M_MPU_BASE)
73 #define V7M_MPU_CTRL_ENABLE (1 << 0)
74 #define V7M_MPU_CTRL_HFNMIENA (1 << 1)
76 #define V7M_MPU_CTRL_ENABLE (1 << 0)
77 #define V7M_MPU_CTRL_DISABLE (0 << 0)
78 #define V7M_MPU_CTRL_HFNMIENA (1 << 1)
80 #define V7M_MPU_RASR_EN (1 << 0)
81 #define V7M_MPU_RASR_SIZE_BITS 1
82 #define V7M_MPU_RASR_SIZE_4GB (31 << V7M_MPU_RASR_SIZE_BITS)
83 #define V7M_MPU_RASR_SIZE_8MB (24 << V7M_MPU_RASR_SIZE_BITS)
84 #define V7M_MPU_RASR_TEX_SHIFT 19
85 #define V7M_MPU_RASR_S_SHIFT 18
86 #define V7M_MPU_RASR_C_SHIFT 17
87 #define V7M_MPU_RASR_B_SHIFT 16
88 #define V7M_MPU_RASR_AP_RW_RW (3 << 24)
89 #define V7M_MPU_RASR_XN_ENABLE (0 << 28)
90 #define V7M_MPU_RASR_XN_DISABLE (1 << 28)
92 #endif /* !defined(__ASSEMBLY__) */