armv7.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. /*
  62. * Workaround for ARM errata # 798870
  63. * Set L2ACTLR[7] to reissue any memory transaction in the L2 that has been
  64. * stalled for 1024 cycles to verify that its hazard condition still exists.
  65. */
  66. static inline void v7_enable_l2_hazard_detect(void)
  67. {
  68. uint32_t val;
  69. /* L2ACTLR[7]: Enable hazard detect timeout */
  70. asm volatile ("mrc p15, 1, %0, c15, c0, 0\n\t" : "=r"(val));
  71. val |= (1 << 7);
  72. asm volatile ("mcr p15, 1, %0, c15, c0, 0\n\t" : : "r"(val));
  73. }
  74. /*
  75. * Workaround for ARM errata # 799270
  76. * Ensure that the L2 logic has been used within the previous 256 cycles
  77. * before modifying the ACTLR.SMP bit. This is required during boot before
  78. * MMU has been enabled, or during a specified reset or power down sequence.
  79. */
  80. static inline void v7_enable_smp(uint32_t address)
  81. {
  82. uint32_t temp, val;
  83. /* Read auxiliary control register */
  84. asm volatile ("mrc p15, 0, %0, c1, c0, 1\n\t" : "=r"(val));
  85. /* Enable SMP */
  86. val |= (1 << 6);
  87. /* Dummy read to assure L2 access */
  88. temp = readl(address);
  89. temp &= 0;
  90. val |= temp;
  91. /* Write auxiliary control register */
  92. asm volatile ("mcr p15, 0, %0, c1, c0, 1\n\t" : : "r"(val));
  93. CP15DSB;
  94. CP15ISB;
  95. }
  96. void v7_en_l2_hazard_detect(void);
  97. void v7_outer_cache_enable(void);
  98. void v7_outer_cache_disable(void);
  99. void v7_outer_cache_flush_all(void);
  100. void v7_outer_cache_inval_all(void);
  101. void v7_outer_cache_flush_range(u32 start, u32 end);
  102. void v7_outer_cache_inval_range(u32 start, u32 end);
  103. #if defined(CONFIG_ARMV7_NONSEC) || defined(CONFIG_ARMV7_VIRT)
  104. int armv7_init_nonsec(void);
  105. bool armv7_boot_nonsec(void);
  106. /* defined in assembly file */
  107. unsigned int _nonsec_init(void);
  108. void _do_nonsec_entry(void *target_pc, unsigned long r0,
  109. unsigned long r1, unsigned long r2);
  110. void _smp_pen(void);
  111. extern char __secure_start[];
  112. extern char __secure_end[];
  113. #endif /* CONFIG_ARMV7_NONSEC || CONFIG_ARMV7_VIRT */
  114. void v7_arch_cp15_set_l2aux_ctrl(u32 l2auxctrl, u32 cpu_midr,
  115. u32 cpu_rev_comb, u32 cpu_variant,
  116. u32 cpu_rev);
  117. void v7_arch_cp15_set_acr(u32 acr, u32 cpu_midr, u32 cpu_rev_comb,
  118. u32 cpu_variant, u32 cpu_rev);
  119. #endif /* ! __ASSEMBLY__ */
  120. #endif