linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] irqchip: atmel-aic: Add irq RTC fixups
@ 2014-07-10 18:25 Boris BREZILLON
  2014-07-10 18:25 ` [PATCH 1/3] irqchip: atmel-aic: Add irq fixup infrastructure Boris BREZILLON
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Boris BREZILLON @ 2014-07-10 18:25 UTC (permalink / raw)
  To: linux-arm-kernel

Hello,

This patch series introduce the notion of irq fixups for atmel SoCs.

In most at91 SoCs the first interrupt line is shared by several IPs, and
some of these HW blocks might be in an unknown state when booting the
Linux kernel.
Hence these IPs might generate spurious interrupts if they've not masked
their irqs and the shared irq line is requested by another peripheral.

These fixups were previously done in arch/arm/mach-at91/sysirq_mask.c
but as we're trying to use standard implementation (IRQCHIP_DECLARE and
automatic call of irqchip_init within arch/arm/kernel/irq.c) we need to
do those fixups in the irqchip driver.

This series only fix RTC irqs, but other HW blocks (RTT, PMC, ...) will
be added later on.

This series depends on this one [1].

Best Regards,

Boris

[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2014-July/271413.html

Boris BREZILLON (3):
  irqchip: atmel-aic: Add irq fixup infrastructure
  irqchip: atmel-aic: Implement RTC irq fixup
  irqchip: atmel-aic: Define irq fixups for atmel SoCs

 drivers/irqchip/irq-atmel-aic-common.c | 47 ++++++++++++++++++++++++++++++++++
 drivers/irqchip/irq-atmel-aic-common.h |  4 +++
 drivers/irqchip/irq-atmel-aic.c        | 15 +++++++++++
 drivers/irqchip/irq-atmel-aic5.c       | 12 +++++++++
 4 files changed, 78 insertions(+)

-- 
1.8.3.2

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/3] irqchip: atmel-aic: Add irq fixup infrastructure
  2014-07-10 18:25 [PATCH 0/3] irqchip: atmel-aic: Add irq RTC fixups Boris BREZILLON
@ 2014-07-10 18:25 ` Boris BREZILLON
  2014-07-10 18:25 ` [PATCH 2/3] irqchip: atmel-aic: Implement RTC irq fixup Boris BREZILLON
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Boris BREZILLON @ 2014-07-10 18:25 UTC (permalink / raw)
  To: linux-arm-kernel

Add irq fixup infrastructure to handle IP blocks connected to shared irqs
that are left in an unknown state when booting the kernel.

In this case the IP block which has not masked its interrupt and has no
driver loaded (either because it is not compiled or because it is not
loaded yet) might generate spurious interrupts when another IP block
request the shared irq.

A good example of this case is the RTC block on which register configs are
kept even after a shutdown (if a proper VDDcore is supplied), and thus
might generate spurious interrupts when the platform is switched on.

Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
---
 drivers/irqchip/irq-atmel-aic-common.c | 19 +++++++++++++++++++
 drivers/irqchip/irq-atmel-aic-common.h |  2 ++
 2 files changed, 21 insertions(+)

diff --git a/drivers/irqchip/irq-atmel-aic-common.c b/drivers/irqchip/irq-atmel-aic-common.c
index 18b76fc..4705bdb 100644
--- a/drivers/irqchip/irq-atmel-aic-common.c
+++ b/drivers/irqchip/irq-atmel-aic-common.c
@@ -139,6 +139,25 @@ static void __init aic_common_ext_irq_of_init(struct irq_domain *domain)
 	}
 }
 
+void __init aic_common_irq_fixup(const struct of_device_id *matches)
+{
+	struct device_node *root = of_find_node_by_path("/");
+	const struct of_device_id *match;
+
+	if (!root)
+		return;
+
+	match = of_match_node(matches, root);
+	of_node_put(root);
+
+	if (match) {
+		void (*fixup)(struct device_node *) = match->data;
+		fixup(root);
+	}
+
+	of_node_put(root);
+}
+
 struct irq_domain *__init aic_common_of_init(struct device_node *node,
 					     const struct irq_domain_ops *ops,
 					     const char *name, int nirqs)
diff --git a/drivers/irqchip/irq-atmel-aic-common.h b/drivers/irqchip/irq-atmel-aic-common.h
index c178557..aa0a42c 100644
--- a/drivers/irqchip/irq-atmel-aic-common.h
+++ b/drivers/irqchip/irq-atmel-aic-common.h
@@ -32,4 +32,6 @@ struct irq_domain *__init aic_common_of_init(struct device_node *node,
 					     const struct irq_domain_ops *ops,
 					     const char *name, int nirqs);
 
+void __init aic_common_irq_fixup(const struct of_device_id *matches);
+
 #endif /* __IRQ_ATMEL_AIC_COMMON_H */
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/3] irqchip: atmel-aic: Implement RTC irq fixup
  2014-07-10 18:25 [PATCH 0/3] irqchip: atmel-aic: Add irq RTC fixups Boris BREZILLON
  2014-07-10 18:25 ` [PATCH 1/3] irqchip: atmel-aic: Add irq fixup infrastructure Boris BREZILLON
