Skip to contentSkip to conversation

add wakeup dt support for irq mmp

PATCH Superseded Neil Zhang 3 participants 11 messages Oct 11, 2013 – Nov 28, 2013

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Neil Zhang

author
#0 lore raw

v2 cover add wakeup dt support for irq mmp

changelog:
V2:
add the missing head file.

Neil Zhang (2):
irqchip: mmp: avoid use head file in a specific arch
irqchip: mmp: add dt support for wakeup

 .../devicetree/bindings/arm/mrvl/intc.txt          |   14 ++-
 drivers/irqchip/irq-mmp.c                          |  126 +++++++++++++++++++-
 include/linux/irqchip/mmp.h                        |   13 ++
 3 files changed, 151 insertions(+), 2 deletions(-)
Signature · 1 line
1.7.9.5
author
#1 lore raw

PATCH v2 1/2 irqchip: mmp: avoid use head file in a specific arch

For example, arm64 doesn't have mach/irq.h.

---
 drivers/irqchip/irq-mmp.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/irqchip/irq-mmp.c +1 -1
index 2cb7cd0..470c5de 100644
@@ -22,7 +22,7 @@
 #include <linux/of_irq.h>
 
 #include <asm/exception.h>
-#include <asm/mach/irq.h>
+#include <asm/hardirq.h>
 
 #include "irqchip.h"
 
Signature · 1 line
1.7.9.5
Acked-by on v2 1/2
#2 lore raw

Re: [PATCH 1/2 v2] irqchip: mmp: avoid use head file in a specific arch

Quoted 21 lines · Neil Zhang

For example, arm64 doesn't have mach/irq.h.

---
 drivers/irqchip/irq-mmp.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/irqchip/irq-mmp.c +1 -2
index 2cb7cd0..470c5de 100644
@@ -22,7 +22,7 @@
 #include <linux/of_irq.h>
 
 #include <asm/exception.h>
-#include <asm/mach/irq.h>
+#include <asm/hardirq.h>
 
 #include "irqchip.h"
 
--
Quoted 2 lines

1.7.9.5

Thomas,
Could you help to pick up this patch into your git tree?

Best Regards
Haojian

author
#3 lore raw

PATCH v2 2/2 irqchip: mmp: add dt support for wakeup

In reply to Neil Zhang

Some of the Marvell SoCs use GIC as its interrupt controller,and ICU only used as wakeup logic. When AP subsystem is powered off, GIC will lose its context, the PMU will need ICU to wakeup the AP subsystem. So add wakeup entry for such kind of usage.

---
 .../devicetree/bindings/arm/mrvl/intc.txt          |   14 ++-
 drivers/irqchip/irq-mmp.c                          |  124 ++++++++++++++++++++
 include/linux/irqchip/mmp.h                        |   13 ++
 3 files changed, 150 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/arm/mrvl/intc.txt +13 -1
index 8b53273..4180928 100644
@@ -2,7 +2,7 @@
 
 Required properties:
 - compatible : Should be "mrvl,mmp-intc", "mrvl,mmp2-intc" or
-  "mrvl,mmp2-mux-intc"
+  "mrvl,mmp2-mux-intc", "mrvl,mmp-intc-wakeupgen"
 - reg : Address and length of the register set of the interrupt controller.
   If the interrupt controller is intc, address and length means the range
   of the whold interrupt controller. If the interrupt controller is mux-intc,
@@ -15,6 +15,9 @@ Required properties:
 - interrupt-controller : Identifies the node as an interrupt controller.
 - #interrupt-cells : Specifies the number of cells needed to encode an
   interrupt source.
+- mrvl,intc-gbl-mask : Specifies the address and value for global mask in the
+  interrupt controller.
+- mrvl,intc-for-cp : Specifies the irqs that will be routed to cp
 - mrvl,intc-nr-irqs : Specifies the number of interrupts in the interrupt
   controller.
 - mrvl,clr-mfp-irq : Specifies the interrupt that needs to clear MFP edge
@@ -39,6 +42,15 @@ Example:
 		mrvl,intc-nr-irqs = <2>;
 	};
 
+     intc: wakeupgen@d4282000 {
+		compatible = "mrvl,mmp-intc-wakeupgen";
+		reg = <0xd4282000 0x1000>;
+		mrvl,intc-nr-irqs = <64>;
+		mrvl,intc-gbl-mask = <0x114 0x3
+		                      0x144 0x3>;
+		mrvl,intc-for-cp = <0 31 32>;
+     };
+
 * Marvell Orion Interrupt controller
 
 Required properties
drivers/irqchip/irq-mmp.c +124 -0

147 lines not on this page · raw message

include/linux/irqchip/mmp.h +13 -0
index c78a892..93b05ad 100644
@@ -1,6 +1,19 @@
 #ifndef	__IRQCHIP_MMP_H
 #define	__IRQCHIP_MMP_H
 
+#define ICU_CONF_CPU3      (1 << 9)
+#define ICU_CONF_CPU2      (1 << 8)
+#define ICU_CONF_CPU1      (1 << 7)
+#define ICU_CONF_CPU0      (1 << 6)
+#define ICU_CONF_AP(n)     (1 << (6 + (n & 0x3)))
+#define ICU_CONF_AP_MASK   (0xF << 6)
+#define ICU_CONF_SEAGULL   (1 << 5)
+#define ICU_CONF_IRQ_FIQ   (1 << 4)
+#define ICU_CONF_PRIO(n)   (n & 0xF)
+
+#define ICU_IRQ_CPU0_MASKED    (ICU_CONF_IRQ_FIQ | ICU_CONF_CPU0)
+
 extern struct irq_chip icu_irq_chip;
 
+extern void __init mmp_of_wakeup_init(void);
 #endif	/* __IRQCHIP_MMP_H */
Signature · 1 line
1.7.9.5
author
#4 lore raw

RE: [PATCH 2/2 v2] irqchip: mmp: add dt support for wakeup

Ping ?

Quoted 235 lines

-----Original Message-----
From: Neil Zhang [mailto:[email protected]]
Sent: 2013年10月11日 16:24
To: [email protected]
Cc: [email protected]; [email protected]; Neil Zhang
Subject: [PATCH 2/2 v2] irqchip: mmp: add dt support for wakeup

Some of the Marvell SoCs use GIC as its interrupt controller,and ICU only used as wakeup logic. When AP subsystem is powered off, GIC will lose its context, the PMU will need ICU to wakeup the AP subsystem.
So add wakeup entry for such kind of usage.

---
 .../devicetree/bindings/arm/mrvl/intc.txt          |   14 ++-
 drivers/irqchip/irq-mmp.c                          |  124
++++++++++++++++++++
 include/linux/irqchip/mmp.h                        |   13 ++
 3 files changed, 150 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/arm/mrvl/intc.txt +14 -3
index 8b53273..4180928 100644
@@ -2,7 +2,7 @@
 
 Required properties:
 - compatible : Should be "mrvl,mmp-intc", "mrvl,mmp2-intc" or
-  "mrvl,mmp2-mux-intc"
+  "mrvl,mmp2-mux-intc", "mrvl,mmp-intc-wakeupgen"
 - reg : Address and length of the register set of the interrupt controller.
   If the interrupt controller is intc, address and length means the range
   of the whold interrupt controller. If the interrupt controller is mux-intc, @@
-15,6 +15,9 @@ Required properties:
 - interrupt-controller : Identifies the node as an interrupt controller.
 - #interrupt-cells : Specifies the number of cells needed to encode an
   interrupt source.
