summaryrefslogtreecommitdiff
path: root/firmware/target/arm/s5l8700/kernel-s5l8700.c
diff options
context:
space:
mode:
authorBertrik Sikken <bertrik@sikken.nl>2009-07-05 19:09:14 +0000
committerBertrik Sikken <bertrik@sikken.nl>2009-07-05 19:09:14 +0000
commit9926c933c799f93abc1d4650f2db349d74dce238 (patch)
tree6c0af9f2ca7328f4e7d7ee62b87b496f5a99a150 /firmware/target/arm/s5l8700/kernel-s5l8700.c
parente63904c7e97cefa5644d9b02b3960f880d110232 (diff)
S5L8700: implement kernel timer
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21672 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/s5l8700/kernel-s5l8700.c')
-rw-r--r--firmware/target/arm/s5l8700/kernel-s5l8700.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/firmware/target/arm/s5l8700/kernel-s5l8700.c b/firmware/target/arm/s5l8700/kernel-s5l8700.c
new file mode 100644
index 0000000000..b905ade0c1
--- /dev/null
+++ b/firmware/target/arm/s5l8700/kernel-s5l8700.c
@@ -0,0 +1,59 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright © 2009 Bertrik Sikken
+ *
+ * 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"
+
+/* S5L8700 driver for the kernel timer
+
+ Timer B is configured as a 10 kHz timer (assuming PCLK = 100 MHz)
+ */
+
+void INT_TIMERB(void)
+{
+ /* clear interrupt */
+ TBCON = TBCON;
+
+ call_tick_tasks(); /* Run through the list of tick tasks */
+}
+
+void tick_start(unsigned int interval_in_ms)
+{
+ int cycles = 10 * interval_in_ms;
+
+ /* enable timer clock */
+ PWRCON &= ~(1 << 4);
+
+ /* configure timer for 10 kHz */
+ TBCMD = (1 << 1); /* TB_CLR */
+ TBPRE = 625; /* prescaler */
+ TBCON = (0 << 13) | /* TB_INT1_EN */
+ (1 << 12) | /* TB_INT0_EN */
+ (0 << 11) | /* TB_START */
+ (2 << 8) | /* TB_CS = PCLK / 16 */
+ (0 << 4); /* TB_MODE_SEL = interval mode */
+ TBDATA0 = cycles-1; /* set interval period */
+ TBCMD = (1 << 0); /* TB_EN */
+
+ /* enable timer interrupt */
+ INTMSK |= (1 << 7);
+}
+