devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Add reset controller to mt7988 infracfg
@ 2024-01-04 17:39 Frank Wunderlich
  2024-01-04 17:39 ` [PATCH 1/2] dt-bindings: reset: mediatek: add MT7988 LVTS reset ID Frank Wunderlich
  2024-01-04 17:39 ` [PATCH 2/2] clk: mediatek: add infracfg reset controller for mt7988 Frank Wunderlich
  0 siblings, 2 replies; 6+ messages in thread
From: Frank Wunderlich @ 2024-01-04 17:39 UTC (permalink / raw)
  To: linux-mediatek
  Cc: Frank Wunderlich, Michael Turquette, Stephen Boyd,
	Matthias Brugger, AngeloGioacchino Del Regno, Philipp Zabel,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Sam Shih,
	Daniel Golle, linux-clk, linux-kernel, linux-arm-kernel,
	devicetree

From: Frank Wunderlich <frank-w@public-files.de>

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(+)

-- 
2.34.1


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

* [PATCH 1/2] dt-bindings: reset: mediatek: add MT7988 LVTS reset ID
  2024-01-04 17:39 [PATCH 0/2] Add reset controller to mt7988 infracfg Frank Wunderlich
@ 2024-01-04 17:39 ` Frank Wunderlich
  2024-01-04 18:12   ` Daniel Golle
  2024-01-04 17:39 ` [PATCH 2/2] clk: mediatek: add infracfg reset controller for mt7988 Frank Wunderlich
  1 sibling, 1 reply; 6+ messages in thread
From: Frank Wunderlich @ 2024-01-04 17:39 UTC (permalink / raw)
  To: linux-mediatek
  Cc: Frank Wunderlich, Michael Turquette, Stephen Boyd,
	Matthias Brugger, AngeloGioacchino Del Regno, Philipp Zabel,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Sam Shih,
	Daniel Golle, linux-clk, linux-kernel, linux-arm-kernel,
	devicetree

From: Frank Wunderlich <frank-w@public-files.de>

---
 include/dt-bindings/reset/mediatek,mt7988-resets.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/include/dt-bindings/reset/mediatek,mt7988-resets.h b/include/dt-bindings/reset/mediatek,mt7988-resets.h
index 493301971367..3f1e4ec07ad5 100644
--- a/include/dt-bindings/reset/mediatek,mt7988-resets.h
+++ b/include/dt-bindings/reset/mediatek,mt7988-resets.h
@@ -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 */
+
-- 
2.34.1


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

* [PATCH 2/2] clk: mediatek: add infracfg reset controller for mt7988
  2024-01-04 17:39 [PATCH 0/2] Add reset controller to mt7988 infracfg Frank Wunderlich
  2024-01-04 17:39 ` [PATCH 1/2] dt-bindings: reset: mediatek: add MT7988 LVTS reset ID Frank Wunderlich
@ 2024-01-04 17:39 ` Frank Wunderlich
  1 sibling, 0 replies; 6+ messages in thread
From: Frank Wunderlich @ 2024-01-04 17:39 UTC (permalink / raw)
  To: linux-mediatek
  Cc: Frank Wunderlich, Michael Turquette, Stephen Boyd,
	Matthias Brugger, AngeloGioacchino Del Regno, Philipp Zabel,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Sam Shih,
	Daniel Golle, linux-clk, linux-kernel, linux-arm-kernel,
	devicetree

From: Frank Wunderlich <frank-w@public-files.de>

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

Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
---
 drivers/clk/mediatek/clk-mt7988-infracfg.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/drivers/clk/mediatek/clk-mt7988-infracfg.c b/drivers/clk/mediatek/clk-mt7988-infracfg.c
index 8011ef278bea..1660a45349ff 100644
--- a/drivers/clk/mediatek/clk-mt7988-infracfg.c
+++ b/drivers/clk/mediatek/clk-mt7988-infracfg.c
@@ -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[] = {
-- 
2.34.1


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

* Re: [PATCH 1/2] dt-bindings: reset: mediatek: add MT7988 LVTS reset ID
  2024-01-04 17:39 ` [PATCH 1/2] dt-bindings: reset: mediatek: add MT7988 LVTS reset ID Frank Wunderlich
@ 2024-01-04 18:12   ` Daniel Golle
  2024-01-04 19:19     ` Krzysztof Kozlowski
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Golle @ 2024-01-04 18:12 UTC (permalink / raw)
  To: Frank Wunderlich
  Cc: linux-mediatek, Frank Wunderlich, Michael Turquette, Stephen Boyd,
	Matthias Brugger, AngeloGioacchino Del Regno, Philipp Zabel,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Sam Shih,
	linux-clk, linux-kernel, linux-arm-kernel, devicetree

Hi Frank,

