2 * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
4 * SPDX-License-Identifier: BSD-3-Clause
9 #include <common/bl_common.h>
10 #include <common/interrupt_props.h>
11 #include <drivers/arm/gicv2.h>
12 #include <drivers/console.h>
20 * Placeholder variables for copying the arguments that have been passed to
23 static entry_point_info_t bl32_image_ep_info
;
24 static entry_point_info_t bl33_image_ep_info
;
26 static const interrupt_prop_t g0_interrupt_props
[] = {
27 INTR_PROP_DESC(9, GIC_HIGHEST_SEC_PRIORITY
,
28 GICV2_INTR_GROUP0
, GIC_INTR_CFG_LEVEL
),
31 gicv2_driver_data_t ls_gic_data
= {
32 .gicd_base
= GICD_BASE
,
33 .gicc_base
= GICC_BASE
,
34 .interrupt_props
= g0_interrupt_props
,
35 .interrupt_props_num
= ARRAY_SIZE(g0_interrupt_props
),
39 /*******************************************************************************
40 * Return a pointer to the 'entry_point_info' structure of the next image for the
41 * security state specified. BL33 corresponds to the non-secure image type
42 * while BL32 corresponds to the secure image type. A NULL pointer is returned
43 * if the image does not exist.
44 ******************************************************************************/
45 entry_point_info_t
*bl31_plat_get_next_image_ep_info(uint32_t type
)
47 entry_point_info_t
*next_image_info
;
49 assert(sec_state_is_valid(type
));
50 next_image_info
= (type
== NON_SECURE
)
51 ? &bl33_image_ep_info
: &bl32_image_ep_info
;
53 if (next_image_info
->pc
)
54 return next_image_info
;
59 /*******************************************************************************
60 * Perform any BL31 early platform setup common to Layerscape platforms.
61 * Here is an opportunity to copy parameters passed by the calling EL (S-EL1
62 * in BL2 & EL3 in BL1) before they are lost (potentially). This needs to be
63 * done before the MMU is initialized so that the memory layout can be used
64 * while creating page tables. BL2 has flushed this information to memory, so
65 * we are guaranteed to pick up good data.
66 ******************************************************************************/
67 void ls_bl31_early_platform_setup(void *from_bl2
,
68 void *plat_params_from_bl2
)
70 static console_ls_16550_t console
;
72 /* Initialize the console to provide early debug support */
73 console_ls_16550_register(LS_TF_UART_BASE
, LS_TF_UART_CLOCK
,
74 LS_TF_UART_BAUDRATE
, &console
);
76 /* There are no parameters from BL2 if BL31 is a reset vector */
77 assert(from_bl2
== NULL
);
78 assert(plat_params_from_bl2
== NULL
);
81 /* Populate entry point information for BL32 */
82 SET_PARAM_HEAD(&bl32_image_ep_info
,
86 SET_SECURITY_STATE(bl32_image_ep_info
.h
.attr
, SECURE
);
87 bl32_image_ep_info
.pc
= BL32_BASE
;
88 bl32_image_ep_info
.spsr
= ls_get_spsr_for_bl32_entry();
89 #endif /* BL32_BASE */
91 /* Populate entry point information for BL33 */
92 SET_PARAM_HEAD(&bl33_image_ep_info
,
97 * Tell BL31 where the non-trusted software image
98 * is located and the entry state information
100 bl33_image_ep_info
.pc
= plat_get_ns_image_entrypoint();
102 bl33_image_ep_info
.spsr
= ls_get_spsr_for_bl33_entry();
103 SET_SECURITY_STATE(bl33_image_ep_info
.h
.attr
, NON_SECURE
);
105 #else /* RESET_TO_BL31 */
108 * In debug builds, we pass a special value in 'plat_params_from_bl2'
109 * to verify platform parameters from BL2 to BL31.
110 * In release builds, it's not used.
112 assert(((unsigned long long)plat_params_from_bl2
) ==
113 LS_BL31_PLAT_PARAM_VAL
);
116 * Check params passed from BL2 should not be NULL,
118 bl_params_t
*params_from_bl2
= (bl_params_t
*)from_bl2
;
120 assert(params_from_bl2
!= NULL
);
121 assert(params_from_bl2
->h
.type
== PARAM_BL_PARAMS
);
122 assert(params_from_bl2
->h
.version
>= VERSION_2
);
124 bl_params_node_t
*bl_params
= params_from_bl2
->head
;
127 * Copy BL33 and BL32 (if present), entry point information.
128 * They are stored in Secure RAM, in BL2's address space.
131 if (bl_params
->image_id
== BL32_IMAGE_ID
)
132 bl32_image_ep_info
= *bl_params
->ep_info
;
134 if (bl_params
->image_id
== BL33_IMAGE_ID
)
135 bl33_image_ep_info
= *bl_params
->ep_info
;
137 bl_params
= bl_params
->next_params_info
;
140 if (bl33_image_ep_info
.pc
== 0)
143 #endif /* RESET_TO_BL31 */
146 /*******************************************************************************
147 * Perform any BL31 platform setup common to Layerscape platforms
148 ******************************************************************************/
149 void ls_bl31_platform_setup(void)
151 uint32_t gicc_base
, gicd_base
;
153 NOTICE(FIRMWARE_WELCOME_STR_LS1043_BL31
);
154 /* Initialize the GIC driver, cpu and distributor interfaces */
155 get_gic_offset(&gicc_base
, &gicd_base
);
156 ls_gic_data
.gicd_base
= (uintptr_t)gicd_base
;
157 ls_gic_data
.gicc_base
= (uintptr_t)gicc_base
;
158 gicv2_driver_init(&ls_gic_data
);
160 gicv2_pcpu_distif_init();
161 gicv2_cpuif_enable();
165 * Do initial security configuration to allow DRAM/device access
166 * (if earlier BL has not already done so).
168 plat_ls_security_setup();
170 #endif /* RESET_TO_BL31 */
172 /* Enable and initialize the System level generic timer */
173 mmio_write_32(LS1043_SYS_CNTCTL_BASE
+ CNTCR_OFF
,
174 CNTCR_FCREQ(0U) | CNTCR_EN
);
176 VERBOSE("Leave arm_bl31_platform_setup\n");
179 /*******************************************************************************
180 * Perform any BL31 platform runtime setup prior to BL31 exit common to Layerscape
182 ******************************************************************************/
183 void ls_bl31_plat_runtime_setup(void)
185 static console_ls_16550_t console
;
187 /* Initialize the runtime console */
188 console_ls_16550_register(PLAT_LS1043_UART_BASE
, PLAT_LS1043_UART_CLOCK
,
189 PLAT_LS1043_UART_BAUDRATE
, &console
);
192 void bl31_platform_setup(void)
194 ls_bl31_platform_setup();
197 void bl31_plat_runtime_setup(void)
199 ls_bl31_plat_runtime_setup();
202 /*******************************************************************************
203 * Perform the very early platform specific architectural setup shared between
204 * Layerscape platforms. This only does basic initialization. Later
205 * architectural setup (bl31_arch_setup()) does not do anything platform
207 ******************************************************************************/
208 void ls_bl31_plat_arch_setup(void)
210 ls_setup_page_tables(BL31_BASE
,
211 BL31_END
- BL31_BASE
,
217 , BL_COHERENT_RAM_BASE
,
224 void bl31_plat_arch_setup(void)
226 ls_bl31_plat_arch_setup();