Devicetree
 help / color / mirror / Atom feed
* [PATCH v4 0/7] Properly describe mt6589 and mt8167 toprgu resets
@ 2026-08-19 10:16 Luca Leonardo Scorcia
  2026-08-19 10:16 ` [PATCH v4 1/7] dt-bindings: reset: Add mt6589 toprgu reset IDs Luca Leonardo Scorcia
                   ` (7 more replies)
  0 siblings, 8 replies; 13+ messages in thread
From: Luca Leonardo Scorcia @ 2026-08-19 10:16 UTC (permalink / raw)
  To: linux-mediatek
  Cc: Luca Leonardo Scorcia, Wim Van Sebroeck, Guenter Roeck,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
	AngeloGioacchino Del Regno, Philipp Zabel, linux-watchdog,
	devicetree, linux-kernel, linux-arm-kernel

Currently mt8167 inherits its watchdog from the included mt8516 dtsi,
which in turn falls back on mt6589-wdt, which does not support toprgu
resets yet. This series adds support for mt6589 toprgu resets with bit
definitions obtained from Android stock sources.

However, according to its data sheet, mt8167 has 14 sw resets instead of
12, and the reset bits are non-contiguous. This is currently unsupported
by the mtk-wtd driver, and it caused confusion between reset IDs and reset
bits in device tree includes.

Therefore in the first three patches we improve the description of the,
resets for mt6589 using the definitions obtained from Android sources.

Then we introduce a dedicated mediatek,mt8167-wdt compatible for the
watchdog driver that describes correctly this SoC's resets. Also while
we're touching the bindings reset includes, we add IDs for the MMSYS
resets.

In the 5th patch we add support for a watchdog reset table to accommodate
the distinction between device tree reset IDs and the actual bits in the
registers. Code is inspired by the reset table currently implemented in the
mmsys driver. There should be no effect on existing sequential wdt resets.

In the 6th patch, we define the mmsys reset table for the SoC. According
to the datasheet, there are 28 mmsys reset bits divided across two
adjacent registers.

In the last patch we actually enable the watchdog driver for mt8167 by
adding a node for the mt8167 watchdog referring to the new compatible in
the SoC dtsi.

The series has been tested on a Sony PlayStation Classic Mini and on a
Lenovo Smart Clock 2.

Changes in v4:
- Squashed the reset IDs includes together with the bindings change;
- Added support for a reset table to the mtk-wdt driver. This allows us
  to decouple reset IDs from device trees from reset bits and lets us
  describe correctly the non-contiguous reset bits of mt8167;
- Improved explanations in commit messages.

Changes in v3 [3]:
- Improved explanations in the commit messages;
- Added the #reset-cells property to mt6589 watchdog node;
- Included the mediatek,mt6589-resets.h file in mt6589.dtsi;
- Included the mediatek,mt8167-resets.h file in mt8167.dtsi;
- Moved the mmsys reset table from the mt8167-mmsys.h header file to
  the mmsys driver implementation.

Changes in v2 [2]:
- Sashiko pointed out correctly a missing entry in the mmsys reset table
  in the last patch.

Initial version: [1]

[1] https://lore.kernel.org/linux-mediatek/20260717151134.678839-1-l.scorcia@gmail.com/
[2] https://lore.kernel.org/linux-mediatek/20260717163959.714561-1-l.scorcia@gmail.com/


Luca Leonardo Scorcia (7):
  dt-bindings: reset: Add mt6589 toprgu reset IDs
  watchdog: mediatek: Add wdt/toprgu resets for mt6589
  arm: dts: mediatek: mt6589: Enable toprgu reset controller
  dt-bindings: watchdog: Add compatible for MediaTek mt8167
  watchdog: mediatek: Add support for mt8167 toprgu/watchdog
  soc: mediatek: mtk-mmsys: Add resets for mt8167
  arm64: dts: mt8167: Properly describe the SoC watchdog and mmsys
    resets

 .../bindings/watchdog/mediatek,mtk-wdt.yaml   |  1 +
 arch/arm/boot/dts/mediatek/mt6589.dtsi        |  2 +
 arch/arm64/boot/dts/mediatek/mt8167.dtsi      | 10 ++++
 drivers/soc/mediatek/mt8167-mmsys.h           |  3 ++
 drivers/soc/mediatek/mtk-mmsys.c              | 38 +++++++++++++
 drivers/watchdog/mtk_wdt.c                    | 54 +++++++++++++++++--
 .../dt-bindings/reset/mediatek,mt6589-wdt.h   | 20 +++++++
 .../dt-bindings/reset/mediatek,mt8167-mmsys.h | 35 ++++++++++++
 .../dt-bindings/reset/mediatek,mt8167-wdt.h   | 21 ++++++++
 9 files changed, 179 insertions(+), 5 deletions(-)
 create mode 100644 include/dt-bindings/reset/mediatek,mt6589-wdt.h
 create mode 100644 include/dt-bindings/reset/mediatek,mt8167-mmsys.h
 create mode 100644 include/dt-bindings/reset/mediatek,mt8167-wdt.h

-- 
2.43.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v4 1/7] dt-bindings: reset: Add mt6589 toprgu reset IDs
  2026-08-19 10:16 [PATCH v4 0/7] Properly describe mt6589 and mt8167 toprgu resets Luca Leonardo Scorcia
@ 2026-08-19 10:16 ` Luca Leonardo Scorcia
  2026-08-19 10:16 ` [PATCH v4 2/7] watchdog: mediatek: Add wdt/toprgu resets for mt6589 Luca Leonardo Scorcia
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 13+ messages in thread
From: Luca Leonardo Scorcia @ 2026-08-19 10:16 UTC (permalink / raw)
  To: linux-mediatek
  Cc: Luca Leonardo Scorcia, Akari Tsuyukusa, Wim Van Sebroeck,
	Guenter Roeck, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Matthias Brugger, AngeloGioacchino Del Regno, Philipp Zabel,
	linux-watchdog, devicetree, linux-kernel, linux-arm-kernel

Add IDs for the 12 mt6589 toprgu resets which can be used in device trees
to identify subsystem resets. The binding for the associated reset
controller mt6589-wdt is already upstream.

Signed-off-by: Luca Leonardo Scorcia <l.scorcia@gmail.com>
Acked-by: Akari Tsuyukusa <akkun11.open@gmail.com>
---
 .../dt-bindings/reset/mediatek,mt6589-wdt.h   | 20 +++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 include/dt-bindings/reset/mediatek,mt6589-wdt.h

diff --git a/include/dt-bindings/reset/mediatek,mt6589-wdt.h b/include/dt-bindings/reset/mediatek,mt6589-wdt.h
new file mode 100644
index 000000000000..5e39c8cdd718
--- /dev/null
+++ b/include/dt-bindings/reset/mediatek,mt6589-wdt.h
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
+#ifndef _DT_BINDINGS_RESET_MEDIATEK_MT6589_WDT_H_
+#define _DT_BINDINGS_RESET_MEDIATEK_MT6589_WDT_H_
+
+/* TOPRGU reset IDs */
+#define MT6589_TOPRGU_INFRA_SW_RST		0
+#define MT6589_TOPRGU_MM_SW_RST			1
+#define MT6589_TOPRGU_MFG_SW_RST		2
+#define MT6589_TOPRGU_VENC_SW_RST		3
+#define MT6589_TOPRGU_VDEC_SW_RST		4
+#define MT6589_TOPRGU_IMG_SW_RST		5
+#define MT6589_TOPRGU_DDRPHY_SW_RST		6
+#define MT6589_TOPRGU_MD_SW_RST			7
+#define MT6589_TOPRGU_INFRA_AO_SW_RST		8
+#define MT6589_TOPRGU_MD_LITE_SW_RST		9
+#define MT6589_TOPRGU_APMIXED_SW_RST		10
+#define MT6589_TOPRGU_PWRAP_SPI_CTL_RST		11
+#define MT6589_TOPRGU_SW_RST_NUM		12
+
+#endif  /* _DT_BINDINGS_RESET_MEDIATEK_MT6589_WDT_H_ */
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v4 2/7] watchdog: mediatek: Add wdt/toprgu resets for mt6589
  2026-08-19 10:16 [PATCH v4 0/7] Properly describe mt6589 and mt8167 toprgu resets Luca Leonardo Scorcia
  2026-08-19 10:16 ` [PATCH v4 1/7] dt-bindings: reset: Add mt6589 toprgu reset IDs Luca Leonardo Scorcia
@ 2026-08-19 10:16 ` Luca Leonardo Scorcia
  2026-08-19 10:30   ` sashiko-bot
  2026-08-19 10:16 ` [PATCH v4 3/7] arm: dts: mediatek: mt6589: Enable toprgu reset controller Luca Leonardo Scorcia
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 13+ messages in thread
From: Luca Leonardo Scorcia @ 2026-08-19 10:16 UTC (permalink / raw)
  To: linux-mediatek
  Cc: Luca Leonardo Scorcia, Wim Van Sebroeck, Guenter Roeck,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
	AngeloGioacchino Del Regno, Philipp Zabel, linux-watchdog,
	devicetree, linux-kernel, linux-arm-kernel

