.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (C) 2002 ARM Limited, All Rights Reserved. |
---|
3 | | - * |
---|
4 | | - * This program is free software; you can redistribute it and/or modify |
---|
5 | | - * it under the terms of the GNU General Public License version 2 as |
---|
6 | | - * published by the Free Software Foundation. |
---|
7 | | - * |
---|
8 | | - * This program is distributed in the hope that it will be useful, |
---|
9 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
10 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
11 | | - * GNU General Public License for more details. |
---|
12 | | - * |
---|
13 | | - * You should have received a copy of the GNU General Public License |
---|
14 | | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
15 | 4 | */ |
---|
16 | 5 | |
---|
17 | 6 | #include <linux/interrupt.h> |
---|
.. | .. |
---|
20 | 9 | #include <linux/irqchip/arm-gic.h> |
---|
21 | 10 | |
---|
22 | 11 | #include "irq-gic-common.h" |
---|
| 12 | + |
---|
| 13 | +#ifdef CONFIG_ROCKCHIP_AMP |
---|
| 14 | +#include <soc/rockchip/rockchip_amp.h> |
---|
| 15 | +#endif |
---|
23 | 16 | |
---|
24 | 17 | static DEFINE_RAW_SPINLOCK(irq_controller_lock); |
---|
25 | 18 | |
---|
.. | .. |
---|
36 | 29 | gic_kvm_info = info; |
---|
37 | 30 | } |
---|
38 | 31 | |
---|
| 32 | +void gic_enable_of_quirks(const struct device_node *np, |
---|
| 33 | + const struct gic_quirk *quirks, void *data) |
---|
| 34 | +{ |
---|
| 35 | + for (; quirks->desc; quirks++) { |
---|
| 36 | + if (!quirks->compatible && !quirks->property) |
---|
| 37 | + continue; |
---|
| 38 | + if (quirks->compatible && |
---|
| 39 | + !of_device_is_compatible(np, quirks->compatible)) |
---|
| 40 | + continue; |
---|
| 41 | + if (quirks->property && |
---|
| 42 | + !of_property_read_bool(np, quirks->property)) |
---|
| 43 | + continue; |
---|
| 44 | + if (quirks->init(data)) |
---|
| 45 | + pr_info("GIC: enabling workaround for %s\n", |
---|
| 46 | + quirks->desc); |
---|
| 47 | + } |
---|
| 48 | +} |
---|
| 49 | + |
---|
39 | 50 | void gic_enable_quirks(u32 iidr, const struct gic_quirk *quirks, |
---|
40 | 51 | void *data) |
---|
41 | 52 | { |
---|
42 | 53 | for (; quirks->desc; quirks++) { |
---|
| 54 | + if (quirks->compatible || quirks->property) |
---|
| 55 | + continue; |
---|
43 | 56 | if (quirks->iidr != (quirks->mask & iidr)) |
---|
44 | 57 | continue; |
---|
45 | 58 | if (quirks->init(data)) |
---|
.. | .. |
---|
62 | 75 | * for "irq", depending on "type". |
---|
63 | 76 | */ |
---|
64 | 77 | raw_spin_lock_irqsave(&irq_controller_lock, flags); |
---|
65 | | - val = oldval = readl_relaxed(base + GIC_DIST_CONFIG + confoff); |
---|
| 78 | + val = oldval = readl_relaxed(base + confoff); |
---|
66 | 79 | if (type & IRQ_TYPE_LEVEL_MASK) |
---|
67 | 80 | val &= ~confmask; |
---|
68 | 81 | else if (type & IRQ_TYPE_EDGE_BOTH) |
---|
.. | .. |
---|
82 | 95 | * does not allow us to set the configuration or we are in a |
---|
83 | 96 | * non-secure mode, and hence it may not be catastrophic. |
---|
84 | 97 | */ |
---|
85 | | - writel_relaxed(val, base + GIC_DIST_CONFIG + confoff); |
---|
86 | | - if (readl_relaxed(base + GIC_DIST_CONFIG + confoff) != val) { |
---|
87 | | - if (WARN_ON(irq >= 32)) |
---|
88 | | - ret = -EINVAL; |
---|
89 | | - else |
---|
90 | | - pr_warn("GIC: PPI%d is secure or misconfigured\n", |
---|
91 | | - irq - 16); |
---|
92 | | - } |
---|
| 98 | + writel_relaxed(val, base + confoff); |
---|
| 99 | + if (readl_relaxed(base + confoff) != val) |
---|
| 100 | + ret = -EINVAL; |
---|
| 101 | + |
---|
93 | 102 | raw_spin_unlock_irqrestore(&irq_controller_lock, flags); |
---|
94 | 103 | |
---|
95 | 104 | if (sync_access) |
---|
.. | .. |
---|
113 | 122 | /* |
---|
114 | 123 | * Set priority on all global interrupts. |
---|
115 | 124 | */ |
---|
| 125 | +#ifdef CONFIG_ROCKCHIP_AMP |
---|
| 126 | + for (i = 32; i < gic_irqs; i += 4) { |
---|
| 127 | + u32 amp_pri, j; |
---|
| 128 | + |
---|
| 129 | + amp_pri = 0; |
---|
| 130 | + for (j = 0; j < 4; j++) { |
---|
| 131 | + if (rockchip_amp_need_init_amp_irq(i + j)) { |
---|
| 132 | + amp_pri |= rockchip_amp_get_irq_prio(i + j) << |
---|
| 133 | + (j * 8); |
---|
| 134 | + } else { |
---|
| 135 | + amp_pri |= GICD_INT_DEF_PRI << (j * 8); |
---|
| 136 | + } |
---|
| 137 | + } |
---|
| 138 | + writel_relaxed(amp_pri, base + GIC_DIST_PRI + i); |
---|
| 139 | + } |
---|
| 140 | +#else |
---|
116 | 141 | for (i = 32; i < gic_irqs; i += 4) |
---|
117 | 142 | writel_relaxed(GICD_INT_DEF_PRI_X4, base + GIC_DIST_PRI + i); |
---|
| 143 | +#endif |
---|
118 | 144 | |
---|
119 | 145 | /* |
---|
120 | 146 | * Deactivate and disable all SPIs. Leave the PPI and SGIs |
---|
.. | .. |
---|
131 | 157 | sync_access(); |
---|
132 | 158 | } |
---|
133 | 159 | |
---|
134 | | -void gic_cpu_config(void __iomem *base, void (*sync_access)(void)) |
---|
| 160 | +void gic_cpu_config(void __iomem *base, int nr, void (*sync_access)(void)) |
---|
135 | 161 | { |
---|
136 | 162 | int i; |
---|
137 | 163 | |
---|
138 | 164 | /* |
---|
139 | 165 | * Deal with the banked PPI and SGI interrupts - disable all |
---|
140 | | - * PPI interrupts, ensure all SGI interrupts are enabled. |
---|
141 | | - * Make sure everything is deactivated. |
---|
| 166 | + * private interrupts. Make sure everything is deactivated. |
---|
142 | 167 | */ |
---|
143 | | - writel_relaxed(GICD_INT_EN_CLR_X32, base + GIC_DIST_ACTIVE_CLEAR); |
---|
144 | | - writel_relaxed(GICD_INT_EN_CLR_PPI, base + GIC_DIST_ENABLE_CLEAR); |
---|
145 | | - writel_relaxed(GICD_INT_EN_SET_SGI, base + GIC_DIST_ENABLE_SET); |
---|
| 168 | + for (i = 0; i < nr; i += 32) { |
---|
| 169 | + writel_relaxed(GICD_INT_EN_CLR_X32, |
---|
| 170 | + base + GIC_DIST_ACTIVE_CLEAR + i / 8); |
---|
| 171 | + writel_relaxed(GICD_INT_EN_CLR_X32, |
---|
| 172 | + base + GIC_DIST_ENABLE_CLEAR + i / 8); |
---|
| 173 | + } |
---|
146 | 174 | |
---|
147 | 175 | /* |
---|
148 | 176 | * Set priority on PPI and SGI interrupts |
---|
149 | 177 | */ |
---|
150 | | - for (i = 0; i < 32; i += 4) |
---|
| 178 | + for (i = 0; i < nr; i += 4) |
---|
151 | 179 | writel_relaxed(GICD_INT_DEF_PRI_X4, |
---|
152 | 180 | base + GIC_DIST_PRI + i * 4 / 4); |
---|
153 | 181 | |
---|