2 * Copyright (c) 2014-2017, ARM Limited and Contributors. All rights reserved.
4 * SPDX-License-Identifier: BSD-3-Clause
10 #include <arch_helpers.h>
11 #include <common/debug.h>
12 #include <drivers/delay_timer.h>
13 #include <plat/common/platform.h>
18 #include "../sds/sds.h"
20 int css_scp_boot_image_xfer(void *image
, unsigned int image_size
)
23 unsigned int image_offset
, image_flags
;
27 ERROR("SCP SDS initialization failed\n");
31 VERBOSE("Writing SCP image metadata\n");
32 image_offset
= (uintptr_t) image
- ARM_TRUSTED_SRAM_BASE
;
33 ret
= sds_struct_write(SDS_SCP_IMG_STRUCT_ID
, SDS_SCP_IMG_ADDR_OFFSET
,
34 &image_offset
, SDS_SCP_IMG_ADDR_SIZE
,
35 SDS_ACCESS_MODE_NON_CACHED
);
39 ret
= sds_struct_write(SDS_SCP_IMG_STRUCT_ID
, SDS_SCP_IMG_SIZE_OFFSET
,
40 &image_size
, SDS_SCP_IMG_SIZE_SIZE
,
41 SDS_ACCESS_MODE_NON_CACHED
);
45 VERBOSE("Marking SCP image metadata as valid\n");
46 image_flags
= SDS_SCP_IMG_VALID_FLAG_BIT
;
47 ret
= sds_struct_write(SDS_SCP_IMG_STRUCT_ID
, SDS_SCP_IMG_FLAG_OFFSET
,
48 &image_flags
, SDS_SCP_IMG_FLAG_SIZE
,
49 SDS_ACCESS_MODE_NON_CACHED
);
55 ERROR("SCP SDS write to SCP IMG struct failed\n");
60 * API to wait for SCP to signal till it's ready after booting the transferred
63 int css_scp_boot_ready(void)
65 uint32_t scp_feature_availability_flags
;
66 int ret
, retry
= CSS_SCP_READY_10US_RETRIES
;
69 VERBOSE("Waiting for SCP RAM to complete its initialization process\n");
71 /* Wait for the SCP RAM Firmware to complete its initialization process */
73 ret
= sds_struct_read(SDS_FEATURE_AVAIL_STRUCT_ID
, 0,
74 &scp_feature_availability_flags
,
75 SDS_FEATURE_AVAIL_SIZE
,
76 SDS_ACCESS_MODE_NON_CACHED
);
77 if (ret
== SDS_ERR_STRUCT_NOT_FINALIZED
)
81 ERROR(" sds_struct_read failed\n");
85 if (scp_feature_availability_flags
&
86 SDS_FEATURE_AVAIL_SCP_RAM_READY_BIT
)
93 ERROR("Timeout of %d ms expired waiting for SCP RAM Ready flag\n",
94 CSS_SCP_READY_10US_RETRIES
/100);