According to Android sources, mt6589 has 12 reset bits in the
WDT_SWSYSRST register. Populate toprgu_sw_rst_num to allow toprgu resets
in device trees of the many compatible devices.

Signed-off-by: Luca Leonardo Scorcia <l.scorcia@gmail.com>
---
 drivers/watchdog/mtk_wdt.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/watchdog/mtk_wdt.c b/drivers/watchdog/mtk_wdt.c
index 91d110646e16..f8208fb0f723 100644
--- a/drivers/watchdog/mtk_wdt.c
+++ b/drivers/watchdog/mtk_wdt.c
@@ -10,6 +10,7 @@
  */
 
 #include <dt-bindings/reset/mt2712-resets.h>
+#include <dt-bindings/reset/mediatek,mt6589-wdt.h>
 #include <dt-bindings/reset/mediatek,mt6735-wdt.h>
 #include <dt-bindings/reset/mediatek,mt6795-resets.h>
 #include <dt-bindings/reset/mt7986-resets.h>
@@ -88,6 +89,10 @@ static const struct mtk_wdt_data mt2712_data = {
 	.toprgu_sw_rst_num = MT2712_TOPRGU_SW_RST_NUM,
 };
 
+static const struct mtk_wdt_data mt6589_data = {
+	.toprgu_sw_rst_num = MT6589_TOPRGU_SW_RST_NUM,
+};
+
 static const struct mtk_wdt_data mt6735_data = {
 	.toprgu_sw_rst_num = MT6735_TOPRGU_RST_NUM,
 };
@@ -493,7 +498,7 @@ static int mtk_wdt_resume(struct device *dev)
 
 static const struct of_device_id mtk_wdt_dt_ids[] = {
 	{ .compatible = "mediatek,mt2712-wdt", .data = &mt2712_data },
-	{ .compatible = "mediatek,mt6589-wdt" },
+	{ .compatible = "mediatek,mt6589-wdt", .data = &mt6589_data },
 	{ .compatible = "mediatek,mt6735-wdt", .data = &mt6735_data },
 	{ .compatible = "mediatek,mt6795-wdt", .data = &mt6795_data },
 	{ .compatible = "mediatek,mt7986-wdt", .data = &mt7986_data },
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v4 3/7] arm: dts: mediatek: mt6589: Enable toprgu reset controller
  2026-08-19 10:16 [PATCH v4 0/7] Properly describe mt6589 and mt8167 toprgu resets Luca Leonardo Scorcia
  2026-08-19 10:16 ` [PATCH v4 1/7] dt-bindings: reset: Add mt6589 toprgu reset IDs Luca Leonardo Scorcia
  2026-08-19 10:16 ` [PATCH v4 2/7] watchdog: mediatek: Add wdt/toprgu resets for mt6589 Luca Leonardo Scorcia
@ 2026-08-19 10:16 ` Luca Leonardo Scorcia
  2026-08-19 17:43   ` Akari Tsuyukusa
  2026-08-19 10:16 ` [PATCH v4 4/7] dt-bindings: watchdog: Add compatible for MediaTek mt8167 Luca Leonardo Scorcia
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 13+ messages in thread
From: Luca Leonardo Scorcia @ 2026-08-19 10:16 UTC (permalink / raw)
  To: linux-mediatek
  Cc: Luca Leonardo Scorcia, Akari Tsuyukusa, Wim Van Sebroeck,
	Guenter Roeck, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Matthias Brugger, AngeloGioacchino Del Regno, Philipp Zabel,
	linux-watchdog, devicetree, linux-kernel, linux-arm-kernel

Enable the toprgu reset controller feature for the mt6589 SoC. This
allows generating reset signals for the 12 subsystems managed by its
top reset generation unit.

Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
Signed-off-by: Luca Leonardo Scorcia <l.scorcia@gmail.com>
---
 arch/arm/boot/dts/mediatek/mt6589.dtsi | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/boot/dts/mediatek/mt6589.dtsi b/arch/arm/boot/dts/mediatek/mt6589.dtsi
index 46dea445742b..2ba912a356af 100644
--- a/arch/arm/boot/dts/mediatek/mt6589.dtsi
+++ b/arch/arm/boot/dts/mediatek/mt6589.dtsi
@@ -7,6 +7,7 @@
 
 #include <dt-bindings/interrupt-controller/irq.h>
 #include <dt-bindings/interrupt-controller/arm-gic.h>
+#include <dt-bindings/reset/mediatek,mt6589-wdt.h>
 
 / {
 	#address-cells = <1>;
@@ -147,6 +148,7 @@ uart3: serial@11009000 {
 		wdt: watchdog@10000000 {
 			compatible = "mediatek,mt6589-wdt";
 			reg = <0x10000000 0x44>;
+			#reset-cells = <1>;
 		};
 	};
 };
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v4 4/7] dt-bindings: watchdog: Add compatible for MediaTek mt8167
  2026-08-19 10:16 [PATCH v4 0/7] Properly describe mt6589 and mt8167 toprgu resets Luca Leonardo Scorcia
                   ` (2 preceding siblings ...)
  2026-08-19 10:16 ` [PATCH v4 3/7] arm: dts: mediatek: mt6589: Enable toprgu reset controller Luca Leonardo Scorcia
@ 2026-08-19 10:16 ` Luca Leonardo Scorcia
  2026-08-19 10:29   ` sashiko-bot
  2026-08-19 10:16 ` [PATCH v4 5/7] watchdog: mediatek: Add support for mt8167 toprgu/watchdog Luca Leonardo Scorcia
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 13+ messages in thread
From: Luca Leonardo Scorcia @ 2026-08-19 10:16 UTC (permalink / raw)
  To: linux-mediatek
  Cc: Luca Leonardo Scorcia, Wim Van Sebroeck, Guenter Roeck,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
	AngeloGioacchino Del Regno, Philipp Zabel, linux-watchdog,
	devicetree, linux-kernel, linux-arm-kernel

Currently mt8167 inherits its watchdog from the included mt8516 dtsi,
which in turn falls back on mt6589-wdt. However according to the data
sheet mt8167 toprgu is not actually compatible with mt6589: the latter
has 12 contiguous toprgu reset bits while the former has 14 non-contiguous
toprgu reset bits.

Update the mtk-wdt binding to add a dedicated compatible for mt8167 and
add the IDs that can be used in device trees to identify toprgu and mmsys
subsystem resets.

Signed-off-by: Luca Leonardo Scorcia <l.scorcia@gmail.com>
---
 .../bindings/watchdog/mediatek,mtk-wdt.yaml   |  1 +
 .../dt-bindings/reset/mediatek,mt8167-mmsys.h | 35 +++++++++++++++++++
 .../dt-bindings/reset/mediatek,mt8167-wdt.h   | 21 +++++++++++
 3 files changed, 57 insertions(+)
 create mode 100644 include/dt-bindings/reset/mediatek,mt8167-mmsys.h
 create mode 100644 include/dt-bindings/reset/mediatek,mt8167-wdt.h

