Skip to contentSkip to conversation

Properly describe mt8167 watchdog and mmsys resets

PATCH Superseded Luca Leonardo Scorcia 4 participants 17 messages Jul 17 – Jul 20

Subsystems (4)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover Properly describe mt8167 watchdog and mmsys resets

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 has 15 sw resets instead of 12, and the reset bits are different from mt6589.

In the first two patches we improve the description of the resets for mt6589 with values 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 header, we add constants for the MMSYS resets.

In the 6th patch we add a node for the mt8167 watchdog referring to the new compatible in the SoC dtsi.

In the last 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.

Changes in v2:
- 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/[email protected]/

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

 .../bindings/watchdog/mediatek,mtk-wdt.yaml   |  1 +
 arch/arm64/boot/dts/mediatek/mt8167.dtsi      |  7 +++
 drivers/soc/mediatek/mt8167-mmsys.h           | 41 ++++++++++++++
 drivers/soc/mediatek/mtk-mmsys.c              |  3 ++
 drivers/watchdog/mtk_wdt.c                    | 13 ++++-
 .../reset/mediatek,mt6589-resets.h            | 24 +++++++++
 .../reset/mediatek,mt8167-resets.h            | 53 +++++++++++++++++++
 7 files changed, 141 insertions(+), 1 deletion(-)
 create mode 100644 include/dt-bindings/reset/mediatek,mt6589-resets.h
 create mode 100644 include/dt-bindings/reset/mediatek,mt8167-resets.h
Signature · 1 line
2.43.0
#1 lore raw

PATCH v2 1/7 dt-bindings: reset: Add MT6589 toprgu reset IDs

Add reset constants for the 12 MT6589 toprgu resets.

---
 .../reset/mediatek,mt6589-resets.h            | 24 +++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 include/dt-bindings/reset/mediatek,mt6589-resets.h
include/dt-bindings/reset/mediatek,mt6589-resets.h new file +24 -0
new file mode 100644
index 000000000000..ee08c39df513
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
+/*
+ * Author: Luca Leonardo Scorcia <[email protected]>
+ */
+
+#ifndef _DT_BINDINGS_RESET_CONTROLLER_MT6589
+#define _DT_BINDINGS_RESET_CONTROLLER_MT6589
+
+/* TOPRGU resets */
+#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_CONTROLLER_MT6589 */
Signature · 1 line
2.43.0
#2 lore raw

Re: [PATCH v2 1/7] dt-bindings: reset: Add MT6589 toprgu reset IDs

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] The patch adds reset provider capabilities for MT6589 without updating the corresponding YAML…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The patch adds reset provider capabilities for MT6589 without updating the corresponding YAML schema to require #reset-cells. --

--- Patch [1]: [PATCH v2 1/7] dt-bindings: reset: Add MT6589 toprgu reset IDs --- commit 1610507569a41df45fcf55f93c1df6323ff7d422
Author: Luca Leonardo Scorcia <[email protected]>

dt-bindings: reset: Add MT6589 toprgu reset IDs

This commit introduces the reset constants for the 12 MT6589 toprgu resets to be used as a reset provider.

Quoted 6 lines
include/dt-bindings/reset/mediatek,mt6589-resets.h new file +0 -0
new file mode 100644
index 0000000000000..ee08c39df5131

include/dt-bindings/reset/mediatek,mt6589-resets.h line 9

Quoted 9 lines
include/dt-bindings/reset/mediatek,mt6589-resets.h new file +9 -0
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
+/*
+ * Author: Luca Leonardo Scorcia <[email protected]>
+ */
+
+#ifndef _DT_BINDINGS_RESET_CONTROLLER_MT6589
+#define _DT_BINDINGS_RESET_CONTROLLER_MT6589
+
+/* TOPRGU resets */

[Severity: Low]
Does Documentation/devicetree/bindings/watchdog/mediatek,mtk-wdt.yaml need to be updated to require #reset-cells when using mediatek,mt6589-wdt?

When adding reset provider capabilities for a hardware variant, the schema typically requires an allOf/if-then block to add #reset-cells to the required list. Without this update, a device tree node utilizing the MT6589 watchdog as a reset provider could omit #reset-cells and still silently pass dt_binding_check validation.

Quoted 2 lines
include/dt-bindings/reset/mediatek,mt6589-resets.h new file +2 -0
+#define MT6589_TOPRGU_INFRA_SW_RST		0
+#define MT6589_TOPRGU_MM_SW_RST			1

[ ... ]

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#3 lore raw

Re: [PATCH v2 1/7] dt-bindings: reset: Add MT6589 toprgu reset IDs

