aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Piggin <npiggin@gmail.com>2020-12-22 02:08:37 +1000
committerVasant Hegde <hegdevasant@linux.vnet.ibm.com>2021-01-05 11:26:43 +0530
commit0f2c57df54bba164dd350b2b4dd49fccda988f85 (patch)
treefc157c09918374bb2d085e0d92b7447e9d30e8fc
parentb44c7594523d20945179e497c45ec9007981ac75 (diff)
downloadskiboot-0f2c57df54bba164dd350b2b4dd49fccda988f85.zip
skiboot-0f2c57df54bba164dd350b2b4dd49fccda988f85.tar.gz
skiboot-0f2c57df54bba164dd350b2b4dd49fccda988f85.tar.bz2
mambo: add a mambo rtc_write
This just keeps the requested delta and uses it to adjust subsequent rtc_read calls. Signed-off-by: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
-rw-r--r--platforms/mambo/mambo.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/platforms/mambo/mambo.c b/platforms/mambo/mambo.c
index 0c96100..a1e0488 100644
--- a/platforms/mambo/mambo.c
+++ b/platforms/mambo/mambo.c
@@ -173,6 +173,8 @@ static void bogus_disk_flash_init(void)
}
}
+static int64_t time_delta = 0;
+
static int64_t mambo_rtc_read(__be32 *ymd, __be64 *hmsm)
{
int64_t mambo_time;
@@ -186,6 +188,7 @@ static int64_t mambo_rtc_read(__be32 *ymd, __be64 *hmsm)
mambo_time = callthru0(SIM_GET_TIME_CODE);
mt = mambo_time >> 32;
+ mt += time_delta;
gmtime_r(&mt, &t);
tm_to_datetime(&t, &__ymd, &__hmsm);
@@ -195,12 +198,30 @@ static int64_t mambo_rtc_read(__be32 *ymd, __be64 *hmsm)
return OPAL_SUCCESS;
}
+static int64_t mambo_rtc_write(uint32_t ymd, uint64_t hmsm)
+{
+ int64_t mambo_time;
+ struct tm tm;
+ time_t mt, new_mt;
+
+ mambo_time = callthru0(SIM_GET_TIME_CODE);
+ mt = mambo_time >> 32;
+
+ datetime_to_tm(ymd, hmsm, &tm);
+ new_mt = mktime(&tm);
+
+ time_delta = new_mt - mt;
+
+ 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);
+ opal_register(OPAL_RTC_WRITE, mambo_rtc_write, 2);
}
static void mambo_system_reset_cpu(struct cpu_thread *cpu)