blob: 2771e0f3794d1b0c648ac03438f85eb8e741b5ea [file] [log] [blame]
Yatharth Kocharede39cb2016-11-14 12:01:04 +00001/*
Dimitris Papastamos47bc2ba2017-06-14 14:47:36 +01002 * Copyright (c) 2016-2017, ARM Limited and Contributors. All rights reserved.
Yatharth Kocharede39cb2016-11-14 12:01:04 +00003 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Yatharth Kocharede39cb2016-11-14 12:01:04 +00005 */
6
7#include <assert.h>
8#include <bl_common.h>
9#include <desc_image_load.h>
10#include <plat_arm.h>
11
12#if JUNO_AARCH32_EL3_RUNTIME
13/*******************************************************************************
14 * This function changes the spsr for BL32 image to bypass
15 * the check in BL1 AArch64 exception handler. This is needed in the aarch32
16 * boot flow as the core comes up in aarch64 and to enter the BL32 image a warm
17 * reset in aarch32 state is required.
18 ******************************************************************************/
19int bl2_plat_handle_post_image_load(unsigned int image_id)
20{
21 int err = arm_bl2_handle_post_image_load(image_id);
22
23 if (!err && (image_id == BL32_IMAGE_ID)) {
24 bl_mem_params_node_t *bl_mem_params = get_bl_mem_params_node(image_id);
25 assert(bl_mem_params);
26 bl_mem_params->ep_info.spsr = SPSR_64(MODE_EL3, MODE_SP_ELX,
27 DISABLE_ALL_EXCEPTIONS);
28 }
29
30 return err;
31}
Dimitris Papastamos47bc2ba2017-06-14 14:47:36 +010032
Soby Mathew1ced6b82017-06-12 12:37:10 +010033#if !CSS_USE_SCMI_SDS_DRIVER
Dimitris Papastamos47bc2ba2017-06-14 14:47:36 +010034/*
35 * We need to override some of the platform functions when booting SP_MIN
Soby Mathew1ced6b82017-06-12 12:37:10 +010036 * on Juno AArch32. These needs to be done only for SCPI/BOM SCP systems as
37 * in case of SDS, the structures remain in memory and doesn't need to be
38 * overwritten.
Dimitris Papastamos47bc2ba2017-06-14 14:47:36 +010039 */
40
41static unsigned int scp_boot_config;
42
43void bl2_early_platform_setup(meminfo_t *mem_layout)
44{
45 arm_bl2_early_platform_setup(mem_layout);
46
47 /* Save SCP Boot config before it gets overwritten by SCP_BL2 loading */
48 VERBOSE("BL2: Saving SCP Boot config = 0x%x\n", scp_boot_config);
49 scp_boot_config = mmio_read_32(SCP_BOOT_CFG_ADDR);
50}
51
52void bl2_platform_setup(void)
53{
54 arm_bl2_platform_setup();
55
56 mmio_write_32(SCP_BOOT_CFG_ADDR, scp_boot_config);
57 VERBOSE("BL2: Restored SCP Boot config = 0x%x\n", scp_boot_config);
58}
Soby Mathew1ced6b82017-06-12 12:37:10 +010059#endif
60
Yatharth Kocharede39cb2016-11-14 12:01:04 +000061#endif /* JUNO_AARCH32_EL3_RUNTIME */