diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/target/arm/imx233/rtc-imx233.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/firmware/target/arm/imx233/rtc-imx233.c b/firmware/target/arm/imx233/rtc-imx233.c new file mode 100644 index 0000000000..072da485d9 --- /dev/null +++ b/firmware/target/arm/imx233/rtc-imx233.c | |||
@@ -0,0 +1,49 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2011 by Amaury Pouly | ||
11 | * | ||
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. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #include "rtc-imx233.h" | ||
22 | #include "string.h" | ||
23 | |||
24 | static void imx233_rtc_write_reg(volatile uint32_t *reg, uint32_t val) | ||
25 | { | ||
26 | while(__XTRACT(HW_RTC_STAT, NEW_REGS) != 0); | ||
27 | *reg = val; | ||
28 | while(__XTRACT(HW_RTC_STAT, NEW_REGS) != 0); | ||
29 | } | ||
30 | |||
31 | void imx233_rtc_write_seconds(uint32_t seconds) | ||
32 | { | ||
33 | imx233_rtc_write_reg(&HW_RTC_SECONDS, seconds); | ||
34 | } | ||
35 | |||
36 | void imx233_rtc_write_persistent(int idx, uint32_t val) | ||
37 | { | ||
38 | imx233_rtc_write_reg(&HW_RTC_PERSISTENTx(idx), val); | ||
39 | } | ||
40 | |||
41 | struct imx233_rtc_info_t imx233_rtc_get_info(void) | ||
42 | { | ||
43 | struct imx233_rtc_info_t info; | ||
44 | memset(&info, 0, sizeof(info)); | ||
45 | info.seconds = HW_RTC_SECONDS; | ||
46 | for(int i = 0; i < 6; i++) | ||
47 | info.persistent[i] = HW_RTC_PERSISTENTx(i); | ||
48 | return info; | ||
49 | } | ||