diff --git a/Documentation/devicetree/bindings/watchdog/mediatek,mtk-wdt.yaml b/Documentation/devicetree/bindings/watchdog/mediatek,mtk-wdt.yaml
index 953629cb9558..f514be8a5851 100644
--- a/Documentation/devicetree/bindings/watchdog/mediatek,mtk-wdt.yaml
+++ b/Documentation/devicetree/bindings/watchdog/mediatek,mtk-wdt.yaml
@@ -26,6 +26,7 @@ properties:
           - mediatek,mt6795-wdt
           - mediatek,mt7986-wdt
           - mediatek,mt7988-wdt
+          - mediatek,mt8167-wdt
           - mediatek,mt8183-wdt
           - mediatek,mt8186-wdt
           - mediatek,mt8188-wdt
diff --git a/include/dt-bindings/reset/mediatek,mt8167-mmsys.h b/include/dt-bindings/reset/mediatek,mt8167-mmsys.h
new file mode 100644
index 000000000000..b21f67b3b55c
--- /dev/null
+++ b/include/dt-bindings/reset/mediatek,mt8167-mmsys.h
@@ -0,0 +1,35 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
+#ifndef _DT_BINDINGS_RESET_MEDIATEK_MT8167_MMSYS_H_
+#define _DT_BINDINGS_RESET_MEDIATEK_MT8167_MMSYS_H_
+
+/* MMSYS reset IDs */
+#define MT8167_MMSYS_SW0_RST_B_SMI_COMMON	0
+#define MT8167_MMSYS_SW0_RST_B_SMI_LARB0	1
+#define MT8167_MMSYS_SW0_RST_B_CAM_MDP		2
+#define MT8167_MMSYS_SW0_RST_B_MDP_RDMA0	3
+#define MT8167_MMSYS_SW0_RST_B_MDP_RSZ0		4
+#define MT8167_MMSYS_SW0_RST_B_MDP_RSZ1		5
+#define MT8167_MMSYS_SW0_RST_B_MDP_TDSHP0	6
+#define MT8167_MMSYS_SW0_RST_B_MDP_WDMA		7
+#define MT8167_MMSYS_SW0_RST_B_MDP_WROT0	8
+#define MT8167_MMSYS_SW0_RST_B_FAKE_ENG		9
+#define MT8167_MMSYS_SW0_RST_B_MUTEX		10
+#define MT8167_MMSYS_SW0_RST_B_DISP_OVL0	11
+#define MT8167_MMSYS_SW0_RST_B_DISP_RDMA0	12
+#define MT8167_MMSYS_SW0_RST_B_DISP_RDMA1	13
+#define MT8167_MMSYS_SW0_RST_B_DISP_WDMA0	14
+#define MT8167_MMSYS_SW0_RST_B_DISP_COLOR	15
+#define MT8167_MMSYS_SW0_RST_B_DISP_CCORR	16
+#define MT8167_MMSYS_SW0_RST_B_DISP_AAL		17
+#define MT8167_MMSYS_SW0_RST_B_DISP_GAMMA	18
+#define MT8167_MMSYS_SW0_RST_B_DISP_DITHER	19
+#define MT8167_MMSYS_SW0_RST_B_DISP_UFOE	20
+#define MT8167_MMSYS_SW0_RST_B_DISP_PWM		21
+#define MT8167_MMSYS_SW0_RST_B_DSI0		22
+#define MT8167_MMSYS_SW0_RST_B_DPI0		23
+#define MT8167_MMSYS_SW0_RST_B_MIPI_TX_CONFIG	24
+#define MT8167_MMSYS_SW1_RST_B_LVDS_ENCODER	25
+#define MT8167_MMSYS_SW1_RST_B_DPI1		26
+#define MT8167_MMSYS_SW1_RST_B_HDMI		27
+
+#endif  /* _DT_BINDINGS_RESET_MEDIATEK_MT8167_MMSYS_H_ */
diff --git a/include/dt-bindings/reset/mediatek,mt8167-wdt.h b/include/dt-bindings/reset/mediatek,mt8167-wdt.h
new file mode 100644
index 000000000000..1a24bfe079ca
--- /dev/null
+++ b/include/dt-bindings/reset/mediatek,mt8167-wdt.h
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
+#ifndef _DT_BINDINGS_RESET_MEDIATEK_MT8167_WDT_H_
+#define _DT_BINDINGS_RESET_MEDIATEK_MT8167_WDT_H_
+
+/* TOPRGU reset IDs */
+#define MT8167_TOPRGU_DDRPHY_FLASH_RST		0
+#define MT8167_TOPRGU_AUD_PAD_RST		1
+#define MT8167_TOPRGU_MM_RST			2
+#define MT8167_TOPRGU_MFG_RST			3
+#define MT8167_TOPRGU_MDSYS_RST			4
+#define MT8167_TOPRGU_CONN_RST			5
+#define MT8167_TOPRGU_PAD2CAM_DIG_MIPI_RX_RST	6
+#define MT8167_TOPRGU_DIG_MIPI_TX_RST		7
+#define MT8167_TOPRGU_SPI_PAD_MACRO_RST		8
+#define MT8167_TOPRGU_APMIXED_RST		9
+#define MT8167_TOPRGU_VDEC_RST			10
+#define MT8167_TOPRGU_CONN_MCU_RST		11
+#define MT8167_TOPRGU_EFUSE_RST			12
+#define MT8167_TOPRGU_PWRAP_SPICTL_RST		13
+
+#endif  /* _DT_BINDINGS_RESET_MEDIATEK_MT8167_WDT_H_ */
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v4 5/7] watchdog: mediatek: Add support for mt8167 toprgu/watchdog
  2026-08-19 10:16 [PATCH v4 0/7] Properly describe mt6589 and mt8167 toprgu resets Luca Leonardo Scorcia
                   ` (3 preceding siblings ...)
  2026-08-19 10:16 ` [PATCH v4 4/7] dt-bindings: watchdog: Add compatible for MediaTek mt8167 Luca Leonardo Scorcia
