@@ -296,18 +296,20 @@ static uint64_t imx_gpt_read(void *opaque, hwaddr
offset, unsigned size)
return reg_value;
}
-static void imx_gpt_reset(DeviceState *dev)
+static void imx_gpt_reset_common(IMXGPTState *s, int is_soft_reset)
{
- IMXGPTState *s = IMX_GPT(dev);
-
/* stop timer */
ptimer_stop(s->timer);
/*
* Soft reset doesn't touch some bits; hard reset clears them
*/
- s->cr &= ~(GPT_CR_EN|GPT_CR_ENMOD|GPT_CR_STOPEN|GPT_CR_DOZEN|
- GPT_CR_WAITEN|GPT_CR_DBGEN);
+ if (is_soft_reset) {
+ s->cr &= GPT_CR_EN|GPT_CR_ENMOD|GPT_CR_STOPEN|GPT_CR_DOZEN|
+ GPT_CR_WAITEN|GPT_CR_DBGEN;
+ } else {
+ s->cr = 0;
+ }
s->sr = 0;
s->pr = 0;
Ok, thank you for reply. Here is another patch. I have created different function for software reset (imx_gpt_soft_reset), and to prevent duplication extracted common code to imx_gpt_reset_common. Take a look, please. --- Subject: [PATCH] i.MX timers: fix software reset Software reset function clears CR bits that should not clear and preserve bits that should clear. Signed-off-by: Kurban Mallachiev <mallachiev@ispras.ru> --- hw/timer/imx_gpt.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) s->ir = 0; @@ -333,6 +335,18 @@ static void imx_gpt_reset(DeviceState *dev) } } +static void imx_gpt_soft_reset(DeviceState *dev) +{ + IMXGPTState *s = IMX_GPT(dev); + imx_gpt_reset_common(s, 1); +} + +static void imx_gpt_reset(DeviceState *dev) +{ + IMXGPTState *s = IMX_GPT(dev); + imx_gpt_reset_common(s, 0); +} + static void imx_gpt_write(void *opaque, hwaddr offset, uint64_t value, unsigned size) { @@ -348,7 +362,7 @@ static void imx_gpt_write(void *opaque, hwaddr offset, uint64_t value, s->cr = value & ~0x7c14; if (s->cr & GPT_CR_SWR) { /* force reset */ /* handle the reset */ - imx_gpt_reset(DEVICE(s)); + imx_gpt_soft_reset(DEVICE(s)); } else { /* set our freq, as the source might have changed */ imx_gpt_set_freq(s);