blob: 263d4921a6b58582adf4fae667e93efcc3f3525e [file] [log] [blame]
rjw1f884582022-01-06 17:20:42 +08001/* Copyright Statement:
2 *
3 * This software/firmware and related documentation ("MediaTek Software") are
4 * protected under relevant copyright laws. The information contained herein is
5 * confidential and proprietary to MediaTek Inc. and/or its licensors. Without
6 * the prior written permission of MediaTek inc. and/or its licensors, any
7 * reproduction, modification, use or disclosure of MediaTek Software, and
8 * information contained herein, in whole or in part, shall be strictly
9 * prohibited.
10 *
11 * MediaTek Inc. (C) 2017. All rights reserved.
12 *
13 * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
14 * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
15 * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER
16 * ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL
17 * WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
19 * NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH
20 * RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
21 * INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES
22 * TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
23 * RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO
24 * OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN MEDIATEK
25 * SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE
26 * RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
27 * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S
28 * ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE
29 * RELEASED HEREUNDER WILL BE, AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE
30 * MEDIATEK SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE
31 * CHARGE PAID BY RECEIVER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
32 *
33 * The following software/firmware and/or related documentation ("MediaTek
34 * Software") have been modified by MediaTek Inc. All revisions are subject to
35 * any receiver's applicable license agreements with MediaTek Inc.
36 */
37
38#ifndef DEVICE_APC_H
39#define DEVICE_APC_H
40
41#include "typedefs.h"
42
43/* #define DEVAPC_UT */
44
45/******************************************************************************
46 * SIP CMD DEFINITION
47 ******************************************************************************/
48#define SIP_APC_MODULE_SET 0x1
49#define SIP_APC_MM2ND_SET 0x2
50#define SIP_APC_MASTER_SET 0x3
51
52/******************************************************************************
53 * FUNCTION DEFINITION
54 ******************************************************************************/
55void tz_apc_common_init(void);
56void tz_apc_common_postinit(void);
57void devapc_init(void);
58int handle_sramrom_vio(uint64_t *vio_sta, uint64_t *vio_addr);
59unsigned int devapc_perm_get(int, int, int);
60uint64_t sip_tee_apc_request(uint32_t cmd, uint32_t x1, uint32_t x2, uint32_t x3);
61
62/******************************************************************************
63 * STRUCTURE DEFINITION
64 ******************************************************************************/
65enum E_TRANSACTION {
66 NON_SECURE_TRANSACTION = 0,
67 SECURE_TRANSACTION,
68 E_TRANSACTION_RESERVRD = 0x7FFFFFFF /* force enum to use 32 bits */
69};
70
71enum APC_ATTR {
72 E_NO_PROTECTION = 0,
73 E_SEC_RW_ONLY,
74 E_SEC_RW_NS_R,
75 E_FORBIDDEN,
76 E_APC_ATTR_RESERVRD = 0x7FFFFFFF /* force enum to use 32 bits */
77};
78
79enum E_MASK_DOM {
80 E_DOMAIN_0 = 0,
81 E_DOMAIN_1,
82 E_DOMAIN_2,
83 E_DOMAIN_3,
84 E_DOMAIN_4,
85 E_DOMAIN_5,
86 E_DOMAIN_6,
87 E_DOMAIN_7,
88 E_DOMAIN_8,
89 E_DOMAIN_9,
90 E_DOMAIN_10,
91 E_DOMAIN_11,
92 E_DOMAIN_12,
93 E_DOMAIN_13,
94 E_DOMAIN_14,
95 E_DOMAIN_15,
96 E_MASK_DOM_RESERVRD = 0x7FFFFFFF /* force enum to use 32 bits */
97};
98
99enum DAPC_MASTER_TYPE {
100 E_DAPC_MASTER = 0,
101 E_DAPC_INFRACFG_AO_MASTER,
102 E_DAPC_MASTER_TYPE_RESERVRD = 0x7FFFFFFF /* force enum to use 32 bits */
103};
104
105enum DAPC_SLAVE_TYPE {
106 E_DAPC_INFRA_SLAVE = 0,
107 E_DAPC_SRAMROM_SLAVE,
108 E_DAPC_MD_SLAVE,
109 E_DAPC_OTHERS_SLAVE,
110 E_DAPC_SLAVE_TYPE_RESERVRD = 0x7FFFFFFF /* force enum to use 32 bits */
111};
112
113enum DAPC_PD_SLAVE_TYPE {
114 E_DAPC_PD_INFRA_MM_MD_SLAVE = 0,
115 E_DAPC_PD_SLAVE_TYPE_RESERVRD = 0x7FFFFFFF /* force enum to use 32 bits */
116};
117
118struct INFRA_PERI_DEVICE_INFO {
119 unsigned char d0_permission;
120 unsigned char d1_permission;
121 unsigned char d9_permission;
122 unsigned char d11_permission;
123};
124
125#define DAPC_INFRA_ATTR(DEV_NAME, PERM_ATTR1, PERM_ATTR2, PERM_ATTR3, PERM_ATTR4) \
126{(unsigned char)PERM_ATTR1, (unsigned char)PERM_ATTR2, (unsigned char)PERM_ATTR3, (unsigned char)PERM_ATTR4}
127
128struct MD_DEVICE_INFO {
129 unsigned char d0_permission;
130};
131
132#define DAPC_MD_ATTR(DEV_NAME, PERM_ATTR1) {(unsigned char)PERM_ATTR1}
133
134enum DEVAPC_ERR_STATUS {
135 DEVAPC_OK = 0x0,
136
137 DEVAPC_ERR_GENERIC = 0x1000,
138 DEVAPC_ERR_INVALID_CMD = 0x1001,
139 DEVAPC_ERR_SLAVE_TYPE_NOT_SUPPORTED = 0x1002,
140 DEVAPC_ERR_SLAVE_IDX_NOT_SUPPORTED = 0x1003,
141 DEVAPC_ERR_DOMAIN_NOT_SUPPORTED = 0x1004,
142 DEVAPC_ERR_PERMISSION_NOT_SUPPORTED = 0x1005,
143 DEVAPC_ERR_OUT_OF_BOUNDARY = 0x1006,
144};
145
146/******************************************************************************
147 * UTILITY DEFINITION
148 ******************************************************************************/
149
150#define devapc_writel(VAL, REG) __raw_writel(VAL, REG)
151#define devapc_readl(REG) __raw_readl(REG)
152
153static void tz_set_field(volatile u32 *reg, u32 field, u32 val)
154{
155 u32 tv = (u32)*reg;
156 tv &= ~(field);
157 tv |= val;
158 *reg = tv;
159}
160
161#define reg_set_field(r, f, v) tz_set_field((volatile u32 *)r, f, v)
162
163/******************************************************************************
164 *
165 * REGISTER ADDRESS DEFINITION
166 *
167 ******************************************************************************/
168#define DEVAPC_AO_INFRA_BASE 0x1001C000
169#define DEVAPC_PD_INFRA_BASE 0x10207000
170
171#define SRAMROM_BASE 0x10214000
172#define INFRACFG_AO_BASE 0x10001000
173#define SECURITY_AO_BASE 0x1001A000
174
175/* #define BLOCKED_REG_BASE 0x10400000 */
176
177/*******************************************************************************************/
178/* Device APC AO */
179#define DEVAPC_SYS0_D0_APC_0 ((volatile unsigned int *)(DEVAPC_AO_INFRA_BASE+0x0000))
180#define DEVAPC_SYS1_D0_APC_0 ((volatile unsigned int *)(DEVAPC_AO_INFRA_BASE+0x1000))
181#define DEVAPC_SYS2_D0_APC_0 ((volatile unsigned int *)(DEVAPC_AO_INFRA_BASE+0x2000))
182
183#define DEVAPC_INFRA_MAS_DOM_0 ((volatile unsigned int *)(DEVAPC_AO_INFRA_BASE+0x0900))
184#define DEVAPC_INFRA_MAS_DOM_1 ((volatile unsigned int *)(DEVAPC_AO_INFRA_BASE+0x0904))
185#define DEVAPC_INFRA_MAS_DOM_2 ((volatile unsigned int *)(DEVAPC_AO_INFRA_BASE+0x0908))
186#define DEVAPC_INFRA_MAS_DOM_3 ((volatile unsigned int *)(DEVAPC_AO_INFRA_BASE+0x090C))
187#define DEVAPC_INFRA_MAS_DOM_4 ((volatile unsigned int *)(DEVAPC_AO_INFRA_BASE+0x0910))
188
189#define DEVAPC_INFRA_MAS_SEC_0 ((volatile unsigned int *)(DEVAPC_AO_INFRA_BASE+0x0A00))
190
191#define DEVAPC_INFRA_APC_CON ((volatile unsigned int *)(DEVAPC_AO_INFRA_BASE+0x0F00))
192
193#define DEVAPC_SRAMROM_DOM_REMAP_0_0 ((volatile unsigned int *)(DEVAPC_AO_INFRA_BASE+0x0800))
194#define DEVAPC_SRAMROM_DOM_REMAP_0_1 ((volatile unsigned int *)(DEVAPC_AO_INFRA_BASE+0x0804))
195#define DEVAPC_SRAMROM_DOM_REMAP_1_0 ((volatile unsigned int *)(DEVAPC_AO_INFRA_BASE+0x0810))
196
197/* MD is combined into DEVAPC_AO SYS2 */
198
199/*******************************************************************************************/
200/* Device APC PD */
201#define DEVAPC_PD_INFRA_VIO_MASK(index) \
202 ((uintptr_t)(DEVAPC_PD_INFRA_BASE + 0x4 * index))
203
204#define DEVAPC_PD_INFRA_VIO_STA(index) \
205 ((uintptr_t)(DEVAPC_PD_INFRA_BASE + 0x400 + 0x4 * index))
206
207#define DEVAPC_PD_INFRA_VIO_DBG0 ((volatile unsigned int *)(DEVAPC_PD_INFRA_BASE+0x0900))
208#define DEVAPC_PD_INFRA_VIO_DBG1 ((volatile unsigned int *)(DEVAPC_PD_INFRA_BASE+0x0904))
209#define DEVAPC_PD_INFRA_VIO_DBG2 ((volatile unsigned int *)(DEVAPC_PD_INFRA_BASE+0x0908))
210
211#define DEVAPC_PD_INFRA_APC_CON ((volatile unsigned int *)(DEVAPC_PD_INFRA_BASE+0x0F00))
212
213#define DEVAPC_PD_INFRA_VIO_SHIFT_STA ((volatile unsigned int *)(DEVAPC_PD_INFRA_BASE+0x0F10))
214#define DEVAPC_PD_INFRA_VIO_SHIFT_SEL ((volatile unsigned int *)(DEVAPC_PD_INFRA_BASE+0x0F14))
215#define DEVAPC_PD_INFRA_VIO_SHIFT_CON ((volatile unsigned int *)(DEVAPC_PD_INFRA_BASE+0x0F20))
216
217/*******************************************************************************************/
218
219#define INFRA_AO_SEC_CON ((volatile unsigned int *)(INFRACFG_AO_BASE+0x0F80))
220
221/* INFRACFG AO */
222#define INFRA_AO_SEC_CG_CON0 ((volatile unsigned int *)(INFRACFG_AO_BASE+0x0F84))
223#define INFRA_AO_SEC_CG_CON1 ((volatile unsigned int *)(INFRACFG_AO_BASE+0x0F88))
224#define INFRA_AO_SEC_CG_CON2 ((volatile unsigned int *)(INFRACFG_AO_BASE+0x0F9C))
225#define INFRA_AO_SEC_CG_CON3 ((volatile unsigned int *)(INFRACFG_AO_BASE+0x0FA4))
226
227#define INFRACFG_AO_DEVAPC_CON ((volatile unsigned int *)(INFRACFG_AO_BASE+0x0710))
228#define INFRACFG_AO_DEVAPC_MAS_DOM ((volatile unsigned int *)(INFRACFG_AO_BASE+0x0714))
229#define INFRACFG_AO_DEVAPC_MAS_SEC ((volatile unsigned int *)(INFRACFG_AO_BASE+0x0718))
230
231/* PMS(MD devapc) */
232/* #define AP2MD1_PMS_CTRL_EN ((unsigned int *)0x100018AC) */
233/* #define AP2MD1_PMS_CTRL_EN_LOCK ((unsigned int *)0x100018A8) */
234
235/*******************************************************************************************/
236
237#define SRAMROM_SEC_VIO_STA ((volatile unsigned int *)(SRAMROM_BASE+0x010))
238#define SRAMROM_SEC_VIO_ADDR ((volatile unsigned int *)(SRAMROM_BASE+0x014))
239#define SRAMROM_SEC_VIO_CLR ((volatile unsigned int *)(SRAMROM_BASE+0x018))
240
241#define SRAMROM_ROM_SEC_VIO_STA ((volatile unsigned int *)(SRAMROM_BASE+0x110))
242#define SRAMROM_ROM_SEC_VIO_ADDR ((volatile unsigned int *)(SRAMROM_BASE+0x114))
243#define SRAMROM_ROM_SEC_VIO_CLR ((volatile unsigned int *)(SRAMROM_BASE+0x118))
244
245
246#define SRAMROM_SEC_CTRL ((volatile unsigned int *)(SECURITY_AO_BASE+0x010))
247#define SRAMROM_SEC_CTRL2 ((volatile unsigned int *)(SECURITY_AO_BASE+0x018))
248#define SRAMROM_SEC_CTRL5 ((volatile unsigned int *)(SECURITY_AO_BASE+0x024))
249#define SRAMROM_SEC_CTRL6 ((volatile unsigned int *)(SECURITY_AO_BASE+0x028))
250#define SRAMROM_SEC_ADDR ((volatile unsigned int *)(SECURITY_AO_BASE+0x050))
251#define SRAMROM_SEC_ADDR1 ((volatile unsigned int *)(SECURITY_AO_BASE+0x054))
252#define SRAMROM_SEC_ADDR2 ((volatile unsigned int *)(SECURITY_AO_BASE+0x058))
253
254#define SRAMROM_SEC_ADDR_SEC0_SEC_EN (28)
255#define SRAMROM_SEC_ADDR_SEC1_SEC_EN (29)
256#define SRAMROM_SEC_ADDR_SEC2_SEC_EN (30)
257#define SRAMROM_SEC_ADDR_SEC3_SEC_EN (31)
258
259/* SEC means region (0~3) */
260#define SRAMROM_SEC_CTRL_SEC0_DOM0_SHIFT (0)
261#define SRAMROM_SEC_CTRL_SEC0_DOM1_SHIFT (3)
262#define SRAMROM_SEC_CTRL_SEC0_DOM2_SHIFT (6)
263#define SRAMROM_SEC_CTRL_SEC0_DOM3_SHIFT (9)
264#define SRAMROM_SEC_CTRL_SEC1_DOM0_SHIFT (16)
265#define SRAMROM_SEC_CTRL_SEC1_DOM1_SHIFT (19)
266#define SRAMROM_SEC_CTRL_SEC1_DOM2_SHIFT (22)
267#define SRAMROM_SEC_CTRL_SEC1_DOM3_SHIFT (25)
268
269#define SRAMROM_SEC_CTRL2_SEC0_DOM4_SHIFT (0)
270#define SRAMROM_SEC_CTRL2_SEC0_DOM5_SHIFT (3)
271#define SRAMROM_SEC_CTRL2_SEC0_DOM6_SHIFT (6)
272#define SRAMROM_SEC_CTRL2_SEC0_DOM7_SHIFT (9)
273#define SRAMROM_SEC_CTRL2_SEC1_DOM4_SHIFT (16)
274#define SRAMROM_SEC_CTRL2_SEC1_DOM5_SHIFT (19)
275#define SRAMROM_SEC_CTRL2_SEC1_DOM6_SHIFT (22)
276#define SRAMROM_SEC_CTRL2_SEC1_DOM7_SHIFT (25)
277
278#define SRAMROM_SEC_CTRL5_SEC2_DOM0_SHIFT (0)
279#define SRAMROM_SEC_CTRL5_SEC2_DOM1_SHIFT (3)
280#define SRAMROM_SEC_CTRL5_SEC2_DOM2_SHIFT (6)
281#define SRAMROM_SEC_CTRL5_SEC2_DOM3_SHIFT (9)
282#define SRAMROM_SEC_CTRL5_SEC3_DOM0_SHIFT (16)
283#define SRAMROM_SEC_CTRL5_SEC3_DOM1_SHIFT (19)
284#define SRAMROM_SEC_CTRL5_SEC3_DOM2_SHIFT (22)
285#define SRAMROM_SEC_CTRL5_SEC3_DOM3_SHIFT (25)
286
287#define SRAMROM_SEC_CTRL6_SEC2_DOM4_SHIFT (0)
288#define SRAMROM_SEC_CTRL6_SEC2_DOM5_SHIFT (3)
289#define SRAMROM_SEC_CTRL6_SEC2_DOM6_SHIFT (6)
290#define SRAMROM_SEC_CTRL6_SEC2_DOM7_SHIFT (9)
291#define SRAMROM_SEC_CTRL6_SEC3_DOM4_SHIFT (16)
292#define SRAMROM_SEC_CTRL6_SEC3_DOM5_SHIFT (19)
293#define SRAMROM_SEC_CTRL6_SEC3_DOM6_SHIFT (22)
294#define SRAMROM_SEC_CTRL6_SEC3_DOM7_SHIFT (25)
295
296
297#define SRAMROM_SEC_CTRL_SEC0_DOM0_MASK (0x7 << SRAMROM_SEC_CTRL_SEC0_DOM0_SHIFT)
298#define SRAMROM_SEC_CTRL_SEC0_DOM1_MASK (0x7 << SRAMROM_SEC_CTRL_SEC0_DOM1_SHIFT)
299#define SRAMROM_SEC_CTRL_SEC0_DOM2_MASK (0x7 << SRAMROM_SEC_CTRL_SEC0_DOM2_SHIFT)
300#define SRAMROM_SEC_CTRL_SEC0_DOM3_MASK (0x7 << SRAMROM_SEC_CTRL_SEC0_DOM3_SHIFT)
301#define SRAMROM_SEC_CTRL_SEC1_DOM0_MASK (0x7 << SRAMROM_SEC_CTRL_SEC1_DOM0_SHIFT)
302#define SRAMROM_SEC_CTRL_SEC1_DOM1_MASK (0x7 << SRAMROM_SEC_CTRL_SEC1_DOM1_SHIFT)
303#define SRAMROM_SEC_CTRL_SEC1_DOM2_MASK (0x7 << SRAMROM_SEC_CTRL_SEC1_DOM2_SHIFT)
304#define SRAMROM_SEC_CTRL_SEC1_DOM3_MASK (0x7 << SRAMROM_SEC_CTRL_SEC1_DOM3_SHIFT)
305
306#define SRAMROM_SEC_CTRL2_SEC0_DOM4_MASK (0x7 << SRAMROM_SEC_CTRL2_SEC0_DOM4_SHIFT)
307#define SRAMROM_SEC_CTRL2_SEC0_DOM5_MASK (0x7 << SRAMROM_SEC_CTRL2_SEC0_DOM5_SHIFT)
308#define SRAMROM_SEC_CTRL2_SEC0_DOM6_MASK (0x7 << SRAMROM_SEC_CTRL2_SEC0_DOM6_SHIFT)
309#define SRAMROM_SEC_CTRL2_SEC0_DOM7_MASK (0x7 << SRAMROM_SEC_CTRL2_SEC0_DOM7_SHIFT)
310#define SRAMROM_SEC_CTRL2_SEC1_DOM4_MASK (0x7 << SRAMROM_SEC_CTRL2_SEC1_DOM4_SHIFT)
311#define SRAMROM_SEC_CTRL2_SEC1_DOM5_MASK (0x7 << SRAMROM_SEC_CTRL2_SEC1_DOM5_SHIFT)
312#define SRAMROM_SEC_CTRL2_SEC1_DOM6_MASK (0x7 << SRAMROM_SEC_CTRL2_SEC1_DOM6_SHIFT)
313#define SRAMROM_SEC_CTRL2_SEC1_DOM7_MASK (0x7 << SRAMROM_SEC_CTRL2_SEC1_DOM7_SHIFT)
314
315#define SRAMROM_SEC_CTRL5_SEC2_DOM0_MASK (0x7 << SRAMROM_SEC_CTRL5_SEC2_DOM0_SHIFT)
316#define SRAMROM_SEC_CTRL5_SEC2_DOM1_MASK (0x7 << SRAMROM_SEC_CTRL5_SEC2_DOM1_SHIFT)
317#define SRAMROM_SEC_CTRL5_SEC2_DOM2_MASK (0x7 << SRAMROM_SEC_CTRL5_SEC2_DOM2_SHIFT)
318#define SRAMROM_SEC_CTRL5_SEC2_DOM3_MASK (0x7 << SRAMROM_SEC_CTRL5_SEC2_DOM3_SHIFT)
319#define SRAMROM_SEC_CTRL5_SEC3_DOM0_MASK (0x7 << SRAMROM_SEC_CTRL5_SEC3_DOM0_SHIFT)
320#define SRAMROM_SEC_CTRL5_SEC3_DOM1_MASK (0x7 << SRAMROM_SEC_CTRL5_SEC3_DOM1_SHIFT)
321#define SRAMROM_SEC_CTRL5_SEC3_DOM2_MASK (0x7 << SRAMROM_SEC_CTRL5_SEC3_DOM2_SHIFT)
322#define SRAMROM_SEC_CTRL5_SEC3_DOM3_MASK (0x7 << SRAMROM_SEC_CTRL5_SEC3_DOM3_SHIFT)
323
324#define SRAMROM_SEC_CTRL6_SEC2_DOM4_MASK (0x7 << SRAMROM_SEC_CTRL6_SEC2_DOM4_SHIFT)
325#define SRAMROM_SEC_CTRL6_SEC2_DOM5_MASK (0x7 << SRAMROM_SEC_CTRL6_SEC2_DOM5_SHIFT)
326#define SRAMROM_SEC_CTRL6_SEC2_DOM6_MASK (0x7 << SRAMROM_SEC_CTRL6_SEC2_DOM6_SHIFT)
327#define SRAMROM_SEC_CTRL6_SEC2_DOM7_MASK (0x7 << SRAMROM_SEC_CTRL6_SEC2_DOM7_SHIFT)
328#define SRAMROM_SEC_CTRL6_SEC3_DOM4_MASK (0x7 << SRAMROM_SEC_CTRL6_SEC3_DOM4_SHIFT)
329#define SRAMROM_SEC_CTRL6_SEC3_DOM5_MASK (0x7 << SRAMROM_SEC_CTRL6_SEC3_DOM5_SHIFT)
330#define SRAMROM_SEC_CTRL6_SEC3_DOM6_MASK (0x7 << SRAMROM_SEC_CTRL6_SEC3_DOM6_SHIFT)
331#define SRAMROM_SEC_CTRL6_SEC3_DOM7_MASK (0x7 << SRAMROM_SEC_CTRL6_SEC3_DOM7_SHIFT)
332
333#define PERMIT_S_RW_NS_RW (0x0)
334#define PERMIT_S_RW_NS_BLOCK (0x1)
335#define PERMIT_S_RW_NS_RO (0x2)
336#define PERMIT_S_RW_NS_WO (0x3)
337#define PERMIT_S_RO_NS_RO (0x4)
338#define PERMIT_S_BLOCK_NS_BLOCK (0x7)
339
340
341/* Set the region 0 size of the on-chip SRAM and the region 1 size will be (192KB - size_of_region_0) */
342#define TZ_SRAMROM_SET_REGION_0_SIZE_KB(size) (devapc_writel(((size & 0xff) << 10), SRAMROM_SEC_ADDR))
343
344/******************************************************************************
345 * Variable DEFINITION
346 ******************************************************************************/
347/* If you config register INFRA_AO_SEC_CON(address 0x10000F80) bit[4] = 1,
348 * the domain comes from device_apc. By default this register is 0,
349 * the domain comes form MD1
350 */
351#define FORCE_MD1_SIGNAL_FROM_DAPC ((0x1) << 4)
352
353/* PROTECT BIT FOR INFRACFG AO */
354#define SEJ_CG_PROTECT_BIT ((0x1) << 5)
355#define TRNG_CG_PROTECT_BIT ((0x1) << 9)
356#define DEVAPC_CG_PROTECT_BIT ((0x1) << 20)
357
358#define SRAM_SEC_VIO_BIT (0x1)
359#define ROM_SEC_VIO_BIT (0x1)
360
361/*******************************************************************************************/
362/* Master domain/secure bit definition */
363#define MASTER_SPM_DOM_INDEX (18)
364#define MASTER_SPM_SEC_INDEX (19)
365#define MASTER_INFRA_MAX_INDEX (19)
366
367/* Below master should be set in INFRACFG_AO */
368#define MASTER_INFRACFG_AO_MAX_INDEX 5
369#define MASTER_APMCU_INDEX 0
370#define MASTER_MD_INDEX 1
371#define MASTER_HSM_INDEX 2
372#define MASTER_USB_INDEX 3
373#define MASTER_SSUSB_INDEX 4
374#define MASTER_MSDC0_INDEX 5
375
376/*******************************************************************************************/
377/* Master domain remap */
378#define MASTER_DOM_RMP_INIT (0xFFFFFFFF)
379#define SRAMROM_RMP_AP (0x7 << 0) // Infra domain 0
380
381#define MD_RMP_AP (0x3 << 0) // Infra domain 0
382
383/*******************************************************************************************/
384#define MOD_NO_IN_1_DEVAPC 16
385#define MAS_DOM_NO_IN_1_DEVAPC 4
386
387/* infra/sramrom/MD support maximum domain num */
388#define DEVAPC_INFRA_DOM_MAX 16
389#define DEVAPC_SRAMROM_DOM_MAX 8
390#define DEVAPC_MD_DOM_MAX 4
391
392/* infra/sramrom/MD APC number per domain */
393#define DEVAPC_INFRA_APC_NUM 10
394#define DEVAPC_SRAMROM_APC_NUM 1
395#define DEVAPC_MD_APC_NUM 3
396
397/* infra/sramrom/MD support maximum ctrl index */
398#define SLAVE_INFRA_MAX_INDEX 146
399#define SLAVE_SRAMROM_MAX_INDEX 0
400#define SLAVE_MD_MAX_INDEX 35
401
402#define VIO_MASK_STA_NUM 13
403#define SRAMROM_VIO_INDEX 355
404#define DEVAPC_CTRL_SRAMROM_INDEX 0
405/* devapc can only handle vio index 0 ~ sramrom */
406#define VIOLATION_MAX_INDEX SRAMROM_VIO_INDEX
407#define VIOLATION_TRIGGERED 1
408
409#endif /* DEVICE_APC_H */