tzc400.h 4.31 KB
Newer Older
Harry Liebel's avatar
Harry Liebel committed
1
/*
2
 * Copyright (c) 2014-2021, ARM Limited and Contributors. All rights reserved.
Harry Liebel's avatar
Harry Liebel committed
3
 *
dp-arm's avatar
dp-arm committed
4
 * SPDX-License-Identifier: BSD-3-Clause
Harry Liebel's avatar
Harry Liebel committed
5
6
 */

Antonio Nino Diaz's avatar
Antonio Nino Diaz committed
7
8
#ifndef TZC400_H
#define TZC400_H
Harry Liebel's avatar
Harry Liebel committed
9

10
11
#include <drivers/arm/tzc_common.h>
#include <lib/utils_def.h>
Harry Liebel's avatar
Harry Liebel committed
12

Antonio Nino Diaz's avatar
Antonio Nino Diaz committed
13
14
15
16
17
#define BUILD_CONFIG_OFF			U(0x000)
#define GATE_KEEPER_OFF				U(0x008)
#define SPECULATION_CTRL_OFF			U(0x00c)
#define INT_STATUS				U(0x010)
#define INT_CLEAR				U(0x014)
18

Antonio Nino Diaz's avatar
Antonio Nino Diaz committed
19
20
21
22
#define FAIL_ADDRESS_LOW_OFF			U(0x020)
#define FAIL_ADDRESS_HIGH_OFF			U(0x024)
#define FAIL_CONTROL_OFF			U(0x028)
#define FAIL_ID					U(0x02c)
23
24

/* ID registers not common across different varieties of TZC */
Antonio Nino Diaz's avatar
Antonio Nino Diaz committed
25
26
27
#define PID5					U(0xFD4)
#define PID6					U(0xFD8)
#define PID7					U(0xFDC)
28
29

#define BUILD_CONFIG_NF_SHIFT			24
Antonio Nino Diaz's avatar
Antonio Nino Diaz committed
30
#define BUILD_CONFIG_NF_MASK			U(0x3)
31
#define BUILD_CONFIG_AW_SHIFT			8
Antonio Nino Diaz's avatar
Antonio Nino Diaz committed
32
#define BUILD_CONFIG_AW_MASK			U(0x3f)
33
#define BUILD_CONFIG_NR_SHIFT			0
Antonio Nino Diaz's avatar
Antonio Nino Diaz committed
34
#define BUILD_CONFIG_NR_MASK			U(0x1f)
Harry Liebel's avatar
Harry Liebel committed
35
36
37
38
39

/*
 * Number of gate keepers is implementation defined. But we know the max for
 * this device is 4. Get implementation details from BUILD_CONFIG.
 */
40
#define GATE_KEEPER_OS_SHIFT			16
Antonio Nino Diaz's avatar
Antonio Nino Diaz committed
41
#define GATE_KEEPER_OS_MASK			U(0xf)
42
#define GATE_KEEPER_OR_SHIFT			0
Antonio Nino Diaz's avatar
Antonio Nino Diaz committed
43
44
#define GATE_KEEPER_OR_MASK			U(0xf)
#define GATE_KEEPER_FILTER_MASK			U(0x1)
Harry Liebel's avatar
Harry Liebel committed
45
46

/* Speculation is enabled by default. */
Antonio Nino Diaz's avatar
Antonio Nino Diaz committed
47
48
#define SPECULATION_CTRL_WRITE_DISABLE		BIT_32(1)
#define SPECULATION_CTRL_READ_DISABLE		BIT_32(0)
Harry Liebel's avatar
Harry Liebel committed
49
50

/* Max number of filters allowed is 4. */
51
#define INT_STATUS_OVERLAP_SHIFT		16
Antonio Nino Diaz's avatar
Antonio Nino Diaz committed
52
#define INT_STATUS_OVERLAP_MASK			U(0xf)
53
#define INT_STATUS_OVERRUN_SHIFT		8
Antonio Nino Diaz's avatar
Antonio Nino Diaz committed
54
#define INT_STATUS_OVERRUN_MASK			U(0xf)
55
#define INT_STATUS_STATUS_SHIFT			0
Antonio Nino Diaz's avatar
Antonio Nino Diaz committed
56
#define INT_STATUS_STATUS_MASK			U(0xf)
57
58

#define INT_CLEAR_CLEAR_SHIFT			0
Antonio Nino Diaz's avatar
Antonio Nino Diaz committed
59
60
61
62
63
64
65
66
67
#define INT_CLEAR_CLEAR_MASK			U(0xf)

