aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorAlistair Popple <alistair@popple.id.au>2014-11-13 17:16:02 +1100
committerStewart Smith <stewart@linux.vnet.ibm.com>2014-12-02 18:38:04 +1100
commit89348d6f95a3dff8ccc1d51c132b524d60c1b1eb (patch)
tree998cb9868ad12fc9dcf523006c44c975d85454c7 /hw
parenteaf4cd02d38946a701f2174b9b8d44156e006eaf (diff)
downloadskiboot-89348d6f95a3dff8ccc1d51c132b524d60c1b1eb.zip
skiboot-89348d6f95a3dff8ccc1d51c132b524d60c1b1eb.tar.gz
skiboot-89348d6f95a3dff8ccc1d51c132b524d60c1b1eb.tar.bz2
ipmi-rtc: Update the rtc cache
Update the ipmi-rtc code to update the rtc cache whenever we are asked the time. Signed-off-by: Alistair Popple <alistair@popple.id.au> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/ipmi/ipmi-rtc.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/hw/ipmi/ipmi-rtc.c b/hw/ipmi/ipmi-rtc.c
index 7dc7f59..ffb33ed 100644
--- a/hw/ipmi/ipmi-rtc.c
+++ b/hw/ipmi/ipmi-rtc.c
@@ -20,9 +20,7 @@
#include <time-utils.h>
#include <device.h>
#include <opal.h>
-
-/* Sane default (2014/01/01) */
-static time_t time = 1388494800;
+#include <rtc.h>
static enum {idle, waiting, updated, error} time_status;
@@ -34,10 +32,14 @@ static void get_sel_time_error(struct ipmi_msg *msg)
static void get_sel_time_complete(struct ipmi_msg *msg)
{
+ struct tm tm;
uint32_t result;
+ time_t time;
memcpy(&result, msg->data, 4);
time = le32_to_cpu(result);
+ gmtime_r(&time, &tm);
+ rtc_cache_update(&tm);
time_status = updated;
ipmi_free_msg(msg);
}
@@ -47,7 +49,7 @@ static int64_t ipmi_get_sel_time(void)
struct ipmi_msg *msg;
msg = ipmi_mkmsg(IPMI_DEFAULT_INTERFACE, IPMI_GET_SEL_TIME,
- get_sel_time_complete, &time, NULL, 0, 4);
+ get_sel_time_complete, NULL, NULL, 0, 4);
if (!msg)
return OPAL_HARDWARE;
@@ -71,9 +73,11 @@ static int64_t ipmi_set_sel_time(uint32_t tv)
static int64_t ipmi_opal_rtc_read(uint32_t *y_m_d,
uint64_t *h_m_s_m)
{
- struct tm tm;
int ret = 0;
+ if (!y_m_d || !h_m_s_m)
+ return OPAL_PARAMETER;
+
switch(time_status) {
case idle:
if (ipmi_get_sel_time() < 0)
@@ -87,8 +91,7 @@ static int64_t ipmi_opal_rtc_read(uint32_t *y_m_d,
break;
case updated:
- gmtime_r(&time, &tm);
- tm_to_datetime(&tm, y_m_d, h_m_s_m);
+ rtc_cache_get_datetime(y_m_d, h_m_s_m);
time_status = idle;
ret = OPAL_SUCCESS;
break;
@@ -123,4 +126,7 @@ void ipmi_rtc_init(void)
opal_register(OPAL_RTC_READ, ipmi_opal_rtc_read, 2);
opal_register(OPAL_RTC_WRITE, ipmi_opal_rtc_write, 2);
+
+ /* Initialise the rtc cache */
+ ipmi_get_sel_time();
}