diff options
author | Dominik Wenger <domonoky@googlemail.com> | 2009-10-19 18:14:27 +0000 |
---|---|---|
committer | Dominik Wenger <domonoky@googlemail.com> | 2009-10-19 18:14:27 +0000 |
commit | 41c497025f40615373817498606fabd0fcd41dd6 (patch) | |
tree | 1a35952304d53a222cae58812114c37c86eee30d /firmware/target/arm/s3c2440/kernel-s3c2440.c | |
parent | 660dbd697d54199db5dfc33d2d3859825f0f77ac (diff) |
Initial mini2440 port.
Flyspray: FS#10627
Author: Bob Cousins
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23265 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/s3c2440/kernel-s3c2440.c')
-rw-r--r-- | firmware/target/arm/s3c2440/kernel-s3c2440.c | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/firmware/target/arm/s3c2440/kernel-s3c2440.c b/firmware/target/arm/s3c2440/kernel-s3c2440.c new file mode 100644 index 0000000000..6cabc8dc81 --- /dev/null +++ b/firmware/target/arm/s3c2440/kernel-s3c2440.c @@ -0,0 +1,79 @@ +/*************************************************************************** +* __________ __ ___. +* Open \______ \ ____ ____ | | _\_ |__ _______ ___ +* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +* \/ \/ \/ \/ \/ +* $Id$ +* +* Copyright (C) 2007 by Michael Sevakis +* +* 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 distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY +* KIND, either express or implied. +* +****************************************************************************/ +#include "config.h" +#include "system.h" +#include "kernel.h" +#include "timer.h" +#include "thread.h" + +void tick_start(unsigned int interval_in_ms) +{ + /* + * Based on default PCLK of 49.1568MHz - scaling chosen to give + * remainder-free result for tick interval of 10ms (100Hz) + * Timer input clock frequency = + * fPCLK / {prescaler value+1} / {divider value} + * TIMER_FREQ = 49156800 / 2 + * 146300 = TIMER_FREQ / 21 / 8 + * 49156800 = 19*11*(7)*7*5*5*(3)*2*2*2*2*2*2 + * 21 = 7*3 + */ + + /* stop timer 4 */ + TCON &= ~(1 << 20); + /* Set the count for timer 4 */ + TCNTB4 = (TIMER_FREQ / TIMER234_PRESCALE / 8) * interval_in_ms / 1000; + /* Set the the prescaler value for timers 2,3, and 4 */ + TCFG0 = (TCFG0 & ~0xff00) | ((TIMER234_PRESCALE-1) << 8); + /* DMA mode off, MUX4 = 1/16 */ + TCFG1 = (TCFG1 & ~0xff0000) | 0x030000; + /* set manual bit */ + TCON |= 1 << 21; + /* reset manual bit */ + TCON &= ~(1 << 21); + + /* interval mode */ + TCON |= 1 << 22; + /* start timer 4 */ + TCON |= (1 << 20); + + /* timer 4 unmask interrupts */ + INTMSK &= ~TIMER4_MASK; +} + +#ifdef BOOTLOADER +void tick_stop(void) +{ + s3c_regset32(&INTMSK, TIMER4_MASK); + TCON &= ~(1 << 20); + SRCPND = TIMER4_MASK; + INTPND = TIMER4_MASK; +} +#endif + +void TIMER4(void) +{ + /* Run through the list of tick tasks */ + call_tick_tasks(); + + SRCPND = TIMER4_MASK; + INTPND = TIMER4_MASK; +} |