+- mrvl,intc-gbl-mask : Specifies the address and value for global mask
+in the
+  interrupt controller.
+- mrvl,intc-for-cp : Specifies the irqs that will be routed to cp
 - mrvl,intc-nr-irqs : Specifies the number of interrupts in the interrupt
   controller.
 - mrvl,clr-mfp-irq : Specifies the interrupt that needs to clear MFP edge @@
-39,6 +42,15 @@ Example:
 		mrvl,intc-nr-irqs = <2>;
 	};
 
+     intc: wakeupgen@d4282000 {
+		compatible = "mrvl,mmp-intc-wakeupgen";
+		reg = <0xd4282000 0x1000>;
+		mrvl,intc-nr-irqs = <64>;
+		mrvl,intc-gbl-mask = <0x114 0x3
+		                      0x144 0x3>;
+		mrvl,intc-for-cp = <0 31 32>;
+     };
+
 * Marvell Orion Interrupt controller
 
 Required properties
drivers/irqchip/irq-mmp.c index renamed from drivers/irqchip/irq-mmp.c +0 -0

470c5de..445a00c 100644

drivers/irqchip/irq-mmp.c +119 -0
@@ -16,6 +16,8 @@
 #include <linux/init.h>
 #include <linux/irq.h>
 #include <linux/irqdomain.h>
+#include <linux/irqchip/mmp.h>
+#include <linux/irqchip/arm-gic.h>
 #include <linux/io.h>
 #include <linux/ioport.h>
 #include <linux/of_address.h>
@@ -58,6 +60,8 @@ struct mmp_intc_conf {  static void __iomem
 *mmp_icu_base;  static struct icu_chip_data icu_data[MAX_ICU_NR];  static
 int max_icu_nr;
+static u32 irq_for_cp[64];
+static u32 irq_for_cp_nr;	/* How many irqs will be routed to cp */
 
 extern void mmp2_clear_pmic_int(void);
 
@@ -123,6 +127,50 @@ static void icu_unmask_irq(struct irq_data *d)
 	}
 }
 
+static int irq_ignore_wakeup(struct icu_chip_data *data, int hwirq) {
+	int i;
+
+	if (hwirq < 0 || hwirq >= data->nr_irqs)
+		return 1;
+
+	for (i = 0; i < irq_for_cp_nr; i++)
+		if (irq_for_cp[i] == hwirq)
+			return 1;
+
+	return 0;
+}
+
+static void icu_mask_irq_wakeup(struct irq_data *d) {
+	struct icu_chip_data *data = &icu_data[0];
+	int hwirq = d->hwirq - data->virq_base;
+	u32 r;
+
+	if (irq_ignore_wakeup(data, hwirq))
+		return;
+
+	r = readl_relaxed(mmp_icu_base + (hwirq << 2));
+	r &= ~data->conf_mask;
+	r |= data->conf_disable;
+	writel_relaxed(r, mmp_icu_base + (hwirq << 2)); }
+
+static void icu_unmask_irq_wakeup(struct irq_data *d) {
+	struct icu_chip_data *data = &icu_data[0];
+	int hwirq = d->irq - data->virq_base;
+	u32 r;
+
+	if (irq_ignore_wakeup(data, hwirq))
+		return;
+
+	r = readl_relaxed(mmp_icu_base + (hwirq << 2));
+	r &= ~data->conf_mask;
+	r |= data->conf_enable;
+	writel_relaxed(r, mmp_icu_base + (hwirq << 2)); }
+
 struct irq_chip icu_irq_chip = {
 	.name		= "icu_irq",
 	.irq_mask	= icu_mask_irq,
@@ -491,5 +539,81 @@ err:
 	irq_domain_remove(icu_data[i].domain);
 	return -EINVAL;
 }
+
+void __init mmp_of_wakeup_init(void)
+{
+	struct device_node *node;
+	const __be32 *wakeup_reg;
+	const __be32 *cp_irq_reg;
+	int ret, nr_irqs;
+	int size, i = 0;
+	int irq;
+
+	node = of_find_compatible_node(NULL, NULL,
 "mrvl,mmp-intc-wakeupgen");
+	if (!node) {
+		pr_err("Failed to find interrupt controller in arch-mmp\n");
+		return;
+	}
+
+	mmp_icu_base = of_iomap(node, 0);
+	if (!mmp_icu_base) {
+		pr_err("Failed to get interrupt controller register\n");
+		return;
+	}
+
+	ret = of_property_read_u32(node, "mrvl,intc-nr-irqs", &nr_irqs);
+	if (ret) {
+		pr_err("Not found mrvl,intc-nr-irqs property\n");
+		return;
+	}
+
+	/*
+	 * Config all the interrupt source be able to interrupt the cpu 0,
+	 * in IRQ mode, with priority 0 as masked by default.
+	 */
+	for (irq = 0; irq < nr_irqs; irq++)
+		__raw_writel(ICU_IRQ_CPU0_MASKED, mmp_icu_base + (irq << 2));
+
+	/* ICU is only used as wake up logic
+	  * disable the global irq/fiq in icu for all cores.
+	  */
+	wakeup_reg = of_get_property(node, "mrvl,intc-gbl-mask", &size);
+	if (!wakeup_reg) {
+		pr_err("Not found mrvl,intc-gbl-mask property\n");
+		return;
+	}
+
+	size /= sizeof(*wakeup_reg);
+	while (i < size) {
+		unsigned offset, val;
+
+		offset = be32_to_cpup(wakeup_reg + i++);
+		val = be32_to_cpup(wakeup_reg + i++);
+		writel_relaxed(val, mmp_icu_base + offset);
+	}
+
+	/* Get the irq lines and ignore irqs */
+	cp_irq_reg = of_get_property(node, "mrvl,intc-for-cp", &size);
+	if (!cp_irq_reg)
+		return;
+
+	irq_for_cp_nr = size / sizeof(*cp_irq_reg);
+	for (i = 0; i < irq_for_cp_nr; i++) {
+		irq_for_cp[i] = be32_to_cpup(cp_irq_reg + i);
+		__raw_writel(ICU_CONF_SEAGULL, mmp_icu_base + (irq_for_cp[i]
 << 2));
+	}
+
+	icu_data[0].conf_enable = mmp_conf.conf_enable;
+	icu_data[0].conf_disable = mmp_conf.conf_disable;
+	icu_data[0].conf_mask = mmp_conf.conf_mask;
+	icu_data[0].nr_irqs = nr_irqs;
+	icu_data[0].virq_base = 32;
+
+	gic_arch_extn.irq_mask = icu_mask_irq_wakeup;
+	gic_arch_extn.irq_unmask = icu_unmask_irq_wakeup;
+
+	return;
+}
+

IRQCHIP_DECLARE(mmp2_mux_intc, "mrvl,mmp2-mux-intc",
mmp2_mux_of_init); #endif diff --git a/include/linux/irqchip/mmp.h b/include/linux/irqchip/mmp.h index c78a892..93b05ad 100644

include/linux/irqchip/mmp.h +13 -0
@@ -1,6 +1,19 @@
 #ifndef	__IRQCHIP_MMP_H
 #define	__IRQCHIP_MMP_H
 
+#define ICU_CONF_CPU3      (1 << 9)
+#define ICU_CONF_CPU2      (1 << 8)
+#define ICU_CONF_CPU1      (1 << 7)
+#define ICU_CONF_CPU0      (1 << 6)
+#define ICU_CONF_AP(n)     (1 << (6 + (n & 0x3)))
+#define ICU_CONF_AP_MASK   (0xF << 6)
+#define ICU_CONF_SEAGULL   (1 << 5)
+#define ICU_CONF_IRQ_FIQ   (1 << 4)
+#define ICU_CONF_PRIO(n)   (n & 0xF)
+
+#define ICU_IRQ_CPU0_MASKED    (ICU_CONF_IRQ_FIQ |
 ICU_CONF_CPU0)
