From e4be0ceecf6e71f9f454838844b84406368407bb Mon Sep 17 00:00:00 2001 From: Kees Jongenburger Date: Tue, 27 Aug 2013 14:23:34 +0200 Subject: [PATCH] arm:timer changes. * Allow to change the timer frequency using the hz paramter. * Unmask the interrupt only after registering the handler. * Pass the hz parameter in the command line. --- kernel/arch/earm/omap_timer.c | 9 ++++++--- releasetools/gen_cmdline.txt.sh | 7 ++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/kernel/arch/earm/omap_timer.c b/kernel/arch/earm/omap_timer.c index 748635368..065674132 100644 --- a/kernel/arch/earm/omap_timer.c +++ b/kernel/arch/earm/omap_timer.c @@ -138,6 +138,8 @@ int omap3_register_timer_handler(const irq_handler_t handler) omap3_timer_hook.irq = timer.irq_nr; put_irq_handler(&omap3_timer_hook, timer.irq_nr, handler); + /* only unmask interrupts after registering */ + omap3_irq_unmask(timer.irq_nr); return 0; } @@ -211,6 +213,7 @@ void omap3_frclock_stop() void omap3_timer_init(unsigned freq) { + /* we only support 1ms resolution */ u32_t tisr; kern_phys_map_ptr(timer.base,ARM_PAGE_SIZE, &timer_phys_map, (vir_bytes) &timer.base); @@ -239,15 +242,15 @@ void omap3_timer_init(unsigned freq) /* Use 1-ms tick mode for GPTIMER1 TRM 16.2.4.2.1 */ mmio_write(timer.base + timer.regs->TPIR, 232000); mmio_write(timer.base + timer.regs->TNIR, -768000); - mmio_write(timer.base + timer.regs->TLDR, 0xffffffe0); - mmio_write(timer.base + timer.regs->TCRR, 0xffffffe0); + mmio_write(timer.base + timer.regs->TLDR, 0xffffffff - (32768 / freq) +1); + mmio_write(timer.base + timer.regs->TCRR, 0xffffffff - (32768 / freq) +1); + /* Set up overflow interrupt */ tisr = OMAP3_TISR_MAT_IT_FLAG | OMAP3_TISR_OVF_IT_FLAG | OMAP3_TISR_TCAR_IT_FLAG; mmio_write(timer.base + timer.regs->TISR, tisr); /* Clear interrupt status */ mmio_write(timer.base + timer.regs->TIER, OMAP3_TIER_OVF_IT_ENA); - omap3_irq_unmask(timer.irq_nr); /* Start timer */ mmio_set(timer.base + timer.regs->TCLR, diff --git a/releasetools/gen_cmdline.txt.sh b/releasetools/gen_cmdline.txt.sh index f258c2411..31c3c215d 100755 --- a/releasetools/gen_cmdline.txt.sh +++ b/releasetools/gen_cmdline.txt.sh @@ -3,6 +3,7 @@ CONSOLE=tty02 #verbosity VERBOSE=3 +HZ=1000 while getopts "c:v:?" c do case "$c" in @@ -18,8 +19,12 @@ do # genrate netbooting uEnv.txt VERBOSE=$OPTARG ;; + h) + # system hz + HZ=$OPTARG + ;; esac done -echo console=$CONSOLE rootdevname=c0d0p1s0 verbose=$VERBOSE +echo console=$CONSOLE rootdevname=c0d0p1s0 verbose=$VERBOSE hz=$HZ -- 2.44.0