[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 12/18] hw/arm/fsl-imx8mp: Add watchdog support
From: |
Bernhard Beschow |
Subject: |
[PATCH v2 12/18] hw/arm/fsl-imx8mp: Add watchdog support |
Date: |
Tue, 4 Feb 2025 10:21:06 +0100 |
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
---
docs/system/arm/imx8mp-evk.rst | 1 +
include/hw/arm/fsl-imx8mp.h | 7 +++++++
hw/arm/fsl-imx8mp.c | 28 ++++++++++++++++++++++++++++
hw/arm/Kconfig | 1 +
4 files changed, 37 insertions(+)
diff --git a/docs/system/arm/imx8mp-evk.rst b/docs/system/arm/imx8mp-evk.rst
index eb7df2059f..15514055b5 100644
--- a/docs/system/arm/imx8mp-evk.rst
+++ b/docs/system/arm/imx8mp-evk.rst
@@ -18,6 +18,7 @@ The ``imx8mp-evk`` machine implements the following devices:
* 5 GPIO Controllers
* 6 I2C Controllers
* 3 SPI Controllers
+ * 3 Watchdogs
* Secure Non-Volatile Storage (SNVS) including an RTC
* Clock Tree
diff --git a/include/hw/arm/fsl-imx8mp.h b/include/hw/arm/fsl-imx8mp.h
index 296a87eb50..dfbdc6ac7f 100644
--- a/include/hw/arm/fsl-imx8mp.h
+++ b/include/hw/arm/fsl-imx8mp.h
@@ -21,6 +21,7 @@
#include "hw/pci-host/fsl_imx8m_phy.h"
#include "hw/sd/sdhci.h"
#include "hw/ssi/imx_spi.h"
+#include "hw/watchdog/wdt_imx2.h"
#include "qom/object.h"
#include "qemu/units.h"
@@ -38,6 +39,7 @@ enum FslImx8mpConfiguration {
FSL_IMX8MP_NUM_IRQS = 160,
FSL_IMX8MP_NUM_UARTS = 4,
FSL_IMX8MP_NUM_USDHCS = 3,
+ FSL_IMX8MP_NUM_WDTS = 3,
};
struct FslImx8mpState {
@@ -53,6 +55,7 @@ struct FslImx8mpState {
IMXI2CState i2c[FSL_IMX8MP_NUM_I2CS];
IMXSerialState uart[FSL_IMX8MP_NUM_UARTS];
SDHCIState usdhc[FSL_IMX8MP_NUM_USDHCS];
+ IMX2WdtState wdt[FSL_IMX8MP_NUM_WDTS];
DesignwarePCIEHost pcie;
FslImx8mPciePhyState pcie_phy;
};
@@ -235,6 +238,10 @@ enum FslImx8mpIrqs {
FSL_IMX8MP_I2C5_IRQ = 76,
FSL_IMX8MP_I2C6_IRQ = 77,
+ FSL_IMX8MP_WDOG1_IRQ = 78,
+ FSL_IMX8MP_WDOG2_IRQ = 79,
+ FSL_IMX8MP_WDOG3_IRQ = 10,
+
FSL_IMX8MP_PCI_INTA_IRQ = 126,
FSL_IMX8MP_PCI_INTB_IRQ = 125,
FSL_IMX8MP_PCI_INTC_IRQ = 124,
diff --git a/hw/arm/fsl-imx8mp.c b/hw/arm/fsl-imx8mp.c
index fa39dfd2da..6646f1c8b4 100644
--- a/hw/arm/fsl-imx8mp.c
+++ b/hw/arm/fsl-imx8mp.c
@@ -231,6 +231,11 @@ static void fsl_imx8mp_init(Object *obj)
object_initialize_child(obj, name, &s->spi[i], TYPE_IMX_SPI);
}
+ for (i = 0; i < FSL_IMX8MP_NUM_WDTS; i++) {
+ snprintf(name, NAME_SIZE, "wdt%d", i);
+ object_initialize_child(obj, name, &s->wdt[i], TYPE_IMX2_WDT);
+ }
+
object_initialize_child(obj, "pcie", &s->pcie, TYPE_DESIGNWARE_PCIE_HOST);
object_initialize_child(obj, "pcie_phy", &s->pcie_phy,
TYPE_FSL_IMX8M_PCIE_PHY);
@@ -495,6 +500,28 @@ static void fsl_imx8mp_realize(DeviceState *dev, Error
**errp)
sysbus_mmio_map(SYS_BUS_DEVICE(&s->snvs), 0,
fsl_imx8mp_memmap[FSL_IMX8MP_SNVS_HP].addr);
+ /* Watchdogs */
+ for (i = 0; i < FSL_IMX8MP_NUM_WDTS; i++) {
+ static const struct {
+ hwaddr addr;
+ unsigned int irq;
+ } wdog_table[FSL_IMX8MP_NUM_WDTS] = {
+ { fsl_imx8mp_memmap[FSL_IMX8MP_WDOG1].addr, FSL_IMX8MP_WDOG1_IRQ },
+ { fsl_imx8mp_memmap[FSL_IMX8MP_WDOG2].addr, FSL_IMX8MP_WDOG2_IRQ },
+ { fsl_imx8mp_memmap[FSL_IMX8MP_WDOG3].addr, FSL_IMX8MP_WDOG3_IRQ },
+ };
+
+ object_property_set_bool(OBJECT(&s->wdt[i]), "pretimeout-support",
+ true, &error_abort);
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->wdt[i]), errp)) {
+ return;
+ }
+
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->wdt[i]), 0, wdog_table[i].addr);
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->wdt[i]), 0,
+ qdev_get_gpio_in(gicdev, wdog_table[i].irq));
+ }
+
/* PCIe */
if (!sysbus_realize(SYS_BUS_DEVICE(&s->pcie), errp)) {
return;
@@ -535,6 +562,7 @@ static void fsl_imx8mp_realize(DeviceState *dev, Error
**errp)
case FSL_IMX8MP_SNVS_HP:
case FSL_IMX8MP_UART1 ... FSL_IMX8MP_UART4:
case FSL_IMX8MP_USDHC1 ... FSL_IMX8MP_USDHC3:
+ case FSL_IMX8MP_WDOG1 ... FSL_IMX8MP_WDOG3:
/* device implemented and treated above */
break;
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
index 4a8695f22a..71102ac0a9 100644
--- a/hw/arm/Kconfig
+++ b/hw/arm/Kconfig
@@ -590,6 +590,7 @@ config FSL_IMX8MP
select PCI_EXPRESS_FSL_IMX8M_PHY
select SDHCI
select UNIMP
+ select WDT_IMX2
config FSL_IMX8MP_EVK
bool
--
2.48.1
- [PATCH v2 02/18] hw/pci-host/designware: Prevent device attachment on internal PCIe root bus, (continued)
- [PATCH v2 02/18] hw/pci-host/designware: Prevent device attachment on internal PCIe root bus, Bernhard Beschow, 2025/02/04
- [PATCH v2 03/18] hw/gpio/pca955*: Move Kconfig switches next to implementations, Bernhard Beschow, 2025/02/04
- [PATCH v2 04/18] hw/arm: Add i.MX 8M Plus EVK board, Bernhard Beschow, 2025/02/04
- [PATCH v2 06/18] hw/arm/fsl-imx8mp: Add SNVS, Bernhard Beschow, 2025/02/04
- [PATCH v2 07/18] hw/arm/fsl-imx8mp: Add USDHC storage controllers, Bernhard Beschow, 2025/02/04
- [PATCH v2 05/18] hw/arm/fsl-imx8mp: Implement clock tree, Bernhard Beschow, 2025/02/04
- [PATCH v2 09/18] hw/arm/fsl-imx8mp: Add GPIO controllers, Bernhard Beschow, 2025/02/04
- [PATCH v2 08/18] hw/arm/fsl-imx8mp: Add PCIe support, Bernhard Beschow, 2025/02/04
- [PATCH v2 11/18] hw/arm/fsl-imx8mp: Add SPI controllers, Bernhard Beschow, 2025/02/04
- [PATCH v2 12/18] hw/arm/fsl-imx8mp: Add watchdog support,
Bernhard Beschow <=
- [PATCH v2 10/18] hw/arm/fsl-imx8mp: Add I2C controllers, Bernhard Beschow, 2025/02/04
- [PATCH v2 16/18] hw/arm/fsl-imx8mp: Add boot ROM, Bernhard Beschow, 2025/02/04
- [PATCH v2 13/18] hw/arm/fsl-imx8mp: Implement gneral purpose timers, Bernhard Beschow, 2025/02/04
- [PATCH v2 15/18] hw/arm/fsl-imx8mp: Add USB support, Bernhard Beschow, 2025/02/04
- [PATCH v2 14/18] hw/arm/fsl-imx8mp: Add Ethernet controller, Bernhard Beschow, 2025/02/04
- [PATCH v2 17/18] hw/arm/fsl-imx8mp: Add on-chip RAM, Bernhard Beschow, 2025/02/04
- [PATCH v2 18/18] hw/rtc: Add Ricoh RS5C372 RTC emulation, Bernhard Beschow, 2025/02/04