@@ -26,6 +26,7 @@
#include "hw/clock.h"
#include "hw/irq.h"
#include "hw/qdev-clock.h"
+#include "qapi/visitor.h"
#include "hw/qdev-properties.h"
#include "hw/qdev-properties-system.h"
#include "hw/registerfields.h"
@@ -523,6 +524,14 @@ static Property stm32l4x5_usart_base_properties[] = {
DEFINE_PROP_END_OF_LIST(),
};
+static void clock_freq_get(Object *obj, Visitor *v,
+ const char *name, void *opaque, Error **errp)
+{
+ Stm32l4x5UsartBaseState *s = STM32L4X5_USART_BASE(obj);
+ uint32_t clock_freq_hz = clock_get_hz(s->clk);
+ visit_type_uint32(v, name, &clock_freq_hz, errp);
+}
+
static void stm32l4x5_usart_base_init(Object *obj)
{
Stm32l4x5UsartBaseState *s = STM32L4X5_USART_BASE(obj);
@@ -534,6 +543,9 @@ static void stm32l4x5_usart_base_init(Object *obj)
sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->mmio);
s->clk = qdev_init_clock_in(DEVICE(s), "clk", NULL, s, 0);
+
+ object_property_add(obj, "clock-freq-hz", "uint32",
+ clock_freq_get, NULL, NULL, NULL);
}
static int stm32l4x5_usart_base_post_load(void *opaque, int version_id)
@@ -546,8 +558,8 @@ static int stm32l4x5_usart_base_post_load(void *opaque, int version_id)
static const VMStateDescription vmstate_stm32l4x5_usart_base = {
.name = TYPE_STM32L4X5_USART_BASE,
- .version_id = 1,
- .minimum_version_id = 1,
+ .version_id = 2,
+ .minimum_version_id = 2,
.post_load = stm32l4x5_usart_base_post_load,
.fields = (VMStateField[]) {
VMSTATE_UINT32(cr1, Stm32l4x5UsartBaseState),
This QOM property will be used to check the clock frequency from QTests. Signed-off-by: Inès Varhol <ines.varhol@telecom-paris.fr> --- hw/char/stm32l4x5_usart.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)