Skip to contentSkip to conversation

arm: omap: intc: remaining patches

PATCH New Felipe Balbi 2 participants 11 messages Sep 15, 2014 – Sep 17, 2014

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover arm: omap: intc: remaining patches

Hi Tony,

Here are the remaining INTC patches rebased on your omap-for-v3.18/intc-v2 branch.

Based on our IRC chat, I kept irq-omap-intc.h header, but included it on common.h instead of modifying every board-file.

cheers

Felipe Balbi (9):
irqchip: add irq-omap-intc.h header
arm: omap: irq: move irq.c to drivers/irqchip/
irqchip: omap-intc: minor improvement to omap_irq_pending()
irqchip: omap-intc: comment style cleanup
irqchip: omap-intc: remove unnecesary of_address_to_resource() call
irqchip: omap-intc: enable IP protection
irqchip: omap-intc: enable TURBO idle mode
irqchip: omap-intc: correct maximum number or MIR registers
irqchip: omap-intc: remove unnecessary comments

 arch/arm/mach-omap2/Kconfig                        |  1 +
 arch/arm/mach-omap2/Makefile                       |  3 +-
 arch/arm/mach-omap2/common.h                       | 10 +---
 drivers/irqchip/Kconfig                            |  5 ++
 drivers/irqchip/Makefile                           |  1 +
 .../irq.c => drivers/irqchip/irq-omap-intc.c       | 64 +++++++++++++---------
 include/linux/irqchip/irq-omap-intc.h              | 32 +++++++++++
 7 files changed, 78 insertions(+), 38 deletions(-)
 rename arch/arm/mach-omap2/irq.c => drivers/irqchip/irq-omap-intc.c (89%)
 create mode 100644 include/linux/irqchip/irq-omap-intc.h
Signature · 1 line
2.0.1.563.g66f467c
#1 lore raw

PATCH 1/9 irqchip: add irq-omap-intc.h header

OMAP INTC irqchip driver will be moved under drivers/irqchip/ soon but we still have a dependency with mach-omap2 when it comes to idle functions.

In order to make it easy to share those function prototypes with OMAP PM code, we introduce this new header.

To avoid modifying several board-files and some of the PM-related code, we just include the new header from common.h which was already included by all users of IRQ-related PM code.

---
 arch/arm/mach-omap2/common.h          | 10 +---------
 include/linux/irqchip/irq-omap-intc.h | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+), 9 deletions(-)
 create mode 100644 include/linux/irqchip/irq-omap-intc.h
arch/arm/mach-omap2/common.h +1 -9
index 1800093..377eea8 100644
@@ -32,6 +32,7 @@
 #include <linux/i2c/twl.h>
 #include <linux/i2c-omap.h>
 #include <linux/reboot.h>
+#include <linux/irqchip/irq-omap-intc.h>
 
 #include <asm/proc-fns.h>
 
@@ -210,15 +211,6 @@ extern struct device *omap2_get_iva_device(void);
 extern struct device *omap2_get_l3_device(void);
 extern struct device *omap4_get_dsp_device(void);
 
-void omap2_init_irq(void);
-void omap3_init_irq(void);
-void ti81xx_init_irq(void);
-extern int omap_irq_pending(void);
-void omap_intc_save_context(void);
-void omap_intc_restore_context(void);
-void omap3_intc_suspend(void);
-void omap3_intc_prepare_idle(void);
-void omap3_intc_resume_idle(void);
 void omap_gic_of_init(void);
 
 #ifdef CONFIG_CACHE_L2X0
