blob: bff45f68801722899c0114f1cac24f749ad3b893 [file] [log] [blame]
Yann Gautier9d135e42018-07-16 19:36:06 +02001/*
Yann Gautierf9d40d52019-01-17 14:41:46 +01002 * Copyright (c) 2015-2019, ARM Limited and Contributors. All rights reserved.
Yann Gautier9d135e42018-07-16 19:36:06 +02003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
Yann Gautier9d135e42018-07-16 19:36:06 +02007#include <assert.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00008#include <string.h>
9
10#include <platform_def.h>
11
12#include <arch_helpers.h>
13#include <common/bl_common.h>
14#include <common/debug.h>
Yann Gautier9d135e42018-07-16 19:36:06 +020015#include <context.h>
Yann Gautierf9d40d52019-01-17 14:41:46 +010016#include <drivers/arm/gicv2.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000017#include <drivers/arm/tzc400.h>
18#include <drivers/generic_delay_timer.h>
19#include <drivers/st/stm32_console.h>
20#include <drivers/st/stm32mp1_clk.h>
Yann Gautier9d135e42018-07-16 19:36:06 +020021#include <dt-bindings/clock/stm32mp1-clks.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000022#include <lib/el3_runtime/context_mgmt.h>
23#include <lib/mmio.h>
24#include <lib/xlat_tables/xlat_tables_v2.h>
25#include <plat/common/platform.h>
26
Yann Gautier9d135e42018-07-16 19:36:06 +020027#include <platform_sp_min.h>
Yann Gautier9d135e42018-07-16 19:36:06 +020028#include <stm32mp1_dt.h>
29#include <stm32mp1_private.h>
Yann Gautier9d135e42018-07-16 19:36:06 +020030
31/******************************************************************************
32 * Placeholder variables for copying the arguments that have been passed to
33 * BL32 from BL2.
34 ******************************************************************************/
35static entry_point_info_t bl33_image_ep_info;
36
Yann Gautier8593e442018-11-14 18:46:15 +010037static struct console_stm32 console;
38
Yann Gautier9d135e42018-07-16 19:36:06 +020039/*******************************************************************************
40 * Interrupt handler for FIQ (secure IRQ)
41 ******************************************************************************/
42void sp_min_plat_fiq_handler(uint32_t id)
43{
Yann Gautierf9d40d52019-01-17 14:41:46 +010044 switch (id & INT_ID_MASK) {
Yann Gautier9d135e42018-07-16 19:36:06 +020045 case STM32MP1_IRQ_TZC400:
46 ERROR("STM32MP1_IRQ_TZC400 generated\n");
47 panic();
48 break;
49 case STM32MP1_IRQ_AXIERRIRQ:
50 ERROR("STM32MP1_IRQ_AXIERRIRQ generated\n");
51 panic();
52 break;
53 default:
Yann Gautierf9d40d52019-01-17 14:41:46 +010054 ERROR("SECURE IT handler not define for it : %u", id);
Yann Gautier9d135e42018-07-16 19:36:06 +020055 break;
56 }
57}
58
59/*******************************************************************************
60 * Return a pointer to the 'entry_point_info' structure of the next image for
61 * the security state specified. BL33 corresponds to the non-secure image type
62 * while BL32 corresponds to the secure image type. A NULL pointer is returned
63 * if the image does not exist.
64 ******************************************************************************/
65entry_point_info_t *sp_min_plat_get_bl33_ep_info(void)
66{
67 entry_point_info_t *next_image_info;
68
69 next_image_info = &bl33_image_ep_info;
70
71 if (next_image_info->pc == 0U) {
72 return NULL;
73 }
74
75 return next_image_info;
76}
77
78/*******************************************************************************
79 * Perform any BL32 specific platform actions.
80 ******************************************************************************/
81void sp_min_early_platform_setup2(u_register_t arg0, u_register_t arg1,
82 u_register_t arg2, u_register_t arg3)
83{
Yann Gautierf9d40d52019-01-17 14:41:46 +010084 struct dt_node_info dt_uart_info;
Yann Gautier9d135e42018-07-16 19:36:06 +020085 int result;
86 bl_params_t *params_from_bl2 = (bl_params_t *)arg0;
87
88 /* Imprecise aborts can be masked in NonSecure */
89 write_scr(read_scr() | SCR_AW_BIT);
90
91 assert(params_from_bl2 != NULL);
92 assert(params_from_bl2->h.type == PARAM_BL_PARAMS);
93 assert(params_from_bl2->h.version >= VERSION_2);
94
95 bl_params_node_t *bl_params = params_from_bl2->head;
96
97 /*
98 * Copy BL33 entry point information.
99 * They are stored in Secure RAM, in BL2's address space.
100 */
101 while (bl_params != NULL) {
102 if (bl_params->image_id == BL33_IMAGE_ID) {
103 bl33_image_ep_info = *bl_params->ep_info;
104 break;
105 }
106
107 bl_params = bl_params->next_params_info;
108 }
109
110 if (dt_open_and_check() < 0) {
111 panic();
112 }
113
114 if (stm32mp1_clk_probe() < 0) {
115 panic();
116 }
117
Yann Gautierf9d40d52019-01-17 14:41:46 +0100118 result = dt_get_stdout_uart_info(&dt_uart_info);
Yann Gautier9d135e42018-07-16 19:36:06 +0200119
Yann Gautierf9d40d52019-01-17 14:41:46 +0100120 if ((result > 0) && dt_uart_info.status) {
121 if (console_stm32_register(dt_uart_info.base, 0,
Yann Gautier8593e442018-11-14 18:46:15 +0100122 STM32MP1_UART_BAUDRATE, &console) ==
123 0) {
Yann Gautier9d135e42018-07-16 19:36:06 +0200124 panic();
125 }
126 }
127}
128
129/*******************************************************************************
130 * Initialize the MMU, security and the GIC.
131 ******************************************************************************/
132void sp_min_platform_setup(void)
133{
134 mmap_add_region(BL_CODE_BASE, BL_CODE_BASE,
135 BL_CODE_END - BL_CODE_BASE,
136 MT_CODE | MT_SECURE);
137
138 configure_mmu();
139
140 /* Initialize tzc400 after DDR initialization */
141 stm32mp1_security_setup();
142
143 generic_delay_timer_init();
144
145 stm32mp1_gic_init();
146}
147
148void sp_min_plat_arch_setup(void)
149{
150}