@ 2026-08-19 10:16 ` Luca Leonardo Scorcia
  2026-08-19 10:29   ` sashiko-bot
  2026-08-19 10:16 ` [PATCH v4 6/7] soc: mediatek: mtk-mmsys: Add resets for mt8167 Luca Leonardo Scorcia
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 13+ messages in thread
From: Luca Leonardo Scorcia @ 2026-08-19 10:16 UTC (permalink / raw)
  To: linux-mediatek
  Cc: Luca Leonardo Scorcia, Wim Van Sebroeck, Guenter Roeck,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
	AngeloGioacchino Del Regno, Philipp Zabel, linux-watchdog,
	devicetree, linux-kernel, linux-arm-kernel

Add support for the Top Reset Generation Unit/Watchdog Timer found on
mt8167.

Since according to its data sheet mt8167 toprgu reset bits are not
contiguous, add support for a reset table to the driver. This lets us
define reset identifiers as contiguous indexes in the binding headers.

Also address a preexisting Sashiko finding that noticed that the
has_swsysrst_en configuration was set after the reset controller
registration.

Signed-off-by: Luca Leonardo Scorcia <l.scorcia@gmail.com>
---
 drivers/watchdog/mtk_wdt.c | 47 ++++++++++++++++++++++++++++++++++----
 1 file changed, 43 insertions(+), 4 deletions(-)

diff --git a/drivers/watchdog/mtk_wdt.c b/drivers/watchdog/mtk_wdt.c
index f8208fb0f723..fa522fd80dd4 100644
--- a/drivers/watchdog/mtk_wdt.c
+++ b/drivers/watchdog/mtk_wdt.c
@@ -13,6 +13,7 @@
 #include <dt-bindings/reset/mediatek,mt6589-wdt.h>
 #include <dt-bindings/reset/mediatek,mt6735-wdt.h>
 #include <dt-bindings/reset/mediatek,mt6795-resets.h>
+#include <dt-bindings/reset/mediatek,mt8167-wdt.h>
 #include <dt-bindings/reset/mt7986-resets.h>
 #include <dt-bindings/reset/mt8183-resets.h>
 #include <dt-bindings/reset/mt8186-resets.h>
@@ -78,11 +79,14 @@ struct mtk_wdt_dev {
 	bool disable_wdt_extrst;
 	bool reset_by_toprgu;
 	bool has_swsysrst_en;
+	const u8 *toprgu_sw_rst_tb;
+	int toprgu_sw_rst_num;
 };
 
 struct mtk_wdt_data {
-	int toprgu_sw_rst_num;
-	bool has_swsysrst_en;
+	const u8 *toprgu_sw_rst_tb;
+	const int toprgu_sw_rst_num;
+	const bool has_swsysrst_en;
 };
 
 static const struct mtk_wdt_data mt2712_data = {
@@ -130,6 +134,29 @@ static const struct mtk_wdt_data mt8195_data = {
 	.toprgu_sw_rst_num = MT8195_TOPRGU_SW_RST_NUM,
 };
 
+static const u8 mt8167_toprgu_sw_rst_tb[] = {
+	[MT8167_TOPRGU_DDRPHY_FLASH_RST]	= 0,
+	[MT8167_TOPRGU_AUD_PAD_RST]		= 1,
+	[MT8167_TOPRGU_MM_RST]			= 2,
+	[MT8167_TOPRGU_MFG_RST]			= 3,
+	[MT8167_TOPRGU_MDSYS_RST]		= 4,
+	[MT8167_TOPRGU_CONN_RST]		= 5,
+	[MT8167_TOPRGU_PAD2CAM_DIG_MIPI_RX_RST]	= 6,
+	[MT8167_TOPRGU_DIG_MIPI_TX_RST]		= 7,
+	[MT8167_TOPRGU_SPI_PAD_MACRO_RST]	= 8,
+	/* The data sheet describes bit 9 as "reserved, unused" */
+	[MT8167_TOPRGU_APMIXED_RST]		= 10,
+	[MT8167_TOPRGU_VDEC_RST]		= 11,
+	[MT8167_TOPRGU_CONN_MCU_RST]		= 12,
+	[MT8167_TOPRGU_EFUSE_RST]		= 13,
+	[MT8167_TOPRGU_PWRAP_SPICTL_RST]	= 14
+};
+
+static const struct mtk_wdt_data mt8167_data = {
+	.toprgu_sw_rst_tb = mt8167_toprgu_sw_rst_tb,
+	.toprgu_sw_rst_num = ARRAY_SIZE(mt8167_toprgu_sw_rst_tb),
+};
+
 /**
  * toprgu_reset_sw_en_unlocked() - enable/disable software control for reset bit
  * @data: Pointer to instance of driver data.
@@ -160,6 +187,15 @@ static int toprgu_reset_update(struct reset_controller_dev *rcdev,
 	struct mtk_wdt_dev *data =
 		 container_of(rcdev, struct mtk_wdt_dev, rcdev);
 
+	if (data->toprgu_sw_rst_tb) {
+		if (id >= data->toprgu_sw_rst_num) {
+			dev_err(rcdev->dev, "Invalid reset ID: %lu (>=%u)\n",
+				id, data->toprgu_sw_rst_num);
+			return -EINVAL;
+		}
+		id = data->toprgu_sw_rst_tb[id];
+	}
+
 	spin_lock_irqsave(&data->lock, flags);
 
 	if (assert && data->has_swsysrst_en)
@@ -457,12 +493,14 @@ static int mtk_wdt_probe(struct platform_device *pdev)
 
 	wdt_data = of_device_get_match_data(dev);
 	if (wdt_data) {
+		mtk_wdt->toprgu_sw_rst_num = wdt_data->toprgu_sw_rst_num;
+		mtk_wdt->toprgu_sw_rst_tb = wdt_data->toprgu_sw_rst_tb;
+		mtk_wdt->has_swsysrst_en = wdt_data->has_swsysrst_en;
+
 		err = toprgu_register_reset_controller(pdev,
 						       wdt_data->toprgu_sw_rst_num);
 		if (err)
 			return err;
-
-		mtk_wdt->has_swsysrst_en = wdt_data->has_swsysrst_en;
 	}
 
 	mtk_wdt->disable_wdt_extrst =
@@ -503,6 +541,7 @@ static const struct of_device_id mtk_wdt_dt_ids[] = {
 	{ .compatible = "mediatek,mt6795-wdt", .data = &mt6795_data },
 	{ .compatible = "mediatek,mt7986-wdt", .data = &mt7986_data },
 	{ .compatible = "mediatek,mt7988-wdt", .data = &mt7988_data },
+	{ .compatible = "mediatek,mt8167-wdt", .data = &mt8167_data },
 	{ .compatible = "mediatek,mt8183-wdt", .data = &mt8183_data },
 	{ .compatible = "mediatek,mt8186-wdt", .data = &mt8186_data },
 	{ .compatible = "mediatek,mt8188-wdt", .data = &mt8188_data },
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v4 6/7] soc: mediatek: mtk-mmsys: Add resets for mt8167
  2026-08-19 10:16 [PATCH v4 0/7] Properly describe mt6589 and mt8167 toprgu resets Luca Leonardo Scorcia
                   ` (4 preceding siblings ...)
  2026-08-19 10:16 ` [PATCH v4 5/7] watchdog: mediatek: Add support for mt8167 toprgu/watchdog Luca Leonardo Scorcia
@ 2026-08-19 10:16 ` Luca Leonardo Scorcia
  2026-08-19 10:16 ` [PATCH v4 7/7] arm64: dts: mt8167: Properly describe the SoC watchdog and mmsys resets Luca Leonardo Scorcia
  2026-08-19 17:17 ` [PATCH v4 0/7] Properly describe mt6589 and mt8167 toprgu resets Akari Tsuyukusa
  7 siblings, 0 replies; 13+ messages in thread
From: Luca Leonardo Scorcia @ 2026-08-19 10:16 UTC (permalink / raw)
  To: linux-mediatek
  Cc: Luca Leonardo Scorcia, Wim Van Sebroeck, Guenter Roeck,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
	AngeloGioacchino Del Regno, Philipp Zabel, linux-watchdog,
	devicetree, linux-kernel, linux-arm-kernel

The mt8167 SoC has 28 mmsys resets, split across two contiguous 32-bits
registers, MMSYS_SW0_RST_B (0x140) and MMSYS_SW1_RST_B (0x144).

Signed-off-by: Luca Leonardo Scorcia <l.scorcia@gmail.com>
---
 drivers/soc/mediatek/mt8167-mmsys.h |  3 +++
 drivers/soc/mediatek/mtk-mmsys.c    | 38 +++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+)

diff --git a/drivers/soc/mediatek/mt8167-mmsys.h b/drivers/soc/mediatek/mt8167-mmsys.h
index 001379373507..5c7cded5cfa4 100644
--- a/drivers/soc/mediatek/mt8167-mmsys.h
+++ b/drivers/soc/mediatek/mt8167-mmsys.h
@@ -3,6 +3,9 @@
 #ifndef __SOC_MEDIATEK_MT8167_MMSYS_H
 #define __SOC_MEDIATEK_MT8167_MMSYS_H
 
+#define MT8167_MMSYS_SW0_RST_B				0x140
+#define MT8167_MMSYS_SW1_RST_B				0x144
+
 #define MT8167_DISP_REG_CONFIG_DISP_OVL0_MOUT_EN	0x030
 #define MT8167_DISP_REG_CONFIG_DISP_DITHER_MOUT_EN	0x038
 #define MT8167_DISP_REG_CONFIG_DISP_COLOR0_SEL_IN	0x058
diff --git a/drivers/soc/mediatek/mtk-mmsys.c b/drivers/soc/mediatek/mtk-mmsys.c
index 2f3e0778bb17..015dc5b86478 100644
--- a/drivers/soc/mediatek/mtk-mmsys.c
+++ b/drivers/soc/mediatek/mtk-mmsys.c
@@ -4,6 +4,7 @@
  * Author: James Liao <jamesjj.liao@mediatek.com>
  */
 
+#include <dt-bindings/reset/mediatek,mt8167-mmsys.h>
 #include <linux/delay.h>
 #include <linux/device.h>
 #include <linux/io.h>
