@samitouri / QOSamiQemu / commits / 1e763ed148

hw/misc/imx8mp_analog: Add property to analog device

Add configurable properties for register reset values that differ between i.MX 8M variants (Plus, Mini, etc.). This allows the same device implementation to be shared across multiple SoCs. Properties added: - arm-pll-fdiv-ctl0-reset: ARM PLL divider control reset value Default value is set to match i.MX 8MP reset value (0x000FA031). This can be overridden in the variant like iMX8MM with its own reset value. Reviewed-by: Bernhard Beschow <shentey@gmail.com> Signed-off-by: Gaurav Sharma <gaurav.sharma_7@nxp.com> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Gaurav Sharma committed Apr 21, 2026 at 12:22 UTC 1e763ed148b8b5e0d5ce19c421ac571bbd44ed58
2 files changed +14 -1
hw/misc/imx8mp_analog.c
+11 -1
@@ -12,6 +12,7 @@
12 #include "qemu/log.h"
13
14 #include "hw/misc/imx8mp_analog.h"
15 +#include "hw/core/qdev-properties.h"
16 #include "migration/vmstate.h"
17
18 #define ANALOG_PLL_LOCK BIT(31)
@@ -51,7 +52,10 @@ static void imx8mp_analog_reset(DeviceState *dev)
52 s->analog[ANALOG_VPU_PLL_LOCKD_CTRL] = 0x0010003f;
53 s->analog[ANALOG_VPU_PLL_MNIT_CTRL] = 0x00280081;
54 s->analog[ANALOG_ARM_PLL_GEN_CTRL] = 0x00000810;
54 - s->analog[ANALOG_ARM_PLL_FDIV_CTL0] = 0x000fa031;
55 +
56 + /* Use property value instead of hardcoded */
57 + s->analog[ANALOG_ARM_PLL_FDIV_CTL0] = s->arm_pll_fdiv_ctl0_reset;
58 +
59 s->analog[ANALOG_ARM_PLL_LOCKD_CTRL] = 0x0010003f;
60 s->analog[ANALOG_ARM_PLL_MNIT_CTRL] = 0x00280081;
61 s->analog[ANALOG_SYS_PLL1_GEN_CTRL] = 0x0aaaa810;
@@ -138,11 +142,17 @@ static const VMStateDescription imx8mp_analog_vmstate = {
142 },
143 };
144
145 +static const Property imx8mp_analog_properties[] = {
146 + DEFINE_PROP_UINT32("arm-pll-fdiv-ctl0-reset", IMX8MPAnalogState,
147 + arm_pll_fdiv_ctl0_reset, 0x000fa031), /* imx8mp default */
148 +};
149 +
150 static void imx8mp_analog_class_init(ObjectClass *klass, const void *data)
151 {
152 DeviceClass *dc = DEVICE_CLASS(klass);
153
154 device_class_set_legacy_reset(dc, imx8mp_analog_reset);
155 + device_class_set_props(dc, imx8mp_analog_properties);
156 dc->vmsd = &imx8mp_analog_vmstate;
157 dc->desc = "i.MX 8M Plus Analog Module";
158 }
include/hw/misc/imx8mp_analog.h
+3
@@ -76,6 +76,9 @@ struct IMX8MPAnalogState {
76 } mmio;
77
78 uint32_t analog[ANALOG_MAX];
79 +
80 + /* Property for variant-specific reset values */
81 + uint32_t arm_pll_fdiv_ctl0_reset;
82 };
83
84 #endif /* IMX8MP_ANALOG_H */