1 /*
2 * Arm SCP/MCP Software
3 * Copyright (c) 2018-2022, Arm Limited and Contributors. All rights reserved.
4 *
5 * SPDX-License-Identifier: BSD-3-Clause
6 */
7
8 /* Use of "subordinate" may be out of sync with older versions of TRM */
9
10 #include "low_level_access.h"
11 #include "synquacer_mmap.h"
12
13 #include <sysdef_option.h>
14
15 #include <internal/nic400.h>
16
17 #include <mod_synquacer_system.h>
18
19 #include <fwk_log.h>
20 #include <fwk_macros.h>
21
22 #include <inttypes.h>
23 #include <stdint.h>
24
25 #define NIC_TOP_ADDR_SEC_REG (0x00000008)
26 #define NIC_SEC_REG_OFFSET (0x04)
27
nic_sec_subordinate_security(uint32_t nic_top_addr,uint32_t subordinate_index,uint32_t value)28 static void nic_sec_subordinate_security(
29 uint32_t nic_top_addr,
30 uint32_t subordinate_index,
31 uint32_t value)
32 {
33 FWK_LOG_INFO(
34 "%s addr 0x%08" PRIx32 " value 0x%08" PRIx32,
35 __func__,
36 (nic_top_addr + NIC_TOP_ADDR_SEC_REG +
37 NIC_SEC_REG_OFFSET * subordinate_index),
38 value);
39
40 writel(
41 (nic_top_addr + NIC_TOP_ADDR_SEC_REG +
42 NIC_SEC_REG_OFFSET * subordinate_index),
43 value);
44 }
45
nic_secure_access_ctrl_init(void)46 void nic_secure_access_ctrl_init(void)
47 {
48 uint32_t n, m;
49 static const uint32_t nic_base_addr[] = CONFIG_SOC_NIC_ADDR_INFO;
50 static const uint32_t nic_config[][32] = CONFIG_SCB_NIC_INFO;
51 const uint32_t *config;
52
53 for (n = 0; n < FWK_ARRAY_SIZE(nic_base_addr); n++) {
54 for (m = 0; nic_config[n][m] != END_OF_NIC_LIST; m++) {
55 if (nic_config[n][m] == NIC_SETUP_SKIP)
56 continue;
57
58 nic_sec_subordinate_security(nic_base_addr[n], m, nic_config[n][m]);
59 }
60 }
61
62 config = sysdef_option_get_scbm_mv_nic_config();
63 for (n = 0; config[n] != END_OF_NIC_LIST; n++) {
64 if (config[n] == NIC_SETUP_SKIP)
65 continue;
66
67 nic_sec_subordinate_security(SCBM_MV_NIC, n, config[n]);
68 }
69 }
70