armv7.h 3.8 KB

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