In reply to Luca Leonardo Scorcia
Quoted 1 line · Luca Leonardo Scorcia

Add reset constants for the 12 MT6589 toprgu resets.

This is not a single-patch patchset. Seven patches.

So one posting per 24h, so we actually have a possibility to review it.

include/dt-bindings/reset/mediatek,mt6589-resets.h

Quoted 12 lines
---
 .../reset/mediatek,mt6589-resets.h            | 24 +++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 include/dt-bindings/reset/mediatek,mt6589-resets.h
include/dt-bindings/reset/mediatek,mt6589-resets.h new file +0 -0
new file mode 100644
index 000000000000..ee08c39df513

Why is this header being added outside of patch documenting compatible? You have entire commit msg to say something useful instead of repeating the subject.

Best regards,
Krzysztof

#4 lore raw

Re: [PATCH v2 1/7] dt-bindings: reset: Add MT6589 toprgu reset IDs

Quoted 8 lines · Krzysztof Kozlowski
Quoted 1 line · Luca Leonardo Scorcia

Add reset constants for the 12 MT6589 toprgu resets.

This is not a single-patch patchset. Seven patches.

So one posting per 24h, so we actually have a possibility to review it.

krzk, that's because Sashiko provides reviews instantly, and people just go and fix things to make it easier on us maintainers to provide reviews (and avoiding to see the same Sashiko complaints from us).

That said, this gets into personal preference territory, and I'm not trying to start any conversation about that specifically...

Quoted 7 lines
Quoted 7 lines
---
  .../reset/mediatek,mt6589-resets.h            | 24 +++++++++++++++++++
  1 file changed, 24 insertions(+)

create mode 100644 include/dt-bindings/reset/mediatek,mt6589-resets.h

Quoted 10 lines

include/dt-bindings/reset/mediatek,mt6589-resets.h

Quoted 5 lines
include/dt-bindings/reset/mediatek,mt6589-resets.h new file +0 -0
new file mode 100644
index 000000000000..ee08c39df513

Why is this header being added outside of patch documenting compatible? You have entire commit msg to say something useful instead of repeating the subject.

Because he wrote it all in the cover letter... which is something that gets read right now, but gets lost once the commits are picked - so all context and explaining are completely lost.

Luca, that's why krzk is complaining :-)

Just write the information in each commit's description, so that it doesn't get lost, and so that the next one trying to understand what went on with the toprgu can just read it there. :-)

Cheers,
Angelo

#5 lore raw

PATCH v2 2/7 watchdog: mediatek: Add wdt/toprgu resets for MT6589

In reply to Luca Leonardo Scorcia

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.

---
 drivers/watchdog/mtk_wdt.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/watchdog/mtk_wdt.c +6 -1
index 91d110646e16..e61f6ae74327 100644
@@ -10,6 +10,7 @@
  */
 
 #include <dt-bindings/reset/mt2712-resets.h>
+#include <dt-bindings/reset/mediatek,mt6589-resets.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 },
Signature · 1 line
2.43.0
#6 lore raw

Re: [PATCH v2 2/7] watchdog: mediatek: Add wdt/toprgu resets for MT6589

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

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

Pre-existing issues:
- [High] Reset controller is synchronously registered before its structural configuration variable has_swsysrst_en is initialized. --

--- Patch [2]: [PATCH v2 2/7] watchdog: mediatek: Add wdt/toprgu resets for MT6589 --- commit 3b51cb7125d43b8f8ea3a7996ec1844775ec36b1
Author: Luca Leonardo Scorcia <[email protected]>

watchdog: mediatek: Add wdt/toprgu resets for MT6589

This commit populates the toprgu_sw_rst_num field for the MT6589 watchdog data. It maps the 12 reset bits available in the WDT_SWSYSRST register to allow toprgu resets via the device tree.

Quoted 4 lines
drivers/watchdog/mtk_wdt.c +0 -0
index 91d110646e16f..e61f6ae743276 100644

[ ... ]

drivers/watchdog/mtk_wdt.c static const struct mtk_wdt_data mt2712_data = { · line 98

Quoted 11 lines
drivers/watchdog/mtk_wdt.c +4 -0
@@ -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,
 };

[Severity: High]
This is a pre-existing issue, but registering the reset controller in mtk_wdt_probe() happens before the structural configuration is fully initialized:

