irqchip: qcom: Add IRQ combiner driver
v4 cover irqchip: qcom: Add IRQ combiner driver
Add support for IRQ combiners in the Top-level Control and Status Registers (TCSR) hardware block in Qualcomm Technologies chips.
The first patch adds support for ResourceSource/IRQ domain mapping when using Extended IRQ Resources with a specific ResourceSource. The core ACPI resource management code has been changed to lookup the IRQ domain when an IRQ resource indicates a ResourceSource, and register the IRQ on that domain, instead of a GSI.
The second patch takes advantage of the new capabilities to implement the driver for the IRQ combiners.
Changes V1 -> V2:
* Remove use of GPIO library for the combiner
* Refactor to use fwnode/ResourceSource to IRQ domain mapping introduced in ACPI core
Changes V2 -> V3:
* Removed parsing of _PRS to find IRQs
* Removed acpi_irq_domain_create and acpi_irq_domain_remove
Changes V3 -> V3:
* Add a DSDT device probe table that is used to probe DSDT IRQ chips as necessary when converting HW IRQs to Linux IRQs
* Describe IRQ combiner registers as ACPI Register resources
Agustin Vega-Frias (2):
ACPI: Add support for ResourceSource/IRQ domain mapping
irqchip: qcom: Add IRQ combiner driver
drivers/acpi/Makefile | 1 + drivers/acpi/irqdomain.c | 135 +++++++++++++++ drivers/acpi/resource.c | 21 ++- drivers/irqchip/Kconfig | 8 + drivers/irqchip/Makefile | 1 + drivers/irqchip/qcom-irq-combiner.c | 332 ++++++++++++++++++++++++++++++++++++ include/asm-generic/vmlinux.lds.h | 1 + include/linux/acpi.h | 50 ++++++ include/linux/irqchip.h | 17 +- 9 files changed, 554 insertions(+), 12 deletions(-) create mode 100644 drivers/acpi/irqdomain.c create mode 100644 drivers/irqchip/qcom-irq-combiner.c
Signature · 2 lines
Qualcomm Datacenter Technologies, Inc. on behalf of the Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
PATCH v4 1/2 ACPI: Add support for ResourceSource/IRQ domain mapping
This allows irqchip drivers to associate an ACPI DSDT device to an IRQ domain and provides support for using the ResourceSource in Extended IRQ Resources to find the domain and map the IRQs specified on that domain.
--- drivers/acpi/Makefile | 1 + drivers/acpi/irqdomain.c | 135 ++++++++++++++++++++++++++++++++++++++ drivers/acpi/resource.c | 21 +++--- include/asm-generic/vmlinux.lds.h | 1 + include/linux/acpi.h | 50 ++++++++++++++ include/linux/irqchip.h | 17 ++++- 6 files changed, 213 insertions(+), 12 deletions(-) create mode 100644 drivers/acpi/irqdomain.c
drivers/acpi/Makefile +1 -0
@@ -57,6 +57,7 @@ acpi-$(CONFIG_ACPI_PROCFS_POWER) += cm_sbs.o acpi-y += acpi_lpat.o acpi-$(CONFIG_ACPI_GENERIC_GSI) += gsi.o acpi-$(CONFIG_ACPI_WATCHDOG) += acpi_watchdog.o +acpi-y += irqdomain.o # These are (potentially) separate modules
drivers/acpi/irqdomain.c new file +135 -0
135 lines not on this page · raw message
drivers/acpi/resource.c +12 -9
@@ -381,14 +381,15 @@ static void acpi_dev_irqresource_disabled(struct resource *res, u32 gsi) res->flags =IORESOURCE_IRQ |IORESOURCE_DISABLED |IORESOURCE_UNSET ; } -static void acpi_dev_get_irqresource (struct resource *res,u32 gsi, +static void acpi_dev_get_irqresource (struct resource *res,u32 hwirq, +struct acpi_resource_source *source,u8 triggering,u8 polarity,u8 shareable,bool legacy) {int irq, p, t; -if (!valid_IRQ (gsi)) { -acpi_dev_irqresource_disabled (res, gsi); +if ((source->string_length ==0 ) && !valid_IRQ (hwirq)) { +acpi_dev_irqresource_disabled (res, hwirq);return ; }
@@ -402,25 +403,25 @@ static void acpi_dev_get_irqresource(struct resource *res, u32 gsi,* using extended IRQ descriptors we take the IRQ configuration * from _CRS directly. */ -if (legacy && !acpi_get_override_irq (gsi, &t, &p)) { +if (legacy && !acpi_get_override_irq (hwirq, &t, &p)) {u8 trig = t ?ACPI_LEVEL_SENSITIVE :ACPI_EDGE_SENSITIVE ;u8 pol = p ?ACPI_ACTIVE_LOW :ACPI_ACTIVE_HIGH ;if (triggering != trig || polarity != pol) { -pr_warning ("ACPI: IRQ %d override to %s, %s\n" , gsi, - t ?"level" :"edge" , p ?"low" :"high" ); +pr_warn ("ACPI: IRQ %d override to %s, %s\n" , hwirq, + t ?"level" :"edge" , p ?"low" :"high" ); triggering = trig; polarity = pol; } } res->flags =acpi_dev_irq_flags (triggering, polarity, shareable); - irq =acpi_register_gsi (NULL , gsi, triggering, polarity); + irq =acpi_irq_domain_register_irq (source, hwirq, triggering, polarity);if (irq >=0 ) { res->start = irq; res->end = irq; }else { -acpi_dev_irqresource_disabled (res, gsi); +acpi_dev_irqresource_disabled (res, hwirq); } }
@@ -448,6 +449,7 @@ bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index, {struct acpi_resource_irq *irq;struct acpi_resource_extended_irq *ext_irq; +struct acpi_resource_source dummy = {0 ,0 ,NULL };switch (ares->type) {case ACPI_RESOURCE_TYPE_IRQ :
@@ -460,7 +462,7 @@ bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index,acpi_dev_irqresource_disabled (res,0 );return false; } -acpi_dev_get_irqresource (res, irq->interrupts[index], +acpi_dev_get_irqresource (res, irq->interrupts[index], &dummy, irq->triggering, irq->polarity, irq->sharable, true);break ;
@@ -471,6 +473,7 @@ bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index,return false; }acpi_dev_get_irqresource (res, ext_irq->interrupts[index], + &ext_irq->resource_source, ext_irq->triggering, ext_irq->polarity, ext_irq->sharable, false);break ;
include/asm-generic/vmlinux.lds.h +1 -0
@@ -563,6 +563,7 @@ IRQCHIP_OF_MATCH_TABLE() \ ACPI_PROBE_TABLE(irqchip) \ ACPI_PROBE_TABLE(clksrc) \ + ACPI_PROBE_TABLE(dsdt) \ EARLYCON_TABLE()#define INIT_TEXT \
include/linux/acpi.h +50 -0
74 lines not on this page · raw message
include/linux/irqchip.h +14 -3
@@ -29,6 +29,10 @@/* * This macro must be used by the different irqchip drivers to declare * the association between their version and their initialization function. +* Two syntaxes are supported depending on the table where the irqchip device +* is declared: +* +* - MADT irqchip syntax, which requires the following five arguments: * * @name: name that must be unique accross all IRQCHIP_ACPI_DECLARE of the * same file.
@@ -37,10 +41,17 @@* Can be NULL. * @data: data to be checked by the validate function. * @fn: initialization function +* +* - DSDT irqchip syntax, which requires the following three arguments: +* +* @name: name that must be unique across all IRQCHIP_ACPI_DECLARE of the +* same file. +* @hid: _HID of the DSDT device +* @fn: initialization function */ -#define IRQCHIP_ACPI_DECLARE (name, subtable, validate, data, fn) \ - ACPI_DECLARE_PROBE_ENTRY(irqchip, name, ACPI_SIG_MADT, \ - subtable, validate, data, fn) + +#define IRQCHIP_ACPI_DECLARE (...) \ + __IRQCHIP_ACPI_DECLARE(__VA_ARGS__, MADT, _unused, DSDT)(__VA_ARGS__)#ifdef CONFIG_IRQCHIP void irqchip_init (void );
Signature · 2 lines
Qualcomm Datacenter Technologies, Inc. on behalf of the Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Re: [PATCH V4 1/2] ACPI: Add support for ResourceSource/IRQ domain mapping
Just a few nits:
drivers/acpi/irqdomain.c line 65
Quoted 10 lines · Agustin Vega-Frias
drivers/acpi/irqdomain.c new file +10
-0+int acpi_irq_domain_register_irq (struct acpi_resource_source *source,u32 hwirq, +int trigger,int polarity) +{ +struct irq_fwspec fwspec; +struct acpi_device *device; +acpi_handle handle; +acpi_status status; +int ret; + +if (source->string_length ==0 )
Would (!source->string_length) be more meaningful?
Quoted 11 lines
drivers/acpi/irqdomain.c new file +11
-0+return acpi_register_gsi (NULL , hwirq, trigger, polarity); + + status =acpi_get_handle (NULL , source->string_ptr, &handle); +if (ACPI_FAILURE (status)) +return -ENODEV ; + + device =acpi_bus_get_acpi_device (handle); +if (!device) +return -ENODEV ; + +if (acpi_irq_domain_ensure_probed (device))
drivers/acpi/irqdomain.c line 86
Quoted 10 lines
drivers/acpi/irqdomain.c new file +10
-0+return -ENODEV ; + + fwspec.fwnode = &device->fwnode; + fwspec.param[0 ] = hwirq; + fwspec.param[1 ] =acpi_dev_get_irq_type (trigger, polarity); + fwspec.param_count =2 ; + + ret =irq_create_fwspec_mapping (&fwspec); +acpi_bus_put_acpi_device (device); +return ret;
Blank line before 'return'.
drivers/acpi/resource.c static void acpi_dev_irqresource_disabled(struct resource *res, u32 gsi) · line 385
Quoted 3 lines
drivers/acpi/resource.c +2
-1-static void acpi_dev_get_irqresource(struct resource *res, u32 gsi, +static void acpi_dev_get_irqresource(struct resource *res, u32 hwirq, + struct acpi_resource_source *source,
This should probably be a 'const', because ...
drivers/acpi/resource.c bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index, · line 452
Quoted 5 lines
drivers/acpi/resource.c +1
-0@@ -448,6 +449,7 @@ bool acpi_dev_resource_interrupt(struct acpi_resource *ares, int index, {struct acpi_resource_irq *irq;struct acpi_resource_extended_irq *ext_irq; +struct acpi_resource_source dummy = {0 ,0 ,NULL };
... then you can make this a static const, which will reduce code size and improve performance.
include/linux/acpi.h struct acpi_probe_entry { · line 1034
Quoted 6 lines
include/linux/acpi.h +2
-0@@ -1024,6 +1030,43 @@ struct acpi_probe_entry { (&ACPI_PROBE_TABLE_END (t) - \ &ACPI_PROBE_TABLE(t))); \ }) + +#define ACPI_HID_LEN 9
Please add a comment for this.
Signature · 3 lines
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
PATCH v4 2/2 irqchip: qcom: Add IRQ combiner driver
In reply to Agustin Vega-FriasDriver for interrupt combiners in the Top-level Control and Status Registers (TCSR) hardware block in Qualcomm Technologies chips.
An interrupt combiner in this block combines a set of interrupts by OR'ing the individual interrupt signals into a summary interrupt signal routed to a parent interrupt controller, and provides read- only, 32-bit registers to query the status of individual interrupts. The status bit for IRQ n is bit (n % 32) within register (n / 32) of the given combiner. Thus, each combiner can be described as a set of register offsets and the number of IRQs managed.
--- drivers/irqchip/Kconfig | 8 + drivers/irqchip/Makefile | 1 + drivers/irqchip/qcom-irq-combiner.c | 332 ++++++++++++++++++++++++++++++++++++ 3 files changed, 341 insertions(+) create mode 100644 drivers/irqchip/qcom-irq-combiner.c
drivers/irqchip/Kconfig +8 -0
@@ -279,3 +279,11 @@ config EZNPS_GIC config STM32_EXTI bool select IRQ_DOMAIN + +config QCOM_IRQ_COMBINER + bool "QCOM IRQ combiner support" + depends on ARCH_QCOM + select IRQ_DOMAIN + help + Say yes here to add support for the IRQ combiner devices embedded + in Qualcomm Technologies chips.
drivers/irqchip/Makefile +1 -0
@@ -74,3 +74,4 @@ obj-$(CONFIG_LS_SCFG_MSI) += irq-ls-scfg-msi.o obj-$(CONFIG_EZNPS_GIC) += irq-eznps.o obj-$(CONFIG_ARCH_ASPEED) += irq-aspeed-vic.o obj-$(CONFIG_STM32_EXTI) += irq-stm32-exti.o +obj-$(CONFIG_QCOM_IRQ_COMBINER) += qcom-irq-combiner.o
drivers/irqchip/qcom-irq-combiner.c new file +332 -0
332 lines not on this page · raw message
Signature · 2 lines
Qualcomm Datacenter Technologies, Inc. on behalf of the Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.