1 /*
2 * Arm SCP/MCP Software
3 * Copyright (c) 2017-2021, Arm Limited and Contributors. All rights reserved.
4 *
5 * SPDX-License-Identifier: BSD-3-Clause
6 */
7
8 #include "clock_devices.h"
9 #include "sgm775_mmap.h"
10 #include "sgm775_sds.h"
11 #include "software_mmap.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 = 0x00000000;
26 static const uint32_t version_packed = FWK_BUILD_VERSION;
27
28 static const struct mod_sds_region_desc sds_module_regions[] = {
29 [SGM775_SDS_REGION_SECURE] = {
30 .base = (void*)SDS_SECURE_BASE,
31 .size = SDS_SECURE_SIZE,
32 },
33 #ifdef BUILD_MODE_DEBUG
34 [SGM775_SDS_REGION_NONSECURE] = {
35 .base = (void *)SDS_NONSECURE_BASE,
36 .size = SDS_NONSECURE_SIZE,
37 },
38 #endif
39 };
40
41 static_assert(FWK_ARRAY_SIZE(sds_module_regions) == SGM775_SDS_REGION_COUNT,
42 "Mismatch between number of SDS regions and number of regions "
43 "provided by the SDS configuration.");
44
45 static const struct mod_sds_config sds_module_config = {
46 .regions = sds_module_regions,
47 .region_count = SGM775_SDS_REGION_COUNT,
48 .clock_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_CLOCK,
49 CLOCK_DEV_IDX_FCMCLK),
50 };
51
52 static const struct fwk_element sds_element_table[] = {
53 {
54 .name = "RAM Version",
55 .data = &((struct mod_sds_structure_desc) {
56 .id = SGM775_SDS_RAM_VERSION,
57 .size = SGM775_SDS_RAM_VERSION_SIZE,
58 .payload = &version_packed,
59 .region_id = SGM775_SDS_REGION_SECURE,
60 .finalize = true,
61 }),
62 },
63 {
64 .name = "Feature Availability",
65 .data = &((struct mod_sds_structure_desc) {
66 .id = SGM775_SDS_FEATURE_AVAILABILITY,
67 .size = sizeof(feature_flags),
68 .payload = &feature_flags,
69 .region_id = SGM775_SDS_REGION_SECURE,
70 .finalize = false,
71 }),
72 },
73 { 0 }, /* Termination description. */
74 };
75
76 static_assert(SDS_SECURE_SIZE >
77 SGM775_SDS_RAM_VERSION_SIZE +
78 sizeof(feature_flags),
79 "SDS structures too large for SDS S-RAM.\n");
80
sds_get_element_table(fwk_id_t module_id)81 static const struct fwk_element *sds_get_element_table(fwk_id_t module_id)
82 {
83 static_assert(BUILD_VERSION_MAJOR < UINT8_MAX, "Invalid version size");
84 static_assert(BUILD_VERSION_MINOR < UINT8_MAX, "Invalid version size");
85 static_assert(BUILD_VERSION_PATCH < UINT16_MAX, "Invalid version size");
86
87 return sds_element_table;
88 }
89
90 struct fwk_module_config config_sds = {
91 .data = &sds_module_config,
92 .elements = FWK_MODULE_DYNAMIC_ELEMENTS(sds_get_element_table),
93 };
94