All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/7] ARM: add clock api to sp804 and smp_twd timers
@ 2011-01-12 23:31 Rob Herring
  2011-01-12 23:31 ` [PATCH 1/7] ARM: integrator cp: init clocks early and add sp804 clock Rob Herring
                   ` (6 more replies)
  0 siblings, 7 replies; 9+ messages in thread
From: Rob Herring @ 2011-01-12 23:31 UTC (permalink / raw)
  To: linux-arm-kernel

From: Rob Herring <rob.herring@calxeda.com>

Russell,

Here is updated patch series based on your previous comments. As I mentioned,
the problem making the clock api mandatory for smp_twd is I don't know what the
frequency of the timer is on various platforms or an understanding of what 
their clock trees look like to do a proper implementation of the clocks. I did
add clocks for vexpress as I can test that platform.

Rob

Rob Herring (7):
  ARM: integrator cp: init clocks early and add sp804 clock
  ARM: realview: init clocks early and add sp804 clock
  ARM: versatile: init clocks early and add sp804 clock
  ARM: vexpress: init clocks early and add sp804 clock
  ARM: timer-sp: support timer clock freq other than 1MHz
  ARM: smp_twd: add clock api support
  ARM: vexpress: add smp_twd clock

 arch/arm/common/timer-sp.c               |   43 +++++++++++++++++++++---------
 arch/arm/include/asm/hardware/timer-sp.h |    4 +-
 arch/arm/include/asm/smp_twd.h           |    1 +
 arch/arm/kernel/smp_twd.c                |   11 +++++++
 arch/arm/mach-integrator/integrator_cp.c |   19 ++++++++++---
 arch/arm/mach-realview/core.c            |   16 +++++++----
 arch/arm/mach-realview/core.h            |    1 +
 arch/arm/mach-realview/realview_eb.c     |    1 +
 arch/arm/mach-realview/realview_pb1176.c |    1 +
 arch/arm/mach-realview/realview_pb11mp.c |    1 +
 arch/arm/mach-realview/realview_pba8.c   |    1 +
 arch/arm/mach-realview/realview_pbx.c    |    1 +
 arch/arm/mach-versatile/core.c           |   22 +++++++++++----
 arch/arm/mach-versatile/core.h           |    1 +
 arch/arm/mach-versatile/versatile_ab.c   |    1 +
 arch/arm/mach-versatile/versatile_pb.c   |    1 +
 arch/arm/mach-vexpress/core.h            |    1 +
 arch/arm/mach-vexpress/ct-ca9x4.c        |   27 ++++++++++++++-----
 arch/arm/mach-vexpress/v2m.c             |   18 +++++++++---
 19 files changed, 129 insertions(+), 42 deletions(-)

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

* [PATCH 1/7] ARM: integrator cp: init clocks early and add sp804 clock
  2011-01-12 23:31 [PATCH 0/7] ARM: add clock api to sp804 and smp_twd timers Rob Herring
@ 2011-01-12 23:31 ` Rob Herring
  2011-01-12 23:53   ` Russell King - ARM Linux
  2011-01-12 23:31 ` [PATCH 2/7] ARM: realview: " Rob Herring
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 9+ messages in thread
From: Rob Herring @ 2011-01-12 23:31 UTC (permalink / raw)
  To: linux-arm-kernel

From: Rob Herring <rob.herring@calxeda.com>

Move clock initialization to mdesc->init_early and add a clock for
sp804 timer.

Signed-off-by: Rob Herring <rob.herring@calxeda.com>
---
 arch/arm/mach-integrator/integrator_cp.c |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-integrator/integrator_cp.c b/arch/arm/mach-integrator/integrator_cp.c
index 85e48a5..d99a880 100644
--- a/arch/arm/mach-integrator/integrator_cp.c
+++ b/arch/arm/mach-integrator/integrator_cp.c
@@ -305,14 +305,25 @@ static struct clk cp_auxclk = {
 	.params	= &cp_auxvco_params,
 	.vcoreg	= CM_AUXOSC,
 };
+static struct clk sp804_clk = {
+	.rate = 1000000,
+};
 
 static struct clk_lookup cp_lookups[] = {
 	{	/* CLCD */
 		.dev_id		= "mb:c0",
 		.clk		= &cp_auxclk,
-	},
+	}, {	/* SP804 Timer */
+		.dev_id		= "sp804",
+		.clk		= &sp804_clk,
+	}
 };
 
+static void __init intcp_init_early(void)
+{
+	clkdev_add_table(cp_lookups, ARRAY_SIZE(cp_lookups));
+}
+
 /*
  * Flash handling.
  */
@@ -569,7 +580,6 @@ static void __init intcp_init(void)
 {
 	int i;
 
-	clkdev_add_table(cp_lookups, ARRAY_SIZE(cp_lookups));
 	platform_add_devices(intcp_devs, ARRAY_SIZE(intcp_devs));
 
 	for (i = 0; i < ARRAY_SIZE(amba_devs); i++) {
@@ -601,6 +611,7 @@ MACHINE_START(CINTEGRATOR, "ARM-IntegratorCP")
 	.boot_params	= 0x00000100,
 	.map_io		= intcp_map_io,
 	.reserve	= integrator_reserve,
+	.init_early	= intcp_init_early,
 	.init_irq	= intcp_init_irq,
 	.timer		= &cp_timer,
 	.init_machine	= intcp_init,
-- 
1.7.1

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

* [PATCH 2/7] ARM: realview: init clocks early and add sp804 clock
  2011-01-12 23:31 [PATCH 0/7] ARM: add clock api to sp804 and smp_twd timers Rob Herring
  2011-01-12 23:31 ` [PATCH 1/7] ARM: integrator cp: init clocks early and add sp804 clock Rob Herring
