From: Heiko Schocher <hs@denx.de>
To: U-Boot Mailing List <u-boot@lists.denx.de>
Cc: Enrico Leto <enrico.leto@siemens.com>,
Walter Schweizer <walter.schweizer@siemens.com>,
Alexander Sverdlin <alexander.sverdlin@siemens.com>,
Heiko Schocher <hs@denx.de>,
Andrej Valek <andrej.valek@siemens.com>,
Bastien Curutchet <bastien.curutchet@bootlin.com>,
Chanho Park <chanho61.park@samsung.com>,
Devarsh Thakkar <devarsht@ti.com>,
Igor Opaniuk <igor.opaniuk@foundries.io>,
Leo Yu-Chi Liang <ycliang@andestech.com>,
Marek Vasut <marek.vasut+renesas@mailbox.org>,
Randolph <randolph@andestech.com>,
Rasmus Villemoes <ravi@prevas.dk>, Simon Glass <sjg@chromium.org>,
Stefan Roese <sr@denx.de>, Tom Rini <trini@konsulko.com>
Subject: [PATCH v1 01/22] wdt: imx8qxp: add option to control external PMIC wdt via IMX8 SCU
Date: Fri, 8 Nov 2024 06:21:22 +0100 [thread overview]
Message-ID: <20241108052143.26874-2-hs@denx.de> (raw)
In-Reply-To: <20241108052143.26874-1-hs@denx.de>
control the watchdog in the PMIC through SCU.
Signed-off-by: Andrej Valek <andrej.valek@siemens.com>
Signed-off-by: Heiko Schocher <hs@denx.de>
---
drivers/misc/imx8/scu_api.c | 21 ++++++++++++++
drivers/watchdog/Kconfig | 7 +++++
drivers/watchdog/Makefile | 1 +
drivers/watchdog/scu_wdt.c | 52 ++++++++++++++++++++++++++++++++++
include/firmware/imx/sci/rpc.h | 1 +
include/firmware/imx/sci/sci.h | 1 +
6 files changed, 83 insertions(+)
create mode 100644 drivers/watchdog/scu_wdt.c
diff --git a/drivers/misc/imx8/scu_api.c b/drivers/misc/imx8/scu_api.c
index 591d71b096a..edb6923151a 100644
--- a/drivers/misc/imx8/scu_api.c
+++ b/drivers/misc/imx8/scu_api.c
@@ -951,6 +951,27 @@ int sc_timer_set_wdog_window(sc_ipc_t ipc, sc_timer_wdog_time_t window)
return ret;
}
+int sc_timer_control_pmic_wdog(sc_ipc_t ipc, u8 cmd)
+{
+ struct udevice *dev = gd->arch.scu_dev;
+ struct sc_rpc_msg_s msg;
+ int size = sizeof(struct sc_rpc_msg_s);
+ int ret;
+
+ RPC_VER(&msg) = SC_RPC_VERSION;
+ RPC_SVC(&msg) = (u8)SC_RPC_SVC_TIMER;
+ RPC_FUNC(&msg) = (u8)TIMER_FUNC_CTRL_PMIC_WDOG;
+ RPC_U8(&msg, 0U) = (u8)cmd;
+ RPC_SIZE(&msg) = 2U;
+
+ ret = misc_call(dev, SC_FALSE, &msg, size, &msg, size);
+ if (ret)
+ printf("%s: res:%d\n",
+ __func__, RPC_R8(&msg));
+
+ return ret;
+}
+
int sc_seco_authenticate(sc_ipc_t ipc, sc_seco_auth_cmd_t cmd,
sc_faddr_t addr)
{
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index 0e45f0a0922..eb9e75abe48 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -428,6 +428,13 @@ config WDT_ARM_SMC
Select this to enable Arm SMC watchdog timer. This watchdog will manage
a watchdog based on ARM SMCCC communication.
+config WDT_IMX_SCU
+ bool "Enable external Watchdog Timer support for IMX"
+ depends on IMX8 && WDT
+ help
+ Select this to enable the external IMX watchdog driver
+ controlled via IMX8 SCU.
+
config SPL_WDT
bool "Enable driver model for watchdog timer drivers in SPL"
depends on SPL_DM
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index 0b107c008f7..e943b904bae 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -33,6 +33,7 @@ obj-$(CONFIG_WDT_DA9063) += da9063-wdt.o
obj-$(CONFIG_WDT_DAVINCI) += davinci_wdt.o
obj-$(CONFIG_WDT_FTWDT010) += ftwdt010_wdt.o
obj-$(CONFIG_$(SPL_TPL_)WDT_GPIO) += gpio_wdt.o
+obj-$(CONFIG_WDT_IMX_SCU) += scu_wdt.o
obj-$(CONFIG_WDT_MAX6370) += max6370_wdt.o
obj-$(CONFIG_WDT_MCF) += mcf_wdt.o
obj-$(CONFIG_WDT_MESON_GXBB) += meson_gxbb_wdt.o
diff --git a/drivers/watchdog/scu_wdt.c b/drivers/watchdog/scu_wdt.c
new file mode 100644
index 00000000000..ad8766dc132
--- /dev/null
+++ b/drivers/watchdog/scu_wdt.c
@@ -0,0 +1,52 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include <dm.h>
+#include <wdt.h>
+#include <firmware/imx/sci/sci.h>
+
+/* watchdog commands */
+#define CMD_START_WDT 0x55
+#define CMD_STOP_WDT 0x45
+#define CMD_PING_WDT 0x35
+
+static int scu_wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags)
+{
+ /* start external watchdog via Timer API */
+ return sc_timer_control_pmic_wdog(-1, CMD_START_WDT);
+}
+
+static int scu_wdt_stop(struct udevice *dev)
+{
+ /* stop external watchdog via Timer API */
+ return sc_timer_control_pmic_wdog(-1, CMD_STOP_WDT);
+}
+
+static int scu_wdt_reset(struct udevice *dev)
+{
+ return sc_timer_control_pmic_wdog(-1, CMD_PING_WDT);
+}
+
+static int scu_wdt_probe(struct udevice *dev)
+{
+ debug("%s(dev=%p)\n", __func__, dev);
+ return 0;
+}
+
+static const struct wdt_ops scu_wdt_ops = {
+ .reset = scu_wdt_reset,
+ .start = scu_wdt_start,
+ .stop = scu_wdt_stop,
+};
+
+static const struct udevice_id scu_wdt_ids[] = {
+ { .compatible = "siemens,scu-wdt" },
+ { }
+};
+
+U_BOOT_DRIVER(scu_wdt) = {
+ .name = "scu_wdt",
+ .id = UCLASS_WDT,
+ .of_match = scu_wdt_ids,
+ .probe = scu_wdt_probe,
+ .ops = &scu_wdt_ops,
+};
diff --git a/include/firmware/imx/sci/rpc.h b/include/firmware/imx/sci/rpc.h
index 28adec2a8e1..9470f9e7178 100644
--- a/include/firmware/imx/sci/rpc.h
+++ b/include/firmware/imx/sci/rpc.h
@@ -230,5 +230,6 @@ struct sc_rpc_msg_s {
#define TIMER_FUNC_SET_SYSCTR_ALARM 16U /* Index for sc_timer_set_sysctr_alarm() RPC call */
#define TIMER_FUNC_SET_SYSCTR_PERIODIC_ALARM 17U /* Index for sc_timer_set_sysctr_periodic_alarm() RPC call */
#define TIMER_FUNC_CANCEL_SYSCTR_ALARM 18U /* Index for sc_timer_cancel_sysctr_alarm() RPC call */
+#define TIMER_FUNC_CTRL_PMIC_WDOG 20U /*!< Index for sc_timer_ctrl_pmic_wdog() RPC call */
#endif /* SC_RPC_H */
diff --git a/include/firmware/imx/sci/sci.h b/include/firmware/imx/sci/sci.h
index 7d8499f070a..b971b62836d 100644
--- a/include/firmware/imx/sci/sci.h
+++ b/include/firmware/imx/sci/sci.h
@@ -123,6 +123,7 @@ int sc_rm_set_master_sid(sc_ipc_t ipc, sc_rsrc_t resource, sc_rm_sid_t sid);
/* Timer API */
int sc_timer_set_wdog_window(sc_ipc_t ipc, sc_timer_wdog_time_t window);
+int sc_timer_control_pmic_wdog(sc_ipc_t ipc, u8 cmd);
/* SECO API */
int sc_seco_authenticate(sc_ipc_t ipc, sc_seco_auth_cmd_t cmd,
--
2.20.1
next prev parent reply other threads:[~2024-11-08 5:21 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-08 5:21 [PATCH v1 00/22] imx8qxp: siemens board: updates / sync with mainline Heiko Schocher
2024-11-08 5:21 ` Heiko Schocher [this message]
2024-11-08 7:19 ` [PATCH v1 01/22] wdt: imx8qxp: add option to control external PMIC wdt via IMX8 SCU Stefan Roese
2024-11-08 11:47 ` Sverdlin, Alexander
2024-11-08 5:21 ` [PATCH v1 02/22] net: fec_mxc: fix probing for imx8qxp Heiko Schocher
2024-11-08 5:21 ` [PATCH v1 03/22] tools: imx8image: Improve error message Heiko Schocher
2024-11-11 8:03 ` Sverdlin, Alexander
2024-11-08 5:21 ` [PATCH v1 04/22] imx: imx_cntr_image.sh: prevent warning for missing spl Heiko Schocher
2024-11-08 5:21 ` [PATCH v1 05/22] imx8qxp: Fix build when using SPL Heiko Schocher
2024-11-08 5:21 ` [PATCH v1 06/22] siemens: capricorn: move to cxg3 reference project with deneb board Heiko Schocher
2024-11-08 5:21 ` [PATCH v1 07/22] siemens: imx8qxp-capricorn-u-boot.dtsi: fix boot Heiko Schocher
2024-11-11 8:34 ` Sverdlin, Alexander
2024-11-08 5:21 ` [PATCH v1 08/22] siemens: capricorn: use DCD_SKIP entry Heiko Schocher
2024-11-11 8:35 ` Schweizer, Walter
2024-11-11 8:49 ` Heiko Schocher
2024-11-08 5:21 ` [PATCH v1 09/22] siemens: imximage.cfg: correct comment Heiko Schocher
2024-11-11 8:41 ` Sverdlin, Alexander
2024-11-08 5:21 ` [PATCH v1 10/22] siemens: imximage.cfg: sync image names Heiko Schocher
2024-11-08 5:21 ` [PATCH v1 11/22] siemens: imx8-capricorn-u-boot.dtsi: add fec2 Heiko Schocher
2024-11-08 5:21 ` [PATCH v1 12/22] siemens: capricorn: add missing ARCH_MISC_INIT Heiko Schocher
2024-11-09 12:03 ` Fabio Estevam
2024-11-08 5:21 ` [PATCH v1 13/22] siemens: configs/capricorn_cxg3_defconfig: updates Heiko Schocher
2024-11-09 12:10 ` Fabio Estevam
2024-11-11 10:04 ` Sverdlin, Alexander
2024-11-08 5:21 ` [PATCH v1 14/22] siemens: capricorn: sync spl code with 8qxp-mek Heiko Schocher
2024-11-08 5:21 ` [PATCH v1 15/22] siemens: imx8-capricorn.dtsi: small adaptions Heiko Schocher
2024-11-09 12:03 ` Fabio Estevam
2024-11-11 5:52 ` Heiko Schocher
2024-11-11 8:25 ` Leto, Enrico
2024-11-11 8:47 ` Heiko Schocher
2024-11-11 9:24 ` Leto, Enrico
2024-11-11 12:08 ` Sverdlin, Alexander
2024-11-11 10:36 ` Sverdlin, Alexander
2024-11-08 5:21 ` [PATCH v1 16/22] siemens: capricorn: board.c fixes Heiko Schocher
2024-11-09 16:38 ` Fabio Estevam
2024-11-11 6:01 ` Heiko Schocher
2024-11-08 5:21 ` [PATCH v1 17/22] siemens: capricorn: add HW version information to boot log Heiko Schocher
2024-11-09 12:09 ` Fabio Estevam
2024-11-11 5:57 ` Heiko Schocher
2024-11-08 5:21 ` [PATCH v1 18/22] siemens: capricorn: get ram size from system controller Heiko Schocher
2024-11-08 5:21 ` [PATCH v1 19/22] siemens: capricorn: get module name from eeprom Heiko Schocher
2024-11-08 5:21 ` [PATCH v1 20/22] siemens: add ddr full memory test Heiko Schocher
2024-11-09 12:06 ` Fabio Estevam
2024-11-11 5:55 ` Heiko Schocher
2024-11-11 8:48 ` Leto, Enrico
2024-11-08 5:21 ` [PATCH v1 21/22] siemens: add ddr signal integrity test Heiko Schocher
2024-11-08 5:21 ` [PATCH v1 22/22] siemens: capricorn: update maintainers Heiko Schocher
2024-11-08 11:51 ` Sverdlin, Alexander
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241108052143.26874-2-hs@denx.de \
--to=hs@denx.de \
--cc=alexander.sverdlin@siemens.com \
--cc=andrej.valek@siemens.com \
--cc=bastien.curutchet@bootlin.com \
--cc=chanho61.park@samsung.com \
--cc=devarsht@ti.com \
--cc=enrico.leto@siemens.com \
--cc=igor.opaniuk@foundries.io \
--cc=marek.vasut+renesas@mailbox.org \
--cc=randolph@andestech.com \
--cc=ravi@prevas.dk \
--cc=sjg@chromium.org \
--cc=sr@denx.de \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=walter.schweizer@siemens.com \
--cc=ycliang@andestech.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox