summaryrefslogtreecommitdiffstats
path: root/firmware/target/arm/imx233/rtc-imx233.h
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2013-06-16 17:21:12 +0200
committerAmaury Pouly <amaury.pouly@gmail.com>2013-06-16 18:21:48 +0200
commit2d12ef6c736699dfef5b97d693225e9a4892bde8 (patch)
tree7c65e1176c759c0344d5a14525475a8f9b72a5af /firmware/target/arm/imx233/rtc-imx233.h
parent3e8c2dc46d843575096e92bd82886c7d6d44855d (diff)
downloadrockbox-2d12ef6c736699dfef5b97d693225e9a4892bde8.tar.gz
rockbox-2d12ef6c736699dfef5b97d693225e9a4892bde8.tar.bz2
rockbox-2d12ef6c736699dfef5b97d693225e9a4892bde8.zip
imx233: rewrite rtc using new registers
Change-Id: I30794dac2175d5717ea8e05e911abec65a214c44
Diffstat (limited to 'firmware/target/arm/imx233/rtc-imx233.h')
-rw-r--r--firmware/target/arm/imx233/rtc-imx233.h65
1 files changed, 7 insertions, 58 deletions
diff --git a/firmware/target/arm/imx233/rtc-imx233.h b/firmware/target/arm/imx233/rtc-imx233.h
index baf30df7c5..3ad523bdbe 100644
--- a/firmware/target/arm/imx233/rtc-imx233.h
+++ b/firmware/target/arm/imx233/rtc-imx233.h
@@ -25,60 +25,9 @@
#include "system.h"
#include "cpu.h"
-#define HW_RTC_BASE 0x8005c000
+#include "regs/regs-rtc.h"
-#define HW_RTC_CTRL (*(volatile uint32_t *)(HW_RTC_BASE + 0x0))
-#define HW_RTC_CTRL__ALARM_IRQ_EN (1 << 0)
-#define HW_RTC_CTRL__ONEMSEC_IRQ_EN (1 << 1)
-#define HW_RTC_CTRL__ALARM_IRQ (1 << 2)
-#define HW_RTC_CTRL__ONEMSEC_IRQ (1 << 3)
-#define HW_RTC_CTRL__WATCHDOGEN (1 << 4)
-#define HW_RTC_CTRL__FORCE_UPDATE (1 << 5)
-#define HW_RTC_CTRL__SUPPRESS_COPY2ANALOG (1 << 6)
-
-#define HW_RTC_STAT (*(volatile uint32_t *)(HW_RTC_BASE + 0x10))
-#define HW_RTC_STAT__NEW_REGS_BP 8
-#define HW_RTC_STAT__NEW_REGS_BM 0xff00
-#define HW_RTC_STAT__STALE_REGS_BP 16
-#define HW_RTC_STAT__STALE_REGS_BM 0xff0000
-#define HW_RTC_STAT__XTAL32768_PRESENT (1 << 27)
-#define HW_RTC_STAT__XTAL32000_PRESENT (1 << 28)
-#define HW_RTC_STAT__WATCHDOG_PRESENT (1 << 29)
-#define HW_RTC_STAT__ALARM_PRESENT (1 << 30)
-#define HW_RTC_STAT__RTC_PRESENT (1 << 31)
-
-#define HW_RTC_MILLISECONDS (*(volatile uint32_t *)(HW_RTC_BASE + 0x20))
-
-#define HW_RTC_SECONDS (*(volatile uint32_t *)(HW_RTC_BASE + 0x30))
-
-#define HW_RTC_ALARM (*(volatile uint32_t *)(HW_RTC_BASE + 0x40))
-
-#define HW_RTC_WATCHDOG (*(volatile uint32_t *)(HW_RTC_BASE + 0x50))
-
-#define HW_RTC_PERSISTENTx(x) (*(volatile uint32_t *)(HW_RTC_BASE + 0x60 + (x) * 0x10))
-
-#define HW_RTC_PERSISTENT0 (*(volatile uint32_t *)(HW_RTC_BASE + 0x60))
-#define HW_RTC_PERSISTENT0__CLOCKSOURCE (1 << 0)
-#define HW_RTC_PERSISTENT0__ALARM_WAKE_EN (1 << 1)
-#define HW_RTC_PERSISTENT0__ALARM_EN (1 << 2)
-#define HW_RTC_PERSISTENT0__XTAL24MHZ_PWRUP (1 << 4)
-#define HW_RTC_PERSISTENT0__XTAL32KHZ_PWRUP (1 << 5)
-#define HW_RTC_PERSISTENT0__XTAL32_FREQ (1 << 6)
-#define HW_RTC_PERSISTENT0__ALARM_WAKE (1 << 7)
-#define HW_RTC_PERSISTENT0__AUTO_RESTART (1 << 17)
-#define HW_RTC_PERSISTENT0__SPARE_BP 18
-#define HW_RTC_PERSISTENT0__SPARE_BM (0x3fff << 18)
-#define HW_RTC_PERSISTENT0__SPARE__RELEASE_GND (1 << 19)
-
-#define HW_RTC_PERSISTENT1 (*(volatile uint32_t *)(HW_RTC_BASE + 0x70))
-
-#define HW_RTC_PERSISTENT2 (*(volatile uint32_t *)(HW_RTC_BASE + 0x80))
-
-#define HW_RTC_PERSISTENT3 (*(volatile uint32_t *)(HW_RTC_BASE + 0x90))
-
-#define HW_RTC_PERSISTENT4 (*(volatile uint32_t *)(HW_RTC_BASE + 0xa0))
-
-#define HW_RTC_PERSISTENT5 (*(volatile uint32_t *)(HW_RTC_BASE + 0xb0))
+#define HW_RTC_PERSISTENTn(n) *(&HW_RTC_PERSISTENT0 + 4 * (n))
struct imx233_rtc_info_t
{
@@ -88,7 +37,7 @@ struct imx233_rtc_info_t
static inline void imx233_rtc_init(void)
{
- __REG_CLR(HW_RTC_CTRL) = __BLOCK_CLKGATE;
+ BF_CLR(RTC_CTRL, CLKGATE);
}
static inline uint32_t imx233_rtc_read_seconds(void)
@@ -98,21 +47,21 @@ static inline uint32_t imx233_rtc_read_seconds(void)
static inline uint32_t imx233_rtc_read_persistent(int idx)
{
- return HW_RTC_PERSISTENTx(idx);
+ return HW_RTC_PERSISTENTn(idx);
}
static inline void imx233_rtc_clear_msec_irq(void)
{
- __REG_CLR(HW_RTC_CTRL) = HW_RTC_CTRL__ONEMSEC_IRQ;
+ BF_CLR(RTC_CTRL, ONEMSEC_IRQ);
}
static inline void imx233_rtc_enable_msec_irq(bool enable)
{
imx233_rtc_clear_msec_irq();
if(enable)
- __REG_SET(HW_RTC_CTRL) = HW_RTC_CTRL__ONEMSEC_IRQ_EN;
+ BF_SET(RTC_CTRL, ONEMSEC_IRQ_EN);
else
- __REG_CLR(HW_RTC_CTRL) = HW_RTC_CTRL__ONEMSEC_IRQ_EN;
+ BF_CLR(RTC_CTRL, ONEMSEC_IRQ_EN);
}
void imx233_rtc_write_seconds(uint32_t seconds);