From: John Hodge (sonata) Date: Wed, 8 May 2013 06:55:46 +0000 (+0800) Subject: Kernel/armv7 - Extra code for Tegra2 timer tests X-Git-Tag: rel0.15~484^2~4 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=9a135546ed260546b4903424232faf1a3c3a8be5;p=tpg%2Facess2.git Kernel/armv7 - Extra code for Tegra2 timer tests --- diff --git a/KernelLand/Kernel/arch/armv7/platform_tegra2.c b/KernelLand/Kernel/arch/armv7/platform_tegra2.c index 0ec90f30..21ff862f 100644 --- a/KernelLand/Kernel/arch/armv7/platform_tegra2.c +++ b/KernelLand/Kernel/arch/armv7/platform_tegra2.c @@ -45,12 +45,40 @@ void Timer_IRQHandler_SysClock(int IRQ, void *_unused) gpTimersMap->TMR1.PCR_0 = (1<<30); } +void Timer_IRQHandler_Timer2(int IRQ, void *_unused) +{ + Log_Debug("Tegra2Tme", "Timer 2"); +} +void Timer_IRQHandler_Timer3(int IRQ, void *_unused) +{ + Log_Debug("Tegra2Tme", "Timer 3"); +} +void Timer_IRQHandler_Timer4(int IRQ, void *_unused) +{ + Log_Debug("Tegra2Tme", "Timer 4"); +} + +void Time_MicroSleep(Uint16 Microsecs) +{ + Uint32 cur_ts = gpTimersMap->TIMERUS.CNTR_1US; + Uint32 tgt_ts = cur_ts + Microsecs; + if( tgt_ts < cur_ts ) + while( gpTimersMap->TIMERUS.CNTR_1US > cur_ts ) + ; + while( gpTimersMap->TIMERUS.CNTR_1US < tgt_ts ) + ; +} + void Time_Setup(void) { gpTimersMap = (void*)MM_MapHWPages(0x60005000, 1); gpClockResetMap = (void*)MM_MapHWPages(0x60006000, 1); + // Timer 1 (used for system timekeeping) IRQ_AddHandler(0*32+0, Timer_IRQHandler_SysClock, NULL); + IRQ_AddHandler(0*32+1, Timer_IRQHandler_Timer2, NULL); + IRQ_AddHandler(1*32+9, Timer_IRQHandler_Timer3, NULL); + IRQ_AddHandler(1*32+10, Timer_IRQHandler_Timer4, NULL); gpTimersMap->TMR1.PTV_0 = (1<<31)|(1<<30)|(100*1000-1); // enable, periodic, 100 ms gpTimersMap->TMR1.PCR_0 = (1<<30); Log_Debug("Tegra2Tme", "TMR0.PCR = 0x%x", gpTimersMap->TMR1.PCR_0);