1 /*
2 * Arm SCP/MCP Software
3 * Copyright (c) 2021-2022, Arm Limited and Contributors. All rights reserved.
4 *
5 * SPDX-License-Identifier: BSD-3-Clause
6 */
7
8 #include "clock_soc.h"
9 #include "scp_mmap.h"
10 #include "scp_pik.h"
11 #include "tc1_sds.h"
12
13 #include <mod_sds.h>
14
15 #include <fwk_assert.h>
16 #include <fwk_element.h>
17 #include <fwk_id.h>
18 #include <fwk_macros.h>
19 #include <fwk_module.h>
20 #include <fwk_module_idx.h>
21
22 #include <stdbool.h>
23 #include <stdint.h>
24
25 static const uint32_t feature_flags = TC1_SDS_FEATURE_FIRMWARE_MASK;
26
27 static const struct mod_sds_region_desc sds_module_regions[1] = {
28 [TC1_SDS_REGION_SECURE] =
29 {
30 .base = (void *)SCP_SDS_MEM_BASE,
31 .size = SCP_SDS_MEM_SIZE,
32 },
33 };
34
35 static_assert(
36 FWK_ARRAY_SIZE(sds_module_regions) == TC1_SDS_REGION_COUNT,
37 "Mismatch between number of SDS regions and number of regions "
38 "provided by the SDS configuration.");
39
40 const struct mod_sds_config sds_module_config = {
41 .regions = sds_module_regions,
42 .region_count = TC1_SDS_REGION_COUNT,
43 .clock_id = FWK_ID_ELEMENT_INIT(
44 FWK_MODULE_IDX_CLOCK,
45 CLOCK_IDX_CPU_GROUP_CORTEX_A510)
46 };
47
48 static struct fwk_element sds_element_table[3] = {
49 {
50 .name = "CPU Info",
51 .data = &((struct mod_sds_structure_desc){
52 .id = TC1_SDS_CPU_INFO,
53 .size = TC1_SDS_CPU_INFO_SIZE,
54 .region_id = TC1_SDS_REGION_SECURE,
55 .finalize = true,
56 }),
57 },
58 {
59 .name = "Feature Availability",
60 .data = &((struct mod_sds_structure_desc){
61 .id = TC1_SDS_FEATURE_AVAILABILITY,
62 .size = TC1_SDS_FEATURE_AVAILABILITY_SIZE,
63 .payload = &feature_flags,
64 .region_id = TC1_SDS_REGION_SECURE,
65 .finalize = true,
66 }),
67 },
68 { 0 }, /* Termination description. */
69 };
70
71 static_assert(
72 SCP_SDS_MEM_SIZE >
73 TC1_SDS_CPU_INFO_SIZE + TC1_SDS_FEATURE_AVAILABILITY_SIZE,
74 "SDS structures too large for SDS SRAM.\n");
75
sds_get_element_table(fwk_id_t module_id)76 static const struct fwk_element *sds_get_element_table(fwk_id_t module_id)
77 {
78 static_assert(BUILD_VERSION_MAJOR < UINT8_MAX, "Invalid version size");
79 static_assert(BUILD_VERSION_MINOR < UINT8_MAX, "Invalid version size");
80 static_assert(BUILD_VERSION_PATCH < UINT16_MAX, "Invalid version size");
81
82 return sds_element_table;
83 }
84
85 struct fwk_module_config config_sds = {
86 .elements = FWK_MODULE_DYNAMIC_ELEMENTS(sds_get_element_table),
87 .data = &sds_module_config,
88 };
89