include/linux/irqchip/irq-omap-intc.h new file +32 -0
new file mode 100644
index 0000000..e06b370
@@ -0,0 +1,32 @@
+/**
+ * irq-omap-intc.h - INTC Idle Functions
+ *
+ * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com
+ *
+ * Author: Felipe Balbi <[email protected]>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2  of
+ * the License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef __INCLUDE_LINUX_IRQCHIP_IRQ_OMAP_INTC_H
+#define __INCLUDE_LINUX_IRQCHIP_IRQ_OMAP_INTC_H
+
+void omap2_init_irq(void);
+void omap3_init_irq(void);
+void ti81xx_init_irq(void);
+
+int omap_irq_pending(void);
+void omap_intc_save_context(void);
+void omap_intc_restore_context(void);
+void omap3_intc_suspend(void);
+void omap3_intc_prepare_idle(void);
+void omap3_intc_resume_idle(void);
+
+#endif /* __INCLUDE_LINUX_IRQCHIP_IRQ_OMAP_INTC_H */
Signature · 1 line
2.0.1.563.g66f467c
#2 lore raw

PATCH 2/9 arm: omap: irq: move irq.c to drivers/irqchip/

In reply to Felipe Balbi

Just move the code over as it has no dependencies
on arch/arm/ anymore.

---
 arch/arm/mach-omap2/Kconfig                                  | 1 +
 arch/arm/mach-omap2/Makefile                                 | 3 +--
 drivers/irqchip/Kconfig                                      | 5 +++++
 drivers/irqchip/Makefile                                     | 1 +
 arch/arm/mach-omap2/irq.c => drivers/irqchip/irq-omap-intc.c | 9 +++++----
 5 files changed, 13 insertions(+), 6 deletions(-)
 rename arch/arm/mach-omap2/irq.c => drivers/irqchip/irq-omap-intc.c (98%)
arch/arm/mach-omap2/Kconfig +1 -0
index 11ccf0b..691d62a 100644
@@ -86,6 +86,7 @@ config ARCH_OMAP2PLUS
 	select PINCTRL
 	select SOC_BUS
 	select TI_PRIV_EDMA
+	select OMAP_IRQCHIP
 	help
 	  Systems based on OMAP2, OMAP3, OMAP4 or OMAP5
 
arch/arm/mach-omap2/Makefile +1 -2
index 69bbcba..0b6095c 100644
@@ -10,7 +10,6 @@ obj-y := id.o io.o control.o mux.o devices.o fb.o serial.o gpmc.o timer.o pm.o \
 	 common.o gpio.o dma.o wd_timer.o display.o i2c.o hdq1w.o omap_hwmod.o \
 	 omap_device.o sram.o drm.o
 
-omap-2-3-common				= irq.o
 hwmod-common				= omap_hwmod.o omap_hwmod_reset.o \
 					  omap_hwmod_common_data.o
 clock-common				= clock.o clock_common_data.o \
@@ -20,7 +19,7 @@ secure-common				= omap-smc.o omap-secure.o
 obj-$(CONFIG_ARCH_OMAP2) += $(omap-2-3-common) $(hwmod-common)
 obj-$(CONFIG_ARCH_OMAP3) += $(omap-2-3-common) $(hwmod-common) $(secure-common)
 obj-$(CONFIG_ARCH_OMAP4) += $(hwmod-common) $(secure-common)
-obj-$(CONFIG_SOC_AM33XX) += irq.o $(hwmod-common)
+obj-$(CONFIG_SOC_AM33XX) += $(hwmod-common)
 obj-$(CONFIG_SOC_OMAP5)	 += $(hwmod-common) $(secure-common)
 obj-$(CONFIG_SOC_AM43XX) += $(hwmod-common) $(secure-common)
 obj-$(CONFIG_SOC_DRA7XX) += $(hwmod-common) $(secure-common)
drivers/irqchip/Kconfig +5 -0
index b8632bf..9d539de 100644
@@ -75,6 +75,11 @@ config OR1K_PIC
 	bool
 	select IRQ_DOMAIN
 
+config OMAP_IRQCHIP
+	bool
+	select GENERIC_IRQ_CHIP
+	select IRQ_DOMAIN
+
 config ORION_IRQCHIP
 	bool
 	select IRQ_DOMAIN
drivers/irqchip/Makefile +1 -0
index 73052ba..d0a2613 100644
@@ -13,6 +13,7 @@ obj-$(CONFIG_ARCH_MOXART)		+= irq-moxart.o
 obj-$(CONFIG_CLPS711X_IRQCHIP)		+= irq-clps711x.o
 obj-$(CONFIG_OR1K_PIC)			+= irq-or1k-pic.o
 obj-$(CONFIG_ORION_IRQCHIP)		+= irq-orion.o
