diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2017-11-09 06:57:46 -0500 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2017-11-09 06:57:46 -0500 |
commit | 9dc505d6df5c607a4ea088b5f1907540079a9859 (patch) | |
tree | 86b546b5cc0aaa3c71788cf5566cc6b86c89bc4e | |
parent | 722c908f84c67bf120105ca870675cadc1bb7b20 (diff) | |
parent | 666740fde412567aa0a8ea251ffee3004a6fa3a6 (diff) |
Merge tag 'irqchip-4.15-3' of git://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms into irq/core
Pull irqchip updates for 4.15, take #3 from Marc Zyngier:
- New Socionext Synquacer EXIU driver
- stm32 new platform support and fixes
- One GICv4 bugfix
- A couple of MIPS GIC cleanups
-rw-r--r-- | Documentation/devicetree/bindings/interrupt-controller/socionext,synquacer-exiu.txt | 32 | ||||
-rw-r--r-- | Documentation/devicetree/bindings/interrupt-controller/st,stm32-exti.txt | 4 | ||||
-rw-r--r-- | arch/arm64/Kconfig.platforms | 3 | ||||
-rw-r--r-- | drivers/irqchip/Kconfig | 1 | ||||
-rw-r--r-- | drivers/irqchip/Makefile | 1 | ||||
-rw-r--r-- | drivers/irqchip/irq-gic-v3-its.c | 2 | ||||
-rw-r--r-- | drivers/irqchip/irq-mips-gic.c | 13 | ||||
-rw-r--r-- | drivers/irqchip/irq-sni-exiu.c | 227 | ||||
-rw-r--r-- | drivers/irqchip/irq-stm32-exti.c | 206 |
9 files changed, 434 insertions, 55 deletions
diff --git a/Documentation/devicetree/bindings/interrupt-controller/socionext,synquacer-exiu.txt b/Documentation/devicetree/bindings/interrupt-controller/socionext,synquacer-exiu.txt new file mode 100644 index 000000000000..8b2faefe29ca --- /dev/null +++ b/Documentation/devicetree/bindings/interrupt-controller/socionext,synquacer-exiu.txt | |||
@@ -0,0 +1,32 @@ | |||
1 | Socionext SynQuacer External Interrupt Unit (EXIU) | ||
2 | |||
3 | The Socionext Synquacer SoC has an external interrupt unit (EXIU) | ||
4 | that forwards a block of 32 configurable input lines to 32 adjacent | ||
5 | level-high type GICv3 SPIs. | ||
6 | |||
7 | Required properties: | ||
8 | |||
9 | - compatible : Should be "socionext,synquacer-exiu". | ||
10 | - reg : Specifies base physical address and size of the | ||
11 | control registers. | ||
12 | - interrupt-controller : Identifies the node as an interrupt controller. | ||
13 | - #interrupt-cells : Specifies the number of cells needed to encode an | ||
14 | interrupt source. The value must be 3. | ||
15 | - interrupt-parent : phandle of the GIC these interrupts are routed to. | ||
16 | - socionext,spi-base : The SPI number of the first SPI of the 32 adjacent | ||
17 | ones the EXIU forwards its interrups to. | ||
18 | |||
19 | Notes: | ||
20 | |||
21 | - Only SPIs can use the EXIU as an interrupt parent. | ||
22 | |||
23 | Example: | ||
24 | |||
25 | exiu: interrupt-controller@510c0000 { | ||
26 | compatible = "socionext,synquacer-exiu"; | ||
27 | reg = <0x0 0x510c0000 0x0 0x20>; | ||
28 | interrupt-controller; | ||
29 | interrupt-parent = <&gic>; | ||
30 | #interrupt-cells = <3>; | ||
31 | socionext,spi-base = <112>; | ||
32 | }; | ||
diff --git a/Documentation/devicetree/bindings/interrupt-controller/st,stm32-exti.txt b/Documentation/devicetree/bindings/interrupt-controller/st,stm32-exti.txt index 6e7703d4ff5b..edf03f09244b 100644 --- a/Documentation/devicetree/bindings/interrupt-controller/st,stm32-exti.txt +++ b/Documentation/devicetree/bindings/interrupt-controller/st,stm32-exti.txt | |||
@@ -2,7 +2,9 @@ STM32 External Interrupt Controller | |||
2 | 2 | ||
3 | Required properties: | 3 | Required properties: |
4 | 4 | ||
5 | - compatible: Should be "st,stm32-exti" | 5 | - compatible: Should be: |
6 | "st,stm32-exti" | ||
7 | "st,stm32h7-exti" | ||
6 | - reg: Specifies base physical address and size of the registers | 8 | - reg: Specifies base physical address and size of the registers |
7 | - interrupt-controller: Indentifies the node as an interrupt controller | 9 | - interrupt-controller: Indentifies the node as an interrupt controller |
8 | - #interrupt-cells: Specifies the number of cells to encode an interrupt | 10 | - #interrupt-cells: Specifies the number of cells to encode an interrupt |
diff --git a/arch/arm64/Kconfig.platforms b/arch/arm64/Kconfig.platforms index 6b54ee8c1262..1d03ef54295a 100644 --- a/arch/arm64/Kconfig.platforms +++ b/arch/arm64/Kconfig.platforms | |||
@@ -161,6 +161,9 @@ config ARCH_SEATTLE | |||
161 | config ARCH_SHMOBILE | 161 | config ARCH_SHMOBILE |
162 | bool | 162 | bool |
163 | 163 | ||
164 | config ARCH_SYNQUACER | ||
165 | bool "Socionext SynQuacer SoC Family" | ||
166 | |||
164 | config ARCH_RENESAS | 167 | config ARCH_RENESAS |
165 | bool "Renesas SoC Platforms" | 168 | bool "Renesas SoC Platforms" |
166 | select ARCH_SHMOBILE | 169 | select ARCH_SHMOBILE |
diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig index 85d0fb2b976c..39816b7e043d 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig | |||
@@ -306,6 +306,7 @@ config EZNPS_GIC | |||
306 | config STM32_EXTI | 306 | config STM32_EXTI |
307 | bool | 307 | bool |
308 | select IRQ_DOMAIN | 308 | select IRQ_DOMAIN |
309 | select GENERIC_IRQ_CHIP | ||
309 | 310 | ||
310 | config QCOM_IRQ_COMBINER | 311 | config QCOM_IRQ_COMBINER |
311 | bool "QCOM IRQ combiner support" | 312 | bool "QCOM IRQ combiner support" |
diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile index 065adf4102c9..dee3390390d5 100644 --- a/drivers/irqchip/Makefile +++ b/drivers/irqchip/Makefile | |||
@@ -79,4 +79,5 @@ obj-$(CONFIG_ARCH_ASPEED) += irq-aspeed-vic.o irq-aspeed-i2c-ic.o | |||
79 | obj-$(CONFIG_STM32_EXTI) += irq-stm32-exti.o | 79 | obj-$(CONFIG_STM32_EXTI) += irq-stm32-exti.o |
80 | obj-$(CONFIG_QCOM_IRQ_COMBINER) += qcom-irq-combiner.o | 80 | obj-$(CONFIG_QCOM_IRQ_COMBINER) += qcom-irq-combiner.o |
81 | obj-$(CONFIG_IRQ_UNIPHIER_AIDET) += irq-uniphier-aidet.o | 81 | obj-$(CONFIG_IRQ_UNIPHIER_AIDET) += irq-uniphier-aidet.o |
82 | obj-$(CONFIG_ARCH_SYNQUACER) += irq-sni-exiu.o | ||
82 | obj-$(CONFIG_MESON_IRQ_GPIO) += irq-meson-gpio.o | 83 | obj-$(CONFIG_MESON_IRQ_GPIO) += irq-meson-gpio.o |
diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 29b2ff5c6841..be99d59bf636 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c | |||
@@ -2802,7 +2802,7 @@ static int its_vpe_irq_domain_activate(struct irq_domain *domain, | |||
2802 | 2802 | ||
2803 | /* If we use the list map, we issue VMAPP on demand... */ | 2803 | /* If we use the list map, we issue VMAPP on demand... */ |
2804 | if (its_list_map) | 2804 | if (its_list_map) |
2805 | return true; | 2805 | return 0; |
2806 | 2806 | ||
2807 | /* Map the VPE to the first possible CPU */ | 2807 | /* Map the VPE to the first possible CPU */ |
2808 | vpe->col_idx = cpumask_first(cpu_online_mask); | 2808 | vpe->col_idx = cpumask_first(cpu_online_mask); |
diff --git a/drivers/irqchip/irq-mips-gic.c b/drivers/irqchip/irq-mips-gic.c index 3ccebb020f40..ef92a4d2038e 100644 --- a/drivers/irqchip/irq-mips-gic.c +++ b/drivers/irqchip/irq-mips-gic.c | |||
@@ -6,6 +6,9 @@ | |||
6 | * Copyright (C) 2008 Ralf Baechle (ralf@linux-mips.org) | 6 | * Copyright (C) 2008 Ralf Baechle (ralf@linux-mips.org) |
7 | * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved. | 7 | * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved. |
8 | */ | 8 | */ |
9 | |||
10 | #define pr_fmt(fmt) "irq-mips-gic: " fmt | ||
11 | |||
9 | #include <linux/bitmap.h> | 12 | #include <linux/bitmap.h> |
10 | #include <linux/clocksource.h> | 13 | #include <linux/clocksource.h> |
11 | #include <linux/cpuhotplug.h> | 14 | #include <linux/cpuhotplug.h> |
@@ -685,7 +688,7 @@ static int __init gic_of_init(struct device_node *node, | |||
685 | 688 | ||
686 | cpu_vec = find_first_zero_bit(&reserved, hweight_long(ST0_IM)); | 689 | cpu_vec = find_first_zero_bit(&reserved, hweight_long(ST0_IM)); |
687 | if (cpu_vec == hweight_long(ST0_IM)) { | 690 | if (cpu_vec == hweight_long(ST0_IM)) { |
688 | pr_err("No CPU vectors available for GIC\n"); | 691 | pr_err("No CPU vectors available\n"); |
689 | return -ENODEV; | 692 | return -ENODEV; |
690 | } | 693 | } |
691 | 694 | ||
@@ -698,8 +701,10 @@ static int __init gic_of_init(struct device_node *node, | |||
698 | gic_base = read_gcr_gic_base() & | 701 | gic_base = read_gcr_gic_base() & |
699 | ~CM_GCR_GIC_BASE_GICEN; | 702 | ~CM_GCR_GIC_BASE_GICEN; |
700 | gic_len = 0x20000; | 703 | gic_len = 0x20000; |
704 | pr_warn("Using inherited base address %pa\n", | ||
705 | &gic_base); | ||
701 | } else { | 706 | } else { |
702 | pr_err("Failed to get GIC memory range\n"); | 707 | pr_err("Failed to get memory range\n"); |
703 | return -ENODEV; | 708 | return -ENODEV; |
704 | } | 709 | } |
705 | } else { | 710 | } else { |
@@ -757,7 +762,7 @@ static int __init gic_of_init(struct device_node *node, | |||
757 | gic_shared_intrs, 0, | 762 | gic_shared_intrs, 0, |
758 | &gic_irq_domain_ops, NULL); | 763 | &gic_irq_domain_ops, NULL); |
759 | if (!gic_irq_domain) { | 764 | if (!gic_irq_domain) { |
760 | pr_err("Failed to add GIC IRQ domain"); | 765 | pr_err("Failed to add IRQ domain"); |
761 | return -ENXIO; | 766 | return -ENXIO; |
762 | } | 767 | } |
763 | 768 | ||
@@ -766,7 +771,7 @@ static int __init gic_of_init(struct device_node *node, | |||
766 | GIC_NUM_LOCAL_INTRS + gic_shared_intrs, | 771 | GIC_NUM_LOCAL_INTRS + gic_shared_intrs, |
767 | node, &gic_ipi_domain_ops, NULL); | 772 | node, &gic_ipi_domain_ops, NULL); |
768 | if (!gic_ipi_domain) { | 773 | if (!gic_ipi_domain) { |
769 | pr_err("Failed to add GIC IPI domain"); | 774 | pr_err("Failed to add IPI domain"); |
770 | return -ENXIO; | 775 | return -ENXIO; |
771 | } | 776 | } |
772 | 777 | ||
diff --git a/drivers/irqchip/irq-sni-exiu.c b/drivers/irqchip/irq-sni-exiu.c new file mode 100644 index 000000000000..1b6e2f7c59af --- /dev/null +++ b/drivers/irqchip/irq-sni-exiu.c | |||
@@ -0,0 +1,227 @@ | |||
1 | /* | ||
2 | * Driver for Socionext External Interrupt Unit (EXIU) | ||
3 | * | ||
4 | * Copyright (c) 2017 Linaro, Ltd. <ard.biesheuvel@linaro.org> | ||
5 | * | ||
6 | * Based on irq-tegra.c: | ||
7 | * Copyright (C) 2011 Google, Inc. | ||
8 | * Copyright (C) 2010,2013, NVIDIA Corporation | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License version 2 as | ||
12 | * published by the Free Software Foundation. | ||
13 | */ | ||
14 | |||
15 | #include <linux/interrupt.h> | ||
16 | #include <linux/io.h> | ||
17 | #include <linux/irq.h> | ||
18 | #include <linux/irqchip.h> | ||
19 | #include <linux/irqdomain.h> | ||
20 | #include <linux/of.h> | ||
21 | #include <linux/of_address.h> | ||
22 | #include <linux/of_irq.h> | ||
23 | |||
24 | #include <dt-bindings/interrupt-controller/arm-gic.h> | ||
25 | |||
26 | #define NUM_IRQS 32 | ||
27 | |||
28 | #define EIMASK 0x00 | ||
29 | #define EISRCSEL 0x04 | ||
30 | #define EIREQSTA 0x08 | ||
31 | #define EIRAWREQSTA 0x0C | ||
32 | #define EIREQCLR 0x10 | ||
33 | #define EILVL 0x14 | ||
34 | #define EIEDG 0x18 | ||
35 | #define EISIR 0x1C | ||
36 | |||
37 | struct exiu_irq_data { | ||
38 | void __iomem *base; | ||
39 | u32 spi_base; | ||
40 | }; | ||
41 | |||
42 | static void exiu_irq_eoi(struct irq_data *d) | ||
43 | { | ||
44 | struct exiu_irq_data *data = irq_data_get_irq_chip_data(d); | ||
45 | |||
46 | writel(BIT(d->hwirq), data->base + EIREQCLR); | ||
47 | irq_chip_eoi_parent(d); | ||
48 | } | ||
49 | |||
50 | static void exiu_irq_mask(struct irq_data *d) | ||
51 | { | ||
52 | struct exiu_irq_data *data = irq_data_get_irq_chip_data(d); | ||
53 | u32 val; | ||
54 | |||
55 | val = readl_relaxed(data->base + EIMASK) | BIT(d->hwirq); | ||
56 | writel_relaxed(val, data->base + EIMASK); | ||
57 | irq_chip_mask_parent(d); | ||
58 | } | ||
59 | |||
60 | static void exiu_irq_unmask(struct irq_data *d) | ||
61 | { | ||
62 | struct exiu_irq_data *data = irq_data_get_irq_chip_data(d); | ||
63 | u32 val; | ||
64 | |||
65 | val = readl_relaxed(data->base + EIMASK) & ~BIT(d->hwirq); | ||
66 | writel_relaxed(val, data->base + EIMASK); | ||
67 | irq_chip_unmask_parent(d); | ||
68 | } | ||
69 | |||
70 | static void exiu_irq_enable(struct irq_data *d) | ||
71 | { | ||
72 | struct exiu_irq_data *data = irq_data_get_irq_chip_data(d); | ||
73 | u32 val; | ||
74 | |||
75 | /* clear interrupts that were latched while disabled */ | ||
76 | writel_relaxed(BIT(d->hwirq), data->base + EIREQCLR); | ||
77 | |||
78 | val = readl_relaxed(data->base + EIMASK) & ~BIT(d->hwirq); | ||
79 | writel_relaxed(val, data->base + EIMASK); | ||
80 | irq_chip_enable_parent(d); | ||
81 | } | ||
82 | |||
83 | static int exiu_irq_set_type(struct irq_data *d, unsigned int type) | ||
84 | { | ||
85 | struct exiu_irq_data *data = irq_data_get_irq_chip_data(d); | ||
86 | u32 val; | ||
87 | |||
88 | val = readl_relaxed(data->base + EILVL); | ||
89 | if (type == IRQ_TYPE_EDGE_RISING || type == IRQ_TYPE_LEVEL_HIGH) | ||
90 | val |= BIT(d->hwirq); | ||
91 | else | ||
92 | val &= ~BIT(d->hwirq); | ||
93 | writel_relaxed(val, data->base + EILVL); | ||
94 | |||
95 | val = readl_relaxed(data->base + EIEDG); | ||
96 | if (type == IRQ_TYPE_LEVEL_LOW || type == IRQ_TYPE_LEVEL_HIGH) | ||
97 | val &= ~BIT(d->hwirq); | ||
98 | else | ||
99 | val |= BIT(d->hwirq); | ||
100 | writel_relaxed(val, data->base + EIEDG); | ||
101 | |||
102 | writel_relaxed(BIT(d->hwirq), data->base + EIREQCLR); | ||
103 | |||
104 | return irq_chip_set_type_parent(d, IRQ_TYPE_LEVEL_HIGH); | ||
105 | } | ||
106 | |||
107 | static struct irq_chip exiu_irq_chip = { | ||
108 | .name = "EXIU", | ||
109 | .irq_eoi = exiu_irq_eoi, | ||
110 | .irq_enable = exiu_irq_enable, | ||
111 | .irq_mask = exiu_irq_mask, | ||
112 | .irq_unmask = exiu_irq_unmask, | ||
113 | .irq_set_type = exiu_irq_set_type, | ||
114 | .irq_set_affinity = irq_chip_set_affinity_parent, | ||
115 | .flags = IRQCHIP_SET_TYPE_MASKED | | ||
116 | IRQCHIP_SKIP_SET_WAKE | | ||
117 | IRQCHIP_EOI_THREADED | | ||
118 | IRQCHIP_MASK_ON_SUSPEND, | ||
119 | }; | ||
120 | |||
121 | static int exiu_domain_translate(struct irq_domain *domain, | ||
122 | struct irq_fwspec *fwspec, | ||
123 | unsigned long *hwirq, | ||
124 | unsigned int *type) | ||
125 | { | ||
126 | struct exiu_irq_data *info = domain->host_data; | ||
127 | |||
128 | if (is_of_node(fwspec->fwnode)) { | ||
129 | if (fwspec->param_count != 3) | ||
130 | return -EINVAL; | ||
131 | |||
132 | if (fwspec->param[0] != GIC_SPI) | ||
133 | return -EINVAL; /* No PPI should point to this domain */ | ||
134 | |||
135 | *hwirq = fwspec->param[1] - info->spi_base; | ||
136 | *type = fwspec->param[2] & IRQ_TYPE_SENSE_MASK; | ||
137 | return 0; | ||
138 | } | ||
139 | return -EINVAL; | ||
140 | } | ||
141 | |||
142 | static int exiu_domain_alloc(struct irq_domain *dom, unsigned int virq, | ||
143 | unsigned int nr_irqs, void *data) | ||
144 | { | ||
145 | struct irq_fwspec *fwspec = data; | ||
146 | struct irq_fwspec parent_fwspec; | ||
147 | struct exiu_irq_data *info = dom->host_data; | ||
148 | irq_hw_number_t hwirq; | ||
149 | |||
150 | if (fwspec->param_count != 3) | ||
151 | return -EINVAL; /* Not GIC compliant */ | ||
152 | if (fwspec->param[0] != GIC_SPI) | ||
153 | return -EINVAL; /* No PPI should point to this domain */ | ||
154 | |||
155 | WARN_ON(nr_irqs != 1); | ||
156 | hwirq = fwspec->param[1] - info->spi_base; | ||
157 | irq_domain_set_hwirq_and_chip(dom, virq, hwirq, &exiu_irq_chip, info); | ||
158 | |||
159 | parent_fwspec = *fwspec; | ||
160 | parent_fwspec.fwnode = dom->parent->fwnode; | ||
161 | return irq_domain_alloc_irqs_parent(dom, virq, nr_irqs, &parent_fwspec); | ||
162 | } | ||
163 | |||
164 | static const struct irq_domain_ops exiu_domain_ops = { | ||
165 | .translate = exiu_domain_translate, | ||
166 | .alloc = exiu_domain_alloc, | ||
167 | .free = irq_domain_free_irqs_common, | ||
168 | }; | ||
169 | |||
170 | static int __init exiu_init(struct device_node *node, | ||
171 | struct device_node *parent) | ||
172 | { | ||
173 | struct irq_domain *parent_domain, *domain; | ||
174 | struct exiu_irq_data *data; | ||
175 | int err; | ||
176 | |||
177 | if (!parent) { | ||
178 | pr_err("%pOF: no parent, giving up\n", node); | ||
179 | return -ENODEV; | ||
180 | } | ||
181 | |||
182 | parent_domain = irq_find_host(parent); | ||
183 | if (!parent_domain) { | ||
184 | pr_err("%pOF: unable to obtain parent domain\n", node); | ||
185 | return -ENXIO; | ||
186 | } | ||
187 | |||
188 | data = kzalloc(sizeof(*data), GFP_KERNEL); | ||
189 | if (!data) | ||
190 | return -ENOMEM; | ||
191 | |||
192 | if (of_property_read_u32(node, "socionext,spi-base", &data->spi_base)) { | ||
193 | pr_err("%pOF: failed to parse 'spi-base' property\n", node); | ||
194 | err = -ENODEV; | ||
195 | goto out_free; | ||
196 | } | ||
197 | |||
198 | data->base = of_iomap(node, 0); | ||
199 | if (IS_ERR(data->base)) { | ||
200 | err = PTR_ERR(data->base); | ||
201 | goto out_free; | ||
202 | } | ||
203 | |||
204 | /* clear and mask all interrupts */ | ||
205 | writel_relaxed(0xFFFFFFFF, data->base + EIREQCLR); | ||
206 | writel_relaxed(0xFFFFFFFF, data->base + EIMASK); | ||
207 | |||
208 | domain = irq_domain_add_hierarchy(parent_domain, 0, NUM_IRQS, node, | ||
209 | &exiu_domain_ops, data); | ||
210 | if (!domain) { | ||
211 | pr_err("%pOF: failed to allocate domain\n", node); | ||
212 | err = -ENOMEM; | ||
213 | goto out_unmap; | ||
214 | } | ||
215 | |||
216 | pr_info("%pOF: %d interrupts forwarded to %pOF\n", node, NUM_IRQS, | ||
217 | parent); | ||
218 | |||
219 | return 0; | ||
220 | |||
221 | out_unmap: | ||
222 | iounmap(data->base); | ||
223 | out_free: | ||
224 | kfree(data); | ||
225 | return err; | ||
226 | } | ||
227 | IRQCHIP_DECLARE(exiu, "socionext,synquacer-exiu", exiu_init); | ||
diff --git a/drivers/irqchip/irq-stm32-exti.c b/drivers/irqchip/irq-stm32-exti.c index 45363ff8d06f..31ab0dee2ce7 100644 --- a/drivers/irqchip/irq-stm32-exti.c +++ b/drivers/irqchip/irq-stm32-exti.c | |||
@@ -14,27 +14,99 @@ | |||
14 | #include <linux/of_address.h> | 14 | #include <linux/of_address.h> |
15 | #include <linux/of_irq.h> | 15 | #include <linux/of_irq.h> |
16 | 16 | ||
17 | #define EXTI_IMR 0x0 | 17 | #define IRQS_PER_BANK 32 |
18 | #define EXTI_EMR 0x4 | 18 | |
19 | #define EXTI_RTSR 0x8 | 19 | struct stm32_exti_bank { |
20 | #define EXTI_FTSR 0xc | 20 | u32 imr_ofst; |
21 | #define EXTI_SWIER 0x10 | 21 | u32 emr_ofst; |
22 | #define EXTI_PR 0x14 | 22 | u32 rtsr_ofst; |
23 | u32 ftsr_ofst; | ||
24 | u32 swier_ofst; | ||
25 | u32 pr_ofst; | ||
26 | }; | ||
27 | |||
28 | static const struct stm32_exti_bank stm32f4xx_exti_b1 = { | ||
29 | .imr_ofst = 0x00, | ||
30 | .emr_ofst = 0x04, | ||
31 | .rtsr_ofst = 0x08, | ||
32 | .ftsr_ofst = 0x0C, | ||
33 | .swier_ofst = 0x10, | ||
34 | .pr_ofst = 0x14, | ||
35 | }; | ||
36 | |||
37 | static const struct stm32_exti_bank *stm32f4xx_exti_banks[] = { | ||
38 | &stm32f4xx_exti_b1, | ||
39 | }; | ||
40 | |||
41 | static const struct stm32_exti_bank stm32h7xx_exti_b1 = { | ||
42 | .imr_ofst = 0x80, | ||
43 | .emr_ofst = 0x84, | ||
44 | .rtsr_ofst = 0x00, | ||
45 | .ftsr_ofst = 0x04, | ||
46 | .swier_ofst = 0x08, | ||
47 | .pr_ofst = 0x88, | ||
48 | }; | ||
49 | |||
50 | static const struct stm32_exti_bank stm32h7xx_exti_b2 = { | ||
51 | .imr_ofst = 0x90, | ||
52 | .emr_ofst = 0x94, | ||
53 | .rtsr_ofst = 0x20, | ||
54 | .ftsr_ofst = 0x24, | ||
55 | .swier_ofst = 0x28, | ||
56 | .pr_ofst = 0x98, | ||
57 | }; | ||
58 | |||
59 | static const struct stm32_exti_bank stm32h7xx_exti_b3 = { | ||
60 | .imr_ofst = 0xA0, | ||
61 | .emr_ofst = 0xA4, | ||
62 | .rtsr_ofst = 0x40, | ||
63 | .ftsr_ofst = 0x44, | ||
64 | .swier_ofst = 0x48, | ||
65 | .pr_ofst = 0xA8, | ||
66 | }; | ||
67 | |||
68 | static const struct stm32_exti_bank *stm32h7xx_exti_banks[] = { | ||
69 | &stm32h7xx_exti_b1, | ||
70 | &stm32h7xx_exti_b2, | ||
71 | &stm32h7xx_exti_b3, | ||
72 | }; | ||
73 | |||
74 | static unsigned long stm32_exti_pending(struct irq_chip_generic *gc) | ||
75 | { | ||
76 | const struct stm32_exti_bank *stm32_bank = gc->private; | ||
77 | |||
78 | return irq_reg_readl(gc, stm32_bank->pr_ofst); | ||
79 | } | ||
80 | |||
81 | static void stm32_exti_irq_ack(struct irq_chip_generic *gc, u32 mask) | ||
82 | { | ||
83 | const struct stm32_exti_bank *stm32_bank = gc->private; | ||
84 | |||
85 | irq_reg_writel(gc, mask, stm32_bank->pr_ofst); | ||
86 | } | ||
23 | 87 | ||
24 | static void stm32_irq_handler(struct irq_desc *desc) | 88 | static void stm32_irq_handler(struct irq_desc *desc) |
25 | { | 89 | { |
26 | struct irq_domain *domain = irq_desc_get_handler_data(desc); | 90 | struct irq_domain *domain = irq_desc_get_handler_data(desc); |
27 | struct irq_chip_generic *gc = domain->gc->gc[0]; | ||
28 | struct irq_chip *chip = irq_desc_get_chip(desc); | 91 | struct irq_chip *chip = irq_desc_get_chip(desc); |
92 | unsigned int virq, nbanks = domain->gc->num_chips; | ||
93 | struct irq_chip_generic *gc; | ||
94 | const struct stm32_exti_bank *stm32_bank; | ||
29 | unsigned long pending; | 95 | unsigned long pending; |
30 | int n; | 96 | int n, i, irq_base = 0; |
31 | 97 | ||
32 | chained_irq_enter(chip, desc); | 98 | chained_irq_enter(chip, desc); |
33 | 99 | ||
34 | while ((pending = irq_reg_readl(gc, EXTI_PR))) { | 100 | for (i = 0; i < nbanks; i++, irq_base += IRQS_PER_BANK) { |
35 | for_each_set_bit(n, &pending, BITS_PER_LONG) { | 101 | gc = irq_get_domain_generic_chip(domain, irq_base); |
36 | generic_handle_irq(irq_find_mapping(domain, n)); | 102 | stm32_bank = gc->private; |
37 | irq_reg_writel(gc, BIT(n), EXTI_PR); | 103 | |
104 | while ((pending = stm32_exti_pending(gc))) { | ||
105 | for_each_set_bit(n, &pending, IRQS_PER_BANK) { | ||
106 | virq = irq_find_mapping(domain, irq_base + n); | ||
107 | generic_handle_irq(virq); | ||
108 | stm32_exti_irq_ack(gc, BIT(n)); | ||
109 | } | ||
38 | } | 110 | } |
39 | } | 111 | } |
40 | 112 | ||
@@ -44,13 +116,14 @@ static void stm32_irq_handler(struct irq_desc *desc) | |||
44 | static int stm32_irq_set_type(struct irq_data *data, unsigned int type) | 116 | static int stm32_irq_set_type(struct irq_data *data, unsigned int type) |
45 | { | 117 | { |
46 | struct irq_chip_generic *gc = irq_data_get_irq_chip_data(data); | 118 | struct irq_chip_generic *gc = irq_data_get_irq_chip_data(data); |
47 | int pin = data->hwirq; | 119 | const struct stm32_exti_bank *stm32_bank = gc->private; |
120 | int pin = data->hwirq % IRQS_PER_BANK; | ||
48 | u32 rtsr, ftsr; | 121 | u32 rtsr, ftsr; |
49 | 122 | ||
50 | irq_gc_lock(gc); | 123 | irq_gc_lock(gc); |
51 | 124 | ||
52 | rtsr = irq_reg_readl(gc, EXTI_RTSR); | 125 | rtsr = irq_reg_readl(gc, stm32_bank->rtsr_ofst); |
53 | ftsr = irq_reg_readl(gc, EXTI_FTSR); | 126 | ftsr = irq_reg_readl(gc, stm32_bank->ftsr_ofst); |
54 | 127 | ||
55 | switch (type) { | 128 | switch (type) { |
56 | case IRQ_TYPE_EDGE_RISING: | 129 | case IRQ_TYPE_EDGE_RISING: |
@@ -70,8 +143,8 @@ static int stm32_irq_set_type(struct irq_data *data, unsigned int type) | |||
70 | return -EINVAL; | 143 | return -EINVAL; |
71 | } | 144 | } |
72 | 145 | ||
73 | irq_reg_writel(gc, rtsr, EXTI_RTSR); | 146 | irq_reg_writel(gc, rtsr, stm32_bank->rtsr_ofst); |
74 | irq_reg_writel(gc, ftsr, EXTI_FTSR); | 147 | irq_reg_writel(gc, ftsr, stm32_bank->ftsr_ofst); |
75 | 148 | ||
76 | irq_gc_unlock(gc); | 149 | irq_gc_unlock(gc); |
77 | 150 | ||
@@ -81,17 +154,18 @@ static int stm32_irq_set_type(struct irq_data *data, unsigned int type) | |||
81 | static int stm32_irq_set_wake(struct irq_data *data, unsigned int on) | 154 | static int stm32_irq_set_wake(struct irq_data *data, unsigned int on) |
82 | { | 155 | { |
83 | struct irq_chip_generic *gc = irq_data_get_irq_chip_data(data); | 156 | struct irq_chip_generic *gc = irq_data_get_irq_chip_data(data); |
84 | int pin = data->hwirq; | 157 | const struct stm32_exti_bank *stm32_bank = gc->private; |
85 | u32 emr; | 158 | int pin = data->hwirq % IRQS_PER_BANK; |
159 | u32 imr; | ||
86 | 160 | ||
87 | irq_gc_lock(gc); | 161 | irq_gc_lock(gc); |
88 | 162 | ||
89 | emr = irq_reg_readl(gc, EXTI_EMR); | 163 | imr = irq_reg_readl(gc, stm32_bank->imr_ofst); |
90 | if (on) | 164 | if (on) |
91 | emr |= BIT(pin); | 165 | imr |= BIT(pin); |
92 | else | 166 | else |
93 | emr &= ~BIT(pin); | 167 | imr &= ~BIT(pin); |
94 | irq_reg_writel(gc, emr, EXTI_EMR); | 168 | irq_reg_writel(gc, imr, stm32_bank->imr_ofst); |
95 | 169 | ||
96 | irq_gc_unlock(gc); | 170 | irq_gc_unlock(gc); |
97 | 171 | ||
@@ -101,11 +175,12 @@ static int stm32_irq_set_wake(struct irq_data *data, unsigned int on) | |||
101 | static int stm32_exti_alloc(struct irq_domain *d, unsigned int virq, | 175 | static int stm32_exti_alloc(struct irq_domain *d, unsigned int virq, |
102 | unsigned int nr_irqs, void *data) | 176 | unsigned int nr_irqs, void *data) |
103 | { | 177 | { |
104 | struct irq_chip_generic *gc = d->gc->gc[0]; | 178 | struct irq_chip_generic *gc; |
105 | struct irq_fwspec *fwspec = data; | 179 | struct irq_fwspec *fwspec = data; |
106 | irq_hw_number_t hwirq; | 180 | irq_hw_number_t hwirq; |
107 | 181 | ||
108 | hwirq = fwspec->param[0]; | 182 | hwirq = fwspec->param[0]; |
183 | gc = irq_get_domain_generic_chip(d, hwirq); | ||
109 | 184 | ||
110 | irq_map_generic_chip(d, virq, hwirq); | 185 | irq_map_generic_chip(d, virq, hwirq); |
111 | irq_domain_set_info(d, virq, hwirq, &gc->chip_types->chip, gc, | 186 | irq_domain_set_info(d, virq, hwirq, &gc->chip_types->chip, gc, |
@@ -129,8 +204,9 @@ struct irq_domain_ops irq_exti_domain_ops = { | |||
129 | .free = stm32_exti_free, | 204 | .free = stm32_exti_free, |
130 | }; | 205 | }; |
131 | 206 | ||
132 | static int __init stm32_exti_init(struct device_node *node, | 207 | static int |
133 | struct device_node *parent) | 208 | __init stm32_exti_init(const struct stm32_exti_bank **stm32_exti_banks, |
209 | int bank_nr, struct device_node *node) | ||
134 | { | 210 | { |
135 | unsigned int clr = IRQ_NOREQUEST | IRQ_NOPROBE | IRQ_NOAUTOEN; | 211 | unsigned int clr = IRQ_NOREQUEST | IRQ_NOPROBE | IRQ_NOAUTOEN; |
136 | int nr_irqs, nr_exti, ret, i; | 212 | int nr_irqs, nr_exti, ret, i; |
@@ -144,23 +220,16 @@ static int __init stm32_exti_init(struct device_node *node, | |||
144 | return -ENOMEM; | 220 | return -ENOMEM; |
145 | } | 221 | } |
146 | 222 | ||
147 | /* Determine number of irqs supported */ | 223 | domain = irq_domain_add_linear(node, bank_nr * IRQS_PER_BANK, |
148 | writel_relaxed(~0UL, base + EXTI_RTSR); | ||
149 | nr_exti = fls(readl_relaxed(base + EXTI_RTSR)); | ||
150 | writel_relaxed(0, base + EXTI_RTSR); | ||
151 | |||
152 | pr_info("%pOF: %d External IRQs detected\n", node, nr_exti); | ||
153 | |||
154 | domain = irq_domain_add_linear(node, nr_exti, | ||
155 | &irq_exti_domain_ops, NULL); | 224 | &irq_exti_domain_ops, NULL); |
156 | if (!domain) { | 225 | if (!domain) { |
157 | pr_err("%s: Could not register interrupt domain.\n", | 226 | pr_err("%s: Could not register interrupt domain.\n", |
158 | node->name); | 227 | node->name); |
159 | ret = -ENOMEM; | 228 | ret = -ENOMEM; |
160 | goto out_unmap; | 229 | goto out_unmap; |
161 | } | 230 | } |
162 | 231 | ||
163 | ret = irq_alloc_domain_generic_chips(domain, nr_exti, 1, "exti", | 232 | ret = irq_alloc_domain_generic_chips(domain, IRQS_PER_BANK, 1, "exti", |
164 | handle_edge_irq, clr, 0, 0); | 233 | handle_edge_irq, clr, 0, 0); |
165 | if (ret) { | 234 | if (ret) { |
166 | pr_err("%pOF: Could not allocate generic interrupt chip.\n", | 235 | pr_err("%pOF: Could not allocate generic interrupt chip.\n", |
@@ -168,18 +237,41 @@ static int __init stm32_exti_init(struct device_node *node, | |||
168 | goto out_free_domain; | 237 | goto out_free_domain; |
169 | } | 238 | } |
170 | 239 | ||
171 | gc = domain->gc->gc[0]; | 240 | for (i = 0; i < bank_nr; i++) { |
172 | gc->reg_base = base; | 241 | const struct stm32_exti_bank *stm32_bank = stm32_exti_banks[i]; |
173 | gc->chip_types->type = IRQ_TYPE_EDGE_BOTH; | 242 | u32 irqs_mask; |
174 | gc->chip_types->chip.name = gc->chip_types[0].chip.name; | 243 | |
175 | gc->chip_types->chip.irq_ack = irq_gc_ack_set_bit; | 244 | gc = irq_get_domain_generic_chip(domain, i * IRQS_PER_BANK); |
176 | gc->chip_types->chip.irq_mask = irq_gc_mask_clr_bit; | 245 | |
177 | gc->chip_types->chip.irq_unmask = irq_gc_mask_set_bit; | 246 | gc->reg_base = base; |
178 | gc->chip_types->chip.irq_set_type = stm32_irq_set_type; | 247 | gc->chip_types->type = IRQ_TYPE_EDGE_BOTH; |
179 | gc->chip_types->chip.irq_set_wake = stm32_irq_set_wake; | 248 | gc->chip_types->chip.irq_ack = irq_gc_ack_set_bit; |
180 | gc->chip_types->regs.ack = EXTI_PR; | 249 | gc->chip_types->chip.irq_mask = irq_gc_mask_clr_bit; |
181 | gc->chip_types->regs.mask = EXTI_IMR; | 250 | gc->chip_types->chip.irq_unmask = irq_gc_mask_set_bit; |
182 | gc->chip_types->handler = handle_edge_irq; | 251 | gc->chip_types->chip.irq_set_type = stm32_irq_set_type; |
252 | gc->chip_types->chip.irq_set_wake = stm32_irq_set_wake; | ||
253 | gc->chip_types->regs.ack = stm32_bank->pr_ofst; | ||
254 | gc->chip_types->regs.mask = stm32_bank->imr_ofst; | ||
255 | gc->private = (void *)stm32_bank; | ||
256 | |||
257 | /* Determine number of irqs supported */ | ||
258 | writel_relaxed(~0UL, base + stm32_bank->rtsr_ofst); | ||
259 | irqs_mask = readl_relaxed(base + stm32_bank->rtsr_ofst); | ||
260 | nr_exti = fls(readl_relaxed(base + stm32_bank->rtsr_ofst)); | ||
261 | |||
262 | /* | ||
263 | * This IP has no reset, so after hot reboot we should | ||
264 | * clear registers to avoid residue | ||
265 | */ | ||
266 | writel_relaxed(0, base + stm32_bank->imr_ofst); | ||
267 | writel_relaxed(0, base + stm32_bank->emr_ofst); | ||
268 | writel_relaxed(0, base + stm32_bank->rtsr_ofst); | ||
269 | writel_relaxed(0, base + stm32_bank->ftsr_ofst); | ||
270 | writel_relaxed(~0UL, base + stm32_bank->pr_ofst); | ||
271 | |||
272 | pr_info("%s: bank%d, External IRQs available:%#x\n", | ||
273 | node->full_name, i, irqs_mask); | ||
274 | } | ||
183 | 275 | ||
184 | nr_irqs = of_irq_count(node); | 276 | nr_irqs = of_irq_count(node); |
185 | for (i = 0; i < nr_irqs; i++) { | 277 | for (i = 0; i < nr_irqs; i++) { |
@@ -198,4 +290,20 @@ out_unmap: | |||
198 | return ret; | 290 | return ret; |
199 | } | 291 | } |
200 | 292 | ||
201 | IRQCHIP_DECLARE(stm32_exti, "st,stm32-exti", stm32_exti_init); | 293 | static int __init stm32f4_exti_of_init(struct device_node *np, |
294 | struct device_node *parent) | ||
295 | { | ||
296 | return stm32_exti_init(stm32f4xx_exti_banks, | ||
297 | ARRAY_SIZE(stm32f4xx_exti_banks), np); | ||
298 | } | ||
299 | |||
300 | IRQCHIP_DECLARE(stm32f4_exti, "st,stm32-exti", stm32f4_exti_of_init); | ||
301 | |||
302 | static int __init stm32h7_exti_of_init(struct device_node *np, | ||
303 | struct device_node *parent) | ||
304 | { | ||
305 | return stm32_exti_init(stm32h7xx_exti_banks, | ||
306 | ARRAY_SIZE(stm32h7xx_exti_banks), np); | ||
307 | } | ||
308 | |||
309 | IRQCHIP_DECLARE(stm32h7_exti, "st,stm32h7-exti", stm32h7_exti_of_init); | ||