imx233: forgot a file
[maemo-rb.git] / firmware / target / arm / imx233 / rtc-imx233.c
blob072da485d9040043110d9a3547e8773a8cba1239
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 #include "rtc-imx233.h"
22 #include "string.h"
24 static void imx233_rtc_write_reg(volatile uint32_t *reg, uint32_t val)
26 while(__XTRACT(HW_RTC_STAT, NEW_REGS) != 0);
27 *reg = val;
28 while(__XTRACT(HW_RTC_STAT, NEW_REGS) != 0);
31 void imx233_rtc_write_seconds(uint32_t seconds)
33 imx233_rtc_write_reg(&HW_RTC_SECONDS, seconds);
36 void imx233_rtc_write_persistent(int idx, uint32_t val)
38 imx233_rtc_write_reg(&HW_RTC_PERSISTENTx(idx), val);
41 struct imx233_rtc_info_t imx233_rtc_get_info(void)
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;