Skip to contentSkip to conversation

Add reset controller to mt7988 infracfg

PATCH Superseded Frank Wunderlich 4 participants 6 messages Jan 4, 2024

Subsystems (4)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover Add reset controller to mt7988 infracfg

From: Frank Wunderlich <[email protected]>

Infracfg on mt7988 supports reset controller function which is needed to get lvts thermal working.

Patches are based on clk-next due to recently added mt7988 clock driver:
https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git

Frank Wunderlich (2):
dt-bindings: reset: mediatek: add MT7988 LVTS reset ID
clk: mediatek: add infracfg reset controller for mt7988

 drivers/clk/mediatek/clk-mt7988-infracfg.c    | 20 +++++++++++++++++++
 .../reset/mediatek,mt7988-resets.h            |  4 ++++
 2 files changed, 24 insertions(+)
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/2 dt-bindings: reset: mediatek: add MT7988 LVTS reset ID

From: Frank Wunderlich <[email protected]>

---
 include/dt-bindings/reset/mediatek,mt7988-resets.h | 4 ++++
 1 file changed, 4 insertions(+)
include/dt-bindings/reset/mediatek,mt7988-resets.h +4 -0
index 493301971367..3f1e4ec07ad5 100644
@@ -10,4 +10,8 @@
 /* ETHWARP resets */
 #define MT7988_ETHWARP_RST_SWITCH		0
 
+/* INFRA resets */
+#define MT7988_INFRA_RST0_THERM_CTRL_SWRST	9
+
 #endif  /* _DT_BINDINGS_RESET_CONTROLLER_MT7988 */
+
Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH 1/2] dt-bindings: reset: mediatek: add MT7988 LVTS reset ID

Hi Frank,

Quoted 11 lines · Frank Wunderlich

From: Frank Wunderlich <[email protected]>

---
 include/dt-bindings/reset/mediatek,mt7988-resets.h | 4 ++++
 1 file changed, 4 insertions(+)
include/dt-bindings/reset/mediatek,mt7988-resets.h +0 -0
index 493301971367..3f1e4ec07ad5 100644

include/dt-bindings/reset/mediatek,mt7988-resets.h line 14

Quoted 5 lines
include/dt-bindings/reset/mediatek,mt7988-resets.h +2 -0
@@ -10,4 +10,8 @@
 /* ETHWARP resets */
 #define MT7988_ETHWARP_RST_SWITCH		0
 
+/* INFRA resets */
+#define MT7988_INFRA_RST0_THERM_CTRL_SWRST	9

I suppose this argument applies here as well:

"IDs should start from 0 or 1 and increment by 1. If these are not IDs, then you do not need them in the bindings."

https://lore.kernel.org/all/[email protected]/

As a consequence, as what you are describing there are hardware bits rather than IDs used by the driver, you can just use a numeric constant in device tree instead of adding dt-bindings header.
Or change the driver so RST0_THERM_CTRL_SWRST could be defined as 0.

#3 lore raw

Re: [PATCH 1/2] dt-bindings: reset: mediatek: add MT7988 LVTS reset ID

Quoted 22 lines · Daniel Golle

Hi Frank,

Quoted 11 lines · Frank Wunderlich

From: Frank Wunderlich <[email protected]>

---
 include/dt-bindings/reset/mediatek,mt7988-resets.h | 4 ++++
 1 file changed, 4 insertions(+)
include/dt-bindings/reset/mediatek,mt7988-resets.h +0 -0
index 493301971367..3f1e4ec07ad5 100644

include/dt-bindings/reset/mediatek,mt7988-resets.h line 14

Quoted 5 lines
include/dt-bindings/reset/mediatek,mt7988-resets.h +2 -0
@@ -10,4 +10,8 @@
 /* ETHWARP resets */
 #define MT7988_ETHWARP_RST_SWITCH		0
 
+/* INFRA resets */
+#define MT7988_INFRA_RST0_THERM_CTRL_SWRST	9

I suppose this argument applies here as well:

Quoted 6 lines

"IDs should start from 0 or 1 and increment by 1. If these are not IDs, then you do not need them in the bindings."

https://lore.kernel.org/all/[email protected]/

As a consequence, as what you are describing there are hardware bits

If this is existing driver which already uses such pattern, then it is fine. I usually comment this on new drivers which can be changed.

Best regards,
Krzysztof

#4 lore raw