@ 2011-01-12 23:31 ` Rob Herring
  2011-01-12 23:31 ` [PATCH 3/7] ARM: versatile: " Rob Herring
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Rob Herring @ 2011-01-12 23:31 UTC (permalink / raw)
  To: linux-arm-kernel

From: Rob Herring <rob.herring@calxeda.com>

Move clock initialization to mdesc->init_early and add a clock for
sp804 timer.

Signed-off-by: Rob Herring <rob.herring@calxeda.com>
---
 arch/arm/mach-realview/core.c            |   12 ++++++++----
 arch/arm/mach-realview/core.h            |    1 +
 arch/arm/mach-realview/realview_eb.c     |    1 +
 arch/arm/mach-realview/realview_pb1176.c |    1 +
 arch/arm/mach-realview/realview_pb11mp.c |    1 +
 arch/arm/mach-realview/realview_pba8.c   |    1 +
 arch/arm/mach-realview/realview_pbx.c    |    1 +
 7 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-realview/core.c b/arch/arm/mach-realview/core.c
index 1c6602c..16b8a81 100644
--- a/arch/arm/mach-realview/core.c
+++ b/arch/arm/mach-realview/core.c
@@ -314,6 +314,10 @@ static struct clk ref24_clk = {
 	.rate	= 24000000,
 };
 
+static struct clk sp804_clk = {
+	.rate	= 1000000,
+};
+
 static struct clk dummy_apb_pclk;
 
 static struct clk_lookup lookups[] = {
@@ -356,10 +360,13 @@ static struct clk_lookup lookups[] = {
 	}, {	/* SSP */
 		.dev_id		= "dev:ssp0",
 		.clk		= &ref24_clk,
+	}, {	/* SP804 Timer */
+		.dev_id		= "sp804",
+		.clk		= &sp804_clk,
 	}
 };
 
-static int __init clk_init(void)
+void __init realview_init_early(void)
 {
 	if (machine_is_realview_pb1176())
 		oscvco_clk.vcoreg = __io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_OSC0_OFFSET;
@@ -367,10 +374,7 @@ static int __init clk_init(void)
 		oscvco_clk.vcoreg = __io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_OSC4_OFFSET;
 
 	clkdev_add_table(lookups, ARRAY_SIZE(lookups));
-
-	return 0;
 }
