blob: ac6c9e7013404b29eaf0f3477faa0da02c488c87 [file] [log] [blame]
Bharat Kumar Reddy Gooty436efc02019-12-16 09:09:43 -08001/* SPDX-License-Identifier: GPL-2.0+ */
2/*
3 * Copyright 2019 Broadcom.
4 */
5
6#ifndef __GIC_V3_H__
7#define __GIC_V3_H__
8
9#define GICR_CTLR_ENABLE_LPIS BIT(0)
10#define GICR_CTLR_RWP BIT(3)
11
12#define GICR_TYPER_CPU_NUMBER(r) (((r) >> 8) & 0xffff)
13
14#define GICR_WAKER_PROCESSORSLEEP BIT(1)
15#define GICR_WAKER_CHILDRENASLEEP BIT(2)
16
17#define GIC_BASER_CACHE_NCNB 0ULL
18#define GIC_BASER_CACHE_SAMEASINNER 0ULL
19#define GIC_BASER_CACHE_NC 1ULL
20#define GIC_BASER_CACHE_RAWT 2ULL
21#define GIC_BASER_CACHE_RAWB 3ULL
22#define GIC_BASER_CACHE_WAWT 4ULL
23#define GIC_BASER_CACHE_WAWB 5ULL
24#define GIC_BASER_CACHE_RAWAWT 6ULL
25#define GIC_BASER_CACHE_RAWAWB 7ULL
26#define GIC_BASER_CACHE_MASK 7ULL
27#define GIC_BASER_NONSHAREABLE 0ULL
28#define GIC_BASER_INNERSHAREABLE 1ULL
29#define GIC_BASER_OUTERSHAREABLE 2ULL
30#define GIC_BASER_SHAREABILITY_MASK 3ULL
31
32#define GIC_BASER_CACHEABILITY(reg, inner_outer, type) \
33 (GIC_BASER_CACHE_##type << reg##_##inner_outer##_CACHEABILITY_SHIFT)
34
35#define GIC_BASER_SHAREABILITY(reg, type) \
36 (GIC_BASER_##type << reg##_SHAREABILITY_SHIFT)
37
38/* encode a size field of width @w containing @n - 1 units */
39#define GIC_ENCODE_SZ(n, w) (((unsigned long)(n) - 1) &\
40 GENMASK_ULL(((w) - 1), 0))
41
42#define GICR_PROPBASER_SHAREABILITY_SHIFT (10)
43#define GICR_PROPBASER_INNER_CACHEABILITY_SHIFT (7)
44#define GICR_PROPBASER_OUTER_CACHEABILITY_SHIFT (56)
45#define GICR_PROPBASER_SHAREABILITY_MASK \
46 GIC_BASER_SHAREABILITY(GICR_PROPBASER, SHAREABILITY_MASK)
47#define GICR_PROPBASER_INNER_CACHEABILITY_MASK \
48 GIC_BASER_CACHEABILITY(GICR_PROPBASER, INNER, MASK)
49#define GICR_PROPBASER_OUTER_CACHEABILITY_MASK \
50 GIC_BASER_CACHEABILITY(GICR_PROPBASER, OUTER, MASK)
51#define GICR_PROPBASER_CACHEABILITY_MASK GICR_PROPBASER_INNER_CACHEABILITY_MASK
52
53#define GICR_PROPBASER_INNERSHAREABLE \
54 GIC_BASER_SHAREABILITY(GICR_PROPBASER, INNERSHAREABLE)
55
56#define GICR_PROPBASER_NCNB \
57 GIC_BASER_CACHEABILITY(GICR_PROPBASER, INNER, NCNB)
58#define GICR_PROPBASER_NC \
59 GIC_BASER_CACHEABILITY(GICR_PROPBASER, INNER, NC)
60#define GICR_PROPBASER_RAWT \
61 GIC_BASER_CACHEABILITY(GICR_PROPBASER, INNER, RAWT)
62#define GICR_PROPBASER_RAWB \
63 GIC_BASER_CACHEABILITY(GICR_PROPBASER, INNER, RAWB)
64#define GICR_PROPBASER_WAWT \
65 GIC_BASER_CACHEABILITY(GICR_PROPBASER, INNER, WAWT)
66#define GICR_PROPBASER_WAWB \
67 GIC_BASER_CACHEABILITY(GICR_PROPBASER, INNER, WAWB)
68#define GICR_PROPBASER_RAWAWT \
69 GIC_BASER_CACHEABILITY(GICR_PROPBASER, INNER, RAWAWT)
70#define GICR_PROPBASER_RAWAWB \
71 GIC_BASER_CACHEABILITY(GICR_PROPBASER, INNER, RAWAWB)
72
73#define GICR_PROPBASER_IDBITS_MASK (0x1f)
74#define GICR_PROPBASER_ADDRESS(x) ((x) & GENMASK_ULL(51, 12))
75#define GICR_PENDBASER_ADDRESS(x) ((x) & GENMASK_ULL(51, 16))
76
77#define GICR_PENDBASER_SHAREABILITY_SHIFT (10)
78#define GICR_PENDBASER_INNER_CACHEABILITY_SHIFT (7)
79#define GICR_PENDBASER_OUTER_CACHEABILITY_SHIFT (56)
80#define GICR_PENDBASER_SHAREABILITY_MASK \
81 GIC_BASER_SHAREABILITY(GICR_PENDBASER, SHAREABILITY_MASK)
82#define GICR_PENDBASER_INNER_CACHEABILITY_MASK \
83 GIC_BASER_CACHEABILITY(GICR_PENDBASER, INNER, MASK)
84#define GICR_PENDBASER_OUTER_CACHEABILITY_MASK \
85 GIC_BASER_CACHEABILITY(GICR_PENDBASER, OUTER, MASK)
86#define GICR_PENDBASER_CACHEABILITY_MASK \
87 GICR_PENDBASER_INNER_CACHEABILITY_MASK
88
89#define GICR_PENDBASER_INNERSHAREABLE \
90 GIC_BASER_SHAREABILITY(GICR_PENDBASER, INNERSHAREABLE)
91
92#define GICR_PENDBASER_NCNB \
93 GIC_BASER_CACHEABILITY(GICR_PENDBASER, INNER, NCNB)
94#define GICR_PENDBASER_NC \
95 GIC_BASER_CACHEABILITY(GICR_PENDBASER, INNER, NC)
96#define GICR_PENDBASER_RAWT \
97 GIC_BASER_CACHEABILITY(GICR_PENDBASER, INNER, RAWT)
98#define GICR_PENDBASER_RAWB \
99 GIC_BASER_CACHEABILITY(GICR_PENDBASER, INNER, RAWB)
100#define GICR_PENDBASER_WAWT \
101 GIC_BASER_CACHEABILITY(GICR_PENDBASER, INNER, WAWT)
102#define GICR_PENDBASER_WAWB \
103 GIC_BASER_CACHEABILITY(GICR_PENDBASER, INNER, WAWB)
104#define GICR_PENDBASER_RAWAWT \
105 GIC_BASER_CACHEABILITY(GICR_PENDBASER, INNER, RAWAWT)
106#define GICR_PENDBASER_RAWAWB \
107 GIC_BASER_CACHEABILITY(GICR_PENDBASER, INNER, RAWAWB)
108
109#define GICR_PENDBASER_PTZ BIT_ULL(62)
110
111#define ITS_MAX_LPI_NRBITS 16 /* 64K LPIs */
112
113#define GICD_TYPER_ID_BITS(typer) ((((typer) >> 19) & 0x1f) + 1)
114#define GICD_TYPER_NUM_LPIS(typer) ((((typer) >> 11) & 0x1f) + 1)
115#define GICD_TYPER_IRQS(typer) ((((typer) & 0x1f) + 1) * 32)
116
117/* Message based interrupts support */
118#define GICD_TYPER_MBIS BIT(16)
119/* LPI support */
120#define GICD_TYPER_LPIS BIT(17)
121#define GICD_TYPER_RSS BIT(26)
122
123#define GIC_REDISTRIBUTOR_OFFSET 0x20000
124
125#ifdef CONFIG_GIC_V3_ITS
126int gic_lpi_tables_init(u64 base, u32 max_redist);
127#else
128int gic_lpi_tables_init(u64 base, u32 max_redist)
129{
130 return 0;
131}
132#endif /* CONFIG_GIC_V3_ITS */
133
134#endif /* __GIC_V3_H__ */