Hopefully finish off the red from r26051.
[kugel-rb.git] / firmware / target / mips / ingenic_jz47xx / kernel-jz4740.c
blob2ef66a1d194f4098f05dc7ffa023ad8d1af4524f
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2008 by Maurus Cuelenaere
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 ****************************************************************************/
22 #include "config.h"
23 #include "system.h"
24 #include "kernel.h"
25 #include "jz4740.h"
27 void tick_start(unsigned int interval_in_ms)
29 unsigned int latch;
31 __cpm_start_tcu();
33 __tcu_stop_counter(0);
34 __tcu_disable_pwm_output(0);
36 __tcu_mask_half_match_irq(0);
37 __tcu_unmask_full_match_irq(0);
39 __tcu_select_extalclk(0);
40 __tcu_select_clk_div4(0);
42 /* 12Mhz / 4 = 3Mhz */
43 latch = interval_in_ms*1000 * 3;
45 REG_TCU_TCNT(0) = 0;
46 REG_TCU_TDFR(0) = latch;
47 REG_TCU_TDHR(0) = latch;
49 __tcu_clear_full_match_flag(0);
50 __tcu_start_counter(0);
52 system_enable_irq(IRQ_TCU0);
55 /* Interrupt handler */
56 void TCU0(void)
58 __tcu_clear_full_match_flag(0);
60 /* Run through the list of tick tasks */
61 call_tick_tasks();