@ 2014-07-10 18:25 ` Boris BREZILLON
  2014-07-10 18:25 ` [PATCH 3/3] irqchip: atmel-aic: Define irq fixups for atmel SoCs Boris BREZILLON
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Boris BREZILLON @ 2014-07-10 18:25 UTC (permalink / raw)
  To: linux-arm-kernel

Provide an implementation to fix RTC irqs before enabling the irqchip.

This was previously done in arch/arm/mach-at91/sysirq_mask.c but as we're
trying to use standard implementation (IRQCHIP_DECLARE and automatic call
of irqchip_init within arch/arm/kernel/irq.c) we need to do those fixups
in the irqchip driver.

Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
---
 drivers/irqchip/irq-atmel-aic-common.c | 28 ++++++++++++++++++++++++++++
 drivers/irqchip/irq-atmel-aic-common.h |  2 ++
 2 files changed, 30 insertions(+)

diff --git a/drivers/irqchip/irq-atmel-aic-common.c b/drivers/irqchip/irq-atmel-aic-common.c
index 4705bdb..6ae3cdee 100644
--- a/drivers/irqchip/irq-atmel-aic-common.c
+++ b/drivers/irqchip/irq-atmel-aic-common.c
@@ -139,6 +139,34 @@ static void __init aic_common_ext_irq_of_init(struct irq_domain *domain)
 	}
 }
 
+#define AT91_RTC_IDR           0x24
+#define AT91_RTC_IMR           0x28
+#define AT91_RTC_IRQ_MASK      0x1f
+
+void __init aic_common_rtc_irq_fixup(struct device_node *root)
+{
+	struct device_node *np;
+	void __iomem *regs;
+
+	np = of_find_compatible_node(root, NULL, "atmel,at91rm9200-rtc");
+	if (!np)
+		np = of_find_compatible_node(root, NULL,
+					     "atmel,at91sam9x5-rtc");
+
+	if (!np)
+		return;
+
+	regs = of_iomap(np, 0);
+	of_node_put(np);
+
+	if (!regs)
+		return;
+
+	writel(AT91_RTC_IRQ_MASK, regs + AT91_RTC_IDR);
+
+	iounmap(regs);
+}
+
 void __init aic_common_irq_fixup(const struct of_device_id *matches)
 {
 	struct device_node *root = of_find_node_by_path("/");
diff --git a/drivers/irqchip/irq-atmel-aic-common.h b/drivers/irqchip/irq-atmel-aic-common.h
index aa0a42c..90aa00e 100644
--- a/drivers/irqchip/irq-atmel-aic-common.h
+++ b/drivers/irqchip/irq-atmel-aic-common.h
@@ -32,6 +32,8 @@ struct irq_domain *__init aic_common_of_init(struct device_node *node,
 					     const struct irq_domain_ops *ops,
 					     const char *name, int nirqs);
 
+void __init aic_common_rtc_irq_fixup(struct device_node *root);
+
 void __init aic_common_irq_fixup(const struct of_device_id *matches);
 
 #endif /* __IRQ_ATMEL_AIC_COMMON_H */
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/3] irqchip: atmel-aic: Define irq fixups for atmel SoCs
  2014-07-10 18:25 [PATCH 0/3] irqchip: atmel-aic: Add irq RTC fixups Boris BREZILLON
  2014-07-10 18:25 ` [PATCH 1/3] irqchip: atmel-aic: Add irq fixup infrastructure Boris BREZILLON
  2014-07-10 18:25 ` [PATCH 2/3] irqchip: atmel-aic: Implement RTC irq fixup Boris BREZILLON
