armv7.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /*
  2. * (C) Copyright 2010
  3. * Texas Instruments, <www.ti.com>
  4. * Aneesh V <aneesh@ti.com>
  5. *
  6. * SPDX-License-Identifier: GPL-2.0+
  7. */
  8. #ifndef ARMV7_H
  9. #define ARMV7_H
  10. /* Cortex-A9 revisions */
  11. #define MIDR_CORTEX_A9_R0P1 0x410FC091
  12. #define MIDR_CORTEX_A9_R1P2 0x411FC092
  13. #define MIDR_CORTEX_A9_R1P3 0x411FC093
  14. #define MIDR_CORTEX_A9_R2P10 0x412FC09A
  15. /* Cortex-A15 revisions */
  16. #define MIDR_CORTEX_A15_R0P0 0x410FC0F0
  17. #define MIDR_CORTEX_A15_R2P2 0x412FC0F2
  18. /* Cortex-A7 revisions */
  19. #define MIDR_CORTEX_A7_R0P0 0x410FC070
  20. #define MIDR_PRIMARY_PART_MASK 0xFF0FFFF0
  21. /* ID_PFR1 feature fields */
  22. #define CPUID_ARM_SEC_SHIFT 4
  23. #define CPUID_ARM_SEC_MASK (0xF << CPUID_ARM_SEC_SHIFT)
  24. #define CPUID_ARM_VIRT_SHIFT 12
  25. #define CPUID_ARM_VIRT_MASK (0xF << CPUID_ARM_VIRT_SHIFT)
  26. #define CPUID_ARM_GENTIMER_SHIFT 16
  27. #define CPUID_ARM_GENTIMER_MASK (0xF << CPUID_ARM_GENTIMER_SHIFT)
  28. /* valid bits in CBAR register / PERIPHBASE value */
  29. #define CBAR_MASK 0xFFFF8000
  30. /* CCSIDR */
  31. #define CCSIDR_LINE_SIZE_OFFSET 0
  32. #define CCSIDR_LINE_SIZE_MASK 0x7
  33. #define CCSIDR_ASSOCIATIVITY_OFFSET 3
  34. #define CCSIDR_ASSOCIATIVITY_MASK (0x3FF << 3)
  35. #define CCSIDR_NUM_SETS_OFFSET 13
  36. #define CCSIDR_NUM_SETS_MASK (0x7FFF << 13)
  37. /*
  38. * Values for InD field in CSSELR
  39. * Selects the type of cache
  40. */
  41. #define ARMV7_CSSELR_IND_DATA_UNIFIED 0
  42. #define ARMV7_CSSELR_IND_INSTRUCTION 1
  43. /* Values for Ctype fields in CLIDR */
  44. #define ARMV7_CLIDR_CTYPE_NO_CACHE 0
  45. #define ARMV7_CLIDR_CTYPE_INSTRUCTION_ONLY 1
  46. #define ARMV7_CLIDR_CTYPE_DATA_ONLY 2
  47. #define ARMV7_CLIDR_CTYPE_INSTRUCTION_DATA 3
  48. #define ARMV7_CLIDR_CTYPE_UNIFIED 4
  49. #ifndef __ASSEMBLY__
  50. #include <linux/types.h>
  51. #include <asm/io.h>
  52. /*
  53. * CP15 Barrier instructions
  54. * Please note that we have separate barrier instructions in ARMv7
  55. * However, we use the CP15 based instructtions because we use
  56. * -march=armv5 in U-Boot
  57. */
  58. #define CP15ISB asm volatile ("mcr p15, 0, %0, c7, c5, 4" : : "r" (0))
  59. #define CP15DSB asm volatile ("mcr p15, 0, %0, c7, c10, 4" : : "r" (0))
  60. #define CP15DMB asm volatile ("mcr p15, 0, %0, c7, c10, 5" : : "r" (0))
  61. #ifdef __ARM_ARCH_7A__
  62. #define ISB asm volatile ("isb" : : : "memory")
  63. #define DSB asm volatile ("dsb" : : : "memory")
  64. #define DMB asm volatile ("dmb" : : : "memory")
  65. #else
  66. #define ISB CP15ISB
  67. #define DSB CP15DSB
  68. #define DMB CP15DMB
  69. #endif
  70. /*
  71. * Workaround for ARM errata # 798870
  72. * Set L2ACTLR[7] to reissue any memory transaction in the L2 that has been
  73. * stalled for 1024 cycles to verify that its hazard condition still exists.
  74. */
  75. static inline void v7_enable_l2_hazard_detect(void)
  76. {
  77. uint32_t val;
  78. /* L2ACTLR[7]: Enable hazard detect timeout */
  79. asm volatile ("mrc p15, 1, %0, c15, c0, 0\n\t" : "=r"(val));
  80. val |= (1 << 7);
  81. asm volatile ("mcr p15, 1, %0, c15, c0, 0\n\t" : : "r"(val));
  82. }
  83. /*
  84. * Workaround for ARM errata # 799270
  85. * Ensure that the L2 logic has been used within the previous 256 cycles
  86. * before modifying the ACTLR.SMP bit. This is required during boot before
  87. * MMU has been enabled, or during a specified reset or power down sequence.
  88. */
  89. static inline void v7_enable_smp(uint32_t address)
  90. {
  91. uint32_t temp, val;
  92. /* Read auxiliary control register */
  93. asm volatile ("mrc p15, 0, %0, c1, c0, 1\n\t" : "=r"(val));
  94. /* Enable SMP */
  95. val |= (1 << 6);
  96. /* Dummy read to assure L2 access */
  97. temp = readl(address);
  98. temp &= 0;
  99. val |= temp;
  100. /* Write auxiliary control register */
  101. asm volatile ("mcr p15, 0, %0, c1, c0, 1\n\t" : : "r"(val));
  102. CP15DSB;
  103. CP15ISB;
  104. }
  105. void v7_en_l2_hazard_detect(void);
  106. void v7_outer_cache_enable(void);
  107. void v7_outer_cache_disable(void);
  108. void v7_outer_cache_flush_all(void);
  109. void v7_outer_cache_inval_all(void);
  110. void v7_outer_cache_flush_range(u32 start, u32 end);
  111. void v7_outer_cache_inval_range(u32 start, u32 end);
  112. #ifdef CONFIG_ARMV7_NONSEC
  113. int armv7_init_nonsec(void);
  114. int armv7_apply_memory_carveout(u64 *start, u64 *size);
  115. bool armv7_boot_nonsec(void);
  116. /* defined in assembly file */
  117. unsigned int _nonsec_init(void);
  118. void _do_nonsec_entry(void *target_pc, unsigned long r0,
  119. unsigned long r1, unsigned long r2);
  120. void _smp_pen(void);
  121. extern char __secure_start[];
  122. extern char __secure_end[];
  123. #endif /* CONFIG_ARMV7_NONSEC */
  124. void v7_arch_cp15_set_l2aux_ctrl(u32 l2auxctrl, u32 cpu_midr,
  125. u32 cpu_rev_comb, u32 cpu_variant,
  126. u32 cpu_rev);
  127. void v7_arch_cp15_set_acr(u32 acr, u32 cpu_midr, u32 cpu_rev_comb,
  128. u32 cpu_variant, u32 cpu_rev);
  129. #endif /* ! __ASSEMBLY__ */
  130. #endif