@@ -53,10 +54,47 @@ static const struct mtk_mmsys_driver_data mt6797_mmsys_driver_data = {
 	.clk_driver = "clk-mt6797-mm",
 };
 
+static const u8 mmsys_mt8167_rst_tb[] = {
+	[MT8167_MMSYS_SW0_RST_B_SMI_COMMON]	= MMSYS_RST_NR(0, 0),
+	[MT8167_MMSYS_SW0_RST_B_SMI_LARB0]	= MMSYS_RST_NR(0, 1),
+	[MT8167_MMSYS_SW0_RST_B_CAM_MDP]	= MMSYS_RST_NR(0, 2),
+	[MT8167_MMSYS_SW0_RST_B_MDP_RDMA0]	= MMSYS_RST_NR(0, 3),
+	[MT8167_MMSYS_SW0_RST_B_MDP_RSZ0]	= MMSYS_RST_NR(0, 4),
+	[MT8167_MMSYS_SW0_RST_B_MDP_RSZ1]	= MMSYS_RST_NR(0, 5),
+	[MT8167_MMSYS_SW0_RST_B_MDP_TDSHP0]	= MMSYS_RST_NR(0, 6),
+	[MT8167_MMSYS_SW0_RST_B_MDP_WDMA]	= MMSYS_RST_NR(0, 7),
+	[MT8167_MMSYS_SW0_RST_B_MDP_WROT0]	= MMSYS_RST_NR(0, 8),
+	[MT8167_MMSYS_SW0_RST_B_FAKE_ENG]	= MMSYS_RST_NR(0, 9),
+	[MT8167_MMSYS_SW0_RST_B_MUTEX]		= MMSYS_RST_NR(0, 10),
+	[MT8167_MMSYS_SW0_RST_B_DISP_OVL0]	= MMSYS_RST_NR(0, 11),
+	[MT8167_MMSYS_SW0_RST_B_DISP_RDMA0]	= MMSYS_RST_NR(0, 12),
+	[MT8167_MMSYS_SW0_RST_B_DISP_RDMA1]	= MMSYS_RST_NR(0, 13),
+	[MT8167_MMSYS_SW0_RST_B_DISP_WDMA0]	= MMSYS_RST_NR(0, 14),
+	[MT8167_MMSYS_SW0_RST_B_DISP_COLOR]	= MMSYS_RST_NR(0, 15),
+	[MT8167_MMSYS_SW0_RST_B_DISP_CCORR]	= MMSYS_RST_NR(0, 16),
+	[MT8167_MMSYS_SW0_RST_B_DISP_AAL]	= MMSYS_RST_NR(0, 17),
+	[MT8167_MMSYS_SW0_RST_B_DISP_GAMMA]	= MMSYS_RST_NR(0, 18),
+	[MT8167_MMSYS_SW0_RST_B_DISP_DITHER]	= MMSYS_RST_NR(0, 19),
+	[MT8167_MMSYS_SW0_RST_B_DISP_UFOE]	= MMSYS_RST_NR(0, 20),
+	[MT8167_MMSYS_SW0_RST_B_DISP_PWM]	= MMSYS_RST_NR(0, 21),
+	[MT8167_MMSYS_SW0_RST_B_DSI0]		= MMSYS_RST_NR(0, 22),
+	[MT8167_MMSYS_SW0_RST_B_DPI0]		= MMSYS_RST_NR(0, 23),
+	/* bit 24 is SMI_COMMON again according to data sheet */
+	/* bit 25 is SMI_LARB0 again according to data sheet */
+	[MT8167_MMSYS_SW0_RST_B_MIPI_TX_CONFIG]	= MMSYS_RST_NR(0, 26),
+	/* all other bits are not described in data sheet */
+	[MT8167_MMSYS_SW1_RST_B_LVDS_ENCODER]	= MMSYS_RST_NR(1, 2),
+	[MT8167_MMSYS_SW1_RST_B_DPI1]		= MMSYS_RST_NR(1, 3),
+	[MT8167_MMSYS_SW1_RST_B_HDMI]		= MMSYS_RST_NR(1, 4),
+};
+
 static const struct mtk_mmsys_driver_data mt8167_mmsys_driver_data = {
 	.clk_driver = "clk-mt8167-mm",
 	.routes = mt8167_mmsys_routing_table,
 	.num_routes = ARRAY_SIZE(mt8167_mmsys_routing_table),
+	.sw0_rst_offset = MT8167_MMSYS_SW0_RST_B,
+	.rst_tb = mmsys_mt8167_rst_tb,
+	.num_resets = ARRAY_SIZE(mmsys_mt8167_rst_tb),
 };
 
 static const struct mtk_mmsys_driver_data mt8173_mmsys_driver_data = {
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v4 7/7] arm64: dts: mt8167: Properly describe the SoC watchdog and mmsys resets
  2026-08-19 10:16 [PATCH v4 0/7] Properly describe mt6589 and mt8167 toprgu resets Luca Leonardo Scorcia
                   ` (5 preceding siblings ...)
  2026-08-19 10:16 ` [PATCH v4 6/7] soc: mediatek: mtk-mmsys: Add resets for mt8167 Luca Leonardo Scorcia
@ 2026-08-19 10:16 ` Luca Leonardo Scorcia
  2026-08-19 17:17 ` [PATCH v4 0/7] Properly describe mt6589 and mt8167 toprgu resets Akari Tsuyukusa
  7 siblings, 0 replies; 13+ messages in thread
From: Luca Leonardo Scorcia @ 2026-08-19 10:16 UTC (permalink / raw)
  To: linux-mediatek
  Cc: Luca Leonardo Scorcia, Wim Van Sebroeck, Guenter Roeck,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
	AngeloGioacchino Del Regno, Philipp Zabel, linux-watchdog,
	devicetree, linux-kernel, linux-arm-kernel

Currently mt8167 inherits its watchdog from the included mt8516 dtsi,
which in turn falls back on mt6589-wdt. However according to the data
sheet mt8167 toprgu is not really compatible with mt6589 (it has 14 sw
resets instead of 12, and the reset IDs are different from mt6589).

Use the dedicated mediatek,mt8167-wdt compatible for the watchdog driver,
as it correctly describes the SoC resets.

Also add support for mmsys resets by declaring the reset-cells property.

Signed-off-by: Luca Leonardo Scorcia <l.scorcia@gmail.com>
---
 arch/arm64/boot/dts/mediatek/mt8167.dtsi | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8167.dtsi b/arch/arm64/boot/dts/mediatek/mt8167.dtsi
index 27cf32d7ae35..cccc487086a1 100644
--- a/arch/arm64/boot/dts/mediatek/mt8167.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8167.dtsi
@@ -8,6 +8,8 @@
 #include <dt-bindings/clock/mt8167-clk.h>
 #include <dt-bindings/memory/mt8167-larb-port.h>
 #include <dt-bindings/power/mt8167-power.h>
+#include <dt-bindings/reset/mediatek,mt8167-mmsys.h>
+#include <dt-bindings/reset/mediatek,mt8167-wdt.h>
 
 #include "mt8167-pinfunc.h"
 
@@ -95,6 +97,13 @@ power-domain@MT8167_POWER_DOMAIN_CONN {
 			};
 		};
 
+		watchdog: watchdog@10007000 {
+			compatible = "mediatek,mt8167-wdt";
+			reg = <0 0x10007000 0 0x1000>;
+			interrupts = <GIC_SPI 198 IRQ_TYPE_LEVEL_LOW>;
+			#reset-cells = <1>;
+		};
+
 		pio: pinctrl@1000b000 {
 			compatible = "mediatek,mt8167-pinctrl";
 			reg = <0 0x1000b000 0 0x1000>;
@@ -124,6 +133,7 @@ mmsys: syscon@14000000 {
 			compatible = "mediatek,mt8167-mmsys", "syscon";
 			reg = <0 0x14000000 0 0x1000>;
 			#clock-cells = <1>;
+			#reset-cells = <1>;
 		};
 
 		larb0: larb@14016000 {
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH v4 4/7] dt-bindings: watchdog: Add compatible for MediaTek mt8167
  2026-08-19 10:16 ` [PATCH v4 4/7] dt-bindings: watchdog: Add compatible for MediaTek mt8167 Luca Leonardo Scorcia
@ 2026-08-19 10:29   ` sashiko-bot
  0 siblings, 0 replies; 13+ messages in thread
From: sashiko-bot @ 2026-08-19 10:29 UTC (permalink / raw)
  To: Luca Leonardo Scorcia; +Cc: robh, conor+dt, devicetree, linux-watchdog

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] Missing `#reset-cells` required property constraint for the `mediatek,mt8167-wdt` reset provider capability.
- [Medium] Missing `#reset-cells` required property constraint for the `mediatek,mt8167-mmsys` reset provider capability.
--

