Clocksource driver for OMAP SoCs
Subsystems (5)
cover Clocksource driver for OMAP SoCs
Here's an RFC series for clocksource migration of OMAP timers. This attempt is going to step-by-step attempt to migrate platforms such that everything is kept working smoothly during migration. Currently the series introduces a clocksource driver and migrates AM335x platform to discuss the general idea.
The plan is to move dmtimer to clocksource (infact make a copy for now so that platforms not migrated still work). Then we add a per-SoC clocksource registration and select a timer as each of them are initialized by clocksource (suggested in [1]).
We also add support for a generic timer init function which is called for every SoC for which support in clocksource driver is available. And, we call a generic OMAP power up function which is introduced in the mach-omap layer in this series.
Lastly, we add clock nodes for the system timers, and setup a default-parent so that the parent clocks are setup correctly. Due to this, the series depends on Tero's series [2].
Please note- this effort is for system timer support. This is the first basic step. Converting dmtimer to use any other generic framework is a completely different topic and should not be discussed in this thread. It is something that can be done only _after_ the work done in this series is completed, thanks.
[1] https://lkml.org/lkml/2013/11/23/88
[2] http://www.spinics.net/lists/linux-omap/msg103069.html
Joel Fernandes (5):
ARM: dts: am33xx: Add clock nodes for timer1 and timer2
ARM: dts: am33xx: Set parent clock for timer through DT
ARM: OMAP2+: timer: Add clocksource initialization and powerup
support
clocksource: omap-timer: Introduce clocksource driver for OMAP SoCs
ARM: AM33xx: Move to using omap_generic_timer_init for init_time
arch/arm/boot/dts/am33xx.dtsi | 4 + arch/arm/mach-omap2/board-generic.c | 2 +- arch/arm/mach-omap2/common.h | 1 + arch/arm/mach-omap2/timer.c | 28 + drivers/clocksource/Makefile | 1 + drivers/clocksource/omap-timer.c | 1157 +++++++++++++++++++++++++++++++++++ drivers/clocksource/omap-timer.h | 422 +++++++++++++ 7 files changed, 1614 insertions(+), 1 deletion(-) create mode 100644 drivers/clocksource/omap-timer.c create mode 100644 drivers/clocksource/omap-timer.h
Signature · 1 line
1.7.9.5
RFC 1/5 ARM: dts: am33xx: Add clock nodes for timer1 and timer2
--- arch/arm/boot/dts/am33xx.dtsi | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/boot/dts/am33xx.dtsi +2 -0
@@ -347,6 +347,7 @@ timer1: timer at 44e31000 { compatible = "ti,am335x-timer-1ms"; + clocks = <&timer1_fck>; reg = <0x44e31000 0x400>; interrupts = <67>; ti,hwmods = "timer1";
@@ -355,6 +356,7 @@ timer2: timer at 48040000 { compatible = "ti,am335x-timer"; + clocks = <&timer2_fck>; reg = <0x48040000 0x400>; interrupts = <68>; ti,hwmods = "timer2";
Signature · 1 line
1.7.9.5
RFC 2/5 ARM: dts: am33xx: Set parent clock for timer through DT
In reply to Joel Fernandes--- arch/arm/boot/dts/am33xx.dtsi | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/boot/dts/am33xx.dtsi +2 -0
@@ -352,6 +352,7 @@ interrupts = <67>; ti,hwmods = "timer1"; ti,timer-alwon; + ti,default-parent = <&sys_clkin_ck>; }; timer2: timer at 48040000 {
@@ -360,6 +361,7 @@ reg = <0x48040000 0x400>; interrupts = <68>; ti,hwmods = "timer2"; + ti,default-parent = <&sys_clkin_ck>; }; timer3: timer at 48042000 {
Signature · 1 line
1.7.9.5
Re: [RFC 2/5] ARM: dts: am33xx: Set parent clock for timer through DT
Quoted 19 lines · Joel Fernandes
Signed-off-by Joel Fernandes <[email protected]>--- arch/arm/boot/dts/am33xx.dtsi | 2 ++ 1 file changed, 2 insertions(+)arch/arm/boot/dts/am33xx.dtsi +1
-0@@ -352,6 +352,7 @@ interrupts = <67>; ti,hwmods = "timer1"; ti,timer-alwon; + ti,default-parent = <&sys_clkin_ck>; }; timer2: timer at 48040000 {
arch/arm/boot/dts/am33xx.dtsi line 367
Quoted 7 lines
arch/arm/boot/dts/am33xx.dtsi +1
-0@@ -360,6 +361,7 @@ reg = <0x48040000 0x400>; interrupts = <68>; ti,hwmods = "timer2"; + ti,default-parent = <&sys_clkin_ck>; }; timer3: timer at 48042000 {
I don't think this works, the ti,default-parent property is only supported for clock nodes (at least I didn't quickly find anything from your clocksource driver that would handle this.) You should do something like this:
&timer1_fck {
ti,default-parent = <&sys_clkin_ck>;
};&timer2_fck {
ti,default-parent = <&sys_clkin_ck>;
};-Tero
RFC 3/5 ARM: OMAP2+: timer: Add clocksource initialization and powerup support
In reply to Joel FernandesIntroduce a generic omap timer initialization function that can be used by all SoCs for which support is available in the clocksource driver introduced in the series.
The function will also be responsible for calling clock initialization required for everything else to work.
--- arch/arm/mach-omap2/common.h | 1 + arch/arm/mach-omap2/timer.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+)
arch/arm/mach-omap2/common.h +1 -0
@@ -92,6 +92,7 @@ extern void omap3_secure_sync32k_timer_init(void);extern void omap3_gptimer_timer_init (void );extern void omap4_local_timer_init (void );extern void omap5_realtime_timer_init (void ); +void omap_generic_timer_init (void );void omap2420_init_early (void );void omap2430_init_early (void );
arch/arm/mach-omap2/timer.c +28 -0
@@ -324,6 +324,25 @@ static int __init omap_dm_timer_init_one(struct omap_dm_timer *timer,return r; } +int __init omap_dmtimer_powerup (struct omap_dm_timer *timer, +struct device_node *np) { +struct omap_hwmod *oh; +const char *oh_name =NULL ; + +of_property_read_string_index (np,"ti,hwmods" ,0 , &oh_name); +if (!oh_name) +return -ENODEV ; + + oh =omap_hwmod_lookup (oh_name); +if (!oh) +return -ENODEV ; + +omap_hwmod_setup_one (oh_name); + +omap_hwmod_enable (oh); +return 0 ; +} +static void __init omap2_gp_clockevent_init (int gptimer_id,const char *fck_source,const char *property)
@@ -615,6 +634,15 @@ static OMAP_SYS_32K_TIMER_INIT(4, 1, "timer_32k_ck", "ti,timer-alwon", 2, "sys_clkin_ck", NULL);#endif +void omap_generic_timer_init (void ) +{ +if (!of_have_populated_dt ()) +BUG_ON ("Generic timer init should only be used for DT boot\n" ); + +omap_clk_init (); +clocksource_of_init (); +} +#ifdef CONFIG_ARCH_OMAP4 #ifdef CONFIG_HAVE_ARM_TWD static DEFINE_TWD_LOCAL_TIMER(twd_local_timer, OMAP44XX_LOCAL_TWD_BASE, 29);
Signature · 1 line
1.7.9.5
Rob Herring
maintainerRe: [RFC 3/5] ARM: OMAP2+: timer: Add clocksource initialization and powerup support
Quoted 30 lines · Joel Fernandes
Introduce a generic omap timer initialization function that can be used by all SoCs for which support is available in the clocksource driver introduced in the series.
The function will also be responsible for calling clock initialization required for everything else to work.
Signed-off-by Joel Fernandes <[email protected]>--- arch/arm/mach-omap2/common.h | 1 + arch/arm/mach-omap2/timer.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+)arch/arm/mach-omap2/common.h +1
-0@@ -92,6 +92,7 @@ extern void omap3_secure_sync32k_timer_init(void);extern void omap3_gptimer_timer_init (void );extern void omap4_local_timer_init (void );extern void omap5_realtime_timer_init (void ); +void omap_generic_timer_init (void );void omap2420_init_early (void );void omap2430_init_early (void );arch/arm/mach-omap2/timer.c +0
-0
arch/arm/mach-omap2/timer.c static int __init omap_dm_timer_init_one(struct omap_dm_timer *timer, · line 328
Quoted 5 lines
arch/arm/mach-omap2/timer.c +2
-0@@ -324,6 +324,25 @@ static int __init omap_dm_timer_init_one(struct omap_dm_timer *timer,return r; } +int __init omap_dmtimer_powerup (struct omap_dm_timer *timer, +struct device_node *np) {
This function seems unrelated to the commit message.
Quoted 21 lines
arch/arm/mach-omap2/timer.c +17
-0+struct omap_hwmod *oh; +const char *oh_name =NULL ; + +of_property_read_string_index (np,"ti,hwmods" ,0 , &oh_name); +if (!oh_name) +return -ENODEV ; + + oh =omap_hwmod_lookup (oh_name); +if (!oh) +return -ENODEV ; + +omap_hwmod_setup_one (oh_name); + +omap_hwmod_enable (oh); +return 0 ; +} +static void __init omap2_gp_clockevent_init (int gptimer_id,const char *fck_source,const char *property)
arch/arm/mach-omap2/timer.c static OMAP_SYS_32K_TIMER_INIT(4, 1, "timer_32k_ck", "ti,timer-alwon", · line 640
Quoted 7 lines
arch/arm/mach-omap2/timer.c +4
-0@@ -615,6 +634,15 @@ static OMAP_SYS_32K_TIMER_INIT(4, 1, "timer_32k_ck", "ti,timer-alwon", 2, "sys_clkin_ck", NULL);#endif +void omap_generic_timer_init (void ) +{ +if (!of_have_populated_dt ()) +BUG_ON ("Generic timer init should only be used for DT boot\n" );
I thought omap2 is always DT boot now.
arch/arm/mach-omap2/timer.c static OMAP_SYS_32K_TIMER_INIT(4, 1, "timer_32k_ck", "ti,timer-alwon", · line 642
Quoted 2 lines
arch/arm/mach-omap2/timer.c +2
-0+ +omap_clk_init ();
Can't you use CLK_OF_DECLARE and remove this? Then you can remove the init_time function hook completely.
Quoted 9 lines
arch/arm/mach-omap2/timer.c +3
-1+clocksource_of_init (); +} +#ifdef CONFIG_ARCH_OMAP4 #ifdef CONFIG_HAVE_ARM_TWD static DEFINE_TWD_LOCAL_TIMER(twd_local_timer, OMAP44XX_LOCAL_TWD_BASE, 29); --1.7.9.5
Re: [RFC 3/5] ARM: OMAP2+: timer: Add clocksource initialization and powerup support
Quoted 34 lines · Rob Herring
Quoted 33 lines · Joel Fernandes
Introduce a generic omap timer initialization function that can be used by all SoCs for which support is available in the clocksource driver introduced in the series.
The function will also be responsible for calling clock initialization required for everything else to work.
Signed-off-by Joel Fernandes <[email protected]>--- arch/arm/mach-omap2/common.h | 1 + arch/arm/mach-omap2/timer.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+)arch/arm/mach-omap2/common.h +1
-0@@ -92,6 +92,7 @@ extern void omap3_secure_sync32k_timer_init(void);extern void omap3_gptimer_timer_init (void );extern void omap4_local_timer_init (void );extern void omap5_realtime_timer_init (void ); +void omap_generic_timer_init (void );void omap2420_init_early (void );void omap2430_init_early (void );arch/arm/mach-omap2/timer.c +0
-0@@ -324,6 +324,25 @@ static int __init omap_dm_timer_init_one(struct omap_dm_timer *timer,return r; }
Quoted 4 lines
arch/arm/mach-omap2/timer.c static int __init omap_dm_timer_init_one(struct omap_dm_timer *timer, · line 328
Quoted 2 lines
arch/arm/mach-omap2/timer.c +2
-0+int __init omap_dmtimer_powerup (struct omap_dm_timer *timer, +struct device_node *np) {This function seems unrelated to the commit message.
Ok, I'll add it in the message.
Quoted 25 lines
Quoted 25 lines
arch/arm/mach-omap2/timer.c +17
-0+struct omap_hwmod *oh; +const char *oh_name =NULL ; + +of_property_read_string_index (np,"ti,hwmods" ,0 , &oh_name); +if (!oh_name) +return -ENODEV ; + + oh =omap_hwmod_lookup (oh_name); +if (!oh) +return -ENODEV ; + +omap_hwmod_setup_one (oh_name); + +omap_hwmod_enable (oh); +return 0 ; +} +static void __init omap2_gp_clockevent_init (int gptimer_id,const char *fck_source,const char *property)@@ -615,6 +634,15 @@ static OMAP_SYS_32K_TIMER_INIT(4, 1, "timer_32k_ck", "ti,timer-alwon", 2, "sys_clkin_ck", NULL);#endif
Quoted 6 lines
arch/arm/mach-omap2/timer.c static OMAP_SYS_32K_TIMER_INIT(4, 1, "timer_32k_ck", "ti,timer-alwon", · line 640
Quoted 4 lines
arch/arm/mach-omap2/timer.c +4
-0+void omap_generic_timer_init (void ) +{ +if (!of_have_populated_dt ()) +BUG_ON ("Generic timer init should only be used for DT boot\n" );I thought omap2 is always DT boot now.
That's right, sorry- I'll get rid of the check.
Quoted 5 lines
arch/arm/mach-omap2/timer.c static OMAP_SYS_32K_TIMER_INIT(4, 1, "timer_32k_ck", "ti,timer-alwon", · line 642
Quoted 2 lines
arch/arm/mach-omap2/timer.c +2
-0+ +omap_clk_init ();Can't you use
CLK_OF_DECLAREand remove this? Then you can remove theinit_timefunction hook completely.
There is some dev-id conn-id -> DT node mapping done. I'll let Tero comment more on this.
Thanks,
-Joel
Quoted 10 lines
Quoted 10 lines
arch/arm/mach-omap2/timer.c +3
-1+clocksource_of_init (); +} +#ifdef CONFIG_ARCH_OMAP4 #ifdef CONFIG_HAVE_ARM_TWD static DEFINE_TWD_LOCAL_TIMER(twd_local_timer, OMAP44XX_LOCAL_TWD_BASE, 29); --1.7.9.5
Re: [RFC 3/5] ARM: OMAP2+: timer: Add clocksource initialization and powerup support
Quoted 76 lines · Joel Fernandes
Quoted 34 lines · Rob Herring
Quoted 33 lines · Joel Fernandes
Introduce a generic omap timer initialization function that can be used by all SoCs for which support is available in the clocksource driver introduced in the series.
The function will also be responsible for calling clock initialization required for everything else to work.
Signed-off-by Joel Fernandes <[email protected]>--- arch/arm/mach-omap2/common.h | 1 + arch/arm/mach-omap2/timer.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+)arch/arm/mach-omap2/common.h +1
-0@@ -92,6 +92,7 @@ extern void omap3_secure_sync32k_timer_init(void);extern void omap3_gptimer_timer_init (void );extern void omap4_local_timer_init (void );extern void omap5_realtime_timer_init (void ); +void omap_generic_timer_init (void );void omap2420_init_early (void );void omap2430_init_early (void );arch/arm/mach-omap2/timer.c +0
-0@@ -324,6 +324,25 @@ static int __init omap_dm_timer_init_one(struct omap_dm_timer *timer,return r; }Quoted 4 lines
arch/arm/mach-omap2/timer.c static int __init omap_dm_timer_init_one(struct omap_dm_timer *timer, · line 328
Quoted 2 lines
arch/arm/mach-omap2/timer.c +2
-0+int __init omap_dmtimer_powerup (struct omap_dm_timer *timer, +struct device_node *np) {This function seems unrelated to the commit message.
Ok, I'll add it in the message.
Quoted 25 lines
Quoted 25 lines
arch/arm/mach-omap2/timer.c +17
-0+struct omap_hwmod *oh; +const char *oh_name =NULL ; + +of_property_read_string_index (np,"ti,hwmods" ,0 , &oh_name); +if (!oh_name) +return -ENODEV ; + + oh =omap_hwmod_lookup (oh_name); +if (!oh) +return -ENODEV ; + +omap_hwmod_setup_one (oh_name); + +omap_hwmod_enable (oh); +return 0 ; +} +static void __init omap2_gp_clockevent_init (int gptimer_id,const char *fck_source,const char *property)@@ -615,6 +634,15 @@ static OMAP_SYS_32K_TIMER_INIT(4, 1, "timer_32k_ck", "ti,timer-alwon", 2, "sys_clkin_ck", NULL);#endif Quoted 6 lines
arch/arm/mach-omap2/timer.c static OMAP_SYS_32K_TIMER_INIT(4, 1, "timer_32k_ck", "ti,timer-alwon", · line 640
Quoted 4 lines
arch/arm/mach-omap2/timer.c +4
-0+void omap_generic_timer_init (void ) +{ +if (!of_have_populated_dt ()) +BUG_ON ("Generic timer init should only be used for DT boot\n" );I thought omap2 is always DT boot now.
That's right, sorry- I'll get rid of the check.
Quoted 8 lines
Quoted 5 lines
arch/arm/mach-omap2/timer.c static OMAP_SYS_32K_TIMER_INIT(4, 1, "timer_32k_ck", "ti,timer-alwon", · line 642
Quoted 2 lines
arch/arm/mach-omap2/timer.c +2
-0+ +omap_clk_init ();Can't you use
CLK_OF_DECLAREand remove this? Then you can remove theinit_timefunction hook completely.There is some dev-id conn-id -> DT node mapping done. I'll let Tero comment more on this.
It is actually more complicated than this, the reason we have omap_clk_init() is the static dependencies between the init order of various components in the system (slab, clocks, hwmod), and also because OMAP clks have pretty much different basic clock init compared to the generic DT clk init (memory mappings done differently etc.).... and, it was impossible to get the generic init modified to support OMAP clk init due to various sources of resistance so here we are. I hope we are able to merge the required stuff from omap_clk_init towards the generic clk init eventually and get rid of OMAP specific stuff.
-Tero
Quoted 15 lines
Thanks,
-JoelQuoted 10 lines
Quoted 10 lines
arch/arm/mach-omap2/timer.c +3
-1+clocksource_of_init (); +} +#ifdef CONFIG_ARCH_OMAP4 #ifdef CONFIG_HAVE_ARM_TWD static DEFINE_TWD_LOCAL_TIMER(twd_local_timer, OMAP44XX_LOCAL_TWD_BASE, 29); --1.7.9.5
Re: [RFC 3/5] ARM: OMAP2+: timer: Add clocksource initialization and powerup support
In reply to Joel FernandesQuoted 67 lines · Joel Fernandes
Quoted 34 lines · Rob Herring
Quoted 33 lines · Joel Fernandes
Introduce a generic omap timer initialization function that can be used by all SoCs for which support is available in the clocksource driver introduced in the series.
The function will also be responsible for calling clock initialization required for everything else to work.
Signed-off-by Joel Fernandes <[email protected]>--- arch/arm/mach-omap2/common.h | 1 + arch/arm/mach-omap2/timer.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+)arch/arm/mach-omap2/common.h +1
-0@@ -92,6 +92,7 @@ extern void omap3_secure_sync32k_timer_init(void);extern void omap3_gptimer_timer_init (void );extern void omap4_local_timer_init (void );extern void omap5_realtime_timer_init (void ); +void omap_generic_timer_init (void );void omap2420_init_early (void );void omap2430_init_early (void );arch/arm/mach-omap2/timer.c +0
-0@@ -324,6 +324,25 @@ static int __init omap_dm_timer_init_one(struct omap_dm_timer *timer,return r; }Quoted 4 lines
arch/arm/mach-omap2/timer.c static int __init omap_dm_timer_init_one(struct omap_dm_timer *timer, · line 328
Quoted 2 lines
arch/arm/mach-omap2/timer.c +2
-0+int __init omap_dmtimer_powerup (struct omap_dm_timer *timer, +struct device_node *np) {This function seems unrelated to the commit message.
Ok, I'll add it in the message.
Quoted 25 lines
Quoted 25 lines
arch/arm/mach-omap2/timer.c +17
-0+struct omap_hwmod *oh; +const char *oh_name =NULL ; + +of_property_read_string_index (np,"ti,hwmods" ,0 , &oh_name); +if (!oh_name) +return -ENODEV ; + + oh =omap_hwmod_lookup (oh_name); +if (!oh) +return -ENODEV ; + +omap_hwmod_setup_one (oh_name); + +omap_hwmod_enable (oh); +return 0 ; +} +static void __init omap2_gp_clockevent_init (int gptimer_id,const char *fck_source,const char *property)@@ -615,6 +634,15 @@ static OMAP_SYS_32K_TIMER_INIT(4, 1, "timer_32k_ck", "ti,timer-alwon", 2, "sys_clkin_ck", NULL);#endif
Quoted 8 lines
Quoted 6 lines
arch/arm/mach-omap2/timer.c static OMAP_SYS_32K_TIMER_INIT(4, 1, "timer_32k_ck", "ti,timer-alwon", · line 640
Quoted 4 lines
arch/arm/mach-omap2/timer.c +4
-0+void omap_generic_timer_init (void ) +{ +if (!of_have_populated_dt ()) +BUG_ON ("Generic timer init should only be used for DT boot\n" );I thought omap2 is always DT boot now.
That's right, sorry- I'll get rid of the check.
Actually, mainline still supports legacy boot and has board files for OMAP3 platforms, and we shouldn't break legacy boot on purpose IMO.
Kevin
Rob Herring
maintainerRe: [RFC 3/5] ARM: OMAP2+: timer: Add clocksource initialization and powerup support
Quoted 12 lines · Kevin Hilman
Quoted 10 lines · Joel Fernandes
Quoted 9 lines · Rob Herring
Quoted 8 lines · Joel Fernandes
Introduce a generic omap timer initialization function that can be used by all SoCs for which support is available in the clocksource driver introduced in the series.
The function will also be responsible for calling clock initialization required for everything else to work.
Signed-off-by Joel Fernandes <[email protected]>
[snip]
Quoted 11 lines
Quoted 8 lines
Quoted 6 lines
arch/arm/mach-omap2/timer.c static OMAP_SYS_32K_TIMER_INIT(4, 1, "timer_32k_ck", "ti,timer-alwon", · line 640
Quoted 4 lines
arch/arm/mach-omap2/timer.c +4
-0+void omap_generic_timer_init (void ) +{ +if (!of_have_populated_dt ()) +BUG_ON ("Generic timer init should only be used for DT boot\n" );I thought omap2 is always DT boot now.
That's right, sorry- I'll get rid of the check.
Actually, mainline still supports legacy boot and has board files for OMAP3 platforms, and we shouldn't break legacy boot on purpose IMO.
It is not breaking anything. You'd have to call this function mistakenly from a legacy machine desc or other non-DT boot path. It's a question of how paranoid you are adding checks. IMHO, the BUG_ON is quite pointless here. You are not likely to progress much further anyway, and you won't see the BUG print because the serial port is not up yet.
Rob
RFC 4/5 clocksource: omap-timer: Introduce clocksource driver for OMAP SoCs
In reply to Joel FernandesWe introduce functions to initialize clocksource and clockevent, use CLOCKSOURCE_OF_DECLARE to declare the clocksource, and handle the clocksource selection on a per-SoC basis (Currently only AM335x is supported). Powering up of the timer will be done with the help of the mach-omap layer function that's introduced earlier in the series.
We make a local copy of dmtimer API for use by clocksource, the original dmtimer API in plat-omap is kept as-is till the migration of all SoCs is completed after which it can't be deleted.
--- drivers/clocksource/Makefile | 1 + drivers/clocksource/omap-timer.c | 1157 ++++++++++++++++++++++++++++++++++++++ drivers/clocksource/omap-timer.h | 422 ++++++++++++++ 3 files changed, 1580 insertions(+) create mode 100644 drivers/clocksource/omap-timer.c create mode 100644 drivers/clocksource/omap-timer.h
drivers/clocksource/Makefile +1 -0
@@ -37,3 +37,4 @@ obj-$(CONFIG_ARM_ARCH_TIMER) += arm_arch_timer.o obj-$(CONFIG_ARM_GLOBAL_TIMER) += arm_global_timer.o obj-$(CONFIG_CLKSRC_METAG_GENERIC) += metag_generic.o obj-$(CONFIG_ARCH_HAS_TICK_BROADCAST) += dummy_timer.o +obj-y += omap-timer.o
drivers/clocksource/omap-timer.c new file +1157 -0
1,157 lines not on this page · raw message
drivers/clocksource/omap-timer.h new file +422 -0
422 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Tony Lindgren
maintainerRe: [RFC 4/5] clocksource: omap-timer: Introduce clocksource driver for OMAP SoCs
Quoted 10 lines · Joel Fernandes
We introduce functions to initialize clocksource and clockevent, use
CLOCKSOURCE_OF_DECLAREto declare the clocksource, and handle the clocksource selection on a per-SoC basis (Currently only AM335x is supported). Powering up of the timer will be done with the help of the mach-omap layer function that's introduced earlier in the series.We make a local copy of dmtimer API for use by clocksource, the original dmtimer API in plat-omap is kept as-is till the migration of all SoCs is completed after which it can't be deleted.
Quoted 8 lines
Signed-off-by Joel Fernandes <[email protected]>--- drivers/clocksource/Makefile | 1 + drivers/clocksource/omap-timer.c | 1157 ++++++++++++++++++++++++++++++++++++++ drivers/clocksource/omap-timer.h | 422 ++++++++++++++ 3 files changed, 1580 insertions(+) create mode 100644 drivers/clocksource/omap-timer.c create mode 100644 drivers/clocksource/omap-timer.h
Hmm this leaves duplicate arch/arm/plat-omap/dmtimer.c code, please sort out that issue too by allowing omap1 and omap3 still to use the legacy timer init functions but with timer code under drivers/clocksource/omap-timer.c.
And not the that drivers/clocksource/omap-timer.h won't be needed at all, those defines can stay private to the drivers/clocksource/omap-timer.c.
So this patch really should just be moving of the code to the new location.
Regards,
Tony
Re: [RFC 4/5] clocksource: omap-timer: Introduce clocksource driver for OMAP SoCs
Quoted 20 lines · Tony Lindgren
Quoted 10 lines · Joel Fernandes
We introduce functions to initialize clocksource and clockevent, use
CLOCKSOURCE_OF_DECLAREto declare the clocksource, and handle the clocksource selection on a per-SoC basis (Currently only AM335x is supported). Powering up of the timer will be done with the help of the mach-omap layer function that's introduced earlier in the series.We make a local copy of dmtimer API for use by clocksource, the original dmtimer API in plat-omap is kept as-is till the migration of all SoCs is completed after which it can't be deleted.
Quoted 8 lines
Signed-off-by Joel Fernandes <[email protected]>--- drivers/clocksource/Makefile | 1 + drivers/clocksource/omap-timer.c | 1157 ++++++++++++++++++++++++++++++++++++++ drivers/clocksource/omap-timer.h | 422 ++++++++++++++ 3 files changed, 1580 insertions(+) create mode 100644 drivers/clocksource/omap-timer.c create mode 100644 drivers/clocksource/omap-timer.h
Quoted 1 line
Hmm this leaves duplicate
arch/arm/plat-omap/dmtimer.ccode, please
Sure, ofcourse- but how else can we make sure everything works while we do the migration in steps. We can get rid of the duplicate once everything is migrated.
Quoted 3 lines
sort out that issue too by allowing omap1 and omap3 still to use the legacy timer init functions but with timer code under
drivers/clocksource/omap-timer.c.
Sorry, I didn't follow. I didn't see OMAP3 using legacy timer stuff. To me it looks like OMAP3 migration should be straight forward along the same lines as this RFC patchset. Could you elaborate a bit more what the legacy functions you mentioned for OMAP1 are? I will just like to keep everything in drivers/clocksource/ private for now till we're done migrating most platforms. IMO once we get system timers working for omap2+, then we can look into omap1 :)
Quoted 2 lines
And not the that
drivers/clocksource/omap-timer.hwon't be needed at all, those defines can stay private to thedrivers/clocksource/omap-timer.c.
Actually- I wanted it separate because omap-timer.c is already huge at 1157 lines. Infact the largest among the clocksource drivers. Is that fair?
Quoted 2 lines
So this patch really should just be moving of the code to the new location.
To be honest, its not just a simple moving of code, there are new things such as selecting correct timer, new functions for clockevent and clocksource init, different handling of clocks etc.
Thanks,
-Joel
Tony Lindgren
maintainerRe: [RFC 4/5] clocksource: omap-timer: Introduce clocksource driver for OMAP SoCs
Quoted 21 lines · Joel Fernandes
Quoted 20 lines · Tony Lindgren
Quoted 18 lines · Joel Fernandes
We introduce functions to initialize clocksource and clockevent, use
CLOCKSOURCE_OF_DECLAREto declare the clocksource, and handle the clocksource selection on a per-SoC basis (Currently only AM335x is supported). Powering up of the timer will be done with the help of the mach-omap layer function that's introduced earlier in the series.We make a local copy of dmtimer API for use by clocksource, the original dmtimer API in plat-omap is kept as-is till the migration of all SoCs is completed after which it can't be deleted.
Signed-off-by Joel Fernandes <[email protected]>--- drivers/clocksource/Makefile | 1 + drivers/clocksource/omap-timer.c | 1157 ++++++++++++++++++++++++++++++++++++++ drivers/clocksource/omap-timer.h | 422 ++++++++++++++ 3 files changed, 1580 insertions(+) create mode 100644 drivers/clocksource/omap-timer.c create mode 100644 drivers/clocksource/omap-timer.h
Quoted 5 lines
Quoted 1 line
Hmm this leaves duplicate
arch/arm/plat-omap/dmtimer.ccode, pleaseSure, ofcourse- but how else can we make sure everything works while we do the migration in steps. We can get rid of the duplicate once everything is migrated.
That's not doing incremental changes then. You're not even modifying the existing omap_dm_timer functions, so please do the changes in incremental steps where things keep working throughout the series.
Quoted 11 lines
Quoted 3 lines
sort out that issue too by allowing omap1 and omap3 still to use the legacy timer init functions but with timer code under
drivers/clocksource/omap-timer.c.Sorry, I didn't follow. I didn't see OMAP3 using legacy timer stuff. To me it looks like OMAP3 migration should be straight forward along the same lines as this RFC patchset. Could you elaborate a bit more what the legacy functions you mentioned for OMAP1 are? I will just like to keep everything in
drivers/clocksource/private for now till we're done migrating most platforms. IMO once we get system timers working for omap2+, then we can look into omap1 :)
Well omap3 is still also booting in legacy mode too.
Quoted 5 lines
Quoted 2 lines
And not the that
drivers/clocksource/omap-timer.hwon't be needed at all, those defines can stay private to thedrivers/clocksource/omap-timer.c.Actually- I wanted it separate because
omap-timer.cis already huge at 1157 lines. Infact the largest among the clocksource drivers. Is that fair?
No need for it. We want to keep these functions private to the driver.
Quoted 6 lines
Quoted 2 lines
So this patch really should just be moving of the code to the new location.
To be honest, its not just a simple moving of code, there are new things such as selecting correct timer, new functions for clockevent and clocksource init, different handling of clocks etc.
Those changes should then be separate patches to prepare things so people can see what changes in arch/arm/plat-omap/dmtimer.c code.
Regards,
Tony
Re: [RFC 4/5] clocksource: omap-timer: Introduce clocksource driver for OMAP SoCs
Quoted 24 lines · Tony Lindgren
Quoted 23 lines · Joel Fernandes
Quoted 21 lines · Tony Lindgren
Quoted 10 lines · Joel Fernandes
We introduce functions to initialize clocksource and clockevent, use
CLOCKSOURCE_OF_DECLAREto declare the clocksource, and handle the clocksource selection on a per-SoC basis (Currently only AM335x is supported). Powering up of the timer will be done with the help of the mach-omap layer function that's introduced earlier in the series.We make a local copy of dmtimer API for use by clocksource, the original dmtimer API in plat-omap is kept as-is till the migration of all SoCs is completed after which it can't be deleted.
Quoted 8 lines
Signed-off-by Joel Fernandes <[email protected]>--- drivers/clocksource/Makefile | 1 + drivers/clocksource/omap-timer.c | 1157 ++++++++++++++++++++++++++++++++++++++ drivers/clocksource/omap-timer.h | 422 ++++++++++++++ 3 files changed, 1580 insertions(+) create mode 100644 drivers/clocksource/omap-timer.c create mode 100644 drivers/clocksource/omap-timer.hHmm this leaves duplicate
arch/arm/plat-omap/dmtimer.ccode, please
Quoted 7 lines
Quoted 3 lines
Sure, ofcourse- but how else can we make sure everything works while we do the migration in steps. We can get rid of the duplicate once everything is migrated.
That's not doing incremental changes then. You're not even modifying the existing
omap_dm_timerfunctions, so please do the changes in incremental steps where things keep working throughout the series.
That is much more work than appears- it is much easier to remove what you don't want after everything is moved, than to pick things up part by part and move it.. That way we also don't accidentally remove something we shouldn't be and introduced more regressions.. right?
Plus this is an RFC that I whipped up in 2 days so I didn't this expectations should be too high ;-)
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
And not the that
drivers/clocksource/omap-timer.hwon't be needed at all, those defines can stay private to thedrivers/clocksource/omap-timer.c.Actually- I wanted it separate because
omap-timer.cis already huge at 1157 lines. Infact the largest among the clocksource drivers. Is that fair?No need for it. We want to keep these functions private to the driver.
Ok, I can do that. I don't mind either way.
Thanks,
-Joel
Re: [RFC 4/5] clocksource: omap-timer: Introduce clocksource driver for OMAP SoCs
Quoted 33 lines · Joel Fernandes
Quoted 24 lines · Tony Lindgren
Quoted 23 lines · Joel Fernandes
Quoted 21 lines · Tony Lindgren
Quoted 10 lines · Joel Fernandes
We introduce functions to initialize clocksource and clockevent, use
CLOCKSOURCE_OF_DECLAREto declare the clocksource, and handle the clocksource selection on a per-SoC basis (Currently only AM335x is supported). Powering up of the timer will be done with the help of the mach-omap layer function that's introduced earlier in the series.We make a local copy of dmtimer API for use by clocksource, the original dmtimer API in plat-omap is kept as-is till the migration of all SoCs is completed after which it can't be deleted.
Quoted 8 lines
Signed-off-by Joel Fernandes <[email protected]>--- drivers/clocksource/Makefile | 1 + drivers/clocksource/omap-timer.c | 1157 ++++++++++++++++++++++++++++++++++++++ drivers/clocksource/omap-timer.h | 422 ++++++++++++++ 3 files changed, 1580 insertions(+) create mode 100644 drivers/clocksource/omap-timer.c create mode 100644 drivers/clocksource/omap-timer.hHmm this leaves duplicate
arch/arm/plat-omap/dmtimer.ccode, pleaseQuoted 7 lines
Quoted 3 lines
Sure, ofcourse- but how else can we make sure everything works while we do the migration in steps. We can get rid of the duplicate once everything is migrated.
That's not doing incremental changes then. You're not even modifying the existing
omap_dm_timerfunctions, so please do the changes in incremental steps where things keep working throughout the series.
Quoted 7 lines
That is much more work than appears- it is much easier to remove what you don't want after everything is moved, than to pick things up part by part and move it.. That way we also don't accidentally remove something we shouldn't be and introduced more regressions.. right?
Plus this is an RFC that I whipped up in 2 days so I didn't this expectations should be too high ;-)
s/this/think/
Re: [RFC 4/5] clocksource: omap-timer: Introduce clocksource driver for OMAP SoCs
In reply to Joel FernandesHi Joel,
Quoted 103 lines · Joel Fernandes
We introduce functions to initialize clocksource and clockevent, use
CLOCKSOURCE_OF_DECLAREto declare the clocksource, and handle the clocksource selection on a per-SoC basis (Currently only AM335x is supported). Powering up of the timer will be done with the help of the mach-omap layer function that's introduced earlier in the series.We make a local copy of dmtimer API for use by clocksource, the original dmtimer API in plat-omap is kept as-is till the migration of all SoCs is completed after which it can't be deleted.
Signed-off-by Joel Fernandes <[email protected]>--- drivers/clocksource/Makefile | 1 + drivers/clocksource/omap-timer.c | 1157 ++++++++++++++++++++++++++++++++++++++ drivers/clocksource/omap-timer.h | 422 ++++++++++++++ 3 files changed, 1580 insertions(+)create mode 100644
drivers/clocksource/omap-timer.ccreate mode 100644drivers/clocksource/omap-timer.hdrivers/clocksource/Makefile +1
-0@@ -37,3 +37,4 @@ obj-$(CONFIG_ARM_ARCH_TIMER) += arm_arch_timer.o obj-$(CONFIG_ARM_GLOBAL_TIMER) += arm_global_timer.o obj-$(CONFIG_CLKSRC_METAG_GENERIC) += metag_generic.o obj-$(CONFIG_ARCH_HAS_TICK_BROADCAST) += dummy_timer.o +obj-y += omap-timer.odrivers/clocksource/omap-timer.c new file +69
-0@@ -0,0 +1,1157 @@ +/* +* drivers/clocksource/omap-timer.c +* +* OMAP Dual-Mode Timers +* +* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ +* Joel Fernandes <[email protected]> +* Tarun Kanti DebBarma <[email protected]> +* Thara Gopinath <[email protected]> +* +* dmtimer adaptation to platform_driver. +* +* Copyright (C) 2005 Nokia Corporation +* OMAP2 support by Juha Yrjola +* API improvements and OMAP2 clock framework support by Timo Teras +* +* Copyright (C) 2014 Texas Instruments +* Added OMAP4 support - Santosh Shilimkar <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or (at your +* option) any later version. +* +* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED +* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN +* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* You should have received a copy of the GNU General Public License along +* with this program; if not, write to the Free Software Foundation, Inc., +* 675 Mass Ave, Cambridge, MA 02139, USA. +*/ +#include <linux/init.h> +#include <linux/time.h> +#include <linux/interrupt.h> +#include <linux/err.h> +#include <linux/clk.h> +#include <linux/delay.h> +#include <linux/irq.h> +#include <linux/clocksource.h> +#include <linux/clockchips.h> +#include <linux/slab.h> +#include <linux/sched_clock.h> + +#include <linux/clk.h> +#include <linux/module.h> +#include <linux/io.h> +#include <linux/device.h> +#include <linux/err.h> +#include <linux/pm_runtime.h> +#include <linux/of.h> +#include <linux/of_irq.h> +#include <linux/of_address.h> + +#include <linux/of_device.h> +#include <linux/platform_device.h> +#include <linux/platform_data/dmtimer-omap.h> +#include "omap-timer.h" +/* +* TODO: OMAP1 support removed due to need for header mach/hardware.h +* OMAP2 support may be broken due to lack of cpu_is stuff, see omap_dm_timer_get_errata +*/ + +/**
drivers/clocksource/omap-timer.c line 79
Quoted 10 lines
drivers/clocksource/omap-timer.c new file +10
-0+* omap_dm_timer_get_errata - get errata flags for a timer +* +* Get the timer errata flags that are specific to the OMAP device being used. +*/ +static u32 __init omap_dm_timer_get_errata (void ) +{ +/* ifdef'd out due to lack of availaibility of soc.h */ +#if 0 +if (cpu_is_omap24xx ()) +return 0 ;
You should be able to fix this using some compatible checks.
regards
Suman
drivers/clocksource/omap-timer.c line 84
Quoted 5 lines
drivers/clocksource/omap-timer.c new file +5
-0+#endif +return OMAP_TIMER_ERRATA_I103_I767 ; +} + +
-snip-
Re: [RFC 4/5] clocksource: omap-timer: Introduce clocksource driver for OMAP SoCs
Quoted 117 lines · Suman Anna
Hi Joel,
Quoted 114 lines · Joel Fernandes
We introduce functions to initialize clocksource and clockevent, use
CLOCKSOURCE_OF_DECLAREto declare the clocksource, and handle the clocksource
selection on a per-SoC basis (Currently only AM335x is supported). Powering up
of the timer will be done with the help of the mach-omap layer function that's
introduced earlier in the series.We make a local copy of dmtimer API for use by clocksource, the original dmtimer API in plat-omap is kept as-is till the migration of all SoCs is completed after which it can't be deleted.
Signed-off-by Joel Fernandes <[email protected]>--- drivers/clocksource/Makefile | 1 + drivers/clocksource/omap-timer.c | 1157 ++++++++++++++++++++++++++++++++++++++ drivers/clocksource/omap-timer.h | 422 ++++++++++++++ 3 files changed, 1580 insertions(+)create mode 100644
drivers/clocksource/omap-timer.ccreate mode 100644drivers/clocksource/omap-timer.hdrivers/clocksource/Makefile +1
-0@@ -37,3 +37,4 @@ obj-$(CONFIG_ARM_ARCH_TIMER) += arm_arch_timer.o obj-$(CONFIG_ARM_GLOBAL_TIMER) += arm_global_timer.o obj-$(CONFIG_CLKSRC_METAG_GENERIC) += metag_generic.o obj-$(CONFIG_ARCH_HAS_TICK_BROADCAST) += dummy_timer.o +obj-y += omap-timer.odrivers/clocksource/omap-timer.c new file +66
-0@@ -0,0 +1,1157 @@ +/* +* drivers/clocksource/omap-timer.c +* +* OMAP Dual-Mode Timers +* +* Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ +* Joel Fernandes <[email protected]> +* Tarun Kanti DebBarma <[email protected]> +* Thara Gopinath <[email protected]> +* +* dmtimer adaptation to platform_driver. +* +* Copyright (C) 2005 Nokia Corporation +* OMAP2 support by Juha Yrjola +* API improvements and OMAP2 clock framework support by Timo Teras +* +* Copyright (C) 2014 Texas Instruments +* Added OMAP4 support - Santosh Shilimkar <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or (at your +* option) any later version. +* +* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED +* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN +* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* You should have received a copy of the GNU General Public License along +* with this program; if not, write to the Free Software Foundation, Inc., +* 675 Mass Ave, Cambridge, MA 02139, USA. +*/ +#include <linux/init.h> +#include <linux/time.h> +#include <linux/interrupt.h> +#include <linux/err.h> +#include <linux/clk.h> +#include <linux/delay.h> +#include <linux/irq.h> +#include <linux/clocksource.h> +#include <linux/clockchips.h> +#include <linux/slab.h> +#include <linux/sched_clock.h> + +#include <linux/clk.h> +#include <linux/module.h> +#include <linux/io.h> +#include <linux/device.h> +#include <linux/err.h> +#include <linux/pm_runtime.h> +#include <linux/of.h> +#include <linux/of_irq.h> +#include <linux/of_address.h> + +#include <linux/of_device.h> +#include <linux/platform_device.h> +#include <linux/platform_data/dmtimer-omap.h> +#include "omap-timer.h" +/* +* TODO: OMAP1 support removed due to need for header mach/hardware.h +* OMAP2 support may be broken due to lack of cpu_is stuff, see
omap_dm_timer_get_errata
+ */drivers/clocksource/omap-timer.c new file +5
-0+ +/** +* omap_dm_timer_get_errata - get errata flags for a timer +* +* Get the timer errata flags that are specific to the OMAP device being used.
+ */
Quoted 8 lines
drivers/clocksource/omap-timer.c line 79
Quoted 6 lines
drivers/clocksource/omap-timer.c new file +6
-0+static u32 __init omap_dm_timer_get_errata (void ) +{ +/* ifdef'd out due to lack of availaibility of soc.h */ +#if 0 +if (cpu_is_omap24xx ()) +return 0 ;You should be able to fix this using some compatible checks.
Thanks. I'll use of_device_is_compatible to check for that.
-Joel
RFC 5/5 ARM: AM33xx: Move to using omap_generic_timer_init for init_time
In reply to Joel FernandesEarlier patch in this series introduced a function omap_generic_timer_init for all DT platforms. Use it for AM33xx SoC.
--- arch/arm/mach-omap2/board-generic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-omap2/board-generic.c +1 -1
@@ -166,7 +166,7 @@ DT_MACHINE_START(AM33XX_DT, "Generic AM33XX (Flattened Device Tree)") .handle_irq = omap3_intc_handle_irq, .init_machine = omap_generic_init, .init_late = am33xx_init_late, - .init_time = omap3_gptimer_timer_init, + .init_time = omap_generic_timer_init, .dt_compat = am33xx_boards_compat, .restart = am33xx_restart,MACHINE_END
Signature · 1 line
1.7.9.5