diff mbox series

[qemu.git,07/11] hw/timer/imx_epit: do not persist CR.SWR bit

Message ID 166718254546.5893.5075929684621857903-7@git.sr.ht (mailing list archive)
State New, archived
Headers show
Series improve hw/timer/imx_epit | expand

Commit Message

~axelheider Oct. 25, 2022, 6:06 p.m. UTC
From: Axel Heider <axel.heider@hensoldt.net>

Signed-off-by: Axel Heider <axel.heider@hensoldt.net>
---
 hw/timer/imx_epit.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/hw/timer/imx_epit.c b/hw/timer/imx_epit.c
index 2e4ff89613..bba9c87cd4 100644
--- a/hw/timer/imx_epit.c
+++ b/hw/timer/imx_epit.c
@@ -175,9 +175,12 @@  static void imx_epit_reload_compare_timer(IMXEPITState *s)
 static void imx_epit_write_cr(IMXEPITState *s, uint32_t value)
 {
     uint32_t freq = 0;
+
+    /* SWR bit is never persisted, it clears itself once reset is done */
     uint32_t oldcr = s->cr;
-    s->cr = value & 0x03ffffff;
-    if (s->cr & CR_SWR) {
+    s->cr = (value & ~CR_SWR) & 0x03ffffff;
+
+    if (value & CR_SWR) {
         /* handle the reset */
         imx_epit_reset(DEVICE(s));
         /*
@@ -189,7 +192,7 @@  static void imx_epit_write_cr(IMXEPITState *s, uint32_t value)
     ptimer_transaction_begin(s->timer_cmp);
     ptimer_transaction_begin(s->timer_reload);
 
-    if (!(s->cr & CR_SWR)) {
+    if (!(value & CR_SWR)) {
         freq = imx_epit_set_freq(s);
     }