Skip to content

Commit ecb3c2b

Browse files
committed
Merge tag 'deps-irqchip-gic-3.17' of git://git.infradead.org/users/jcooper/linux
* tag 'deps-irqchip-gic-3.17' of git://git.infradead.org/users/jcooper/linux: irqchip: gic-v3: Initial support for GICv3 irqchip: gic: Move some bits of GICv2 to a library-type file Conflicts: arch/arm64/Kconfig
2 parents 05ac653 + 021f653 commit ecb3c2b

10 files changed

Lines changed: 1065 additions & 56 deletions

File tree

‎arch/arm64/Kconfig‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ config ARM64
1010
select ARM_ARCH_TIMER
1111
select ARM_GIC
1212
select AUDIT_ARCH_COMPAT_GENERIC
13+
select ARM_GIC_V3
1314
select BUILDTIME_EXTABLE_SORT
1415
select CLONE_BACKWARDS
1516
select COMMON_CLK

‎arch/arm64/kernel/head.S‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
#include <linux/linkage.h>
2424
#include <linux/init.h>
25+
#include <linux/irqchip/arm-gic-v3.h>
2526

2627
#include <asm/assembler.h>
2728
#include <asm/ptrace.h>
@@ -289,6 +290,23 @@ CPU_LE( bic x0, x0, #(3 << 24) ) // Clear the EE and E0E bits for EL1
289290
msr cnthctl_el2, x0
290291
msr cntvoff_el2, xzr // Clear virtual offset
291292

293+
#ifdef CONFIG_ARM_GIC_V3
294+
/* GICv3 system register access */
295+
mrs x0, id_aa64pfr0_el1
296+
ubfx x0, x0, #24, #4
297+
cmp x0, #1
298+
b.ne 3f
299+
300+
mrs x0, ICC_SRE_EL2
301+
orr x0, x0, #ICC_SRE_EL2_SRE // Set ICC_SRE_EL2.SRE==1
302+
orr x0, x0, #ICC_SRE_EL2_ENABLE // Set ICC_SRE_EL2.Enable==1
303+
msr ICC_SRE_EL2, x0
304+
isb // Make sure SRE is now set
305+
msr ICH_HCR_EL2, xzr // Reset ICC_HCR_EL2 to defaults
306+
307+
3:
308+
#endif
309+
292310
/* Populate ID registers. */
293311
mrs x0, midr_el1
294312
mrs x1, mpidr_el1

‎arch/arm64/kernel/hyp-stub.S‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#include <linux/init.h>
2121
#include <linux/linkage.h>
22+
#include <linux/irqchip/arm-gic-v3.h>
2223

2324
#include <asm/assembler.h>
2425
#include <asm/ptrace.h>

‎drivers/irqchip/Kconfig‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ config ARM_GIC
1010
config GIC_NON_BANKED
1111
bool
1212

13+
config ARM_GIC_V3
14+
bool
15+
select IRQ_DOMAIN
16+
select MULTI_IRQ_HANDLER
17+
1318
config ARM_NVIC
1419
bool
1520
select IRQ_DOMAIN

‎drivers/irqchip/Makefile‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ obj-$(CONFIG_ORION_IRQCHIP) += irq-orion.o
1515
obj-$(CONFIG_ARCH_SUNXI) += irq-sun4i.o
1616
obj-$(CONFIG_ARCH_SUNXI) += irq-sunxi-nmi.o
1717
obj-$(CONFIG_ARCH_SPEAR3XX) += spear-shirq.o
18-
obj-$(CONFIG_ARM_GIC) += irq-gic.o
18+
obj-$(CONFIG_ARM_GIC) += irq-gic.o irq-gic-common.o
19+
obj-$(CONFIG_ARM_GIC_V3) += irq-gic-v3.o irq-gic-common.o
1920
obj-$(CONFIG_ARM_NVIC) += irq-nvic.o
2021
obj-$(CONFIG_ARM_VIC) += irq-vic.o
2122
obj-$(CONFIG_IMGPDC_IRQ) += irq-imgpdc.o

‎drivers/irqchip/irq-gic-common.c‎

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
/*
2+
* 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+
*/
16+
17+
#include <linux/interrupt.h>
18+
#include <linux/io.h>
19+
#include <linux/irq.h>
20+
#include <linux/irqchip/arm-gic.h>
21+
22+
#include "irq-gic-common.h"
23+
24+
void gic_configure_irq(unsigned int irq, unsigned int type,
25+
void __iomem *base, void (*sync_access)(void))
26+
{
27+
u32 enablemask = 1 << (irq % 32);
28+
u32 enableoff = (irq / 32) * 4;
29+
u32 confmask = 0x2 << ((irq % 16) * 2);
30+
u32 confoff = (irq / 16) * 4;
31+
bool enabled = false;
32+
u32 val;
33+
34+
/*
35+
* Read current configuration register, and insert the config
36+
* for "irq", depending on "type".
37+
*/
38+
val = readl_relaxed(base + GIC_DIST_CONFIG + confoff);
39+
if (type == IRQ_TYPE_LEVEL_HIGH)
40+
val &= ~confmask;
41+
else if (type == IRQ_TYPE_EDGE_RISING)
42+
val |= confmask;
43+
44+
/*
45+
* As recommended by the spec, disable the interrupt before changing
46+
* the configuration
47+
*/
48+
if (readl_relaxed(base + GIC_DIST_ENABLE_SET + enableoff) & enablemask) {
49+
writel_relaxed(enablemask, base + GIC_DIST_ENABLE_CLEAR + enableoff);
50+
if (sync_access)
51+
sync_access();
52+
enabled = true;
53+
}
54+
55+
/*
56+
* Write back the new configuration, and possibly re-enable
57+
* the interrupt.
58+
*/
59+
writel_relaxed(val, base + GIC_DIST_CONFIG + confoff);
60+
61+
if (enabled)
62+
writel_relaxed(enablemask, base + GIC_DIST_ENABLE_SET + enableoff);
63+
64+
if (sync_access)
65+
sync_access();
66+
}
67+
68+
void __init gic_dist_config(void __iomem *base, int gic_irqs,
69+
void (*sync_access)(void))
70+
{
71+
unsigned int i;
72+
73+
/*
74+
* Set all global interrupts to be level triggered, active low.
75+
*/
76+
for (i = 32; i < gic_irqs; i += 16)
77+
writel_relaxed(0, base + GIC_DIST_CONFIG + i / 4);
78+
79+
/*
80+
* Set priority on all global interrupts.
81+
*/
82+
for (i = 32; i < gic_irqs; i += 4)
83+
writel_relaxed(0xa0a0a0a0, base + GIC_DIST_PRI + i);
84+
85+
/*
86+
* Disable all interrupts. Leave the PPI and SGIs alone
87+
* as they are enabled by redistributor registers.
88+
*/
89+
for (i = 32; i < gic_irqs; i += 32)
90+
writel_relaxed(0xffffffff, base + GIC_DIST_ENABLE_CLEAR + i / 8);
91+
92+
if (sync_access)
93+
sync_access();
94+
}
95+
96+
void gic_cpu_config(void __iomem *base, void (*sync_access)(void))
97+
{
98+
int i;
99+
100+
/*
101+
* Deal with the banked PPI and SGI interrupts - disable all
102+
* PPI interrupts, ensure all SGI interrupts are enabled.
103+
*/
104+
writel_relaxed(0xffff0000, base + GIC_DIST_ENABLE_CLEAR);
105+
writel_relaxed(0x0000ffff, base + GIC_DIST_ENABLE_SET);
106+
107+
/*
108+
* Set priority on PPI and SGI interrupts
109+
*/
110+
for (i = 0; i < 32; i += 4)
111+
writel_relaxed(0xa0a0a0a0, base + GIC_DIST_PRI + i * 4 / 4);
112+
113+
if (sync_access)
114+
sync_access();
115+
}

‎drivers/irqchip/irq-gic-common.h‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* 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+
*/
16+
17+
#ifndef _IRQ_GIC_COMMON_H
18+
#define _IRQ_GIC_COMMON_H
19+
20+
#include <linux/of.h>
21+
#include <linux/irqdomain.h>
22+
23+
void gic_configure_irq(unsigned int irq, unsigned int type,
24+
void __iomem *base, void (*sync_access)(void));
25+
void gic_dist_config(void __iomem *base, int gic_irqs,
26+
void (*sync_access)(void));
27+
void gic_cpu_config(void __iomem *base, void (*sync_access)(void));
28+
29+
#endif /* _IRQ_GIC_COMMON_H */

0 commit comments

Comments
 (0)