+obj-$(CONFIG_OMAP_IRQCHIP)		+= irq-omap-intc.o
 obj-$(CONFIG_ARCH_SUNXI)		+= irq-sun4i.o
 obj-$(CONFIG_ARCH_SUNXI)		+= irq-sunxi-nmi.o
 obj-$(CONFIG_ARCH_SPEAR3XX)		+= spear-shirq.o
drivers/irqchip/irq-omap-intc.c renamed from arch/arm/mach-omap2/irq.c +5 -4
similarity index 98%
rename from arch/arm/mach-omap2/irq.c
rename to drivers/irqchip/irq-omap-intc.c
index b2993e4..1478f1a 100644
@@ -17,15 +17,16 @@
 #include <linux/io.h>
 
 #include <asm/exception.h>
-#include <asm/mach/irq.h>
 #include <linux/irqdomain.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
 #include <linux/of_irq.h>
 
-#include "soc.h"
-#include "common.h"
-#include "../../drivers/irqchip/irqchip.h"
+#include "irqchip.h"
+
+/* Define these here for now until we drop all board-files */
+#define OMAP24XX_IC_BASE	0x480fe000
+#define OMAP34XX_IC_BASE	0x48200000
 
 /* selected INTC register offsets */
 
Signature · 1 line
2.0.1.563.g66f467c
#3 lore raw

PATCH 3/9 irqchip: omap-intc: minor improvement to omap_irq_pending()

In reply to Felipe Balbi

We already hold the number of Pending registers
in omap_nr_pending. Let's use that instead.

---
 drivers/irqchip/irq-omap-intc.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/irqchip/irq-omap-intc.c +3 -4
index 1478f1a..2933760 100644
@@ -174,11 +174,10 @@ static void __init omap_irq_soft_reset(void)
 
 int omap_irq_pending(void)
 {
-	int irq;
+	int i;
 
-	for (irq = 0; irq < omap_nr_irqs; irq += 32)
-		if (intc_readl(INTC_PENDING_IRQ0 +
-					((irq >> 5) << 5)))
+	for (i = 0; i < omap_nr_pending; i++)
+		if (intc_readl(INTC_PENDING_IRQ0 + (0x20 * i)))
 			return 1;
 	return 0;
 }
Signature · 1 line
2.0.1.563.g66f467c
#4 lore raw

PATCH 4/9 irqchip: omap-intc: comment style cleanup

In reply to Felipe Balbi

no functional changes, just making sure comment
follows Coding Style.

---
 drivers/irqchip/irq-omap-intc.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/irqchip/irq-omap-intc.c +4 -2
index 2933760..f4d562e 100644
@@ -326,9 +326,11 @@ out:
 		}
 	} while (irqnr);
 
-	/* If an irq is masked or deasserted while active, we will
+	/*
+	 * If an irq is masked or deasserted while active, we will
 	 * keep ending up here with no irq handled. So remove it from
-	 * the INTC with an ack.*/
+	 * the INTC with an ack.
+	 */
 	if (!handled_irq)
 		omap_ack_irq(NULL);
 }
Signature · 1 line
2.0.1.563.g66f467c
#5 lore raw

PATCH 5/9 irqchip: omap-intc: remove unnecesary of_address_to_resource() call

In reply to Felipe Balbi

of_iomap(), which is called from omap_init_irq_of(), already takes care of making sure we have a valid resource to deal with. Because of that, we can safely remove our explicit call to of_address_to_resource().

---
 drivers/irqchip/irq-omap-intc.c | 6 ------
 1 file changed, 6 deletions(-)
