File indexing completed on 2025-05-11 08:23:02
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036 #ifndef LIBBSP_ARM_SHARED_ARM_A9MPCORE_START_H
0037 #define LIBBSP_ARM_SHARED_ARM_A9MPCORE_START_H
0038
0039 #include <rtems/score/smpimpl.h>
0040
0041 #include <libcpu/arm-cp15.h>
0042
0043 #include <bsp.h>
0044 #include <bsp/start.h>
0045 #include <bsp/arm-a9mpcore-regs.h>
0046 #include <bsp/arm-cp15-start.h>
0047 #include <bsp/arm-errata.h>
0048 #include <dev/irq/arm-gic-irq.h>
0049
0050 #ifdef __cplusplus
0051 extern "C" {
0052 #endif
0053
0054
0055
0056
0057
0058
0059
0060 BSP_START_TEXT_SECTION static inline void arm_a9mpcore_start_scu_invalidate(
0061 volatile a9mpcore_scu *scu,
0062 uint32_t cpu_id,
0063 uint32_t ways
0064 )
0065 {
0066 scu->invss = (ways & 0xf) << ((cpu_id & 0x3) * 4);
0067 }
0068
0069 BSP_START_TEXT_SECTION static inline void
0070 arm_a9mpcore_start_errata_764369_handler(volatile a9mpcore_scu *scu)
0071 {
0072 if (arm_errata_is_applicable_processor_errata_764369()) {
0073 scu->diagn_ctrl |= A9MPCORE_SCU_DIAGN_CTRL_MIGRATORY_BIT_DISABLE;
0074 }
0075 }
0076
0077 BSP_START_TEXT_SECTION static inline void
0078 arm_a9mpcore_start_scu_enable(volatile a9mpcore_scu *scu)
0079 {
0080 scu->ctrl |= A9MPCORE_SCU_CTRL_SCU_EN;
0081 arm_a9mpcore_start_errata_764369_handler(scu);
0082 }
0083
0084 #ifdef RTEMS_SMP
0085 BSP_START_TEXT_SECTION static inline void
0086 arm_a9mpcore_start_on_secondary_processor(void)
0087 {
0088 uint32_t ctrl;
0089
0090 arm_gic_irq_initialize_secondary_cpu();
0091
0092
0093 arm_cp15_set_vector_base_address(bsp_vector_table_begin);
0094
0095 ctrl = arm_cp15_start_setup_mmu_and_cache(
0096 0,
0097 ARM_CP15_CTRL_AFE | ARM_CP15_CTRL_Z
0098 );
0099
0100 arm_cp15_set_domain_access_control(
0101 ARM_CP15_DAC_DOMAIN(ARM_MMU_DEFAULT_CLIENT_DOMAIN, ARM_CP15_DAC_CLIENT)
0102 );
0103
0104
0105 arm_cp15_set_translation_table_base(
0106 (uint32_t *) bsp_translation_table_base
0107 );
0108
0109 ctrl |= ARM_CP15_CTRL_I | ARM_CP15_CTRL_C | ARM_CP15_CTRL_M;
0110 arm_cp15_set_control(ctrl);
0111
0112 _SMP_Start_multitasking_on_secondary_processor(_Per_CPU_Get());
0113 }
0114
0115 BSP_START_TEXT_SECTION static inline void
0116 arm_a9mpcore_start_enable_smp_in_auxiliary_control(void)
0117 {
0118
0119
0120
0121
0122 uint32_t actlr = arm_cp15_get_auxiliary_control();
0123 actlr |= ARM_CORTEX_A9_ACTL_SMP | ARM_CORTEX_A9_ACTL_FW;
0124 arm_cp15_set_auxiliary_control(actlr);
0125 }
0126
0127 BSP_START_TEXT_SECTION static inline void
0128 arm_a9mpcore_start_errata_794072_handler(void)
0129 {
0130 uint32_t diag;
0131
0132
0133
0134
0135
0136
0137 diag = arm_cp15_get_diagnostic_control();
0138 diag |= 1U << 4;
0139 arm_cp15_set_diagnostic_control(diag);
0140 }
0141
0142 BSP_START_TEXT_SECTION static inline void
0143 arm_a9mpcore_start_errata_845369_handler(void)
0144 {
0145 uint32_t diag;
0146
0147
0148
0149
0150
0151 diag = arm_cp15_get_diagnostic_control();
0152 diag |= 1U << 22;
0153 arm_cp15_set_diagnostic_control(diag);
0154 }
0155 #endif
0156
0157 BSP_START_TEXT_SECTION static inline void arm_a9mpcore_start_hook_0(void)
0158 {
0159 volatile a9mpcore_scu *scu =
0160 (volatile a9mpcore_scu *) BSP_ARM_A9MPCORE_SCU_BASE;
0161 uint32_t cpu_id = arm_cortex_a9_get_multiprocessor_cpu_id();
0162
0163 if (cpu_id == 0) {
0164 arm_a9mpcore_start_scu_enable(scu);
0165 }
0166
0167 #ifdef RTEMS_SMP
0168 arm_a9mpcore_start_errata_794072_handler();
0169 arm_a9mpcore_start_errata_845369_handler();
0170 arm_a9mpcore_start_enable_smp_in_auxiliary_control();
0171 #endif
0172
0173 arm_a9mpcore_start_scu_invalidate(scu, cpu_id, 0xf);
0174
0175 #ifdef RTEMS_SMP
0176 if (cpu_id != 0) {
0177 arm_a9mpcore_start_on_secondary_processor();
0178 }
0179 #endif
0180 }
0181
0182 BSP_START_TEXT_SECTION static inline void arm_a9mpcore_start_global_timer(void)
0183 {
0184 volatile a9mpcore_gt *gt = (volatile a9mpcore_gt *) BSP_ARM_A9MPCORE_GT_BASE;
0185
0186 gt->ctrl = 0;
0187 gt->cntrlower = 0;
0188 gt->cntrupper = 0;
0189 gt->ctrl = A9MPCORE_GT_CTRL_TMR_EN;
0190 }
0191
0192 BSP_START_TEXT_SECTION static inline void arm_a9mpcore_start_hook_1(void)
0193 {
0194 arm_a9mpcore_start_global_timer();
0195 }
0196
0197
0198
0199 #ifdef __cplusplus
0200 }
0201 #endif
0202
0203 #endif