drivers/watchdog/mtk_wdt.c:mtk_wdt_probe() {
    ...
	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 driver probes concurrently and asserts the reset line, could it execute before the has_swsysrst_en flag is set?

On SoCs requiring software reset enable, reading the uninitialized has_swsysrst_en as false would cause the reset assertion to fail silently, potentially leaving consumer devices in an undefined state.

Should mtk_wdt->has_swsysrst_en be initialized before calling toprgu_register_reset_controller()?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
#7 lore raw

PATCH v2 3/7 dt-bindings: watchdog: Add compatible for MediaTek mt8167

In reply to Luca Leonardo Scorcia

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 has 15 sw resets instead of 12, and their order is different from mt6589. Update the wdt binding to add a dedicated compatible for mt8167.

---
 Documentation/devicetree/bindings/watchdog/mediatek,mtk-wdt.yaml | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/watchdog/mediatek,mtk-wdt.yaml +1 -0
index 953629cb9558..f514be8a5851 100644
@@ -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
Signature · 1 line
2.43.0
#8 lore raw

Re: [PATCH v2 3/7] dt-bindings: watchdog: Add compatible for MediaTek mt8167

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] The `mediatek,mt8167-wdt` compatible string is added as a standalone compatible (without…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The mediatek,mt8167-wdt compatible string is added as a standalone compatible (without fallback) in the DT bindings, but the patch series is missing the corresponding driver support and reset definitions header. --

--- Patch [3]: [PATCH v2 3/7] dt-bindings: watchdog: Add compatible for MediaTek mt8167 --- commit 666f2d36168cb1a5fa647ba2d10b40b0cd2f2240
Author: Luca Leonardo Scorcia <[email protected]>

dt-bindings: watchdog: Add compatible for MediaTek mt8167

This commit adds a dedicated compatible string for the MediaTek mt8167 watchdog. It replaces the previous fallback to mt6589-wdt since the mt8167 hardware has 15 software resets instead of 12, and in a different order.

Documentation/devicetree/bindings/watchdog/mediatek,mtk-wdt.yaml properties: · line 29

Quoted 9 lines
Documentation/devicetree/bindings/watchdog/mediatek,mtk-wdt.yaml +1 -0
index 953629cb9558b..f514be8a5851d 100644
@@ -26,6 +26,7 @@ properties:
           - mediatek,mt6795-wdt
           - mediatek,mt7986-wdt
           - mediatek,mt7988-wdt
+          - mediatek,mt8167-wdt

[Severity: Medium]
Will this new compatible string probe successfully without driver support?

Looking at the driver match table:

drivers/watchdog/mtk_wdt.c:mtk_wdt_dt_ids[] {
    { .compatible = "mediatek,mt2712-wdt", .data = &mt2712_data },
    ...
}

It seems there is no match entry for "mediatek,mt8167-wdt".

Since this is added as a standalone compatible without a fallback to an existing string, any device tree using it will fail to probe the watchdog driver.

Additionally, the commit message mentions the mt8167 has 15 software resets instead of 12, but there doesn't appear to be a corresponding dt-bindings header exporting these new reset indices for device tree consumers to use.

Quoted 3 lines
Documentation/devicetree/bindings/watchdog/mediatek,mtk-wdt.yaml +0 -0
           - mediatek,mt8183-wdt
           - mediatek,mt8186-wdt
           - mediatek,mt8188-wdt
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
#9 lore raw

Re: [PATCH v2 3/7] dt-bindings: watchdog: Add compatible for MediaTek mt8167

In reply to Luca Leonardo Scorcia
Quoted 3 lines · Luca Leonardo Scorcia

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 has 15 sw resets instead of 12, and their order is different

Does 15 over 12 make it incompatible?

And how does the order matter? Order where? Binding does not have even a single reset.

Quoted 23 lines

from mt6589. Update the wdt binding to add a dedicated compatible for mt8167.

---
 Documentation/devicetree/bindings/watchdog/mediatek,mtk-wdt.yaml | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/watchdog/mediatek,mtk-wdt.yaml +1 -0
index 953629cb9558..f514be8a5851 100644
@@ -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
Signature · 1 line
2.43.0
#10 lore raw

PATCH v2 4/7 dt-bindings: reset: Add reset controller constants for mt8167

In reply to Luca Leonardo Scorcia

Add the various bits that identify watchdog and mmsys resets. IDs for mmsys resets restart from zero as they are used in a different device.

---
 .../reset/mediatek,mt8167-resets.h            | 53 +++++++++++++++++++
 1 file changed, 53 insertions(+)
 create mode 100644 include/dt-bindings/reset/mediatek,mt8167-resets.h
include/dt-bindings/reset/mediatek,mt8167-resets.h new file +53 -0
new file mode 100644
index 000000000000..85d2d0e99c68
@@ -0,0 +1,53 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
+#ifndef _DT_BINDINGS_RESET_CONTROLLER_MT8167
+#define _DT_BINDINGS_RESET_CONTROLLER_MT8167
+
+/* TOPRGU resets, these are actual bits in the register */
+#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
+/* bit 9 is reserved, unused according to data sheet */
+#define MT8167_TOPRGU_APMIXED_RST		10
+#define MT8167_TOPRGU_VDEC_RST			11
+#define MT8167_TOPRGU_CONN_MCU_RST		12
+#define MT8167_TOPRGU_EFUSE_RST			13
+#define MT8167_TOPRGU_PWRAP_SPICTL_RST		14
+#define MT8167_TOPRGU_SW_RST_NUM		15
+
+/* MMSYS resets, these are 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_CONTROLLER_MT8167 */
Signature · 1 line
2.43.0
#11 lore raw

Re: [PATCH v2 4/7] dt-bindings: reset: Add reset controller constants for mt8167

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] Incorrect reset ID mapping for MMSYS SW1 reset constants. --

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Incorrect reset ID mapping for MMSYS SW1 reset constants.
--