-core_initcall(clk_init);
 
 /*
  * CLCD support.
diff --git a/arch/arm/mach-realview/core.h b/arch/arm/mach-realview/core.h
index 693239d..cb44595 100644
--- a/arch/arm/mach-realview/core.h
+++ b/arch/arm/mach-realview/core.h
@@ -65,6 +65,7 @@ extern int realview_eth_register(const char *name, struct resource *res);
 extern int realview_usb_register(struct resource *res);
 extern void realview_fixup(struct machine_desc *mdesc, struct tag *tags,
 			   char **from, struct meminfo *meminfo);
+extern void realview_init_early(void);
 extern void (*realview_reset)(char);
 
 #endif
diff --git a/arch/arm/mach-realview/realview_eb.c b/arch/arm/mach-realview/realview_eb.c
index 6ef5c5e..c00e527 100644
--- a/arch/arm/mach-realview/realview_eb.c
+++ b/arch/arm/mach-realview/realview_eb.c
@@ -487,6 +487,7 @@ MACHINE_START(REALVIEW_EB, "ARM-RealView EB")
 	.boot_params	= PHYS_OFFSET + 0x00000100,
 	.fixup		= realview_fixup,
 	.map_io		= realview_eb_map_io,
+	.init_early	= realview_init_early,
 	.init_irq	= gic_init_irq,
 	.timer		= &realview_eb_timer,
 	.init_machine	= realview_eb_init,
diff --git a/arch/arm/mach-realview/realview_pb1176.c b/arch/arm/mach-realview/realview_pb1176.c
index cbdc97a..f0447bb 100644
--- a/arch/arm/mach-realview/realview_pb1176.c
+++ b/arch/arm/mach-realview/realview_pb1176.c
@@ -382,6 +382,7 @@ MACHINE_START(REALVIEW_PB1176, "ARM-RealView PB1176")
 	.boot_params	= PHYS_OFFSET + 0x00000100,
 	.fixup		= realview_pb1176_fixup,
 	.map_io		= realview_pb1176_map_io,
+	.init_early	= realview_init_early,
 	.init_irq	= gic_init_irq,
 	.timer		= &realview_pb1176_timer,
 	.init_machine	= realview_pb1176_init,
diff --git a/arch/arm/mach-realview/realview_pb11mp.c b/arch/arm/mach-realview/realview_pb11mp.c
index 8e8ab7d..3b4f788 100644
--- a/arch/arm/mach-realview/realview_pb11mp.c
+++ b/arch/arm/mach-realview/realview_pb11mp.c
@@ -384,6 +384,7 @@ MACHINE_START(REALVIEW_PB11MP, "ARM-RealView PB11MPCore")
 	.boot_params	= PHYS_OFFSET + 0x00000100,
 	.fixup		= realview_fixup,
 	.map_io		= realview_pb11mp_map_io,
+	.init_early	= realview_init_early,
 	.init_irq	= gic_init_irq,
 	.timer		= &realview_pb11mp_timer,
 	.init_machine	= realview_pb11mp_init,
diff --git a/arch/arm/mach-realview/realview_pba8.c b/arch/arm/mach-realview/realview_pba8.c
index 841118e..f98d4fa 100644
--- a/arch/arm/mach-realview/realview_pba8.c
+++ b/arch/arm/mach-realview/realview_pba8.c
@@ -334,6 +334,7 @@ MACHINE_START(REALVIEW_PBA8, "ARM-RealView PB-A8")
 	.boot_params	= PHYS_OFFSET + 0x00000100,
 	.fixup		= realview_fixup,
 	.map_io		= realview_pba8_map_io,
+	.init_early	= realview_init_early,
 	.init_irq	= gic_init_irq,
 	.timer		= &realview_pba8_timer,
 	.init_machine	= realview_pba8_init,
diff --git a/arch/arm/mach-realview/realview_pbx.c b/arch/arm/mach-realview/realview_pbx.c
index 02b755b..b0521e1 100644
--- a/arch/arm/mach-realview/realview_pbx.c
+++ b/arch/arm/mach-realview/realview_pbx.c
@@ -417,6 +417,7 @@ MACHINE_START(REALVIEW_PBX, "ARM-RealView PBX")
 	.boot_params	= PHYS_OFFSET + 0x00000100,
 	.fixup		= realview_pbx_fixup,
 	.map_io		= realview_pbx_map_io,
+	.init_early	= realview_init_early,
 	.init_irq	= gic_init_irq,
 	.timer		= &realview_pbx_timer,
 	.init_machine	= realview_pbx_init,
-- 
1.7.1

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

* [PATCH 3/7] ARM: versatile: init clocks early and add sp804 clock
  2011-01-12 23:31 [PATCH 0/7] ARM: add clock api to sp804 and smp_twd timers Rob Herring
  2011-01-12 23:31 ` [PATCH 1/7] ARM: integrator cp: init clocks early and add sp804 clock Rob Herring
  2011-01-12 23:31 ` [PATCH 2/7] ARM: realview: " Rob Herring
@ 2011-01-12 23:31 ` Rob Herring
  2011-01-12 23:32 ` [PATCH 4/7] ARM: vexpress: " Rob Herring
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Rob Herring @ 2011-01-12 23:31 UTC (permalink / raw)
  To: linux-arm-kernel

From: Rob Herring <rob.herring@calxeda.com>

Move clock initialization to mdesc->init_early and add a clock for
sp804 timer.

Signed-off-by: Rob Herring <rob.herring@calxeda.com>
---
 arch/arm/mach-versatile/core.c         |   18 ++++++++++++++----
 arch/arm/mach-versatile/core.h         |    1 +
 arch/arm/mach-versatile/versatile_ab.c |    1 +
 arch/arm/mach-versatile/versatile_pb.c |    1 +
 4 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-versatile/core.c b/arch/arm/mach-versatile/core.c
index 13a83e4..399e2ef 100644
--- a/arch/arm/mach-versatile/core.c
+++ b/arch/arm/mach-versatile/core.c
@@ -417,6 +417,10 @@ static struct clk ref24_clk = {
 	.rate	= 24000000,
 };
 
+static struct clk sp804_clk = {
+	.rate	= 1000000,
+};
+
 static struct clk dummy_apb_pclk;
 
 static struct clk_lookup lookups[] = {
@@ -453,9 +457,19 @@ static struct clk_lookup lookups[] = {
 	}, {	/* CLCD */
 		.dev_id		= "dev:20",
 		.clk		= &osc4_clk,
+	}, {	/* SP804 Timer */
+		.dev_id		= "sp804",
+		.clk		= &sp804_clk,
 	}
 };
 
+void __init versatile_init_early(void)
+{
+	osc4_clk.vcoreg = __io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_OSCCLCD_OFFSET;
+
+	clkdev_add_table(lookups, ARRAY_SIZE(lookups));
+}
+
 /*
  * CLCD support.
  */
@@ -867,10 +881,6 @@ void __init versatile_init(void)
 {
 	int i;
 
-	osc4_clk.vcoreg	= __io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_OSCCLCD_OFFSET;
-
-	clkdev_add_table(lookups, ARRAY_SIZE(lookups));
-
 	platform_device_register(&versatile_flash_device);
 	platform_device_register(&versatile_i2c_device);
 	platform_device_register(&smc91x_device);
diff --git a/arch/arm/mach-versatile/core.h b/arch/arm/mach-versatile/core.h
index 9d39886..e04768a 100644
--- a/arch/arm/mach-versatile/core.h
+++ b/arch/arm/mach-versatile/core.h
@@ -25,6 +25,7 @@
 #include <linux/amba/bus.h>
 
 extern void __init versatile_init(void);
+extern void __init versatile_init_early(void);
 extern void __init versatile_init_irq(void);
 extern void __init versatile_map_io(void);
 extern struct sys_timer versatile_timer;
diff --git a/arch/arm/mach-versatile/versatile_ab.c b/arch/arm/mach-versatile/versatile_ab.c
index aa9730f..f8ae64b 100644
--- a/arch/arm/mach-versatile/versatile_ab.c
+++ b/arch/arm/mach-versatile/versatile_ab.c
@@ -37,6 +37,7 @@ MACHINE_START(VERSATILE_AB, "ARM-Versatile AB")
 	/* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */
 	.boot_params	= 0x00000100,
 	.map_io		= versatile_map_io,
+	.init_early	= versatile_init_early,
 	.init_irq	= versatile_init_irq,
 	.timer		= &versatile_timer,
 	.init_machine	= versatile_init,
diff --git a/arch/arm/mach-versatile/versatile_pb.c b/arch/arm/mach-versatile/versatile_pb.c
index bf46964..97fb306 100644
--- a/arch/arm/mach-versatile/versatile_pb.c
+++ b/arch/arm/mach-versatile/versatile_pb.c
@@ -110,6 +110,7 @@ MACHINE_START(VERSATILE_PB, "ARM-Versatile PB")
 	/* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */
 	.boot_params	= 0x00000100,
 	.map_io		= versatile_map_io,
+	.init_early	= versatile_init_early,
 	.init_irq	= versatile_init_irq,
 	.timer		= &versatile_timer,
 	.init_machine	= versatile_pb_init,
-- 
1.7.1

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

* [PATCH 4/7] ARM: vexpress: init clocks early and add sp804 clock
  2011-01-12 23:31 [PATCH 0/7] ARM: add clock api to sp804 and smp_twd timers Rob Herring
                   ` (2 preceding siblings ...)
  2011-01-12 23:31 ` [PATCH 3/7] ARM: versatile: " Rob Herring
@ 2011-01-12 23:32 ` Rob Herring
  2011-01-12 23:32 ` [PATCH 5/7] ARM: timer-sp: support timer clock freq other than 1MHz Rob Herring
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: Rob Herring @ 2011-01-12 23:32 UTC (permalink / raw)
  To: linux-arm-kernel

From: Rob Herring <rob.herring@calxeda.com>

Move clock initialization to mdesc->init_early and add a clock for
sp804 timer.

Signed-off-by: Rob Herring <rob.herring@calxeda.com>
---
 arch/arm/mach-vexpress/core.h     |    1 +
 arch/arm/mach-vexpress/ct-ca9x4.c |   13 +++++++++----
 arch/arm/mach-vexpress/v2m.c      |   14 ++++++++++++--
 3 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-vexpress/core.h b/arch/arm/mach-vexpress/core.h
index 362780d..e0312a1 100644
--- a/arch/arm/mach-vexpress/core.h
+++ b/arch/arm/mach-vexpress/core.h
@@ -21,4 +21,5 @@ struct amba_device name##_device = {		\
 struct map_desc;
 
 void v2m_map_io(struct map_desc *tile, size_t num);
+void v2m_init_early(void);
 extern struct sys_timer v2m_timer;
diff --git a/arch/arm/mach-vexpress/ct-ca9x4.c b/arch/arm/mach-vexpress/ct-ca9x4.c
index e628402..db4614c 100644
--- a/arch/arm/mach-vexpress/ct-ca9x4.c
+++ b/arch/arm/mach-vexpress/ct-ca9x4.c
@@ -71,8 +71,8 @@ static void __init ct_ca9x4_timer_init(void)
 	writel(0, MMIO_P2V(CT_CA9X4_TIMER0) + TIMER_CTRL);
 	writel(0, MMIO_P2V(CT_CA9X4_TIMER1) + TIMER_CTRL);
 
-	sp804_clocksource_init(MMIO_P2V(CT_CA9X4_TIMER1));
-	sp804_clockevents_init(MMIO_P2V(CT_CA9X4_TIMER0), IRQ_CT_CA9X4_TIMER0);
+	sp804_clocksource_init(MMIO_P2V(CT_CA9X4_TIMER1), NULL);
+	sp804_clockevents_init(MMIO_P2V(CT_CA9X4_TIMER0), IRQ_CT_CA9X4_TIMER0, NULL);
 }
 
 static struct sys_timer ct_ca9x4_timer = {
@@ -190,6 +190,12 @@ static struct clk_lookup lookups[] = {
 	},
 };
 
+static void __init ct_ca9x4_init_early(void)
+{
+	clkdev_add_table(lookups, ARRAY_SIZE(lookups));
+	v2m_init_early();
+}
+
 static struct resource pmu_resources[] = {
 	[0] = {
 		.start	= IRQ_CT_CA9X4_PMU_CPU0,
@@ -234,8 +240,6 @@ static void __init ct_ca9x4_init(void)
 	l2x0_init(l2x0_base, 0x00400000, 0xfe0fffff);
 #endif
 
-	clkdev_add_table(lookups, ARRAY_SIZE(lookups));
-
 	for (i = 0; i < ARRAY_SIZE(ct_ca9x4_amba_devs); i++)
 		amba_device_register(ct_ca9x4_amba_devs[i], &iomem_resource);
 
@@ -245,6 +249,7 @@ static void __init ct_ca9x4_init(void)
 MACHINE_START(VEXPRESS, "ARM-Versatile Express CA9x4")
 	.boot_params	= PHYS_OFFSET + 0x00000100,
 	.map_io		= ct_ca9x4_map_io,
+	.init_early	= ct_ca9x4_init_early,
 	.init_irq	= ct_ca9x4_init_irq,
 #if 0
 	.timer		= &ct_ca9x4_timer,
diff --git a/arch/arm/mach-vexpress/v2m.c b/arch/arm/mach-vexpress/v2m.c
index a9ed342..e371d99 100644
--- a/arch/arm/mach-vexpress/v2m.c
+++ b/arch/arm/mach-vexpress/v2m.c
@@ -300,6 +300,10 @@ static struct clk osc2_clk = {
 	.rate	= 24000000,
 };
 
+static struct clk sp804_clk = {
+	.rate	= 1000000,
+};
+
 static struct clk dummy_apb_pclk;
 
 static struct clk_lookup v2m_lookups[] = {
@@ -330,9 +334,17 @@ static struct clk_lookup v2m_lookups[] = {
 	}, {	/* CLCD */
 		.dev_id		= "mb:clcd",
 		.clk		= &osc1_clk,
+	}, {	/* SP804 Timer */
+		.dev_id		= "sp804",
+		.clk		= &sp804_clk,
 	},
 };
 
+void __init v2m_init_early(void)
+{
+	clkdev_add_table(v2m_lookups, ARRAY_SIZE(v2m_lookups));
+}
+
 static void v2m_power_off(void)
 {
 	if (v2m_cfg_write(SYS_CFG_SHUTDOWN | SYS_CFG_SITE_MB, 0))
@@ -349,8 +361,6 @@ static int __init v2m_init(void)
 {
 	int i;
 
-	clkdev_add_table(v2m_lookups, ARRAY_SIZE(v2m_lookups));
-
 	platform_device_register(&v2m_pcie_i2c_device);
 	platform_device_register(&v2m_ddc_i2c_device);
 	platform_device_register(&v2m_flash_device);
-- 
1.7.1

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

* [PATCH 5/7] ARM: timer-sp: support timer clock freq other than 1MHz
  2011-01-12 23:31 [PATCH 0/7] ARM: add clock api to sp804 and smp_twd timers Rob Herring
                   ` (3 preceding siblings ...)
  2011-01-12 23:32 ` [PATCH 4/7] ARM: vexpress: " Rob Herring
@ 2011-01-12 23:32 ` Rob Herring
  2011-01-12 23:32 ` [PATCH 6/7] ARM: smp_twd: add clock api support Rob Herring
  2011-01-12 23:32 ` [PATCH 7/7] ARM: vexpress: add smp_twd clock Rob Herring
  6 siblings, 0 replies; 9+ messages in thread
From: Rob Herring @ 2011-01-12 23:32 UTC (permalink / raw)
  To: linux-arm-kernel

From: Rob Herring <rob.herring@calxeda.com>

The timer-sp code is fixed to 1MHz timer clock. Add clock api
calls to get the timer clock frequency and support for independent
clock frequencies.

Rename timer names for clocksource and clockevent to timer-sp or
the clock connection ID string if provided.

Compile tested on integrator, realview, versatile, and vexpress. Boot
tested on vexpress.

Signed-off-by: Rob Herring <rob.herring@calxeda.com>
---
 arch/arm/common/timer-sp.c               |   43 +++++++++++++++++++++---------
 arch/arm/include/asm/hardware/timer-sp.h |    4 +-
 arch/arm/mach-integrator/integrator_cp.c |    4 +-
 arch/arm/mach-realview/core.c            |    4 +-
 arch/arm/mach-versatile/core.c           |    4 +-
 arch/arm/mach-vexpress/v2m.c             |    4 +-
 6 files changed, 40 insertions(+), 23 deletions(-)

diff --git a/arch/arm/common/timer-sp.c b/arch/arm/common/timer-sp.c
index 6ef3342..c5572d0 100644
--- a/arch/arm/common/timer-sp.c
+++ b/arch/arm/common/timer-sp.c
@@ -18,6 +18,8 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+#include <linux/clk.h>
+#include <linux/err.h>
 #include <linux/clocksource.h>
 #include <linux/clockchips.h>
 #include <linux/interrupt.h>
@@ -26,12 +28,7 @@
 
 #include <asm/hardware/arm_timer.h>
 
-/*
- * These timers are currently always setup to be clocked at 1MHz.
- */
-#define TIMER_FREQ_KHZ	(1000)
-#define TIMER_RELOAD	(TIMER_FREQ_KHZ * 1000 / HZ)
-
+static unsigned long sp804_clksrc_rate;
 static void __iomem *clksrc_base;
 
 static cycle_t sp804_read(struct clocksource *cs)
@@ -40,19 +37,28 @@ static cycle_t sp804_read(struct clocksource *cs)
 }
 
 static struct clocksource clocksource_sp804 = {
-	.name		= "timer3",
 	.rating		= 200,
 	.read		= sp804_read,
 	.mask		= CLOCKSOURCE_MASK(32),
 	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
 };
 
-void __init sp804_clocksource_init(void __iomem *base)
+void __init sp804_clocksource_init(void __iomem *base, char *clk_id)
 {
+	struct clk *clk;
 	struct clocksource *cs = &clocksource_sp804;
 
+	cs->name = clk_id ? clk_id : "timer-sp";
+
 	clksrc_base = base;
 
+	clk = clk_get_sys("sp804", clk_id);
+	if (IS_ERR(clk) || clk_enable(clk))
+		panic("sp804 clksrc: cannot get clock\n");
+
+	clk_enable(clk);
+	sp804_clksrc_rate = clk_get_rate(clk);
+
 	/* setup timer 0 as free-running clocksource */
 	writel(0, clksrc_base + TIMER_CTRL);
 	writel(0xffffffff, clksrc_base + TIMER_LOAD);
@@ -60,10 +66,11 @@ void __init sp804_clocksource_init(void __iomem *base)
 	writel(TIMER_CTRL_32BIT | TIMER_CTRL_ENABLE | TIMER_CTRL_PERIODIC,
 		clksrc_base + TIMER_CTRL);
 
-	clocksource_register_khz(cs, TIMER_FREQ_KHZ);
+	clocksource_register_hz(cs, sp804_clksrc_rate);
 }
 
 
+static unsigned long sp804_clkevt_rate;
 static void __iomem *clkevt_base;
 
 /*
@@ -90,7 +97,7 @@ static void sp804_set_mode(enum clock_event_mode mode,
 
 	switch (mode) {
 	case CLOCK_EVT_MODE_PERIODIC:
-		writel(TIMER_RELOAD, clkevt_base + TIMER_LOAD);
+		writel(sp804_clkevt_rate / HZ, clkevt_base + TIMER_LOAD);
 		ctrl |= TIMER_CTRL_PERIODIC | TIMER_CTRL_ENABLE;
 		break;
 
@@ -120,7 +127,6 @@ static int sp804_set_next_event(unsigned long next,
 }
 
 static struct clock_event_device sp804_clockevent = {
-	.name		= "timer0",
 	.shift		= 32,
 	.features       = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
 	.set_mode	= sp804_set_mode,
@@ -136,14 +142,25 @@ static struct irqaction sp804_timer_irq = {
 	.dev_id		= &sp804_clockevent,
 };
 
-void __init sp804_clockevents_init(void __iomem *base, unsigned int timer_irq)
+void __init sp804_clockevents_init(void __iomem *base, unsigned int timer_irq,
+				   char *clk_id)
 {
+	struct clk *clk;
 	struct clock_event_device *evt = &sp804_clockevent;
 
+	evt->name = clk_id ? clk_id : "timer-sp";
+
 	clkevt_base = base;
 
+	clk = clk_get_sys("sp804", clk_id);
+	if (IS_ERR(clk) || clk_enable(clk))
+		panic("sp804 clkevt: cannot get clock\n");
+
+	clk_enable(clk);
+	sp804_clkevt_rate = clk_get_rate(clk);
+
 	evt->irq = timer_irq;
-	evt->mult = div_sc(TIMER_FREQ_KHZ, NSEC_PER_MSEC, evt->shift);
+	evt->mult = div_sc(sp804_clkevt_rate, NSEC_PER_SEC, evt->shift);
 	evt->max_delta_ns = clockevent_delta2ns(0xffffffff, evt);
 	evt->min_delta_ns = clockevent_delta2ns(0xf, evt);
 
diff --git a/arch/arm/include/asm/hardware/timer-sp.h b/arch/arm/include/asm/hardware/timer-sp.h
index 21e75e3..dc31cb0 100644
--- a/arch/arm/include/asm/hardware/timer-sp.h
+++ b/arch/arm/include/asm/hardware/timer-sp.h
@@ -1,2 +1,2 @@
-void sp804_clocksource_init(void __iomem *);
-void sp804_clockevents_init(void __iomem *, unsigned int);
+void sp804_clocksource_init(void __iomem *, char *);
+void sp804_clockevents_init(void __iomem *, unsigned int, char *);
diff --git a/arch/arm/mach-integrator/integrator_cp.c b/arch/arm/mach-integrator/integrator_cp.c
index d99a880..10ba4f0 100644
--- a/arch/arm/mach-integrator/integrator_cp.c
+++ b/arch/arm/mach-integrator/integrator_cp.c
@@ -598,8 +598,8 @@ static void __init intcp_timer_init(void)
 	writel(0, TIMER1_VA_BASE + TIMER_CTRL);
 	writel(0, TIMER2_VA_BASE + TIMER_CTRL);
 
-	sp804_clocksource_init(TIMER2_VA_BASE);
-	sp804_clockevents_init(TIMER1_VA_BASE, IRQ_TIMERINT1);
+	sp804_clocksource_init(TIMER2_VA_BASE, NULL);
+	sp804_clockevents_init(TIMER1_VA_BASE, IRQ_TIMERINT1, NULL);
 }
 
 static struct sys_timer cp_timer = {
diff --git a/arch/arm/mach-realview/core.c b/arch/arm/mach-realview/core.c
index 16b8a81..1a9d0f9 100644
--- a/arch/arm/mach-realview/core.c
+++ b/arch/arm/mach-realview/core.c
@@ -702,8 +702,8 @@ void __init realview_timer_init(unsigned int timer_irq)
 	writel(0, timer2_va_base + TIMER_CTRL);
 	writel(0, timer3_va_base + TIMER_CTRL);
 
-	sp804_clocksource_init(timer3_va_base);
-	sp804_clockevents_init(timer0_va_base, timer_irq);
+	sp804_clocksource_init(timer3_va_base, NULL);
+	sp804_clockevents_init(timer0_va_base, timer_irq, NULL);
 }
 
 /*
diff --git a/arch/arm/mach-versatile/core.c b/arch/arm/mach-versatile/core.c
index 399e2ef..b0685ad 100644
--- a/arch/arm/mach-versatile/core.c
+++ b/arch/arm/mach-versatile/core.c
@@ -939,8 +939,8 @@ static void __init versatile_timer_init(void)
 	writel(0, TIMER2_VA_BASE + TIMER_CTRL);
 	writel(0, TIMER3_VA_BASE + TIMER_CTRL);
 
-	sp804_clocksource_init(TIMER3_VA_BASE);
-	sp804_clockevents_init(TIMER0_VA_BASE, IRQ_TIMERINT0_1);
+	sp804_clocksource_init(TIMER3_VA_BASE, NULL);
+	sp804_clockevents_init(TIMER0_VA_BASE, IRQ_TIMERINT0_1, NULL);
 }
 
 struct sys_timer versatile_timer = {
diff --git a/arch/arm/mach-vexpress/v2m.c b/arch/arm/mach-vexpress/v2m.c
index e371d99..8bb28b9 100644
--- a/arch/arm/mach-vexpress/v2m.c
+++ b/arch/arm/mach-vexpress/v2m.c
@@ -55,8 +55,8 @@ static void __init v2m_timer_init(void)
 	writel(0, MMIO_P2V(V2M_TIMER0) + TIMER_CTRL);
 	writel(0, MMIO_P2V(V2M_TIMER1) + TIMER_CTRL);
 
-	sp804_clocksource_init(MMIO_P2V(V2M_TIMER1));
-	sp804_clockevents_init(MMIO_P2V(V2M_TIMER0), IRQ_V2M_TIMER0);
+	sp804_clocksource_init(MMIO_P2V(V2M_TIMER1), NULL);
+	sp804_clockevents_init(MMIO_P2V(V2M_TIMER0), IRQ_V2M_TIMER0, NULL);
 }
 
 struct sys_timer v2m_timer = {
-- 
1.7.1

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

* [PATCH 6/7] ARM: smp_twd: add clock api support
  2011-01-12 23:31 [PATCH 0/7] ARM: add clock api to sp804 and smp_twd timers Rob Herring
                   ` (4 preceding siblings ...)
  2011-01-12 23:32 ` [PATCH 5/7] ARM: timer-sp: support timer clock freq other than 1MHz Rob Herring
@ 2011-01-12 23:32 ` Rob Herring
  2011-01-12 23:32 ` [PATCH 7/7] ARM: vexpress: add smp_twd clock Rob Herring
  6 siblings, 0 replies; 9+ messages in thread
From: Rob Herring @ 2011-01-12 23:32 UTC (permalink / raw)
  To: linux-arm-kernel

From: Rob Herring <rob.herring@calxeda.com>

The private timer freq is currently dynamically detected
using jiffies count to determine the rate. This method adds
a delay to boot-up, so use the clock api instead to get the
clock rate.

Signed-off-by: Rob Herring <rob.herring@calxeda.com>
---
 arch/arm/include/asm/smp_twd.h |    1 +
 arch/arm/kernel/smp_twd.c      |   11 +++++++++++
 2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/arch/arm/include/asm/smp_twd.h b/arch/arm/include/asm/smp_twd.h
index fed9981..6b0f591 100644
--- a/arch/arm/include/asm/smp_twd.h
+++ b/arch/arm/include/asm/smp_twd.h
@@ -24,5 +24,6 @@ extern void __iomem *twd_base;
 
 int twd_timer_ack(void);
 void twd_timer_setup(struct clock_event_device *);
+void twd_timer_init(void __iomem *base);
 
 #endif
diff --git a/arch/arm/kernel/smp_twd.c b/arch/arm/kernel/smp_twd.c
index dd79074..9a20729 100644
--- a/arch/arm/kernel/smp_twd.c
+++ b/arch/arm/kernel/smp_twd.c
@@ -8,6 +8,8 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
+#include <linux/clk.h>
+#include <linux/err.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/delay.h>
@@ -145,3 +147,12 @@ void __cpuinit twd_timer_setup(struct clock_event_device *clk)
 
 	clockevents_register_device(clk);
 }
+
+void __init twd_timer_init(void __iomem *base)
+{
+	struct clk *clk = clk_get_sys("smp_twd", NULL);
+	if (!IS_ERR(clk))
+		twd_timer_rate = clk_get_rate(clk);
+
+	twd_base = base;
+}
-- 
1.7.1

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

* [PATCH 7/7] ARM: vexpress: add smp_twd clock
  2011-01-12 23:31 [PATCH 0/7] ARM: add clock api to sp804 and smp_twd timers Rob Herring
                   ` (5 preceding siblings ...)
  2011-01-12 23:32 ` [PATCH 6/7] ARM: smp_twd: add clock api support Rob Herring
@ 2011-01-12 23:32 ` Rob Herring
  6 siblings, 0 replies; 9+ messages in thread
From: Rob Herring @ 2011-01-12 23:32 UTC (permalink / raw)
  To: linux-arm-kernel

From: Rob Herring <rob.herring@calxeda.com>

Add smp_twd clock and call twd_timer_init to enable using it.

Signed-off-by: Rob Herring <rob.herring@calxeda.com>
---
 arch/arm/mach-vexpress/ct-ca9x4.c |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-vexpress/ct-ca9x4.c b/arch/arm/mach-vexpress/ct-ca9x4.c
index db4614c..62d5a2d 100644
--- a/arch/arm/mach-vexpress/ct-ca9x4.c
+++ b/arch/arm/mach-vexpress/ct-ca9x4.c
@@ -53,9 +53,6 @@ static struct map_desc ct_ca9x4_io_desc[] __initdata = {
 
 static void __init ct_ca9x4_map_io(void)
 {
-#ifdef CONFIG_LOCAL_TIMERS
-	twd_base = MMIO_P2V(A9_MPCORE_TWD);
-#endif
 	v2m_map_io(ct_ca9x4_io_desc, ARRAY_SIZE(ct_ca9x4_io_desc));
 }
 
@@ -183,10 +180,17 @@ static struct clk osc1_clk = {
 	.rate	= 24000000,
 };
 
+static struct clk twd_clk = {
+	.rate	= 200000000,
+};
+
 static struct clk_lookup lookups[] = {
 	{	/* CLCD */
 		.dev_id		= "ct:clcd",
 		.clk		= &osc1_clk,
+	}, {	/* TWD */
+		.dev_id		= "smp_twd",
+		.clk		= &twd_clk,
 	},
 };
 
@@ -194,6 +198,10 @@ static void __init ct_ca9x4_init_early(void)
 {
 	clkdev_add_table(lookups, ARRAY_SIZE(lookups));
 	v2m_init_early();
+
+#ifdef CONFIG_LOCAL_TIMERS
+	twd_timer_init(MMIO_P2V(A9_MPCORE_TWD));
+#endif
 }
 
 static struct resource pmu_resources[] = {
-- 
1.7.1

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

* [PATCH 1/7] ARM: integrator cp: init clocks early and add sp804 clock
  2011-01-12 23:31 ` [PATCH 1/7] ARM: integrator cp: init clocks early and add sp804 clock Rob Herring
@ 2011-01-12 23:53   ` Russell King - ARM Linux
  0 siblings, 0 replies; 9+ messages in thread
From: Russell King - ARM Linux @ 2011-01-12 23:53 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Jan 12, 2011 at 05:31:57PM -0600, Rob Herring wrote:
> From: Rob Herring <rob.herring@calxeda.com>
> 
> Move clock initialization to mdesc->init_early and add a clock for
> sp804 timer.

Please wait for my patches to do this.  I've already got them committed
and waiting - init_early was originally intended to solve the sched_clock
initialization issue...

I'll be pushing that stuff out after the merge window has closed.

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

end of thread, other threads:[~2011-01-12 23:53 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-12 23:31 [PATCH 0/7] ARM: add clock api to sp804 and smp_twd timers Rob Herring
2011-01-12 23:31 ` [PATCH 1/7] ARM: integrator cp: init clocks early and add sp804 clock Rob Herring
2011-01-12 23:53   ` Russell King - ARM Linux
2011-01-12 23:31 ` [PATCH 2/7] ARM: realview: " Rob Herring
2011-01-12 23:31 ` [PATCH 3/7] ARM: versatile: " Rob Herring
2011-01-12 23:32 ` [PATCH 4/7] ARM: vexpress: " Rob Herring
2011-01-12 23:32 ` [PATCH 5/7] ARM: timer-sp: support timer clock freq other than 1MHz Rob Herring
2011-01-12 23:32 ` [PATCH 6/7] ARM: smp_twd: add clock api support Rob Herring
2011-01-12 23:32 ` [PATCH 7/7] ARM: vexpress: add smp_twd clock Rob Herring

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.