+
 extern struct irq_chip icu_irq_chip;
 
+extern void __init mmp_of_wakeup_init(void);
Quoted 3 lines

#endif /* __IRQCHIP_MMP_H */
--
1.7.9.5

Best Regards,
Neil Zhang

�翳簕.n�+壏煯壄�+%娝�遍荻w�簕.n�+壏{炳G珴�妠ay�蕠跈�,jf"穐殢飦�戧鐉_璁(殠娸"濟�m���G珴�⒏?櫒璀�&x忈秈O曟瑉窔v豝�m��� �鹅�⒏?朓�

author
#5 lore raw

RE: [PATCH 2/2 v2] irqchip: mmp: add dt support for wakeup

Haojian,

Quoted 7 lines

-----Original Message-----
From: Neil Zhang
Sent: 2013年10月18日 17:50
To: Neil Zhang; [email protected]
Cc: [email protected]; [email protected]
Subject: RE: [PATCH 2/2 v2] irqchip: mmp: add dt support for wakeup

Quoted 9 lines

Ping ?

Quoted 7 lines

-----Original Message-----
From: Neil Zhang [mailto:[email protected]]
Sent: 2013年10月11日 16:24
To: [email protected]
Cc: [email protected]; [email protected]; Neil Zhang
Subject: [PATCH 2/2 v2] irqchip: mmp: add dt support for wakeup

Would you please have a look?

Quoted 229 lines
Quoted 229 lines

Some of the Marvell SoCs use GIC as its interrupt controller,and ICU only used as wakeup logic. When AP subsystem is powered off, GIC will lose its context, the PMU will need ICU to wakeup the AP subsystem. So add wakeup entry for such kind of usage.

---
 .../devicetree/bindings/arm/mrvl/intc.txt          |   14 ++-
 drivers/irqchip/irq-mmp.c                          |  124
++++++++++++++++++++
 include/linux/irqchip/mmp.h                        |   13 ++
 3 files changed, 150 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/arm/mrvl/intc.txt +1 -1
index 8b53273..4180928 100644
@@ -2,7 +2,7 @@
 
 Required properties:
 - compatible : Should be "mrvl,mmp-intc", "mrvl,mmp2-intc" or
-  "mrvl,mmp2-mux-intc"
+  "mrvl,mmp2-mux-intc", "mrvl,mmp-intc-wakeupgen"
 - reg : Address and length of the register set of the interrupt controller.
   If the interrupt controller is intc, address and length means the range
   of the whold interrupt controller. If the interrupt controller is

mux-intc, @@
-15,6 +15,9 @@ Required properties:
- interrupt-controller : Identifies the node as an interrupt controller.
- #interrupt-cells : Specifies the number of cells needed to encode an interrupt source.
+- mrvl,intc-gbl-mask : Specifies the address and value for global

Documentation/devicetree/bindings/arm/mrvl/intc.txt +3 -0
+mask in the
+  interrupt controller.
+- mrvl,intc-for-cp : Specifies the irqs that will be routed to cp
 - mrvl,intc-nr-irqs : Specifies the number of interrupts in the interrupt
   controller.
 - mrvl,clr-mfp-irq : Specifies the interrupt that needs to clear MFP

edge @@
-39,6 +42,15 @@ Example:

Documentation/devicetree/bindings/arm/mrvl/intc.txt +9 -0
 		mrvl,intc-nr-irqs = <2>;
 	};
 
+     intc: wakeupgen@d4282000 {
+		compatible = "mrvl,mmp-intc-wakeupgen";
+		reg = <0xd4282000 0x1000>;
+		mrvl,intc-nr-irqs = <64>;
+		mrvl,intc-gbl-mask = <0x114 0x3
+		                      0x144 0x3>;
+		mrvl,intc-for-cp = <0 31 32>;
+     };
+
 * Marvell Orion Interrupt controller
 
 Required properties
drivers/irqchip/irq-mmp.c +119 -0
index 470c5de..445a00c 100644
@@ -16,6 +16,8 @@
 #include <linux/init.h>
 #include <linux/irq.h>
 #include <linux/irqdomain.h>
+#include <linux/irqchip/mmp.h>
+#include <linux/irqchip/arm-gic.h>
 #include <linux/io.h>
 #include <linux/ioport.h>
 #include <linux/of_address.h>
@@ -58,6 +60,8 @@ struct mmp_intc_conf {  static void __iomem
 *mmp_icu_base;  static struct icu_chip_data icu_data[MAX_ICU_NR];
 static int max_icu_nr;
+static u32 irq_for_cp[64];
+static u32 irq_for_cp_nr;	/* How many irqs will be routed to cp */
 
 extern void mmp2_clear_pmic_int(void);
 
@@ -123,6 +127,50 @@ static void icu_unmask_irq(struct irq_data *d)
 	}
 }
 
+static int irq_ignore_wakeup(struct icu_chip_data *data, int hwirq) {
+	int i;
+
+	if (hwirq < 0 || hwirq >= data->nr_irqs)
+		return 1;
+
+	for (i = 0; i < irq_for_cp_nr; i++)
+		if (irq_for_cp[i] == hwirq)
+			return 1;
+
+	return 0;
+}
+
+static void icu_mask_irq_wakeup(struct irq_data *d) {
+	struct icu_chip_data *data = &icu_data[0];
+	int hwirq = d->hwirq - data->virq_base;
+	u32 r;
+
+	if (irq_ignore_wakeup(data, hwirq))
+		return;
+
+	r = readl_relaxed(mmp_icu_base + (hwirq << 2));
+	r &= ~data->conf_mask;
+	r |= data->conf_disable;
+	writel_relaxed(r, mmp_icu_base + (hwirq << 2)); }
+
+static void icu_unmask_irq_wakeup(struct irq_data *d) {
+	struct icu_chip_data *data = &icu_data[0];
+	int hwirq = d->irq - data->virq_base;
+	u32 r;
+
+	if (irq_ignore_wakeup(data, hwirq))
+		return;
+
+	r = readl_relaxed(mmp_icu_base + (hwirq << 2));
+	r &= ~data->conf_mask;
+	r |= data->conf_enable;
+	writel_relaxed(r, mmp_icu_base + (hwirq << 2)); }
+
 struct irq_chip icu_irq_chip = {
 	.name		= "icu_irq",
 	.irq_mask	= icu_mask_irq,
@@ -491,5 +539,81 @@ err:
 	irq_domain_remove(icu_data[i].domain);
 	return -EINVAL;
 }