#define FAIL_CONTROL_DIR_SHIFT			24
#define FAIL_CONTROL_DIR_READ			U(0)
#define FAIL_CONTROL_DIR_WRITE			U(1)
#define FAIL_CONTROL_NS_SHIFT			21
#define FAIL_CONTROL_NS_SECURE			U(0)
#define FAIL_CONTROL_NS_NONSECURE		U(1)
#define FAIL_CONTROL_PRIV_SHIFT			20
68
69
#define FAIL_CONTROL_PRIV_UNPRIV		U(0)
#define FAIL_CONTROL_PRIV_PRIV			U(1)
Harry Liebel's avatar
Harry Liebel committed
70
71
72
73
74

/*
 * FAIL_ID_ID_MASK depends on AID_WIDTH which is platform specific.
 * Platform should provide the value on initialisation.
 */
75
#define FAIL_ID_VNET_SHIFT			24
Antonio Nino Diaz's avatar
Antonio Nino Diaz committed
76
#define FAIL_ID_VNET_MASK			U(0xf)
77
#define FAIL_ID_ID_SHIFT			0
Harry Liebel's avatar
Harry Liebel committed
78

Antonio Nino Diaz's avatar
Antonio Nino Diaz committed
79
#define TZC_400_PERIPHERAL_ID			U(0x460)
Harry Liebel's avatar
Harry Liebel committed
80

81
/* Filter enable bits in a TZC */
Antonio Nino Diaz's avatar
Antonio Nino Diaz committed
82
#define TZC_400_REGION_ATTR_F_EN_MASK		U(0xf)
83
84
#define TZC_400_REGION_ATTR_FILTER_BIT(x)	(U(1) << (x))
#define TZC_400_REGION_ATTR_FILTER_BIT_ALL	TZC_400_REGION_ATTR_F_EN_MASK
Harry Liebel's avatar
Harry Liebel committed
85

86
87
88
89
/*
 * All TZC region configuration registers are placed one after another. It
 * depicts size of block of registers for programming each region.
 */
Antonio Nino Diaz's avatar
Antonio Nino Diaz committed
90
91
#define TZC_400_REGION_SIZE			U(0x20)
#define TZC_400_ACTION_OFF			U(0x4)
92

93
94
#define FILTER_OFFSET				U(0x10)

95
#ifndef __ASSEMBLER__
96

97
#include <cdefs.h>
98
99
#include <stdint.h>

Harry Liebel's avatar
Harry Liebel committed
100
101
102
/*******************************************************************************
 * Function & variable prototypes
 ******************************************************************************/
103
void tzc400_init(uintptr_t base);
Antonio Nino Diaz's avatar
Antonio Nino Diaz committed
104
void tzc400_configure_region0(unsigned int sec_attr,
105
106
			   unsigned int ns_device_access);
void tzc400_configure_region(unsigned int filters,
Antonio Nino Diaz's avatar
Antonio Nino Diaz committed
107
			  unsigned int region,
108
109
			  unsigned long long region_base,
			  unsigned long long region_top,
Antonio Nino Diaz's avatar
Antonio Nino Diaz committed
110
			  unsigned int sec_attr,
Roberto Vargas's avatar
Roberto Vargas committed
111
			  unsigned int nsaid_permissions);
Antonio Nino Diaz's avatar
Antonio Nino Diaz committed
112
void tzc400_set_action(unsigned int action);
113
114
void tzc400_enable_filters(void);
void tzc400_disable_filters(void);
115
int tzc400_it_handler(void);
Harry Liebel's avatar
Harry Liebel committed
116

117
118
119
120
121
122
static inline void tzc_init(uintptr_t base)
{
	tzc400_init(base);
}

static inline void tzc_configure_region0(
Antonio Nino Diaz's avatar
Antonio Nino Diaz committed
123
			unsigned int sec_attr,
124
125
126
127
128
129
130
			unsigned int ns_device_access)
{
	tzc400_configure_region0(sec_attr, ns_device_access);
}

static inline void tzc_configure_region(
			  unsigned int filters,
Antonio Nino Diaz's avatar
Antonio Nino Diaz committed
131
			  unsigned int region,
132
133
			  unsigned long long region_base,
			  unsigned long long region_top,
Antonio Nino Diaz's avatar
Antonio Nino Diaz committed
134
			  unsigned int sec_attr,
135
136
137
138
139
140
			  unsigned int ns_device_access)
{
	tzc400_configure_region(filters, region, region_base,
			region_top, sec_attr, ns_device_access);
}

Antonio Nino Diaz's avatar
Antonio Nino Diaz committed
141
static inline void tzc_set_action(unsigned int action)
142
143
144
145
146
147
148
149
150
151
152
153
154
155
{
	tzc400_set_action(action);
}


static inline void tzc_enable_filters(void)
{
	tzc400_enable_filters();
}

static inline void tzc_disable_filters(void)
{
	tzc400_disable_filters();
}
Harry Liebel's avatar
Harry Liebel committed
156

157
#endif /* __ASSEMBLER__ */
Harry Liebel's avatar
Harry Liebel committed
158

Antonio Nino Diaz's avatar
Antonio Nino Diaz committed
159
#endif /* TZC400_H */