of/irq: store IRQ trigger/level in struct resource flags
Subsystems (3)
PATCH 1/1 of/irq: store IRQ trigger/level in struct resource flags
According to Documentation/devicetree/bindings/interrupt-controller/interrupts.txt the "#interrupt-cells" property of an "interrupt-controller" is used to define the number of cells needed to specify a single interrupt.
A commonly used variant is two cell on which #interrupt-cells = <2> and the first cell defines the index of the interrupt in the controller and the second cell is used to specify any of the following flags:
- bits[3:0] trigger type and level flags
1 = low-to-high edge triggered
2 = high-to-low edge triggered
4 = active high level-sensitive
8 = active low level-sensitive
An example of an interrupt controller which use the two cell format is the OMAP GPIO controller that allows GPIO lines to be used as IRQ (Documentation/devicetree/bindings/gpio/gpio-omap.txt)
But setting #interrupt-cells = <2> on the OMAP GPIO device node and specifying the GPIO-IRQ type and level flags on the second cell does not store this value on the populated IORESOURCE_IRQ struct resource.
This is because when using an IRQ from an interrupt controller and setting both cells (e.g:)
interrupt-parent = <&gpio6>; interrupts = <16 8>;
A call to of_irq_to_resource() is made and this function calls to irq_of_parse_and_map_type() to get the virtual IRQ mapped to the real index for this interrupt controller. This IRQ number is populated on the struct resource:
int of_irq_to_resource(struct device_node *dev, int index, struct resource *r)
{
int irq = irq_of_parse_and_map(dev, index);
..
r->start = r->end = irq;
}irq_of_parse_and_map() calls to irq_create_of_mapping() which calls to the correct xlate function handler according to "#interrupt-cells" (irq_domain_xlate_onecell or irq_domain_xlate_twocell) and to irq_set_irq_type() to set the IRQ type.
But the type is never returned so it can't be saved on the IRQ struct resource flags member.
This means that drivers that need the IRQ type/level flags defined in the DT won't be able to get it.
--- drivers/of/irq.c | 30 ++++++++++++++++++++++++------ include/linux/of_irq.h | 4 ++++ kernel/irq/irqdomain.c | 14 ++++++++++++-- 3 files changed, 40 insertions(+), 8 deletions(-)
drivers/of/irq.c +24 -6
@@ -27,22 +27,39 @@#include <linux/slab.h> /** -* irq_of_parse_and_map - Parse and map an interrupt into linux virq space +* irq_of_parse_and_map_type - Parse and map an interrupt into linux virq space * @device: Device node of the device whose interrupt is to be mapped * @index: Index of the interrupt to map +* @type: Interrupt trigger type and level flags filled by this function * * This function is a wrapper that chains of_irq_map_one() and * irq_create_of_mapping() to make things easier to callers */ -unsigned int irq_of_parse_and_map (struct device_node *dev,int index) +static unsigned int irq_of_parse_and_map_type (struct device_node *dev, +int index,unsigned int *type) {struct of_irq oirq; +unsigned int virq;if (of_irq_map_one (dev, index, &oirq))return 0 ; -return irq_create_of_mapping (oirq.controller, oirq.specifier, - oirq.size); + virq =irq_create_of_mapping_type (oirq.controller, oirq.specifier, + oirq.size, type); +return virq; +} + +/** +* irq_of_parse_and_map - Parse and map an interrupt into linux virq space +* @device: Device node of the device whose interrupt is to be mapped +* @index: Index of the interrupt to map +* +* This function is a wrapper of irq_of_parse_and_map_type() when the IRQ +* type and level flags are not needed +*/ +unsigned int irq_of_parse_and_map (struct device_node *dev,int index) +{ +return irq_of_parse_and_map_type (dev, index,NULL ); }EXPORT_SYMBOL_GPL (irq_of_parse_and_map);
@@ -338,7 +355,8 @@ EXPORT_SYMBOL_GPL(of_irq_map_one);*/ int of_irq_to_resource (struct device_node *dev,int index,struct resource *r) { -int irq =irq_of_parse_and_map (dev, index); +int type =IRQ_TYPE_NONE ; +int irq =irq_of_parse_and_map_type (dev, index, &type);/* Only dereference the resource if both the * resource and the irq are valid. */
@@ -353,7 +371,7 @@ int of_irq_to_resource(struct device_node *dev, int index, struct resource *r) &name); r->start = r->end = irq; - r->flags =IORESOURCE_IRQ ; + r->flags = (IORESOURCE_IRQ | type); r->name = name ? name : dev->full_name; }
include/linux/of_irq.h +4 -0
@@ -66,6 +66,10 @@ extern int of_irq_map_one(struct device_node *device, int index,extern unsigned int irq_create_of_mapping (struct device_node *controller,const u32 *intspec,unsigned int intsize); +extern unsigned int irq_create_of_mapping_type (struct device_node *controller, +const u32 *intspec, +unsigned int intsize, +unsigned int *otype);extern int of_irq_to_resource (struct device_node *dev,int index,struct resource *r);extern int of_irq_count (struct device_node *dev);
kernel/irq/irqdomain.c +12 -2
@@ -636,8 +636,9 @@ int irq_create_strict_mappings(struct irq_domain *domain, unsigned int irq_base, }EXPORT_SYMBOL_GPL (irq_create_strict_mappings); -unsigned int irq_create_of_mapping (struct device_node *controller, -const u32 *intspec,unsigned int intsize) +unsigned int irq_create_of_mapping_type (struct device_node *controller, +const u32 *intspec,unsigned int intsize, +unsigned int *otype) {struct irq_domain *domain;irq_hw_number_t hwirq;
@@ -681,8 +682,17 @@ unsigned int irq_create_of_mapping(struct device_node *controller,if (type !=IRQ_TYPE_NONE && type != (irqd_get_trigger_type (irq_get_irq_data (virq))))irq_set_irq_type (virq, type); +if (otype) + *otype = type;return virq; } +EXPORT_SYMBOL_GPL (irq_create_of_mapping_type); + +unsigned int irq_create_of_mapping (struct device_node *controller, +const u32 *intspec,unsigned int intsize) +{ +return irq_create_of_mapping_type (controller, intspec, intsize,NULL ); +}EXPORT_SYMBOL_GPL (irq_create_of_mapping);/**
Signature · 1 line
1.7.7.6
PATCH 1/1 of/irq: store IRQ trigger/level in struct resource flags
Quoted 45 lines · Javier Martinez Canillas
According to
Documentation/devicetree/bindings/interrupt-controller/interrupts.txtthe "#interrupt-cells" property of an "interrupt-controller" is used to define the number of cells needed to specify a single interrupt.A commonly used variant is two cell on which #interrupt-cells = <2> and the first cell defines the index of the interrupt in the controller and the second cell is used to specify any of the following flags:
- bits[3:0] trigger type and level flags
1 = low-to-high edge triggered
2 = high-to-low edge triggered
4 = active high level-sensitive
8 = active low level-sensitiveAn example of an interrupt controller which use the two cell format is the OMAP GPIO controller that allows GPIO lines to be used as IRQ (
Documentation/devicetree/bindings/gpio/gpio-omap.txt)But setting #interrupt-cells = <2> on the OMAP GPIO device node and specifying the GPIO-IRQ type and level flags on the second cell does not store this value on the populated
IORESOURCE_IRQstruct resource.This is because when using an IRQ from an interrupt controller and setting both cells (e.g:)
interrupt-parent = <&gpio6>; interrupts = <16 8>;A call to
of_irq_to_resource()is made and this function calls toirq_of_parse_and_map_type()to get the virtual IRQ mapped to the real index for this interrupt controller. This IRQ number is populated on the struct resource:int
of_irq_to_resource(struct device_node *dev, int index, struct resource *r){ int irq = irq_of_parse_and_map(dev, index); .. r->start = r->end = irq; }
irq_of_parse_and_map()calls toirq_create_of_mapping()which calls to the correct xlate function handler according to "#interrupt-cells" (irq_domain_xlate_onecellorirq_domain_xlate_twocell) and toirq_set_irq_type()to set the IRQ type.
Quoted 5 lines
But the type is never returned so it can't be saved on the IRQ struct resource flags member.
This means that drivers that need the IRQ type/level flags defined in the DT won't be able to get it.
But the interrupt controllers that need the information should be able to get to it via irqd_get_trigger_type. What problem exactly are you trying to fix? What driver would use this?
My understanding of the IORESOURCE_IRQ_xxx (and DMA) bits are they are ISA specific and therefore should not be used on non-ISA buses.
Rob
PATCH 1/1 of/irq: store IRQ trigger/level in struct resource flags
Quoted 4 lines · Rob Herring
Quoted 3 lines · Javier Martinez Canillas
According to
Documentation/devicetree/bindings/interrupt-controller/interrupts.txtthe "#interrupt-cells" property of an "interrupt-controller" is used to define the number of cells needed to specify a single interrupt.
...
Quoted 9 lines
Quoted 5 lines
But the type is never returned so it can't be saved on the IRQ struct resource flags member.
This means that drivers that need the IRQ type/level flags defined in the DT won't be able to get it.
But the interrupt controllers that need the information should be able to get to it via
irqd_get_trigger_type. What problem exactly are you trying to fix? What driver would use this?
FYI, that is indeed what I did in sound/soc/codecs/wm8903.c. Thinking back, I'm not sure if that was the right thing or whether I should have sent this same patch:-)
PATCH 1/1 of/irq: store IRQ trigger/level in struct resource flags
Quoted 12 lines · Stephen Warren
Quoted 4 lines · Rob Herring
Quoted 3 lines · Javier Martinez Canillas
According to
Documentation/devicetree/bindings/interrupt-controller/interrupts.txtthe "#interrupt-cells" property of an "interrupt-controller" is used to define the number of cells needed to specify a single interrupt....
Quoted 6 lines
Quoted 5 lines
But the type is never returned so it can't be saved on the IRQ struct resource flags member.
This means that drivers that need the IRQ type/level flags defined in the DT won't be able to get it.
Quoted 8 lines
Quoted 3 lines
But the interrupt controllers that need the information should be able to get to it via
irqd_get_trigger_type. What problem exactly are you trying to fix? What driver would use this?FYI, that is indeed what I did in
sound/soc/codecs/wm8903.c. Thinking back, I'm not sure if that was the right thing or whether I should have sent this same patch:-)
Hi Stephen,
I'm glad you agree :-)
I could change drivers/net/ethernet/smsc/smsc911x.c to get the type flags for the IRQ with irqd_get_trigger_type() but I prefer $subject because:
a) This works in the non-DT case with board files and filling the resources from platform data in arch/arm/mach-omap2/gpmc-smsc911x.c. So this is definitely a bug on the DT core.
b) I don't see why of_irq_to_resource() should discard the type/level flags when filling the IORESOURCE_IRQ if it was specified on the DT.
c) We will have to change all drivers that expect to get the IRQ type flags from a IORESOURCE_IRQ struct resource.
Thanks a lot and best regards,
Javier
PATCH 1/1 of/irq: store IRQ trigger/level in struct resource flags
Quoted 22 lines · Javier Martinez Canillas
Quoted 12 lines · Stephen Warren
Quoted 4 lines · Rob Herring
Quoted 3 lines · Javier Martinez Canillas
According to
Documentation/devicetree/bindings/interrupt-controller/interrupts.txtthe "#interrupt-cells" property of an "interrupt-controller" is used to define the number of cells needed to specify a single interrupt....
Quoted 6 lines
Quoted 5 lines
But the type is never returned so it can't be saved on the IRQ struct resource flags member.
This means that drivers that need the IRQ type/level flags defined in the DT won't be able to get it.
Quoted 8 lines
Quoted 3 lines
But the interrupt controllers that need the information should be able to get to it via
irqd_get_trigger_type. What problem exactly are you trying to fix? What driver would use this?FYI, that is indeed what I did in
sound/soc/codecs/wm8903.c. Thinking back, I'm not sure if that was the right thing or whether I should have sent this same patch:-)
Quoted 6 lines
Hi Stephen,
I'm glad you agree :-)
I could change
drivers/net/ethernet/smsc/smsc911x.cto get the type flags for the IRQ withirqd_get_trigger_type()but I prefer $subject because:
irqd_get_trigger_type probably is not meant for outside of irqchips. Creating an irq_get_irq_type function which takes an irq number would be the right function as that does not expose struct irq_data.
Quoted 3 lines
a) This works in the non-DT case with board files and filling the resources from platform data in
arch/arm/mach-omap2/gpmc-smsc911x.c. So this is definitely a bug on the DT core.
And hackery/abuse like this:
arch/arm/mach-omap2/board-3630sdp.c:32: .flags =GPMC_MUX_ADD_DATA | IORESOURCE_IRQ_LOWLEVEL,
Quoted 5 lines
b) I don't see why
of_irq_to_resource()should discard the type/level flags when filling theIORESOURCE_IRQif it was specified on the DT.c) We will have to change all drivers that expect to get the IRQ type flags from a
IORESOURCE_IRQstruct resource.
I'm not convinced that is a high number of drivers. Nearly all the occurrences of IORESOURCE_IRQ_ in drivers/ are for ISA (acpi/pnp) and drivers for ISA devices.
Rob
PATCH 1/1 of/irq: store IRQ trigger/level in struct resource flags
Quoted 25 lines · Rob Herring
Quoted 24 lines · Javier Martinez Canillas
Quoted 12 lines · Stephen Warren
Quoted 4 lines · Rob Herring
Quoted 3 lines · Javier Martinez Canillas
According to
Documentation/devicetree/bindings/interrupt-controller/interrupts.txtthe "#interrupt-cells" property of an "interrupt-controller" is used to define the number of cells needed to specify a single interrupt....
Quoted 6 lines
Quoted 5 lines
But the type is never returned so it can't be saved on the IRQ struct resource flags member.
This means that drivers that need the IRQ type/level flags defined in the DT won't be able to get it.
Quoted 8 lines
Quoted 3 lines
But the interrupt controllers that need the information should be able to get to it via
irqd_get_trigger_type. What problem exactly are you trying to fix? What driver would use this?FYI, that is indeed what I did in
sound/soc/codecs/wm8903.c. Thinking back, I'm not sure if that was the right thing or whether I should have sent this same patch:-)Hi Stephen,
Quoted 9 lines
Quoted 4 lines
I'm glad you agree :-)
I could change
drivers/net/ethernet/smsc/smsc911x.cto get the type flags for the IRQ withirqd_get_trigger_type()but I prefer $subject because:
irqd_get_trigger_typeprobably is not meant for outside of irqchips. Creating anirq_get_irq_typefunction which takes an irq number would be the right function as that does not expose structirq_data.
Ok, I can add an irqd_get_trigger_type() that just return the flags to the caller without exposing the struct irq_data and using it on the SMSC 911x driver instead using struct resource *irq_res->flags
I hope networking folks understand why this change is needed in this driver to get the type/level flags for an IRQ defined on a DT...
Quoted 12 lines
Quoted 3 lines
a) This works in the non-DT case with board files and filling the resources from platform data in
arch/arm/mach-omap2/gpmc-smsc911x.c. So this is definitely a bug on the DT core.And hackery/abuse like this:
arch/arm/mach-omap2/board-3630sdp.c:32: .flags =GPMC_MUX_ADD_DATA|IORESOURCE_IRQ_LOWLEVEL,Quoted 3 lines
b) I don't see why
of_irq_to_resource()should discard the type/level flags when filling theIORESOURCE_IRQif it was specified on the DT.
Quoted 7 lines
Quoted 2 lines
c) We will have to change all drivers that expect to get the IRQ type flags from a
IORESOURCE_IRQstruct resource.I'm not convinced that is a high number of drivers. Nearly all the occurrences of
IORESOURCE_IRQ_indrivers/are for ISA (acpi/pnp) and drivers for ISA devices.
If IORESOURCE_IRQ is just supposed to be used for ISA devices drivers that use ACPI/PnP instead DT, then of_irq_to_resource() callers should just use irq_of_parse_and_map() that returns the virtual IRQ number for an index within a controller instead of a struct resource.
In fact I wonder what's the point to have an of_irq_to_resource() function at all if IORESOURCE_IRQ is not supposed to be used for devices connected through dumb buses that need a DT and the struct resource will only hold the mapped virtual IRQ number and no the IRQ flags.
Quoted 2 lines
Rob
Best regards,
Javier
PATCH 1/1 of/irq: store IRQ trigger/level in struct resource flags
Quoted 31 lines · Javier Martinez Canillas
Quoted 30 lines · Rob Herring
Quoted 28 lines · Javier Martinez Canillas
Quoted 12 lines · Stephen Warren
Quoted 4 lines · Rob Herring
Quoted 3 lines · Javier Martinez Canillas
According to
Documentation/devicetree/bindings/interrupt-controller/interrupts.txtthe "#interrupt-cells" property of an "interrupt-controller" is used to define the number of cells needed to specify a single interrupt....
Quoted 6 lines
Quoted 5 lines
But the type is never returned so it can't be saved on the IRQ struct resource flags member.
This means that drivers that need the IRQ type/level flags defined in the DT won't be able to get it.
Quoted 8 lines
Quoted 3 lines
But the interrupt controllers that need the information should be able to get to it via
irqd_get_trigger_type. What problem exactly are you trying to fix? What driver would use this?FYI, that is indeed what I did in
sound/soc/codecs/wm8903.c. Thinking back, I'm not sure if that was the right thing or whether I should have sent this same patch:-)Hi Stephen,
I'm glad you agree :-)
I could change
drivers/net/ethernet/smsc/smsc911x.cto get the type flags for the IRQ withirqd_get_trigger_type()but I prefer $subject because:
Quoted 6 lines
Quoted 4 lines
irqd_get_trigger_typeprobably is not meant for outside of irqchips. Creating anirq_get_irq_typefunction which takes an irq number would be the right function as that does not expose structirq_data.Ok, I can add an
irqd_get_trigger_type()that just return the flags to
I meant irq_get_irq_type() of course.
Best regards,
Javier
PATCH 1/1 of/irq: store IRQ trigger/level in struct resource flags
In reply to Rob HerringQuoted 25 lines · Rob Herring
Quoted 24 lines · Javier Martinez Canillas
Quoted 12 lines · Stephen Warren
Quoted 4 lines · Rob Herring
Quoted 3 lines · Javier Martinez Canillas
According to
Documentation/devicetree/bindings/interrupt-controller/interrupts.txtthe "#interrupt-cells" property of an "interrupt-controller" is used to define the number of cells needed to specify a single interrupt....
Quoted 6 lines
Quoted 5 lines
But the type is never returned so it can't be saved on the IRQ struct resource flags member.
This means that drivers that need the IRQ type/level flags defined in the DT won't be able to get it.
Quoted 8 lines
Quoted 3 lines
But the interrupt controllers that need the information should be able to get to it via
irqd_get_trigger_type. What problem exactly are you trying to fix? What driver would use this?FYI, that is indeed what I did in
sound/soc/codecs/wm8903.c. Thinking back, I'm not sure if that was the right thing or whether I should have sent this same patch:-)Hi Stephen,
Quoted 9 lines
Quoted 4 lines
I'm glad you agree :-)
I could change
drivers/net/ethernet/smsc/smsc911x.cto get the type flags for the IRQ withirqd_get_trigger_type()but I prefer $subject because:
irqd_get_trigger_typeprobably is not meant for outside of irqchips. Creating anirq_get_irq_typefunction which takes an irq number would be the right function as that does not expose structirq_data.
Hi Rob,
I sent a patch-set a few days ago that adds an irq_get_irq_type() function [1] as you suggested and this function is used on the smsc911x driver probe function to get the edge/level flags [2].
It would be great if I can get your feedback on this.
Thanks a lot and best regards,
Javier
[1]: http://permalink.gmane.org/gmane.linux.ports.arm.omap/97117
[2]: http://permalink.gmane.org/gmane.linux.network/265587
PATCH 1/1 of/irq: store IRQ trigger/level in struct resource flags
In reply to Rob HerringQuoted 49 lines · Rob Herring
Quoted 48 lines · Javier Martinez Canillas
According to
Documentation/devicetree/bindings/interrupt-controller/interrupts.txtthe "#interrupt-cells" property of an "interrupt-controller" is used to define the number of cells needed to specify a single interrupt.A commonly used variant is two cell on which #interrupt-cells = <2> and the first cell defines the index of the interrupt in the controller and the second cell is used to specify any of the following flags:
- bits[3:0] trigger type and level flags
1 = low-to-high edge triggered
2 = high-to-low edge triggered
4 = active high level-sensitive
8 = active low level-sensitiveAn example of an interrupt controller which use the two cell format is the OMAP GPIO controller that allows GPIO lines to be used as IRQ (
Documentation/devicetree/bindings/gpio/gpio-omap.txt)But setting #interrupt-cells = <2> on the OMAP GPIO device node and specifying the GPIO-IRQ type and level flags on the second cell does not store this value on the populated
IORESOURCE_IRQstruct resource.This is because when using an IRQ from an interrupt controller and setting both cells (e.g:)
interrupt-parent = <&gpio6>; interrupts = <16 8>;A call to
of_irq_to_resource()is made and this function calls toirq_of_parse_and_map_type()to get the virtual IRQ mapped to the real index for this interrupt controller. This IRQ number is populated on the struct resource:int
of_irq_to_resource(struct device_node *dev, int index, struct resource *r){ int irq = irq_of_parse_and_map(dev, index); .. r->start = r->end = irq; }
irq_of_parse_and_map()calls toirq_create_of_mapping()which calls to the correct xlate function handler according to "#interrupt-cells" (irq_domain_xlate_onecellorirq_domain_xlate_twocell) and toirq_set_irq_type()to set the IRQ type.But the type is never returned so it can't be saved on the IRQ struct resource flags member.
Quoted 7 lines
Quoted 2 lines
This means that drivers that need the IRQ type/level flags defined in the DT won't be able to get it.
But the interrupt controllers that need the information should be able to get to it via
irqd_get_trigger_type. What problem exactly are you trying to fix? What driver would use this?
Yes but this is not about the interrupt controller wanting this information but a device driver that is using the IORESOURCE_IRQ struct resource that has the information about the virtual IRQ associated with a GPIO-IRQ.
The driver doesn't know neither care if its IRQ line is connected to a line of an real IRQ controller or to a GPIO controller that allows a GPIO line to be used as an IRQ.
Quoted 3 lines
My understanding of the
IORESOURCE_IRQ_xxx(and DMA) bits are they are ISA specific and therefore should not be used on non-ISA buses.
Many TI OMAP2+ SoC based boards have an SMSC LAN911x/912x controller (drivers/net/ethernet/smsc/smsc911x.c) that is connected to the OMAP processor through its General-Purpose Memory Controller (GPMC) and this LAN driver obtain its IRQ and I/O address space from a struct resource IORESOURCE_IRQ and IORESOURCE_MEM respectively, that is filled by the DeviceTree core.
It does this:
irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); irq_flags = irq_res->flags & IRQF_TRIGGER_MASK;
Since of_irq_to_resource() doesn't fill the trigger/level flags on the IORESOURCE_IRQ struct resource, irq_flags will always be 0 regarding the value specified on the second cell of the "interrupts" DT property.
A previous discussion about this can be found here [1].
Quoted 3 lines
Rob
Thanks a lot and best regards,
Javier
PATCH 1/1 of/irq: store IRQ trigger/level in struct resource flags
Quoted 30 lines · Javier Martinez Canillas
Quoted 8 lines · Rob Herring
Quoted 2 lines · Javier Martinez Canillas
This means that drivers that need the IRQ type/level flags defined in the DT won't be able to get it.
But the interrupt controllers that need the information should be able to get to it via
irqd_get_trigger_type. What problem exactly are you trying to fix? What driver would use this?Yes but this is not about the interrupt controller wanting this information but a device driver that is using the
IORESOURCE_IRQstruct resource that has the information about the virtual IRQ associated with a GPIO-IRQ.The driver doesn't know neither care if its IRQ line is connected to a line of an real IRQ controller or to a GPIO controller that allows a GPIO line to be used as an IRQ.
Quoted 3 lines
My understanding of the
IORESOURCE_IRQ_xxx(and DMA) bits are they are ISA specific and therefore should not be used on non-ISA buses.Many TI OMAP2+ SoC based boards have an SMSC LAN911x/912x controller (
drivers/net/ethernet/smsc/smsc911x.c) that is connected to the OMAP processor through its General-Purpose Memory Controller (GPMC) and this LAN driver obtain its IRQ and I/O address space from a struct resourceIORESOURCE_IRQandIORESOURCE_MEMrespectively, that is filled by the DeviceTree core.It does this:
Quoted 8 lines
irq_res=platform_get_resource(pdev, IORESOURCE_IRQ, 0);irq_flags=irq_res->flags&IRQF_TRIGGER_MASK;Since
of_irq_to_resource()doesn't fill the trigger/level flags on theIORESOURCE_IRQstruct resource,irq_flagswill always be 0 regarding the value specified on the second cell of the "interrupts" DT property.A previous discussion about this can be found here [1].
I can't remember if there was ever a reason for not returning the IRQ flags, but I don't have any major objection to doing so if drivers find them useful. The one concern I do have however is if it will cause any problems with drivers that expect flags == IORESOURCE_IRQ without any additional flags. Any users doing that are buggy anyway, but I do want to be careful about breakage.
I'll go over your patch and reply with comments.
g.
PATCH 1/1 of/irq: store IRQ trigger/level in struct resource flags
Quoted 47 lines · Grant Likely
Quoted 30 lines · Javier Martinez Canillas
Quoted 8 lines · Rob Herring
Quoted 2 lines · Javier Martinez Canillas
This means that drivers that need the IRQ type/level flags defined in the DT won't be able to get it.
But the interrupt controllers that need the information should be able to get to it via
irqd_get_trigger_type. What problem exactly are you trying to fix? What driver would use this?Yes but this is not about the interrupt controller wanting this information but a device driver that is using the
IORESOURCE_IRQstruct resource that has the information about the virtual IRQ associated with a GPIO-IRQ.The driver doesn't know neither care if its IRQ line is connected to a line of an real IRQ controller or to a GPIO controller that allows a GPIO line to be used as an IRQ.
Quoted 3 lines
My understanding of the
IORESOURCE_IRQ_xxx(and DMA) bits are they are ISA specific and therefore should not be used on non-ISA buses.Many TI OMAP2+ SoC based boards have an SMSC LAN911x/912x controller (
drivers/net/ethernet/smsc/smsc911x.c) that is connected to the OMAP processor through its General-Purpose Memory Controller (GPMC) and this LAN driver obtain its IRQ and I/O address space from a struct resourceIORESOURCE_IRQandIORESOURCE_MEMrespectively, that is filled by the DeviceTree core.It does this:
Quoted 8 lines
irq_res=platform_get_resource(pdev, IORESOURCE_IRQ, 0);irq_flags=irq_res->flags&IRQF_TRIGGER_MASK;Since
of_irq_to_resource()doesn't fill the trigger/level flags on theIORESOURCE_IRQstruct resource,irq_flagswill always be 0 regarding the value specified on the second cell of the "interrupts" DT property.A previous discussion about this can be found here [1].
I can't remember if there was ever a reason for not returning the IRQ flags, but I don't have any major objection to doing so if drivers find them useful. The one concern I do have however is if it will cause any problems with drivers that expect flags ==
IORESOURCE_IRQwithout any additional flags. Any users doing that are buggy anyway, but I do want to be careful about breakage.
Quoted 4 lines
I'll go over your patch and reply with comments.
g.
It turns out that if you don't pass a trigger type to the request_irq() call, it will use the trigger type set by the irq chip earlier with .xlate
For some reasons it was not getting the right trigger type when I sent this patch but now it is working correctly so probably there was a bug on the irq_chip driver I was using (drivers/gpio/gpio-omap.c) and got fixed in the meantime.
So I don't need this patch anymore to make the LAN chip work on my board and I don't know if the fact that an empty edge/level flags defaults to what was set using the .xlate function handler and this function is called in irq_create_of_mapping() is a reason enough to not return the IRQ flags on the struct resource.
Having said that, if you still think this patch is useful then I can send a v2 that take into account your comments on the patch.
Best regards,
Javier
PATCH 1/1 of/irq: store IRQ trigger/level in struct resource flags
In reply to Grant LikelyQuoted 29 lines · Grant Likely
Quoted 28 lines · Javier Martinez Canillas
Quoted 8 lines · Rob Herring
Quoted 2 lines · Javier Martinez Canillas
This means that drivers that need the IRQ type/level flags defined in the DT won't be able to get it.
But the interrupt controllers that need the information should be able to get to it via
irqd_get_trigger_type. What problem exactly are you trying to fix? What driver would use this?Yes but this is not about the interrupt controller wanting this information but a device driver that is using the
IORESOURCE_IRQstruct resource that has the information about the virtual IRQ associated with a GPIO-IRQ.The driver doesn't know neither care if its IRQ line is connected to a line of an real IRQ controller or to a GPIO controller that allows a GPIO line to be used as an IRQ.
Quoted 3 lines
My understanding of the
IORESOURCE_IRQ_xxx(and DMA) bits are they are ISA specific and therefore should not be used on non-ISA buses.Many TI OMAP2+ SoC based boards have an SMSC LAN911x/912x controller (
drivers/net/ethernet/smsc/smsc911x.c) that is connected to the OMAP processor through its General-Purpose Memory Controller (GPMC) and this LAN driver obtain its IRQ and I/O address space from a struct resourceIORESOURCE_IRQandIORESOURCE_MEMrespectively, that is filled by the DeviceTree core.
Quoted 8 lines
Quoted 8 lines
It does this:
irq_res=platform_get_resource(pdev, IORESOURCE_IRQ, 0);irq_flags=irq_res->flags&IRQF_TRIGGER_MASK;Since
of_irq_to_resource()doesn't fill the trigger/level flags on theIORESOURCE_IRQstruct resource,irq_flagswill always be 0 regarding the value specified on the second cell of the "interrupts" DT property.
why do you need to known this in you driver this need to be handle in the irq chip
I does use irq gpio without at all
Best Regards,
J.
PATCH 1/1 of/irq: store IRQ trigger/level in struct resource flags
Quoted 39 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 29 lines · Grant Likely
Quoted 28 lines · Javier Martinez Canillas
Quoted 8 lines · Rob Herring
Quoted 2 lines · Javier Martinez Canillas
This means that drivers that need the IRQ type/level flags defined in the DT won't be able to get it.
But the interrupt controllers that need the information should be able to get to it via
irqd_get_trigger_type. What problem exactly are you trying to fix? What driver would use this?Yes but this is not about the interrupt controller wanting this information but a device driver that is using the
IORESOURCE_IRQstruct resource that has the information about the virtual IRQ associated with a GPIO-IRQ.The driver doesn't know neither care if its IRQ line is connected to a line of an real IRQ controller or to a GPIO controller that allows a GPIO line to be used as an IRQ.
Quoted 3 lines
My understanding of the
IORESOURCE_IRQ_xxx(and DMA) bits are they are ISA specific and therefore should not be used on non-ISA buses.Many TI OMAP2+ SoC based boards have an SMSC LAN911x/912x controller (
drivers/net/ethernet/smsc/smsc911x.c) that is connected to the OMAP processor through its General-Purpose Memory Controller (GPMC) and this LAN driver obtain its IRQ and I/O address space from a struct resourceIORESOURCE_IRQandIORESOURCE_MEMrespectively, that is filled by the DeviceTree core.Quoted 8 lines
Quoted 8 lines
It does this:
irq_res=platform_get_resource(pdev, IORESOURCE_IRQ, 0);irq_flags=irq_res->flags&IRQF_TRIGGER_MASK;Since
of_irq_to_resource()doesn't fill the trigger/level flags on theIORESOURCE_IRQstruct resource,irq_flagswill always be 0 regarding the value specified on the second cell of the "interrupts" DT property.
Quoted 8 lines
why do you need to known this in you driver this need to be handle in the irq chip
I does use irq gpio without at all
Best Regards,
J.
Yes, in fact as I said on an earlier email on this thread if you don't pass a trigger type to the request_irq() call, it will use the trigger type set by the irq chip earlier with .xlate.
A few months ago when I was testing DT on my OMAP3 board, for some reasons it was not getting the right trigger type. That's why I sent this patch but it seems it was a bug on the GPIO omap irq_chip driver since now is working correctly without this. It is taking the trigger type that was set on the .xlate function handler.
So, I don't need this patch anymore to make the LAN chip work on my board and I don't know if the fact that an empty edge/level flags means that is going to be used whatever was set on the .xlate function handler is a reason enough to not return the IRQ flags on the struct resource or if someone else is still interested on this patch and filling this information on the struct resource.
Best regards,
Javier
PATCH 1/1 of/irq: store IRQ trigger/level in struct resource flags
In reply to Jean-Christophe PLAGNIOL-VILLARDQuoted 2 lines · On Thursday 06 of June 2013 10:50:39 Jean-Christophe PLAGNIOL-VILLARD wrote:
Quoted 1 line · Grant Likely
On Tue, 09 Apr 2013 00:44:05 +0200, Javier Martinez Canillas
Quoted 37 lines · <[email protected]> wrote:
Quoted 37 lines
Quoted 37 lines · Rob Herring
Quoted 10 lines · Javier Martinez Canillas
Quoted 3 lines
This means that drivers that need the IRQ type/level flags defined in
the DT won't be able to get it.But the interrupt controllers that need the information should be able
to get to it viairqd_get_trigger_type. What problem exactly are you
trying to fix? What driver would use this?Yes but this is not about the interrupt controller wanting this information but a device driver that is using the
IORESOURCE_IRQstruct resource that has the information about the virtual IRQ associated with a GPIO-IRQ.The driver doesn't know neither care if its IRQ line is connected to a line of an real IRQ controller or to a GPIO controller that allows a GPIO line to be used as an IRQ.
Quoted 3 lines
My understanding of the
IORESOURCE_IRQ_xxx(and DMA) bits are they are
ISA specific and therefore should not be used on non-ISA buses.Many TI OMAP2+ SoC based boards have an SMSC LAN911x/912x controller (
drivers/net/ethernet/smsc/smsc911x.c) that is connected to the OMAP processor through its General-Purpose Memory Controller (GPMC) and this LAN driver obtain its IRQ and I/O address space from a struct resourceIORESOURCE_IRQandIORESOURCE_MEMrespectively, that is filled by the DeviceTree core.It does this:
irq_res=platform_get_resource(pdev, IORESOURCE_IRQ, 0);irq_flags=irq_res->flags&IRQF_TRIGGER_MASK;
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Since
of_irq_to_resource()doesn't fill the trigger/level flags on theIORESOURCE_IRQstruct resource,irq_flagswill always be 0 regarding the value specified on the second cell of the "interrupts" DT property.why do you need to known this in you driver this need to be handle in the irq chip
There are devices that support multiple interrupt trigger types, like Broadcom WLAN chips, and drivers must configure them properly for requested trigger type, obtaining the information from flags field of the IRQ resource.
Best regards,
Tomasz
PATCH 1/1 of/irq: store IRQ trigger/level in struct resource flags
In reply to Javier Martinez CanillasOn Fri, 5 Apr 2013 09:48:08 +0200, Javier Martinez Canillas <[email protected]> wrote:
[...]
Quoted 12 lines
irq_of_parse_and_map()calls toirq_create_of_mapping()which calls to the correct xlate function handler according to "#interrupt-cells" (irq_domain_xlate_onecellorirq_domain_xlate_twocell) and toirq_set_irq_type()to set the IRQ type.But the type is never returned so it can't be saved on the IRQ struct resource flags member.
This means that drivers that need the IRQ type/level flags defined in the DT won't be able to get it.
Signed-off-by Javier Martinez Canillas <[email protected]>
[...]
include/linux/of_irq.h extern int of_irq_map_one(struct device_node *device, int index, · line 72
Quoted 12 lines
include/linux/of_irq.h +4
-0@@ -66,6 +66,10 @@ extern int of_irq_map_one(struct device_node *device, int index,extern unsigned int irq_create_of_mapping (struct device_node *controller,const u32 *intspec,unsigned int intsize); +extern unsigned int irq_create_of_mapping_type (struct device_node *controller, +const u32 *intspec, +unsigned int intsize, +unsigned int *otype);
I count 11 users of irq_create_of_mapping(). That's a managable number to update. Instead of creating a new function, please modify the existing one and split it off into a separate patch.
Otherwise the patch looks fine to me.
g.
PATCH 1/1 of/irq: store IRQ trigger/level in struct resource flags
Quoted 15 lines · Grant Likely
On Fri, 5 Apr 2013 09:48:08 +0200, Javier Martinez Canillas <[email protected]> wrote:
[...]Quoted 12 lines
irq_of_parse_and_map()calls toirq_create_of_mapping()which calls to the correct xlate function handler according to "#interrupt-cells" (irq_domain_xlate_onecellorirq_domain_xlate_twocell) and toirq_set_irq_type()to set the IRQ type.But the type is never returned so it can't be saved on the IRQ struct resource flags member.
This means that drivers that need the IRQ type/level flags defined in the DT won't be able to get it.
Signed-off-by Javier Martinez Canillas <[email protected]>[...]
Quoted 12 lines
include/linux/of_irq.h extern int of_irq_map_one(struct device_node *device, int index, · line 72
Quoted 12 lines
include/linux/of_irq.h +4
-0@@ -66,6 +66,10 @@ extern int of_irq_map_one(struct device_node *device, int index,extern unsigned int irq_create_of_mapping (struct device_node *controller,const u32 *intspec,unsigned int intsize); +extern unsigned int irq_create_of_mapping_type (struct device_node *controller, +const u32 *intspec, +unsigned int intsize, +unsigned int *otype);
Hi Grant, thanks a lot for your feedback.
Quoted 3 lines
I count 11 users of
irq_create_of_mapping(). That's a managable number to update.
Yes, but since of_irq_to_resource() doesn't call irq_create_of_mapping() directly but it does though irq_of_parse_and_map(), then this function signature has to be modified too.
I'm counting 223 users of irq_of_parse_and_map() so the change is not that small anymore. Another approach is to call of_irq_map_one() and irq_create_of_mapping() directly from of_irq_to_resource() instead of using irq_of_parse_and_map() but I don't like that...
Quoted 2 lines
Instead of creating a new function, please modify the existing one and split it off into a separate patch.
But that won't break git bisect-ability? or do you mean to first just change the functions signatures by adding an argument and update its users and then in a separate patch do the actual change to the functions to store the IRQ?
Quoted 4 lines
Otherwise the patch looks fine to me.
g.
Best regards,
Javier