system.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  1. #ifndef __ASM_ARM_SYSTEM_H
  2. #define __ASM_ARM_SYSTEM_H
  3. #include <common.h>
  4. #include <linux/compiler.h>
  5. #include <asm/barriers.h>
  6. #ifdef CONFIG_ARM64
  7. /*
  8. * SCTLR_EL1/SCTLR_EL2/SCTLR_EL3 bits definitions
  9. */
  10. #define CR_M (1 << 0) /* MMU enable */
  11. #define CR_A (1 << 1) /* Alignment abort enable */
  12. #define CR_C (1 << 2) /* Dcache enable */
  13. #define CR_SA (1 << 3) /* Stack Alignment Check Enable */
  14. #define CR_I (1 << 12) /* Icache enable */
  15. #define CR_WXN (1 << 19) /* Write Permision Imply XN */
  16. #define CR_EE (1 << 25) /* Exception (Big) Endian */
  17. #define ES_TO_AARCH64 1
  18. #define ES_TO_AARCH32 0
  19. /*
  20. * SCR_EL3 bits definitions
  21. */
  22. #define SCR_EL3_RW_AARCH64 (1 << 10) /* Next lower level is AArch64 */
  23. #define SCR_EL3_RW_AARCH32 (0 << 10) /* Lower lowers level are AArch32 */
  24. #define SCR_EL3_HCE_EN (1 << 8) /* Hypervisor Call enable */
  25. #define SCR_EL3_SMD_DIS (1 << 7) /* Secure Monitor Call disable */
  26. #define SCR_EL3_RES1 (3 << 4) /* Reserved, RES1 */
  27. #define SCR_EL3_NS_EN (1 << 0) /* EL0 and EL1 in Non-scure state */
  28. /*
  29. * SPSR_EL3/SPSR_EL2 bits definitions
  30. */
  31. #define SPSR_EL_END_LE (0 << 9) /* Exception Little-endian */
  32. #define SPSR_EL_DEBUG_MASK (1 << 9) /* Debug exception masked */
  33. #define SPSR_EL_ASYN_MASK (1 << 8) /* Asynchronous data abort masked */
  34. #define SPSR_EL_SERR_MASK (1 << 8) /* System Error exception masked */
  35. #define SPSR_EL_IRQ_MASK (1 << 7) /* IRQ exception masked */
  36. #define SPSR_EL_FIQ_MASK (1 << 6) /* FIQ exception masked */
  37. #define SPSR_EL_T_A32 (0 << 5) /* AArch32 instruction set A32 */
  38. #define SPSR_EL_M_AARCH64 (0 << 4) /* Exception taken from AArch64 */
  39. #define SPSR_EL_M_AARCH32 (1 << 4) /* Exception taken from AArch32 */
  40. #define SPSR_EL_M_SVC (0x3) /* Exception taken from SVC mode */
  41. #define SPSR_EL_M_HYP (0xa) /* Exception taken from HYP mode */
  42. #define SPSR_EL_M_EL1H (5) /* Exception taken from EL1h mode */
  43. #define SPSR_EL_M_EL2H (9) /* Exception taken from EL2h mode */
  44. /*
  45. * CPTR_EL2 bits definitions
  46. */
  47. #define CPTR_EL2_RES1 (3 << 12 | 0x3ff) /* Reserved, RES1 */
  48. /*
  49. * SCTLR_EL2 bits definitions
  50. */
  51. #define SCTLR_EL2_RES1 (3 << 28 | 3 << 22 | 1 << 18 | 1 << 16 |\
  52. 1 << 11 | 3 << 4) /* Reserved, RES1 */
  53. #define SCTLR_EL2_EE_LE (0 << 25) /* Exception Little-endian */
  54. #define SCTLR_EL2_WXN_DIS (0 << 19) /* Write permission is not XN */
  55. #define SCTLR_EL2_ICACHE_DIS (0 << 12) /* Instruction cache disabled */
  56. #define SCTLR_EL2_SA_DIS (0 << 3) /* Stack Alignment Check disabled */
  57. #define SCTLR_EL2_DCACHE_DIS (0 << 2) /* Data cache disabled */
  58. #define SCTLR_EL2_ALIGN_DIS (0 << 1) /* Alignment check disabled */
  59. #define SCTLR_EL2_MMU_DIS (0) /* MMU disabled */
  60. /*
  61. * CNTHCTL_EL2 bits definitions
  62. */
  63. #define CNTHCTL_EL2_EL1PCEN_EN (1 << 1) /* Physical timer regs accessible */
  64. #define CNTHCTL_EL2_EL1PCTEN_EN (1 << 0) /* Physical counter accessible */
  65. /*
  66. * HCR_EL2 bits definitions
  67. */
  68. #define HCR_EL2_RW_AARCH64 (1 << 31) /* EL1 is AArch64 */
  69. #define HCR_EL2_RW_AARCH32 (0 << 31) /* Lower levels are AArch32 */
  70. #define HCR_EL2_HCD_DIS (1 << 29) /* Hypervisor Call disabled */
  71. /*
  72. * CPACR_EL1 bits definitions
  73. */
  74. #define CPACR_EL1_FPEN_EN (3 << 20) /* SIMD and FP instruction enabled */
  75. /*
  76. * SCTLR_EL1 bits definitions
  77. */
  78. #define SCTLR_EL1_RES1 (3 << 28 | 3 << 22 | 1 << 20 |\
  79. 1 << 11) /* Reserved, RES1 */
  80. #define SCTLR_EL1_UCI_DIS (0 << 26) /* Cache instruction disabled */
  81. #define SCTLR_EL1_EE_LE (0 << 25) /* Exception Little-endian */
  82. #define SCTLR_EL1_WXN_DIS (0 << 19) /* Write permission is not XN */
  83. #define SCTLR_EL1_NTWE_DIS (0 << 18) /* WFE instruction disabled */
  84. #define SCTLR_EL1_NTWI_DIS (0 << 16) /* WFI instruction disabled */
  85. #define SCTLR_EL1_UCT_DIS (0 << 15) /* CTR_EL0 access disabled */
  86. #define SCTLR_EL1_DZE_DIS (0 << 14) /* DC ZVA instruction disabled */
  87. #define SCTLR_EL1_ICACHE_DIS (0 << 12) /* Instruction cache disabled */
  88. #define SCTLR_EL1_UMA_DIS (0 << 9) /* User Mask Access disabled */
  89. #define SCTLR_EL1_SED_EN (0 << 8) /* SETEND instruction enabled */
  90. #define SCTLR_EL1_ITD_EN (0 << 7) /* IT instruction enabled */
  91. #define SCTLR_EL1_CP15BEN_DIS (0 << 5) /* CP15 barrier operation disabled */
  92. #define SCTLR_EL1_SA0_DIS (0 << 4) /* Stack Alignment EL0 disabled */
  93. #define SCTLR_EL1_SA_DIS (0 << 3) /* Stack Alignment EL1 disabled */
  94. #define SCTLR_EL1_DCACHE_DIS (0 << 2) /* Data cache disabled */
  95. #define SCTLR_EL1_ALIGN_DIS (0 << 1) /* Alignment check disabled */
  96. #define SCTLR_EL1_MMU_DIS (0) /* MMU disabled */
  97. #ifndef __ASSEMBLY__
  98. u64 get_page_table_size(void);
  99. #define PGTABLE_SIZE get_page_table_size()
  100. /* 2MB granularity */
  101. #define MMU_SECTION_SHIFT 21
  102. #define MMU_SECTION_SIZE (1 << MMU_SECTION_SHIFT)
  103. /* These constants need to be synced to the MT_ types in asm/armv8/mmu.h */
  104. enum dcache_option {
  105. DCACHE_OFF = 0 << 2,
  106. DCACHE_WRITETHROUGH = 3 << 2,
  107. DCACHE_WRITEBACK = 4 << 2,
  108. DCACHE_WRITEALLOC = 4 << 2,
  109. };
  110. #define wfi() \
  111. ({asm volatile( \
  112. "wfi" : : : "memory"); \
  113. })
  114. static inline unsigned int current_el(void)
  115. {
  116. unsigned int el;
  117. asm volatile("mrs %0, CurrentEL" : "=r" (el) : : "cc");
  118. return el >> 2;
  119. }
  120. static inline unsigned int get_sctlr(void)
  121. {
  122. unsigned int el, val;
  123. el = current_el();
  124. if (el == 1)
  125. asm volatile("mrs %0, sctlr_el1" : "=r" (val) : : "cc");
  126. else if (el == 2)
  127. asm volatile("mrs %0, sctlr_el2" : "=r" (val) : : "cc");
  128. else
  129. asm volatile("mrs %0, sctlr_el3" : "=r" (val) : : "cc");
  130. return val;
  131. }
  132. static inline void set_sctlr(unsigned int val)
  133. {
  134. unsigned int el;
  135. el = current_el();
  136. if (el == 1)
  137. asm volatile("msr sctlr_el1, %0" : : "r" (val) : "cc");
  138. else if (el == 2)
  139. asm volatile("msr sctlr_el2, %0" : : "r" (val) : "cc");
  140. else
  141. asm volatile("msr sctlr_el3, %0" : : "r" (val) : "cc");
  142. asm volatile("isb");
  143. }
  144. static inline unsigned long read_mpidr(void)
  145. {
  146. unsigned long val;
  147. asm volatile("mrs %0, mpidr_el1" : "=r" (val));
  148. return val;
  149. }
  150. #define BSP_COREID 0
  151. void __asm_flush_dcache_all(void);
  152. void __asm_invalidate_dcache_all(void);
  153. void __asm_flush_dcache_range(u64 start, u64 end);
  154. void __asm_invalidate_tlb_all(void);
  155. void __asm_invalidate_icache_all(void);
  156. int __asm_invalidate_l3_dcache(void);
  157. int __asm_flush_l3_dcache(void);
  158. int __asm_invalidate_l3_icache(void);
  159. void __asm_switch_ttbr(u64 new_ttbr);
  160. /*
  161. * Switch from EL3 to EL2 for ARMv8
  162. *
  163. * @args: For loading 64-bit OS, fdt address.
  164. * For loading 32-bit OS, zero.
  165. * @mach_nr: For loading 64-bit OS, zero.
  166. * For loading 32-bit OS, machine nr
  167. * @fdt_addr: For loading 64-bit OS, zero.
  168. * For loading 32-bit OS, fdt address.
  169. * @entry_point: kernel entry point
  170. * @es_flag: execution state flag, ES_TO_AARCH64 or ES_TO_AARCH32
  171. */
  172. void armv8_switch_to_el2(u64 args, u64 mach_nr, u64 fdt_addr,
  173. u64 entry_point, u64 es_flag);
  174. /*
  175. * Switch from EL2 to EL1 for ARMv8
  176. *
  177. * @args: For loading 64-bit OS, fdt address.
  178. * For loading 32-bit OS, zero.
  179. * @mach_nr: For loading 64-bit OS, zero.
  180. * For loading 32-bit OS, machine nr
  181. * @fdt_addr: For loading 64-bit OS, zero.
  182. * For loading 32-bit OS, fdt address.
  183. * @entry_point: kernel entry point
  184. * @es_flag: execution state flag, ES_TO_AARCH64 or ES_TO_AARCH32
  185. */
  186. void armv8_switch_to_el1(u64 args, u64 mach_nr, u64 fdt_addr,
  187. u64 entry_point, u64 es_flag);
  188. void armv8_el2_to_aarch32(u64 args, u64 mach_nr, u64 fdt_addr,
  189. u64 entry_point);
  190. void gic_init(void);
  191. void gic_send_sgi(unsigned long sgino);
  192. void wait_for_wakeup(void);
  193. void protect_secure_region(void);
  194. void smp_kick_all_cpus(void);
  195. void flush_l3_cache(void);
  196. /*
  197. *Issue a secure monitor call in accordance with ARM "SMC Calling convention",
  198. * DEN0028A
  199. *
  200. * @args: input and output arguments
  201. *
  202. */
  203. void smc_call(struct pt_regs *args);
  204. void __noreturn psci_system_reset(void);
  205. void __noreturn psci_system_off(void);
  206. #endif /* __ASSEMBLY__ */
  207. #else /* CONFIG_ARM64 */
  208. #ifdef __KERNEL__
  209. #define CPU_ARCH_UNKNOWN 0
  210. #define CPU_ARCH_ARMv3 1
  211. #define CPU_ARCH_ARMv4 2
  212. #define CPU_ARCH_ARMv4T 3
  213. #define CPU_ARCH_ARMv5 4
  214. #define CPU_ARCH_ARMv5T 5
  215. #define CPU_ARCH_ARMv5TE 6
  216. #define CPU_ARCH_ARMv5TEJ 7
  217. #define CPU_ARCH_ARMv6 8
  218. #define CPU_ARCH_ARMv7 9
  219. /*
  220. * CR1 bits (CP#15 CR1)
  221. */
  222. #define CR_M (1 << 0) /* MMU enable */
  223. #define CR_A (1 << 1) /* Alignment abort enable */
  224. #define CR_C (1 << 2) /* Dcache enable */
  225. #define CR_W (1 << 3) /* Write buffer enable */
  226. #define CR_P (1 << 4) /* 32-bit exception handler */
  227. #define CR_D (1 << 5) /* 32-bit data address range */
  228. #define CR_L (1 << 6) /* Implementation defined */
  229. #define CR_B (1 << 7) /* Big endian */
  230. #define CR_S (1 << 8) /* System MMU protection */
  231. #define CR_R (1 << 9) /* ROM MMU protection */
  232. #define CR_F (1 << 10) /* Implementation defined */
  233. #define CR_Z (1 << 11) /* Implementation defined */
  234. #define CR_I (1 << 12) /* Icache enable */
  235. #define CR_V (1 << 13) /* Vectors relocated to 0xffff0000 */
  236. #define CR_RR (1 << 14) /* Round Robin cache replacement */
  237. #define CR_L4 (1 << 15) /* LDR pc can set T bit */
  238. #define CR_DT (1 << 16)
  239. #define CR_IT (1 << 18)
  240. #define CR_ST (1 << 19)
  241. #define CR_FI (1 << 21) /* Fast interrupt (lower latency mode) */
  242. #define CR_U (1 << 22) /* Unaligned access operation */
  243. #define CR_XP (1 << 23) /* Extended page tables */
  244. #define CR_VE (1 << 24) /* Vectored interrupts */
  245. #define CR_EE (1 << 25) /* Exception (Big) Endian */
  246. #define CR_TRE (1 << 28) /* TEX remap enable */
  247. #define CR_AFE (1 << 29) /* Access flag enable */
  248. #define CR_TE (1 << 30) /* Thumb exception enable */
  249. #if defined(CONFIG_ARMV7_LPAE) && !defined(PGTABLE_SIZE)
  250. #define PGTABLE_SIZE (4096 * 5)
  251. #elif !defined(PGTABLE_SIZE)
  252. #define PGTABLE_SIZE (4096 * 4)
  253. #endif
  254. /*
  255. * This is used to ensure the compiler did actually allocate the register we
  256. * asked it for some inline assembly sequences. Apparently we can't trust
  257. * the compiler from one version to another so a bit of paranoia won't hurt.
  258. * This string is meant to be concatenated with the inline asm string and
  259. * will cause compilation to stop on mismatch.
  260. * (for details, see gcc PR 15089)
  261. */
  262. #define __asmeq(x, y) ".ifnc " x "," y " ; .err ; .endif\n\t"
  263. #ifndef __ASSEMBLY__
  264. /**
  265. * save_boot_params() - Save boot parameters before starting reset sequence
  266. *
  267. * If you provide this function it will be called immediately U-Boot starts,
  268. * both for SPL and U-Boot proper.
  269. *
  270. * All registers are unchanged from U-Boot entry. No registers need be
  271. * preserved.
  272. *
  273. * This is not a normal C function. There is no stack. Return by branching to
  274. * save_boot_params_ret.
  275. *
  276. * void save_boot_params(u32 r0, u32 r1, u32 r2, u32 r3);
  277. */
  278. /**
  279. * save_boot_params_ret() - Return from save_boot_params()
  280. *
  281. * If you provide save_boot_params(), then you should jump back to this
  282. * function when done. Try to preserve all registers.
  283. *
  284. * If your implementation of save_boot_params() is in C then it is acceptable
  285. * to simply call save_boot_params_ret() at the end of your function. Since
  286. * there is no link register set up, you cannot just exit the function. U-Boot
  287. * will return to the (initialised) value of lr, and likely crash/hang.
  288. *
  289. * If your implementation of save_boot_params() is in assembler then you
  290. * should use 'b' or 'bx' to return to save_boot_params_ret.
  291. */
  292. void save_boot_params_ret(void);
  293. #ifdef CONFIG_ARMV7_LPAE
  294. void switch_to_hypervisor_ret(void);
  295. #endif
  296. #define nop() __asm__ __volatile__("mov\tr0,r0\t@ nop\n\t");
  297. #ifdef __ARM_ARCH_7A__
  298. #define wfi() __asm__ __volatile__ ("wfi" : : : "memory")
  299. #else
  300. #define wfi()
  301. #endif
  302. static inline unsigned long get_cpsr(void)
  303. {
  304. unsigned long cpsr;
  305. asm volatile("mrs %0, cpsr" : "=r"(cpsr): );
  306. return cpsr;
  307. }
  308. static inline int is_hyp(void)
  309. {
  310. #ifdef CONFIG_ARMV7_LPAE
  311. /* HYP mode requires LPAE ... */
  312. return ((get_cpsr() & 0x1f) == 0x1a);
  313. #else
  314. /* ... so without LPAE support we can optimize all hyp code away */
  315. return 0;
  316. #endif
  317. }
  318. static inline unsigned int get_cr(void)
  319. {
  320. unsigned int val;
  321. if (is_hyp())
  322. asm volatile("mrc p15, 4, %0, c1, c0, 0 @ get CR" : "=r" (val)
  323. :
  324. : "cc");
  325. else
  326. asm volatile("mrc p15, 0, %0, c1, c0, 0 @ get CR" : "=r" (val)
  327. :
  328. : "cc");
  329. return val;
  330. }
  331. static inline void set_cr(unsigned int val)
  332. {
  333. if (is_hyp())
  334. asm volatile("mcr p15, 4, %0, c1, c0, 0 @ set CR" :
  335. : "r" (val)
  336. : "cc");
  337. else
  338. asm volatile("mcr p15, 0, %0, c1, c0, 0 @ set CR" :
  339. : "r" (val)
  340. : "cc");
  341. isb();
  342. }
  343. static inline unsigned int get_dacr(void)
  344. {
  345. unsigned int val;
  346. asm("mrc p15, 0, %0, c3, c0, 0 @ get DACR" : "=r" (val) : : "cc");
  347. return val;
  348. }
  349. static inline void set_dacr(unsigned int val)
  350. {
  351. asm volatile("mcr p15, 0, %0, c3, c0, 0 @ set DACR"
  352. : : "r" (val) : "cc");
  353. isb();
  354. }
  355. #ifdef CONFIG_ARMV7_LPAE
  356. /* Long-Descriptor Translation Table Level 1/2 Bits */
  357. #define TTB_SECT_XN_MASK (1ULL << 54)
  358. #define TTB_SECT_NG_MASK (1 << 11)
  359. #define TTB_SECT_AF (1 << 10)
  360. #define TTB_SECT_SH_MASK (3 << 8)
  361. #define TTB_SECT_NS_MASK (1 << 5)
  362. #define TTB_SECT_AP (1 << 6)
  363. /* Note: TTB AP bits are set elsewhere */
  364. #define TTB_SECT_MAIR(x) ((x & 0x7) << 2) /* Index into MAIR */
  365. #define TTB_SECT (1 << 0)
  366. #define TTB_PAGETABLE (3 << 0)
  367. /* TTBCR flags */
  368. #define TTBCR_EAE (1 << 31)
  369. #define TTBCR_T0SZ(x) ((x) << 0)
  370. #define TTBCR_T1SZ(x) ((x) << 16)
  371. #define TTBCR_USING_TTBR0 (TTBCR_T0SZ(0) | TTBCR_T1SZ(0))
  372. #define TTBCR_IRGN0_NC (0 << 8)
  373. #define TTBCR_IRGN0_WBWA (1 << 8)
  374. #define TTBCR_IRGN0_WT (2 << 8)
  375. #define TTBCR_IRGN0_WBNWA (3 << 8)
  376. #define TTBCR_IRGN0_MASK (3 << 8)
  377. #define TTBCR_ORGN0_NC (0 << 10)
  378. #define TTBCR_ORGN0_WBWA (1 << 10)
  379. #define TTBCR_ORGN0_WT (2 << 10)
  380. #define TTBCR_ORGN0_WBNWA (3 << 10)
  381. #define TTBCR_ORGN0_MASK (3 << 10)
  382. #define TTBCR_SHARED_NON (0 << 12)
  383. #define TTBCR_SHARED_OUTER (2 << 12)
  384. #define TTBCR_SHARED_INNER (3 << 12)
  385. #define TTBCR_EPD0 (0 << 7)
  386. /*
  387. * Memory types
  388. */
  389. #define MEMORY_ATTRIBUTES ((0x00 << (0 * 8)) | (0x88 << (1 * 8)) | \
  390. (0xcc << (2 * 8)) | (0xff << (3 * 8)))
  391. /* options available for data cache on each page */
  392. enum dcache_option {
  393. DCACHE_OFF = TTB_SECT | TTB_SECT_MAIR(0) | TTB_SECT_XN_MASK,
  394. DCACHE_WRITETHROUGH = TTB_SECT | TTB_SECT_MAIR(1),
  395. DCACHE_WRITEBACK = TTB_SECT | TTB_SECT_MAIR(2),
  396. DCACHE_WRITEALLOC = TTB_SECT | TTB_SECT_MAIR(3),
  397. };
  398. #elif defined(CONFIG_CPU_V7)
  399. /* Short-Descriptor Translation Table Level 1 Bits */
  400. #define TTB_SECT_NS_MASK (1 << 19)
  401. #define TTB_SECT_NG_MASK (1 << 17)
  402. #define TTB_SECT_S_MASK (1 << 16)
  403. /* Note: TTB AP bits are set elsewhere */
  404. #define TTB_SECT_AP (3 << 10)
  405. #define TTB_SECT_TEX(x) ((x & 0x7) << 12)
  406. #define TTB_SECT_DOMAIN(x) ((x & 0xf) << 5)
  407. #define TTB_SECT_XN_MASK (1 << 4)
  408. #define TTB_SECT_C_MASK (1 << 3)
  409. #define TTB_SECT_B_MASK (1 << 2)
  410. #define TTB_SECT (2 << 0)
  411. /* options available for data cache on each page */
  412. enum dcache_option {
  413. DCACHE_OFF = TTB_SECT_DOMAIN(0) | TTB_SECT_XN_MASK | TTB_SECT,
  414. DCACHE_WRITETHROUGH = DCACHE_OFF | TTB_SECT_C_MASK,
  415. DCACHE_WRITEBACK = DCACHE_WRITETHROUGH | TTB_SECT_B_MASK,
  416. DCACHE_WRITEALLOC = DCACHE_WRITEBACK | TTB_SECT_TEX(1),
  417. };
  418. #else
  419. #define TTB_SECT_AP (3 << 10)
  420. /* options available for data cache on each page */
  421. enum dcache_option {
  422. DCACHE_OFF = 0x12,
  423. DCACHE_WRITETHROUGH = 0x1a,
  424. DCACHE_WRITEBACK = 0x1e,
  425. DCACHE_WRITEALLOC = 0x16,
  426. };
  427. #endif
  428. /* Size of an MMU section */
  429. enum {
  430. #ifdef CONFIG_ARMV7_LPAE
  431. MMU_SECTION_SHIFT = 21, /* 2MB */
  432. #else
  433. MMU_SECTION_SHIFT = 20, /* 1MB */
  434. #endif
  435. MMU_SECTION_SIZE = 1 << MMU_SECTION_SHIFT,
  436. };
  437. #ifdef CONFIG_CPU_V7
  438. /* TTBR0 bits */
  439. #define TTBR0_BASE_ADDR_MASK 0xFFFFC000
  440. #define TTBR0_RGN_NC (0 << 3)
  441. #define TTBR0_RGN_WBWA (1 << 3)
  442. #define TTBR0_RGN_WT (2 << 3)
  443. #define TTBR0_RGN_WB (3 << 3)
  444. /* TTBR0[6] is IRGN[0] and TTBR[0] is IRGN[1] */
  445. #define TTBR0_IRGN_NC (0 << 0 | 0 << 6)
  446. #define TTBR0_IRGN_WBWA (0 << 0 | 1 << 6)
  447. #define TTBR0_IRGN_WT (1 << 0 | 0 << 6)
  448. #define TTBR0_IRGN_WB (1 << 0 | 1 << 6)
  449. #endif
  450. /**
  451. * Register an update to the page tables, and flush the TLB
  452. *
  453. * \param start start address of update in page table
  454. * \param stop stop address of update in page table
  455. */
  456. void mmu_page_table_flush(unsigned long start, unsigned long stop);
  457. #endif /* __ASSEMBLY__ */
  458. #define arch_align_stack(x) (x)
  459. #endif /* __KERNEL__ */
  460. #endif /* CONFIG_ARM64 */
  461. #ifndef __ASSEMBLY__
  462. /**
  463. * Change the cache settings for a region.
  464. *
  465. * \param start start address of memory region to change
  466. * \param size size of memory region to change
  467. * \param option dcache option to select
  468. */
  469. void mmu_set_region_dcache_behaviour(phys_addr_t start, size_t size,
  470. enum dcache_option option);
  471. #ifdef CONFIG_SYS_NONCACHED_MEMORY
  472. void noncached_init(void);
  473. phys_addr_t noncached_alloc(size_t size, size_t align);
  474. #endif /* CONFIG_SYS_NONCACHED_MEMORY */
  475. #endif /* __ASSEMBLY__ */
  476. #endif