summaryrefslogtreecommitdiff
path: root/firmware/target/arm/imx233/rtc-imx233.h
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/imx233/rtc-imx233.h')
-rw-r--r--firmware/target/arm/imx233/rtc-imx233.h74
1 files changed, 73 insertions, 1 deletions
diff --git a/firmware/target/arm/imx233/rtc-imx233.h b/firmware/target/arm/imx233/rtc-imx233.h
index c26832ab57..054ace40b8 100644
--- a/firmware/target/arm/imx233/rtc-imx233.h
+++ b/firmware/target/arm/imx233/rtc-imx233.h
@@ -25,13 +25,85 @@
25#include "system.h" 25#include "system.h"
26#include "cpu.h" 26#include "cpu.h"
27 27
28#define HW_RTC_BASE 0x8005C000 28#define HW_RTC_BASE 0x8005c000
29 29
30#define HW_RTC_CTRL (*(volatile uint32_t *)(HW_RTC_BASE + 0x0)) 30#define HW_RTC_CTRL (*(volatile uint32_t *)(HW_RTC_BASE + 0x0))
31#define HW_RTC_CTRL__ALARM_IRQ_EN (1 << 0)
32#define HW_RTC_CTRL__ONEMSEC_IRQ_EN (1 << 1)
33#define HW_RTC_CTRL__ALARM_IRQ (1 << 2)
34#define HW_RTC_CTRL__ONEMSEC_IRQ (1 << 3)
35#define HW_RTC_CTRL__WATCHDOGEN (1 << 4)
36#define HW_RTC_CTRL__FORCE_UPDATE (1 << 5)
37#define HW_RTC_CTRL__SUPPRESS_COPY2ANALOG (1 << 6)
38
39#define HW_RTC_STAT (*(volatile uint32_t *)(HW_RTC_BASE + 0x10))
40#define HW_RTC_STAT__NEW_REGS_BP 8
41#define HW_RTC_STAT__NEW_REGS_BM 0xff00
42#define HW_RTC_STAT__STALE_REGS_BP 16
43#define HW_RTC_STAT__STALE_REGS_BM 0xff0000
44#define HW_RTC_STAT__XTAL32768_PRESENT (1 << 27)
45#define HW_RTC_STAT__XTAL32000_PRESENT (1 << 28)
46#define HW_RTC_STAT__WATCHDOG_PRESENT (1 << 29)
47#define HW_RTC_STAT__ALARM_PRESENT (1 << 30)
48#define HW_RTC_STAT__RTC_PRESENT (1 << 31)
49
50#define HW_RTC_MILLISECONDS (*(volatile uint32_t *)(HW_RTC_BASE + 0x20))
51
52#define HW_RTC_SECONDS (*(volatile uint32_t *)(HW_RTC_BASE + 0x30))
53
54#define HW_RTC_ALARM (*(volatile uint32_t *)(HW_RTC_BASE + 0x40))
55
56#define HW_RTC_WATCHDOG (*(volatile uint32_t *)(HW_RTC_BASE + 0x50))
57
58#define HW_RTC_PERSISTENTx(x) (*(volatile uint32_t *)(HW_RTC_BASE + 0x60 + (x) * 0x10))
31 59
32#define HW_RTC_PERSISTENT0 (*(volatile uint32_t *)(HW_RTC_BASE + 0x60)) 60#define HW_RTC_PERSISTENT0 (*(volatile uint32_t *)(HW_RTC_BASE + 0x60))
61#define HW_RTC_PERSISTENT0__CLOCKSOURCE (1 << 0)
62#define HW_RTC_PERSISTENT0__ALARM_WAKE_EN (1 << 1)
63#define HW_RTC_PERSISTENT0__ALARM_EN (1 << 2)
64#define HW_RTC_PERSISTENT0__XTAL24MHZ_PWRUP (1 << 4)
65#define HW_RTC_PERSISTENT0__XTAL32KHZ_PWRUP (1 << 5)
66#define HW_RTC_PERSISTENT0__XTAL32_FREQ (1 << 6)
67#define HW_RTC_PERSISTENT0__ALARM_WAKE (1 << 7)
68#define HW_RTC_PERSISTENT0__AUTO_RESTART (1 << 17)
33#define HW_RTC_PERSISTENT0__SPARE_BP 18 69#define HW_RTC_PERSISTENT0__SPARE_BP 18
34#define HW_RTC_PERSISTENT0__SPARE_BM (0x3fff << 18) 70#define HW_RTC_PERSISTENT0__SPARE_BM (0x3fff << 18)
35#define HW_RTC_PERSISTENT0__SPARE__RELEASE_GND (1 << 19) 71#define HW_RTC_PERSISTENT0__SPARE__RELEASE_GND (1 << 19)
36 72
73#define HW_RTC_PERSISTENT1 (*(volatile uint32_t *)(HW_RTC_BASE + 0x70))
74
75#define HW_RTC_PERSISTENT2 (*(volatile uint32_t *)(HW_RTC_BASE + 0x80))
76
77#define HW_RTC_PERSISTENT3 (*(volatile uint32_t *)(HW_RTC_BASE + 0x90))
78
79#define HW_RTC_PERSISTENT4 (*(volatile uint32_t *)(HW_RTC_BASE + 0xa0))
80
81#define HW_RTC_PERSISTENT5 (*(volatile uint32_t *)(HW_RTC_BASE + 0xb0))
82
83struct imx233_rtc_info_t
84{
85 uint32_t seconds;
86 uint32_t persistent[6];
87};
88
89static inline void imx233_rtc_init(void)
90{
91 __REG_CLR(HW_RTC_CTRL) = __BLOCK_CLKGATE;
92}
93
94static inline uint32_t imx233_rtc_read_seconds(void)
95{
96 return HW_RTC_SECONDS;
97}
98
99static inline uint32_t imx233_rtc_read_persistent(int idx)
100{
101 return HW_RTC_PERSISTENTx(idx);
102}
103
104void imx233_rtc_write_seconds(uint32_t seconds);
105void imx233_rtc_write_persistent(int idx, uint32_t val);
106
107struct imx233_rtc_info_t imx233_rtc_get_info(void);
108
37#endif /* RTC_IMX233_H */ 109#endif /* RTC_IMX233_H */