drivers/irqchip/irq-omap-intc.c +0 -6
index f4d562e..e97b535 100644
@@ -362,7 +362,6 @@ void __init ti81xx_init_irq(void)
 static int __init intc_of_init(struct device_node *node,
 			     struct device_node *parent)
 {
-	struct resource res;
 	int ret;
 
 	omap_nr_pending = 3;
@@ -371,11 +370,6 @@ static int __init intc_of_init(struct device_node *node,
 	if (WARN_ON(!node))
 		return -ENODEV;
 
-	if (of_address_to_resource(node, 0, &res)) {
-		WARN(1, "unable to get intc registers\n");
-		return -EINVAL;
-	}
-
 	if (of_device_is_compatible(node, "ti,am33xx-intc")) {
 		omap_nr_irqs = 128;
 		omap_nr_pending = 4;
Signature · 1 line
2.0.1.563.g66f467c
#6 lore raw

PATCH 6/9 irqchip: omap-intc: enable IP protection

In reply to Felipe Balbi

When PROTECTION bit in enabled in PROTECTION
register, INTC's registers are only accessible
from privileged mode.

---
 drivers/irqchip/irq-omap-intc.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)
drivers/irqchip/irq-omap-intc.c +20 -2
index e97b535..7681b13 100644
@@ -51,6 +51,8 @@
 #define INTCPS_NR_ILR_REGS	128
 #define INTCPS_NR_MIR_REGS	3
 
+#define INTC_PROTECTION_ENABLE	(1 << 0)
+
 /*
  * OMAP2 has a number of different interrupt controllers, each interrupt
  * controller is identified as its own "bank". Register definitions are
@@ -290,12 +292,28 @@ static int __init omap_init_irq_legacy(u32 base)
 	return 0;
 }
 
+static void __init omap_irq_enable_protection(void)
+{
+	u32 reg;
+
+	reg = intc_readl(INTC_PROTECTION);
+	reg |= INTC_PROTECTION_ENABLE;
+	intc_writel(INTC_PROTECTION, reg);
+}
+
 static int __init omap_init_irq(u32 base, struct device_node *node)
 {
+	int ret;
+
 	if (node)
-		return omap_init_irq_of(node);
+		ret = omap_init_irq_of(node);
 	else
-		return omap_init_irq_legacy(base);
+		ret = omap_init_irq_legacy(base);
+
+	if (ret == 0)
+		omap_irq_enable_protection();
+
+	return ret;
 }
 
 static asmlinkage void __exception_irq_entry
Signature · 1 line
2.0.1.563.g66f467c
#7 lore raw

PATCH 7/9 irqchip: omap-intc: enable TURBO idle mode

In reply to Felipe Balbi

When TURBO bit is set in the INTC_IDLE register,
the input synchronizer clock will be autogated
based on activity on the INTC.

Because this idle mode increases the interrupt
latency by 2 clock cycles, we're only enabling
it during suspend.

---

Tony, let me know if you want TURBO to be set unconditionally. That's likely going to shave off a few extra microwatts, although I don't have a good way to measure it.

 drivers/irqchip/irq-omap-intc.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/irqchip/irq-omap-intc.c +5 -0
index 7681b13..dfa2d9d 100644
@@ -51,6 +51,9 @@
 #define INTCPS_NR_ILR_REGS	128
 #define INTCPS_NR_MIR_REGS	3
 
+#define INTC_IDLE_FUNCIDLE	(1 << 0)
+#define INTC_IDLE_TURBO		(1 << 1)
+
 #define INTC_PROTECTION_ENABLE	(1 << 0)
 
 /*
@@ -134,12 +137,14 @@ void omap3_intc_prepare_idle(void)
 	 * cf. errata ID i540 for 3430 (all revisions up to 3.1.x)
 	 */
 	intc_writel(INTC_SYSCONFIG, 0);
+	intc_writel(INTC_IDLE, INTC_IDLE_TURBO);
 }
 
 void omap3_intc_resume_idle(void)
 {
 	/* Re-enable autoidle */
 	intc_writel(INTC_SYSCONFIG, 1);
+	intc_writel(INTC_IDLE, 0);
 }
 
 /* XXX: FIQ and additional INTC support (only MPU@the moment) */
Signature · 1 line
2.0.1.563.g66f467c
#8 lore raw

PATCH 8/9 irqchip: omap-intc: correct maximum number or MIR registers

In reply to Felipe Balbi

maximum number of MIR register is 4, rather than 3. Fix that.

---
 drivers/irqchip/irq-omap-intc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/irqchip/irq-omap-intc.c +1 -1
index dfa2d9d..976d4c1 100644
@@ -49,7 +49,7 @@
 
 #define ACTIVEIRQ_MASK		0x7f	/* omap2/3 active interrupt bits */
 #define INTCPS_NR_ILR_REGS	128
-#define INTCPS_NR_MIR_REGS	3
+#define INTCPS_NR_MIR_REGS	4
 
 #define INTC_IDLE_FUNCIDLE	(1 << 0)
 #define INTC_IDLE_TURBO		(1 << 1)
Signature · 1 line
2.0.1.563.g66f467c
#9 lore raw

PATCH 9/9 irqchip: omap-intc: remove unnecessary comments

In reply to Felipe Balbi

no fuctional changes.

---
 drivers/irqchip/irq-omap-intc.c | 9 ---------
 1 file changed, 9 deletions(-)
drivers/irqchip/irq-omap-intc.c +0 -9
index 976d4c1..f3814e7 100644
@@ -56,14 +56,6 @@
 
 #define INTC_PROTECTION_ENABLE	(1 << 0)
 
-/*
- * OMAP2 has a number of different interrupt controllers, each interrupt
- * controller is identified as its own "bank". Register definitions are
- * fairly consistent for each bank, but not all registers are implemented
- * for each bank.. when in doubt, consult the TRM.
- */
-
-/* Structure to save interrupt controller context */
 struct omap_intc_regs {
 	u32 sysconfig;
 	u32 protection;
@@ -79,7 +71,6 @@ static void __iomem *omap_irq_base;
 static int omap_nr_pending = 3;
 static int omap_nr_irqs = 96;
 
-/* INTC bank register get/set */
 static void intc_writel(u32 reg, u32 val)
 {
 	writel_relaxed(val, omap_irq_base + reg);
Signature · 1 line
2.0.1.563.g66f467c
maintainer
#10 lore raw

cover arm: omap: intc: remaining patches

In reply to Felipe Balbi
Quoted 7 lines · Felipe Balbi

Hi Tony,

Here are the remaining INTC patches rebased on your omap-for-v3.18/intc-v2 branch.

Based on our IRC chat, I kept irq-omap-intc.h header, but included it on common.h instead of modifying every board-file.

Great thanks. We can deal with common.h header once we've dropped the legacy board-*.c files for omap3.

Applying all into omap-for-v3.18/intc-v2.

Regards,

Tony

Quoted 27 lines

cheers

Felipe Balbi (9):
irqchip: add irq-omap-intc.h header
arm: omap: irq: move irq.c to drivers/irqchip/
irqchip: omap-intc: minor improvement to omap_irq_pending()
irqchip: omap-intc: comment style cleanup
irqchip: omap-intc: remove unnecesary of_address_to_resource() call
irqchip: omap-intc: enable IP protection
irqchip: omap-intc: enable TURBO idle mode
irqchip: omap-intc: correct maximum number or MIR registers
irqchip: omap-intc: remove unnecessary comments

 arch/arm/mach-omap2/Kconfig                        |  1 +
 arch/arm/mach-omap2/Makefile                       |  3 +-
 arch/arm/mach-omap2/common.h                       | 10 +---
 drivers/irqchip/Kconfig                            |  5 ++
 drivers/irqchip/Makefile                           |  1 +
 .../irq.c => drivers/irqchip/irq-omap-intc.c       | 64 +++++++++++++---------
 include/linux/irqchip/irq-omap-intc.h              | 32 +++++++++++
 7 files changed, 78 insertions(+), 38 deletions(-)
 rename arch/arm/mach-omap2/irq.c => drivers/irqchip/irq-omap-intc.c (89%)
 create mode 100644 include/linux/irqchip/irq-omap-intc.h
Signature · 1 line
2.0.1.563.g66f467c