Skip to contentSkip to conversation

of: irq: Pass trigger type in IRQ resource flags

PATCH In review Tomasz Figa 3 participants 4 messages May 18, 2013 – Jun 15, 2013 Device tree

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 of: irq: Pass trigger type in IRQ resource flags

Some drivers might rely on availability of trigger flags in IRQ resource, for example to configure the hardware for particular interrupt type. However current code creating IRQ resources from data in device tree does not configure trigger flags in resulting resources.

This patch solves the problem, based on the fact that irq_of_parse_and_map() configures the trigger based on DT interrupt specifier, IRQD_TRIGGER_* flags are consistent with IORESOURCE_IRQ_*, and we can get trigger type by calling irqd_get_trigger_type() after mapping the interrupt.

---
 drivers/of/irq.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/of/irq.c +10 -0
index a3c1c5a..79a7a26 100644
@@ -355,6 +355,16 @@ int of_irq_to_resource(struct device_node *dev, int index, struct resource *r)
 		r->start = r->end = irq;
 		r->flags = IORESOURCE_IRQ;
 		r->name = name ? name : dev->full_name;
+
+		/*
+		 * Some drivers might rely on availability of trigger flags
+		 * in IRQ resource. Since irq_of_parse_and_map() configures the
+		 * trigger based on interrupt specifier and IRQD_TRIGGER_*
+		 * flags are consistent with IORESOURCE_IRQ_*, we can get
+		 * trigger type that was just set and pass it through resource
+		 * flags as well.
+		 */
+		r->flags |= irqd_get_trigger_type(irq_get_irq_data(irq));
 	}
 
 	return irq;
Signature · 1 line
1.8.2.1
#1 lore raw

Hi,

Quoted 21 lines · On Sunday 19 of May 2013 00:56:30 Tomasz Figa wrote:

Some drivers might rely on availability of trigger flags in IRQ resource, for example to configure the hardware for particular interrupt type. However current code creating IRQ resources from data in device tree does not configure trigger flags in resulting resources.

This patch solves the problem, based on the fact that irq_of_parse_and_map() configures the trigger based on DT interrupt specifier, IRQD_TRIGGER_* flags are consistent with IORESOURCE_IRQ_*, and we can get trigger type by calling irqd_get_trigger_type() after mapping the interrupt.

---
 drivers/of/irq.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/of/irq.c +0 -0
index a3c1c5a..79a7a26 100644

drivers/of/irq.c int of_irq_to_resource(struct device_node *dev, int · line 360

Quoted 6 lines
drivers/of/irq.c +3 -0
@@ -355,6 +355,16 @@ int of_irq_to_resource(struct device_node *dev, int
 index, struct resource *r) r->start = r->end = irq;
 		r->flags = IORESOURCE_IRQ;
 		r->name = name ? name : dev->full_name;
+
+		/*
+		 * Some drivers might rely on availability of trigger 

flags

drivers/of/irq.c int of_irq_to_resource(struct device_node *dev, int · line 361

Quoted 1 line
drivers/of/irq.c +1 -0
+		 * in IRQ resource. Since irq_of_parse_and_map() 

configures the

drivers/of/irq.c int of_irq_to_resource(struct device_node *dev, int index, struct resource *r)

Quoted 3 lines
drivers/of/irq.c +3 -0
+		 * trigger based on interrupt specifier and IRQD_TRIGGER_*
+		 * flags are consistent with IORESOURCE_IRQ_*, we can get
+		 * trigger type that was just set and pass it through 

resource

drivers/of/irq.c int of_irq_to_resource(struct device_node *dev, int index, struct resource *r) · line 370

Quoted 6 lines
drivers/of/irq.c +3 -0
+		 * flags as well.
+		 */
+		r->flags |= irqd_get_trigger_type(irq_get_irq_data(irq));
 	}
 
 	return irq;

Any comments on this patch?

Best regards,
Tomasz

#2 lore raw
Quoted 37 lines · Tomasz Figa

Hi,

Quoted 21 lines · On Sunday 19 of May 2013 00:56:30 Tomasz Figa wrote:

Some drivers might rely on availability of trigger flags in IRQ resource, for example to configure the hardware for particular interrupt type. However current code creating IRQ resources from data in device tree does not configure trigger flags in resulting resources.

This patch solves the problem, based on the fact that irq_of_parse_and_map() configures the trigger based on DT interrupt specifier, IRQD_TRIGGER_* flags are consistent with IORESOURCE_IRQ_*, and we can get trigger type by calling irqd_get_trigger_type() after mapping the interrupt.

