blob: a6e10a7b75291688e9e735979c95b179de4ef865 [file] [log] [blame]
Jacky Bai64130a32019-07-18 13:43:17 +08001/*
Jacky Bai0e400552022-03-14 17:14:26 +08002 * Copyright (c) 2019-2022 NXP. All rights reserved.
Jacky Bai64130a32019-07-18 13:43:17 +08003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef IMX_RDC_H
8#define IMX_RDC_H
9
10#include <lib/utils_def.h>
11
Jacky Bai0e400552022-03-14 17:14:26 +080012#include <imx_sec_def.h>
Jacky Bai64130a32019-07-18 13:43:17 +080013#include <platform_def.h>
14
15#define MDAn(x) (IMX_RDC_BASE + 0x200 + (x) * 4)
16#define PDAPn(x) (IMX_RDC_BASE + 0x400 + (x) * 4)
Jacky Baia5a8bae2019-11-29 10:25:42 +080017#define MRSAn(x) (IMX_RDC_BASE + 0x800 + (x) * 0x10)
18#define MREAn(x) (IMX_RDC_BASE + 0x804 + (x) * 0x10)
19#define MRCn(x) (IMX_RDC_BASE + 0x808 + (x) * 0x10)
Jacky Bai64130a32019-07-18 13:43:17 +080020
21#define LCK BIT(31)
22#define SREQ BIT(30)
23#define ENA BIT(30)
24
25#define DID0 U(0x0)
26#define DID1 U(0x1)
27#define DID2 U(0x2)
28#define DID3 U(0x3)
29
30#define D3R BIT(7)
31#define D3W BIT(6)
32#define D2R BIT(5)
33#define D2W BIT(4)
34#define D1R BIT(3)
35#define D1W BIT(2)
36#define D0R BIT(1)
37#define D0W BIT(0)
38
39union rdc_setting {
40 uint32_t rdc_mda; /* Master Domain Assignment */
41 uint32_t rdc_pdap; /* Peripheral Domain Access Permissions */
42 uint32_t rdc_mem_region[3]; /* Memory Region Access Control */
43};
44
45enum rdc_type {
46 RDC_INVALID,
47 RDC_MDA,
48 RDC_PDAP,
49 RDC_MEM_REGION,
50};
51
52struct imx_rdc_cfg {
53 enum rdc_type type; /* config type Master, Peripheral or Memory region */
54 int index;
55 union rdc_setting setting;
56};
57
58#define RDC_MDAn(i, mda) \
59 {RDC_MDA, (i), .setting.rdc_mda = (mda), }
60#define RDC_PDAPn(i, pdap) \
61 {RDC_PDAP, (i), .setting.rdc_pdap = (pdap), }
62
63#define RDC_MEM_REGIONn(i, msa, mea, mrc) \
64 { RDC_MEM_REGION, (i), \
65 .setting.rdc_mem_region[0] = (msa), \
66 .setting.rdc_mem_region[1] = (mea), \
67 .setting.rdc_mem_region[2] = (mrc), \
68 }
69
70void imx_rdc_init(const struct imx_rdc_cfg *cfg);
71
72#endif /* IMX_RDC_H */
73