Aw: Re: [PATCH 1/2] dt-bindings: reset: mediatek: add MT7988 LVTS reset ID

Hi

Quoted 30 lines

Gesendet: Donnerstag, 04. Januar 2024 um 20:19 Uhr
Von: "Krzysztof Kozlowski" <[email protected]>
Betreff: Re: [PATCH 1/2] dt-bindings: reset: mediatek: add MT7988 LVTS reset ID

Quoted 25 lines · Daniel Golle

Hi Frank,

Quoted 11 lines · Frank Wunderlich

From: Frank Wunderlich <[email protected]>

---
 include/dt-bindings/reset/mediatek,mt7988-resets.h | 4 ++++
 1 file changed, 4 insertions(+)
include/dt-bindings/reset/mediatek,mt7988-resets.h +0 -0
index 493301971367..3f1e4ec07ad5 100644

include/dt-bindings/reset/mediatek,mt7988-resets.h line 14

Quoted 5 lines
include/dt-bindings/reset/mediatek,mt7988-resets.h +2 -0
@@ -10,4 +10,8 @@
 /* ETHWARP resets */
 #define MT7988_ETHWARP_RST_SWITCH		0
 
+/* INFRA resets */
+#define MT7988_INFRA_RST0_THERM_CTRL_SWRST	9

I suppose this argument applies here as well:

"IDs should start from 0 or 1 and increment by 1. If these are not IDs, then you do not need them in the bindings."

Quoted 6 lines
Quoted 3 lines

https://lore.kernel.org/all/[email protected]/

As a consequence, as what you are describing there are hardware bits

If this is existing driver which already uses such pattern, then it is fine. I usually comment this on new drivers which can be changed.

this is a new driver so i guess i should change this like daniel suggests.
As i want to use this constant in dts and driver i would like keep it as binding in the reset header, but because i use it only as index in the infra_idx_map array its value does not need to have the value needed in hardware. i kept it same to not have different values and for ordering purposes (when the other possible resets are added).

so the way starting at 0 will be the preferred one for me, is this ok?

regards Frank

#5 lore raw

PATCH 2/2 clk: mediatek: add infracfg reset controller for mt7988

In reply to Frank Wunderlich

From: Frank Wunderlich <[email protected]>

Infracfg can also operate as reset controller, add support for it.

---
 drivers/clk/mediatek/clk-mt7988-infracfg.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
drivers/clk/mediatek/clk-mt7988-infracfg.c +20 -0
index 8011ef278bea..1660a45349ff 100644
@@ -14,6 +14,9 @@
 #include "clk-gate.h"
 #include "clk-mux.h"
 #include <dt-bindings/clock/mediatek,mt7988-clk.h>
+#include <dt-bindings/reset/mediatek,mt7988-resets.h>
+
+#define	INFRA_RST_SET_OFFSET	0x80
 
 static DEFINE_SPINLOCK(mt7988_clk_lock);
 
@@ -249,12 +252,29 @@ static const struct mtk_gate infra_clks[] = {
 	GATE_INFRA3(CLK_INFRA_133M_PCIE_CK_P3, "infra_133m_pcie_ck_p3", "sysaxi_sel", 31),
 };
 
+static u16 infra_rst_ofs[] = {
+	INFRA_RST_SET_OFFSET,
+};
+
+static u16 infra_idx_map[] = {
+	[MT7988_INFRA_RST0_THERM_CTRL_SWRST] = 0 * RST_NR_PER_BANK + 9,
+};
+
+static struct mtk_clk_rst_desc infra_rst_desc = {
+	.version = MTK_RST_SET_CLR,
+	.rst_bank_ofs = infra_rst_ofs,
+	.rst_bank_nr = ARRAY_SIZE(infra_rst_ofs),
+	.rst_idx_map = infra_idx_map,
+	.rst_idx_map_nr = ARRAY_SIZE(infra_idx_map),
+};
+
 static const struct mtk_clk_desc infra_desc = {
 	.clks = infra_clks,
 	.num_clks = ARRAY_SIZE(infra_clks),
 	.mux_clks = infra_muxes,
 	.num_mux_clks = ARRAY_SIZE(infra_muxes),
 	.clk_lock = &mt7988_clk_lock,
+	.rst_desc = &infra_rst_desc,
 };
 
 static const struct of_device_id of_match_clk_mt7988_infracfg[] = {
Signature · 1 line
2.34.1