blob: a537dcfeeb91151962953f80da61693e1f6a70ba [file] [log] [blame]
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +02001/*
2 * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef __ARCH_H__
8#define __ARCH_H__
9
10#include <utils_def.h>
11
12/*******************************************************************************
13 * MIDR bit definitions
14 ******************************************************************************/
15#define MIDR_IMPL_MASK U(0xff)
16#define MIDR_IMPL_SHIFT U(24)
17#define MIDR_VAR_SHIFT U(20)
18#define MIDR_VAR_BITS U(4)
19#define MIDR_REV_SHIFT U(0)
20#define MIDR_REV_BITS U(4)
21#define MIDR_PN_MASK U(0xfff)
22#define MIDR_PN_SHIFT U(4)
23
24/*******************************************************************************
25 * MPIDR macros
26 ******************************************************************************/
27#define MPIDR_MT_MASK (U(1) << 24)
28#define MPIDR_CPU_MASK MPIDR_AFFLVL_MASK
29#define MPIDR_CLUSTER_MASK (MPIDR_AFFLVL_MASK << MPIDR_AFFINITY_BITS)
30#define MPIDR_AFFINITY_BITS U(8)
31#define MPIDR_AFFLVL_MASK U(0xff)
32#define MPIDR_AFFLVL_SHIFT U(3)
33#define MPIDR_AFF0_SHIFT U(0)
34#define MPIDR_AFF1_SHIFT U(8)
35#define MPIDR_AFF2_SHIFT U(16)
36#define MPIDR_AFF_SHIFT(_n) MPIDR_AFF##_n##_SHIFT
37#define MPIDR_AFFINITY_MASK U(0x00ffffff)
38#define MPIDR_AFFLVL0 U(0)
39#define MPIDR_AFFLVL1 U(1)
40#define MPIDR_AFFLVL2 U(2)
41#define MPIDR_AFFLVL(_n) MPIDR_AFFLVL##_n
42
43#define MPIDR_AFFLVL0_VAL(mpidr) \
44 (((mpidr) >> MPIDR_AFF0_SHIFT) & MPIDR_AFFLVL_MASK)
45#define MPIDR_AFFLVL1_VAL(mpidr) \
46 (((mpidr) >> MPIDR_AFF1_SHIFT) & MPIDR_AFFLVL_MASK)
47#define MPIDR_AFFLVL2_VAL(mpidr) \
48 (((mpidr) >> MPIDR_AFF2_SHIFT) & MPIDR_AFFLVL_MASK)
49
50#define MPIDR_AFF_ID(mpid, n) \
51 (((mpid) >> MPIDR_AFF_SHIFT(n)) & MPIDR_AFFLVL_MASK)
52
53#define MPIDR_CLUSTER_ID(mpid) MPIDR_AFF_ID(mpid, 1)
54#define MPIDR_CPU_ID(mpid) MPIDR_AFF_ID(mpid, 0)
55
56/* Constant to highlight the assumption that MPIDR allocation starts from 0 */
57#define FIRST_MPIDR U(0)
58
59#define MPID_MASK (MPIDR_MT_MASK |\
60 (MPIDR_AFFLVL_MASK << MPIDR_AFF2_SHIFT)|\
61 (MPIDR_AFFLVL_MASK << MPIDR_AFF1_SHIFT)|\
62 (MPIDR_AFFLVL_MASK << MPIDR_AFF0_SHIFT))
63
64/*
65 * An invalid MPID. This value can be used by functions that return an MPID to
66 * indicate an error.
67 */
68#define INVALID_MPID U(0xFFFFFFFF)
69
70/*
71 * The MPIDR_MAX_AFFLVL count starts from 0. Take care to
72 * add one while using this macro to define array sizes.
73 */
74#define MPIDR_MAX_AFFLVL U(2)
75
76/* Data Cache set/way op type defines */
77#define DC_OP_ISW U(0x0)
78#define DC_OP_CISW U(0x1)
79#define DC_OP_CSW U(0x2)
80
81/*******************************************************************************
82 * Generic timer memory mapped registers & offsets
83 ******************************************************************************/
84#define CNTCR_OFF U(0x000)
85#define CNTFID_OFF U(0x020)
86
87#define CNTCR_EN (U(1) << 0)
88#define CNTCR_HDBG (U(1) << 1)
89#define CNTCR_FCREQ(x) ((x) << 8)
90
91/*******************************************************************************
92 * System register bit definitions
93 ******************************************************************************/
94/* CLIDR definitions */
95#define LOUIS_SHIFT U(21)
96#define LOC_SHIFT U(24)
97#define CLIDR_FIELD_WIDTH U(3)
98
99/* CSSELR definitions */
100#define LEVEL_SHIFT U(1)
101
102/* ID_PFR0 definitions */
103#define ID_PFR0_AMU_SHIFT U(20)
104#define ID_PFR0_AMU_LENGTH U(4)
105#define ID_PFR0_AMU_MASK U(0xf)
106
107/* ID_PFR1 definitions */
108#define ID_PFR1_VIRTEXT_SHIFT U(12)
109#define ID_PFR1_VIRTEXT_MASK U(0xf)
110#define GET_VIRT_EXT(id) (((id) >> ID_PFR1_VIRTEXT_SHIFT) \
111 & ID_PFR1_VIRTEXT_MASK)
112#define ID_PFR1_GIC_SHIFT U(28)
113#define ID_PFR1_GIC_MASK U(0xf)
114
115/* SCTLR definitions */
116#define SCTLR_RES1 ((U(1) << 23) | (U(1) << 22) | (U(1) << 11) | \
117 (U(1) << 4) | (U(1) << 3) | SCTLR_CP15BEN_BIT \
118 | SCTLR_NTWI_BIT | SCTLR_NTWE_BIT)
119#define SCTLR_M_BIT (U(1) << 0)
120#define SCTLR_A_BIT (U(1) << 1)
121#define SCTLR_C_BIT (U(1) << 2)
122#define SCTLR_CP15BEN_BIT (U(1) << 5)
123#define SCTLR_ITD_BIT (U(1) << 7)
124#define SCTLR_Z_BIT (U(1) << 11)
125#define SCTLR_I_BIT (U(1) << 12)
126#define SCTLR_V_BIT (U(1) << 13)
127#define SCTLR_RR_BIT (U(1) << 14)
128#define SCTLR_NTWI_BIT (U(1) << 16)
129#define SCTLR_NTWE_BIT (U(1) << 18)
130#define SCTLR_WXN_BIT (U(1) << 19)
131#define SCTLR_UWXN_BIT (U(1) << 20)
132#define SCTLR_EE_BIT (U(1) << 25)
133#define SCTLR_TRE_BIT (U(1) << 28)
134#define SCTLR_AFE_BIT (U(1) << 29)
135#define SCTLR_TE_BIT (U(1) << 30)
136
137/* HSCTLR definitions */
138#define HSCTLR_RES1 ((U(1) << 29) | (U(1) << 28) | (U(1) << 23) | \
139 (U(1) << 22) | (U(1) << 18) | (U(1) << 16) | \
140 (U(1) << 11) | (U(1) << 4) | (U(1) << 3) | \
141 HSCTLR_CP15BEN_BIT)
142#define HSCTLR_M_BIT (U(1) << 0)
143#define HSCTLR_A_BIT (U(1) << 1)
144#define HSCTLR_C_BIT (U(1) << 2)
145#define HSCTLR_CP15BEN_BIT (U(1) << 5)
146#define HSCTLR_ITD_BIT (U(1) << 7)
147#define HSCTLR_SED_BIT (U(1) << 8)
148#define HSCTLR_I_BIT (U(1) << 12)
149#define HSCTLR_WXN_BIT (U(1) << 19)
150#define HSCTLR_EE_BIT (U(1) << 25)
151#define HSCTLR_TE_BIT (U(1) << 30)
152
153/* CPACR definitions */
154#define CPACR_FPEN(x) ((x) << 20)
155#define CPACR_FP_TRAP_PL0 U(0x1)
156#define CPACR_FP_TRAP_ALL U(0x2)
157#define CPACR_FP_TRAP_NONE U(0x3)
158
159/* SCR definitions */
160#define SCR_TWE_BIT (U(1) << 13)
161#define SCR_TWI_BIT (U(1) << 12)
162#define SCR_SIF_BIT (U(1) << 9)
163#define SCR_HCE_BIT (U(1) << 8)
164#define SCR_SCD_BIT (U(1) << 7)
165#define SCR_NET_BIT (U(1) << 6)
166#define SCR_AW_BIT (U(1) << 5)
167#define SCR_FW_BIT (U(1) << 4)
168#define SCR_EA_BIT (U(1) << 3)
169#define SCR_FIQ_BIT (U(1) << 2)
170#define SCR_IRQ_BIT (U(1) << 1)
171#define SCR_NS_BIT (U(1) << 0)
172#define SCR_VALID_BIT_MASK U(0x33ff)
173#define SCR_RESET_VAL U(0x0)
174
175#define GET_NS_BIT(scr) ((scr) & SCR_NS_BIT)
176
177/* HCR definitions */
178#define HCR_TGE_BIT (U(1) << 27)
179#define HCR_AMO_BIT (U(1) << 5)
180#define HCR_IMO_BIT (U(1) << 4)
181#define HCR_FMO_BIT (U(1) << 3)
182#define HCR_RESET_VAL U(0x0)
183
184/* CNTHCTL definitions */
185#define CNTHCTL_RESET_VAL U(0x0)
186#define EVNTEN_BIT (U(1) << 2)
187#define PL1PCEN_BIT (U(1) << 1)
188#define PL1PCTEN_BIT (U(1) << 0)
189
190/* CNTKCTL definitions */
191#define PL0PTEN_BIT (U(1) << 9)
192#define PL0VTEN_BIT (U(1) << 8)
193#define PL0PCTEN_BIT (U(1) << 0)
194#define PL0VCTEN_BIT (U(1) << 1)
195#define EVNTEN_BIT (U(1) << 2)
196#define EVNTDIR_BIT (U(1) << 3)
197#define EVNTI_SHIFT U(4)
198#define EVNTI_MASK U(0xf)
199
200/* HCPTR definitions */
201#define HCPTR_RES1 ((U(1) << 13) | (U(1) << 12) | U(0x3ff))
202#define TCPAC_BIT (U(1) << 31)
203#define TAM_BIT (U(1) << 30)
204#define TTA_BIT (U(1) << 20)
205#define TCP11_BIT (U(1) << 11)
206#define TCP10_BIT (U(1) << 10)
207#define HCPTR_RESET_VAL HCPTR_RES1
208
209/* NASCR definitions */
210#define NSASEDIS_BIT (U(1) << 15)
211#define NSTRCDIS_BIT (U(1) << 20)
212#define NSACR_CP11_BIT (U(1) << 11)
213#define NSACR_CP10_BIT (U(1) << 10)
214#define NSACR_IMP_DEF_MASK (U(0x7) << 16)
215#define NSACR_ENABLE_FP_ACCESS (NSACR_CP11_BIT | NSACR_CP10_BIT)
216#define NSACR_RESET_VAL U(0x0)
217
218/* CPACR definitions */
219#define ASEDIS_BIT (U(1) << 31)
220#define TRCDIS_BIT (U(1) << 28)
221#define CPACR_CP11_SHIFT U(22)
222#define CPACR_CP10_SHIFT U(20)
223#define CPACR_ENABLE_FP_ACCESS ((U(0x3) << CPACR_CP11_SHIFT) |\
224 (U(0x3) << CPACR_CP10_SHIFT))
225#define CPACR_RESET_VAL U(0x0)
226
227/* FPEXC definitions */
228#define FPEXC_RES1 ((U(1) << 10) | (U(1) << 9) | (U(1) << 8))
229#define FPEXC_EN_BIT (U(1) << 30)
230#define FPEXC_RESET_VAL FPEXC_RES1
231
232/* SPSR/CPSR definitions */
233#define SPSR_FIQ_BIT (U(1) << 0)
234#define SPSR_IRQ_BIT (U(1) << 1)
235#define SPSR_ABT_BIT (U(1) << 2)
236#define SPSR_AIF_SHIFT U(6)
237#define SPSR_AIF_MASK U(0x7)
238
239#define SPSR_E_SHIFT U(9)
240#define SPSR_E_MASK U(0x1)
241#define SPSR_E_LITTLE U(0)
242#define SPSR_E_BIG U(1)
243
244#define SPSR_T_SHIFT U(5)
245#define SPSR_T_MASK U(0x1)
246#define SPSR_T_ARM U(0)
247#define SPSR_T_THUMB U(1)
248
249#define SPSR_MODE_SHIFT U(0)
250#define SPSR_MODE_MASK U(0x7)
251
252#define DISABLE_ALL_EXCEPTIONS \
253 (SPSR_FIQ_BIT | SPSR_IRQ_BIT | SPSR_ABT_BIT)
254
255/*
256 * TTBCR definitions
257 */
258/* The translation tables library uses the long descriptor format */
259#define TTBCR_EAE_BIT (U(1) << 31)
260
261#define TTBCR_SH1_NON_SHAREABLE (U(0x0) << 28)
262#define TTBCR_SH1_OUTER_SHAREABLE (U(0x2) << 28)
263#define TTBCR_SH1_INNER_SHAREABLE (U(0x3) << 28)
264
265#define TTBCR_RGN1_OUTER_NC (U(0x0) << 26)
266#define TTBCR_RGN1_OUTER_WBA (U(0x1) << 26)
267#define TTBCR_RGN1_OUTER_WT (U(0x2) << 26)
268#define TTBCR_RGN1_OUTER_WBNA (U(0x3) << 26)
269
270#define TTBCR_RGN1_INNER_NC (U(0x0) << 24)
271#define TTBCR_RGN1_INNER_WBA (U(0x1) << 24)
272#define TTBCR_RGN1_INNER_WT (U(0x2) << 24)
273#define TTBCR_RGN1_INNER_WBNA (U(0x3) << 24)
274
275#define TTBCR_EPD1_BIT (U(1) << 23)
276#define TTBCR_A1_BIT (U(1) << 22)
277
278#define TTBCR_T1SZ_SHIFT U(16)
279#define TTBCR_T1SZ_MASK U(0x7)
280#define TTBCR_TxSZ_MIN U(0)
281#define TTBCR_TxSZ_MAX U(7)
282
283#define TTBCR_SH0_NON_SHAREABLE (U(0x0) << 12)
284#define TTBCR_SH0_OUTER_SHAREABLE (U(0x2) << 12)
285#define TTBCR_SH0_INNER_SHAREABLE (U(0x3) << 12)
286
287#define TTBCR_RGN0_OUTER_NC (U(0x0) << 10)
288#define TTBCR_RGN0_OUTER_WBA (U(0x1) << 10)
289#define TTBCR_RGN0_OUTER_WT (U(0x2) << 10)
290#define TTBCR_RGN0_OUTER_WBNA (U(0x3) << 10)
291
292#define TTBCR_RGN0_INNER_NC (U(0x0) << 8)
293#define TTBCR_RGN0_INNER_WBA (U(0x1) << 8)
294#define TTBCR_RGN0_INNER_WT (U(0x2) << 8)
295#define TTBCR_RGN0_INNER_WBNA (U(0x3) << 8)
296
297#define TTBCR_EPD0_BIT (U(1) << 7)
298#define TTBCR_T0SZ_SHIFT U(0)
299#define TTBCR_T0SZ_MASK U(0x7)
300
301/*
302 * HTCR definitions
303 */
304#define HTCR_RES1 ((1 << 31) | (1 << 23))
305
306#define HTCR_SH0_NON_SHAREABLE (0x0 << 12)
307#define HTCR_SH0_OUTER_SHAREABLE (0x2 << 12)
308#define HTCR_SH0_INNER_SHAREABLE (0x3 << 12)
309
310#define HTCR_RGN0_OUTER_NC (0x0 << 10)
311#define HTCR_RGN0_OUTER_WBA (0x1 << 10)
312#define HTCR_RGN0_OUTER_WT (0x2 << 10)
313#define HTCR_RGN0_OUTER_WBNA (0x3 << 10)
314
315#define HTCR_RGN0_INNER_NC (0x0 << 8)
316#define HTCR_RGN0_INNER_WBA (0x1 << 8)
317#define HTCR_RGN0_INNER_WT (0x2 << 8)
318#define HTCR_RGN0_INNER_WBNA (0x3 << 8)
319
320#define HTCR_T0SZ_SHIFT 0
321#define HTCR_T0SZ_MASK (0x7)
322
323#define MODE_RW_SHIFT U(0x4)
324#define MODE_RW_MASK U(0x1)
325#define MODE_RW_32 U(0x1)
326
327#define MODE32_SHIFT U(0)
328#define MODE32_MASK U(0x1f)
329#define MODE32_usr U(0x10)
330#define MODE32_fiq U(0x11)
331#define MODE32_irq U(0x12)
332#define MODE32_svc U(0x13)
333#define MODE32_mon U(0x16)
334#define MODE32_abt U(0x17)
335#define MODE32_hyp U(0x1a)
336#define MODE32_und U(0x1b)
337#define MODE32_sys U(0x1f)
338
339#define GET_M32(mode) (((mode) >> MODE32_SHIFT) & MODE32_MASK)
340
341#define SPSR_MODE32(mode, isa, endian, aif) \
342 (MODE_RW_32 << MODE_RW_SHIFT | \
343 ((mode) & MODE32_MASK) << MODE32_SHIFT | \
344 ((isa) & SPSR_T_MASK) << SPSR_T_SHIFT | \
345 ((endian) & SPSR_E_MASK) << SPSR_E_SHIFT | \
346 ((aif) & SPSR_AIF_MASK) << SPSR_AIF_SHIFT)
347
348/*
349 * TTBR definitions
350 */
351#define TTBR_CNP_BIT U(0x1)
352
353/*******************************************************************************
354 * Definitions of register offsets, fields and macros for CPU system
355 * instructions.
356 ******************************************************************************/
357
358#define TLBI_ADDR_SHIFT U(0)
359#define TLBI_ADDR_MASK U(0xFFFFF000)
360#define TLBI_ADDR(x) (((x) >> TLBI_ADDR_SHIFT) & TLBI_ADDR_MASK)
361
362/*******************************************************************************
363 * Definitions of register offsets and fields in the CNTBaseN Frame of the
364 * system level implementation of the Generic Timer.
365 ******************************************************************************/
366/* Physical Count register. */
367#define CNTPCT_LO 0x0
368/* Counter Frequency register. */
369#define CNTBASEN_CNTFRQ 0x10
370/* Physical Timer CompareValue register. */
371#define CNTP_CVAL_LO 0x20
372/* Physical Timer Control register. */
373#define CNTP_CTL 0x2c
374
375/* Physical timer control register bit fields shifts and masks */
376#define CNTP_CTL_ENABLE_SHIFT 0
377#define CNTP_CTL_IMASK_SHIFT 1
378#define CNTP_CTL_ISTATUS_SHIFT 2
379
380#define CNTP_CTL_ENABLE_MASK 1
381#define CNTP_CTL_IMASK_MASK 1
382#define CNTP_CTL_ISTATUS_MASK 1
383
384#define get_cntp_ctl_enable(x) ((x >> CNTP_CTL_ENABLE_SHIFT) & \
385 CNTP_CTL_ENABLE_MASK)
386#define get_cntp_ctl_imask(x) ((x >> CNTP_CTL_IMASK_SHIFT) & \
387 CNTP_CTL_IMASK_MASK)
388#define get_cntp_ctl_istatus(x) ((x >> CNTP_CTL_ISTATUS_SHIFT) & \
389 CNTP_CTL_ISTATUS_MASK)
390
391#define set_cntp_ctl_enable(x) (x |= 1 << CNTP_CTL_ENABLE_SHIFT)
392#define set_cntp_ctl_imask(x) (x |= 1 << CNTP_CTL_IMASK_SHIFT)
393
394#define clr_cntp_ctl_enable(x) (x &= ~(1 << CNTP_CTL_ENABLE_SHIFT))
395#define clr_cntp_ctl_imask(x) (x &= ~(1 << CNTP_CTL_IMASK_SHIFT))
396
397/* MAIR macros */
398#define MAIR0_ATTR_SET(attr, index) ((attr) << ((index) << U(3)))
399#define MAIR1_ATTR_SET(attr, index) ((attr) << (((index) - U(3)) << U(3)))
400
401/* System register defines The format is: coproc, opt1, CRn, CRm, opt2 */
402#define SCR p15, 0, c1, c1, 0
403#define SCTLR p15, 0, c1, c0, 0
404#define MPIDR p15, 0, c0, c0, 5
405#define MIDR p15, 0, c0, c0, 0
406#define HVBAR p15, 4, c12, c0, 0
407#define VBAR p15, 0, c12, c0, 0
408#define MVBAR p15, 0, c12, c0, 1
409#define NSACR p15, 0, c1, c1, 2
410#define CPACR p15, 0, c1, c0, 2
411#define DCCIMVAC p15, 0, c7, c14, 1
412#define DCCMVAC p15, 0, c7, c10, 1
413#define DCIMVAC p15, 0, c7, c6, 1
414#define DCCISW p15, 0, c7, c14, 2
415#define DCCSW p15, 0, c7, c10, 2
416#define DCISW p15, 0, c7, c6, 2
417#define CTR p15, 0, c0, c0, 1
418#define CNTFRQ p15, 0, c14, c0, 0
419#define ID_PFR0 p15, 0, c0, c1, 0
420#define ID_PFR1 p15, 0, c0, c1, 1
421#define MAIR0 p15, 0, c10, c2, 0
422#define MAIR1 p15, 0, c10, c2, 1
423#define TTBCR p15, 0, c2, c0, 2
424#define TTBR0 p15, 0, c2, c0, 0
425#define TTBR1 p15, 0, c2, c0, 1
426#define TLBIALL p15, 0, c8, c7, 0
427#define TLBIALLH p15, 4, c8, c7, 0
428#define TLBIALLIS p15, 0, c8, c3, 0
429#define TLBIMVA p15, 0, c8, c7, 1
430#define TLBIMVAA p15, 0, c8, c7, 3
431#define TLBIMVAAIS p15, 0, c8, c3, 3
432#define TLBIMVAHIS p15, 4, c8, c3, 1
433#define BPIALLIS p15, 0, c7, c1, 6
434#define BPIALL p15, 0, c7, c5, 6
435#define HSCTLR p15, 4, c1, c0, 0
436#define HCR p15, 4, c1, c1, 0
437#define HCPTR p15, 4, c1, c1, 2
438#define CNTHCTL p15, 4, c14, c1, 0
439#define VPIDR p15, 4, c0, c0, 0
440#define VMPIDR p15, 4, c0, c0, 5
441#define ISR p15, 0, c12, c1, 0
442#define CLIDR p15, 1, c0, c0, 1
443#define CSSELR p15, 2, c0, c0, 0
444#define CCSIDR p15, 1, c0, c0, 0
445#define HTCR p15, 4, c2, c0, 2
446#define HMAIR0 p15, 4, c10, c2, 0
447#define CNTHP_CTL p15, 4, c14, c2, 1
448#define CNTHP_TVAL p15, 4, c14, c2, 0
449
450/* GICv3 CPU Interface system register defines. The format is: coproc, opt1, CRn, CRm, opt2 */
451#define ICC_IAR1 p15, 0, c12, c12, 0
452#define ICC_IAR0 p15, 0, c12, c8, 0
453#define ICC_EOIR1 p15, 0, c12, c12, 1
454#define ICC_EOIR0 p15, 0, c12, c8, 1
455#define ICC_HPPIR1 p15, 0, c12, c12, 2
456#define ICC_HPPIR0 p15, 0, c12, c8, 2
457#define ICC_BPR1 p15, 0, c12, c12, 3
458#define ICC_BPR0 p15, 0, c12, c8, 3
459#define ICC_DIR p15, 0, c12, c11, 1
460#define ICC_PMR p15, 0, c4, c6, 0
461#define ICC_RPR p15, 0, c12, c11, 3
462#define ICC_CTLR p15, 0, c12, c12, 4
463#define ICC_MCTLR p15, 6, c12, c12, 4
464#define ICC_SRE p15, 0, c12, c12, 5
465#define ICC_HSRE p15, 4, c12, c9, 5
466#define ICC_MSRE p15, 6, c12, c12, 5
467#define ICC_IGRPEN0 p15, 0, c12, c12, 6
468#define ICC_IGRPEN1 p15, 0, c12, c12, 7
469#define ICC_MGRPEN1 p15, 6, c12, c12, 7
470
471/* 64 bit system register defines The format is: coproc, opt1, CRm */
472#define TTBR0_64 p15, 0, c2
473#define TTBR1_64 p15, 1, c2
474#define CNTVOFF_64 p15, 4, c14
475#define VTTBR_64 p15, 6, c2
476#define CNTPCT_64 p15, 0, c14
477#define HTTBR_64 p15, 4, c2
478#define CNTHP_CVAL_64 p15, 6, c14
479
480/* 64 bit GICv3 CPU Interface system register defines. The format is: coproc, opt1, CRm */
481#define ICC_SGI1R_EL1_64 p15, 0, c12
482#define ICC_ASGI1R_EL1_64 p15, 1, c12
483#define ICC_SGI0R_EL1_64 p15, 2, c12
484
485/*******************************************************************************
486 * Definitions of MAIR encodings for device and normal memory
487 ******************************************************************************/
488/*
489 * MAIR encodings for device memory attributes.
490 */
491#define MAIR_DEV_nGnRnE U(0x0)
492#define MAIR_DEV_nGnRE U(0x4)
493#define MAIR_DEV_nGRE U(0x8)
494#define MAIR_DEV_GRE U(0xc)
495
496/*
497 * MAIR encodings for normal memory attributes.
498 *
499 * Cache Policy
500 * WT: Write Through
501 * WB: Write Back
502 * NC: Non-Cacheable
503 *
504 * Transient Hint
505 * NTR: Non-Transient
506 * TR: Transient
507 *
508 * Allocation Policy
509 * RA: Read Allocate
510 * WA: Write Allocate
511 * RWA: Read and Write Allocate
512 * NA: No Allocation
513 */
514#define MAIR_NORM_WT_TR_WA U(0x1)
515#define MAIR_NORM_WT_TR_RA U(0x2)
516#define MAIR_NORM_WT_TR_RWA U(0x3)
517#define MAIR_NORM_NC U(0x4)
518#define MAIR_NORM_WB_TR_WA U(0x5)
519#define MAIR_NORM_WB_TR_RA U(0x6)
520#define MAIR_NORM_WB_TR_RWA U(0x7)
521#define MAIR_NORM_WT_NTR_NA U(0x8)
522#define MAIR_NORM_WT_NTR_WA U(0x9)
523#define MAIR_NORM_WT_NTR_RA U(0xa)
524#define MAIR_NORM_WT_NTR_RWA U(0xb)
525#define MAIR_NORM_WB_NTR_NA U(0xc)
526#define MAIR_NORM_WB_NTR_WA U(0xd)
527#define MAIR_NORM_WB_NTR_RA U(0xe)
528#define MAIR_NORM_WB_NTR_RWA U(0xf)
529
530#define MAIR_NORM_OUTER_SHIFT U(4)
531
532#define MAKE_MAIR_NORMAL_MEMORY(inner, outer) \
533 ((inner) | ((outer) << MAIR_NORM_OUTER_SHIFT))
534
535/*******************************************************************************
536 * Definitions for system register interface to AMU for ARMv8.4 onwards
537 ******************************************************************************/
538#define AMCR p15, 0, c13, c2, 0
539#define AMCFGR p15, 0, c13, c2, 1
540#define AMCGCR p15, 0, c13, c2, 2
541#define AMUSERENR p15, 0, c13, c2, 3
542#define AMCNTENCLR0 p15, 0, c13, c2, 4
543#define AMCNTENSET0 p15, 0, c13, c2, 5
544#define AMCNTENCLR1 p15, 0, c13, c3, 0
545#define AMCNTENSET1 p15, 0, c13, c3, 1
546
547/* Activity Monitor Group 0 Event Counter Registers */
548#define AMEVCNTR00 p15, 0, c0
549#define AMEVCNTR01 p15, 1, c0
550#define AMEVCNTR02 p15, 2, c0
551#define AMEVCNTR03 p15, 3, c0
552
553/* Activity Monitor Group 0 Event Type Registers */
554#define AMEVTYPER00 p15, 0, c13, c6, 0
555#define AMEVTYPER01 p15, 0, c13, c6, 1
556#define AMEVTYPER02 p15, 0, c13, c6, 2
557#define AMEVTYPER03 p15, 0, c13, c6, 3
558
559/* Activity Monitor Group 1 Event Counter Registers */
560#define AMEVCNTR10 p15, 0, c4
561#define AMEVCNTR11 p15, 1, c4
562#define AMEVCNTR12 p15, 2, c4
563#define AMEVCNTR13 p15, 3, c4
564#define AMEVCNTR14 p15, 4, c4
565#define AMEVCNTR15 p15, 5, c4
566#define AMEVCNTR16 p15, 6, c4
567#define AMEVCNTR17 p15, 7, c4
568#define AMEVCNTR18 p15, 0, c5
569#define AMEVCNTR19 p15, 1, c5
570#define AMEVCNTR1A p15, 2, c5
571#define AMEVCNTR1B p15, 3, c5
572#define AMEVCNTR1C p15, 4, c5
573#define AMEVCNTR1D p15, 5, c5
574#define AMEVCNTR1E p15, 6, c5
575#define AMEVCNTR1F p15, 7, c5
576
577/* Activity Monitor Group 1 Event Type Registers */
578#define AMEVTYPER10 p15, 0, c13, c14, 0
579#define AMEVTYPER11 p15, 0, c13, c14, 1
580#define AMEVTYPER12 p15, 0, c13, c14, 2
581#define AMEVTYPER13 p15, 0, c13, c14, 3
582#define AMEVTYPER14 p15, 0, c13, c14, 4
583#define AMEVTYPER15 p15, 0, c13, c14, 5
584#define AMEVTYPER16 p15, 0, c13, c14, 6
585#define AMEVTYPER17 p15, 0, c13, c14, 7
586#define AMEVTYPER18 p15, 0, c13, c15, 0
587#define AMEVTYPER19 p15, 0, c13, c15, 1
588#define AMEVTYPER1A p15, 0, c13, c15, 2
589#define AMEVTYPER1B p15, 0, c13, c15, 3
590#define AMEVTYPER1C p15, 0, c13, c15, 4
591#define AMEVTYPER1D p15, 0, c13, c15, 5
592#define AMEVTYPER1E p15, 0, c13, c15, 6
593#define AMEVTYPER1F p15, 0, c13, c15, 7
594
595#endif /* __ARCH_H__ */