Sansa Fuze+: initial commit (bootloader only, LCD basically working)
[kugel-rb.git] / firmware / target / arm / imx233 / timrot-imx233.h
blob792ab767ac994d74cbeb3e4a77ebb25db2b5cd2f
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2011 by Amaury Pouly
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 #ifndef TIMROT_IMX233_H
22 #define TIMROT_IMX233_H
24 #include "system.h"
25 #include "cpu.h"
27 #define HW_TIMROT_BASE 0x80068000
29 #define HW_TIMROT_ROTCTRL (*(volatile uint32_t *)(HW_TIMROT_BASE + 0x0))
31 #define HW_TIMROT_ROTCOUNT (*(volatile uint32_t *)(HW_TIMROT_BASE + 0x10))
33 #define HW_TIMROT_TIMCTRL(i) (*(volatile uint32_t *)(HW_TIMROT_BASE + 0x20 + (i) * 0x20))
34 #define HW_TIMROT_TIMCTRL__IRQ (1 << 15)
35 #define HW_TIMROT_TIMCTRL__IRQ_EN (1 << 14)
36 #define HW_TIMROT_TIMCTRL__POLARITY (1 << 8)
37 #define HW_TIMROT_TIMCTRL__UPDATE (1 << 7)
38 #define HW_TIMROT_TIMCTRL__RELOAD (1 << 6)
39 #define HW_TIMROT_TIMCTRL__PRESCALE_1 (0 << 4)
40 #define HW_TIMROT_TIMCTRL__PRESCALE_2 (1 << 4)
41 #define HW_TIMROT_TIMCTRL__PRESCALE_4 (2 << 4)
42 #define HW_TIMROT_TIMCTRL__PRESCALE_8 (3 << 4)
43 #define HW_TIMROT_TIMCTRL__SELECT_32KHZ_XTAL 8
44 #define HW_TIMROT_TIMCTRL__SELECT_8KHZ_XTAL 9
45 #define HW_TIMROT_TIMCTRL__SELECT_4KHZ_XTAL 10
46 #define HW_TIMROT_TIMCTRL__SELECT_1KHZ_XTAL 11
47 #define HW_TIMROT_TIMCTRL__SELECT_TICK_ALWAYS 12
49 #define HW_TIMROT_TIMCOUNT(i) (*(volatile uint32_t *)(HW_TIMROT_BASE + 0x30 + (i) * 0x20))
51 typedef void (*imx233_timer_fn_t)(void);
53 void imx233_timrot_init(void);
54 void imx233_setup_timer(unsigned timer_nr, bool reload, unsigned count,
55 unsigned src, unsigned prescale, bool polarity, imx233_timer_fn_t fn);
57 #endif /* TIMROT_IMX233_H */