xref: /rk3399_ARM-atf/plat/arm/css/common/css_bl2u_setup.c (revision bd9344f670a46125cdd8949ded75be124f34d587)
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*bd9344f6SAntonio Nino Diaz #include <plat/arm/common/plat_arm.h>
1009d40e0eSAntonio Nino Diaz #include <plat/common/platform.h>
1109d40e0eSAntonio Nino Diaz 
1274d44a49SSoby Mathew #include "../drivers/scp/css_scp.h"
13dcda29f6SYatharth Kochar 
14dcda29f6SYatharth Kochar /* Weak definition may be overridden in specific CSS based platform */
15dcda29f6SYatharth Kochar #pragma weak bl2u_plat_handle_scp_bl2u
16dcda29f6SYatharth Kochar 
17dcda29f6SYatharth Kochar /* Data structure which holds the SCP_BL2U image info for BL2U */
18dcda29f6SYatharth Kochar static image_info_t scp_bl2u_image_info;
19dcda29f6SYatharth Kochar 
20dcda29f6SYatharth Kochar /*******************************************************************************
21dcda29f6SYatharth Kochar  * BL1 can pass platform dependent information to BL2U in x1.
22dcda29f6SYatharth Kochar  * In case of ARM CSS platforms x1 contains SCP_BL2U image info.
23dcda29f6SYatharth Kochar  * In case of ARM FVP platforms x1 is not used.
24dcda29f6SYatharth Kochar  * In both cases, x0 contains the extents of the memory available to BL2U
25dcda29f6SYatharth Kochar  ******************************************************************************/
26dcda29f6SYatharth Kochar void bl2u_early_platform_setup(meminfo_t *mem_layout, void *plat_info)
27dcda29f6SYatharth Kochar {
28dcda29f6SYatharth Kochar 	if (!plat_info)
29dcda29f6SYatharth Kochar 		panic();
30dcda29f6SYatharth Kochar 
31dcda29f6SYatharth Kochar 	arm_bl2u_early_platform_setup(mem_layout, plat_info);
32dcda29f6SYatharth Kochar 
33dcda29f6SYatharth Kochar 	scp_bl2u_image_info = *(image_info_t *)plat_info;
34dcda29f6SYatharth Kochar }
35dcda29f6SYatharth Kochar 
36dcda29f6SYatharth Kochar /*******************************************************************************
37dcda29f6SYatharth Kochar  * Transfer SCP_BL2U from Trusted RAM using the SCP Download protocol.
38dcda29f6SYatharth Kochar  ******************************************************************************/
39dcda29f6SYatharth Kochar int bl2u_plat_handle_scp_bl2u(void)
40dcda29f6SYatharth Kochar {
41dcda29f6SYatharth Kochar 	int ret;
42dcda29f6SYatharth Kochar 
43dcda29f6SYatharth Kochar 	INFO("BL2U: Initiating SCP_BL2U transfer to SCP\n");
44dcda29f6SYatharth Kochar 
4574d44a49SSoby Mathew 	ret = css_scp_boot_image_xfer((void *)scp_bl2u_image_info.image_base,
46dcda29f6SYatharth Kochar 		scp_bl2u_image_info.image_size);
47dcda29f6SYatharth Kochar 
48dcda29f6SYatharth Kochar 	if (ret == 0)
4974d44a49SSoby Mathew 		ret = css_scp_boot_ready();
5074d44a49SSoby Mathew 
5174d44a49SSoby Mathew 	if (ret == 0)
52dcda29f6SYatharth Kochar 		INFO("BL2U: SCP_BL2U transferred to SCP\n");
53dcda29f6SYatharth Kochar 	else
54dcda29f6SYatharth Kochar 		ERROR("BL2U: SCP_BL2U transfer failure\n");
55dcda29f6SYatharth Kochar 
56dcda29f6SYatharth Kochar 	return ret;
57dcda29f6SYatharth Kochar }
58