aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2021-08-12 10:33:46 +0100
committerPeter Maydell <peter.maydell@linaro.org>2021-09-01 11:08:20 +0100
commitc08e612662e4bdc84f2e9bd4ae598e8c07a23565 (patch)
tree74260eb9d9b3b7914b513ccbbffe4b1f620a82bc
parent7580384b34da99134d1162729957ed63ae2da230 (diff)
downloadqemu-c08e612662e4bdc84f2e9bd4ae598e8c07a23565.zip
qemu-c08e612662e4bdc84f2e9bd4ae598e8c07a23565.tar.gz
qemu-c08e612662e4bdc84f2e9bd4ae598e8c07a23565.tar.bz2
hw/arm/nrf51: Wire up sysclk
Wire up the sysclk input to the armv7m object. Strictly this SoC should not have a systick device at all, but our armv7m container object doesn't currently support disabling the systick device. For the moment, add a TODO comment, but note that this is why we aren't wiring up a refclk (no need for one). Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Alexandre Iooss <erdnaxe@crans.org> Message-id: 20210812093356.1946-16-peter.maydell@linaro.org
-rw-r--r--hw/arm/nrf51_soc.c20
-rw-r--r--include/hw/arm/nrf51_soc.h2
2 files changed, 22 insertions, 0 deletions
diff --git a/hw/arm/nrf51_soc.c b/hw/arm/nrf51_soc.c
index 9407c2f..e3e849a 100644
--- a/hw/arm/nrf51_soc.c
+++ b/hw/arm/nrf51_soc.c
@@ -12,6 +12,7 @@
#include "qapi/error.h"
#include "hw/arm/boot.h"
#include "hw/sysbus.h"
+#include "hw/qdev-clock.h"
#include "hw/misc/unimp.h"
#include "qemu/log.h"
@@ -66,6 +67,23 @@ static void nrf51_soc_realize(DeviceState *dev_soc, Error **errp)
return;
}
+ /*
+ * HCLK on this SoC is fixed, so we set up sysclk ourselves and
+ * the board shouldn't connect it.
+ */
+ if (clock_has_source(s->sysclk)) {
+ error_setg(errp, "sysclk clock must not be wired up by the board code");
+ return;
+ }
+ /* This clock doesn't need migration because it is fixed-frequency */
+ clock_set_hz(s->sysclk, HCLK_FRQ);
+ qdev_connect_clock_in(DEVICE(&s->cpu), "cpuclk", s->sysclk);
+ /*
+ * This SoC has no systick device, so don't connect refclk.
+ * TODO: model the lack of systick (currently the armv7m object
+ * will always provide one).
+ */
+
system_clock_scale = NANOSECONDS_PER_SECOND / HCLK_FRQ;
object_property_set_link(OBJECT(&s->cpu), "memory", OBJECT(&s->container),
@@ -191,6 +209,8 @@ static void nrf51_soc_init(Object *obj)
TYPE_NRF51_TIMER);
}
+
+ s->sysclk = qdev_init_clock_in(DEVICE(s), "sysclk", NULL, NULL, 0);
}
static Property nrf51_soc_properties[] = {
diff --git a/include/hw/arm/nrf51_soc.h b/include/hw/arm/nrf51_soc.h
index f8a6725..e52a56e 100644
--- a/include/hw/arm/nrf51_soc.h
+++ b/include/hw/arm/nrf51_soc.h
@@ -17,6 +17,7 @@
#include "hw/gpio/nrf51_gpio.h"
#include "hw/nvram/nrf51_nvm.h"
#include "hw/timer/nrf51_timer.h"
+#include "hw/clock.h"
#include "qom/object.h"
#define TYPE_NRF51_SOC "nrf51-soc"
@@ -50,6 +51,7 @@ struct NRF51State {
MemoryRegion container;
+ Clock *sysclk;
};
#endif