---
 drivers/of/irq.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/of/irq.c +0 -0
index a3c1c5a..79a7a26 100644

drivers/of/irq.c int of_irq_to_resource(struct device_node *dev, int · line 360

Quoted 6 lines
drivers/of/irq.c +3 -0
@@ -355,6 +355,16 @@ int of_irq_to_resource(struct device_node *dev, int
 index, struct resource *r) r->start = r->end = irq;
 		r->flags = IORESOURCE_IRQ;
 		r->name = name ? name : dev->full_name;
+
+		/*
+		 * Some drivers might rely on availability of trigger 

flags

drivers/of/irq.c int of_irq_to_resource(struct device_node *dev, int · line 361

Quoted 1 line
drivers/of/irq.c +1 -0
+		 * in IRQ resource. Since irq_of_parse_and_map() 

configures the

drivers/of/irq.c int of_irq_to_resource(struct device_node *dev, int index, struct resource *r)

Quoted 3 lines
drivers/of/irq.c +3 -0
+		 * trigger based on interrupt specifier and IRQD_TRIGGER_*
+		 * flags are consistent with IORESOURCE_IRQ_*, we can get
+		 * trigger type that was just set and pass it through 

resource

Quoted 8 lines

drivers/of/irq.c int of_irq_to_resource(struct device_node *dev, int index, struct resource *r) · line 370

Quoted 6 lines
drivers/of/irq.c +3 -0
+		 * flags as well.
+		 */
+		r->flags |= irqd_get_trigger_type(irq_get_irq_data(irq));
 	}
 
 	return irq;

Any comments on this patch?

That's actually a pretty good solution and a whole lot less invasive that the approach that Javier was pursuing. Javier, I'm going to pick up this patch. Please yell if it doesn't solve the problem that you're trying to solve.

g.

#3 lore raw
Quoted 45 lines · Grant Likely
Quoted 44 lines · Tomasz Figa

Hi,

Quoted 21 lines · On Sunday 19 of May 2013 00:56:30 Tomasz Figa wrote:

Some drivers might rely on availability of trigger flags in IRQ resource, for example to configure the hardware for particular interrupt type. However current code creating IRQ resources from data in device tree does not configure trigger flags in resulting resources.

This patch solves the problem, based on the fact that irq_of_parse_and_map() configures the trigger based on DT interrupt specifier, IRQD_TRIGGER_* flags are consistent with IORESOURCE_IRQ_*, and we can get trigger type by calling irqd_get_trigger_type() after mapping the interrupt.

---
drivers/of/irq.c | 10 ++++++++++

1 file changed, 10 insertions(+)
drivers/of/irq.c +0 -0
index a3c1c5a..79a7a26 100644

drivers/of/irq.c int of_irq_to_resource(struct device_node *dev, int · line 360

Quoted 6 lines
drivers/of/irq.c +3 -0
@@ -355,6 +355,16 @@ int of_irq_to_resource(struct device_node *dev, int
 index, struct resource *r) r->start = r->end = irq;
       r->flags = IORESOURCE_IRQ;
       r->name = name ? name : dev->full_name;
+
+        /*
+         * Some drivers might rely on availability of trigger

flags

drivers/of/irq.c int of_irq_to_resource(struct device_node *dev, int · line 361

Quoted 1 line
drivers/of/irq.c +1 -0
+         * in IRQ resource. Since irq_of_parse_and_map()

configures the

drivers/of/irq.c int of_irq_to_resource(struct device_node *dev, int index, struct resource *r)

Quoted 3 lines
drivers/of/irq.c +3 -0
+         * trigger based on interrupt specifier and IRQD_TRIGGER_*
+         * flags are consistent with IORESOURCE_IRQ_*, we can get
+         * trigger type that was just set and pass it through

resource

Quoted 6 lines
drivers/of/irq.c +3 -0
+         * flags as well.
+         */
+        r->flags |= irqd_get_trigger_type(irq_get_irq_data(irq));
   }
 
   return irq;
Quoted 9 lines
Quoted 1 line

Any comments on this patch?

That's actually a pretty good solution and a whole lot less invasive that the approach that Javier was pursuing. Javier, I'm going to pick up this patch. Please yell if it doesn't solve the problem that you're trying to solve.

g.

It solves the issue I was trying to solve and the solution is indeed more elegant and simpler than the one I posted.

Thanks a lot for pointing this out.

Best regards,
Javier