[03/12] irqchip/stm32-exti: Map interrupts through interrupt nexus node
Commit Message
The mapping of EXTI interrupts to its parent interrupt controller
is both SoC and instance dependent.
The current implementation requires adding a new table to the
driver's code and a new compatible for each new EXTI instance.
Check for the presence of the optional interrupt nexus child node
and use its property 'interrup-map' to map EXTI interrupts to the
parent's interrupts.
For old DT's without the optional nexus child node, the driver's
behavior is unchanged, thus keeps backward compatibility.
Signed-off-by: Antonio Borneo <antonio.borneo@foss.st.com>
---
drivers/irqchip/irq-stm32-exti.c | 29 +++++++++++++++++++++++++++--
1 file changed, 27 insertions(+), 2 deletions(-)
Comments
On Fri, Feb 16 2024 at 10:47, Antonio Borneo wrote:
> diff --git a/drivers/irqchip/irq-stm32-exti.c b/drivers/irqchip/irq-stm32-exti.c
> index 69982f21126a..95bb3dd10b2c 100644
> --- a/drivers/irqchip/irq-stm32-exti.c
> +++ b/drivers/irqchip/irq-stm32-exti.c
> @@ -61,6 +61,7 @@ struct stm32_exti_host_data {
> struct stm32_exti_chip_data *chips_data;
> const struct stm32_exti_drv_data *drv_data;
> struct hwspinlock *hwlock;
> + struct device_node *irq_map_node;
Please keep variable declarations ordered in reverse fir tree layout:
https://www.kernel.org/doc/html/latest/process/maintainer-tip.html#variable-declarations
> };
>
> static struct stm32_exti_host_data *stm32_host_data;
> @@ -713,8 +714,9 @@ static int stm32_exti_h_domain_alloc(struct irq_domain *dm,
> u8 desc_irq;
> struct irq_fwspec *fwspec = data;
> struct irq_fwspec p_fwspec;
> + struct of_phandle_args out_irq;
Please move this into the condition path where it is actually used.
> irq_hw_number_t hwirq;
> - int bank;
> + int bank, ret;
> u32 event_trg;
> struct irq_chip *chip;
>
> @@ -731,6 +733,25 @@ static int stm32_exti_h_domain_alloc(struct irq_domain *dm,
>
> irq_domain_set_hwirq_and_chip(dm, virq, hwirq, chip, chip_data);
>
> + if (host_data->irq_map_node) {
> + out_irq.np = host_data->irq_map_node;
Thanks,
tglx
@@ -61,6 +61,7 @@ struct stm32_exti_host_data {
struct stm32_exti_chip_data *chips_data;
const struct stm32_exti_drv_data *drv_data;
struct hwspinlock *hwlock;
+ struct device_node *irq_map_node;
};
static struct stm32_exti_host_data *stm32_host_data;
@@ -713,8 +714,9 @@ static int stm32_exti_h_domain_alloc(struct irq_domain *dm,
u8 desc_irq;
struct irq_fwspec *fwspec = data;
struct irq_fwspec p_fwspec;
+ struct of_phandle_args out_irq;
irq_hw_number_t hwirq;
- int bank;
+ int bank, ret;
u32 event_trg;
struct irq_chip *chip;
@@ -731,6 +733,25 @@ static int stm32_exti_h_domain_alloc(struct irq_domain *dm,
irq_domain_set_hwirq_and_chip(dm, virq, hwirq, chip, chip_data);
+ if (host_data->irq_map_node) {
+ out_irq.np = host_data->irq_map_node;
+ out_irq.args_count = 2;
+ out_irq.args[0] = fwspec->param[0];
+ out_irq.args[1] = fwspec->param[1];
+
+ ret = of_irq_parse_raw(NULL, &out_irq);
+ if (ret)
+ return ret;
+ /* we only support one parent, so far */
+ if (of_node_to_fwnode(out_irq.np) != dm->parent->fwnode)
+ return -EINVAL;
+
+ of_phandle_args_to_fwspec(out_irq.np, out_irq.args,
+ out_irq.args_count, &p_fwspec);
+
+ return irq_domain_alloc_irqs_parent(dm, virq, 1, &p_fwspec);
+ }
+
if (!host_data->drv_data->desc_irqs)
return -EINVAL;
@@ -908,7 +929,7 @@ static int stm32_exti_probe(struct platform_device *pdev)
{
int ret, i;
struct device *dev = &pdev->dev;
- struct device_node *np = dev->of_node;
+ struct device_node *child, *np = dev->of_node;
struct irq_domain *parent_domain, *domain;
struct stm32_exti_host_data *host_data;
const struct stm32_exti_drv_data *drv_data;
@@ -976,6 +997,10 @@ static int stm32_exti_probe(struct platform_device *pdev)
if (ret)
return ret;
+ child = of_get_child_by_name(np, "exti-interrupt-map");
+ if (child && of_property_read_bool(child, "interrupt-map"))
+ host_data->irq_map_node = child;
+
stm32_exti_h_syscore_init(host_data);
return 0;