Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'irq/ipi-as-irq', remote-tracking branches 'origin/irq/dw' and 'origin/irq/owl' into irq/irqchip-next

Signed-off-by: Marc Zyngier <maz@kernel.org>

+537 -27
+65
Documentation/devicetree/bindings/interrupt-controller/actions,owl-sirq.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/interrupt-controller/actions,owl-sirq.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Actions Semi Owl SoCs SIRQ interrupt controller 8 + 9 + maintainers: 10 + - Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> 11 + - Cristian Ciocaltea <cristian.ciocaltea@gmail.com> 12 + 13 + description: | 14 + This interrupt controller is found in the Actions Semi Owl SoCs (S500, S700 15 + and S900) and provides support for handling up to 3 external interrupt lines. 16 + 17 + properties: 18 + compatible: 19 + enum: 20 + - actions,s500-sirq 21 + - actions,s700-sirq 22 + - actions,s900-sirq 23 + 24 + reg: 25 + maxItems: 1 26 + 27 + interrupt-controller: true 28 + 29 + '#interrupt-cells': 30 + const: 2 31 + description: 32 + The first cell is the input IRQ number, between 0 and 2, while the second 33 + cell is the trigger type as defined in interrupt.txt in this directory. 34 + 35 + 'interrupts': 36 + description: | 37 + Contains the GIC SPI IRQs mapped to the external interrupt lines. 38 + They shall be specified sequentially from output 0 to 2. 39 + minItems: 3 40 + maxItems: 3 41 + 42 + required: 43 + - compatible 44 + - reg 45 + - interrupt-controller 46 + - '#interrupt-cells' 47 + - 'interrupts' 48 + 49 + additionalProperties: false 50 + 51 + examples: 52 + - | 53 + #include <dt-bindings/interrupt-controller/arm-gic.h> 54 + 55 + sirq: interrupt-controller@b01b0200 { 56 + compatible = "actions,s500-sirq"; 57 + reg = <0xb01b0200 0x4>; 58 + interrupt-controller; 59 + #interrupt-cells = <2>; 60 + interrupts = <GIC_SPI 13 IRQ_TYPE_LEVEL_HIGH>, /* SIRQ0 */ 61 + <GIC_SPI 14 IRQ_TYPE_LEVEL_HIGH>, /* SIRQ1 */ 62 + <GIC_SPI 15 IRQ_TYPE_LEVEL_HIGH>; /* SIRQ2 */ 63 + }; 64 + 65 + ...
+13 -1
Documentation/devicetree/bindings/interrupt-controller/snps,dw-apb-ictl.txt
··· 2 2 3 3 Synopsys DesignWare provides interrupt controller IP for APB known as 4 4 dw_apb_ictl. The IP is used as secondary interrupt controller in some SoCs with 5 - APB bus, e.g. Marvell Armada 1500. 5 + APB bus, e.g. Marvell Armada 1500. It can also be used as primary interrupt 6 + controller in some SoCs, e.g. Hisilicon SD5203. 6 7 7 8 Required properties: 8 9 - compatible: shall be "snps,dw-apb-ictl" ··· 11 10 region starting with ENABLE_LOW register 12 11 - interrupt-controller: identifies the node as an interrupt controller 13 12 - #interrupt-cells: number of cells to encode an interrupt-specifier, shall be 1 13 + 14 + Additional required property when it's used as secondary interrupt controller: 14 15 - interrupts: interrupt reference to primary interrupt controller 15 16 16 17 The interrupt sources map to the corresponding bits in the interrupt ··· 24 21 - (optional) fast interrupts start at 64. 25 22 26 23 Example: 24 + /* dw_apb_ictl is used as secondary interrupt controller */ 27 25 aic: interrupt-controller@3000 { 28 26 compatible = "snps,dw-apb-ictl"; 29 27 reg = <0x3000 0xc00>; ··· 32 28 #interrupt-cells = <1>; 33 29 interrupt-parent = <&gic>; 34 30 interrupts = <GIC_SPI 3 IRQ_TYPE_LEVEL_HIGH>; 31 + }; 32 + 33 + /* dw_apb_ictl is used as primary interrupt controller */ 34 + vic: interrupt-controller@10130000 { 35 + compatible = "snps,dw-apb-ictl"; 36 + reg = <0x10130000 0x1000>; 37 + interrupt-controller; 38 + #interrupt-cells = <1>; 35 39 };
+2
MAINTAINERS
··· 1525 1525 F: Documentation/devicetree/bindings/clock/actions,owl-cmu.txt 1526 1526 F: Documentation/devicetree/bindings/dma/owl-dma.txt 1527 1527 F: Documentation/devicetree/bindings/i2c/i2c-owl.txt 1528 + F: Documentation/devicetree/bindings/interrupt-controller/actions,owl-sirq.yaml 1528 1529 F: Documentation/devicetree/bindings/mmc/owl-mmc.yaml 1529 1530 F: Documentation/devicetree/bindings/pinctrl/actions,s900-pinctrl.txt 1530 1531 F: Documentation/devicetree/bindings/power/actions,owl-sps.txt ··· 1537 1536 F: drivers/clocksource/timer-owl* 1538 1537 F: drivers/dma/owl-dma.c 1539 1538 F: drivers/i2c/busses/i2c-owl.c 1539 + F: drivers/irqchip/irq-owl-sirq.c 1540 1540 F: drivers/mmc/host/owl-mmc.c 1541 1541 F: drivers/pinctrl/actions/* 1542 1542 F: drivers/soc/actions/
+17 -13
arch/arm/kernel/smp.c
··· 85 85 static struct irq_desc *ipi_desc[MAX_IPI] __read_mostly; 86 86 87 87 static void ipi_setup(int cpu); 88 - static void ipi_teardown(int cpu); 89 88 90 89 static DECLARE_COMPLETION(cpu_running); 91 90 ··· 233 234 * of clock tick interrupts. 234 235 */ 235 236 return cpu != 0; 237 + } 238 + 239 + static void ipi_teardown(int cpu) 240 + { 241 + int i; 242 + 243 + if (WARN_ON_ONCE(!ipi_irq_base)) 244 + return; 245 + 246 + for (i = 0; i < nr_ipi; i++) 247 + disable_percpu_irq(ipi_irq_base + i); 236 248 } 237 249 238 250 /* ··· 541 531 unsigned int cpu, i; 542 532 543 533 for (i = 0; i < NR_IPI; i++) { 544 - unsigned int irq = irq_desc_get_irq(ipi_desc[i]); 534 + unsigned int irq; 535 + 536 + if (!ipi_desc[i]) 537 + continue; 538 + 539 + irq = irq_desc_get_irq(ipi_desc[i]); 545 540 seq_printf(p, "%*s%u: ", prec - 1, "IPI", i); 546 541 547 542 for_each_online_cpu(cpu) ··· 720 705 721 706 for (i = 0; i < nr_ipi; i++) 722 707 enable_percpu_irq(ipi_irq_base + i, 0); 723 - } 724 - 725 - static void ipi_teardown(int cpu) 726 - { 727 - int i; 728 - 729 - if (WARN_ON_ONCE(!ipi_irq_base)) 730 - return; 731 - 732 - for (i = 0; i < nr_ipi; i++) 733 - disable_percpu_irq(ipi_irq_base + i); 734 708 } 735 709 736 710 void __init set_smp_ipi_range(int ipi_base, int n)
+3 -1
arch/arm64/kernel/smp.c
··· 82 82 static struct irq_desc *ipi_desc[NR_IPI] __read_mostly; 83 83 84 84 static void ipi_setup(int cpu); 85 - static void ipi_teardown(int cpu); 86 85 87 86 #ifdef CONFIG_HOTPLUG_CPU 87 + static void ipi_teardown(int cpu); 88 88 static int op_cpu_kill(unsigned int cpu); 89 89 #else 90 90 static inline int op_cpu_kill(unsigned int cpu) ··· 964 964 enable_percpu_irq(ipi_irq_base + i, 0); 965 965 } 966 966 967 + #ifdef CONFIG_HOTPLUG_CPU 967 968 static void ipi_teardown(int cpu) 968 969 { 969 970 int i; ··· 975 974 for (i = 0; i < nr_ipi; i++) 976 975 disable_percpu_irq(ipi_irq_base + i); 977 976 } 977 + #endif 978 978 979 979 void __init set_smp_ipi_range(int ipi_base, int n) 980 980 {
+1 -1
drivers/irqchip/Kconfig
··· 148 148 config DW_APB_ICTL 149 149 bool 150 150 select GENERIC_IRQ_CHIP 151 - select IRQ_DOMAIN 151 + select IRQ_DOMAIN_HIERARCHY 152 152 153 153 config FARADAY_FTINTC010 154 154 bool
+1
drivers/irqchip/Makefile
··· 7 7 obj-$(CONFIG_ATH79) += irq-ath79-misc.o 8 8 obj-$(CONFIG_ARCH_BCM2835) += irq-bcm2835.o 9 9 obj-$(CONFIG_ARCH_BCM2835) += irq-bcm2836.o 10 + obj-$(CONFIG_ARCH_ACTIONS) += irq-owl-sirq.o 10 11 obj-$(CONFIG_DAVINCI_AINTC) += irq-davinci-aintc.o 11 12 obj-$(CONFIG_DAVINCI_CP_INTC) += irq-davinci-cp-intc.o 12 13 obj-$(CONFIG_EXYNOS_IRQ_COMBINER) += exynos-combiner.o
+70 -11
drivers/irqchip/irq-dw-apb-ictl.c
··· 17 17 #include <linux/irqchip/chained_irq.h> 18 18 #include <linux/of_address.h> 19 19 #include <linux/of_irq.h> 20 + #include <linux/interrupt.h> 20 21 21 22 #define APB_INT_ENABLE_L 0x00 22 23 #define APB_INT_ENABLE_H 0x04 ··· 27 26 #define APB_INT_FINALSTATUS_H 0x34 28 27 #define APB_INT_BASE_OFFSET 0x04 29 28 30 - static void dw_apb_ictl_handler(struct irq_desc *desc) 29 + /* irq domain of the primary interrupt controller. */ 30 + static struct irq_domain *dw_apb_ictl_irq_domain; 31 + 32 + static void __irq_entry dw_apb_ictl_handle_irq(struct pt_regs *regs) 33 + { 34 + struct irq_domain *d = dw_apb_ictl_irq_domain; 35 + int n; 36 + 37 + for (n = 0; n < d->revmap_size; n += 32) { 38 + struct irq_chip_generic *gc = irq_get_domain_generic_chip(d, n); 39 + u32 stat = readl_relaxed(gc->reg_base + APB_INT_FINALSTATUS_L); 40 + 41 + while (stat) { 42 + u32 hwirq = ffs(stat) - 1; 43 + 44 + handle_domain_irq(d, hwirq, regs); 45 + stat &= ~BIT(hwirq); 46 + } 47 + } 48 + } 49 + 50 + static void dw_apb_ictl_handle_irq_cascaded(struct irq_desc *desc) 31 51 { 32 52 struct irq_domain *d = irq_desc_get_handler_data(desc); 33 53 struct irq_chip *chip = irq_desc_get_chip(desc); ··· 65 43 u32 virq = irq_find_mapping(d, gc->irq_base + hwirq); 66 44 67 45 generic_handle_irq(virq); 68 - stat &= ~(1 << hwirq); 46 + stat &= ~BIT(hwirq); 69 47 } 70 48 } 71 49 72 50 chained_irq_exit(chip, desc); 73 51 } 52 + 53 + static int dw_apb_ictl_irq_domain_alloc(struct irq_domain *domain, unsigned int virq, 54 + unsigned int nr_irqs, void *arg) 55 + { 56 + int i, ret; 57 + irq_hw_number_t hwirq; 58 + unsigned int type = IRQ_TYPE_NONE; 59 + struct irq_fwspec *fwspec = arg; 60 + 61 + ret = irq_domain_translate_onecell(domain, fwspec, &hwirq, &type); 62 + if (ret) 63 + return ret; 64 + 65 + for (i = 0; i < nr_irqs; i++) 66 + irq_map_generic_chip(domain, virq + i, hwirq + i); 67 + 68 + return 0; 69 + } 70 + 71 + static const struct irq_domain_ops dw_apb_ictl_irq_domain_ops = { 72 + .translate = irq_domain_translate_onecell, 73 + .alloc = dw_apb_ictl_irq_domain_alloc, 74 + .free = irq_domain_free_irqs_top, 75 + }; 74 76 75 77 #ifdef CONFIG_PM 76 78 static void dw_apb_ictl_resume(struct irq_data *d) ··· 114 68 static int __init dw_apb_ictl_init(struct device_node *np, 115 69 struct device_node *parent) 116 70 { 71 + const struct irq_domain_ops *domain_ops; 117 72 unsigned int clr = IRQ_NOREQUEST | IRQ_NOPROBE | IRQ_NOAUTOEN; 118 73 struct resource r; 119 74 struct irq_domain *domain; 120 75 struct irq_chip_generic *gc; 121 76 void __iomem *iobase; 122 - int ret, nrirqs, irq, i; 77 + int ret, nrirqs, parent_irq, i; 123 78 u32 reg; 124 79 125 - /* Map the parent interrupt for the chained handler */ 126 - irq = irq_of_parse_and_map(np, 0); 127 - if (irq <= 0) { 128 - pr_err("%pOF: unable to parse irq\n", np); 129 - return -EINVAL; 80 + if (!parent) { 81 + /* Used as the primary interrupt controller */ 82 + parent_irq = 0; 83 + domain_ops = &dw_apb_ictl_irq_domain_ops; 84 + } else { 85 + /* Map the parent interrupt for the chained handler */ 86 + parent_irq = irq_of_parse_and_map(np, 0); 87 + if (parent_irq <= 0) { 88 + pr_err("%pOF: unable to parse irq\n", np); 89 + return -EINVAL; 90 + } 91 + domain_ops = &irq_generic_chip_ops; 130 92 } 131 93 132 94 ret = of_address_to_resource(np, 0, &r); ··· 174 120 else 175 121 nrirqs = fls(readl_relaxed(iobase + APB_INT_ENABLE_L)); 176 122 177 - domain = irq_domain_add_linear(np, nrirqs, 178 - &irq_generic_chip_ops, NULL); 123 + domain = irq_domain_add_linear(np, nrirqs, domain_ops, NULL); 179 124 if (!domain) { 180 125 pr_err("%pOF: unable to add irq domain\n", np); 181 126 ret = -ENOMEM; ··· 199 146 gc->chip_types[0].chip.irq_resume = dw_apb_ictl_resume; 200 147 } 201 148 202 - irq_set_chained_handler_and_data(irq, dw_apb_ictl_handler, domain); 149 + if (parent_irq) { 150 + irq_set_chained_handler_and_data(parent_irq, 151 + dw_apb_ictl_handle_irq_cascaded, domain); 152 + } else { 153 + dw_apb_ictl_irq_domain = domain; 154 + set_handle_irq(dw_apb_ictl_handle_irq); 155 + } 203 156 204 157 return 0; 205 158
+359
drivers/irqchip/irq-owl-sirq.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 2 + /* 3 + * Actions Semi Owl SoCs SIRQ interrupt controller driver 4 + * 5 + * Copyright (C) 2014 Actions Semi Inc. 6 + * David Liu <liuwei@actions-semi.com> 7 + * 8 + * Author: Parthiban Nallathambi <pn@denx.de> 9 + * Author: Saravanan Sekar <sravanhome@gmail.com> 10 + * Author: Cristian Ciocaltea <cristian.ciocaltea@gmail.com> 11 + */ 12 + 13 + #include <linux/bitfield.h> 14 + #include <linux/interrupt.h> 15 + #include <linux/irqchip.h> 16 + #include <linux/of_address.h> 17 + #include <linux/of_irq.h> 18 + 19 + #include <dt-bindings/interrupt-controller/arm-gic.h> 20 + 21 + #define NUM_SIRQ 3 22 + 23 + #define INTC_EXTCTL_PENDING BIT(0) 24 + #define INTC_EXTCTL_CLK_SEL BIT(4) 25 + #define INTC_EXTCTL_EN BIT(5) 26 + #define INTC_EXTCTL_TYPE_MASK GENMASK(7, 6) 27 + #define INTC_EXTCTL_TYPE_HIGH 0 28 + #define INTC_EXTCTL_TYPE_LOW BIT(6) 29 + #define INTC_EXTCTL_TYPE_RISING BIT(7) 30 + #define INTC_EXTCTL_TYPE_FALLING (BIT(6) | BIT(7)) 31 + 32 + /* S500 & S700 SIRQ control register masks */ 33 + #define INTC_EXTCTL_SIRQ0_MASK GENMASK(23, 16) 34 + #define INTC_EXTCTL_SIRQ1_MASK GENMASK(15, 8) 35 + #define INTC_EXTCTL_SIRQ2_MASK GENMASK(7, 0) 36 + 37 + /* S900 SIRQ control register offsets, relative to controller base address */ 38 + #define INTC_EXTCTL0 0x0000 39 + #define INTC_EXTCTL1 0x0328 40 + #define INTC_EXTCTL2 0x032c 41 + 42 + struct owl_sirq_params { 43 + /* INTC_EXTCTL reg shared for all three SIRQ lines */ 44 + bool reg_shared; 45 + /* INTC_EXTCTL reg offsets relative to controller base address */ 46 + u16 reg_offset[NUM_SIRQ]; 47 + }; 48 + 49 + struct owl_sirq_chip_data { 50 + const struct owl_sirq_params *params; 51 + void __iomem *base; 52 + raw_spinlock_t lock; 53 + u32 ext_irqs[NUM_SIRQ]; 54 + }; 55 + 56 + /* S500 & S700 SoCs */ 57 + static const struct owl_sirq_params owl_sirq_s500_params = { 58 + .reg_shared = true, 59 + .reg_offset = { 0, 0, 0 }, 60 + }; 61 + 62 + /* S900 SoC */ 63 + static const struct owl_sirq_params owl_sirq_s900_params = { 64 + .reg_shared = false, 65 + .reg_offset = { INTC_EXTCTL0, INTC_EXTCTL1, INTC_EXTCTL2 }, 66 + }; 67 + 68 + static u32 owl_field_get(u32 val, u32 index) 69 + { 70 + switch (index) { 71 + case 0: 72 + return FIELD_GET(INTC_EXTCTL_SIRQ0_MASK, val); 73 + case 1: 74 + return FIELD_GET(INTC_EXTCTL_SIRQ1_MASK, val); 75 + case 2: 76 + default: 77 + return FIELD_GET(INTC_EXTCTL_SIRQ2_MASK, val); 78 + } 79 + } 80 + 81 + static u32 owl_field_prep(u32 val, u32 index) 82 + { 83 + switch (index) { 84 + case 0: 85 + return FIELD_PREP(INTC_EXTCTL_SIRQ0_MASK, val); 86 + case 1: 87 + return FIELD_PREP(INTC_EXTCTL_SIRQ1_MASK, val); 88 + case 2: 89 + default: 90 + return FIELD_PREP(INTC_EXTCTL_SIRQ2_MASK, val); 91 + } 92 + } 93 + 94 + static u32 owl_sirq_read_extctl(struct owl_sirq_chip_data *data, u32 index) 95 + { 96 + u32 val; 97 + 98 + val = readl_relaxed(data->base + data->params->reg_offset[index]); 99 + if (data->params->reg_shared) 100 + val = owl_field_get(val, index); 101 + 102 + return val; 103 + } 104 + 105 + static void owl_sirq_write_extctl(struct owl_sirq_chip_data *data, 106 + u32 extctl, u32 index) 107 + { 108 + u32 val; 109 + 110 + if (data->params->reg_shared) { 111 + val = readl_relaxed(data->base + data->params->reg_offset[index]); 112 + val &= ~owl_field_prep(0xff, index); 113 + extctl = owl_field_prep(extctl, index) | val; 114 + } 115 + 116 + writel_relaxed(extctl, data->base + data->params->reg_offset[index]); 117 + } 118 + 119 + static void owl_sirq_clear_set_extctl(struct owl_sirq_chip_data *d, 120 + u32 clear, u32 set, u32 index) 121 + { 122 + unsigned long flags; 123 + u32 val; 124 + 125 + raw_spin_lock_irqsave(&d->lock, flags); 126 + val = owl_sirq_read_extctl(d, index); 127 + val &= ~clear; 128 + val |= set; 129 + owl_sirq_write_extctl(d, val, index); 130 + raw_spin_unlock_irqrestore(&d->lock, flags); 131 + } 132 + 133 + static void owl_sirq_eoi(struct irq_data *data) 134 + { 135 + struct owl_sirq_chip_data *chip_data = irq_data_get_irq_chip_data(data); 136 + 137 + /* 138 + * Software must clear external interrupt pending, when interrupt type 139 + * is edge triggered, so we need per SIRQ based clearing. 140 + */ 141 + if (!irqd_is_level_type(data)) 142 + owl_sirq_clear_set_extctl(chip_data, 0, INTC_EXTCTL_PENDING, 143 + data->hwirq); 144 + 145 + irq_chip_eoi_parent(data); 146 + } 147 + 148 + static void owl_sirq_mask(struct irq_data *data) 149 + { 150 + struct owl_sirq_chip_data *chip_data = irq_data_get_irq_chip_data(data); 151 + 152 + owl_sirq_clear_set_extctl(chip_data, INTC_EXTCTL_EN, 0, data->hwirq); 153 + irq_chip_mask_parent(data); 154 + } 155 + 156 + static void owl_sirq_unmask(struct irq_data *data) 157 + { 158 + struct owl_sirq_chip_data *chip_data = irq_data_get_irq_chip_data(data); 159 + 160 + owl_sirq_clear_set_extctl(chip_data, 0, INTC_EXTCTL_EN, data->hwirq); 161 + irq_chip_unmask_parent(data); 162 + } 163 + 164 + /* 165 + * GIC does not handle falling edge or active low, hence SIRQ shall be 166 + * programmed to convert falling edge to rising edge signal and active 167 + * low to active high signal. 168 + */ 169 + static int owl_sirq_set_type(struct irq_data *data, unsigned int type) 170 + { 171 + struct owl_sirq_chip_data *chip_data = irq_data_get_irq_chip_data(data); 172 + u32 sirq_type; 173 + 174 + switch (type) { 175 + case IRQ_TYPE_LEVEL_LOW: 176 + sirq_type = INTC_EXTCTL_TYPE_LOW; 177 + type = IRQ_TYPE_LEVEL_HIGH; 178 + break; 179 + case IRQ_TYPE_LEVEL_HIGH: 180 + sirq_type = INTC_EXTCTL_TYPE_HIGH; 181 + break; 182 + case IRQ_TYPE_EDGE_FALLING: 183 + sirq_type = INTC_EXTCTL_TYPE_FALLING; 184 + type = IRQ_TYPE_EDGE_RISING; 185 + break; 186 + case IRQ_TYPE_EDGE_RISING: 187 + sirq_type = INTC_EXTCTL_TYPE_RISING; 188 + break; 189 + default: 190 + return -EINVAL; 191 + } 192 + 193 + owl_sirq_clear_set_extctl(chip_data, INTC_EXTCTL_TYPE_MASK, sirq_type, 194 + data->hwirq); 195 + 196 + return irq_chip_set_type_parent(data, type); 197 + } 198 + 199 + static struct irq_chip owl_sirq_chip = { 200 + .name = "owl-sirq", 201 + .irq_mask = owl_sirq_mask, 202 + .irq_unmask = owl_sirq_unmask, 203 + .irq_eoi = owl_sirq_eoi, 204 + .irq_set_type = owl_sirq_set_type, 205 + .irq_retrigger = irq_chip_retrigger_hierarchy, 206 + #ifdef CONFIG_SMP 207 + .irq_set_affinity = irq_chip_set_affinity_parent, 208 + #endif 209 + }; 210 + 211 + static int owl_sirq_domain_translate(struct irq_domain *d, 212 + struct irq_fwspec *fwspec, 213 + unsigned long *hwirq, 214 + unsigned int *type) 215 + { 216 + if (!is_of_node(fwspec->fwnode)) 217 + return -EINVAL; 218 + 219 + if (fwspec->param_count != 2 || fwspec->param[0] >= NUM_SIRQ) 220 + return -EINVAL; 221 + 222 + *hwirq = fwspec->param[0]; 223 + *type = fwspec->param[1]; 224 + 225 + return 0; 226 + } 227 + 228 + static int owl_sirq_domain_alloc(struct irq_domain *domain, unsigned int virq, 229 + unsigned int nr_irqs, void *data) 230 + { 231 + struct owl_sirq_chip_data *chip_data = domain->host_data; 232 + struct irq_fwspec *fwspec = data; 233 + struct irq_fwspec parent_fwspec; 234 + irq_hw_number_t hwirq; 235 + unsigned int type; 236 + int ret; 237 + 238 + if (WARN_ON(nr_irqs != 1)) 239 + return -EINVAL; 240 + 241 + ret = owl_sirq_domain_translate(domain, fwspec, &hwirq, &type); 242 + if (ret) 243 + return ret; 244 + 245 + switch (type) { 246 + case IRQ_TYPE_EDGE_RISING: 247 + case IRQ_TYPE_LEVEL_HIGH: 248 + break; 249 + case IRQ_TYPE_EDGE_FALLING: 250 + type = IRQ_TYPE_EDGE_RISING; 251 + break; 252 + case IRQ_TYPE_LEVEL_LOW: 253 + type = IRQ_TYPE_LEVEL_HIGH; 254 + break; 255 + default: 256 + return -EINVAL; 257 + } 258 + 259 + irq_domain_set_hwirq_and_chip(domain, virq, hwirq, &owl_sirq_chip, 260 + chip_data); 261 + 262 + parent_fwspec.fwnode = domain->parent->fwnode; 263 + parent_fwspec.param_count = 3; 264 + parent_fwspec.param[0] = GIC_SPI; 265 + parent_fwspec.param[1] = chip_data->ext_irqs[hwirq]; 266 + parent_fwspec.param[2] = type; 267 + 268 + return irq_domain_alloc_irqs_parent(domain, virq, 1, &parent_fwspec); 269 + } 270 + 271 + static const struct irq_domain_ops owl_sirq_domain_ops = { 272 + .translate = owl_sirq_domain_translate, 273 + .alloc = owl_sirq_domain_alloc, 274 + .free = irq_domain_free_irqs_common, 275 + }; 276 + 277 + static int __init owl_sirq_init(const struct owl_sirq_params *params, 278 + struct device_node *node, 279 + struct device_node *parent) 280 + { 281 + struct irq_domain *domain, *parent_domain; 282 + struct owl_sirq_chip_data *chip_data; 283 + int ret, i; 284 + 285 + parent_domain = irq_find_host(parent); 286 + if (!parent_domain) { 287 + pr_err("%pOF: failed to find sirq parent domain\n", node); 288 + return -ENXIO; 289 + } 290 + 291 + chip_data = kzalloc(sizeof(*chip_data), GFP_KERNEL); 292 + if (!chip_data) 293 + return -ENOMEM; 294 + 295 + raw_spin_lock_init(&chip_data->lock); 296 + 297 + chip_data->params = params; 298 + 299 + chip_data->base = of_iomap(node, 0); 300 + if (!chip_data->base) { 301 + pr_err("%pOF: failed to map sirq registers\n", node); 302 + ret = -ENXIO; 303 + goto out_free; 304 + } 305 + 306 + for (i = 0; i < NUM_SIRQ; i++) { 307 + struct of_phandle_args irq; 308 + 309 + ret = of_irq_parse_one(node, i, &irq); 310 + if (ret) { 311 + pr_err("%pOF: failed to parse interrupt %d\n", node, i); 312 + goto out_unmap; 313 + } 314 + 315 + if (WARN_ON(irq.args_count != 3)) { 316 + ret = -EINVAL; 317 + goto out_unmap; 318 + } 319 + 320 + chip_data->ext_irqs[i] = irq.args[1]; 321 + 322 + /* Set 24MHz external interrupt clock freq */ 323 + owl_sirq_clear_set_extctl(chip_data, 0, INTC_EXTCTL_CLK_SEL, i); 324 + } 325 + 326 + domain = irq_domain_add_hierarchy(parent_domain, 0, NUM_SIRQ, node, 327 + &owl_sirq_domain_ops, chip_data); 328 + if (!domain) { 329 + pr_err("%pOF: failed to add domain\n", node); 330 + ret = -ENOMEM; 331 + goto out_unmap; 332 + } 333 + 334 + return 0; 335 + 336 + out_unmap: 337 + iounmap(chip_data->base); 338 + out_free: 339 + kfree(chip_data); 340 + 341 + return ret; 342 + } 343 + 344 + static int __init owl_sirq_s500_of_init(struct device_node *node, 345 + struct device_node *parent) 346 + { 347 + return owl_sirq_init(&owl_sirq_s500_params, node, parent); 348 + } 349 + 350 + IRQCHIP_DECLARE(owl_sirq_s500, "actions,s500-sirq", owl_sirq_s500_of_init); 351 + IRQCHIP_DECLARE(owl_sirq_s700, "actions,s700-sirq", owl_sirq_s500_of_init); 352 + 353 + static int __init owl_sirq_s900_of_init(struct device_node *node, 354 + struct device_node *parent) 355 + { 356 + return owl_sirq_init(&owl_sirq_s900_params, node, parent); 357 + } 358 + 359 + IRQCHIP_DECLARE(owl_sirq_s900, "actions,s900-sirq", owl_sirq_s900_of_init);
+6
include/linux/irq.h
··· 1255 1255 * top-level IRQ handler. 1256 1256 */ 1257 1257 extern void (*handle_arch_irq)(struct pt_regs *) __ro_after_init; 1258 + #else 1259 + #define set_handle_irq(handle_irq) \ 1260 + do { \ 1261 + (void)handle_irq; \ 1262 + WARN_ON(1); \ 1263 + } while (0) 1258 1264 #endif 1259 1265 1260 1266 #endif /* _LINUX_IRQ_H */