* [PATCH V3 1/5] genirq: define flag IRQ_SRC_DST_INVERTED, and accessors
@ 2014-03-03 19:51 Stephen Warren
2014-03-03 19:51 ` [PATCH V3 2/5] dt: define IRQ flags bit 4 as src/dst inversion Stephen Warren
` (3 more replies)
0 siblings, 4 replies; 14+ messages in thread
From: Stephen Warren @ 2014-03-03 19:51 UTC (permalink / raw)
To: Thomas Gleixner, Samuel Ortiz, Lee Jones, Rob Herring, Pawel Moll,
Mark Rutland, Ian Campbell, Kumar Gala
Cc: devicetree, linux-kernel, linux-arm-kernel, linux-tegra,
Stephen Warren
From: Stephen Warren <swarren@nvidia.com>
Some devices have configurable IRQ output polarities. Software might
use IRQ_TYPE_* to determine how to configure such a device's IRQ
output polarity in order to match how the IRQ controller input is
configured. If the board or SoC inverts the signal between the
device's IRQ output and controller's IRQ output, software must be
aware of this fact, in order to program the IRQ output to the correct
(i.e. opposite) polarity. This flag provides that information.
Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
v3: New patch.
---
include/linux/irq.h | 12 ++++++++++++
kernel/irq/chip.c | 24 ++++++++++++++++++++++++
kernel/irq/irqdomain.c | 4 ++++
3 files changed, 40 insertions(+)
diff --git a/include/linux/irq.h b/include/linux/irq.h
index 7dc10036eff5..535f3937e99e 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -73,6 +73,11 @@ typedef void (*irq_preflow_handler_t)(struct irq_data *data);
* IRQ_IS_POLLED - Always polled by another interrupt. Exclude
* it from the spurious interrupt detection
* mechanism and from core side polling.
+ * IRQ_SRC_DST_INVERTED - An inverter exists between the source's IRQ
+ * output, and the IRQ controller's input.
+ * For devices with programmable output polarity
+ * this helps the driver match the device output
+ * to the controller's input polarity.
*/
enum {
IRQ_TYPE_NONE = 0x00000000,
@@ -98,6 +103,7 @@ enum {
IRQ_NOTHREAD = (1 << 16),
IRQ_PER_CPU_DEVID = (1 << 17),
IRQ_IS_POLLED = (1 << 18),
+ IRQ_SRC_DST_INVERTED = (1 << 19),
};
#define IRQF_MODIFY_MASK \
@@ -218,6 +224,11 @@ static inline u32 irqd_get_trigger_type(struct irq_data *d)
return d->state_use_accessors & IRQD_TRIGGER_MASK;
}
+static inline u32 irqd_get_src_dst_inverted(struct irq_data *d)
+{
+ return d->state_use_accessors & IRQ_SRC_DST_INVERTED;
+}
+
/*
* Must only be called inside irq_chip.irq_set_type() functions.
*/
@@ -538,6 +549,7 @@ extern int irq_set_chip(unsigned int irq, struct irq_chip *chip);
extern int irq_set_handler_data(unsigned int irq, void *data);
extern int irq_set_chip_data(unsigned int irq, void *data);
extern int irq_set_irq_type(unsigned int irq, unsigned int type);
+extern int irq_set_src_dst_inverted(unsigned int irq, unsigned int inverted);
extern int irq_set_msi_desc(unsigned int irq, struct msi_desc *entry);
extern int irq_set_msi_desc_off(unsigned int irq_base, unsigned int irq_offset,
struct msi_desc *entry);
diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
index dc04c166c54d..ff9e13fa1170 100644
--- a/kernel/irq/chip.c
+++ b/kernel/irq/chip.c
@@ -70,6 +70,30 @@ int irq_set_irq_type(unsigned int irq, unsigned int type)
EXPORT_SYMBOL(irq_set_irq_type);
/**
+ * irq_set_src_dst_inverted(unsigned int irq, u32 inverted)
+ * @irq: irq number
+ * @inverted: IRQ_SRC_DST_INVERTED value - see include/linux/irq.h
+ */
+int irq_set_src_dst_inverted(unsigned int irq, unsigned int inverted)
+{
+ unsigned long flags;
+ struct irq_desc *desc = irq_get_desc_buslock(irq, &flags, IRQ_GET_DESC_CHECK_GLOBAL);
+ int ret = 0;
+
+ if (!desc)
+ return -EINVAL;
+
+ inverted &= IRQ_SRC_DST_INVERTED;
+ if (inverted)
+ irqd_set(&desc->irq_data, inverted);
+ else
+ irqd_clear(&desc->irq_data, inverted);
+ irq_put_desc_busunlock(desc, flags);
+ return ret;
+}
+EXPORT_SYMBOL(irq_set_src_dst_inverted);
+
+/**
* irq_set_handler_data - set irq handler data for an irq
* @irq: Interrupt number
* @data: Pointer to interrupt specific data
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index f14033700c25..f9cee747424e 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -471,6 +471,7 @@ unsigned int irq_create_of_mapping(struct of_phandle_args *irq_data)
struct irq_domain *domain;
irq_hw_number_t hwirq;
unsigned int type = IRQ_TYPE_NONE;
+ unsigned int inverted = 0;
unsigned int virq;
domain = irq_data->np ? irq_find_host(irq_data->np) : irq_default_domain;
@@ -487,6 +488,8 @@ unsigned int irq_create_of_mapping(struct of_phandle_args *irq_data)
if (domain->ops->xlate(domain, irq_data->np, irq_data->args,
irq_data->args_count, &hwirq, &type))
return 0;
+ inverted = type & IRQ_SRC_DST_INVERTED;
+ type &= IRQ_TYPE_SENSE_MASK;
}
/* Create mapping */
@@ -498,6 +501,7 @@ unsigned int irq_create_of_mapping(struct of_phandle_args *irq_data)
if (type != IRQ_TYPE_NONE &&
type != irq_get_trigger_type(virq))
irq_set_irq_type(virq, type);
+ irq_set_src_dst_inverted(virq, inverted);
return virq;
}
EXPORT_SYMBOL_GPL(irq_create_of_mapping);
--
1.8.1.5
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH V3 2/5] dt: define IRQ flags bit 4 as src/dst inversion
2014-03-03 19:51 [PATCH V3 1/5] genirq: define flag IRQ_SRC_DST_INVERTED, and accessors Stephen Warren
@ 2014-03-03 19:51 ` Stephen Warren
2014-03-03 19:51 ` [PATCH V3 3/5] irqchip: gic: parse IRQ specifier flag " Stephen Warren
` (2 subsequent siblings)
3 siblings, 0 replies; 14+ messages in thread
From: Stephen Warren @ 2014-03-03 19:51 UTC (permalink / raw)
To: Thomas Gleixner, Samuel Ortiz, Lee Jones, Rob Herring, Pawel Moll,
Mark Rutland, Ian Campbell, Kumar Gala
Cc: devicetree, linux-kernel, linux-arm-kernel, linux-tegra,
Stephen Warren
From: Stephen Warren <swarren@nvidia.com>
Some devices have configurable IRQ output polarities. Software might
use IRQ specifier flag bits[3:0] to determine how to configure such a
device's IRQ output polarity in order to match how the IRQ controller
input is configured. If the board or SoC inverts the signal between the
device's IRQ output and controller's IRQ output, software must be
aware of this fact, in order to program the IRQ output to the correct
(i.e. opposite) polarity. This flag provides that information.
Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
v3: New patch.
---
Documentation/devicetree/bindings/arm/gic.txt | 8 ++++++++
.../devicetree/bindings/interrupt-controller/interrupts.txt | 8 ++++++++
include/dt-bindings/interrupt-controller/irq.h | 1 +
3 files changed, 17 insertions(+)
diff --git a/Documentation/devicetree/bindings/arm/gic.txt b/Documentation/devicetree/bindings/arm/gic.txt
index bae0d87a38b2..b0b65a440239 100644
--- a/Documentation/devicetree/bindings/arm/gic.txt
+++ b/Documentation/devicetree/bindings/arm/gic.txt
@@ -33,6 +33,14 @@ Main node required properties:
2 = high-to-low edge triggered
4 = active high level-sensitive
8 = active low level-sensitive
+ bit[4] IRQ is inverted between source and sink.
+ Some devices have configurable IRQ output polarities. Software might
+ use flag bits[3:0] to determine how to configure such a device's IRQ
+ output polarity in order to match how the IRQ controller input is
+ configured. If the board or SoC inverts the signal between the
+ device's IRQ output and controller's IRQ output, software must be
+ aware of this fact, in order to program the IRQ output to the correct
+ (i.e. opposite) polarity. This flag provides that information.
bits[15:8] PPI interrupt cpu mask. Each bit corresponds to each of
the 8 possible cpus attached to the GIC. A bit set to '1' indicated
the interrupt is wired to that CPU. Only valid for PPI interrupts.
diff --git a/Documentation/devicetree/bindings/interrupt-controller/interrupts.txt b/Documentation/devicetree/bindings/interrupt-controller/interrupts.txt
index 1486497a24c1..636eb0f478bf 100644
--- a/Documentation/devicetree/bindings/interrupt-controller/interrupts.txt
+++ b/Documentation/devicetree/bindings/interrupt-controller/interrupts.txt
@@ -76,6 +76,14 @@ commonly used:
2 = high-to-low edge triggered
4 = active high level-sensitive
8 = active low level-sensitive
+ - bit[4] IRQ is inverted between source and sink
+ Some devices have configurable IRQ output polarities. Software might
+ use flag bits[3:0] to determine how to configure such a device's IRQ
+ output polarity in order to match how the IRQ controller input is
+ configured. If the board or SoC inverts the signal between the
+ device's IRQ output and controller's IRQ output, software must be
+ aware of this fact, in order to program the IRQ output to the correct
+ (i.e. opposite) polarity. This flag provides that information.
Example:
diff --git a/include/dt-bindings/interrupt-controller/irq.h b/include/dt-bindings/interrupt-controller/irq.h
index 33a1003c55aa..5b04918c5c72 100644
--- a/include/dt-bindings/interrupt-controller/irq.h
+++ b/include/dt-bindings/interrupt-controller/irq.h
@@ -15,5 +15,6 @@
#define IRQ_TYPE_EDGE_BOTH (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING)
#define IRQ_TYPE_LEVEL_HIGH 4
#define IRQ_TYPE_LEVEL_LOW 8
+#define IRQ_SRC_DST_INVERTED 16
#endif
--
1.8.1.5
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH V3 3/5] irqchip: gic: parse IRQ specifier flag src/dst inversion
2014-03-03 19:51 [PATCH V3 1/5] genirq: define flag IRQ_SRC_DST_INVERTED, and accessors Stephen Warren
2014-03-03 19:51 ` [PATCH V3 2/5] dt: define IRQ flags bit 4 as src/dst inversion Stephen Warren
@ 2014-03-03 19:51 ` Stephen Warren
[not found] ` <1393876300-3061-1-git-send-email-swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2014-03-03 19:51 ` [PATCH V3 5/5] ARM: tegra: fix Dalmore PMIC IRQ polarity Stephen Warren
3 siblings, 0 replies; 14+ messages in thread
From: Stephen Warren @ 2014-03-03 19:51 UTC (permalink / raw)
To: Thomas Gleixner, Samuel Ortiz, Lee Jones, Rob Herring, Pawel Moll,
Mark Rutland, Ian Campbell, Kumar Gala
Cc: linux-tegra, devicetree, Stephen Warren, linux-kernel,
linux-arm-kernel
From: Stephen Warren <swarren@nvidia.com>
Modify the GIC driver to parse IRQ specifier flag bit 4 (src/dst
inverted) in the xlate function.
Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
v3: New patch.
---
drivers/irqchip/irq-gic.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
index 500e533b9648..97800b349f54 100644
--- a/drivers/irqchip/irq-gic.c
+++ b/drivers/irqchip/irq-gic.c
@@ -847,6 +847,9 @@ static int gic_irq_domain_xlate(struct irq_domain *d,
*out_hwirq += 16;
*out_type = intspec[2] & IRQ_TYPE_SENSE_MASK;
+ if (intspec[2] & BIT(4))
+ *out_type |= IRQ_SRC_DST_INVERTED;
+
return 0;
}
--
1.8.1.5
^ permalink raw reply related [flat|nested] 14+ messages in thread
[parent not found: <1393876300-3061-1-git-send-email-swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>]
* [PATCH V3 4/5] mfd: palmas: support IRQ inversion at the board level
[not found] ` <1393876300-3061-1-git-send-email-swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
@ 2014-03-03 19:51 ` Stephen Warren
2014-03-04 8:25 ` Lee Jones
[not found] ` <1393876300-3061-4-git-send-email-swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2014-03-04 10:04 ` [PATCH V3 1/5] genirq: define flag IRQ_SRC_DST_INVERTED, and accessors Thomas Gleixner
1 sibling, 2 replies; 14+ messages in thread
From: Stephen Warren @ 2014-03-03 19:51 UTC (permalink / raw)
To: Thomas Gleixner, Samuel Ortiz, Lee Jones, Rob Herring, Pawel Moll,
Mark Rutland, Ian Campbell, Kumar Gala
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-tegra-u79uwXL29TY76Z2rM5mHXA, Stephen Warren
From: Stephen Warren <swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Implement the new DT property ti,irq-externally-inverted, and add an
equivalent platform data field to match. This allows the driver to
correctly automatically configure the IRQ output polarity when the board
or SoC contains an inverter between the Palmas IRQ output and IRQ
controller input.
Signed-off-by: Stephen Warren <swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
---
v3:
* Use an IRQD flag to represent the data, rather than a custom DT property.
v2:
* Split V1's patch 1/2 into separate patches 1/3 and 2/3.
---
drivers/mfd/palmas.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/mfd/palmas.c b/drivers/mfd/palmas.c
index d280d789e55a..3281d4103e9d 100644
--- a/drivers/mfd/palmas.c
+++ b/drivers/mfd/palmas.c
@@ -292,7 +292,8 @@ static int palmas_set_pdata_irq_flag(struct i2c_client *i2c,
return -EINVAL;
}
- pdata->irq_flags = irqd_get_trigger_type(irq_data);
+ pdata->irq_flags = irqd_get_trigger_type(irq_data) |
+ irqd_get_src_dst_inverted(irq_data);
dev_info(&i2c->dev, "Irq flag is 0x%08x\n", pdata->irq_flags);
return 0;
}
@@ -447,6 +448,8 @@ static int palmas_i2c_probe(struct i2c_client *i2c,
reg = PALMAS_POLARITY_CTRL_INT_POLARITY;
else
reg = 0;
+ if (pdata->irq_flags & IRQ_SRC_DST_INVERTED)
+ reg ^= PALMAS_POLARITY_CTRL_INT_POLARITY;
ret = palmas_update_bits(palmas, PALMAS_PU_PD_OD_BASE,
PALMAS_POLARITY_CTRL, PALMAS_POLARITY_CTRL_INT_POLARITY,
reg);
--
1.8.1.5
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH V3 4/5] mfd: palmas: support IRQ inversion at the board level
2014-03-03 19:51 ` [PATCH V3 4/5] mfd: palmas: support IRQ inversion at the board level Stephen Warren
@ 2014-03-04 8:25 ` Lee Jones
[not found] ` <1393876300-3061-4-git-send-email-swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
1 sibling, 0 replies; 14+ messages in thread
From: Lee Jones @ 2014-03-04 8:25 UTC (permalink / raw)
To: Stephen Warren
Cc: Thomas Gleixner, Samuel Ortiz, Rob Herring, Pawel Moll,
Mark Rutland, Ian Campbell, Kumar Gala, devicetree, linux-kernel,
linux-arm-kernel, linux-tegra, Stephen Warren
> From: Stephen Warren <swarren@nvidia.com>
>
> Implement the new DT property ti,irq-externally-inverted, and add an
> equivalent platform data field to match. This allows the driver to
> correctly automatically configure the IRQ output polarity when the board
> or SoC contains an inverter between the Palmas IRQ output and IRQ
> controller input.
>
> Signed-off-by: Stephen Warren <swarren@nvidia.com>
> ---
> v3:
> * Use an IRQD flag to represent the data, rather than a custom DT property.
> v2:
> * Split V1's patch 1/2 into separate patches 1/3 and 2/3.
> ---
> drivers/mfd/palmas.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
Looks good to me. Let me know how you want to deal with this. I'm
happy to create an immutable branch for everyone to pull from.
Acked-by: Lee Jones <lee.jones@linaro.org>
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
^ permalink raw reply [flat|nested] 14+ messages in thread
[parent not found: <1393876300-3061-4-git-send-email-swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>]
* Re: [PATCH V3 4/5] mfd: palmas: support IRQ inversion at the board level
[not found] ` <1393876300-3061-4-git-send-email-swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
@ 2014-04-10 7:04 ` Alexandre Courbot
[not found] ` <CAAVeFuJY67zdoHiZufxDbkaw=xt8YwxyDAwHW_T7UZeSOt35NA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
0 siblings, 1 reply; 14+ messages in thread
From: Alexandre Courbot @ 2014-04-10 7:04 UTC (permalink / raw)
To: Stephen Warren
Cc: Thomas Gleixner, Samuel Ortiz, Lee Jones, Rob Herring, Pawel Moll,
Mark Rutland, Ian Campbell, Kumar Gala,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Linux Kernel Mailing List,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Stephen Warren
Stephen, any news about this patch? I'm waiting for it to be merged in
order to resend some Tegra DTs, but still cannot see it in -next.
Thanks,
Alex.
On Tue, Mar 4, 2014 at 4:51 AM, Stephen Warren <swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org> wrote:
> From: Stephen Warren <swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
>
> Implement the new DT property ti,irq-externally-inverted, and add an
> equivalent platform data field to match. This allows the driver to
> correctly automatically configure the IRQ output polarity when the board
> or SoC contains an inverter between the Palmas IRQ output and IRQ
> controller input.
>
> Signed-off-by: Stephen Warren <swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
> ---
> v3:
> * Use an IRQD flag to represent the data, rather than a custom DT property.
> v2:
> * Split V1's patch 1/2 into separate patches 1/3 and 2/3.
> ---
> drivers/mfd/palmas.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mfd/palmas.c b/drivers/mfd/palmas.c
> index d280d789e55a..3281d4103e9d 100644
> --- a/drivers/mfd/palmas.c
> +++ b/drivers/mfd/palmas.c
> @@ -292,7 +292,8 @@ static int palmas_set_pdata_irq_flag(struct i2c_client *i2c,
> return -EINVAL;
> }
>
> - pdata->irq_flags = irqd_get_trigger_type(irq_data);
> + pdata->irq_flags = irqd_get_trigger_type(irq_data) |
> + irqd_get_src_dst_inverted(irq_data);
> dev_info(&i2c->dev, "Irq flag is 0x%08x\n", pdata->irq_flags);
> return 0;
> }
> @@ -447,6 +448,8 @@ static int palmas_i2c_probe(struct i2c_client *i2c,
> reg = PALMAS_POLARITY_CTRL_INT_POLARITY;
> else
> reg = 0;
> + if (pdata->irq_flags & IRQ_SRC_DST_INVERTED)
> + reg ^= PALMAS_POLARITY_CTRL_INT_POLARITY;
> ret = palmas_update_bits(palmas, PALMAS_PU_PD_OD_BASE,
> PALMAS_POLARITY_CTRL, PALMAS_POLARITY_CTRL_INT_POLARITY,
> reg);
> --
> 1.8.1.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-tegra" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH V3 1/5] genirq: define flag IRQ_SRC_DST_INVERTED, and accessors
[not found] ` <1393876300-3061-1-git-send-email-swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2014-03-03 19:51 ` [PATCH V3 4/5] mfd: palmas: support IRQ inversion at the board level Stephen Warren
@ 2014-03-04 10:04 ` Thomas Gleixner
[not found] ` <alpine.DEB.2.02.1403041018370.18573-3cz04HxQygjZikZi3RtOZ1XZhhPuCNm+@public.gmane.org>
1 sibling, 1 reply; 14+ messages in thread
From: Thomas Gleixner @ 2014-03-04 10:04 UTC (permalink / raw)
To: Stephen Warren
Cc: Samuel Ortiz, Lee Jones, Rob Herring, Pawel Moll, Mark Rutland,
Ian Campbell, Kumar Gala, devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-tegra-u79uwXL29TY76Z2rM5mHXA, Stephen Warren
On Mon, 3 Mar 2014, Stephen Warren wrote:
> From: Stephen Warren <swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
>
> Some devices have configurable IRQ output polarities. Software might
> use IRQ_TYPE_* to determine how to configure such a device's IRQ
> output polarity in order to match how the IRQ controller input is
> configured. If the board or SoC inverts the signal between the
> device's IRQ output and controller's IRQ output, software must be
> aware of this fact, in order to program the IRQ output to the correct
> (i.e. opposite) polarity. This flag provides that information.
So what you're saying is:
Device IRQ output --> [Optional Inverter Logic] --> IRQ controller input.
And you're storing the information about the presence of the inverter
logic in the irq itself, but the core does not make any use of it and
you let the device driver deal with the outcome.
This sucks as all affected drivers have to implement the same sanity
logic for this.
Why don't you implement a core function which tells the driver which
polarity to select? That requires a few more changes, but I think it's
worth it for other reasons.
Right now the set_type logic requires the irq chip drivers to
implement sanity checking and default selections for TYPE_NONE. We can
be more clever about that and add this information to the irq chip
flags.
enum {
IRQ_CHIP_TYPES_MASK = 0x0f,
IRQ_CHIP_DEFAULT_MASK = 0xf0,
IRQ_CHIP_EXISTING_FLAGS ....
}
Now the irq_chip setup tells the core which types are available and
which one is the default fallback for TYPE_NONE.
So the core can do the sanity checks and we can kill quite some
repeated stuff from the irq chip implementations. For the inverted
logic case you can handle the inversion in the core as well, i.e. if a
driver requests IRQ_TYPE_LEVEL_HIGH you select IRQ_TYPE_LEVEL_LOW for
the chip, if possible.
For the case where the irq chip can only handle a single polarity you
can provide a core function to figure out to which polarity the driver
should set the device IRQ output line.
int irq_get_device_irq_polarity(int irq, int device_types)
{
/*
* Handle the inversion logic and select a proper
* device irq polarity from irq_chip(@irq)->flags and
* @device_types.
*
* Return a proper error code if no match.
*/
}
Let's look at an example:
irq_chip.flags = IRQ_TYPE_LEVEL_HIGH;
device_types = IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW;
Now for the non inverted case, this returns IRQ_TYPE_LEVEL_HIGH, for
the inverted case it returns IRQ_TYPE_LEVEL_LOW.
In both cases the irq_set_type() logic handles this correctly:
Non-Inverted case:
irq_set_type(irq, IRQ_TYPE_LEVEL_HIGH);
-> Success
Inverted case:
irq_set_type(irq, IRQ_TYPE_LEVEL_LOW);
invert -> IRQ_TYPE_LEVEL_HIGH
-> Success
To make this work for interrupt chips which have no set_type callback
we can do the following in irq_set_type():
if (irq_is_inverted(irq))
type = invert(type);
ret = irq_check_type(chip, &type);
if (ret < 0 || !chip->irq_settype)
return ret;
return chip->irq_settype();
And irq_check_type() does:
if (!(chip->flags & IRQ_CHIP_TYPES_MASK))
return chip->irq_settype ? 0 : -ENOTSUP;
if (*type == IRQ_TYPE_NONE)
*type == (chip->flags & IRQ_CHIP_DEFAULT_MASK) >> 4;
return type_supported(chip->flags, *type);
Thanks,
tglx
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH V3 5/5] ARM: tegra: fix Dalmore PMIC IRQ polarity
2014-03-03 19:51 [PATCH V3 1/5] genirq: define flag IRQ_SRC_DST_INVERTED, and accessors Stephen Warren
` (2 preceding siblings ...)
[not found] ` <1393876300-3061-1-git-send-email-swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
@ 2014-03-03 19:51 ` Stephen Warren
3 siblings, 0 replies; 14+ messages in thread
From: Stephen Warren @ 2014-03-03 19:51 UTC (permalink / raw)
To: Thomas Gleixner, Samuel Ortiz, Lee Jones, Rob Herring, Pawel Moll,
Mark Rutland, Ian Campbell, Kumar Gala
Cc: devicetree, linux-kernel, linux-arm-kernel, linux-tegra,
Stephen Warren
From: Stephen Warren <swarren@nvidia.com>
The Tegra PMC's resume-from-sleep logic wants an active-low IRQ input
from the PMIC. However, the PMIC IRQ is also routed to the GIC, which
only supports active high IRQs (or rising edge). Hence, the signal must
be inverted in the PMC before being routed to the GIC. This implies that
the PMC DT property nvidia,invert-interrupt must be set, and it is.
The PMIC's DT interrupts property must represent the IRQ level at the
GIC, since that is the PMIC's parent IRQ controller. Fix the PMIC's
interrupts property to correctly describe the GIC input polarity.
However, the PMIC IRQ output's polarity is programmable in HW, and by
default follows the parent IRQ controller's input polarity. We need to
have an active-low output due to the inversion inside the Tegra PMC.
Hence, add the IRQ specifier flag which request that to the PMIC.
Reported-by: Stefan Agner <stefan@agner.ch>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
v3: Update to match changes to IRQ specifier DT binding.
v2: No change.
---
arch/arm/boot/dts/tegra114-dalmore.dts | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/arm/boot/dts/tegra114-dalmore.dts b/arch/arm/boot/dts/tegra114-dalmore.dts
index 8de543777882..f4319ac1a401 100644
--- a/arch/arm/boot/dts/tegra114-dalmore.dts
+++ b/arch/arm/boot/dts/tegra114-dalmore.dts
@@ -893,7 +893,8 @@
palmas: tps65913@58 {
compatible = "ti,palmas";
reg = <0x58>;
- interrupts = <0 86 IRQ_TYPE_LEVEL_LOW>;
+ interrupts = <0 86
+ (IRQ_TYPE_LEVEL_HIGH | IRQ_SRC_DST_INVERTED)>;
#interrupt-cells = <2>;
interrupt-controller;
--
1.8.1.5
^ permalink raw reply related [flat|nested] 14+ messages in thread
end of thread, other threads:[~2014-04-11 2:44 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-03 19:51 [PATCH V3 1/5] genirq: define flag IRQ_SRC_DST_INVERTED, and accessors Stephen Warren
2014-03-03 19:51 ` [PATCH V3 2/5] dt: define IRQ flags bit 4 as src/dst inversion Stephen Warren
2014-03-03 19:51 ` [PATCH V3 3/5] irqchip: gic: parse IRQ specifier flag " Stephen Warren
[not found] ` <1393876300-3061-1-git-send-email-swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2014-03-03 19:51 ` [PATCH V3 4/5] mfd: palmas: support IRQ inversion at the board level Stephen Warren
2014-03-04 8:25 ` Lee Jones
[not found] ` <1393876300-3061-4-git-send-email-swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2014-04-10 7:04 ` Alexandre Courbot
[not found] ` <CAAVeFuJY67zdoHiZufxDbkaw=xt8YwxyDAwHW_T7UZeSOt35NA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-04-10 7:25 ` Lee Jones
2014-04-10 15:42 ` Stephen Warren
[not found] ` <5346BBDF.4050901-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2014-04-11 2:44 ` Alexandre Courbot
2014-03-04 10:04 ` [PATCH V3 1/5] genirq: define flag IRQ_SRC_DST_INVERTED, and accessors Thomas Gleixner
[not found] ` <alpine.DEB.2.02.1403041018370.18573-3cz04HxQygjZikZi3RtOZ1XZhhPuCNm+@public.gmane.org>
2014-03-04 10:34 ` Thomas Gleixner
2014-03-04 15:57 ` Stephen Warren
2014-03-04 21:31 ` Thomas Gleixner
2014-03-03 19:51 ` [PATCH V3 5/5] ARM: tegra: fix Dalmore PMIC IRQ polarity Stephen Warren
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).