nc100: add RTC support
authorAlan Cox <alan@linux.intel.com>
Mon, 22 Dec 2014 14:30:28 +0000 (14:30 +0000)
committerAlan Cox <alan@linux.intel.com>
Mon, 22 Dec 2014 14:30:28 +0000 (14:30 +0000)
Kernel/platform-nc100/config.h
Kernel/platform-nc100/devices.c
Kernel/platform-nc100/main.c

index fd35a20..26170e3 100644 (file)
@@ -5,6 +5,8 @@
 #define CONFIG_CPM_EMU
 #endif
 
+/* We have an RTC */
+#define CONFIG_RTC
 /* Enable to make ^Z dump the inode table for debug */
 #undef CONFIG_IDUMP
 /* Enable to make ^A drop back into the monitor */
index c82ede5..3c7ad1c 100644 (file)
@@ -34,6 +34,7 @@ bool validdev(uint16_t dev)
 
 void device_init(void)
 {
+  inittod();
   nc100_tty_init();
 }
 
index cbc4b4e..783652d 100644 (file)
@@ -38,3 +38,20 @@ void pagemap_init(void)
 void map_init(void)
 {
 }
+
+__sfr __at 0xD0 rtc_secl;
+__sfr __at 0xD1 rtc_sech;
+__sfr __at 0xDD rtc_page;
+
+uint8_t rtc_secs(void)
+{
+    uint8_t sl, rv;
+    /* Make sure we are seeing the seconds not NVRAM */
+    rtc_page = 0;
+    /* BCD encoded */
+    do {
+        sl = rtc_secl;
+        rv = sl + rtc_sech * 10;
+    } while (sl != rtc_secl);
+    return rv;
+}