From: "Benoît Monin" <benoit.monin@bootlin.com>
To: opensbi@lists.infradead.org
Cc: "Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
"Randolph Sheng-Kai Lin(林聖凱)" <randolph@andestech.com>,
"Jun Chang" <jun.chang@metanoia-comm.com>,
"Benoît Monin" <benoit.monin@bootlin.com>
Subject: [PATCH v2 2/2] lib: utils/reset: Add Metanoia MT2824 system reset driver
Date: Thu, 25 Jun 2026 09:54:55 +0200 [thread overview]
Message-ID: <20260625-mt5824-v2-2-48bd438fc2e5@bootlin.com> (raw)
In-Reply-To: <20260625-mt5824-v2-0-48bd438fc2e5@bootlin.com>
Add a driver for the system reset function found in Metanoia MT2824 SoC
and enable it in the generic platform configuration.
Originally-by: Jun Chang <jun.chang@metanoia-comm.com>
Signed-off-by: Benoît Monin <benoit.monin@bootlin.com>
---
lib/utils/reset/Kconfig | 4 ++
lib/utils/reset/fdt_reset_metanoia.c | 72 ++++++++++++++++++++++++++++++++++++
lib/utils/reset/objects.mk | 3 ++
platform/generic/configs/defconfig | 1 +
4 files changed, 80 insertions(+)
diff --git a/lib/utils/reset/Kconfig b/lib/utils/reset/Kconfig
index b2ac120e..8988548c 100644
--- a/lib/utils/reset/Kconfig
+++ b/lib/utils/reset/Kconfig
@@ -29,6 +29,10 @@ config FDT_RESET_LITEX
depends on FDT_GPIO
default n
+config FDT_RESET_METANOIA
+ bool "Metanoia FDT reset driver"
+ default n
+
config FDT_RESET_RPMI
bool "RPMI FDT reset driver"
depends on FDT_MAILBOX && RPMI_MAILBOX
diff --git a/lib/utils/reset/fdt_reset_metanoia.c b/lib/utils/reset/fdt_reset_metanoia.c
new file mode 100644
index 00000000..bdf8c492
--- /dev/null
+++ b/lib/utils/reset/fdt_reset_metanoia.c
@@ -0,0 +1,72 @@
+/*
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2026 Metanoia Communications Inc.
+ *
+ */
+
+#include <sbi/riscv_io.h>
+#include <sbi/sbi_platform.h>
+#include <sbi/sbi_system.h>
+#include <sbi_utils/fdt/fdt_helper.h>
+#include <sbi_utils/fdt/fdt_driver.h>
+
+#define SWRSTREQ_CTRL_REG_OFFSET 0x00
+#define SWRSTREQ_REG_OFFSET 0x04
+
+struct reset_metanoia_data {
+ u8 *reg_base;
+};
+
+static struct reset_metanoia_data reset_data;
+
+static int metanoia_system_reset_check(u32 type, u32 reason)
+{
+ switch (type) {
+ case SBI_SRST_RESET_TYPE_WARM_REBOOT:
+ case SBI_SRST_RESET_TYPE_COLD_REBOOT:
+ return 1;
+ case SBI_SRST_RESET_TYPE_SHUTDOWN:
+ default:
+ return 0;
+ }
+}
+
+static void metanoia_system_reset(u32 type, u32 reason)
+{
+ writew(0x1, reset_data.reg_base + SWRSTREQ_CTRL_REG_OFFSET);
+ writew(0x1, reset_data.reg_base + SWRSTREQ_REG_OFFSET);
+}
+
+static struct sbi_system_reset_device metanoia_reset = {
+ .name = "metanoia-mt2824-reset",
+ .system_reset_check = metanoia_system_reset_check,
+ .system_reset = metanoia_system_reset,
+};
+
+static int metanoia_reset_init(const void *fdt, int nodeoff,
+ const struct fdt_match *match)
+{
+ u64 reg_addr;
+ int rc;
+
+ rc = fdt_get_node_addr_size(fdt, nodeoff, 0, ®_addr, NULL);
+ if (rc < 0 || !reg_addr)
+ return SBI_ENODEV;
+
+ reset_data.reg_base = (u8 *)reg_addr;
+
+ sbi_system_reset_add_device(&metanoia_reset);
+
+ return 0;
+}
+
+static const struct fdt_match metanoia_reset_match[] = {
+ { .compatible = "metanoia,mt2824-reboot" },
+ { /* sentinel */ }
+};
+
+const struct fdt_driver fdt_reset_metanoia = {
+ .match_table = metanoia_reset_match,
+ .init = metanoia_reset_init,
+};
diff --git a/lib/utils/reset/objects.mk b/lib/utils/reset/objects.mk
index 38b4e306..a9b6edad 100644
--- a/lib/utils/reset/objects.mk
+++ b/lib/utils/reset/objects.mk
@@ -20,6 +20,9 @@ libsbiutils-objs-$(CONFIG_FDT_RESET_HTIF) += reset/fdt_reset_htif.o
carray-fdt_early_drivers-$(CONFIG_FDT_RESET_LITEX) += fdt_reset_litex
libsbiutils-objs-$(CONFIG_FDT_RESET_LITEX) += reset/fdt_reset_litex.o
+carray-fdt_early_drivers-$(CONFIG_FDT_RESET_METANOIA) += fdt_reset_metanoia
+libsbiutils-objs-$(CONFIG_FDT_RESET_METANOIA) += reset/fdt_reset_metanoia.o
+
carray-fdt_early_drivers-$(CONFIG_FDT_RESET_SG2042_HWMON_MCU) += fdt_reset_sg2042_mcu
libsbiutils-objs-$(CONFIG_FDT_RESET_SG2042_HWMON_MCU) += reset/fdt_reset_sg2042_hwmon_mcu.o
diff --git a/platform/generic/configs/defconfig b/platform/generic/configs/defconfig
index 820c98b6..ac76eb27 100644
--- a/platform/generic/configs/defconfig
+++ b/platform/generic/configs/defconfig
@@ -52,6 +52,7 @@ CONFIG_FDT_RESET_ATCWDT200=y
CONFIG_FDT_RESET_GPIO=y
CONFIG_FDT_RESET_LITEX=y
CONFIG_FDT_RESET_HTIF=y
+CONFIG_FDT_RESET_METANOIA=y
CONFIG_FDT_RESET_RPMI=y
CONFIG_FDT_RESET_SG2042_HWMON_MCU=y
CONFIG_FDT_RESET_SPACEMIT_P1=y
--
2.54.0
--
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
prev parent reply other threads:[~2026-06-25 7:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-25 7:54 [PATCH v2 0/2] Introduce Metanoia MT2824 SoC support Benoît Monin
2026-06-25 7:54 ` [PATCH v2 1/2] platform: generic: Add Metanoia MT2824 initial support Benoît Monin
2026-06-25 7:54 ` Benoît Monin [this message]
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=20260625-mt5824-v2-2-48bd438fc2e5@bootlin.com \
--to=benoit.monin@bootlin.com \
--cc=jun.chang@metanoia-comm.com \
--cc=opensbi@lists.infradead.org \
--cc=randolph@andestech.com \
--cc=thomas.petazzoni@bootlin.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