sp804 and integrator timer CLKSRC_OF support
Subsystems (9)
cover sp804 and integrator timer CLKSRC_OF support
From: Rob Herring <[email protected]>
This series add device-tree support using CLKSRC_OF for initialization of integrator ap and cp timers and sp804 timers. The timer code for all of these is moved to drivers/clocksource. The common DT based initialization of sp804 is supported on highbank, versatile-ab and vexpress. The DT init support is newly added for versatile-ab.
This series is dependent on my CLKSRC_OF clean-up in arm-soc, my sched_clock selection series[1], and Arnd's default machine descriptor patch (for default clocksource_of_init call). The full series is available here:
git://sources.calxeda.com/kernel/linux.git arm-timers
http://sources.calxeda.com/gitweb/?p=kernel/linux.git;a=shortlog;h=refs/heads/arm-timers
I've tested integrator and versatile on qemu and on highbank h/w.
Rob
[1] http://comments.gmane.org/gmane.linux.ports.arm.kernel/222282
Haojian Zhuang (1):
devtree: add binding documentation for sp804
Rob Herring (10):
OF: add empty of_device_is_available for !OF
ARM: remove extra timer-sp control register clearing
ARM: timer-sp: convert to use CLKSRC_OF init
ARM: highbank: use OF init for sp804 timer
ARM: vexpress: remove sp804 OF init
ARM: dts: vexpress: disable CA9 core tile sp804 timer
ARM: versatile: add versatile dtbs to dtbs target
ARM: versatile: use OF init for sp804 timer
ARM: integrator-cp: convert use CLKSRC_OF for timer init
ARM: move sp804 and integrator timers to drivers/clocksource
.../devicetree/bindings/timer/arm,sp804.txt | 29 +++
arch/arm/Kconfig | 5 -
arch/arm/boot/dts/Makefile | 2 +
arch/arm/boot/dts/integratorcp.dts | 6 +-
arch/arm/boot/dts/versatile-ab.dts | 12 ++
arch/arm/boot/dts/vexpress-v2p-ca9.dts | 1 +
arch/arm/common/Makefile | 1 -
arch/arm/include/asm/hardware/timer-sp.h | 15 --
arch/arm/mach-highbank/highbank.c | 19 --
arch/arm/mach-integrator/Kconfig | 1 +
arch/arm/mach-integrator/integrator_ap.c | 173 +-----------------
arch/arm/mach-integrator/integrator_cp.c | 42 +----
arch/arm/mach-realview/core.c | 12 +-
arch/arm/mach-versatile/core.c | 37 ++--
arch/arm/mach-versatile/versatile_dt.c | 1 -
arch/arm/mach-vexpress/ct-ca9x4.c | 4 +-
arch/arm/mach-vexpress/v2m.c | 17 +-
drivers/clocksource/Kconfig | 12 ++
drivers/clocksource/Makefile | 2 +
.../hardware => drivers/clocksource}/arm_timer.h | 6 +-
drivers/clocksource/integrator_ap_timer.c | 190 ++++++++++++++++++++
.../arm/common => drivers/clocksource}/timer-sp.c | 132 ++++++++++++--
include/clocksource/integrator_ap_timer.h | 7 +
include/clocksource/timer-sp.h | 31 ++++
include/linux/of.h | 5 +
25 files changed, 429 insertions(+), 333 deletions(-)
create mode 100644 Documentation/devicetree/bindings/timer/arm,sp804.txt
delete mode 100644 arch/arm/include/asm/hardware/timer-sp.h
rename {arch/arm/include/asm/hardware => drivers/clocksource}/arm_timer.h (89%)
create mode 100644 drivers/clocksource/integrator_ap_timer.c
rename {arch/arm/common => drivers/clocksource}/timer-sp.c (60%)
create mode 100644 include/clocksource/integrator_ap_timer.h
create mode 100644 include/clocksource/timer-sp.hSignature · 1 line
1.7.10.4
PATCH 1/11 OF: add empty of_device_is_available for !OF
From: Rob Herring <[email protected]>
Add an empty version of of_device_is_available.
--- include/linux/of.h | 5 +++++ 1 file changed, 5 insertions(+)
include/linux/of.h +5 -0
@@ -379,6 +379,11 @@ static inline int of_device_is_compatible(const struct device_node *device,return 0 ; } +static inline int of_device_is_available(const struct device_node *device,) +{ +return 0 ; +} +static inline struct property *of_find_property (const struct device_node *np,const char *name,int *lenp)
Signature · 1 line
1.7.10.4
PATCH 2/11 ARM: remove extra timer-sp control register clearing
In reply to Rob HerringFrom: Rob Herring <[email protected]>
The timer-sp initialization code clears the control register before initializing the timers, so every platform doing this is redundant.
For unused timers, we should not care what state they are in.
--- arch/arm/mach-integrator/integrator_ap.c | 4 ---- arch/arm/mach-integrator/integrator_cp.c | 7 ------- arch/arm/mach-realview/core.c | 9 --------- arch/arm/mach-versatile/core.c | 9 --------- arch/arm/mach-vexpress/v2m.c | 3 --- 5 files changed, 32 deletions(-)
arch/arm/mach-integrator/integrator_ap.c +0 -4
@@ -643,10 +643,6 @@ static void __init ap_timer_init(void)clk_prepare_enable (clk); rate =clk_get_rate (clk); -writel (0 ,TIMER0_VA_BASE +TIMER_CTRL ); -writel (0 ,TIMER1_VA_BASE +TIMER_CTRL ); -writel (0 ,TIMER2_VA_BASE +TIMER_CTRL ); -integrator_clocksource_init (rate, (void __iomem *)TIMER2_VA_BASE );integrator_clockevent_init (rate, (void __iomem *)TIMER1_VA_BASE ,IRQ_TIMERINT1 );
arch/arm/mach-integrator/integrator_cp.c +0 -7
@@ -33,7 +33,6 @@#include <mach/platform.h> #include <asm/setup.h> #include <asm/mach-types.h> -#include <asm/hardware/arm_timer.h> #include <asm/hardware/icst.h> #include <mach/cm.h>
@@ -267,7 +266,6 @@ static void __init cp_of_timer_init(void) base =of_iomap (node,0 );if (WARN_ON (!base))return ; -writel (0 , base +TIMER_CTRL );sp804_clocksource_init (base, node->name); err = of_property_read_string(of_aliases,
@@ -279,7 +277,6 @@ static void __init cp_of_timer_init(void)if (WARN_ON (!base))return ; irq =irq_of_parse_and_map (node,0 ); -writel (0 , base +TIMER_CTRL );sp804_clockevents_init (base, irq, node->name); }
@@ -510,10 +507,6 @@ static void __init intcp_init_irq(void)static void __init cp_timer_init (void ) { -writel (0 ,TIMER0_VA_BASE +TIMER_CTRL ); -writel (0 ,TIMER1_VA_BASE +TIMER_CTRL ); -writel (0 ,TIMER2_VA_BASE +TIMER_CTRL ); -sp804_clocksource_init (TIMER2_VA_BASE ,"timer2" );sp804_clockevents_init (TIMER1_VA_BASE ,IRQ_TIMERINT1 ,"timer1" ); }
arch/arm/mach-realview/core.c +0 -9
@@ -35,7 +35,6 @@#include <mach/hardware.h> #include <asm/irq.h> #include <asm/mach-types.h> -#include <asm/hardware/arm_timer.h> #include <asm/hardware/icst.h> #include <asm/mach/arch.h>
@@ -355,14 +354,6 @@ void __init realview_timer_init(unsigned int timer_irq) (REALVIEW_TIMCLK << REALVIEW_TIMER4_EnSel) | val, __io_address(REALVIEW_SCTL_BASE)); -/* -* Initialise to a known state (all timers off) -*/ -writel (0 , timer0_va_base +TIMER_CTRL ); -writel (0 , timer1_va_base +TIMER_CTRL ); -writel (0 , timer2_va_base +TIMER_CTRL ); -writel (0 , timer3_va_base +TIMER_CTRL ); -sp804_clocksource_init (timer3_va_base,"timer3" );sp804_clockevents_init (timer0_va_base, timer_irq,"timer0" ); }
arch/arm/mach-versatile/core.c +0 -9
@@ -40,7 +40,6 @@#include <linux/bitops.h> #include <asm/irq.h> -#include <asm/hardware/arm_timer.h> #include <asm/hardware/icst.h> #include <asm/mach-types.h>
@@ -799,14 +798,6 @@ void __init versatile_timer_init(void) (VERSATILE_TIMCLK << VERSATILE_TIMER4_EnSel) | val, __io_address(VERSATILE_SCTL_BASE)); -/* -* Initialise to a known state (all timers off) -*/ -writel (0 ,TIMER0_VA_BASE +TIMER_CTRL ); -writel (0 ,TIMER1_VA_BASE +TIMER_CTRL ); -writel (0 ,TIMER2_VA_BASE +TIMER_CTRL ); -writel (0 ,TIMER3_VA_BASE +TIMER_CTRL ); -sp804_clocksource_init (TIMER3_VA_BASE ,"timer3" );sp804_clockevents_init (TIMER0_VA_BASE ,IRQ_TIMERINT0_1 ,"timer0" ); }
arch/arm/mach-vexpress/v2m.c +0 -3
@@ -61,9 +61,6 @@ static void __init v2m_sp804_init(void __iomem *base, unsigned int irq)if (WARN_ON (!base || irq ==NO_IRQ ))return ; -writel (0 , base +TIMER_1_BASE +TIMER_CTRL ); -writel (0 , base +TIMER_2_BASE +TIMER_CTRL ); -sp804_clocksource_init (base +TIMER_2_BASE ,"v2m-timer1" );sp804_clockevents_init (base +TIMER_1_BASE , irq,"v2m-timer0" ); }
Signature · 1 line
1.7.10.4
PATCH 3/11 ARM: timer-sp: convert to use CLKSRC_OF init
In reply to Rob HerringFrom: Rob Herring <[email protected]>
This adds CLKSRC_OF based init for sp804 timer. The clock initialization is refactored to support retrieving the clock(s) from the DT.
--- arch/arm/Kconfig | 1 + arch/arm/common/timer-sp.c | 98 +++++++++++++++++++++++++----- arch/arm/include/asm/hardware/timer-sp.h | 16 +++-- 3 files changed, 95 insertions(+), 20 deletions(-)
arch/arm/Kconfig +1 -0
@@ -1172,6 +1172,7 @@ config PLAT_VERSATILE config ARM_TIMER_SP804 bool select CLKSRC_MMIO + select CLKSRC_OF if OF select HAVE_SCHED_CLOCK source arch/arm/mm/Kconfig
arch/arm/common/timer-sp.c +82 -16
149 lines not on this page · raw message
arch/arm/include/asm/hardware/timer-sp.h +12 -4
@@ -1,15 +1,23 @@ +struct clk ; +void __sp804_clocksource_and_sched_clock_init (void __iomem *, -const char *,int ); +const char *,struct clk *,int ); +void __sp804_clockevents_init (void __iomem *,unsigned int , +struct clk *,const char *);static inline void sp804_clocksource_init (void __iomem *base,const char *name) { -__sp804_clocksource_and_sched_clock_init (base, name,0 ); +__sp804_clocksource_and_sched_clock_init (base, name,NULL ,0 ); }static inline void sp804_clocksource_and_sched_clock_init (void __iomem *base,const char *name) { -__sp804_clocksource_and_sched_clock_init (base, name,1 ); +__sp804_clocksource_and_sched_clock_init (base, name,NULL ,1 ); } -void sp804_clockevents_init (void __iomem *,unsigned int ,const char *); +static inline void sp804_clockevents_init (void __iomem *base,unsigned int irq,const char *name) +{ +__sp804_clockevents_init (base, irq,NULL , name); + +}
Signature · 1 line
1.7.10.4
PATCH 4/11 ARM: highbank: use OF init for sp804 timer
In reply to Rob HerringFrom: Rob Herring <[email protected]>
Remove the highbank specific setup for the sp804 timer now that clocksource_of_init will do it.
--- arch/arm/mach-highbank/highbank.c | 19 ------------------- 1 file changed, 19 deletions(-)
arch/arm/mach-highbank/highbank.c +0 -19
@@ -32,8 +32,6 @@#include <asm/cacheflush.h> #include <asm/cputype.h> #include <asm/smp_plat.h> -#include <asm/hardware/arm_timer.h> -#include <asm/hardware/timer-sp.h> #include <asm/hardware/cache-l2x0.h> #include <asm/mach/arch.h> #include <asm/mach/map.h>
@@ -90,33 +88,16 @@ static void __init highbank_init_irq(void)#endif } -static struct clk_lookup lookup = { - .dev_id ="sp804" , - .con_id =NULL , -}; -static void __init highbank_timer_init (void ) { -int irq;struct device_node *np; -void __iomem *timer_base;/* Map system registers */ np =of_find_compatible_node (NULL ,NULL ,"calxeda,hb-sregs" ); sregs_base =of_iomap (np,0 );WARN_ON (!sregs_base); - np =of_find_compatible_node (NULL ,NULL ,"arm,sp804" ); - timer_base =of_iomap (np,0 ); -WARN_ON (!timer_base); - irq =irq_of_parse_and_map (np,0 ); -of_clk_init (NULL ); - lookup.clk =of_clk_get (np,0 ); -clkdev_add (&lookup); - -sp804_clocksource_and_sched_clock_init (timer_base +0x20 ,"timer1" ); -sp804_clockevents_init (timer_base, irq,"timer0" );clocksource_of_init (); }
Signature · 1 line
1.7.10.4
PATCH 5/11 ARM: vexpress: remove sp804 OF init
In reply to Rob HerringFrom: Rob Herring <[email protected]>
Remove the vexpress specific setup for the sp804 timer now that clocksource_of_init will do it.
--- arch/arm/mach-vexpress/v2m.c | 11 ----------- 1 file changed, 11 deletions(-)
arch/arm/mach-vexpress/v2m.c +0 -11
@@ -428,20 +428,9 @@ void __init v2m_dt_init_early(void)static void __init v2m_dt_timer_init (void ) { -struct device_node *node =NULL ; -vexpress_clk_of_init ();clocksource_of_init (); -do { - node =of_find_compatible_node (node,NULL ,"arm,sp804" ); - }while (node &&vexpress_get_site_by_node (node) !=VEXPRESS_SITE_MB ); -if (node) { -pr_info ("Using SP804 '%s' as a clock & events source\n" , - node->full_name); -v2m_sp804_init (of_iomap (node,0 ), -irq_of_parse_and_map (node,0 )); - }versatile_sched_clock_init (vexpress_get_24mhz_clock_base (),24000000 );
Signature · 1 line
1.7.10.4
PATCH 6/11 ARM: dts: vexpress: disable CA9 core tile sp804 timer
In reply to Rob HerringFrom: Rob Herring <[email protected]>
The motherboard sp804 timer is used, but core tile sp804 timer is not. According to Russell King, the clock configuration is undocumented and defaults to 32kHz which is not desireable. So mark core tile sp804 timer as disabled.
--- arch/arm/boot/dts/vexpress-v2p-ca9.dts | 1 + 1 file changed, 1 insertion(+)
arch/arm/boot/dts/vexpress-v2p-ca9.dts +1 -0
@@ -98,6 +98,7 @@ <0 49 4>; clocks = <&oscclk2>, <&oscclk2>; clock-names = "timclk", "apb_pclk"; + status = "disabled"; }; watchdog at 100e5000 {
Signature · 1 line
1.7.10.4
PATCH 7/11 ARM: versatile: add versatile dtbs to dtbs target
In reply to Rob HerringFrom: Rob Herring <[email protected]>
Add the versatile platform dtbs to the dtbs make rule.
--- arch/arm/boot/dts/Makefile | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/boot/dts/Makefile +2 -0
@@ -165,6 +165,8 @@ dtb-$(CONFIG_ARCH_TEGRA) += tegra20-harmony.dtb \ tegra30-cardhu-a04.dtb \ tegra114-dalmore.dtb \ tegra114-pluto.dtb +dtb-$(CONFIG_ARCH_VERSATILE) += versatile-ab.dtb \ + versatile-pb.dtb dtb-$(CONFIG_ARCH_VEXPRESS) += vexpress-v2p-ca5s.dtb \ vexpress-v2p-ca9.dtb \ vexpress-v2p-ca15-tc1.dtb \
Signature · 1 line
1.7.10.4
PATCH 8/11 ARM: versatile: use OF init for sp804 timer
In reply to Rob HerringFrom: Rob Herring <[email protected]>
Enable DT based init for the sp804 timers on versatile DT platform.
--- arch/arm/boot/dts/versatile-ab.dts | 12 ++++++++++++ arch/arm/mach-versatile/core.c | 26 +++++++++++++------------- arch/arm/mach-versatile/versatile_dt.c | 1 - 3 files changed, 25 insertions(+), 14 deletions(-)
arch/arm/boot/dts/versatile-ab.dts +12 -0
@@ -121,6 +121,18 @@ interrupts = <0>; }; + timer at 101e2000 { + compatible = "arm,sp804", "arm,primecell"; + reg = <0x101e2000 0x1000>; + interrupts = <4>; + }; + + timer at 101e3000 { + compatible = "arm,sp804", "arm,primecell"; + reg = <0x101e3000 0x1000>; + interrupts = <5>; + }; + gpio0: gpio at 101e4000 { compatible = "arm,pl061", "arm,primecell"; reg = <0x101e4000 0x1000>;
arch/arm/mach-versatile/core.c +13 -13
@@ -748,12 +748,25 @@ void versatile_restart(char mode, const char *cmd)/* Early initializations */ void __init versatile_init_early (void ) { +u32 val;void __iomem *sys =__io_address (VERSATILE_SYS_BASE ); osc4_clk.vcoreg = sys +VERSATILE_SYS_OSCCLCD_OFFSET ;clkdev_add_table (lookups,ARRAY_SIZE (lookups));versatile_sched_clock_init (sys + VERSATILE_SYS_24MHz_OFFSET,24000000 ); + +/* +* set clock frequency: +* VERSATILE_REFCLK is 32KHz +* VERSATILE_TIMCLK is 1MHz +*/ + val =readl (__io_address (VERSATILE_SCTL_BASE )); +writel ((VERSATILE_TIMCLK << VERSATILE_TIMER1_EnSel) | + (VERSATILE_TIMCLK << VERSATILE_TIMER2_EnSel) | + (VERSATILE_TIMCLK << VERSATILE_TIMER3_EnSel) | + (VERSATILE_TIMCLK << VERSATILE_TIMER4_EnSel) | val, +__io_address (VERSATILE_SCTL_BASE )); }void __init versatile_init (void )
@@ -784,19 +797,6 @@ void __init versatile_init(void)*/ void __init versatile_timer_init (void ) { -u32 val; - -/* -* set clock frequency: -* VERSATILE_REFCLK is 32KHz -* VERSATILE_TIMCLK is 1MHz -*/ - val =readl (__io_address (VERSATILE_SCTL_BASE )); -writel ((VERSATILE_TIMCLK << VERSATILE_TIMER1_EnSel) | - (VERSATILE_TIMCLK << VERSATILE_TIMER2_EnSel) | - (VERSATILE_TIMCLK << VERSATILE_TIMER3_EnSel) | - (VERSATILE_TIMCLK << VERSATILE_TIMER4_EnSel) | val, -__io_address (VERSATILE_SCTL_BASE ));sp804_clocksource_init (TIMER3_VA_BASE ,"timer3" );sp804_clockevents_init (TIMER0_VA_BASE ,IRQ_TIMERINT0_1 ,"timer0" );
arch/arm/mach-versatile/versatile_dt.c +0 -1
@@ -45,7 +45,6 @@ DT_MACHINE_START(VERSATILE_PB, "ARM-Versatile (Device Tree Support)") .map_io = versatile_map_io, .init_early = versatile_init_early, .init_irq = versatile_init_irq, - .init_time = versatile_timer_init, .init_machine = versatile_dt_init, .dt_compat = versatile_dt_match, .restart = versatile_restart,
Signature · 1 line
1.7.10.4
PATCH 9/11 ARM: integrator-cp: convert use CLKSRC_OF for timer init
In reply to Rob HerringFrom: Rob Herring <[email protected]>
Move the integrator-cp timer init to timer-sp.c and use CLKSRC_OF. There is no reason to use the aliases, so drop them from the init code.
The integrator-cp timers are mistakenly called sp804 timers in the dts, but in fact they are not sp804 dual timers, but single timers with the same programming model. Fix the dts to reflect this.
--- arch/arm/boot/dts/integratorcp.dts | 6 +++--- arch/arm/common/timer-sp.c | 29 +++++++++++++++++++++++++++ arch/arm/mach-integrator/integrator_cp.c | 32 ------------------------------ 3 files changed, 32 insertions(+), 35 deletions(-)
arch/arm/boot/dts/integratorcp.dts +3 -3
@@ -24,15 +24,15 @@ }; timer0: timer at 13000000 { - compatible = "arm,sp804", "arm,primecell"; + compatible = "arm,integrator-cp-timer"; }; timer1: timer at 13000100 { - compatible = "arm,sp804", "arm,primecell"; + compatible = "arm,integrator-cp-timer"; }; timer2: timer at 13000200 { - compatible = "arm,sp804", "arm,primecell"; + compatible = "arm,integrator-cp-timer"; }; pic: pic at 14000000 {
arch/arm/common/timer-sp.c +29 -0
@@ -31,6 +31,7 @@#include <asm/sched_clock.h> #include <asm/hardware/arm_timer.h> +#include <asm/hardware/timer-sp.h> static long __init sp804_get_clock_rate (struct clk *clk) {
@@ -255,3 +256,31 @@ static void __init sp804_of_init(struct device_node *np) initialized = true; }CLOCKSOURCE_OF_DECLARE (sp804,"arm,sp804" , sp804_of_init); + +static void __init integrator_cp_of_init (struct device_node *np) +{ +static int init_count =0 ; +void __iomem *base; +int irq; +const char *name =of_get_property (np,"compatible" ,NULL ); + +if (init_count ==2 || !of_device_is_available (np)) +return ; + + base =of_iomap (np,0 ); +if (WARN_ON (!base)) +return ; + +if (!init_count) +sp804_clocksource_init (base, name); +else { + irq =irq_of_parse_and_map (np,0 ); +if (irq <=0 ) +return ; + +sp804_clockevents_init (base, irq, name); + } + + init_count++; +} +CLOCKSOURCE_OF_DECLARE (intcp,"arm,integrator-cp-timer" , integrator_cp_of_init);
arch/arm/mach-integrator/integrator_cp.c +0 -32
@@ -249,37 +249,6 @@ static void __init intcp_init_early(void) }#ifdef CONFIG_OF - -static void __init cp_of_timer_init (void ) -{ -struct device_node *node; -const char *path; -void __iomem *base; -int err; -int irq; - - err =of_property_read_string (of_aliases, -"arm,timer-primary" , &path); -if (WARN_ON (err)) -return ; - node =of_find_node_by_path (path); - base =of_iomap (node,0 ); -if (WARN_ON (!base)) -return ; -sp804_clocksource_init (base, node->name); - - err =of_property_read_string (of_aliases, -"arm,timer-secondary" , &path); -if (WARN_ON (err)) -return ; - node =of_find_node_by_path (path); - base =of_iomap (node,0 ); -if (WARN_ON (!base)) -return ; - irq =irq_of_parse_and_map (node,0 ); -sp804_clockevents_init (base, irq, node->name); -} -static const struct of_device_id fpga_irq_of_match[]__initconst = { { .compatible ="arm,versatile-fpga-irq" , .data = fpga_irq_of_init, }, { /* Sentinel */ }
@@ -383,7 +352,6 @@ DT_MACHINE_START(INTEGRATOR_CP_DT, "ARM Integrator/CP (Device Tree)") .init_early = intcp_init_early, .init_irq = intcp_init_irq_of, .handle_irq = fpga_handle_irq, - .init_time = cp_of_timer_init, .init_machine = intcp_init_of, .restart = integrator_restart, .dt_compat = intcp_dt_board_compat,
Signature · 1 line
1.7.10.4
PATCH 10/11 ARM: move sp804 and integrator timers to drivers/clocksource
In reply to Rob HerringFrom: Rob Herring <[email protected]>
Move timer-sp and integrator-ap timer code to drivers/clocksource and update timer-sp.h and arm_timer.h includes.
This adds CLKSRC_OF support for the integrator-ap timer and removes the use of "arm,timer-primary" and "arm,timer-secondary" aliases. The timer selection should not be important as all 3 timers are equal capability.
---
arch/arm/Kconfig | 6 -
arch/arm/common/Makefile | 1 -
arch/arm/mach-integrator/Kconfig | 1 +
arch/arm/mach-integrator/integrator_ap.c | 169 +----------------
arch/arm/mach-integrator/integrator_cp.c | 3 +-
arch/arm/mach-realview/core.c | 3 +-
arch/arm/mach-versatile/core.c | 2 +-
arch/arm/mach-vexpress/ct-ca9x4.c | 4 +-
arch/arm/mach-vexpress/v2m.c | 3 +-
drivers/clocksource/Kconfig | 12 ++
drivers/clocksource/Makefile | 2 +
.../hardware => drivers/clocksource}/arm_timer.h | 6 +-
drivers/clocksource/integrator_ap_timer.c | 190 ++++++++++++++++++++
.../arm/common => drivers/clocksource}/timer-sp.c | 9 +-
include/clocksource/integrator_ap_timer.h | 7 +
.../hardware => include/clocksource}/timer-sp.h | 8 +
16 files changed, 232 insertions(+), 194 deletions(-)
rename {arch/arm/include/asm/hardware => drivers/clocksource}/arm_timer.h (89%)
create mode 100644 drivers/clocksource/integrator_ap_timer.c
rename {arch/arm/common => drivers/clocksource}/timer-sp.c (98%)
create mode 100644 include/clocksource/integrator_ap_timer.h
rename {arch/arm/include/asm/hardware => include/clocksource}/timer-sp.h (84%)arch/arm/Kconfig +0 -6
@@ -1169,12 +1169,6 @@ config PLAT_PXA config PLAT_VERSATILE bool -config ARM_TIMER_SP804 - bool - select CLKSRC_MMIO - select CLKSRC_OF if OF - select HAVE_SCHED_CLOCK - source arch/arm/mm/Kconfig config ARM_NR_BANKS
arch/arm/common/Makefile +0 -1
@@ -10,4 +10,3 @@ obj-$(CONFIG_SHARP_LOCOMO) += locomo.o obj-$(CONFIG_SHARP_PARAM) += sharpsl_param.o obj-$(CONFIG_SHARP_SCOOP) += scoop.o obj-$(CONFIG_PCI_HOST_ITE8152) += it8152.o -obj-$(CONFIG_ARM_TIMER_SP804) += timer-sp.o
arch/arm/mach-integrator/Kconfig +1 -0
@@ -5,6 +5,7 @@ menu "Integrator Options" config ARCH_INTEGRATOR_AP bool "Support Integrator/AP and Integrator/PP2 platforms" select CLKSRC_MMIO + select INTEGRATOR_AP_TIMER select MIGHT_HAVE_PCI select SERIAL_AMBA_PL010 select SERIAL_AMBA_PL010_CONSOLE
arch/arm/mach-integrator/integrator_ap.c +1 -168
212 lines not on this page · raw message
arch/arm/mach-integrator/integrator_cp.c +1 -2
@@ -28,6 +28,7 @@#include <linux/of_address.h> #include <linux/of_platform.h> #include <linux/sys_soc.h> +#include <clocksource/timer-sp.h> #include <mach/hardware.h> #include <mach/platform.h>
@@ -44,8 +45,6 @@#include <asm/mach/map.h> #include <asm/mach/time.h> -#include <asm/hardware/timer-sp.h> -#include <plat/clcd.h> #include <plat/sched_clock.h>
arch/arm/mach-realview/core.c +1 -2
@@ -31,6 +31,7 @@#include <linux/amba/mmci.h> #include <linux/gfp.h> #include <linux/mtd/physmap.h> +#include <clocksource/timer-sp.h> #include <mach/hardware.h> #include <asm/irq.h>
@@ -41,10 +42,8 @@#include <asm/mach/irq.h> #include <asm/mach/map.h> -#include <mach/platform.h> #include <mach/irqs.h> -#include <asm/hardware/timer-sp.h> #include <plat/clcd.h> #include <plat/sched_clock.h>
arch/arm/mach-versatile/core.c +1 -1
@@ -38,6 +38,7 @@#include <linux/clkdev.h> #include <linux/mtd/physmap.h> #include <linux/bitops.h> +#include <clocksource/timer-sp.h> #include <asm/irq.h> #include <asm/hardware/icst.h>
@@ -49,7 +50,6 @@#include <asm/mach/map.h> #include <mach/hardware.h> #include <mach/platform.h> -#include <asm/hardware/timer-sp.h> #include <plat/clcd.h> #include <plat/sched_clock.h>
arch/arm/mach-vexpress/ct-ca9x4.c +1 -3
@@ -11,16 +11,14 @@#include <linux/clkdev.h> #include <linux/vexpress.h> #include <linux/irqchip/arm-gic.h> +#include <clocksource/timer-sp.h> -#include <asm/hardware/arm_timer.h> #include <asm/hardware/cache-l2x0.h> #include <asm/smp_scu.h> #include <asm/smp_twd.h> #include <mach/ct-ca9x4.h> -#include <asm/hardware/timer-sp.h> -#include <asm/mach/map.h> #include <asm/mach/time.h>
arch/arm/mach-vexpress/v2m.c +1 -2
@@ -23,15 +23,14 @@#include <linux/regulator/fixed.h> #include <linux/regulator/machine.h> #include <linux/vexpress.h> +#include <clocksource/timer-sp.h> #include <asm/mach-types.h> #include <asm/sizes.h> #include <asm/mach/arch.h> #include <asm/mach/map.h> #include <asm/mach/time.h> -#include <asm/hardware/arm_timer.h> #include <asm/hardware/cache-l2x0.h> -#include <asm/hardware/timer-sp.h> #include <mach/ct-ca9x4.h> #include <mach/motherboard.h>
drivers/clocksource/Kconfig +12 -0
@@ -25,6 +25,18 @@ config DW_APB_TIMER_OF config ARMADA_370_XP_TIMER bool +config ARM_TIMER_SP804 + bool + depends on ARM + select CLKSRC_MMIO + select CLKSRC_OF if OF + select HAVE_SCHED_CLOCK + +config INTEGRATOR_AP_TIMER + bool + depends on ARM + select CLKSRC_OF if OF + config SUNXI_TIMER bool
drivers/clocksource/Makefile +2 -0
@@ -14,8 +14,10 @@ obj-$(CONFIG_DW_APB_TIMER) += dw_apb_timer.o obj-$(CONFIG_DW_APB_TIMER_OF) += dw_apb_timer_of.o obj-$(CONFIG_CLKSRC_NOMADIK_MTU) += nomadik-mtu.o obj-$(CONFIG_CLKSRC_DBX500_PRCMU) += clksrc-dbx500-prcmu.o +obj-$(CONFIG_ARM_TIMER_SP804) += timer-sp.o obj-$(CONFIG_ARMADA_370_XP_TIMER) += time-armada-370-xp.o obj-$(CONFIG_ARCH_BCM2835) += bcm2835_timer.o +obj-$(CONFIG_INTEGRATOR_AP_TIMER) += integrator_ap_timer.o obj-$(CONFIG_SUNXI_TIMER) += sunxi_timer.o obj-$(CONFIG_ARCH_TEGRA) += tegra20_timer.o obj-$(CONFIG_VT8500_TIMER) += vt8500_timer.o
drivers/clocksource/arm_timer.h renamed from arch/arm/include/asm/hardware/arm_timer.h +2 -4
@@ -1,5 +1,5 @@ -#ifndef __ASM_ARM_HARDWARE_ARM_TIMER_H -#define __ASM_ARM_HARDWARE_ARM_TIMER_H +#ifndef __CLOCKSOURCE_ARM_TIMER_H +#define __CLOCKSOURCE_ARM_TIMER_H/* * ARM timer implementation, found in Integrator, Versatile and Realview
@@ -12,8 +12,6 @@* * Every SP804 contains two identical timers. */ -#define TIMER_1_BASE 0x00 -#define TIMER_2_BASE 0x20#define TIMER_LOAD 0x00/* ACVR rw */ #define TIMER_VALUE 0x04/* ACVR ro */
drivers/clocksource/integrator_ap_timer.c new file +190 -0
190 lines not on this page · raw message
drivers/clocksource/timer-sp.c renamed from arch/arm/common/timer-sp.c +4 -5
@@ -1,6 +1,4 @@/* -* linux/arch/arm/common/timer-sp.c -* * Copyright (C) 1999 - 2003 ARM Limited * Copyright (C) 2000 Deep Blue Solutions Ltd *
@@ -28,10 +26,11 @@#include <linux/of.h> #include <linux/of_address.h> #include <linux/of_irq.h> +#include <clocksource/timer-sp.h> #include <asm/sched_clock.h> -#include <asm/hardware/arm_timer.h> -#include <asm/hardware/timer-sp.h> + +#include "arm_timer.h" static long __init sp804_get_clock_rate (struct clk *clk) {
@@ -283,4 +282,4 @@ static void __init integrator_cp_of_init(struct device_node *np) init_count++; } -CLOCKSOURCE_OF_DECLARE (intcp,"arm,integrator-cp-timer" , integrator_cp_of_init); +CLOCKSOURCE_OF_DECLARE (intcp,"arm,integrator-cp-timer" , integrator_cp_of_init);
include/clocksource/integrator_ap_timer.h new file +7 -0
@@ -0,0 +1,7 @@ +#ifndef __CLOCKSOURCE_INTEGRATOR_AP_TIMER +#define __CLOCKSOURCE_INTEGRATOR_AP_TIMER + +void integrator_clocksource_init (unsigned long inrate,void __iomem *base); +void integrator_clockevent_init (unsigned long inrate,void __iomem *base,int irq); + +#endif
include/clocksource/timer-sp.h renamed from arch/arm/include/asm/hardware/timer-sp.h +8 -0
@@ -1,3 +1,9 @@ +#ifndef __CLOCKSOURCE_TIMER_SP +#define __CLOCKSOURCE_TIMER_SP + +#define TIMER_1_BASE 0x00 +#define TIMER_2_BASE 0x20 +struct clk ; void __sp804_clocksource_and_sched_clock_init(void __iomem *,
@@ -21,3 +27,5 @@ static inline void sp804_clockevents_init(void __iomem *base, unsigned int irq, __sp804_clockevents_init(base, irq, NULL, name); } + +#endif
Signature · 1 line
1.7.10.4
PATCH 11/11 devtree: add binding documentation for sp804
In reply to Rob HerringFrom: Haojian Zhuang <[email protected]>
The sp804 binding is already in use by several platforms. This adds missing documentation for the binding and also extends the binding to handle some additional possible interrupt configurations.
--- .../devicetree/bindings/timer/arm,sp804.txt | 29 ++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Documentation/devicetree/bindings/timer/arm,sp804.txt
Documentation/devicetree/bindings/timer/arm,sp804.txt new file +29 -0
@@ -0,0 +1,29 @@ +ARM sp804 Dual Timers +--------------------------------------- + +Required properties: +- compatible: Should be "arm,sp804" & "arm,primecell" +- interrupts: Should contain the list of Dual Timer interrupts. This is the + interrupt for timer 1 and timer 2. In the case of a single entry, it is + the combined interrupt or if "arm,sp804-has-irq" is present that + specifies which timer interrupt is connected. +- reg: Should contain location and length for dual timer register. +- clocks: clocks driving the dual timer hardware. This list should be 1 or 3 + clocks. With 3 clocks, the order is timer0 clock, timer1 clock, + apb_pclk. A single clock can also be specified if the same clock is + used for all clock inputs. + +Optional properties: +- arm,sp804-has-irq = <#>: In the case of only 1 timer irq line connected, this + specifies if the irq connection is for timer 1 or timer 2. A value of 1 + or 2 should be used. + +Example: + + timer0: timer at fc800000 { + compatible = "arm,sp804", "arm,primecell"; + reg = <0xfc800000 0x1000>; + interrupts = <0 0 4>, <0 1 4>; + clocks = <&timclk1 &timclk2 &pclk>; + clock-names = "timer1", "timer2", "apb_pclk"; + };
Signature · 1 line
1.7.10.4
Arnd Bergmann
maintainerQuoted 4 lines · Rob Herring
This series is dependent on my
CLKSRC_OFclean-up in arm-soc, mysched_clockselection series[1], and Arnd's default machine descriptor patch (for defaultclocksource_of_initcall). The full series is available here:
All your patches look good to me, but I'd suggest you don't depend on my default machine descriptor patch yet, that just makes the dependencies harder to track, and we can easily remove all the calls once they are obsoletely.
Arnd
Quoted 11 lines · Arnd Bergmann
Quoted 4 lines · Rob Herring
This series is dependent on my
CLKSRC_OFclean-up in arm-soc, mysched_clockselection series[1], and Arnd's default machine descriptor patch (for defaultclocksource_of_initcall). The full series is available here:All your patches look good to me, but I'd suggest you don't depend on my default machine descriptor patch yet, that just makes the dependencies harder to track, and we can easily remove all the calls once they are obsoletely.
I really only need the hunk that calls clocksource_of_init which is really somewhat unrelated to a default machine desc. So what if I just pull out this hunk to a separate patch:
arch/arm/kernel/time.c +1 -0
@@ -22,6 +22,7 @@#include <linux/errno.h> #include <linux/profile.h> #include <linux/timer.h> +#include <linux/clocksource.h> #include <linux/irq.h> #include <asm/thread_info.h>
@@ -115,6 +116,10 @@ int __init
register_persistent_clock(clock_access_fn read_boot,
void __init time_init(void)
{
- machine_desc->init_time();
+ if (machine_desc->init_time)
+ machine_desc->init_time();
+ else
+ clocksource_of_init();
+
sched_clock_postinit();
}
Re: [PATCH 01/11] OF: add empty of_device_is_available for !OF
In reply to Rob HerringQuoted 14 lines · Rob Herring
From: Rob Herring <[email protected]>
Add an empty version of
of_device_is_available.Signed-off-by Rob Herring <[email protected]>--- include/linux/of.h | 5 +++++ 1 file changed, 5 insertions(+)include/linux/of.h +0
-0
include/linux/of.h static inline int of_device_is_compatible(const struct device_node *device, · line 382
Quoted 4 lines
include/linux/of.h +1
-0@@ -379,6 +379,11 @@ static inline int of_device_is_compatible(const struct device_node *device,return 0 ; } +static inline int of_device_is_available(const struct device_node *device,)
I assume that comma shouldn't be there? ^
Mark.
Re: [PATCH 01/11] OF: add empty of_device_is_available for !OF
Quoted 18 lines · Mark Rutland
Quoted 17 lines · Rob Herring
From: Rob Herring <[email protected]>
Add an empty version of
of_device_is_available.Signed-off-by Rob Herring <[email protected]>--- include/linux/of.h | 5 +++++ 1 file changed, 5 insertions(+)include/linux/of.h +0
-0@@ -379,6 +379,11 @@ static inline int of_device_is_compatible(const struct device_node *device,return 0 ; }
Quoted 3 lines
include/linux/of.h static inline int of_device_is_compatible(const struct device_node *device, · line 382
Quoted 1 line
include/linux/of.h +1
-0+static inline int of_device_is_available(const struct device_node *device,)I assume that comma shouldn't be there? ^
Right. I've fixed that up in my git tree.
Rob
Re: [PATCH 02/11] ARM: remove extra timer-sp control register clearing
In reply to Rob HerringQuoted 8 lines · Rob Herring
From: Rob Herring <[email protected]>
The timer-sp initialization code clears the control register before initializing the timers, so every platform doing this is redundant.
For unused timers, we should not care what state they are in.
Signed-off-by Rob Herring <[email protected]>
(...)
arch/arm/mach-integrator/integrator_ap.c static void __init ap_timer_init(void) · line 649
Quoted 12 lines
arch/arm/mach-integrator/integrator_ap.c +0
-4@@ -643,10 +643,6 @@ static void __init ap_timer_init(void)clk_prepare_enable (clk); rate =clk_get_rate (clk); -writel (0 ,TIMER0_VA_BASE +TIMER_CTRL ); -writel (0 ,TIMER1_VA_BASE +TIMER_CTRL ); -writel (0 ,TIMER2_VA_BASE +TIMER_CTRL ); -
As noted this is not an init function for timer-sp.c so please drop this hunk of the patch. Maybe this zeroing is pointless but that would be a separate patch that I can test.
arch/arm/mach-integrator/integrator_cp.c line 36
Quoted 9 lines
arch/arm/mach-integrator/integrator_cp.c +0
-1@@ -33,7 +33,6 @@#include <mach/platform.h> #include <asm/setup.h> #include <asm/mach-types.h> -#include <asm/hardware/arm_timer.h>
What doe this change has to do with $SUBJECT?
Quoted 20 lines
arch/arm/mach-integrator/integrator_cp.c +0
-2#include <asm/hardware/icst.h> #include <mach/cm.h> @@ -267,7 +266,6 @@ static void __init cp_of_timer_init(void) base =of_iomap (node,0 );if (WARN_ON (!base))return ; -writel (0 , base +TIMER_CTRL );sp804_clocksource_init (base, node->name); err = of_property_read_string(of_aliases,@@ -279,7 +277,6 @@ static void __init cp_of_timer_init(void)if (WARN_ON (!base))return ; irq =irq_of_parse_and_map (node,0 ); -writel (0 , base +TIMER_CTRL );sp804_clockevents_init (base, irq, node->name); }
arch/arm/mach-integrator/integrator_cp.c static void __init intcp_init_irq(void) · line 512
Quoted 10 lines
arch/arm/mach-integrator/integrator_cp.c +0
-4@@ -510,10 +507,6 @@ static void __init intcp_init_irq(void)static void __init cp_timer_init (void ) { -writel (0 ,TIMER0_VA_BASE +TIMER_CTRL ); -writel (0 ,TIMER1_VA_BASE +TIMER_CTRL ); -writel (0 ,TIMER2_VA_BASE +TIMER_CTRL ); -sp804_clocksource_init (TIMER2_VA_BASE ,"timer2" );sp804_clockevents_init (TIMER1_VA_BASE ,IRQ_TIMERINT1 ,"timer1" ); }
The rest of the changes to integrator_cp.c looks OK...
Yours,
Linus Walleij
Re: [PATCH 03/11] ARM: timer-sp: convert to use CLKSRC_OF init
In reply to Rob HerringQuoted 6 lines · Rob Herring
From: Rob Herring <[email protected]>
This adds
CLKSRC_OFbased init for sp804 timer. The clock initialization is refactored to support retrieving the clock(s) from the DT.Signed-off-by Rob Herring <[email protected]>
(...)
arch/arm/common/timer-sp.c void __init sp804_clockevents_init(void __iomem *base, unsigned int irq, · line 205
Quoted 6 lines
arch/arm/common/timer-sp.c +2
-0@@ -186,6 +201,57 @@ void __init sp804_clockevents_init(void __iomem *base, unsigned int irq, evt->irq = irq; evt->cpumask = cpu_possible_mask; +writel (0 , clkevt_base +TIMER_CTRL ); +
Wait, patch 1/11 depends on this being done first, right?
So patch 1/11 has to be moved after this one in the series to avoid bisectability problems?
Apart from that:
Yours,
Linus Walleij
Re: [PATCH 02/11] ARM: remove extra timer-sp control register clearing
In reply to Linus WalleijQuoted 19 lines · Linus Walleij
Quoted 8 lines · Rob Herring
From: Rob Herring <[email protected]>
The timer-sp initialization code clears the control register before initializing the timers, so every platform doing this is redundant.
For unused timers, we should not care what state they are in.
Signed-off-by Rob Herring <[email protected]>(...)
Quoted 8 lines
arch/arm/mach-integrator/integrator_ap.c +0
-0@@ -643,10 +643,6 @@ static void __init ap_timer_init(void)clk_prepare_enable (clk); rate =clk_get_rate (clk);
Quoted 8 lines
arch/arm/mach-integrator/integrator_ap.c static void __init ap_timer_init(void) · line 649
Quoted 4 lines
arch/arm/mach-integrator/integrator_ap.c +0
-4-writel (0 ,TIMER0_VA_BASE +TIMER_CTRL ); -writel (0 ,TIMER1_VA_BASE +TIMER_CTRL ); -writel (0 ,TIMER2_VA_BASE +TIMER_CTRL ); -As noted this is not an init function for
timer-sp.cso please drop this hunk of the patch. Maybe this zeroing is pointless but that would be a separate patch that I can test.
Okay. I'll split this out.
Quoted 12 lines
arch/arm/mach-integrator/integrator_cp.c line 36
Quoted 10 lines
arch/arm/mach-integrator/integrator_cp.c +0
-1@@ -33,7 +33,6 @@#include <mach/platform.h> #include <asm/setup.h> #include <asm/mach-types.h> -#include <asm/hardware/arm_timer.h> What doe this change has to do with $SUBJECT?
If I remove TIMER_CTRL use, then I don't need the header that defines it any more.
Rob
Re: [PATCH 09/11] ARM: integrator-cp: convert use CLKSRC_OF for timer init
In reply to Rob HerringQuoted 10 lines · Rob Herring
From: Rob Herring <[email protected]>
Move the integrator-cp timer init to
timer-sp.cand useCLKSRC_OF. There is no reason to use the aliases, so drop them from the init code.The integrator-cp timers are mistakenly called sp804 timers in the dts, but in fact they are not sp804 dual timers, but single timers with the same programming model. Fix the dts to reflect this.
Signed-off-by Rob Herring <[email protected]>
Looks correct to me. Throw it into linux-next and I'll test if it works too! :-)
Yours,
Linus Walleij
Re: [PATCH 10/11] ARM: move sp804 and integrator timers to drivers/clocksource
In reply to Rob HerringQuoted 5 lines · Rob Herring
From: Rob Herring <[email protected]>
Move timer-sp and integrator-ap timer code to
drivers/clocksourceand updatetimer-sp.handarm_timer.hincludes.
Quoted 8 lines
This adds
CLKSRC_OFsupport for the integrator-ap timer and removes the use of "arm,timer-primary" and "arm,timer-secondary" aliases. The timer selection should not be important as all 3 timers are equal capability.Signed-off-by Rob Herring <[email protected]>Cc Russell King <[email protected]>Cc John Stultz <[email protected]>Cc Thomas Gleixner <[email protected]>
Nice!
This looks like it'll work.
Yours,
Linus Walleij
Re: [PATCH 02/11] ARM: remove extra timer-sp control register clearing
In reply to Rob HerringQuoted 6 lines · Rob Herring
From: Rob Herring <[email protected]>
The timer-sp initialization code clears the control register before initializing the timers, so every platform doing this is redundant.
For unused timers, we should not care what state they are in.
NAK. We do care what state they're in. What if they have their interrupt enable bit set, and IRQ is shared with the clock event timer?
No, this patch is just wrong.
Re: [PATCH 03/11] ARM: timer-sp: convert to use CLKSRC_OF init
In reply to Rob HerringQuoted 17 lines · Rob Herring
arch/arm/common/timer-sp.c +17
-0+ clk0 =of_clk_get (np,0 ); +if (IS_ERR (clk0)) + clk0 =NULL ; + +/* Get the 2nd clock if the timer has 2 timer clocks */ +if (of_count_phandle_with_args (np,"clocks" ,"#clock-cells" ) ==3 ) { + clk1 =of_clk_get (np,1 ); +if (IS_ERR (clk1)) { +pr_err ("sp804: %s clock not found: %d\n" , np->name, + (int )PTR_ERR (clk1)); +return ; + } + }else + clk1 = clk0; + + irq =irq_of_parse_and_map (np,0 ); +if (irq <=0 )
arch/arm/common/timer-sp.c void __init sp804_clockevents_init(void __iomem *base, unsigned int irq, · line 253
Quoted 10 lines
arch/arm/common/timer-sp.c +10
-0+return ; + +of_property_read_u32 (np,"arm,sp804-has-irq" , &irq_num); +if (irq_num ==2 ) + tmr2_evt = true; + +__sp804_clockevents_init (base + (tmr2_evt ?TIMER_2_BASE :0 ), + irq, tmr2_evt ? clk1 : clk0, name); +__sp804_clocksource_and_sched_clock_init (base + (tmr2_evt ?0 :TIMER_2_BASE ), + name, tmr2_evt ? clk0 : clk1,1 );
This just looks totally screwed to me.
A SP804 cell has two timers, and has one clock input and two clock enable inputs. The clock input is common to both timers. The timers only count on the rising edge of the clock input when the enable input is high. (the APB PCLK also matters too...)
Now, the clock enable inputs are controlled by the SP810 system controller to achieve different clock rates for each. So, we *can* view an SP804 as having two clock inputs.
However, the two clock inputs do not depend on whether one or the other has an IRQ or not. Timer 1 is always clocked by TIMCLK & TIMCLKEN1. Timer 2 is always clocked by TIMCLK & TIMCLKEN2.
Using the logic above, the clocks depend on how the IRQs are wired up... really? Can you see from my description above why that is screwed? What bearing does the IRQ have on the wiring of the clock inputs?
And, by doing this aren't you embedding into the DT description something specific to the Linux implementation for this device - namely the decision by you that the IRQs determine how the clocks get used?
So... NAK.
Re: [PATCH 11/11] devtree: add binding documentation for sp804
In reply to Rob HerringDocumentation/devicetree/bindings/timer/arm,sp804.txt line 19
Quoted 4 lines · Rob Herring
Documentation/devicetree/bindings/timer/arm,sp804.txt new file +4
-0+Optional properties: +- arm,sp804-has-irq = <#>: In the case of only 1 timer irq line connected, this + specifies if the irq connection is for timer 1 or timer 2. A value of 1 + or 2 should be used.
This fails to mention that it has any bearing on the clocks.
Re: [PATCH 03/11] ARM: timer-sp: convert to use CLKSRC_OF init
In reply to Russell King - ARM LinuxQuoted 31 lines · Russell King - ARM Linux
Quoted 17 lines · Rob Herring
arch/arm/common/timer-sp.c +17
-0+ clk0 =of_clk_get (np,0 ); +if (IS_ERR (clk0)) + clk0 =NULL ; + +/* Get the 2nd clock if the timer has 2 timer clocks */ +if (of_count_phandle_with_args (np,"clocks" ,"#clock-cells" ) ==3 ) { + clk1 =of_clk_get (np,1 ); +if (IS_ERR (clk1)) { +pr_err ("sp804: %s clock not found: %d\n" , np->name, + (int )PTR_ERR (clk1)); +return ; + } + }else + clk1 = clk0; + + irq =irq_of_parse_and_map (np,0 ); +if (irq <=0 )arch/arm/common/timer-sp.c void __init sp804_clockevents_init(void __iomem *base, unsigned int irq, · line 253
Quoted 10 lines
arch/arm/common/timer-sp.c +10
-0+return ; + +of_property_read_u32 (np,"arm,sp804-has-irq" , &irq_num); +if (irq_num ==2 ) + tmr2_evt = true; + +__sp804_clockevents_init (base + (tmr2_evt ?TIMER_2_BASE :0 ), + irq, tmr2_evt ? clk1 : clk0, name); +__sp804_clocksource_and_sched_clock_init (base + (tmr2_evt ?0 :TIMER_2_BASE ), + name, tmr2_evt ? clk0 : clk1,1 );This just looks totally screwed to me.
Quoted 8 lines
A SP804 cell has two timers, and has one clock input and two clock enable inputs. The clock input is common to both timers. The timers only count on the rising edge of the clock input when the enable input is high. (the APB PCLK also matters too...)
Now, the clock enable inputs are controlled by the SP810 system controller to achieve different clock rates for each. So, we *can* view an SP804 as having two clock inputs.
Exactly. Effectively, the TIMCLKENx are just dividers of the clock input.
Quoted 8 lines
However, the two clock inputs do not depend on whether one or the other has an IRQ or not. Timer 1 is always clocked by TIMCLK & TIMCLKEN1. Timer 2 is always clocked by TIMCLK & TIMCLKEN2.
Using the logic above, the clocks depend on how the IRQs are wired up... really? Can you see from my description above why that is screwed? What bearing does the IRQ have on the wiring of the clock inputs?
No. I'm simply swapping which timer is used for clksrc vs. clkevt based on the irq connection DT describes. If only timer 2's irq being hooked up, then timer 2 is the clkevt. Otherwise I always use timer 1 for the clkevt because I either have a combined interrupt or timer 1 interrupt hooked up.
Perhaps re-writing it like this would be more clear:
if (irq_num == 2){
__sp804_clockevents_init(base + TIMER_2_BASE, irq, clk1, name);
__sp804_clocksource_and_sched_clock_init(base, name, clk0, 1);
} else {
__sp804_clockevents_init(base, irq, clk0, name);
__sp804_clocksource_and_sched_clock_init(base + TIMER_2_BASE,
name, clk1, 1);
}Rob
Re: [PATCH 02/11] ARM: remove extra timer-sp control register clearing
In reply to Russell King - ARM LinuxQuoted 6 lines · Russell King - ARM Linux
Quoted 5 lines · Rob Herring
From: Rob Herring <[email protected]>
The timer-sp initialization code clears the control register before initializing the timers, so every platform doing this is redundant.
Quoted 6 lines
Quoted 1 line
For unused timers, we should not care what state they are in.
NAK. We do care what state they're in. What if they have their interrupt enable bit set, and IRQ is shared with the clock event timer?
No, this patch is just wrong.
Okay, I can have the timer init function clear the register in the case that even when the timer is unused.
Rob
Re: [PATCH 03/11] ARM: timer-sp: convert to use CLKSRC_OF init
In reply to Rob HerringQuoted 10 lines · Rob Herring
Perhaps re-writing it like this would be more clear:
if (irq_num == 2){ __sp804_clockevents_init(base + TIMER_2_BASE, irq, clk1, name); __sp804_clocksource_and_sched_clock_init(base, name, clk0, 1); } else { __sp804_clockevents_init(base, irq, clk0, name); __sp804_clocksource_and_sched_clock_init(base + TIMER_2_BASE, name, clk1, 1); }
Yes, that is definitely much clearer than the original patch.