hw/arm: Implement i.MX watchdog support
v2 cover hw/arm: Implement i.MX watchdog support
The current i.MX watchdog implementation only supports resets. This patch series implements the full watchdog, including optional pretimeout support.
Notable changes:
- The existing i.MX watchdog emulation (which only emulates syste resets) is moved from hw/misc to hw/watchdog and renamed to match the naming convention in hw/watchdog (patch 1/8).
- Full watchdog support is implemented in patch 2/8.
- The watchdog is wired up for i.MX25 and i.MX31 emulations (patch 3/8 and 4/8).
- The watchdog interrupt (for pretimeout support) is connected for i.MX6, i.MX6UL, and i.MX7 emulations (patch 5/8, 6/8, and 8/8).
- For i.MX7, various devices are wired up as unimplemented devices (patch 7/8). This was necessary to avoid crashes when booting recent Linux kernels.
The code was tested with all available emulations.
v2: Select WDT_IMX2 explicitly for supported platforms, not automatically
with IMX
Rebased to current master (as of 3/22)
Fixed typo "octop" -> "ocotp"
Added Reviewed-by: tags where given
----------------------------------------------------------------
Guenter Roeck (8):
hw: Move i.MX watchdog driver to hw/watchdog hw/watchdog: Implement full i.MX watchdog support hw/arm/fsl-imx25: Wire up watchdog hw/arm/fsl-imx31: Wire up watchdog hw/arm/fsl-imx6: Connect watchdog interrupts hw/arm/fsl-imx6ul: Connect watchdog interrupts hw/arm/fsl-imx7: Instantiate various unimplemented devices hw/arm/fsl-imx7: Connect watchdog interrupts
MAINTAINERS | 2 + hw/arm/Kconfig | 5 + hw/arm/fsl-imx25.c | 10 ++ hw/arm/fsl-imx31.c | 6 + hw/arm/fsl-imx6.c | 9 ++ hw/arm/fsl-imx6ul.c | 10 ++ hw/arm/fsl-imx7.c | 35 ++++++ hw/misc/Makefile.objs | 1 - hw/misc/imx2_wdt.c | 90 -------------- hw/watchdog/Kconfig | 3 + hw/watchdog/Makefile.objs | 1 + hw/watchdog/wdt_imx2.c | 262 +++++++++++++++++++++++++++++++++++++++++ include/hw/arm/fsl-imx25.h | 5 + include/hw/arm/fsl-imx31.h | 4 + include/hw/arm/fsl-imx6.h | 2 +- include/hw/arm/fsl-imx6ul.h | 2 +- include/hw/arm/fsl-imx7.h | 23 +++- include/hw/misc/imx2_wdt.h | 33 ------ include/hw/watchdog/wdt_imx2.h | 78 ++++++++++++ 19 files changed, 454 insertions(+), 127 deletions(-) delete mode 100644 hw/misc/imx2_wdt.c create mode 100644 hw/watchdog/wdt_imx2.c delete mode 100644 include/hw/misc/imx2_wdt.h create mode 100644 include/hw/watchdog/wdt_imx2.h
PATCH v2 1/8 hw: Move i.MX watchdog driver to hw/watchdog
In preparation for a full implementation, move i.MX watchdog driver from hw/misc to hw/watchdog. While at it, add the watchdog files to MAINTAINERS.
---
v2: Instead of auto-selecting WDT_IMX2 if IMX is enabled, select it
explicitly for each emulation using it.
In Makefile, fix CONFIG_WDT_IMX -> CONFIG_WDT_IMX2 Added Philippe's Reviewed-by: tag
MAINTAINERS | 2 ++
hw/arm/Kconfig | 3 +++
hw/misc/Makefile.objs | 1 -
hw/watchdog/Kconfig | 3 +++
hw/watchdog/Makefile.objs | 1 +
hw/{misc/imx2_wdt.c => watchdog/wdt_imx2.c} | 2 +-
include/hw/arm/fsl-imx6.h | 2 +-
include/hw/arm/fsl-imx6ul.h | 2 +-
include/hw/arm/fsl-imx7.h | 2 +-
include/hw/{misc/imx2_wdt.h => watchdog/wdt_imx2.h} | 0
10 files changed, 13 insertions(+), 5 deletions(-)
rename hw/{misc/imx2_wdt.c => watchdog/wdt_imx2.c} (98%)
rename include/hw/{misc/imx2_wdt.h => watchdog/wdt_imx2.h} (100%)MAINTAINERS +2 -0
@@ -620,8 +620,10 @@ S: Odd Fixes F: hw/arm/fsl-imx25.c F: hw/arm/imx25_pdk.c F: hw/misc/imx25_ccm.c +F: hw/watchdog/wdt_imx2.c F: include/hw/arm/fsl-imx25.h F: include/hw/misc/imx25_ccm.h +F: include/hw/watchdog/wdt_imx2.h i.MX31 (kzm) M: Peter Chubb <[email protected]>
hw/arm/Kconfig +3 -0
@@ -374,6 +374,7 @@ config FSL_IMX6 select IMX_FEC select IMX_I2C select IMX_USBPHY + select WDT_IMX2 select SDHCI config ASPEED_SOC
@@ -411,6 +412,7 @@ config FSL_IMX7 select IMX select IMX_FEC select IMX_I2C + select WDT_IMX2 select PCI_EXPRESS_DESIGNWARE select SDHCI select UNIMP
@@ -424,6 +426,7 @@ config FSL_IMX6UL select IMX select IMX_FEC select IMX_I2C + select WDT_IMX2 select SDHCI select UNIMP
hw/misc/Makefile.objs +0 -1
@@ -44,7 +44,6 @@ common-obj-$(CONFIG_IMX) += imx6_ccm.o common-obj-$(CONFIG_IMX) += imx6ul_ccm.o obj-$(CONFIG_IMX) += imx6_src.o common-obj-$(CONFIG_IMX) += imx7_ccm.o -common-obj-$(CONFIG_IMX) += imx2_wdt.o common-obj-$(CONFIG_IMX) += imx7_snvs.o common-obj-$(CONFIG_IMX) += imx7_gpr.o common-obj-$(CONFIG_IMX) += imx_rngc.o
hw/watchdog/Kconfig +3 -0
@@ -14,3 +14,6 @@ config WDT_IB700 config WDT_DIAG288 bool + +config WDT_IMX2 + bool
hw/watchdog/Makefile.objs +1 -0
@@ -4,3 +4,4 @@ common-obj-$(CONFIG_WDT_IB6300ESB) += wdt_i6300esb.o common-obj-$(CONFIG_WDT_IB700) += wdt_ib700.o common-obj-$(CONFIG_WDT_DIAG288) += wdt_diag288.o common-obj-$(CONFIG_ASPEED_SOC) += wdt_aspeed.o +common-obj-$(CONFIG_WDT_IMX2) += wdt_imx2.o
hw/watchdog/wdt_imx2.c renamed from hw/misc/imx2_wdt.c +1 -1
@@ -14,7 +14,7 @@#include "qemu/module.h" #include "sysemu/watchdog.h" -#include "hw/misc/imx2_wdt.h" +#include "hw/watchdog/wdt_imx2.h" #define IMX2_WDT_WCR_WDA BIT(5)/* -> External Reset WDOG_B */ #define IMX2_WDT_WCR_SRS BIT(4)/* -> Software Reset Signal */
include/hw/arm/fsl-imx6.h +1 -1
@@ -21,7 +21,7 @@#include "hw/cpu/a9mpcore.h" #include "hw/misc/imx6_ccm.h" #include "hw/misc/imx6_src.h" -#include "hw/misc/imx2_wdt.h" +#include "hw/watchdog/wdt_imx2.h" #include "hw/char/imx_serial.h" #include "hw/timer/imx_gpt.h" #include "hw/timer/imx_epit.h"
include/hw/arm/fsl-imx6ul.h +1 -1
@@ -24,7 +24,7 @@#include "hw/misc/imx7_snvs.h" #include "hw/misc/imx7_gpr.h" #include "hw/intc/imx_gpcv2.h" -#include "hw/misc/imx2_wdt.h" +#include "hw/watchdog/wdt_imx2.h" #include "hw/gpio/imx_gpio.h" #include "hw/char/imx_serial.h" #include "hw/timer/imx_gpt.h"
include/hw/arm/fsl-imx7.h +1 -1
@@ -26,7 +26,7 @@#include "hw/misc/imx7_snvs.h" #include "hw/misc/imx7_gpr.h" #include "hw/misc/imx6_src.h" -#include "hw/misc/imx2_wdt.h" +#include "hw/watchdog/wdt_imx2.h" #include "hw/gpio/imx_gpio.h" #include "hw/char/imx_serial.h" #include "hw/timer/imx_gpt.h"
include/hw/watchdog/wdt_imx2.h renamed from include/hw/misc/imx2_wdt.h +0 -0
Signature · 1 line
2.17.1
PATCH v2 2/8 hw/watchdog: Implement full i.MX watchdog support
In reply to Guenter RoeckImplement full support for the watchdog in i.MX systems. Pretimeout support is optional because the watchdog hardware on i.MX31 does not support pretimeouts.
---
v2: Fixup of CONFIG_WDT_IMX -> CONFIG_WDT_IMX2 moved to patch 1/8
hw/watchdog/wdt_imx2.c | 196 +++++++++++++++++++++++++++++++-- include/hw/watchdog/wdt_imx2.h | 49 ++++++++- 2 files changed, 231 insertions(+), 14 deletions(-)
hw/watchdog/wdt_imx2.c +184 -12
@@ -13,24 +13,157 @@#include "qemu/bitops.h" #include "qemu/module.h" #include "sysemu/watchdog.h" +#include "migration/vmstate.h" +#include "hw/qdev-properties.h" #include "hw/watchdog/wdt_imx2.h" -#define IMX2_WDT_WCR_WDA BIT(5)/* -> External Reset WDOG_B */ -#define IMX2_WDT_WCR_SRS BIT(4)/* -> Software Reset Signal */ +static void imx2_wdt_interrupt (void *opaque) +{ +IMX2WdtState *s =IMX2_WDT (opaque); + + s->wicr |=IMX2_WDT_WICR_WTIS ; +qemu_set_irq (s->irq,1 ); +} -static uint64_t imx2_wdt_read (void *opaque,hwaddr addr, -unsigned int size) +static void imx2_wdt_expired (void *opaque) { +IMX2WdtState *s =IMX2_WDT (opaque); + + s->wrsr =IMX2_WDT_WRSR_TOUT ; + +/* Perform watchdog action if watchdog is enabled */ +if (s->wcr &IMX2_WDT_WCR_WDE ) { +watchdog_perform_action (); + } +} + +static void imx2_wdt_reset (DeviceState *dev) +{ +IMX2WdtState *s =IMX2_WDT (dev); + + s->wcr =IMX2_WDT_WCR_WDA |IMX2_WDT_WCR_SRS ; + s->wsr =0 ; + s->wrsr &= ~(IMX2_WDT_WRSR_TOUT |IMX2_WDT_WRSR_SFTW ); + s->wicr =4 ; + s->wmcr =IMX2_WDT_WMCR_PDE ; +} + +static uint64_t imx2_wdt_read (void *opaque,hwaddr addr,unsigned int size) +{ +IMX2WdtState *s =IMX2_WDT (opaque); + +switch (addr) { +case IMX2_WDT_WCR : +return s->wcr; +case IMX2_WDT_WSR : +return s->wsr; +case IMX2_WDT_WRSR : +return s->wrsr; +case IMX2_WDT_WICR : +return s->wicr; +case IMX2_WDT_WMCR : +return s->wmcr; + }return 0 ; } +static void imx_wdt2_update_itimer (IMX2WdtState *s,bool start) +{ +bool running = (s->wcr &IMX2_WDT_WCR_WDE ) && (s->wcr &IMX2_WDT_WCR_WT ); +bool enabled = s->wicr &IMX2_WDT_WICR_WIE ; + +ptimer_transaction_begin (s->itimer); +if (start || !enabled) { +ptimer_stop (s->itimer); + } +if (running && enabled) { +int count =ptimer_get_count (s->timer); +int pretimeout = s->wicr &IMX2_WDT_WICR_WICT ; + +/* +* Only (re-)start pretimeout timer if its counter value is larger +* than 0. Otherwise it will fire right away and we'll get an +* interrupt loop. +*/ +if (count > pretimeout) { +ptimer_set_count (s->itimer, count - pretimeout); +if (start) { +ptimer_run (s->itimer,1 ); + } + } + } +ptimer_transaction_commit (s->itimer); +} + +static void imx_wdt2_update_timer (IMX2WdtState *s,bool start) +{ +ptimer_transaction_begin (s->timer); +if (start) { +ptimer_stop (s->timer); + } +if ((s->wcr &IMX2_WDT_WCR_WDE ) && (s->wcr &IMX2_WDT_WCR_WT )) { +int count = (s->wcr &IMX2_WDT_WCR_WT ) >>8 ; + +ptimer_set_count (s->timer, count); +if (start) { +ptimer_run (s->timer,1 ); + } + } +ptimer_transaction_commit (s->timer); +if (s->pretimeout_support) { +imx_wdt2_update_itimer (s, start); + } +} +static void imx2_wdt_write (void *opaque,hwaddr addr,uint64_t value,unsigned int size) { -if (addr ==IMX2_WDT_WCR && - (~value & (IMX2_WDT_WCR_WDA |IMX2_WDT_WCR_SRS ))) { -watchdog_perform_action (); +IMX2WdtState *s =IMX2_WDT (opaque); + +switch (addr) { +case IMX2_WDT_WCR : + s->wcr = value; +if (!(value &IMX2_WDT_WCR_SRS )) { + s->wrsr =IMX2_WDT_WRSR_SFTW ; + } +if (!(value & (IMX2_WDT_WCR_WDA |IMX2_WDT_WCR_SRS )) || + (!(value &IMX2_WDT_WCR_WT ) && (value &IMX2_WDT_WCR_WDE ))) { +watchdog_perform_action (); + } + s->wcr |=IMX2_WDT_WCR_SRS ; +imx_wdt2_update_timer (s, true); +break ; +case IMX2_WDT_WSR : +if (s->wsr ==IMX2_WDT_SEQ1 && value ==IMX2_WDT_SEQ2 ) { +imx_wdt2_update_timer (s, false); + } + s->wsr = value; +break ; +case IMX2_WDT_WRSR : +break ; +case IMX2_WDT_WICR : +if (!s->pretimeout_support) { +return ; + } +/* The pretimeout value is write-once */ +if (s->pretimeout_locked) { + value &= ~IMX2_WDT_WICR_WICT ; + s->wicr &= (IMX2_WDT_WICR_WTIS |IMX2_WDT_WICR_WICT ); + }else { + s->wicr &=IMX2_WDT_WICR_WTIS ; + } + s->wicr |= value & (IMX2_WDT_WICR_WIE |IMX2_WDT_WICR_WICT ); +if (value &IMX2_WDT_WICR_WTIS ) { + s->wicr &= ~IMX2_WDT_WICR_WTIS ; +qemu_set_irq (s->irq,0 ); + } +imx_wdt2_update_itimer (s, true); + s->pretimeout_locked = true; +break ; +case IMX2_WDT_WMCR : + s->wmcr = value &IMX2_WDT_WMCR_PDE ; +break ; } }
@@ -45,28 +178,67 @@ static const MemoryRegionOps imx2_wdt_ops = {* real device but in practice there is no reason for a guest * to access this device unaligned. */ - .min_access_size = 4, - .max_access_size = 4, + .min_access_size = 2, + .max_access_size = 2, .unaligned = false, }, }; +static const VMStateDescription vmstate_imx2_wdt = { + .name ="imx2.wdt" , + .fields = (VMStateField []) { +VMSTATE_PTIMER (timer, IMX2WdtState), +VMSTATE_PTIMER (itimer, IMX2WdtState), +VMSTATE_BOOL (pretimeout_locked, IMX2WdtState), +VMSTATE_UINT16 (wcr, IMX2WdtState), +VMSTATE_UINT16 (wsr, IMX2WdtState), +VMSTATE_UINT16 (wrsr, IMX2WdtState), +VMSTATE_UINT16 (wmcr, IMX2WdtState), +VMSTATE_UINT16 (wicr, IMX2WdtState), +VMSTATE_END_OF_LIST () + } +}; +static void imx2_wdt_realize (DeviceState *dev,Error **errp) {IMX2WdtState *s =IMX2_WDT (dev); +SysBusDevice *sbd =SYS_BUS_DEVICE (dev);memory_region_init_io (&s->mmio,OBJECT (dev), &imx2_wdt_ops, s, -TYPE_IMX2_WDT ".mmio" , -IMX2_WDT_REG_NUM *sizeof (uint16_t )); -sysbus_init_mmio (SYS_BUS_DEVICE (dev), &s->mmio); +TYPE_IMX2_WDT , +IMX2_WDT_MMIO_SIZE ); +sysbus_init_mmio (sbd, &s->mmio); +sysbus_init_irq (sbd, &s->irq); + + s->timer =ptimer_init (imx2_wdt_expired, s,PTIMER_POLICY_DEFAULT ); +ptimer_transaction_begin (s->timer); +ptimer_set_freq (s->timer,2 ); +ptimer_set_limit (s->timer,0xff ,1 ); +ptimer_transaction_commit (s->timer); +if (s->pretimeout_support) { + s->itimer =ptimer_init (imx2_wdt_interrupt, s,PTIMER_POLICY_DEFAULT ); +ptimer_transaction_begin (s->itimer); +ptimer_set_freq (s->itimer,2 ); +ptimer_set_limit (s->itimer,0xff ,1 ); +ptimer_transaction_commit (s->itimer); + } } +static Property imx2_wdt_properties[] = { +DEFINE_PROP_BOOL ("pretimeout-support" , IMX2WdtState, pretimeout_support, + false), +}; +static void imx2_wdt_class_init (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass); +device_class_set_props (dc, imx2_wdt_properties); dc->realize = imx2_wdt_realize; + dc->reset = imx2_wdt_reset; + dc->vmsd = &vmstate_imx2_wdt; + dc->desc ="i.MX watchdog timer" ;set_bit (DEVICE_CATEGORY_MISC , dc->categories); }
include/hw/watchdog/wdt_imx2.h +47 -2
69 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [PATCH v2 2/8] hw/watchdog: Implement full i.MX watchdog support
Quoted 8 lines · Guenter Roeck
Implement full support for the watchdog in i.MX systems. Pretimeout support is optional because the watchdog hardware on i.MX31 does not support pretimeouts.
Signed-off-by Guenter Roeck <[email protected]>---
v2: Fixup ofCONFIG_WDT_IMX->CONFIG_WDT_IMX2moved to patch 1/8
Sorry for not getting to this earlier, I've been focusing on work for the 5.0 release. Some comments below, but overall this looks pretty good.
Quoted 41 lines
hw/watchdog/wdt_imx2.c | 196 +++++++++++++++++++++++++++++++-- include/hw/watchdog/wdt_imx2.h | 49 ++++++++- 2 files changed, 231 insertions(+), 14 deletions(-)hw/watchdog/wdt_imx2.c +19
-4@@ -13,24 +13,157 @@#include "qemu/bitops.h" #include "qemu/module.h" #include "sysemu/watchdog.h" +#include "migration/vmstate.h" +#include "hw/qdev-properties.h" #include "hw/watchdog/wdt_imx2.h" -#define IMX2_WDT_WCR_WDA BIT(5)/* -> External Reset WDOG_B */ -#define IMX2_WDT_WCR_SRS BIT(4)/* -> Software Reset Signal */ +static void imx2_wdt_interrupt (void *opaque) +{ +IMX2WdtState *s =IMX2_WDT (opaque); + + s->wicr |=IMX2_WDT_WICR_WTIS ; +qemu_set_irq (s->irq,1 ); +} -static uint64_t imx2_wdt_read (void *opaque,hwaddr addr, -unsigned int size) +static void imx2_wdt_expired (void *opaque) { +IMX2WdtState *s =IMX2_WDT (opaque); + + s->wrsr =IMX2_WDT_WRSR_TOUT ; + +/* Perform watchdog action if watchdog is enabled */ +if (s->wcr &IMX2_WDT_WCR_WDE ) { +watchdog_perform_action (); + } +}
hw/watchdog/wdt_imx2.c line 49
Quoted 10 lines
hw/watchdog/wdt_imx2.c +10
-0+ +static void imx2_wdt_reset (DeviceState *dev) +{ +IMX2WdtState *s =IMX2_WDT (dev); + + s->wcr =IMX2_WDT_WCR_WDA |IMX2_WDT_WCR_SRS ; + s->wsr =0 ; + s->wrsr &= ~(IMX2_WDT_WRSR_TOUT |IMX2_WDT_WRSR_SFTW ); + s->wicr =4 ; + s->wmcr =IMX2_WDT_WMCR_PDE ;
Your reset function probably also needs to ptimer_stop() the timers or otherwise put them into whatever is the correct state for the device-as-reset.
Quoted 27 lines
hw/watchdog/wdt_imx2.c +20
-3+} +static void imx2_wdt_write (void *opaque,hwaddr addr,uint64_t value,unsigned int size) { -if (addr ==IMX2_WDT_WCR && - (~value & (IMX2_WDT_WCR_WDA |IMX2_WDT_WCR_SRS ))) { -watchdog_perform_action (); +IMX2WdtState *s =IMX2_WDT (opaque); + +switch (addr) { +case IMX2_WDT_WCR : + s->wcr = value; +if (!(value &IMX2_WDT_WCR_SRS )) { + s->wrsr =IMX2_WDT_WRSR_SFTW ; + } +if (!(value & (IMX2_WDT_WCR_WDA |IMX2_WDT_WCR_SRS )) || + (!(value &IMX2_WDT_WCR_WT ) && (value &IMX2_WDT_WCR_WDE ))) { +watchdog_perform_action (); + } + s->wcr |=IMX2_WDT_WCR_SRS ; +imx_wdt2_update_timer (s, true); +break ; +case IMX2_WDT_WSR : +if (s->wsr ==IMX2_WDT_SEQ1 && value ==IMX2_WDT_SEQ2 ) { +imx_wdt2_update_timer (s, false);
hw/watchdog/wdt_imx2.c line 149
Quoted 10 lines
hw/watchdog/wdt_imx2.c +10
-0+ } + s->wsr = value; +break ; +case IMX2_WDT_WRSR : +break ; +case IMX2_WDT_WICR : +if (!s->pretimeout_support) { +return ; + } +/* The pretimeout value is write-once */
My imx6 manual says that the WICR WIE bit is also write-once, so I think that changes to it should also be guarded under !pretimeout_locked, like the WICT bits.
(In fact quite a lot of registers seem to have write-once bits.)
Quoted 26 lines
hw/watchdog/wdt_imx2.c +18
-0+if (s->pretimeout_locked) { + value &= ~IMX2_WDT_WICR_WICT ; + s->wicr &= (IMX2_WDT_WICR_WTIS |IMX2_WDT_WICR_WICT ); + }else { + s->wicr &=IMX2_WDT_WICR_WTIS ; + } + s->wicr |= value & (IMX2_WDT_WICR_WIE |IMX2_WDT_WICR_WICT ); +if (value &IMX2_WDT_WICR_WTIS ) { + s->wicr &= ~IMX2_WDT_WICR_WTIS ; +qemu_set_irq (s->irq,0 ); + } +imx_wdt2_update_itimer (s, true); + s->pretimeout_locked = true; +break ; +case IMX2_WDT_WMCR : + s->wmcr = value &IMX2_WDT_WMCR_PDE ; +break ; } }static void imx2_wdt_realize (DeviceState *dev,Error **errp) {IMX2WdtState *s =IMX2_WDT (dev); +SysBusDevice *sbd =SYS_BUS_DEVICE (dev); memory_region_init_io(&s->mmio, OBJECT(dev),
hw/watchdog/wdt_imx2.c
Quoted 10 lines
hw/watchdog/wdt_imx2.c +6
-3&imx2_wdt_ops, s, -TYPE_IMX2_WDT ".mmio" , - IMX2_WDT_REG_NUM * sizeof(uint16_t)); -sysbus_init_mmio (SYS_BUS_DEVICE (dev), &s->mmio); +TYPE_IMX2_WDT , + IMX2_WDT_MMIO_SIZE); +sysbus_init_mmio (sbd, &s->mmio); +sysbus_init_irq (sbd, &s->irq); + + s->timer =ptimer_init (imx2_wdt_expired, s,PTIMER_POLICY_DEFAULT );
PTIMER_POLICY_DEFAULT is almost never the right thing: it basically means "same as the old legacy behaviour of our first somewhat-broken implementation of ptimer". The comments in include/hw/ptimer.h suggests some behaviours real timers tend to have which can be enabled with suitable bits. If the default really is the right thing for this timer then a comment is helpful to indicate that we've looked at this and made an active decision to use the 'default' rather than the timer implementation just having been grandfathered in.
hw/watchdog/wdt_imx2.c static const MemoryRegionOps imx2_wdt_ops = { · line 226
Quoted 12 lines
hw/watchdog/wdt_imx2.c +11
-0+ptimer_transaction_begin (s->timer); +ptimer_set_freq (s->timer,2 ); +ptimer_set_limit (s->timer,0xff ,1 ); +ptimer_transaction_commit (s->timer); +if (s->pretimeout_support) { + s->itimer =ptimer_init (imx2_wdt_interrupt, s,PTIMER_POLICY_DEFAULT ); +ptimer_transaction_begin (s->itimer); +ptimer_set_freq (s->itimer,2 ); +ptimer_set_limit (s->itimer,0xff ,1 ); +ptimer_transaction_commit (s->itimer); + } }
thanks
-- PMM
PATCH v2 3/8 hw/arm/fsl-imx25: Wire up watchdog
In reply to Guenter RoeckWith this commit, the watchdog on imx25-pdk is fully operational, including pretimeout support.
---
v2: Select WDT_IMX2 explicitly
Added Philippe's Reviewed-by: tag
hw/arm/Kconfig | 1 + hw/arm/fsl-imx25.c | 10 ++++++++++ include/hw/arm/fsl-imx25.h | 5 +++++ 3 files changed, 16 insertions(+)
hw/arm/Kconfig +1 -0
@@ -358,6 +358,7 @@ config FSL_IMX25 select IMX select IMX_FEC select IMX_I2C + select WDT_IMX2 select DS1338 config FSL_IMX31
hw/arm/fsl-imx25.c +10 -0
@@ -87,6 +87,7 @@ static void fsl_imx25_init(Object *obj) TYPE_CHIPIDEA); } +sysbus_init_child_obj (obj,"wdt" , &s->wdt,sizeof (s->wdt),TYPE_IMX2_WDT ); }static void fsl_imx25_realize (DeviceState *dev,Error **errp)
@@ -302,6 +303,15 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp) usb_table[i].irq)); } +/* Watchdog */ +object_property_set_bool (OBJECT (&s->wdt), true,"pretimeout-support" , + &error_abort); +object_property_set_bool (OBJECT (&s->wdt), true,"realized" , &error_abort); +sysbus_mmio_map (SYS_BUS_DEVICE (&s->wdt),0 ,FSL_IMX25_WDT_ADDR ); +sysbus_connect_irq (SYS_BUS_DEVICE (&s->wdt),0 , +qdev_get_gpio_in (DEVICE (&s->avic), +FSL_IMX25_WDT_IRQ )); +/* initialize 2 x 16 KB ROM */ memory_region_init_rom (&s->rom[0 ],OBJECT (dev),"imx25.rom0" ,FSL_IMX25_ROM0_SIZE , &err);
include/hw/arm/fsl-imx25.h +5 -0
@@ -29,6 +29,7 @@#include "hw/gpio/imx_gpio.h" #include "hw/sd/sdhci.h" #include "hw/usb/chipidea.h" +#include "hw/watchdog/wdt_imx2.h" #include "exec/memory.h" #include "target/arm/cpu.h"
@@ -60,6 +61,7 @@ typedef struct FslIMX25State {IMXGPIOState gpio[FSL_IMX25_NUM_GPIOS ];SDHCIState esdhc[FSL_IMX25_NUM_ESDHCS ];ChipideaState usb[FSL_IMX25_NUM_USBS ]; +IMX2WdtState wdt;MemoryRegion rom[2 ];MemoryRegion iram;MemoryRegion iram_alias;
@@ -229,6 +231,8 @@ typedef struct FslIMX25State {#define FSL_IMX25_GPIO1_SIZE 0x4000#define FSL_IMX25_GPIO2_ADDR 0x53FD0000#define FSL_IMX25_GPIO2_SIZE 0x4000 +#define FSL_IMX25_WDT_ADDR 0x53FDC000 +#define FSL_IMX25_WDT_SIZE 0x4000#define FSL_IMX25_USB1_ADDR 0x53FF4000#define FSL_IMX25_USB1_SIZE 0x0200#define FSL_IMX25_USB2_ADDR 0x53FF4400
@@ -268,5 +272,6 @@ typedef struct FslIMX25State {#define FSL_IMX25_ESDHC2_IRQ 8#define FSL_IMX25_USB1_IRQ 37#define FSL_IMX25_USB2_IRQ 35 +#define FSL_IMX25_WDT_IRQ 55#endif /* FSL_IMX25_H */
Signature · 1 line
2.17.1
PATCH v2 4/8 hw/arm/fsl-imx31: Wire up watchdog
In reply to Guenter RoeckWith this patch, the watchdog on i.MX31 emulations is fully operational.
---
v2: Select WDT_IMX2 explicitly
Added Philippe's Reviewed-by: tag
hw/arm/Kconfig | 1 + hw/arm/fsl-imx31.c | 6 ++++++ include/hw/arm/fsl-imx31.h | 4 ++++ 3 files changed, 11 insertions(+)
hw/arm/Kconfig +1 -0
@@ -366,6 +366,7 @@ config FSL_IMX31 select SERIAL select IMX select IMX_I2C + select WDT_IMX2 select LAN9118 config FSL_IMX6
hw/arm/fsl-imx31.c +6 -0
@@ -63,6 +63,8 @@ static void fsl_imx31_init(Object *obj)sysbus_init_child_obj (obj,"gpio[*]" , &s->gpio[i],sizeof (s->gpio[i]),TYPE_IMX_GPIO ); } + +sysbus_init_child_obj (obj,"wdt" , &s->wdt,sizeof (s->wdt),TYPE_IMX2_WDT ); }static void fsl_imx31_realize (DeviceState *dev,Error **errp)
@@ -205,6 +207,10 @@ static void fsl_imx31_realize(DeviceState *dev, Error **errp) gpio_table[i].irq)); } +/* Watchdog */ +object_property_set_bool (OBJECT (&s->wdt), true,"realized" , &error_abort); +sysbus_mmio_map (SYS_BUS_DEVICE (&s->wdt),0 ,FSL_IMX31_WDT_ADDR ); +/* On a real system, the first 16k is a `secure boot rom' */ memory_region_init_rom (&s->secure_rom,OBJECT (dev),"imx31.secure_rom" ,FSL_IMX31_SECURE_ROM_SIZE , &err);
include/hw/arm/fsl-imx31.h +4 -0
@@ -25,6 +25,7 @@#include "hw/timer/imx_epit.h" #include "hw/i2c/imx_i2c.h" #include "hw/gpio/imx_gpio.h" +#include "hw/watchdog/wdt_imx2.h" #include "exec/memory.h" #include "target/arm/cpu.h"
@@ -49,6 +50,7 @@ typedef struct FslIMX31State {IMXEPITState epit[FSL_IMX31_NUM_EPITS ];IMXI2CState i2c[FSL_IMX31_NUM_I2CS ];IMXGPIOState gpio[FSL_IMX31_NUM_GPIOS ]; +IMX2WdtState wdt;MemoryRegion secure_rom;MemoryRegion rom;MemoryRegion iram;
@@ -87,6 +89,8 @@ typedef struct FslIMX31State {#define FSL_IMX31_GPIO1_SIZE 0x4000#define FSL_IMX31_GPIO2_ADDR 0x53FD0000#define FSL_IMX31_GPIO2_SIZE 0x4000 +#define FSL_IMX31_WDT_ADDR 0x53FDC000 +#define FSL_IMX31_WDT_SIZE 0x4000#define FSL_IMX31_AVIC_ADDR 0x68000000#define FSL_IMX31_AVIC_SIZE 0x100#define FSL_IMX31_SDRAM0_ADDR 0x80000000
Signature · 1 line
2.17.1
PATCH v2 5/8 hw/arm/fsl-imx6: Connect watchdog interrupts
In reply to Guenter RoeckWith this patch applied, the watchdog in the sabrelite emulation is fully operational, including pretimeout support.
---
v2: No change
hw/arm/fsl-imx6.c | 9 +++++++++ 1 file changed, 9 insertions(+)
hw/arm/fsl-imx6.c +9 -0
@@ -433,11 +433,20 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)FSL_IMX6_WDOG1_ADDR , FSL_IMX6_WDOG2_ADDR, }; +static const int FSL_IMX6_WDOGn_IRQ[FSL_IMX6_NUM_WDTS ] = { +FSL_IMX6_WDOG1_IRQ , +FSL_IMX6_WDOG2_IRQ , + }; +object_property_set_bool (OBJECT (&s->wdt[i]), true,"pretimeout-support" , + &error_abort);object_property_set_bool (OBJECT (&s->wdt[i]), true,"realized" , &error_abort);sysbus_mmio_map (SYS_BUS_DEVICE (&s->wdt[i]),0 , FSL_IMX6_WDOGn_ADDR[i]); +sysbus_connect_irq (SYS_BUS_DEVICE (&s->wdt[i]),0 , +qdev_get_gpio_in (DEVICE (&s->a9mpcore), + FSL_IMX6_WDOGn_IRQ[i])); }/* ROM memory */
Signature · 1 line
2.17.1
Re: [PATCH v2 5/8] hw/arm/fsl-imx6: Connect watchdog interrupts
Quoted 26 lines · Guenter Roeck
With this patch applied, the watchdog in the sabrelite emulation is fully operational, including pretimeout support.
Signed-off-by Guenter Roeck <[email protected]>---
v2: No changehw/arm/fsl-imx6.c | 9 +++++++++ 1 file changed, 9 insertions(+)hw/arm/fsl-imx6.c +6
-0@@ -433,11 +433,20 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)FSL_IMX6_WDOG1_ADDR , FSL_IMX6_WDOG2_ADDR, }; +static const int FSL_IMX6_WDOGn_IRQ[FSL_IMX6_NUM_WDTS ] = { +FSL_IMX6_WDOG1_IRQ , +FSL_IMX6_WDOG2_IRQ , + }; +object_property_set_bool (OBJECT (&s->wdt[i]), true,"pretimeout-support" , + &error_abort);
hw/arm/fsl-imx6.c static void fsl_imx6_realize(DeviceState *dev, Error **errp) · line 452
Quoted 10 lines
hw/arm/fsl-imx6.c +3
-0object_property_set_bool (OBJECT (&s->wdt[i]), true,"realized" , &error_abort);sysbus_mmio_map (SYS_BUS_DEVICE (&s->wdt[i]),0 , FSL_IMX6_WDOGn_ADDR[i]); +sysbus_connect_irq (SYS_BUS_DEVICE (&s->wdt[i]),0 , +qdev_get_gpio_in (DEVICE (&s->a9mpcore), + FSL_IMX6_WDOGn_IRQ[i])); }/* ROM memory */
PATCH v2 6/8 hw/arm/fsl-imx6ul: Connect watchdog interrupts
In reply to Guenter RoeckWith this commit, the watchdog on mcimx6ul-evk is fully operational, including pretimeout support.
---
v2: No change
hw/arm/fsl-imx6ul.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
hw/arm/fsl-imx6ul.c +10 -0
@@ -531,12 +531,22 @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp)FSL_IMX6UL_WDOG2_ADDR , FSL_IMX6UL_WDOG3_ADDR, }; +static const int FSL_IMX6UL_WDOGn_IRQ[FSL_IMX6UL_NUM_WDTS ] = { +FSL_IMX6UL_WDOG1_IRQ , +FSL_IMX6UL_WDOG2_IRQ , +FSL_IMX6UL_WDOG3_IRQ , + }; +object_property_set_bool (OBJECT (&s->wdt[i]), true,"pretimeout-support" , + &error_abort);object_property_set_bool (OBJECT (&s->wdt[i]), true,"realized" , &error_abort);sysbus_mmio_map (SYS_BUS_DEVICE (&s->wdt[i]),0 , FSL_IMX6UL_WDOGn_ADDR[i]); +sysbus_connect_irq (SYS_BUS_DEVICE (&s->wdt[i]),0 , +qdev_get_gpio_in (DEVICE (&s->a7mpcore), + FSL_IMX6UL_WDOGn_IRQ[i])); }/*
Signature · 1 line
2.17.1
Re: [PATCH v2 6/8] hw/arm/fsl-imx6ul: Connect watchdog interrupts
Quoted 28 lines · Guenter Roeck
With this commit, the watchdog on mcimx6ul-evk is fully operational, including pretimeout support.
Signed-off-by Guenter Roeck <[email protected]>---
v2: No changehw/arm/fsl-imx6ul.c | 10 ++++++++++ 1 file changed, 10 insertions(+)hw/arm/fsl-imx6ul.c +7
-0@@ -531,12 +531,22 @@ static void fsl_imx6ul_realize(DeviceState *dev, Error **errp)FSL_IMX6UL_WDOG2_ADDR , FSL_IMX6UL_WDOG3_ADDR, }; +static const int FSL_IMX6UL_WDOGn_IRQ[FSL_IMX6UL_NUM_WDTS ] = { +FSL_IMX6UL_WDOG1_IRQ , +FSL_IMX6UL_WDOG2_IRQ , +FSL_IMX6UL_WDOG3_IRQ , + }; +object_property_set_bool (OBJECT (&s->wdt[i]), true,"pretimeout-support" , + &error_abort); object_property_set_bool(OBJECT(&s->wdt[i]), true, "realized",
hw/arm/fsl-imx6ul.c static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) · line 552
Quoted 10 lines
hw/arm/fsl-imx6ul.c +3
-0&error_abort);sysbus_mmio_map (SYS_BUS_DEVICE (&s->wdt[i]),0 , FSL_IMX6UL_WDOGn_ADDR[i]); +sysbus_connect_irq (SYS_BUS_DEVICE (&s->wdt[i]),0 , +qdev_get_gpio_in (DEVICE (&s->a7mpcore), + FSL_IMX6UL_WDOGn_IRQ[i])); }/*
PATCH v2 7/8 hw/arm/fsl-imx7: Instantiate various unimplemented devices
In reply to Guenter RoeckInstantiating PWM, CAN, CAAM, and OCOTP devices is necessary to avoid crashes when booting mainline Linux.
---
v2: "octop" -> "ocotp"
hw/arm/fsl-imx7.c | 24 ++++++++++++++++++++++++ include/hw/arm/fsl-imx7.h | 16 ++++++++++++++++ 2 files changed, 40 insertions(+)
hw/arm/fsl-imx7.c +24 -0
@@ -459,6 +459,30 @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp)*/ create_unimplemented_device ("sdma" ,FSL_IMX7_SDMA_ADDR ,FSL_IMX7_SDMA_SIZE ); +/* +* CAAM +*/ +create_unimplemented_device ("caam" ,FSL_IMX7_CAAM_ADDR ,FSL_IMX7_CAAM_SIZE ); + +/* +* PWM +*/ +create_unimplemented_device ("pwm1" ,FSL_IMX7_PWM1_ADDR , FSL_IMX7_PWMn_SIZE); +create_unimplemented_device ("pwm2" ,FSL_IMX7_PWM2_ADDR , FSL_IMX7_PWMn_SIZE); +create_unimplemented_device ("pwm3" ,FSL_IMX7_PWM3_ADDR , FSL_IMX7_PWMn_SIZE); +create_unimplemented_device ("pwm4" ,FSL_IMX7_PWM4_ADDR , FSL_IMX7_PWMn_SIZE); + +/* +* CAN +*/ +create_unimplemented_device ("can1" ,FSL_IMX7_CAN1_ADDR , FSL_IMX7_CANn_SIZE); +create_unimplemented_device ("can2" ,FSL_IMX7_CAN2_ADDR , FSL_IMX7_CANn_SIZE); + +/* +* OCOTP +*/ +create_unimplemented_device ("ocotp" ,FSL_IMX7_OCOTP_ADDR , +FSL_IMX7_OCOTP_SIZE );object_property_set_bool (OBJECT (&s->gpr), true,"realized" , &error_abort);
include/hw/arm/fsl-imx7.h +16 -0
@@ -113,6 +113,9 @@ enum FslIMX7MemoryMap {FSL_IMX7_IOMUXC_GPR_ADDR =0x30340000 , FSL_IMX7_IOMUXCn_SIZE =0x1000 , +FSL_IMX7_OCOTP_ADDR =0x30350000 , +FSL_IMX7_OCOTP_SIZE =0x10000 , +FSL_IMX7_ANALOG_ADDR =0x30360000 ,FSL_IMX7_SNVS_ADDR =0x30370000 , FSL_IMX7_CCM_ADDR = 0x30380000,
@@ -124,11 +127,24 @@ enum FslIMX7MemoryMap {FSL_IMX7_ADC2_ADDR =0x30620000 , FSL_IMX7_ADCn_SIZE =0x1000 , +FSL_IMX7_PWM1_ADDR =0x30660000 , +FSL_IMX7_PWM2_ADDR =0x30670000 , +FSL_IMX7_PWM3_ADDR =0x30680000 , +FSL_IMX7_PWM4_ADDR =0x30690000 , + FSL_IMX7_PWMn_SIZE =0x10000 , +FSL_IMX7_PCIE_PHY_ADDR =0x306D0000 ,FSL_IMX7_PCIE_PHY_SIZE =0x10000 ,FSL_IMX7_GPC_ADDR =0x303A0000 , +FSL_IMX7_CAAM_ADDR =0x30900000 , +FSL_IMX7_CAAM_SIZE =0x40000 , + +FSL_IMX7_CAN1_ADDR =0x30A00000 , +FSL_IMX7_CAN2_ADDR =0x30A10000 , + FSL_IMX7_CANn_SIZE =0x10000 , +FSL_IMX7_I2C1_ADDR =0x30A20000 ,FSL_IMX7_I2C2_ADDR =0x30A30000 , FSL_IMX7_I2C3_ADDR = 0x30A40000,
Signature · 1 line
2.17.1
Re: [PATCH v2 7/8] hw/arm/fsl-imx7: Instantiate various unimplemented devices
Quoted 5 lines · Guenter Roeck
Instantiating PWM, CAN, CAAM, and OCOTP devices is necessary to avoid crashes when booting mainline Linux.
Signed-off-by Guenter Roeck <[email protected]>
thanks
-- PMM
PATCH v2 8/8 hw/arm/fsl-imx7: Connect watchdog interrupts
In reply to Guenter Roecki.MX7 supports watchdog pretimeout interupts. With this commit, the watchdog in mcimx7d-sabre is fully operational, including pretimeout support.
---
v2: No change
hw/arm/fsl-imx7.c | 11 +++++++++++ include/hw/arm/fsl-imx7.h | 5 +++++ 2 files changed, 16 insertions(+)
hw/arm/fsl-imx7.c +11 -0
@@ -447,11 +447,22 @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp)FSL_IMX7_WDOG3_ADDR , FSL_IMX7_WDOG4_ADDR, }; +static const int FSL_IMX7_WDOGn_IRQ[FSL_IMX7_NUM_WDTS ] = { +FSL_IMX7_WDOG1_IRQ , +FSL_IMX7_WDOG2_IRQ , +FSL_IMX7_WDOG3_IRQ , +FSL_IMX7_WDOG4_IRQ , + }; +object_property_set_bool (OBJECT (&s->wdt[i]), true,"pretimeout-support" , + &error_abort);object_property_set_bool (OBJECT (&s->wdt[i]), true,"realized" , &error_abort);sysbus_mmio_map (SYS_BUS_DEVICE (&s->wdt[i]),0 , FSL_IMX7_WDOGn_ADDR[i]); +sysbus_connect_irq (SYS_BUS_DEVICE (&s->wdt[i]),0 , +qdev_get_gpio_in (DEVICE (&s->a7mpcore), + FSL_IMX7_WDOGn_IRQ[i])); }/*
include/hw/arm/fsl-imx7.h +5 -0
@@ -228,6 +228,11 @@ enum FslIMX7IRQs {FSL_IMX7_USB2_IRQ =42 ,FSL_IMX7_USB3_IRQ =40 , +FSL_IMX7_WDOG1_IRQ =78 , +FSL_IMX7_WDOG2_IRQ =79 , +FSL_IMX7_WDOG3_IRQ =10 , +FSL_IMX7_WDOG4_IRQ =109 , +FSL_IMX7_PCI_INTA_IRQ =125 ,FSL_IMX7_PCI_INTB_IRQ =124 , FSL_IMX7_PCI_INTC_IRQ = 123,
Signature · 1 line
2.17.1
Re: [PATCH v2 8/8] hw/arm/fsl-imx7: Connect watchdog interrupts
Quoted 12 lines · Guenter Roeck
i.MX7 supports watchdog pretimeout interupts. With this commit, the watchdog in mcimx7d-sabre is fully operational, including pretimeout support.
Signed-off-by Guenter Roeck <[email protected]>include/hw/arm/fsl-imx7.h +0
-0
include/hw/arm/fsl-imx7.h enum FslIMX7IRQs { · line 234
Quoted 7 lines
include/hw/arm/fsl-imx7.h +4
-0@@ -228,6 +228,11 @@ enum FslIMX7IRQs {FSL_IMX7_USB2_IRQ =42 ,FSL_IMX7_USB3_IRQ =40 , +FSL_IMX7_WDOG1_IRQ =78 , +FSL_IMX7_WDOG2_IRQ =79 , +FSL_IMX7_WDOG3_IRQ =10 , + FSL_IMX7_WDOG4_IRQ = 109,
irq 10 for wdog3 seems to match the kernel's dts, but it's a bit weird that it's way out of the range of the others. Did you sanity check it against the imx7 data sheet and/or real h/w behaviour that it's not a typo for one-hundred-and-something? (108 would be the obvious guess...)
Otherwise
thanks
-- PMM
Re: [PATCH v2 8/8] hw/arm/fsl-imx7: Connect watchdog interrupts
Hi Peter,
Quoted 16 lines · Peter Maydell
Quoted 15 lines · Guenter Roeck
i.MX7 supports watchdog pretimeout interupts. With this commit, the watchdog in mcimx7d-sabre is fully operational, including pretimeout support.
Signed-off-by Guenter Roeck <[email protected]>include/hw/arm/fsl-imx7.h +0
-0@@ -228,6 +228,11 @@ enum FslIMX7IRQs {FSL_IMX7_USB2_IRQ =42 , FSL_IMX7_USB3_IRQ = 40,
Quoted 11 lines
include/hw/arm/fsl-imx7.h enum FslIMX7IRQs { · line 234
Quoted 4 lines
include/hw/arm/fsl-imx7.h +4
-0+FSL_IMX7_WDOG1_IRQ =78 , +FSL_IMX7_WDOG2_IRQ =79 , +FSL_IMX7_WDOG3_IRQ =10 , + FSL_IMX7_WDOG4_IRQ = 109,irq 10 for wdog3 seems to match the kernel's dts, but it's a bit weird that it's way out of the range of the others. Did you sanity check it against the imx7 data sheet and/or real h/w behaviour that it's not a typo for one-hundred-and-something? (108 would be the obvious guess...)
I actually did check, for that very same reason. To be sure I looked again. 10 is correct per datasheet. 108 is TZASC1 (TZASC (PL380) interrupt).
Quoted 3 lines
Otherwise
Reviewed-by Peter Maydell <[email protected]>
Thanks,
Guenter