arm: aspeed: Add RTC Model
Joel Stanley
maintainerv2 cover arm: aspeed: Add RTC Model
v2: Minor fixes, added vmstate and reset, and rebased on Cédric's series
Based-on: [email protected]
[PATCH 3/3] aspeed: use sysbus_init_child_obj() to initialize children
A model for the ASPEED BMC real time clock (RTC). The model is sufficient for running the guest Linux kernel driver, and ticks in time with the host when programmed.
It does not implement the alarm functionality, which includes the interrupt.
Joel Stanley (2):
hw: timer: Add ASPEED RTC device
hw/arm/aspeed: Add RTC to SoC
hw/arm/aspeed_soc.c | 13 +++ hw/timer/Makefile.objs | 2 +- hw/timer/aspeed_rtc.c | 180 ++++++++++++++++++++++++++++++++++ hw/timer/trace-events | 4 + include/hw/arm/aspeed_soc.h | 2 + include/hw/timer/aspeed_rtc.h | 31 ++++++ 6 files changed, 231 insertions(+), 1 deletion(-) create mode 100644 hw/timer/aspeed_rtc.c create mode 100644 include/hw/timer/aspeed_rtc.h
Signature · 1 line
2.20.1
Joel Stanley
maintainerPATCH v2 1/2 hw: timer: Add ASPEED RTC device
Signed-off-by Joel Stanley <[email protected]>
Signed-off-by Cédric Le Goater <[email protected]>
---
v2:
Use g_assert_not_reached
Add vmstate
Add reset callback
Annotate fall through cases
hw/timer/Makefile.objs | 2 +- hw/timer/aspeed_rtc.c | 180 ++++++++++++++++++++++++++++++++++ hw/timer/trace-events | 4 + include/hw/timer/aspeed_rtc.h | 31 ++++++ 4 files changed, 216 insertions(+), 1 deletion(-) create mode 100644 hw/timer/aspeed_rtc.c create mode 100644 include/hw/timer/aspeed_rtc.h
hw/timer/Makefile.objs +1 -1
@@ -41,7 +41,7 @@ obj-$(CONFIG_MC146818RTC) += mc146818rtc.o obj-$(CONFIG_ALLWINNER_A10_PIT) += allwinner-a10-pit.o common-obj-$(CONFIG_STM32F2XX_TIMER) += stm32f2xx_timer.o -common-obj-$(CONFIG_ASPEED_SOC) += aspeed_timer.o +common-obj-$(CONFIG_ASPEED_SOC) += aspeed_timer.o aspeed_rtc.o common-obj-$(CONFIG_SUN4V_RTC) += sun4v-rtc.o common-obj-$(CONFIG_CMSDK_APB_TIMER) += cmsdk-apb-timer.o
hw/timer/aspeed_rtc.c new file +180 -0
180 lines not on this page · raw message
hw/timer/trace-events +4 -0
@@ -66,6 +66,10 @@ cmsdk_apb_dualtimer_read(uint64_t offset, uint64_t data, unsigned size) "CMSDK A cmsdk_apb_dualtimer_write(uint64_t offset, uint64_t data, unsigned size) "CMSDK APB dualtimer write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u" cmsdk_apb_dualtimer_reset(void) "CMSDK APB dualtimer: reset" +# hw/timer/aspeed-rtc.c +aspeed_rtc_read(uint64_t addr, uint64_t value) "addr 0x%02" PRIx64 " value 0x%08" PRIx64 +aspeed_rtc_write(uint64_t addr, uint64_t value) "addr 0x%02" PRIx64 " value 0x%08" PRIx64 + # sun4v-rtc.c sun4v_rtc_read(uint64_t addr, uint64_t value) "read: addr 0x%" PRIx64 " value 0x%" PRIx64 sun4v_rtc_write(uint64_t addr, uint64_t value) "write: addr 0x%" PRIx64 " value 0x%" PRIx64
include/hw/timer/aspeed_rtc.h new file +31 -0
@@ -0,0 +1,31 @@ +/* +* ASPEED Real Time Clock +* Joel Stanley <[email protected]> +* +* Copyright 2019 IBM Corp +* SPDX-License-Identifier: GPL-2.0-or-later +*/ +#ifndef ASPEED_RTC_H +#define ASPEED_RTC_H + +#include <stdint.h> + +#include "hw/hw.h" +#include "hw/irq.h" +#include "hw/sysbus.h" + +typedef struct AspeedRtcState { +SysBusDevice parent_obj; + +MemoryRegion iomem; +qemu_irq irq; + +uint32_t reg[0x18 ]; +int offset; + +}AspeedRtcState ; + +#define TYPE_ASPEED_RTC "aspeed.rtc" +#define ASPEED_RTC (obj) OBJECT_CHECK(AspeedRtcState, (obj), TYPE_ASPEED_RTC) + +#endif /* ASPEED_RTC_H */
Signature · 1 line
2.20.1