@ 2014-07-10 18:25 ` Boris BREZILLON
  2014-07-10 18:32 ` [PATCH 0/3] irqchip: atmel-aic: Add irq RTC fixups Boris BREZILLON
  2014-07-17 13:39 ` Jason Cooper
  4 siblings, 0 replies; 7+ messages in thread
From: Boris BREZILLON @ 2014-07-10 18:25 UTC (permalink / raw)
  To: linux-arm-kernel

Define SoCs that need irq fixups before enabling the AIC irqchip.

At the moment we're only fixing irq generated by the RTC block, but other
fixups will be added later on.

Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
---
 drivers/irqchip/irq-atmel-aic.c  | 15 +++++++++++++++
 drivers/irqchip/irq-atmel-aic5.c | 12 ++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/drivers/irqchip/irq-atmel-aic.c b/drivers/irqchip/irq-atmel-aic.c
index b15b566..a82869e 100644
--- a/drivers/irqchip/irq-atmel-aic.c
+++ b/drivers/irqchip/irq-atmel-aic.c
@@ -211,6 +211,19 @@ static const struct irq_domain_ops aic_irq_ops = {
 	.xlate	= aic_irq_domain_xlate,
 };
 
+static void __init at91sam9_aic_irq_fixup(struct device_node *root)
+{
+	aic_common_rtc_irq_fixup(root);
+}
+
+static const struct of_device_id __initdata aic_irq_fixups[] = {
+	{ .compatible = "atmel,at91sam9g45", .data = at91sam9_aic_irq_fixup },
+	{ .compatible = "atmel,at91sam9n12", .data = at91sam9_aic_irq_fixup },
+	{ .compatible = "atmel,at91sam9rl", .data = at91sam9_aic_irq_fixup },
+	{ .compatible = "atmel,at91sam9x5", .data = at91sam9_aic_irq_fixup },
+	{ /* sentinel */ },
+};
+
 static int __init aic_of_init(struct device_node *node,
 			      struct device_node *parent)
 {
@@ -225,6 +238,8 @@ static int __init aic_of_init(struct device_node *node,
 	if (IS_ERR(domain))
 		return PTR_ERR(domain);
 
+	aic_common_irq_fixup(aic_irq_fixups);
+
 	aic_domain = domain;
 	gc = irq_get_domain_generic_chip(domain, 0);
 
diff --git a/drivers/irqchip/irq-atmel-aic5.c b/drivers/irqchip/irq-atmel-aic5.c
index c9c753a..edb2270 100644
--- a/drivers/irqchip/irq-atmel-aic5.c
+++ b/drivers/irqchip/irq-atmel-aic5.c
@@ -290,6 +290,16 @@ static const struct irq_domain_ops aic5_irq_ops = {
 	.xlate	= aic5_irq_domain_xlate,
 };
 
+static void __init sama5d3_aic_irq_fixup(struct device_node *root)
+{
+	aic_common_rtc_irq_fixup(root);
+}
+
+static const struct of_device_id __initdata aic5_irq_fixups[] = {
+	{ .compatible = "atmel,sama5d3", .data = sama5d3_aic_irq_fixup },
+	{ /* sentinel */ },
+};
+
 static int __init aic5_of_init(struct device_node *node,
 			       struct device_node *parent,
 			       int nirqs)
@@ -310,6 +320,8 @@ static int __init aic5_of_init(struct device_node *node,
 	if (IS_ERR(domain))
 		return PTR_ERR(domain);
 
+	aic_common_irq_fixup(aic5_irq_fixups);
+
 	aic5_domain = domain;
 	nchips = aic5_domain->revmap_size / 32;
 	for (i = 0; i < nchips; i++) {
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 0/3] irqchip: atmel-aic: Add irq RTC fixups
  2014-07-10 18:25 [PATCH 0/3] irqchip: atmel-aic: Add irq RTC fixups Boris BREZILLON
                   ` (2 preceding siblings ...)
  2014-07-10 18:25 ` [PATCH 3/3] irqchip: atmel-aic: Define irq fixups for atmel SoCs Boris BREZILLON
@ 2014-07-10 18:32 ` Boris BREZILLON
  2014-07-10 18:36   ` Boris BREZILLON
  2014-07-17 13:39 ` Jason Cooper
  4 siblings, 1 reply; 7+ messages in thread
From: Boris BREZILLON @ 2014-07-10 18:32 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, 10 Jul 2014 20:25:38 +0200
Boris BREZILLON <boris.brezillon@free-electrons.com> wrote:

> Hello,
> 
> This patch series introduce the notion of irq fixups for atmel SoCs.
> 
> In most at91 SoCs the first interrupt line is shared by several IPs, and
> some of these HW blocks might be in an unknown state when booting the
> Linux kernel.
> Hence these IPs might generate spurious interrupts if they've not masked
> their irqs and the shared irq line is requested by another peripheral.
> 
> These fixups were previously done in arch/arm/mach-at91/sysirq_mask.c
> but as we're trying to use standard implementation (IRQCHIP_DECLARE and
> automatic call of irqchip_init within arch/arm/kernel/irq.c) we need to
> do those fixups in the irqchip driver.

This is what I was talking about:

http://lists.infradead.org/pipermail/linux-arm-kernel/2014-July/271425.htm


-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 0/3] irqchip: atmel-aic: Add irq RTC fixups
  2014-07-10 18:32 ` [PATCH 0/3] irqchip: atmel-aic: Add irq RTC fixups Boris BREZILLON
@ 2014-07-10 18:36   ` Boris BREZILLON
  0 siblings, 0 replies; 7+ messages in thread