--- Patch [4]: [PATCH v4 4/7] dt-bindings: watchdog: Add compatible for MediaTek mt8167 ---
commit cda604d8e57545578970aa161f863c629cec7278
Author: Luca Leonardo Scorcia <l.scorcia@gmail.com>

dt-bindings: watchdog: Add compatible for MediaTek mt8167

This commit adds a dedicated compatible string for the MediaTek mt8167
watchdog. It also introduces two new header files defining reset IDs for
the toprgu (watchdog) and mmsys subsystems.

> diff --git a/Documentation/devicetree/bindings/watchdog/mediatek,mtk-wdt.yaml b/Documentation/devicetree/bindings/watchdog/mediatek,mtk-wdt.yaml
> index 953629cb9558b..f514be8a5851d 100644
> --- a/Documentation/devicetree/bindings/watchdog/mediatek,mtk-wdt.yaml
> +++ b/Documentation/devicetree/bindings/watchdog/mediatek,mtk-wdt.yaml
> @@ -26,6 +26,7 @@ properties:
>            - mediatek,mt6795-wdt
>            - mediatek,mt7986-wdt
>            - mediatek,mt7988-wdt
> +          - mediatek,mt8167-wdt

[Severity: Medium]
Since this compatible string is being added as a reset provider (indicated by
the new mediatek,mt8167-wdt.h header), should #reset-cells be added as a
required property constraint for mediatek,mt8167-wdt?

Without this constraint, device tree nodes using the mediatek,mt8167-wdt
compatible string could silently pass validation even if they omit
#reset-cells. This would allow incomplete configurations to escape schema
verification, leading to downstream driver or probe failures when another node
attempts to reference it as a reset provider.

[ ... ]

> diff --git a/include/dt-bindings/reset/mediatek,mt8167-mmsys.h b/include/dt-bindings/reset/mediatek,mt8167-mmsys.h
> new file mode 100644
> index 0000000000000..b21f67b3b55c7
> --- /dev/null
> +++ b/include/dt-bindings/reset/mediatek,mt8167-mmsys.h
> @@ -0,0 +1,35 @@
> +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
> +#ifndef _DT_BINDINGS_RESET_MEDIATEK_MT8167_MMSYS_H_

[Severity: Medium]
This new header introduces reset IDs for the mt8167-mmsys hardware, formally
making it a reset provider.

Does the Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.yaml
schema also need to be updated in this patch to require the #reset-cells
property for the mediatek,mt8167-mmsys hardware?

If the schema is not updated, a device tree author could attempt to use an
mt8167 mmsys node as a reset provider but forget to specify #reset-cells,
which would pass schema validation but fail to provide resets at runtime.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260819101853.44681-1-l.scorcia@gmail.com?part=4

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v4 5/7] watchdog: mediatek: Add support for mt8167 toprgu/watchdog
  2026-08-19 10:16 ` [PATCH v4 5/7] watchdog: mediatek: Add support for mt8167 toprgu/watchdog Luca Leonardo Scorcia
@ 2026-08-19 10:29   ` sashiko-bot
  0 siblings, 0 replies; 13+ messages in thread
From: sashiko-bot @ 2026-08-19 10:29 UTC (permalink / raw)
  To: Luca Leonardo Scorcia; +Cc: linux-watchdog, conor+dt, devicetree, robh

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Race condition in watchdog registration exposing uninitialized device properties.
--

--- Patch [5]: [PATCH v4 5/7] watchdog: mediatek: Add support for mt8167 toprgu/watchdog ---
commit 918b68ccd6f0fbc5fe13cfd642a3baccbeddc0ed
Author: Luca Leonardo Scorcia <l.scorcia@gmail.com>

watchdog: mediatek: Add support for mt8167 toprgu/watchdog

This commit adds support for the Top Reset Generation Unit/Watchdog Timer
found on the mt8167 SoC. It uses a reset table to handle non-contiguous
reset bits and ensures the reset controller is registered with the correct
configuration.

> diff --git a/drivers/watchdog/mtk_wdt.c b/drivers/watchdog/mtk_wdt.c
> index f8208fb0f7234..fa522fd80dd45 100644
> --- a/drivers/watchdog/mtk_wdt.c
> +++ b/drivers/watchdog/mtk_wdt.c

[ ... ]

> @@ -457,12 +493,14 @@ static int mtk_wdt_probe(struct platform_device *pdev)
>  
>  	wdt_data = of_device_get_match_data(dev);
>  	if (wdt_data) {

[ ... ]

>  		err = toprgu_register_reset_controller(pdev,
>  						       wdt_data->toprgu_sw_rst_num);
>  		if (err)
>  			return err;
> -
> -		mtk_wdt->has_swsysrst_en = wdt_data->has_swsysrst_en;
>  	}
>  
>  	mtk_wdt->disable_wdt_extrst =

[Severity: High]
This is a pre-existing issue, but does the ordering in mtk_wdt_probe()
create a race condition with userspace?

Looking at the probe function, devm_watchdog_register_device() is called
and exposes the device to userspace before the hardware-specific properties
disable_wdt_extrst and reset_by_toprgu are populated.

If udev or another userspace process opens the watchdog device immediately
upon registration, could mtk_wdt_start() execute before these properties
are initialized?

If so, mtk_wdt_start() would evaluate the properties as false:

mtk_wdt_start() {
        ...
        if (mtk_wdt->disable_wdt_extrst)
                reg &= ~WDT_MODE_EXRST_EN;
        if (mtk_wdt->reset_by_toprgu)
                reg |= WDT_MODE_CNT_SEL;
        ...
}

Could this lead to incorrectly asserting external reset signals or failing
to trigger the proper TOPRGU reset path? Should the watchdog registration
be deferred until all device tree properties are fully parsed?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260819101853.44681-1-l.scorcia@gmail.com?part=5

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v4 2/7] watchdog: mediatek: Add wdt/toprgu resets for mt6589
  2026-08-19 10:16 ` [PATCH v4 2/7] watchdog: mediatek: Add wdt/toprgu resets for mt6589 Luca Leonardo Scorcia
@ 2026-08-19 10:30   ` sashiko-bot
  0 siblings, 0 replies; 13+ messages in thread
From: sashiko-bot @ 2026-08-19 10:30 UTC (permalink / raw)
  To: Luca Leonardo Scorcia; +Cc: conor+dt, robh, devicetree, linux-watchdog

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Pre-existing issues:
- [High] Watchdog device is registered before its driver data is fully initialized, allowing userspace to trigger `mtk_wdt_start()` with uninitialized flags.
- [High] Reset controller is registered before `has_swsysrst_en` is initialized, causing a race condition where reset operations use incorrect configurations.
--

--- Patch [2]: [PATCH v4 2/7] watchdog: mediatek: Add wdt/toprgu resets for mt6589 ---
commit 62a8c76fbad14150f6f3dabaecc0a569e1dfdcb5
Author: Luca Leonardo Scorcia <l.scorcia@gmail.com>

watchdog: mediatek: Add wdt/toprgu resets for mt6589

According to Android sources, mt6589 has 12 reset bits in the
WDT_SWSYSRST register. Populate toprgu_sw_rst_num to allow toprgu resets
in device trees of the many compatible devices.

> diff --git a/drivers/watchdog/mtk_wdt.c b/drivers/watchdog/mtk_wdt.c
> index 91d110646e16f..f8208fb0f7234 100644
> --- a/drivers/watchdog/mtk_wdt.c
> +++ b/drivers/watchdog/mtk_wdt.c

