diff options
-rw-r--r-- | asm/misc.S | 8 | ||||
-rw-r--r-- | platforms/Makefile.inc | 3 | ||||
-rw-r--r-- | platforms/mambo/Makefile.inc | 6 | ||||
-rw-r--r-- | platforms/mambo/mambo.c | 81 |
4 files changed, 97 insertions, 1 deletions
@@ -74,3 +74,11 @@ mambo_sim_exit: li %r3, 31 /* aka. SimExitCode */ .long 0x000eaeb0 b . + +.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/Makefile.inc b/platforms/Makefile.inc index a29d5f7..12c82c8 100644 --- a/platforms/Makefile.inc +++ b/platforms/Makefile.inc @@ -6,5 +6,6 @@ PLATFORMS = $(PLATDIR)/built-in.o include $(SRC)/$(PLATDIR)/ibm-fsp/Makefile.inc include $(SRC)/$(PLATDIR)/rhesus/Makefile.inc include $(SRC)/$(PLATDIR)/astbmc/Makefile.inc +include $(SRC)/$(PLATDIR)/mambo/Makefile.inc -$(PLATFORMS): $(IBM_FSP) $(RHESUS) $(ASTBMC) +$(PLATFORMS): $(IBM_FSP) $(RHESUS) $(ASTBMC) $(MAMBO) diff --git a/platforms/mambo/Makefile.inc b/platforms/mambo/Makefile.inc new file mode 100644 index 0000000..2cc8613 --- /dev/null +++ b/platforms/mambo/Makefile.inc @@ -0,0 +1,6 @@ +SUBDIRS += $(PLATDIR)/mambo + +MAMBO_OBJS = mambo.o +MAMBO = $(PLATDIR)/mambo/built-in.o +$(MAMBO): $(MAMBO_OBJS:%=$(PLATDIR)/mambo/%) + diff --git a/platforms/mambo/mambo.c b/platforms/mambo/mambo.c new file mode 100644 index 0000000..7d77aff --- /dev/null +++ b/platforms/mambo/mambo.c @@ -0,0 +1,81 @@ +/* Copyright 2015 IBM Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#include <skiboot.h> +#include <device.h> +#include <console.h> +#include <chip.h> +#include <opal-api.h> +#include <opal-internal.h> +#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")) + return false; + + return true; +} + +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 void mambo_platform_init(void) +{ + force_dummy_console(); + mambo_rtc_init(); +} + +static int64_t mambo_cec_power_down(uint64_t request __unused) +{ + if (chip_quirk(QUIRK_MAMBO_CALLOUTS)) + mambo_sim_exit(); + + return OPAL_UNSUPPORTED; +} + +DECLARE_PLATFORM(mambo) = { + .name = "Mambo", + .probe = mambo_probe, + .init = mambo_platform_init, + .cec_power_down = mambo_cec_power_down, +}; |