blob: 0d09aa6890dc3a45febf8b4c6bf5a81b513833c5 [file] [log] [blame]
Jacky Bai8e2109d2023-05-25 09:35:44 +08001/*
2 * Copyright 2022-2023 NXP
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <assert.h>
8#include <errno.h>
9#include <stdbool.h>
10
11#include <common/bl_common.h>
12#include <common/debug.h>
13#include <lib/mmio.h>
14
15#include "trdc_config.h"
16
17struct trdc_mgr_info trdc_mgr_blks[] = {
18 { TRDC_A_BASE, 0, 0, 39, 40 },
19 { TRDC_W_BASE, 0, 0, 70, 71 },
20 { TRDC_M_BASE, 1, 0, 1, 2 },
21 { TRDC_N_BASE, 0, 1, 1, 2 },
22};
23
24unsigned int trdc_mgr_num = ARRAY_SIZE(trdc_mgr_blks);
25
26struct trdc_config_info trdc_cfg_info[] = {
27 { TRDC_A_BASE,
28 trdc_a_mbc_glbac, ARRAY_SIZE(trdc_a_mbc_glbac),
29 trdc_a_mbc, ARRAY_SIZE(trdc_a_mbc),
30 trdc_a_mrc_glbac, ARRAY_SIZE(trdc_a_mrc_glbac),
31 trdc_a_mrc, ARRAY_SIZE(trdc_a_mrc)
32 }, /* TRDC_A */
33 { TRDC_W_BASE,
34 trdc_w_mbc_glbac, ARRAY_SIZE(trdc_w_mbc_glbac),
35 trdc_w_mbc, ARRAY_SIZE(trdc_w_mbc),
36 trdc_w_mrc_glbac, ARRAY_SIZE(trdc_w_mrc_glbac),
37 trdc_w_mrc, ARRAY_SIZE(trdc_w_mrc)
38 }, /* TRDC_W */
39 { TRDC_N_BASE,
40 trdc_n_mbc_glbac, ARRAY_SIZE(trdc_n_mbc_glbac),
41 trdc_n_mbc, ARRAY_SIZE(trdc_n_mbc),
42 trdc_n_mrc_glbac, ARRAY_SIZE(trdc_n_mrc_glbac),
43 trdc_n_mrc, ARRAY_SIZE(trdc_n_mrc)
44 }, /* TRDC_N */
45};
46
47void trdc_config(void)
48{
49 unsigned int i;
50
51 /* Set MTR to DID1 */
52 trdc_mda_set_noncpu(TRDC_A_BASE, 4, false, 0x2, 0x2, 0x1);
53
54 /* Set M33 to DID2*/
55 trdc_mda_set_cpu(TRDC_A_BASE, 1, 0, 0x2, 0x0, 0x2, 0x0, 0x0, 0x0);
56
57 /* Configure the access permission for TRDC MGR and MC slots */
58 for (i = 0U; i < ARRAY_SIZE(trdc_mgr_blks); i++) {
59 trdc_mgr_mbc_setup(&trdc_mgr_blks[i]);
60 }
61
62 /* Configure TRDC user settings from config table */
63 for (i = 0U; i < ARRAY_SIZE(trdc_cfg_info); i++) {
64 trdc_setup(&trdc_cfg_info[i]);
65 }
66
67 NOTICE("TRDC init done\n");
68}