xref: /rk3399_ARM-atf/plat/arm/css/common/css_bl2u_setup.c (revision 83a2285ec8d5e4bdbf12481b441489eed5bb6018)
1dcda29f6SYatharth Kochar /*
2fd116b9fSRoberto Vargas  * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
3dcda29f6SYatharth Kochar  *
482cb2c1aSdp-arm  * SPDX-License-Identifier: BSD-3-Clause
5dcda29f6SYatharth Kochar  */
6dcda29f6SYatharth Kochar 
709d40e0eSAntonio Nino Diaz #include <common/bl_common.h>
809d40e0eSAntonio Nino Diaz #include <common/debug.h>
9*2d4135e0SAntonio Nino Diaz #include <drivers/arm/css/css_scp.h>
10bd9344f6SAntonio Nino Diaz #include <plat/arm/common/plat_arm.h>
1109d40e0eSAntonio Nino Diaz #include <plat/common/platform.h>
1209d40e0eSAntonio Nino Diaz 
13dcda29f6SYatharth Kochar /* Weak definition may be overridden in specific CSS based platform */
14dcda29f6SYatharth Kochar #pragma weak bl2u_plat_handle_scp_bl2u
15dcda29f6SYatharth Kochar 
16dcda29f6SYatharth Kochar /* Data structure which holds the SCP_BL2U image info for BL2U */
17dcda29f6SYatharth Kochar static image_info_t scp_bl2u_image_info;
18dcda29f6SYatharth Kochar 
19dcda29f6SYatharth Kochar /*******************************************************************************
20dcda29f6SYatharth Kochar  * BL1 can pass platform dependent information to BL2U in x1.
21dcda29f6SYatharth Kochar  * In case of ARM CSS platforms x1 contains SCP_BL2U image info.
22dcda29f6SYatharth Kochar  * In case of ARM FVP platforms x1 is not used.
23dcda29f6SYatharth Kochar  * In both cases, x0 contains the extents of the memory available to BL2U
24dcda29f6SYatharth Kochar  ******************************************************************************/
bl2u_early_platform_setup(meminfo_t * mem_layout,void * plat_info)25dcda29f6SYatharth Kochar void bl2u_early_platform_setup(meminfo_t *mem_layout, void *plat_info)
26dcda29f6SYatharth Kochar {
27dcda29f6SYatharth Kochar 	if (!plat_info)
28dcda29f6SYatharth Kochar 		panic();
29dcda29f6SYatharth Kochar 
30dcda29f6SYatharth Kochar 	arm_bl2u_early_platform_setup(mem_layout, plat_info);
31dcda29f6SYatharth Kochar 
32dcda29f6SYatharth Kochar 	scp_bl2u_image_info = *(image_info_t *)plat_info;
33dcda29f6SYatharth Kochar }
34dcda29f6SYatharth Kochar 
35dcda29f6SYatharth Kochar /*******************************************************************************
36dcda29f6SYatharth Kochar  * Transfer SCP_BL2U from Trusted RAM using the SCP Download protocol.
37dcda29f6SYatharth Kochar  ******************************************************************************/
bl2u_plat_handle_scp_bl2u(void)38dcda29f6SYatharth Kochar int bl2u_plat_handle_scp_bl2u(void)
39dcda29f6SYatharth Kochar {
40dcda29f6SYatharth Kochar 	int ret;
41dcda29f6SYatharth Kochar 
42dcda29f6SYatharth Kochar 	INFO("BL2U: Initiating SCP_BL2U transfer to SCP\n");
43dcda29f6SYatharth Kochar 
4474d44a49SSoby Mathew 	ret = css_scp_boot_image_xfer((void *)scp_bl2u_image_info.image_base,
45dcda29f6SYatharth Kochar 		scp_bl2u_image_info.image_size);
46dcda29f6SYatharth Kochar 
47dcda29f6SYatharth Kochar 	if (ret == 0)
4874d44a49SSoby Mathew 		ret = css_scp_boot_ready();
4974d44a49SSoby Mathew 
5074d44a49SSoby Mathew 	if (ret == 0)
51dcda29f6SYatharth Kochar 		INFO("BL2U: SCP_BL2U transferred to SCP\n");
52dcda29f6SYatharth Kochar 	else
53dcda29f6SYatharth Kochar 		ERROR("BL2U: SCP_BL2U transfer failure\n");
54dcda29f6SYatharth Kochar 
55dcda29f6SYatharth Kochar 	return ret;
56dcda29f6SYatharth Kochar }
57