+
+void __init mmp_of_wakeup_init(void)
+{
+	struct device_node *node;
+	const __be32 *wakeup_reg;
+	const __be32 *cp_irq_reg;
+	int ret, nr_irqs;
+	int size, i = 0;
+	int irq;
+
+	node = of_find_compatible_node(NULL, NULL,
 "mrvl,mmp-intc-wakeupgen");
+	if (!node) {
+		pr_err("Failed to find interrupt controller in arch-mmp\n");
+		return;
+	}
+
+	mmp_icu_base = of_iomap(node, 0);
+	if (!mmp_icu_base) {
+		pr_err("Failed to get interrupt controller register\n");
+		return;
+	}
+
+	ret = of_property_read_u32(node, "mrvl,intc-nr-irqs", &nr_irqs);
+	if (ret) {
+		pr_err("Not found mrvl,intc-nr-irqs property\n");
+		return;
+	}
+
+	/*
+	 * Config all the interrupt source be able to interrupt the cpu 0,
+	 * in IRQ mode, with priority 0 as masked by default.
+	 */
+	for (irq = 0; irq < nr_irqs; irq++)
+		__raw_writel(ICU_IRQ_CPU0_MASKED, mmp_icu_base + (irq << 2));
+
+	/* ICU is only used as wake up logic
+	  * disable the global irq/fiq in icu for all cores.
+	  */
+	wakeup_reg = of_get_property(node, "mrvl,intc-gbl-mask", &size);
+	if (!wakeup_reg) {
+		pr_err("Not found mrvl,intc-gbl-mask property\n");
+		return;
+	}
+
+	size /= sizeof(*wakeup_reg);
+	while (i < size) {
+		unsigned offset, val;
+
+		offset = be32_to_cpup(wakeup_reg + i++);
+		val = be32_to_cpup(wakeup_reg + i++);
+		writel_relaxed(val, mmp_icu_base + offset);
+	}
+
+	/* Get the irq lines and ignore irqs */
+	cp_irq_reg = of_get_property(node, "mrvl,intc-for-cp", &size);
+	if (!cp_irq_reg)
+		return;
+
+	irq_for_cp_nr = size / sizeof(*cp_irq_reg);
+	for (i = 0; i < irq_for_cp_nr; i++) {
+		irq_for_cp[i] = be32_to_cpup(cp_irq_reg + i);
+		__raw_writel(ICU_CONF_SEAGULL, mmp_icu_base + (irq_for_cp[i]
 << 2));
+	}
+
+	icu_data[0].conf_enable = mmp_conf.conf_enable;
+	icu_data[0].conf_disable = mmp_conf.conf_disable;
+	icu_data[0].conf_mask = mmp_conf.conf_mask;
+	icu_data[0].nr_irqs = nr_irqs;
+	icu_data[0].virq_base = 32;
+
+	gic_arch_extn.irq_mask = icu_mask_irq_wakeup;
+	gic_arch_extn.irq_unmask = icu_unmask_irq_wakeup;
+
+	return;
+}
+

IRQCHIP_DECLARE(mmp2_mux_intc, "mrvl,mmp2-mux-intc",
mmp2_mux_of_init); #endif diff --git a/include/linux/irqchip/mmp.h b/include/linux/irqchip/mmp.h index c78a892..93b05ad 100644

include/linux/irqchip/mmp.h +12 -0
@@ -1,6 +1,19 @@
 #ifndef	__IRQCHIP_MMP_H
 #define	__IRQCHIP_MMP_H
 
+#define ICU_CONF_CPU3      (1 << 9)
+#define ICU_CONF_CPU2      (1 << 8)
+#define ICU_CONF_CPU1      (1 << 7)
+#define ICU_CONF_CPU0      (1 << 6)
+#define ICU_CONF_AP(n)     (1 << (6 + (n & 0x3)))
+#define ICU_CONF_AP_MASK   (0xF << 6)
+#define ICU_CONF_SEAGULL   (1 << 5)
+#define ICU_CONF_IRQ_FIQ   (1 << 4)
+#define ICU_CONF_PRIO(n)   (n & 0xF)
+
+#define ICU_IRQ_CPU0_MASKED    (ICU_CONF_IRQ_FIQ |
 ICU_CONF_CPU0)
+
 extern struct irq_chip icu_irq_chip;
 
Quoted 7 lines
Quoted 4 lines
include/linux/irqchip/mmp.h +1 -0
+extern void __init mmp_of_wakeup_init(void);

#endif /* __IRQCHIP_MMP_H */
--
1.7.9.5

Best Regards,
Neil Zhang

Best Regards,
Neil Zhang �翳簕.n�+壏煯壄�+%娝�遍荻w�簕.n�+壏{炳G珴�妠ay�蕠跈�,jf"穐殢飦�戧鐉_璁(殠娸"濟�m���G珴�⒏?櫒璀�&x忈秈O曟瑉窔v豝�m��� �鹅�⒏?朓�

#6 lore raw

Re: [PATCH 2/2 v2] irqchip: mmp: add dt support for wakeup

In reply to Neil Zhang
Quoted 26 lines · Neil Zhang

Some of the Marvell SoCs use GIC as its interrupt controller,and ICU only used as wakeup logic. When AP subsystem is powered off, GIC will lose its context, the PMU will need ICU to wakeup the AP subsystem. So add wakeup entry for such kind of usage.

---
 .../devicetree/bindings/arm/mrvl/intc.txt          |   14 ++-
 drivers/irqchip/irq-mmp.c                          |  124 ++++++++++++++++++++
 include/linux/irqchip/mmp.h                        |   13 ++
 3 files changed, 150 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/arm/mrvl/intc.txt +1 -1
index 8b53273..4180928 100644
@@ -2,7 +2,7 @@
 
 Required properties:
 - compatible : Should be "mrvl,mmp-intc", "mrvl,mmp2-intc" or
-  "mrvl,mmp2-mux-intc"
+  "mrvl,mmp2-mux-intc", "mrvl,mmp-intc-wakeupgen"
 - reg : Address and length of the register set of the interrupt controller.
   If the interrupt controller is intc, address and length means the range
   of the whold interrupt controller. If the interrupt controller is mux-intc,

Documentation/devicetree/bindings/arm/mrvl/intc.txt Required properties: · line 19

Quoted 5 lines
Documentation/devicetree/bindings/arm/mrvl/intc.txt +2 -0
@@ -15,6 +15,9 @@ Required properties:
 - interrupt-controller : Identifies the node as an interrupt controller.
 - #interrupt-cells : Specifies the number of cells needed to encode an
   interrupt source.
+- mrvl,intc-gbl-mask : Specifies the address and value for global mask in the
+  interrupt controller.

As my understanding, we should avoid to write register settings in DTS file.

Loop devicetree guys.

Quoted 200 lines
Documentation/devicetree/bindings/arm/mrvl/intc.txt +10 -0
+- mrvl,intc-for-cp : Specifies the irqs that will be routed to cp
 - mrvl,intc-nr-irqs : Specifies the number of interrupts in the interrupt
   controller.
 - mrvl,clr-mfp-irq : Specifies the interrupt that needs to clear MFP edge
@@ -39,6 +42,15 @@ Example:
                mrvl,intc-nr-irqs = <2>;
        };
 
+     intc: wakeupgen@d4282000 {
+               compatible = "mrvl,mmp-intc-wakeupgen";
+               reg = <0xd4282000 0x1000>;
+               mrvl,intc-nr-irqs = <64>;
+               mrvl,intc-gbl-mask = <0x114 0x3
+                                     0x144 0x3>;
+               mrvl,intc-for-cp = <0 31 32>;
+     };
+
 * Marvell Orion Interrupt controller
 
 Required properties
drivers/irqchip/irq-mmp.c +124 -0
index 470c5de..445a00c 100644
@@ -16,6 +16,8 @@
 #include <linux/init.h>
 #include <linux/irq.h>
 #include <linux/irqdomain.h>
+#include <linux/irqchip/mmp.h>
+#include <linux/irqchip/arm-gic.h>
 #include <linux/io.h>
 #include <linux/ioport.h>
 #include <linux/of_address.h>
@@ -58,6 +60,8 @@ struct mmp_intc_conf {
 static void __iomem *mmp_icu_base;
 static struct icu_chip_data icu_data[MAX_ICU_NR];
 static int max_icu_nr;
+static u32 irq_for_cp[64];
+static u32 irq_for_cp_nr;      /* How many irqs will be routed to cp */
 
 extern void mmp2_clear_pmic_int(void);
 
@@ -123,6 +127,50 @@ static void icu_unmask_irq(struct irq_data *d)
        }
 }
 
+static int irq_ignore_wakeup(struct icu_chip_data *data, int hwirq)
+{
+       int i;
+
+       if (hwirq < 0 || hwirq >= data->nr_irqs)
+               return 1;
+
+       for (i = 0; i < irq_for_cp_nr; i++)
+               if (irq_for_cp[i] == hwirq)
+                       return 1;
+
+       return 0;
+}
+
+static void icu_mask_irq_wakeup(struct irq_data *d)
+{
+       struct icu_chip_data *data = &icu_data[0];
+       int hwirq = d->hwirq - data->virq_base;
+       u32 r;
+
+       if (irq_ignore_wakeup(data, hwirq))
+               return;
+
+       r = readl_relaxed(mmp_icu_base + (hwirq << 2));
+       r &= ~data->conf_mask;
+       r |= data->conf_disable;
+       writel_relaxed(r, mmp_icu_base + (hwirq << 2));
+}
+
+static void icu_unmask_irq_wakeup(struct irq_data *d)
+{
+       struct icu_chip_data *data = &icu_data[0];
+       int hwirq = d->irq - data->virq_base;
+       u32 r;
+
+       if (irq_ignore_wakeup(data, hwirq))
+               return;
+
+       r = readl_relaxed(mmp_icu_base + (hwirq << 2));
+       r &= ~data->conf_mask;
+       r |= data->conf_enable;
+       writel_relaxed(r, mmp_icu_base + (hwirq << 2));
+}
+
 struct irq_chip icu_irq_chip = {
        .name           = "icu_irq",
        .irq_mask       = icu_mask_irq,
@@ -491,5 +539,81 @@ err:
        irq_domain_remove(icu_data[i].domain);
        return -EINVAL;
 }
+
+void __init mmp_of_wakeup_init(void)
+{
+       struct device_node *node;
+       const __be32 *wakeup_reg;
+       const __be32 *cp_irq_reg;
+       int ret, nr_irqs;
+       int size, i = 0;
+       int irq;
+
+       node = of_find_compatible_node(NULL, NULL, "mrvl,mmp-intc-wakeupgen");
+       if (!node) {
+               pr_err("Failed to find interrupt controller in arch-mmp\n");
+               return;
+       }
+
+       mmp_icu_base = of_iomap(node, 0);
+       if (!mmp_icu_base) {
+               pr_err("Failed to get interrupt controller register\n");
+               return;
+       }
+
+       ret = of_property_read_u32(node, "mrvl,intc-nr-irqs", &nr_irqs);
+       if (ret) {
+               pr_err("Not found mrvl,intc-nr-irqs property\n");
+               return;
+       }
+
+       /*
+        * Config all the interrupt source be able to interrupt the cpu 0,
+        * in IRQ mode, with priority 0 as masked by default.
+        */
+       for (irq = 0; irq < nr_irqs; irq++)
+               __raw_writel(ICU_IRQ_CPU0_MASKED, mmp_icu_base + (irq << 2));
+
+       /* ICU is only used as wake up logic
+         * disable the global irq/fiq in icu for all cores.
+         */
+       wakeup_reg = of_get_property(node, "mrvl,intc-gbl-mask", &size);
+       if (!wakeup_reg) {
+               pr_err("Not found mrvl,intc-gbl-mask property\n");
+               return;
+       }
+
+       size /= sizeof(*wakeup_reg);
+       while (i < size) {
+               unsigned offset, val;
+
+               offset = be32_to_cpup(wakeup_reg + i++);
+               val = be32_to_cpup(wakeup_reg + i++);
+               writel_relaxed(val, mmp_icu_base + offset);
+       }
+
+       /* Get the irq lines and ignore irqs */
+       cp_irq_reg = of_get_property(node, "mrvl,intc-for-cp", &size);
+       if (!cp_irq_reg)
+               return;
+
+       irq_for_cp_nr = size / sizeof(*cp_irq_reg);
+       for (i = 0; i < irq_for_cp_nr; i++) {
+               irq_for_cp[i] = be32_to_cpup(cp_irq_reg + i);
+               __raw_writel(ICU_CONF_SEAGULL, mmp_icu_base + (irq_for_cp[i] << 2));
+       }
+
+       icu_data[0].conf_enable = mmp_conf.conf_enable;
+       icu_data[0].conf_disable = mmp_conf.conf_disable;
+       icu_data[0].conf_mask = mmp_conf.conf_mask;
+       icu_data[0].nr_irqs = nr_irqs;
+       icu_data[0].virq_base = 32;
+
+       gic_arch_extn.irq_mask = icu_mask_irq_wakeup;
+       gic_arch_extn.irq_unmask = icu_unmask_irq_wakeup;
+
+       return;
+}
+
 IRQCHIP_DECLARE(mmp2_mux_intc, "mrvl,mmp2-mux-intc", mmp2_mux_of_init);
 #endif
include/linux/irqchip/mmp.h +13 -1
index c78a892..93b05ad 100644
@@ -1,6 +1,19 @@
 #ifndef        __IRQCHIP_MMP_H
 #define        __IRQCHIP_MMP_H
 
+#define ICU_CONF_CPU3      (1 << 9)
+#define ICU_CONF_CPU2      (1 << 8)
+#define ICU_CONF_CPU1      (1 << 7)
+#define ICU_CONF_CPU0      (1 << 6)
+#define ICU_CONF_AP(n)     (1 << (6 + (n & 0x3)))
+#define ICU_CONF_AP_MASK   (0xF << 6)
+#define ICU_CONF_SEAGULL   (1 << 5)
+#define ICU_CONF_IRQ_FIQ   (1 << 4)
+#define ICU_CONF_PRIO(n)   (n & 0xF)
+
+#define ICU_IRQ_CPU0_MASKED    (ICU_CONF_IRQ_FIQ | ICU_CONF_CPU0)
+
 extern struct irq_chip icu_irq_chip;
 
+extern void __init mmp_of_wakeup_init(void);
 #endif /* __IRQCHIP_MMP_H */
--
Quoted 2 lines

1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#7 lore raw

Re: [PATCH 2/2 v2] irqchip: mmp: add dt support for wakeup

Quoted 19 lines · Haojian Zhuang
Quoted 18 lines · Neil Zhang

Some of the Marvell SoCs use GIC as its interrupt controller,and ICU only used as wakeup logic. When AP subsystem is powered off, GIC will lose its context, the PMU will need ICU to wakeup the AP subsystem. So add wakeup entry for such kind of usage.

---
 .../devicetree/bindings/arm/mrvl/intc.txt          |   14 ++-
 drivers/irqchip/irq-mmp.c                          |  124 ++++++++++++++++++++
 include/linux/irqchip/mmp.h                        |   13 ++
 3 files changed, 150 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/arm/mrvl/intc.txt +0 -0
index 8b53273..4180928 100644
@@ -2,7 +2,7 @@
 
Quoted 4 lines

Documentation/devicetree/bindings/arm/mrvl/intc.txt line 5

Quoted 4 lines
Documentation/devicetree/bindings/arm/mrvl/intc.txt +1 -1
 Required properties:
 - compatible : Should be "mrvl,mmp-intc", "mrvl,mmp2-intc" or
-  "mrvl,mmp2-mux-intc"
+  "mrvl,mmp2-mux-intc", "mrvl,mmp-intc-wakeupgen"

Why do we need a new compatible string?

Quoted 11 lines

Documentation/devicetree/bindings/arm/mrvl/intc.txt Required properties: · line 19