[ ... ]

> @@ -493,7 +498,7 @@ static int mtk_wdt_resume(struct device *dev)
>  
>  static const struct of_device_id mtk_wdt_dt_ids[] = {
>  	{ .compatible = "mediatek,mt2712-wdt", .data = &mt2712_data },
> -	{ .compatible = "mediatek,mt6589-wdt" },
> +	{ .compatible = "mediatek,mt6589-wdt", .data = &mt6589_data },

[Severity: High]
This isn't a bug introduced by this patch, but I noticed a potential race
condition during probe that might affect all watchdog devices here.

In mtk_wdt_probe(), the watchdog device is registered before its configuration
flags are read:

        err = devm_watchdog_register_device(dev, &mtk_wdt->wdt_dev);
        if (unlikely(err))
                return err;
        
        ...

        mtk_wdt->disable_wdt_extrst =
                of_property_read_bool(dev->of_node, "mediatek,disable-extrst");

        mtk_wdt->reset_by_toprgu =
                of_property_read_bool(dev->of_node, "mediatek,reset-by-toprgu");

If userspace (like systemd) opens the device immediately after registration,
could mtk_wdt_start() run before these flags are initialized?

Since these flags are written to the WDT_MODE register and not re-applied
later, could this permanently misconfigure the watchdog for the system uptime
and cause a hang instead of a reboot upon timeout?


[Severity: High]
This is also a pre-existing issue, but while reviewing the probe path that
uses the newly assigned device data, I noticed a potential race condition
with the reset controller.

In mtk_wdt_probe(), the reset controller is registered before the
has_swsysrst_en flag is initialized:

        wdt_data = of_device_get_match_data(dev);
        if (wdt_data) {
                err = toprgu_register_reset_controller(pdev,
                                                       wdt_data->toprgu_sw_rst_num);
                if (err)
                        return err;

                mtk_wdt->has_swsysrst_en = wdt_data->has_swsysrst_en;
        }

If a consumer device requests and asserts a reset line immediately upon
registration (e.g. from a concurrent deferred probe), could
toprgu_reset_update() observe has_swsysrst_en as false before it is
assigned?

If so, would it skip calling toprgu_reset_sw_en_unlocked() and fail to
enable software control for the reset bit in WDT_SWSYSRST_EN, leading to a
probe failure for the consumer device?

>  	{ .compatible = "mediatek,mt6735-wdt", .data = &mt6735_data },
>  	{ .compatible = "mediatek,mt6795-wdt", .data = &mt6795_data },
>  	{ .compatible = "mediatek,mt7986-wdt", .data = &mt7986_data },

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260819101853.44681-1-l.scorcia@gmail.com?part=2

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v4 0/7] Properly describe mt6589 and mt8167 toprgu resets
  2026-08-19 10:16 [PATCH v4 0/7] Properly describe mt6589 and mt8167 toprgu resets Luca Leonardo Scorcia
                   ` (6 preceding siblings ...)
  2026-08-19 10:16 ` [PATCH v4 7/7] arm64: dts: mt8167: Properly describe the SoC watchdog and mmsys resets Luca Leonardo Scorcia
@ 2026-08-19 17:17 ` Akari Tsuyukusa
  7 siblings, 0 replies; 13+ messages in thread
From: Akari Tsuyukusa @ 2026-08-19 17:17 UTC (permalink / raw)
  To: Luca Leonardo Scorcia
  Cc: linux-mediatek, Wim Van Sebroeck, Guenter Roeck, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
	AngeloGioacchino Del Regno, Philipp Zabel, linux-watchdog,
	devicetree, linux-kernel, linux-arm-kernel

Hi Luca,

On Wed, Aug 19, 2026 at 12:16:21PM +0200, Luca Leonardo Scorcia wrote:
> Currently mt8167 inherits its watchdog from the included mt8516 dtsi,
> which in turn falls back on mt6589-wdt, which does not support toprgu
> resets yet. This series adds support for mt6589 toprgu resets with bit
> definitions obtained from Android stock sources.
> 
> However, according to its data sheet, mt8167 has 14 sw resets instead of
> 12, and the reset bits are non-contiguous. This is currently unsupported
> by the mtk-wtd driver, and it caused confusion between reset IDs and reset
> bits in device tree includes.
> 
> Therefore in the first three patches we improve the description of the,
> resets for mt6589 using the definitions obtained from Android sources.
> 
> Then we introduce a dedicated mediatek,mt8167-wdt compatible for the
> watchdog driver that describes correctly this SoC's resets. Also while
> we're touching the bindings reset includes, we add IDs for the MMSYS
> resets.

This is somewhat outside the scope of this series, but adding TOPRGU
reset support for MT6589 exposes a pre-existing problem with the
mtk-wdt binding that I think should not go unnoticed.

Until now, using `mediatek,mt6589-wdt` as a fallback compatible for
other SoCs was mostly harmless, since the driver did not expose the
TOPRGU reset controller.
This series changes that by adding reset controller support for MT6589.

According to the MT6589 datasheet, its TOPRGU reset bits are:

  0 infra
  1 disp (same as mmsys in upstream)
  2 mfg
  3 venc
  4 vdec
  5 img
  6 ddrphy
  7 md
  8 infra_ao
  9 md_lite
 10 apmixed
 11 pwrap_spictl

These are the reset bits that `mediatek,mt6589-wdt` will provide once
this series is merged.
Therefore, for another SoC to use this compatible as a fallback,
its TOPRGU reset layout needs to be compatible with the above.

At commit bd5f485f3f02, mediatek,mtk-wdt.yaml contains:

      - items:
          - enum:
              - mediatek,mt2701-wdt
              - mediatek,mt6572-wdt
              - mediatek,mt6582-wdt
              - mediatek,mt6797-wdt
              - mediatek,mt7622-wdt
              - mediatek,mt7623-wdt
              - mediatek,mt7629-wdt
              - mediatek,mt8173-wdt
              - mediatek,mt8188-wdt
              - mediatek,mt8189-wdt
              - mediatek,mt8365-wdt
              - mediatek,mt8516-wdt
          - const: mediatek,mt6589-wdt

Let's examine the evidence for each of these SoCs.

## MT2701

I could not find enough public information to determine the reset
layout.


## MT6572

A downstream kernel suggests it has the same reset layout as MT6589:
https://github.com/orangepi-xunlong/OrangePi3G-iot_external/blob/b8a66e9bde91d75a8535dc6342d668efb6ab14ee/mediatek/platform/mt6572/kernel/core/include/mach/mt_wdt.h

However, a report based on actual hardware suggests
it may have fewer resets than MT6589:
https://lore.kernel.org/linux-mediatek/W7fWZU3pu6akI_HMTAWPGnnErv60QtTz-LaPb6OtGvU5Bx0Iekl4SxWB6mxBPx8cBo9q9Lg7t8dDzcyfti-5fTirEACcwCLhNAh8e5xoHus=@protonmail.com/

The datasheet is missing the bitfield for WDT_SWRST. 


## MT6582

According to the datasheet, the reset bits are:

  0 infra
  1 mm
  2 mfg
  4 vdec
  5 venc
  6 ddrphy
  7 md
  8 infra_ao
  9 conn
 10 apmixed
 12 conn_mcu

This is clearly not the same reset layout as MT6589.


## MT6797

According to the downstream kernel,
it has additional resets compared to MT6589:

  #define MTK_WDT_SWSYS_RST_C2KSYS_RST    (0x10000)
  #define MTK_WDT_SWSYS_RST_C2KWDT_RST    (0x20000)
  #define MTK_WDT_SWSYS_RST_CONMCU_RST    (0x1000)

https://github.com/SHIFTPHONES/android_kernel_shift_mt6797/blob/4c594e5fa5648dd9a8b8ccc5d609bb523f4799b7/drivers/watchdog/mediatek/wdt/mt6797/mt_wdt.h


## MT7622

According to the datasheet, the reset bits are:

  0 infra
  1 ethdma
  6 ddrphy
  8 infra_ao
  9 conn
 10 apmixed
 12 conn_mcu

This is not the MT6589 reset layout.


## MT7623

According to the datasheet, the reset bits are:

  0 infra
  1 mm
  2 mfg
  3 ethdma
  4 vdec
  5 venc_img
  6 ddrphy
  7 md
  8 infra_ao
  9 conn
 10 apmixed
 11 hifsys
 12 conn_mcu
 13 bdp_disp

Again, this is not the MT6589 reset layout.


## MT7629

I have no evidence either way. 


## MT8173

A the downstream kernel claims that MT8173 is compatible
with MT2701, MT8127 and MT8163:
https://github.com/bq/aquaris-M10/blob/ab0f5a519edaf314e9b537e448838ec9a4a9a3c8/drivers/watchdog/mediatek/wdt/common/mtk_wdt.c

I don't find this particularly convincing.

MT8163 has 15 reset bits:
https://github.com/amazon-oss/android_kernel_amazon_mt8163/blob/479f405abf2ee6c0f13688b8cf567cce135924af/include/dt-bindings/reset-controller/mt8163-resets.h

MT8127 appears to have the same reset layout as MT6589:
https://github.com/amazon-oss/android_kernel_amazon_mt8127/blob/8428ef2958b83fa51edd6de734c069455f00cd8b/arch/arm/mach-mt8127/include/mach/mt_wdt.h

However, I am not sure whether this actually reflects the hardware.


## MT8188

This is presumably a typo for MT8189, because there is no explanation
for using MT8188 in the patch:


[PATCH v7 6/9] dt-bindings: watchdog: Support MediaTek MT8189 wdt

modify dt-binding for support mt8189 dts node of wdt

Signed-off-by: Jack Hsu <jh.hsu@mediatek.com>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Acked-by: Guenter Roeck <linux@roeck-us.net>

---
Changs in v7:
 - update dt-bindings commit msg
   (use "mt8189" instead of "mt8189 evb board")

---
 Documentation/devicetree/bindings/watchdog/mediatek,mtk-wdt.yaml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/watchdog/mediatek,mtk-wdt.yaml b/Documentation/devicetree/bindings/watchdog/mediatek,mtk-wdt.yaml
index ba0bfd73ab62..a05f8155b738 100644
--- a/Documentation/devicetree/bindings/watchdog/mediatek,mtk-wdt.yaml
+++ b/Documentation/devicetree/bindings/watchdog/mediatek,mtk-wdt.yaml
@@ -41,6 +41,7 @@ properties:
               - mediatek,mt7623-wdt
               - mediatek,mt7629-wdt
               - mediatek,mt8173-wdt
+              - mediatek,mt8188-wdt
               - mediatek,mt8365-wdt
               - mediatek,mt8516-wdt
           - const: mediatek,mt6589-wdt
-- 
2.45.2


https://lore.kernel.org/linux-arm-kernel/20251111070031.305281-7-jh.hsu@mediatek.com/
https://github.com/torvalds/linux/commit/a742d1713c34dff992d1273f614548d214ba1550
I honestly cannot understand how this passed review.

MT8188 already had a standalone compatible entry before this patch,
and it is clearly not compatible with MT6589:
https://github.com/torvalds/linux/blob/bd5f485f3f026225b86573e559af0b7254ef4184/include/dt-bindings/reset/mt8188-resets.h


## MT8189

There is no publicly available information about its reset layout:
https://github.com/external-mirrors/chromiumos-third_party-kernel/blob/a5153266e4c8777fac687e9009a12d32d946514b/drivers/watchdog/mtk_wdt.c#L462


## MT8365

I have no evidence to establish compatibility.


## MT8516

According to the downstream kernel, its reset layout appears to be
compatible with MT6589:
https://android.googlesource.com/platform/hardware/bsp/kernel/mediatek/mt8516-v4.4/+/refs/heads/nougat-iot-release/drivers/watchdog/mediatek/wdt/common/mtk_wdt.h


Note that a downstream kernel claiming compatibility does not necessarily
mean that the SoCs are actually compatible. In my experience, MediaTek's
downstream kernels contain substantial amounts of copied code between
different SoCs, so I would not consider such compatibility claims
sufficient evidence on their own.

Overall, I don't think `mediatek,mt6589-wdt` is an appropriate fallback
compatible for most of the SoCs currently listed in the binding.
I realize that fixing all of these bindings is outside the scope of
this series, but I think this should be addressed rather than leaving
`mediatek,mt6589-wdt` as a generic fallback.


I also noticed that the v3 link is missing from the cover letter:
[3] https://lore.kernel.org/linux-arm-kernel/20260809160643.33991-1-l.scorcia@gmail.com/

Best regards,
Akari

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH v4 3/7] arm: dts: mediatek: mt6589: Enable toprgu reset controller
  2026-08-19 10:16 ` [PATCH v4 3/7] arm: dts: mediatek: mt6589: Enable toprgu reset controller Luca Leonardo Scorcia
