ADD ARM AMBA PL031 RTC Support
PATCH 1/1 ADD ARM AMBA PL031 RTC Support
Hi,
This patch adds support to arm amba pl031 rtc chip.
user needs to define 3 variables in board config to make use of this driver
#define CONFIG_RTC_PL031 1 /* use ARM AMBA PL031 RTC */
#define CFG_RTC_PL031_BASE 0x101e8000 /* RTC Registers Base Address */
and
#define CONFIG_CMD_DATE
Comments are welcome.
Regards
Gururaja
Signed off by: Gururaja Hebbar <[email protected]>
- Add support to the ARM AMBA PL031 RTC Chip.
drivers/rtc/Makefile renamed from drivers/rtc_orig/Makefile +1 -0
@@ -56,6 +56,7 @@ COBJS-y += rs5c372.o COBJS-y += rx8025.o COBJS-y += s3c24x0_rtc.o COBJS-y += x1205.o +COBJS-y += rtc_pl031.o COBJS := $(COBJS-y) SRCS := $(COBJS:.o=.c)
drivers/rtc/rtc_pl031.c renamed from drivers/rtc_orig/rtc_pl031.c +50 -0
50 lines not on this page · raw message
*)(CFG_RTC_PL031_BASE + (addr)) = (val))
+#define RTC_READ_REG(addr) (*(volatile unsigned int *)(CFG_RTC_PL031_BASE
+ (addr)))
+
+/*
+ * Reset the RTC. We set the date back to 1970-01-01.
+ */
+void rtc_reset(void)
+{
+ RTC_WRITE_REG(RTC_LR,0x00);
+}
+
+/* Enable RTC Start in Control register*/ +int rtc_init(void)
+{
+ RTC_WRITE_REG(RTC_CR,RTC_CR_MIE);
+ return 0;
+}
+
+/*
+ * Set the RTC
+*/
+void rtc_set(struct rtc_time *tmp)
+{
+ unsigned long tim;
+
+ if (tmp == NULL) {
+ puts("Error setting the date/time\n");
+ return;
+ }
+
+ /* Calculate number of seconds this incoming time represents */
+ tim = mktime(tmp->tm_year, tmp->tm_mon, tmp->tm_mday,
+ tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
+
+ RTC_WRITE_REG(RTC_LR,tim);
+}
+
+/*
+ * Get the current time from the RTC
+ */
+int rtc_get(struct rtc_time *tmp)
+{
+ ulong tim;
+
+ if (tmp == NULL) {
+ puts("Error getting the date/time\n");
+ return -1;
+ }
+
+ tim = RTC_READ_REG(RTC_DR);
+
+ to_tm (tim, tmp);
+
+ debug ( "Get DATE: %4d-%02d-%02d (wday=%d) TIME: %2d:%02d:%02d\n",
+ tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday,
+ tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
+
+ return 0;
+}
+
+#endif
lib_arm/board.c renamed from lib_arm_orig/board.c +7 -0
@@ -85,6 +85,10 @@ extern void cs8900_get_enetaddr (uchar *extern void rtl8019_get_enetaddr (uchar * addr);#endif +#if defined(CONFIG_RTC_PL031 ) && defined(CONFIG_CMD_DATE ) +extern int rtc_init (void ); +#endif +#if defined(CONFIG_HARD_I2C ) || \ defined(CONFIG_SOFT_I2C )#include <i2c.h>
@@ -267,6 +271,9 @@ init_fnc_t *init_sequence[] = {#if defined(CONFIG_DISPLAY_BOARDINFO ) checkboard, /* display board info */#endif +#if defined(CONFIG_RTC_PL031 ) && defined(CONFIG_CMD_DATE ) + rtc_init, +#endif #if defined(CONFIG_HARD_I2C ) || defined(CONFIG_SOFT_I2C ) init_func_i2c,#endif
http://www.nabble.com/file/p18483701/add_arm_amba_pl031_rtc.patch
add_arm_amba_pl031_rtc.patch
http://www.nabble.com/file/p18483701/add_rtc_init_arm_boot_seq.patch
add_rtc_init_arm_boot_seq.patch
Signature · 2 lines
View this message in context: http://www.nabble.com/-PATCH--ADD-ARM-AMBA-PL031-RTC-Support-tp18483701p18483701.html Sent from the Uboot - Users mailing list archive at Nabble.com.
PATCH 1/1 ADD ARM AMBA PL031 RTC Support
HI,
Dont apply this patch. i need to change the call to rtc_init to a different place.
since wd has mentioned in other thread that uboot doesnt initialize hardware/devices that board doesnt need. so i will change and re-send/re-submit
Regards
Gururaja
Signature · 2 lines
View this message in context: http://www.nabble.com/-PATCH--ADD-ARM-AMBA-PL031-RTC-Support-tp18483701p18484773.html Sent from the Uboot - Users mailing list archive at Nabble.com.