From: Boris BREZILLON @ 2014-07-10 18:36 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, 10 Jul 2014 20:32:49 +0200
Boris BREZILLON <boris.brezillon@free-electrons.com> wrote:

> On Thu, 10 Jul 2014 20:25:38 +0200
> Boris BREZILLON <boris.brezillon@free-electrons.com> wrote:
> 
> > Hello,
> > 
> > This patch series introduce the notion of irq fixups for atmel SoCs.
> > 
> > In most at91 SoCs the first interrupt line is shared by several IPs, and
> > some of these HW blocks might be in an unknown state when booting the
> > Linux kernel.
> > Hence these IPs might generate spurious interrupts if they've not masked
> > their irqs and the shared irq line is requested by another peripheral.
> > 
> > These fixups were previously done in arch/arm/mach-at91/sysirq_mask.c
> > but as we're trying to use standard implementation (IRQCHIP_DECLARE and
> > automatic call of irqchip_init within arch/arm/kernel/irq.c) we need to
> > do those fixups in the irqchip driver.
> 
> This is what I was talking about:
> 
> http://lists.infradead.org/pipermail/linux-arm-kernel/2014-July/271425.htm
> 
> 

Oops, sorry this is not the appropriate thread: I meant to send this
reply to this series:

http://lists.infradead.org/pipermail/linux-arm-kernel/2014-July/271413.html



-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 0/3] irqchip: atmel-aic: Add irq RTC fixups
  2014-07-10 18:25 [PATCH 0/3] irqchip: atmel-aic: Add irq RTC fixups Boris BREZILLON
                   ` (3 preceding siblings ...)
  2014-07-10 18:32 ` [PATCH 0/3] irqchip: atmel-aic: Add irq RTC fixups Boris BREZILLON
@ 2014-07-17 13:39 ` Jason Cooper
  4 siblings, 0 replies; 7+ messages in thread
From: Jason Cooper @ 2014-07-17 13:39 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Jul 10, 2014 at 08:25:38PM +0200, Boris BREZILLON wrote:
> Hello,
> 
> This patch series introduce the notion of irq fixups for atmel SoCs.
> 
> In most at91 SoCs the first interrupt line is shared by several IPs, and
> some of these HW blocks might be in an unknown state when booting the
> Linux kernel.
> Hence these IPs might generate spurious interrupts if they've not masked
> their irqs and the shared irq line is requested by another peripheral.
> 
> These fixups were previously done in arch/arm/mach-at91/sysirq_mask.c
> but as we're trying to use standard implementation (IRQCHIP_DECLARE and
> automatic call of irqchip_init within arch/arm/kernel/irq.c) we need to
> do those fixups in the irqchip driver.
> 
> This series only fix RTC irqs, but other HW blocks (RTT, PMC, ...) will
> be added later on.
> 
> This series depends on this one [1].
> 
> Best Regards,
> 
> Boris
> 
> [1] http://lists.infradead.org/pipermail/linux-arm-kernel/2014-July/271413.html
> 
> Boris BREZILLON (3):
>   irqchip: atmel-aic: Add irq fixup infrastructure
>   irqchip: atmel-aic: Implement RTC irq fixup
>   irqchip: atmel-aic: Define irq fixups for atmel SoCs
> 
>  drivers/irqchip/irq-atmel-aic-common.c | 47 ++++++++++++++++++++++++++++++++++
>  drivers/irqchip/irq-atmel-aic-common.h |  4 +++
>  drivers/irqchip/irq-atmel-aic.c        | 15 +++++++++++
>  drivers/irqchip/irq-atmel-aic5.c       | 12 +++++++++
>  4 files changed, 78 insertions(+)

Whole series applied on top of irqchip/atmel-aic.

thx,

Jason.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-07-17 13:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-10 18:25 [PATCH 0/3] irqchip: atmel-aic: Add irq RTC fixups Boris BREZILLON
2014-07-10 18:25 ` [PATCH 1/3] irqchip: atmel-aic: Add irq fixup infrastructure Boris BREZILLON
2014-07-10 18:25 ` [PATCH 2/3] irqchip: atmel-aic: Implement RTC irq fixup Boris BREZILLON
2014-07-10 18:25 ` [PATCH 3/3] irqchip: atmel-aic: Define irq fixups for atmel SoCs Boris BREZILLON
2014-07-10 18:32 ` [PATCH 0/3] irqchip: atmel-aic: Add irq RTC fixups Boris BREZILLON
2014-07-10 18:36   ` Boris BREZILLON
2014-07-17 13:39 ` Jason Cooper

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).