[Skiboot] [PATCH 5/6] mambo: Convert RTC read from asm to C

Michael Neuling mikey at neuling.org
Wed Nov 2 18:07:38 AEDT 2016


Also moves some code around to ensure things are defined before they
are used.

Signed-off-by: Michael Neuling <mikey at neuling.org>
---
 asm/misc.S              |  8 --------
 platforms/mambo/mambo.c | 53 ++++++++++++++++++++++++-------------------------
 2 files changed, 26 insertions(+), 35 deletions(-)

diff --git a/asm/misc.S b/asm/misc.S
index be87fbe8ed..1d9170b5cc 100644
--- a/asm/misc.S
+++ b/asm/misc.S
@@ -50,11 +50,3 @@ _mcount:
 	mflr	%r4
 	b	__mcount_stack_check
 #endif
-
-.global mambo_get_time
-mambo_get_time:
-#define SIM_GET_TIME_CODE 70
-	li	%r3,SIM_GET_TIME_CODE
-	.long	0x000eaeb0
-	blr
-
diff --git a/platforms/mambo/mambo.c b/platforms/mambo/mambo.c
index 45ce34d9ca..b1c795b85c 100644
--- a/platforms/mambo/mambo.c
+++ b/platforms/mambo/mambo.c
@@ -24,8 +24,6 @@
 #include <time-utils.h>
 #include <time.h>
 
-extern int64_t mambo_get_time(void);
-
 static bool mambo_probe(void)
 {
 	if (!dt_find_by_path(dt_root, "/mambo"))
@@ -41,31 +39,6 @@ static inline unsigned long callthru0(int command)
 	return (c);
 }
 
-static int64_t mambo_rtc_read(uint32_t *ymd, uint64_t *hmsm)
-{
-	int64_t mambo_time;
-	struct tm t;
-	time_t mt;
-
-	if (!ymd || !hmsm)
-		return OPAL_PARAMETER;
-
-	mambo_time = mambo_get_time();
-	mt = mambo_time >> 32;
-	gmtime_r(&mt, &t);
-	tm_to_datetime(&t, ymd, hmsm);
-
-	return OPAL_SUCCESS;
-}
-
-static void mambo_rtc_init(void)
-{
-	struct dt_node *np = dt_new(opal_node, "rtc");
-	dt_add_property_strings(np, "compatible", "ibm,opal-rtc");
-
-	opal_register(OPAL_RTC_READ, mambo_rtc_read, 2);
-}
-
 static inline unsigned long callthru2(int command, unsigned long arg1,
 				      unsigned long arg2)
 {
@@ -99,6 +72,7 @@ static inline unsigned long callthru3(int command, unsigned long arg1,
 #define SIM_WRITE_CONSOLE_CODE	0
 #define SIM_EXIT_CODE		31
 #define SIM_READ_CONSOLE_CODE	60
+#define SIM_GET_TIME_CODE	70
 #define BOGUS_DISK_READ		116
 #define BOGUS_DISK_WRITE	117
 #define BOGUS_DISK_INFO		118
@@ -242,6 +216,31 @@ static void bogus_disk_flash_init(void)
 	}
 }
 
+static int64_t mambo_rtc_read(uint32_t *ymd, uint64_t *hmsm)
+{
+	int64_t mambo_time;
+	struct tm t;
+	time_t mt;
+
+	if (!ymd || !hmsm)
+		return OPAL_PARAMETER;
+
+	mambo_time = callthru0(SIM_GET_TIME_CODE);
+	mt = mambo_time >> 32;
+	gmtime_r(&mt, &t);
+	tm_to_datetime(&t, ymd, hmsm);
+
+	return OPAL_SUCCESS;
+}
+
+static void mambo_rtc_init(void)
+{
+	struct dt_node *np = dt_new(opal_node, "rtc");
+	dt_add_property_strings(np, "compatible", "ibm,opal-rtc");
+
+	opal_register(OPAL_RTC_READ, mambo_rtc_read, 2);
+}
+
 int mambo_console_read(void)
 {
 	return callthru0(SIM_READ_CONSOLE_CODE);
-- 
2.9.3



More information about the Skiboot mailing list