--- Patch [4]: [PATCH v2 4/7] dt-bindings: reset: Add reset controller constants for mt8167 --- commit 3e501b19a4f1986647da6f341a25af00a37a8d1d
Author: Luca Leonardo Scorcia <[email protected]>

dt-bindings: reset: Add reset controller constants for mt8167

This commit adds identifying bits for watchdog and mmsys resets on the mt8167 platform.

Quoted 5 lines
include/dt-bindings/reset/mediatek,mt8167-resets.h new file +0 -0
new file mode 100644
index 0000000000000..85d2d0e99c689

[ ... ]

include/dt-bindings/reset/mediatek,mt8167-resets.h line 51

Quoted 5 lines
include/dt-bindings/reset/mediatek,mt8167-resets.h new file +5 -0
+#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

[Severity: High]
Will these reset IDs correctly map to the SW1 register?

In drivers/soc/mediatek/mtk-mmsys.c, mtk_mmsys_reset_update() dynamically calculates the register offset by dividing the ID by 32.

Since MT8167 does not provide an rst_tb mapping array, the raw ID is used for this division. For IDs 25, 26, and 27, this calculates to an offset of 0, which targets the SW0_RST_B register instead of SW1_RST_B.

Should these IDs be greater than or equal to 32 if they belong to SW1, or is the SW1 naming a typo for bits that actually reside in the SW0 register?

Quoted 2 lines
include/dt-bindings/reset/mediatek,mt8167-resets.h new file +2 -0
+
+#endif  /* _DT_BINDINGS_RESET_CONTROLLER_MT8167 */
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
#12 lore raw

Re: [PATCH v2 4/7] dt-bindings: reset: Add reset controller constants for mt8167

In reply to Luca Leonardo Scorcia
Quoted 6 lines · Luca Leonardo Scorcia

Add the various bits that identify watchdog and mmsys resets. IDs for mmsys resets restart from zero as they are used in a different device.

---
 .../reset/mediatek,mt8167-resets.h            | 53 +++++++++++++++++++

I do not see any user of this ABI nor explanation why you are doing it.

Quoted 14 lines
 1 file changed, 53 insertions(+)
 create mode 100644 include/dt-bindings/reset/mediatek,mt8167-resets.h
include/dt-bindings/reset/mediatek,mt8167-resets.h new file +5 -0
new file mode 100644
index 000000000000..85d2d0e99c68
@@ -0,0 +1,53 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
+#ifndef _DT_BINDINGS_RESET_CONTROLLER_MT8167
+#define _DT_BINDINGS_RESET_CONTROLLER_MT8167
+
+/* TOPRGU resets, these are actual bits in the register */

include/dt-bindings/reset/mediatek,mt8167-resets.h line 15

Quoted 10 lines
include/dt-bindings/reset/mediatek,mt8167-resets.h new file +10 -0
+#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
+/* bit 9 is reserved, unused according to data sheet */

NAK, how driver can reserve something? Fix your driver.

This is ABI for Linux driver.

Best regards,
Krzysztof

#13 lore raw

PATCH v2 5/7 watchdog: mediatek: Add support for mt8167 TOPRGU/WDT

In reply to Luca Leonardo Scorcia

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

---
 drivers/watchdog/mtk_wdt.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/watchdog/mtk_wdt.c +6 -0
index e61f6ae74327..10a3d4b5ee30 100644
@@ -13,6 +13,7 @@
 #include <dt-bindings/reset/mediatek,mt6589-resets.h>
 #include <dt-bindings/reset/mediatek,mt6735-wdt.h>
 #include <dt-bindings/reset/mediatek,mt6795-resets.h>
