forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 072de836f53be56a70cecf70b43ae43b7ce17376
kernel/drivers/irqchip/irq-gic-common.c
....@@ -1,17 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * 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/>.
154 */
165
176 #include <linux/interrupt.h>
....@@ -20,6 +9,10 @@
209 #include <linux/irqchip/arm-gic.h>
2110
2211 #include "irq-gic-common.h"
12
+
13
+#ifdef CONFIG_ROCKCHIP_AMP
14
+#include <soc/rockchip/rockchip_amp.h>
15
+#endif
2316
2417 static DEFINE_RAW_SPINLOCK(irq_controller_lock);
2518
....@@ -36,10 +29,24 @@
3629 gic_kvm_info = info;
3730 }
3831
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 (!of_device_is_compatible(np, quirks->compatible))
37
+ continue;
38
+ if (quirks->init(data))
39
+ pr_info("GIC: enabling workaround for %s\n",
40
+ quirks->desc);
41
+ }
42
+}
43
+
3944 void gic_enable_quirks(u32 iidr, const struct gic_quirk *quirks,
4045 void *data)
4146 {
4247 for (; quirks->desc; quirks++) {
48
+ if (quirks->compatible)
49
+ continue;
4350 if (quirks->iidr != (quirks->mask & iidr))
4451 continue;
4552 if (quirks->init(data))
....@@ -62,7 +69,7 @@
6269 * for "irq", depending on "type".
6370 */
6471 raw_spin_lock_irqsave(&irq_controller_lock, flags);
65
- val = oldval = readl_relaxed(base + GIC_DIST_CONFIG + confoff);
72
+ val = oldval = readl_relaxed(base + confoff);
6673 if (type & IRQ_TYPE_LEVEL_MASK)
6774 val &= ~confmask;
6875 else if (type & IRQ_TYPE_EDGE_BOTH)
....@@ -82,14 +89,10 @@
8289 * does not allow us to set the configuration or we are in a
8390 * non-secure mode, and hence it may not be catastrophic.
8491 */
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
- }
92
+ writel_relaxed(val, base + confoff);
93
+ if (readl_relaxed(base + confoff) != val)
94
+ ret = -EINVAL;
95
+
9396 raw_spin_unlock_irqrestore(&irq_controller_lock, flags);
9497
9598 if (sync_access)
....@@ -113,8 +116,25 @@
113116 /*
114117 * Set priority on all global interrupts.
115118 */
119
+#ifdef CONFIG_ROCKCHIP_AMP
120
+ for (i = 32; i < gic_irqs; i += 4) {
121
+ u32 amp_pri, j;
122
+
123
+ amp_pri = 0;
124
+ for (j = 0; j < 4; j++) {
125
+ if (rockchip_amp_check_amp_irq(i + j)) {
126
+ amp_pri |= rockchip_amp_get_irq_prio(i + j) <<
127
+ (j * 8);
128
+ } else {
129
+ amp_pri |= GICD_INT_DEF_PRI << (j * 8);
130
+ }
131
+ }
132
+ writel_relaxed(amp_pri, base + GIC_DIST_PRI + i);
133
+ }
134
+#else
116135 for (i = 32; i < gic_irqs; i += 4)
117136 writel_relaxed(GICD_INT_DEF_PRI_X4, base + GIC_DIST_PRI + i);
137
+#endif
118138
119139 /*
120140 * Deactivate and disable all SPIs. Leave the PPI and SGIs
....@@ -131,23 +151,25 @@
131151 sync_access();
132152 }
133153
134
-void gic_cpu_config(void __iomem *base, void (*sync_access)(void))
154
+void gic_cpu_config(void __iomem *base, int nr, void (*sync_access)(void))
135155 {
136156 int i;
137157
138158 /*
139159 * 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.
160
+ * private interrupts. Make sure everything is deactivated.
142161 */
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);
162
+ for (i = 0; i < nr; i += 32) {
163
+ writel_relaxed(GICD_INT_EN_CLR_X32,
164
+ base + GIC_DIST_ACTIVE_CLEAR + i / 8);
165
+ writel_relaxed(GICD_INT_EN_CLR_X32,
166
+ base + GIC_DIST_ENABLE_CLEAR + i / 8);
167
+ }
146168
147169 /*
148170 * Set priority on PPI and SGI interrupts
149171 */
150
- for (i = 0; i < 32; i += 4)
172
+ for (i = 0; i < nr; i += 4)
151173 writel_relaxed(GICD_INT_DEF_PRI_X4,
152174 base + GIC_DIST_PRI + i * 4 / 4);
153175