On Thu, Jan 04, 2024 at 06:39:29PM +0100, Frank Wunderlich wrote:
> From: Frank Wunderlich <frank-w@public-files.de>
> 
> ---
>  include/dt-bindings/reset/mediatek,mt7988-resets.h | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/include/dt-bindings/reset/mediatek,mt7988-resets.h b/include/dt-bindings/reset/mediatek,mt7988-resets.h
> index 493301971367..3f1e4ec07ad5 100644
> --- a/include/dt-bindings/reset/mediatek,mt7988-resets.h
> +++ b/include/dt-bindings/reset/mediatek,mt7988-resets.h
> @@ -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/59629ec1-cc0c-4c5a-87cc-ea30d64ec191@linaro.org/

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.


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

* Re: [PATCH 1/2] dt-bindings: reset: mediatek: add MT7988 LVTS reset ID
  2024-01-04 18:12   ` Daniel Golle
@ 2024-01-04 19:19     ` Krzysztof Kozlowski
  2024-01-04 20:54       ` Aw: " Frank Wunderlich
  0 siblings, 1 reply; 6+ messages in thread
From: Krzysztof Kozlowski @ 2024-01-04 19:19 UTC (permalink / raw)
  To: Daniel Golle, Frank Wunderlich
  Cc: linux-mediatek, Frank Wunderlich, Michael Turquette, Stephen Boyd,
	Matthias Brugger, AngeloGioacchino Del Regno, Philipp Zabel,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Sam Shih,
	linux-clk, linux-kernel, linux-arm-kernel, devicetree

On 04/01/2024 19:12, Daniel Golle wrote:
> Hi Frank,
> 
> On Thu, Jan 04, 2024 at 06:39:29PM +0100, Frank Wunderlich wrote:
>> From: Frank Wunderlich <frank-w@public-files.de>
>>
>> ---
>>  include/dt-bindings/reset/mediatek,mt7988-resets.h | 4 ++++
>>  1 file changed, 4 insertions(+)
>>
>> diff --git a/include/dt-bindings/reset/mediatek,mt7988-resets.h b/include/dt-bindings/reset/mediatek,mt7988-resets.h
>> index 493301971367..3f1e4ec07ad5 100644
>> --- a/include/dt-bindings/reset/mediatek,mt7988-resets.h
>> +++ b/include/dt-bindings/reset/mediatek,mt7988-resets.h
>> @@ -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/59629ec1-cc0c-4c5a-87cc-ea30d64ec191@linaro.org/
> 
> 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


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

* Aw: Re: [PATCH 1/2] dt-bindings: reset: mediatek: add MT7988 LVTS reset ID
  2024-01-04 19:19     ` Krzysztof Kozlowski
@ 2024-01-04 20:54       ` Frank Wunderlich
  0 siblings, 0 replies; 6+ messages in thread
From: Frank Wunderlich @ 2024-01-04 20:54 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Daniel Golle, Frank Wunderlich, linux-mediatek, Michael Turquette,
	Stephen Boyd, Matthias Brugger, AngeloGioacchino Del Regno,
	Philipp Zabel, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Sam Shih, linux-clk, linux-kernel, linux-arm-kernel, devicetree

Hi

> Gesendet: Donnerstag, 04. Januar 2024 um 20:19 Uhr
> Von: "Krzysztof Kozlowski" <krzysztof.kozlowski@linaro.org>
> Betreff: Re: [PATCH 1/2] dt-bindings: reset: mediatek: add MT7988 LVTS reset ID
>
> On 04/01/2024 19:12, Daniel Golle wrote:
> > Hi Frank,
> >
> > On Thu, Jan 04, 2024 at 06:39:29PM +0100, Frank Wunderlich wrote:
> >> From: Frank Wunderlich <frank-w@public-files.de>
> >>
> >> ---
> >>  include/dt-bindings/reset/mediatek,mt7988-resets.h | 4 ++++
> >>  1 file changed, 4 insertions(+)
> >>
> >> diff --git a/include/dt-bindings/reset/mediatek,mt7988-resets.h b/include/dt-bindings/reset/mediatek,mt7988-resets.h
> >> index 493301971367..3f1e4ec07ad5 100644
> >> --- a/include/dt-bindings/reset/mediatek,mt7988-resets.h
> >> +++ b/include/dt-bindings/reset/mediatek,mt7988-resets.h
> >> @@ -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/59629ec1-cc0c-4c5a-87cc-ea30d64ec191@linaro.org/
> >
> > 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

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

end of thread, other threads:[~2024-01-04 20:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-04 17:39 [PATCH 0/2] Add reset controller to mt7988 infracfg Frank Wunderlich
2024-01-04 17:39 ` [PATCH 1/2] dt-bindings: reset: mediatek: add MT7988 LVTS reset ID Frank Wunderlich
2024-01-04 18:12   ` Daniel Golle
2024-01-04 19:19     ` Krzysztof Kozlowski
2024-01-04 20:54       ` Aw: " Frank Wunderlich
2024-01-04 17:39 ` [PATCH 2/2] clk: mediatek: add infracfg reset controller for mt7988 Frank Wunderlich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).