+#include <dt-bindings/reset/mediatek,mt8167-resets.h>
 #include <dt-bindings/reset/mt7986-resets.h>
 #include <dt-bindings/reset/mt8183-resets.h>
 #include <dt-bindings/reset/mt8186-resets.h>
@@ -110,6 +111,10 @@ static const struct mtk_wdt_data mt7988_data = {
 	.has_swsysrst_en = true,
 };
 
+static const struct mtk_wdt_data mt8167_data = {
+	.toprgu_sw_rst_num = MT8167_TOPRGU_SW_RST_NUM,
+};
+
 static const struct mtk_wdt_data mt8183_data = {
 	.toprgu_sw_rst_num = MT8183_TOPRGU_SW_RST_NUM,
 };
@@ -503,6 +508,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 },
Signature · 1 line
2.43.0
#14 lore raw

PATCH v2 6/7 arm64: dts: mt8167: Properly describe the SoC watchdog

In reply to Luca Leonardo Scorcia

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 has 15 sw resets instead of 12, and the reset bits are different from mt6589.

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

---
 arch/arm64/boot/dts/mediatek/mt8167.dtsi | 7 +++++++
 1 file changed, 7 insertions(+)
arch/arm64/boot/dts/mediatek/mt8167.dtsi +7 -0
index 27cf32d7ae35..4ebf305c10fe 100644
@@ -95,6 +95,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>;
Signature · 1 line
2.43.0
#15 lore raw

PATCH v2 7/7 soc: mediatek: mtk-mmsys: Add resets for mt8167

In reply to Luca Leonardo Scorcia

The mt8167 SoC has 64 MMSYS resets, split in two contiguous 32-bits registers, MMSYS_SW0_RST_B (0x140) and MMSYS_SW1_RST_B (0x144), as also stated in the downstream kernel for the Lenovo Smart Clock in the ddp_reg.h header.

---
 drivers/soc/mediatek/mt8167-mmsys.h | 41 +++++++++++++++++++++++++++++
 drivers/soc/mediatek/mtk-mmsys.c    |  3 +++
 2 files changed, 44 insertions(+)
drivers/soc/mediatek/mt8167-mmsys.h +41 -0
index eef14083c47b..dc3e882a9893 100644
@@ -3,6 +3,47 @@
 #ifndef __SOC_MEDIATEK_MT8167_MMSYS_H
 #define __SOC_MEDIATEK_MT8167_MMSYS_H
 
+#include <linux/soc/mediatek/mtk-mmsys.h>
+#include <dt-bindings/reset/mediatek,mt8167-resets.h>
+
+#define MT8167_MMSYS_SW0_RST_B				0x140
+#define MT8167_MMSYS_SW1_RST_B				0x144
+
+/* MMSYS resets */
+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),
+};
+
 #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
drivers/soc/mediatek/mtk-mmsys.c +3 -0
index 2f3e0778bb17..abd96634b63c 100644
@@ -57,6 +57,9 @@ 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 = {
Signature · 1 line
2.43.0
#16 lore raw

Re: [PATCH v2 7/7] soc: mediatek: mtk-mmsys: Add resets for mt8167

Quoted 17 lines · Luca Leonardo Scorcia

The mt8167 SoC has 64 MMSYS resets, split in two contiguous 32-bits registers, MMSYS_SW0_RST_B (0x140) and MMSYS_SW1_RST_B (0x144), as also stated in the downstream kernel for the Lenovo Smart Clock in the ddp_reg.h header.

---
 drivers/soc/mediatek/mt8167-mmsys.h | 41 +++++++++++++++++++++++++++++
 drivers/soc/mediatek/mtk-mmsys.c    |  3 +++
 2 files changed, 44 insertions(+)
drivers/soc/mediatek/mt8167-mmsys.h +0 -0
index eef14083c47b..dc3e882a9893 100644
@@ -3,6 +3,47 @@
 #ifndef __SOC_MEDIATEK_MT8167_MMSYS_H

drivers/soc/mediatek/mt8167-mmsys.h line 13

Quoted 10 lines
drivers/soc/mediatek/mt8167-mmsys.h +8 -0
 #define __SOC_MEDIATEK_MT8167_MMSYS_H
 
+#include <linux/soc/mediatek/mtk-mmsys.h>
+#include <dt-bindings/reset/mediatek,mt8167-resets.h>
+
+#define MT8167_MMSYS_SW0_RST_B				0x140
+#define MT8167_MMSYS_SW1_RST_B				0x144
+
+/* MMSYS resets */
+static const u8 mmsys_mt8167_rst_tb[] = {

No, data structures NEVER go to the headers because it leads easily to duplicated data.

Best regards,
Krzysztof