[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 46/51] hw/arm/msf2-soc: Wire up refclk
From: |
Peter Maydell |
Subject: |
[PULL 46/51] hw/arm/msf2-soc: Wire up refclk |
Date: |
Wed, 1 Sep 2021 11:36:48 +0100 |
Wire up the refclk for the msf2 SoC. This SoC runs the refclk at a
frequency which is programmably either /4, /8, /16 or /32 of the main
CPU clock. We don't currently model the register which allows the
guest to set the divisor, so implement the refclk as a fixed /32 of
the CPU clock (which is the value of the divisor at reset).
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Damien Hedde <damien.hedde@greensocs.com>
Message-id: 20210812093356.1946-21-peter.maydell@linaro.org
---
include/hw/arm/msf2-soc.h | 1 +
hw/arm/msf2-soc.c | 23 +++++++++++++++++++++++
2 files changed, 24 insertions(+)
diff --git a/include/hw/arm/msf2-soc.h b/include/hw/arm/msf2-soc.h
index 01f904cec47..ce417a6266a 100644
--- a/include/hw/arm/msf2-soc.h
+++ b/include/hw/arm/msf2-soc.h
@@ -59,6 +59,7 @@ struct MSF2State {
uint64_t esram_size;
Clock *m3clk;
+ Clock *refclk;
uint8_t apb0div;
uint8_t apb1div;
diff --git a/hw/arm/msf2-soc.c b/hw/arm/msf2-soc.c
index 0a1e594aee6..dbc6d936a76 100644
--- a/hw/arm/msf2-soc.c
+++ b/hw/arm/msf2-soc.c
@@ -76,6 +76,7 @@ static void m2sxxx_soc_initfn(Object *obj)
object_initialize_child(obj, "emac", &s->emac, TYPE_MSS_EMAC);
s->m3clk = qdev_init_clock_in(DEVICE(obj), "m3clk", NULL, NULL, 0);
+ s->refclk = qdev_init_clock_in(DEVICE(obj), "refclk", NULL, NULL, 0);
}
static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp)
@@ -92,6 +93,27 @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error
**errp)
return;
}
+ /*
+ * We use s->refclk internally and only define it with qdev_init_clock_in()
+ * so it is correctly parented and not leaked on an init/deinit; it is not
+ * intended as an externally exposed clock.
+ */
+ if (clock_has_source(s->refclk)) {
+ error_setg(errp, "refclk must not be wired up by the board code");
+ return;
+ }
+
+ /*
+ * TODO: ideally we should model the SoC SYSTICK_CR register at 0xe0042038,
+ * which allows the guest to program the divisor between the m3clk and
+ * the systick refclk to either /4, /8, /16 or /32, as well as setting
+ * the value the guest can read in the STCALIB register. Currently we
+ * implement the divisor as a fixed /32, which matches the reset value
+ * of SYSTICK_CR.
+ */
+ clock_set_mul_div(s->refclk, 32, 1);
+ clock_set_source(s->refclk, s->m3clk);
+
memory_region_init_rom(&s->nvm, OBJECT(dev_soc), "MSF2.eNVM", s->envm_size,
&error_fatal);
/*
@@ -115,6 +137,7 @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error
**errp)
qdev_prop_set_string(armv7m, "cpu-type", s->cpu_type);
qdev_prop_set_bit(armv7m, "enable-bitband", true);
qdev_connect_clock_in(armv7m, "cpuclk", s->m3clk);
+ qdev_connect_clock_in(armv7m, "refclk", s->refclk);
object_property_set_link(OBJECT(&s->armv7m), "memory",
OBJECT(get_system_memory()), &error_abort);
if (!sysbus_realize(SYS_BUS_DEVICE(&s->armv7m), errp)) {
--
2.20.1
- [PULL 30/51] hw/timer/armv7m_systick: Add usual QEMU interface comment, (continued)
- [PULL 30/51] hw/timer/armv7m_systick: Add usual QEMU interface comment, Peter Maydell, 2021/09/01
- [PULL 36/51] hw/arm: Don't allocate separate MemoryRegions in stm32 SoC realize, Peter Maydell, 2021/09/01
- [PULL 39/51] hw/arm/stm32f405: Wire up sysclk and refclk, Peter Maydell, 2021/09/01
- [PULL 37/51] hw/arm/stm32f100: Wire up sysclk and refclk, Peter Maydell, 2021/09/01
- [PULL 43/51] hw/arm/stellaris: Wire sysclk up to armv7m, Peter Maydell, 2021/09/01
- [PULL 35/51] clock: Provide builtin multiplier/divider, Peter Maydell, 2021/09/01
- [PULL 34/51] hw/arm/mps2.c: Connect up armv7m clocks, Peter Maydell, 2021/09/01
- [PULL 45/51] hw/arm/msf2: Use Clock input to MSF2_SOC instead of m3clk property, Peter Maydell, 2021/09/01
- [PULL 41/51] hw/arm/nrf51: Wire up sysclk, Peter Maydell, 2021/09/01
- [PULL 48/51] hw/arm/stellaris: Fix code style issues in GPTM code, Peter Maydell, 2021/09/01
- [PULL 46/51] hw/arm/msf2-soc: Wire up refclk,
Peter Maydell <=
- [PULL 23/51] target/arm: Enable MVE in Cortex-M55, Peter Maydell, 2021/09/01
- [PULL 25/51] hw/arm/virt: target-arm: Add A64FX processor support to virt machine, Peter Maydell, 2021/09/01
- [PULL 28/51] arm: Move systick device creation from NVIC to ARMv7M object, Peter Maydell, 2021/09/01
- [PULL 29/51] arm: Move system PPB container handling to armv7m, Peter Maydell, 2021/09/01
- [PULL 40/51] hw/arm/stm32vldiscovery: Delete trailing blank line, Peter Maydell, 2021/09/01
- [PULL 47/51] hw/timer/armv7m_systick: Use clock inputs instead of system_clock_scale, Peter Maydell, 2021/09/01
- [PULL 38/51] hw/arm/stm32f205: Wire up sysclk and refclk, Peter Maydell, 2021/09/01
- [PULL 44/51] hw/arm/msf2_soc: Don't allocate separate MemoryRegions, Peter Maydell, 2021/09/01
- [PULL 51/51] arm: Remove system_clock_scale global, Peter Maydell, 2021/09/01
- [PULL 26/51] tests/arm-cpu-features: Add A64FX processor related tests, Peter Maydell, 2021/09/01