Add support for hr timer
Subsystems (3)
PATCH 1/1 Add support for hr timer
From: aditya <[email protected]>
This patch add support for the S3C64XX hr timer (tick timer and sched timer).
--- arch/arm/plat-s3c/Kconfig | 18 ++ arch/arm/plat-s3c/Makefile | 10 + arch/arm/plat-s3c/hr-time.c | 305 +++++++++++++++++++++++++++ arch/arm/plat-s3c/include/plat/regs-timer.h | 11 + 4 files changed, 344 insertions(+), 0 deletions(-) create mode 100644 arch/arm/plat-s3c/hr-time.c
arch/arm/plat-s3c/Kconfig +18 -0
@@ -203,4 +203,22 @@ config S3C_DEV_NAND help Compile in platform device definition for NAND controller +#option for OS tick timer (fixed/dynamic) + +choice + prompt "OS Timer support" + depends on PLAT_S3C64XX + default DYNAMIC_TIMER + +config FIXED_TIMER + bool "Fixed Tick timer" + +config DYNAMIC_TIMER + bool "Tickless and HR Timer" + select GENERIC_TIME + select GENERIC_CLOCKEVENTS + +endchoice + + endif
arch/arm/plat-s3c/Makefile +10 -0
@@ -12,7 +12,17 @@ obj- := # Core support for all Samsung SoCs obj-y += init.o +ifdef CONFIG_NO_HZ +obj-y += hr-time.o +else + +ifndef CONFIG_HIGH_RES_TIMERS obj-y += time.o +else +obj-y += hr-time.o +endif + +endif obj-y += clock.o obj-y += pwm-clock.o obj-y += gpio.o
arch/arm/plat-s3c/hr-time.c new file +305 -0
305 lines not on this page · raw message
arch/arm/plat-s3c/include/plat/regs-timer.h +11 -0
@@ -117,6 +117,17 @@#define S3C2410_TCON_T0INVERT (1<<2)#define S3C2410_TCON_T0MANUALUPD (1<<1)#define S3C2410_TCON_T0START (1<<0) +/* Interrupt Control and Status register*/ +#define S3C_TINT_CSTAT_T4INT (1<<9) +#define S3C_TINT_CSTAT_T3INT (1<<8) +#define S3C_TINT_CSTAT_T2INT (1<<7) +#define S3C_TINT_CSTAT_T1INT (1<<6) +#define S3C_TINT_CSTAT_T0INT (1<<5) +#define S3C_TINT_CSTAT_T4INTEN (1<<4) +#define S3C_TINT_CSTAT_T3INTEN (1<<3) +#define S3C_TINT_CSTAT_T2INTEN (1<<2) +#define S3C_TINT_CSTAT_T1INTEN (1<<1) +#define S3C_TINT_CSTAT_T0INTEN (1<<0)#endif /* __ASM_ARCH_REGS_TIMER_H */
Signature · 1 line
1.6.2.5
Hi Aditya,
thanks for your [first] patch :)
arch/arm/plat-s3c/Kconfig config S3C_DEV_NAND · line 219
Quoted 13 lines · On Fri, Nov 06, 2009 at 09:45:45AM +0900, [email protected] wrote:
arch/arm/plat-s3c/Kconfig +13
-0+ +choice + prompt "OS Timer support" + depends on PLAT_S3C64XX + default DYNAMIC_TIMER + +config FIXED_TIMER + bool "Fixed Tick timer" + +config DYNAMIC_TIMER + bool "Tickless and HR Timer" + select GENERIC_TIME + select GENERIC_CLOCKEVENTS
I think those should probably be prefixed with S3C_ as the Kconfig namespace is global. Like with symbol names, we should not use generic names unless we are implementing generic code.
arch/arm/plat-s3c/Makefile obj- := · line 23
Quoted 10 lines
obj-y += init.o
arch/arm/plat-s3c/Makefile +8
-0+ifdef CONFIG_NO_HZ +obj-y += hr-time.o +else + +ifndef CONFIG_HIGH_RES_TIMERS obj-y += time.o +else +obj-y += hr-time.o +endif
Mh. This means the actual timer code depends only on CONFIG_NO_HZ and CONFIG_HIGH_RES_TIMERS.
The two Kconfig choices FIXED_TIMER and DYNAMIC_TIMER are not really used anywhere.
At last to me, it is unclear how this all works together. I think the choices are either
1) you build the timer code solely on core kernel configuration options like GENERIC_TIME, GENERIC_CLOCKEVENTS, HIGH_RES_TIMERS, NO_HZ or the like
or
2) you have a private (s3c-specific) Kconfig option to select it. In this case, dependent options need to be selected (like you do). But then, the Makefile should still reflect the s3c-specific Kconfig.
Mixing both does not really seem to make sense to me.
So as I can see, there are the three following possible cases:
a) the regular/old timer code is used. No high-res and no tickless.
b) the high-resolution timer is used but not tickless (NO_HZ not set)
c) the high-resolution timer are used tickless.
If you configure+build yoru code, each of those three options has to work as expected.
arch/arm/plat-s3c/hr-time.c line 183
Quoted 7 lines
arch/arm/plat-s3c/hr-time.c new file +7
-0+static struct clock_event_device clockevent_tick_timer = { + .name ="pwm_timer4" , + .features =CLOCK_EVT_FEAT_PERIODIC |CLOCK_EVT_FEAT_ONESHOT , + .shift =32 , + .set_next_event = s3c64xx_tick_set_next_event, + .set_mode = s3c64xx_tick_set_mode, +};
if you give this static variable a shorter name, (like clkevt_tick_tmr or even only tick_timer), then you can probably avoid some line wraps further down the code:
arch/arm/plat-s3c/hr-time.c line 206
Quoted 6 lines
arch/arm/plat-s3c/hr-time.c new file +6
-0+ clockevent_tick_timer.mult =div_sc (rate,NSEC_PER_SEC , + clockevent_tick_timer.shift); + clockevent_tick_timer.max_delta_ns = +clockevent_delta2ns (-1 , &clockevent_tick_timer); + clockevent_tick_timer.min_delta_ns = +clockevent_delta2ns (1 , &clockevent_tick_timer);
Also, we typically don't define a static string and then printk'
arch/arm/plat-s3c/hr-time.c line 256
Quoted 3 lines
arch/arm/plat-s3c/hr-time.c new file +3
-0+static char err[]__initdata =KERN_ERR +"%s: can't register clocksource!\n" ; +printk (err, clocksource_s3c64xx.name);
why not simply
printk(KERN_ERR "%s: can't register clocksource\n", clocksource_s3c64xx.name);
Review
Quoted 2 lines
(quoted diff) +2
-0+ if (IS_ERR(ck_ref)) + panic("failed to get clock for system timer");
here we panic. Is this failure really more severe than the failure above where we simply printk(KERN_ERR) ?
Yes, I think if we can't get the clocks for the system timer, then we should panic since the kernel will not be able to function. But is failing the clocksource registration any less severe? (this is a real question, you probably know better than I do)
Regards,
Harald
Signature · 4 lines
- Harald Welte <[email protected]> http://laforge.gnumonks.org/ ============================================================================ "Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6)
Hi Harald,
Quoted 37 lines · Harald Welte
Hi Aditya,
thanks for your [first] patch :)
arch/arm/plat-s3c/Kconfig config S3C_DEV_NAND · line 219
Quoted 13 lines · On Fri, Nov 06, 2009 at 09:45:45AM +0900, [email protected] wrote:
arch/arm/plat-s3c/Kconfig +13
-0+ +choice + prompt "OS Timer support" + depends on PLAT_S3C64XX + default DYNAMIC_TIMER + +config FIXED_TIMER + bool "Fixed Tick timer" + +config DYNAMIC_TIMER + bool "Tickless and HR Timer" + select GENERIC_TIME + select GENERIC_CLOCKEVENTSI think those should probably be prefixed with
S3C_as theKconfignamespace is global. Like with symbol names, we should not use generic names unless we are implementing generic code.arch/arm/plat-s3c/Makefile obj- := · line 23
Quoted 10 lines
obj-y += init.o
arch/arm/plat-s3c/Makefile +5
-0+ifdef CONFIG_NO_HZ +obj-y += hr-time.o +else + +ifndef CONFIG_HIGH_RES_TIMERSobj-y += time.o
arch/arm/plat-s3c/Makefile +3
-0+else +obj-y += hr-time.o +endifMh. This means the actual timer code depends only on
CONFIG_NO_HZandCONFIG_HIGH_RES_TIMERS.
Quoted 9 lines
The two
KconfigchoicesFIXED_TIMERandDYNAMIC_TIMERare not really used anywhere.At last to me, it is unclear how this all works together. I think the choices are either
1) you build the timer code solely on core kernel configuration options like
GENERIC_TIME,GENERIC_CLOCKEVENTS,HIGH_RES_TIMERS,NO_HZor the like
Yes, selected the GENERIC_TIME, GENERIC_CLOCKEVENTS during machine configuration.
Quoted 40 lines
or
2) you have a private (s3c-specific)
Kconfigoption to select it. In this case, dependent options need to be selected (like you do). But then, theMakefileshould still reflect the s3c-specificKconfig.Mixing both does not really seem to make sense to me.
So as I can see, there are the three following possible cases:
a) the regular/old timer code is used. No high-res and no tickless.
b) the high-resolution timer is used but not tickless (
NO_HZnot set)c) the high-resolution timer are used tickless.
If you configure+build yoru code, each of those three options has to work as expected.
arch/arm/plat-s3c/hr-time.c line 183
Quoted 7 lines
arch/arm/plat-s3c/hr-time.c new file +7
-0+static struct clock_event_device clockevent_tick_timer = { + .name = "pwm_timer4", + .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT, + .shift = 32, + .set_next_event = s3c64xx_tick_set_next_event, + .set_mode = s3c64xx_tick_set_mode, +};if you give this static variable a shorter name, (like
clkevt_tick_tmror even onlytick_timer), then you can probably avoid some line wraps further down the code:Quoted 6 lines
+ clockevent_tick_timer.mult = div_sc(rate,
NSEC_PER_SEC,
+ clockevent_tick_timer.shift);
+ clockevent_tick_timer.max_delta_ns =
+clockevent_delta2ns(-1, &clockevent_tick_timer);
+ clockevent_tick_timer.min_delta_ns =
+clockevent_delta2ns(1, &clockevent_tick_timer);Also, we typically don't define a static string and then printk'
Quoted 8 lines
Quoted 3 lines
+ static char err[]
__initdata=KERN_ERR
+ "%s: can't register clocksource!\n";
+printk(err, clocksource_s3c64xx.name);why not simply
printk(KERN_ERR "%s: can't register clocksource\n", clocksource_s3c64xx.name);
i have made these changes in the new patch.
Quoted 23 lines
Quoted 2 lines
+ if (
IS_ERR(ck_ref))
+panic("failed to get clock for system timer");here we panic. Is this failure really more severe than the failure above where we simply
printk(KERN_ERR)?Yes, I think if we can't get the clocks for the system timer, then we should panic since the kernel will not be able to function. But is failing the clocksource registration any less severe? (this is a real question, you probably know better than I do)
Regards,
Harald
--
- Harald Welte <[email protected]> http://laforge.gnumonks.org/
============================================================================
"Privacy in residential applications is a desirable marketing option." (ETSI EN 300 175-7 Ch. A6) --
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Thanks and best regards Aditya