Detail comment in timer configuration of S5L870x.
[kugel-rb.git] / firmware / target / arm / s5l8700 / kernel-s5l8700.c
blob1d5949a7ed2b8d3a8dec84e8e070c1fb42b1a3d8
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright © 2009 Bertrik Sikken
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
21 #include "config.h"
22 #include "system.h"
23 #include "kernel.h"
25 /* S5L8700 driver for the kernel timer
27 Timer B is configured as a 10 kHz timer (assuming PCLK = 48 MHz)
30 void INT_TIMERB(void)
32 /* clear interrupt */
33 TBCON = TBCON;
35 call_tick_tasks(); /* Run through the list of tick tasks */
38 void tick_start(unsigned int interval_in_ms)
40 int cycles = 10 * interval_in_ms;
42 /* enable timer clock */
43 PWRCON &= ~(1 << 4);
45 /* configure timer for 10 kHz */
46 TBCMD = (1 << 1); /* TB_CLR */
47 TBPRE = 300 - 1; /* prescaler for 48 MHz HCLK */
48 TBCON = (0 << 13) | /* TB_INT1_EN */
49 (1 << 12) | /* TB_INT0_EN */
50 (0 << 11) | /* TB_START */
51 (2 << 8) | /* TB_CS = PCLK / 16 */
52 (0 << 4); /* TB_MODE_SEL = interval mode */
53 TBDATA0 = cycles; /* set interval period */
54 TBCMD = (1 << 0); /* TB_EN */
56 /* enable timer interrupt */
57 INTMSK |= INTMSK_TIMERB;