[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 7/8] hw/arm/nrf51_soc: Set system_clock_scale
From: |
Peter Maydell |
Subject: |
[PULL 7/8] hw/arm/nrf51_soc: Set system_clock_scale |
Date: |
Mon, 3 Aug 2020 20:33:58 +0100 |
The nrf51 SoC model wasn't setting the system_clock_scale
global.which meant that if guest code used the systick timer in "use
the processor clock" mode it would hang because time never advances.
Set the global to match the documented CPU clock speed for this SoC.
This SoC in fact doesn't have a SysTick timer (which is the only thing
currently that cares about the system_clock_scale), because it's
a configurable option in the Cortex-M0. However our Cortex-M0 and
thus our nrf51 and our micro:bit board do provide a SysTick, so
we ought to provide a functional one rather than a broken one.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-id: 20200727193458.31250-1-peter.maydell@linaro.org
---
hw/arm/nrf51_soc.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/hw/arm/nrf51_soc.c b/hw/arm/nrf51_soc.c
index 45e6cc97d70..e15981e019f 100644
--- a/hw/arm/nrf51_soc.c
+++ b/hw/arm/nrf51_soc.c
@@ -32,6 +32,9 @@
#define BASE_TO_IRQ(base) ((base >> 12) & 0x1F)
+/* HCLK (the main CPU clock) on this SoC is always 16MHz */
+#define HCLK_FRQ 16000000
+
static uint64_t clock_read(void *opaque, hwaddr addr, unsigned int size)
{
qemu_log_mask(LOG_UNIMP, "%s: 0x%" HWADDR_PRIx " [%u]\n",
@@ -65,6 +68,8 @@ static void nrf51_soc_realize(DeviceState *dev_soc, Error
**errp)
return;
}
+ system_clock_scale = NANOSECONDS_PER_SECOND / HCLK_FRQ;
+
object_property_set_link(OBJECT(&s->cpu), "memory", OBJECT(&s->container),
&error_abort);
if (!sysbus_realize(SYS_BUS_DEVICE(&s->cpu), errp)) {
--
2.20.1
- [PULL 0/8] target-arm queue, Peter Maydell, 2020/08/03
- [PULL 1/8] hw/arm/netduino2, netduinoplus2: Set system_clock_scale, Peter Maydell, 2020/08/03
- [PULL 2/8] include/hw/irq.h: New function qemu_irq_is_connected(), Peter Maydell, 2020/08/03
- [PULL 3/8] hw/intc/armv7m_nvic: Provide default "reset the system" behaviour for SYSRESETREQ, Peter Maydell, 2020/08/03
- [PULL 4/8] msf2-soc, stellaris: Don't wire up SYSRESETREQ, Peter Maydell, 2020/08/03
- [PULL 5/8] target/arm: Fix AddPAC error indication, Peter Maydell, 2020/08/03
- [PULL 6/8] target/arm: Avoid maybe-uninitialized warning with gcc 4.9, Peter Maydell, 2020/08/03
- [PULL 7/8] hw/arm/nrf51_soc: Set system_clock_scale,
Peter Maydell <=
- [PULL 8/8] hw/timer/imx_epit: Avoid assertion when CR.SWR is written, Peter Maydell, 2020/08/03
- Re: [PULL 0/8] target-arm queue, Peter Maydell, 2020/08/03