@ 2026-08-19 17:43   ` Akari Tsuyukusa
  0 siblings, 0 replies; 13+ messages in thread
From: Akari Tsuyukusa @ 2026-08-19 17:43 UTC (permalink / raw)
  To: Luca Leonardo Scorcia
  Cc: linux-mediatek, Wim Van Sebroeck, Guenter Roeck, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
	AngeloGioacchino Del Regno, Philipp Zabel, linux-watchdog,
	devicetree, linux-kernel, linux-arm-kernel

Hi,

I noticed that my Signed-off-by is still present on this patch in v4.

On Wed, Aug 19, 2026 at 12:16:24PM +0200, Luca Leonardo Scorcia wrote:
> Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
> Signed-off-by: Luca Leonardo Scorcia <l.scorcia@gmail.com>

Sorry for confusing you with the v3 patch discussion. As discussed in
v3, my Signed-off-by should not be included in the sign-off chain.

Please drop my Signed-off-by from this patch.

> --- a/arch/arm/boot/dts/mediatek/mt6589.dtsi
> +++ b/arch/arm/boot/dts/mediatek/mt6589.dtsi
> @@ -7,6 +7,7 @@
>  
>  #include <dt-bindings/interrupt-controller/irq.h>
>  #include <dt-bindings/interrupt-controller/arm-gic.h>
> +#include <dt-bindings/reset/mediatek,mt6589-wdt.h>

By the way, this header is not used by any part of mt6589.dtsi,
so I think this line can simply be dropped.

Best regards,
Akari

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2026-08-19 17:43 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-19 10:16 [PATCH v4 0/7] Properly describe mt6589 and mt8167 toprgu resets Luca Leonardo Scorcia
2026-08-19 10:16 ` [PATCH v4 1/7] dt-bindings: reset: Add mt6589 toprgu reset IDs Luca Leonardo Scorcia
2026-08-19 10:16 ` [PATCH v4 2/7] watchdog: mediatek: Add wdt/toprgu resets for mt6589 Luca Leonardo Scorcia
2026-08-19 10:30   ` sashiko-bot
2026-08-19 10:16 ` [PATCH v4 3/7] arm: dts: mediatek: mt6589: Enable toprgu reset controller Luca Leonardo Scorcia
2026-08-19 17:43   ` Akari Tsuyukusa
2026-08-19 10:16 ` [PATCH v4 4/7] dt-bindings: watchdog: Add compatible for MediaTek mt8167 Luca Leonardo Scorcia
2026-08-19 10:29   ` sashiko-bot
2026-08-19 10:16 ` [PATCH v4 5/7] watchdog: mediatek: Add support for mt8167 toprgu/watchdog Luca Leonardo Scorcia
2026-08-19 10:29   ` sashiko-bot
2026-08-19 10:16 ` [PATCH v4 6/7] soc: mediatek: mtk-mmsys: Add resets for mt8167 Luca Leonardo Scorcia
2026-08-19 10:16 ` [PATCH v4 7/7] arm64: dts: mt8167: Properly describe the SoC watchdog and mmsys resets Luca Leonardo Scorcia
2026-08-19 17:17 ` [PATCH v4 0/7] Properly describe mt6589 and mt8167 toprgu resets Akari Tsuyukusa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox