linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] MIPS: Malta: Probe gic-timer via devicetree
@ 2017-04-19 12:26 Matt Redfearn
  2017-04-19 12:26 ` [PATCH 2/2] Clocksource: mips-gic: Remove redundant non devicetree init Matt Redfearn
  2017-04-20 13:13 ` [tip:timers/core] MIPS/Malta: Probe gic-timer via devicetree tip-bot for Matt Redfearn
  0 siblings, 2 replies; 4+ messages in thread
From: Matt Redfearn @ 2017-04-19 12:26 UTC (permalink / raw)
  To: Ralf Baechle, Daniel Lezcano
  Cc: linux-mips, Matt Redfearn, linux-kernel, Thomas Gleixner, James Hogan

The Malta platform is the only platform remaining to probe the GIC
clocksource via gic_clocksource_init. This route hardcodes an expected
virq number based on MIPS_GIC_IRQ_BASE, which can be fragile to the
eventual virq layout. Instread, probe the driver using the preferred and
more modern devicetree method.

Before the driver is probed, set the "clock-frequency" property of the
devicetree node to the value detected by Malta platform code.

Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com>
---

 arch/mips/mti-malta/malta-time.c | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/arch/mips/mti-malta/malta-time.c b/arch/mips/mti-malta/malta-time.c
index 1829a9031eec..289edcfadd7c 100644
--- a/arch/mips/mti-malta/malta-time.c
+++ b/arch/mips/mti-malta/malta-time.c
@@ -21,6 +21,7 @@
 #include <linux/i8253.h>
 #include <linux/init.h>
 #include <linux/kernel_stat.h>
+#include <linux/libfdt.h>
 #include <linux/math64.h>
 #include <linux/sched.h>
 #include <linux/spinlock.h>
@@ -207,6 +208,33 @@ static void __init init_rtc(void)
 		CMOS_WRITE(ctrl & ~RTC_SET, RTC_CONTROL);
 }
 
+#ifdef CONFIG_CLKSRC_MIPS_GIC
+static u32 gic_frequency_dt;
+
+static struct property gic_frequency_prop = {
+	.name = "clock-frequency",
+	.length = sizeof(u32),
+	.value = &gic_frequency_dt,
+};
+
+static void update_gic_frequency_dt(void)
+{
+	struct device_node *node;
+
+	gic_frequency_dt = cpu_to_be32(gic_frequency);
+
+	node = of_find_compatible_node(NULL, NULL, "mti,gic-timer");
+	if (!node) {
+		pr_err("mti,gic-timer device node not found\n");
+		return;
+	}
+
+	if (of_update_property(node, &gic_frequency_prop) < 0)
+		pr_err("error updating gic frequency property\n");
+}
+
+#endif
+
 void __init plat_time_init(void)
 {
 	unsigned int prid = read_c0_prid() & (PRID_COMP_MASK | PRID_IMP_MASK);
@@ -236,7 +264,8 @@ void __init plat_time_init(void)
 		printk("GIC frequency %d.%02d MHz\n", freq/1000000,
 		       (freq%1000000)*100/1000000);
 #ifdef CONFIG_CLKSRC_MIPS_GIC
-		gic_clocksource_init(gic_frequency);
+		update_gic_frequency_dt();
+		clocksource_probe();
 #endif
 	}
 #endif
-- 
2.7.4

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

* [PATCH 2/2] Clocksource: mips-gic: Remove redundant non devicetree init
  2017-04-19 12:26 [PATCH 1/2] MIPS: Malta: Probe gic-timer via devicetree Matt Redfearn
@ 2017-04-19 12:26 ` Matt Redfearn
  2017-04-20 13:13   ` [tip:timers/core] Clocksource/mips-gic: " tip-bot for Matt Redfearn
  2017-04-20 13:13 ` [tip:timers/core] MIPS/Malta: Probe gic-timer via devicetree tip-bot for Matt Redfearn
  1 sibling, 1 reply; 4+ messages in thread
From: Matt Redfearn @ 2017-04-19 12:26 UTC (permalink / raw)
  To: Ralf Baechle, Daniel Lezcano
  Cc: linux-mips, Matt Redfearn, Jason Cooper, Thomas Gleixner,
	linux-kernel, Paul Burton

Malta was the only platform probing this driver from platform code
without using device tree. With that code removed, gic_clocksource_init
is redundant so remove it.

Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com>

---

 drivers/clocksource/mips-gic-timer.c | 13 -------------
 include/linux/irqchip/mips-gic.h     |  1 -
 2 files changed, 14 deletions(-)

diff --git a/drivers/clocksource/mips-gic-timer.c b/drivers/clocksource/mips-gic-timer.c
index d9ef7a61e093..0bce89c1266d 100644
--- a/drivers/clocksource/mips-gic-timer.c
+++ b/drivers/clocksource/mips-gic-timer.c
@@ -154,19 +154,6 @@ static int __init __gic_clocksource_init(void)
 	return ret;
 }
 
-void __init gic_clocksource_init(unsigned int frequency)
-{
-	gic_frequency = frequency;
-	gic_timer_irq = MIPS_GIC_IRQ_BASE +
-		GIC_LOCAL_TO_HWIRQ(GIC_LOCAL_INT_COMPARE);
-
-	__gic_clocksource_init();
-	gic_clockevent_init();
-
-	/* And finally start the counter */
-	gic_start_count();
-}
-
 static int __init gic_clocksource_of_init(struct device_node *node)
 {
 	struct clk *clk;
diff --git a/include/linux/irqchip/mips-gic.h b/include/linux/irqchip/mips-gic.h
index 7b49c71c968b..2b0e56619e53 100644
--- a/include/linux/irqchip/mips-gic.h
+++ b/include/linux/irqchip/mips-gic.h
@@ -258,7 +258,6 @@ extern unsigned int gic_present;
 extern void gic_init(unsigned long gic_base_addr,
 	unsigned long gic_addrspace_size, unsigned int cpu_vec,
 	unsigned int irqbase);
-extern void gic_clocksource_init(unsigned int);
 extern u64 gic_read_count(void);
 extern unsigned int gic_get_count_width(void);
 extern u64 gic_read_compare(void);
-- 
2.7.4

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

* [tip:timers/core] MIPS/Malta: Probe gic-timer via devicetree
  2017-04-19 12:26 [PATCH 1/2] MIPS: Malta: Probe gic-timer via devicetree Matt Redfearn
  2017-04-19 12:26 ` [PATCH 2/2] Clocksource: mips-gic: Remove redundant non devicetree init Matt Redfearn
@ 2017-04-20 13:13 ` tip-bot for Matt Redfearn
  1 sibling, 0 replies; 4+ messages in thread
From: tip-bot for Matt Redfearn @ 2017-04-20 13:13 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: matt.redfearn, james.hogan, hpa, mingo, ralf, tglx,
	daniel.lezcano, linux-kernel

Commit-ID:  4287adec7212d48fb878a45400fd7e11a198462c
Gitweb:     http://git.kernel.org/tip/4287adec7212d48fb878a45400fd7e11a198462c
Author:     Matt Redfearn <matt.redfearn@imgtec.com>
AuthorDate: Wed, 19 Apr 2017 13:26:45 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Thu, 20 Apr 2017 14:56:58 +0200

MIPS/Malta: Probe gic-timer via devicetree

The Malta platform is the only platform remaining to probe the GIC
clocksource via gic_clocksource_init. This route hardcodes an expected
virq number based on MIPS_GIC_IRQ_BASE, which can be fragile to the
eventual virq layout. Instread, probe the driver using the preferred and
more modern devicetree method.

Before the driver is probed, set the "clock-frequency" property of the
devicetree node to the value detected by Malta platform code.

Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com>
Cc: linux-mips@linux-mips.org
Cc: James Hogan <james.hogan@imgtec.com>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Link: http://lkml.kernel.org/r/1492604806-23420-1-git-send-email-matt.redfearn@imgtec.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 arch/mips/mti-malta/malta-time.c | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/arch/mips/mti-malta/malta-time.c b/arch/mips/mti-malta/malta-time.c
index 1829a90..289edcf 100644
--- a/arch/mips/mti-malta/malta-time.c
+++ b/arch/mips/mti-malta/malta-time.c
@@ -21,6 +21,7 @@
 #include <linux/i8253.h>
 #include <linux/init.h>
 #include <linux/kernel_stat.h>
+#include <linux/libfdt.h>
 #include <linux/math64.h>
 #include <linux/sched.h>
 #include <linux/spinlock.h>
@@ -207,6 +208,33 @@ static void __init init_rtc(void)
 		CMOS_WRITE(ctrl & ~RTC_SET, RTC_CONTROL);
 }
 
+#ifdef CONFIG_CLKSRC_MIPS_GIC
+static u32 gic_frequency_dt;
+
+static struct property gic_frequency_prop = {
+	.name = "clock-frequency",
+	.length = sizeof(u32),
+	.value = &gic_frequency_dt,
+};
+
+static void update_gic_frequency_dt(void)
+{
+	struct device_node *node;
+
+	gic_frequency_dt = cpu_to_be32(gic_frequency);
+
+	node = of_find_compatible_node(NULL, NULL, "mti,gic-timer");
+	if (!node) {
+		pr_err("mti,gic-timer device node not found\n");
+		return;
+	}
+
+	if (of_update_property(node, &gic_frequency_prop) < 0)
+		pr_err("error updating gic frequency property\n");
+}
+
+#endif
+
 void __init plat_time_init(void)
 {
 	unsigned int prid = read_c0_prid() & (PRID_COMP_MASK | PRID_IMP_MASK);
@@ -236,7 +264,8 @@ void __init plat_time_init(void)
 		printk("GIC frequency %d.%02d MHz\n", freq/1000000,
 		       (freq%1000000)*100/1000000);
 #ifdef CONFIG_CLKSRC_MIPS_GIC
-		gic_clocksource_init(gic_frequency);
+		update_gic_frequency_dt();
+		clocksource_probe();
 #endif
 	}
 #endif

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

* [tip:timers/core] Clocksource/mips-gic: Remove redundant non devicetree init
  2017-04-19 12:26 ` [PATCH 2/2] Clocksource: mips-gic: Remove redundant non devicetree init Matt Redfearn