Quoted 9 lines
Documentation/devicetree/bindings/arm/mrvl/intc.txt +2 -0
 - reg : Address and length of the register set of the interrupt controller.
   If the interrupt controller is intc, address and length means the range
   of the whold interrupt controller. If the interrupt controller is mux-intc,
@@ -15,6 +15,9 @@ Required properties:
 - interrupt-controller : Identifies the node as an interrupt controller.
 - #interrupt-cells : Specifies the number of cells needed to encode an
   interrupt source.
+- mrvl,intc-gbl-mask : Specifies the address and value for global mask in the
+  interrupt controller.

As my understanding, we should avoid to write register settings in DTS file.

In general, yes. We should describe the hardware and let Linux choose how to configure it as far as possible.

What is this global mask? What is it used for? Why do there seem to be multiple global masks (judging by the example)?

Quoted 4 lines

Loop devicetree guys.

Quoted 1 line
Documentation/devicetree/bindings/arm/mrvl/intc.txt +1 -0
+- mrvl,intc-for-cp : Specifies the irqs that will be routed to cp

cp?

_why_ do we need this, and what exactly does routing the irqs to the cp imply?

Quoted 7 lines
Quoted 7 lines
Documentation/devicetree/bindings/arm/mrvl/intc.txt +0 -0
 - mrvl,intc-nr-irqs : Specifies the number of interrupts in the interrupt
   controller.
 - mrvl,clr-mfp-irq : Specifies the interrupt that needs to clear MFP edge
@@ -39,6 +42,15 @@ Example:
                mrvl,intc-nr-irqs = <2>;
        };
 
Quoted 6 lines

Documentation/devicetree/bindings/arm/mrvl/intc.txt Example: · line 50

