blob: 86bebe55c9c08f7bafbaa2bd2063495066c0f465 [file] [log] [blame]
Karl Lidece5f02023-04-27 10:38:28 +08001/*
2 * Copyright (c) 2023, MediaTek Inc. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7/* TF-A system header */
8#include <common/debug.h>
9#include <lib/mmio.h>
10
11/* Vendor header */
12#include "apusys_security_ctrl_plat.h"
13
14static void apusys_domain_remap_init(void)
15{
16 const uint32_t remap_domains[] = {
17 D0_REMAP_DOMAIN, D1_REMAP_DOMAIN, D2_REMAP_DOMAIN, D3_REMAP_DOMAIN,
18 D4_REMAP_DOMAIN, D5_REMAP_DOMAIN, D6_REMAP_DOMAIN, D7_REMAP_DOMAIN,
19 D8_REMAP_DOMAIN, D9_REMAP_DOMAIN, D10_REMAP_DOMAIN, D11_REMAP_DOMAIN,
20 D12_REMAP_DOMAIN, D13_REMAP_DOMAIN, D14_REMAP_DOMAIN, D15_REMAP_DOMAIN
21 };
22 uint32_t lower_domain = 0;
23 uint32_t higher_domain = 0;
24 int i;
25
26 for (i = 0; i < ARRAY_SIZE(remap_domains); i++) {
27 if (i < REG_DOMAIN_NUM) {
28 lower_domain |= (remap_domains[i] << (i * REG_DOMAIN_BITS));
29 } else {
30 higher_domain |= (remap_domains[i] <<
31 ((i - REG_DOMAIN_NUM) * REG_DOMAIN_BITS));
32 }
33 }
34
35 mmio_write_32(SOC2APU_SET1_0, lower_domain);
36 mmio_write_32(SOC2APU_SET1_1, higher_domain);
37 mmio_setbits_32(APU_SEC_CON, DOMAIN_REMAP_SEL);
38}
39
40void apusys_security_ctrl_init(void)
41{
42 apusys_domain_remap_init();
43}