@ 2017-04-20 13:13   ` tip-bot for Matt Redfearn
  0 siblings, 0 replies; 4+ messages in thread
From: tip-bot for Matt Redfearn @ 2017-04-20 13:13 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: matt.redfearn, ralf, mingo, jason, linux-kernel, hpa,
	daniel.lezcano, tglx, paul.burton

Commit-ID:  58bb100a9de10329ca0d63484e76f27c257e9a2e
Gitweb:     http://git.kernel.org/tip/58bb100a9de10329ca0d63484e76f27c257e9a2e
Author:     Matt Redfearn <matt.redfearn@imgtec.com>
AuthorDate: Wed, 19 Apr 2017 13:26:46 +0100
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Thu, 20 Apr 2017 14:56:59 +0200

Clocksource/mips-gic: Remove redundant non devicetree init

Malta was the only platform probing this driver from platform code
without using device tree. With that code removed, gic_clocksource_init
is redundant so remove it.

Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com>
Cc: linux-mips@linux-mips.org
Cc: Jason Cooper <jason@lakedaemon.net>
Cc: Paul Burton <paul.burton@imgtec.com>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Link: http://lkml.kernel.org/r/1492604806-23420-2-git-send-email-matt.redfearn@imgtec.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 drivers/clocksource/mips-gic-timer.c | 13 -------------
 include/linux/irqchip/mips-gic.h     |  1 -
 2 files changed, 14 deletions(-)

diff --git a/drivers/clocksource/mips-gic-timer.c b/drivers/clocksource/mips-gic-timer.c
index b6ad9c0..3f52ee2 100644
--- a/drivers/clocksource/mips-gic-timer.c
+++ b/drivers/clocksource/mips-gic-timer.c
@@ -154,19 +154,6 @@ static int __init __gic_clocksource_init(void)
 	return ret;
 }
 
-void __init gic_clocksource_init(unsigned int frequency)
-{
-	gic_frequency = frequency;
-	gic_timer_irq = MIPS_GIC_IRQ_BASE +
-		GIC_LOCAL_TO_HWIRQ(GIC_LOCAL_INT_COMPARE);
-
-	__gic_clocksource_init();
-	gic_clockevent_init();
-
-	/* And finally start the counter */
-	gic_start_count();
-}
-
 static int __init gic_clocksource_of_init(struct device_node *node)
 {
 	struct clk *clk;
diff --git a/include/linux/irqchip/mips-gic.h b/include/linux/irqchip/mips-gic.h
index 7b49c71..2b0e566 100644
--- a/include/linux/irqchip/mips-gic.h
+++ b/include/linux/irqchip/mips-gic.h
@@ -258,7 +258,6 @@ extern unsigned int gic_present;
 extern void gic_init(unsigned long gic_base_addr,
 	unsigned long gic_addrspace_size, unsigned int cpu_vec,
 	unsigned int irqbase);
-extern void gic_clocksource_init(unsigned int);
 extern u64 gic_read_count(void);
 extern unsigned int gic_get_count_width(void);
 extern u64 gic_read_compare(void);

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

end of thread, other threads:[~2017-04-20 13:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-19 12:26 [PATCH 1/2] MIPS: Malta: Probe gic-timer via devicetree Matt Redfearn
2017-04-19 12:26 ` [PATCH 2/2] Clocksource: mips-gic: Remove redundant non devicetree init Matt Redfearn
2017-04-20 13:13   ` [tip:timers/core] Clocksource/mips-gic: " tip-bot for Matt Redfearn
2017-04-20 13:13 ` [tip:timers/core] MIPS/Malta: Probe gic-timer via devicetree tip-bot for Matt Redfearn

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