Quoted 6 lines
Documentation/devicetree/bindings/arm/mrvl/intc.txt +6 -0
+     intc: wakeupgen@d4282000 {
+               compatible = "mrvl,mmp-intc-wakeupgen";
+               reg = <0xd4282000 0x1000>;
+               mrvl,intc-nr-irqs = <64>;
+               mrvl,intc-gbl-mask = <0x114 0x3
+                                     0x144 0x3>;

Are these multiple entries? The binding text implied there was only one entry. What is this?

[...]

Quoted 6 lines
Quoted 6 lines
Documentation/devicetree/bindings/arm/mrvl/intc.txt +6 -0
+void __init mmp_of_wakeup_init(void)
+{
+       struct device_node *node;
+       const __be32 *wakeup_reg;
+       const __be32 *cp_irq_reg;
+       int ret, nr_irqs;
Quoted 8 lines

Documentation/devicetree/bindings/arm/mrvl/intc.txt Example:

Quoted 8 lines
Documentation/devicetree/bindings/arm/mrvl/intc.txt +8 -0
+       int size, i = 0;
+       int irq;
+
+       node = of_find_compatible_node(NULL, NULL, "mrvl,mmp-intc-wakeupgen");
+       if (!node) {
+               pr_err("Failed to find interrupt controller in arch-mmp\n");
+               return;
+       }

Why can this not be done in the standard probe path, using the node you'll have been handed by the core code?

Quoted 27 lines
Quoted 27 lines
Documentation/devicetree/bindings/arm/mrvl/intc.txt +27 -0
+
+       mmp_icu_base = of_iomap(node, 0);
+       if (!mmp_icu_base) {
+               pr_err("Failed to get interrupt controller register\n");
+               return;
+       }
+
+       ret = of_property_read_u32(node, "mrvl,intc-nr-irqs", &nr_irqs);
+       if (ret) {
+               pr_err("Not found mrvl,intc-nr-irqs property\n");
+               return;
+       }
+
+       /*
+        * Config all the interrupt source be able to interrupt the cpu 0,
+        * in IRQ mode, with priority 0 as masked by default.
+        */
+       for (irq = 0; irq < nr_irqs; irq++)
+               __raw_writel(ICU_IRQ_CPU0_MASKED, mmp_icu_base + (irq << 2));
+
+       /* ICU is only used as wake up logic
+         * disable the global irq/fiq in icu for all cores.
+         */
+       wakeup_reg = of_get_property(node, "mrvl,intc-gbl-mask", &size);
+       if (!wakeup_reg) {
+               pr_err("Not found mrvl,intc-gbl-mask property\n");
+               return;
Quoted 8 lines

Documentation/devicetree/bindings/arm/mrvl/intc.txt

Quoted 8 lines
Documentation/devicetree/bindings/arm/mrvl/intc.txt +8 -0
+       }
+
+       size /= sizeof(*wakeup_reg);
+       while (i < size) {
+               unsigned offset, val;
+
+               offset = be32_to_cpup(wakeup_reg + i++);
+               val = be32_to_cpup(wakeup_reg + i++);

Use of_property_read_u32_index. You don't need to deal with the raw dtb.

Quoted 11 lines

Documentation/devicetree/bindings/arm/mrvl/intc.txt

Quoted 11 lines
Documentation/devicetree/bindings/arm/mrvl/intc.txt +11 -0
+               writel_relaxed(val, mmp_icu_base + offset);
+       }
+
+       /* Get the irq lines and ignore irqs */
+       cp_irq_reg = of_get_property(node, "mrvl,intc-for-cp", &size);
+       if (!cp_irq_reg)
+               return;
+
+       irq_for_cp_nr = size / sizeof(*cp_irq_reg);
+       for (i = 0; i < irq_for_cp_nr; i++) {
+               irq_for_cp[i] = be32_to_cpup(cp_irq_reg + i);

Use of_property_read_u32_index.

Thanks,
Mark.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#8 lore raw

RE: [PATCH 2/2 v2] irqchip: mmp: add dt support for wakeup

DQo+IC0tLS0tT3JpZ2luYWwgTWVzc2FnZS0tLS0tDQo+IEZyb206IE1hcmsgUnV0bGFuZCBbbWFp bHRvOm1hcmsucnV0bGFuZEBhcm0uY29tXQ0KPiBTZW50OiAyMDEzxOoxMdTCMTTI1SAyMDoyOA0K PiBUbzogSGFvamlhbiBaaHVhbmcNCj4gQ2M6IE5laWwgWmhhbmc7IGRldmljZXRyZWVAdmdlci5r ZXJuZWwub3JnOyBsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnOw0KPiBUaG9tYXMgR2xlaXhu ZXINCj4gU3ViamVjdDogUmU6IFtQQVRDSCAyLzIgdjJdIGlycWNoaXA6IG1tcDogYWRkIGR0IHN1 cHBvcnQgZm9yIHdha2V1cA0KPiANCj4gT24gVGh1LCBOb3YgMTQsIDIwMTMgYXQgMTA6Mjg6NTNB TSArMDAwMCwgSGFvamlhbiBaaHVhbmcgd3JvdGU6DQo+ID4g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mV0dXJuOw0KPiA+ID4gKw0KPiA+ ID4gKyAgICAgICBpcnFfZm9yX2NwX25yID0gc2l6ZSAvIHNpemVvZigqY3BfaXJxX3JlZyk7DQo+ ID4gPiArICAgICAgIGZvciAoaSA9IDA7IGkgPCBpcnFfZm9yX2NwX25yOyBpKyspIHsNCj4gPiA+ ICsgICAgICAgICAgICAgICBpcnFfZm9yX2NwW2ldID0gYmUzMl90b19jcHVwKGNwX2lycV9yZWcg KyBpKTsNCj4gDQo+IFVzZSBvZl9wcm9wZXJ0eV9yZWFkX3UzMl9pbmRleC4NCg0KWWVzLCBpdCBz aG91bGQgYmUgT0ssIHRoYW5rcyB2ZXJ5IG11Y2guDQoNCj4gDQo+IFRoYW5rcywNCj4gTWFyay4N Cg0KQmVzdCBSZWdhcmRzLA0KTmVpbCBaaGFuZw0K
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#9 lore raw

Re: [PATCH 2/2 v2] irqchip: mmp: add dt support for wakeup

Quoted 38 lines · Neil Zhang
Quoted 31 lines

-----Original Message-----
From: Mark Rutland [mailto:[email protected]]
Sent: 2013年11月14日 20:28
To: Haojian Zhuang
Cc: Neil Zhang; [email protected]; [email protected]; Thomas Gleixner
Subject: Re: [PATCH 2/2 v2] irqchip: mmp: add dt support for wakeup

Quoted 10 lines · Haojian Zhuang
Quoted 9 lines · Neil Zhang

Some of the Marvell SoCs use GIC as its interrupt controller,and ICU only used as wakeup logic. When AP subsystem is powered off, GIC will lose its context, the PMU will need ICU to wakeup the AP subsystem. So add wakeup entry for such kind of usage.

---
 .../devicetree/bindings/arm/mrvl/intc.txt          |   14 ++-
 drivers/irqchip/irq-mmp.c                          |  124

++++++++++++++++++++

Quoted 10 lines
Quoted 10 lines
 include/linux/irqchip/mmp.h                        |   13 ++
 3 files changed, 150 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/arm/mrvl/intc.txt +0 -0
index 8b53273..4180928 100644
@@ -2,7 +2,7 @@
 
Quoted 6 lines
Quoted 4 lines

Documentation/devicetree/bindings/arm/mrvl/intc.txt line 5

Quoted 4 lines
Documentation/devicetree/bindings/arm/mrvl/intc.txt +1 -1
 Required properties:
 - compatible : Should be "mrvl,mmp-intc", "mrvl,mmp2-intc" or
-  "mrvl,mmp2-mux-intc"
+  "mrvl,mmp2-mux-intc", "mrvl,mmp-intc-wakeupgen"

Why do we need a new compatible string?

Quoted 2 lines

As the patch comments said, we don't use the ICU as an interrupt controller in some Marvell Socs, Just use them to wakeup CPU when GIC is powered off.

Hmm. Is it possible to use the ICU as an interrupt controller in those SoCs?

Quoted 18 lines
Quoted 18 lines
Quoted 13 lines

Documentation/devicetree/bindings/arm/mrvl/intc.txt

Quoted 12 lines
Documentation/devicetree/bindings/arm/mrvl/intc.txt +0 -0
 - reg : Address and length of the register set of the interrupt controller.
   If the interrupt controller is intc, address and length means the range
   of the whold interrupt controller. If the interrupt controller is

mux-intc, @@ -15,6 +15,9 @@ Required properties:
- interrupt-controller : Identifies the node as an interrupt controller.
- #interrupt-cells : Specifies the number of cells needed to encode an interrupt source.
+- mrvl,intc-gbl-mask : Specifies the address and value for global

Documentation/devicetree/bindings/arm/mrvl/intc.txt +2 -0
+mask in the
+  interrupt controller.
Quoted 1 line

As my understanding, we should avoid to write register settings in DTS file.

In general, yes. We should describe the hardware and let Linux choose how to configure it as far as possible.

Quoted 7 lines
Quoted 3 lines

What is this global mask? What is it used for? Why do there seem to be multiple global masks (judging by the example)?

Global mask will prevent distributing interrupt from ICU to GIC.
Since we will use GIC as the interrupt controller, so we need to mask the ICU global mask. ICU has connection to every core in the system, so we need to mask all global mask registers for each core.

Why can the driver not figure out these masks for itself?

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Loop devicetree guys.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line

+- mrvl,intc-for-cp : Specifies the irqs that will be routed to cp

cp?

_why_ do we need this, and what exactly does routing the irqs to the cp imply?

Communication processor.
Kernel should avoid to handle the irq lines that has been routed to communication processor.

Ok. Does this just tell the kernel the set of IRQs to ignore, or does this imply that the kernel must configure something in the hardware based on this? If so, what specifically?

Quoted 16 lines
Quoted 16 lines
Quoted 15 lines
Quoted 15 lines

- mrvl,intc-nr-irqs : Specifies the number of interrupts in the interrupt controller.
- mrvl,clr-mfp-irq : Specifies the interrupt that needs to clear
MFP edge @@ -39,6 +42,15 @@ Example:

                mrvl,intc-nr-irqs = <2>;
        };
Documentation/devicetree/bindings/arm/mrvl/intc.txt +6 -0
+     intc: wakeupgen@d4282000 {
+               compatible = "mrvl,mmp-intc-wakeupgen";
+               reg = <0xd4282000 0x1000>;
+               mrvl,intc-nr-irqs = <64>;
+               mrvl,intc-gbl-mask = <0x114 0x3
+                                     0x144 0x3>;
Quoted 4 lines
Quoted 2 lines

Are these multiple entries? The binding text implied there was only one entry. What is this?

This specify the register offset and value to mask for each core.

Why can the driver not have these offsets hard-coded? How variable are they?

[...]

Quoted 11 lines
Quoted 8 lines
Quoted 6 lines

Documentation/devicetree/bindings/arm/mrvl/intc.txt

Quoted 6 lines
Documentation/devicetree/bindings/arm/mrvl/intc.txt +6 -0
+       size /= sizeof(*wakeup_reg);
+       while (i < size) {
+               unsigned offset, val;
+
+               offset = be32_to_cpup(wakeup_reg + i++);
+               val = be32_to_cpup(wakeup_reg + i++);

Use of_property_read_u32_index. You don't need to deal with the raw dtb.

It's offset / value pair, it there convenient way to get such kind of key / value pair? Thanks.

Unfortunately there's no of_property_read_u32_array_index, but it's perfectly possible to do something similar to what you have here, without relying on the raw binary DTB:

for (;;) {
	u32 offset, val;
	if (of_property_read_u32_index(node, PROP_NAME, i++, &offset) != 0)
		break;
	if (of_property_read_u32_index(node, PROP_NAME, i++, &val) != 0)
		break;
	
	do_something(offset, val);
}
Quoted 16 lines
Quoted 15 lines
Quoted 13 lines

Documentation/devicetree/bindings/arm/mrvl/intc.txt

Quoted 13 lines
Documentation/devicetree/bindings/arm/mrvl/intc.txt +11 -0
+               writel_relaxed(val, mmp_icu_base + offset);
+       }
+
+       /* Get the irq lines and ignore irqs */
+       cp_irq_reg = of_get_property(node, "mrvl,intc-for-cp", &size);
+       if (!cp_irq_reg)
+               return;
+
+       irq_for_cp_nr = size / sizeof(*cp_irq_reg);
+       for (i = 0; i < irq_for_cp_nr; i++) {
+               irq_for_cp[i] = be32_to_cpup(cp_irq_reg + i);

Use of_property_read_u32_index.

Quoted 1 line

Yes, it should be OK, thanks very much.

Cheers,
Mark.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#10 lore raw

RE: [PATCH 2/2 v2] irqchip: mmp: add dt support for wakeup

Mark,

Sorry for reply late.

Quoted 49 lines

-----Original Message-----
From: Mark Rutland [mailto:[email protected]]
Sent: 2013年11月15日 20:50
To: Neil Zhang
Cc: Haojian Zhuang; [email protected]; [email protected]; Thomas Gleixner
Subject: Re: [PATCH 2/2 v2] irqchip: mmp: add dt support for wakeup

Quoted 11 lines · Neil Zhang
Quoted 11 lines

-----Original Message-----
From: Mark Rutland [mailto:[email protected]]
Sent: 2013年11月14日 20:28
To: Haojian Zhuang
Cc: Neil Zhang; [email protected]; [email protected]; Thomas Gleixner
Subject: Re: [PATCH 2/2 v2] irqchip: mmp: add dt support for wakeup

Quoted 1 line · Haojian Zhuang

On Fri, Oct 11, 2013 at 4:23 PM, Neil Zhang <[email protected]>

Quoted 3 lines · wrote:
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Some of the Marvell SoCs use GIC as its interrupt controller,and ICU only used as wakeup logic. When AP subsystem is powered off, GIC will lose its context, the PMU will need ICU to wakeup the AP

subsystem.

Quoted 24 lines
Quoted 23 lines
Quoted 6 lines
Quoted 6 lines

So add wakeup entry for such kind of usage.

---
 .../devicetree/bindings/arm/mrvl/intc.txt          |   14 ++-
 drivers/irqchip/irq-mmp.c                          |  124

++++++++++++++++++++

Quoted 10 lines
Quoted 10 lines
 include/linux/irqchip/mmp.h                        |   13 ++
 3 files changed, 150 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/arm/mrvl/intc.txt +0 -0
index 8b53273..4180928 100644
@@ -2,7 +2,7 @@
 
Quoted 4 lines

Documentation/devicetree/bindings/arm/mrvl/intc.txt line 5

Quoted 4 lines
Documentation/devicetree/bindings/arm/mrvl/intc.txt +1 -1
 Required properties:
 - compatible : Should be "mrvl,mmp-intc", "mrvl,mmp2-intc" or
-  "mrvl,mmp2-mux-intc"
+  "mrvl,mmp2-mux-intc", "mrvl,mmp-intc-wakeupgen"

Why do we need a new compatible string?

Quoted 5 lines
Quoted 2 lines

As the patch comments said, we don't use the ICU as an interrupt controller in some Marvell Socs, Just use them to wakeup CPU when GIC is

powered off.

Hmm. Is it possible to use the ICU as an interrupt controller in those SoCs?

No, we have to use GIC as an interrupt controller since they are SMP system.

Quoted 23 lines
Quoted 23 lines
Quoted 22 lines
Quoted 14 lines

Documentation/devicetree/bindings/arm/mrvl/intc.txt

Quoted 13 lines
Documentation/devicetree/bindings/arm/mrvl/intc.txt +0 -0
 - reg : Address and length of the register set of the interrupt controller.
   If the interrupt controller is intc, address and length means the range
   of the whold interrupt controller. If the interrupt

controller is mux-intc, @@ -15,6 +15,9 @@ Required properties:
- interrupt-controller : Identifies the node as an interrupt controller.
- #interrupt-cells : Specifies the number of cells needed to encode an interrupt source.
+- mrvl,intc-gbl-mask : Specifies the address and value for

Documentation/devicetree/bindings/arm/mrvl/intc.txt +2 -0
+global mask in the
+  interrupt controller.
Quoted 1 line

As my understanding, we should avoid to write register settings in DTS file.

In general, yes. We should describe the hardware and let Linux choose how to configure it as far as possible.

What is this global mask? What is it used for? Why do there seem to be multiple global masks (judging by the example)?

Quoted 7 lines
Quoted 2 lines

Global mask will prevent distributing interrupt from ICU to GIC. Since we will use GIC as the interrupt controller, so we need to mask the ICU

global mask.

Quoted 1 line

ICU has connection to every core in the system, so we need to mask all global

mask registers for each core.

Why can the driver not figure out these masks for itself?

Different SoCs will have different global mask registers, so it's not suitable to hard code in driver.

Quoted 13 lines
Quoted 11 lines
Quoted 11 lines
Quoted 7 lines

Loop devicetree guys.

Quoted 2 lines

+- mrvl,intc-for-cp : Specifies the irqs that will be routed to +cp

cp?

_why_ do we need this, and what exactly does routing the irqs to the cp

imply?

Quoted 1 line
Quoted 8 lines
Quoted 2 lines

Communication processor.
Kernel should avoid to handle the irq lines that has been routed to

communication processor.

Ok. Does this just tell the kernel the set of IRQs to ignore, or does this imply that the kernel must configure something in the hardware based on this? If so, what specifically?

As the patch did, we need to configure it to cp when init and kernel will ignore to change them in runtime.

Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 15 lines
Quoted 15 lines

- mrvl,intc-nr-irqs : Specifies the number of interrupts in the interrupt controller.
- mrvl,clr-mfp-irq : Specifies the interrupt that needs to
clear MFP edge @@ -39,6 +42,15 @@ Example:

                mrvl,intc-nr-irqs = <2>;
        };
Documentation/devicetree/bindings/arm/mrvl/intc.txt +6 -0
+     intc: wakeupgen@d4282000 {
+               compatible = "mrvl,mmp-intc-wakeupgen";
+               reg = <0xd4282000 0x1000>;
+               mrvl,intc-nr-irqs = <64>;
+               mrvl,intc-gbl-mask = <0x114 0x3
+                                     0x144 0x3>;
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Are these multiple entries? The binding text implied there was only one entry. What is this?

This specify the register offset and value to mask for each core.

Why can the driver not have these offsets hard-coded? How variable are they?

As I said above, different SoCs will have different global mask registers, It's not suitable to hard code in driver.

Quoted 20 lines

[...]

Quoted 10 lines
Quoted 8 lines
Quoted 6 lines

Documentation/devicetree/bindings/arm/mrvl/intc.txt

Quoted 6 lines
Documentation/devicetree/bindings/arm/mrvl/intc.txt +6 -0
+       size /= sizeof(*wakeup_reg);
+       while (i < size) {
+               unsigned offset, val;
+
+               offset = be32_to_cpup(wakeup_reg + i++);
+               val = be32_to_cpup(wakeup_reg + i++);

Use of_property_read_u32_index. You don't need to deal with the raw dtb.

It's offset / value pair, it there convenient way to get such kind of key / value

pair?

Quoted 1 line

Thanks.

Unfortunately there's no of_property_read_u32_array_index, but it's perfectly possible to do something similar to what you have here, without relying on the raw binary DTB:

Quoted 10 lines
for (;;) {
	u32 offset, val;
	if (of_property_read_u32_index(node, PROP_NAME, i++, &offset) != 0)
		break;
	if (of_property_read_u32_index(node, PROP_NAME, i++, &val) != 0)
		break;

	do_something(offset, val);
}

Thanks very much, I'll change to use this way.

Quoted 16 lines
Quoted 16 lines
Quoted 15 lines
Quoted 13 lines

Documentation/devicetree/bindings/arm/mrvl/intc.txt

Quoted 13 lines
Documentation/devicetree/bindings/arm/mrvl/intc.txt +11 -0
+               writel_relaxed(val, mmp_icu_base + offset);
+       }
+
+       /* Get the irq lines and ignore irqs */
+       cp_irq_reg = of_get_property(node, "mrvl,intc-for-cp", &size);
+       if (!cp_irq_reg)
+               return;
+
+       irq_for_cp_nr = size / sizeof(*cp_irq_reg);
+       for (i = 0; i < irq_for_cp_nr; i++) {
+               irq_for_cp[i] = be32_to_cpup(cp_irq_reg + i);

Use of_property_read_u32_index.

Quoted 4 lines
Quoted 1 line

Yes, it should be OK, thanks very much.

Cheers,
Mark.

Best Regards,
Neil Zhang ���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m���� ������?�I