mediatek: 6.6: drop backport patches
Drop all backport patches that are now included in kernel 6.6. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
This commit is contained in:
parent
95d3d353f8
commit
23a8e28256
@ -1,44 +0,0 @@
|
||||
From 363547d2191cbc32ca954ba75d72908712398ff2 Mon Sep 17 00:00:00 2001
|
||||
From: Andrew Davis <afd@ti.com>
|
||||
Date: Mon, 24 Oct 2022 12:34:28 -0500
|
||||
Subject: [PATCH] kbuild: Allow DTB overlays to built from .dtso named source
|
||||
files
|
||||
|
||||
Currently DTB Overlays (.dtbo) are build from source files with the same
|
||||
extension (.dts) as the base DTs (.dtb). This may become confusing and
|
||||
even lead to wrong results. For example, a composite DTB (created from a
|
||||
base DTB and a set of overlays) might have the same name as one of the
|
||||
overlays that create it.
|
||||
|
||||
Different files should be generated from differently named sources.
|
||||
.dtb <-> .dts
|
||||
.dtbo <-> .dtso
|
||||
|
||||
We do not remove the ability to compile DTBO files from .dts files here,
|
||||
only add a new rule allowing the .dtso file name. The current .dts named
|
||||
overlays can be renamed with time. After all have been renamed we can
|
||||
remove the other rule.
|
||||
|
||||
Signed-off-by: Andrew Davis <afd@ti.com>
|
||||
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
|
||||
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
|
||||
Reviewed-by: Frank Rowand <frowand.list@gmail.com>
|
||||
Tested-by: Frank Rowand <frowand.list@gmail.com>
|
||||
Link: https://lore.kernel.org/r/20221024173434.32518-2-afd@ti.com
|
||||
Signed-off-by: Rob Herring <robh@kernel.org>
|
||||
---
|
||||
scripts/Makefile.lib | 3 +++
|
||||
1 file changed, 3 insertions(+)
|
||||
|
||||
--- a/scripts/Makefile.lib
|
||||
+++ b/scripts/Makefile.lib
|
||||
@@ -408,6 +408,9 @@ $(obj)/%.dtb: $(src)/%.dts $(DTC) $(DT_T
|
||||
$(obj)/%.dtbo: $(src)/%.dts $(DTC) FORCE
|
||||
$(call if_changed_dep,dtc)
|
||||
|
||||
+$(obj)/%.dtbo: $(src)/%.dtso $(DTC) FORCE
|
||||
+ $(call if_changed_dep,dtc)
|
||||
+
|
||||
dtc-tmp = $(subst $(comma),_,$(dot-target).dts.tmp)
|
||||
|
||||
# Bzip2
|
@ -1,106 +0,0 @@
|
||||
From 2c4daed9580164522859fa100128be408cc69be2 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Sat, 5 Nov 2022 23:36:16 +0100
|
||||
Subject: [PATCH 01/19] arm64: dts: mediatek: mt7986: add support for RX
|
||||
Wireless Ethernet Dispatch
|
||||
|
||||
Similar to TX Wireless Ethernet Dispatch, introduce RX Wireless Ethernet
|
||||
Dispatch to offload traffic received by the wlan interface to lan/wan
|
||||
one.
|
||||
|
||||
Co-developed-by: Sujuan Chen <sujuan.chen@mediatek.com>
|
||||
Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
---
|
||||
arch/arm64/boot/dts/mediatek/mt7986a.dtsi | 65 +++++++++++++++++++++++
|
||||
1 file changed, 65 insertions(+)
|
||||
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt7986a.dtsi
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt7986a.dtsi
|
||||
@@ -76,6 +76,47 @@
|
||||
no-map;
|
||||
reg = <0 0x4fc00000 0 0x00100000>;
|
||||
};
|
||||
+
|
||||
+ wo_emi0: wo-emi@4fd00000 {
|
||||
+ reg = <0 0x4fd00000 0 0x40000>;
|
||||
+ no-map;
|
||||
+ };
|
||||
+
|
||||
+ wo_emi1: wo-emi@4fd40000 {
|
||||
+ reg = <0 0x4fd40000 0 0x40000>;
|
||||
+ no-map;
|
||||
+ };
|
||||
+
|
||||
+ wo_ilm0: wo-ilm@151e0000 {
|
||||
+ reg = <0 0x151e0000 0 0x8000>;
|
||||
+ no-map;
|
||||
+ };
|
||||
+
|
||||
+ wo_ilm1: wo-ilm@151f0000 {
|
||||
+ reg = <0 0x151f0000 0 0x8000>;
|
||||
+ no-map;
|
||||
+ };
|
||||
+
|
||||
+ wo_data: wo-data@4fd80000 {
|
||||
+ reg = <0 0x4fd80000 0 0x240000>;
|
||||
+ no-map;
|
||||
+ };
|
||||
+
|
||||
+ wo_dlm0: wo-dlm@151e8000 {
|
||||
+ reg = <0 0x151e8000 0 0x2000>;
|
||||
+ no-map;
|
||||
+ };
|
||||
+
|
||||
+ wo_dlm1: wo-dlm@151f8000 {
|
||||
+ reg = <0 0x151f8000 0 0x2000>;
|
||||
+ no-map;
|
||||
+ };
|
||||
+
|
||||
+ wo_boot: wo-boot@15194000 {
|
||||
+ reg = <0 0x15194000 0 0x1000>;
|
||||
+ no-map;
|
||||
+ };
|
||||
+
|
||||
};
|
||||
|
||||
timer {
|
||||
@@ -239,6 +280,11 @@
|
||||
reg = <0 0x15010000 0 0x1000>;
|
||||
interrupt-parent = <&gic>;
|
||||
interrupts = <GIC_SPI 205 IRQ_TYPE_LEVEL_HIGH>;
|
||||
+ memory-region = <&wo_emi0>, <&wo_ilm0>, <&wo_dlm0>,
|
||||
+ <&wo_data>, <&wo_boot>;
|
||||
+ memory-region-names = "wo-emi", "wo-ilm", "wo-dlm",
|
||||
+ "wo-data", "wo-boot";
|
||||
+ mediatek,wo-ccif = <&wo_ccif0>;
|
||||
};
|
||||
|
||||
wed1: wed@15011000 {
|
||||
@@ -247,6 +293,25 @@
|
||||
reg = <0 0x15011000 0 0x1000>;
|
||||
interrupt-parent = <&gic>;
|
||||
interrupts = <GIC_SPI 206 IRQ_TYPE_LEVEL_HIGH>;
|
||||
+ memory-region = <&wo_emi1>, <&wo_ilm1>, <&wo_dlm1>,
|
||||
+ <&wo_data>, <&wo_boot>;
|
||||
+ memory-region-names = "wo-emi", "wo-ilm", "wo-dlm",
|
||||
+ "wo-data", "wo-boot";
|
||||
+ mediatek,wo-ccif = <&wo_ccif1>;
|
||||
+ };
|
||||
+
|
||||
+ wo_ccif0: syscon@151a5000 {
|
||||
+ compatible = "mediatek,mt7986-wo-ccif", "syscon";
|
||||
+ reg = <0 0x151a5000 0 0x1000>;
|
||||
+ interrupt-parent = <&gic>;
|
||||
+ interrupts = <GIC_SPI 211 IRQ_TYPE_LEVEL_HIGH>;
|
||||
+ };
|
||||
+
|
||||
+ wo_ccif1: syscon@151ad000 {
|
||||
+ compatible = "mediatek,mt7986-wo-ccif", "syscon";
|
||||
+ reg = <0 0x151ad000 0 0x1000>;
|
||||
+ interrupt-parent = <&gic>;
|
||||
+ interrupts = <GIC_SPI 212 IRQ_TYPE_LEVEL_HIGH>;
|
||||
};
|
||||
|
||||
eth: ethernet@15100000 {
|
@ -1,166 +0,0 @@
|
||||
From 438e53828c08cf0e8a65b61cf6ce1e4b6620551a Mon Sep 17 00:00:00 2001
|
||||
From: Sam Shih <sam.shih@mediatek.com>
|
||||
Date: Sun, 6 Nov 2022 09:50:24 +0100
|
||||
Subject: [PATCH 02/19] arm64: dts: mt7986: harmonize device node order
|
||||
|
||||
This arrange device tree nodes in alphabetical order.
|
||||
|
||||
Signed-off-by: Sam Shih <sam.shih@mediatek.com>
|
||||
Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Link: https://lore.kernel.org/r/20221106085034.12582-2-linux@fw-web.de
|
||||
Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
|
||||
---
|
||||
arch/arm64/boot/dts/mediatek/mt7986a-rfb.dts | 94 ++++++++++----------
|
||||
arch/arm64/boot/dts/mediatek/mt7986b-rfb.dts | 22 ++---
|
||||
2 files changed, 58 insertions(+), 58 deletions(-)
|
||||
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt7986a-rfb.dts
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt7986a-rfb.dts
|
||||
@@ -54,6 +54,53 @@
|
||||
};
|
||||
};
|
||||
|
||||
+&pio {
|
||||
+ uart1_pins: uart1-pins {
|
||||
+ mux {
|
||||
+ function = "uart";
|
||||
+ groups = "uart1";
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
+ uart2_pins: uart2-pins {
|
||||
+ mux {
|
||||
+ function = "uart";
|
||||
+ groups = "uart2";
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
+ wf_2g_5g_pins: wf-2g-5g-pins {
|
||||
+ mux {
|
||||
+ function = "wifi";
|
||||
+ groups = "wf_2g", "wf_5g";
|
||||
+ };
|
||||
+ conf {
|
||||
+ pins = "WF0_HB1", "WF0_HB2", "WF0_HB3", "WF0_HB4",
|
||||
+ "WF0_HB0", "WF0_HB0_B", "WF0_HB5", "WF0_HB6",
|
||||
+ "WF0_HB7", "WF0_HB8", "WF0_HB9", "WF0_HB10",
|
||||
+ "WF0_TOP_CLK", "WF0_TOP_DATA", "WF1_HB1",
|
||||
+ "WF1_HB2", "WF1_HB3", "WF1_HB4", "WF1_HB0",
|
||||
+ "WF1_HB5", "WF1_HB6", "WF1_HB7", "WF1_HB8",
|
||||
+ "WF1_TOP_CLK", "WF1_TOP_DATA";
|
||||
+ drive-strength = <4>;
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
+ wf_dbdc_pins: wf-dbdc-pins {
|
||||
+ mux {
|
||||
+ function = "wifi";
|
||||
+ groups = "wf_dbdc";
|
||||
+ };
|
||||
+ conf {
|
||||
+ pins = "WF0_HB1", "WF0_HB2", "WF0_HB3", "WF0_HB4",
|
||||
+ "WF0_HB0", "WF0_HB0_B", "WF0_HB5", "WF0_HB6",
|
||||
+ "WF0_HB7", "WF0_HB8", "WF0_HB9", "WF0_HB10",
|
||||
+ "WF0_TOP_CLK", "WF0_TOP_DATA";
|
||||
+ drive-strength = <4>;
|
||||
+ };
|
||||
+ };
|
||||
+};
|
||||
+
|
||||
&switch {
|
||||
ports {
|
||||
#address-cells = <1>;
|
||||
@@ -121,50 +168,3 @@
|
||||
pinctrl-0 = <&wf_2g_5g_pins>;
|
||||
pinctrl-1 = <&wf_dbdc_pins>;
|
||||
};
|
||||
-
|
||||
-&pio {
|
||||
- uart1_pins: uart1-pins {
|
||||
- mux {
|
||||
- function = "uart";
|
||||
- groups = "uart1";
|
||||
- };
|
||||
- };
|
||||
-
|
||||
- uart2_pins: uart2-pins {
|
||||
- mux {
|
||||
- function = "uart";
|
||||
- groups = "uart2";
|
||||
- };
|
||||
- };
|
||||
-
|
||||
- wf_2g_5g_pins: wf-2g-5g-pins {
|
||||
- mux {
|
||||
- function = "wifi";
|
||||
- groups = "wf_2g", "wf_5g";
|
||||
- };
|
||||
- conf {
|
||||
- pins = "WF0_HB1", "WF0_HB2", "WF0_HB3", "WF0_HB4",
|
||||
- "WF0_HB0", "WF0_HB0_B", "WF0_HB5", "WF0_HB6",
|
||||
- "WF0_HB7", "WF0_HB8", "WF0_HB9", "WF0_HB10",
|
||||
- "WF0_TOP_CLK", "WF0_TOP_DATA", "WF1_HB1",
|
||||
- "WF1_HB2", "WF1_HB3", "WF1_HB4", "WF1_HB0",
|
||||
- "WF1_HB5", "WF1_HB6", "WF1_HB7", "WF1_HB8",
|
||||
- "WF1_TOP_CLK", "WF1_TOP_DATA";
|
||||
- drive-strength = <4>;
|
||||
- };
|
||||
- };
|
||||
-
|
||||
- wf_dbdc_pins: wf-dbdc-pins {
|
||||
- mux {
|
||||
- function = "wifi";
|
||||
- groups = "wf_dbdc";
|
||||
- };
|
||||
- conf {
|
||||
- pins = "WF0_HB1", "WF0_HB2", "WF0_HB3", "WF0_HB4",
|
||||
- "WF0_HB0", "WF0_HB0_B", "WF0_HB5", "WF0_HB6",
|
||||
- "WF0_HB7", "WF0_HB8", "WF0_HB9", "WF0_HB10",
|
||||
- "WF0_TOP_CLK", "WF0_TOP_DATA";
|
||||
- drive-strength = <4>;
|
||||
- };
|
||||
- };
|
||||
-};
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt7986b-rfb.dts
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt7986b-rfb.dts
|
||||
@@ -25,10 +25,6 @@
|
||||
};
|
||||
};
|
||||
|
||||
-&uart0 {
|
||||
- status = "okay";
|
||||
-};
|
||||
-
|
||||
ð {
|
||||
status = "okay";
|
||||
|
||||
@@ -99,13 +95,6 @@
|
||||
};
|
||||
};
|
||||
|
||||
-&wifi {
|
||||
- status = "okay";
|
||||
- pinctrl-names = "default", "dbdc";
|
||||
- pinctrl-0 = <&wf_2g_5g_pins>;
|
||||
- pinctrl-1 = <&wf_dbdc_pins>;
|
||||
-};
|
||||
-
|
||||
&pio {
|
||||
wf_2g_5g_pins: wf-2g-5g-pins {
|
||||
mux {
|
||||
@@ -138,3 +127,14 @@
|
||||
};
|
||||
};
|
||||
};
|
||||
+
|
||||
+&uart0 {
|
||||
+ status = "okay";
|
||||
+};
|
||||
+
|
||||
+&wifi {
|
||||
+ status = "okay";
|
||||
+ pinctrl-names = "default", "dbdc";
|
||||
+ pinctrl-0 = <&wf_2g_5g_pins>;
|
||||
+ pinctrl-1 = <&wf_dbdc_pins>;
|
||||
+};
|
@ -1,68 +0,0 @@
|
||||
From ffb05357b47f06b2b4d1e14ba89169e28feb727b Mon Sep 17 00:00:00 2001
|
||||
From: Sam Shih <sam.shih@mediatek.com>
|
||||
Date: Sun, 6 Nov 2022 09:50:27 +0100
|
||||
Subject: [PATCH 03/19] arm64: dts: mt7986: add crypto related device nodes
|
||||
|
||||
This patch adds crypto engine support for MT7986.
|
||||
|
||||
Signed-off-by: Vic Wu <vic.wu@mediatek.com>
|
||||
Signed-off-by: Sam Shih <sam.shih@mediatek.com>
|
||||
Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
|
||||
Link: https://lore.kernel.org/r/20221106085034.12582-5-linux@fw-web.de
|
||||
Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
|
||||
---
|
||||
arch/arm64/boot/dts/mediatek/mt7986a-rfb.dts | 4 ++++
|
||||
arch/arm64/boot/dts/mediatek/mt7986a.dtsi | 15 +++++++++++++++
|
||||
arch/arm64/boot/dts/mediatek/mt7986b-rfb.dts | 4 ++++
|
||||
3 files changed, 23 insertions(+)
|
||||
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt7986a-rfb.dts
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt7986a-rfb.dts
|
||||
@@ -25,6 +25,10 @@
|
||||
};
|
||||
};
|
||||
|
||||
+&crypto {
|
||||
+ status = "okay";
|
||||
+};
|
||||
+
|
||||
ð {
|
||||
status = "okay";
|
||||
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt7986a.dtsi
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt7986a.dtsi
|
||||
@@ -223,6 +223,21 @@
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
+ crypto: crypto@10320000 {
|
||||
+ compatible = "inside-secure,safexcel-eip97";
|
||||
+ reg = <0 0x10320000 0 0x40000>;
|
||||
+ interrupts = <GIC_SPI 116 IRQ_TYPE_LEVEL_HIGH>,
|
||||
+ <GIC_SPI 117 IRQ_TYPE_LEVEL_HIGH>,
|
||||
+ <GIC_SPI 118 IRQ_TYPE_LEVEL_HIGH>,
|
||||
+ <GIC_SPI 119 IRQ_TYPE_LEVEL_HIGH>;
|
||||
+ interrupt-names = "ring0", "ring1", "ring2", "ring3";
|
||||
+ clocks = <&infracfg CLK_INFRA_EIP97_CK>;
|
||||
+ clock-names = "infra_eip97_ck";
|
||||
+ assigned-clocks = <&topckgen CLK_TOP_EIP_B_SEL>;
|
||||
+ assigned-clock-parents = <&apmixedsys CLK_APMIXED_NET2PLL>;
|
||||
+ status = "disabled";
|
||||
+ };
|
||||
+
|
||||
uart0: serial@11002000 {
|
||||
compatible = "mediatek,mt7986-uart",
|
||||
"mediatek,mt6577-uart";
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt7986b-rfb.dts
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt7986b-rfb.dts
|
||||
@@ -25,6 +25,10 @@
|
||||
};
|
||||
};
|
||||
|
||||
+&crypto {
|
||||
+ status = "okay";
|
||||
+};
|
||||
+
|
||||
ð {
|
||||
status = "okay";
|
||||
|
@ -1,37 +0,0 @@
|
||||
From b49b7dc404ded1d89cbc568d875009a5c1ed4ef6 Mon Sep 17 00:00:00 2001
|
||||
From: Frank Wunderlich <frank-w@public-files.de>
|
||||
Date: Sun, 6 Nov 2022 09:50:29 +0100
|
||||
Subject: [PATCH 04/19] arm64: dts: mt7986: add i2c node
|
||||
|
||||
Add i2c Node to mt7986 devicetree.
|
||||
|
||||
Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
|
||||
Link: https://lore.kernel.org/r/20221106085034.12582-7-linux@fw-web.de
|
||||
Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
|
||||
---
|
||||
arch/arm64/boot/dts/mediatek/mt7986a.dtsi | 14 ++++++++++++++
|
||||
1 file changed, 14 insertions(+)
|
||||
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt7986a.dtsi
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt7986a.dtsi
|
||||
@@ -279,6 +279,20 @@
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
+ i2c0: i2c@11008000 {
|
||||
+ compatible = "mediatek,mt7986-i2c";
|
||||
+ reg = <0 0x11008000 0 0x90>,
|
||||
+ <0 0x10217080 0 0x80>;
|
||||
+ interrupts = <GIC_SPI 136 IRQ_TYPE_LEVEL_HIGH>;
|
||||
+ clock-div = <5>;
|
||||
+ clocks = <&infracfg CLK_INFRA_I2C0_CK>,
|
||||
+ <&infracfg CLK_INFRA_AP_DMA_CK>;
|
||||
+ clock-names = "main", "dma";
|
||||
+ #address-cells = <1>;
|
||||
+ #size-cells = <0>;
|
||||
+ status = "disabled";
|
||||
+ };
|
||||
+
|
||||
ethsys: syscon@15000000 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
@ -1,61 +0,0 @@
|
||||
From 2cd6022800d6da7822e169f3e6f7f790c1431445 Mon Sep 17 00:00:00 2001
|
||||
From: Matthias Brugger <mbrugger@suse.com>
|
||||
Date: Mon, 14 Nov 2022 13:16:53 +0100
|
||||
Subject: [PATCH 05/19] arm64: dts: mediatek: mt7986: Add SoC compatible
|
||||
|
||||
Missing SoC compatible in the board file causes dt bindings check.
|
||||
|
||||
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
|
||||
Link: https://lore.kernel.org/r/20221114121653.14739-1-matthias.bgg@kernel.org
|
||||
Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
|
||||
---
|
||||
arch/arm64/boot/dts/mediatek/mt7986a-rfb.dts | 2 +-
|
||||
arch/arm64/boot/dts/mediatek/mt7986a.dtsi | 1 +
|
||||
arch/arm64/boot/dts/mediatek/mt7986b-rfb.dts | 2 +-
|
||||
arch/arm64/boot/dts/mediatek/mt7986b.dtsi | 3 +++
|
||||
4 files changed, 6 insertions(+), 2 deletions(-)
|
||||
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt7986a-rfb.dts
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt7986a-rfb.dts
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
/ {
|
||||
model = "MediaTek MT7986a RFB";
|
||||
- compatible = "mediatek,mt7986a-rfb";
|
||||
+ compatible = "mediatek,mt7986a-rfb", "mediatek,mt7986a";
|
||||
|
||||
aliases {
|
||||
serial0 = &uart0;
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt7986a.dtsi
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt7986a.dtsi
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <dt-bindings/reset/mt7986-resets.h>
|
||||
|
||||
/ {
|
||||
+ compatible = "mediatek,mt7986a";
|
||||
interrupt-parent = <&gic>;
|
||||
#address-cells = <2>;
|
||||
#size-cells = <2>;
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt7986b-rfb.dts
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt7986b-rfb.dts
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
/ {
|
||||
model = "MediaTek MT7986b RFB";
|
||||
- compatible = "mediatek,mt7986b-rfb";
|
||||
+ compatible = "mediatek,mt7986b-rfb", "mediatek,mt7986b";
|
||||
|
||||
aliases {
|
||||
serial0 = &uart0;
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt7986b.dtsi
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt7986b.dtsi
|
||||
@@ -5,6 +5,9 @@
|
||||
*/
|
||||
|
||||
#include "mt7986a.dtsi"
|
||||
+/ {
|
||||
+ compatible = "mediatek,mt7986b";
|
||||
+};
|
||||
|
||||
&pio {
|
||||
compatible = "mediatek,mt7986b-pinctrl";
|
@ -1,157 +0,0 @@
|
||||
From f4029538f063a845dc9aae46cce4cf386e6253a5 Mon Sep 17 00:00:00 2001
|
||||
From: Sam Shih <sam.shih@mediatek.com>
|
||||
Date: Fri, 18 Nov 2022 20:01:21 +0100
|
||||
Subject: [PATCH 06/19] arm64: dts: mt7986: add spi related device nodes
|
||||
|
||||
This patch adds spi support for MT7986.
|
||||
|
||||
Signed-off-by: Sam Shih <sam.shih@mediatek.com>
|
||||
Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Link: https://lore.kernel.org/r/20221118190126.100895-7-linux@fw-web.de
|
||||
Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
|
||||
---
|
||||
arch/arm64/boot/dts/mediatek/mt7986a-rfb.dts | 35 ++++++++++++++++++++
|
||||
arch/arm64/boot/dts/mediatek/mt7986a.dtsi | 28 ++++++++++++++++
|
||||
arch/arm64/boot/dts/mediatek/mt7986b-rfb.dts | 35 ++++++++++++++++++++
|
||||
3 files changed, 98 insertions(+)
|
||||
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt7986a-rfb.dts
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt7986a-rfb.dts
|
||||
@@ -59,6 +59,20 @@
|
||||
};
|
||||
|
||||
&pio {
|
||||
+ spi_flash_pins: spi-flash-pins {
|
||||
+ mux {
|
||||
+ function = "spi";
|
||||
+ groups = "spi0", "spi0_wp_hold";
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
+ spic_pins: spic-pins {
|
||||
+ mux {
|
||||
+ function = "spi";
|
||||
+ groups = "spi1_2";
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
uart1_pins: uart1-pins {
|
||||
mux {
|
||||
function = "uart";
|
||||
@@ -105,6 +119,27 @@
|
||||
};
|
||||
};
|
||||
|
||||
+&spi0 {
|
||||
+ pinctrl-names = "default";
|
||||
+ pinctrl-0 = <&spi_flash_pins>;
|
||||
+ cs-gpios = <0>, <0>;
|
||||
+ status = "okay";
|
||||
+ spi_nand: spi_nand@0 {
|
||||
+ compatible = "spi-nand";
|
||||
+ reg = <0>;
|
||||
+ spi-max-frequency = <10000000>;
|
||||
+ spi-tx-bus-width = <4>;
|
||||
+ spi-rx-bus-width = <4>;
|
||||
+ };
|
||||
+};
|
||||
+
|
||||
+&spi1 {
|
||||
+ pinctrl-names = "default";
|
||||
+ pinctrl-0 = <&spic_pins>;
|
||||
+ cs-gpios = <0>, <0>;
|
||||
+ status = "okay";
|
||||
+};
|
||||
+
|
||||
&switch {
|
||||
ports {
|
||||
#address-cells = <1>;
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt7986a.dtsi
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt7986a.dtsi
|
||||
@@ -294,6 +294,34 @@
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
+ spi0: spi@1100a000 {
|
||||
+ compatible = "mediatek,mt7986-spi-ipm", "mediatek,spi-ipm";
|
||||
+ #address-cells = <1>;
|
||||
+ #size-cells = <0>;
|
||||
+ reg = <0 0x1100a000 0 0x100>;
|
||||
+ interrupts = <GIC_SPI 140 IRQ_TYPE_LEVEL_HIGH>;
|
||||
+ clocks = <&topckgen CLK_TOP_MPLL_D2>,
|
||||
+ <&topckgen CLK_TOP_SPI_SEL>,
|
||||
+ <&infracfg CLK_INFRA_SPI0_CK>,
|
||||
+ <&infracfg CLK_INFRA_SPI0_HCK_CK>;
|
||||
+ clock-names = "parent-clk", "sel-clk", "spi-clk", "hclk";
|
||||
+ status = "disabled";
|
||||
+ };
|
||||
+
|
||||
+ spi1: spi@1100b000 {
|
||||
+ compatible = "mediatek,mt7986-spi-ipm", "mediatek,spi-ipm";
|
||||
+ #address-cells = <1>;
|
||||
+ #size-cells = <0>;
|
||||
+ reg = <0 0x1100b000 0 0x100>;
|
||||
+ interrupts = <GIC_SPI 141 IRQ_TYPE_LEVEL_HIGH>;
|
||||
+ clocks = <&topckgen CLK_TOP_MPLL_D2>,
|
||||
+ <&topckgen CLK_TOP_SPIM_MST_SEL>,
|
||||
+ <&infracfg CLK_INFRA_SPI1_CK>,
|
||||
+ <&infracfg CLK_INFRA_SPI1_HCK_CK>;
|
||||
+ clock-names = "parent-clk", "sel-clk", "spi-clk", "hclk";
|
||||
+ status = "disabled";
|
||||
+ };
|
||||
+
|
||||
ethsys: syscon@15000000 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt7986b-rfb.dts
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt7986b-rfb.dts
|
||||
@@ -100,6 +100,20 @@
|
||||
};
|
||||
|
||||
&pio {
|
||||
+ spi_flash_pins: spi-flash-pins {
|
||||
+ mux {
|
||||
+ function = "spi";
|
||||
+ groups = "spi0", "spi0_wp_hold";
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
+ spic_pins: spic-pins {
|
||||
+ mux {
|
||||
+ function = "spi";
|
||||
+ groups = "spi1_2";
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
wf_2g_5g_pins: wf-2g-5g-pins {
|
||||
mux {
|
||||
function = "wifi";
|
||||
@@ -132,6 +146,27 @@
|
||||
};
|
||||
};
|
||||
|
||||
+&spi0 {
|
||||
+ pinctrl-names = "default";
|
||||
+ pinctrl-0 = <&spi_flash_pins>;
|
||||
+ cs-gpios = <0>, <0>;
|
||||
+ status = "okay";
|
||||
+ spi_nand: spi_nand@0 {
|
||||
+ compatible = "spi-nand";
|
||||
+ reg = <0>;
|
||||
+ spi-max-frequency = <10000000>;
|
||||
+ spi-tx-bus-width = <4>;
|
||||
+ spi-rx-bus-width = <4>;
|
||||
+ };
|
||||
+};
|
||||
+
|
||||
+&spi1 {
|
||||
+ pinctrl-names = "default";
|
||||
+ pinctrl-0 = <&spic_pins>;
|
||||
+ cs-gpios = <0>, <0>;
|
||||
+ status = "okay";
|
||||
+};
|
||||
+
|
||||
&uart0 {
|
||||
status = "okay";
|
||||
};
|
@ -1,127 +0,0 @@
|
||||
From 9e8e24ab716098e617195ce29b88e84608bf2108 Mon Sep 17 00:00:00 2001
|
||||
From: Sam Shih <sam.shih@mediatek.com>
|
||||
Date: Fri, 6 Jan 2023 16:28:42 +0100
|
||||
Subject: [PATCH 07/19] arm64: dts: mt7986: add usb related device nodes
|
||||
|
||||
This patch adds USB support for MT7986.
|
||||
|
||||
Signed-off-by: Sam Shih <sam.shih@mediatek.com>
|
||||
Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
|
||||
Reviewed-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
|
||||
Link: https://lore.kernel.org/r/20230106152845.88717-3-linux@fw-web.de
|
||||
Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
|
||||
---
|
||||
arch/arm64/boot/dts/mediatek/mt7986a-rfb.dts | 8 +++
|
||||
arch/arm64/boot/dts/mediatek/mt7986a.dtsi | 55 ++++++++++++++++++++
|
||||
arch/arm64/boot/dts/mediatek/mt7986b-rfb.dts | 8 +++
|
||||
3 files changed, 71 insertions(+)
|
||||
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt7986a-rfb.dts
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt7986a-rfb.dts
|
||||
@@ -140,6 +140,10 @@
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
+&ssusb {
|
||||
+ status = "okay";
|
||||
+};
|
||||
+
|
||||
&switch {
|
||||
ports {
|
||||
#address-cells = <1>;
|
||||
@@ -201,6 +205,10 @@
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
+&usb_phy {
|
||||
+ status = "okay";
|
||||
+};
|
||||
+
|
||||
&wifi {
|
||||
status = "okay";
|
||||
pinctrl-names = "default", "dbdc";
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt7986a.dtsi
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt7986a.dtsi
|
||||
@@ -322,6 +322,61 @@
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
+ ssusb: usb@11200000 {
|
||||
+ compatible = "mediatek,mt7986-xhci",
|
||||
+ "mediatek,mtk-xhci";
|
||||
+ reg = <0 0x11200000 0 0x2e00>,
|
||||
+ <0 0x11203e00 0 0x0100>;
|
||||
+ reg-names = "mac", "ippc";
|
||||
+ interrupts = <GIC_SPI 173 IRQ_TYPE_LEVEL_HIGH>;
|
||||
+ clocks = <&infracfg CLK_INFRA_IUSB_SYS_CK>,
|
||||
+ <&infracfg CLK_INFRA_IUSB_CK>,
|
||||
+ <&infracfg CLK_INFRA_IUSB_133_CK>,
|
||||
+ <&infracfg CLK_INFRA_IUSB_66M_CK>,
|
||||
+ <&topckgen CLK_TOP_U2U3_XHCI_SEL>;
|
||||
+ clock-names = "sys_ck",
|
||||
+ "ref_ck",
|
||||
+ "mcu_ck",
|
||||
+ "dma_ck",
|
||||
+ "xhci_ck";
|
||||
+ phys = <&u2port0 PHY_TYPE_USB2>,
|
||||
+ <&u3port0 PHY_TYPE_USB3>,
|
||||
+ <&u2port1 PHY_TYPE_USB2>;
|
||||
+ status = "disabled";
|
||||
+ };
|
||||
+
|
||||
+ usb_phy: t-phy@11e10000 {
|
||||
+ compatible = "mediatek,mt7986-tphy",
|
||||
+ "mediatek,generic-tphy-v2";
|
||||
+ #address-cells = <1>;
|
||||
+ #size-cells = <1>;
|
||||
+ ranges = <0 0 0x11e10000 0x1700>;
|
||||
+ status = "disabled";
|
||||
+
|
||||
+ u2port0: usb-phy@0 {
|
||||
+ reg = <0x0 0x700>;
|
||||
+ clocks = <&topckgen CLK_TOP_DA_U2_REFSEL>,
|
||||
+ <&topckgen CLK_TOP_DA_U2_CK_1P_SEL>;
|
||||
+ clock-names = "ref", "da_ref";
|
||||
+ #phy-cells = <1>;
|
||||
+ };
|
||||
+
|
||||
+ u3port0: usb-phy@700 {
|
||||
+ reg = <0x700 0x900>;
|
||||
+ clocks = <&topckgen CLK_TOP_USB3_PHY_SEL>;
|
||||
+ clock-names = "ref";
|
||||
+ #phy-cells = <1>;
|
||||
+ };
|
||||
+
|
||||
+ u2port1: usb-phy@1000 {
|
||||
+ reg = <0x1000 0x700>;
|
||||
+ clocks = <&topckgen CLK_TOP_DA_U2_REFSEL>,
|
||||
+ <&topckgen CLK_TOP_DA_U2_CK_1P_SEL>;
|
||||
+ clock-names = "ref", "da_ref";
|
||||
+ #phy-cells = <1>;
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
ethsys: syscon@15000000 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt7986b-rfb.dts
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt7986b-rfb.dts
|
||||
@@ -167,10 +167,18 @@
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
+&ssusb {
|
||||
+ status = "okay";
|
||||
+};
|
||||
+
|
||||
&uart0 {
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
+&usb_phy {
|
||||
+ status = "okay";
|
||||
+};
|
||||
+
|
||||
&wifi {
|
||||
status = "okay";
|
||||
pinctrl-names = "default", "dbdc";
|
@ -1,160 +0,0 @@
|
||||
From c1744e9e75a6a8abc7c893f349bcbf725b9c0d74 Mon Sep 17 00:00:00 2001
|
||||
From: Sam Shih <sam.shih@mediatek.com>
|
||||
Date: Fri, 6 Jan 2023 16:28:43 +0100
|
||||
Subject: [PATCH 08/19] arm64: dts: mt7986: add mmc related device nodes
|
||||
|
||||
This patch adds mmc support for MT7986.
|
||||
|
||||
Signed-off-by: Sam Shih <sam.shih@mediatek.com>
|
||||
Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
|
||||
Link: https://lore.kernel.org/r/20230106152845.88717-4-linux@fw-web.de
|
||||
Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
|
||||
---
|
||||
arch/arm64/boot/dts/mediatek/mt7986a-rfb.dts | 96 ++++++++++++++++++++
|
||||
arch/arm64/boot/dts/mediatek/mt7986a.dtsi | 15 +++
|
||||
2 files changed, 111 insertions(+)
|
||||
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt7986a-rfb.dts
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt7986a-rfb.dts
|
||||
@@ -5,6 +5,8 @@
|
||||
*/
|
||||
|
||||
/dts-v1/;
|
||||
+#include <dt-bindings/pinctrl/mt65xx.h>
|
||||
+
|
||||
#include "mt7986a.dtsi"
|
||||
|
||||
/ {
|
||||
@@ -23,6 +25,24 @@
|
||||
device_type = "memory";
|
||||
reg = <0 0x40000000 0 0x40000000>;
|
||||
};
|
||||
+
|
||||
+ reg_1p8v: regulator-1p8v {
|
||||
+ compatible = "regulator-fixed";
|
||||
+ regulator-name = "fixed-1.8V";
|
||||
+ regulator-min-microvolt = <1800000>;
|
||||
+ regulator-max-microvolt = <1800000>;
|
||||
+ regulator-boot-on;
|
||||
+ regulator-always-on;
|
||||
+ };
|
||||
+
|
||||
+ reg_3p3v: regulator-3p3v {
|
||||
+ compatible = "regulator-fixed";
|
||||
+ regulator-name = "fixed-3.3V";
|
||||
+ regulator-min-microvolt = <3300000>;
|
||||
+ regulator-max-microvolt = <3300000>;
|
||||
+ regulator-boot-on;
|
||||
+ regulator-always-on;
|
||||
+ };
|
||||
};
|
||||
|
||||
&crypto {
|
||||
@@ -58,7 +78,83 @@
|
||||
};
|
||||
};
|
||||
|
||||
+&mmc0 {
|
||||
+ pinctrl-names = "default", "state_uhs";
|
||||
+ pinctrl-0 = <&mmc0_pins_default>;
|
||||
+ pinctrl-1 = <&mmc0_pins_uhs>;
|
||||
+ bus-width = <8>;
|
||||
+ max-frequency = <200000000>;
|
||||
+ cap-mmc-highspeed;
|
||||
+ mmc-hs200-1_8v;
|
||||
+ mmc-hs400-1_8v;
|
||||
+ hs400-ds-delay = <0x14014>;
|
||||
+ vmmc-supply = <®_3p3v>;
|
||||
+ vqmmc-supply = <®_1p8v>;
|
||||
+ non-removable;
|
||||
+ no-sd;
|
||||
+ no-sdio;
|
||||
+ status = "okay";
|
||||
+};
|
||||
+
|
||||
&pio {
|
||||
+ mmc0_pins_default: mmc0-pins {
|
||||
+ mux {
|
||||
+ function = "emmc";
|
||||
+ groups = "emmc_51";
|
||||
+ };
|
||||
+ conf-cmd-dat {
|
||||
+ pins = "EMMC_DATA_0", "EMMC_DATA_1", "EMMC_DATA_2",
|
||||
+ "EMMC_DATA_3", "EMMC_DATA_4", "EMMC_DATA_5",
|
||||
+ "EMMC_DATA_6", "EMMC_DATA_7", "EMMC_CMD";
|
||||
+ input-enable;
|
||||
+ drive-strength = <4>;
|
||||
+ bias-pull-up = <MTK_PUPD_SET_R1R0_01>; /* pull-up 10K */
|
||||
+ };
|
||||
+ conf-clk {
|
||||
+ pins = "EMMC_CK";
|
||||
+ drive-strength = <6>;
|
||||
+ bias-pull-down = <MTK_PUPD_SET_R1R0_10>; /* pull-down 50K */
|
||||
+ };
|
||||
+ conf-ds {
|
||||
+ pins = "EMMC_DSL";
|
||||
+ bias-pull-down = <MTK_PUPD_SET_R1R0_10>; /* pull-down 50K */
|
||||
+ };
|
||||
+ conf-rst {
|
||||
+ pins = "EMMC_RSTB";
|
||||
+ drive-strength = <4>;
|
||||
+ bias-pull-up = <MTK_PUPD_SET_R1R0_01>; /* pull-up 10K */
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
+ mmc0_pins_uhs: mmc0-uhs-pins {
|
||||
+ mux {
|
||||
+ function = "emmc";
|
||||
+ groups = "emmc_51";
|
||||
+ };
|
||||
+ conf-cmd-dat {
|
||||
+ pins = "EMMC_DATA_0", "EMMC_DATA_1", "EMMC_DATA_2",
|
||||
+ "EMMC_DATA_3", "EMMC_DATA_4", "EMMC_DATA_5",
|
||||
+ "EMMC_DATA_6", "EMMC_DATA_7", "EMMC_CMD";
|
||||
+ input-enable;
|
||||
+ drive-strength = <4>;
|
||||
+ bias-pull-up = <MTK_PUPD_SET_R1R0_01>; /* pull-up 10K */
|
||||
+ };
|
||||
+ conf-clk {
|
||||
+ pins = "EMMC_CK";
|
||||
+ drive-strength = <6>;
|
||||
+ bias-pull-down = <MTK_PUPD_SET_R1R0_10>; /* pull-down 50K */
|
||||
+ };
|
||||
+ conf-ds {
|
||||
+ pins = "EMMC_DSL";
|
||||
+ bias-pull-down = <MTK_PUPD_SET_R1R0_10>; /* pull-down 50K */
|
||||
+ };
|
||||
+ conf-rst {
|
||||
+ pins = "EMMC_RSTB";
|
||||
+ drive-strength = <4>;
|
||||
+ bias-pull-up = <MTK_PUPD_SET_R1R0_01>; /* pull-up 10K */
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
spi_flash_pins: spi-flash-pins {
|
||||
mux {
|
||||
function = "spi";
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt7986a.dtsi
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt7986a.dtsi
|
||||
@@ -345,6 +345,21 @@
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
+ mmc0: mmc@11230000 {
|
||||
+ compatible = "mediatek,mt7986-mmc";
|
||||
+ reg = <0 0x11230000 0 0x1000>,
|
||||
+ <0 0x11c20000 0 0x1000>;
|
||||
+ interrupts = <GIC_SPI 143 IRQ_TYPE_LEVEL_HIGH>;
|
||||
+ clocks = <&topckgen CLK_TOP_EMMC_416M_SEL>,
|
||||
+ <&infracfg CLK_INFRA_MSDC_HCK_CK>,
|
||||
+ <&infracfg CLK_INFRA_MSDC_CK>,
|
||||
+ <&infracfg CLK_INFRA_MSDC_133M_CK>,
|
||||
+ <&infracfg CLK_INFRA_MSDC_66M_CK>;
|
||||
+ clock-names = "source", "hclk", "source_cg", "bus_clk",
|
||||
+ "sys_cg";
|
||||
+ status = "disabled";
|
||||
+ };
|
||||
+
|
||||
usb_phy: t-phy@11e10000 {
|
||||
compatible = "mediatek,mt7986-tphy",
|
||||
"mediatek,generic-tphy-v2";
|
@ -1,118 +0,0 @@
|
||||
From 87a42ef1d6cf602e4aa40555b4404cad6149a90f Mon Sep 17 00:00:00 2001
|
||||
From: Sam Shih <sam.shih@mediatek.com>
|
||||
Date: Fri, 6 Jan 2023 16:28:44 +0100
|
||||
Subject: [PATCH 09/19] arm64: dts: mt7986: add pcie related device nodes
|
||||
|
||||
This patch adds PCIe support for MT7986.
|
||||
|
||||
Signed-off-by: Jieyy Yang <jieyy.yang@mediatek.com>
|
||||
Signed-off-by: Sam Shih <sam.shih@mediatek.com>
|
||||
Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Link: https://lore.kernel.org/r/20230106152845.88717-5-linux@fw-web.de
|
||||
Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
|
||||
---
|
||||
arch/arm64/boot/dts/mediatek/mt7986a-rfb.dts | 16 ++++++
|
||||
arch/arm64/boot/dts/mediatek/mt7986a.dtsi | 52 ++++++++++++++++++++
|
||||
2 files changed, 68 insertions(+)
|
||||
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt7986a-rfb.dts
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt7986a-rfb.dts
|
||||
@@ -93,6 +93,15 @@
|
||||
non-removable;
|
||||
no-sd;
|
||||
no-sdio;
|
||||
+};
|
||||
+
|
||||
+&pcie {
|
||||
+ pinctrl-names = "default";
|
||||
+ pinctrl-0 = <&pcie_pins>;
|
||||
+ status = "okay";
|
||||
+};
|
||||
+
|
||||
+&pcie_phy {
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
@@ -155,6 +164,13 @@
|
||||
};
|
||||
};
|
||||
|
||||
+ pcie_pins: pcie-pins {
|
||||
+ mux {
|
||||
+ function = "pcie";
|
||||
+ groups = "pcie_clk", "pcie_wake", "pcie_pereset";
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
spi_flash_pins: spi-flash-pins {
|
||||
mux {
|
||||
function = "spi";
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt7986a.dtsi
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt7986a.dtsi
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <dt-bindings/interrupt-controller/arm-gic.h>
|
||||
#include <dt-bindings/clock/mt7986-clk.h>
|
||||
#include <dt-bindings/reset/mt7986-resets.h>
|
||||
+#include <dt-bindings/phy/phy.h>
|
||||
|
||||
/ {
|
||||
compatible = "mediatek,mt7986a";
|
||||
@@ -360,6 +361,57 @@
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
+ pcie: pcie@11280000 {
|
||||
+ compatible = "mediatek,mt7986-pcie",
|
||||
+ "mediatek,mt8192-pcie";
|
||||
+ device_type = "pci";
|
||||
+ #address-cells = <3>;
|
||||
+ #size-cells = <2>;
|
||||
+ reg = <0x00 0x11280000 0x00 0x4000>;
|
||||
+ reg-names = "pcie-mac";
|
||||
+ interrupts = <GIC_SPI 168 IRQ_TYPE_LEVEL_HIGH>;
|
||||
+ bus-range = <0x00 0xff>;
|
||||
+ ranges = <0x82000000 0x00 0x20000000 0x00
|
||||
+ 0x20000000 0x00 0x10000000>;
|
||||
+ clocks = <&infracfg CLK_INFRA_IPCIE_PIPE_CK>,
|
||||
+ <&infracfg CLK_INFRA_IPCIE_CK>,
|
||||
+ <&infracfg CLK_INFRA_IPCIER_CK>,
|
||||
+ <&infracfg CLK_INFRA_IPCIEB_CK>;
|
||||
+ clock-names = "pl_250m", "tl_26m", "peri_26m", "top_133m";
|
||||
+ status = "disabled";
|
||||
+
|
||||
+ phys = <&pcie_port PHY_TYPE_PCIE>;
|
||||
+ phy-names = "pcie-phy";
|
||||
+
|
||||
+ #interrupt-cells = <1>;
|
||||
+ interrupt-map-mask = <0 0 0 0x7>;
|
||||
+ interrupt-map = <0 0 0 1 &pcie_intc 0>,
|
||||
+ <0 0 0 2 &pcie_intc 1>,
|
||||
+ <0 0 0 3 &pcie_intc 2>,
|
||||
+ <0 0 0 4 &pcie_intc 3>;
|
||||
+ pcie_intc: interrupt-controller {
|
||||
+ #address-cells = <0>;
|
||||
+ #interrupt-cells = <1>;
|
||||
+ interrupt-controller;
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
+ pcie_phy: t-phy@11c00000 {
|
||||
+ compatible = "mediatek,mt7986-tphy",
|
||||
+ "mediatek,generic-tphy-v2";
|
||||
+ #address-cells = <2>;
|
||||
+ #size-cells = <2>;
|
||||
+ ranges;
|
||||
+ status = "disabled";
|
||||
+
|
||||
+ pcie_port: pcie-phy@11c00000 {
|
||||
+ reg = <0 0x11c00000 0 0x20000>;
|
||||
+ clocks = <&clk40m>;
|
||||
+ clock-names = "ref";
|
||||
+ #phy-cells = <1>;
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
usb_phy: t-phy@11e10000 {
|
||||
compatible = "mediatek,mt7986-tphy",
|
||||
"mediatek,generic-tphy-v2";
|
@ -1,689 +0,0 @@
|
||||
From a751f7412e0098801673b80bc7a4738ae7d710ce Mon Sep 17 00:00:00 2001
|
||||
From: Frank Wunderlich <frank-w@public-files.de>
|
||||
Date: Fri, 6 Jan 2023 16:28:45 +0100
|
||||
Subject: [PATCH 10/19] arm64: dts: mt7986: add Bananapi R3
|
||||
|
||||
Add support for Bananapi R3 SBC.
|
||||
|
||||
- SD/eMMC support (switching first 4 bits of data-bus with sw6/D)
|
||||
- SPI-NAND/NOR support (switched CS by sw5/C)
|
||||
- all rj45 ports and both SFP working (eth1/lan4)
|
||||
- all USB-Ports + SIM-Slot tested
|
||||
- i2c and all uarts tested
|
||||
- wifi tested (with eeprom calibration data)
|
||||
|
||||
The device can boot from all 4 storage options. Both, SPI and MMC, can
|
||||
be switched using hardware switches on the board, see
|
||||
https://wiki.banana-pi.org/Banana_Pi_BPI-R3#Jumper_setting
|
||||
|
||||
Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
|
||||
Link: https://lore.kernel.org/r/20230106152845.88717-6-linux@fw-web.de
|
||||
Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
|
||||
---
|
||||
arch/arm64/boot/dts/mediatek/Makefile | 5 +
|
||||
.../mt7986a-bananapi-bpi-r3-emmc.dtso | 29 ++
|
||||
.../mt7986a-bananapi-bpi-r3-nand.dtso | 55 +++
|
||||
.../mediatek/mt7986a-bananapi-bpi-r3-nor.dtso | 68 +++
|
||||
.../mediatek/mt7986a-bananapi-bpi-r3-sd.dtso | 23 +
|
||||
.../dts/mediatek/mt7986a-bananapi-bpi-r3.dts | 450 ++++++++++++++++++
|
||||
6 files changed, 630 insertions(+)
|
||||
create mode 100644 arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-emmc.dtso
|
||||
create mode 100644 arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-nand.dtso
|
||||
create mode 100644 arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-nor.dtso
|
||||
create mode 100644 arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-sd.dtso
|
||||
create mode 100644 arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dts
|
||||
|
||||
--- a/arch/arm64/boot/dts/mediatek/Makefile
|
||||
+++ b/arch/arm64/boot/dts/mediatek/Makefile
|
||||
@@ -7,6 +7,11 @@ dtb-$(CONFIG_ARCH_MEDIATEK) += mt6797-ev
|
||||
dtb-$(CONFIG_ARCH_MEDIATEK) += mt6797-x20-dev.dtb
|
||||
dtb-$(CONFIG_ARCH_MEDIATEK) += mt7622-rfb1.dtb
|
||||
dtb-$(CONFIG_ARCH_MEDIATEK) += mt7622-bananapi-bpi-r64.dtb
|
||||
+dtb-$(CONFIG_ARCH_MEDIATEK) += mt7986a-bananapi-bpi-r3.dtb
|
||||
+dtb-$(CONFIG_ARCH_MEDIATEK) += mt7986a-bananapi-bpi-r3-emmc.dtbo
|
||||
+dtb-$(CONFIG_ARCH_MEDIATEK) += mt7986a-bananapi-bpi-r3-nand.dtbo
|
||||
+dtb-$(CONFIG_ARCH_MEDIATEK) += mt7986a-bananapi-bpi-r3-nor.dtbo
|
||||
+dtb-$(CONFIG_ARCH_MEDIATEK) += mt7986a-bananapi-bpi-r3-sd.dtbo
|
||||
dtb-$(CONFIG_ARCH_MEDIATEK) += mt7986a-rfb.dtb
|
||||
dtb-$(CONFIG_ARCH_MEDIATEK) += mt7986b-rfb.dtb
|
||||
dtb-$(CONFIG_ARCH_MEDIATEK) += mt8167-pumpkin.dtb
|
||||
--- /dev/null
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-emmc.dtso
|
||||
@@ -0,0 +1,29 @@
|
||||
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
|
||||
+/*
|
||||
+ * Copyright (C) 2021 MediaTek Inc.
|
||||
+ * Author: Sam.Shih <sam.shih@mediatek.com>
|
||||
+ */
|
||||
+
|
||||
+/dts-v1/;
|
||||
+/plugin/;
|
||||
+
|
||||
+/ {
|
||||
+ compatible = "bananapi,bpi-r3", "mediatek,mt7986a";
|
||||
+
|
||||
+ fragment@0 {
|
||||
+ target-path = "/soc/mmc@11230000";
|
||||
+ __overlay__ {
|
||||
+ bus-width = <8>;
|
||||
+ max-frequency = <200000000>;
|
||||
+ cap-mmc-highspeed;
|
||||
+ mmc-hs200-1_8v;
|
||||
+ mmc-hs400-1_8v;
|
||||
+ hs400-ds-delay = <0x14014>;
|
||||
+ non-removable;
|
||||
+ no-sd;
|
||||
+ no-sdio;
|
||||
+ status = "okay";
|
||||
+ };
|
||||
+ };
|
||||
+};
|
||||
+
|
||||
--- /dev/null
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-nand.dtso
|
||||
@@ -0,0 +1,55 @@
|
||||
+/* SPDX-License-Identifier: (GPL-2.0-only OR MIT) */
|
||||
+/*
|
||||
+ * Authors: Daniel Golle <daniel@makrotopia.org>
|
||||
+ * Frank Wunderlich <frank-w@public-files.de>
|
||||
+ */
|
||||
+
|
||||
+/dts-v1/;
|
||||
+/plugin/;
|
||||
+
|
||||
+/ {
|
||||
+ compatible = "bananapi,bpi-r3", "mediatek,mt7986a";
|
||||
+
|
||||
+ fragment@0 {
|
||||
+ target-path = "/soc/spi@1100a000";
|
||||
+ __overlay__ {
|
||||
+ #address-cells = <1>;
|
||||
+ #size-cells = <0>;
|
||||
+ spi_nand: spi_nand@0 {
|
||||
+ compatible = "spi-nand";
|
||||
+ reg = <0>;
|
||||
+ spi-max-frequency = <10000000>;
|
||||
+ spi-tx-bus-width = <4>;
|
||||
+ spi-rx-bus-width = <4>;
|
||||
+
|
||||
+ partitions {
|
||||
+ compatible = "fixed-partitions";
|
||||
+ #address-cells = <1>;
|
||||
+ #size-cells = <1>;
|
||||
+
|
||||
+ partition@0 {
|
||||
+ label = "bl2";
|
||||
+ reg = <0x0 0x80000>;
|
||||
+ read-only;
|
||||
+ };
|
||||
+
|
||||
+ partition@80000 {
|
||||
+ label = "reserved";
|
||||
+ reg = <0x80000 0x300000>;
|
||||
+ };
|
||||
+
|
||||
+ partition@380000 {
|
||||
+ label = "fip";
|
||||
+ reg = <0x380000 0x200000>;
|
||||
+ read-only;
|
||||
+ };
|
||||
+
|
||||
+ partition@580000 {
|
||||
+ label = "ubi";
|
||||
+ reg = <0x580000 0x7a80000>;
|
||||
+ };
|
||||
+ };
|
||||
+ };
|
||||
+ };
|
||||
+ };
|
||||
+};
|
||||
--- /dev/null
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-nor.dtso
|
||||
@@ -0,0 +1,68 @@
|
||||
+/* SPDX-License-Identifier: (GPL-2.0-only OR MIT) */
|
||||
+/*
|
||||
+ * Authors: Daniel Golle <daniel@makrotopia.org>
|
||||
+ * Frank Wunderlich <frank-w@public-files.de>
|
||||
+ */
|
||||
+
|
||||
+/dts-v1/;
|
||||
+/plugin/;
|
||||
+
|
||||
+/ {
|
||||
+ compatible = "bananapi,bpi-r3", "mediatek,mt7986a";
|
||||
+
|
||||
+ fragment@0 {
|
||||
+ target-path = "/soc/spi@1100a000";
|
||||
+ __overlay__ {
|
||||
+ #address-cells = <1>;
|
||||
+ #size-cells = <0>;
|
||||
+ flash@0 {
|
||||
+ compatible = "jedec,spi-nor";
|
||||
+ reg = <0>;
|
||||
+ spi-max-frequency = <10000000>;
|
||||
+
|
||||
+ partitions {
|
||||
+ compatible = "fixed-partitions";
|
||||
+ #address-cells = <1>;
|
||||
+ #size-cells = <1>;
|
||||
+
|
||||
+ partition@0 {
|
||||
+ label = "bl2";
|
||||
+ reg = <0x0 0x20000>;
|
||||
+ read-only;
|
||||
+ };
|
||||
+
|
||||
+ partition@20000 {
|
||||
+ label = "reserved";
|
||||
+ reg = <0x20000 0x20000>;
|
||||
+ };
|
||||
+
|
||||
+ partition@40000 {
|
||||
+ label = "u-boot-env";
|
||||
+ reg = <0x40000 0x40000>;
|
||||
+ };
|
||||
+
|
||||
+ partition@80000 {
|
||||
+ label = "reserved2";
|
||||
+ reg = <0x80000 0x80000>;
|
||||
+ };
|
||||
+
|
||||
+ partition@100000 {
|
||||
+ label = "fip";
|
||||
+ reg = <0x100000 0x80000>;
|
||||
+ read-only;
|
||||
+ };
|
||||
+
|
||||
+ partition@180000 {
|
||||
+ label = "recovery";
|
||||
+ reg = <0x180000 0xa80000>;
|
||||
+ };
|
||||
+
|
||||
+ partition@c00000 {
|
||||
+ label = "fit";
|
||||
+ reg = <0xc00000 0x1400000>;
|
||||
+ };
|
||||
+ };
|
||||
+ };
|
||||
+ };
|
||||
+ };
|
||||
+};
|
||||
--- /dev/null
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-sd.dtso
|
||||
@@ -0,0 +1,23 @@
|
||||
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
|
||||
+/*
|
||||
+ * Copyright (C) 2021 MediaTek Inc.
|
||||
+ * Author: Sam.Shih <sam.shih@mediatek.com>
|
||||
+ */
|
||||
+
|
||||
+/dts-v1/;
|
||||
+/plugin/;
|
||||
+
|
||||
+/ {
|
||||
+ compatible = "bananapi,bpi-r3", "mediatek,mt7986a";
|
||||
+
|
||||
+ fragment@0 {
|
||||
+ target-path = "/soc/mmc@11230000";
|
||||
+ __overlay__ {
|
||||
+ bus-width = <4>;
|
||||
+ max-frequency = <52000000>;
|
||||
+ cap-sd-highspeed;
|
||||
+ status = "okay";
|
||||
+ };
|
||||
+ };
|
||||
+};
|
||||
+
|
||||
--- /dev/null
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dts
|
||||
@@ -0,0 +1,450 @@
|
||||
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
|
||||
+/*
|
||||
+ * Copyright (C) 2021 MediaTek Inc.
|
||||
+ * Authors: Sam.Shih <sam.shih@mediatek.com>
|
||||
+ * Frank Wunderlich <frank-w@public-files.de>
|
||||
+ * Daniel Golle <daniel@makrotopia.org>
|
||||
+ */
|
||||
+
|
||||
+/dts-v1/;
|
||||
+#include <dt-bindings/gpio/gpio.h>
|
||||
+#include <dt-bindings/input/input.h>
|
||||
+#include <dt-bindings/leds/common.h>
|
||||
+#include <dt-bindings/pinctrl/mt65xx.h>
|
||||
+
|
||||
+#include "mt7986a.dtsi"
|
||||
+
|
||||
+/ {
|
||||
+ model = "Bananapi BPI-R3";
|
||||
+ compatible = "bananapi,bpi-r3", "mediatek,mt7986a";
|
||||
+
|
||||
+ aliases {
|
||||
+ serial0 = &uart0;
|
||||
+ ethernet0 = &gmac0;
|
||||
+ ethernet1 = &gmac1;
|
||||
+ };
|
||||
+
|
||||
+ chosen {
|
||||
+ stdout-path = "serial0:115200n8";
|
||||
+ };
|
||||
+
|
||||
+ dcin: regulator-12vd {
|
||||
+ compatible = "regulator-fixed";
|
||||
+ regulator-name = "12vd";
|
||||
+ regulator-min-microvolt = <12000000>;
|
||||
+ regulator-max-microvolt = <12000000>;
|
||||
+ regulator-boot-on;
|
||||
+ regulator-always-on;
|
||||
+ };
|
||||
+
|
||||
+ gpio-keys {
|
||||
+ compatible = "gpio-keys";
|
||||
+
|
||||
+ reset-key {
|
||||
+ label = "reset";
|
||||
+ linux,code = <KEY_RESTART>;
|
||||
+ gpios = <&pio 9 GPIO_ACTIVE_LOW>;
|
||||
+ };
|
||||
+
|
||||
+ wps-key {
|
||||
+ label = "wps";
|
||||
+ linux,code = <KEY_WPS_BUTTON>;
|
||||
+ gpios = <&pio 10 GPIO_ACTIVE_LOW>;
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
+ /* i2c of the left SFP cage (wan) */
|
||||
+ i2c_sfp1: i2c-gpio-0 {
|
||||
+ compatible = "i2c-gpio";
|
||||
+ sda-gpios = <&pio 16 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
|
||||
+ scl-gpios = <&pio 17 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
|
||||
+ i2c-gpio,delay-us = <2>;
|
||||
+ #address-cells = <1>;
|
||||
+ #size-cells = <0>;
|
||||
+ };
|
||||
+
|
||||
+ /* i2c of the right SFP cage (lan) */
|
||||
+ i2c_sfp2: i2c-gpio-1 {
|
||||
+ compatible = "i2c-gpio";
|
||||
+ sda-gpios = <&pio 18 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
|
||||
+ scl-gpios = <&pio 19 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
|
||||
+ i2c-gpio,delay-us = <2>;
|
||||
+ #address-cells = <1>;
|
||||
+ #size-cells = <0>;
|
||||
+ };
|
||||
+
|
||||
+ leds {
|
||||
+ compatible = "gpio-leds";
|
||||
+
|
||||
+ green_led: led-0 {
|
||||
+ color = <LED_COLOR_ID_GREEN>;
|
||||
+ function = LED_FUNCTION_POWER;
|
||||
+ gpios = <&pio 69 GPIO_ACTIVE_HIGH>;
|
||||
+ default-state = "on";
|
||||
+ };
|
||||
+
|
||||
+ blue_led: led-1 {
|
||||
+ color = <LED_COLOR_ID_BLUE>;
|
||||
+ function = LED_FUNCTION_STATUS;
|
||||
+ gpios = <&pio 86 GPIO_ACTIVE_HIGH>;
|
||||
+ default-state = "off";
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
+ reg_1p8v: regulator-1p8v {
|
||||
+ compatible = "regulator-fixed";
|
||||
+ regulator-name = "1.8vd";
|
||||
+ regulator-min-microvolt = <1800000>;
|
||||
+ regulator-max-microvolt = <1800000>;
|
||||
+ regulator-boot-on;
|
||||
+ regulator-always-on;
|
||||
+ vin-supply = <&dcin>;
|
||||
+ };
|
||||
+
|
||||
+ reg_3p3v: regulator-3p3v {
|
||||
+ compatible = "regulator-fixed";
|
||||
+ regulator-name = "3.3vd";
|
||||
+ regulator-min-microvolt = <3300000>;
|
||||
+ regulator-max-microvolt = <3300000>;
|
||||
+ regulator-boot-on;
|
||||
+ regulator-always-on;
|
||||
+ vin-supply = <&dcin>;
|
||||
+ };
|
||||
+
|
||||
+ /* left SFP cage (wan) */
|
||||
+ sfp1: sfp-1 {
|
||||
+ compatible = "sff,sfp";
|
||||
+ i2c-bus = <&i2c_sfp1>;
|
||||
+ los-gpios = <&pio 46 GPIO_ACTIVE_HIGH>;
|
||||
+ mod-def0-gpios = <&pio 49 GPIO_ACTIVE_LOW>;
|
||||
+ tx-disable-gpios = <&pio 20 GPIO_ACTIVE_HIGH>;
|
||||
+ tx-fault-gpios = <&pio 7 GPIO_ACTIVE_HIGH>;
|
||||
+ };
|
||||
+
|
||||
+ /* right SFP cage (lan) */
|
||||
+ sfp2: sfp-2 {
|
||||
+ compatible = "sff,sfp";
|
||||
+ i2c-bus = <&i2c_sfp2>;
|
||||
+ los-gpios = <&pio 31 GPIO_ACTIVE_HIGH>;
|
||||
+ mod-def0-gpios = <&pio 47 GPIO_ACTIVE_LOW>;
|
||||
+ tx-disable-gpios = <&pio 15 GPIO_ACTIVE_HIGH>;
|
||||
+ tx-fault-gpios = <&pio 48 GPIO_ACTIVE_HIGH>;
|
||||
+ };
|
||||
+};
|
||||
+
|
||||
+&crypto {
|
||||
+ status = "okay";
|
||||
+};
|
||||
+
|
||||
+ð {
|
||||
+ status = "okay";
|
||||
+
|
||||
+ gmac0: mac@0 {
|
||||
+ compatible = "mediatek,eth-mac";
|
||||
+ reg = <0>;
|
||||
+ phy-mode = "2500base-x";
|
||||
+
|
||||
+ fixed-link {
|
||||
+ speed = <2500>;
|
||||
+ full-duplex;
|
||||
+ pause;
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
+ gmac1: mac@1 {
|
||||
+ compatible = "mediatek,eth-mac";
|
||||
+ reg = <1>;
|
||||
+ phy-mode = "2500base-x";
|
||||
+ sfp = <&sfp1>;
|
||||
+ managed = "in-band-status";
|
||||
+ };
|
||||
+
|
||||
+ mdio: mdio-bus {
|
||||
+ #address-cells = <1>;
|
||||
+ #size-cells = <0>;
|
||||
+ };
|
||||
+};
|
||||
+
|
||||
+&mdio {
|
||||
+ switch: switch@1f {
|
||||
+ compatible = "mediatek,mt7531";
|
||||
+ reg = <31>;
|
||||
+ interrupt-controller;
|
||||
+ #interrupt-cells = <1>;
|
||||
+ interrupt-parent = <&pio>;
|
||||
+ interrupts = <66 IRQ_TYPE_LEVEL_HIGH>;
|
||||
+ reset-gpios = <&pio 5 GPIO_ACTIVE_HIGH>;
|
||||
+ };
|
||||
+};
|
||||
+
|
||||
+&mmc0 {
|
||||
+ pinctrl-names = "default", "state_uhs";
|
||||
+ pinctrl-0 = <&mmc0_pins_default>;
|
||||
+ pinctrl-1 = <&mmc0_pins_uhs>;
|
||||
+ vmmc-supply = <®_3p3v>;
|
||||
+ vqmmc-supply = <®_1p8v>;
|
||||
+};
|
||||
+
|
||||
+&i2c0 {
|
||||
+ pinctrl-names = "default";
|
||||
+ pinctrl-0 = <&i2c_pins>;
|
||||
+ status = "okay";
|
||||
+};
|
||||
+
|
||||
+&pcie {
|
||||
+ pinctrl-names = "default";
|
||||
+ pinctrl-0 = <&pcie_pins>;
|
||||
+ status = "okay";
|
||||
+};
|
||||
+
|
||||
+&pcie_phy {
|
||||
+ status = "okay";
|
||||
+};
|
||||
+
|
||||
+&pio {
|
||||
+ i2c_pins: i2c-pins {
|
||||
+ mux {
|
||||
+ function = "i2c";
|
||||
+ groups = "i2c";
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
+ mmc0_pins_default: mmc0-pins {
|
||||
+ mux {
|
||||
+ function = "emmc";
|
||||
+ groups = "emmc_51";
|
||||
+ };
|
||||
+ conf-cmd-dat {
|
||||
+ pins = "EMMC_DATA_0", "EMMC_DATA_1", "EMMC_DATA_2",
|
||||
+ "EMMC_DATA_3", "EMMC_DATA_4", "EMMC_DATA_5",
|
||||
+ "EMMC_DATA_6", "EMMC_DATA_7", "EMMC_CMD";
|
||||
+ input-enable;
|
||||
+ drive-strength = <4>;
|
||||
+ bias-pull-up = <MTK_PUPD_SET_R1R0_01>; /* pull-up 10K */
|
||||
+ };
|
||||
+ conf-clk {
|
||||
+ pins = "EMMC_CK";
|
||||
+ drive-strength = <6>;
|
||||
+ bias-pull-down = <MTK_PUPD_SET_R1R0_10>; /* pull-down 50K */
|
||||
+ };
|
||||
+ conf-ds {
|
||||
+ pins = "EMMC_DSL";
|
||||
+ bias-pull-down = <MTK_PUPD_SET_R1R0_10>; /* pull-down 50K */
|
||||
+ };
|
||||
+ conf-rst {
|
||||
+ pins = "EMMC_RSTB";
|
||||
+ drive-strength = <4>;
|
||||
+ bias-pull-up = <MTK_PUPD_SET_R1R0_01>; /* pull-up 10K */
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
+ mmc0_pins_uhs: mmc0-uhs-pins {
|
||||
+ mux {
|
||||
+ function = "emmc";
|
||||
+ groups = "emmc_51";
|
||||
+ };
|
||||
+ conf-cmd-dat {
|
||||
+ pins = "EMMC_DATA_0", "EMMC_DATA_1", "EMMC_DATA_2",
|
||||
+ "EMMC_DATA_3", "EMMC_DATA_4", "EMMC_DATA_5",
|
||||
+ "EMMC_DATA_6", "EMMC_DATA_7", "EMMC_CMD";
|
||||
+ input-enable;
|
||||
+ drive-strength = <4>;
|
||||
+ bias-pull-up = <MTK_PUPD_SET_R1R0_01>; /* pull-up 10K */
|
||||
+ };
|
||||
+ conf-clk {
|
||||
+ pins = "EMMC_CK";
|
||||
+ drive-strength = <6>;
|
||||
+ bias-pull-down = <MTK_PUPD_SET_R1R0_10>; /* pull-down 50K */
|
||||
+ };
|
||||
+ conf-ds {
|
||||
+ pins = "EMMC_DSL";
|
||||
+ bias-pull-down = <MTK_PUPD_SET_R1R0_10>; /* pull-down 50K */
|
||||
+ };
|
||||
+ conf-rst {
|
||||
+ pins = "EMMC_RSTB";
|
||||
+ drive-strength = <4>;
|
||||
+ bias-pull-up = <MTK_PUPD_SET_R1R0_01>; /* pull-up 10K */
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
+ pcie_pins: pcie-pins {
|
||||
+ mux {
|
||||
+ function = "pcie";
|
||||
+ groups = "pcie_clk", "pcie_pereset";
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
+ spi_flash_pins: spi-flash-pins {
|
||||
+ mux {
|
||||
+ function = "spi";
|
||||
+ groups = "spi0", "spi0_wp_hold";
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
+ spic_pins: spic-pins {
|
||||
+ mux {
|
||||
+ function = "spi";
|
||||
+ groups = "spi1_0";
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
+ uart1_pins: uart1-pins {
|
||||
+ mux {
|
||||
+ function = "uart";
|
||||
+ groups = "uart1_rx_tx";
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
+ uart2_pins: uart2-pins {
|
||||
+ mux {
|
||||
+ function = "uart";
|
||||
+ groups = "uart2_0_rx_tx";
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
+ wf_2g_5g_pins: wf-2g-5g-pins {
|
||||
+ mux {
|
||||
+ function = "wifi";
|
||||
+ groups = "wf_2g", "wf_5g";
|
||||
+ };
|
||||
+ conf {
|
||||
+ pins = "WF0_HB1", "WF0_HB2", "WF0_HB3", "WF0_HB4",
|
||||
+ "WF0_HB0", "WF0_HB0_B", "WF0_HB5", "WF0_HB6",
|
||||
+ "WF0_HB7", "WF0_HB8", "WF0_HB9", "WF0_HB10",
|
||||
+ "WF0_TOP_CLK", "WF0_TOP_DATA", "WF1_HB1",
|
||||
+ "WF1_HB2", "WF1_HB3", "WF1_HB4", "WF1_HB0",
|
||||
+ "WF1_HB5", "WF1_HB6", "WF1_HB7", "WF1_HB8",
|
||||
+ "WF1_TOP_CLK", "WF1_TOP_DATA";
|
||||
+ drive-strength = <4>;
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
+ wf_dbdc_pins: wf-dbdc-pins {
|
||||
+ mux {
|
||||
+ function = "wifi";
|
||||
+ groups = "wf_dbdc";
|
||||
+ };
|
||||
+ conf {
|
||||
+ pins = "WF0_HB1", "WF0_HB2", "WF0_HB3", "WF0_HB4",
|
||||
+ "WF0_HB0", "WF0_HB0_B", "WF0_HB5", "WF0_HB6",
|
||||
+ "WF0_HB7", "WF0_HB8", "WF0_HB9", "WF0_HB10",
|
||||
+ "WF0_TOP_CLK", "WF0_TOP_DATA", "WF1_HB1",
|
||||
+ "WF1_HB2", "WF1_HB3", "WF1_HB4", "WF1_HB0",
|
||||
+ "WF1_HB5", "WF1_HB6", "WF1_HB7", "WF1_HB8",
|
||||
+ "WF1_TOP_CLK", "WF1_TOP_DATA";
|
||||
+ drive-strength = <4>;
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
+ wf_led_pins: wf-led-pins {
|
||||
+ mux {
|
||||
+ function = "led";
|
||||
+ groups = "wifi_led";
|
||||
+ };
|
||||
+ };
|
||||
+};
|
||||
+
|
||||
+&spi0 {
|
||||
+ pinctrl-names = "default";
|
||||
+ pinctrl-0 = <&spi_flash_pins>;
|
||||
+ status = "okay";
|
||||
+};
|
||||
+
|
||||
+&spi1 {
|
||||
+ pinctrl-names = "default";
|
||||
+ pinctrl-0 = <&spic_pins>;
|
||||
+ status = "okay";
|
||||
+};
|
||||
+
|
||||
+&ssusb {
|
||||
+ status = "okay";
|
||||
+};
|
||||
+
|
||||
+&switch {
|
||||
+ ports {
|
||||
+ #address-cells = <1>;
|
||||
+ #size-cells = <0>;
|
||||
+
|
||||
+ port@0 {
|
||||
+ reg = <0>;
|
||||
+ label = "wan";
|
||||
+ };
|
||||
+
|
||||
+ port@1 {
|
||||
+ reg = <1>;
|
||||
+ label = "lan0";
|
||||
+ };
|
||||
+
|
||||
+ port@2 {
|
||||
+ reg = <2>;
|
||||
+ label = "lan1";
|
||||
+ };
|
||||
+
|
||||
+ port@3 {
|
||||
+ reg = <3>;
|
||||
+ label = "lan2";
|
||||
+ };
|
||||
+
|
||||
+ port@4 {
|
||||
+ reg = <4>;
|
||||
+ label = "lan3";
|
||||
+ };
|
||||
+
|
||||
+ port5: port@5 {
|
||||
+ reg = <5>;
|
||||
+ label = "lan4";
|
||||
+ phy-mode = "2500base-x";
|
||||
+ sfp = <&sfp2>;
|
||||
+ managed = "in-band-status";
|
||||
+ };
|
||||
+
|
||||
+ port@6 {
|
||||
+ reg = <6>;
|
||||
+ label = "cpu";
|
||||
+ ethernet = <&gmac0>;
|
||||
+ phy-mode = "2500base-x";
|
||||
+
|
||||
+ fixed-link {
|
||||
+ speed = <2500>;
|
||||
+ full-duplex;
|
||||
+ pause;
|
||||
+ };
|
||||
+ };
|
||||
+ };
|
||||
+};
|
||||
+
|
||||
+&trng {
|
||||
+ status = "okay";
|
||||
+};
|
||||
+
|
||||
+&uart0 {
|
||||
+ status = "okay";
|
||||
+};
|
||||
+
|
||||
+&uart1 {
|
||||
+ pinctrl-names = "default";
|
||||
+ pinctrl-0 = <&uart1_pins>;
|
||||
+ status = "okay";
|
||||
+};
|
||||
+
|
||||
+&uart2 {
|
||||
+ pinctrl-names = "default";
|
||||
+ pinctrl-0 = <&uart2_pins>;
|
||||
+ status = "okay";
|
||||
+};
|
||||
+
|
||||
+&usb_phy {
|
||||
+ status = "okay";
|
||||
+};
|
||||
+
|
||||
+&watchdog {
|
||||
+ status = "okay";
|
||||
+};
|
||||
+
|
||||
+&wifi {
|
||||
+ status = "okay";
|
||||
+ pinctrl-names = "default", "dbdc";
|
||||
+ pinctrl-0 = <&wf_2g_5g_pins>, <&wf_led_pins>;
|
||||
+ pinctrl-1 = <&wf_dbdc_pins>, <&wf_led_pins>;
|
||||
+};
|
||||
+
|
@ -1,323 +0,0 @@
|
||||
From 4c2d5411f4b101f7aa0fd74f80109e3afd6dc967 Mon Sep 17 00:00:00 2001
|
||||
From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Date: Wed, 17 May 2023 12:11:08 +0200
|
||||
Subject: [PATCH 11/19] arm64: mediatek: Propagate chassis-type where possible
|
||||
|
||||
The chassis-type string identifies the form-factor of the system:
|
||||
add this property to all device trees of devices for which the form
|
||||
factor is known.
|
||||
|
||||
Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Link: https://lore.kernel.org/r/20230517101108.205654-1-angelogioacchino.delregno@collabora.com
|
||||
Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
|
||||
---
|
||||
arch/arm64/boot/dts/mediatek/mt2712-evb.dts | 1 +
|
||||
arch/arm64/boot/dts/mediatek/mt6755-evb.dts | 1 +
|
||||
arch/arm64/boot/dts/mediatek/mt6779-evb.dts | 1 +
|
||||
arch/arm64/boot/dts/mediatek/mt6795-evb.dts | 1 +
|
||||
arch/arm64/boot/dts/mediatek/mt6797-evb.dts | 1 +
|
||||
arch/arm64/boot/dts/mediatek/mt6797-x20-dev.dts | 1 +
|
||||
arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts | 1 +
|
||||
arch/arm64/boot/dts/mediatek/mt7622-rfb1.dts | 1 +
|
||||
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dts | 1 +
|
||||
arch/arm64/boot/dts/mediatek/mt7986a-rfb.dts | 1 +
|
||||
arch/arm64/boot/dts/mediatek/mt7986b-rfb.dts | 1 +
|
||||
arch/arm64/boot/dts/mediatek/mt8167-pumpkin.dts | 1 +
|
||||
arch/arm64/boot/dts/mediatek/mt8173-elm-hana-rev7.dts | 1 +
|
||||
arch/arm64/boot/dts/mediatek/mt8173-elm-hana.dts | 1 +
|
||||
arch/arm64/boot/dts/mediatek/mt8173-elm.dts | 1 +
|
||||
arch/arm64/boot/dts/mediatek/mt8173-evb.dts | 1 +
|
||||
arch/arm64/boot/dts/mediatek/mt8183-evb.dts | 1 +
|
||||
arch/arm64/boot/dts/mediatek/mt8183-kukui-jacuzzi-burnet.dts | 1 +
|
||||
arch/arm64/boot/dts/mediatek/mt8183-kukui-jacuzzi-damu.dts | 1 +
|
||||
.../boot/dts/mediatek/mt8183-kukui-jacuzzi-juniper-sku16.dts | 1 +
|
||||
arch/arm64/boot/dts/mediatek/mt8183-kukui-kakadu-sku22.dts | 1 +
|
||||
arch/arm64/boot/dts/mediatek/mt8183-kukui-kakadu.dts | 1 +
|
||||
arch/arm64/boot/dts/mediatek/mt8183-kukui-kodama-sku16.dts | 1 +
|
||||
arch/arm64/boot/dts/mediatek/mt8183-kukui-kodama-sku272.dts | 1 +
|
||||
arch/arm64/boot/dts/mediatek/mt8183-kukui-kodama-sku288.dts | 1 +
|
||||
arch/arm64/boot/dts/mediatek/mt8183-kukui-krane-sku0.dts | 1 +
|
||||
arch/arm64/boot/dts/mediatek/mt8183-kukui-krane-sku176.dts | 1 +
|
||||
arch/arm64/boot/dts/mediatek/mt8186-evb.dts | 1 +
|
||||
28 files changed, 28 insertions(+)
|
||||
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt2712-evb.dts
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt2712-evb.dts
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
/ {
|
||||
model = "MediaTek MT2712 evaluation board";
|
||||
+ chassis-type = "embedded";
|
||||
compatible = "mediatek,mt2712-evb", "mediatek,mt2712";
|
||||
|
||||
aliases {
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt6755-evb.dts
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt6755-evb.dts
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
/ {
|
||||
model = "MediaTek MT6755 EVB";
|
||||
+ chassis-type = "embedded";
|
||||
compatible = "mediatek,mt6755-evb", "mediatek,mt6755";
|
||||
|
||||
aliases {
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt6779-evb.dts
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt6779-evb.dts
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
/ {
|
||||
model = "MediaTek MT6779 EVB";
|
||||
+ chassis-type = "embedded";
|
||||
compatible = "mediatek,mt6779-evb", "mediatek,mt6779";
|
||||
|
||||
aliases {
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt6795-evb.dts
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt6795-evb.dts
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
/ {
|
||||
model = "MediaTek MT6795 Evaluation Board";
|
||||
+ chassis-type = "embedded";
|
||||
compatible = "mediatek,mt6795-evb", "mediatek,mt6795";
|
||||
|
||||
aliases {
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt6797-evb.dts
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt6797-evb.dts
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
/ {
|
||||
model = "MediaTek MT6797 Evaluation Board";
|
||||
+ chassis-type = "embedded";
|
||||
compatible = "mediatek,mt6797-evb", "mediatek,mt6797";
|
||||
|
||||
aliases {
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt6797-x20-dev.dts
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt6797-x20-dev.dts
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
/ {
|
||||
model = "Mediatek X20 Development Board";
|
||||
+ chassis-type = "embedded";
|
||||
compatible = "archermind,mt6797-x20-dev", "mediatek,mt6797";
|
||||
|
||||
aliases {
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
/ {
|
||||
model = "Bananapi BPI-R64";
|
||||
+ chassis-type = "embedded";
|
||||
compatible = "bananapi,bpi-r64", "mediatek,mt7622";
|
||||
|
||||
aliases {
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt7622-rfb1.dts
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt7622-rfb1.dts
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
/ {
|
||||
model = "MediaTek MT7622 RFB1 board";
|
||||
+ chassis-type = "embedded";
|
||||
compatible = "mediatek,mt7622-rfb1", "mediatek,mt7622";
|
||||
|
||||
aliases {
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dts
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dts
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
/ {
|
||||
model = "Bananapi BPI-R3";
|
||||
+ chassis-type = "embedded";
|
||||
compatible = "bananapi,bpi-r3", "mediatek,mt7986a";
|
||||
|
||||
aliases {
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt7986a-rfb.dts
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt7986a-rfb.dts
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
/ {
|
||||
model = "MediaTek MT7986a RFB";
|
||||
+ chassis-type = "embedded";
|
||||
compatible = "mediatek,mt7986a-rfb", "mediatek,mt7986a";
|
||||
|
||||
aliases {
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt7986b-rfb.dts
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt7986b-rfb.dts
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
/ {
|
||||
model = "MediaTek MT7986b RFB";
|
||||
+ chassis-type = "embedded";
|
||||
compatible = "mediatek,mt7986b-rfb", "mediatek,mt7986b";
|
||||
|
||||
aliases {
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt8167-pumpkin.dts
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt8167-pumpkin.dts
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
/ {
|
||||
model = "Pumpkin MT8167";
|
||||
+ chassis-type = "embedded";
|
||||
compatible = "mediatek,mt8167-pumpkin", "mediatek,mt8167";
|
||||
|
||||
memory@40000000 {
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt8173-elm-hana-rev7.dts
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt8173-elm-hana-rev7.dts
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
/ {
|
||||
model = "Google Hanawl";
|
||||
+ chassis-type = "laptop";
|
||||
compatible = "google,hana-rev7", "mediatek,mt8173";
|
||||
};
|
||||
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt8173-elm-hana.dts
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt8173-elm-hana.dts
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
/ {
|
||||
model = "Google Hana";
|
||||
+ chassis-type = "laptop";
|
||||
compatible = "google,hana-rev6", "google,hana-rev5",
|
||||
"google,hana-rev4", "google,hana-rev3",
|
||||
"google,hana", "mediatek,mt8173";
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt8173-elm.dts
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt8173-elm.dts
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
/ {
|
||||
model = "Google Elm";
|
||||
+ chassis-type = "laptop";
|
||||
compatible = "google,elm-rev8", "google,elm-rev7", "google,elm-rev6",
|
||||
"google,elm-rev5", "google,elm-rev4", "google,elm-rev3",
|
||||
"google,elm", "mediatek,mt8173";
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt8173-evb.dts
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt8173-evb.dts
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
/ {
|
||||
model = "MediaTek MT8173 evaluation board";
|
||||
+ chassis-type = "embedded";
|
||||
compatible = "mediatek,mt8173-evb", "mediatek,mt8173";
|
||||
|
||||
aliases {
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt8183-evb.dts
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt8183-evb.dts
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
/ {
|
||||
model = "MediaTek MT8183 evaluation board";
|
||||
+ chassis-type = "embedded";
|
||||
compatible = "mediatek,mt8183-evb", "mediatek,mt8183";
|
||||
|
||||
aliases {
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt8183-kukui-jacuzzi-burnet.dts
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt8183-kukui-jacuzzi-burnet.dts
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
/ {
|
||||
model = "Google burnet board";
|
||||
+ chassis-type = "convertible";
|
||||
compatible = "google,burnet", "mediatek,mt8183";
|
||||
};
|
||||
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt8183-kukui-jacuzzi-damu.dts
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt8183-kukui-jacuzzi-damu.dts
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
/ {
|
||||
model = "Google damu board";
|
||||
+ chassis-type = "convertible";
|
||||
compatible = "google,damu", "mediatek,mt8183";
|
||||
};
|
||||
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt8183-kukui-jacuzzi-juniper-sku16.dts
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt8183-kukui-jacuzzi-juniper-sku16.dts
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
/ {
|
||||
model = "Google juniper sku16 board";
|
||||
+ chassis-type = "convertible";
|
||||
compatible = "google,juniper-sku16", "google,juniper", "mediatek,mt8183";
|
||||
};
|
||||
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt8183-kukui-kakadu-sku22.dts
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt8183-kukui-kakadu-sku22.dts
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
/ {
|
||||
model = "MediaTek kakadu board sku22";
|
||||
+ chassis-type = "tablet";
|
||||
compatible = "google,kakadu-rev3-sku22", "google,kakadu-rev2-sku22",
|
||||
"google,kakadu", "mediatek,mt8183";
|
||||
};
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt8183-kukui-kakadu.dts
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt8183-kukui-kakadu.dts
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
/ {
|
||||
model = "MediaTek kakadu board";
|
||||
+ chassis-type = "tablet";
|
||||
compatible = "google,kakadu-rev3", "google,kakadu-rev2",
|
||||
"google,kakadu", "mediatek,mt8183";
|
||||
};
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt8183-kukui-kodama-sku16.dts
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt8183-kukui-kodama-sku16.dts
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
/ {
|
||||
model = "MediaTek kodama sku16 board";
|
||||
+ chassis-type = "tablet";
|
||||
compatible = "google,kodama-sku16", "google,kodama", "mediatek,mt8183";
|
||||
};
|
||||
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt8183-kukui-kodama-sku272.dts
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt8183-kukui-kodama-sku272.dts
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
/ {
|
||||
model = "MediaTek kodama sku272 board";
|
||||
+ chassis-type = "tablet";
|
||||
compatible = "google,kodama-sku272", "google,kodama", "mediatek,mt8183";
|
||||
};
|
||||
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt8183-kukui-kodama-sku288.dts
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt8183-kukui-kodama-sku288.dts
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
/ {
|
||||
model = "MediaTek kodama sku288 board";
|
||||
+ chassis-type = "tablet";
|
||||
compatible = "google,kodama-sku288", "google,kodama", "mediatek,mt8183";
|
||||
};
|
||||
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt8183-kukui-krane-sku0.dts
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt8183-kukui-krane-sku0.dts
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
/ {
|
||||
model = "MediaTek krane sku0 board";
|
||||
+ chassis-type = "tablet";
|
||||
compatible = "google,krane-sku0", "google,krane", "mediatek,mt8183";
|
||||
};
|
||||
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt8183-kukui-krane-sku176.dts
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt8183-kukui-krane-sku176.dts
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
/ {
|
||||
model = "MediaTek krane sku176 board";
|
||||
+ chassis-type = "tablet";
|
||||
compatible = "google,krane-sku176", "google,krane", "mediatek,mt8183";
|
||||
};
|
||||
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt8186-evb.dts
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt8186-evb.dts
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
/ {
|
||||
model = "MediaTek MT8186 evaluation board";
|
||||
+ chassis-type = "embedded";
|
||||
compatible = "mediatek,mt8186-evb", "mediatek,mt8186";
|
||||
|
||||
aliases {
|
@ -1,38 +0,0 @@
|
||||
From 3b92c547e3d4a35c6214b3e7fa1103d0749d83b1 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Fri, 21 Apr 2023 15:20:44 +0200
|
||||
Subject: [PATCH 12/19] arm64: dts: mt7986: add PWM
|
||||
|
||||
This adds pwm node to mt7986.
|
||||
|
||||
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
|
||||
Link: https://lore.kernel.org/r/20230421132047.42166-5-linux@fw-web.de
|
||||
Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
|
||||
---
|
||||
arch/arm64/boot/dts/mediatek/mt7986a.dtsi | 14 ++++++++++++++
|
||||
1 file changed, 14 insertions(+)
|
||||
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt7986a.dtsi
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt7986a.dtsi
|
||||
@@ -240,6 +240,20 @@
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
+ pwm: pwm@10048000 {
|
||||
+ compatible = "mediatek,mt7986-pwm";
|
||||
+ reg = <0 0x10048000 0 0x1000>;
|
||||
+ #clock-cells = <1>;
|
||||
+ #pwm-cells = <2>;
|
||||
+ interrupts = <GIC_SPI 137 IRQ_TYPE_LEVEL_HIGH>;
|
||||
+ clocks = <&topckgen CLK_TOP_PWM_SEL>,
|
||||
+ <&infracfg CLK_INFRA_PWM_STA>,
|
||||
+ <&infracfg CLK_INFRA_PWM1_CK>,
|
||||
+ <&infracfg CLK_INFRA_PWM2_CK>;
|
||||
+ clock-names = "top", "main", "pwm1", "pwm2";
|
||||
+ status = "disabled";
|
||||
+ };
|
||||
+
|
||||
uart0: serial@11002000 {
|
||||
compatible = "mediatek,mt7986-uart",
|
||||
"mediatek,mt6577-uart";
|
@ -1,43 +0,0 @@
|
||||
From 35e482bb599df010b4869017ff576dbb7a4d4c2e Mon Sep 17 00:00:00 2001
|
||||
From: Frank Wunderlich <frank-w@public-files.de>
|
||||
Date: Fri, 21 Apr 2023 15:20:45 +0200
|
||||
Subject: [PATCH 13/19] arm64: dts: mt7986: add PWM to BPI-R3
|
||||
|
||||
Add pwm node and pinctrl to BananaPi R3 devicetree.
|
||||
|
||||
Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
|
||||
Link: https://lore.kernel.org/r/20230421132047.42166-6-linux@fw-web.de
|
||||
Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
|
||||
---
|
||||
.../boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dts | 13 +++++++++++++
|
||||
1 file changed, 13 insertions(+)
|
||||
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dts
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dts
|
||||
@@ -275,6 +275,13 @@
|
||||
};
|
||||
};
|
||||
|
||||
+ pwm_pins: pwm-pins {
|
||||
+ mux {
|
||||
+ function = "pwm";
|
||||
+ groups = "pwm0", "pwm1_0";
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
spi_flash_pins: spi-flash-pins {
|
||||
mux {
|
||||
function = "spi";
|
||||
@@ -345,6 +352,12 @@
|
||||
};
|
||||
};
|
||||
|
||||
+&pwm {
|
||||
+ pinctrl-names = "default";
|
||||
+ pinctrl-0 = <&pwm_pins>;
|
||||
+ status = "okay";
|
||||
+};
|
||||
+
|
||||
&spi0 {
|
||||
pinctrl-names = "default";
|
||||
pinctrl-0 = <&spi_flash_pins>;
|
@ -1,27 +0,0 @@
|
||||
From ccdda5714446db8690505371442f7807f5d7c6fc Mon Sep 17 00:00:00 2001
|
||||
From: Frank Wunderlich <frank-w@public-files.de>
|
||||
Date: Sun, 5 Feb 2023 18:48:33 +0100
|
||||
Subject: [PATCH 14/19] arm64: dts: mt7986: set Wifi Leds low-active for BPI-R3
|
||||
|
||||
Leds for Wifi are low-active, so add property to devicetree.
|
||||
|
||||
Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Link: https://lore.kernel.org/r/20230205174833.107050-1-linux@fw-web.de
|
||||
Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
|
||||
---
|
||||
arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dts | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dts
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dts
|
||||
@@ -460,5 +460,9 @@
|
||||
pinctrl-names = "default", "dbdc";
|
||||
pinctrl-0 = <&wf_2g_5g_pins>, <&wf_led_pins>;
|
||||
pinctrl-1 = <&wf_dbdc_pins>, <&wf_led_pins>;
|
||||
+
|
||||
+ led {
|
||||
+ led-active-low;
|
||||
+ };
|
||||
};
|
||||
|
@ -1,46 +0,0 @@
|
||||
From 1423b4b780adcf3994e63a5988a62d5d1d509bb1 Mon Sep 17 00:00:00 2001
|
||||
From: Frank Wunderlich <frank-w@public-files.de>
|
||||
Date: Sun, 28 May 2023 13:33:42 +0200
|
||||
Subject: [PATCH 15/19] arm64: dts: mt7986: use size of reserved partition for
|
||||
bl2
|
||||
|
||||
To store uncompressed bl2 more space is required than partition is
|
||||
actually defined.
|
||||
|
||||
There is currently no known usage of this reserved partition.
|
||||
Openwrt uses same partition layout.
|
||||
|
||||
We added same change to u-boot with commit d7bb1099 [1].
|
||||
|
||||
[1] https://source.denx.de/u-boot/u-boot/-/commit/d7bb109900c1ca754a0198b9afb50e3161ffc21e
|
||||
|
||||
Cc: stable@vger.kernel.org
|
||||
Fixes: 8e01fb15b815 ("arm64: dts: mt7986: add Bananapi R3")
|
||||
Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Reviewed-by: Daniel Golle <daniel@makrotopia.org>
|
||||
Link: https://lore.kernel.org/r/20230528113343.7649-1-linux@fw-web.de
|
||||
Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
|
||||
---
|
||||
.../boot/dts/mediatek/mt7986a-bananapi-bpi-r3-nor.dtso | 7 +------
|
||||
1 file changed, 1 insertion(+), 6 deletions(-)
|
||||
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-nor.dtso
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-nor.dtso
|
||||
@@ -27,15 +27,10 @@
|
||||
|
||||
partition@0 {
|
||||
label = "bl2";
|
||||
- reg = <0x0 0x20000>;
|
||||
+ reg = <0x0 0x40000>;
|
||||
read-only;
|
||||
};
|
||||
|
||||
- partition@20000 {
|
||||
- label = "reserved";
|
||||
- reg = <0x20000 0x20000>;
|
||||
- };
|
||||
-
|
||||
partition@40000 {
|
||||
label = "u-boot-env";
|
||||
reg = <0x40000 0x40000>;
|
@ -1,80 +0,0 @@
|
||||
From 40a5a767d698ef7a71f8be851ea18b0a7a8b47bd Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Tue, 30 May 2023 22:12:33 +0200
|
||||
Subject: [PATCH 16/19] arm64: dts: mt7986: add thermal and efuse
|
||||
|
||||
Add thermal related nodes to mt7986 devicetree.
|
||||
|
||||
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Link: https://lore.kernel.org/r/20230530201235.22330-3-linux@fw-web.de
|
||||
Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
|
||||
---
|
||||
arch/arm64/boot/dts/mediatek/mt7986a.dtsi | 36 ++++++++++++++++++++++-
|
||||
1 file changed, 35 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt7986a.dtsi
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt7986a.dtsi
|
||||
@@ -337,6 +337,15 @@
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
+ auxadc: adc@1100d000 {
|
||||
+ compatible = "mediatek,mt7986-auxadc";
|
||||
+ reg = <0 0x1100d000 0 0x1000>;
|
||||
+ clocks = <&infracfg CLK_INFRA_ADC_26M_CK>;
|
||||
+ clock-names = "main";
|
||||
+ #io-channel-cells = <1>;
|
||||
+ status = "disabled";
|
||||
+ };
|
||||
+
|
||||
ssusb: usb@11200000 {
|
||||
compatible = "mediatek,mt7986-xhci",
|
||||
"mediatek,mtk-xhci";
|
||||
@@ -375,6 +384,21 @@
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
+ thermal: thermal@1100c800 {
|
||||
+ #thermal-sensor-cells = <1>;
|
||||
+ compatible = "mediatek,mt7986-thermal";
|
||||
+ reg = <0 0x1100c800 0 0x800>;
|
||||
+ interrupts = <GIC_SPI 138 IRQ_TYPE_LEVEL_HIGH>;
|
||||
+ clocks = <&infracfg CLK_INFRA_THERM_CK>,
|
||||
+ <&infracfg CLK_INFRA_ADC_26M_CK>,
|
||||
+ <&infracfg CLK_INFRA_ADC_FRC_CK>;
|
||||
+ clock-names = "therm", "auxadc", "adc_32k";
|
||||
+ mediatek,auxadc = <&auxadc>;
|
||||
+ mediatek,apmixedsys = <&apmixedsys>;
|
||||
+ nvmem-cells = <&thermal_calibration>;
|
||||
+ nvmem-cell-names = "calibration-data";
|
||||
+ };
|
||||
+
|
||||
pcie: pcie@11280000 {
|
||||
compatible = "mediatek,mt7986-pcie",
|
||||
"mediatek,mt8192-pcie";
|
||||
@@ -426,6 +450,17 @@
|
||||
};
|
||||
};
|
||||
|
||||
+ efuse: efuse@11d00000 {
|
||||
+ compatible = "mediatek,mt7986-efuse", "mediatek,efuse";
|
||||
+ reg = <0 0x11d00000 0 0x1000>;
|
||||
+ #address-cells = <1>;
|
||||
+ #size-cells = <1>;
|
||||
+
|
||||
+ thermal_calibration: calib@274 {
|
||||
+ reg = <0x274 0xc>;
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
usb_phy: t-phy@11e10000 {
|
||||
compatible = "mediatek,mt7986-tphy",
|
||||
"mediatek,generic-tphy-v2";
|
||||
@@ -567,5 +602,4 @@
|
||||
memory-region = <&wmcpu_emi>;
|
||||
};
|
||||
};
|
||||
-
|
||||
};
|
@ -1,51 +0,0 @@
|
||||
From bb78d0cf5117517f1ed296ae71048945d9107675 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Tue, 30 May 2023 22:12:34 +0200
|
||||
Subject: [PATCH 17/19] arm64: dts: mt7986: add thermal-zones
|
||||
|
||||
Add thermal-zones to mt7986 devicetree.
|
||||
|
||||
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Link: https://lore.kernel.org/r/20230530201235.22330-4-linux@fw-web.de
|
||||
Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
|
||||
---
|
||||
arch/arm64/boot/dts/mediatek/mt7986a.dtsi | 28 +++++++++++++++++++++++
|
||||
1 file changed, 28 insertions(+)
|
||||
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt7986a.dtsi
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt7986a.dtsi
|
||||
@@ -602,4 +602,32 @@
|
||||
memory-region = <&wmcpu_emi>;
|
||||
};
|
||||
};
|
||||
+
|
||||
+ thermal-zones {
|
||||
+ cpu_thermal: cpu-thermal {
|
||||
+ polling-delay-passive = <1000>;
|
||||
+ polling-delay = <1000>;
|
||||
+ thermal-sensors = <&thermal 0>;
|
||||
+
|
||||
+ trips {
|
||||
+ cpu_trip_active_high: active-high {
|
||||
+ temperature = <115000>;
|
||||
+ hysteresis = <2000>;
|
||||
+ type = "active";
|
||||
+ };
|
||||
+
|
||||
+ cpu_trip_active_low: active-low {
|
||||
+ temperature = <85000>;
|
||||
+ hysteresis = <2000>;
|
||||
+ type = "active";
|
||||
+ };
|
||||
+
|
||||
+ cpu_trip_passive: passive {
|
||||
+ temperature = <40000>;
|
||||
+ hysteresis = <2000>;
|
||||
+ type = "passive";
|
||||
+ };
|
||||
+ };
|
||||
+ };
|
||||
+ };
|
||||
};
|
@ -1,64 +0,0 @@
|
||||
From 5d90603b09e5814ffc38c47e79ccf9bc564f9296 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Tue, 30 May 2023 22:12:35 +0200
|
||||
Subject: [PATCH 18/19] arm64: dts: mt7986: add pwm-fan and cooling-maps to
|
||||
BPI-R3 dts
|
||||
|
||||
Add pwm-fan and cooling-maps to BananaPi-R3 devicetree.
|
||||
|
||||
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Link: https://lore.kernel.org/r/20230530201235.22330-5-linux@fw-web.de
|
||||
Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
|
||||
---
|
||||
.../dts/mediatek/mt7986a-bananapi-bpi-r3.dts | 31 +++++++++++++++++++
|
||||
1 file changed, 31 insertions(+)
|
||||
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dts
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3.dts
|
||||
@@ -38,6 +38,15 @@
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
+ fan: pwm-fan {
|
||||
+ compatible = "pwm-fan";
|
||||
+ #cooling-cells = <2>;
|
||||
+ /* cooling level (0, 1, 2) - pwm inverted */
|
||||
+ cooling-levels = <255 96 0>;
|
||||
+ pwms = <&pwm 0 10000 0>;
|
||||
+ status = "okay";
|
||||
+ };
|
||||
+
|
||||
gpio-keys {
|
||||
compatible = "gpio-keys";
|
||||
|
||||
@@ -133,6 +142,28 @@
|
||||
};
|
||||
};
|
||||
|
||||
+&cpu_thermal {
|
||||
+ cooling-maps {
|
||||
+ cpu-active-high {
|
||||
+ /* active: set fan to cooling level 2 */
|
||||
+ cooling-device = <&fan 2 2>;
|
||||
+ trip = <&cpu_trip_active_high>;
|
||||
+ };
|
||||
+
|
||||
+ cpu-active-low {
|
||||
+ /* active: set fan to cooling level 1 */
|
||||
+ cooling-device = <&fan 1 1>;
|
||||
+ trip = <&cpu_trip_active_low>;
|
||||
+ };
|
||||
+
|
||||
+ cpu-passive {
|
||||
+ /* passive: set fan to cooling level 0 */
|
||||
+ cooling-device = <&fan 0 0>;
|
||||
+ trip = <&cpu_trip_passive>;
|
||||
+ };
|
||||
+ };
|
||||
+};
|
||||
+
|
||||
&crypto {
|
||||
status = "okay";
|
||||
};
|
@ -1,41 +0,0 @@
|
||||
From 6dd3b939370094eb79529683be84500f3c757404 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Tue, 6 Jun 2023 16:43:20 +0100
|
||||
Subject: [PATCH 19/19] arm64: dts: mt7986: increase bl2 partition on NAND of
|
||||
Bananapi R3
|
||||
|
||||
The bootrom burned into the MT7986 SoC will try multiple locations on
|
||||
the SPI-NAND flash to load bl2 in case the bl2 image located at the the
|
||||
previously attempted offset is corrupt.
|
||||
|
||||
Use 0x100000 instead of 0x80000 as partition size for bl2 on SPI-NAND,
|
||||
allowing for up to four redundant copies of bl2 (typically sized a
|
||||
bit less than 0x40000).
|
||||
|
||||
Fixes: 8e01fb15b8157 ("arm64: dts: mt7986: add Bananapi R3")
|
||||
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
Link: https://lore.kernel.org/r/ZH9UGF99RgzrHZ88@makrotopia.org
|
||||
Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
|
||||
---
|
||||
.../boot/dts/mediatek/mt7986a-bananapi-bpi-r3-nand.dtso | 6 +++---
|
||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-nand.dtso
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt7986a-bananapi-bpi-r3-nand.dtso
|
||||
@@ -29,13 +29,13 @@
|
||||
|
||||
partition@0 {
|
||||
label = "bl2";
|
||||
- reg = <0x0 0x80000>;
|
||||
+ reg = <0x0 0x100000>;
|
||||
read-only;
|
||||
};
|
||||
|
||||
- partition@80000 {
|
||||
+ partition@100000 {
|
||||
label = "reserved";
|
||||
- reg = <0x80000 0x300000>;
|
||||
+ reg = <0x100000 0x280000>;
|
||||
};
|
||||
|
||||
partition@380000 {
|
@ -1,70 +0,0 @@
|
||||
From d278f43f25beedfd0cb784d1dd0a9e7e8c8f123f Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Wed, 19 Apr 2023 20:15:53 +0100
|
||||
Subject: [PATCH] arm64: dts: mt7622: declare SPI-NAND present on BPI-R64
|
||||
|
||||
The SPI-NOR node in the device tree of the BananaPi R64 has most likely
|
||||
been copied from the reference board's device tree even though the R64
|
||||
comes with an SPI-NAND chip rather than SPI-NOR.
|
||||
|
||||
Setup the Serial NAND Flash Interface (SNFI) controller, enable
|
||||
hardware BCH error detection and correction engine and add the SPI-NAND
|
||||
chip including basic partitions,
|
||||
|
||||
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
Link: https://lore.kernel.org/r/ZEA96dmaXqTpk8u8@makrotopia.org
|
||||
Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
|
||||
---
|
||||
.../dts/mediatek/mt7622-bananapi-bpi-r64.dts | 38 ++++++++++++++++---
|
||||
1 file changed, 33 insertions(+), 5 deletions(-)
|
||||
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts
|
||||
@@ -253,14 +253,42 @@
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
-&nor_flash {
|
||||
- pinctrl-names = "default";
|
||||
- pinctrl-0 = <&spi_nor_pins>;
|
||||
- status = "disabled";
|
||||
+&bch {
|
||||
+ status = "okay";
|
||||
+};
|
||||
|
||||
+&snfi {
|
||||
+ pinctrl-names = "default";
|
||||
+ pinctrl-0 = <&serial_nand_pins>;
|
||||
+ status = "okay";
|
||||
flash@0 {
|
||||
- compatible = "jedec,spi-nor";
|
||||
+ compatible = "spi-nand";
|
||||
reg = <0>;
|
||||
+ spi-tx-bus-width = <4>;
|
||||
+ spi-rx-bus-width = <4>;
|
||||
+ nand-ecc-engine = <&snfi>;
|
||||
+ partitions {
|
||||
+ compatible = "fixed-partitions";
|
||||
+ #address-cells = <1>;
|
||||
+ #size-cells = <1>;
|
||||
+
|
||||
+ partition@0 {
|
||||
+ label = "bl2";
|
||||
+ reg = <0x0 0x80000>;
|
||||
+ read-only;
|
||||
+ };
|
||||
+
|
||||
+ partition@80000 {
|
||||
+ label = "fip";
|
||||
+ reg = <0x80000 0x200000>;
|
||||
+ read-only;
|
||||
+ };
|
||||
+
|
||||
+ ubi: partition@280000 {
|
||||
+ label = "ubi";
|
||||
+ reg = <0x280000 0x7d80000>;
|
||||
+ };
|
||||
+ };
|
||||
};
|
||||
};
|
||||
|
@ -1,32 +0,0 @@
|
||||
From 983f37ee08acb60435744f1b1e2afea2d2a09c48 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Wed, 19 Apr 2023 20:16:29 +0100
|
||||
Subject: [PATCH] arm64: dts: mt7622: handle interrupts from MT7531 switch on
|
||||
BPI-R64
|
||||
|
||||
Since commit ba751e28d442 ("net: dsa: mt7530: add interrupt support")
|
||||
the mt7530 driver can act as an interrupt controller. Wire up irq line
|
||||
of the MT7531 switch on the BananaPi BPi-R64 board, so the status of
|
||||
the PHYs of the five 1000Base-T ports doesn't need to be polled any
|
||||
more.
|
||||
|
||||
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
Link: https://lore.kernel.org/r/ZEA-DV_OsmFg5egL@makrotopia.org
|
||||
Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
|
||||
---
|
||||
arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
--- a/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts
|
||||
+++ b/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts
|
||||
@@ -154,6 +154,10 @@
|
||||
switch@0 {
|
||||
compatible = "mediatek,mt7531";
|
||||
reg = <0>;
|
||||
+ interrupt-controller;
|
||||
+ #interrupt-cells = <1>;
|
||||
+ interrupt-parent = <&pio>;
|
||||
+ interrupts = <53 IRQ_TYPE_LEVEL_HIGH>;
|
||||
reset-gpios = <&pio 54 0>;
|
||||
|
||||
ports {
|
@ -1,88 +0,0 @@
|
||||
From f76e8bc416bebb0f7b9f57b1247eae945421c0b9 Mon Sep 17 00:00:00 2001
|
||||
From: Sam Shih <sam.shih@mediatek.com>
|
||||
Date: Sat, 8 Oct 2022 18:48:06 +0200
|
||||
Subject: [PATCH 1/2] pinctrl: mt7986: allow configuring uart rx/tx and rts/cts
|
||||
separately
|
||||
|
||||
Some mt7986 boards use uart rts/cts pins as gpio,
|
||||
This patch allows to change rts/cts to gpio mode, but keep
|
||||
rx/tx as UART function.
|
||||
|
||||
Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
|
||||
Signed-off-by: Sam Shih <sam.shih@mediatek.com>
|
||||
Link: https://lore.kernel.org/r/20221008164807.113590-1-linux@fw-web.de
|
||||
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
|
||||
---
|
||||
drivers/pinctrl/mediatek/pinctrl-mt7986.c | 32 ++++++++++++++++++-----
|
||||
1 file changed, 25 insertions(+), 7 deletions(-)
|
||||
|
||||
--- a/drivers/pinctrl/mediatek/pinctrl-mt7986.c
|
||||
+++ b/drivers/pinctrl/mediatek/pinctrl-mt7986.c
|
||||
@@ -675,11 +675,17 @@ static int mt7986_uart1_1_funcs[] = { 4,
|
||||
static int mt7986_spi1_2_pins[] = { 29, 30, 31, 32, };
|
||||
static int mt7986_spi1_2_funcs[] = { 1, 1, 1, 1, };
|
||||
|
||||
-static int mt7986_uart1_2_pins[] = { 29, 30, 31, 32, };
|
||||
-static int mt7986_uart1_2_funcs[] = { 3, 3, 3, 3, };
|
||||
+static int mt7986_uart1_2_rx_tx_pins[] = { 29, 30, };
|
||||
+static int mt7986_uart1_2_rx_tx_funcs[] = { 3, 3, };
|
||||
|
||||
-static int mt7986_uart2_0_pins[] = { 29, 30, 31, 32, };
|
||||
-static int mt7986_uart2_0_funcs[] = { 4, 4, 4, 4, };
|
||||
+static int mt7986_uart1_2_cts_rts_pins[] = { 31, 32, };
|
||||
+static int mt7986_uart1_2_cts_rts_funcs[] = { 3, 3, };
|
||||
+
|
||||
+static int mt7986_uart2_0_rx_tx_pins[] = { 29, 30, };
|
||||
+static int mt7986_uart2_0_rx_tx_funcs[] = { 4, 4, };
|
||||
+
|
||||
+static int mt7986_uart2_0_cts_rts_pins[] = { 31, 32, };
|
||||
+static int mt7986_uart2_0_cts_rts_funcs[] = { 4, 4, };
|
||||
|
||||
static int mt7986_spi0_pins[] = { 33, 34, 35, 36, };
|
||||
static int mt7986_spi0_funcs[] = { 1, 1, 1, 1, };
|
||||
@@ -708,6 +714,12 @@ static int mt7986_pcie_reset_funcs[] = {
|
||||
static int mt7986_uart1_pins[] = { 42, 43, 44, 45, };
|
||||
static int mt7986_uart1_funcs[] = { 1, 1, 1, 1, };
|
||||
|
||||
+static int mt7986_uart1_rx_tx_pins[] = { 42, 43, };
|
||||
+static int mt7986_uart1_rx_tx_funcs[] = { 1, 1, };
|
||||
+
|
||||
+static int mt7986_uart1_cts_rts_pins[] = { 44, 45, };
|
||||
+static int mt7986_uart1_cts_rts_funcs[] = { 1, 1, };
|
||||
+
|
||||
static int mt7986_uart2_pins[] = { 46, 47, 48, 49, };
|
||||
static int mt7986_uart2_funcs[] = { 1, 1, 1, 1, };
|
||||
|
||||
@@ -749,6 +761,8 @@ static const struct group_desc mt7986_gr
|
||||
PINCTRL_PIN_GROUP("wifi_led", mt7986_wifi_led),
|
||||
PINCTRL_PIN_GROUP("i2c", mt7986_i2c),
|
||||
PINCTRL_PIN_GROUP("uart1_0", mt7986_uart1_0),
|
||||
+ PINCTRL_PIN_GROUP("uart1_rx_tx", mt7986_uart1_rx_tx),
|
||||
+ PINCTRL_PIN_GROUP("uart1_cts_rts", mt7986_uart1_cts_rts),
|
||||
PINCTRL_PIN_GROUP("pcie_clk", mt7986_pcie_clk),
|
||||
PINCTRL_PIN_GROUP("pcie_wake", mt7986_pcie_wake),
|
||||
PINCTRL_PIN_GROUP("spi1_0", mt7986_spi1_0),
|
||||
@@ -760,8 +774,10 @@ static const struct group_desc mt7986_gr
|
||||
PINCTRL_PIN_GROUP("spi1_1", mt7986_spi1_1),
|
||||
PINCTRL_PIN_GROUP("uart1_1", mt7986_uart1_1),
|
||||
PINCTRL_PIN_GROUP("spi1_2", mt7986_spi1_2),
|
||||
- PINCTRL_PIN_GROUP("uart1_2", mt7986_uart1_2),
|
||||
- PINCTRL_PIN_GROUP("uart2_0", mt7986_uart2_0),
|
||||
+ PINCTRL_PIN_GROUP("uart1_2_rx_tx", mt7986_uart1_2_rx_tx),
|
||||
+ PINCTRL_PIN_GROUP("uart1_2_cts_rts", mt7986_uart1_2_cts_rts),
|
||||
+ PINCTRL_PIN_GROUP("uart2_0_rx_tx", mt7986_uart2_0_rx_tx),
|
||||
+ PINCTRL_PIN_GROUP("uart2_0_cts_rts", mt7986_uart2_0_cts_rts),
|
||||
PINCTRL_PIN_GROUP("spi0", mt7986_spi0),
|
||||
PINCTRL_PIN_GROUP("spi0_wp_hold", mt7986_spi0_wp_hold),
|
||||
PINCTRL_PIN_GROUP("uart2_1", mt7986_uart2_1),
|
||||
@@ -800,7 +816,9 @@ static const char *mt7986_pwm_groups[] =
|
||||
static const char *mt7986_spi_groups[] = {
|
||||
"spi0", "spi0_wp_hold", "spi1_0", "spi1_1", "spi1_2", "spi1_3", };
|
||||
static const char *mt7986_uart_groups[] = {
|
||||
- "uart1_0", "uart1_1", "uart1_2", "uart1_3_rx_tx", "uart1_3_cts_rts",
|
||||
+ "uart1_0", "uart1_1", "uart1_rx_tx", "uart1_cts_rts",
|
||||
+ "uart1_2_rx_tx", "uart1_2_cts_rts",
|
||||
+ "uart1_3_rx_tx", "uart1_3_cts_rts", "uart2_0_rx_tx", "uart2_0_cts_rts",
|
||||
"uart2_0", "uart2_1", "uart0", "uart1", "uart2",
|
||||
};
|
||||
static const char *mt7986_wdt_groups[] = { "watchdog", };
|
@ -1,100 +0,0 @@
|
||||
From 822d774abbcc66b811e28c68b59b40b964ba5b46 Mon Sep 17 00:00:00 2001
|
||||
From: Sam Shih <sam.shih@mediatek.com>
|
||||
Date: Sun, 6 Nov 2022 09:01:13 +0100
|
||||
Subject: [PATCH 2/2] pinctrl: mediatek: add pull_type attribute for mediatek
|
||||
MT7986 SoC
|
||||
|
||||
Commit fb34a9ae383a ("pinctrl: mediatek: support rsel feature")
|
||||
add SoC specify 'pull_type' attribute for bias configuration.
|
||||
|
||||
This patch add pull_type attribute to pinctrl-mt7986.c, and make
|
||||
bias_set_combo and bias_get_combo available to mediatek MT7986 SoC.
|
||||
|
||||
Signed-off-by: Sam Shih <sam.shih@mediatek.com>
|
||||
Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Link: https://lore.kernel.org/r/20221106080114.7426-7-linux@fw-web.de
|
||||
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
|
||||
---
|
||||
drivers/pinctrl/mediatek/pinctrl-mt7986.c | 56 +++++++++++++++++++++++
|
||||
1 file changed, 56 insertions(+)
|
||||
|
||||
--- a/drivers/pinctrl/mediatek/pinctrl-mt7986.c
|
||||
+++ b/drivers/pinctrl/mediatek/pinctrl-mt7986.c
|
||||
@@ -407,6 +407,60 @@ static const struct mtk_pin_field_calc m
|
||||
PIN_FIELD_BASE(66, 68, IOCFG_LB_BASE, 0x60, 0x10, 2, 1),
|
||||
};
|
||||
|
||||
+static const unsigned int mt7986_pull_type[] = {
|
||||
+ MTK_PULL_PUPD_R1R0_TYPE,/*0*/ MTK_PULL_PUPD_R1R0_TYPE,/*1*/
|
||||
+ MTK_PULL_PUPD_R1R0_TYPE,/*2*/ MTK_PULL_PUPD_R1R0_TYPE,/*3*/
|
||||
+ MTK_PULL_PUPD_R1R0_TYPE,/*4*/ MTK_PULL_PUPD_R1R0_TYPE,/*5*/
|
||||
+ MTK_PULL_PUPD_R1R0_TYPE,/*6*/ MTK_PULL_PUPD_R1R0_TYPE,/*7*/
|
||||
+ MTK_PULL_PUPD_R1R0_TYPE,/*8*/ MTK_PULL_PUPD_R1R0_TYPE,/*9*/
|
||||
+ MTK_PULL_PUPD_R1R0_TYPE,/*10*/ MTK_PULL_PUPD_R1R0_TYPE,/*11*/
|
||||
+ MTK_PULL_PUPD_R1R0_TYPE,/*12*/ MTK_PULL_PUPD_R1R0_TYPE,/*13*/
|
||||
+ MTK_PULL_PUPD_R1R0_TYPE,/*14*/ MTK_PULL_PUPD_R1R0_TYPE,/*15*/
|
||||
+ MTK_PULL_PUPD_R1R0_TYPE,/*16*/ MTK_PULL_PUPD_R1R0_TYPE,/*17*/
|
||||
+ MTK_PULL_PUPD_R1R0_TYPE,/*18*/ MTK_PULL_PUPD_R1R0_TYPE,/*19*/
|
||||
+ MTK_PULL_PUPD_R1R0_TYPE,/*20*/ MTK_PULL_PUPD_R1R0_TYPE,/*21*/
|
||||
+ MTK_PULL_PUPD_R1R0_TYPE,/*22*/ MTK_PULL_PUPD_R1R0_TYPE,/*23*/
|
||||
+ MTK_PULL_PUPD_R1R0_TYPE,/*24*/ MTK_PULL_PUPD_R1R0_TYPE,/*25*/
|
||||
+ MTK_PULL_PUPD_R1R0_TYPE,/*26*/ MTK_PULL_PUPD_R1R0_TYPE,/*27*/
|
||||
+ MTK_PULL_PUPD_R1R0_TYPE,/*28*/ MTK_PULL_PUPD_R1R0_TYPE,/*29*/
|
||||
+ MTK_PULL_PUPD_R1R0_TYPE,/*30*/ MTK_PULL_PUPD_R1R0_TYPE,/*31*/
|
||||
+ MTK_PULL_PUPD_R1R0_TYPE,/*32*/ MTK_PULL_PUPD_R1R0_TYPE,/*33*/
|
||||
+ MTK_PULL_PUPD_R1R0_TYPE,/*34*/ MTK_PULL_PUPD_R1R0_TYPE,/*35*/
|
||||
+ MTK_PULL_PUPD_R1R0_TYPE,/*36*/ MTK_PULL_PUPD_R1R0_TYPE,/*37*/
|
||||
+ MTK_PULL_PUPD_R1R0_TYPE,/*38*/ MTK_PULL_PUPD_R1R0_TYPE,/*39*/
|
||||
+ MTK_PULL_PUPD_R1R0_TYPE,/*40*/ MTK_PULL_PUPD_R1R0_TYPE,/*41*/
|
||||
+ MTK_PULL_PUPD_R1R0_TYPE,/*42*/ MTK_PULL_PUPD_R1R0_TYPE,/*43*/
|
||||
+ MTK_PULL_PUPD_R1R0_TYPE,/*44*/ MTK_PULL_PUPD_R1R0_TYPE,/*45*/
|
||||
+ MTK_PULL_PUPD_R1R0_TYPE,/*46*/ MTK_PULL_PUPD_R1R0_TYPE,/*47*/
|
||||
+ MTK_PULL_PUPD_R1R0_TYPE,/*48*/ MTK_PULL_PUPD_R1R0_TYPE,/*49*/
|
||||
+ MTK_PULL_PUPD_R1R0_TYPE,/*50*/ MTK_PULL_PUPD_R1R0_TYPE,/*51*/
|
||||
+ MTK_PULL_PUPD_R1R0_TYPE,/*52*/ MTK_PULL_PUPD_R1R0_TYPE,/*53*/
|
||||
+ MTK_PULL_PUPD_R1R0_TYPE,/*54*/ MTK_PULL_PUPD_R1R0_TYPE,/*55*/
|
||||
+ MTK_PULL_PUPD_R1R0_TYPE,/*56*/ MTK_PULL_PUPD_R1R0_TYPE,/*57*/
|
||||
+ MTK_PULL_PUPD_R1R0_TYPE,/*58*/ MTK_PULL_PUPD_R1R0_TYPE,/*59*/
|
||||
+ MTK_PULL_PUPD_R1R0_TYPE,/*60*/ MTK_PULL_PUPD_R1R0_TYPE,/*61*/
|
||||
+ MTK_PULL_PUPD_R1R0_TYPE,/*62*/ MTK_PULL_PUPD_R1R0_TYPE,/*63*/
|
||||
+ MTK_PULL_PUPD_R1R0_TYPE,/*64*/ MTK_PULL_PUPD_R1R0_TYPE,/*65*/
|
||||
+ MTK_PULL_PUPD_R1R0_TYPE,/*66*/ MTK_PULL_PUPD_R1R0_TYPE,/*67*/
|
||||
+ MTK_PULL_PUPD_R1R0_TYPE,/*68*/ MTK_PULL_PU_PD_TYPE,/*69*/
|
||||
+ MTK_PULL_PU_PD_TYPE,/*70*/ MTK_PULL_PU_PD_TYPE,/*71*/
|
||||
+ MTK_PULL_PU_PD_TYPE,/*72*/ MTK_PULL_PU_PD_TYPE,/*73*/
|
||||
+ MTK_PULL_PU_PD_TYPE,/*74*/ MTK_PULL_PU_PD_TYPE,/*75*/
|
||||
+ MTK_PULL_PU_PD_TYPE,/*76*/ MTK_PULL_PU_PD_TYPE,/*77*/
|
||||
+ MTK_PULL_PU_PD_TYPE,/*78*/ MTK_PULL_PU_PD_TYPE,/*79*/
|
||||
+ MTK_PULL_PU_PD_TYPE,/*80*/ MTK_PULL_PU_PD_TYPE,/*81*/
|
||||
+ MTK_PULL_PU_PD_TYPE,/*82*/ MTK_PULL_PU_PD_TYPE,/*83*/
|
||||
+ MTK_PULL_PU_PD_TYPE,/*84*/ MTK_PULL_PU_PD_TYPE,/*85*/
|
||||
+ MTK_PULL_PU_PD_TYPE,/*86*/ MTK_PULL_PU_PD_TYPE,/*87*/
|
||||
+ MTK_PULL_PU_PD_TYPE,/*88*/ MTK_PULL_PU_PD_TYPE,/*89*/
|
||||
+ MTK_PULL_PU_PD_TYPE,/*90*/ MTK_PULL_PU_PD_TYPE,/*91*/
|
||||
+ MTK_PULL_PU_PD_TYPE,/*92*/ MTK_PULL_PU_PD_TYPE,/*93*/
|
||||
+ MTK_PULL_PU_PD_TYPE,/*94*/ MTK_PULL_PU_PD_TYPE,/*95*/
|
||||
+ MTK_PULL_PU_PD_TYPE,/*96*/ MTK_PULL_PU_PD_TYPE,/*97*/
|
||||
+ MTK_PULL_PU_PD_TYPE,/*98*/ MTK_PULL_PU_PD_TYPE,/*99*/
|
||||
+ MTK_PULL_PU_PD_TYPE,/*100*/
|
||||
+};
|
||||
+
|
||||
static const struct mtk_pin_reg_calc mt7986_reg_cals[] = {
|
||||
[PINCTRL_PIN_REG_MODE] = MTK_RANGE(mt7986_pin_mode_range),
|
||||
[PINCTRL_PIN_REG_DIR] = MTK_RANGE(mt7986_pin_dir_range),
|
||||
@@ -868,6 +922,7 @@ static struct mtk_pin_soc mt7986a_data =
|
||||
.ies_present = false,
|
||||
.base_names = mt7986_pinctrl_register_base_names,
|
||||
.nbase_names = ARRAY_SIZE(mt7986_pinctrl_register_base_names),
|
||||
+ .pull_type = mt7986_pull_type,
|
||||
.bias_set_combo = mtk_pinconf_bias_set_combo,
|
||||
.bias_get_combo = mtk_pinconf_bias_get_combo,
|
||||
.drive_set = mtk_pinconf_drive_set_rev1,
|
||||
@@ -889,6 +944,7 @@ static struct mtk_pin_soc mt7986b_data =
|
||||
.ies_present = false,
|
||||
.base_names = mt7986_pinctrl_register_base_names,
|
||||
.nbase_names = ARRAY_SIZE(mt7986_pinctrl_register_base_names),
|
||||
+ .pull_type = mt7986_pull_type,
|
||||
.bias_set_combo = mtk_pinconf_bias_set_combo,
|
||||
.bias_get_combo = mtk_pinconf_bias_get_combo,
|
||||
.drive_set = mtk_pinconf_drive_set_rev1,
|
File diff suppressed because it is too large
Load Diff
@ -1,30 +0,0 @@
|
||||
From c0ad453e94e5c404efbcf668648d07eaa1a71ed7 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= <arinc.unal@arinc9.com>
|
||||
Date: Sat, 18 Feb 2023 09:51:06 +0300
|
||||
Subject: [PATCH] pinctrl: mediatek: add missing options to PINCTRL_MT7981
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
There are options missing from PINCTRL_MT7981 whilst being on every other
|
||||
pin controller. Add them.
|
||||
|
||||
Signed-off-by: Arınç ÜNAL <arinc.unal@arinc9.com>
|
||||
Acked-by: Daniel Golle <daniel@makrotopia.org>
|
||||
Link: https://lore.kernel.org/r/20230218065108.8958-1-arinc.unal@arinc9.com
|
||||
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
|
||||
---
|
||||
drivers/pinctrl/mediatek/Kconfig | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
--- a/drivers/pinctrl/mediatek/Kconfig
|
||||
+++ b/drivers/pinctrl/mediatek/Kconfig
|
||||
@@ -130,6 +130,8 @@ config PINCTRL_MT7622
|
||||
config PINCTRL_MT7981
|
||||
bool "Mediatek MT7981 pin control"
|
||||
depends on OF
|
||||
+ depends on ARM64 || COMPILE_TEST
|
||||
+ default ARM64 && ARCH_MEDIATEK
|
||||
select PINCTRL_MTK_MOORE
|
||||
|
||||
config PINCTRL_MT7986
|
@ -1,76 +0,0 @@
|
||||
From 8f6f16fe1553ce63edfb98a39ef9d4754a0c39bf Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Fri, 18 Aug 2023 04:02:35 +0100
|
||||
Subject: [PATCH] pinctrl: mediatek: fix pull_type data for MT7981
|
||||
|
||||
MediaTek has released pull_type data for MT7981 in their SDK.
|
||||
Use it and set functions to configure pin bias.
|
||||
|
||||
Fixes: 6c83b2d94fcc ("pinctrl: add mt7981 pinctrl driver")
|
||||
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
Link: https://lore.kernel.org/r/7bcc8ead25dbfabc7f5a85d066224a926fbb4941.1692327317.git.daniel@makrotopia.org
|
||||
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
|
||||
---
|
||||
drivers/pinctrl/mediatek/pinctrl-mt7981.c | 44 +++++++----------------
|
||||
1 file changed, 13 insertions(+), 31 deletions(-)
|
||||
|
||||
--- a/drivers/pinctrl/mediatek/pinctrl-mt7981.c
|
||||
+++ b/drivers/pinctrl/mediatek/pinctrl-mt7981.c
|
||||
@@ -457,37 +457,15 @@ static const unsigned int mt7981_pull_ty
|
||||
MTK_PULL_PUPD_R1R0_TYPE,/*34*/ MTK_PULL_PUPD_R1R0_TYPE,/*35*/
|
||||
MTK_PULL_PUPD_R1R0_TYPE,/*36*/ MTK_PULL_PUPD_R1R0_TYPE,/*37*/
|
||||
MTK_PULL_PUPD_R1R0_TYPE,/*38*/ MTK_PULL_PUPD_R1R0_TYPE,/*39*/
|
||||
- MTK_PULL_PUPD_R1R0_TYPE,/*40*/ MTK_PULL_PUPD_R1R0_TYPE,/*41*/
|
||||
- MTK_PULL_PUPD_R1R0_TYPE,/*42*/ MTK_PULL_PUPD_R1R0_TYPE,/*43*/
|
||||
- MTK_PULL_PUPD_R1R0_TYPE,/*44*/ MTK_PULL_PUPD_R1R0_TYPE,/*45*/
|
||||
- MTK_PULL_PUPD_R1R0_TYPE,/*46*/ MTK_PULL_PUPD_R1R0_TYPE,/*47*/
|
||||
- MTK_PULL_PUPD_R1R0_TYPE,/*48*/ MTK_PULL_PUPD_R1R0_TYPE,/*49*/
|
||||
- MTK_PULL_PUPD_R1R0_TYPE,/*50*/ MTK_PULL_PUPD_R1R0_TYPE,/*51*/
|
||||
- MTK_PULL_PUPD_R1R0_TYPE,/*52*/ MTK_PULL_PUPD_R1R0_TYPE,/*53*/
|
||||
- MTK_PULL_PUPD_R1R0_TYPE,/*54*/ MTK_PULL_PUPD_R1R0_TYPE,/*55*/
|
||||
- MTK_PULL_PUPD_R1R0_TYPE,/*56*/ MTK_PULL_PUPD_R1R0_TYPE,/*57*/
|
||||
- MTK_PULL_PUPD_R1R0_TYPE,/*58*/ MTK_PULL_PUPD_R1R0_TYPE,/*59*/
|
||||
- MTK_PULL_PUPD_R1R0_TYPE,/*60*/ MTK_PULL_PUPD_R1R0_TYPE,/*61*/
|
||||
- MTK_PULL_PUPD_R1R0_TYPE,/*62*/ MTK_PULL_PUPD_R1R0_TYPE,/*63*/
|
||||
- MTK_PULL_PUPD_R1R0_TYPE,/*64*/ MTK_PULL_PUPD_R1R0_TYPE,/*65*/
|
||||
- MTK_PULL_PUPD_R1R0_TYPE,/*66*/ MTK_PULL_PUPD_R1R0_TYPE,/*67*/
|
||||
- MTK_PULL_PUPD_R1R0_TYPE,/*68*/ MTK_PULL_PU_PD_TYPE,/*69*/
|
||||
- MTK_PULL_PU_PD_TYPE,/*70*/ MTK_PULL_PU_PD_TYPE,/*71*/
|
||||
- MTK_PULL_PU_PD_TYPE,/*72*/ MTK_PULL_PU_PD_TYPE,/*73*/
|
||||
- MTK_PULL_PU_PD_TYPE,/*74*/ MTK_PULL_PU_PD_TYPE,/*75*/
|
||||
- MTK_PULL_PU_PD_TYPE,/*76*/ MTK_PULL_PU_PD_TYPE,/*77*/
|
||||
- MTK_PULL_PU_PD_TYPE,/*78*/ MTK_PULL_PU_PD_TYPE,/*79*/
|
||||
- MTK_PULL_PU_PD_TYPE,/*80*/ MTK_PULL_PU_PD_TYPE,/*81*/
|
||||
- MTK_PULL_PU_PD_TYPE,/*82*/ MTK_PULL_PU_PD_TYPE,/*83*/
|
||||
- MTK_PULL_PU_PD_TYPE,/*84*/ MTK_PULL_PU_PD_TYPE,/*85*/
|
||||
- MTK_PULL_PU_PD_TYPE,/*86*/ MTK_PULL_PU_PD_TYPE,/*87*/
|
||||
- MTK_PULL_PU_PD_TYPE,/*88*/ MTK_PULL_PU_PD_TYPE,/*89*/
|
||||
- MTK_PULL_PU_PD_TYPE,/*90*/ MTK_PULL_PU_PD_TYPE,/*91*/
|
||||
- MTK_PULL_PU_PD_TYPE,/*92*/ MTK_PULL_PU_PD_TYPE,/*93*/
|
||||
- MTK_PULL_PU_PD_TYPE,/*94*/ MTK_PULL_PU_PD_TYPE,/*95*/
|
||||
- MTK_PULL_PU_PD_TYPE,/*96*/ MTK_PULL_PU_PD_TYPE,/*97*/
|
||||
- MTK_PULL_PU_PD_TYPE,/*98*/ MTK_PULL_PU_PD_TYPE,/*99*/
|
||||
- MTK_PULL_PU_PD_TYPE,/*100*/
|
||||
+ MTK_PULL_PU_PD_TYPE,/*40*/ MTK_PULL_PU_PD_TYPE,/*41*/
|
||||
+ MTK_PULL_PU_PD_TYPE,/*42*/ MTK_PULL_PU_PD_TYPE,/*43*/
|
||||
+ MTK_PULL_PU_PD_TYPE,/*44*/ MTK_PULL_PU_PD_TYPE,/*45*/
|
||||
+ MTK_PULL_PU_PD_TYPE,/*46*/ MTK_PULL_PU_PD_TYPE,/*47*/
|
||||
+ MTK_PULL_PU_PD_TYPE,/*48*/ MTK_PULL_PU_PD_TYPE,/*49*/
|
||||
+ MTK_PULL_PU_PD_TYPE,/*50*/ MTK_PULL_PU_PD_TYPE,/*51*/
|
||||
+ MTK_PULL_PU_PD_TYPE,/*52*/ MTK_PULL_PU_PD_TYPE,/*53*/
|
||||
+ MTK_PULL_PU_PD_TYPE,/*54*/ MTK_PULL_PU_PD_TYPE,/*55*/
|
||||
+ MTK_PULL_PU_PD_TYPE,/*56*/
|
||||
};
|
||||
|
||||
static const struct mtk_pin_reg_calc mt7981_reg_cals[] = {
|
||||
@@ -1014,6 +992,10 @@ static struct mtk_pin_soc mt7981_data =
|
||||
.ies_present = false,
|
||||
.base_names = mt7981_pinctrl_register_base_names,
|
||||
.nbase_names = ARRAY_SIZE(mt7981_pinctrl_register_base_names),
|
||||
+ .bias_disable_set = mtk_pinconf_bias_disable_set,
|
||||
+ .bias_disable_get = mtk_pinconf_bias_disable_get,
|
||||
+ .bias_set = mtk_pinconf_bias_set,
|
||||
+ .bias_get = mtk_pinconf_bias_get,
|
||||
.pull_type = mt7981_pull_type,
|
||||
.bias_set_combo = mtk_pinconf_bias_set_combo,
|
||||
.bias_get_combo = mtk_pinconf_bias_get_combo,
|
@ -1,41 +0,0 @@
|
||||
From 0d8387fba9f151220e48dc3dcdc2335539708f13 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Fri, 18 Aug 2023 04:03:26 +0100
|
||||
Subject: [PATCH] pinctrl: mediatek: assign functions to configure pin bias on
|
||||
MT7986
|
||||
|
||||
Assign bias_disable_get/set and bias_get/set functions to allow
|
||||
configuring pin bias on MT7986.
|
||||
|
||||
Fixes: 2c58d8dc9cd0 ("pinctrl: mediatek: add pull_type attribute for mediatek MT7986 SoC")
|
||||
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
Link: https://lore.kernel.org/r/47f72372354312a839b9337e09476aadcc206e8b.1692327317.git.daniel@makrotopia.org
|
||||
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
|
||||
---
|
||||
drivers/pinctrl/mediatek/pinctrl-mt7986.c | 8 ++++++++
|
||||
1 file changed, 8 insertions(+)
|
||||
|
||||
--- a/drivers/pinctrl/mediatek/pinctrl-mt7986.c
|
||||
+++ b/drivers/pinctrl/mediatek/pinctrl-mt7986.c
|
||||
@@ -922,6 +922,10 @@ static struct mtk_pin_soc mt7986a_data =
|
||||
.ies_present = false,
|
||||
.base_names = mt7986_pinctrl_register_base_names,
|
||||
.nbase_names = ARRAY_SIZE(mt7986_pinctrl_register_base_names),
|
||||
+ .bias_disable_set = mtk_pinconf_bias_disable_set,
|
||||
+ .bias_disable_get = mtk_pinconf_bias_disable_get,
|
||||
+ .bias_set = mtk_pinconf_bias_set,
|
||||
+ .bias_get = mtk_pinconf_bias_get,
|
||||
.pull_type = mt7986_pull_type,
|
||||
.bias_set_combo = mtk_pinconf_bias_set_combo,
|
||||
.bias_get_combo = mtk_pinconf_bias_get_combo,
|
||||
@@ -944,6 +948,10 @@ static struct mtk_pin_soc mt7986b_data =
|
||||
.ies_present = false,
|
||||
.base_names = mt7986_pinctrl_register_base_names,
|
||||
.nbase_names = ARRAY_SIZE(mt7986_pinctrl_register_base_names),
|
||||
+ .bias_disable_set = mtk_pinconf_bias_disable_set,
|
||||
+ .bias_disable_get = mtk_pinconf_bias_disable_get,
|
||||
+ .bias_set = mtk_pinconf_bias_set,
|
||||
+ .bias_get = mtk_pinconf_bias_get,
|
||||
.pull_type = mt7986_pull_type,
|
||||
.bias_set_combo = mtk_pinconf_bias_set_combo,
|
||||
.bias_get_combo = mtk_pinconf_bias_get_combo,
|
@ -1,536 +0,0 @@
|
||||
From fe5c8d03f3de89ae058e365b783f8c1314f47490 Mon Sep 17 00:00:00 2001
|
||||
From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Date: Fri, 20 Jan 2023 10:20:33 +0100
|
||||
Subject: [PATCH 01/15] clk: mediatek: clk-gate: Propagate struct device with
|
||||
mtk_clk_register_gates()
|
||||
|
||||
Commit e4c23e19aa2a ("clk: mediatek: Register clock gate with device")
|
||||
introduces a helper function for the sole purpose of propagating a
|
||||
struct device pointer to the clk API when registering the mtk-gate
|
||||
clocks to take advantage of Runtime PM when/where needed and where
|
||||
a power domain is defined in devicetree.
|
||||
|
||||
Function mtk_clk_register_gates() then becomes a wrapper around the
|
||||
new mtk_clk_register_gates_with_dev() function that will simply pass
|
||||
NULL as struct device: this is essential when registering drivers
|
||||
with CLK_OF_DECLARE instead of as a platform device, as there will
|
||||
be no struct device to pass... but we can as well simply have only
|
||||
one function that always takes such pointer as a param and pass NULL
|
||||
when unavoidable.
|
||||
|
||||
This commit removes the mtk_clk_register_gates() wrapper and renames
|
||||
mtk_clk_register_gates_with_dev() to the former and all of the calls
|
||||
to either of the two functions were fixed in all drivers in order to
|
||||
reflect this change; also, to improve consistency with other kernel
|
||||
functions, the pointer to struct device was moved as the first param.
|
||||
|
||||
Since a lot of MediaTek clock drivers are actually registering as a
|
||||
platform device, but were still registering the mtk-gate clocks
|
||||
without passing any struct device to the clock framework, they've
|
||||
been changed to pass a valid one now, as to make all those platforms
|
||||
able to use runtime power management where available.
|
||||
|
||||
While at it, some much needed indentation changes were also done.
|
||||
|
||||
Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
|
||||
Reviewed-by: Markus Schneider-Pargmann <msp@baylibre.com>
|
||||
Tested-by: Miles Chen <miles.chen@mediatek.com>
|
||||
Link: https://lore.kernel.org/r/20230120092053.182923-4-angelogioacchino.delregno@collabora.com
|
||||
Tested-by: Mingming Su <mingming.su@mediatek.com>
|
||||
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
|
||||
|
||||
[daniel@makrotopia.org: dropped parts not relevant for OpenWrt]
|
||||
---
|
||||
drivers/clk/mediatek/clk-gate.c | 23 +++++++---------------
|
||||
drivers/clk/mediatek/clk-gate.h | 7 +------
|
||||
drivers/clk/mediatek/clk-mt2701-aud.c | 4 ++--
|
||||
drivers/clk/mediatek/clk-mt2701-eth.c | 4 ++--
|
||||
drivers/clk/mediatek/clk-mt2701-g3d.c | 2 +-
|
||||
drivers/clk/mediatek/clk-mt2701-hif.c | 4 ++--
|
||||
drivers/clk/mediatek/clk-mt2701-mm.c | 4 ++--
|
||||
drivers/clk/mediatek/clk-mt2701.c | 12 +++++------
|
||||
drivers/clk/mediatek/clk-mt2712-mm.c | 4 ++--
|
||||
drivers/clk/mediatek/clk-mt2712.c | 12 +++++------
|
||||
drivers/clk/mediatek/clk-mt7622-aud.c | 4 ++--
|
||||
drivers/clk/mediatek/clk-mt7622-eth.c | 8 ++++----
|
||||
drivers/clk/mediatek/clk-mt7622-hif.c | 8 ++++----
|
||||
drivers/clk/mediatek/clk-mt7622.c | 14 ++++++-------
|
||||
drivers/clk/mediatek/clk-mt7629-eth.c | 7 ++++---
|
||||
drivers/clk/mediatek/clk-mt7629-hif.c | 8 ++++----
|
||||
drivers/clk/mediatek/clk-mt7629.c | 10 +++++-----
|
||||
drivers/clk/mediatek/clk-mt7986-eth.c | 10 +++++-----
|
||||
drivers/clk/mediatek/clk-mt7986-infracfg.c | 4 ++--
|
||||
19 files changed, 68 insertions(+), 81 deletions(-)
|
||||
|
||||
--- a/drivers/clk/mediatek/clk-gate.c
|
||||
+++ b/drivers/clk/mediatek/clk-gate.c
|
||||
@@ -152,12 +152,12 @@ const struct clk_ops mtk_clk_gate_ops_no
|
||||
};
|
||||
EXPORT_SYMBOL_GPL(mtk_clk_gate_ops_no_setclr_inv);
|
||||
|
||||
-static struct clk_hw *mtk_clk_register_gate(const char *name,
|
||||
+static struct clk_hw *mtk_clk_register_gate(struct device *dev, const char *name,
|
||||
const char *parent_name,
|
||||
struct regmap *regmap, int set_ofs,
|
||||
int clr_ofs, int sta_ofs, u8 bit,
|
||||
const struct clk_ops *ops,
|
||||
- unsigned long flags, struct device *dev)
|
||||
+ unsigned long flags)
|
||||
{
|
||||
struct mtk_clk_gate *cg;
|
||||
int ret;
|
||||
@@ -202,10 +202,9 @@ static void mtk_clk_unregister_gate(stru
|
||||
kfree(cg);
|
||||
}
|
||||
|
||||
-int mtk_clk_register_gates_with_dev(struct device_node *node,
|
||||
- const struct mtk_gate *clks, int num,
|
||||
- struct clk_hw_onecell_data *clk_data,
|
||||
- struct device *dev)
|
||||
+int mtk_clk_register_gates(struct device *dev, struct device_node *node,
|
||||
+ const struct mtk_gate *clks, int num,
|
||||
+ struct clk_hw_onecell_data *clk_data)
|
||||
{
|
||||
int i;
|
||||
struct clk_hw *hw;
|
||||
@@ -229,13 +228,13 @@ int mtk_clk_register_gates_with_dev(stru
|
||||
continue;
|
||||
}
|
||||
|
||||
- hw = mtk_clk_register_gate(gate->name, gate->parent_name,
|
||||
+ hw = mtk_clk_register_gate(dev, gate->name, gate->parent_name,
|
||||
regmap,
|
||||
gate->regs->set_ofs,
|
||||
gate->regs->clr_ofs,
|
||||
gate->regs->sta_ofs,
|
||||
gate->shift, gate->ops,
|
||||
- gate->flags, dev);
|
||||
+ gate->flags);
|
||||
|
||||
if (IS_ERR(hw)) {
|
||||
pr_err("Failed to register clk %s: %pe\n", gate->name,
|
||||
@@ -261,14 +260,6 @@ err:
|
||||
|
||||
return PTR_ERR(hw);
|
||||
}
|
||||
-EXPORT_SYMBOL_GPL(mtk_clk_register_gates_with_dev);
|
||||
-
|
||||
-int mtk_clk_register_gates(struct device_node *node,
|
||||
- const struct mtk_gate *clks, int num,
|
||||
- struct clk_hw_onecell_data *clk_data)
|
||||
-{
|
||||
- return mtk_clk_register_gates_with_dev(node, clks, num, clk_data, NULL);
|
||||
-}
|
||||
EXPORT_SYMBOL_GPL(mtk_clk_register_gates);
|
||||
|
||||
void mtk_clk_unregister_gates(const struct mtk_gate *clks, int num,
|
||||
--- a/drivers/clk/mediatek/clk-gate.h
|
||||
+++ b/drivers/clk/mediatek/clk-gate.h
|
||||
@@ -50,15 +50,10 @@ struct mtk_gate {
|
||||
#define GATE_MTK(_id, _name, _parent, _regs, _shift, _ops) \
|
||||
GATE_MTK_FLAGS(_id, _name, _parent, _regs, _shift, _ops, 0)
|
||||
|
||||
-int mtk_clk_register_gates(struct device_node *node,
|
||||
+int mtk_clk_register_gates(struct device *dev, struct device_node *node,
|
||||
const struct mtk_gate *clks, int num,
|
||||
struct clk_hw_onecell_data *clk_data);
|
||||
|
||||
-int mtk_clk_register_gates_with_dev(struct device_node *node,
|
||||
- const struct mtk_gate *clks, int num,
|
||||
- struct clk_hw_onecell_data *clk_data,
|
||||
- struct device *dev);
|
||||
-
|
||||
void mtk_clk_unregister_gates(const struct mtk_gate *clks, int num,
|
||||
struct clk_hw_onecell_data *clk_data);
|
||||
|
||||
--- a/drivers/clk/mediatek/clk-mt2701-aud.c
|
||||
+++ b/drivers/clk/mediatek/clk-mt2701-aud.c
|
||||
@@ -127,8 +127,8 @@ static int clk_mt2701_aud_probe(struct p
|
||||
|
||||
clk_data = mtk_alloc_clk_data(CLK_AUD_NR);
|
||||
|
||||
- mtk_clk_register_gates(node, audio_clks, ARRAY_SIZE(audio_clks),
|
||||
- clk_data);
|
||||
+ mtk_clk_register_gates(&pdev->dev, node, audio_clks,
|
||||
+ ARRAY_SIZE(audio_clks), clk_data);
|
||||
|
||||
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
|
||||
if (r) {
|
||||
--- a/drivers/clk/mediatek/clk-mt2701-eth.c
|
||||
+++ b/drivers/clk/mediatek/clk-mt2701-eth.c
|
||||
@@ -51,8 +51,8 @@ static int clk_mt2701_eth_probe(struct p
|
||||
|
||||
clk_data = mtk_alloc_clk_data(CLK_ETHSYS_NR);
|
||||
|
||||
- mtk_clk_register_gates(node, eth_clks, ARRAY_SIZE(eth_clks),
|
||||
- clk_data);
|
||||
+ mtk_clk_register_gates(&pdev->dev, node, eth_clks,
|
||||
+ ARRAY_SIZE(eth_clks), clk_data);
|
||||
|
||||
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
|
||||
if (r)
|
||||
--- a/drivers/clk/mediatek/clk-mt2701-g3d.c
|
||||
+++ b/drivers/clk/mediatek/clk-mt2701-g3d.c
|
||||
@@ -45,7 +45,7 @@ static int clk_mt2701_g3dsys_init(struct
|
||||
|
||||
clk_data = mtk_alloc_clk_data(CLK_G3DSYS_NR);
|
||||
|
||||
- mtk_clk_register_gates(node, g3d_clks, ARRAY_SIZE(g3d_clks),
|
||||
+ mtk_clk_register_gates(&pdev->dev, node, g3d_clks, ARRAY_SIZE(g3d_clks),
|
||||
clk_data);
|
||||
|
||||
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
|
||||
--- a/drivers/clk/mediatek/clk-mt2701-hif.c
|
||||
+++ b/drivers/clk/mediatek/clk-mt2701-hif.c
|
||||
@@ -48,8 +48,8 @@ static int clk_mt2701_hif_probe(struct p
|
||||
|
||||
clk_data = mtk_alloc_clk_data(CLK_HIFSYS_NR);
|
||||
|
||||
- mtk_clk_register_gates(node, hif_clks, ARRAY_SIZE(hif_clks),
|
||||
- clk_data);
|
||||
+ mtk_clk_register_gates(&pdev->dev, node, hif_clks,
|
||||
+ ARRAY_SIZE(hif_clks), clk_data);
|
||||
|
||||
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
|
||||
if (r) {
|
||||
--- a/drivers/clk/mediatek/clk-mt2701-mm.c
|
||||
+++ b/drivers/clk/mediatek/clk-mt2701-mm.c
|
||||
@@ -76,8 +76,8 @@ static int clk_mt2701_mm_probe(struct pl
|
||||
|
||||
clk_data = mtk_alloc_clk_data(CLK_MM_NR);
|
||||
|
||||
- mtk_clk_register_gates(node, mm_clks, ARRAY_SIZE(mm_clks),
|
||||
- clk_data);
|
||||
+ mtk_clk_register_gates(&pdev->dev, node, mm_clks,
|
||||
+ ARRAY_SIZE(mm_clks), clk_data);
|
||||
|
||||
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
|
||||
if (r)
|
||||
--- a/drivers/clk/mediatek/clk-mt2701.c
|
||||
+++ b/drivers/clk/mediatek/clk-mt2701.c
|
||||
@@ -685,8 +685,8 @@ static int mtk_topckgen_init(struct plat
|
||||
mtk_clk_register_dividers(top_adj_divs, ARRAY_SIZE(top_adj_divs),
|
||||
base, &mt2701_clk_lock, clk_data);
|
||||
|
||||
- mtk_clk_register_gates(node, top_clks, ARRAY_SIZE(top_clks),
|
||||
- clk_data);
|
||||
+ mtk_clk_register_gates(&pdev->dev, node, top_clks,
|
||||
+ ARRAY_SIZE(top_clks), clk_data);
|
||||
|
||||
return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
|
||||
}
|
||||
@@ -789,8 +789,8 @@ static int mtk_infrasys_init(struct plat
|
||||
}
|
||||
}
|
||||
|
||||
- mtk_clk_register_gates(node, infra_clks, ARRAY_SIZE(infra_clks),
|
||||
- infra_clk_data);
|
||||
+ mtk_clk_register_gates(&pdev->dev, node, infra_clks,
|
||||
+ ARRAY_SIZE(infra_clks), infra_clk_data);
|
||||
mtk_clk_register_factors(infra_fixed_divs, ARRAY_SIZE(infra_fixed_divs),
|
||||
infra_clk_data);
|
||||
|
||||
@@ -902,8 +902,8 @@ static int mtk_pericfg_init(struct platf
|
||||
if (!clk_data)
|
||||
return -ENOMEM;
|
||||
|
||||
- mtk_clk_register_gates(node, peri_clks, ARRAY_SIZE(peri_clks),
|
||||
- clk_data);
|
||||
+ mtk_clk_register_gates(&pdev->dev, node, peri_clks,
|
||||
+ ARRAY_SIZE(peri_clks), clk_data);
|
||||
|
||||
mtk_clk_register_composites(peri_muxs, ARRAY_SIZE(peri_muxs), base,
|
||||
&mt2701_clk_lock, clk_data);
|
||||
--- a/drivers/clk/mediatek/clk-mt2712-mm.c
|
||||
+++ b/drivers/clk/mediatek/clk-mt2712-mm.c
|
||||
@@ -117,8 +117,8 @@ static int clk_mt2712_mm_probe(struct pl
|
||||
|
||||
clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK);
|
||||
|
||||
- mtk_clk_register_gates(node, mm_clks, ARRAY_SIZE(mm_clks),
|
||||
- clk_data);
|
||||
+ mtk_clk_register_gates(&pdev->dev, node, mm_clks,
|
||||
+ ARRAY_SIZE(mm_clks), clk_data);
|
||||
|
||||
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
|
||||
|
||||
--- a/drivers/clk/mediatek/clk-mt2712.c
|
||||
+++ b/drivers/clk/mediatek/clk-mt2712.c
|
||||
@@ -1324,8 +1324,8 @@ static int clk_mt2712_top_probe(struct p
|
||||
&mt2712_clk_lock, top_clk_data);
|
||||
mtk_clk_register_dividers(top_adj_divs, ARRAY_SIZE(top_adj_divs), base,
|
||||
&mt2712_clk_lock, top_clk_data);
|
||||
- mtk_clk_register_gates(node, top_clks, ARRAY_SIZE(top_clks),
|
||||
- top_clk_data);
|
||||
+ mtk_clk_register_gates(&pdev->dev, node, top_clks,
|
||||
+ ARRAY_SIZE(top_clks), top_clk_data);
|
||||
|
||||
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, top_clk_data);
|
||||
|
||||
@@ -1344,8 +1344,8 @@ static int clk_mt2712_infra_probe(struct
|
||||
|
||||
clk_data = mtk_alloc_clk_data(CLK_INFRA_NR_CLK);
|
||||
|
||||
- mtk_clk_register_gates(node, infra_clks, ARRAY_SIZE(infra_clks),
|
||||
- clk_data);
|
||||
+ mtk_clk_register_gates(&pdev->dev, node, infra_clks,
|
||||
+ ARRAY_SIZE(infra_clks), clk_data);
|
||||
|
||||
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
|
||||
|
||||
@@ -1366,8 +1366,8 @@ static int clk_mt2712_peri_probe(struct
|
||||
|
||||
clk_data = mtk_alloc_clk_data(CLK_PERI_NR_CLK);
|
||||
|
||||
- mtk_clk_register_gates(node, peri_clks, ARRAY_SIZE(peri_clks),
|
||||
- clk_data);
|
||||
+ mtk_clk_register_gates(&pdev->dev, node, peri_clks,
|
||||
+ ARRAY_SIZE(peri_clks), clk_data);
|
||||
|
||||
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
|
||||
|
||||
--- a/drivers/clk/mediatek/clk-mt7622-aud.c
|
||||
+++ b/drivers/clk/mediatek/clk-mt7622-aud.c
|
||||
@@ -114,8 +114,8 @@ static int clk_mt7622_audiosys_init(stru
|
||||
|
||||
clk_data = mtk_alloc_clk_data(CLK_AUDIO_NR_CLK);
|
||||
|
||||
- mtk_clk_register_gates(node, audio_clks, ARRAY_SIZE(audio_clks),
|
||||
- clk_data);
|
||||
+ mtk_clk_register_gates(&pdev->dev, node, audio_clks,
|
||||
+ ARRAY_SIZE(audio_clks), clk_data);
|
||||
|
||||
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
|
||||
if (r) {
|
||||
--- a/drivers/clk/mediatek/clk-mt7622-eth.c
|
||||
+++ b/drivers/clk/mediatek/clk-mt7622-eth.c
|
||||
@@ -69,8 +69,8 @@ static int clk_mt7622_ethsys_init(struct
|
||||
|
||||
clk_data = mtk_alloc_clk_data(CLK_ETH_NR_CLK);
|
||||
|
||||
- mtk_clk_register_gates(node, eth_clks, ARRAY_SIZE(eth_clks),
|
||||
- clk_data);
|
||||
+ mtk_clk_register_gates(&pdev->dev, node, eth_clks,
|
||||
+ ARRAY_SIZE(eth_clks), clk_data);
|
||||
|
||||
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
|
||||
if (r)
|
||||
@@ -91,8 +91,8 @@ static int clk_mt7622_sgmiisys_init(stru
|
||||
|
||||
clk_data = mtk_alloc_clk_data(CLK_SGMII_NR_CLK);
|
||||
|
||||
- mtk_clk_register_gates(node, sgmii_clks, ARRAY_SIZE(sgmii_clks),
|
||||
- clk_data);
|
||||
+ mtk_clk_register_gates(&pdev->dev, node, sgmii_clks,
|
||||
+ ARRAY_SIZE(sgmii_clks), clk_data);
|
||||
|
||||
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
|
||||
if (r)
|
||||
--- a/drivers/clk/mediatek/clk-mt7622-hif.c
|
||||
+++ b/drivers/clk/mediatek/clk-mt7622-hif.c
|
||||
@@ -80,8 +80,8 @@ static int clk_mt7622_ssusbsys_init(stru
|
||||
|
||||
clk_data = mtk_alloc_clk_data(CLK_SSUSB_NR_CLK);
|
||||
|
||||
- mtk_clk_register_gates(node, ssusb_clks, ARRAY_SIZE(ssusb_clks),
|
||||
- clk_data);
|
||||
+ mtk_clk_register_gates(&pdev->dev, node, ssusb_clks,
|
||||
+ ARRAY_SIZE(ssusb_clks), clk_data);
|
||||
|
||||
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
|
||||
if (r)
|
||||
@@ -102,8 +102,8 @@ static int clk_mt7622_pciesys_init(struc
|
||||
|
||||
clk_data = mtk_alloc_clk_data(CLK_PCIE_NR_CLK);
|
||||
|
||||
- mtk_clk_register_gates(node, pcie_clks, ARRAY_SIZE(pcie_clks),
|
||||
- clk_data);
|
||||
+ mtk_clk_register_gates(&pdev->dev, node, pcie_clks,
|
||||
+ ARRAY_SIZE(pcie_clks), clk_data);
|
||||
|
||||
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
|
||||
if (r)
|
||||
--- a/drivers/clk/mediatek/clk-mt7622.c
|
||||
+++ b/drivers/clk/mediatek/clk-mt7622.c
|
||||
@@ -621,8 +621,8 @@ static int mtk_topckgen_init(struct plat
|
||||
mtk_clk_register_dividers(top_adj_divs, ARRAY_SIZE(top_adj_divs),
|
||||
base, &mt7622_clk_lock, clk_data);
|
||||
|
||||
- mtk_clk_register_gates(node, top_clks, ARRAY_SIZE(top_clks),
|
||||
- clk_data);
|
||||
+ mtk_clk_register_gates(&pdev->dev, node, top_clks,
|
||||
+ ARRAY_SIZE(top_clks), clk_data);
|
||||
|
||||
return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
|
||||
}
|
||||
@@ -635,8 +635,8 @@ static int mtk_infrasys_init(struct plat
|
||||
|
||||
clk_data = mtk_alloc_clk_data(CLK_INFRA_NR_CLK);
|
||||
|
||||
- mtk_clk_register_gates(node, infra_clks, ARRAY_SIZE(infra_clks),
|
||||
- clk_data);
|
||||
+ mtk_clk_register_gates(&pdev->dev, node, infra_clks,
|
||||
+ ARRAY_SIZE(infra_clks), clk_data);
|
||||
|
||||
mtk_clk_register_cpumuxes(node, infra_muxes, ARRAY_SIZE(infra_muxes),
|
||||
clk_data);
|
||||
@@ -663,7 +663,7 @@ static int mtk_apmixedsys_init(struct pl
|
||||
mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls),
|
||||
clk_data);
|
||||
|
||||
- mtk_clk_register_gates(node, apmixed_clks,
|
||||
+ mtk_clk_register_gates(&pdev->dev, node, apmixed_clks,
|
||||
ARRAY_SIZE(apmixed_clks), clk_data);
|
||||
|
||||
return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
|
||||
@@ -682,8 +682,8 @@ static int mtk_pericfg_init(struct platf
|
||||
|
||||
clk_data = mtk_alloc_clk_data(CLK_PERI_NR_CLK);
|
||||
|
||||
- mtk_clk_register_gates(node, peri_clks, ARRAY_SIZE(peri_clks),
|
||||
- clk_data);
|
||||
+ mtk_clk_register_gates(&pdev->dev, node, peri_clks,
|
||||
+ ARRAY_SIZE(peri_clks), clk_data);
|
||||
|
||||
mtk_clk_register_composites(peri_muxes, ARRAY_SIZE(peri_muxes), base,
|
||||
&mt7622_clk_lock, clk_data);
|
||||
--- a/drivers/clk/mediatek/clk-mt7629-eth.c
|
||||
+++ b/drivers/clk/mediatek/clk-mt7629-eth.c
|
||||
@@ -82,7 +82,8 @@ static int clk_mt7629_ethsys_init(struct
|
||||
if (!clk_data)
|
||||
return -ENOMEM;
|
||||
|
||||
- mtk_clk_register_gates(node, eth_clks, CLK_ETH_NR_CLK, clk_data);
|
||||
+ mtk_clk_register_gates(&pdev->dev, node, eth_clks,
|
||||
+ CLK_ETH_NR_CLK, clk_data);
|
||||
|
||||
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
|
||||
if (r)
|
||||
@@ -106,8 +107,8 @@ static int clk_mt7629_sgmiisys_init(stru
|
||||
if (!clk_data)
|
||||
return -ENOMEM;
|
||||
|
||||
- mtk_clk_register_gates(node, sgmii_clks[id++], CLK_SGMII_NR_CLK,
|
||||
- clk_data);
|
||||
+ mtk_clk_register_gates(&pdev->dev, node, sgmii_clks[id++],
|
||||
+ CLK_SGMII_NR_CLK, clk_data);
|
||||
|
||||
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
|
||||
if (r)
|
||||
--- a/drivers/clk/mediatek/clk-mt7629-hif.c
|
||||
+++ b/drivers/clk/mediatek/clk-mt7629-hif.c
|
||||
@@ -75,8 +75,8 @@ static int clk_mt7629_ssusbsys_init(stru
|
||||
|
||||
clk_data = mtk_alloc_clk_data(CLK_SSUSB_NR_CLK);
|
||||
|
||||
- mtk_clk_register_gates(node, ssusb_clks, ARRAY_SIZE(ssusb_clks),
|
||||
- clk_data);
|
||||
+ mtk_clk_register_gates(&pdev->dev, node, ssusb_clks,
|
||||
+ ARRAY_SIZE(ssusb_clks), clk_data);
|
||||
|
||||
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
|
||||
if (r)
|
||||
@@ -97,8 +97,8 @@ static int clk_mt7629_pciesys_init(struc
|
||||
|
||||
clk_data = mtk_alloc_clk_data(CLK_PCIE_NR_CLK);
|
||||
|
||||
- mtk_clk_register_gates(node, pcie_clks, ARRAY_SIZE(pcie_clks),
|
||||
- clk_data);
|
||||
+ mtk_clk_register_gates(&pdev->dev, node, pcie_clks,
|
||||
+ ARRAY_SIZE(pcie_clks), clk_data);
|
||||
|
||||
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
|
||||
if (r)
|
||||
--- a/drivers/clk/mediatek/clk-mt7629.c
|
||||
+++ b/drivers/clk/mediatek/clk-mt7629.c
|
||||
@@ -585,8 +585,8 @@ static int mtk_infrasys_init(struct plat
|
||||
if (!clk_data)
|
||||
return -ENOMEM;
|
||||
|
||||
- mtk_clk_register_gates(node, infra_clks, ARRAY_SIZE(infra_clks),
|
||||
- clk_data);
|
||||
+ mtk_clk_register_gates(&pdev->dev, node, infra_clks,
|
||||
+ ARRAY_SIZE(infra_clks), clk_data);
|
||||
|
||||
mtk_clk_register_cpumuxes(node, infra_muxes, ARRAY_SIZE(infra_muxes),
|
||||
clk_data);
|
||||
@@ -610,8 +610,8 @@ static int mtk_pericfg_init(struct platf
|
||||
if (!clk_data)
|
||||
return -ENOMEM;
|
||||
|
||||
- mtk_clk_register_gates(node, peri_clks, ARRAY_SIZE(peri_clks),
|
||||
- clk_data);
|
||||
+ mtk_clk_register_gates(&pdev->dev, node, peri_clks,
|
||||
+ ARRAY_SIZE(peri_clks), clk_data);
|
||||
|
||||
mtk_clk_register_composites(peri_muxes, ARRAY_SIZE(peri_muxes), base,
|
||||
&mt7629_clk_lock, clk_data);
|
||||
@@ -637,7 +637,7 @@ static int mtk_apmixedsys_init(struct pl
|
||||
mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls),
|
||||
clk_data);
|
||||
|
||||
- mtk_clk_register_gates(node, apmixed_clks,
|
||||
+ mtk_clk_register_gates(&pdev->dev, node, apmixed_clks,
|
||||
ARRAY_SIZE(apmixed_clks), clk_data);
|
||||
|
||||
clk_prepare_enable(clk_data->hws[CLK_APMIXED_ARMPLL]->clk);
|
||||
--- a/drivers/clk/mediatek/clk-mt7986-eth.c
|
||||
+++ b/drivers/clk/mediatek/clk-mt7986-eth.c
|
||||
@@ -72,8 +72,8 @@ static void __init mtk_sgmiisys_0_init(s
|
||||
|
||||
clk_data = mtk_alloc_clk_data(ARRAY_SIZE(sgmii0_clks));
|
||||
|
||||
- mtk_clk_register_gates(node, sgmii0_clks, ARRAY_SIZE(sgmii0_clks),
|
||||
- clk_data);
|
||||
+ mtk_clk_register_gates(NULL, node, sgmii0_clks,
|
||||
+ ARRAY_SIZE(sgmii0_clks), clk_data);
|
||||
|
||||
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
|
||||
if (r)
|
||||
@@ -90,8 +90,8 @@ static void __init mtk_sgmiisys_1_init(s
|
||||
|
||||
clk_data = mtk_alloc_clk_data(ARRAY_SIZE(sgmii1_clks));
|
||||
|
||||
- mtk_clk_register_gates(node, sgmii1_clks, ARRAY_SIZE(sgmii1_clks),
|
||||
- clk_data);
|
||||
+ mtk_clk_register_gates(NULL, node, sgmii1_clks,
|
||||
+ ARRAY_SIZE(sgmii1_clks), clk_data);
|
||||
|
||||
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
|
||||
|
||||
@@ -109,7 +109,7 @@ static void __init mtk_ethsys_init(struc
|
||||
|
||||
clk_data = mtk_alloc_clk_data(ARRAY_SIZE(eth_clks));
|
||||
|
||||
- mtk_clk_register_gates(node, eth_clks, ARRAY_SIZE(eth_clks), clk_data);
|
||||
+ mtk_clk_register_gates(NULL, node, eth_clks, ARRAY_SIZE(eth_clks), clk_data);
|
||||
|
||||
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
|
||||
|
||||
--- a/drivers/clk/mediatek/clk-mt7986-infracfg.c
|
||||
+++ b/drivers/clk/mediatek/clk-mt7986-infracfg.c
|
||||
@@ -180,8 +180,8 @@ static int clk_mt7986_infracfg_probe(str
|
||||
mtk_clk_register_factors(infra_divs, ARRAY_SIZE(infra_divs), clk_data);
|
||||
mtk_clk_register_muxes(infra_muxes, ARRAY_SIZE(infra_muxes), node,
|
||||
&mt7986_clk_lock, clk_data);
|
||||
- mtk_clk_register_gates(node, infra_clks, ARRAY_SIZE(infra_clks),
|
||||
- clk_data);
|
||||
+ mtk_clk_register_gates(&pdev->dev, node, infra_clks,
|
||||
+ ARRAY_SIZE(infra_clks), clk_data);
|
||||
|
||||
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
|
||||
if (r) {
|
||||
--- a/drivers/clk/mediatek/clk-mtk.c
|
||||
+++ b/drivers/clk/mediatek/clk-mtk.c
|
||||
@@ -459,8 +459,8 @@ int mtk_clk_simple_probe(struct platform
|
||||
if (!clk_data)
|
||||
return -ENOMEM;
|
||||
|
||||
- r = mtk_clk_register_gates_with_dev(node, mcd->clks, mcd->num_clks,
|
||||
- clk_data, &pdev->dev);
|
||||
+ r = mtk_clk_register_gates(&pdev->dev, node, mcd->clks, mcd->num_clks,
|
||||
+ clk_data);
|
||||
if (r)
|
||||
goto free_data;
|
||||
|
@ -1,140 +0,0 @@
|
||||
From b888303c7d23d7bd0c8667cfc657669e5d153fea Mon Sep 17 00:00:00 2001
|
||||
From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Date: Fri, 20 Jan 2023 10:20:34 +0100
|
||||
Subject: [PATCH 02/15] clk: mediatek: cpumux: Propagate struct device where
|
||||
possible
|
||||
|
||||
Take a pointer to a struct device in mtk_clk_register_cpumuxes() and
|
||||
propagate the same to mtk_clk_register_cpumux() => clk_hw_register().
|
||||
Even though runtime pm is unlikely to be used with CPU muxes, this
|
||||
helps with code consistency and possibly opens to commonization of
|
||||
some mtk_clk_register_(x) functions.
|
||||
|
||||
Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
|
||||
Reviewed-by: Markus Schneider-Pargmann <msp@baylibre.com>
|
||||
Tested-by: Miles Chen <miles.chen@mediatek.com>
|
||||
Link: https://lore.kernel.org/r/20230120092053.182923-5-angelogioacchino.delregno@collabora.com
|
||||
Tested-by: Mingming Su <mingming.su@mediatek.com>
|
||||
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
|
||||
---
|
||||
drivers/clk/mediatek/clk-cpumux.c | 8 ++++----
|
||||
drivers/clk/mediatek/clk-cpumux.h | 2 +-
|
||||
drivers/clk/mediatek/clk-mt2701.c | 2 +-
|
||||
drivers/clk/mediatek/clk-mt6795-infracfg.c | 3 ++-
|
||||
drivers/clk/mediatek/clk-mt7622.c | 4 ++--
|
||||
drivers/clk/mediatek/clk-mt7629.c | 4 ++--
|
||||
drivers/clk/mediatek/clk-mt8173.c | 4 ++--
|
||||
7 files changed, 14 insertions(+), 13 deletions(-)
|
||||
|
||||
--- a/drivers/clk/mediatek/clk-cpumux.c
|
||||
+++ b/drivers/clk/mediatek/clk-cpumux.c
|
||||
@@ -58,7 +58,7 @@ static const struct clk_ops clk_cpumux_o
|
||||
};
|
||||
|
||||
static struct clk_hw *
|
||||
-mtk_clk_register_cpumux(const struct mtk_composite *mux,
|
||||
+mtk_clk_register_cpumux(struct device *dev, const struct mtk_composite *mux,
|
||||
struct regmap *regmap)
|
||||
{
|
||||
struct mtk_clk_cpumux *cpumux;
|
||||
@@ -81,7 +81,7 @@ mtk_clk_register_cpumux(const struct mtk
|
||||
cpumux->regmap = regmap;
|
||||
cpumux->hw.init = &init;
|
||||
|
||||
- ret = clk_hw_register(NULL, &cpumux->hw);
|
||||
+ ret = clk_hw_register(dev, &cpumux->hw);
|
||||
if (ret) {
|
||||
kfree(cpumux);
|
||||
return ERR_PTR(ret);
|
||||
@@ -102,7 +102,7 @@ static void mtk_clk_unregister_cpumux(st
|
||||
kfree(cpumux);
|
||||
}
|
||||
|
||||
-int mtk_clk_register_cpumuxes(struct device_node *node,
|
||||
+int mtk_clk_register_cpumuxes(struct device *dev, struct device_node *node,
|
||||
const struct mtk_composite *clks, int num,
|
||||
struct clk_hw_onecell_data *clk_data)
|
||||
{
|
||||
@@ -125,7 +125,7 @@ int mtk_clk_register_cpumuxes(struct dev
|
||||
continue;
|
||||
}
|
||||
|
||||
- hw = mtk_clk_register_cpumux(mux, regmap);
|
||||
+ hw = mtk_clk_register_cpumux(dev, mux, regmap);
|
||||
if (IS_ERR(hw)) {
|
||||
pr_err("Failed to register clk %s: %pe\n", mux->name,
|
||||
hw);
|
||||
--- a/drivers/clk/mediatek/clk-cpumux.h
|
||||
+++ b/drivers/clk/mediatek/clk-cpumux.h
|
||||
@@ -11,7 +11,7 @@ struct clk_hw_onecell_data;
|
||||
struct device_node;
|
||||
struct mtk_composite;
|
||||
|
||||
-int mtk_clk_register_cpumuxes(struct device_node *node,
|
||||
+int mtk_clk_register_cpumuxes(struct device *dev, struct device_node *node,
|
||||
const struct mtk_composite *clks, int num,
|
||||
struct clk_hw_onecell_data *clk_data);
|
||||
|
||||
--- a/drivers/clk/mediatek/clk-mt2701.c
|
||||
+++ b/drivers/clk/mediatek/clk-mt2701.c
|
||||
@@ -761,7 +761,7 @@ static void __init mtk_infrasys_init_ear
|
||||
mtk_clk_register_factors(infra_fixed_divs, ARRAY_SIZE(infra_fixed_divs),
|
||||
infra_clk_data);
|
||||
|
||||
- mtk_clk_register_cpumuxes(node, cpu_muxes, ARRAY_SIZE(cpu_muxes),
|
||||
+ mtk_clk_register_cpumuxes(NULL, node, cpu_muxes, ARRAY_SIZE(cpu_muxes),
|
||||
infra_clk_data);
|
||||
|
||||
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get,
|
||||
--- a/drivers/clk/mediatek/clk-mt6795-infracfg.c
|
||||
+++ b/drivers/clk/mediatek/clk-mt6795-infracfg.c
|
||||
@@ -105,7 +105,8 @@ static int clk_mt6795_infracfg_probe(str
|
||||
if (ret)
|
||||
goto free_clk_data;
|
||||
|
||||
- ret = mtk_clk_register_cpumuxes(node, cpu_muxes, ARRAY_SIZE(cpu_muxes), clk_data);
|
||||
+ ret = mtk_clk_register_cpumuxes(&pdev->dev, node, cpu_muxes,
|
||||
+ ARRAY_SIZE(cpu_muxes), clk_data);
|
||||
if (ret)
|
||||
goto unregister_gates;
|
||||
|
||||
--- a/drivers/clk/mediatek/clk-mt7622.c
|
||||
+++ b/drivers/clk/mediatek/clk-mt7622.c
|
||||
@@ -638,8 +638,8 @@ static int mtk_infrasys_init(struct plat
|
||||
mtk_clk_register_gates(&pdev->dev, node, infra_clks,
|
||||
ARRAY_SIZE(infra_clks), clk_data);
|
||||
|
||||
- mtk_clk_register_cpumuxes(node, infra_muxes, ARRAY_SIZE(infra_muxes),
|
||||
- clk_data);
|
||||
+ mtk_clk_register_cpumuxes(&pdev->dev, node, infra_muxes,
|
||||
+ ARRAY_SIZE(infra_muxes), clk_data);
|
||||
|
||||
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get,
|
||||
clk_data);
|
||||
--- a/drivers/clk/mediatek/clk-mt7629.c
|
||||
+++ b/drivers/clk/mediatek/clk-mt7629.c
|
||||
@@ -588,8 +588,8 @@ static int mtk_infrasys_init(struct plat
|
||||
mtk_clk_register_gates(&pdev->dev, node, infra_clks,
|
||||
ARRAY_SIZE(infra_clks), clk_data);
|
||||
|
||||
- mtk_clk_register_cpumuxes(node, infra_muxes, ARRAY_SIZE(infra_muxes),
|
||||
- clk_data);
|
||||
+ mtk_clk_register_cpumuxes(&pdev->dev, node, infra_muxes,
|
||||
+ ARRAY_SIZE(infra_muxes), clk_data);
|
||||
|
||||
return of_clk_add_hw_provider(node, of_clk_hw_onecell_get,
|
||||
clk_data);
|
||||
--- a/drivers/clk/mediatek/clk-mt8173.c
|
||||
+++ b/drivers/clk/mediatek/clk-mt8173.c
|
||||
@@ -892,8 +892,8 @@ static void __init mtk_infrasys_init(str
|
||||
clk_data);
|
||||
mtk_clk_register_factors(infra_divs, ARRAY_SIZE(infra_divs), clk_data);
|
||||
|
||||
- mtk_clk_register_cpumuxes(node, cpu_muxes, ARRAY_SIZE(cpu_muxes),
|
||||
- clk_data);
|
||||
+ mtk_clk_register_cpumuxes(NULL, node, cpu_muxes,
|
||||
+ ARRAY_SIZE(cpu_muxes), clk_data);
|
||||
|
||||
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
|
||||
if (r)
|
@ -1,181 +0,0 @@
|
||||
From f23375db001ec0fe9f565be75eff43adde15407e Mon Sep 17 00:00:00 2001
|
||||
From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Date: Fri, 20 Jan 2023 10:20:35 +0100
|
||||
Subject: [PATCH 03/15] clk: mediatek: clk-mtk: Propagate struct device for
|
||||
composites
|
||||
|
||||
Like done for cpumux clocks, propagate struct device for composite
|
||||
clocks registered through clk-mtk helpers to be able to get runtime
|
||||
pm support for MTK clocks.
|
||||
|
||||
Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Tested-by: Miles Chen <miles.chen@mediatek.com>
|
||||
Link: https://lore.kernel.org/r/20230120092053.182923-6-angelogioacchino.delregno@collabora.com
|
||||
Tested-by: Mingming Su <mingming.su@mediatek.com>
|
||||
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
|
||||
|
||||
[daniel@makrotopia.org: remove parts not relevant for OpenWrt]
|
||||
---
|
||||
drivers/clk/mediatek/clk-mt2701.c | 10 ++++++----
|
||||
drivers/clk/mediatek/clk-mt2712.c | 12 ++++++++----
|
||||
drivers/clk/mediatek/clk-mt7622.c | 8 +++++---
|
||||
drivers/clk/mediatek/clk-mt7629.c | 8 +++++---
|
||||
drivers/clk/mediatek/clk-mtk.c | 11 ++++++-----
|
||||
drivers/clk/mediatek/clk-mtk.h | 3 ++-
|
||||
6 files changed, 32 insertions(+), 20 deletions(-)
|
||||
|
||||
--- a/drivers/clk/mediatek/clk-mt2701.c
|
||||
+++ b/drivers/clk/mediatek/clk-mt2701.c
|
||||
@@ -679,8 +679,9 @@ static int mtk_topckgen_init(struct plat
|
||||
mtk_clk_register_factors(top_fixed_divs, ARRAY_SIZE(top_fixed_divs),
|
||||
clk_data);
|
||||
|
||||
- mtk_clk_register_composites(top_muxes, ARRAY_SIZE(top_muxes),
|
||||
- base, &mt2701_clk_lock, clk_data);
|
||||
+ mtk_clk_register_composites(&pdev->dev, top_muxes,
|
||||
+ ARRAY_SIZE(top_muxes), base,
|
||||
+ &mt2701_clk_lock, clk_data);
|
||||
|
||||
mtk_clk_register_dividers(top_adj_divs, ARRAY_SIZE(top_adj_divs),
|
||||
base, &mt2701_clk_lock, clk_data);
|
||||
@@ -905,8 +906,9 @@ static int mtk_pericfg_init(struct platf
|
||||
mtk_clk_register_gates(&pdev->dev, node, peri_clks,
|
||||
ARRAY_SIZE(peri_clks), clk_data);
|
||||
|
||||
- mtk_clk_register_composites(peri_muxs, ARRAY_SIZE(peri_muxs), base,
|
||||
- &mt2701_clk_lock, clk_data);
|
||||
+ mtk_clk_register_composites(&pdev->dev, peri_muxs,
|
||||
+ ARRAY_SIZE(peri_muxs), base,
|
||||
+ &mt2701_clk_lock, clk_data);
|
||||
|
||||
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
|
||||
if (r)
|
||||
--- a/drivers/clk/mediatek/clk-mt2712.c
|
||||
+++ b/drivers/clk/mediatek/clk-mt2712.c
|
||||
@@ -1320,8 +1320,9 @@ static int clk_mt2712_top_probe(struct p
|
||||
mtk_clk_register_factors(top_early_divs, ARRAY_SIZE(top_early_divs),
|
||||
top_clk_data);
|
||||
mtk_clk_register_factors(top_divs, ARRAY_SIZE(top_divs), top_clk_data);
|
||||
- mtk_clk_register_composites(top_muxes, ARRAY_SIZE(top_muxes), base,
|
||||
- &mt2712_clk_lock, top_clk_data);
|
||||
+ mtk_clk_register_composites(&pdev->dev, top_muxes,
|
||||
+ ARRAY_SIZE(top_muxes), base,
|
||||
+ &mt2712_clk_lock, top_clk_data);
|
||||
mtk_clk_register_dividers(top_adj_divs, ARRAY_SIZE(top_adj_divs), base,
|
||||
&mt2712_clk_lock, top_clk_data);
|
||||
mtk_clk_register_gates(&pdev->dev, node, top_clks,
|
||||
@@ -1395,8 +1396,11 @@ static int clk_mt2712_mcu_probe(struct p
|
||||
|
||||
clk_data = mtk_alloc_clk_data(CLK_MCU_NR_CLK);
|
||||
|
||||
- mtk_clk_register_composites(mcu_muxes, ARRAY_SIZE(mcu_muxes), base,
|
||||
- &mt2712_clk_lock, clk_data);
|
||||
+ r = mtk_clk_register_composites(&pdev->dev, mcu_muxes,
|
||||
+ ARRAY_SIZE(mcu_muxes), base,
|
||||
+ &mt2712_clk_lock, clk_data);
|
||||
+ if (r)
|
||||
+ dev_err(&pdev->dev, "Could not register composites: %d\n", r);
|
||||
|
||||
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
|
||||
|
||||
--- a/drivers/clk/mediatek/clk-mt7622.c
|
||||
+++ b/drivers/clk/mediatek/clk-mt7622.c
|
||||
@@ -615,8 +615,9 @@ static int mtk_topckgen_init(struct plat
|
||||
mtk_clk_register_factors(top_divs, ARRAY_SIZE(top_divs),
|
||||
clk_data);
|
||||
|
||||
- mtk_clk_register_composites(top_muxes, ARRAY_SIZE(top_muxes),
|
||||
- base, &mt7622_clk_lock, clk_data);
|
||||
+ mtk_clk_register_composites(&pdev->dev, top_muxes,
|
||||
+ ARRAY_SIZE(top_muxes), base,
|
||||
+ &mt7622_clk_lock, clk_data);
|
||||
|
||||
mtk_clk_register_dividers(top_adj_divs, ARRAY_SIZE(top_adj_divs),
|
||||
base, &mt7622_clk_lock, clk_data);
|
||||
@@ -685,7 +686,8 @@ static int mtk_pericfg_init(struct platf
|
||||
mtk_clk_register_gates(&pdev->dev, node, peri_clks,
|
||||
ARRAY_SIZE(peri_clks), clk_data);
|
||||
|
||||
- mtk_clk_register_composites(peri_muxes, ARRAY_SIZE(peri_muxes), base,
|
||||
+ mtk_clk_register_composites(&pdev->dev, peri_muxes,
|
||||
+ ARRAY_SIZE(peri_muxes), base,
|
||||
&mt7622_clk_lock, clk_data);
|
||||
|
||||
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
|
||||
--- a/drivers/clk/mediatek/clk-mt7629.c
|
||||
+++ b/drivers/clk/mediatek/clk-mt7629.c
|
||||
@@ -566,8 +566,9 @@ static int mtk_topckgen_init(struct plat
|
||||
mtk_clk_register_factors(top_divs, ARRAY_SIZE(top_divs),
|
||||
clk_data);
|
||||
|
||||
- mtk_clk_register_composites(top_muxes, ARRAY_SIZE(top_muxes),
|
||||
- base, &mt7629_clk_lock, clk_data);
|
||||
+ mtk_clk_register_composites(&pdev->dev, top_muxes,
|
||||
+ ARRAY_SIZE(top_muxes), base,
|
||||
+ &mt7629_clk_lock, clk_data);
|
||||
|
||||
clk_prepare_enable(clk_data->hws[CLK_TOP_AXI_SEL]->clk);
|
||||
clk_prepare_enable(clk_data->hws[CLK_TOP_MEM_SEL]->clk);
|
||||
@@ -613,7 +614,8 @@ static int mtk_pericfg_init(struct platf
|
||||
mtk_clk_register_gates(&pdev->dev, node, peri_clks,
|
||||
ARRAY_SIZE(peri_clks), clk_data);
|
||||
|
||||
- mtk_clk_register_composites(peri_muxes, ARRAY_SIZE(peri_muxes), base,
|
||||
+ mtk_clk_register_composites(&pdev->dev, peri_muxes,
|
||||
+ ARRAY_SIZE(peri_muxes), base,
|
||||
&mt7629_clk_lock, clk_data);
|
||||
|
||||
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
|
||||
--- a/drivers/clk/mediatek/clk-mtk.c
|
||||
+++ b/drivers/clk/mediatek/clk-mtk.c
|
||||
@@ -197,8 +197,8 @@ void mtk_clk_unregister_factors(const st
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mtk_clk_unregister_factors);
|
||||
|
||||
-static struct clk_hw *mtk_clk_register_composite(const struct mtk_composite *mc,
|
||||
- void __iomem *base, spinlock_t *lock)
|
||||
+static struct clk_hw *mtk_clk_register_composite(struct device *dev,
|
||||
+ const struct mtk_composite *mc, void __iomem *base, spinlock_t *lock)
|
||||
{
|
||||
struct clk_hw *hw;
|
||||
struct clk_mux *mux = NULL;
|
||||
@@ -264,7 +264,7 @@ static struct clk_hw *mtk_clk_register_c
|
||||
div_ops = &clk_divider_ops;
|
||||
}
|
||||
|
||||
- hw = clk_hw_register_composite(NULL, mc->name, parent_names, num_parents,
|
||||
+ hw = clk_hw_register_composite(dev, mc->name, parent_names, num_parents,
|
||||
mux_hw, mux_ops,
|
||||
div_hw, div_ops,
|
||||
gate_hw, gate_ops,
|
||||
@@ -308,7 +308,8 @@ static void mtk_clk_unregister_composite
|
||||
kfree(mux);
|
||||
}
|
||||
|
||||
-int mtk_clk_register_composites(const struct mtk_composite *mcs, int num,
|
||||
+int mtk_clk_register_composites(struct device *dev,
|
||||
+ const struct mtk_composite *mcs, int num,
|
||||
void __iomem *base, spinlock_t *lock,
|
||||
struct clk_hw_onecell_data *clk_data)
|
||||
{
|
||||
@@ -327,7 +328,7 @@ int mtk_clk_register_composites(const st
|
||||
continue;
|
||||
}
|
||||
|
||||
- hw = mtk_clk_register_composite(mc, base, lock);
|
||||
+ hw = mtk_clk_register_composite(dev, mc, base, lock);
|
||||
|
||||
if (IS_ERR(hw)) {
|
||||
pr_err("Failed to register clk %s: %pe\n", mc->name,
|
||||
--- a/drivers/clk/mediatek/clk-mtk.h
|
||||
+++ b/drivers/clk/mediatek/clk-mtk.h
|
||||
@@ -149,7 +149,8 @@ struct mtk_composite {
|
||||
.flags = 0, \
|
||||
}
|
||||
|
||||
-int mtk_clk_register_composites(const struct mtk_composite *mcs, int num,
|
||||
+int mtk_clk_register_composites(struct device *dev,
|
||||
+ const struct mtk_composite *mcs, int num,
|
||||
void __iomem *base, spinlock_t *lock,
|
||||
struct clk_hw_onecell_data *clk_data);
|
||||
void mtk_clk_unregister_composites(const struct mtk_composite *mcs, int num,
|
@ -1,103 +0,0 @@
|
||||
From 5d911479e4c732729bfa798e4a9e3e5aec3e30a7 Mon Sep 17 00:00:00 2001
|
||||
From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Date: Fri, 20 Jan 2023 10:20:36 +0100
|
||||
Subject: [PATCH 04/15] clk: mediatek: clk-mux: Propagate struct device for
|
||||
mtk-mux
|
||||
|
||||
Like done for other clocks, propagate struct device for mtk mux clocks
|
||||
registered through clk-mux helpers to enable runtime pm support.
|
||||
|
||||
Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Tested-by: Miles Chen <miles.chen@mediatek.com>
|
||||
Link: https://lore.kernel.org/r/20230120092053.182923-7-angelogioacchino.delregno@collabora.com
|
||||
Tested-by: Mingming Su <mingming.su@mediatek.com>
|
||||
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
|
||||
|
||||
[daniel@makrotopia.org: removed parts not relevant for OpenWrt]
|
||||
---
|
||||
drivers/clk/mediatek/clk-mt7986-infracfg.c | 3 ++-
|
||||
drivers/clk/mediatek/clk-mt7986-topckgen.c | 3 ++-
|
||||
drivers/clk/mediatek/clk-mux.c | 14 ++++++++------
|
||||
drivers/clk/mediatek/clk-mux.h | 3 ++-
|
||||
4 files changed, 14 insertions(+), 9 deletions(-)
|
||||
|
||||
--- a/drivers/clk/mediatek/clk-mt7986-infracfg.c
|
||||
+++ b/drivers/clk/mediatek/clk-mt7986-infracfg.c
|
||||
@@ -178,7 +178,8 @@ static int clk_mt7986_infracfg_probe(str
|
||||
return -ENOMEM;
|
||||
|
||||
mtk_clk_register_factors(infra_divs, ARRAY_SIZE(infra_divs), clk_data);
|
||||
- mtk_clk_register_muxes(infra_muxes, ARRAY_SIZE(infra_muxes), node,
|
||||
+ mtk_clk_register_muxes(&pdev->dev, infra_muxes,
|
||||
+ ARRAY_SIZE(infra_muxes), node,
|
||||
&mt7986_clk_lock, clk_data);
|
||||
mtk_clk_register_gates(&pdev->dev, node, infra_clks,
|
||||
ARRAY_SIZE(infra_clks), clk_data);
|
||||
--- a/drivers/clk/mediatek/clk-mt7986-topckgen.c
|
||||
+++ b/drivers/clk/mediatek/clk-mt7986-topckgen.c
|
||||
@@ -303,7 +303,8 @@ static int clk_mt7986_topckgen_probe(str
|
||||
mtk_clk_register_fixed_clks(top_fixed_clks, ARRAY_SIZE(top_fixed_clks),
|
||||
clk_data);
|
||||
mtk_clk_register_factors(top_divs, ARRAY_SIZE(top_divs), clk_data);
|
||||
- mtk_clk_register_muxes(top_muxes, ARRAY_SIZE(top_muxes), node,
|
||||
+ mtk_clk_register_muxes(&pdev->dev, top_muxes,
|
||||
+ ARRAY_SIZE(top_muxes), node,
|
||||
&mt7986_clk_lock, clk_data);
|
||||
|
||||
clk_prepare_enable(clk_data->hws[CLK_TOP_SYSAXI_SEL]->clk);
|
||||
--- a/drivers/clk/mediatek/clk-mux.c
|
||||
+++ b/drivers/clk/mediatek/clk-mux.c
|
||||
@@ -154,9 +154,10 @@ const struct clk_ops mtk_mux_gate_clr_se
|
||||
};
|
||||
EXPORT_SYMBOL_GPL(mtk_mux_gate_clr_set_upd_ops);
|
||||
|
||||
-static struct clk_hw *mtk_clk_register_mux(const struct mtk_mux *mux,
|
||||
- struct regmap *regmap,
|
||||
- spinlock_t *lock)
|
||||
+static struct clk_hw *mtk_clk_register_mux(struct device *dev,
|
||||
+ const struct mtk_mux *mux,
|
||||
+ struct regmap *regmap,
|
||||
+ spinlock_t *lock)
|
||||
{
|
||||
struct mtk_clk_mux *clk_mux;
|
||||
struct clk_init_data init = {};
|
||||
@@ -177,7 +178,7 @@ static struct clk_hw *mtk_clk_register_m
|
||||
clk_mux->lock = lock;
|
||||
clk_mux->hw.init = &init;
|
||||
|
||||
- ret = clk_hw_register(NULL, &clk_mux->hw);
|
||||
+ ret = clk_hw_register(dev, &clk_mux->hw);
|
||||
if (ret) {
|
||||
kfree(clk_mux);
|
||||
return ERR_PTR(ret);
|
||||
@@ -198,7 +199,8 @@ static void mtk_clk_unregister_mux(struc
|
||||
kfree(mux);
|
||||
}
|
||||
|
||||
-int mtk_clk_register_muxes(const struct mtk_mux *muxes,
|
||||
+int mtk_clk_register_muxes(struct device *dev,
|
||||
+ const struct mtk_mux *muxes,
|
||||
int num, struct device_node *node,
|
||||
spinlock_t *lock,
|
||||
struct clk_hw_onecell_data *clk_data)
|
||||
@@ -222,7 +224,7 @@ int mtk_clk_register_muxes(const struct
|
||||
continue;
|
||||
}
|
||||
|
||||
- hw = mtk_clk_register_mux(mux, regmap, lock);
|
||||
+ hw = mtk_clk_register_mux(dev, mux, regmap, lock);
|
||||
|
||||
if (IS_ERR(hw)) {
|
||||
pr_err("Failed to register clk %s: %pe\n", mux->name,
|
||||
--- a/drivers/clk/mediatek/clk-mux.h
|
||||
+++ b/drivers/clk/mediatek/clk-mux.h
|
||||
@@ -83,7 +83,8 @@ extern const struct clk_ops mtk_mux_gate
|
||||
0, _upd_ofs, _upd, CLK_SET_RATE_PARENT, \
|
||||
mtk_mux_clr_set_upd_ops)
|
||||
|
||||
-int mtk_clk_register_muxes(const struct mtk_mux *muxes,
|
||||
+int mtk_clk_register_muxes(struct device *dev,
|
||||
+ const struct mtk_mux *muxes,
|
||||
int num, struct device_node *node,
|
||||
spinlock_t *lock,
|
||||
struct clk_hw_onecell_data *clk_data);
|
@ -1,74 +0,0 @@
|
||||
From b8eb1081d267708ba976525a1fe2162901b34f3a Mon Sep 17 00:00:00 2001
|
||||
From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Date: Fri, 20 Jan 2023 10:20:37 +0100
|
||||
Subject: [PATCH] clk: mediatek: clk-mtk: Add dummy clock ops
|
||||
|
||||
In order to migrate some (few) old clock drivers to the common
|
||||
mtk_clk_simple_probe() function, add dummy clock ops to be able
|
||||
to insert a dummy clock with ID 0 at the beginning of the list.
|
||||
|
||||
Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Reviewed-by: Miles Chen <miles.chen@mediatek.com>
|
||||
Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
|
||||
Tested-by: Miles Chen <miles.chen@mediatek.com>
|
||||
Link: https://lore.kernel.org/r/20230120092053.182923-8-angelogioacchino.delregno@collabora.com
|
||||
Tested-by: Mingming Su <mingming.su@mediatek.com>
|
||||
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
|
||||
---
|
||||
drivers/clk/mediatek/clk-mtk.c | 16 ++++++++++++++++
|
||||
drivers/clk/mediatek/clk-mtk.h | 19 +++++++++++++++++++
|
||||
2 files changed, 35 insertions(+)
|
||||
|
||||
--- a/drivers/clk/mediatek/clk-mtk.c
|
||||
+++ b/drivers/clk/mediatek/clk-mtk.c
|
||||
@@ -18,6 +18,22 @@
|
||||
#include "clk-mtk.h"
|
||||
#include "clk-gate.h"
|
||||
|
||||
+const struct mtk_gate_regs cg_regs_dummy = { 0, 0, 0 };
|
||||
+EXPORT_SYMBOL_GPL(cg_regs_dummy);
|
||||
+
|
||||
+static int mtk_clk_dummy_enable(struct clk_hw *hw)
|
||||
+{
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void mtk_clk_dummy_disable(struct clk_hw *hw) { }
|
||||
+
|
||||
+const struct clk_ops mtk_clk_dummy_ops = {
|
||||
+ .enable = mtk_clk_dummy_enable,
|
||||
+ .disable = mtk_clk_dummy_disable,
|
||||
+};
|
||||
+EXPORT_SYMBOL_GPL(mtk_clk_dummy_ops);
|
||||
+
|
||||
static void mtk_init_clk_data(struct clk_hw_onecell_data *clk_data,
|
||||
unsigned int clk_num)
|
||||
{
|
||||
--- a/drivers/clk/mediatek/clk-mtk.h
|
||||
+++ b/drivers/clk/mediatek/clk-mtk.h
|
||||
@@ -22,6 +22,25 @@
|
||||
|
||||
struct platform_device;
|
||||
|
||||
+/*
|
||||
+ * We need the clock IDs to start from zero but to maintain devicetree
|
||||
+ * backwards compatibility we can't change bindings to start from zero.
|
||||
+ * Only a few platforms are affected, so we solve issues given by the
|
||||
+ * commonized MTK clocks probe function(s) by adding a dummy clock at
|
||||
+ * the beginning where needed.
|
||||
+ */
|
||||
+#define CLK_DUMMY 0
|
||||
+
|
||||
+extern const struct clk_ops mtk_clk_dummy_ops;
|
||||
+extern const struct mtk_gate_regs cg_regs_dummy;
|
||||
+
|
||||
+#define GATE_DUMMY(_id, _name) { \
|
||||
+ .id = _id, \
|
||||
+ .name = _name, \
|
||||
+ .regs = &cg_regs_dummy, \
|
||||
+ .ops = &mtk_clk_dummy_ops, \
|
||||
+ }
|
||||
+
|
||||
struct mtk_fixed_clk {
|
||||
int id;
|
||||
const char *name;
|
@ -1,790 +0,0 @@
|
||||
From c26e28015b74af73e0b299f6ad3ff22931e600b4 Mon Sep 17 00:00:00 2001
|
||||
From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Date: Fri, 20 Jan 2023 10:20:41 +0100
|
||||
Subject: [PATCH 05/15] clk: mediatek: Switch to mtk_clk_simple_probe() where
|
||||
possible
|
||||
|
||||
mtk_clk_simple_probe() is a function that registers mtk gate clocks
|
||||
and, if reset data is present, a reset controller and across all of
|
||||
the MTK clock drivers, such a function is duplicated many times:
|
||||
switch to the common mtk_clk_simple_probe() function for all of the
|
||||
clock drivers that are registering as platform drivers.
|
||||
|
||||
Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Reviewed-by: Miles Chen <miles.chen@mediatek.com>
|
||||
Tested-by: Miles Chen <miles.chen@mediatek.com>
|
||||
Link: https://lore.kernel.org/r/20230120092053.182923-12-angelogioacchino.delregno@collabora.com
|
||||
Tested-by: Mingming Su <mingming.su@mediatek.com>
|
||||
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
|
||||
|
||||
[daniel@makrotopia.org: removed parts not relevant for OpenWrt]
|
||||
---
|
||||
drivers/clk/mediatek/clk-mt2701-aud.c | 31 ++++++----
|
||||
drivers/clk/mediatek/clk-mt2701-eth.c | 36 ++++--------
|
||||
drivers/clk/mediatek/clk-mt2701-g3d.c | 56 ++++--------------
|
||||
drivers/clk/mediatek/clk-mt2701-hif.c | 38 ++++--------
|
||||
drivers/clk/mediatek/clk-mt2712.c | 83 ++++++++++----------------
|
||||
drivers/clk/mediatek/clk-mt7622-aud.c | 54 ++++++-----------
|
||||
drivers/clk/mediatek/clk-mt7622-eth.c | 82 +++++---------------------
|
||||
drivers/clk/mediatek/clk-mt7622-hif.c | 85 +++++----------------------
|
||||
drivers/clk/mediatek/clk-mt7629-hif.c | 85 +++++----------------------
|
||||
9 files changed, 144 insertions(+), 406 deletions(-)
|
||||
|
||||
--- a/drivers/clk/mediatek/clk-mt2701-aud.c
|
||||
+++ b/drivers/clk/mediatek/clk-mt2701-aud.c
|
||||
@@ -52,6 +52,7 @@ static const struct mtk_gate_regs audio3
|
||||
};
|
||||
|
||||
static const struct mtk_gate audio_clks[] = {
|
||||
+ GATE_DUMMY(CLK_DUMMY, "aud_dummy"),
|
||||
/* AUDIO0 */
|
||||
GATE_AUDIO0(CLK_AUD_AFE, "audio_afe", "aud_intbus_sel", 2),
|
||||
GATE_AUDIO0(CLK_AUD_HDMI, "audio_hdmi", "audpll_sel", 20),
|
||||
@@ -114,29 +115,27 @@ static const struct mtk_gate audio_clks[
|
||||
GATE_AUDIO3(CLK_AUD_MEM_ASRC5, "audio_mem_asrc5", "asm_h_sel", 14),
|
||||
};
|
||||
|
||||
+static const struct mtk_clk_desc audio_desc = {
|
||||
+ .clks = audio_clks,
|
||||
+ .num_clks = ARRAY_SIZE(audio_clks),
|
||||
+};
|
||||
+
|
||||
static const struct of_device_id of_match_clk_mt2701_aud[] = {
|
||||
- { .compatible = "mediatek,mt2701-audsys", },
|
||||
- {}
|
||||
+ { .compatible = "mediatek,mt2701-audsys", .data = &audio_desc },
|
||||
+ { /* sentinel */ }
|
||||
};
|
||||
|
||||
static int clk_mt2701_aud_probe(struct platform_device *pdev)
|
||||
{
|
||||
- struct clk_hw_onecell_data *clk_data;
|
||||
- struct device_node *node = pdev->dev.of_node;
|
||||
int r;
|
||||
|
||||
- clk_data = mtk_alloc_clk_data(CLK_AUD_NR);
|
||||
-
|
||||
- mtk_clk_register_gates(&pdev->dev, node, audio_clks,
|
||||
- ARRAY_SIZE(audio_clks), clk_data);
|
||||
-
|
||||
- r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
|
||||
+ r = mtk_clk_simple_probe(pdev);
|
||||
if (r) {
|
||||
dev_err(&pdev->dev,
|
||||
"could not register clock provider: %s: %d\n",
|
||||
pdev->name, r);
|
||||
|
||||
- goto err_clk_provider;
|
||||
+ return r;
|
||||
}
|
||||
|
||||
r = devm_of_platform_populate(&pdev->dev);
|
||||
@@ -146,13 +145,19 @@ static int clk_mt2701_aud_probe(struct p
|
||||
return 0;
|
||||
|
||||
err_plat_populate:
|
||||
- of_clk_del_provider(node);
|
||||
-err_clk_provider:
|
||||
+ mtk_clk_simple_remove(pdev);
|
||||
return r;
|
||||
}
|
||||
|
||||
+static int clk_mt2701_aud_remove(struct platform_device *pdev)
|
||||
+{
|
||||
+ of_platform_depopulate(&pdev->dev);
|
||||
+ return mtk_clk_simple_remove(pdev);
|
||||
+}
|
||||
+
|
||||
static struct platform_driver clk_mt2701_aud_drv = {
|
||||
.probe = clk_mt2701_aud_probe,
|
||||
+ .remove = clk_mt2701_aud_remove,
|
||||
.driver = {
|
||||
.name = "clk-mt2701-aud",
|
||||
.of_match_table = of_match_clk_mt2701_aud,
|
||||
--- a/drivers/clk/mediatek/clk-mt2701-eth.c
|
||||
+++ b/drivers/clk/mediatek/clk-mt2701-eth.c
|
||||
@@ -20,6 +20,7 @@ static const struct mtk_gate_regs eth_cg
|
||||
GATE_MTK(_id, _name, _parent, ð_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv)
|
||||
|
||||
static const struct mtk_gate eth_clks[] = {
|
||||
+ GATE_DUMMY(CLK_DUMMY, "eth_dummy"),
|
||||
GATE_ETH(CLK_ETHSYS_HSDMA, "hsdma_clk", "ethif_sel", 5),
|
||||
GATE_ETH(CLK_ETHSYS_ESW, "esw_clk", "ethpll_500m_ck", 6),
|
||||
GATE_ETH(CLK_ETHSYS_GP2, "gp2_clk", "trgpll", 7),
|
||||
@@ -38,35 +39,20 @@ static const struct mtk_clk_rst_desc clk
|
||||
.rst_bank_nr = ARRAY_SIZE(rst_ofs),
|
||||
};
|
||||
|
||||
-static const struct of_device_id of_match_clk_mt2701_eth[] = {
|
||||
- { .compatible = "mediatek,mt2701-ethsys", },
|
||||
- {}
|
||||
+static const struct mtk_clk_desc eth_desc = {
|
||||
+ .clks = eth_clks,
|
||||
+ .num_clks = ARRAY_SIZE(eth_clks),
|
||||
+ .rst_desc = &clk_rst_desc,
|
||||
};
|
||||
|
||||
-static int clk_mt2701_eth_probe(struct platform_device *pdev)
|
||||
-{
|
||||
- struct clk_hw_onecell_data *clk_data;
|
||||
- int r;
|
||||
- struct device_node *node = pdev->dev.of_node;
|
||||
-
|
||||
- clk_data = mtk_alloc_clk_data(CLK_ETHSYS_NR);
|
||||
-
|
||||
- mtk_clk_register_gates(&pdev->dev, node, eth_clks,
|
||||
- ARRAY_SIZE(eth_clks), clk_data);
|
||||
-
|
||||
- r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
|
||||
- if (r)
|
||||
- dev_err(&pdev->dev,
|
||||
- "could not register clock provider: %s: %d\n",
|
||||
- pdev->name, r);
|
||||
-
|
||||
- mtk_register_reset_controller_with_dev(&pdev->dev, &clk_rst_desc);
|
||||
-
|
||||
- return r;
|
||||
-}
|
||||
+static const struct of_device_id of_match_clk_mt2701_eth[] = {
|
||||
+ { .compatible = "mediatek,mt2701-ethsys", .data = ð_desc },
|
||||
+ { /* sentinel */ }
|
||||
+};
|
||||
|
||||
static struct platform_driver clk_mt2701_eth_drv = {
|
||||
- .probe = clk_mt2701_eth_probe,
|
||||
+ .probe = mtk_clk_simple_probe,
|
||||
+ .remove = mtk_clk_simple_remove,
|
||||
.driver = {
|
||||
.name = "clk-mt2701-eth",
|
||||
.of_match_table = of_match_clk_mt2701_eth,
|
||||
--- a/drivers/clk/mediatek/clk-mt2701-g3d.c
|
||||
+++ b/drivers/clk/mediatek/clk-mt2701-g3d.c
|
||||
@@ -26,6 +26,7 @@ static const struct mtk_gate_regs g3d_cg
|
||||
};
|
||||
|
||||
static const struct mtk_gate g3d_clks[] = {
|
||||
+ GATE_DUMMY(CLK_DUMMY, "g3d_dummy"),
|
||||
GATE_G3D(CLK_G3DSYS_CORE, "g3d_core", "mfg_sel", 0),
|
||||
};
|
||||
|
||||
@@ -37,57 +38,20 @@ static const struct mtk_clk_rst_desc clk
|
||||
.rst_bank_nr = ARRAY_SIZE(rst_ofs),
|
||||
};
|
||||
|
||||
-static int clk_mt2701_g3dsys_init(struct platform_device *pdev)
|
||||
-{
|
||||
- struct clk_hw_onecell_data *clk_data;
|
||||
- struct device_node *node = pdev->dev.of_node;
|
||||
- int r;
|
||||
-
|
||||
- clk_data = mtk_alloc_clk_data(CLK_G3DSYS_NR);
|
||||
-
|
||||
- mtk_clk_register_gates(&pdev->dev, node, g3d_clks, ARRAY_SIZE(g3d_clks),
|
||||
- clk_data);
|
||||
-
|
||||
- r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
|
||||
- if (r)
|
||||
- dev_err(&pdev->dev,
|
||||
- "could not register clock provider: %s: %d\n",
|
||||
- pdev->name, r);
|
||||
-
|
||||
- mtk_register_reset_controller_with_dev(&pdev->dev, &clk_rst_desc);
|
||||
-
|
||||
- return r;
|
||||
-}
|
||||
+static const struct mtk_clk_desc g3d_desc = {
|
||||
+ .clks = g3d_clks,
|
||||
+ .num_clks = ARRAY_SIZE(g3d_clks),
|
||||
+ .rst_desc = &clk_rst_desc,
|
||||
+};
|
||||
|
||||
static const struct of_device_id of_match_clk_mt2701_g3d[] = {
|
||||
- {
|
||||
- .compatible = "mediatek,mt2701-g3dsys",
|
||||
- .data = clk_mt2701_g3dsys_init,
|
||||
- }, {
|
||||
- /* sentinel */
|
||||
- }
|
||||
+ { .compatible = "mediatek,mt2701-g3dsys", .data = &g3d_desc },
|
||||
+ { /* sentinel */ }
|
||||
};
|
||||
|
||||
-static int clk_mt2701_g3d_probe(struct platform_device *pdev)
|
||||
-{
|
||||
- int (*clk_init)(struct platform_device *);
|
||||
- int r;
|
||||
-
|
||||
- clk_init = of_device_get_match_data(&pdev->dev);
|
||||
- if (!clk_init)
|
||||
- return -EINVAL;
|
||||
-
|
||||
- r = clk_init(pdev);
|
||||
- if (r)
|
||||
- dev_err(&pdev->dev,
|
||||
- "could not register clock provider: %s: %d\n",
|
||||
- pdev->name, r);
|
||||
-
|
||||
- return r;
|
||||
-}
|
||||
-
|
||||
static struct platform_driver clk_mt2701_g3d_drv = {
|
||||
- .probe = clk_mt2701_g3d_probe,
|
||||
+ .probe = mtk_clk_simple_probe,
|
||||
+ .remove = mtk_clk_simple_remove,
|
||||
.driver = {
|
||||
.name = "clk-mt2701-g3d",
|
||||
.of_match_table = of_match_clk_mt2701_g3d,
|
||||
--- a/drivers/clk/mediatek/clk-mt2701-hif.c
|
||||
+++ b/drivers/clk/mediatek/clk-mt2701-hif.c
|
||||
@@ -20,6 +20,7 @@ static const struct mtk_gate_regs hif_cg
|
||||
GATE_MTK(_id, _name, _parent, &hif_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv)
|
||||
|
||||
static const struct mtk_gate hif_clks[] = {
|
||||
+ GATE_DUMMY(CLK_DUMMY, "hif_dummy"),
|
||||
GATE_HIF(CLK_HIFSYS_USB0PHY, "usb0_phy_clk", "ethpll_500m_ck", 21),
|
||||
GATE_HIF(CLK_HIFSYS_USB1PHY, "usb1_phy_clk", "ethpll_500m_ck", 22),
|
||||
GATE_HIF(CLK_HIFSYS_PCIE0, "pcie0_clk", "ethpll_500m_ck", 24),
|
||||
@@ -35,37 +36,20 @@ static const struct mtk_clk_rst_desc clk
|
||||
.rst_bank_nr = ARRAY_SIZE(rst_ofs),
|
||||
};
|
||||
|
||||
-static const struct of_device_id of_match_clk_mt2701_hif[] = {
|
||||
- { .compatible = "mediatek,mt2701-hifsys", },
|
||||
- {}
|
||||
+static const struct mtk_clk_desc hif_desc = {
|
||||
+ .clks = hif_clks,
|
||||
+ .num_clks = ARRAY_SIZE(hif_clks),
|
||||
+ .rst_desc = &clk_rst_desc,
|
||||
};
|
||||
|
||||
-static int clk_mt2701_hif_probe(struct platform_device *pdev)
|
||||
-{
|
||||
- struct clk_hw_onecell_data *clk_data;
|
||||
- int r;
|
||||
- struct device_node *node = pdev->dev.of_node;
|
||||
-
|
||||
- clk_data = mtk_alloc_clk_data(CLK_HIFSYS_NR);
|
||||
-
|
||||
- mtk_clk_register_gates(&pdev->dev, node, hif_clks,
|
||||
- ARRAY_SIZE(hif_clks), clk_data);
|
||||
-
|
||||
- r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
|
||||
- if (r) {
|
||||
- dev_err(&pdev->dev,
|
||||
- "could not register clock provider: %s: %d\n",
|
||||
- pdev->name, r);
|
||||
- return r;
|
||||
- }
|
||||
-
|
||||
- mtk_register_reset_controller_with_dev(&pdev->dev, &clk_rst_desc);
|
||||
-
|
||||
- return 0;
|
||||
-}
|
||||
+static const struct of_device_id of_match_clk_mt2701_hif[] = {
|
||||
+ { .compatible = "mediatek,mt2701-hifsys", .data = &hif_desc },
|
||||
+ { /* sentinel */ }
|
||||
+};
|
||||
|
||||
static struct platform_driver clk_mt2701_hif_drv = {
|
||||
- .probe = clk_mt2701_hif_probe,
|
||||
+ .probe = mtk_clk_simple_probe,
|
||||
+ .remove = mtk_clk_simple_remove,
|
||||
.driver = {
|
||||
.name = "clk-mt2701-hif",
|
||||
.of_match_table = of_match_clk_mt2701_hif,
|
||||
--- a/drivers/clk/mediatek/clk-mt2712.c
|
||||
+++ b/drivers/clk/mediatek/clk-mt2712.c
|
||||
@@ -1337,50 +1337,6 @@ static int clk_mt2712_top_probe(struct p
|
||||
return r;
|
||||
}
|
||||
|
||||
-static int clk_mt2712_infra_probe(struct platform_device *pdev)
|
||||
-{
|
||||
- struct clk_hw_onecell_data *clk_data;
|
||||
- int r;
|
||||
- struct device_node *node = pdev->dev.of_node;
|
||||
-
|
||||
- clk_data = mtk_alloc_clk_data(CLK_INFRA_NR_CLK);
|
||||
-
|
||||
- mtk_clk_register_gates(&pdev->dev, node, infra_clks,
|
||||
- ARRAY_SIZE(infra_clks), clk_data);
|
||||
-
|
||||
- r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
|
||||
-
|
||||
- if (r != 0)
|
||||
- pr_err("%s(): could not register clock provider: %d\n",
|
||||
- __func__, r);
|
||||
-
|
||||
- mtk_register_reset_controller_with_dev(&pdev->dev, &clk_rst_desc[0]);
|
||||
-
|
||||
- return r;
|
||||
-}
|
||||
-
|
||||
-static int clk_mt2712_peri_probe(struct platform_device *pdev)
|
||||
-{
|
||||
- struct clk_hw_onecell_data *clk_data;
|
||||
- int r;
|
||||
- struct device_node *node = pdev->dev.of_node;
|
||||
-
|
||||
- clk_data = mtk_alloc_clk_data(CLK_PERI_NR_CLK);
|
||||
-
|
||||
- mtk_clk_register_gates(&pdev->dev, node, peri_clks,
|
||||
- ARRAY_SIZE(peri_clks), clk_data);
|
||||
-
|
||||
- r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
|
||||
-
|
||||
- if (r != 0)
|
||||
- pr_err("%s(): could not register clock provider: %d\n",
|
||||
- __func__, r);
|
||||
-
|
||||
- mtk_register_reset_controller_with_dev(&pdev->dev, &clk_rst_desc[1]);
|
||||
-
|
||||
- return r;
|
||||
-}
|
||||
-
|
||||
static int clk_mt2712_mcu_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct clk_hw_onecell_data *clk_data;
|
||||
@@ -1419,12 +1375,6 @@ static const struct of_device_id of_matc
|
||||
.compatible = "mediatek,mt2712-topckgen",
|
||||
.data = clk_mt2712_top_probe,
|
||||
}, {
|
||||
- .compatible = "mediatek,mt2712-infracfg",
|
||||
- .data = clk_mt2712_infra_probe,
|
||||
- }, {
|
||||
- .compatible = "mediatek,mt2712-pericfg",
|
||||
- .data = clk_mt2712_peri_probe,
|
||||
- }, {
|
||||
.compatible = "mediatek,mt2712-mcucfg",
|
||||
.data = clk_mt2712_mcu_probe,
|
||||
}, {
|
||||
@@ -1450,6 +1400,33 @@ static int clk_mt2712_probe(struct platf
|
||||
return r;
|
||||
}
|
||||
|
||||
+static const struct mtk_clk_desc infra_desc = {
|
||||
+ .clks = infra_clks,
|
||||
+ .num_clks = ARRAY_SIZE(infra_clks),
|
||||
+ .rst_desc = &clk_rst_desc[0],
|
||||
+};
|
||||
+
|
||||
+static const struct mtk_clk_desc peri_desc = {
|
||||
+ .clks = peri_clks,
|
||||
+ .num_clks = ARRAY_SIZE(peri_clks),
|
||||
+ .rst_desc = &clk_rst_desc[1],
|
||||
+};
|
||||
+
|
||||
+static const struct of_device_id of_match_clk_mt2712_simple[] = {
|
||||
+ { .compatible = "mediatek,mt2712-infracfg", .data = &infra_desc },
|
||||
+ { .compatible = "mediatek,mt2712-pericfg", .data = &peri_desc, },
|
||||
+ { /* sentinel */ }
|
||||
+};
|
||||
+
|
||||
+static struct platform_driver clk_mt2712_simple_drv = {
|
||||
+ .probe = mtk_clk_simple_probe,
|
||||
+ .remove = mtk_clk_simple_remove,
|
||||
+ .driver = {
|
||||
+ .name = "clk-mt2712-simple",
|
||||
+ .of_match_table = of_match_clk_mt2712_simple,
|
||||
+ },
|
||||
+};
|
||||
+
|
||||
static struct platform_driver clk_mt2712_drv = {
|
||||
.probe = clk_mt2712_probe,
|
||||
.driver = {
|
||||
@@ -1460,7 +1437,11 @@ static struct platform_driver clk_mt2712
|
||||
|
||||
static int __init clk_mt2712_init(void)
|
||||
{
|
||||
- return platform_driver_register(&clk_mt2712_drv);
|
||||
+ int ret = platform_driver_register(&clk_mt2712_drv);
|
||||
+
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+ return platform_driver_register(&clk_mt2712_simple_drv);
|
||||
}
|
||||
|
||||
arch_initcall(clk_mt2712_init);
|
||||
--- a/drivers/clk/mediatek/clk-mt7622-aud.c
|
||||
+++ b/drivers/clk/mediatek/clk-mt7622-aud.c
|
||||
@@ -106,24 +106,22 @@ static const struct mtk_gate audio_clks[
|
||||
GATE_AUDIO3(CLK_AUDIO_MEM_ASRC5, "audio_mem_asrc5", "asm_h_sel", 14),
|
||||
};
|
||||
|
||||
-static int clk_mt7622_audiosys_init(struct platform_device *pdev)
|
||||
+static const struct mtk_clk_desc audio_desc = {
|
||||
+ .clks = audio_clks,
|
||||
+ .num_clks = ARRAY_SIZE(audio_clks),
|
||||
+};
|
||||
+
|
||||
+static int clk_mt7622_aud_probe(struct platform_device *pdev)
|
||||
{
|
||||
- struct clk_hw_onecell_data *clk_data;
|
||||
- struct device_node *node = pdev->dev.of_node;
|
||||
int r;
|
||||
|
||||
- clk_data = mtk_alloc_clk_data(CLK_AUDIO_NR_CLK);
|
||||
-
|
||||
- mtk_clk_register_gates(&pdev->dev, node, audio_clks,
|
||||
- ARRAY_SIZE(audio_clks), clk_data);
|
||||
-
|
||||
- r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
|
||||
+ r = mtk_clk_simple_probe(pdev);
|
||||
if (r) {
|
||||
dev_err(&pdev->dev,
|
||||
"could not register clock provider: %s: %d\n",
|
||||
pdev->name, r);
|
||||
|
||||
- goto err_clk_provider;
|
||||
+ return r;
|
||||
}
|
||||
|
||||
r = devm_of_platform_populate(&pdev->dev);
|
||||
@@ -133,40 +131,24 @@ static int clk_mt7622_audiosys_init(stru
|
||||
return 0;
|
||||
|
||||
err_plat_populate:
|
||||
- of_clk_del_provider(node);
|
||||
-err_clk_provider:
|
||||
+ mtk_clk_simple_remove(pdev);
|
||||
return r;
|
||||
}
|
||||
|
||||
-static const struct of_device_id of_match_clk_mt7622_aud[] = {
|
||||
- {
|
||||
- .compatible = "mediatek,mt7622-audsys",
|
||||
- .data = clk_mt7622_audiosys_init,
|
||||
- }, {
|
||||
- /* sentinel */
|
||||
- }
|
||||
-};
|
||||
-
|
||||
-static int clk_mt7622_aud_probe(struct platform_device *pdev)
|
||||
+static int clk_mt7622_aud_remove(struct platform_device *pdev)
|
||||
{
|
||||
- int (*clk_init)(struct platform_device *);
|
||||
- int r;
|
||||
-
|
||||
- clk_init = of_device_get_match_data(&pdev->dev);
|
||||
- if (!clk_init)
|
||||
- return -EINVAL;
|
||||
-
|
||||
- r = clk_init(pdev);
|
||||
- if (r)
|
||||
- dev_err(&pdev->dev,
|
||||
- "could not register clock provider: %s: %d\n",
|
||||
- pdev->name, r);
|
||||
-
|
||||
- return r;
|
||||
+ of_platform_depopulate(&pdev->dev);
|
||||
+ return mtk_clk_simple_remove(pdev);
|
||||
}
|
||||
|
||||
+static const struct of_device_id of_match_clk_mt7622_aud[] = {
|
||||
+ { .compatible = "mediatek,mt7622-audsys", .data = &audio_desc },
|
||||
+ { /* sentinel */ }
|
||||
+};
|
||||
+
|
||||
static struct platform_driver clk_mt7622_aud_drv = {
|
||||
.probe = clk_mt7622_aud_probe,
|
||||
+ .remove = clk_mt7622_aud_remove,
|
||||
.driver = {
|
||||
.name = "clk-mt7622-aud",
|
||||
.of_match_table = of_match_clk_mt7622_aud,
|
||||
--- a/drivers/clk/mediatek/clk-mt7622-eth.c
|
||||
+++ b/drivers/clk/mediatek/clk-mt7622-eth.c
|
||||
@@ -61,80 +61,26 @@ static const struct mtk_clk_rst_desc clk
|
||||
.rst_bank_nr = ARRAY_SIZE(rst_ofs),
|
||||
};
|
||||
|
||||
-static int clk_mt7622_ethsys_init(struct platform_device *pdev)
|
||||
-{
|
||||
- struct clk_hw_onecell_data *clk_data;
|
||||
- struct device_node *node = pdev->dev.of_node;
|
||||
- int r;
|
||||
-
|
||||
- clk_data = mtk_alloc_clk_data(CLK_ETH_NR_CLK);
|
||||
-
|
||||
- mtk_clk_register_gates(&pdev->dev, node, eth_clks,
|
||||
- ARRAY_SIZE(eth_clks), clk_data);
|
||||
-
|
||||
- r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
|
||||
- if (r)
|
||||
- dev_err(&pdev->dev,
|
||||
- "could not register clock provider: %s: %d\n",
|
||||
- pdev->name, r);
|
||||
-
|
||||
- mtk_register_reset_controller_with_dev(&pdev->dev, &clk_rst_desc);
|
||||
-
|
||||
- return r;
|
||||
-}
|
||||
-
|
||||
-static int clk_mt7622_sgmiisys_init(struct platform_device *pdev)
|
||||
-{
|
||||
- struct clk_hw_onecell_data *clk_data;
|
||||
- struct device_node *node = pdev->dev.of_node;
|
||||
- int r;
|
||||
-
|
||||
- clk_data = mtk_alloc_clk_data(CLK_SGMII_NR_CLK);
|
||||
-
|
||||
- mtk_clk_register_gates(&pdev->dev, node, sgmii_clks,
|
||||
- ARRAY_SIZE(sgmii_clks), clk_data);
|
||||
-
|
||||
- r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
|
||||
- if (r)
|
||||
- dev_err(&pdev->dev,
|
||||
- "could not register clock provider: %s: %d\n",
|
||||
- pdev->name, r);
|
||||
+static const struct mtk_clk_desc eth_desc = {
|
||||
+ .clks = eth_clks,
|
||||
+ .num_clks = ARRAY_SIZE(eth_clks),
|
||||
+ .rst_desc = &clk_rst_desc,
|
||||
+};
|
||||
|
||||
- return r;
|
||||
-}
|
||||
+static const struct mtk_clk_desc sgmii_desc = {
|
||||
+ .clks = sgmii_clks,
|
||||
+ .num_clks = ARRAY_SIZE(sgmii_clks),
|
||||
+};
|
||||
|
||||
static const struct of_device_id of_match_clk_mt7622_eth[] = {
|
||||
- {
|
||||
- .compatible = "mediatek,mt7622-ethsys",
|
||||
- .data = clk_mt7622_ethsys_init,
|
||||
- }, {
|
||||
- .compatible = "mediatek,mt7622-sgmiisys",
|
||||
- .data = clk_mt7622_sgmiisys_init,
|
||||
- }, {
|
||||
- /* sentinel */
|
||||
- }
|
||||
+ { .compatible = "mediatek,mt7622-ethsys", .data = ð_desc },
|
||||
+ { .compatible = "mediatek,mt7622-sgmiisys", .data = &sgmii_desc },
|
||||
+ { /* sentinel */ }
|
||||
};
|
||||
|
||||
-static int clk_mt7622_eth_probe(struct platform_device *pdev)
|
||||
-{
|
||||
- int (*clk_init)(struct platform_device *);
|
||||
- int r;
|
||||
-
|
||||
- clk_init = of_device_get_match_data(&pdev->dev);
|
||||
- if (!clk_init)
|
||||
- return -EINVAL;
|
||||
-
|
||||
- r = clk_init(pdev);
|
||||
- if (r)
|
||||
- dev_err(&pdev->dev,
|
||||
- "could not register clock provider: %s: %d\n",
|
||||
- pdev->name, r);
|
||||
-
|
||||
- return r;
|
||||
-}
|
||||
-
|
||||
static struct platform_driver clk_mt7622_eth_drv = {
|
||||
- .probe = clk_mt7622_eth_probe,
|
||||
+ .probe = mtk_clk_simple_probe,
|
||||
+ .remove = mtk_clk_simple_remove,
|
||||
.driver = {
|
||||
.name = "clk-mt7622-eth",
|
||||
.of_match_table = of_match_clk_mt7622_eth,
|
||||
--- a/drivers/clk/mediatek/clk-mt7622-hif.c
|
||||
+++ b/drivers/clk/mediatek/clk-mt7622-hif.c
|
||||
@@ -72,82 +72,27 @@ static const struct mtk_clk_rst_desc clk
|
||||
.rst_bank_nr = ARRAY_SIZE(rst_ofs),
|
||||
};
|
||||
|
||||
-static int clk_mt7622_ssusbsys_init(struct platform_device *pdev)
|
||||
-{
|
||||
- struct clk_hw_onecell_data *clk_data;
|
||||
- struct device_node *node = pdev->dev.of_node;
|
||||
- int r;
|
||||
-
|
||||
- clk_data = mtk_alloc_clk_data(CLK_SSUSB_NR_CLK);
|
||||
-
|
||||
- mtk_clk_register_gates(&pdev->dev, node, ssusb_clks,
|
||||
- ARRAY_SIZE(ssusb_clks), clk_data);
|
||||
-
|
||||
- r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
|
||||
- if (r)
|
||||
- dev_err(&pdev->dev,
|
||||
- "could not register clock provider: %s: %d\n",
|
||||
- pdev->name, r);
|
||||
-
|
||||
- mtk_register_reset_controller_with_dev(&pdev->dev, &clk_rst_desc);
|
||||
-
|
||||
- return r;
|
||||
-}
|
||||
-
|
||||
-static int clk_mt7622_pciesys_init(struct platform_device *pdev)
|
||||
-{
|
||||
- struct clk_hw_onecell_data *clk_data;
|
||||
- struct device_node *node = pdev->dev.of_node;
|
||||
- int r;
|
||||
-
|
||||
- clk_data = mtk_alloc_clk_data(CLK_PCIE_NR_CLK);
|
||||
-
|
||||
- mtk_clk_register_gates(&pdev->dev, node, pcie_clks,
|
||||
- ARRAY_SIZE(pcie_clks), clk_data);
|
||||
-
|
||||
- r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
|
||||
- if (r)
|
||||
- dev_err(&pdev->dev,
|
||||
- "could not register clock provider: %s: %d\n",
|
||||
- pdev->name, r);
|
||||
-
|
||||
- mtk_register_reset_controller_with_dev(&pdev->dev, &clk_rst_desc);
|
||||
+static const struct mtk_clk_desc ssusb_desc = {
|
||||
+ .clks = ssusb_clks,
|
||||
+ .num_clks = ARRAY_SIZE(ssusb_clks),
|
||||
+ .rst_desc = &clk_rst_desc,
|
||||
+};
|
||||
|
||||
- return r;
|
||||
-}
|
||||
+static const struct mtk_clk_desc pcie_desc = {
|
||||
+ .clks = pcie_clks,
|
||||
+ .num_clks = ARRAY_SIZE(pcie_clks),
|
||||
+ .rst_desc = &clk_rst_desc,
|
||||
+};
|
||||
|
||||
static const struct of_device_id of_match_clk_mt7622_hif[] = {
|
||||
- {
|
||||
- .compatible = "mediatek,mt7622-pciesys",
|
||||
- .data = clk_mt7622_pciesys_init,
|
||||
- }, {
|
||||
- .compatible = "mediatek,mt7622-ssusbsys",
|
||||
- .data = clk_mt7622_ssusbsys_init,
|
||||
- }, {
|
||||
- /* sentinel */
|
||||
- }
|
||||
+ { .compatible = "mediatek,mt7622-pciesys", .data = &pcie_desc },
|
||||
+ { .compatible = "mediatek,mt7622-ssusbsys", .data = &ssusb_desc },
|
||||
+ { /* sentinel */ }
|
||||
};
|
||||
|
||||
-static int clk_mt7622_hif_probe(struct platform_device *pdev)
|
||||
-{
|
||||
- int (*clk_init)(struct platform_device *);
|
||||
- int r;
|
||||
-
|
||||
- clk_init = of_device_get_match_data(&pdev->dev);
|
||||
- if (!clk_init)
|
||||
- return -EINVAL;
|
||||
-
|
||||
- r = clk_init(pdev);
|
||||
- if (r)
|
||||
- dev_err(&pdev->dev,
|
||||
- "could not register clock provider: %s: %d\n",
|
||||
- pdev->name, r);
|
||||
-
|
||||
- return r;
|
||||
-}
|
||||
-
|
||||
static struct platform_driver clk_mt7622_hif_drv = {
|
||||
- .probe = clk_mt7622_hif_probe,
|
||||
+ .probe = mtk_clk_simple_probe,
|
||||
+ .remove = mtk_clk_simple_remove,
|
||||
.driver = {
|
||||
.name = "clk-mt7622-hif",
|
||||
.of_match_table = of_match_clk_mt7622_hif,
|
||||
--- a/drivers/clk/mediatek/clk-mt7629-hif.c
|
||||
+++ b/drivers/clk/mediatek/clk-mt7629-hif.c
|
||||
@@ -67,82 +67,27 @@ static const struct mtk_clk_rst_desc clk
|
||||
.rst_bank_nr = ARRAY_SIZE(rst_ofs),
|
||||
};
|
||||
|
||||
-static int clk_mt7629_ssusbsys_init(struct platform_device *pdev)
|
||||
-{
|
||||
- struct clk_hw_onecell_data *clk_data;
|
||||
- struct device_node *node = pdev->dev.of_node;
|
||||
- int r;
|
||||
-
|
||||
- clk_data = mtk_alloc_clk_data(CLK_SSUSB_NR_CLK);
|
||||
-
|
||||
- mtk_clk_register_gates(&pdev->dev, node, ssusb_clks,
|
||||
- ARRAY_SIZE(ssusb_clks), clk_data);
|
||||
-
|
||||
- r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
|
||||
- if (r)
|
||||
- dev_err(&pdev->dev,
|
||||
- "could not register clock provider: %s: %d\n",
|
||||
- pdev->name, r);
|
||||
-
|
||||
- mtk_register_reset_controller_with_dev(&pdev->dev, &clk_rst_desc);
|
||||
-
|
||||
- return r;
|
||||
-}
|
||||
-
|
||||
-static int clk_mt7629_pciesys_init(struct platform_device *pdev)
|
||||
-{
|
||||
- struct clk_hw_onecell_data *clk_data;
|
||||
- struct device_node *node = pdev->dev.of_node;
|
||||
- int r;
|
||||
-
|
||||
- clk_data = mtk_alloc_clk_data(CLK_PCIE_NR_CLK);
|
||||
-
|
||||
- mtk_clk_register_gates(&pdev->dev, node, pcie_clks,
|
||||
- ARRAY_SIZE(pcie_clks), clk_data);
|
||||
-
|
||||
- r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
|
||||
- if (r)
|
||||
- dev_err(&pdev->dev,
|
||||
- "could not register clock provider: %s: %d\n",
|
||||
- pdev->name, r);
|
||||
-
|
||||
- mtk_register_reset_controller_with_dev(&pdev->dev, &clk_rst_desc);
|
||||
+static const struct mtk_clk_desc ssusb_desc = {
|
||||
+ .clks = ssusb_clks,
|
||||
+ .num_clks = ARRAY_SIZE(ssusb_clks),
|
||||
+ .rst_desc = &clk_rst_desc,
|
||||
+};
|
||||
|
||||
- return r;
|
||||
-}
|
||||
+static const struct mtk_clk_desc pcie_desc = {
|
||||
+ .clks = pcie_clks,
|
||||
+ .num_clks = ARRAY_SIZE(pcie_clks),
|
||||
+ .rst_desc = &clk_rst_desc,
|
||||
+};
|
||||
|
||||
static const struct of_device_id of_match_clk_mt7629_hif[] = {
|
||||
- {
|
||||
- .compatible = "mediatek,mt7629-pciesys",
|
||||
- .data = clk_mt7629_pciesys_init,
|
||||
- }, {
|
||||
- .compatible = "mediatek,mt7629-ssusbsys",
|
||||
- .data = clk_mt7629_ssusbsys_init,
|
||||
- }, {
|
||||
- /* sentinel */
|
||||
- }
|
||||
+ { .compatible = "mediatek,mt7629-pciesys", .data = &pcie_desc },
|
||||
+ { .compatible = "mediatek,mt7629-ssusbsys", .data = &ssusb_desc },
|
||||
+ { /* sentinel */ }
|
||||
};
|
||||
|
||||
-static int clk_mt7629_hif_probe(struct platform_device *pdev)
|
||||
-{
|
||||
- int (*clk_init)(struct platform_device *);
|
||||
- int r;
|
||||
-
|
||||
- clk_init = of_device_get_match_data(&pdev->dev);
|
||||
- if (!clk_init)
|
||||
- return -EINVAL;
|
||||
-
|
||||
- r = clk_init(pdev);
|
||||
- if (r)
|
||||
- dev_err(&pdev->dev,
|
||||
- "could not register clock provider: %s: %d\n",
|
||||
- pdev->name, r);
|
||||
-
|
||||
- return r;
|
||||
-}
|
||||
-
|
||||
static struct platform_driver clk_mt7629_hif_drv = {
|
||||
- .probe = clk_mt7629_hif_probe,
|
||||
+ .probe = mtk_clk_simple_probe,
|
||||
+ .remove = mtk_clk_simple_remove,
|
||||
.driver = {
|
||||
.name = "clk-mt7629-hif",
|
||||
.of_match_table = of_match_clk_mt7629_hif,
|
@ -1,189 +0,0 @@
|
||||
From 7b6183108c8ccf0dc295f39cdf78bd8078455636 Mon Sep 17 00:00:00 2001
|
||||
From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Date: Fri, 20 Jan 2023 10:20:42 +0100
|
||||
Subject: [PATCH] clk: mediatek: clk-mtk: Extend mtk_clk_simple_probe()
|
||||
|
||||
As a preparation to increase probe functions commonization across
|
||||
various MediaTek SoC clock controller drivers, extend function
|
||||
mtk_clk_simple_probe() to be able to register not only gates, but
|
||||
also fixed clocks, factors, muxes and composites.
|
||||
|
||||
Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Reviewed-by: Miles Chen <miles.chen@mediatek.com>
|
||||
Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
|
||||
Tested-by: Miles Chen <miles.chen@mediatek.com>
|
||||
Link: https://lore.kernel.org/r/20230120092053.182923-13-angelogioacchino.delregno@collabora.com
|
||||
Tested-by: Mingming Su <mingming.su@mediatek.com>
|
||||
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
|
||||
---
|
||||
drivers/clk/mediatek/clk-mtk.c | 101 ++++++++++++++++++++++++++++++---
|
||||
drivers/clk/mediatek/clk-mtk.h | 10 ++++
|
||||
2 files changed, 103 insertions(+), 8 deletions(-)
|
||||
|
||||
--- a/drivers/clk/mediatek/clk-mtk.c
|
||||
+++ b/drivers/clk/mediatek/clk-mtk.c
|
||||
@@ -11,12 +11,14 @@
|
||||
#include <linux/mfd/syscon.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/of.h>
|
||||
+#include <linux/of_address.h>
|
||||
#include <linux/of_device.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/slab.h>
|
||||
|
||||
#include "clk-mtk.h"
|
||||
#include "clk-gate.h"
|
||||
+#include "clk-mux.h"
|
||||
|
||||
const struct mtk_gate_regs cg_regs_dummy = { 0, 0, 0 };
|
||||
EXPORT_SYMBOL_GPL(cg_regs_dummy);
|
||||
@@ -466,20 +468,71 @@ int mtk_clk_simple_probe(struct platform
|
||||
const struct mtk_clk_desc *mcd;
|
||||
struct clk_hw_onecell_data *clk_data;
|
||||
struct device_node *node = pdev->dev.of_node;
|
||||
- int r;
|
||||
+ void __iomem *base;
|
||||
+ int num_clks, r;
|
||||
|
||||
mcd = of_device_get_match_data(&pdev->dev);
|
||||
if (!mcd)
|
||||
return -EINVAL;
|
||||
|
||||
- clk_data = mtk_alloc_clk_data(mcd->num_clks);
|
||||
+ /* Composite clocks needs us to pass iomem pointer */
|
||||
+ if (mcd->composite_clks) {
|
||||
+ if (!mcd->shared_io)
|
||||
+ base = devm_platform_ioremap_resource(pdev, 0);
|
||||
+ else
|
||||
+ base = of_iomap(node, 0);
|
||||
+
|
||||
+ if (IS_ERR_OR_NULL(base))
|
||||
+ return IS_ERR(base) ? PTR_ERR(base) : -ENOMEM;
|
||||
+ }
|
||||
+
|
||||
+ /* Calculate how many clk_hw_onecell_data entries to allocate */
|
||||
+ num_clks = mcd->num_clks + mcd->num_composite_clks;
|
||||
+ num_clks += mcd->num_fixed_clks + mcd->num_factor_clks;
|
||||
+ num_clks += mcd->num_mux_clks;
|
||||
+
|
||||
+ clk_data = mtk_alloc_clk_data(num_clks);
|
||||
if (!clk_data)
|
||||
return -ENOMEM;
|
||||
|
||||
- r = mtk_clk_register_gates(&pdev->dev, node, mcd->clks, mcd->num_clks,
|
||||
- clk_data);
|
||||
- if (r)
|
||||
- goto free_data;
|
||||
+ if (mcd->fixed_clks) {
|
||||
+ r = mtk_clk_register_fixed_clks(mcd->fixed_clks,
|
||||
+ mcd->num_fixed_clks, clk_data);
|
||||
+ if (r)
|
||||
+ goto free_data;
|
||||
+ }
|
||||
+
|
||||
+ if (mcd->factor_clks) {
|
||||
+ r = mtk_clk_register_factors(mcd->factor_clks,
|
||||
+ mcd->num_factor_clks, clk_data);
|
||||
+ if (r)
|
||||
+ goto unregister_fixed_clks;
|
||||
+ }
|
||||
+
|
||||
+ if (mcd->mux_clks) {
|
||||
+ r = mtk_clk_register_muxes(&pdev->dev, mcd->mux_clks,
|
||||
+ mcd->num_mux_clks, node,
|
||||
+ mcd->clk_lock, clk_data);
|
||||
+ if (r)
|
||||
+ goto unregister_factors;
|
||||
+ };
|
||||
+
|
||||
+ if (mcd->composite_clks) {
|
||||
+ /* We don't check composite_lock because it's optional */
|
||||
+ r = mtk_clk_register_composites(&pdev->dev,
|
||||
+ mcd->composite_clks,
|
||||
+ mcd->num_composite_clks,
|
||||
+ base, mcd->clk_lock, clk_data);
|
||||
+ if (r)
|
||||
+ goto unregister_muxes;
|
||||
+ }
|
||||
+
|
||||
+ if (mcd->clks) {
|
||||
+ r = mtk_clk_register_gates(&pdev->dev, node, mcd->clks,
|
||||
+ mcd->num_clks, clk_data);
|
||||
+ if (r)
|
||||
+ goto unregister_composites;
|
||||
+ }
|
||||
|
||||
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
|
||||
if (r)
|
||||
@@ -497,9 +550,28 @@ int mtk_clk_simple_probe(struct platform
|
||||
return r;
|
||||
|
||||
unregister_clks:
|
||||
- mtk_clk_unregister_gates(mcd->clks, mcd->num_clks, clk_data);
|
||||
+ if (mcd->clks)
|
||||
+ mtk_clk_unregister_gates(mcd->clks, mcd->num_clks, clk_data);
|
||||
+unregister_composites:
|
||||
+ if (mcd->composite_clks)
|
||||
+ mtk_clk_unregister_composites(mcd->composite_clks,
|
||||
+ mcd->num_composite_clks, clk_data);
|
||||
+unregister_muxes:
|
||||
+ if (mcd->mux_clks)
|
||||
+ mtk_clk_unregister_muxes(mcd->mux_clks,
|
||||
+ mcd->num_mux_clks, clk_data);
|
||||
+unregister_factors:
|
||||
+ if (mcd->factor_clks)
|
||||
+ mtk_clk_unregister_factors(mcd->factor_clks,
|
||||
+ mcd->num_factor_clks, clk_data);
|
||||
+unregister_fixed_clks:
|
||||
+ if (mcd->fixed_clks)
|
||||
+ mtk_clk_unregister_fixed_clks(mcd->fixed_clks,
|
||||
+ mcd->num_fixed_clks, clk_data);
|
||||
free_data:
|
||||
mtk_free_clk_data(clk_data);
|
||||
+ if (mcd->shared_io && base)
|
||||
+ iounmap(base);
|
||||
return r;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mtk_clk_simple_probe);
|
||||
@@ -511,7 +583,20 @@ int mtk_clk_simple_remove(struct platfor
|
||||
struct device_node *node = pdev->dev.of_node;
|
||||
|
||||
of_clk_del_provider(node);
|
||||
- mtk_clk_unregister_gates(mcd->clks, mcd->num_clks, clk_data);
|
||||
+ if (mcd->clks)
|
||||
+ mtk_clk_unregister_gates(mcd->clks, mcd->num_clks, clk_data);
|
||||
+ if (mcd->composite_clks)
|
||||
+ mtk_clk_unregister_composites(mcd->composite_clks,
|
||||
+ mcd->num_composite_clks, clk_data);
|
||||
+ if (mcd->mux_clks)
|
||||
+ mtk_clk_unregister_muxes(mcd->mux_clks,
|
||||
+ mcd->num_mux_clks, clk_data);
|
||||
+ if (mcd->factor_clks)
|
||||
+ mtk_clk_unregister_factors(mcd->factor_clks,
|
||||
+ mcd->num_factor_clks, clk_data);
|
||||
+ if (mcd->fixed_clks)
|
||||
+ mtk_clk_unregister_fixed_clks(mcd->fixed_clks,
|
||||
+ mcd->num_fixed_clks, clk_data);
|
||||
mtk_free_clk_data(clk_data);
|
||||
|
||||
return 0;
|
||||
--- a/drivers/clk/mediatek/clk-mtk.h
|
||||
+++ b/drivers/clk/mediatek/clk-mtk.h
|
||||
@@ -215,7 +215,17 @@ void mtk_clk_unregister_ref2usb_tx(struc
|
||||
struct mtk_clk_desc {
|
||||
const struct mtk_gate *clks;
|
||||
size_t num_clks;
|
||||
+ const struct mtk_composite *composite_clks;
|
||||
+ size_t num_composite_clks;
|
||||
+ const struct mtk_fixed_clk *fixed_clks;
|
||||
+ size_t num_fixed_clks;
|
||||
+ const struct mtk_fixed_factor *factor_clks;
|
||||
+ size_t num_factor_clks;
|
||||
+ const struct mtk_mux *mux_clks;
|
||||
+ size_t num_mux_clks;
|
||||
const struct mtk_clk_rst_desc *rst_desc;
|
||||
+ spinlock_t *clk_lock;
|
||||
+ bool shared_io;
|
||||
};
|
||||
|
||||
int mtk_clk_simple_probe(struct platform_device *pdev);
|
@ -1,97 +0,0 @@
|
||||
From 3511004225ce917a4aa6e6ac61481ac60f08f401 Mon Sep 17 00:00:00 2001
|
||||
From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Date: Fri, 20 Jan 2023 10:20:52 +0100
|
||||
Subject: [PATCH 06/15] clk: mediatek: clk-mt7986-topckgen: Properly keep some
|
||||
clocks enabled
|
||||
|
||||
Instead of calling clk_prepare_enable() on a bunch of clocks at probe
|
||||
time, set the CLK_IS_CRITICAL flag to the same as these are required
|
||||
to be always on, and this is the right way of achieving that.
|
||||
|
||||
Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
|
||||
Reviewed-by: Miles Chen <miles.chen@mediatek.com>
|
||||
Link: https://lore.kernel.org/r/20230120092053.182923-23-angelogioacchino.delregno@collabora.com
|
||||
Tested-by: Mingming Su <mingming.su@mediatek.com>
|
||||
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
|
||||
---
|
||||
drivers/clk/mediatek/clk-mt7986-topckgen.c | 46 +++++++++++-----------
|
||||
1 file changed, 24 insertions(+), 22 deletions(-)
|
||||
|
||||
--- a/drivers/clk/mediatek/clk-mt7986-topckgen.c
|
||||
+++ b/drivers/clk/mediatek/clk-mt7986-topckgen.c
|
||||
@@ -202,16 +202,23 @@ static const struct mtk_mux top_muxes[]
|
||||
MUX_GATE_CLR_SET_UPD(CLK_TOP_F_26M_ADC_SEL, "f_26m_adc_sel",
|
||||
f_26m_adc_parents, 0x020, 0x024, 0x028, 16, 1, 23,
|
||||
0x1C0, 10),
|
||||
- MUX_GATE_CLR_SET_UPD(CLK_TOP_DRAMC_SEL, "dramc_sel", f_26m_adc_parents,
|
||||
- 0x020, 0x024, 0x028, 24, 1, 31, 0x1C0, 11),
|
||||
+ MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_DRAMC_SEL, "dramc_sel",
|
||||
+ f_26m_adc_parents, 0x020, 0x024, 0x028,
|
||||
+ 24, 1, 31, 0x1C0, 11,
|
||||
+ CLK_IS_CRITICAL | CLK_SET_RATE_PARENT),
|
||||
/* CLK_CFG_3 */
|
||||
- MUX_GATE_CLR_SET_UPD(CLK_TOP_DRAMC_MD32_SEL, "dramc_md32_sel",
|
||||
- dramc_md32_parents, 0x030, 0x034, 0x038, 0, 1, 7,
|
||||
- 0x1C0, 12),
|
||||
- MUX_GATE_CLR_SET_UPD(CLK_TOP_SYSAXI_SEL, "sysaxi_sel", sysaxi_parents,
|
||||
- 0x030, 0x034, 0x038, 8, 2, 15, 0x1C0, 13),
|
||||
- MUX_GATE_CLR_SET_UPD(CLK_TOP_SYSAPB_SEL, "sysapb_sel", sysapb_parents,
|
||||
- 0x030, 0x034, 0x038, 16, 2, 23, 0x1C0, 14),
|
||||
+ MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_DRAMC_MD32_SEL, "dramc_md32_sel",
|
||||
+ dramc_md32_parents, 0x030, 0x034, 0x038,
|
||||
+ 0, 1, 7, 0x1C0, 12,
|
||||
+ CLK_IS_CRITICAL | CLK_SET_RATE_PARENT),
|
||||
+ MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_SYSAXI_SEL, "sysaxi_sel",
|
||||
+ sysaxi_parents, 0x030, 0x034, 0x038,
|
||||
+ 8, 2, 15, 0x1C0, 13,
|
||||
+ CLK_IS_CRITICAL | CLK_SET_RATE_PARENT),
|
||||
+ MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_SYSAPB_SEL, "sysapb_sel",
|
||||
+ sysapb_parents, 0x030, 0x034, 0x038,
|
||||
+ 16, 2, 23, 0x1C0, 14,
|
||||
+ CLK_IS_CRITICAL | CLK_SET_RATE_PARENT),
|
||||
MUX_GATE_CLR_SET_UPD(CLK_TOP_ARM_DB_MAIN_SEL, "arm_db_main_sel",
|
||||
arm_db_main_parents, 0x030, 0x034, 0x038, 24, 1,
|
||||
31, 0x1C0, 15),
|
||||
@@ -234,9 +241,10 @@ static const struct mtk_mux top_muxes[]
|
||||
MUX_GATE_CLR_SET_UPD(CLK_TOP_SGM_325M_SEL, "sgm_325m_sel",
|
||||
sgm_325m_parents, 0x050, 0x054, 0x058, 8, 1, 15,
|
||||
0x1C0, 21),
|
||||
- MUX_GATE_CLR_SET_UPD(CLK_TOP_SGM_REG_SEL, "sgm_reg_sel",
|
||||
- sgm_reg_parents, 0x050, 0x054, 0x058, 16, 1, 23,
|
||||
- 0x1C0, 22),
|
||||
+ MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_SGM_REG_SEL, "sgm_reg_sel",
|
||||
+ sgm_reg_parents, 0x050, 0x054, 0x058,
|
||||
+ 16, 1, 23, 0x1C0, 22,
|
||||
+ CLK_IS_CRITICAL | CLK_SET_RATE_PARENT),
|
||||
MUX_GATE_CLR_SET_UPD(CLK_TOP_A1SYS_SEL, "a1sys_sel", a1sys_parents,
|
||||
0x050, 0x054, 0x058, 24, 1, 31, 0x1C0, 23),
|
||||
/* CLK_CFG_6 */
|
||||
@@ -252,9 +260,10 @@ static const struct mtk_mux top_muxes[]
|
||||
f_26m_adc_parents, 0x060, 0x064, 0x068, 24, 1, 31,
|
||||
0x1C0, 27),
|
||||
/* CLK_CFG_7 */
|
||||
- MUX_GATE_CLR_SET_UPD(CLK_TOP_F26M_SEL, "csw_f26m_sel",
|
||||
- f_26m_adc_parents, 0x070, 0x074, 0x078, 0, 1, 7,
|
||||
- 0x1C0, 28),
|
||||
+ MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_F26M_SEL, "csw_f26m_sel",
|
||||
+ f_26m_adc_parents, 0x070, 0x074, 0x078,
|
||||
+ 0, 1, 7, 0x1C0, 28,
|
||||
+ CLK_IS_CRITICAL | CLK_SET_RATE_PARENT),
|
||||
MUX_GATE_CLR_SET_UPD(CLK_TOP_AUD_L_SEL, "aud_l_sel", aud_l_parents,
|
||||
0x070, 0x074, 0x078, 8, 2, 15, 0x1C0, 29),
|
||||
MUX_GATE_CLR_SET_UPD(CLK_TOP_A_TUNER_SEL, "a_tuner_sel",
|
||||
@@ -307,13 +316,6 @@ static int clk_mt7986_topckgen_probe(str
|
||||
ARRAY_SIZE(top_muxes), node,
|
||||
&mt7986_clk_lock, clk_data);
|
||||
|
||||
- clk_prepare_enable(clk_data->hws[CLK_TOP_SYSAXI_SEL]->clk);
|
||||
- clk_prepare_enable(clk_data->hws[CLK_TOP_SYSAPB_SEL]->clk);
|
||||
- clk_prepare_enable(clk_data->hws[CLK_TOP_DRAMC_SEL]->clk);
|
||||
- clk_prepare_enable(clk_data->hws[CLK_TOP_DRAMC_MD32_SEL]->clk);
|
||||
- clk_prepare_enable(clk_data->hws[CLK_TOP_F26M_SEL]->clk);
|
||||
- clk_prepare_enable(clk_data->hws[CLK_TOP_SGM_REG_SEL]->clk);
|
||||
-
|
||||
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
|
||||
|
||||
if (r) {
|
@ -1,88 +0,0 @@
|
||||
From 9ce3b4e4719d4eec38b2c8da939c073835573d1d Mon Sep 17 00:00:00 2001
|
||||
From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Date: Fri, 20 Jan 2023 10:20:53 +0100
|
||||
Subject: [PATCH 07/15] clk: mediatek: clk-mt7986-topckgen: Migrate to
|
||||
mtk_clk_simple_probe()
|
||||
|
||||
There are no more non-common calls in clk_mt7986_topckgen_probe():
|
||||
migrate this driver to mtk_clk_simple_probe().
|
||||
|
||||
Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Reviewed-by: Miles Chen <miles.chen@mediatek.com>
|
||||
Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
|
||||
Link: https://lore.kernel.org/r/20230120092053.182923-24-angelogioacchino.delregno@collabora.com
|
||||
Tested-by: Mingming Su <mingming.su@mediatek.com>
|
||||
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
|
||||
---
|
||||
drivers/clk/mediatek/clk-mt7986-topckgen.c | 55 +++++-----------------
|
||||
1 file changed, 13 insertions(+), 42 deletions(-)
|
||||
|
||||
--- a/drivers/clk/mediatek/clk-mt7986-topckgen.c
|
||||
+++ b/drivers/clk/mediatek/clk-mt7986-topckgen.c
|
||||
@@ -290,53 +290,24 @@ static const struct mtk_mux top_muxes[]
|
||||
0x1C4, 5),
|
||||
};
|
||||
|
||||
-static int clk_mt7986_topckgen_probe(struct platform_device *pdev)
|
||||
-{
|
||||
- struct clk_hw_onecell_data *clk_data;
|
||||
- struct device_node *node = pdev->dev.of_node;
|
||||
- int r;
|
||||
- void __iomem *base;
|
||||
- int nr = ARRAY_SIZE(top_fixed_clks) + ARRAY_SIZE(top_divs) +
|
||||
- ARRAY_SIZE(top_muxes);
|
||||
-
|
||||
- base = of_iomap(node, 0);
|
||||
- if (!base) {
|
||||
- pr_err("%s(): ioremap failed\n", __func__);
|
||||
- return -ENOMEM;
|
||||
- }
|
||||
-
|
||||
- clk_data = mtk_alloc_clk_data(nr);
|
||||
- if (!clk_data)
|
||||
- return -ENOMEM;
|
||||
-
|
||||
- mtk_clk_register_fixed_clks(top_fixed_clks, ARRAY_SIZE(top_fixed_clks),
|
||||
- clk_data);
|
||||
- mtk_clk_register_factors(top_divs, ARRAY_SIZE(top_divs), clk_data);
|
||||
- mtk_clk_register_muxes(&pdev->dev, top_muxes,
|
||||
- ARRAY_SIZE(top_muxes), node,
|
||||
- &mt7986_clk_lock, clk_data);
|
||||
-
|
||||
- r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
|
||||
-
|
||||
- if (r) {
|
||||
- pr_err("%s(): could not register clock provider: %d\n",
|
||||
- __func__, r);
|
||||
- goto free_topckgen_data;
|
||||
- }
|
||||
- return r;
|
||||
-
|
||||
-free_topckgen_data:
|
||||
- mtk_free_clk_data(clk_data);
|
||||
- return r;
|
||||
-}
|
||||
+static const struct mtk_clk_desc topck_desc = {
|
||||
+ .fixed_clks = top_fixed_clks,
|
||||
+ .num_fixed_clks = ARRAY_SIZE(top_fixed_clks),
|
||||
+ .factor_clks = top_divs,
|
||||
+ .num_factor_clks = ARRAY_SIZE(top_divs),
|
||||
+ .mux_clks = top_muxes,
|
||||
+ .num_mux_clks = ARRAY_SIZE(top_muxes),
|
||||
+ .clk_lock = &mt7986_clk_lock,
|
||||
+};
|
||||
|
||||
static const struct of_device_id of_match_clk_mt7986_topckgen[] = {
|
||||
- { .compatible = "mediatek,mt7986-topckgen", },
|
||||
- {}
|
||||
+ { .compatible = "mediatek,mt7986-topckgen", .data = &topck_desc },
|
||||
+ { /* sentinel */ }
|
||||
};
|
||||
|
||||
static struct platform_driver clk_mt7986_topckgen_drv = {
|
||||
- .probe = clk_mt7986_topckgen_probe,
|
||||
+ .probe = mtk_clk_simple_probe,
|
||||
+ .remove = mtk_clk_simple_remove,
|
||||
.driver = {
|
||||
.name = "clk-mt7986-topckgen",
|
||||
.of_match_table = of_match_clk_mt7986_topckgen,
|
@ -1,38 +0,0 @@
|
||||
From 06abdc84080729dc2c54946e1712c5ee1589ca1c Mon Sep 17 00:00:00 2001
|
||||
From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Date: Mon, 6 Mar 2023 15:05:21 +0100
|
||||
Subject: [PATCH 13/15] clk: mediatek: mt7986-apmixed: Use PLL_AO flag to set
|
||||
critical clock
|
||||
|
||||
Instead of calling clk_prepare_enable() at probe time, add the PLL_AO
|
||||
flag to CLK_APMIXED_ARMPLL clock: this will set CLK_IS_CRITICAL.
|
||||
|
||||
Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
|
||||
Tested-by: Daniel Golle <daniel@makrotopia.org>
|
||||
Link: https://lore.kernel.org/r/20230306140543.1813621-33-angelogioacchino.delregno@collabora.com
|
||||
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
|
||||
---
|
||||
drivers/clk/mediatek/clk-mt7986-apmixed.c | 4 +---
|
||||
1 file changed, 1 insertion(+), 3 deletions(-)
|
||||
|
||||
--- a/drivers/clk/mediatek/clk-mt7986-apmixed.c
|
||||
+++ b/drivers/clk/mediatek/clk-mt7986-apmixed.c
|
||||
@@ -42,7 +42,7 @@
|
||||
"clkxtal")
|
||||
|
||||
static const struct mtk_pll_data plls[] = {
|
||||
- PLL(CLK_APMIXED_ARMPLL, "armpll", 0x0200, 0x020C, 0x0, 0, 32,
|
||||
+ PLL(CLK_APMIXED_ARMPLL, "armpll", 0x0200, 0x020C, 0x0, PLL_AO, 32,
|
||||
0x0200, 4, 0, 0x0204, 0),
|
||||
PLL(CLK_APMIXED_NET2PLL, "net2pll", 0x0210, 0x021C, 0x0, 0, 32,
|
||||
0x0210, 4, 0, 0x0214, 0),
|
||||
@@ -77,8 +77,6 @@ static int clk_mt7986_apmixed_probe(stru
|
||||
|
||||
mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data);
|
||||
|
||||
- clk_prepare_enable(clk_data->hws[CLK_APMIXED_ARMPLL]->clk);
|
||||
-
|
||||
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
|
||||
if (r) {
|
||||
pr_err("%s(): could not register clock provider: %d\n",
|
@ -1,237 +0,0 @@
|
||||
From a6473d0f9f07b1196f3a67099826f50a2a4e84e8 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Thu, 26 Jan 2023 03:34:05 +0000
|
||||
Subject: [PATCH] dt-bindings: clock: mediatek: add mt7981 clock IDs
|
||||
|
||||
Add MT7981 clock dt-bindings, include topckgen, apmixedsys,
|
||||
infracfg, and ethernet subsystem clocks.
|
||||
|
||||
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
|
||||
Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com>
|
||||
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
Link: https://lore.kernel.org/r/e353d32b5a4481766519a037afe1ed44e31ece1a.1674703830.git.daniel@makrotopia.org
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
|
||||
---
|
||||
.../dt-bindings/clock/mediatek,mt7981-clk.h | 215 ++++++++++++++++++
|
||||
1 file changed, 215 insertions(+)
|
||||
create mode 100644 include/dt-bindings/clock/mediatek,mt7981-clk.h
|
||||
|
||||
--- /dev/null
|
||||
+++ b/include/dt-bindings/clock/mediatek,mt7981-clk.h
|
||||
@@ -0,0 +1,215 @@
|
||||
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
|
||||
+/*
|
||||
+ * Copyright (c) 2021 MediaTek Inc.
|
||||
+ * Author: Wenzhen.Yu <wenzhen.yu@mediatek.com>
|
||||
+ * Author: Jianhui Zhao <zhaojh329@gmail.com>
|
||||
+ * Author: Daniel Golle <daniel@makrotopia.org>
|
||||
+ */
|
||||
+
|
||||
+#ifndef _DT_BINDINGS_CLK_MT7981_H
|
||||
+#define _DT_BINDINGS_CLK_MT7981_H
|
||||
+
|
||||
+/* TOPCKGEN */
|
||||
+#define CLK_TOP_CB_CKSQ_40M 0
|
||||
+#define CLK_TOP_CB_M_416M 1
|
||||
+#define CLK_TOP_CB_M_D2 2
|
||||
+#define CLK_TOP_CB_M_D3 3
|
||||
+#define CLK_TOP_M_D3_D2 4
|
||||
+#define CLK_TOP_CB_M_D4 5
|
||||
+#define CLK_TOP_CB_M_D8 6
|
||||
+#define CLK_TOP_M_D8_D2 7
|
||||
+#define CLK_TOP_CB_MM_720M 8
|
||||
+#define CLK_TOP_CB_MM_D2 9
|
||||
+#define CLK_TOP_CB_MM_D3 10
|
||||
+#define CLK_TOP_CB_MM_D3_D5 11
|
||||
+#define CLK_TOP_CB_MM_D4 12
|
||||
+#define CLK_TOP_CB_MM_D6 13
|
||||
+#define CLK_TOP_MM_D6_D2 14
|
||||
+#define CLK_TOP_CB_MM_D8 15
|
||||
+#define CLK_TOP_CB_APLL2_196M 16
|
||||
+#define CLK_TOP_APLL2_D2 17
|
||||
+#define CLK_TOP_APLL2_D4 18
|
||||
+#define CLK_TOP_NET1_2500M 19
|
||||
+#define CLK_TOP_CB_NET1_D4 20
|
||||
+#define CLK_TOP_CB_NET1_D5 21
|
||||
+#define CLK_TOP_NET1_D5_D2 22
|
||||
+#define CLK_TOP_NET1_D5_D4 23
|
||||
+#define CLK_TOP_CB_NET1_D8 24
|
||||
+#define CLK_TOP_NET1_D8_D2 25
|
||||
+#define CLK_TOP_NET1_D8_D4 26
|
||||
+#define CLK_TOP_CB_NET2_800M 27
|
||||
+#define CLK_TOP_CB_NET2_D2 28
|
||||
+#define CLK_TOP_CB_NET2_D4 29
|
||||
+#define CLK_TOP_NET2_D4_D2 30
|
||||
+#define CLK_TOP_NET2_D4_D4 31
|
||||
+#define CLK_TOP_CB_NET2_D6 32
|
||||
+#define CLK_TOP_CB_WEDMCU_208M 33
|
||||
+#define CLK_TOP_CB_SGM_325M 34
|
||||
+#define CLK_TOP_CKSQ_40M_D2 35
|
||||
+#define CLK_TOP_CB_RTC_32K 36
|
||||
+#define CLK_TOP_CB_RTC_32P7K 37
|
||||
+#define CLK_TOP_USB_TX250M 38
|
||||
+#define CLK_TOP_FAUD 39
|
||||
+#define CLK_TOP_NFI1X 40
|
||||
+#define CLK_TOP_USB_EQ_RX250M 41
|
||||
+#define CLK_TOP_USB_CDR_CK 42
|
||||
+#define CLK_TOP_USB_LN0_CK 43
|
||||
+#define CLK_TOP_SPINFI_BCK 44
|
||||
+#define CLK_TOP_SPI 45
|
||||
+#define CLK_TOP_SPIM_MST 46
|
||||
+#define CLK_TOP_UART_BCK 47
|
||||
+#define CLK_TOP_PWM_BCK 48
|
||||
+#define CLK_TOP_I2C_BCK 49
|
||||
+#define CLK_TOP_PEXTP_TL 50
|
||||
+#define CLK_TOP_EMMC_208M 51
|
||||
+#define CLK_TOP_EMMC_400M 52
|
||||
+#define CLK_TOP_DRAMC_REF 53
|
||||
+#define CLK_TOP_DRAMC_MD32 54
|
||||
+#define CLK_TOP_SYSAXI 55
|
||||
+#define CLK_TOP_SYSAPB 56
|
||||
+#define CLK_TOP_ARM_DB_MAIN 57
|
||||
+#define CLK_TOP_AP2CNN_HOST 58
|
||||
+#define CLK_TOP_NETSYS 59
|
||||
+#define CLK_TOP_NETSYS_500M 60
|
||||
+#define CLK_TOP_NETSYS_WED_MCU 61
|
||||
+#define CLK_TOP_NETSYS_2X 62
|
||||
+#define CLK_TOP_SGM_325M 63
|
||||
+#define CLK_TOP_SGM_REG 64
|
||||
+#define CLK_TOP_F26M 65
|
||||
+#define CLK_TOP_EIP97B 66
|
||||
+#define CLK_TOP_USB3_PHY 67
|
||||
+#define CLK_TOP_AUD 68
|
||||
+#define CLK_TOP_A1SYS 69
|
||||
+#define CLK_TOP_AUD_L 70
|
||||
+#define CLK_TOP_A_TUNER 71
|
||||
+#define CLK_TOP_U2U3_REF 72
|
||||
+#define CLK_TOP_U2U3_SYS 73
|
||||
+#define CLK_TOP_U2U3_XHCI 74
|
||||
+#define CLK_TOP_USB_FRMCNT 75
|
||||
+#define CLK_TOP_NFI1X_SEL 76
|
||||
+#define CLK_TOP_SPINFI_SEL 77
|
||||
+#define CLK_TOP_SPI_SEL 78
|
||||
+#define CLK_TOP_SPIM_MST_SEL 79
|
||||
+#define CLK_TOP_UART_SEL 80
|
||||
+#define CLK_TOP_PWM_SEL 81
|
||||
+#define CLK_TOP_I2C_SEL 82
|
||||
+#define CLK_TOP_PEXTP_TL_SEL 83
|
||||
+#define CLK_TOP_EMMC_208M_SEL 84
|
||||
+#define CLK_TOP_EMMC_400M_SEL 85
|
||||
+#define CLK_TOP_F26M_SEL 86
|
||||
+#define CLK_TOP_DRAMC_SEL 87
|
||||
+#define CLK_TOP_DRAMC_MD32_SEL 88
|
||||
+#define CLK_TOP_SYSAXI_SEL 89
|
||||
+#define CLK_TOP_SYSAPB_SEL 90
|
||||
+#define CLK_TOP_ARM_DB_MAIN_SEL 91
|
||||
+#define CLK_TOP_AP2CNN_HOST_SEL 92
|
||||
+#define CLK_TOP_NETSYS_SEL 93
|
||||
+#define CLK_TOP_NETSYS_500M_SEL 94
|
||||
+#define CLK_TOP_NETSYS_MCU_SEL 95
|
||||
+#define CLK_TOP_NETSYS_2X_SEL 96
|
||||
+#define CLK_TOP_SGM_325M_SEL 97
|
||||
+#define CLK_TOP_SGM_REG_SEL 98
|
||||
+#define CLK_TOP_EIP97B_SEL 99
|
||||
+#define CLK_TOP_USB3_PHY_SEL 100
|
||||
+#define CLK_TOP_AUD_SEL 101
|
||||
+#define CLK_TOP_A1SYS_SEL 102
|
||||
+#define CLK_TOP_AUD_L_SEL 103
|
||||
+#define CLK_TOP_A_TUNER_SEL 104
|
||||
+#define CLK_TOP_U2U3_SEL 105
|
||||
+#define CLK_TOP_U2U3_SYS_SEL 106
|
||||
+#define CLK_TOP_U2U3_XHCI_SEL 107
|
||||
+#define CLK_TOP_USB_FRMCNT_SEL 108
|
||||
+#define CLK_TOP_AUD_I2S_M 109
|
||||
+
|
||||
+/* INFRACFG */
|
||||
+#define CLK_INFRA_66M_MCK 0
|
||||
+#define CLK_INFRA_UART0_SEL 1
|
||||
+#define CLK_INFRA_UART1_SEL 2
|
||||
+#define CLK_INFRA_UART2_SEL 3
|
||||
+#define CLK_INFRA_SPI0_SEL 4
|
||||
+#define CLK_INFRA_SPI1_SEL 5
|
||||
+#define CLK_INFRA_SPI2_SEL 6
|
||||
+#define CLK_INFRA_PWM1_SEL 7
|
||||
+#define CLK_INFRA_PWM2_SEL 8
|
||||
+#define CLK_INFRA_PWM3_SEL 9
|
||||
+#define CLK_INFRA_PWM_BSEL 10
|
||||
+#define CLK_INFRA_PCIE_SEL 11
|
||||
+#define CLK_INFRA_GPT_STA 12
|
||||
+#define CLK_INFRA_PWM_HCK 13
|
||||
+#define CLK_INFRA_PWM_STA 14
|
||||
+#define CLK_INFRA_PWM1_CK 15
|
||||
+#define CLK_INFRA_PWM2_CK 16
|
||||
+#define CLK_INFRA_PWM3_CK 17
|
||||
+#define CLK_INFRA_CQ_DMA_CK 18
|
||||
+#define CLK_INFRA_AUD_BUS_CK 19
|
||||
+#define CLK_INFRA_AUD_26M_CK 20
|
||||
+#define CLK_INFRA_AUD_L_CK 21
|
||||
+#define CLK_INFRA_AUD_AUD_CK 22
|
||||
+#define CLK_INFRA_AUD_EG2_CK 23
|
||||
+#define CLK_INFRA_DRAMC_26M_CK 24
|
||||
+#define CLK_INFRA_DBG_CK 25
|
||||
+#define CLK_INFRA_AP_DMA_CK 26
|
||||
+#define CLK_INFRA_SEJ_CK 27
|
||||
+#define CLK_INFRA_SEJ_13M_CK 28
|
||||
+#define CLK_INFRA_THERM_CK 29
|
||||
+#define CLK_INFRA_I2C0_CK 30
|
||||
+#define CLK_INFRA_UART0_CK 31
|
||||
+#define CLK_INFRA_UART1_CK 32
|
||||
+#define CLK_INFRA_UART2_CK 33
|
||||
+#define CLK_INFRA_SPI2_CK 34
|
||||
+#define CLK_INFRA_SPI2_HCK_CK 35
|
||||
+#define CLK_INFRA_NFI1_CK 36
|
||||
+#define CLK_INFRA_SPINFI1_CK 37
|
||||
+#define CLK_INFRA_NFI_HCK_CK 38
|
||||
+#define CLK_INFRA_SPI0_CK 39
|
||||
+#define CLK_INFRA_SPI1_CK 40
|
||||
+#define CLK_INFRA_SPI0_HCK_CK 41
|
||||
+#define CLK_INFRA_SPI1_HCK_CK 42
|
||||
+#define CLK_INFRA_FRTC_CK 43
|
||||
+#define CLK_INFRA_MSDC_CK 44
|
||||
+#define CLK_INFRA_MSDC_HCK_CK 45
|
||||
+#define CLK_INFRA_MSDC_133M_CK 46
|
||||
+#define CLK_INFRA_MSDC_66M_CK 47
|
||||
+#define CLK_INFRA_ADC_26M_CK 48
|
||||
+#define CLK_INFRA_ADC_FRC_CK 49
|
||||
+#define CLK_INFRA_FBIST2FPC_CK 50
|
||||
+#define CLK_INFRA_I2C_MCK_CK 51
|
||||
+#define CLK_INFRA_I2C_PCK_CK 52
|
||||
+#define CLK_INFRA_IUSB_133_CK 53
|
||||
+#define CLK_INFRA_IUSB_66M_CK 54
|
||||
+#define CLK_INFRA_IUSB_SYS_CK 55
|
||||
+#define CLK_INFRA_IUSB_CK 56
|
||||
+#define CLK_INFRA_IPCIE_CK 57
|
||||
+#define CLK_INFRA_IPCIE_PIPE_CK 58
|
||||
+#define CLK_INFRA_IPCIER_CK 59
|
||||
+#define CLK_INFRA_IPCIEB_CK 60
|
||||
+
|
||||
+/* APMIXEDSYS */
|
||||
+#define CLK_APMIXED_ARMPLL 0
|
||||
+#define CLK_APMIXED_NET2PLL 1
|
||||
+#define CLK_APMIXED_MMPLL 2
|
||||
+#define CLK_APMIXED_SGMPLL 3
|
||||
+#define CLK_APMIXED_WEDMCUPLL 4
|
||||
+#define CLK_APMIXED_NET1PLL 5
|
||||
+#define CLK_APMIXED_MPLL 6
|
||||
+#define CLK_APMIXED_APLL2 7
|
||||
+
|
||||
+/* SGMIISYS_0 */
|
||||
+#define CLK_SGM0_TX_EN 0
|
||||
+#define CLK_SGM0_RX_EN 1
|
||||
+#define CLK_SGM0_CK0_EN 2
|
||||
+#define CLK_SGM0_CDR_CK0_EN 3
|
||||
+
|
||||
+/* SGMIISYS_1 */
|
||||
+#define CLK_SGM1_TX_EN 0
|
||||
+#define CLK_SGM1_RX_EN 1
|
||||
+#define CLK_SGM1_CK1_EN 2
|
||||
+#define CLK_SGM1_CDR_CK1_EN 3
|
||||
+
|
||||
+/* ETHSYS */
|
||||
+#define CLK_ETH_FE_EN 0
|
||||
+#define CLK_ETH_GP2_EN 1
|
||||
+#define CLK_ETH_GP1_EN 2
|
||||
+#define CLK_ETH_WOCPU0_EN 3
|
||||
+
|
||||
+#endif /* _DT_BINDINGS_CLK_MT7981_H */
|
@ -1,932 +0,0 @@
|
||||
From 8efeeb9c8b4ecf4fb4a74be9403aba951403bbaa Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Thu, 26 Jan 2023 03:34:24 +0000
|
||||
Subject: [PATCH] clk: mediatek: add MT7981 clock support
|
||||
|
||||
Add MT7981 clock support, include topckgen, apmixedsys, infracfg and
|
||||
ethernet subsystem clocks.
|
||||
|
||||
The drivers are based on clk-mt7981.c which can be found in MediaTek's
|
||||
SDK sources. To be fit for upstream inclusion the driver has been split
|
||||
into clock domains and the infracfg part has been significantly
|
||||
de-bloated by removing all the 1:1 factors (aliases).
|
||||
|
||||
Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com>
|
||||
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
Link: https://lore.kernel.org/r/8136eb5b2049177bc2f6d3e0f2aefecc342d626f.1674703830.git.daniel@makrotopia.org
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
[sboyd@kernel.org: Add module license]
|
||||
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
|
||||
---
|
||||
drivers/clk/mediatek/Kconfig | 17 +
|
||||
drivers/clk/mediatek/Makefile | 4 +
|
||||
drivers/clk/mediatek/clk-mt7981-apmixed.c | 102 +++++
|
||||
drivers/clk/mediatek/clk-mt7981-eth.c | 118 ++++++
|
||||
drivers/clk/mediatek/clk-mt7981-infracfg.c | 207 ++++++++++
|
||||
drivers/clk/mediatek/clk-mt7981-topckgen.c | 422 +++++++++++++++++++++
|
||||
6 files changed, 870 insertions(+)
|
||||
create mode 100644 drivers/clk/mediatek/clk-mt7981-apmixed.c
|
||||
create mode 100644 drivers/clk/mediatek/clk-mt7981-eth.c
|
||||
create mode 100644 drivers/clk/mediatek/clk-mt7981-infracfg.c
|
||||
create mode 100644 drivers/clk/mediatek/clk-mt7981-topckgen.c
|
||||
|
||||
--- a/drivers/clk/mediatek/Kconfig
|
||||
+++ b/drivers/clk/mediatek/Kconfig
|
||||
@@ -381,6 +381,23 @@ config COMMON_CLK_MT7629_HIFSYS
|
||||
This driver supports MediaTek MT7629 HIFSYS clocks providing
|
||||
to PCI-E and USB.
|
||||
|
||||
+config COMMON_CLK_MT7981
|
||||
+ bool "Clock driver for MediaTek MT7981"
|
||||
+ depends on ARCH_MEDIATEK || COMPILE_TEST
|
||||
+ select COMMON_CLK_MEDIATEK
|
||||
+ default ARCH_MEDIATEK
|
||||
+ help
|
||||
+ This driver supports MediaTek MT7981 basic clocks and clocks
|
||||
+ required for various peripherals found on this SoC.
|
||||
+
|
||||
+config COMMON_CLK_MT7981_ETHSYS
|
||||
+ tristate "Clock driver for MediaTek MT7981 ETHSYS"
|
||||
+ depends on COMMON_CLK_MT7981
|
||||
+ default COMMON_CLK_MT7981
|
||||
+ help
|
||||
+ This driver adds support for clocks for Ethernet and SGMII
|
||||
+ required on MediaTek MT7981 SoC.
|
||||
+
|
||||
config COMMON_CLK_MT7986
|
||||
bool "Clock driver for MediaTek MT7986"
|
||||
depends on ARCH_MEDIATEK || COMPILE_TEST
|
||||
--- a/drivers/clk/mediatek/Makefile
|
||||
+++ b/drivers/clk/mediatek/Makefile
|
||||
@@ -52,6 +52,10 @@ obj-$(CONFIG_COMMON_CLK_MT7622_AUDSYS) +
|
||||
obj-$(CONFIG_COMMON_CLK_MT7629) += clk-mt7629.o
|
||||
obj-$(CONFIG_COMMON_CLK_MT7629_ETHSYS) += clk-mt7629-eth.o
|
||||
obj-$(CONFIG_COMMON_CLK_MT7629_HIFSYS) += clk-mt7629-hif.o
|
||||
+obj-$(CONFIG_COMMON_CLK_MT7981) += clk-mt7981-apmixed.o
|
||||
+obj-$(CONFIG_COMMON_CLK_MT7981) += clk-mt7981-topckgen.o
|
||||
+obj-$(CONFIG_COMMON_CLK_MT7981) += clk-mt7981-infracfg.o
|
||||
+obj-$(CONFIG_COMMON_CLK_MT7981_ETHSYS) += clk-mt7981-eth.o
|
||||
obj-$(CONFIG_COMMON_CLK_MT7986) += clk-mt7986-apmixed.o
|
||||
obj-$(CONFIG_COMMON_CLK_MT7986) += clk-mt7986-topckgen.o
|
||||
obj-$(CONFIG_COMMON_CLK_MT7986) += clk-mt7986-infracfg.o
|
||||
--- /dev/null
|
||||
+++ b/drivers/clk/mediatek/clk-mt7981-apmixed.c
|
||||
@@ -0,0 +1,102 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0
|
||||
+/*
|
||||
+ * Copyright (c) 2021 MediaTek Inc.
|
||||
+ * Author: Sam Shih <sam.shih@mediatek.com>
|
||||
+ * Author: Wenzhen Yu <wenzhen.yu@mediatek.com>
|
||||
+ * Author: Jianhui Zhao <zhaojh329@gmail.com>
|
||||
+ * Author: Daniel Golle <daniel@makrotopia.org>
|
||||
+ */
|
||||
+
|
||||
+#include <linux/clk-provider.h>
|
||||
+#include <linux/of.h>
|
||||
+#include <linux/of_address.h>
|
||||
+#include <linux/of_device.h>
|
||||
+#include <linux/platform_device.h>
|
||||
+
|
||||
+#include "clk-gate.h"
|
||||
+#include "clk-mtk.h"
|
||||
+#include "clk-mux.h"
|
||||
+#include "clk-pll.h"
|
||||
+
|
||||
+#include <dt-bindings/clock/mediatek,mt7981-clk.h>
|
||||
+#include <linux/clk.h>
|
||||
+
|
||||
+#define MT7981_PLL_FMAX (2500UL * MHZ)
|
||||
+#define CON0_MT7981_RST_BAR BIT(27)
|
||||
+
|
||||
+#define PLL_xtal(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits, \
|
||||
+ _pd_reg, _pd_shift, _tuner_reg, _pcw_reg, _pcw_shift, \
|
||||
+ _div_table, _parent_name) \
|
||||
+ { \
|
||||
+ .id = _id, .name = _name, .reg = _reg, .pwr_reg = _pwr_reg, \
|
||||
+ .en_mask = _en_mask, .flags = _flags, \
|
||||
+ .rst_bar_mask = CON0_MT7981_RST_BAR, .fmax = MT7981_PLL_FMAX, \
|
||||
+ .pcwbits = _pcwbits, .pd_reg = _pd_reg, .pd_shift = _pd_shift, \
|
||||
+ .tuner_reg = _tuner_reg, .pcw_reg = _pcw_reg, \
|
||||
+ .pcw_shift = _pcw_shift, .div_table = _div_table, \
|
||||
+ .parent_name = _parent_name, \
|
||||
+ }
|
||||
+
|
||||
+#define PLL(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits, _pd_reg, \
|
||||
+ _pd_shift, _tuner_reg, _pcw_reg, _pcw_shift) \
|
||||
+ PLL_xtal(_id, _name, _reg, _pwr_reg, _en_mask, _flags, _pcwbits, \
|
||||
+ _pd_reg, _pd_shift, _tuner_reg, _pcw_reg, _pcw_shift, NULL, \
|
||||
+ "clkxtal")
|
||||
+
|
||||
+static const struct mtk_pll_data plls[] = {
|
||||
+ PLL(CLK_APMIXED_ARMPLL, "armpll", 0x0200, 0x020C, 0x00000001, PLL_AO,
|
||||
+ 32, 0x0200, 4, 0, 0x0204, 0),
|
||||
+ PLL(CLK_APMIXED_NET2PLL, "net2pll", 0x0210, 0x021C, 0x00000001, 0, 32,
|
||||
+ 0x0210, 4, 0, 0x0214, 0),
|
||||
+ PLL(CLK_APMIXED_MMPLL, "mmpll", 0x0220, 0x022C, 0x00000001, 0, 32,
|
||||
+ 0x0220, 4, 0, 0x0224, 0),
|
||||
+ PLL(CLK_APMIXED_SGMPLL, "sgmpll", 0x0230, 0x023C, 0x00000001, 0, 32,
|
||||
+ 0x0230, 4, 0, 0x0234, 0),
|
||||
+ PLL(CLK_APMIXED_WEDMCUPLL, "wedmcupll", 0x0240, 0x024C, 0x00000001, 0, 32,
|
||||
+ 0x0240, 4, 0, 0x0244, 0),
|
||||
+ PLL(CLK_APMIXED_NET1PLL, "net1pll", 0x0250, 0x025C, 0x00000001, 0, 32,
|
||||
+ 0x0250, 4, 0, 0x0254, 0),
|
||||
+ PLL(CLK_APMIXED_MPLL, "mpll", 0x0260, 0x0270, 0x00000001, 0, 32,
|
||||
+ 0x0260, 4, 0, 0x0264, 0),
|
||||
+ PLL(CLK_APMIXED_APLL2, "apll2", 0x0278, 0x0288, 0x00000001, 0, 32,
|
||||
+ 0x0278, 4, 0, 0x027C, 0),
|
||||
+};
|
||||
+
|
||||
+static const struct of_device_id of_match_clk_mt7981_apmixed[] = {
|
||||
+ { .compatible = "mediatek,mt7981-apmixedsys", },
|
||||
+ { /* sentinel */ }
|
||||
+};
|
||||
+
|
||||
+static int clk_mt7981_apmixed_probe(struct platform_device *pdev)
|
||||
+{
|
||||
+ struct clk_hw_onecell_data *clk_data;
|
||||
+ struct device_node *node = pdev->dev.of_node;
|
||||
+ int r;
|
||||
+
|
||||
+ clk_data = mtk_alloc_clk_data(ARRAY_SIZE(plls));
|
||||
+ if (!clk_data)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data);
|
||||
+
|
||||
+ r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
|
||||
+ if (r) {
|
||||
+ pr_err("%s(): could not register clock provider: %d\n",
|
||||
+ __func__, r);
|
||||
+ goto free_apmixed_data;
|
||||
+ }
|
||||
+ return r;
|
||||
+
|
||||
+free_apmixed_data:
|
||||
+ mtk_free_clk_data(clk_data);
|
||||
+ return r;
|
||||
+}
|
||||
+
|
||||
+static struct platform_driver clk_mt7981_apmixed_drv = {
|
||||
+ .probe = clk_mt7981_apmixed_probe,
|
||||
+ .driver = {
|
||||
+ .name = "clk-mt7981-apmixed",
|
||||
+ .of_match_table = of_match_clk_mt7981_apmixed,
|
||||
+ },
|
||||
+};
|
||||
+builtin_platform_driver(clk_mt7981_apmixed_drv);
|
||||
--- /dev/null
|
||||
+++ b/drivers/clk/mediatek/clk-mt7981-eth.c
|
||||
@@ -0,0 +1,118 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0
|
||||
+/*
|
||||
+ * Copyright (c) 2021 MediaTek Inc.
|
||||
+ * Author: Sam Shih <sam.shih@mediatek.com>
|
||||
+ * Author: Wenzhen Yu <wenzhen.yu@mediatek.com>
|
||||
+ * Author: Jianhui Zhao <zhaojh329@gmail.com>
|
||||
+ * Author: Daniel Golle <daniel@makrotopia.org>
|
||||
+ */
|
||||
+
|
||||
+#include <linux/clk-provider.h>
|
||||
+#include <linux/of.h>
|
||||
+#include <linux/of_address.h>
|
||||
+#include <linux/of_device.h>
|
||||
+#include <linux/platform_device.h>
|
||||
+
|
||||
+#include "clk-mtk.h"
|
||||
+#include "clk-gate.h"
|
||||
+
|
||||
+#include <dt-bindings/clock/mediatek,mt7981-clk.h>
|
||||
+
|
||||
+static const struct mtk_gate_regs sgmii0_cg_regs = {
|
||||
+ .set_ofs = 0xE4,
|
||||
+ .clr_ofs = 0xE4,
|
||||
+ .sta_ofs = 0xE4,
|
||||
+};
|
||||
+
|
||||
+#define GATE_SGMII0(_id, _name, _parent, _shift) { \
|
||||
+ .id = _id, \
|
||||
+ .name = _name, \
|
||||
+ .parent_name = _parent, \
|
||||
+ .regs = &sgmii0_cg_regs, \
|
||||
+ .shift = _shift, \
|
||||
+ .ops = &mtk_clk_gate_ops_no_setclr_inv, \
|
||||
+ }
|
||||
+
|
||||
+static const struct mtk_gate sgmii0_clks[] __initconst = {
|
||||
+ GATE_SGMII0(CLK_SGM0_TX_EN, "sgm0_tx_en", "usb_tx250m", 2),
|
||||
+ GATE_SGMII0(CLK_SGM0_RX_EN, "sgm0_rx_en", "usb_eq_rx250m", 3),
|
||||
+ GATE_SGMII0(CLK_SGM0_CK0_EN, "sgm0_ck0_en", "usb_ln0", 4),
|
||||
+ GATE_SGMII0(CLK_SGM0_CDR_CK0_EN, "sgm0_cdr_ck0_en", "usb_cdr", 5),
|
||||
+};
|
||||
+
|
||||
+static const struct mtk_gate_regs sgmii1_cg_regs = {
|
||||
+ .set_ofs = 0xE4,
|
||||
+ .clr_ofs = 0xE4,
|
||||
+ .sta_ofs = 0xE4,
|
||||
+};
|
||||
+
|
||||
+#define GATE_SGMII1(_id, _name, _parent, _shift) { \
|
||||
+ .id = _id, \
|
||||
+ .name = _name, \
|
||||
+ .parent_name = _parent, \
|
||||
+ .regs = &sgmii1_cg_regs, \
|
||||
+ .shift = _shift, \
|
||||
+ .ops = &mtk_clk_gate_ops_no_setclr_inv, \
|
||||
+ }
|
||||
+
|
||||
+static const struct mtk_gate sgmii1_clks[] __initconst = {
|
||||
+ GATE_SGMII1(CLK_SGM1_TX_EN, "sgm1_tx_en", "usb_tx250m", 2),
|
||||
+ GATE_SGMII1(CLK_SGM1_RX_EN, "sgm1_rx_en", "usb_eq_rx250m", 3),
|
||||
+ GATE_SGMII1(CLK_SGM1_CK1_EN, "sgm1_ck1_en", "usb_ln0", 4),
|
||||
+ GATE_SGMII1(CLK_SGM1_CDR_CK1_EN, "sgm1_cdr_ck1_en", "usb_cdr", 5),
|
||||
+};
|
||||
+
|
||||
+static const struct mtk_gate_regs eth_cg_regs = {
|
||||
+ .set_ofs = 0x30,
|
||||
+ .clr_ofs = 0x30,
|
||||
+ .sta_ofs = 0x30,
|
||||
+};
|
||||
+
|
||||
+#define GATE_ETH(_id, _name, _parent, _shift) { \
|
||||
+ .id = _id, \
|
||||
+ .name = _name, \
|
||||
+ .parent_name = _parent, \
|
||||
+ .regs = ð_cg_regs, \
|
||||
+ .shift = _shift, \
|
||||
+ .ops = &mtk_clk_gate_ops_no_setclr_inv, \
|
||||
+ }
|
||||
+
|
||||
+static const struct mtk_gate eth_clks[] __initconst = {
|
||||
+ GATE_ETH(CLK_ETH_FE_EN, "eth_fe_en", "netsys_2x", 6),
|
||||
+ GATE_ETH(CLK_ETH_GP2_EN, "eth_gp2_en", "sgm_325m", 7),
|
||||
+ GATE_ETH(CLK_ETH_GP1_EN, "eth_gp1_en", "sgm_325m", 8),
|
||||
+ GATE_ETH(CLK_ETH_WOCPU0_EN, "eth_wocpu0_en", "netsys_wed_mcu", 15),
|
||||
+};
|
||||
+
|
||||
+static const struct mtk_clk_desc eth_desc = {
|
||||
+ .clks = eth_clks,
|
||||
+ .num_clks = ARRAY_SIZE(eth_clks),
|
||||
+};
|
||||
+
|
||||
+static const struct mtk_clk_desc sgmii0_desc = {
|
||||
+ .clks = sgmii0_clks,
|
||||
+ .num_clks = ARRAY_SIZE(sgmii0_clks),
|
||||
+};
|
||||
+
|
||||
+static const struct mtk_clk_desc sgmii1_desc = {
|
||||
+ .clks = sgmii1_clks,
|
||||
+ .num_clks = ARRAY_SIZE(sgmii1_clks),
|
||||
+};
|
||||
+
|
||||
+static const struct of_device_id of_match_clk_mt7981_eth[] = {
|
||||
+ { .compatible = "mediatek,mt7981-ethsys", .data = ð_desc },
|
||||
+ { .compatible = "mediatek,mt7981-sgmiisys_0", .data = &sgmii0_desc },
|
||||
+ { .compatible = "mediatek,mt7981-sgmiisys_1", .data = &sgmii1_desc },
|
||||
+ { /* sentinel */ }
|
||||
+};
|
||||
+
|
||||
+static struct platform_driver clk_mt7981_eth_drv = {
|
||||
+ .probe = mtk_clk_simple_probe,
|
||||
+ .remove = mtk_clk_simple_remove,
|
||||
+ .driver = {
|
||||
+ .name = "clk-mt7981-eth",
|
||||
+ .of_match_table = of_match_clk_mt7981_eth,
|
||||
+ },
|
||||
+};
|
||||
+module_platform_driver(clk_mt7981_eth_drv);
|
||||
+MODULE_LICENSE("GPL v2");
|
||||
--- /dev/null
|
||||
+++ b/drivers/clk/mediatek/clk-mt7981-infracfg.c
|
||||
@@ -0,0 +1,207 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0
|
||||
+/*
|
||||
+ * Copyright (c) 2021 MediaTek Inc.
|
||||
+ * Author: Sam Shih <sam.shih@mediatek.com>
|
||||
+ * Author: Wenzhen Yu <wenzhen.yu@mediatek.com>
|
||||
+ * Author: Jianhui Zhao <zhaojh329@gmail.com>
|
||||
+ * Author: Daniel Golle <daniel@makrotopia.org>
|
||||
+ */
|
||||
+
|
||||
+#include <linux/clk-provider.h>
|
||||
+#include <linux/of.h>
|
||||
+#include <linux/of_address.h>
|
||||
+#include <linux/of_device.h>
|
||||
+#include <linux/platform_device.h>
|
||||
+#include "clk-mtk.h"
|
||||
+#include "clk-gate.h"
|
||||
+#include "clk-mux.h"
|
||||
+
|
||||
+#include <dt-bindings/clock/mediatek,mt7981-clk.h>
|
||||
+#include <linux/clk.h>
|
||||
+
|
||||
+static DEFINE_SPINLOCK(mt7981_clk_lock);
|
||||
+
|
||||
+static const struct mtk_fixed_factor infra_divs[] = {
|
||||
+ FACTOR(CLK_INFRA_66M_MCK, "infra_66m_mck", "sysaxi_sel", 1, 2),
|
||||
+};
|
||||
+
|
||||
+static const char *const infra_uart_parent[] __initconst = { "csw_f26m_sel",
|
||||
+ "uart_sel" };
|
||||
+
|
||||
+static const char *const infra_spi0_parents[] __initconst = { "i2c_sel",
|
||||
+ "spi_sel" };
|
||||
+
|
||||
+static const char *const infra_spi1_parents[] __initconst = { "i2c_sel",
|
||||
+ "spim_mst_sel" };
|
||||
+
|
||||
+static const char *const infra_pwm1_parents[] __initconst = { "pwm_sel" };
|
||||
+
|
||||
+static const char *const infra_pwm_bsel_parents[] __initconst = {
|
||||
+ "cb_rtc_32p7k", "csw_f26m_sel", "infra_66m_mck", "pwm_sel"
|
||||
+};
|
||||
+
|
||||
+static const char *const infra_pcie_parents[] __initconst = {
|
||||
+ "cb_rtc_32p7k", "csw_f26m_sel", "cb_cksq_40m", "pextp_tl_ck_sel"
|
||||
+};
|
||||
+
|
||||
+static const struct mtk_mux infra_muxes[] = {
|
||||
+ /* MODULE_CLK_SEL_0 */
|
||||
+ MUX_GATE_CLR_SET_UPD(CLK_INFRA_UART0_SEL, "infra_uart0_sel",
|
||||
+ infra_uart_parent, 0x0018, 0x0010, 0x0014, 0, 1,
|
||||
+ -1, -1, -1),
|
||||
+ MUX_GATE_CLR_SET_UPD(CLK_INFRA_UART1_SEL, "infra_uart1_sel",
|
||||
+ infra_uart_parent, 0x0018, 0x0010, 0x0014, 1, 1,
|
||||
+ -1, -1, -1),
|
||||
+ MUX_GATE_CLR_SET_UPD(CLK_INFRA_UART2_SEL, "infra_uart2_sel",
|
||||
+ infra_uart_parent, 0x0018, 0x0010, 0x0014, 2, 1,
|
||||
+ -1, -1, -1),
|
||||
+ MUX_GATE_CLR_SET_UPD(CLK_INFRA_SPI0_SEL, "infra_spi0_sel",
|
||||
+ infra_spi0_parents, 0x0018, 0x0010, 0x0014, 4, 1,
|
||||
+ -1, -1, -1),
|
||||
+ MUX_GATE_CLR_SET_UPD(CLK_INFRA_SPI1_SEL, "infra_spi1_sel",
|
||||
+ infra_spi1_parents, 0x0018, 0x0010, 0x0014, 5, 1,
|
||||
+ -1, -1, -1),
|
||||
+ MUX_GATE_CLR_SET_UPD(CLK_INFRA_SPI2_SEL, "infra_spi2_sel",
|
||||
+ infra_spi0_parents, 0x0018, 0x0010, 0x0014, 6, 1,
|
||||
+ -1, -1, -1),
|
||||
+ MUX_GATE_CLR_SET_UPD(CLK_INFRA_PWM1_SEL, "infra_pwm1_sel",
|
||||
+ infra_pwm1_parents, 0x0018, 0x0010, 0x0014, 9, 1,
|
||||
+ -1, -1, -1),
|
||||
+ MUX_GATE_CLR_SET_UPD(CLK_INFRA_PWM2_SEL, "infra_pwm2_sel",
|
||||
+ infra_pwm1_parents, 0x0018, 0x0010, 0x0014, 11, 1,
|
||||
+ -1, -1, -1),
|
||||
+ MUX_GATE_CLR_SET_UPD(CLK_INFRA_PWM3_SEL, "infra_pwm3_sel",
|
||||
+ infra_pwm1_parents, 0x0018, 0x0010, 0x0014, 15, 1,
|
||||
+ -1, -1, -1),
|
||||
+ MUX_GATE_CLR_SET_UPD(CLK_INFRA_PWM_BSEL, "infra_pwm_bsel",
|
||||
+ infra_pwm_bsel_parents, 0x0018, 0x0010, 0x0014, 13,
|
||||
+ 2, -1, -1, -1),
|
||||
+ /* MODULE_CLK_SEL_1 */
|
||||
+ MUX_GATE_CLR_SET_UPD(CLK_INFRA_PCIE_SEL, "infra_pcie_sel",
|
||||
+ infra_pcie_parents, 0x0028, 0x0020, 0x0024, 0, 2,
|
||||
+ -1, -1, -1),
|
||||
+};
|
||||
+
|
||||
+static const struct mtk_gate_regs infra0_cg_regs = {
|
||||
+ .set_ofs = 0x40,
|
||||
+ .clr_ofs = 0x44,
|
||||
+ .sta_ofs = 0x48,
|
||||
+};
|
||||
+
|
||||
+static const struct mtk_gate_regs infra1_cg_regs = {
|
||||
+ .set_ofs = 0x50,
|
||||
+ .clr_ofs = 0x54,
|
||||
+ .sta_ofs = 0x58,
|
||||
+};
|
||||
+
|
||||
+static const struct mtk_gate_regs infra2_cg_regs = {
|
||||
+ .set_ofs = 0x60,
|
||||
+ .clr_ofs = 0x64,
|
||||
+ .sta_ofs = 0x68,
|
||||
+};
|
||||
+
|
||||
+#define GATE_INFRA0(_id, _name, _parent, _shift) \
|
||||
+ { \
|
||||
+ .id = _id, .name = _name, .parent_name = _parent, \
|
||||
+ .regs = &infra0_cg_regs, .shift = _shift, \
|
||||
+ .ops = &mtk_clk_gate_ops_setclr, \
|
||||
+ }
|
||||
+
|
||||
+#define GATE_INFRA1(_id, _name, _parent, _shift) \
|
||||
+ { \
|
||||
+ .id = _id, .name = _name, .parent_name = _parent, \
|
||||
+ .regs = &infra1_cg_regs, .shift = _shift, \
|
||||
+ .ops = &mtk_clk_gate_ops_setclr, \
|
||||
+ }
|
||||
+
|
||||
+#define GATE_INFRA2(_id, _name, _parent, _shift) \
|
||||
+ { \
|
||||
+ .id = _id, .name = _name, .parent_name = _parent, \
|
||||
+ .regs = &infra2_cg_regs, .shift = _shift, \
|
||||
+ .ops = &mtk_clk_gate_ops_setclr, \
|
||||
+ }
|
||||
+
|
||||
+static const struct mtk_gate infra_clks[] = {
|
||||
+ /* INFRA0 */
|
||||
+ GATE_INFRA0(CLK_INFRA_GPT_STA, "infra_gpt_sta", "infra_66m_mck", 0),
|
||||
+ GATE_INFRA0(CLK_INFRA_PWM_HCK, "infra_pwm_hck", "infra_66m_mck", 1),
|
||||
+ GATE_INFRA0(CLK_INFRA_PWM_STA, "infra_pwm_sta", "infra_pwm_bsel", 2),
|
||||
+ GATE_INFRA0(CLK_INFRA_PWM1_CK, "infra_pwm1", "infra_pwm1_sel", 3),
|
||||
+ GATE_INFRA0(CLK_INFRA_PWM2_CK, "infra_pwm2", "infra_pwm2_sel", 4),
|
||||
+ GATE_INFRA0(CLK_INFRA_CQ_DMA_CK, "infra_cq_dma", "sysaxi", 6),
|
||||
+
|
||||
+ GATE_INFRA0(CLK_INFRA_AUD_BUS_CK, "infra_aud_bus", "sysaxi", 8),
|
||||
+ GATE_INFRA0(CLK_INFRA_AUD_26M_CK, "infra_aud_26m", "csw_f26m_sel", 9),
|
||||
+ GATE_INFRA0(CLK_INFRA_AUD_L_CK, "infra_aud_l", "aud_l", 10),
|
||||
+ GATE_INFRA0(CLK_INFRA_AUD_AUD_CK, "infra_aud_aud", "a1sys", 11),
|
||||
+ GATE_INFRA0(CLK_INFRA_AUD_EG2_CK, "infra_aud_eg2", "a_tuner", 13),
|
||||
+ GATE_INFRA0(CLK_INFRA_DRAMC_26M_CK, "infra_dramc_26m", "csw_f26m_sel",
|
||||
+ 14),
|
||||
+ GATE_INFRA0(CLK_INFRA_DBG_CK, "infra_dbg", "infra_66m_mck", 15),
|
||||
+ GATE_INFRA0(CLK_INFRA_AP_DMA_CK, "infra_ap_dma", "infra_66m_mck", 16),
|
||||
+ GATE_INFRA0(CLK_INFRA_SEJ_CK, "infra_sej", "infra_66m_mck", 24),
|
||||
+ GATE_INFRA0(CLK_INFRA_SEJ_13M_CK, "infra_sej_13m", "csw_f26m_sel", 25),
|
||||
+ GATE_INFRA0(CLK_INFRA_PWM3_CK, "infra_pwm3", "infra_pwm3_sel", 27),
|
||||
+ /* INFRA1 */
|
||||
+ GATE_INFRA1(CLK_INFRA_THERM_CK, "infra_therm", "csw_f26m_sel", 0),
|
||||
+ GATE_INFRA1(CLK_INFRA_I2C0_CK, "infra_i2c0", "i2c_bck", 1),
|
||||
+ GATE_INFRA1(CLK_INFRA_UART0_CK, "infra_uart0", "infra_uart0_sel", 2),
|
||||
+ GATE_INFRA1(CLK_INFRA_UART1_CK, "infra_uart1", "infra_uart1_sel", 3),
|
||||
+ GATE_INFRA1(CLK_INFRA_UART2_CK, "infra_uart2", "infra_uart2_sel", 4),
|
||||
+ GATE_INFRA1(CLK_INFRA_SPI2_CK, "infra_spi2", "infra_spi2_sel", 6),
|
||||
+ GATE_INFRA1(CLK_INFRA_SPI2_HCK_CK, "infra_spi2_hck", "infra_66m_mck", 7),
|
||||
+ GATE_INFRA1(CLK_INFRA_NFI1_CK, "infra_nfi1", "nfi1x", 8),
|
||||
+ GATE_INFRA1(CLK_INFRA_SPINFI1_CK, "infra_spinfi1", "spinfi_bck", 9),
|
||||
+ GATE_INFRA1(CLK_INFRA_NFI_HCK_CK, "infra_nfi_hck", "infra_66m_mck", 10),
|
||||
+ GATE_INFRA1(CLK_INFRA_SPI0_CK, "infra_spi0", "infra_spi0_sel", 11),
|
||||
+ GATE_INFRA1(CLK_INFRA_SPI1_CK, "infra_spi1", "infra_spi1_sel", 12),
|
||||
+ GATE_INFRA1(CLK_INFRA_SPI0_HCK_CK, "infra_spi0_hck", "infra_66m_mck",
|
||||
+ 13),
|
||||
+ GATE_INFRA1(CLK_INFRA_SPI1_HCK_CK, "infra_spi1_hck", "infra_66m_mck",
|
||||
+ 14),
|
||||
+ GATE_INFRA1(CLK_INFRA_FRTC_CK, "infra_frtc", "cb_rtc_32k", 15),
|
||||
+ GATE_INFRA1(CLK_INFRA_MSDC_CK, "infra_msdc", "emmc_400m", 16),
|
||||
+ GATE_INFRA1(CLK_INFRA_MSDC_HCK_CK, "infra_msdc_hck", "emmc_208m", 17),
|
||||
+ GATE_INFRA1(CLK_INFRA_MSDC_133M_CK, "infra_msdc_133m", "sysaxi", 18),
|
||||
+ GATE_INFRA1(CLK_INFRA_MSDC_66M_CK, "infra_msdc_66m", "sysaxi", 19),
|
||||
+ GATE_INFRA1(CLK_INFRA_ADC_26M_CK, "infra_adc_26m", "infra_adc_frc", 20),
|
||||
+ GATE_INFRA1(CLK_INFRA_ADC_FRC_CK, "infra_adc_frc", "csw_f26m", 21),
|
||||
+ GATE_INFRA1(CLK_INFRA_FBIST2FPC_CK, "infra_fbist2fpc", "nfi1x", 23),
|
||||
+ GATE_INFRA1(CLK_INFRA_I2C_MCK_CK, "infra_i2c_mck", "sysaxi", 25),
|
||||
+ GATE_INFRA1(CLK_INFRA_I2C_PCK_CK, "infra_i2c_pck", "infra_66m_mck", 26),
|
||||
+ /* INFRA2 */
|
||||
+ GATE_INFRA2(CLK_INFRA_IUSB_133_CK, "infra_iusb_133", "sysaxi", 0),
|
||||
+ GATE_INFRA2(CLK_INFRA_IUSB_66M_CK, "infra_iusb_66m", "sysaxi", 1),
|
||||
+ GATE_INFRA2(CLK_INFRA_IUSB_SYS_CK, "infra_iusb_sys", "u2u3_sys", 2),
|
||||
+ GATE_INFRA2(CLK_INFRA_IUSB_CK, "infra_iusb", "u2u3_ref", 3),
|
||||
+ GATE_INFRA2(CLK_INFRA_IPCIE_CK, "infra_ipcie", "pextp_tl", 12),
|
||||
+ GATE_INFRA2(CLK_INFRA_IPCIE_PIPE_CK, "infra_ipcie_pipe", "cb_cksq_40m",
|
||||
+ 13),
|
||||
+ GATE_INFRA2(CLK_INFRA_IPCIER_CK, "infra_ipcier", "csw_f26m", 14),
|
||||
+ GATE_INFRA2(CLK_INFRA_IPCIEB_CK, "infra_ipcieb", "sysaxi", 15),
|
||||
+};
|
||||
+
|
||||
+static const struct mtk_clk_desc infracfg_desc = {
|
||||
+ .factor_clks = infra_divs,
|
||||
+ .num_factor_clks = ARRAY_SIZE(infra_divs),
|
||||
+ .mux_clks = infra_muxes,
|
||||
+ .num_mux_clks = ARRAY_SIZE(infra_muxes),
|
||||
+ .clks = infra_clks,
|
||||
+ .num_clks = ARRAY_SIZE(infra_clks),
|
||||
+ .clk_lock = &mt7981_clk_lock,
|
||||
+};
|
||||
+
|
||||
+static const struct of_device_id of_match_clk_mt7981_infracfg[] = {
|
||||
+ { .compatible = "mediatek,mt7981-infracfg", .data = &infracfg_desc },
|
||||
+ { /* sentinel */ }
|
||||
+};
|
||||
+
|
||||
+static struct platform_driver clk_mt7981_infracfg_drv = {
|
||||
+ .probe = mtk_clk_simple_probe,
|
||||
+ .remove = mtk_clk_simple_remove,
|
||||
+ .driver = {
|
||||
+ .name = "clk-mt7981-infracfg",
|
||||
+ .of_match_table = of_match_clk_mt7981_infracfg,
|
||||
+ },
|
||||
+};
|
||||
+builtin_platform_driver(clk_mt7981_infracfg_drv);
|
||||
--- /dev/null
|
||||
+++ b/drivers/clk/mediatek/clk-mt7981-topckgen.c
|
||||
@@ -0,0 +1,422 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0
|
||||
+/*
|
||||
+ * Copyright (c) 2021 MediaTek Inc.
|
||||
+ * Author: Sam Shih <sam.shih@mediatek.com>
|
||||
+ * Author: Wenzhen Yu <wenzhen.yu@mediatek.com>
|
||||
+ * Author: Jianhui Zhao <zhaojh329@gmail.com>
|
||||
+ */
|
||||
+
|
||||
+
|
||||
+#include <linux/clk-provider.h>
|
||||
+#include <linux/of.h>
|
||||
+#include <linux/of_address.h>
|
||||
+#include <linux/of_device.h>
|
||||
+#include <linux/platform_device.h>
|
||||
+#include "clk-mtk.h"
|
||||
+#include "clk-gate.h"
|
||||
+#include "clk-mux.h"
|
||||
+
|
||||
+#include <dt-bindings/clock/mediatek,mt7981-clk.h>
|
||||
+#include <linux/clk.h>
|
||||
+
|
||||
+static DEFINE_SPINLOCK(mt7981_clk_lock);
|
||||
+
|
||||
+static const struct mtk_fixed_factor top_divs[] = {
|
||||
+ FACTOR(CLK_TOP_CB_CKSQ_40M, "cb_cksq_40m", "clkxtal", 1, 1),
|
||||
+ FACTOR(CLK_TOP_CB_M_416M, "cb_m_416m", "mpll", 1, 1),
|
||||
+ FACTOR(CLK_TOP_CB_M_D2, "cb_m_d2", "mpll", 1, 2),
|
||||
+ FACTOR(CLK_TOP_CB_M_D3, "cb_m_d3", "mpll", 1, 3),
|
||||
+ FACTOR(CLK_TOP_M_D3_D2, "m_d3_d2", "mpll", 1, 2),
|
||||
+ FACTOR(CLK_TOP_CB_M_D4, "cb_m_d4", "mpll", 1, 4),
|
||||
+ FACTOR(CLK_TOP_CB_M_D8, "cb_m_d8", "mpll", 1, 8),
|
||||
+ FACTOR(CLK_TOP_M_D8_D2, "m_d8_d2", "mpll", 1, 16),
|
||||
+ FACTOR(CLK_TOP_CB_MM_720M, "cb_mm_720m", "mmpll", 1, 1),
|
||||
+ FACTOR(CLK_TOP_CB_MM_D2, "cb_mm_d2", "mmpll", 1, 2),
|
||||
+ FACTOR(CLK_TOP_CB_MM_D3, "cb_mm_d3", "mmpll", 1, 3),
|
||||
+ FACTOR(CLK_TOP_CB_MM_D3_D5, "cb_mm_d3_d5", "mmpll", 1, 15),
|
||||
+ FACTOR(CLK_TOP_CB_MM_D4, "cb_mm_d4", "mmpll", 1, 4),
|
||||
+ FACTOR(CLK_TOP_CB_MM_D6, "cb_mm_d6", "mmpll", 1, 6),
|
||||
+ FACTOR(CLK_TOP_MM_D6_D2, "mm_d6_d2", "mmpll", 1, 12),
|
||||
+ FACTOR(CLK_TOP_CB_MM_D8, "cb_mm_d8", "mmpll", 1, 8),
|
||||
+ FACTOR(CLK_TOP_CB_APLL2_196M, "cb_apll2_196m", "apll2", 1, 1),
|
||||
+ FACTOR(CLK_TOP_APLL2_D2, "apll2_d2", "apll2", 1, 2),
|
||||
+ FACTOR(CLK_TOP_APLL2_D4, "apll2_d4", "apll2", 1, 4),
|
||||
+ FACTOR(CLK_TOP_NET1_2500M, "net1_2500m", "net1pll", 1, 1),
|
||||
+ FACTOR(CLK_TOP_CB_NET1_D4, "cb_net1_d4", "net1pll", 1, 4),
|
||||
+ FACTOR(CLK_TOP_CB_NET1_D5, "cb_net1_d5", "net1pll", 1, 5),
|
||||
+ FACTOR(CLK_TOP_NET1_D5_D2, "net1_d5_d2", "net1pll", 1, 10),
|
||||
+ FACTOR(CLK_TOP_NET1_D5_D4, "net1_d5_d4", "net1pll", 1, 20),
|
||||
+ FACTOR(CLK_TOP_CB_NET1_D8, "cb_net1_d8", "net1pll", 1, 8),
|
||||
+ FACTOR(CLK_TOP_NET1_D8_D2, "net1_d8_d2", "net1pll", 1, 16),
|
||||
+ FACTOR(CLK_TOP_NET1_D8_D4, "net1_d8_d4", "net1pll", 1, 32),
|
||||
+ FACTOR(CLK_TOP_CB_NET2_800M, "cb_net2_800m", "net2pll", 1, 1),
|
||||
+ FACTOR(CLK_TOP_CB_NET2_D2, "cb_net2_d2", "net2pll", 1, 2),
|
||||
+ FACTOR(CLK_TOP_CB_NET2_D4, "cb_net2_d4", "net2pll", 1, 4),
|
||||
+ FACTOR(CLK_TOP_NET2_D4_D2, "net2_d4_d2", "net2pll", 1, 8),
|
||||
+ FACTOR(CLK_TOP_NET2_D4_D4, "net2_d4_d4", "net2pll", 1, 16),
|
||||
+ FACTOR(CLK_TOP_CB_NET2_D6, "cb_net2_d6", "net2pll", 1, 6),
|
||||
+ FACTOR(CLK_TOP_CB_WEDMCU_208M, "cb_wedmcu_208m", "wedmcupll", 1, 1),
|
||||
+ FACTOR(CLK_TOP_CB_SGM_325M, "cb_sgm_325m", "sgmpll", 1, 1),
|
||||
+ FACTOR(CLK_TOP_CKSQ_40M_D2, "cksq_40m_d2", "cb_cksq_40m", 1, 2),
|
||||
+ FACTOR(CLK_TOP_CB_RTC_32K, "cb_rtc_32k", "cb_cksq_40m", 1, 1250),
|
||||
+ FACTOR(CLK_TOP_CB_RTC_32P7K, "cb_rtc_32p7k", "cb_cksq_40m", 1, 1220),
|
||||
+ FACTOR(CLK_TOP_USB_TX250M, "usb_tx250m", "cb_cksq_40m", 1, 1),
|
||||
+ FACTOR(CLK_TOP_FAUD, "faud", "aud_sel", 1, 1),
|
||||
+ FACTOR(CLK_TOP_NFI1X, "nfi1x", "nfi1x_sel", 1, 1),
|
||||
+ FACTOR(CLK_TOP_USB_EQ_RX250M, "usb_eq_rx250m", "cb_cksq_40m", 1, 1),
|
||||
+ FACTOR(CLK_TOP_USB_CDR_CK, "usb_cdr", "cb_cksq_40m", 1, 1),
|
||||
+ FACTOR(CLK_TOP_USB_LN0_CK, "usb_ln0", "cb_cksq_40m", 1, 1),
|
||||
+ FACTOR(CLK_TOP_SPINFI_BCK, "spinfi_bck", "spinfi_sel", 1, 1),
|
||||
+ FACTOR(CLK_TOP_SPI, "spi", "spi_sel", 1, 1),
|
||||
+ FACTOR(CLK_TOP_SPIM_MST, "spim_mst", "spim_mst_sel", 1, 1),
|
||||
+ FACTOR(CLK_TOP_UART_BCK, "uart_bck", "uart_sel", 1, 1),
|
||||
+ FACTOR(CLK_TOP_PWM_BCK, "pwm_bck", "pwm_sel", 1, 1),
|
||||
+ FACTOR(CLK_TOP_I2C_BCK, "i2c_bck", "i2c_sel", 1, 1),
|
||||
+ FACTOR(CLK_TOP_PEXTP_TL, "pextp_tl", "pextp_tl_ck_sel", 1, 1),
|
||||
+ FACTOR(CLK_TOP_EMMC_208M, "emmc_208m", "emmc_208m_sel", 1, 1),
|
||||
+ FACTOR(CLK_TOP_EMMC_400M, "emmc_400m", "emmc_400m_sel", 1, 1),
|
||||
+ FACTOR(CLK_TOP_DRAMC_REF, "dramc_ref", "dramc_sel", 1, 1),
|
||||
+ FACTOR(CLK_TOP_DRAMC_MD32, "dramc_md32", "dramc_md32_sel", 1, 1),
|
||||
+ FACTOR(CLK_TOP_SYSAXI, "sysaxi", "sysaxi_sel", 1, 1),
|
||||
+ FACTOR(CLK_TOP_SYSAPB, "sysapb", "sysapb_sel", 1, 1),
|
||||
+ FACTOR(CLK_TOP_ARM_DB_MAIN, "arm_db_main", "arm_db_main_sel", 1, 1),
|
||||
+ FACTOR(CLK_TOP_AP2CNN_HOST, "ap2cnn_host", "ap2cnn_host_sel", 1, 1),
|
||||
+ FACTOR(CLK_TOP_NETSYS, "netsys", "netsys_sel", 1, 1),
|
||||
+ FACTOR(CLK_TOP_NETSYS_500M, "netsys_500m", "netsys_500m_sel", 1, 1),
|
||||
+ FACTOR(CLK_TOP_NETSYS_WED_MCU, "netsys_wed_mcu", "netsys_mcu_sel", 1, 1),
|
||||
+ FACTOR(CLK_TOP_NETSYS_2X, "netsys_2x", "netsys_2x_sel", 1, 1),
|
||||
+ FACTOR(CLK_TOP_SGM_325M, "sgm_325m", "sgm_325m_sel", 1, 1),
|
||||
+ FACTOR(CLK_TOP_SGM_REG, "sgm_reg", "sgm_reg_sel", 1, 1),
|
||||
+ FACTOR(CLK_TOP_F26M, "csw_f26m", "csw_f26m_sel", 1, 1),
|
||||
+ FACTOR(CLK_TOP_EIP97B, "eip97b", "eip97b_sel", 1, 1),
|
||||
+ FACTOR(CLK_TOP_USB3_PHY, "usb3_phy", "usb3_phy_sel", 1, 1),
|
||||
+ FACTOR(CLK_TOP_AUD, "aud", "faud", 1, 1),
|
||||
+ FACTOR(CLK_TOP_A1SYS, "a1sys", "a1sys_sel", 1, 1),
|
||||
+ FACTOR(CLK_TOP_AUD_L, "aud_l", "aud_l_sel", 1, 1),
|
||||
+ FACTOR(CLK_TOP_A_TUNER, "a_tuner", "a_tuner_sel", 1, 1),
|
||||
+ FACTOR(CLK_TOP_U2U3_REF, "u2u3_ref", "u2u3_sel", 1, 1),
|
||||
+ FACTOR(CLK_TOP_U2U3_SYS, "u2u3_sys", "u2u3_sys_sel", 1, 1),
|
||||
+ FACTOR(CLK_TOP_U2U3_XHCI, "u2u3_xhci", "u2u3_xhci_sel", 1, 1),
|
||||
+ FACTOR(CLK_TOP_USB_FRMCNT, "usb_frmcnt", "usb_frmcnt_sel", 1, 1),
|
||||
+};
|
||||
+
|
||||
+static const char * const nfi1x_parents[] __initconst = {
|
||||
+ "cb_cksq_40m",
|
||||
+ "cb_mm_d4",
|
||||
+ "net1_d8_d2",
|
||||
+ "cb_net2_d6",
|
||||
+ "cb_m_d4",
|
||||
+ "cb_mm_d8",
|
||||
+ "net1_d8_d4",
|
||||
+ "cb_m_d8"
|
||||
+};
|
||||
+
|
||||
+static const char * const spinfi_parents[] __initconst = {
|
||||
+ "cksq_40m_d2",
|
||||
+ "cb_cksq_40m",
|
||||
+ "net1_d5_d4",
|
||||
+ "cb_m_d4",
|
||||
+ "cb_mm_d8",
|
||||
+ "net1_d8_d4",
|
||||
+ "mm_d6_d2",
|
||||
+ "cb_m_d8"
|
||||
+};
|
||||
+
|
||||
+static const char * const spi_parents[] __initconst = {
|
||||
+ "cb_cksq_40m",
|
||||
+ "cb_m_d2",
|
||||
+ "cb_mm_d4",
|
||||
+ "net1_d8_d2",
|
||||
+ "cb_net2_d6",
|
||||
+ "net1_d5_d4",
|
||||
+ "cb_m_d4",
|
||||
+ "net1_d8_d4"
|
||||
+};
|
||||
+
|
||||
+static const char * const uart_parents[] __initconst = {
|
||||
+ "cb_cksq_40m",
|
||||
+ "cb_m_d8",
|
||||
+ "m_d8_d2"
|
||||
+};
|
||||
+
|
||||
+static const char * const pwm_parents[] __initconst = {
|
||||
+ "cb_cksq_40m",
|
||||
+ "net1_d8_d2",
|
||||
+ "net1_d5_d4",
|
||||
+ "cb_m_d4",
|
||||
+ "m_d8_d2",
|
||||
+ "cb_rtc_32k"
|
||||
+};
|
||||
+
|
||||
+static const char * const i2c_parents[] __initconst = {
|
||||
+ "cb_cksq_40m",
|
||||
+ "net1_d5_d4",
|
||||
+ "cb_m_d4",
|
||||
+ "net1_d8_d4"
|
||||
+};
|
||||
+
|
||||
+static const char * const pextp_tl_ck_parents[] __initconst = {
|
||||
+ "cb_cksq_40m",
|
||||
+ "net1_d5_d4",
|
||||
+ "cb_m_d4",
|
||||
+ "cb_rtc_32k"
|
||||
+};
|
||||
+
|
||||
+static const char * const emmc_208m_parents[] __initconst = {
|
||||
+ "cb_cksq_40m",
|
||||
+ "cb_m_d2",
|
||||
+ "cb_net2_d4",
|
||||
+ "cb_apll2_196m",
|
||||
+ "cb_mm_d4",
|
||||
+ "net1_d8_d2",
|
||||
+ "cb_mm_d6"
|
||||
+};
|
||||
+
|
||||
+static const char * const emmc_400m_parents[] __initconst = {
|
||||
+ "cb_cksq_40m",
|
||||
+ "cb_net2_d2",
|
||||
+ "cb_mm_d2",
|
||||
+ "cb_net2_d2"
|
||||
+};
|
||||
+
|
||||
+static const char * const csw_f26m_parents[] __initconst = {
|
||||
+ "cksq_40m_d2",
|
||||
+ "m_d8_d2"
|
||||
+};
|
||||
+
|
||||
+static const char * const dramc_md32_parents[] __initconst = {
|
||||
+ "cb_cksq_40m",
|
||||
+ "cb_m_d2",
|
||||
+ "cb_wedmcu_208m"
|
||||
+};
|
||||
+
|
||||
+static const char * const sysaxi_parents[] __initconst = {
|
||||
+ "cb_cksq_40m",
|
||||
+ "net1_d8_d2"
|
||||
+};
|
||||
+
|
||||
+static const char * const sysapb_parents[] __initconst = {
|
||||
+ "cb_cksq_40m",
|
||||
+ "m_d3_d2"
|
||||
+};
|
||||
+
|
||||
+static const char * const arm_db_main_parents[] __initconst = {
|
||||
+ "cb_cksq_40m",
|
||||
+ "cb_net2_d6"
|
||||
+};
|
||||
+
|
||||
+static const char * const ap2cnn_host_parents[] __initconst = {
|
||||
+ "cb_cksq_40m",
|
||||
+ "net1_d8_d4"
|
||||
+};
|
||||
+
|
||||
+static const char * const netsys_parents[] __initconst = {
|
||||
+ "cb_cksq_40m",
|
||||
+ "cb_mm_d2"
|
||||
+};
|
||||
+
|
||||
+static const char * const netsys_500m_parents[] __initconst = {
|
||||
+ "cb_cksq_40m",
|
||||
+ "cb_net1_d5"
|
||||
+};
|
||||
+
|
||||
+static const char * const netsys_mcu_parents[] __initconst = {
|
||||
+ "cb_cksq_40m",
|
||||
+ "cb_mm_720m",
|
||||
+ "cb_net1_d4",
|
||||
+ "cb_net1_d5",
|
||||
+ "cb_m_416m"
|
||||
+};
|
||||
+
|
||||
+static const char * const netsys_2x_parents[] __initconst = {
|
||||
+ "cb_cksq_40m",
|
||||
+ "cb_net2_800m",
|
||||
+ "cb_mm_720m"
|
||||
+};
|
||||
+
|
||||
+static const char * const sgm_325m_parents[] __initconst = {
|
||||
+ "cb_cksq_40m",
|
||||
+ "cb_sgm_325m"
|
||||
+};
|
||||
+
|
||||
+static const char * const sgm_reg_parents[] __initconst = {
|
||||
+ "cb_cksq_40m",
|
||||
+ "cb_net2_d4"
|
||||
+};
|
||||
+
|
||||
+static const char * const eip97b_parents[] __initconst = {
|
||||
+ "cb_cksq_40m",
|
||||
+ "cb_net1_d5",
|
||||
+ "cb_m_416m",
|
||||
+ "cb_mm_d2",
|
||||
+ "net1_d5_d2"
|
||||
+};
|
||||
+
|
||||
+static const char * const aud_parents[] __initconst = {
|
||||
+ "cb_cksq_40m",
|
||||
+ "cb_apll2_196m"
|
||||
+};
|
||||
+
|
||||
+static const char * const a1sys_parents[] __initconst = {
|
||||
+ "cb_cksq_40m",
|
||||
+ "apll2_d4"
|
||||
+};
|
||||
+
|
||||
+static const char * const aud_l_parents[] __initconst = {
|
||||
+ "cb_cksq_40m",
|
||||
+ "cb_apll2_196m",
|
||||
+ "m_d8_d2"
|
||||
+};
|
||||
+
|
||||
+static const char * const a_tuner_parents[] __initconst = {
|
||||
+ "cb_cksq_40m",
|
||||
+ "apll2_d4",
|
||||
+ "m_d8_d2"
|
||||
+};
|
||||
+
|
||||
+static const char * const u2u3_parents[] __initconst = {
|
||||
+ "cb_cksq_40m",
|
||||
+ "m_d8_d2"
|
||||
+};
|
||||
+
|
||||
+static const char * const u2u3_sys_parents[] __initconst = {
|
||||
+ "cb_cksq_40m",
|
||||
+ "net1_d5_d4"
|
||||
+};
|
||||
+
|
||||
+static const char * const usb_frmcnt_parents[] __initconst = {
|
||||
+ "cb_cksq_40m",
|
||||
+ "cb_mm_d3_d5"
|
||||
+};
|
||||
+
|
||||
+static const struct mtk_mux top_muxes[] = {
|
||||
+ /* CLK_CFG_0 */
|
||||
+ MUX_GATE_CLR_SET_UPD(CLK_TOP_NFI1X_SEL, "nfi1x_sel", nfi1x_parents,
|
||||
+ 0x000, 0x004, 0x008, 0, 3, 7, 0x1C0, 0),
|
||||
+ MUX_GATE_CLR_SET_UPD(CLK_TOP_SPINFI_SEL, "spinfi_sel", spinfi_parents,
|
||||
+ 0x000, 0x004, 0x008, 8, 3, 15, 0x1C0, 1),
|
||||
+ MUX_GATE_CLR_SET_UPD(CLK_TOP_SPI_SEL, "spi_sel", spi_parents,
|
||||
+ 0x000, 0x004, 0x008, 16, 3, 23, 0x1C0, 2),
|
||||
+ MUX_GATE_CLR_SET_UPD(CLK_TOP_SPIM_MST_SEL, "spim_mst_sel", spi_parents,
|
||||
+ 0x000, 0x004, 0x008, 24, 3, 31, 0x1C0, 3),
|
||||
+ /* CLK_CFG_1 */
|
||||
+ MUX_GATE_CLR_SET_UPD(CLK_TOP_UART_SEL, "uart_sel", uart_parents,
|
||||
+ 0x010, 0x014, 0x018, 0, 2, 7, 0x1C0, 4),
|
||||
+ MUX_GATE_CLR_SET_UPD(CLK_TOP_PWM_SEL, "pwm_sel", pwm_parents,
|
||||
+ 0x010, 0x014, 0x018, 8, 3, 15, 0x1C0, 5),
|
||||
+ MUX_GATE_CLR_SET_UPD(CLK_TOP_I2C_SEL, "i2c_sel", i2c_parents,
|
||||
+ 0x010, 0x014, 0x018, 16, 2, 23, 0x1C0, 6),
|
||||
+ MUX_GATE_CLR_SET_UPD(CLK_TOP_PEXTP_TL_SEL, "pextp_tl_ck_sel",
|
||||
+ pextp_tl_ck_parents, 0x010, 0x014, 0x018, 24, 2, 31,
|
||||
+ 0x1C0, 7),
|
||||
+ /* CLK_CFG_2 */
|
||||
+ MUX_GATE_CLR_SET_UPD(CLK_TOP_EMMC_208M_SEL, "emmc_208m_sel",
|
||||
+ emmc_208m_parents, 0x020, 0x024, 0x028, 0, 3, 7,
|
||||
+ 0x1C0, 8),
|
||||
+ MUX_GATE_CLR_SET_UPD(CLK_TOP_EMMC_400M_SEL, "emmc_400m_sel",
|
||||
+ emmc_400m_parents, 0x020, 0x024, 0x028, 8, 2, 15,
|
||||
+ 0x1C0, 9),
|
||||
+ MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_F26M_SEL, "csw_f26m_sel",
|
||||
+ csw_f26m_parents, 0x020, 0x024, 0x028, 16, 1, 23,
|
||||
+ 0x1C0, 10,
|
||||
+ CLK_IS_CRITICAL | CLK_SET_RATE_PARENT),
|
||||
+ MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_DRAMC_SEL, "dramc_sel",
|
||||
+ csw_f26m_parents, 0x020, 0x024, 0x028, 24, 1,
|
||||
+ 31, 0x1C0, 11,
|
||||
+ CLK_IS_CRITICAL | CLK_SET_RATE_PARENT),
|
||||
+ /* CLK_CFG_3 */
|
||||
+ MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_DRAMC_MD32_SEL, "dramc_md32_sel",
|
||||
+ dramc_md32_parents, 0x030, 0x034, 0x038, 0, 2,
|
||||
+ 7, 0x1C0, 12,
|
||||
+ CLK_IS_CRITICAL | CLK_SET_RATE_PARENT),
|
||||
+ MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_SYSAXI_SEL, "sysaxi_sel",
|
||||
+ sysaxi_parents, 0x030, 0x034, 0x038, 8, 1, 15,
|
||||
+ 0x1C0, 13,
|
||||
+ CLK_IS_CRITICAL | CLK_SET_RATE_PARENT),
|
||||
+ MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_SYSAPB_SEL, "sysapb_sel",
|
||||
+ sysapb_parents, 0x030, 0x034, 0x038, 16, 1,
|
||||
+ 23, 0x1C0, 14,
|
||||
+ CLK_IS_CRITICAL | CLK_SET_RATE_PARENT),
|
||||
+ MUX_GATE_CLR_SET_UPD(CLK_TOP_ARM_DB_MAIN_SEL, "arm_db_main_sel",
|
||||
+ arm_db_main_parents, 0x030, 0x034, 0x038, 24, 1, 31,
|
||||
+ 0x1C0, 15),
|
||||
+ /* CLK_CFG_4 */
|
||||
+ MUX_GATE_CLR_SET_UPD(CLK_TOP_AP2CNN_HOST_SEL, "ap2cnn_host_sel",
|
||||
+ ap2cnn_host_parents, 0x040, 0x044, 0x048, 0, 1, 7,
|
||||
+ 0x1C0, 16),
|
||||
+ MUX_GATE_CLR_SET_UPD(CLK_TOP_NETSYS_SEL, "netsys_sel", netsys_parents,
|
||||
+ 0x040, 0x044, 0x048, 8, 1, 15, 0x1C0, 17),
|
||||
+ MUX_GATE_CLR_SET_UPD(CLK_TOP_NETSYS_500M_SEL, "netsys_500m_sel",
|
||||
+ netsys_500m_parents, 0x040, 0x044, 0x048, 16, 1, 23,
|
||||
+ 0x1C0, 18),
|
||||
+ MUX_GATE_CLR_SET_UPD(CLK_TOP_NETSYS_MCU_SEL, "netsys_mcu_sel",
|
||||
+ netsys_mcu_parents, 0x040, 0x044, 0x048, 24, 3, 31,
|
||||
+ 0x1C0, 19),
|
||||
+ /* CLK_CFG_5 */
|
||||
+ MUX_GATE_CLR_SET_UPD(CLK_TOP_NETSYS_2X_SEL, "netsys_2x_sel",
|
||||
+ netsys_2x_parents, 0x050, 0x054, 0x058, 0, 2, 7,
|
||||
+ 0x1C0, 20),
|
||||
+ MUX_GATE_CLR_SET_UPD(CLK_TOP_SGM_325M_SEL, "sgm_325m_sel",
|
||||
+ sgm_325m_parents, 0x050, 0x054, 0x058, 8, 1, 15,
|
||||
+ 0x1C0, 21),
|
||||
+ MUX_GATE_CLR_SET_UPD(CLK_TOP_SGM_REG_SEL, "sgm_reg_sel", sgm_reg_parents,
|
||||
+ 0x050, 0x054, 0x058, 16, 1, 23, 0x1C0, 22),
|
||||
+ MUX_GATE_CLR_SET_UPD(CLK_TOP_EIP97B_SEL, "eip97b_sel", eip97b_parents,
|
||||
+ 0x050, 0x054, 0x058, 24, 3, 31, 0x1C0, 23),
|
||||
+ /* CLK_CFG_6 */
|
||||
+ MUX_GATE_CLR_SET_UPD(CLK_TOP_USB3_PHY_SEL, "usb3_phy_sel",
|
||||
+ csw_f26m_parents, 0x060, 0x064, 0x068, 0, 1,
|
||||
+ 7, 0x1C0, 24),
|
||||
+ MUX_GATE_CLR_SET_UPD(CLK_TOP_AUD_SEL, "aud_sel", aud_parents, 0x060,
|
||||
+ 0x064, 0x068, 8, 1, 15, 0x1C0, 25),
|
||||
+ MUX_GATE_CLR_SET_UPD(CLK_TOP_A1SYS_SEL, "a1sys_sel", a1sys_parents,
|
||||
+ 0x060, 0x064, 0x068, 16, 1, 23, 0x1C0, 26),
|
||||
+ MUX_GATE_CLR_SET_UPD(CLK_TOP_AUD_L_SEL, "aud_l_sel", aud_l_parents,
|
||||
+ 0x060, 0x064, 0x068, 24, 2, 31, 0x1C0, 27),
|
||||
+ /* CLK_CFG_7 */
|
||||
+ MUX_GATE_CLR_SET_UPD(CLK_TOP_A_TUNER_SEL, "a_tuner_sel",
|
||||
+ a_tuner_parents, 0x070, 0x074, 0x078, 0, 2, 7,
|
||||
+ 0x1C0, 28),
|
||||
+ MUX_GATE_CLR_SET_UPD(CLK_TOP_U2U3_SEL, "u2u3_sel", u2u3_parents, 0x070,
|
||||
+ 0x074, 0x078, 8, 1, 15, 0x1C0, 29),
|
||||
+ MUX_GATE_CLR_SET_UPD(CLK_TOP_U2U3_SYS_SEL, "u2u3_sys_sel",
|
||||
+ u2u3_sys_parents, 0x070, 0x074, 0x078, 16, 1, 23,
|
||||
+ 0x1C0, 30),
|
||||
+ MUX_GATE_CLR_SET_UPD(CLK_TOP_U2U3_XHCI_SEL, "u2u3_xhci_sel",
|
||||
+ u2u3_sys_parents, 0x070, 0x074, 0x078, 24, 1, 31,
|
||||
+ 0x1C4, 0),
|
||||
+ /* CLK_CFG_8 */
|
||||
+ MUX_GATE_CLR_SET_UPD(CLK_TOP_USB_FRMCNT_SEL, "usb_frmcnt_sel",
|
||||
+ usb_frmcnt_parents, 0x080, 0x084, 0x088, 0, 1, 7,
|
||||
+ 0x1C4, 1),
|
||||
+};
|
||||
+
|
||||
+static struct mtk_composite top_aud_divs[] = {
|
||||
+ DIV_GATE(CLK_TOP_AUD_I2S_M, "aud_i2s_m", "aud",
|
||||
+ 0x0420, 0, 0x0420, 8, 8),
|
||||
+};
|
||||
+
|
||||
+static const struct mtk_clk_desc topck_desc = {
|
||||
+ .factor_clks = top_divs,
|
||||
+ .num_factor_clks = ARRAY_SIZE(top_divs),
|
||||
+ .mux_clks = top_muxes,
|
||||
+ .num_mux_clks = ARRAY_SIZE(top_muxes),
|
||||
+ .composite_clks = top_aud_divs,
|
||||
+ .num_composite_clks = ARRAY_SIZE(top_aud_divs),
|
||||
+ .clk_lock = &mt7981_clk_lock,
|
||||
+};
|
||||
+
|
||||
+static const struct of_device_id of_match_clk_mt7981_topckgen[] = {
|
||||
+ { .compatible = "mediatek,mt7981-topckgen", .data = &topck_desc },
|
||||
+ { /* sentinel */ }
|
||||
+};
|
||||
+
|
||||
+static struct platform_driver clk_mt7981_topckgen_drv = {
|
||||
+ .probe = mtk_clk_simple_probe,
|
||||
+ .remove = mtk_clk_simple_remove,
|
||||
+ .driver = {
|
||||
+ .name = "clk-mt7981-topckgen",
|
||||
+ .of_match_table = of_match_clk_mt7981_topckgen,
|
||||
+ },
|
||||
+};
|
||||
+builtin_platform_driver(clk_mt7981_topckgen_drv);
|
@ -1,75 +0,0 @@
|
||||
From cc4d9e0c77494fcf6bccbc57e23db0007cf681b7 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Thu, 26 Jan 2023 03:33:46 +0000
|
||||
Subject: [PATCH] dt-bindings: clock: Add compatibles for MT7981
|
||||
|
||||
Add compatible string for MT7981 to existing bindings at
|
||||
- mediatek,apmixedsys.yaml
|
||||
- mediatek,topckgen.yaml
|
||||
- mediatek,ethsys.txt
|
||||
- mediatek,infracfg.yaml
|
||||
- mediatek,sgmiisys.txt
|
||||
|
||||
Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com>
|
||||
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
Link: https://lore.kernel.org/r/cc85ee470c781ff4013f6c21c92c0a21574b12b2.1674703830.git.daniel@makrotopia.org
|
||||
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
|
||||
---
|
||||
.../devicetree/bindings/arm/mediatek/mediatek,ethsys.txt | 1 +
|
||||
.../devicetree/bindings/arm/mediatek/mediatek,infracfg.yaml | 1 +
|
||||
.../devicetree/bindings/arm/mediatek/mediatek,sgmiisys.txt | 2 ++
|
||||
.../devicetree/bindings/clock/mediatek,apmixedsys.yaml | 1 +
|
||||
Documentation/devicetree/bindings/clock/mediatek,topckgen.yaml | 1 +
|
||||
5 files changed, 6 insertions(+)
|
||||
|
||||
--- a/Documentation/devicetree/bindings/arm/mediatek/mediatek,ethsys.txt
|
||||
+++ b/Documentation/devicetree/bindings/arm/mediatek/mediatek,ethsys.txt
|
||||
@@ -10,6 +10,7 @@ Required Properties:
|
||||
- "mediatek,mt7622-ethsys", "syscon"
|
||||
- "mediatek,mt7623-ethsys", "mediatek,mt2701-ethsys", "syscon"
|
||||
- "mediatek,mt7629-ethsys", "syscon"
|
||||
+ - "mediatek,mt7981-ethsys", "syscon"
|
||||
- "mediatek,mt7986-ethsys", "syscon"
|
||||
- #clock-cells: Must be 1
|
||||
- #reset-cells: Must be 1
|
||||
--- a/Documentation/devicetree/bindings/arm/mediatek/mediatek,infracfg.yaml
|
||||
+++ b/Documentation/devicetree/bindings/arm/mediatek/mediatek,infracfg.yaml
|
||||
@@ -28,6 +28,7 @@ properties:
|
||||
- mediatek,mt6797-infracfg
|
||||
- mediatek,mt7622-infracfg
|
||||
- mediatek,mt7629-infracfg
|
||||
+ - mediatek,mt7981-infracfg
|
||||
- mediatek,mt7986-infracfg
|
||||
- mediatek,mt8135-infracfg
|
||||
- mediatek,mt8167-infracfg
|
||||
--- a/Documentation/devicetree/bindings/arm/mediatek/mediatek,sgmiisys.txt
|
||||
+++ b/Documentation/devicetree/bindings/arm/mediatek/mediatek,sgmiisys.txt
|
||||
@@ -8,6 +8,8 @@ Required Properties:
|
||||
- compatible: Should be:
|
||||
- "mediatek,mt7622-sgmiisys", "syscon"
|
||||
- "mediatek,mt7629-sgmiisys", "syscon"
|
||||
+ - "mediatek,mt7981-sgmiisys_0", "syscon"
|
||||
+ - "mediatek,mt7981-sgmiisys_1", "syscon"
|
||||
- "mediatek,mt7986-sgmiisys_0", "syscon"
|
||||
- "mediatek,mt7986-sgmiisys_1", "syscon"
|
||||
- #clock-cells: Must be 1
|
||||
--- a/Documentation/devicetree/bindings/clock/mediatek,apmixedsys.yaml
|
||||
+++ b/Documentation/devicetree/bindings/clock/mediatek,apmixedsys.yaml
|
||||
@@ -20,6 +20,7 @@ properties:
|
||||
- enum:
|
||||
- mediatek,mt6797-apmixedsys
|
||||
- mediatek,mt7622-apmixedsys
|
||||
+ - mediatek,mt7981-apmixedsys
|
||||
- mediatek,mt7986-apmixedsys
|
||||
- mediatek,mt8135-apmixedsys
|
||||
- mediatek,mt8173-apmixedsys
|
||||
--- a/Documentation/devicetree/bindings/clock/mediatek,topckgen.yaml
|
||||
+++ b/Documentation/devicetree/bindings/clock/mediatek,topckgen.yaml
|
||||
@@ -35,6 +35,7 @@ properties:
|
||||
- mediatek,mt6779-topckgen
|
||||
- mediatek,mt6795-topckgen
|
||||
- mediatek,mt7629-topckgen
|
||||
+ - mediatek,mt7981-topckgen
|
||||
- mediatek,mt7986-topckgen
|
||||
- mediatek,mt8167-topckgen
|
||||
- mediatek,mt8183-topckgen
|
@ -1,107 +0,0 @@
|
||||
From d4f08a703565abf47baa5a77d05365cf4598d55c Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Sun, 19 Mar 2023 12:56:52 +0000
|
||||
Subject: [PATCH 1/2] dt-bindings: arm: mediatek: sgmiisys: Convert to DT
|
||||
schema
|
||||
|
||||
Convert mediatek,sgmiiisys bindings to DT schema format.
|
||||
Add maintainer Matthias Brugger, no maintainers were listed in the
|
||||
original documentation.
|
||||
As this node is also referenced by the Ethernet controller and used
|
||||
as SGMII PCS add this fact to the description.
|
||||
Move the file to Documentation/devicetree/bindings/net/pcs/ which seems
|
||||
more appropriate given that the great majority of registers are related
|
||||
to SGMII PCS functionality and only one register represents clock bits.
|
||||
|
||||
Reviewed-by: Rob Herring <robh@kernel.org>
|
||||
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
.../arm/mediatek/mediatek,sgmiisys.txt | 27 ----------
|
||||
.../bindings/net/pcs/mediatek,sgmiisys.yaml | 49 +++++++++++++++++++
|
||||
2 files changed, 49 insertions(+), 27 deletions(-)
|
||||
delete mode 100644 Documentation/devicetree/bindings/arm/mediatek/mediatek,sgmiisys.txt
|
||||
create mode 100644 Documentation/devicetree/bindings/net/pcs/mediatek,sgmiisys.yaml
|
||||
|
||||
--- a/Documentation/devicetree/bindings/arm/mediatek/mediatek,sgmiisys.txt
|
||||
+++ /dev/null
|
||||
@@ -1,27 +0,0 @@
|
||||
-MediaTek SGMIISYS controller
|
||||
-============================
|
||||
-
|
||||
-The MediaTek SGMIISYS controller provides various clocks to the system.
|
||||
-
|
||||
-Required Properties:
|
||||
-
|
||||
-- compatible: Should be:
|
||||
- - "mediatek,mt7622-sgmiisys", "syscon"
|
||||
- - "mediatek,mt7629-sgmiisys", "syscon"
|
||||
- - "mediatek,mt7981-sgmiisys_0", "syscon"
|
||||
- - "mediatek,mt7981-sgmiisys_1", "syscon"
|
||||
- - "mediatek,mt7986-sgmiisys_0", "syscon"
|
||||
- - "mediatek,mt7986-sgmiisys_1", "syscon"
|
||||
-- #clock-cells: Must be 1
|
||||
-
|
||||
-The SGMIISYS controller uses the common clk binding from
|
||||
-Documentation/devicetree/bindings/clock/clock-bindings.txt
|
||||
-The available clocks are defined in dt-bindings/clock/mt*-clk.h.
|
||||
-
|
||||
-Example:
|
||||
-
|
||||
-sgmiisys: sgmiisys@1b128000 {
|
||||
- compatible = "mediatek,mt7622-sgmiisys", "syscon";
|
||||
- reg = <0 0x1b128000 0 0x1000>;
|
||||
- #clock-cells = <1>;
|
||||
-};
|
||||
--- /dev/null
|
||||
+++ b/Documentation/devicetree/bindings/net/pcs/mediatek,sgmiisys.yaml
|
||||
@@ -0,0 +1,49 @@
|
||||
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
|
||||
+%YAML 1.2
|
||||
+---
|
||||
+$id: http://devicetree.org/schemas/net/pcs/mediatek,sgmiisys.yaml#
|
||||
+$schema: http://devicetree.org/meta-schemas/core.yaml#
|
||||
+
|
||||
+title: MediaTek SGMIISYS Controller
|
||||
+
|
||||
+maintainers:
|
||||
+ - Matthias Brugger <matthias.bgg@gmail.com>
|
||||
+
|
||||
+description:
|
||||
+ The MediaTek SGMIISYS controller provides a SGMII PCS and some clocks
|
||||
+ to the ethernet subsystem to which it is attached.
|
||||
+
|
||||
+properties:
|
||||
+ compatible:
|
||||
+ items:
|
||||
+ - enum:
|
||||
+ - mediatek,mt7622-sgmiisys
|
||||
+ - mediatek,mt7629-sgmiisys
|
||||
+ - mediatek,mt7986-sgmiisys_0
|
||||
+ - mediatek,mt7986-sgmiisys_1
|
||||
+ - const: syscon
|
||||
+
|
||||
+ reg:
|
||||
+ maxItems: 1
|
||||
+
|
||||
+ '#clock-cells':
|
||||
+ const: 1
|
||||
+
|
||||
+required:
|
||||
+ - compatible
|
||||
+ - reg
|
||||
+ - '#clock-cells'
|
||||
+
|
||||
+additionalProperties: false
|
||||
+
|
||||
+examples:
|
||||
+ - |
|
||||
+ soc {
|
||||
+ #address-cells = <2>;
|
||||
+ #size-cells = <2>;
|
||||
+ sgmiisys: syscon@1b128000 {
|
||||
+ compatible = "mediatek,mt7622-sgmiisys", "syscon";
|
||||
+ reg = <0 0x1b128000 0 0x1000>;
|
||||
+ #clock-cells = <1>;
|
||||
+ };
|
||||
+ };
|
@ -1,37 +0,0 @@
|
||||
From 4f7eb19c4f44078100659f6ba073b0cc7191bc91 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Sun, 19 Mar 2023 12:57:04 +0000
|
||||
Subject: [PATCH 2/2] dt-bindings: net: pcs: mediatek,sgmiisys: add MT7981 SoC
|
||||
|
||||
Add mediatek,pnswap boolean property needed on many boards using the
|
||||
MediaTek MT7981 SoC.
|
||||
|
||||
Reviewed-by: Rob Herring <robh@kernel.org>
|
||||
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
.../devicetree/bindings/net/pcs/mediatek,sgmiisys.yaml | 6 ++++++
|
||||
1 file changed, 6 insertions(+)
|
||||
|
||||
--- a/Documentation/devicetree/bindings/net/pcs/mediatek,sgmiisys.yaml
|
||||
+++ b/Documentation/devicetree/bindings/net/pcs/mediatek,sgmiisys.yaml
|
||||
@@ -19,6 +19,8 @@ properties:
|
||||
- enum:
|
||||
- mediatek,mt7622-sgmiisys
|
||||
- mediatek,mt7629-sgmiisys
|
||||
+ - mediatek,mt7981-sgmiisys_0
|
||||
+ - mediatek,mt7981-sgmiisys_1
|
||||
- mediatek,mt7986-sgmiisys_0
|
||||
- mediatek,mt7986-sgmiisys_1
|
||||
- const: syscon
|
||||
@@ -29,6 +31,10 @@ properties:
|
||||
'#clock-cells':
|
||||
const: 1
|
||||
|
||||
+ mediatek,pnswap:
|
||||
+ description: Invert polarity of the SGMII data lanes
|
||||
+ type: boolean
|
||||
+
|
||||
required:
|
||||
- compatible
|
||||
- reg
|
@ -1,47 +0,0 @@
|
||||
From 24e961b93d292d0dd6380213d22a071a99ea787d Mon Sep 17 00:00:00 2001
|
||||
From: Sam Shih <sam.shih@mediatek.com>
|
||||
Date: Tue, 25 Oct 2022 15:29:53 +0200
|
||||
Subject: [PATCH 1/6] mmc: mediatek: add support for MT7986 SoC
|
||||
|
||||
Adding mt7986 own characteristics and of_device_id to have support
|
||||
of MT7986 SoC.
|
||||
|
||||
Signed-off-by: Sam Shih <sam.shih@mediatek.com>
|
||||
Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Link: https://lore.kernel.org/r/20221025132953.81286-7-linux@fw-web.de
|
||||
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
|
||||
---
|
||||
drivers/mmc/host/mtk-sd.c | 14 ++++++++++++++
|
||||
1 file changed, 14 insertions(+)
|
||||
|
||||
--- a/drivers/mmc/host/mtk-sd.c
|
||||
+++ b/drivers/mmc/host/mtk-sd.c
|
||||
@@ -552,6 +552,19 @@ static const struct mtk_mmc_compatible m
|
||||
.support_64g = false,
|
||||
};
|
||||
|
||||
+static const struct mtk_mmc_compatible mt7986_compat = {
|
||||
+ .clk_div_bits = 12,
|
||||
+ .recheck_sdio_irq = true,
|
||||
+ .hs400_tune = false,
|
||||
+ .pad_tune_reg = MSDC_PAD_TUNE0,
|
||||
+ .async_fifo = true,
|
||||
+ .data_tune = true,
|
||||
+ .busy_check = true,
|
||||
+ .stop_clk_fix = true,
|
||||
+ .enhance_rx = true,
|
||||
+ .support_64g = true,
|
||||
+};
|
||||
+
|
||||
static const struct mtk_mmc_compatible mt8135_compat = {
|
||||
.clk_div_bits = 8,
|
||||
.recheck_sdio_irq = true,
|
||||
@@ -609,6 +622,7 @@ static const struct of_device_id msdc_of
|
||||
{ .compatible = "mediatek,mt6795-mmc", .data = &mt6795_compat},
|
||||
{ .compatible = "mediatek,mt7620-mmc", .data = &mt7620_compat},
|
||||
{ .compatible = "mediatek,mt7622-mmc", .data = &mt7622_compat},
|
||||
+ { .compatible = "mediatek,mt7986-mmc", .data = &mt7986_compat},
|
||||
{ .compatible = "mediatek,mt8135-mmc", .data = &mt8135_compat},
|
||||
{ .compatible = "mediatek,mt8173-mmc", .data = &mt8173_compat},
|
||||
{ .compatible = "mediatek,mt8183-mmc", .data = &mt8183_compat},
|
@ -1,57 +0,0 @@
|
||||
From 7b438d0377fbd520b475a68bdd9de1692393f22d Mon Sep 17 00:00:00 2001
|
||||
From: Mengqi Zhang <mengqi.zhang@mediatek.com>
|
||||
Date: Sun, 6 Nov 2022 11:39:24 +0800
|
||||
Subject: [PATCH 2/6] mmc: mtk-sd: add Inline Crypto Engine clock control
|
||||
|
||||
Add crypto clock control and ungate it before CQHCI init.
|
||||
|
||||
Signed-off-by: Mengqi Zhang <mengqi.zhang@mediatek.com>
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Link: https://lore.kernel.org/r/20221106033924.9854-2-mengqi.zhang@mediatek.com
|
||||
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
|
||||
---
|
||||
drivers/mmc/host/mtk-sd.c | 12 ++++++++++++
|
||||
1 file changed, 12 insertions(+)
|
||||
|
||||
--- a/drivers/mmc/host/mtk-sd.c
|
||||
+++ b/drivers/mmc/host/mtk-sd.c
|
||||
@@ -452,6 +452,7 @@ struct msdc_host {
|
||||
struct clk *bus_clk; /* bus clock which used to access register */
|
||||
struct clk *src_clk_cg; /* msdc source clock control gate */
|
||||
struct clk *sys_clk_cg; /* msdc subsys clock control gate */
|
||||
+ struct clk *crypto_clk; /* msdc crypto clock control gate */
|
||||
struct clk_bulk_data bulk_clks[MSDC_NR_CLOCKS];
|
||||
u32 mclk; /* mmc subsystem clock frequency */
|
||||
u32 src_clk_freq; /* source clock frequency */
|
||||
@@ -840,6 +841,7 @@ static void msdc_set_busy_timeout(struct
|
||||
static void msdc_gate_clock(struct msdc_host *host)
|
||||
{
|
||||
clk_bulk_disable_unprepare(MSDC_NR_CLOCKS, host->bulk_clks);
|
||||
+ clk_disable_unprepare(host->crypto_clk);
|
||||
clk_disable_unprepare(host->src_clk_cg);
|
||||
clk_disable_unprepare(host->src_clk);
|
||||
clk_disable_unprepare(host->bus_clk);
|
||||
@@ -855,6 +857,7 @@ static int msdc_ungate_clock(struct msdc
|
||||
clk_prepare_enable(host->bus_clk);
|
||||
clk_prepare_enable(host->src_clk);
|
||||
clk_prepare_enable(host->src_clk_cg);
|
||||
+ clk_prepare_enable(host->crypto_clk);
|
||||
ret = clk_bulk_prepare_enable(MSDC_NR_CLOCKS, host->bulk_clks);
|
||||
if (ret) {
|
||||
dev_err(host->dev, "Cannot enable pclk/axi/ahb clock gates\n");
|
||||
@@ -2670,6 +2673,15 @@ static int msdc_drv_probe(struct platfor
|
||||
goto host_free;
|
||||
}
|
||||
|
||||
+ /* only eMMC has crypto property */
|
||||
+ if (!(mmc->caps2 & MMC_CAP2_NO_MMC)) {
|
||||
+ host->crypto_clk = devm_clk_get_optional(&pdev->dev, "crypto");
|
||||
+ if (IS_ERR(host->crypto_clk))
|
||||
+ host->crypto_clk = NULL;
|
||||
+ else
|
||||
+ mmc->caps2 |= MMC_CAP2_CRYPTO;
|
||||
+ }
|
||||
+
|
||||
host->irq = platform_get_irq(pdev, 0);
|
||||
if (host->irq < 0) {
|
||||
ret = host->irq;
|
@ -1,36 +0,0 @@
|
||||
From 4b323f02b6e8df1b04292635ef829e7f723bf50e Mon Sep 17 00:00:00 2001
|
||||
From: Yu Zhe <yuzhe@nfschina.com>
|
||||
Date: Thu, 10 Nov 2022 15:28:19 +0800
|
||||
Subject: [PATCH 3/6] mmc: mtk-sd: fix two spelling mistakes in comment
|
||||
|
||||
spelling mistake fix : "alreay" -> "already"
|
||||
"checksume" -> "checksum"
|
||||
|
||||
Signed-off-by: Yu Zhe <yuzhe@nfschina.com>
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Link: https://lore.kernel.org/r/20221110072819.11530-1-yuzhe@nfschina.com
|
||||
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
|
||||
---
|
||||
drivers/mmc/host/mtk-sd.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
--- a/drivers/mmc/host/mtk-sd.c
|
||||
+++ b/drivers/mmc/host/mtk-sd.c
|
||||
@@ -750,7 +750,7 @@ static inline void msdc_dma_setup(struct
|
||||
else
|
||||
bd[j].bd_info &= ~BDMA_DESC_EOL;
|
||||
|
||||
- /* checksume need to clear first */
|
||||
+ /* checksum need to clear first */
|
||||
bd[j].bd_info &= ~BDMA_DESC_CHECKSUM;
|
||||
bd[j].bd_info |= msdc_dma_calcs((u8 *)(&bd[j]), 16) << 8;
|
||||
}
|
||||
@@ -1229,7 +1229,7 @@ static bool msdc_cmd_done(struct msdc_ho
|
||||
!host->hs400_tuning))
|
||||
/*
|
||||
* should not clear fifo/interrupt as the tune data
|
||||
- * may have alreay come when cmd19/cmd21 gets response
|
||||
+ * may have already come when cmd19/cmd21 gets response
|
||||
* CRC error.
|
||||
*/
|
||||
msdc_reset_hw(host);
|
@ -1,39 +0,0 @@
|
||||
From b98e7e8daf0ebab9dcc36812378a71e1be0b5089 Mon Sep 17 00:00:00 2001
|
||||
From: ChanWoo Lee <cw9316.lee@samsung.com>
|
||||
Date: Thu, 24 Nov 2022 17:00:31 +0900
|
||||
Subject: [PATCH 4/6] mmc: Avoid open coding by using mmc_op_tuning()
|
||||
|
||||
Replace code with the already defined function. No functional changes.
|
||||
|
||||
Signed-off-by: ChanWoo Lee <cw9316.lee@samsung.com>
|
||||
Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
|
||||
Link: https://lore.kernel.org/r/20221124080031.14690-1-cw9316.lee@samsung.com
|
||||
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
|
||||
---
|
||||
drivers/mmc/host/mtk-sd.c | 8 ++------
|
||||
1 file changed, 2 insertions(+), 6 deletions(-)
|
||||
|
||||
--- a/drivers/mmc/host/mtk-sd.c
|
||||
+++ b/drivers/mmc/host/mtk-sd.c
|
||||
@@ -1224,9 +1224,7 @@ static bool msdc_cmd_done(struct msdc_ho
|
||||
|
||||
if (!sbc_error && !(events & MSDC_INT_CMDRDY)) {
|
||||
if (events & MSDC_INT_CMDTMO ||
|
||||
- (cmd->opcode != MMC_SEND_TUNING_BLOCK &&
|
||||
- cmd->opcode != MMC_SEND_TUNING_BLOCK_HS200 &&
|
||||
- !host->hs400_tuning))
|
||||
+ (!mmc_op_tuning(cmd->opcode) && !host->hs400_tuning))
|
||||
/*
|
||||
* should not clear fifo/interrupt as the tune data
|
||||
* may have already come when cmd19/cmd21 gets response
|
||||
@@ -1320,9 +1318,7 @@ static void msdc_cmd_next(struct msdc_ho
|
||||
{
|
||||
if ((cmd->error &&
|
||||
!(cmd->error == -EILSEQ &&
|
||||
- (cmd->opcode == MMC_SEND_TUNING_BLOCK ||
|
||||
- cmd->opcode == MMC_SEND_TUNING_BLOCK_HS200 ||
|
||||
- host->hs400_tuning))) ||
|
||||
+ (mmc_op_tuning(cmd->opcode) || host->hs400_tuning))) ||
|
||||
(mrq->sbc && mrq->sbc->error))
|
||||
msdc_request_done(host, mrq);
|
||||
else if (cmd == mrq->sbc)
|
@ -1,43 +0,0 @@
|
||||
From f1da27b7c4191f78ed81d3dabf64c769f896296c Mon Sep 17 00:00:00 2001
|
||||
From: "Mingming.Su" <Mingming.Su@mediatek.com>
|
||||
Date: Sat, 8 Oct 2022 18:45:53 +0200
|
||||
Subject: [PATCH] hwrng: mtk - add mt7986 support
|
||||
|
||||
1. Add trng compatible name for MT7986
|
||||
2. Fix mtk_rng_wait_ready() function
|
||||
|
||||
Signed-off-by: Mingming.Su <Mingming.Su@mediatek.com>
|
||||
Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
|
||||
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
||||
---
|
||||
drivers/char/hw_random/mtk-rng.c | 5 +++--
|
||||
1 file changed, 3 insertions(+), 2 deletions(-)
|
||||
|
||||
--- a/drivers/char/hw_random/mtk-rng.c
|
||||
+++ b/drivers/char/hw_random/mtk-rng.c
|
||||
@@ -22,7 +22,7 @@
|
||||
#define RNG_AUTOSUSPEND_TIMEOUT 100
|
||||
|
||||
#define USEC_POLL 2
|
||||
-#define TIMEOUT_POLL 20
|
||||
+#define TIMEOUT_POLL 60
|
||||
|
||||
#define RNG_CTRL 0x00
|
||||
#define RNG_EN BIT(0)
|
||||
@@ -77,7 +77,7 @@ static bool mtk_rng_wait_ready(struct hw
|
||||
readl_poll_timeout_atomic(priv->base + RNG_CTRL, ready,
|
||||
ready & RNG_READY, USEC_POLL,
|
||||
TIMEOUT_POLL);
|
||||
- return !!ready;
|
||||
+ return !!(ready & RNG_READY);
|
||||
}
|
||||
|
||||
static int mtk_rng_read(struct hwrng *rng, void *buf, size_t max, bool wait)
|
||||
@@ -179,6 +179,7 @@ static const struct dev_pm_ops mtk_rng_p
|
||||
#endif /* CONFIG_PM */
|
||||
|
||||
static const struct of_device_id mtk_rng_match[] = {
|
||||
+ { .compatible = "mediatek,mt7986-rng" },
|
||||
{ .compatible = "mediatek,mt7623-rng" },
|
||||
{},
|
||||
};
|
File diff suppressed because it is too large
Load Diff
@ -1,524 +0,0 @@
|
||||
From c66937b0f8dbb4c6c043663c702b1053fb47fab2 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Mon, 14 Aug 2023 02:58:14 +0100
|
||||
Subject: [PATCH] net: phy: mediatek-ge-soc: support PHY LEDs
|
||||
|
||||
Implement netdev trigger and primitive bliking offloading as well as
|
||||
simple set_brigthness function for both PHY LEDs of the in-SoC PHYs
|
||||
found in MT7981 and MT7988.
|
||||
|
||||
For MT7988, read boottrap register and apply LED polarities accordingly
|
||||
to get uniform behavior from all LEDs on MT7988.
|
||||
This requires syscon phandle 'mediatek,pio' present in parenting MDIO bus
|
||||
which should point to the syscon holding the boottrap register.
|
||||
|
||||
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
|
||||
Link: https://lore.kernel.org/r/dc324d48c00cd7350f3a506eaa785324cae97372.1691977904.git.daniel@makrotopia.org
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/phy/mediatek-ge-soc.c | 435 +++++++++++++++++++++++++++++-
|
||||
1 file changed, 426 insertions(+), 9 deletions(-)
|
||||
|
||||
--- a/drivers/net/phy/mediatek-ge-soc.c
|
||||
+++ b/drivers/net/phy/mediatek-ge-soc.c
|
||||
@@ -1,11 +1,14 @@
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
#include <linux/bitfield.h>
|
||||
+#include <linux/bitmap.h>
|
||||
+#include <linux/mfd/syscon.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/nvmem-consumer.h>
|
||||
#include <linux/of_address.h>
|
||||
#include <linux/of_platform.h>
|
||||
#include <linux/pinctrl/consumer.h>
|
||||
#include <linux/phy.h>
|
||||
+#include <linux/regmap.h>
|
||||
|
||||
#define MTK_GPHY_ID_MT7981 0x03a29461
|
||||
#define MTK_GPHY_ID_MT7988 0x03a29481
|
||||
@@ -208,9 +211,42 @@
|
||||
#define MTK_PHY_DA_TX_R50_PAIR_C 0x53f
|
||||
#define MTK_PHY_DA_TX_R50_PAIR_D 0x540
|
||||
|
||||
+/* Registers on MDIO_MMD_VEND2 */
|
||||
+#define MTK_PHY_LED0_ON_CTRL 0x24
|
||||
+#define MTK_PHY_LED1_ON_CTRL 0x26
|
||||
+#define MTK_PHY_LED_ON_MASK GENMASK(6, 0)
|
||||
+#define MTK_PHY_LED_ON_LINK1000 BIT(0)
|
||||
+#define MTK_PHY_LED_ON_LINK100 BIT(1)
|
||||
+#define MTK_PHY_LED_ON_LINK10 BIT(2)
|
||||
+#define MTK_PHY_LED_ON_LINKDOWN BIT(3)
|
||||
+#define MTK_PHY_LED_ON_FDX BIT(4) /* Full duplex */
|
||||
+#define MTK_PHY_LED_ON_HDX BIT(5) /* Half duplex */
|
||||
+#define MTK_PHY_LED_ON_FORCE_ON BIT(6)
|
||||
+#define MTK_PHY_LED_ON_POLARITY BIT(14)
|
||||
+#define MTK_PHY_LED_ON_ENABLE BIT(15)
|
||||
+
|
||||
+#define MTK_PHY_LED0_BLINK_CTRL 0x25
|
||||
+#define MTK_PHY_LED1_BLINK_CTRL 0x27
|
||||
+#define MTK_PHY_LED_BLINK_1000TX BIT(0)
|
||||
+#define MTK_PHY_LED_BLINK_1000RX BIT(1)
|
||||
+#define MTK_PHY_LED_BLINK_100TX BIT(2)
|
||||
+#define MTK_PHY_LED_BLINK_100RX BIT(3)
|
||||
+#define MTK_PHY_LED_BLINK_10TX BIT(4)
|
||||
+#define MTK_PHY_LED_BLINK_10RX BIT(5)
|
||||
+#define MTK_PHY_LED_BLINK_COLLISION BIT(6)
|
||||
+#define MTK_PHY_LED_BLINK_RX_CRC_ERR BIT(7)
|
||||
+#define MTK_PHY_LED_BLINK_RX_IDLE_ERR BIT(8)
|
||||
+#define MTK_PHY_LED_BLINK_FORCE_BLINK BIT(9)
|
||||
+
|
||||
+#define MTK_PHY_LED1_DEFAULT_POLARITIES BIT(1)
|
||||
+
|
||||
#define MTK_PHY_RG_BG_RASEL 0x115
|
||||
#define MTK_PHY_RG_BG_RASEL_MASK GENMASK(2, 0)
|
||||
|
||||
+/* 'boottrap' register reflecting the configuration of the 4 PHY LEDs */
|
||||
+#define RG_GPIO_MISC_TPBANK0 0x6f0
|
||||
+#define RG_GPIO_MISC_TPBANK0_BOOTMODE GENMASK(11, 8)
|
||||
+
|
||||
/* These macro privides efuse parsing for internal phy. */
|
||||
#define EFS_DA_TX_I2MPB_A(x) (((x) >> 0) & GENMASK(5, 0))
|
||||
#define EFS_DA_TX_I2MPB_B(x) (((x) >> 6) & GENMASK(5, 0))
|
||||
@@ -238,13 +274,6 @@ enum {
|
||||
PAIR_D,
|
||||
};
|
||||
|
||||
-enum {
|
||||
- GPHY_PORT0,
|
||||
- GPHY_PORT1,
|
||||
- GPHY_PORT2,
|
||||
- GPHY_PORT3,
|
||||
-};
|
||||
-
|
||||
enum calibration_mode {
|
||||
EFUSE_K,
|
||||
SW_K
|
||||
@@ -263,6 +292,19 @@ enum CAL_MODE {
|
||||
SW_M
|
||||
};
|
||||
|
||||
+#define MTK_PHY_LED_STATE_FORCE_ON 0
|
||||
+#define MTK_PHY_LED_STATE_FORCE_BLINK 1
|
||||
+#define MTK_PHY_LED_STATE_NETDEV 2
|
||||
+
|
||||
+struct mtk_socphy_priv {
|
||||
+ unsigned long led_state;
|
||||
+};
|
||||
+
|
||||
+struct mtk_socphy_shared {
|
||||
+ u32 boottrap;
|
||||
+ struct mtk_socphy_priv priv[4];
|
||||
+};
|
||||
+
|
||||
static int mtk_socphy_read_page(struct phy_device *phydev)
|
||||
{
|
||||
return __phy_read(phydev, MTK_EXT_PAGE_ACCESS);
|
||||
@@ -1073,6 +1115,371 @@ static int mt798x_phy_config_init(struct
|
||||
return mt798x_phy_calibration(phydev);
|
||||
}
|
||||
|
||||
+static int mt798x_phy_hw_led_on_set(struct phy_device *phydev, u8 index,
|
||||
+ bool on)
|
||||
+{
|
||||
+ unsigned int bit_on = MTK_PHY_LED_STATE_FORCE_ON + (index ? 16 : 0);
|
||||
+ struct mtk_socphy_priv *priv = phydev->priv;
|
||||
+ bool changed;
|
||||
+
|
||||
+ if (on)
|
||||
+ changed = !test_and_set_bit(bit_on, &priv->led_state);
|
||||
+ else
|
||||
+ changed = !!test_and_clear_bit(bit_on, &priv->led_state);
|
||||
+
|
||||
+ changed |= !!test_and_clear_bit(MTK_PHY_LED_STATE_NETDEV +
|
||||
+ (index ? 16 : 0), &priv->led_state);
|
||||
+ if (changed)
|
||||
+ return phy_modify_mmd(phydev, MDIO_MMD_VEND2, index ?
|
||||
+ MTK_PHY_LED1_ON_CTRL : MTK_PHY_LED0_ON_CTRL,
|
||||
+ MTK_PHY_LED_ON_MASK,
|
||||
+ on ? MTK_PHY_LED_ON_FORCE_ON : 0);
|
||||
+ else
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int mt798x_phy_hw_led_blink_set(struct phy_device *phydev, u8 index,
|
||||
+ bool blinking)
|
||||
+{
|
||||
+ unsigned int bit_blink = MTK_PHY_LED_STATE_FORCE_BLINK + (index ? 16 : 0);
|
||||
+ struct mtk_socphy_priv *priv = phydev->priv;
|
||||
+ bool changed;
|
||||
+
|
||||
+ if (blinking)
|
||||
+ changed = !test_and_set_bit(bit_blink, &priv->led_state);
|
||||
+ else
|
||||
+ changed = !!test_and_clear_bit(bit_blink, &priv->led_state);
|
||||
+
|
||||
+ changed |= !!test_bit(MTK_PHY_LED_STATE_NETDEV +
|
||||
+ (index ? 16 : 0), &priv->led_state);
|
||||
+ if (changed)
|
||||
+ return phy_write_mmd(phydev, MDIO_MMD_VEND2, index ?
|
||||
+ MTK_PHY_LED1_BLINK_CTRL : MTK_PHY_LED0_BLINK_CTRL,
|
||||
+ blinking ? MTK_PHY_LED_BLINK_FORCE_BLINK : 0);
|
||||
+ else
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int mt798x_phy_led_blink_set(struct phy_device *phydev, u8 index,
|
||||
+ unsigned long *delay_on,
|
||||
+ unsigned long *delay_off)
|
||||
+{
|
||||
+ bool blinking = false;
|
||||
+ int err = 0;
|
||||
+
|
||||
+ if (index > 1)
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ if (delay_on && delay_off && (*delay_on > 0) && (*delay_off > 0)) {
|
||||
+ blinking = true;
|
||||
+ *delay_on = 50;
|
||||
+ *delay_off = 50;
|
||||
+ }
|
||||
+
|
||||
+ err = mt798x_phy_hw_led_blink_set(phydev, index, blinking);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ return mt798x_phy_hw_led_on_set(phydev, index, false);
|
||||
+}
|
||||
+
|
||||
+static int mt798x_phy_led_brightness_set(struct phy_device *phydev,
|
||||
+ u8 index, enum led_brightness value)
|
||||
+{
|
||||
+ int err;
|
||||
+
|
||||
+ err = mt798x_phy_hw_led_blink_set(phydev, index, false);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ return mt798x_phy_hw_led_on_set(phydev, index, (value != LED_OFF));
|
||||
+}
|
||||
+
|
||||
+static const unsigned long supported_triggers = (BIT(TRIGGER_NETDEV_FULL_DUPLEX) |
|
||||
+ BIT(TRIGGER_NETDEV_HALF_DUPLEX) |
|
||||
+ BIT(TRIGGER_NETDEV_LINK) |
|
||||
+ BIT(TRIGGER_NETDEV_LINK_10) |
|
||||
+ BIT(TRIGGER_NETDEV_LINK_100) |
|
||||
+ BIT(TRIGGER_NETDEV_LINK_1000) |
|
||||
+ BIT(TRIGGER_NETDEV_RX) |
|
||||
+ BIT(TRIGGER_NETDEV_TX));
|
||||
+
|
||||
+static int mt798x_phy_led_hw_is_supported(struct phy_device *phydev, u8 index,
|
||||
+ unsigned long rules)
|
||||
+{
|
||||
+ if (index > 1)
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ /* All combinations of the supported triggers are allowed */
|
||||
+ if (rules & ~supported_triggers)
|
||||
+ return -EOPNOTSUPP;
|
||||
+
|
||||
+ return 0;
|
||||
+};
|
||||
+
|
||||
+static int mt798x_phy_led_hw_control_get(struct phy_device *phydev, u8 index,
|
||||
+ unsigned long *rules)
|
||||
+{
|
||||
+ unsigned int bit_blink = MTK_PHY_LED_STATE_FORCE_BLINK + (index ? 16 : 0);
|
||||
+ unsigned int bit_netdev = MTK_PHY_LED_STATE_NETDEV + (index ? 16 : 0);
|
||||
+ unsigned int bit_on = MTK_PHY_LED_STATE_FORCE_ON + (index ? 16 : 0);
|
||||
+ struct mtk_socphy_priv *priv = phydev->priv;
|
||||
+ int on, blink;
|
||||
+
|
||||
+ if (index > 1)
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ on = phy_read_mmd(phydev, MDIO_MMD_VEND2,
|
||||
+ index ? MTK_PHY_LED1_ON_CTRL : MTK_PHY_LED0_ON_CTRL);
|
||||
+
|
||||
+ if (on < 0)
|
||||
+ return -EIO;
|
||||
+
|
||||
+ blink = phy_read_mmd(phydev, MDIO_MMD_VEND2,
|
||||
+ index ? MTK_PHY_LED1_BLINK_CTRL :
|
||||
+ MTK_PHY_LED0_BLINK_CTRL);
|
||||
+ if (blink < 0)
|
||||
+ return -EIO;
|
||||
+
|
||||
+ if ((on & (MTK_PHY_LED_ON_LINK1000 | MTK_PHY_LED_ON_LINK100 |
|
||||
+ MTK_PHY_LED_ON_LINK10)) ||
|
||||
+ (blink & (MTK_PHY_LED_BLINK_1000RX | MTK_PHY_LED_BLINK_100RX |
|
||||
+ MTK_PHY_LED_BLINK_10RX | MTK_PHY_LED_BLINK_1000TX |
|
||||
+ MTK_PHY_LED_BLINK_100TX | MTK_PHY_LED_BLINK_10TX)))
|
||||
+ set_bit(bit_netdev, &priv->led_state);
|
||||
+ else
|
||||
+ clear_bit(bit_netdev, &priv->led_state);
|
||||
+
|
||||
+ if (on & MTK_PHY_LED_ON_FORCE_ON)
|
||||
+ set_bit(bit_on, &priv->led_state);
|
||||
+ else
|
||||
+ clear_bit(bit_on, &priv->led_state);
|
||||
+
|
||||
+ if (blink & MTK_PHY_LED_BLINK_FORCE_BLINK)
|
||||
+ set_bit(bit_blink, &priv->led_state);
|
||||
+ else
|
||||
+ clear_bit(bit_blink, &priv->led_state);
|
||||
+
|
||||
+ if (!rules)
|
||||
+ return 0;
|
||||
+
|
||||
+ if (on & (MTK_PHY_LED_ON_LINK1000 | MTK_PHY_LED_ON_LINK100 | MTK_PHY_LED_ON_LINK10))
|
||||
+ *rules |= BIT(TRIGGER_NETDEV_LINK);
|
||||
+
|
||||
+ if (on & MTK_PHY_LED_ON_LINK10)
|
||||
+ *rules |= BIT(TRIGGER_NETDEV_LINK_10);
|
||||
+
|
||||
+ if (on & MTK_PHY_LED_ON_LINK100)
|
||||
+ *rules |= BIT(TRIGGER_NETDEV_LINK_100);
|
||||
+
|
||||
+ if (on & MTK_PHY_LED_ON_LINK1000)
|
||||
+ *rules |= BIT(TRIGGER_NETDEV_LINK_1000);
|
||||
+
|
||||
+ if (on & MTK_PHY_LED_ON_FDX)
|
||||
+ *rules |= BIT(TRIGGER_NETDEV_FULL_DUPLEX);
|
||||
+
|
||||
+ if (on & MTK_PHY_LED_ON_HDX)
|
||||
+ *rules |= BIT(TRIGGER_NETDEV_HALF_DUPLEX);
|
||||
+
|
||||
+ if (blink & (MTK_PHY_LED_BLINK_1000RX | MTK_PHY_LED_BLINK_100RX | MTK_PHY_LED_BLINK_10RX))
|
||||
+ *rules |= BIT(TRIGGER_NETDEV_RX);
|
||||
+
|
||||
+ if (blink & (MTK_PHY_LED_BLINK_1000TX | MTK_PHY_LED_BLINK_100TX | MTK_PHY_LED_BLINK_10TX))
|
||||
+ *rules |= BIT(TRIGGER_NETDEV_TX);
|
||||
+
|
||||
+ return 0;
|
||||
+};
|
||||
+
|
||||
+static int mt798x_phy_led_hw_control_set(struct phy_device *phydev, u8 index,
|
||||
+ unsigned long rules)
|
||||
+{
|
||||
+ unsigned int bit_netdev = MTK_PHY_LED_STATE_NETDEV + (index ? 16 : 0);
|
||||
+ struct mtk_socphy_priv *priv = phydev->priv;
|
||||
+ u16 on = 0, blink = 0;
|
||||
+ int ret;
|
||||
+
|
||||
+ if (index > 1)
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ if (rules & BIT(TRIGGER_NETDEV_FULL_DUPLEX))
|
||||
+ on |= MTK_PHY_LED_ON_FDX;
|
||||
+
|
||||
+ if (rules & BIT(TRIGGER_NETDEV_HALF_DUPLEX))
|
||||
+ on |= MTK_PHY_LED_ON_HDX;
|
||||
+
|
||||
+ if (rules & (BIT(TRIGGER_NETDEV_LINK_10) | BIT(TRIGGER_NETDEV_LINK)))
|
||||
+ on |= MTK_PHY_LED_ON_LINK10;
|
||||
+
|
||||
+ if (rules & (BIT(TRIGGER_NETDEV_LINK_100) | BIT(TRIGGER_NETDEV_LINK)))
|
||||
+ on |= MTK_PHY_LED_ON_LINK100;
|
||||
+
|
||||
+ if (rules & (BIT(TRIGGER_NETDEV_LINK_1000) | BIT(TRIGGER_NETDEV_LINK)))
|
||||
+ on |= MTK_PHY_LED_ON_LINK1000;
|
||||
+
|
||||
+ if (rules & BIT(TRIGGER_NETDEV_RX)) {
|
||||
+ blink |= MTK_PHY_LED_BLINK_10RX |
|
||||
+ MTK_PHY_LED_BLINK_100RX |
|
||||
+ MTK_PHY_LED_BLINK_1000RX;
|
||||
+ }
|
||||
+
|
||||
+ if (rules & BIT(TRIGGER_NETDEV_TX)) {
|
||||
+ blink |= MTK_PHY_LED_BLINK_10TX |
|
||||
+ MTK_PHY_LED_BLINK_100TX |
|
||||
+ MTK_PHY_LED_BLINK_1000TX;
|
||||
+ }
|
||||
+
|
||||
+ if (blink || on)
|
||||
+ set_bit(bit_netdev, &priv->led_state);
|
||||
+ else
|
||||
+ clear_bit(bit_netdev, &priv->led_state);
|
||||
+
|
||||
+ ret = phy_modify_mmd(phydev, MDIO_MMD_VEND2, index ?
|
||||
+ MTK_PHY_LED1_ON_CTRL :
|
||||
+ MTK_PHY_LED0_ON_CTRL,
|
||||
+ MTK_PHY_LED_ON_FDX |
|
||||
+ MTK_PHY_LED_ON_HDX |
|
||||
+ MTK_PHY_LED_ON_LINK10 |
|
||||
+ MTK_PHY_LED_ON_LINK100 |
|
||||
+ MTK_PHY_LED_ON_LINK1000,
|
||||
+ on);
|
||||
+
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+ return phy_write_mmd(phydev, MDIO_MMD_VEND2, index ?
|
||||
+ MTK_PHY_LED1_BLINK_CTRL :
|
||||
+ MTK_PHY_LED0_BLINK_CTRL, blink);
|
||||
+};
|
||||
+
|
||||
+static bool mt7988_phy_led_get_polarity(struct phy_device *phydev, int led_num)
|
||||
+{
|
||||
+ struct mtk_socphy_shared *priv = phydev->shared->priv;
|
||||
+ u32 polarities;
|
||||
+
|
||||
+ if (led_num == 0)
|
||||
+ polarities = ~(priv->boottrap);
|
||||
+ else
|
||||
+ polarities = MTK_PHY_LED1_DEFAULT_POLARITIES;
|
||||
+
|
||||
+ if (polarities & BIT(phydev->mdio.addr))
|
||||
+ return true;
|
||||
+
|
||||
+ return false;
|
||||
+}
|
||||
+
|
||||
+static int mt7988_phy_fix_leds_polarities(struct phy_device *phydev)
|
||||
+{
|
||||
+ struct pinctrl *pinctrl;
|
||||
+ int index;
|
||||
+
|
||||
+ /* Setup LED polarity according to bootstrap use of LED pins */
|
||||
+ for (index = 0; index < 2; ++index)
|
||||
+ phy_modify_mmd(phydev, MDIO_MMD_VEND2, index ?
|
||||
+ MTK_PHY_LED1_ON_CTRL : MTK_PHY_LED0_ON_CTRL,
|
||||
+ MTK_PHY_LED_ON_POLARITY,
|
||||
+ mt7988_phy_led_get_polarity(phydev, index) ?
|
||||
+ MTK_PHY_LED_ON_POLARITY : 0);
|
||||
+
|
||||
+ /* Only now setup pinctrl to avoid bogus blinking */
|
||||
+ pinctrl = devm_pinctrl_get_select(&phydev->mdio.dev, "gbe-led");
|
||||
+ if (IS_ERR(pinctrl))
|
||||
+ dev_err(&phydev->mdio.bus->dev, "Failed to setup PHY LED pinctrl\n");
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int mt7988_phy_probe_shared(struct phy_device *phydev)
|
||||
+{
|
||||
+ struct device_node *np = dev_of_node(&phydev->mdio.bus->dev);
|
||||
+ struct mtk_socphy_shared *shared = phydev->shared->priv;
|
||||
+ struct regmap *regmap;
|
||||
+ u32 reg;
|
||||
+ int ret;
|
||||
+
|
||||
+ /* The LED0 of the 4 PHYs in MT7988 are wired to SoC pins LED_A, LED_B,
|
||||
+ * LED_C and LED_D respectively. At the same time those pins are used to
|
||||
+ * bootstrap configuration of the reference clock source (LED_A),
|
||||
+ * DRAM DDRx16b x2/x1 (LED_B) and boot device (LED_C, LED_D).
|
||||
+ * In practise this is done using a LED and a resistor pulling the pin
|
||||
+ * either to GND or to VIO.
|
||||
+ * The detected value at boot time is accessible at run-time using the
|
||||
+ * TPBANK0 register located in the gpio base of the pinctrl, in order
|
||||
+ * to read it here it needs to be referenced by a phandle called
|
||||
+ * 'mediatek,pio' in the MDIO bus hosting the PHY.
|
||||
+ * The 4 bits in TPBANK0 are kept as package shared data and are used to
|
||||
+ * set LED polarity for each of the LED0.
|
||||
+ */
|
||||
+ regmap = syscon_regmap_lookup_by_phandle(np, "mediatek,pio");
|
||||
+ if (IS_ERR(regmap))
|
||||
+ return PTR_ERR(regmap);
|
||||
+
|
||||
+ ret = regmap_read(regmap, RG_GPIO_MISC_TPBANK0, ®);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+ shared->boottrap = FIELD_GET(RG_GPIO_MISC_TPBANK0_BOOTMODE, reg);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void mt798x_phy_leds_state_init(struct phy_device *phydev)
|
||||
+{
|
||||
+ int i;
|
||||
+
|
||||
+ for (i = 0; i < 2; ++i)
|
||||
+ mt798x_phy_led_hw_control_get(phydev, i, NULL);
|
||||
+}
|
||||
+
|
||||
+static int mt7988_phy_probe(struct phy_device *phydev)
|
||||
+{
|
||||
+ struct mtk_socphy_shared *shared;
|
||||
+ struct mtk_socphy_priv *priv;
|
||||
+ int err;
|
||||
+
|
||||
+ if (phydev->mdio.addr > 3)
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ err = devm_phy_package_join(&phydev->mdio.dev, phydev, 0,
|
||||
+ sizeof(struct mtk_socphy_shared));
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ if (phy_package_probe_once(phydev)) {
|
||||
+ err = mt7988_phy_probe_shared(phydev);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+ }
|
||||
+
|
||||
+ shared = phydev->shared->priv;
|
||||
+ priv = &shared->priv[phydev->mdio.addr];
|
||||
+
|
||||
+ phydev->priv = priv;
|
||||
+
|
||||
+ mt798x_phy_leds_state_init(phydev);
|
||||
+
|
||||
+ err = mt7988_phy_fix_leds_polarities(phydev);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ return mt798x_phy_calibration(phydev);
|
||||
+}
|
||||
+
|
||||
+static int mt7981_phy_probe(struct phy_device *phydev)
|
||||
+{
|
||||
+ struct mtk_socphy_priv *priv;
|
||||
+
|
||||
+ priv = devm_kzalloc(&phydev->mdio.dev, sizeof(struct mtk_socphy_priv),
|
||||
+ GFP_KERNEL);
|
||||
+ if (!priv)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ phydev->priv = priv;
|
||||
+
|
||||
+ mt798x_phy_leds_state_init(phydev);
|
||||
+
|
||||
+ return mt798x_phy_calibration(phydev);
|
||||
+}
|
||||
+
|
||||
static struct phy_driver mtk_socphy_driver[] = {
|
||||
{
|
||||
PHY_ID_MATCH_EXACT(MTK_GPHY_ID_MT7981),
|
||||
@@ -1080,11 +1487,16 @@ static struct phy_driver mtk_socphy_driv
|
||||
.config_init = mt798x_phy_config_init,
|
||||
.config_intr = genphy_no_config_intr,
|
||||
.handle_interrupt = genphy_handle_interrupt_no_ack,
|
||||
- .probe = mt798x_phy_calibration,
|
||||
+ .probe = mt7981_phy_probe,
|
||||
.suspend = genphy_suspend,
|
||||
.resume = genphy_resume,
|
||||
.read_page = mtk_socphy_read_page,
|
||||
.write_page = mtk_socphy_write_page,
|
||||
+ .led_blink_set = mt798x_phy_led_blink_set,
|
||||
+ .led_brightness_set = mt798x_phy_led_brightness_set,
|
||||
+ .led_hw_is_supported = mt798x_phy_led_hw_is_supported,
|
||||
+ .led_hw_control_set = mt798x_phy_led_hw_control_set,
|
||||
+ .led_hw_control_get = mt798x_phy_led_hw_control_get,
|
||||
},
|
||||
{
|
||||
PHY_ID_MATCH_EXACT(MTK_GPHY_ID_MT7988),
|
||||
@@ -1092,11 +1504,16 @@ static struct phy_driver mtk_socphy_driv
|
||||
.config_init = mt798x_phy_config_init,
|
||||
.config_intr = genphy_no_config_intr,
|
||||
.handle_interrupt = genphy_handle_interrupt_no_ack,
|
||||
- .probe = mt798x_phy_calibration,
|
||||
+ .probe = mt7988_phy_probe,
|
||||
.suspend = genphy_suspend,
|
||||
.resume = genphy_resume,
|
||||
.read_page = mtk_socphy_read_page,
|
||||
.write_page = mtk_socphy_write_page,
|
||||
+ .led_blink_set = mt798x_phy_led_blink_set,
|
||||
+ .led_brightness_set = mt798x_phy_led_brightness_set,
|
||||
+ .led_hw_is_supported = mt798x_phy_led_hw_is_supported,
|
||||
+ .led_hw_control_set = mt798x_phy_led_hw_control_set,
|
||||
+ .led_hw_control_get = mt798x_phy_led_hw_control_get,
|
||||
},
|
||||
};
|
||||
|
@ -1,23 +0,0 @@
|
||||
--- a/drivers/pwm/pwm-mediatek.c
|
||||
+++ b/drivers/pwm/pwm-mediatek.c
|
||||
@@ -329,6 +329,12 @@ static const struct pwm_mediatek_of_data
|
||||
.has_ck_26m_sel = true,
|
||||
};
|
||||
|
||||
+static const struct pwm_mediatek_of_data mt7986_pwm_data = {
|
||||
+ .num_pwms = 2,
|
||||
+ .pwm45_fixup = false,
|
||||
+ .has_ck_26m_sel = true,
|
||||
+};
|
||||
+
|
||||
static const struct pwm_mediatek_of_data mt8516_pwm_data = {
|
||||
.num_pwms = 5,
|
||||
.pwm45_fixup = false,
|
||||
@@ -342,6 +348,7 @@ static const struct of_device_id pwm_med
|
||||
{ .compatible = "mediatek,mt7623-pwm", .data = &mt7623_pwm_data },
|
||||
{ .compatible = "mediatek,mt7628-pwm", .data = &mt7628_pwm_data },
|
||||
{ .compatible = "mediatek,mt7629-pwm", .data = &mt7629_pwm_data },
|
||||
+ { .compatible = "mediatek,mt7986-pwm", .data = &mt7986_pwm_data },
|
||||
{ .compatible = "mediatek,mt8183-pwm", .data = &mt8183_pwm_data },
|
||||
{ .compatible = "mediatek,mt8365-pwm", .data = &mt8365_pwm_data },
|
||||
{ .compatible = "mediatek,mt8516-pwm", .data = &mt8516_pwm_data },
|
@ -1,129 +0,0 @@
|
||||
From fae82621ac33e2a4a96220c56e90d1ec6237d394 Mon Sep 17 00:00:00 2001
|
||||
From: Sam Shih <sam.shih@mediatek.com>
|
||||
Date: Sun, 6 Nov 2022 09:01:12 +0100
|
||||
Subject: [PATCH] pinctrl: mediatek: extend pinctrl-moore to support new bias
|
||||
functions
|
||||
|
||||
Commit fb34a9ae383a ("pinctrl: mediatek: support rsel feature")
|
||||
introduced SoC specify 'pull_type' attribute to mtk_pinconf_bias_set_combo
|
||||
and mtk_pinconf_bias_get_combo, and make the functions able to support
|
||||
almost all Mediatek SoCs that use pinctrl-mtk-common-v2.c.
|
||||
|
||||
This patch enables pinctrl_moore to support these functions.
|
||||
|
||||
Signed-off-by: Sam Shih <sam.shih@mediatek.com>
|
||||
Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Link: https://lore.kernel.org/r/20221106080114.7426-6-linux@fw-web.de
|
||||
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
|
||||
---
|
||||
drivers/pinctrl/mediatek/pinctrl-moore.c | 49 ++++++++++++++++++++----
|
||||
1 file changed, 42 insertions(+), 7 deletions(-)
|
||||
|
||||
--- a/drivers/pinctrl/mediatek/pinctrl-moore.c
|
||||
+++ b/drivers/pinctrl/mediatek/pinctrl-moore.c
|
||||
@@ -8,6 +8,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
+#include <dt-bindings/pinctrl/mt65xx.h>
|
||||
#include <linux/gpio/driver.h>
|
||||
#include "pinctrl-moore.h"
|
||||
|
||||
@@ -105,7 +106,7 @@ static int mtk_pinconf_get(struct pinctr
|
||||
{
|
||||
struct mtk_pinctrl *hw = pinctrl_dev_get_drvdata(pctldev);
|
||||
u32 param = pinconf_to_config_param(*config);
|
||||
- int val, val2, err, reg, ret = 1;
|
||||
+ int val, val2, err, pullup, reg, ret = 1;
|
||||
const struct mtk_pin_desc *desc;
|
||||
|
||||
desc = (const struct mtk_pin_desc *)&hw->soc->pins[pin];
|
||||
@@ -114,7 +115,13 @@ static int mtk_pinconf_get(struct pinctr
|
||||
|
||||
switch (param) {
|
||||
case PIN_CONFIG_BIAS_DISABLE:
|
||||
- if (hw->soc->bias_disable_get) {
|
||||
+ if (hw->soc->bias_get_combo) {
|
||||
+ err = hw->soc->bias_get_combo(hw, desc, &pullup, &ret);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+ if (ret != MTK_PUPD_SET_R1R0_00 && ret != MTK_DISABLE)
|
||||
+ return -EINVAL;
|
||||
+ } else if (hw->soc->bias_disable_get) {
|
||||
err = hw->soc->bias_disable_get(hw, desc, &ret);
|
||||
if (err)
|
||||
return err;
|
||||
@@ -123,7 +130,15 @@ static int mtk_pinconf_get(struct pinctr
|
||||
}
|
||||
break;
|
||||
case PIN_CONFIG_BIAS_PULL_UP:
|
||||
- if (hw->soc->bias_get) {
|
||||
+ if (hw->soc->bias_get_combo) {
|
||||
+ err = hw->soc->bias_get_combo(hw, desc, &pullup, &ret);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+ if (ret == MTK_PUPD_SET_R1R0_00 || ret == MTK_DISABLE)
|
||||
+ return -EINVAL;
|
||||
+ if (!pullup)
|
||||
+ return -EINVAL;
|
||||
+ } else if (hw->soc->bias_get) {
|
||||
err = hw->soc->bias_get(hw, desc, 1, &ret);
|
||||
if (err)
|
||||
return err;
|
||||
@@ -132,7 +147,15 @@ static int mtk_pinconf_get(struct pinctr
|
||||
}
|
||||
break;
|
||||
case PIN_CONFIG_BIAS_PULL_DOWN:
|
||||
- if (hw->soc->bias_get) {
|
||||
+ if (hw->soc->bias_get_combo) {
|
||||
+ err = hw->soc->bias_get_combo(hw, desc, &pullup, &ret);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+ if (ret == MTK_PUPD_SET_R1R0_00 || ret == MTK_DISABLE)
|
||||
+ return -EINVAL;
|
||||
+ if (pullup)
|
||||
+ return -EINVAL;
|
||||
+ } else if (hw->soc->bias_get) {
|
||||
err = hw->soc->bias_get(hw, desc, 0, &ret);
|
||||
if (err)
|
||||
return err;
|
||||
@@ -235,7 +258,11 @@ static int mtk_pinconf_set(struct pinctr
|
||||
|
||||
switch (param) {
|
||||
case PIN_CONFIG_BIAS_DISABLE:
|
||||
- if (hw->soc->bias_disable_set) {
|
||||
+ if (hw->soc->bias_set_combo) {
|
||||
+ err = hw->soc->bias_set_combo(hw, desc, 0, MTK_DISABLE);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+ } else if (hw->soc->bias_disable_set) {
|
||||
err = hw->soc->bias_disable_set(hw, desc);
|
||||
if (err)
|
||||
return err;
|
||||
@@ -244,7 +271,11 @@ static int mtk_pinconf_set(struct pinctr
|
||||
}
|
||||
break;
|
||||
case PIN_CONFIG_BIAS_PULL_UP:
|
||||
- if (hw->soc->bias_set) {
|
||||
+ if (hw->soc->bias_set_combo) {
|
||||
+ err = hw->soc->bias_set_combo(hw, desc, 1, arg);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+ } else if (hw->soc->bias_set) {
|
||||
err = hw->soc->bias_set(hw, desc, 1);
|
||||
if (err)
|
||||
return err;
|
||||
@@ -253,7 +284,11 @@ static int mtk_pinconf_set(struct pinctr
|
||||
}
|
||||
break;
|
||||
case PIN_CONFIG_BIAS_PULL_DOWN:
|
||||
- if (hw->soc->bias_set) {
|
||||
+ if (hw->soc->bias_set_combo) {
|
||||
+ err = hw->soc->bias_set_combo(hw, desc, 0, arg);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+ } else if (hw->soc->bias_set) {
|
||||
err = hw->soc->bias_set(hw, desc, 0);
|
||||
if (err)
|
||||
return err;
|
@ -1,37 +0,0 @@
|
||||
From f167da186acf90847e1a6d3716e253825a6218ec Mon Sep 17 00:00:00 2001
|
||||
From: Randy Dunlap <rdunlap@infradead.org>
|
||||
Date: Thu, 12 Jan 2023 22:44:49 -0800
|
||||
Subject: [PATCH 01/42] thermal/drivers/mtk_thermal: Fix kernel-doc function
|
||||
name
|
||||
|
||||
Use the correct function name in a kernel-doc comment to prevent
|
||||
a warning:
|
||||
|
||||
drivers/thermal/mtk_thermal.c:562: warning: expecting prototype for raw_to_mcelsius(). Prototype was for raw_to_mcelsius_v1() instead
|
||||
|
||||
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
|
||||
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
|
||||
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
|
||||
Cc: Amit Kucheria <amitk@kernel.org>
|
||||
Cc: Zhang Rui <rui.zhang@intel.com>
|
||||
Cc: Matthias Brugger <matthias.bgg@gmail.com>
|
||||
Cc: linux-pm@vger.kernel.org
|
||||
Cc: linux-arm-kernel@lists.infradead.org
|
||||
Cc: linux-mediatek@lists.infradead.org
|
||||
Link: https://lore.kernel.org/r/20230113064449.15061-1-rdunlap@infradead.org
|
||||
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|
||||
---
|
||||
drivers/thermal/mtk_thermal.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/thermal/mtk_thermal.c
|
||||
+++ b/drivers/thermal/mtk_thermal.c
|
||||
@@ -550,7 +550,7 @@ static const struct mtk_thermal_data mt8
|
||||
};
|
||||
|
||||
/**
|
||||
- * raw_to_mcelsius - convert a raw ADC value to mcelsius
|
||||
+ * raw_to_mcelsius_v1 - convert a raw ADC value to mcelsius
|
||||
* @mt: The thermal controller
|
||||
* @sensno: sensor number
|
||||
* @raw: raw ADC value
|
@ -1,37 +0,0 @@
|
||||
From 255509232417ee71fd606cb957d44cf6544f0c43 Mon Sep 17 00:00:00 2001
|
||||
From: ye xingchen <ye.xingchen@zte.com.cn>
|
||||
Date: Wed, 18 Jan 2023 16:37:47 +0800
|
||||
Subject: [PATCH 02/42] thermal/drivers/mtk_thermal: Use
|
||||
devm_platform_get_and_ioremap_resource()
|
||||
|
||||
Convert platform_get_resource(), devm_ioremap_resource() to a single
|
||||
call to devm_platform_get_and_ioremap_resource(), as this is exactly
|
||||
what this function does.
|
||||
|
||||
Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
|
||||
Link: https://lore.kernel.org/r/202301181637472073620@zte.com.cn
|
||||
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|
||||
---
|
||||
drivers/thermal/mtk_thermal.c | 4 +---
|
||||
1 file changed, 1 insertion(+), 3 deletions(-)
|
||||
|
||||
--- a/drivers/thermal/mtk_thermal.c
|
||||
+++ b/drivers/thermal/mtk_thermal.c
|
||||
@@ -990,7 +990,6 @@ static int mtk_thermal_probe(struct plat
|
||||
int ret, i, ctrl_id;
|
||||
struct device_node *auxadc, *apmixedsys, *np = pdev->dev.of_node;
|
||||
struct mtk_thermal *mt;
|
||||
- struct resource *res;
|
||||
u64 auxadc_phys_base, apmixed_phys_base;
|
||||
struct thermal_zone_device *tzdev;
|
||||
void __iomem *apmixed_base, *auxadc_base;
|
||||
@@ -1009,8 +1008,7 @@ static int mtk_thermal_probe(struct plat
|
||||
if (IS_ERR(mt->clk_auxadc))
|
||||
return PTR_ERR(mt->clk_auxadc);
|
||||
|
||||
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
- mt->thermal_base = devm_ioremap_resource(&pdev->dev, res);
|
||||
+ mt->thermal_base = devm_platform_get_and_ioremap_resource(pdev, 0, NULL);
|
||||
if (IS_ERR(mt->thermal_base))
|
||||
return PTR_ERR(mt->thermal_base);
|
||||
|
@ -1,60 +0,0 @@
|
||||
From ca86dbd309ba03bef38ae91f037e2030bb671ab7 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Wed, 18 Jan 2023 15:40:39 +0000
|
||||
Subject: [PATCH 03/42] thermal/drivers/mtk: Use function pointer for
|
||||
raw_to_mcelsius
|
||||
|
||||
Instead of having if-else logic selecting either raw_to_mcelsius_v1 or
|
||||
raw_to_mcelsius_v2 in mtk_thermal_bank_temperature introduce a function
|
||||
pointer raw_to_mcelsius to struct mtk_thermal which is initialized in the
|
||||
probe function.
|
||||
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>
|
||||
Link: https://lore.kernel.org/r/69c17529e8418da3eec703dde31e1b01e5b0f7e8.1674055882.git.daniel@makrotopia.org
|
||||
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|
||||
---
|
||||
drivers/thermal/mtk_thermal.c | 17 ++++++++++-------
|
||||
1 file changed, 10 insertions(+), 7 deletions(-)
|
||||
|
||||
--- a/drivers/thermal/mtk_thermal.c
|
||||
+++ b/drivers/thermal/mtk_thermal.c
|
||||
@@ -292,6 +292,8 @@ struct mtk_thermal {
|
||||
|
||||
const struct mtk_thermal_data *conf;
|
||||
struct mtk_thermal_bank banks[MAX_NUM_ZONES];
|
||||
+
|
||||
+ int (*raw_to_mcelsius)(struct mtk_thermal *mt, int sensno, s32 raw);
|
||||
};
|
||||
|
||||
/* MT8183 thermal sensor data */
|
||||
@@ -656,13 +658,9 @@ static int mtk_thermal_bank_temperature(
|
||||
for (i = 0; i < conf->bank_data[bank->id].num_sensors; i++) {
|
||||
raw = readl(mt->thermal_base + conf->msr[i]);
|
||||
|
||||
- if (mt->conf->version == MTK_THERMAL_V1) {
|
||||
- temp = raw_to_mcelsius_v1(
|
||||
- mt, conf->bank_data[bank->id].sensors[i], raw);
|
||||
- } else {
|
||||
- temp = raw_to_mcelsius_v2(
|
||||
- mt, conf->bank_data[bank->id].sensors[i], raw);
|
||||
- }
|
||||
+ temp = mt->raw_to_mcelsius(
|
||||
+ mt, conf->bank_data[bank->id].sensors[i], raw);
|
||||
+
|
||||
|
||||
/*
|
||||
* The first read of a sensor often contains very high bogus
|
||||
@@ -1073,6 +1071,11 @@ static int mtk_thermal_probe(struct plat
|
||||
mtk_thermal_release_periodic_ts(mt, auxadc_base);
|
||||
}
|
||||
|
||||
+ if (mt->conf->version == MTK_THERMAL_V1)
|
||||
+ mt->raw_to_mcelsius = raw_to_mcelsius_v1;
|
||||
+ else
|
||||
+ mt->raw_to_mcelsius = raw_to_mcelsius_v2;
|
||||
+
|
||||
for (ctrl_id = 0; ctrl_id < mt->conf->num_controller ; ctrl_id++)
|
||||
for (i = 0; i < mt->conf->num_banks; i++)
|
||||
mtk_thermal_init_bank(mt, i, apmixed_phys_base,
|
@ -1,236 +0,0 @@
|
||||
From aec1d89dccc7cba04fdb3e52dfda328f3302ba17 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Wed, 18 Jan 2023 15:40:58 +0000
|
||||
Subject: [PATCH 04/42] thermal/drivers/mtk: Add support for MT7986 and MT7981
|
||||
|
||||
Add support for V3 generation thermal found in MT7986 and MT7981 SoCs.
|
||||
Brings code to assign values from efuse as well as new function to
|
||||
convert raw temperature to millidegree celsius, as found in MediaTek's
|
||||
SDK sources (but cleaned up and de-duplicated)
|
||||
|
||||
[1]: https://git01.mediatek.com/plugins/gitiles/openwrt/feeds/mtk-openwrt-feeds/+/baf36c7eef477aae1f8f2653b6c29e2caf48475b
|
||||
|
||||
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Link: https://lore.kernel.org/r/2d341fc45266217249586eb4bd3be3ac4ca83a12.1674055882.git.daniel@makrotopia.org
|
||||
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|
||||
---
|
||||
drivers/thermal/mtk_thermal.c | 128 ++++++++++++++++++++++++++++++++--
|
||||
1 file changed, 124 insertions(+), 4 deletions(-)
|
||||
|
||||
--- a/drivers/thermal/mtk_thermal.c
|
||||
+++ b/drivers/thermal/mtk_thermal.c
|
||||
@@ -150,6 +150,20 @@
|
||||
#define CALIB_BUF1_VALID_V2(x) (((x) >> 4) & 0x1)
|
||||
#define CALIB_BUF1_O_SLOPE_SIGN_V2(x) (((x) >> 3) & 0x1)
|
||||
|
||||
+/*
|
||||
+ * Layout of the fuses providing the calibration data
|
||||
+ * These macros can be used for MT7981 and MT7986.
|
||||
+ */
|
||||
+#define CALIB_BUF0_ADC_GE_V3(x) (((x) >> 0) & 0x3ff)
|
||||
+#define CALIB_BUF0_DEGC_CALI_V3(x) (((x) >> 20) & 0x3f)
|
||||
+#define CALIB_BUF0_O_SLOPE_V3(x) (((x) >> 26) & 0x3f)
|
||||
+#define CALIB_BUF1_VTS_TS1_V3(x) (((x) >> 0) & 0x1ff)
|
||||
+#define CALIB_BUF1_VTS_TS2_V3(x) (((x) >> 21) & 0x1ff)
|
||||
+#define CALIB_BUF1_VTS_TSABB_V3(x) (((x) >> 9) & 0x1ff)
|
||||
+#define CALIB_BUF1_VALID_V3(x) (((x) >> 18) & 0x1)
|
||||
+#define CALIB_BUF1_O_SLOPE_SIGN_V3(x) (((x) >> 19) & 0x1)
|
||||
+#define CALIB_BUF1_ID_V3(x) (((x) >> 20) & 0x1)
|
||||
+
|
||||
enum {
|
||||
VTS1,
|
||||
VTS2,
|
||||
@@ -163,6 +177,7 @@ enum {
|
||||
enum mtk_thermal_version {
|
||||
MTK_THERMAL_V1 = 1,
|
||||
MTK_THERMAL_V2,
|
||||
+ MTK_THERMAL_V3,
|
||||
};
|
||||
|
||||
/* MT2701 thermal sensors */
|
||||
@@ -245,6 +260,27 @@ enum mtk_thermal_version {
|
||||
/* The calibration coefficient of sensor */
|
||||
#define MT8183_CALIBRATION 153
|
||||
|
||||
+/* AUXADC channel 11 is used for the temperature sensors */
|
||||
+#define MT7986_TEMP_AUXADC_CHANNEL 11
|
||||
+
|
||||
+/* The total number of temperature sensors in the MT7986 */
|
||||
+#define MT7986_NUM_SENSORS 1
|
||||
+
|
||||
+/* The number of banks in the MT7986 */
|
||||
+#define MT7986_NUM_ZONES 1
|
||||
+
|
||||
+/* The number of sensing points per bank */
|
||||
+#define MT7986_NUM_SENSORS_PER_ZONE 1
|
||||
+
|
||||
+/* MT7986 thermal sensors */
|
||||
+#define MT7986_TS1 0
|
||||
+
|
||||
+/* The number of controller in the MT7986 */
|
||||
+#define MT7986_NUM_CONTROLLER 1
|
||||
+
|
||||
+/* The calibration coefficient of sensor */
|
||||
+#define MT7986_CALIBRATION 165
|
||||
+
|
||||
struct mtk_thermal;
|
||||
|
||||
struct thermal_bank_cfg {
|
||||
@@ -388,6 +424,14 @@ static const int mt7622_mux_values[MT762
|
||||
static const int mt7622_vts_index[MT7622_NUM_SENSORS] = { VTS1 };
|
||||
static const int mt7622_tc_offset[MT7622_NUM_CONTROLLER] = { 0x0, };
|
||||
|
||||
+/* MT7986 thermal sensor data */
|
||||
+static const int mt7986_bank_data[MT7986_NUM_SENSORS] = { MT7986_TS1, };
|
||||
+static const int mt7986_msr[MT7986_NUM_SENSORS_PER_ZONE] = { TEMP_MSR0, };
|
||||
+static const int mt7986_adcpnp[MT7986_NUM_SENSORS_PER_ZONE] = { TEMP_ADCPNP0, };
|
||||
+static const int mt7986_mux_values[MT7986_NUM_SENSORS] = { 0, };
|
||||
+static const int mt7986_vts_index[MT7986_NUM_SENSORS] = { VTS1 };
|
||||
+static const int mt7986_tc_offset[MT7986_NUM_CONTROLLER] = { 0x0, };
|
||||
+
|
||||
/*
|
||||
* The MT8173 thermal controller has four banks. Each bank can read up to
|
||||
* four temperature sensors simultaneously. The MT8173 has a total of 5
|
||||
@@ -551,6 +595,30 @@ static const struct mtk_thermal_data mt8
|
||||
.version = MTK_THERMAL_V1,
|
||||
};
|
||||
|
||||
+/*
|
||||
+ * MT7986 uses AUXADC Channel 11 for raw data access.
|
||||
+ */
|
||||
+static const struct mtk_thermal_data mt7986_thermal_data = {
|
||||
+ .auxadc_channel = MT7986_TEMP_AUXADC_CHANNEL,
|
||||
+ .num_banks = MT7986_NUM_ZONES,
|
||||
+ .num_sensors = MT7986_NUM_SENSORS,
|
||||
+ .vts_index = mt7986_vts_index,
|
||||
+ .cali_val = MT7986_CALIBRATION,
|
||||
+ .num_controller = MT7986_NUM_CONTROLLER,
|
||||
+ .controller_offset = mt7986_tc_offset,
|
||||
+ .need_switch_bank = true,
|
||||
+ .bank_data = {
|
||||
+ {
|
||||
+ .num_sensors = 1,
|
||||
+ .sensors = mt7986_bank_data,
|
||||
+ },
|
||||
+ },
|
||||
+ .msr = mt7986_msr,
|
||||
+ .adcpnp = mt7986_adcpnp,
|
||||
+ .sensor_mux_values = mt7986_mux_values,
|
||||
+ .version = MTK_THERMAL_V3,
|
||||
+};
|
||||
+
|
||||
/**
|
||||
* raw_to_mcelsius_v1 - convert a raw ADC value to mcelsius
|
||||
* @mt: The thermal controller
|
||||
@@ -605,6 +673,22 @@ static int raw_to_mcelsius_v2(struct mtk
|
||||
return (format_2 - tmp) * 100;
|
||||
}
|
||||
|
||||
+static int raw_to_mcelsius_v3(struct mtk_thermal *mt, int sensno, s32 raw)
|
||||
+{
|
||||
+ s32 tmp;
|
||||
+
|
||||
+ if (raw == 0)
|
||||
+ return 0;
|
||||
+
|
||||
+ raw &= 0xfff;
|
||||
+ tmp = 100000 * 15 / 16 * 10000;
|
||||
+ tmp /= 4096 - 512 + mt->adc_ge;
|
||||
+ tmp /= 1490;
|
||||
+ tmp *= raw - mt->vts[sensno] - 2900;
|
||||
+
|
||||
+ return mt->degc_cali * 500 - tmp;
|
||||
+}
|
||||
+
|
||||
/**
|
||||
* mtk_thermal_get_bank - get bank
|
||||
* @bank: The bank
|
||||
@@ -885,6 +969,25 @@ static int mtk_thermal_extract_efuse_v2(
|
||||
return 0;
|
||||
}
|
||||
|
||||
+static int mtk_thermal_extract_efuse_v3(struct mtk_thermal *mt, u32 *buf)
|
||||
+{
|
||||
+ if (!CALIB_BUF1_VALID_V3(buf[1]))
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ mt->adc_ge = CALIB_BUF0_ADC_GE_V3(buf[0]);
|
||||
+ mt->degc_cali = CALIB_BUF0_DEGC_CALI_V3(buf[0]);
|
||||
+ mt->o_slope = CALIB_BUF0_O_SLOPE_V3(buf[0]);
|
||||
+ mt->vts[VTS1] = CALIB_BUF1_VTS_TS1_V3(buf[1]);
|
||||
+ mt->vts[VTS2] = CALIB_BUF1_VTS_TS2_V3(buf[1]);
|
||||
+ mt->vts[VTSABB] = CALIB_BUF1_VTS_TSABB_V3(buf[1]);
|
||||
+ mt->o_slope_sign = CALIB_BUF1_O_SLOPE_SIGN_V3(buf[1]);
|
||||
+
|
||||
+ if (CALIB_BUF1_ID_V3(buf[1]) == 0)
|
||||
+ mt->o_slope = 0;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
static int mtk_thermal_get_calibration_data(struct device *dev,
|
||||
struct mtk_thermal *mt)
|
||||
{
|
||||
@@ -895,6 +998,7 @@ static int mtk_thermal_get_calibration_d
|
||||
|
||||
/* Start with default values */
|
||||
mt->adc_ge = 512;
|
||||
+ mt->adc_oe = 512;
|
||||
for (i = 0; i < mt->conf->num_sensors; i++)
|
||||
mt->vts[i] = 260;
|
||||
mt->degc_cali = 40;
|
||||
@@ -920,10 +1024,20 @@ static int mtk_thermal_get_calibration_d
|
||||
goto out;
|
||||
}
|
||||
|
||||
- if (mt->conf->version == MTK_THERMAL_V1)
|
||||
+ switch (mt->conf->version) {
|
||||
+ case MTK_THERMAL_V1:
|
||||
ret = mtk_thermal_extract_efuse_v1(mt, buf);
|
||||
- else
|
||||
+ break;
|
||||
+ case MTK_THERMAL_V2:
|
||||
ret = mtk_thermal_extract_efuse_v2(mt, buf);
|
||||
+ break;
|
||||
+ case MTK_THERMAL_V3:
|
||||
+ ret = mtk_thermal_extract_efuse_v3(mt, buf);
|
||||
+ break;
|
||||
+ default:
|
||||
+ ret = -EINVAL;
|
||||
+ break;
|
||||
+ }
|
||||
|
||||
if (ret) {
|
||||
dev_info(dev, "Device not calibrated, using default calibration values\n");
|
||||
@@ -954,6 +1068,10 @@ static const struct of_device_id mtk_the
|
||||
.data = (void *)&mt7622_thermal_data,
|
||||
},
|
||||
{
|
||||
+ .compatible = "mediatek,mt7986-thermal",
|
||||
+ .data = (void *)&mt7986_thermal_data,
|
||||
+ },
|
||||
+ {
|
||||
.compatible = "mediatek,mt8183-thermal",
|
||||
.data = (void *)&mt8183_thermal_data,
|
||||
}, {
|
||||
@@ -1066,15 +1184,17 @@ static int mtk_thermal_probe(struct plat
|
||||
goto err_disable_clk_auxadc;
|
||||
}
|
||||
|
||||
- if (mt->conf->version == MTK_THERMAL_V2) {
|
||||
+ if (mt->conf->version != MTK_THERMAL_V1) {
|
||||
mtk_thermal_turn_on_buffer(apmixed_base);
|
||||
mtk_thermal_release_periodic_ts(mt, auxadc_base);
|
||||
}
|
||||
|
||||
if (mt->conf->version == MTK_THERMAL_V1)
|
||||
mt->raw_to_mcelsius = raw_to_mcelsius_v1;
|
||||
- else
|
||||
+ else if (mt->conf->version == MTK_THERMAL_V2)
|
||||
mt->raw_to_mcelsius = raw_to_mcelsius_v2;
|
||||
+ else
|
||||
+ mt->raw_to_mcelsius = raw_to_mcelsius_v3;
|
||||
|
||||
for (ctrl_id = 0; ctrl_id < mt->conf->num_controller ; ctrl_id++)
|
||||
for (i = 0; i < mt->conf->num_banks; i++)
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,186 +0,0 @@
|
||||
From 498e2f7a6e69dcbca24715de2b4b97569fdfeff4 Mon Sep 17 00:00:00 2001
|
||||
From: Balsam CHIHI <bchihi@baylibre.com>
|
||||
Date: Thu, 9 Feb 2023 11:56:24 +0100
|
||||
Subject: [PATCH] dt-bindings: thermal: mediatek: Add LVTS thermal controllers
|
||||
|
||||
Add LVTS thermal controllers dt-binding definition for mt8192 and mt8195.
|
||||
|
||||
Signed-off-by: Balsam CHIHI <bchihi@baylibre.com>
|
||||
Reviewed-by: Rob Herring <robh@kernel.org>
|
||||
Link: https://lore.kernel.org/r/20230209105628.50294-3-bchihi@baylibre.com
|
||||
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|
||||
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
|
||||
---
|
||||
.../thermal/mediatek,lvts-thermal.yaml | 142 ++++++++++++++++++
|
||||
.../thermal/mediatek,lvts-thermal.h | 19 +++
|
||||
2 files changed, 161 insertions(+)
|
||||
create mode 100644 Documentation/devicetree/bindings/thermal/mediatek,lvts-thermal.yaml
|
||||
create mode 100644 include/dt-bindings/thermal/mediatek,lvts-thermal.h
|
||||
|
||||
--- /dev/null
|
||||
+++ b/Documentation/devicetree/bindings/thermal/mediatek,lvts-thermal.yaml
|
||||
@@ -0,0 +1,142 @@
|
||||
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
|
||||
+%YAML 1.2
|
||||
+---
|
||||
+$id: http://devicetree.org/schemas/thermal/mediatek,lvts-thermal.yaml#
|
||||
+$schema: http://devicetree.org/meta-schemas/core.yaml#
|
||||
+
|
||||
+title: MediaTek SoC Low Voltage Thermal Sensor (LVTS)
|
||||
+
|
||||
+maintainers:
|
||||
+ - Balsam CHIHI <bchihi@baylibre.com>
|
||||
+
|
||||
+description: |
|
||||
+ LVTS is a thermal management architecture composed of three subsystems,
|
||||
+ a Sensing device - Thermal Sensing Micro Circuit Unit (TSMCU),
|
||||
+ a Converter - Low Voltage Thermal Sensor converter (LVTS), and
|
||||
+ a Digital controller (LVTS_CTRL).
|
||||
+
|
||||
+properties:
|
||||
+ compatible:
|
||||
+ enum:
|
||||
+ - mediatek,mt8192-lvts-ap
|
||||
+ - mediatek,mt8192-lvts-mcu
|
||||
+ - mediatek,mt8195-lvts-ap
|
||||
+ - mediatek,mt8195-lvts-mcu
|
||||
+
|
||||
+ reg:
|
||||
+ maxItems: 1
|
||||
+
|
||||
+ interrupts:
|
||||
+ maxItems: 1
|
||||
+
|
||||
+ clocks:
|
||||
+ maxItems: 1
|
||||
+
|
||||
+ resets:
|
||||
+ maxItems: 1
|
||||
+ description: LVTS reset for clearing temporary data on AP/MCU.
|
||||
+
|
||||
+ nvmem-cells:
|
||||
+ minItems: 1
|
||||
+ items:
|
||||
+ - description: Calibration eFuse data 1 for LVTS
|
||||
+ - description: Calibration eFuse data 2 for LVTS
|
||||
+
|
||||
+ nvmem-cell-names:
|
||||
+ minItems: 1
|
||||
+ items:
|
||||
+ - const: lvts-calib-data-1
|
||||
+ - const: lvts-calib-data-2
|
||||
+
|
||||
+ "#thermal-sensor-cells":
|
||||
+ const: 1
|
||||
+
|
||||
+allOf:
|
||||
+ - $ref: thermal-sensor.yaml#
|
||||
+
|
||||
+ - if:
|
||||
+ properties:
|
||||
+ compatible:
|
||||
+ contains:
|
||||
+ enum:
|
||||
+ - mediatek,mt8192-lvts-ap
|
||||
+ - mediatek,mt8192-lvts-mcu
|
||||
+ then:
|
||||
+ properties:
|
||||
+ nvmem-cells:
|
||||
+ maxItems: 1
|
||||
+
|
||||
+ nvmem-cell-names:
|
||||
+ maxItems: 1
|
||||
+
|
||||
+ - if:
|
||||
+ properties:
|
||||
+ compatible:
|
||||
+ contains:
|
||||
+ enum:
|
||||
+ - mediatek,mt8195-lvts-ap
|
||||
+ - mediatek,mt8195-lvts-mcu
|
||||
+ then:
|
||||
+ properties:
|
||||
+ nvmem-cells:
|
||||
+ minItems: 2
|
||||
+
|
||||
+ nvmem-cell-names:
|
||||
+ minItems: 2
|
||||
+
|
||||
+required:
|
||||
+ - compatible
|
||||
+ - reg
|
||||
+ - interrupts
|
||||
+ - clocks
|
||||
+ - resets
|
||||
+ - nvmem-cells
|
||||
+ - nvmem-cell-names
|
||||
+ - "#thermal-sensor-cells"
|
||||
+
|
||||
+additionalProperties: false
|
||||
+
|
||||
+examples:
|
||||
+ - |
|
||||
+ #include <dt-bindings/interrupt-controller/arm-gic.h>
|
||||
+ #include <dt-bindings/clock/mt8195-clk.h>
|
||||
+ #include <dt-bindings/reset/mt8195-resets.h>
|
||||
+ #include <dt-bindings/thermal/mediatek,lvts-thermal.h>
|
||||
+
|
||||
+ soc {
|
||||
+ #address-cells = <2>;
|
||||
+ #size-cells = <2>;
|
||||
+
|
||||
+ lvts_mcu: thermal-sensor@11278000 {
|
||||
+ compatible = "mediatek,mt8195-lvts-mcu";
|
||||
+ reg = <0 0x11278000 0 0x1000>;
|
||||
+ interrupts = <GIC_SPI 170 IRQ_TYPE_LEVEL_HIGH 0>;
|
||||
+ clocks = <&infracfg_ao CLK_INFRA_AO_THERM>;
|
||||
+ resets = <&infracfg_ao MT8195_INFRA_RST4_THERM_CTRL_MCU_SWRST>;
|
||||
+ nvmem-cells = <&lvts_efuse_data1 &lvts_efuse_data2>;
|
||||
+ nvmem-cell-names = "lvts-calib-data-1", "lvts-calib-data-2";
|
||||
+ #thermal-sensor-cells = <1>;
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
+ thermal_zones: thermal-zones {
|
||||
+ cpu0-thermal {
|
||||
+ polling-delay = <1000>;
|
||||
+ polling-delay-passive = <250>;
|
||||
+ thermal-sensors = <&lvts_mcu MT8195_MCU_LITTLE_CPU0>;
|
||||
+
|
||||
+ trips {
|
||||
+ cpu0_alert: trip-alert {
|
||||
+ temperature = <85000>;
|
||||
+ hysteresis = <2000>;
|
||||
+ type = "passive";
|
||||
+ };
|
||||
+
|
||||
+ cpu0_crit: trip-crit {
|
||||
+ temperature = <100000>;
|
||||
+ hysteresis = <2000>;
|
||||
+ type = "critical";
|
||||
+ };
|
||||
+ };
|
||||
+ };
|
||||
+ };
|
||||
--- /dev/null
|
||||
+++ b/include/dt-bindings/thermal/mediatek,lvts-thermal.h
|
||||
@@ -0,0 +1,19 @@
|
||||
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
|
||||
+/*
|
||||
+ * Copyright (c) 2023 MediaTek Inc.
|
||||
+ * Author: Balsam CHIHI <bchihi@baylibre.com>
|
||||
+ */
|
||||
+
|
||||
+#ifndef __MEDIATEK_LVTS_DT_H
|
||||
+#define __MEDIATEK_LVTS_DT_H
|
||||
+
|
||||
+#define MT8195_MCU_BIG_CPU0 0
|
||||
+#define MT8195_MCU_BIG_CPU1 1
|
||||
+#define MT8195_MCU_BIG_CPU2 2
|
||||
+#define MT8195_MCU_BIG_CPU3 3
|
||||
+#define MT8195_MCU_LITTLE_CPU0 4
|
||||
+#define MT8195_MCU_LITTLE_CPU1 5
|
||||
+#define MT8195_MCU_LITTLE_CPU2 6
|
||||
+#define MT8195_MCU_LITTLE_CPU3 7
|
||||
+
|
||||
+#endif /* __MEDIATEK_LVTS_DT_H */
|
@ -1,35 +0,0 @@
|
||||
From 05aaa7fdb0736262e224369b9b9f1410320fc71b Mon Sep 17 00:00:00 2001
|
||||
From: Balsam CHIHI <bchihi@baylibre.com>
|
||||
Date: Tue, 7 Mar 2023 16:45:21 +0100
|
||||
Subject: [PATCH] dt-bindings: thermal: mediatek: Add AP domain to LVTS thermal
|
||||
controllers for mt8195
|
||||
|
||||
Add AP Domain to LVTS thermal controllers dt-binding definition for mt8195.
|
||||
|
||||
Signed-off-by: Balsam CHIHI <bchihi@baylibre.com>
|
||||
Acked-by: Rob Herring <robh@kernel.org>
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Tested-by: Chen-Yu Tsai <wenst@chromium.org>
|
||||
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20230307154524.118541-2-bchihi@baylibre.com
|
||||
---
|
||||
include/dt-bindings/thermal/mediatek,lvts-thermal.h | 10 ++++++++++
|
||||
1 file changed, 10 insertions(+)
|
||||
|
||||
--- a/include/dt-bindings/thermal/mediatek,lvts-thermal.h
|
||||
+++ b/include/dt-bindings/thermal/mediatek,lvts-thermal.h
|
||||
@@ -16,4 +16,14 @@
|
||||
#define MT8195_MCU_LITTLE_CPU2 6
|
||||
#define MT8195_MCU_LITTLE_CPU3 7
|
||||
|
||||
+#define MT8195_AP_VPU0 8
|
||||
+#define MT8195_AP_VPU1 9
|
||||
+#define MT8195_AP_GPU0 10
|
||||
+#define MT8195_AP_GPU1 11
|
||||
+#define MT8195_AP_VDEC 12
|
||||
+#define MT8195_AP_IMG 13
|
||||
+#define MT8195_AP_INFRA 14
|
||||
+#define MT8195_AP_CAM0 15
|
||||
+#define MT8195_AP_CAM1 16
|
||||
+
|
||||
#endif /* __MEDIATEK_LVTS_DT_H */
|
@ -1,65 +0,0 @@
|
||||
From a6ff3c0021468721b96e84892a8cae24bde8d65f Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Lezcano <daniel.lezcano@linaro.org>
|
||||
Date: Wed, 1 Mar 2023 21:14:29 +0100
|
||||
Subject: [PATCH] thermal/core: Add a thermal zone 'devdata' accessor
|
||||
|
||||
The thermal zone device structure is exposed to the different drivers
|
||||
and obviously they access the internals while that should be
|
||||
restricted to the core thermal code.
|
||||
|
||||
In order to self-encapsulate the thermal core code, we need to prevent
|
||||
the drivers accessing directly the thermal zone structure and provide
|
||||
accessor functions to deal with.
|
||||
|
||||
Provide an accessor to the 'devdata' structure and make use of it in
|
||||
the different drivers.
|
||||
|
||||
No functional changes intended.
|
||||
|
||||
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|
||||
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
|
||||
Acked-by: Mark Brown <broonie@kernel.org>
|
||||
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
|
||||
---
|
||||
drivers/thermal/thermal_core.c | 6 ++++++
|
||||
include/linux/thermal.h | 7 +++++++
|
||||
2 files changed, 13 insertions(+)
|
||||
|
||||
--- a/drivers/thermal/thermal_core.c
|
||||
+++ b/drivers/thermal/thermal_core.c
|
||||
@@ -1346,6 +1346,12 @@ struct thermal_zone_device *thermal_zone
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(thermal_zone_device_register);
|
||||
|
||||
+void *thermal_zone_device_priv(struct thermal_zone_device *tzd)
|
||||
+{
|
||||
+ return tzd->devdata;
|
||||
+}
|
||||
+EXPORT_SYMBOL_GPL(thermal_zone_device_priv);
|
||||
+
|
||||
/**
|
||||
* thermal_zone_device_unregister - removes the registered thermal zone device
|
||||
* @tz: the thermal zone device to remove
|
||||
--- a/include/linux/thermal.h
|
||||
+++ b/include/linux/thermal.h
|
||||
@@ -346,6 +346,8 @@ thermal_zone_device_register_with_trips(
|
||||
void *, struct thermal_zone_device_ops *,
|
||||
struct thermal_zone_params *, int, int);
|
||||
|
||||
+void *thermal_zone_device_priv(struct thermal_zone_device *tzd);
|
||||
+
|
||||
int thermal_zone_bind_cooling_device(struct thermal_zone_device *, int,
|
||||
struct thermal_cooling_device *,
|
||||
unsigned long, unsigned long,
|
||||
@@ -417,6 +419,11 @@ static inline int thermal_zone_get_offse
|
||||
struct thermal_zone_device *tz)
|
||||
{ return -ENODEV; }
|
||||
|
||||
+static inline void *thermal_zone_device_priv(struct thermal_zone_device *tz)
|
||||
+{
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
static inline int thermal_zone_device_enable(struct thermal_zone_device *tz)
|
||||
{ return -ENODEV; }
|
||||
|
@ -1,55 +0,0 @@
|
||||
From 072e35c98806100182c0a7263cf4cba09ce43463 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Lezcano <daniel.lezcano@linaro.org>
|
||||
Date: Wed, 1 Mar 2023 21:14:38 +0100
|
||||
Subject: [PATCH] thermal/core: Add thermal_zone_device structure 'type'
|
||||
accessor
|
||||
|
||||
The thermal zone device structure is exposed via the exported
|
||||
thermal.h header. This structure should stay private the thermal core
|
||||
code. In order to encapsulate the structure, let's add an accessor to
|
||||
get the 'type' of the thermal zone.
|
||||
|
||||
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|
||||
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
|
||||
---
|
||||
drivers/thermal/thermal_core.c | 6 ++++++
|
||||
include/linux/thermal.h | 6 ++++++
|
||||
2 files changed, 12 insertions(+)
|
||||
|
||||
--- a/drivers/thermal/thermal_core.c
|
||||
+++ b/drivers/thermal/thermal_core.c
|
||||
@@ -1352,6 +1352,12 @@ void *thermal_zone_device_priv(struct th
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(thermal_zone_device_priv);
|
||||
|
||||
+const char *thermal_zone_device_type(struct thermal_zone_device *tzd)
|
||||
+{
|
||||
+ return tzd->type;
|
||||
+}
|
||||
+EXPORT_SYMBOL_GPL(thermal_zone_device_type);
|
||||
+
|
||||
/**
|
||||
* thermal_zone_device_unregister - removes the registered thermal zone device
|
||||
* @tz: the thermal zone device to remove
|
||||
--- a/include/linux/thermal.h
|
||||
+++ b/include/linux/thermal.h
|
||||
@@ -347,6 +347,7 @@ thermal_zone_device_register_with_trips(
|
||||
struct thermal_zone_params *, int, int);
|
||||
|
||||
void *thermal_zone_device_priv(struct thermal_zone_device *tzd);
|
||||
+const char *thermal_zone_device_type(struct thermal_zone_device *tzd);
|
||||
|
||||
int thermal_zone_bind_cooling_device(struct thermal_zone_device *, int,
|
||||
struct thermal_cooling_device *,
|
||||
@@ -423,6 +424,11 @@ static inline void *thermal_zone_device_
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
+
|
||||
+static inline const char *thermal_zone_device_type(struct thermal_zone_device *tzd)
|
||||
+{
|
||||
+ return NULL;
|
||||
+}
|
||||
|
||||
static inline int thermal_zone_device_enable(struct thermal_zone_device *tz)
|
||||
{ return -ENODEV; }
|
@ -1,74 +0,0 @@
|
||||
From 7d78bab533eb9aa0e5240e25a204e8f416723ed6 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Lezcano <daniel.lezcano@linaro.org>
|
||||
Date: Wed, 1 Mar 2023 21:14:30 +0100
|
||||
Subject: [PATCH 07/42] thermal/core: Use the thermal zone 'devdata' accessor
|
||||
in thermal located drivers
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
The thermal zone device structure is exposed to the different drivers
|
||||
and obviously they access the internals while that should be
|
||||
restricted to the core thermal code.
|
||||
|
||||
In order to self-encapsulate the thermal core code, we need to prevent
|
||||
the drivers accessing directly the thermal zone structure and provide
|
||||
accessor functions to deal with.
|
||||
|
||||
Use the devdata accessor introduced in the previous patch.
|
||||
|
||||
No functional changes intended.
|
||||
|
||||
[skipped drivers not relevant for mediatek target]
|
||||
|
||||
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|
||||
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> #R-Car
|
||||
Acked-by: Mark Brown <broonie@kernel.org>
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> #MediaTek auxadc and lvts
|
||||
Reviewed-by: Balsam CHIHI <bchihi@baylibre.com> #Mediatek lvts
|
||||
Reviewed-by: Adam Ward <DLG-Adam.Ward.opensource@dm.renesas.com> #da9062
|
||||
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com> #spread
|
||||
Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com> #sun8i_thermal
|
||||
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
|
||||
Acked-by: Florian Fainelli <f.fainelli@gmail.com> #Broadcom
|
||||
Reviewed-by: Dhruva Gole <d-gole@ti.com> # K3 bandgap
|
||||
Acked-by: Linus Walleij <linus.walleij@linaro.org>
|
||||
Acked-by: Heiko Stuebner <heiko@sntech.de> #rockchip
|
||||
Reviewed-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com> #uniphier
|
||||
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
|
||||
---
|
||||
drivers/thermal/mediatek/auxadc_thermal.c | 2 +-
|
||||
drivers/thermal/mediatek/lvts_thermal.c | 4 ++--
|
||||
43 files changed, 71 insertions(+), 73 deletions(-)
|
||||
|
||||
--- a/drivers/thermal/mediatek/auxadc_thermal.c
|
||||
+++ b/drivers/thermal/mediatek/auxadc_thermal.c
|
||||
@@ -763,7 +763,7 @@ static int mtk_thermal_bank_temperature(
|
||||
|
||||
static int mtk_read_temp(struct thermal_zone_device *tz, int *temperature)
|
||||
{
|
||||
- struct mtk_thermal *mt = tz->devdata;
|
||||
+ struct mtk_thermal *mt = thermal_zone_device_priv(tz);
|
||||
int i;
|
||||
int tempmax = INT_MIN;
|
||||
|
||||
--- a/drivers/thermal/mediatek/lvts_thermal.c
|
||||
+++ b/drivers/thermal/mediatek/lvts_thermal.c
|
||||
@@ -252,7 +252,7 @@ static u32 lvts_temp_to_raw(int temperat
|
||||
|
||||
static int lvts_get_temp(struct thermal_zone_device *tz, int *temp)
|
||||
{
|
||||
- struct lvts_sensor *lvts_sensor = tz->devdata;
|
||||
+ struct lvts_sensor *lvts_sensor = thermal_zone_device_priv(tz);
|
||||
void __iomem *msr = lvts_sensor->msr;
|
||||
u32 value;
|
||||
|
||||
@@ -290,7 +290,7 @@ static int lvts_get_temp(struct thermal_
|
||||
|
||||
static int lvts_set_trips(struct thermal_zone_device *tz, int low, int high)
|
||||
{
|
||||
- struct lvts_sensor *lvts_sensor = tz->devdata;
|
||||
+ struct lvts_sensor *lvts_sensor = thermal_zone_device_priv(tz);
|
||||
void __iomem *base = lvts_sensor->base;
|
||||
u32 raw_low = lvts_temp_to_raw(low);
|
||||
u32 raw_high = lvts_temp_to_raw(high);
|
@ -1,201 +0,0 @@
|
||||
From cc9c60e9cfeeac45d63361fa8c085c43c4bdfe3a Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Lezcano <daniel.lezcano@linaro.org>
|
||||
Date: Wed, 1 Mar 2023 21:14:36 +0100
|
||||
Subject: [PATCH 08/42] thermal/hwmon: Use the right device for
|
||||
devm_thermal_add_hwmon_sysfs()
|
||||
|
||||
The devres variant of thermal_add_hwmon_sysfs() only takes the thermal
|
||||
zone structure pointer as parameter.
|
||||
|
||||
Actually, it uses the tz->device to add it in the devres list.
|
||||
|
||||
It is preferable to use the device registering the thermal zone
|
||||
instead of the thermal zone device itself. That prevents the driver
|
||||
accessing the thermal zone structure internals and it is from my POV
|
||||
more correct regarding how devm_ is used.
|
||||
|
||||
[skipped imx thermal which did not apply cleanly and irrelevant on
|
||||
mediatek target]
|
||||
|
||||
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|
||||
Acked-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> #amlogic_thermal
|
||||
Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com> #sun8i_thermal
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> #MediaTek auxadc
|
||||
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
|
||||
---
|
||||
drivers/thermal/amlogic_thermal.c | 2 +-
|
||||
drivers/thermal/imx_sc_thermal.c | 2 +-
|
||||
drivers/thermal/k3_bandgap.c | 2 +-
|
||||
drivers/thermal/mediatek/auxadc_thermal.c | 2 +-
|
||||
drivers/thermal/qcom/qcom-spmi-adc-tm5.c | 2 +-
|
||||
drivers/thermal/qcom/qcom-spmi-temp-alarm.c | 2 +-
|
||||
drivers/thermal/qcom/tsens.c | 2 +-
|
||||
drivers/thermal/qoriq_thermal.c | 2 +-
|
||||
drivers/thermal/sun8i_thermal.c | 2 +-
|
||||
drivers/thermal/tegra/tegra30-tsensor.c | 2 +-
|
||||
drivers/thermal/thermal_hwmon.c | 4 ++--
|
||||
drivers/thermal/thermal_hwmon.h | 4 ++--
|
||||
drivers/thermal/ti-soc-thermal/ti-thermal-common.c | 2 +-
|
||||
13 files changed, 15 insertions(+), 15 deletions(-)
|
||||
|
||||
--- a/drivers/thermal/amlogic_thermal.c
|
||||
+++ b/drivers/thermal/amlogic_thermal.c
|
||||
@@ -286,7 +286,7 @@ static int amlogic_thermal_probe(struct
|
||||
return ret;
|
||||
}
|
||||
|
||||
- if (devm_thermal_add_hwmon_sysfs(pdata->tzd))
|
||||
+ if (devm_thermal_add_hwmon_sysfs(&pdev->dev, pdata->tzd))
|
||||
dev_warn(&pdev->dev, "Failed to add hwmon sysfs attributes\n");
|
||||
|
||||
ret = amlogic_thermal_initialize(pdata);
|
||||
--- a/drivers/thermal/imx_sc_thermal.c
|
||||
+++ b/drivers/thermal/imx_sc_thermal.c
|
||||
@@ -120,7 +120,7 @@ static int imx_sc_thermal_probe(struct p
|
||||
return ret;
|
||||
}
|
||||
|
||||
- if (devm_thermal_add_hwmon_sysfs(sensor->tzd))
|
||||
+ if (devm_thermal_add_hwmon_sysfs(&pdev->dev, sensor->tzd))
|
||||
dev_warn(&pdev->dev, "failed to add hwmon sysfs attributes\n");
|
||||
}
|
||||
|
||||
--- a/drivers/thermal/k3_bandgap.c
|
||||
+++ b/drivers/thermal/k3_bandgap.c
|
||||
@@ -222,7 +222,7 @@ static int k3_bandgap_probe(struct platf
|
||||
goto err_alloc;
|
||||
}
|
||||
|
||||
- if (devm_thermal_add_hwmon_sysfs(data[id].tzd))
|
||||
+ if (devm_thermal_add_hwmon_sysfs(dev, data[id].tzd))
|
||||
dev_warn(dev, "Failed to add hwmon sysfs attributes\n");
|
||||
}
|
||||
|
||||
--- a/drivers/thermal/mediatek/auxadc_thermal.c
|
||||
+++ b/drivers/thermal/mediatek/auxadc_thermal.c
|
||||
@@ -1210,7 +1210,7 @@ static int mtk_thermal_probe(struct plat
|
||||
goto err_disable_clk_peri_therm;
|
||||
}
|
||||
|
||||
- ret = devm_thermal_add_hwmon_sysfs(tzdev);
|
||||
+ ret = devm_thermal_add_hwmon_sysfs(&pdev->dev, tzdev);
|
||||
if (ret)
|
||||
dev_warn(&pdev->dev, "error in thermal_add_hwmon_sysfs");
|
||||
|
||||
--- a/drivers/thermal/qcom/qcom-spmi-adc-tm5.c
|
||||
+++ b/drivers/thermal/qcom/qcom-spmi-adc-tm5.c
|
||||
@@ -688,7 +688,7 @@ static int adc_tm5_register_tzd(struct a
|
||||
return PTR_ERR(tzd);
|
||||
}
|
||||
adc_tm->channels[i].tzd = tzd;
|
||||
- if (devm_thermal_add_hwmon_sysfs(tzd))
|
||||
+ if (devm_thermal_add_hwmon_sysfs(adc_tm->dev, tzd))
|
||||
dev_warn(adc_tm->dev,
|
||||
"Failed to add hwmon sysfs attributes\n");
|
||||
}
|
||||
--- a/drivers/thermal/qcom/qcom-spmi-temp-alarm.c
|
||||
+++ b/drivers/thermal/qcom/qcom-spmi-temp-alarm.c
|
||||
@@ -460,7 +460,7 @@ static int qpnp_tm_probe(struct platform
|
||||
return ret;
|
||||
}
|
||||
|
||||
- if (devm_thermal_add_hwmon_sysfs(chip->tz_dev))
|
||||
+ if (devm_thermal_add_hwmon_sysfs(&pdev->dev, chip->tz_dev))
|
||||
dev_warn(&pdev->dev,
|
||||
"Failed to add hwmon sysfs attributes\n");
|
||||
|
||||
--- a/drivers/thermal/qcom/tsens.c
|
||||
+++ b/drivers/thermal/qcom/tsens.c
|
||||
@@ -1056,7 +1056,7 @@ static int tsens_register(struct tsens_p
|
||||
if (priv->ops->enable)
|
||||
priv->ops->enable(priv, i);
|
||||
|
||||
- if (devm_thermal_add_hwmon_sysfs(tzd))
|
||||
+ if (devm_thermal_add_hwmon_sysfs(priv->dev, tzd))
|
||||
dev_warn(priv->dev,
|
||||
"Failed to add hwmon sysfs attributes\n");
|
||||
}
|
||||
--- a/drivers/thermal/qoriq_thermal.c
|
||||
+++ b/drivers/thermal/qoriq_thermal.c
|
||||
@@ -158,7 +158,7 @@ static int qoriq_tmu_register_tmu_zone(s
|
||||
return ret;
|
||||
}
|
||||
|
||||
- if (devm_thermal_add_hwmon_sysfs(tzd))
|
||||
+ if (devm_thermal_add_hwmon_sysfs(dev, tzd))
|
||||
dev_warn(dev,
|
||||
"Failed to add hwmon sysfs attributes\n");
|
||||
|
||||
--- a/drivers/thermal/sun8i_thermal.c
|
||||
+++ b/drivers/thermal/sun8i_thermal.c
|
||||
@@ -468,7 +468,7 @@ static int sun8i_ths_register(struct ths
|
||||
if (IS_ERR(tmdev->sensor[i].tzd))
|
||||
return PTR_ERR(tmdev->sensor[i].tzd);
|
||||
|
||||
- if (devm_thermal_add_hwmon_sysfs(tmdev->sensor[i].tzd))
|
||||
+ if (devm_thermal_add_hwmon_sysfs(tmdev->dev, tmdev->sensor[i].tzd))
|
||||
dev_warn(tmdev->dev,
|
||||
"Failed to add hwmon sysfs attributes\n");
|
||||
}
|
||||
--- a/drivers/thermal/tegra/tegra30-tsensor.c
|
||||
+++ b/drivers/thermal/tegra/tegra30-tsensor.c
|
||||
@@ -530,7 +530,7 @@ static int tegra_tsensor_register_channe
|
||||
return 0;
|
||||
}
|
||||
|
||||
- if (devm_thermal_add_hwmon_sysfs(tsc->tzd))
|
||||
+ if (devm_thermal_add_hwmon_sysfs(ts->dev, tsc->tzd))
|
||||
dev_warn(ts->dev, "failed to add hwmon sysfs attributes\n");
|
||||
|
||||
return 0;
|
||||
--- a/drivers/thermal/thermal_hwmon.c
|
||||
+++ b/drivers/thermal/thermal_hwmon.c
|
||||
@@ -255,7 +255,7 @@ static void devm_thermal_hwmon_release(s
|
||||
thermal_remove_hwmon_sysfs(*(struct thermal_zone_device **)res);
|
||||
}
|
||||
|
||||
-int devm_thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
|
||||
+int devm_thermal_add_hwmon_sysfs(struct device *dev, struct thermal_zone_device *tz)
|
||||
{
|
||||
struct thermal_zone_device **ptr;
|
||||
int ret;
|
||||
@@ -272,7 +272,7 @@ int devm_thermal_add_hwmon_sysfs(struct
|
||||
}
|
||||
|
||||
*ptr = tz;
|
||||
- devres_add(&tz->device, ptr);
|
||||
+ devres_add(dev, ptr);
|
||||
|
||||
return ret;
|
||||
}
|
||||
--- a/drivers/thermal/thermal_hwmon.h
|
||||
+++ b/drivers/thermal/thermal_hwmon.h
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
#ifdef CONFIG_THERMAL_HWMON
|
||||
int thermal_add_hwmon_sysfs(struct thermal_zone_device *tz);
|
||||
-int devm_thermal_add_hwmon_sysfs(struct thermal_zone_device *tz);
|
||||
+int devm_thermal_add_hwmon_sysfs(struct device *dev, struct thermal_zone_device *tz);
|
||||
void thermal_remove_hwmon_sysfs(struct thermal_zone_device *tz);
|
||||
#else
|
||||
static inline int
|
||||
@@ -27,7 +27,7 @@ thermal_add_hwmon_sysfs(struct thermal_z
|
||||
}
|
||||
|
||||
static inline int
|
||||
-devm_thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
|
||||
+devm_thermal_add_hwmon_sysfs(struct device *dev, struct thermal_zone_device *tz)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
--- a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
|
||||
+++ b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
|
||||
@@ -182,7 +182,7 @@ int ti_thermal_expose_sensor(struct ti_b
|
||||
ti_bandgap_set_sensor_data(bgp, id, data);
|
||||
ti_bandgap_write_update_interval(bgp, data->sensor_id, interval);
|
||||
|
||||
- if (devm_thermal_add_hwmon_sysfs(data->ti_thermal))
|
||||
+ if (devm_thermal_add_hwmon_sysfs(bgp->dev, data->ti_thermal))
|
||||
dev_warn(bgp->dev, "failed to add hwmon sysfs attributes\n");
|
||||
|
||||
return 0;
|
@ -1,79 +0,0 @@
|
||||
From 5a72b8e4bac753e4dc74dc0a1335d120f63df97a Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Lezcano <daniel.lezcano@linaro.org>
|
||||
Date: Wed, 1 Mar 2023 21:14:37 +0100
|
||||
Subject: [PATCH 09/42] thermal: Don't use 'device' internal thermal zone
|
||||
structure field
|
||||
|
||||
Some drivers are directly using the thermal zone's 'device' structure
|
||||
field.
|
||||
|
||||
Use the driver device pointer instead of the thermal zone device when
|
||||
it is available.
|
||||
|
||||
Remove the traces when they are duplicate with the traces in the core
|
||||
code.
|
||||
|
||||
[again skipped imx_thermal.c]
|
||||
|
||||
Cc: Jean Delvare <jdelvare@suse.com>
|
||||
Cc: Guenter Roeck <linux@roeck-us.net>
|
||||
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|
||||
Reviewed-by: Balsam CHIHI <bchihi@baylibre.com> #Mediatek LVTS
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> #MediaTek LVTS
|
||||
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
|
||||
---
|
||||
drivers/thermal/mediatek/lvts_thermal.c | 4 ++--
|
||||
drivers/thermal/thermal_hwmon.c | 4 ++--
|
||||
drivers/thermal/ti-soc-thermal/ti-thermal-common.c | 2 +-
|
||||
3 files changed, 5 insertions(+), 5 deletions(-)
|
||||
|
||||
--- a/drivers/thermal/mediatek/lvts_thermal.c
|
||||
+++ b/drivers/thermal/mediatek/lvts_thermal.c
|
||||
@@ -305,7 +305,7 @@ static int lvts_set_trips(struct thermal
|
||||
* 14-0 : Raw temperature for threshold
|
||||
*/
|
||||
if (low != -INT_MAX) {
|
||||
- dev_dbg(&tz->device, "Setting low limit temperature interrupt: %d\n", low);
|
||||
+ pr_debug("%s: Setting low limit temperature interrupt: %d\n", tz->type, low);
|
||||
writel(raw_low, LVTS_H2NTHRE(base));
|
||||
}
|
||||
|
||||
@@ -318,7 +318,7 @@ static int lvts_set_trips(struct thermal
|
||||
*
|
||||
* 14-0 : Raw temperature for threshold
|
||||
*/
|
||||
- dev_dbg(&tz->device, "Setting high limit temperature interrupt: %d\n", high);
|
||||
+ pr_debug("%s: Setting high limit temperature interrupt: %d\n", tz->type, high);
|
||||
writel(raw_high, LVTS_HTHRE(base));
|
||||
|
||||
return 0;
|
||||
--- a/drivers/thermal/thermal_hwmon.c
|
||||
+++ b/drivers/thermal/thermal_hwmon.c
|
||||
@@ -220,14 +220,14 @@ void thermal_remove_hwmon_sysfs(struct t
|
||||
hwmon = thermal_hwmon_lookup_by_type(tz);
|
||||
if (unlikely(!hwmon)) {
|
||||
/* Should never happen... */
|
||||
- dev_dbg(&tz->device, "hwmon device lookup failed!\n");
|
||||
+ dev_dbg(hwmon->device, "hwmon device lookup failed!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
temp = thermal_hwmon_lookup_temp(hwmon, tz);
|
||||
if (unlikely(!temp)) {
|
||||
/* Should never happen... */
|
||||
- dev_dbg(&tz->device, "temperature input lookup failed!\n");
|
||||
+ dev_dbg(hwmon->device, "temperature input lookup failed!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
--- a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
|
||||
+++ b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
|
||||
@@ -43,7 +43,7 @@ static void ti_thermal_work(struct work_
|
||||
|
||||
thermal_zone_device_update(data->ti_thermal, THERMAL_EVENT_UNSPECIFIED);
|
||||
|
||||
- dev_dbg(&data->ti_thermal->device, "updated thermal zone %s\n",
|
||||
+ dev_dbg(data->bgp->dev, "updated thermal zone %s\n",
|
||||
data->ti_thermal->type);
|
||||
}
|
||||
|
@ -1,62 +0,0 @@
|
||||
From 66b3a292d3fc749e8ec7ac5278a17e8a5757ecbc Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Lezcano <daniel.lezcano@linaro.org>
|
||||
Date: Wed, 1 Mar 2023 21:14:41 +0100
|
||||
Subject: [PATCH 10/42] thermal: Use thermal_zone_device_type() accessor
|
||||
|
||||
Replace the accesses to 'tz->type' by its accessor version in order to
|
||||
self-encapsulate the thermal_zone_device structure.
|
||||
|
||||
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|
||||
Reviewed-by: Ido Schimmel <idosch@nvidia.com> #mlxsw
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> #MediaTek LVTS
|
||||
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
|
||||
---
|
||||
drivers/net/ethernet/mellanox/mlxsw/core_thermal.c | 2 +-
|
||||
drivers/thermal/mediatek/lvts_thermal.c | 6 ++++--
|
||||
drivers/thermal/ti-soc-thermal/ti-thermal-common.c | 2 +-
|
||||
3 files changed, 6 insertions(+), 4 deletions(-)
|
||||
|
||||
--- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
|
||||
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
|
||||
@@ -168,7 +168,7 @@ mlxsw_thermal_module_trips_update(struct
|
||||
|
||||
if (crit_temp > emerg_temp) {
|
||||
dev_warn(dev, "%s : Critical threshold %d is above emergency threshold %d\n",
|
||||
- tz->tzdev->type, crit_temp, emerg_temp);
|
||||
+ thermal_zone_device_type(tz->tzdev), crit_temp, emerg_temp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
--- a/drivers/thermal/mediatek/lvts_thermal.c
|
||||
+++ b/drivers/thermal/mediatek/lvts_thermal.c
|
||||
@@ -305,7 +305,8 @@ static int lvts_set_trips(struct thermal
|
||||
* 14-0 : Raw temperature for threshold
|
||||
*/
|
||||
if (low != -INT_MAX) {
|
||||
- pr_debug("%s: Setting low limit temperature interrupt: %d\n", tz->type, low);
|
||||
+ pr_debug("%s: Setting low limit temperature interrupt: %d\n",
|
||||
+ thermal_zone_device_type(tz), low);
|
||||
writel(raw_low, LVTS_H2NTHRE(base));
|
||||
}
|
||||
|
||||
@@ -318,7 +319,8 @@ static int lvts_set_trips(struct thermal
|
||||
*
|
||||
* 14-0 : Raw temperature for threshold
|
||||
*/
|
||||
- pr_debug("%s: Setting high limit temperature interrupt: %d\n", tz->type, high);
|
||||
+ pr_debug("%s: Setting high limit temperature interrupt: %d\n",
|
||||
+ thermal_zone_device_type(tz), high);
|
||||
writel(raw_high, LVTS_HTHRE(base));
|
||||
|
||||
return 0;
|
||||
--- a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
|
||||
+++ b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
|
||||
@@ -44,7 +44,7 @@ static void ti_thermal_work(struct work_
|
||||
thermal_zone_device_update(data->ti_thermal, THERMAL_EVENT_UNSPECIFIED);
|
||||
|
||||
dev_dbg(data->bgp->dev, "updated thermal zone %s\n",
|
||||
- data->ti_thermal->type);
|
||||
+ thermal_zone_device_type(data->ti_thermal));
|
||||
}
|
||||
|
||||
/**
|
@ -1,81 +0,0 @@
|
||||
From f6658c1c4ae98477d6be00495226c0617354fe76 Mon Sep 17 00:00:00 2001
|
||||
From: Markus Schneider-Pargmann <msp@baylibre.com>
|
||||
Date: Fri, 27 Jan 2023 16:44:43 +0100
|
||||
Subject: [PATCH 11/42] thermal/drivers/mediatek: Control buffer enablement
|
||||
tweaks
|
||||
|
||||
Add logic in order to be able to turn on the control buffer on MT8365.
|
||||
This change now allows to have control buffer support for MTK_THERMAL_V1,
|
||||
and it allows to define the register offset, and mask used to enable it.
|
||||
|
||||
Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com>
|
||||
Signed-off-by: Fabien Parent <fparent@baylibre.com>
|
||||
Signed-off-by: Amjad Ouled-Ameur <aouledameur@baylibre.com>
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Link: https://lore.kernel.org/r/20221018-up-i350-thermal-bringup-v9-2-55a1ae14af74@baylibre.com
|
||||
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|
||||
---
|
||||
drivers/thermal/mediatek/auxadc_thermal.c | 28 +++++++++++++++--------
|
||||
1 file changed, 19 insertions(+), 9 deletions(-)
|
||||
|
||||
--- a/drivers/thermal/mediatek/auxadc_thermal.c
|
||||
+++ b/drivers/thermal/mediatek/auxadc_thermal.c
|
||||
@@ -307,6 +307,9 @@ struct mtk_thermal_data {
|
||||
bool need_switch_bank;
|
||||
struct thermal_bank_cfg bank_data[MAX_NUM_ZONES];
|
||||
enum mtk_thermal_version version;
|
||||
+ u32 apmixed_buffer_ctl_reg;
|
||||
+ u32 apmixed_buffer_ctl_mask;
|
||||
+ u32 apmixed_buffer_ctl_set;
|
||||
};
|
||||
|
||||
struct mtk_thermal {
|
||||
@@ -560,6 +563,9 @@ static const struct mtk_thermal_data mt7
|
||||
.adcpnp = mt7622_adcpnp,
|
||||
.sensor_mux_values = mt7622_mux_values,
|
||||
.version = MTK_THERMAL_V2,
|
||||
+ .apmixed_buffer_ctl_reg = APMIXED_SYS_TS_CON1,
|
||||
+ .apmixed_buffer_ctl_mask = GENMASK(31, 6) | BIT(3),
|
||||
+ .apmixed_buffer_ctl_set = BIT(0),
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -1079,14 +1085,18 @@ static const struct of_device_id mtk_the
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, mtk_thermal_of_match);
|
||||
|
||||
-static void mtk_thermal_turn_on_buffer(void __iomem *apmixed_base)
|
||||
+static void mtk_thermal_turn_on_buffer(struct mtk_thermal *mt,
|
||||
+ void __iomem *apmixed_base)
|
||||
{
|
||||
- int tmp;
|
||||
+ u32 tmp;
|
||||
+
|
||||
+ if (!mt->conf->apmixed_buffer_ctl_reg)
|
||||
+ return;
|
||||
|
||||
- tmp = readl(apmixed_base + APMIXED_SYS_TS_CON1);
|
||||
- tmp &= ~(0x37);
|
||||
- tmp |= 0x1;
|
||||
- writel(tmp, apmixed_base + APMIXED_SYS_TS_CON1);
|
||||
+ tmp = readl(apmixed_base + mt->conf->apmixed_buffer_ctl_reg);
|
||||
+ tmp &= mt->conf->apmixed_buffer_ctl_mask;
|
||||
+ tmp |= mt->conf->apmixed_buffer_ctl_set;
|
||||
+ writel(tmp, apmixed_base + mt->conf->apmixed_buffer_ctl_reg);
|
||||
udelay(200);
|
||||
}
|
||||
|
||||
@@ -1184,10 +1194,10 @@ static int mtk_thermal_probe(struct plat
|
||||
goto err_disable_clk_auxadc;
|
||||
}
|
||||
|
||||
- if (mt->conf->version != MTK_THERMAL_V1) {
|
||||
- mtk_thermal_turn_on_buffer(apmixed_base);
|
||||
+ mtk_thermal_turn_on_buffer(mt, apmixed_base);
|
||||
+
|
||||
+ if (mt->conf->version != MTK_THERMAL_V2)
|
||||
mtk_thermal_release_periodic_ts(mt, auxadc_base);
|
||||
- }
|
||||
|
||||
if (mt->conf->version == MTK_THERMAL_V1)
|
||||
mt->raw_to_mcelsius = raw_to_mcelsius_v1;
|
@ -1,123 +0,0 @@
|
||||
From c4eff784465f88218dc5eb51320320464db83d3f Mon Sep 17 00:00:00 2001
|
||||
From: Fabien Parent <fparent@baylibre.com>
|
||||
Date: Fri, 27 Jan 2023 16:44:44 +0100
|
||||
Subject: [PATCH 12/42] thermal/drivers/mediatek: Add support for MT8365 SoC
|
||||
|
||||
MT8365 is similar to the other SoCs supported by the driver. It has only
|
||||
one bank and 3 actual sensors that can be multiplexed. There is another
|
||||
one sensor that does not have usable data.
|
||||
|
||||
Signed-off-by: Fabien Parent <fparent@baylibre.com>
|
||||
Signed-off-by: Amjad Ouled-Ameur <aouledameur@baylibre.com>
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Link: https://lore.kernel.org/r/20221018-up-i350-thermal-bringup-v9-3-55a1ae14af74@baylibre.com
|
||||
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|
||||
---
|
||||
drivers/thermal/mediatek/auxadc_thermal.c | 68 +++++++++++++++++++++++
|
||||
1 file changed, 68 insertions(+)
|
||||
|
||||
--- a/drivers/thermal/mediatek/auxadc_thermal.c
|
||||
+++ b/drivers/thermal/mediatek/auxadc_thermal.c
|
||||
@@ -31,6 +31,7 @@
|
||||
#define AUXADC_CON2_V 0x010
|
||||
#define AUXADC_DATA(channel) (0x14 + (channel) * 4)
|
||||
|
||||
+#define APMIXED_SYS_TS_CON0 0x600
|
||||
#define APMIXED_SYS_TS_CON1 0x604
|
||||
|
||||
/* Thermal Controller Registers */
|
||||
@@ -281,6 +282,17 @@ enum mtk_thermal_version {
|
||||
/* The calibration coefficient of sensor */
|
||||
#define MT7986_CALIBRATION 165
|
||||
|
||||
+/* MT8365 */
|
||||
+#define MT8365_TEMP_AUXADC_CHANNEL 11
|
||||
+#define MT8365_CALIBRATION 164
|
||||
+#define MT8365_NUM_CONTROLLER 1
|
||||
+#define MT8365_NUM_BANKS 1
|
||||
+#define MT8365_NUM_SENSORS 3
|
||||
+#define MT8365_NUM_SENSORS_PER_ZONE 3
|
||||
+#define MT8365_TS1 0
|
||||
+#define MT8365_TS2 1
|
||||
+#define MT8365_TS3 2
|
||||
+
|
||||
struct mtk_thermal;
|
||||
|
||||
struct thermal_bank_cfg {
|
||||
@@ -435,6 +447,24 @@ static const int mt7986_mux_values[MT798
|
||||
static const int mt7986_vts_index[MT7986_NUM_SENSORS] = { VTS1 };
|
||||
static const int mt7986_tc_offset[MT7986_NUM_CONTROLLER] = { 0x0, };
|
||||
|
||||
+/* MT8365 thermal sensor data */
|
||||
+static const int mt8365_bank_data[MT8365_NUM_SENSORS] = {
|
||||
+ MT8365_TS1, MT8365_TS2, MT8365_TS3
|
||||
+};
|
||||
+
|
||||
+static const int mt8365_msr[MT8365_NUM_SENSORS_PER_ZONE] = {
|
||||
+ TEMP_MSR0, TEMP_MSR1, TEMP_MSR2
|
||||
+};
|
||||
+
|
||||
+static const int mt8365_adcpnp[MT8365_NUM_SENSORS_PER_ZONE] = {
|
||||
+ TEMP_ADCPNP0, TEMP_ADCPNP1, TEMP_ADCPNP2
|
||||
+};
|
||||
+
|
||||
+static const int mt8365_mux_values[MT8365_NUM_SENSORS] = { 0, 1, 2 };
|
||||
+static const int mt8365_tc_offset[MT8365_NUM_CONTROLLER] = { 0 };
|
||||
+
|
||||
+static const int mt8365_vts_index[MT8365_NUM_SENSORS] = { VTS1, VTS2, VTS3 };
|
||||
+
|
||||
/*
|
||||
* The MT8173 thermal controller has four banks. Each bank can read up to
|
||||
* four temperature sensors simultaneously. The MT8173 has a total of 5
|
||||
@@ -510,6 +540,40 @@ static const struct mtk_thermal_data mt2
|
||||
};
|
||||
|
||||
/*
|
||||
+ * The MT8365 thermal controller has one bank, which can read up to
|
||||
+ * four temperature sensors simultaneously. The MT8365 has a total of 3
|
||||
+ * temperature sensors.
|
||||
+ *
|
||||
+ * The thermal core only gets the maximum temperature of this one bank,
|
||||
+ * so the bank concept wouldn't be necessary here. However, the SVS (Smart
|
||||
+ * Voltage Scaling) unit makes its decisions based on the same bank
|
||||
+ * data.
|
||||
+ */
|
||||
+static const struct mtk_thermal_data mt8365_thermal_data = {
|
||||
+ .auxadc_channel = MT8365_TEMP_AUXADC_CHANNEL,
|
||||
+ .num_banks = MT8365_NUM_BANKS,
|
||||
+ .num_sensors = MT8365_NUM_SENSORS,
|
||||
+ .vts_index = mt8365_vts_index,
|
||||
+ .cali_val = MT8365_CALIBRATION,
|
||||
+ .num_controller = MT8365_NUM_CONTROLLER,
|
||||
+ .controller_offset = mt8365_tc_offset,
|
||||
+ .need_switch_bank = false,
|
||||
+ .bank_data = {
|
||||
+ {
|
||||
+ .num_sensors = MT8365_NUM_SENSORS,
|
||||
+ .sensors = mt8365_bank_data
|
||||
+ },
|
||||
+ },
|
||||
+ .msr = mt8365_msr,
|
||||
+ .adcpnp = mt8365_adcpnp,
|
||||
+ .sensor_mux_values = mt8365_mux_values,
|
||||
+ .version = MTK_THERMAL_V1,
|
||||
+ .apmixed_buffer_ctl_reg = APMIXED_SYS_TS_CON0,
|
||||
+ .apmixed_buffer_ctl_mask = (u32) ~GENMASK(29, 28),
|
||||
+ .apmixed_buffer_ctl_set = 0,
|
||||
+};
|
||||
+
|
||||
+/*
|
||||
* The MT2712 thermal controller has one bank, which can read up to
|
||||
* four temperature sensors simultaneously. The MT2712 has a total of 4
|
||||
* temperature sensors.
|
||||
@@ -1080,6 +1144,10 @@ static const struct of_device_id mtk_the
|
||||
{
|
||||
.compatible = "mediatek,mt8183-thermal",
|
||||
.data = (void *)&mt8183_thermal_data,
|
||||
+ },
|
||||
+ {
|
||||
+ .compatible = "mediatek,mt8365-thermal",
|
||||
+ .data = (void *)&mt8365_thermal_data,
|
||||
}, {
|
||||
},
|
||||
};
|
@ -1,50 +0,0 @@
|
||||
From 4eead70db74922bc61e9d0b4591524369a335751 Mon Sep 17 00:00:00 2001
|
||||
From: Amjad Ouled-Ameur <aouledameur@baylibre.com>
|
||||
Date: Fri, 27 Jan 2023 16:44:46 +0100
|
||||
Subject: [PATCH 13/42] thermal/drivers/mediatek: Add delay after thermal banks
|
||||
initialization
|
||||
|
||||
Thermal sensor reads performed immediately after thermal bank
|
||||
initialization returns bogus values. This is currently tackled by returning
|
||||
0 if the temperature is bogus (exceeding 200000).
|
||||
|
||||
Instead, add a delay between the bank init and the thermal zone device
|
||||
register to properly fix this.
|
||||
|
||||
Signed-off-by: Michael Kao <michael.kao@mediatek.com>
|
||||
Signed-off-by: Hsin-Yi Wang <hsinyi@chromium.org>
|
||||
Signed-off-by: Amjad Ouled-Ameur <aouledameur@baylibre.com>
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Link: https://lore.kernel.org/r/20221018-up-i350-thermal-bringup-v9-5-55a1ae14af74@baylibre.com
|
||||
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|
||||
---
|
||||
drivers/thermal/mediatek/auxadc_thermal.c | 11 +++--------
|
||||
1 file changed, 3 insertions(+), 8 deletions(-)
|
||||
|
||||
--- a/drivers/thermal/mediatek/auxadc_thermal.c
|
||||
+++ b/drivers/thermal/mediatek/auxadc_thermal.c
|
||||
@@ -816,14 +816,6 @@ static int mtk_thermal_bank_temperature(
|
||||
mt, conf->bank_data[bank->id].sensors[i], raw);
|
||||
|
||||
|
||||
- /*
|
||||
- * The first read of a sensor often contains very high bogus
|
||||
- * temperature value. Filter these out so that the system does
|
||||
- * not immediately shut down.
|
||||
- */
|
||||
- if (temp > 200000)
|
||||
- temp = 0;
|
||||
-
|
||||
if (temp > max)
|
||||
max = temp;
|
||||
}
|
||||
@@ -1281,6 +1273,9 @@ static int mtk_thermal_probe(struct plat
|
||||
|
||||
platform_set_drvdata(pdev, mt);
|
||||
|
||||
+ /* Delay for thermal banks to be ready */
|
||||
+ msleep(30);
|
||||
+
|
||||
tzdev = devm_thermal_of_zone_register(&pdev->dev, 0, mt,
|
||||
&mtk_thermal_ops);
|
||||
if (IS_ERR(tzdev)) {
|
@ -1,46 +0,0 @@
|
||||
From ad9dc9e92367803a4f9576aea0dab110d03fc510 Mon Sep 17 00:00:00 2001
|
||||
From: Chen-Yu Tsai <wenst@chromium.org>
|
||||
Date: Tue, 28 Mar 2023 11:10:17 +0800
|
||||
Subject: [PATCH 14/42] thermal/drivers/mediatek/lvts_thermal: Fix sensor 1
|
||||
interrupt status bitmask
|
||||
|
||||
The binary representation for sensor 1 interrupt status was incorrectly
|
||||
assembled, when compared to the full table given in the same comment
|
||||
section. The conversion into hex was also incorrect, leading to
|
||||
incorrect interrupt status bitmask for sensor 1. This would cause the
|
||||
driver to incorrectly identify changes for sensor 1, when in fact it
|
||||
was sensor 0, or a sensor access time out.
|
||||
|
||||
Fix the binary and hex representations in the comments, and the actual
|
||||
bitmask macro.
|
||||
|
||||
Fixes: f5f633b18234 ("thermal/drivers/mediatek: Add the Low Voltage Thermal Sensor driver")
|
||||
Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
|
||||
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20230328031017.1360976-1-wenst@chromium.org
|
||||
---
|
||||
drivers/thermal/mediatek/lvts_thermal.c | 6 +++---
|
||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
--- a/drivers/thermal/mediatek/lvts_thermal.c
|
||||
+++ b/drivers/thermal/mediatek/lvts_thermal.c
|
||||
@@ -66,7 +66,7 @@
|
||||
#define LVTS_MONINT_CONF 0x9FBF7BDE
|
||||
|
||||
#define LVTS_INT_SENSOR0 0x0009001F
|
||||
-#define LVTS_INT_SENSOR1 0X000881F0
|
||||
+#define LVTS_INT_SENSOR1 0x001203E0
|
||||
#define LVTS_INT_SENSOR2 0x00247C00
|
||||
#define LVTS_INT_SENSOR3 0x1FC00000
|
||||
|
||||
@@ -395,8 +395,8 @@ static irqreturn_t lvts_ctrl_irq_handler
|
||||
* => 0x1FC00000
|
||||
* sensor 2 interrupt: 0000 0000 0010 0100 0111 1100 0000 0000
|
||||
* => 0x00247C00
|
||||
- * sensor 1 interrupt: 0000 0000 0001 0001 0000 0011 1110 0000
|
||||
- * => 0X000881F0
|
||||
+ * sensor 1 interrupt: 0000 0000 0001 0010 0000 0011 1110 0000
|
||||
+ * => 0X001203E0
|
||||
* sensor 0 interrupt: 0000 0000 0000 1001 0000 0000 0001 1111
|
||||
* => 0x0009001F
|
||||
*/
|
@ -1,149 +0,0 @@
|
||||
From 9aad43ad3285fc21158fb416830a6156a9a31fa5 Mon Sep 17 00:00:00 2001
|
||||
From: Balsam CHIHI <bchihi@baylibre.com>
|
||||
Date: Tue, 7 Mar 2023 16:45:22 +0100
|
||||
Subject: [PATCH 15/42] thermal/drivers/mediatek/lvts_thermal: Add AP domain
|
||||
for mt8195
|
||||
|
||||
Add MT8195 AP Domain support to LVTS Driver.
|
||||
|
||||
Take the opportunity to update the comments to show calibration data
|
||||
information related to the new domain.
|
||||
|
||||
[dlezcano]: Massaged a bit the changelog
|
||||
|
||||
Signed-off-by: Balsam CHIHI <bchihi@baylibre.com>
|
||||
Tested-by: Chen-Yu Tsai <wenst@chromium.org>
|
||||
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20230307154524.118541-3-bchihi@baylibre.com
|
||||
---
|
||||
drivers/thermal/mediatek/lvts_thermal.c | 94 +++++++++++++++++++------
|
||||
1 file changed, 74 insertions(+), 20 deletions(-)
|
||||
|
||||
--- a/drivers/thermal/mediatek/lvts_thermal.c
|
||||
+++ b/drivers/thermal/mediatek/lvts_thermal.c
|
||||
@@ -530,29 +530,33 @@ static int lvts_sensor_init(struct devic
|
||||
* The efuse blob values follows the sensor enumeration per thermal
|
||||
* controller. The decoding of the stream is as follow:
|
||||
*
|
||||
- * <--?-> <----big0 ???---> <-sensor0-> <-0->
|
||||
- * ------------------------------------------
|
||||
- * index in the stream: : | 0x0 | 0x1 | 0x2 | 0x3 | 0x4 | 0x5 | 0x6 |
|
||||
- * ------------------------------------------
|
||||
+ * stream index map for MCU Domain :
|
||||
*
|
||||
- * <--sensor1--><-0-> <----big1 ???---> <-sen
|
||||
- * ------------------------------------------
|
||||
- * | 0x7 | 0x8 | 0x9 | 0xA | 0xB | OxC | OxD |
|
||||
- * ------------------------------------------
|
||||
+ * <-----mcu-tc#0-----> <-----sensor#0-----> <-----sensor#1----->
|
||||
+ * 0x01 | 0x02 | 0x03 | 0x04 | 0x05 | 0x06 | 0x07 | 0x08 | 0x09
|
||||
*
|
||||
- * sor0-> <-0-> <-sensor1-> <-0-> ..........
|
||||
- * ------------------------------------------
|
||||
- * | 0x7 | 0x8 | 0x9 | 0xA | 0xB | OxC | OxD |
|
||||
- * ------------------------------------------
|
||||
+ * <-----mcu-tc#1-----> <-----sensor#2-----> <-----sensor#3----->
|
||||
+ * 0x0A | 0x0B | 0x0C | 0x0D | 0x0E | 0x0F | 0x10 | 0x11 | 0x12
|
||||
*
|
||||
- * And so on ...
|
||||
+ * <-----mcu-tc#2-----> <-----sensor#4-----> <-----sensor#5-----> <-----sensor#6-----> <-----sensor#7----->
|
||||
+ * 0x13 | 0x14 | 0x15 | 0x16 | 0x17 | 0x18 | 0x19 | 0x1A | 0x1B | 0x1C | 0x1D | 0x1E | 0x1F | 0x20 | 0x21
|
||||
+ *
|
||||
+ * stream index map for AP Domain :
|
||||
+ *
|
||||
+ * <-----ap--tc#0-----> <-----sensor#0-----> <-----sensor#1----->
|
||||
+ * 0x22 | 0x23 | 0x24 | 0x25 | 0x26 | 0x27 | 0x28 | 0x29 | 0x2A
|
||||
+ *
|
||||
+ * <-----ap--tc#1-----> <-----sensor#2-----> <-----sensor#3----->
|
||||
+ * 0x2B | 0x2C | 0x2D | 0x2E | 0x2F | 0x30 | 0x31 | 0x32 | 0x33
|
||||
+ *
|
||||
+ * <-----ap--tc#2-----> <-----sensor#4-----> <-----sensor#5-----> <-----sensor#6----->
|
||||
+ * 0x34 | 0x35 | 0x36 | 0x37 | 0x38 | 0x39 | 0x3A | 0x3B | 0x3C | 0x3D | 0x3E | 0x3F
|
||||
+ *
|
||||
+ * <-----ap--tc#3-----> <-----sensor#7-----> <-----sensor#8----->
|
||||
+ * 0x40 | 0x41 | 0x42 | 0x43 | 0x44 | 0x45 | 0x46 | 0x47 | 0x48
|
||||
*
|
||||
* The data description gives the offset of the calibration data in
|
||||
* this bytes stream for each sensor.
|
||||
- *
|
||||
- * Each thermal controller can handle up to 4 sensors max, we don't
|
||||
- * care if there are less as the array of calibration is sized to 4
|
||||
- * anyway. The unused sensor slot will be zeroed.
|
||||
*/
|
||||
static int lvts_calibration_init(struct device *dev, struct lvts_ctrl *lvts_ctrl,
|
||||
const struct lvts_ctrl_data *lvts_ctrl_data,
|
||||
@@ -1165,7 +1169,7 @@ static int lvts_remove(struct platform_d
|
||||
return 0;
|
||||
}
|
||||
|
||||
-static const struct lvts_ctrl_data mt8195_lvts_data_ctrl[] = {
|
||||
+static const struct lvts_ctrl_data mt8195_lvts_mcu_data_ctrl[] = {
|
||||
{
|
||||
.cal_offset = { 0x04, 0x07 },
|
||||
.lvts_sensor = {
|
||||
@@ -1200,13 +1204,63 @@ static const struct lvts_ctrl_data mt819
|
||||
}
|
||||
};
|
||||
|
||||
+static const struct lvts_ctrl_data mt8195_lvts_ap_data_ctrl[] = {
|
||||
+ {
|
||||
+ .cal_offset = { 0x25, 0x28 },
|
||||
+ .lvts_sensor = {
|
||||
+ { .dt_id = MT8195_AP_VPU0 },
|
||||
+ { .dt_id = MT8195_AP_VPU1 }
|
||||
+ },
|
||||
+ .num_lvts_sensor = 2,
|
||||
+ .offset = 0x0,
|
||||
+ .hw_tshut_temp = LVTS_HW_SHUTDOWN_MT8195,
|
||||
+ },
|
||||
+ {
|
||||
+ .cal_offset = { 0x2e, 0x31 },
|
||||
+ .lvts_sensor = {
|
||||
+ { .dt_id = MT8195_AP_GPU0 },
|
||||
+ { .dt_id = MT8195_AP_GPU1 }
|
||||
+ },
|
||||
+ .num_lvts_sensor = 2,
|
||||
+ .offset = 0x100,
|
||||
+ .hw_tshut_temp = LVTS_HW_SHUTDOWN_MT8195,
|
||||
+ },
|
||||
+ {
|
||||
+ .cal_offset = { 0x37, 0x3a, 0x3d },
|
||||
+ .lvts_sensor = {
|
||||
+ { .dt_id = MT8195_AP_VDEC },
|
||||
+ { .dt_id = MT8195_AP_IMG },
|
||||
+ { .dt_id = MT8195_AP_INFRA },
|
||||
+ },
|
||||
+ .num_lvts_sensor = 3,
|
||||
+ .offset = 0x200,
|
||||
+ .hw_tshut_temp = LVTS_HW_SHUTDOWN_MT8195,
|
||||
+ },
|
||||
+ {
|
||||
+ .cal_offset = { 0x43, 0x46 },
|
||||
+ .lvts_sensor = {
|
||||
+ { .dt_id = MT8195_AP_CAM0 },
|
||||
+ { .dt_id = MT8195_AP_CAM1 }
|
||||
+ },
|
||||
+ .num_lvts_sensor = 2,
|
||||
+ .offset = 0x300,
|
||||
+ .hw_tshut_temp = LVTS_HW_SHUTDOWN_MT8195,
|
||||
+ }
|
||||
+};
|
||||
+
|
||||
static const struct lvts_data mt8195_lvts_mcu_data = {
|
||||
- .lvts_ctrl = mt8195_lvts_data_ctrl,
|
||||
- .num_lvts_ctrl = ARRAY_SIZE(mt8195_lvts_data_ctrl),
|
||||
+ .lvts_ctrl = mt8195_lvts_mcu_data_ctrl,
|
||||
+ .num_lvts_ctrl = ARRAY_SIZE(mt8195_lvts_mcu_data_ctrl),
|
||||
+};
|
||||
+
|
||||
+static const struct lvts_data mt8195_lvts_ap_data = {
|
||||
+ .lvts_ctrl = mt8195_lvts_ap_data_ctrl,
|
||||
+ .num_lvts_ctrl = ARRAY_SIZE(mt8195_lvts_ap_data_ctrl),
|
||||
};
|
||||
|
||||
static const struct of_device_id lvts_of_match[] = {
|
||||
{ .compatible = "mediatek,mt8195-lvts-mcu", .data = &mt8195_lvts_mcu_data },
|
||||
+ { .compatible = "mediatek,mt8195-lvts-ap", .data = &mt8195_lvts_ap_data },
|
||||
{},
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, lvts_of_match);
|
@ -1,53 +0,0 @@
|
||||
From 7105a86760bd9e4d107075cefc75016b693a5542 Mon Sep 17 00:00:00 2001
|
||||
From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Date: Wed, 19 Apr 2023 08:11:45 +0200
|
||||
Subject: [PATCH 16/42] Revert "thermal/drivers/mediatek: Add delay after
|
||||
thermal banks initialization"
|
||||
|
||||
Some more testing revealed that this commit introduces a regression on some
|
||||
MT8173 Chromebooks and at least on one MT6795 Sony Xperia M5 smartphone due
|
||||
to the delay being apparently variable and machine specific.
|
||||
|
||||
Another solution would be to delay for a bit more (~70ms) but this is not
|
||||
feasible for two reasons: first of all, we're adding an even bigger delay
|
||||
in a probe function; second, some machines need less, some may need even
|
||||
more, making the msleep at probe solution highly suboptimal.
|
||||
|
||||
This reverts commit 10debf8c2da8011c8009dd4b3f6d0ab85891c81b.
|
||||
|
||||
Fixes: 10debf8c2da8 ("thermal/drivers/mediatek: Add delay after thermal banks initialization")
|
||||
Reported-by: "kernelci.org bot" <bot@kernelci.org>
|
||||
Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20230419061146.22246-2-angelogioacchino.delregno@collabora.com
|
||||
---
|
||||
drivers/thermal/mediatek/auxadc_thermal.c | 11 ++++++++---
|
||||
1 file changed, 8 insertions(+), 3 deletions(-)
|
||||
|
||||
--- a/drivers/thermal/mediatek/auxadc_thermal.c
|
||||
+++ b/drivers/thermal/mediatek/auxadc_thermal.c
|
||||
@@ -816,6 +816,14 @@ static int mtk_thermal_bank_temperature(
|
||||
mt, conf->bank_data[bank->id].sensors[i], raw);
|
||||
|
||||
|
||||
+ /*
|
||||
+ * The first read of a sensor often contains very high bogus
|
||||
+ * temperature value. Filter these out so that the system does
|
||||
+ * not immediately shut down.
|
||||
+ */
|
||||
+ if (temp > 200000)
|
||||
+ temp = 0;
|
||||
+
|
||||
if (temp > max)
|
||||
max = temp;
|
||||
}
|
||||
@@ -1273,9 +1281,6 @@ static int mtk_thermal_probe(struct plat
|
||||
|
||||
platform_set_drvdata(pdev, mt);
|
||||
|
||||
- /* Delay for thermal banks to be ready */
|
||||
- msleep(30);
|
||||
-
|
||||
tzdev = devm_thermal_of_zone_register(&pdev->dev, 0, mt,
|
||||
&mtk_thermal_ops);
|
||||
if (IS_ERR(tzdev)) {
|
@ -1,78 +0,0 @@
|
||||
From 681b652c9dfc4037d4a55b2733e091a4e1a5de18 Mon Sep 17 00:00:00 2001
|
||||
From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Date: Wed, 19 Apr 2023 08:11:46 +0200
|
||||
Subject: [PATCH 17/42] thermal/drivers/mediatek: Add temperature constraints
|
||||
to validate read
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
The AUXADC thermal v1 allows reading temperature range between -20°C to
|
||||
150°C and any value out of this range is invalid.
|
||||
|
||||
Add new definitions for MT8173_TEMP_{MIN_MAX} and a new small helper
|
||||
mtk_thermal_temp_is_valid() to check if new readings are in range: if
|
||||
not, we tell to the API that the reading is invalid by returning
|
||||
THERMAL_TEMP_INVALID.
|
||||
|
||||
It was chosen to introduce the helper function because, even though this
|
||||
temperature range is realistically ok for all, it comes from a downstream
|
||||
kernel driver for version 1, but here we also support v2 and v3 which may
|
||||
may have wider constraints.
|
||||
|
||||
Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20230419061146.22246-3-angelogioacchino.delregno@collabora.com
|
||||
---
|
||||
drivers/thermal/mediatek/auxadc_thermal.c | 24 +++++++++++++++++------
|
||||
1 file changed, 18 insertions(+), 6 deletions(-)
|
||||
|
||||
--- a/drivers/thermal/mediatek/auxadc_thermal.c
|
||||
+++ b/drivers/thermal/mediatek/auxadc_thermal.c
|
||||
@@ -116,6 +116,10 @@
|
||||
/* The calibration coefficient of sensor */
|
||||
#define MT8173_CALIBRATION 165
|
||||
|
||||
+/* Valid temperatures range */
|
||||
+#define MT8173_TEMP_MIN -20000
|
||||
+#define MT8173_TEMP_MAX 150000
|
||||
+
|
||||
/*
|
||||
* Layout of the fuses providing the calibration data
|
||||
* These macros could be used for MT8183, MT8173, MT2701, and MT2712.
|
||||
@@ -689,6 +693,11 @@ static const struct mtk_thermal_data mt7
|
||||
.version = MTK_THERMAL_V3,
|
||||
};
|
||||
|
||||
+static bool mtk_thermal_temp_is_valid(int temp)
|
||||
+{
|
||||
+ return (temp >= MT8173_TEMP_MIN) && (temp <= MT8173_TEMP_MAX);
|
||||
+}
|
||||
+
|
||||
/**
|
||||
* raw_to_mcelsius_v1 - convert a raw ADC value to mcelsius
|
||||
* @mt: The thermal controller
|
||||
@@ -815,14 +824,17 @@ static int mtk_thermal_bank_temperature(
|
||||
temp = mt->raw_to_mcelsius(
|
||||
mt, conf->bank_data[bank->id].sensors[i], raw);
|
||||
|
||||
-
|
||||
/*
|
||||
- * The first read of a sensor often contains very high bogus
|
||||
- * temperature value. Filter these out so that the system does
|
||||
- * not immediately shut down.
|
||||
+ * Depending on the filt/sen intervals and ADC polling time,
|
||||
+ * we may need up to 60 milliseconds after initialization: this
|
||||
+ * will result in the first reading containing an out of range
|
||||
+ * temperature value.
|
||||
+ * Validate the reading to both address the aforementioned issue
|
||||
+ * and to eventually avoid bogus readings during runtime in the
|
||||
+ * event that the AUXADC gets unstable due to high EMI, etc.
|
||||
*/
|
||||
- if (temp > 200000)
|
||||
- temp = 0;
|
||||
+ if (!mtk_thermal_temp_is_valid(temp))
|
||||
+ temp = THERMAL_TEMP_INVALID;
|
||||
|
||||
if (temp > max)
|
||||
max = temp;
|
@ -1,53 +0,0 @@
|
||||
From 458fa1d508de3f17e49d974a0158d9aeff273a58 Mon Sep 17 00:00:00 2001
|
||||
From: Kang Chen <void0red@hust.edu.cn>
|
||||
Date: Wed, 19 Apr 2023 10:07:48 +0800
|
||||
Subject: [PATCH 18/42] thermal/drivers/mediatek: Use devm_of_iomap to avoid
|
||||
resource leak in mtk_thermal_probe
|
||||
|
||||
Smatch reports:
|
||||
1. mtk_thermal_probe() warn: 'apmixed_base' from of_iomap() not released.
|
||||
2. mtk_thermal_probe() warn: 'auxadc_base' from of_iomap() not released.
|
||||
|
||||
The original code forgets to release iomap resource when handling errors,
|
||||
fix it by switch to devm_of_iomap.
|
||||
|
||||
Fixes: 89945047b166 ("thermal: mediatek: Add tsensor support for V2 thermal system")
|
||||
Signed-off-by: Kang Chen <void0red@hust.edu.cn>
|
||||
Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn>
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20230419020749.621257-1-void0red@hust.edu.cn
|
||||
---
|
||||
drivers/thermal/mediatek/auxadc_thermal.c | 14 ++++++++++++--
|
||||
1 file changed, 12 insertions(+), 2 deletions(-)
|
||||
|
||||
--- a/drivers/thermal/mediatek/auxadc_thermal.c
|
||||
+++ b/drivers/thermal/mediatek/auxadc_thermal.c
|
||||
@@ -1232,7 +1232,12 @@ static int mtk_thermal_probe(struct plat
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
- auxadc_base = of_iomap(auxadc, 0);
|
||||
+ auxadc_base = devm_of_iomap(&pdev->dev, auxadc, 0, NULL);
|
||||
+ if (IS_ERR(auxadc_base)) {
|
||||
+ of_node_put(auxadc);
|
||||
+ return PTR_ERR(auxadc_base);
|
||||
+ }
|
||||
+
|
||||
auxadc_phys_base = of_get_phys_base(auxadc);
|
||||
|
||||
of_node_put(auxadc);
|
||||
@@ -1248,7 +1253,12 @@ static int mtk_thermal_probe(struct plat
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
- apmixed_base = of_iomap(apmixedsys, 0);
|
||||
+ apmixed_base = devm_of_iomap(&pdev->dev, apmixedsys, 0, NULL);
|
||||
+ if (IS_ERR(apmixed_base)) {
|
||||
+ of_node_put(apmixedsys);
|
||||
+ return PTR_ERR(apmixed_base);
|
||||
+ }
|
||||
+
|
||||
apmixed_phys_base = of_get_phys_base(apmixedsys);
|
||||
|
||||
of_node_put(apmixedsys);
|
@ -1,100 +0,0 @@
|
||||
From 227d1856924ec00a4f5bdf5afcf77bc7f3f04e86 Mon Sep 17 00:00:00 2001
|
||||
From: Kang Chen <void0red@hust.edu.cn>
|
||||
Date: Wed, 19 Apr 2023 10:07:49 +0800
|
||||
Subject: [PATCH 19/42] thermal/drivers/mediatek: Change clk_prepare_enable to
|
||||
devm_clk_get_enabled in mtk_thermal_probe
|
||||
|
||||
Use devm_clk_get_enabled to do automatic resource management.
|
||||
Meanwhile, remove error handling labels in the probe function and
|
||||
the whole remove function.
|
||||
|
||||
Signed-off-by: Kang Chen <void0red@hust.edu.cn>
|
||||
Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn>
|
||||
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20230419020749.621257-2-void0red@hust.edu.cn
|
||||
---
|
||||
drivers/thermal/mediatek/auxadc_thermal.c | 44 +++++------------------
|
||||
1 file changed, 9 insertions(+), 35 deletions(-)
|
||||
|
||||
--- a/drivers/thermal/mediatek/auxadc_thermal.c
|
||||
+++ b/drivers/thermal/mediatek/auxadc_thermal.c
|
||||
@@ -1206,14 +1206,6 @@ static int mtk_thermal_probe(struct plat
|
||||
|
||||
mt->conf = of_device_get_match_data(&pdev->dev);
|
||||
|
||||
- mt->clk_peri_therm = devm_clk_get(&pdev->dev, "therm");
|
||||
- if (IS_ERR(mt->clk_peri_therm))
|
||||
- return PTR_ERR(mt->clk_peri_therm);
|
||||
-
|
||||
- mt->clk_auxadc = devm_clk_get(&pdev->dev, "auxadc");
|
||||
- if (IS_ERR(mt->clk_auxadc))
|
||||
- return PTR_ERR(mt->clk_auxadc);
|
||||
-
|
||||
mt->thermal_base = devm_platform_get_and_ioremap_resource(pdev, 0, NULL);
|
||||
if (IS_ERR(mt->thermal_base))
|
||||
return PTR_ERR(mt->thermal_base);
|
||||
@@ -1272,16 +1264,18 @@ static int mtk_thermal_probe(struct plat
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
- ret = clk_prepare_enable(mt->clk_auxadc);
|
||||
- if (ret) {
|
||||
+ mt->clk_auxadc = devm_clk_get_enabled(&pdev->dev, "auxadc");
|
||||
+ if (IS_ERR(mt->clk_auxadc)) {
|
||||
+ ret = PTR_ERR(mt->clk_auxadc);
|
||||
dev_err(&pdev->dev, "Can't enable auxadc clk: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
- ret = clk_prepare_enable(mt->clk_peri_therm);
|
||||
- if (ret) {
|
||||
+ mt->clk_peri_therm = devm_clk_get_enabled(&pdev->dev, "therm");
|
||||
+ if (IS_ERR(mt->clk_peri_therm)) {
|
||||
+ ret = PTR_ERR(mt->clk_peri_therm);
|
||||
dev_err(&pdev->dev, "Can't enable peri clk: %d\n", ret);
|
||||
- goto err_disable_clk_auxadc;
|
||||
+ return ret;
|
||||
}
|
||||
|
||||
mtk_thermal_turn_on_buffer(mt, apmixed_base);
|
||||
@@ -1305,38 +1299,18 @@ static int mtk_thermal_probe(struct plat
|
||||
|
||||
tzdev = devm_thermal_of_zone_register(&pdev->dev, 0, mt,
|
||||
&mtk_thermal_ops);
|
||||
- if (IS_ERR(tzdev)) {
|
||||
- ret = PTR_ERR(tzdev);
|
||||
- goto err_disable_clk_peri_therm;
|
||||
- }
|
||||
+ if (IS_ERR(tzdev))
|
||||
+ return PTR_ERR(tzdev);
|
||||
|
||||
ret = devm_thermal_add_hwmon_sysfs(&pdev->dev, tzdev);
|
||||
if (ret)
|
||||
dev_warn(&pdev->dev, "error in thermal_add_hwmon_sysfs");
|
||||
|
||||
return 0;
|
||||
-
|
||||
-err_disable_clk_peri_therm:
|
||||
- clk_disable_unprepare(mt->clk_peri_therm);
|
||||
-err_disable_clk_auxadc:
|
||||
- clk_disable_unprepare(mt->clk_auxadc);
|
||||
-
|
||||
- return ret;
|
||||
-}
|
||||
-
|
||||
-static int mtk_thermal_remove(struct platform_device *pdev)
|
||||
-{
|
||||
- struct mtk_thermal *mt = platform_get_drvdata(pdev);
|
||||
-
|
||||
- clk_disable_unprepare(mt->clk_peri_therm);
|
||||
- clk_disable_unprepare(mt->clk_auxadc);
|
||||
-
|
||||
- return 0;
|
||||
}
|
||||
|
||||
static struct platform_driver mtk_thermal_driver = {
|
||||
.probe = mtk_thermal_probe,
|
||||
- .remove = mtk_thermal_remove,
|
||||
.driver = {
|
||||
.name = "mtk-thermal",
|
||||
.of_match_table = mtk_thermal_of_match,
|
@ -1,36 +0,0 @@
|
||||
From 655fe2533ac05323a07c19ba079bf2064e7741af Mon Sep 17 00:00:00 2001
|
||||
From: Rob Herring <robh@kernel.org>
|
||||
Date: Sun, 19 Mar 2023 11:32:31 -0500
|
||||
Subject: [PATCH 20/42] thermal/drivers/mediatek: Use of_address_to_resource()
|
||||
|
||||
Replace of_get_address() and of_translate_address() calls with single
|
||||
call to of_address_to_resource().
|
||||
|
||||
Signed-off-by: Rob Herring <robh@kernel.org>
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20230319163231.226738-1-robh@kernel.org
|
||||
---
|
||||
drivers/thermal/mediatek/auxadc_thermal.c | 8 +++-----
|
||||
1 file changed, 3 insertions(+), 5 deletions(-)
|
||||
|
||||
--- a/drivers/thermal/mediatek/auxadc_thermal.c
|
||||
+++ b/drivers/thermal/mediatek/auxadc_thermal.c
|
||||
@@ -979,14 +979,12 @@ static void mtk_thermal_init_bank(struct
|
||||
|
||||
static u64 of_get_phys_base(struct device_node *np)
|
||||
{
|
||||
- u64 size64;
|
||||
- const __be32 *regaddr_p;
|
||||
+ struct resource res;
|
||||
|
||||
- regaddr_p = of_get_address(np, 0, &size64, NULL);
|
||||
- if (!regaddr_p)
|
||||
+ if (of_address_to_resource(np, 0, &res))
|
||||
return OF_BAD_ADDR;
|
||||
|
||||
- return of_translate_address(np, regaddr_p);
|
||||
+ return res.start;
|
||||
}
|
||||
|
||||
static int mtk_thermal_extract_efuse_v1(struct mtk_thermal *mt, u32 *buf)
|
@ -1,57 +0,0 @@
|
||||
From 2c380d07215e6fce3ac66cc5af059bc2c2a69f7a Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Ricardo=20Ca=C3=B1uelo?= <ricardo.canuelo@collabora.com>
|
||||
Date: Thu, 25 May 2023 14:18:11 +0200
|
||||
Subject: [PATCH 21/42] Revert "thermal/drivers/mediatek: Use devm_of_iomap to
|
||||
avoid resource leak in mtk_thermal_probe"
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
This reverts commit f05c7b7d9ea9477fcc388476c6f4ade8c66d2d26.
|
||||
|
||||
That change was causing a regression in the generic-adc-thermal-probed
|
||||
bootrr test as reported in the kernelci-results list [1].
|
||||
A proper rework will take longer, so revert it for now.
|
||||
|
||||
[1] https://groups.io/g/kernelci-results/message/42660
|
||||
|
||||
Fixes: f05c7b7d9ea9 ("thermal/drivers/mediatek: Use devm_of_iomap to avoid resource leak in mtk_thermal_probe")
|
||||
Signed-off-by: Ricardo Cañuelo <ricardo.canuelo@collabora.com>
|
||||
Suggested-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20230525121811.3360268-1-ricardo.canuelo@collabora.com
|
||||
---
|
||||
drivers/thermal/mediatek/auxadc_thermal.c | 14 ++------------
|
||||
1 file changed, 2 insertions(+), 12 deletions(-)
|
||||
|
||||
--- a/drivers/thermal/mediatek/auxadc_thermal.c
|
||||
+++ b/drivers/thermal/mediatek/auxadc_thermal.c
|
||||
@@ -1222,12 +1222,7 @@ static int mtk_thermal_probe(struct plat
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
- auxadc_base = devm_of_iomap(&pdev->dev, auxadc, 0, NULL);
|
||||
- if (IS_ERR(auxadc_base)) {
|
||||
- of_node_put(auxadc);
|
||||
- return PTR_ERR(auxadc_base);
|
||||
- }
|
||||
-
|
||||
+ auxadc_base = of_iomap(auxadc, 0);
|
||||
auxadc_phys_base = of_get_phys_base(auxadc);
|
||||
|
||||
of_node_put(auxadc);
|
||||
@@ -1243,12 +1238,7 @@ static int mtk_thermal_probe(struct plat
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
- apmixed_base = devm_of_iomap(&pdev->dev, apmixedsys, 0, NULL);
|
||||
- if (IS_ERR(apmixed_base)) {
|
||||
- of_node_put(apmixedsys);
|
||||
- return PTR_ERR(apmixed_base);
|
||||
- }
|
||||
-
|
||||
+ apmixed_base = of_iomap(apmixedsys, 0);
|
||||
apmixed_phys_base = of_get_phys_base(apmixedsys);
|
||||
|
||||
of_node_put(apmixedsys);
|
@ -1,37 +0,0 @@
|
||||
From 496f4b08981d8a788ad5a2073fa1c65a2af1862b Mon Sep 17 00:00:00 2001
|
||||
From: Chen-Yu Tsai <wenst@chromium.org>
|
||||
Date: Tue, 13 Jun 2023 17:13:16 +0800
|
||||
Subject: [PATCH 22/42] thermal/drivers/mediatek/lvts_thermal: Register thermal
|
||||
zones as hwmon sensors
|
||||
|
||||
Register thermal zones as hwmon sensors to let userspace read
|
||||
temperatures using standard hwmon interface.
|
||||
|
||||
Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
|
||||
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20230613091317.1691247-1-wenst@chromium.org
|
||||
---
|
||||
drivers/thermal/mediatek/lvts_thermal.c | 5 +++++
|
||||
1 file changed, 5 insertions(+)
|
||||
|
||||
--- a/drivers/thermal/mediatek/lvts_thermal.c
|
||||
+++ b/drivers/thermal/mediatek/lvts_thermal.c
|
||||
@@ -19,6 +19,8 @@
|
||||
#include <linux/thermal.h>
|
||||
#include <dt-bindings/thermal/mediatek,lvts-thermal.h>
|
||||
|
||||
+#include "../thermal_hwmon.h"
|
||||
+
|
||||
#define LVTS_MONCTL0(__base) (__base + 0x0000)
|
||||
#define LVTS_MONCTL1(__base) (__base + 0x0004)
|
||||
#define LVTS_MONCTL2(__base) (__base + 0x0008)
|
||||
@@ -996,6 +998,9 @@ static int lvts_ctrl_start(struct device
|
||||
return PTR_ERR(tz);
|
||||
}
|
||||
|
||||
+ if (devm_thermal_add_hwmon_sysfs(dev, tz))
|
||||
+ dev_warn(dev, "zone %d: Failed to add hwmon sysfs attributes\n", dt_id);
|
||||
+
|
||||
/*
|
||||
* The thermal zone pointer will be needed in the
|
||||
* interrupt handler, we store it in the sensor
|
@ -1,28 +0,0 @@
|
||||
From 885b9768ce2a66ed5d250822aed53d5114c895da Mon Sep 17 00:00:00 2001
|
||||
From: Yangtao Li <frank.li@vivo.com>
|
||||
Date: Tue, 20 Jun 2023 17:07:31 +0800
|
||||
Subject: [PATCH 23/42] thermal/drivers/mediatek/lvts_thermal: Remove redundant
|
||||
msg in lvts_ctrl_start()
|
||||
|
||||
The upper-layer devm_thermal_add_hwmon_sysfs() function can directly
|
||||
print error information.
|
||||
|
||||
Signed-off-by: Yangtao Li <frank.li@vivo.com>
|
||||
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20230620090732.50025-10-frank.li@vivo.com
|
||||
---
|
||||
drivers/thermal/mediatek/lvts_thermal.c | 3 +--
|
||||
1 file changed, 1 insertion(+), 2 deletions(-)
|
||||
|
||||
--- a/drivers/thermal/mediatek/lvts_thermal.c
|
||||
+++ b/drivers/thermal/mediatek/lvts_thermal.c
|
||||
@@ -998,8 +998,7 @@ static int lvts_ctrl_start(struct device
|
||||
return PTR_ERR(tz);
|
||||
}
|
||||
|
||||
- if (devm_thermal_add_hwmon_sysfs(dev, tz))
|
||||
- dev_warn(dev, "zone %d: Failed to add hwmon sysfs attributes\n", dt_id);
|
||||
+ devm_thermal_add_hwmon_sysfs(dev, tz);
|
||||
|
||||
/*
|
||||
* The thermal zone pointer will be needed in the
|
@ -1,40 +0,0 @@
|
||||
From 27b389d9f62c2174f95fe4002b11e77d4cb3ce80 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?N=C3=ADcolas=20F=2E=20R=2E=20A=2E=20Prado?=
|
||||
<nfraprado@collabora.com>
|
||||
Date: Thu, 6 Jul 2023 11:37:32 -0400
|
||||
Subject: [PATCH 25/42] thermal/drivers/mediatek/lvts_thermal: Handle IRQ on
|
||||
all controllers
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
There is a single IRQ handler for each LVTS thermal domain, and it is
|
||||
supposed to check each of its underlying controllers for the origin of
|
||||
the interrupt and clear its status. However due to a typo, only the
|
||||
first controller was ever being handled, which resulted in the interrupt
|
||||
never being cleared when it happened on the other controllers. Add the
|
||||
missing index so interrupts are handled for all controllers.
|
||||
|
||||
Fixes: f5f633b18234 ("thermal/drivers/mediatek: Add the Low Voltage Thermal Sensor driver")
|
||||
Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Tested-by: Chen-Yu Tsai <wenst@chromium.org>
|
||||
Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
|
||||
Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com>
|
||||
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20230706153823.201943-2-nfraprado@collabora.com
|
||||
---
|
||||
drivers/thermal/mediatek/lvts_thermal.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/thermal/mediatek/lvts_thermal.c
|
||||
+++ b/drivers/thermal/mediatek/lvts_thermal.c
|
||||
@@ -451,7 +451,7 @@ static irqreturn_t lvts_irq_handler(int
|
||||
|
||||
for (i = 0; i < lvts_td->num_lvts_ctrl; i++) {
|
||||
|
||||
- aux = lvts_ctrl_irq_handler(lvts_td->lvts_ctrl);
|
||||
+ aux = lvts_ctrl_irq_handler(&lvts_td->lvts_ctrl[i]);
|
||||
if (aux != IRQ_HANDLED)
|
||||
continue;
|
||||
|
@ -1,120 +0,0 @@
|
||||
From 6d827142643ee10c13ff9a1d90f38fb399aa9fff Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?N=C3=ADcolas=20F=2E=20R=2E=20A=2E=20Prado?=
|
||||
<nfraprado@collabora.com>
|
||||
Date: Thu, 6 Jul 2023 11:37:33 -0400
|
||||
Subject: [PATCH 26/42] thermal/drivers/mediatek/lvts_thermal: Honor sensors in
|
||||
immediate mode
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Each controller can be configured to operate on immediate or filtered
|
||||
mode. On filtered mode, the sensors are enabled by setting the
|
||||
corresponding bits in MONCTL0, while on immediate mode, by setting
|
||||
MSRCTL1.
|
||||
|
||||
Previously, the code would set MSRCTL1 for all four sensors when
|
||||
configured to immediate mode, but given that the controller might not
|
||||
have all four sensors connected, this would cause interrupts to trigger
|
||||
for non-existent sensors. Fix this by handling the MSRCTL1 register
|
||||
analogously to the MONCTL0: only enable the sensors that were declared.
|
||||
|
||||
Fixes: f5f633b18234 ("thermal/drivers/mediatek: Add the Low Voltage Thermal Sensor driver")
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Tested-by: Chen-Yu Tsai <wenst@chromium.org>
|
||||
Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
|
||||
Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com>
|
||||
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20230706153823.201943-3-nfraprado@collabora.com
|
||||
---
|
||||
drivers/thermal/mediatek/lvts_thermal.c | 57 ++++++++++++++-----------
|
||||
1 file changed, 33 insertions(+), 24 deletions(-)
|
||||
|
||||
--- a/drivers/thermal/mediatek/lvts_thermal.c
|
||||
+++ b/drivers/thermal/mediatek/lvts_thermal.c
|
||||
@@ -897,24 +897,6 @@ static int lvts_ctrl_configure(struct de
|
||||
writel(value, LVTS_MSRCTL0(lvts_ctrl->base));
|
||||
|
||||
/*
|
||||
- * LVTS_MSRCTL1 : Measurement control
|
||||
- *
|
||||
- * Bits:
|
||||
- *
|
||||
- * 9: Ignore MSRCTL0 config and do immediate measurement on sensor3
|
||||
- * 6: Ignore MSRCTL0 config and do immediate measurement on sensor2
|
||||
- * 5: Ignore MSRCTL0 config and do immediate measurement on sensor1
|
||||
- * 4: Ignore MSRCTL0 config and do immediate measurement on sensor0
|
||||
- *
|
||||
- * That configuration will ignore the filtering and the delays
|
||||
- * introduced below in MONCTL1 and MONCTL2
|
||||
- */
|
||||
- if (lvts_ctrl->mode == LVTS_MSR_IMMEDIATE_MODE) {
|
||||
- value = BIT(9) | BIT(6) | BIT(5) | BIT(4);
|
||||
- writel(value, LVTS_MSRCTL1(lvts_ctrl->base));
|
||||
- }
|
||||
-
|
||||
- /*
|
||||
* LVTS_MONCTL1 : Period unit and group interval configuration
|
||||
*
|
||||
* The clock source of LVTS thermal controller is 26MHz.
|
||||
@@ -979,6 +961,15 @@ static int lvts_ctrl_start(struct device
|
||||
struct thermal_zone_device *tz;
|
||||
u32 sensor_map = 0;
|
||||
int i;
|
||||
+ /*
|
||||
+ * Bitmaps to enable each sensor on immediate and filtered modes, as
|
||||
+ * described in MSRCTL1 and MONCTL0 registers below, respectively.
|
||||
+ */
|
||||
+ u32 sensor_imm_bitmap[] = { BIT(4), BIT(5), BIT(6), BIT(9) };
|
||||
+ u32 sensor_filt_bitmap[] = { BIT(0), BIT(1), BIT(2), BIT(3) };
|
||||
+
|
||||
+ u32 *sensor_bitmap = lvts_ctrl->mode == LVTS_MSR_IMMEDIATE_MODE ?
|
||||
+ sensor_imm_bitmap : sensor_filt_bitmap;
|
||||
|
||||
for (i = 0; i < lvts_ctrl->num_lvts_sensor; i++) {
|
||||
|
||||
@@ -1016,20 +1007,38 @@ static int lvts_ctrl_start(struct device
|
||||
* map, so we can enable the temperature monitoring in
|
||||
* the hardware thermal controller.
|
||||
*/
|
||||
- sensor_map |= BIT(i);
|
||||
+ sensor_map |= sensor_bitmap[i];
|
||||
}
|
||||
|
||||
/*
|
||||
- * Bits:
|
||||
- * 9: Single point access flow
|
||||
- * 0-3: Enable sensing point 0-3
|
||||
- *
|
||||
* The initialization of the thermal zones give us
|
||||
* which sensor point to enable. If any thermal zone
|
||||
* was not described in the device tree, it won't be
|
||||
* enabled here in the sensor map.
|
||||
*/
|
||||
- writel(sensor_map | BIT(9), LVTS_MONCTL0(lvts_ctrl->base));
|
||||
+ if (lvts_ctrl->mode == LVTS_MSR_IMMEDIATE_MODE) {
|
||||
+ /*
|
||||
+ * LVTS_MSRCTL1 : Measurement control
|
||||
+ *
|
||||
+ * Bits:
|
||||
+ *
|
||||
+ * 9: Ignore MSRCTL0 config and do immediate measurement on sensor3
|
||||
+ * 6: Ignore MSRCTL0 config and do immediate measurement on sensor2
|
||||
+ * 5: Ignore MSRCTL0 config and do immediate measurement on sensor1
|
||||
+ * 4: Ignore MSRCTL0 config and do immediate measurement on sensor0
|
||||
+ *
|
||||
+ * That configuration will ignore the filtering and the delays
|
||||
+ * introduced in MONCTL1 and MONCTL2
|
||||
+ */
|
||||
+ writel(sensor_map, LVTS_MSRCTL1(lvts_ctrl->base));
|
||||
+ } else {
|
||||
+ /*
|
||||
+ * Bits:
|
||||
+ * 9: Single point access flow
|
||||
+ * 0-3: Enable sensing point 0-3
|
||||
+ */
|
||||
+ writel(sensor_map | BIT(9), LVTS_MONCTL0(lvts_ctrl->base));
|
||||
+ }
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,77 +0,0 @@
|
||||
From 93bb11dd19bdcc1fc97c7ceababd0db9fde128ad Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?N=C3=ADcolas=20F=2E=20R=2E=20A=2E=20Prado?=
|
||||
<nfraprado@collabora.com>
|
||||
Date: Thu, 6 Jul 2023 11:37:34 -0400
|
||||
Subject: [PATCH 27/42] thermal/drivers/mediatek/lvts_thermal: Use offset
|
||||
threshold for IRQ
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
There are two kinds of temperature monitoring interrupts available:
|
||||
* High Offset, Low Offset
|
||||
* Hot, Hot to normal, Cold
|
||||
|
||||
The code currently uses the hot/h2n/cold interrupts, however in a way
|
||||
that doesn't work: the cold threshold is left uninitialized, which
|
||||
prevents the other thresholds from ever triggering, and the h2n
|
||||
interrupt is used as the lower threshold, which prevents the hot
|
||||
interrupt from triggering again after the thresholds are updated by the
|
||||
thermal framework, since a hot interrupt can only trigger again after
|
||||
the hot to normal interrupt has been triggered.
|
||||
|
||||
But better yet than addressing those issues, is to use the high/low
|
||||
offset interrupts instead. This way only two thresholds need to be
|
||||
managed, which have a simpler state machine, making them a better match
|
||||
to the thermal framework's high and low thresholds.
|
||||
|
||||
Fixes: f5f633b18234 ("thermal/drivers/mediatek: Add the Low Voltage Thermal Sensor driver")
|
||||
Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
|
||||
Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com>
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20230706153823.201943-4-nfraprado@collabora.com
|
||||
---
|
||||
drivers/thermal/mediatek/lvts_thermal.c | 12 ++++++------
|
||||
1 file changed, 6 insertions(+), 6 deletions(-)
|
||||
|
||||
--- a/drivers/thermal/mediatek/lvts_thermal.c
|
||||
+++ b/drivers/thermal/mediatek/lvts_thermal.c
|
||||
@@ -298,9 +298,9 @@ static int lvts_set_trips(struct thermal
|
||||
u32 raw_high = lvts_temp_to_raw(high);
|
||||
|
||||
/*
|
||||
- * Hot to normal temperature threshold
|
||||
+ * Low offset temperature threshold
|
||||
*
|
||||
- * LVTS_H2NTHRE
|
||||
+ * LVTS_OFFSETL
|
||||
*
|
||||
* Bits:
|
||||
*
|
||||
@@ -309,13 +309,13 @@ static int lvts_set_trips(struct thermal
|
||||
if (low != -INT_MAX) {
|
||||
pr_debug("%s: Setting low limit temperature interrupt: %d\n",
|
||||
thermal_zone_device_type(tz), low);
|
||||
- writel(raw_low, LVTS_H2NTHRE(base));
|
||||
+ writel(raw_low, LVTS_OFFSETL(base));
|
||||
}
|
||||
|
||||
/*
|
||||
- * Hot temperature threshold
|
||||
+ * High offset temperature threshold
|
||||
*
|
||||
- * LVTS_HTHRE
|
||||
+ * LVTS_OFFSETH
|
||||
*
|
||||
* Bits:
|
||||
*
|
||||
@@ -323,7 +323,7 @@ static int lvts_set_trips(struct thermal
|
||||
*/
|
||||
pr_debug("%s: Setting high limit temperature interrupt: %d\n",
|
||||
thermal_zone_device_type(tz), high);
|
||||
- writel(raw_high, LVTS_HTHRE(base));
|
||||
+ writel(raw_high, LVTS_OFFSETH(base));
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
From 8f8cab9d3e90acf1db278ef44ad05f10aefb973f Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?N=C3=ADcolas=20F=2E=20R=2E=20A=2E=20Prado?=
|
||||
<nfraprado@collabora.com>
|
||||
Date: Thu, 6 Jul 2023 11:37:35 -0400
|
||||
Subject: [PATCH 28/42] thermal/drivers/mediatek/lvts_thermal: Disable
|
||||
undesired interrupts
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Out of the many interrupts supported by the hardware, the only ones of
|
||||
interest to the driver currently are:
|
||||
* The temperature went over the high offset threshold, for any of the
|
||||
sensors
|
||||
* The temperature went below the low offset threshold, for any of the
|
||||
sensors
|
||||
* The temperature went over the stage3 threshold
|
||||
|
||||
These are the only thresholds configured by the driver through the
|
||||
OFFSETH, OFFSETL, and PROTTC registers, respectively.
|
||||
|
||||
The current interrupt mask in LVTS_MONINT_CONF, enables many more
|
||||
interrupts, including data ready on sensors for both filtered and
|
||||
immediate mode. These are not only not handled by the driver, but they
|
||||
are also triggered too often, causing unneeded overhead. Disable these
|
||||
unnecessary interrupts.
|
||||
|
||||
The meaning of each bit can be seen in the comment describing
|
||||
LVTS_MONINTST in the IRQ handler.
|
||||
|
||||
Fixes: f5f633b18234 ("thermal/drivers/mediatek: Add the Low Voltage Thermal Sensor driver")
|
||||
Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com>
|
||||
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20230706153823.201943-5-nfraprado@collabora.com
|
||||
---
|
||||
drivers/thermal/mediatek/lvts_thermal.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/thermal/mediatek/lvts_thermal.c
|
||||
+++ b/drivers/thermal/mediatek/lvts_thermal.c
|
||||
@@ -65,7 +65,7 @@
|
||||
#define LVTS_HW_FILTER 0x2
|
||||
#define LVTS_TSSEL_CONF 0x13121110
|
||||
#define LVTS_CALSCALE_CONF 0x300
|
||||
-#define LVTS_MONINT_CONF 0x9FBF7BDE
|
||||
+#define LVTS_MONINT_CONF 0x8300318C
|
||||
|
||||
#define LVTS_INT_SENSOR0 0x0009001F
|
||||
#define LVTS_INT_SENSOR1 0x001203E0
|
@ -1,70 +0,0 @@
|
||||
From bd1ccf9408e6155564530af5e09b53ae497fe332 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?N=C3=ADcolas=20F=2E=20R=2E=20A=2E=20Prado?=
|
||||
<nfraprado@collabora.com>
|
||||
Date: Thu, 6 Jul 2023 11:37:36 -0400
|
||||
Subject: [PATCH 29/42] thermal/drivers/mediatek/lvts_thermal: Don't leave
|
||||
threshold zeroed
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
The thermal framework might leave the low threshold unset if there
|
||||
aren't any lower trip points. This leaves the register zeroed, which
|
||||
translates to a very high temperature for the low threshold. The
|
||||
interrupt for this threshold is then immediately triggered, and the
|
||||
state machine gets stuck, preventing any other temperature monitoring
|
||||
interrupts to ever trigger.
|
||||
|
||||
(The same happens by not setting the Cold or Hot to Normal thresholds
|
||||
when using those)
|
||||
|
||||
Set the unused threshold to a valid low value. This value was chosen so
|
||||
that for any valid golden temperature read from the efuse, when the
|
||||
value is converted to raw and back again to milliCelsius, the result
|
||||
doesn't underflow.
|
||||
|
||||
Fixes: f5f633b18234 ("thermal/drivers/mediatek: Add the Low Voltage Thermal Sensor driver")
|
||||
Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
|
||||
Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com>
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20230706153823.201943-6-nfraprado@collabora.com
|
||||
---
|
||||
drivers/thermal/mediatek/lvts_thermal.c | 12 ++++++------
|
||||
1 file changed, 6 insertions(+), 6 deletions(-)
|
||||
|
||||
--- a/drivers/thermal/mediatek/lvts_thermal.c
|
||||
+++ b/drivers/thermal/mediatek/lvts_thermal.c
|
||||
@@ -83,6 +83,8 @@
|
||||
|
||||
#define LVTS_HW_SHUTDOWN_MT8195 105000
|
||||
|
||||
+#define LVTS_MINIMUM_THRESHOLD 20000
|
||||
+
|
||||
static int golden_temp = LVTS_GOLDEN_TEMP_DEFAULT;
|
||||
static int coeff_b = LVTS_COEFF_B;
|
||||
|
||||
@@ -294,7 +296,7 @@ static int lvts_set_trips(struct thermal
|
||||
{
|
||||
struct lvts_sensor *lvts_sensor = thermal_zone_device_priv(tz);
|
||||
void __iomem *base = lvts_sensor->base;
|
||||
- u32 raw_low = lvts_temp_to_raw(low);
|
||||
+ u32 raw_low = lvts_temp_to_raw(low != -INT_MAX ? low : LVTS_MINIMUM_THRESHOLD);
|
||||
u32 raw_high = lvts_temp_to_raw(high);
|
||||
|
||||
/*
|
||||
@@ -306,11 +308,9 @@ static int lvts_set_trips(struct thermal
|
||||
*
|
||||
* 14-0 : Raw temperature for threshold
|
||||
*/
|
||||
- if (low != -INT_MAX) {
|
||||
- pr_debug("%s: Setting low limit temperature interrupt: %d\n",
|
||||
- thermal_zone_device_type(tz), low);
|
||||
- writel(raw_low, LVTS_OFFSETL(base));
|
||||
- }
|
||||
+ pr_debug("%s: Setting low limit temperature interrupt: %d\n",
|
||||
+ thermal_zone_device_type(tz), low);
|
||||
+ writel(raw_low, LVTS_OFFSETL(base));
|
||||
|
||||
/*
|
||||
* High offset temperature threshold
|
@ -1,156 +0,0 @@
|
||||
From d4dd09968cab3249e6148e1c3fccb51824edb411 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?N=C3=ADcolas=20F=2E=20R=2E=20A=2E=20Prado?=
|
||||
<nfraprado@collabora.com>
|
||||
Date: Thu, 6 Jul 2023 11:37:37 -0400
|
||||
Subject: [PATCH 30/42] thermal/drivers/mediatek/lvts_thermal: Manage threshold
|
||||
between sensors
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Each LVTS thermal controller can have up to four sensors, each capable
|
||||
of triggering its own interrupt when its measured temperature crosses
|
||||
the configured threshold. The threshold for each sensor is handled
|
||||
separately by the thermal framework, since each one is registered with
|
||||
its own thermal zone and trips. However, the temperature thresholds are
|
||||
configured on the controller, and therefore are shared between all
|
||||
sensors on that controller.
|
||||
|
||||
When the temperature measured by the sensors is different enough to
|
||||
cause the thermal framework to configure different thresholds for each
|
||||
one, interrupts start triggering on sensors outside the last threshold
|
||||
configured.
|
||||
|
||||
To address the issue, track the thresholds required by each sensor and
|
||||
only actually set the highest one in the hardware, and disable
|
||||
interrupts for all sensors outside the current configured range.
|
||||
|
||||
Fixes: f5f633b18234 ("thermal/drivers/mediatek: Add the Low Voltage Thermal Sensor driver")
|
||||
Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
|
||||
Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com>
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20230706153823.201943-7-nfraprado@collabora.com
|
||||
---
|
||||
drivers/thermal/mediatek/lvts_thermal.c | 69 +++++++++++++++++++++++++
|
||||
1 file changed, 69 insertions(+)
|
||||
|
||||
--- a/drivers/thermal/mediatek/lvts_thermal.c
|
||||
+++ b/drivers/thermal/mediatek/lvts_thermal.c
|
||||
@@ -67,6 +67,11 @@
|
||||
#define LVTS_CALSCALE_CONF 0x300
|
||||
#define LVTS_MONINT_CONF 0x8300318C
|
||||
|
||||
+#define LVTS_MONINT_OFFSET_SENSOR0 0xC
|
||||
+#define LVTS_MONINT_OFFSET_SENSOR1 0x180
|
||||
+#define LVTS_MONINT_OFFSET_SENSOR2 0x3000
|
||||
+#define LVTS_MONINT_OFFSET_SENSOR3 0x3000000
|
||||
+
|
||||
#define LVTS_INT_SENSOR0 0x0009001F
|
||||
#define LVTS_INT_SENSOR1 0x001203E0
|
||||
#define LVTS_INT_SENSOR2 0x00247C00
|
||||
@@ -112,6 +117,8 @@ struct lvts_sensor {
|
||||
void __iomem *base;
|
||||
int id;
|
||||
int dt_id;
|
||||
+ int low_thresh;
|
||||
+ int high_thresh;
|
||||
};
|
||||
|
||||
struct lvts_ctrl {
|
||||
@@ -121,6 +128,8 @@ struct lvts_ctrl {
|
||||
int num_lvts_sensor;
|
||||
int mode;
|
||||
void __iomem *base;
|
||||
+ int low_thresh;
|
||||
+ int high_thresh;
|
||||
};
|
||||
|
||||
struct lvts_domain {
|
||||
@@ -292,12 +301,66 @@ static int lvts_get_temp(struct thermal_
|
||||
return 0;
|
||||
}
|
||||
|
||||
+static void lvts_update_irq_mask(struct lvts_ctrl *lvts_ctrl)
|
||||
+{
|
||||
+ u32 masks[] = {
|
||||
+ LVTS_MONINT_OFFSET_SENSOR0,
|
||||
+ LVTS_MONINT_OFFSET_SENSOR1,
|
||||
+ LVTS_MONINT_OFFSET_SENSOR2,
|
||||
+ LVTS_MONINT_OFFSET_SENSOR3,
|
||||
+ };
|
||||
+ u32 value = 0;
|
||||
+ int i;
|
||||
+
|
||||
+ value = readl(LVTS_MONINT(lvts_ctrl->base));
|
||||
+
|
||||
+ for (i = 0; i < ARRAY_SIZE(masks); i++) {
|
||||
+ if (lvts_ctrl->sensors[i].high_thresh == lvts_ctrl->high_thresh
|
||||
+ && lvts_ctrl->sensors[i].low_thresh == lvts_ctrl->low_thresh)
|
||||
+ value |= masks[i];
|
||||
+ else
|
||||
+ value &= ~masks[i];
|
||||
+ }
|
||||
+
|
||||
+ writel(value, LVTS_MONINT(lvts_ctrl->base));
|
||||
+}
|
||||
+
|
||||
+static bool lvts_should_update_thresh(struct lvts_ctrl *lvts_ctrl, int high)
|
||||
+{
|
||||
+ int i;
|
||||
+
|
||||
+ if (high > lvts_ctrl->high_thresh)
|
||||
+ return true;
|
||||
+
|
||||
+ for (i = 0; i < lvts_ctrl->num_lvts_sensor; i++)
|
||||
+ if (lvts_ctrl->sensors[i].high_thresh == lvts_ctrl->high_thresh
|
||||
+ && lvts_ctrl->sensors[i].low_thresh == lvts_ctrl->low_thresh)
|
||||
+ return false;
|
||||
+
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
static int lvts_set_trips(struct thermal_zone_device *tz, int low, int high)
|
||||
{
|
||||
struct lvts_sensor *lvts_sensor = thermal_zone_device_priv(tz);
|
||||
+ struct lvts_ctrl *lvts_ctrl = container_of(lvts_sensor, struct lvts_ctrl, sensors[lvts_sensor->id]);
|
||||
void __iomem *base = lvts_sensor->base;
|
||||
u32 raw_low = lvts_temp_to_raw(low != -INT_MAX ? low : LVTS_MINIMUM_THRESHOLD);
|
||||
u32 raw_high = lvts_temp_to_raw(high);
|
||||
+ bool should_update_thresh;
|
||||
+
|
||||
+ lvts_sensor->low_thresh = low;
|
||||
+ lvts_sensor->high_thresh = high;
|
||||
+
|
||||
+ should_update_thresh = lvts_should_update_thresh(lvts_ctrl, high);
|
||||
+ if (should_update_thresh) {
|
||||
+ lvts_ctrl->high_thresh = high;
|
||||
+ lvts_ctrl->low_thresh = low;
|
||||
+ }
|
||||
+ lvts_update_irq_mask(lvts_ctrl);
|
||||
+
|
||||
+ if (!should_update_thresh)
|
||||
+ return 0;
|
||||
|
||||
/*
|
||||
* Low offset temperature threshold
|
||||
@@ -521,6 +584,9 @@ static int lvts_sensor_init(struct devic
|
||||
*/
|
||||
lvts_sensor[i].msr = lvts_ctrl_data->mode == LVTS_MSR_IMMEDIATE_MODE ?
|
||||
imm_regs[i] : msr_regs[i];
|
||||
+
|
||||
+ lvts_sensor[i].low_thresh = INT_MIN;
|
||||
+ lvts_sensor[i].high_thresh = INT_MIN;
|
||||
};
|
||||
|
||||
lvts_ctrl->num_lvts_sensor = lvts_ctrl_data->num_lvts_sensor;
|
||||
@@ -688,6 +754,9 @@ static int lvts_ctrl_init(struct device
|
||||
*/
|
||||
lvts_ctrl[i].hw_tshut_raw_temp =
|
||||
lvts_temp_to_raw(lvts_data->lvts_ctrl[i].hw_tshut_temp);
|
||||
+
|
||||
+ lvts_ctrl[i].low_thresh = INT_MIN;
|
||||
+ lvts_ctrl[i].high_thresh = INT_MIN;
|
||||
}
|
||||
|
||||
/*
|
@ -1,29 +0,0 @@
|
||||
From 5af4904adc8b840987000724977c13c706d3b7d8 Mon Sep 17 00:00:00 2001
|
||||
From: Minjie Du <duminjie@vivo.com>
|
||||
Date: Thu, 13 Jul 2023 12:24:12 +0800
|
||||
Subject: [PATCH 31/42] thermal/drivers/mediatek/lvts: Fix parameter check in
|
||||
lvts_debugfs_init()
|
||||
|
||||
The documentation says "If an error occurs, ERR_PTR(-ERROR) will be
|
||||
returned" but the current code checks against a NULL pointer returned.
|
||||
|
||||
Fix this by checking if IS_ERR().
|
||||
|
||||
Signed-off-by: Minjie Du <duminjie@vivo.com>
|
||||
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20230713042413.2519-1-duminjie@vivo.com
|
||||
---
|
||||
drivers/thermal/mediatek/lvts_thermal.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/thermal/mediatek/lvts_thermal.c
|
||||
+++ b/drivers/thermal/mediatek/lvts_thermal.c
|
||||
@@ -201,7 +201,7 @@ static int lvts_debugfs_init(struct devi
|
||||
int i;
|
||||
|
||||
lvts_td->dom_dentry = debugfs_create_dir(dev_name(dev), NULL);
|
||||
- if (!lvts_td->dom_dentry)
|
||||
+ if (IS_ERR(lvts_td->dom_dentry))
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < lvts_td->num_lvts_ctrl; i++) {
|
@ -1,33 +0,0 @@
|
||||
From 6186be80317d1dbda34d35c06c084a083938f2d3 Mon Sep 17 00:00:00 2001
|
||||
From: Chen Jiahao <chenjiahao16@huawei.com>
|
||||
Date: Wed, 2 Aug 2023 17:45:27 +0800
|
||||
Subject: [PATCH 32/42] thermal/drivers/mediatek: Clean up redundant
|
||||
dev_err_probe()
|
||||
|
||||
Referring to platform_get_irq()'s definition, the return value has
|
||||
already been checked if ret < 0, and printed via dev_err_probe().
|
||||
Calling dev_err_probe() one more time outside platform_get_irq()
|
||||
is obviously redundant.
|
||||
|
||||
Removing dev_err_probe() outside platform_get_irq() to clean up
|
||||
above problem.
|
||||
|
||||
Signed-off-by: Chen Jiahao <chenjiahao16@huawei.com>
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20230802094527.988842-1-chenjiahao16@huawei.com
|
||||
---
|
||||
drivers/thermal/mediatek/lvts_thermal.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/thermal/mediatek/lvts_thermal.c
|
||||
+++ b/drivers/thermal/mediatek/lvts_thermal.c
|
||||
@@ -1216,7 +1216,7 @@ static int lvts_probe(struct platform_de
|
||||
|
||||
irq = platform_get_irq(pdev, 0);
|
||||
if (irq < 0)
|
||||
- return dev_err_probe(dev, irq, "No irq resource\n");
|
||||
+ return irq;
|
||||
|
||||
ret = lvts_domain_init(dev, lvts_td, lvts_data);
|
||||
if (ret)
|
@ -1,95 +0,0 @@
|
||||
From c2ab54ab0425388e65901a7af2fbf69ead968708 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?N=C3=ADcolas=20F=2E=20R=2E=20A=2E=20Prado?=
|
||||
<nfraprado@collabora.com>
|
||||
Date: Thu, 13 Jul 2023 11:42:37 -0400
|
||||
Subject: [PATCH 33/42] thermal/drivers/mediatek/lvts_thermal: Make readings
|
||||
valid in filtered mode
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Currently, when a controller is configured to use filtered mode, thermal
|
||||
readings are valid only about 30% of the time.
|
||||
|
||||
Upon testing, it was noticed that lowering any of the interval settings
|
||||
resulted in an improved rate of valid data. The same was observed when
|
||||
decreasing the number of samples for each sensor (which also results in
|
||||
quicker measurements).
|
||||
|
||||
Retrying the read with a timeout longer than the time it takes to
|
||||
resample (about 344us with these settings and 4 sensors) also improves
|
||||
the rate.
|
||||
|
||||
Lower all timing settings to the minimum, configure the filtering to
|
||||
single sample, and poll the measurement register for at least one period
|
||||
to improve the data validity on filtered mode. With these changes in
|
||||
place, out of 100000 reads, a single one failed, ie 99.999% of the data
|
||||
was valid.
|
||||
|
||||
Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
|
||||
Tested-by: Chen-Yu Tsai <wenst@chromium.org>
|
||||
Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
|
||||
Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com>
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20230713154743.611870-1-nfraprado@collabora.com
|
||||
---
|
||||
drivers/thermal/mediatek/lvts_thermal.c | 19 ++++++++++++-------
|
||||
1 file changed, 12 insertions(+), 7 deletions(-)
|
||||
|
||||
--- a/drivers/thermal/mediatek/lvts_thermal.c
|
||||
+++ b/drivers/thermal/mediatek/lvts_thermal.c
|
||||
@@ -58,11 +58,11 @@
|
||||
#define LVTS_PROTTC(__base) (__base + 0x00CC)
|
||||
#define LVTS_CLKEN(__base) (__base + 0x00E4)
|
||||
|
||||
-#define LVTS_PERIOD_UNIT ((118 * 1000) / (256 * 38))
|
||||
-#define LVTS_GROUP_INTERVAL 1
|
||||
-#define LVTS_FILTER_INTERVAL 1
|
||||
-#define LVTS_SENSOR_INTERVAL 1
|
||||
-#define LVTS_HW_FILTER 0x2
|
||||
+#define LVTS_PERIOD_UNIT 0
|
||||
+#define LVTS_GROUP_INTERVAL 0
|
||||
+#define LVTS_FILTER_INTERVAL 0
|
||||
+#define LVTS_SENSOR_INTERVAL 0
|
||||
+#define LVTS_HW_FILTER 0x0
|
||||
#define LVTS_TSSEL_CONF 0x13121110
|
||||
#define LVTS_CALSCALE_CONF 0x300
|
||||
#define LVTS_MONINT_CONF 0x8300318C
|
||||
@@ -86,6 +86,9 @@
|
||||
#define LVTS_MSR_IMMEDIATE_MODE 0
|
||||
#define LVTS_MSR_FILTERED_MODE 1
|
||||
|
||||
+#define LVTS_MSR_READ_TIMEOUT_US 400
|
||||
+#define LVTS_MSR_READ_WAIT_US (LVTS_MSR_READ_TIMEOUT_US / 2)
|
||||
+
|
||||
#define LVTS_HW_SHUTDOWN_MT8195 105000
|
||||
|
||||
#define LVTS_MINIMUM_THRESHOLD 20000
|
||||
@@ -268,6 +271,7 @@ static int lvts_get_temp(struct thermal_
|
||||
struct lvts_sensor *lvts_sensor = thermal_zone_device_priv(tz);
|
||||
void __iomem *msr = lvts_sensor->msr;
|
||||
u32 value;
|
||||
+ int rc;
|
||||
|
||||
/*
|
||||
* Measurement registers:
|
||||
@@ -280,7 +284,8 @@ static int lvts_get_temp(struct thermal_
|
||||
* 16 : Valid temperature
|
||||
* 15-0 : Raw temperature
|
||||
*/
|
||||
- value = readl(msr);
|
||||
+ rc = readl_poll_timeout(msr, value, value & BIT(16),
|
||||
+ LVTS_MSR_READ_WAIT_US, LVTS_MSR_READ_TIMEOUT_US);
|
||||
|
||||
/*
|
||||
* As the thermal zone temperature will read before the
|
||||
@@ -293,7 +298,7 @@ static int lvts_get_temp(struct thermal_
|
||||
* functionning temperature and directly jump to a system
|
||||
* shutdown.
|
||||
*/
|
||||
- if (!(value & BIT(16)))
|
||||
+ if (rc)
|
||||
return -EAGAIN;
|
||||
|
||||
*temp = lvts_raw_to_temp(value & 0xFFFF);
|
@ -1,30 +0,0 @@
|
||||
From c864ff9de3b225b43bb8e08dedb223632323e059 Mon Sep 17 00:00:00 2001
|
||||
From: Andrei Coardos <aboutphysycs@gmail.com>
|
||||
Date: Fri, 11 Aug 2023 22:28:47 +0300
|
||||
Subject: [PATCH 34/42] thermal/drivers/mediatek/auxadc_thermal: Removed call
|
||||
to platform_set_drvdata()
|
||||
|
||||
This function call was found to be unnecessary as there is no equivalent
|
||||
platform_get_drvdata() call to access the private data of the driver. Also,
|
||||
the private data is defined in this driver, so there is no risk of it being
|
||||
accessed outside of this driver file.
|
||||
|
||||
Signed-off-by: Andrei Coardos <aboutphysycs@gmail.com>
|
||||
Reviewed-by: Alexandru Ardelean <alex@shruggie.ro>
|
||||
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20230811192847.3838-1-aboutphysycs@gmail.com
|
||||
---
|
||||
drivers/thermal/mediatek/auxadc_thermal.c | 2 --
|
||||
1 file changed, 2 deletions(-)
|
||||
|
||||
--- a/drivers/thermal/mediatek/auxadc_thermal.c
|
||||
+++ b/drivers/thermal/mediatek/auxadc_thermal.c
|
||||
@@ -1283,8 +1283,6 @@ static int mtk_thermal_probe(struct plat
|
||||
mtk_thermal_init_bank(mt, i, apmixed_phys_base,
|
||||
auxadc_phys_base, ctrl_id);
|
||||
|
||||
- platform_set_drvdata(pdev, mt);
|
||||
-
|
||||
tzdev = devm_thermal_of_zone_register(&pdev->dev, 0, mt,
|
||||
&mtk_thermal_ops);
|
||||
if (IS_ERR(tzdev))
|
@ -1,44 +0,0 @@
|
||||
From 11f9a0f4e51887ad7b4a2898a368fcd0c2984e89 Mon Sep 17 00:00:00 2001
|
||||
From: Frank Wunderlich <frank-w@public-files.de>
|
||||
Date: Sun, 9 Oct 2022 12:16:31 +0200
|
||||
Subject: [PATCH 12/16] i2c: mediatek: add mt7986 support
|
||||
|
||||
Add i2c support for MT7986 SoC.
|
||||
|
||||
Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Signed-off-by: Wolfram Sang <wsa@kernel.org>
|
||||
---
|
||||
drivers/i2c/busses/i2c-mt65xx.c | 14 ++++++++++++++
|
||||
1 file changed, 14 insertions(+)
|
||||
|
||||
--- a/drivers/i2c/busses/i2c-mt65xx.c
|
||||
+++ b/drivers/i2c/busses/i2c-mt65xx.c
|
||||
@@ -431,6 +431,19 @@ static const struct mtk_i2c_compatible m
|
||||
.max_dma_support = 33,
|
||||
};
|
||||
|
||||
+static const struct mtk_i2c_compatible mt7986_compat = {
|
||||
+ .quirks = &mt7622_i2c_quirks,
|
||||
+ .regs = mt_i2c_regs_v1,
|
||||
+ .pmic_i2c = 0,
|
||||
+ .dcm = 1,
|
||||
+ .auto_restart = 1,
|
||||
+ .aux_len_reg = 1,
|
||||
+ .timing_adjust = 0,
|
||||
+ .dma_sync = 1,
|
||||
+ .ltiming_adjust = 0,
|
||||
+ .max_dma_support = 32,
|
||||
+};
|
||||
+
|
||||
static const struct mtk_i2c_compatible mt8173_compat = {
|
||||
.regs = mt_i2c_regs_v1,
|
||||
.pmic_i2c = 0,
|
||||
@@ -503,6 +516,7 @@ static const struct of_device_id mtk_i2c
|
||||
{ .compatible = "mediatek,mt6577-i2c", .data = &mt6577_compat },
|
||||
{ .compatible = "mediatek,mt6589-i2c", .data = &mt6589_compat },
|
||||
{ .compatible = "mediatek,mt7622-i2c", .data = &mt7622_compat },
|
||||
+ { .compatible = "mediatek,mt7986-i2c", .data = &mt7986_compat },
|
||||
{ .compatible = "mediatek,mt8168-i2c", .data = &mt8168_compat },
|
||||
{ .compatible = "mediatek,mt8173-i2c", .data = &mt8173_compat },
|
||||
{ .compatible = "mediatek,mt8183-i2c", .data = &mt8183_compat },
|
@ -1,42 +0,0 @@
|
||||
From 98204ccafd45a8a6109ff2d60e2c179b95d92578 Mon Sep 17 00:00:00 2001
|
||||
From: ye xingchen <ye.xingchen@zte.com.cn>
|
||||
Date: Thu, 19 Jan 2023 17:19:58 +0800
|
||||
Subject: [PATCH 13/16] i2c: mt65xx: Use
|
||||
devm_platform_get_and_ioremap_resource()
|
||||
|
||||
Convert platform_get_resource(), devm_ioremap_resource() to a single
|
||||
call to devm_platform_get_and_ioremap_resource(), as this is exactly
|
||||
what this function does.
|
||||
|
||||
Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Signed-off-by: Wolfram Sang <wsa@kernel.org>
|
||||
---
|
||||
drivers/i2c/busses/i2c-mt65xx.c | 7 ++-----
|
||||
1 file changed, 2 insertions(+), 5 deletions(-)
|
||||
|
||||
--- a/drivers/i2c/busses/i2c-mt65xx.c
|
||||
+++ b/drivers/i2c/busses/i2c-mt65xx.c
|
||||
@@ -1366,20 +1366,17 @@ static int mtk_i2c_probe(struct platform
|
||||
{
|
||||
int ret = 0;
|
||||
struct mtk_i2c *i2c;
|
||||
- struct resource *res;
|
||||
int i, irq, speed_clk;
|
||||
|
||||
i2c = devm_kzalloc(&pdev->dev, sizeof(*i2c), GFP_KERNEL);
|
||||
if (!i2c)
|
||||
return -ENOMEM;
|
||||
|
||||
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
- i2c->base = devm_ioremap_resource(&pdev->dev, res);
|
||||
+ i2c->base = devm_platform_get_and_ioremap_resource(pdev, 0, NULL);
|
||||
if (IS_ERR(i2c->base))
|
||||
return PTR_ERR(i2c->base);
|
||||
|
||||
- res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
|
||||
- i2c->pdmabase = devm_ioremap_resource(&pdev->dev, res);
|
||||
+ i2c->pdmabase = devm_platform_get_and_ioremap_resource(pdev, 1, NULL);
|
||||
if (IS_ERR(i2c->pdmabase))
|
||||
return PTR_ERR(i2c->pdmabase);
|
||||
|
@ -1,33 +0,0 @@
|
||||
From 8106fa2e0ae6082833fe1df97829c46c0183eaea Mon Sep 17 00:00:00 2001
|
||||
From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
|
||||
Date: Sat, 11 Mar 2023 12:16:54 +0100
|
||||
Subject: [PATCH 14/16] i2c: mt65xx: drop of_match_ptr for ID table
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
The driver can match only via the DT table so the table should be always
|
||||
used and the of_match_ptr does not have any sense (this also allows ACPI
|
||||
matching via PRP0001, even though it might not be relevant here).
|
||||
|
||||
drivers/i2c/busses/i2c-mt65xx.c:514:34: error: ‘mtk_i2c_of_match’ defined but not used [-Werror=unused-const-variable=]
|
||||
|
||||
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
|
||||
Reviewed-by: Guenter Roeck <groeck@chromium.org>
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Signed-off-by: Wolfram Sang <wsa@kernel.org>
|
||||
---
|
||||
drivers/i2c/busses/i2c-mt65xx.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/i2c/busses/i2c-mt65xx.c
|
||||
+++ b/drivers/i2c/busses/i2c-mt65xx.c
|
||||
@@ -1546,7 +1546,7 @@ static struct platform_driver mtk_i2c_dr
|
||||
.driver = {
|
||||
.name = I2C_DRV_NAME,
|
||||
.pm = &mtk_i2c_pm,
|
||||
- .of_match_table = of_match_ptr(mtk_i2c_of_match),
|
||||
+ .of_match_table = mtk_i2c_of_match,
|
||||
},
|
||||
};
|
||||
|
@ -1,47 +0,0 @@
|
||||
From f69f3d662ba3bf999c36d9ac1e684540c4487bc3 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Mon, 10 Apr 2023 17:19:38 +0100
|
||||
Subject: [PATCH 15/16] i2c: mediatek: add support for MT7981 SoC
|
||||
|
||||
Add support for the I2C units found in the MediaTek MT7981 and MT7988
|
||||
SoCs. Just like other recent MediaTek I2C units that also uses v3
|
||||
register offsets (which differ from v2 only by OFFSET_SLAVE_ADDR being
|
||||
0x94 instead of 0x4).
|
||||
|
||||
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com>
|
||||
Signed-off-by: Wolfram Sang <wsa@kernel.org>
|
||||
---
|
||||
drivers/i2c/busses/i2c-mt65xx.c | 13 +++++++++++++
|
||||
1 file changed, 13 insertions(+)
|
||||
|
||||
--- a/drivers/i2c/busses/i2c-mt65xx.c
|
||||
+++ b/drivers/i2c/busses/i2c-mt65xx.c
|
||||
@@ -431,6 +431,18 @@ static const struct mtk_i2c_compatible m
|
||||
.max_dma_support = 33,
|
||||
};
|
||||
|
||||
+static const struct mtk_i2c_compatible mt7981_compat = {
|
||||
+ .regs = mt_i2c_regs_v3,
|
||||
+ .pmic_i2c = 0,
|
||||
+ .dcm = 0,
|
||||
+ .auto_restart = 1,
|
||||
+ .aux_len_reg = 1,
|
||||
+ .timing_adjust = 1,
|
||||
+ .dma_sync = 1,
|
||||
+ .ltiming_adjust = 1,
|
||||
+ .max_dma_support = 33
|
||||
+};
|
||||
+
|
||||
static const struct mtk_i2c_compatible mt7986_compat = {
|
||||
.quirks = &mt7622_i2c_quirks,
|
||||
.regs = mt_i2c_regs_v1,
|
||||
@@ -516,6 +528,7 @@ static const struct of_device_id mtk_i2c
|
||||
{ .compatible = "mediatek,mt6577-i2c", .data = &mt6577_compat },
|
||||
{ .compatible = "mediatek,mt6589-i2c", .data = &mt6589_compat },
|
||||
{ .compatible = "mediatek,mt7622-i2c", .data = &mt7622_compat },
|
||||
+ { .compatible = "mediatek,mt7981-i2c", .data = &mt7981_compat },
|
||||
{ .compatible = "mediatek,mt7986-i2c", .data = &mt7986_compat },
|
||||
{ .compatible = "mediatek,mt8168-i2c", .data = &mt8168_compat },
|
||||
{ .compatible = "mediatek,mt8173-i2c", .data = &mt8173_compat },
|
@ -1,269 +0,0 @@
|
||||
From d35469096915f2551ed1d26da1ab12ff500fc963 Mon Sep 17 00:00:00 2001
|
||||
From: Maso Huang <maso.huang@mediatek.com>
|
||||
Date: Thu, 17 Aug 2023 18:13:33 +0800
|
||||
Subject: [PATCH 1/9] ASoC: mediatek: mt7986: add common header
|
||||
|
||||
Add header files for register definition and structure.
|
||||
|
||||
Signed-off-by: Maso Huang <maso.huang@mediatek.com>
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Link: https://lore.kernel.org/r/20230817101338.18782-2-maso.huang@mediatek.com
|
||||
Signed-off-by: Mark Brown <broonie@kernel.org>
|
||||
---
|
||||
sound/soc/mediatek/mt7986/mt7986-afe-common.h | 49 +++++
|
||||
sound/soc/mediatek/mt7986/mt7986-reg.h | 196 ++++++++++++++++++
|
||||
2 files changed, 245 insertions(+)
|
||||
create mode 100644 sound/soc/mediatek/mt7986/mt7986-afe-common.h
|
||||
create mode 100644 sound/soc/mediatek/mt7986/mt7986-reg.h
|
||||
|
||||
--- /dev/null
|
||||
+++ b/sound/soc/mediatek/mt7986/mt7986-afe-common.h
|
||||
@@ -0,0 +1,49 @@
|
||||
+/* SPDX-License-Identifier: GPL-2.0 */
|
||||
+/*
|
||||
+ * mt7986-afe-common.h -- MediaTek 7986 audio driver definitions
|
||||
+ *
|
||||
+ * Copyright (c) 2023 MediaTek Inc.
|
||||
+ * Authors: Vic Wu <vic.wu@mediatek.com>
|
||||
+ * Maso Huang <maso.huang@mediatek.com>
|
||||
+ */
|
||||
+
|
||||
+#ifndef _MT_7986_AFE_COMMON_H_
|
||||
+#define _MT_7986_AFE_COMMON_H_
|
||||
+
|
||||
+#include <sound/soc.h>
|
||||
+#include <linux/clk.h>
|
||||
+#include <linux/list.h>
|
||||
+#include <linux/regmap.h>
|
||||
+#include "../common/mtk-base-afe.h"
|
||||
+
|
||||
+enum {
|
||||
+ MT7986_MEMIF_DL1,
|
||||
+ MT7986_MEMIF_VUL12,
|
||||
+ MT7986_MEMIF_NUM,
|
||||
+ MT7986_DAI_ETDM = MT7986_MEMIF_NUM,
|
||||
+ MT7986_DAI_NUM,
|
||||
+};
|
||||
+
|
||||
+enum {
|
||||
+ MT7986_IRQ_0,
|
||||
+ MT7986_IRQ_1,
|
||||
+ MT7986_IRQ_2,
|
||||
+ MT7986_IRQ_NUM,
|
||||
+};
|
||||
+
|
||||
+struct mt7986_afe_private {
|
||||
+ struct clk_bulk_data *clks;
|
||||
+ int num_clks;
|
||||
+
|
||||
+ int pm_runtime_bypass_reg_ctl;
|
||||
+
|
||||
+ /* dai */
|
||||
+ void *dai_priv[MT7986_DAI_NUM];
|
||||
+};
|
||||
+
|
||||
+unsigned int mt7986_afe_rate_transform(struct device *dev,
|
||||
+ unsigned int rate);
|
||||
+
|
||||
+/* dai register */
|
||||
+int mt7986_dai_etdm_register(struct mtk_base_afe *afe);
|
||||
+#endif
|
||||
--- /dev/null
|
||||
+++ b/sound/soc/mediatek/mt7986/mt7986-reg.h
|
||||
@@ -0,0 +1,196 @@
|
||||
+/* SPDX-License-Identifier: GPL-2.0 */
|
||||
+/*
|
||||
+ * mt7986-reg.h -- MediaTek 7986 audio driver reg definition
|
||||
+ *
|
||||
+ * Copyright (c) 2023 MediaTek Inc.
|
||||
+ * Authors: Vic Wu <vic.wu@mediatek.com>
|
||||
+ * Maso Huang <maso.huang@mediatek.com>
|
||||
+ */
|
||||
+
|
||||
+#ifndef _MT7986_REG_H_
|
||||
+#define _MT7986_REG_H_
|
||||
+
|
||||
+#define AUDIO_TOP_CON2 0x0008
|
||||
+#define AUDIO_TOP_CON4 0x0010
|
||||
+#define AUDIO_ENGEN_CON0 0x0014
|
||||
+#define AFE_IRQ_MCU_EN 0x0100
|
||||
+#define AFE_IRQ_MCU_STATUS 0x0120
|
||||
+#define AFE_IRQ_MCU_CLR 0x0128
|
||||
+#define AFE_IRQ0_MCU_CFG0 0x0140
|
||||
+#define AFE_IRQ0_MCU_CFG1 0x0144
|
||||
+#define AFE_IRQ1_MCU_CFG0 0x0148
|
||||
+#define AFE_IRQ1_MCU_CFG1 0x014c
|
||||
+#define AFE_IRQ2_MCU_CFG0 0x0150
|
||||
+#define AFE_IRQ2_MCU_CFG1 0x0154
|
||||
+#define ETDM_IN5_CON0 0x13f0
|
||||
+#define ETDM_IN5_CON1 0x13f4
|
||||
+#define ETDM_IN5_CON2 0x13f8
|
||||
+#define ETDM_IN5_CON3 0x13fc
|
||||
+#define ETDM_IN5_CON4 0x1400
|
||||
+#define ETDM_OUT5_CON0 0x1570
|
||||
+#define ETDM_OUT5_CON4 0x1580
|
||||
+#define ETDM_OUT5_CON5 0x1584
|
||||
+#define ETDM_4_7_COWORK_CON0 0x15e0
|
||||
+#define ETDM_4_7_COWORK_CON1 0x15e4
|
||||
+#define AFE_CONN018_1 0x1b44
|
||||
+#define AFE_CONN018_4 0x1b50
|
||||
+#define AFE_CONN019_1 0x1b64
|
||||
+#define AFE_CONN019_4 0x1b70
|
||||
+#define AFE_CONN124_1 0x2884
|
||||
+#define AFE_CONN124_4 0x2890
|
||||
+#define AFE_CONN125_1 0x28a4
|
||||
+#define AFE_CONN125_4 0x28b0
|
||||
+#define AFE_CONN_RS_0 0x3920
|
||||
+#define AFE_CONN_RS_3 0x392c
|
||||
+#define AFE_CONN_16BIT_0 0x3960
|
||||
+#define AFE_CONN_16BIT_3 0x396c
|
||||
+#define AFE_CONN_24BIT_0 0x3980
|
||||
+#define AFE_CONN_24BIT_3 0x398c
|
||||
+#define AFE_MEMIF_CON0 0x3d98
|
||||
+#define AFE_MEMIF_RD_MON 0x3da0
|
||||
+#define AFE_MEMIF_WR_MON 0x3da4
|
||||
+#define AFE_DL0_BASE_MSB 0x3e40
|
||||
+#define AFE_DL0_BASE 0x3e44
|
||||
+#define AFE_DL0_CUR_MSB 0x3e48
|
||||
+#define AFE_DL0_CUR 0x3e4c
|
||||
+#define AFE_DL0_END_MSB 0x3e50
|
||||
+#define AFE_DL0_END 0x3e54
|
||||
+#define AFE_DL0_RCH_MON 0x3e58
|
||||
+#define AFE_DL0_LCH_MON 0x3e5c
|
||||
+#define AFE_DL0_CON0 0x3e60
|
||||
+#define AFE_VUL0_BASE_MSB 0x4220
|
||||
+#define AFE_VUL0_BASE 0x4224
|
||||
+#define AFE_VUL0_CUR_MSB 0x4228
|
||||
+#define AFE_VUL0_CUR 0x422c
|
||||
+#define AFE_VUL0_END_MSB 0x4230
|
||||
+#define AFE_VUL0_END 0x4234
|
||||
+#define AFE_VUL0_CON0 0x4238
|
||||
+
|
||||
+#define AFE_MAX_REGISTER AFE_VUL0_CON0
|
||||
+#define AFE_IRQ_STATUS_BITS 0x7
|
||||
+#define AFE_IRQ_CNT_SHIFT 0
|
||||
+#define AFE_IRQ_CNT_MASK 0xffffff
|
||||
+
|
||||
+/* AUDIO_TOP_CON2 */
|
||||
+#define CLK_OUT5_PDN BIT(14)
|
||||
+#define CLK_OUT5_PDN_MASK BIT(14)
|
||||
+#define CLK_IN5_PDN BIT(7)
|
||||
+#define CLK_IN5_PDN_MASK BIT(7)
|
||||
+
|
||||
+/* AUDIO_TOP_CON4 */
|
||||
+#define PDN_APLL_TUNER2 BIT(12)
|
||||
+#define PDN_APLL_TUNER2_MASK BIT(12)
|
||||
+
|
||||
+/* AUDIO_ENGEN_CON0 */
|
||||
+#define AUD_APLL2_EN BIT(3)
|
||||
+#define AUD_APLL2_EN_MASK BIT(3)
|
||||
+#define AUD_26M_EN BIT(0)
|
||||
+#define AUD_26M_EN_MASK BIT(0)
|
||||
+
|
||||
+/* AFE_DL0_CON0 */
|
||||
+#define DL0_ON_SFT 28
|
||||
+#define DL0_ON_MASK 0x1
|
||||
+#define DL0_ON_MASK_SFT BIT(28)
|
||||
+#define DL0_MINLEN_SFT 20
|
||||
+#define DL0_MINLEN_MASK 0xf
|
||||
+#define DL0_MINLEN_MASK_SFT (0xf << 20)
|
||||
+#define DL0_MODE_SFT 8
|
||||
+#define DL0_MODE_MASK 0x1f
|
||||
+#define DL0_MODE_MASK_SFT (0x1f << 8)
|
||||
+#define DL0_PBUF_SIZE_SFT 5
|
||||
+#define DL0_PBUF_SIZE_MASK 0x3
|
||||
+#define DL0_PBUF_SIZE_MASK_SFT (0x3 << 5)
|
||||
+#define DL0_MONO_SFT 4
|
||||
+#define DL0_MONO_MASK 0x1
|
||||
+#define DL0_MONO_MASK_SFT BIT(4)
|
||||
+#define DL0_HALIGN_SFT 2
|
||||
+#define DL0_HALIGN_MASK 0x1
|
||||
+#define DL0_HALIGN_MASK_SFT BIT(2)
|
||||
+#define DL0_HD_MODE_SFT 0
|
||||
+#define DL0_HD_MODE_MASK 0x3
|
||||
+#define DL0_HD_MODE_MASK_SFT (0x3 << 0)
|
||||
+
|
||||
+/* AFE_VUL0_CON0 */
|
||||
+#define VUL0_ON_SFT 28
|
||||
+#define VUL0_ON_MASK 0x1
|
||||
+#define VUL0_ON_MASK_SFT BIT(28)
|
||||
+#define VUL0_MODE_SFT 8
|
||||
+#define VUL0_MODE_MASK 0x1f
|
||||
+#define VUL0_MODE_MASK_SFT (0x1f << 8)
|
||||
+#define VUL0_MONO_SFT 4
|
||||
+#define VUL0_MONO_MASK 0x1
|
||||
+#define VUL0_MONO_MASK_SFT BIT(4)
|
||||
+#define VUL0_HALIGN_SFT 2
|
||||
+#define VUL0_HALIGN_MASK 0x1
|
||||
+#define VUL0_HALIGN_MASK_SFT BIT(2)
|
||||
+#define VUL0_HD_MODE_SFT 0
|
||||
+#define VUL0_HD_MODE_MASK 0x3
|
||||
+#define VUL0_HD_MODE_MASK_SFT (0x3 << 0)
|
||||
+
|
||||
+/* AFE_IRQ_MCU_CON */
|
||||
+#define IRQ_MCU_MODE_SFT 4
|
||||
+#define IRQ_MCU_MODE_MASK 0x1f
|
||||
+#define IRQ_MCU_MODE_MASK_SFT (0x1f << 4)
|
||||
+#define IRQ_MCU_ON_SFT 0
|
||||
+#define IRQ_MCU_ON_MASK 0x1
|
||||
+#define IRQ_MCU_ON_MASK_SFT BIT(0)
|
||||
+#define IRQ0_MCU_CLR_SFT 0
|
||||
+#define IRQ0_MCU_CLR_MASK 0x1
|
||||
+#define IRQ0_MCU_CLR_MASK_SFT BIT(0)
|
||||
+#define IRQ1_MCU_CLR_SFT 1
|
||||
+#define IRQ1_MCU_CLR_MASK 0x1
|
||||
+#define IRQ1_MCU_CLR_MASK_SFT BIT(1)
|
||||
+#define IRQ2_MCU_CLR_SFT 2
|
||||
+#define IRQ2_MCU_CLR_MASK 0x1
|
||||
+#define IRQ2_MCU_CLR_MASK_SFT BIT(2)
|
||||
+
|
||||
+/* ETDM_IN5_CON2 */
|
||||
+#define IN_CLK_SRC(x) ((x) << 10)
|
||||
+#define IN_CLK_SRC_SFT 10
|
||||
+#define IN_CLK_SRC_MASK GENMASK(12, 10)
|
||||
+
|
||||
+/* ETDM_IN5_CON3 */
|
||||
+#define IN_SEL_FS(x) ((x) << 26)
|
||||
+#define IN_SEL_FS_SFT 26
|
||||
+#define IN_SEL_FS_MASK GENMASK(30, 26)
|
||||
+
|
||||
+/* ETDM_IN5_CON4 */
|
||||
+#define IN_RELATCH(x) ((x) << 20)
|
||||
+#define IN_RELATCH_SFT 20
|
||||
+#define IN_RELATCH_MASK GENMASK(24, 20)
|
||||
+#define IN_CLK_INV BIT(18)
|
||||
+#define IN_CLK_INV_MASK BIT(18)
|
||||
+
|
||||
+/* ETDM_IN5_CON0 & ETDM_OUT5_CON0 */
|
||||
+#define RELATCH_SRC_MASK GENMASK(30, 28)
|
||||
+#define ETDM_CH_NUM_MASK GENMASK(27, 23)
|
||||
+#define ETDM_WRD_LEN_MASK GENMASK(20, 16)
|
||||
+#define ETDM_BIT_LEN_MASK GENMASK(15, 11)
|
||||
+#define ETDM_FMT_MASK GENMASK(8, 6)
|
||||
+#define ETDM_SYNC BIT(1)
|
||||
+#define ETDM_SYNC_MASK BIT(1)
|
||||
+#define ETDM_EN BIT(0)
|
||||
+#define ETDM_EN_MASK BIT(0)
|
||||
+
|
||||
+/* ETDM_OUT5_CON4 */
|
||||
+#define OUT_RELATCH(x) ((x) << 24)
|
||||
+#define OUT_RELATCH_SFT 24
|
||||
+#define OUT_RELATCH_MASK GENMASK(28, 24)
|
||||
+#define OUT_CLK_SRC(x) ((x) << 6)
|
||||
+#define OUT_CLK_SRC_SFT 6
|
||||
+#define OUT_CLK_SRC_MASK GENMASK(8, 6)
|
||||
+#define OUT_SEL_FS(x) (x)
|
||||
+#define OUT_SEL_FS_SFT 0
|
||||
+#define OUT_SEL_FS_MASK GENMASK(4, 0)
|
||||
+
|
||||
+/* ETDM_OUT5_CON5 */
|
||||
+#define ETDM_CLK_DIV BIT(12)
|
||||
+#define ETDM_CLK_DIV_MASK BIT(12)
|
||||
+#define OUT_CLK_INV BIT(9)
|
||||
+#define OUT_CLK_INV_MASK BIT(9)
|
||||
+
|
||||
+/* ETDM_4_7_COWORK_CON0 */
|
||||
+#define OUT_SEL(x) ((x) << 12)
|
||||
+#define OUT_SEL_SFT 12
|
||||
+#define OUT_SEL_MASK GENMASK(15, 12)
|
||||
+#endif
|
@ -1,430 +0,0 @@
|
||||
From 948a288897015fb3ee63b3f720b396b590c17fd7 Mon Sep 17 00:00:00 2001
|
||||
From: Maso Huang <maso.huang@mediatek.com>
|
||||
Date: Thu, 17 Aug 2023 18:13:34 +0800
|
||||
Subject: [PATCH 2/9] ASoC: mediatek: mt7986: support etdm in platform driver
|
||||
|
||||
Add mt7986 etdm dai driver support.
|
||||
|
||||
Signed-off-by: Maso Huang <maso.huang@mediatek.com>
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Link: https://lore.kernel.org/r/20230817101338.18782-3-maso.huang@mediatek.com
|
||||
Signed-off-by: Mark Brown <broonie@kernel.org>
|
||||
---
|
||||
sound/soc/mediatek/mt7986/mt7986-dai-etdm.c | 411 ++++++++++++++++++++
|
||||
1 file changed, 411 insertions(+)
|
||||
create mode 100644 sound/soc/mediatek/mt7986/mt7986-dai-etdm.c
|
||||
|
||||
--- /dev/null
|
||||
+++ b/sound/soc/mediatek/mt7986/mt7986-dai-etdm.c
|
||||
@@ -0,0 +1,411 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0
|
||||
+/*
|
||||
+ * MediaTek ALSA SoC Audio DAI eTDM Control
|
||||
+ *
|
||||
+ * Copyright (c) 2023 MediaTek Inc.
|
||||
+ * Authors: Vic Wu <vic.wu@mediatek.com>
|
||||
+ * Maso Huang <maso.huang@mediatek.com>
|
||||
+ */
|
||||
+
|
||||
+#include <linux/bitfield.h>
|
||||
+#include <linux/bitops.h>
|
||||
+#include <linux/regmap.h>
|
||||
+#include <sound/pcm_params.h>
|
||||
+#include "mt7986-afe-common.h"
|
||||
+#include "mt7986-reg.h"
|
||||
+
|
||||
+#define HOPPING_CLK 0
|
||||
+#define APLL_CLK 1
|
||||
+#define MTK_DAI_ETDM_FORMAT_I2S 0
|
||||
+#define MTK_DAI_ETDM_FORMAT_DSPA 4
|
||||
+#define MTK_DAI_ETDM_FORMAT_DSPB 5
|
||||
+
|
||||
+enum {
|
||||
+ MTK_ETDM_RATE_8K = 0,
|
||||
+ MTK_ETDM_RATE_12K = 1,
|
||||
+ MTK_ETDM_RATE_16K = 2,
|
||||
+ MTK_ETDM_RATE_24K = 3,
|
||||
+ MTK_ETDM_RATE_32K = 4,
|
||||
+ MTK_ETDM_RATE_48K = 5,
|
||||
+ MTK_ETDM_RATE_96K = 7,
|
||||
+ MTK_ETDM_RATE_192K = 9,
|
||||
+ MTK_ETDM_RATE_11K = 16,
|
||||
+ MTK_ETDM_RATE_22K = 17,
|
||||
+ MTK_ETDM_RATE_44K = 18,
|
||||
+ MTK_ETDM_RATE_88K = 19,
|
||||
+ MTK_ETDM_RATE_176K = 20,
|
||||
+};
|
||||
+
|
||||
+struct mtk_dai_etdm_priv {
|
||||
+ bool bck_inv;
|
||||
+ bool lrck_inv;
|
||||
+ bool slave_mode;
|
||||
+ unsigned int format;
|
||||
+};
|
||||
+
|
||||
+static unsigned int mt7986_etdm_rate_transform(struct device *dev, unsigned int rate)
|
||||
+{
|
||||
+ switch (rate) {
|
||||
+ case 8000:
|
||||
+ return MTK_ETDM_RATE_8K;
|
||||
+ case 11025:
|
||||
+ return MTK_ETDM_RATE_11K;
|
||||
+ case 12000:
|
||||
+ return MTK_ETDM_RATE_12K;
|
||||
+ case 16000:
|
||||
+ return MTK_ETDM_RATE_16K;
|
||||
+ case 22050:
|
||||
+ return MTK_ETDM_RATE_22K;
|
||||
+ case 24000:
|
||||
+ return MTK_ETDM_RATE_24K;
|
||||
+ case 32000:
|
||||
+ return MTK_ETDM_RATE_32K;
|
||||
+ case 44100:
|
||||
+ return MTK_ETDM_RATE_44K;
|
||||
+ case 48000:
|
||||
+ return MTK_ETDM_RATE_48K;
|
||||
+ case 88200:
|
||||
+ return MTK_ETDM_RATE_88K;
|
||||
+ case 96000:
|
||||
+ return MTK_ETDM_RATE_96K;
|
||||
+ case 176400:
|
||||
+ return MTK_ETDM_RATE_176K;
|
||||
+ case 192000:
|
||||
+ return MTK_ETDM_RATE_192K;
|
||||
+ default:
|
||||
+ dev_warn(dev, "%s(), rate %u invalid, using %d!!!\n",
|
||||
+ __func__, rate, MTK_ETDM_RATE_48K);
|
||||
+ return MTK_ETDM_RATE_48K;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static int get_etdm_wlen(unsigned int bitwidth)
|
||||
+{
|
||||
+ return bitwidth <= 16 ? 16 : 32;
|
||||
+}
|
||||
+
|
||||
+/* dai component */
|
||||
+/* interconnection */
|
||||
+
|
||||
+static const struct snd_kcontrol_new o124_mix[] = {
|
||||
+ SOC_DAPM_SINGLE_AUTODISABLE("I032_Switch", AFE_CONN124_1, 0, 1, 0),
|
||||
+};
|
||||
+
|
||||
+static const struct snd_kcontrol_new o125_mix[] = {
|
||||
+ SOC_DAPM_SINGLE_AUTODISABLE("I033_Switch", AFE_CONN125_1, 1, 1, 0),
|
||||
+};
|
||||
+
|
||||
+static const struct snd_soc_dapm_widget mtk_dai_etdm_widgets[] = {
|
||||
+
|
||||
+ /* DL */
|
||||
+ SND_SOC_DAPM_MIXER("I150", SND_SOC_NOPM, 0, 0, NULL, 0),
|
||||
+ SND_SOC_DAPM_MIXER("I151", SND_SOC_NOPM, 0, 0, NULL, 0),
|
||||
+ /* UL */
|
||||
+ SND_SOC_DAPM_MIXER("O124", SND_SOC_NOPM, 0, 0, o124_mix, ARRAY_SIZE(o124_mix)),
|
||||
+ SND_SOC_DAPM_MIXER("O125", SND_SOC_NOPM, 0, 0, o125_mix, ARRAY_SIZE(o125_mix)),
|
||||
+};
|
||||
+
|
||||
+static const struct snd_soc_dapm_route mtk_dai_etdm_routes[] = {
|
||||
+ {"I150", NULL, "ETDM Capture"},
|
||||
+ {"I151", NULL, "ETDM Capture"},
|
||||
+ {"ETDM Playback", NULL, "O124"},
|
||||
+ {"ETDM Playback", NULL, "O125"},
|
||||
+ {"O124", "I032_Switch", "I032"},
|
||||
+ {"O125", "I033_Switch", "I033"},
|
||||
+};
|
||||
+
|
||||
+/* dai ops */
|
||||
+static int mtk_dai_etdm_startup(struct snd_pcm_substream *substream,
|
||||
+ struct snd_soc_dai *dai)
|
||||
+{
|
||||
+ struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai);
|
||||
+ struct mt7986_afe_private *afe_priv = afe->platform_priv;
|
||||
+ int ret;
|
||||
+
|
||||
+ ret = clk_bulk_prepare_enable(afe_priv->num_clks, afe_priv->clks);
|
||||
+ if (ret)
|
||||
+ return dev_err_probe(afe->dev, ret, "Failed to enable clocks\n");
|
||||
+
|
||||
+ regmap_update_bits(afe->regmap, AUDIO_TOP_CON2, CLK_OUT5_PDN_MASK, 0);
|
||||
+ regmap_update_bits(afe->regmap, AUDIO_TOP_CON2, CLK_IN5_PDN_MASK, 0);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void mtk_dai_etdm_shutdown(struct snd_pcm_substream *substream,
|
||||
+ struct snd_soc_dai *dai)
|
||||
+{
|
||||
+ struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai);
|
||||
+ struct mt7986_afe_private *afe_priv = afe->platform_priv;
|
||||
+
|
||||
+ regmap_update_bits(afe->regmap, AUDIO_TOP_CON2, CLK_OUT5_PDN_MASK,
|
||||
+ CLK_OUT5_PDN);
|
||||
+ regmap_update_bits(afe->regmap, AUDIO_TOP_CON2, CLK_IN5_PDN_MASK,
|
||||
+ CLK_IN5_PDN);
|
||||
+
|
||||
+ clk_bulk_disable_unprepare(afe_priv->num_clks, afe_priv->clks);
|
||||
+}
|
||||
+
|
||||
+static unsigned int get_etdm_ch_fixup(unsigned int channels)
|
||||
+{
|
||||
+ if (channels > 16)
|
||||
+ return 24;
|
||||
+ else if (channels > 8)
|
||||
+ return 16;
|
||||
+ else if (channels > 4)
|
||||
+ return 8;
|
||||
+ else if (channels > 2)
|
||||
+ return 4;
|
||||
+ else
|
||||
+ return 2;
|
||||
+}
|
||||
+
|
||||
+static int mtk_dai_etdm_config(struct mtk_base_afe *afe,
|
||||
+ struct snd_pcm_hw_params *params,
|
||||
+ struct snd_soc_dai *dai,
|
||||
+ int stream)
|
||||
+{
|
||||
+ struct mt7986_afe_private *afe_priv = afe->platform_priv;
|
||||
+ struct mtk_dai_etdm_priv *etdm_data = afe_priv->dai_priv[dai->id];
|
||||
+ unsigned int rate = params_rate(params);
|
||||
+ unsigned int etdm_rate = mt7986_etdm_rate_transform(afe->dev, rate);
|
||||
+ unsigned int afe_rate = mt7986_afe_rate_transform(afe->dev, rate);
|
||||
+ unsigned int channels = params_channels(params);
|
||||
+ unsigned int bit_width = params_width(params);
|
||||
+ unsigned int wlen = get_etdm_wlen(bit_width);
|
||||
+ unsigned int val = 0;
|
||||
+ unsigned int mask = 0;
|
||||
+
|
||||
+ dev_dbg(afe->dev, "%s(), stream %d, rate %u, bitwidth %u\n",
|
||||
+ __func__, stream, rate, bit_width);
|
||||
+
|
||||
+ /* CON0 */
|
||||
+ mask |= ETDM_BIT_LEN_MASK;
|
||||
+ val |= FIELD_PREP(ETDM_BIT_LEN_MASK, bit_width - 1);
|
||||
+ mask |= ETDM_WRD_LEN_MASK;
|
||||
+ val |= FIELD_PREP(ETDM_WRD_LEN_MASK, wlen - 1);
|
||||
+ mask |= ETDM_FMT_MASK;
|
||||
+ val |= FIELD_PREP(ETDM_FMT_MASK, etdm_data->format);
|
||||
+ mask |= ETDM_CH_NUM_MASK;
|
||||
+ val |= FIELD_PREP(ETDM_CH_NUM_MASK, get_etdm_ch_fixup(channels) - 1);
|
||||
+ mask |= RELATCH_SRC_MASK;
|
||||
+ val |= FIELD_PREP(RELATCH_SRC_MASK, APLL_CLK);
|
||||
+
|
||||
+ switch (stream) {
|
||||
+ case SNDRV_PCM_STREAM_PLAYBACK:
|
||||
+ /* set ETDM_OUT5_CON0 */
|
||||
+ regmap_update_bits(afe->regmap, ETDM_OUT5_CON0, mask, val);
|
||||
+
|
||||
+ /* set ETDM_OUT5_CON4 */
|
||||
+ regmap_update_bits(afe->regmap, ETDM_OUT5_CON4,
|
||||
+ OUT_RELATCH_MASK, OUT_RELATCH(afe_rate));
|
||||
+ regmap_update_bits(afe->regmap, ETDM_OUT5_CON4,
|
||||
+ OUT_CLK_SRC_MASK, OUT_CLK_SRC(APLL_CLK));
|
||||
+ regmap_update_bits(afe->regmap, ETDM_OUT5_CON4,
|
||||
+ OUT_SEL_FS_MASK, OUT_SEL_FS(etdm_rate));
|
||||
+
|
||||
+ /* set ETDM_OUT5_CON5 */
|
||||
+ regmap_update_bits(afe->regmap, ETDM_OUT5_CON5,
|
||||
+ ETDM_CLK_DIV_MASK, ETDM_CLK_DIV);
|
||||
+ break;
|
||||
+ case SNDRV_PCM_STREAM_CAPTURE:
|
||||
+ /* set ETDM_IN5_CON0 */
|
||||
+ regmap_update_bits(afe->regmap, ETDM_IN5_CON0, mask, val);
|
||||
+ regmap_update_bits(afe->regmap, ETDM_IN5_CON0,
|
||||
+ ETDM_SYNC_MASK, ETDM_SYNC);
|
||||
+
|
||||
+ /* set ETDM_IN5_CON2 */
|
||||
+ regmap_update_bits(afe->regmap, ETDM_IN5_CON2,
|
||||
+ IN_CLK_SRC_MASK, IN_CLK_SRC(APLL_CLK));
|
||||
+
|
||||
+ /* set ETDM_IN5_CON3 */
|
||||
+ regmap_update_bits(afe->regmap, ETDM_IN5_CON3,
|
||||
+ IN_SEL_FS_MASK, IN_SEL_FS(etdm_rate));
|
||||
+
|
||||
+ /* set ETDM_IN5_CON4 */
|
||||
+ regmap_update_bits(afe->regmap, ETDM_IN5_CON4,
|
||||
+ IN_RELATCH_MASK, IN_RELATCH(afe_rate));
|
||||
+ break;
|
||||
+ default:
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int mtk_dai_etdm_hw_params(struct snd_pcm_substream *substream,
|
||||
+ struct snd_pcm_hw_params *params,
|
||||
+ struct snd_soc_dai *dai)
|
||||
+{
|
||||
+ struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai);
|
||||
+
|
||||
+ mtk_dai_etdm_config(afe, params, dai, SNDRV_PCM_STREAM_PLAYBACK);
|
||||
+ mtk_dai_etdm_config(afe, params, dai, SNDRV_PCM_STREAM_CAPTURE);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int mtk_dai_etdm_trigger(struct snd_pcm_substream *substream, int cmd,
|
||||
+ struct snd_soc_dai *dai)
|
||||
+{
|
||||
+ struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai);
|
||||
+
|
||||
+ dev_dbg(afe->dev, "%s(), cmd %d, dai id %d\n", __func__, cmd, dai->id);
|
||||
+ switch (cmd) {
|
||||
+ case SNDRV_PCM_TRIGGER_START:
|
||||
+ case SNDRV_PCM_TRIGGER_RESUME:
|
||||
+ regmap_update_bits(afe->regmap, ETDM_IN5_CON0, ETDM_EN_MASK,
|
||||
+ ETDM_EN);
|
||||
+ regmap_update_bits(afe->regmap, ETDM_OUT5_CON0, ETDM_EN_MASK,
|
||||
+ ETDM_EN);
|
||||
+ break;
|
||||
+ case SNDRV_PCM_TRIGGER_STOP:
|
||||
+ case SNDRV_PCM_TRIGGER_SUSPEND:
|
||||
+ regmap_update_bits(afe->regmap, ETDM_IN5_CON0, ETDM_EN_MASK,
|
||||
+ 0);
|
||||
+ regmap_update_bits(afe->regmap, ETDM_OUT5_CON0, ETDM_EN_MASK,
|
||||
+ 0);
|
||||
+ break;
|
||||
+ default:
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int mtk_dai_etdm_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
|
||||
+{
|
||||
+ struct mtk_base_afe *afe = snd_soc_dai_get_drvdata(dai);
|
||||
+ struct mt7986_afe_private *afe_priv = afe->platform_priv;
|
||||
+ struct mtk_dai_etdm_priv *etdm_data;
|
||||
+ void *priv_data;
|
||||
+
|
||||
+ switch (dai->id) {
|
||||
+ case MT7986_DAI_ETDM:
|
||||
+ break;
|
||||
+ default:
|
||||
+ dev_warn(afe->dev, "%s(), id %d not support\n",
|
||||
+ __func__, dai->id);
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+
|
||||
+ priv_data = devm_kzalloc(afe->dev, sizeof(struct mtk_dai_etdm_priv),
|
||||
+ GFP_KERNEL);
|
||||
+ if (!priv_data)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ afe_priv->dai_priv[dai->id] = priv_data;
|
||||
+ etdm_data = afe_priv->dai_priv[dai->id];
|
||||
+
|
||||
+ switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
|
||||
+ case SND_SOC_DAIFMT_I2S:
|
||||
+ etdm_data->format = MTK_DAI_ETDM_FORMAT_I2S;
|
||||
+ break;
|
||||
+ case SND_SOC_DAIFMT_DSP_A:
|
||||
+ etdm_data->format = MTK_DAI_ETDM_FORMAT_DSPA;
|
||||
+ break;
|
||||
+ case SND_SOC_DAIFMT_DSP_B:
|
||||
+ etdm_data->format = MTK_DAI_ETDM_FORMAT_DSPB;
|
||||
+ break;
|
||||
+ default:
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+
|
||||
+ switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
|
||||
+ case SND_SOC_DAIFMT_NB_NF:
|
||||
+ etdm_data->bck_inv = false;
|
||||
+ etdm_data->lrck_inv = false;
|
||||
+ break;
|
||||
+ case SND_SOC_DAIFMT_NB_IF:
|
||||
+ etdm_data->bck_inv = false;
|
||||
+ etdm_data->lrck_inv = true;
|
||||
+ break;
|
||||
+ case SND_SOC_DAIFMT_IB_NF:
|
||||
+ etdm_data->bck_inv = true;
|
||||
+ etdm_data->lrck_inv = false;
|
||||
+ break;
|
||||
+ case SND_SOC_DAIFMT_IB_IF:
|
||||
+ etdm_data->bck_inv = true;
|
||||
+ etdm_data->lrck_inv = true;
|
||||
+ break;
|
||||
+ default:
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+
|
||||
+ switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
|
||||
+ case SND_SOC_DAIFMT_CBM_CFM:
|
||||
+ etdm_data->slave_mode = true;
|
||||
+ break;
|
||||
+ case SND_SOC_DAIFMT_CBS_CFS:
|
||||
+ etdm_data->slave_mode = false;
|
||||
+ break;
|
||||
+ default:
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static const struct snd_soc_dai_ops mtk_dai_etdm_ops = {
|
||||
+ .startup = mtk_dai_etdm_startup,
|
||||
+ .shutdown = mtk_dai_etdm_shutdown,
|
||||
+ .hw_params = mtk_dai_etdm_hw_params,
|
||||
+ .trigger = mtk_dai_etdm_trigger,
|
||||
+ .set_fmt = mtk_dai_etdm_set_fmt,
|
||||
+};
|
||||
+
|
||||
+/* dai driver */
|
||||
+#define MTK_ETDM_RATES (SNDRV_PCM_RATE_8000_48000 |\
|
||||
+ SNDRV_PCM_RATE_88200 |\
|
||||
+ SNDRV_PCM_RATE_96000 |\
|
||||
+ SNDRV_PCM_RATE_176400 |\
|
||||
+ SNDRV_PCM_RATE_192000)
|
||||
+
|
||||
+#define MTK_ETDM_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\
|
||||
+ SNDRV_PCM_FMTBIT_S24_LE |\
|
||||
+ SNDRV_PCM_FMTBIT_S32_LE)
|
||||
+
|
||||
+static struct snd_soc_dai_driver mtk_dai_etdm_driver[] = {
|
||||
+ {
|
||||
+ .name = "ETDM",
|
||||
+ .id = MT7986_DAI_ETDM,
|
||||
+ .capture = {
|
||||
+ .stream_name = "ETDM Capture",
|
||||
+ .channels_min = 1,
|
||||
+ .channels_max = 2,
|
||||
+ .rates = MTK_ETDM_RATES,
|
||||
+ .formats = MTK_ETDM_FORMATS,
|
||||
+ },
|
||||
+ .playback = {
|
||||
+ .stream_name = "ETDM Playback",
|
||||
+ .channels_min = 1,
|
||||
+ .channels_max = 2,
|
||||
+ .rates = MTK_ETDM_RATES,
|
||||
+ .formats = MTK_ETDM_FORMATS,
|
||||
+ },
|
||||
+ .ops = &mtk_dai_etdm_ops,
|
||||
+ .symmetric_rate = 1,
|
||||
+ .symmetric_sample_bits = 1,
|
||||
+ },
|
||||
+};
|
||||
+
|
||||
+int mt7986_dai_etdm_register(struct mtk_base_afe *afe)
|
||||
+{
|
||||
+ struct mtk_base_afe_dai *dai;
|
||||
+
|
||||
+ dai = devm_kzalloc(afe->dev, sizeof(*dai), GFP_KERNEL);
|
||||
+ if (!dai)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ list_add(&dai->list, &afe->sub_dais);
|
||||
+
|
||||
+ dai->dai_drivers = mtk_dai_etdm_driver;
|
||||
+ dai->num_dai_drivers = ARRAY_SIZE(mtk_dai_etdm_driver);
|
||||
+
|
||||
+ dai->dapm_widgets = mtk_dai_etdm_widgets;
|
||||
+ dai->num_dapm_widgets = ARRAY_SIZE(mtk_dai_etdm_widgets);
|
||||
+ dai->dapm_routes = mtk_dai_etdm_routes;
|
||||
+ dai->num_dapm_routes = ARRAY_SIZE(mtk_dai_etdm_routes);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
@ -1,685 +0,0 @@
|
||||
From fc7776dee86bc07d22820a904760a95f49a2f12e Mon Sep 17 00:00:00 2001
|
||||
From: Maso Huang <maso.huang@mediatek.com>
|
||||
Date: Thu, 17 Aug 2023 18:13:35 +0800
|
||||
Subject: [PATCH 3/9] ASoC: mediatek: mt7986: add platform driver
|
||||
|
||||
Add mt7986 platform driver.
|
||||
|
||||
Signed-off-by: Maso Huang <maso.huang@mediatek.com>
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Link: https://lore.kernel.org/r/20230817101338.18782-4-maso.huang@mediatek.com
|
||||
Signed-off-by: Mark Brown <broonie@kernel.org>
|
||||
---
|
||||
sound/soc/mediatek/Kconfig | 10 +
|
||||
sound/soc/mediatek/Makefile | 1 +
|
||||
sound/soc/mediatek/mt7986/Makefile | 8 +
|
||||
sound/soc/mediatek/mt7986/mt7986-afe-pcm.c | 622 +++++++++++++++++++++
|
||||
4 files changed, 641 insertions(+)
|
||||
create mode 100644 sound/soc/mediatek/mt7986/Makefile
|
||||
create mode 100644 sound/soc/mediatek/mt7986/mt7986-afe-pcm.c
|
||||
|
||||
--- a/sound/soc/mediatek/Kconfig
|
||||
+++ b/sound/soc/mediatek/Kconfig
|
||||
@@ -54,6 +54,16 @@ config SND_SOC_MT6797_MT6351
|
||||
Select Y if you have such device.
|
||||
If unsure select "N".
|
||||
|
||||
+config SND_SOC_MT7986
|
||||
+ tristate "ASoC support for Mediatek MT7986 chip"
|
||||
+ depends on ARCH_MEDIATEK
|
||||
+ select SND_SOC_MEDIATEK
|
||||
+ help
|
||||
+ This adds ASoC platform driver support for MediaTek MT7986 chip
|
||||
+ that can be used with other codecs.
|
||||
+ Select Y if you have such device.
|
||||
+ If unsure select "N".
|
||||
+
|
||||
config SND_SOC_MT8173
|
||||
tristate "ASoC support for Mediatek MT8173 chip"
|
||||
depends on ARCH_MEDIATEK
|
||||
--- a/sound/soc/mediatek/Makefile
|
||||
+++ b/sound/soc/mediatek/Makefile
|
||||
@@ -2,6 +2,7 @@
|
||||
obj-$(CONFIG_SND_SOC_MEDIATEK) += common/
|
||||
obj-$(CONFIG_SND_SOC_MT2701) += mt2701/
|
||||
obj-$(CONFIG_SND_SOC_MT6797) += mt6797/
|
||||
+obj-$(CONFIG_SND_SOC_MT7986) += mt7986/
|
||||
obj-$(CONFIG_SND_SOC_MT8173) += mt8173/
|
||||
obj-$(CONFIG_SND_SOC_MT8183) += mt8183/
|
||||
obj-$(CONFIG_SND_SOC_MT8186) += mt8186/
|
||||
--- /dev/null
|
||||
+++ b/sound/soc/mediatek/mt7986/Makefile
|
||||
@@ -0,0 +1,8 @@
|
||||
+# SPDX-License-Identifier: GPL-2.0
|
||||
+
|
||||
+# platform driver
|
||||
+snd-soc-mt7986-afe-objs := \
|
||||
+ mt7986-afe-pcm.o \
|
||||
+ mt7986-dai-etdm.o
|
||||
+
|
||||
+obj-$(CONFIG_SND_SOC_MT7986) += snd-soc-mt7986-afe.o
|
||||
--- /dev/null
|
||||
+++ b/sound/soc/mediatek/mt7986/mt7986-afe-pcm.c
|
||||
@@ -0,0 +1,622 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0
|
||||
+/*
|
||||
+ * MediaTek ALSA SoC AFE platform driver for MT7986
|
||||
+ *
|
||||
+ * Copyright (c) 2023 MediaTek Inc.
|
||||
+ * Authors: Vic Wu <vic.wu@mediatek.com>
|
||||
+ * Maso Huang <maso.huang@mediatek.com>
|
||||
+ */
|
||||
+
|
||||
+#include <linux/clk.h>
|
||||
+#include <linux/delay.h>
|
||||
+#include <linux/module.h>
|
||||
+#include <linux/of.h>
|
||||
+#include <linux/of_address.h>
|
||||
+#include <linux/pm_runtime.h>
|
||||
+
|
||||
+#include "mt7986-afe-common.h"
|
||||
+#include "mt7986-reg.h"
|
||||
+#include "../common/mtk-afe-platform-driver.h"
|
||||
+#include "../common/mtk-afe-fe-dai.h"
|
||||
+
|
||||
+enum {
|
||||
+ MTK_AFE_RATE_8K = 0,
|
||||
+ MTK_AFE_RATE_11K = 1,
|
||||
+ MTK_AFE_RATE_12K = 2,
|
||||
+ MTK_AFE_RATE_16K = 4,
|
||||
+ MTK_AFE_RATE_22K = 5,
|
||||
+ MTK_AFE_RATE_24K = 6,
|
||||
+ MTK_AFE_RATE_32K = 8,
|
||||
+ MTK_AFE_RATE_44K = 9,
|
||||
+ MTK_AFE_RATE_48K = 10,
|
||||
+ MTK_AFE_RATE_88K = 13,
|
||||
+ MTK_AFE_RATE_96K = 14,
|
||||
+ MTK_AFE_RATE_176K = 17,
|
||||
+ MTK_AFE_RATE_192K = 18,
|
||||
+};
|
||||
+
|
||||
+enum {
|
||||
+ CLK_INFRA_AUD_BUS_CK = 0,
|
||||
+ CLK_INFRA_AUD_26M_CK,
|
||||
+ CLK_INFRA_AUD_L_CK,
|
||||
+ CLK_INFRA_AUD_AUD_CK,
|
||||
+ CLK_INFRA_AUD_EG2_CK,
|
||||
+ CLK_NUM
|
||||
+};
|
||||
+
|
||||
+static const char *aud_clks[CLK_NUM] = {
|
||||
+ [CLK_INFRA_AUD_BUS_CK] = "aud_bus_ck",
|
||||
+ [CLK_INFRA_AUD_26M_CK] = "aud_26m_ck",
|
||||
+ [CLK_INFRA_AUD_L_CK] = "aud_l_ck",
|
||||
+ [CLK_INFRA_AUD_AUD_CK] = "aud_aud_ck",
|
||||
+ [CLK_INFRA_AUD_EG2_CK] = "aud_eg2_ck",
|
||||
+};
|
||||
+
|
||||
+unsigned int mt7986_afe_rate_transform(struct device *dev, unsigned int rate)
|
||||
+{
|
||||
+ switch (rate) {
|
||||
+ case 8000:
|
||||
+ return MTK_AFE_RATE_8K;
|
||||
+ case 11025:
|
||||
+ return MTK_AFE_RATE_11K;
|
||||
+ case 12000:
|
||||
+ return MTK_AFE_RATE_12K;
|
||||
+ case 16000:
|
||||
+ return MTK_AFE_RATE_16K;
|
||||
+ case 22050:
|
||||
+ return MTK_AFE_RATE_22K;
|
||||
+ case 24000:
|
||||
+ return MTK_AFE_RATE_24K;
|
||||
+ case 32000:
|
||||
+ return MTK_AFE_RATE_32K;
|
||||
+ case 44100:
|
||||
+ return MTK_AFE_RATE_44K;
|
||||
+ case 48000:
|
||||
+ return MTK_AFE_RATE_48K;
|
||||
+ case 88200:
|
||||
+ return MTK_AFE_RATE_88K;
|
||||
+ case 96000:
|
||||
+ return MTK_AFE_RATE_96K;
|
||||
+ case 176400:
|
||||
+ return MTK_AFE_RATE_176K;
|
||||
+ case 192000:
|
||||
+ return MTK_AFE_RATE_192K;
|
||||
+ default:
|
||||
+ dev_warn(dev, "%s(), rate %u invalid, using %d!!!\n",
|
||||
+ __func__, rate, MTK_AFE_RATE_48K);
|
||||
+ return MTK_AFE_RATE_48K;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static const struct snd_pcm_hardware mt7986_afe_hardware = {
|
||||
+ .info = SNDRV_PCM_INFO_MMAP |
|
||||
+ SNDRV_PCM_INFO_INTERLEAVED |
|
||||
+ SNDRV_PCM_INFO_MMAP_VALID,
|
||||
+ .formats = SNDRV_PCM_FMTBIT_S16_LE |
|
||||
+ SNDRV_PCM_FMTBIT_S24_LE |
|
||||
+ SNDRV_PCM_FMTBIT_S32_LE,
|
||||
+ .period_bytes_min = 256,
|
||||
+ .period_bytes_max = 4 * 48 * 1024,
|
||||
+ .periods_min = 2,
|
||||
+ .periods_max = 256,
|
||||
+ .buffer_bytes_max = 8 * 48 * 1024,
|
||||
+ .fifo_size = 0,
|
||||
+};
|
||||
+
|
||||
+static int mt7986_memif_fs(struct snd_pcm_substream *substream,
|
||||
+ unsigned int rate)
|
||||
+{
|
||||
+ struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
||||
+ struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
|
||||
+ struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);
|
||||
+
|
||||
+ return mt7986_afe_rate_transform(afe->dev, rate);
|
||||
+}
|
||||
+
|
||||
+static int mt7986_irq_fs(struct snd_pcm_substream *substream,
|
||||
+ unsigned int rate)
|
||||
+{
|
||||
+ struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
||||
+ struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
|
||||
+ struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);
|
||||
+
|
||||
+ return mt7986_afe_rate_transform(afe->dev, rate);
|
||||
+}
|
||||
+
|
||||
+#define MTK_PCM_RATES (SNDRV_PCM_RATE_8000_48000 |\
|
||||
+ SNDRV_PCM_RATE_88200 |\
|
||||
+ SNDRV_PCM_RATE_96000 |\
|
||||
+ SNDRV_PCM_RATE_176400 |\
|
||||
+ SNDRV_PCM_RATE_192000)
|
||||
+
|
||||
+#define MTK_PCM_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\
|
||||
+ SNDRV_PCM_FMTBIT_S24_LE |\
|
||||
+ SNDRV_PCM_FMTBIT_S32_LE)
|
||||
+
|
||||
+static struct snd_soc_dai_driver mt7986_memif_dai_driver[] = {
|
||||
+ /* FE DAIs: memory intefaces to CPU */
|
||||
+ {
|
||||
+ .name = "DL1",
|
||||
+ .id = MT7986_MEMIF_DL1,
|
||||
+ .playback = {
|
||||
+ .stream_name = "DL1",
|
||||
+ .channels_min = 1,
|
||||
+ .channels_max = 2,
|
||||
+ .rates = MTK_PCM_RATES,
|
||||
+ .formats = MTK_PCM_FORMATS,
|
||||
+ },
|
||||
+ .ops = &mtk_afe_fe_ops,
|
||||
+ },
|
||||
+ {
|
||||
+ .name = "UL1",
|
||||
+ .id = MT7986_MEMIF_VUL12,
|
||||
+ .capture = {
|
||||
+ .stream_name = "UL1",
|
||||
+ .channels_min = 1,
|
||||
+ .channels_max = 2,
|
||||
+ .rates = MTK_PCM_RATES,
|
||||
+ .formats = MTK_PCM_FORMATS,
|
||||
+ },
|
||||
+ .ops = &mtk_afe_fe_ops,
|
||||
+ },
|
||||
+};
|
||||
+
|
||||
+static const struct snd_kcontrol_new o018_mix[] = {
|
||||
+ SOC_DAPM_SINGLE_AUTODISABLE("I150_Switch", AFE_CONN018_4, 22, 1, 0),
|
||||
+};
|
||||
+
|
||||
+static const struct snd_kcontrol_new o019_mix[] = {
|
||||
+ SOC_DAPM_SINGLE_AUTODISABLE("I151_Switch", AFE_CONN019_4, 23, 1, 0),
|
||||
+};
|
||||
+
|
||||
+static const struct snd_soc_dapm_widget mt7986_memif_widgets[] = {
|
||||
+ /* DL */
|
||||
+ SND_SOC_DAPM_MIXER("I032", SND_SOC_NOPM, 0, 0, NULL, 0),
|
||||
+ SND_SOC_DAPM_MIXER("I033", SND_SOC_NOPM, 0, 0, NULL, 0),
|
||||
+
|
||||
+ /* UL */
|
||||
+ SND_SOC_DAPM_MIXER("O018", SND_SOC_NOPM, 0, 0,
|
||||
+ o018_mix, ARRAY_SIZE(o018_mix)),
|
||||
+ SND_SOC_DAPM_MIXER("O019", SND_SOC_NOPM, 0, 0,
|
||||
+ o019_mix, ARRAY_SIZE(o019_mix)),
|
||||
+};
|
||||
+
|
||||
+static const struct snd_soc_dapm_route mt7986_memif_routes[] = {
|
||||
+ {"I032", NULL, "DL1"},
|
||||
+ {"I033", NULL, "DL1"},
|
||||
+ {"UL1", NULL, "O018"},
|
||||
+ {"UL1", NULL, "O019"},
|
||||
+ {"O018", "I150_Switch", "I150"},
|
||||
+ {"O019", "I151_Switch", "I151"},
|
||||
+};
|
||||
+
|
||||
+static const struct snd_soc_component_driver mt7986_afe_pcm_dai_component = {
|
||||
+ .name = "mt7986-afe-pcm-dai",
|
||||
+};
|
||||
+
|
||||
+static const struct mtk_base_memif_data memif_data[MT7986_MEMIF_NUM] = {
|
||||
+ [MT7986_MEMIF_DL1] = {
|
||||
+ .name = "DL1",
|
||||
+ .id = MT7986_MEMIF_DL1,
|
||||
+ .reg_ofs_base = AFE_DL0_BASE,
|
||||
+ .reg_ofs_cur = AFE_DL0_CUR,
|
||||
+ .reg_ofs_end = AFE_DL0_END,
|
||||
+ .reg_ofs_base_msb = AFE_DL0_BASE_MSB,
|
||||
+ .reg_ofs_cur_msb = AFE_DL0_CUR_MSB,
|
||||
+ .reg_ofs_end_msb = AFE_DL0_END_MSB,
|
||||
+ .fs_reg = AFE_DL0_CON0,
|
||||
+ .fs_shift = DL0_MODE_SFT,
|
||||
+ .fs_maskbit = DL0_MODE_MASK,
|
||||
+ .mono_reg = AFE_DL0_CON0,
|
||||
+ .mono_shift = DL0_MONO_SFT,
|
||||
+ .enable_reg = AFE_DL0_CON0,
|
||||
+ .enable_shift = DL0_ON_SFT,
|
||||
+ .hd_reg = AFE_DL0_CON0,
|
||||
+ .hd_shift = DL0_HD_MODE_SFT,
|
||||
+ .hd_align_reg = AFE_DL0_CON0,
|
||||
+ .hd_align_mshift = DL0_HALIGN_SFT,
|
||||
+ .pbuf_reg = AFE_DL0_CON0,
|
||||
+ .pbuf_shift = DL0_PBUF_SIZE_SFT,
|
||||
+ .minlen_reg = AFE_DL0_CON0,
|
||||
+ .minlen_shift = DL0_MINLEN_SFT,
|
||||
+ },
|
||||
+ [MT7986_MEMIF_VUL12] = {
|
||||
+ .name = "VUL12",
|
||||
+ .id = MT7986_MEMIF_VUL12,
|
||||
+ .reg_ofs_base = AFE_VUL0_BASE,
|
||||
+ .reg_ofs_cur = AFE_VUL0_CUR,
|
||||
+ .reg_ofs_end = AFE_VUL0_END,
|
||||
+ .reg_ofs_base_msb = AFE_VUL0_BASE_MSB,
|
||||
+ .reg_ofs_cur_msb = AFE_VUL0_CUR_MSB,
|
||||
+ .reg_ofs_end_msb = AFE_VUL0_END_MSB,
|
||||
+ .fs_reg = AFE_VUL0_CON0,
|
||||
+ .fs_shift = VUL0_MODE_SFT,
|
||||
+ .fs_maskbit = VUL0_MODE_MASK,
|
||||
+ .mono_reg = AFE_VUL0_CON0,
|
||||
+ .mono_shift = VUL0_MONO_SFT,
|
||||
+ .enable_reg = AFE_VUL0_CON0,
|
||||
+ .enable_shift = VUL0_ON_SFT,
|
||||
+ .hd_reg = AFE_VUL0_CON0,
|
||||
+ .hd_shift = VUL0_HD_MODE_SFT,
|
||||
+ .hd_align_reg = AFE_VUL0_CON0,
|
||||
+ .hd_align_mshift = VUL0_HALIGN_SFT,
|
||||
+ },
|
||||
+};
|
||||
+
|
||||
+static const struct mtk_base_irq_data irq_data[MT7986_IRQ_NUM] = {
|
||||
+ [MT7986_IRQ_0] = {
|
||||
+ .id = MT7986_IRQ_0,
|
||||
+ .irq_cnt_reg = AFE_IRQ0_MCU_CFG1,
|
||||
+ .irq_cnt_shift = AFE_IRQ_CNT_SHIFT,
|
||||
+ .irq_cnt_maskbit = AFE_IRQ_CNT_MASK,
|
||||
+ .irq_fs_reg = AFE_IRQ0_MCU_CFG0,
|
||||
+ .irq_fs_shift = IRQ_MCU_MODE_SFT,
|
||||
+ .irq_fs_maskbit = IRQ_MCU_MODE_MASK,
|
||||
+ .irq_en_reg = AFE_IRQ0_MCU_CFG0,
|
||||
+ .irq_en_shift = IRQ_MCU_ON_SFT,
|
||||
+ .irq_clr_reg = AFE_IRQ_MCU_CLR,
|
||||
+ .irq_clr_shift = IRQ0_MCU_CLR_SFT,
|
||||
+ },
|
||||
+ [MT7986_IRQ_1] = {
|
||||
+ .id = MT7986_IRQ_1,
|
||||
+ .irq_cnt_reg = AFE_IRQ1_MCU_CFG1,
|
||||
+ .irq_cnt_shift = AFE_IRQ_CNT_SHIFT,
|
||||
+ .irq_cnt_maskbit = AFE_IRQ_CNT_MASK,
|
||||
+ .irq_fs_reg = AFE_IRQ1_MCU_CFG0,
|
||||
+ .irq_fs_shift = IRQ_MCU_MODE_SFT,
|
||||
+ .irq_fs_maskbit = IRQ_MCU_MODE_MASK,
|
||||
+ .irq_en_reg = AFE_IRQ1_MCU_CFG0,
|
||||
+ .irq_en_shift = IRQ_MCU_ON_SFT,
|
||||
+ .irq_clr_reg = AFE_IRQ_MCU_CLR,
|
||||
+ .irq_clr_shift = IRQ1_MCU_CLR_SFT,
|
||||
+ },
|
||||
+ [MT7986_IRQ_2] = {
|
||||
+ .id = MT7986_IRQ_2,
|
||||
+ .irq_cnt_reg = AFE_IRQ2_MCU_CFG1,
|
||||
+ .irq_cnt_shift = AFE_IRQ_CNT_SHIFT,
|
||||
+ .irq_cnt_maskbit = AFE_IRQ_CNT_MASK,
|
||||
+ .irq_fs_reg = AFE_IRQ2_MCU_CFG0,
|
||||
+ .irq_fs_shift = IRQ_MCU_MODE_SFT,
|
||||
+ .irq_fs_maskbit = IRQ_MCU_MODE_MASK,
|
||||
+ .irq_en_reg = AFE_IRQ2_MCU_CFG0,
|
||||
+ .irq_en_shift = IRQ_MCU_ON_SFT,
|
||||
+ .irq_clr_reg = AFE_IRQ_MCU_CLR,
|
||||
+ .irq_clr_shift = IRQ2_MCU_CLR_SFT,
|
||||
+ },
|
||||
+};
|
||||
+
|
||||
+static bool mt7986_is_volatile_reg(struct device *dev, unsigned int reg)
|
||||
+{
|
||||
+ /*
|
||||
+ * Those auto-gen regs are read-only, so put it as volatile because
|
||||
+ * volatile registers cannot be cached, which means that they cannot
|
||||
+ * be set when power is off
|
||||
+ */
|
||||
+
|
||||
+ switch (reg) {
|
||||
+ case AFE_DL0_CUR_MSB:
|
||||
+ case AFE_DL0_CUR:
|
||||
+ case AFE_DL0_RCH_MON:
|
||||
+ case AFE_DL0_LCH_MON:
|
||||
+ case AFE_VUL0_CUR_MSB:
|
||||
+ case AFE_VUL0_CUR:
|
||||
+ case AFE_IRQ_MCU_STATUS:
|
||||
+ case AFE_MEMIF_RD_MON:
|
||||
+ case AFE_MEMIF_WR_MON:
|
||||
+ return true;
|
||||
+ default:
|
||||
+ return false;
|
||||
+ };
|
||||
+}
|
||||
+
|
||||
+static const struct regmap_config mt7986_afe_regmap_config = {
|
||||
+ .reg_bits = 32,
|
||||
+ .reg_stride = 4,
|
||||
+ .val_bits = 32,
|
||||
+ .volatile_reg = mt7986_is_volatile_reg,
|
||||
+ .max_register = AFE_MAX_REGISTER,
|
||||
+ .num_reg_defaults_raw = ((AFE_MAX_REGISTER / 4) + 1),
|
||||
+};
|
||||
+
|
||||
+static int mt7986_init_clock(struct mtk_base_afe *afe)
|
||||
+{
|
||||
+ struct mt7986_afe_private *afe_priv = afe->platform_priv;
|
||||
+ int ret, i;
|
||||
+
|
||||
+ afe_priv->clks = devm_kcalloc(afe->dev, CLK_NUM,
|
||||
+ sizeof(*afe_priv->clks), GFP_KERNEL);
|
||||
+ if (!afe_priv->clks)
|
||||
+ return -ENOMEM;
|
||||
+ afe_priv->num_clks = CLK_NUM;
|
||||
+
|
||||
+ for (i = 0; i < afe_priv->num_clks; i++)
|
||||
+ afe_priv->clks[i].id = aud_clks[i];
|
||||
+
|
||||
+ ret = devm_clk_bulk_get(afe->dev, afe_priv->num_clks, afe_priv->clks);
|
||||
+ if (ret)
|
||||
+ return dev_err_probe(afe->dev, ret, "Failed to get clocks\n");
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static irqreturn_t mt7986_afe_irq_handler(int irq_id, void *dev)
|
||||
+{
|
||||
+ struct mtk_base_afe *afe = dev;
|
||||
+ struct mtk_base_afe_irq *irq;
|
||||
+ u32 mcu_en, status, status_mcu;
|
||||
+ int i, ret;
|
||||
+ irqreturn_t irq_ret = IRQ_HANDLED;
|
||||
+
|
||||
+ /* get irq that is sent to MCU */
|
||||
+ regmap_read(afe->regmap, AFE_IRQ_MCU_EN, &mcu_en);
|
||||
+
|
||||
+ ret = regmap_read(afe->regmap, AFE_IRQ_MCU_STATUS, &status);
|
||||
+ /* only care IRQ which is sent to MCU */
|
||||
+ status_mcu = status & mcu_en & AFE_IRQ_STATUS_BITS;
|
||||
+
|
||||
+ if (ret || status_mcu == 0) {
|
||||
+ dev_err(afe->dev, "%s(), irq status err, ret %d, status 0x%x, mcu_en 0x%x\n",
|
||||
+ __func__, ret, status, mcu_en);
|
||||
+
|
||||
+ irq_ret = IRQ_NONE;
|
||||
+ goto err_irq;
|
||||
+ }
|
||||
+
|
||||
+ for (i = 0; i < MT7986_MEMIF_NUM; i++) {
|
||||
+ struct mtk_base_afe_memif *memif = &afe->memif[i];
|
||||
+
|
||||
+ if (!memif->substream)
|
||||
+ continue;
|
||||
+
|
||||
+ if (memif->irq_usage < 0)
|
||||
+ continue;
|
||||
+
|
||||
+ irq = &afe->irqs[memif->irq_usage];
|
||||
+
|
||||
+ if (status_mcu & (1 << irq->irq_data->irq_en_shift))
|
||||
+ snd_pcm_period_elapsed(memif->substream);
|
||||
+ }
|
||||
+
|
||||
+err_irq:
|
||||
+ /* clear irq */
|
||||
+ regmap_write(afe->regmap, AFE_IRQ_MCU_CLR, status_mcu);
|
||||
+
|
||||
+ return irq_ret;
|
||||
+}
|
||||
+
|
||||
+static int mt7986_afe_runtime_suspend(struct device *dev)
|
||||
+{
|
||||
+ struct mtk_base_afe *afe = dev_get_drvdata(dev);
|
||||
+ struct mt7986_afe_private *afe_priv = afe->platform_priv;
|
||||
+
|
||||
+ if (!afe->regmap || afe_priv->pm_runtime_bypass_reg_ctl)
|
||||
+ goto skip_regmap;
|
||||
+
|
||||
+ /* disable clk*/
|
||||
+ regmap_update_bits(afe->regmap, AUDIO_TOP_CON4, 0x3fff, 0x3fff);
|
||||
+ regmap_update_bits(afe->regmap, AUDIO_ENGEN_CON0, AUD_APLL2_EN_MASK, 0);
|
||||
+ regmap_update_bits(afe->regmap, AUDIO_ENGEN_CON0, AUD_26M_EN_MASK, 0);
|
||||
+
|
||||
+ /* make sure all irq status are cleared, twice intended */
|
||||
+ regmap_update_bits(afe->regmap, AFE_IRQ_MCU_CLR, 0xffff, 0xffff);
|
||||
+
|
||||
+skip_regmap:
|
||||
+ clk_bulk_disable_unprepare(afe_priv->num_clks, afe_priv->clks);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int mt7986_afe_runtime_resume(struct device *dev)
|
||||
+{
|
||||
+ struct mtk_base_afe *afe = dev_get_drvdata(dev);
|
||||
+ struct mt7986_afe_private *afe_priv = afe->platform_priv;
|
||||
+ int ret;
|
||||
+
|
||||
+ ret = clk_bulk_prepare_enable(afe_priv->num_clks, afe_priv->clks);
|
||||
+ if (ret)
|
||||
+ return dev_err_probe(afe->dev, ret, "Failed to enable clocks\n");
|
||||
+
|
||||
+ if (!afe->regmap || afe_priv->pm_runtime_bypass_reg_ctl)
|
||||
+ return 0;
|
||||
+
|
||||
+ /* enable clk*/
|
||||
+ regmap_update_bits(afe->regmap, AUDIO_TOP_CON4, 0x3fff, 0);
|
||||
+ regmap_update_bits(afe->regmap, AUDIO_ENGEN_CON0, AUD_APLL2_EN_MASK,
|
||||
+ AUD_APLL2_EN);
|
||||
+ regmap_update_bits(afe->regmap, AUDIO_ENGEN_CON0, AUD_26M_EN_MASK,
|
||||
+ AUD_26M_EN);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int mt7986_afe_component_probe(struct snd_soc_component *component)
|
||||
+{
|
||||
+ return mtk_afe_add_sub_dai_control(component);
|
||||
+}
|
||||
+
|
||||
+static const struct snd_soc_component_driver mt7986_afe_component = {
|
||||
+ .name = AFE_PCM_NAME,
|
||||
+ .probe = mt7986_afe_component_probe,
|
||||
+ .pointer = mtk_afe_pcm_pointer,
|
||||
+ .pcm_construct = mtk_afe_pcm_new,
|
||||
+};
|
||||
+
|
||||
+static int mt7986_dai_memif_register(struct mtk_base_afe *afe)
|
||||
+{
|
||||
+ struct mtk_base_afe_dai *dai;
|
||||
+
|
||||
+ dai = devm_kzalloc(afe->dev, sizeof(*dai), GFP_KERNEL);
|
||||
+ if (!dai)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ list_add(&dai->list, &afe->sub_dais);
|
||||
+
|
||||
+ dai->dai_drivers = mt7986_memif_dai_driver;
|
||||
+ dai->num_dai_drivers = ARRAY_SIZE(mt7986_memif_dai_driver);
|
||||
+
|
||||
+ dai->dapm_widgets = mt7986_memif_widgets;
|
||||
+ dai->num_dapm_widgets = ARRAY_SIZE(mt7986_memif_widgets);
|
||||
+ dai->dapm_routes = mt7986_memif_routes;
|
||||
+ dai->num_dapm_routes = ARRAY_SIZE(mt7986_memif_routes);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+typedef int (*dai_register_cb)(struct mtk_base_afe *);
|
||||
+static const dai_register_cb dai_register_cbs[] = {
|
||||
+ mt7986_dai_etdm_register,
|
||||
+ mt7986_dai_memif_register,
|
||||
+};
|
||||
+
|
||||
+static int mt7986_afe_pcm_dev_probe(struct platform_device *pdev)
|
||||
+{
|
||||
+ struct mtk_base_afe *afe;
|
||||
+ struct mt7986_afe_private *afe_priv;
|
||||
+ struct device *dev;
|
||||
+ int i, irq_id, ret;
|
||||
+
|
||||
+ afe = devm_kzalloc(&pdev->dev, sizeof(*afe), GFP_KERNEL);
|
||||
+ if (!afe)
|
||||
+ return -ENOMEM;
|
||||
+ platform_set_drvdata(pdev, afe);
|
||||
+
|
||||
+ afe->platform_priv = devm_kzalloc(&pdev->dev, sizeof(*afe_priv),
|
||||
+ GFP_KERNEL);
|
||||
+ if (!afe->platform_priv)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ afe_priv = afe->platform_priv;
|
||||
+ afe->dev = &pdev->dev;
|
||||
+ dev = afe->dev;
|
||||
+
|
||||
+ afe->base_addr = devm_platform_ioremap_resource(pdev, 0);
|
||||
+ if (IS_ERR(afe->base_addr))
|
||||
+ return PTR_ERR(afe->base_addr);
|
||||
+
|
||||
+ /* initial audio related clock */
|
||||
+ ret = mt7986_init_clock(afe);
|
||||
+ if (ret)
|
||||
+ return dev_err_probe(dev, ret, "Cannot initialize clocks\n");
|
||||
+
|
||||
+ ret = devm_pm_runtime_enable(dev);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+ /* enable clock for regcache get default value from hw */
|
||||
+ afe_priv->pm_runtime_bypass_reg_ctl = true;
|
||||
+ pm_runtime_get_sync(&pdev->dev);
|
||||
+
|
||||
+ afe->regmap = devm_regmap_init_mmio(&pdev->dev, afe->base_addr,
|
||||
+ &mt7986_afe_regmap_config);
|
||||
+
|
||||
+ pm_runtime_put_sync(&pdev->dev);
|
||||
+ if (IS_ERR(afe->regmap))
|
||||
+ return PTR_ERR(afe->regmap);
|
||||
+
|
||||
+ afe_priv->pm_runtime_bypass_reg_ctl = false;
|
||||
+
|
||||
+ /* init memif */
|
||||
+ afe->memif_size = MT7986_MEMIF_NUM;
|
||||
+ afe->memif = devm_kcalloc(dev, afe->memif_size, sizeof(*afe->memif),
|
||||
+ GFP_KERNEL);
|
||||
+ if (!afe->memif)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ for (i = 0; i < afe->memif_size; i++) {
|
||||
+ afe->memif[i].data = &memif_data[i];
|
||||
+ afe->memif[i].irq_usage = -1;
|
||||
+ }
|
||||
+
|
||||
+ mutex_init(&afe->irq_alloc_lock);
|
||||
+
|
||||
+ /* irq initialize */
|
||||
+ afe->irqs_size = MT7986_IRQ_NUM;
|
||||
+ afe->irqs = devm_kcalloc(dev, afe->irqs_size, sizeof(*afe->irqs),
|
||||
+ GFP_KERNEL);
|
||||
+ if (!afe->irqs)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ for (i = 0; i < afe->irqs_size; i++)
|
||||
+ afe->irqs[i].irq_data = &irq_data[i];
|
||||
+
|
||||
+ /* request irq */
|
||||
+ irq_id = platform_get_irq(pdev, 0);
|
||||
+ if (irq_id < 0) {
|
||||
+ ret = irq_id;
|
||||
+ return dev_err_probe(dev, ret, "No irq found\n");
|
||||
+ }
|
||||
+ ret = devm_request_irq(dev, irq_id, mt7986_afe_irq_handler,
|
||||
+ IRQF_TRIGGER_NONE, "asys-isr", (void *)afe);
|
||||
+ if (ret)
|
||||
+ return dev_err_probe(dev, ret, "Failed to request irq for asys-isr\n");
|
||||
+
|
||||
+ /* init sub_dais */
|
||||
+ INIT_LIST_HEAD(&afe->sub_dais);
|
||||
+
|
||||
+ for (i = 0; i < ARRAY_SIZE(dai_register_cbs); i++) {
|
||||
+ ret = dai_register_cbs[i](afe);
|
||||
+ if (ret)
|
||||
+ return dev_err_probe(dev, ret, "DAI register failed, i: %d\n", i);
|
||||
+ }
|
||||
+
|
||||
+ /* init dai_driver and component_driver */
|
||||
+ ret = mtk_afe_combine_sub_dai(afe);
|
||||
+ if (ret)
|
||||
+ return dev_err_probe(dev, ret, "mtk_afe_combine_sub_dai fail\n");
|
||||
+
|
||||
+ afe->mtk_afe_hardware = &mt7986_afe_hardware;
|
||||
+ afe->memif_fs = mt7986_memif_fs;
|
||||
+ afe->irq_fs = mt7986_irq_fs;
|
||||
+
|
||||
+ afe->runtime_resume = mt7986_afe_runtime_resume;
|
||||
+ afe->runtime_suspend = mt7986_afe_runtime_suspend;
|
||||
+
|
||||
+ /* register component */
|
||||
+ ret = devm_snd_soc_register_component(&pdev->dev,
|
||||
+ &mt7986_afe_component,
|
||||
+ NULL, 0);
|
||||
+ if (ret)
|
||||
+ return dev_err_probe(dev, ret, "Cannot register AFE component\n");
|
||||
+
|
||||
+ ret = devm_snd_soc_register_component(afe->dev,
|
||||
+ &mt7986_afe_pcm_dai_component,
|
||||
+ afe->dai_drivers,
|
||||
+ afe->num_dai_drivers);
|
||||
+ if (ret)
|
||||
+ return dev_err_probe(dev, ret, "Cannot register PCM DAI component\n");
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void mt7986_afe_pcm_dev_remove(struct platform_device *pdev)
|
||||
+{
|
||||
+ pm_runtime_disable(&pdev->dev);
|
||||
+ if (!pm_runtime_status_suspended(&pdev->dev))
|
||||
+ mt7986_afe_runtime_suspend(&pdev->dev);
|
||||
+}
|
||||
+
|
||||
+static const struct of_device_id mt7986_afe_pcm_dt_match[] = {
|
||||
+ { .compatible = "mediatek,mt7986-afe" },
|
||||
+ { /* sentinel */ }
|
||||
+};
|
||||
+MODULE_DEVICE_TABLE(of, mt7986_afe_pcm_dt_match);
|
||||
+
|
||||
+static const struct dev_pm_ops mt7986_afe_pm_ops = {
|
||||
+ SET_RUNTIME_PM_OPS(mt7986_afe_runtime_suspend,
|
||||
+ mt7986_afe_runtime_resume, NULL)
|
||||
+};
|
||||
+
|
||||
+static struct platform_driver mt7986_afe_pcm_driver = {
|
||||
+ .driver = {
|
||||
+ .name = "mt7986-audio",
|
||||
+ .of_match_table = mt7986_afe_pcm_dt_match,
|
||||
+ .pm = &mt7986_afe_pm_ops,
|
||||
+ },
|
||||
+ .probe = mt7986_afe_pcm_dev_probe,
|
||||
+ .remove_new = mt7986_afe_pcm_dev_remove,
|
||||
+};
|
||||
+module_platform_driver(mt7986_afe_pcm_driver);
|
||||
+
|
||||
+MODULE_DESCRIPTION("MediaTek SoC AFE platform driver for ALSA MT7986");
|
||||
+MODULE_AUTHOR("Vic Wu <vic.wu@mediatek.com>");
|
||||
+MODULE_LICENSE("GPL");
|
@ -1,243 +0,0 @@
|
||||
From ddf6abc1c78072f8ccad59166be95f0ca5af8ca4 Mon Sep 17 00:00:00 2001
|
||||
From: Maso Huang <maso.huang@mediatek.com>
|
||||
Date: Thu, 17 Aug 2023 18:13:36 +0800
|
||||
Subject: [PATCH 4/9] ASoC: mediatek: mt7986: add machine driver with wm8960
|
||||
|
||||
Add support for mt7986 board with wm8960.
|
||||
|
||||
Signed-off-by: Maso Huang <maso.huang@mediatek.com>
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Link: https://lore.kernel.org/r/20230817101338.18782-5-maso.huang@mediatek.com
|
||||
Signed-off-by: Mark Brown <broonie@kernel.org>
|
||||
---
|
||||
sound/soc/mediatek/Kconfig | 10 ++
|
||||
sound/soc/mediatek/mt7986/Makefile | 1 +
|
||||
sound/soc/mediatek/mt7986/mt7986-wm8960.c | 196 ++++++++++++++++++++++
|
||||
3 files changed, 207 insertions(+)
|
||||
create mode 100644 sound/soc/mediatek/mt7986/mt7986-wm8960.c
|
||||
|
||||
--- a/sound/soc/mediatek/Kconfig
|
||||
+++ b/sound/soc/mediatek/Kconfig
|
||||
@@ -64,6 +64,16 @@ config SND_SOC_MT7986
|
||||
Select Y if you have such device.
|
||||
If unsure select "N".
|
||||
|
||||
+config SND_SOC_MT7986_WM8960
|
||||
+ tristate "ASoc Audio driver for MT7986 with WM8960 codec"
|
||||
+ depends on SND_SOC_MT7986 && I2C
|
||||
+ select SND_SOC_WM8960
|
||||
+ help
|
||||
+ This adds support for ASoC machine driver for MediaTek MT7986
|
||||
+ boards with the WM8960 codecs.
|
||||
+ Select Y if you have such device.
|
||||
+ If unsure select "N".
|
||||
+
|
||||
config SND_SOC_MT8173
|
||||
tristate "ASoC support for Mediatek MT8173 chip"
|
||||
depends on ARCH_MEDIATEK
|
||||
--- a/sound/soc/mediatek/mt7986/Makefile
|
||||
+++ b/sound/soc/mediatek/mt7986/Makefile
|
||||
@@ -6,3 +6,4 @@ snd-soc-mt7986-afe-objs := \
|
||||
mt7986-dai-etdm.o
|
||||
|
||||
obj-$(CONFIG_SND_SOC_MT7986) += snd-soc-mt7986-afe.o
|
||||
+obj-$(CONFIG_SND_SOC_MT7986_WM8960) += mt7986-wm8960.o
|
||||
--- /dev/null
|
||||
+++ b/sound/soc/mediatek/mt7986/mt7986-wm8960.c
|
||||
@@ -0,0 +1,196 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0
|
||||
+/*
|
||||
+ * mt7986-wm8960.c -- MT7986-WM8960 ALSA SoC machine driver
|
||||
+ *
|
||||
+ * Copyright (c) 2023 MediaTek Inc.
|
||||
+ * Authors: Vic Wu <vic.wu@mediatek.com>
|
||||
+ * Maso Huang <maso.huang@mediatek.com>
|
||||
+ */
|
||||
+
|
||||
+#include <linux/module.h>
|
||||
+#include <sound/soc.h>
|
||||
+
|
||||
+#include "mt7986-afe-common.h"
|
||||
+
|
||||
+struct mt7986_wm8960_priv {
|
||||
+ struct device_node *platform_node;
|
||||
+ struct device_node *codec_node;
|
||||
+};
|
||||
+
|
||||
+static const struct snd_soc_dapm_widget mt7986_wm8960_widgets[] = {
|
||||
+ SND_SOC_DAPM_HP("Headphone", NULL),
|
||||
+ SND_SOC_DAPM_MIC("AMIC", NULL),
|
||||
+};
|
||||
+
|
||||
+static const struct snd_kcontrol_new mt7986_wm8960_controls[] = {
|
||||
+ SOC_DAPM_PIN_SWITCH("Headphone"),
|
||||
+ SOC_DAPM_PIN_SWITCH("AMIC"),
|
||||
+};
|
||||
+
|
||||
+SND_SOC_DAILINK_DEFS(playback,
|
||||
+ DAILINK_COMP_ARRAY(COMP_CPU("DL1")),
|
||||
+ DAILINK_COMP_ARRAY(COMP_DUMMY()),
|
||||
+ DAILINK_COMP_ARRAY(COMP_EMPTY()));
|
||||
+
|
||||
+SND_SOC_DAILINK_DEFS(capture,
|
||||
+ DAILINK_COMP_ARRAY(COMP_CPU("UL1")),
|
||||
+ DAILINK_COMP_ARRAY(COMP_DUMMY()),
|
||||
+ DAILINK_COMP_ARRAY(COMP_EMPTY()));
|
||||
+
|
||||
+SND_SOC_DAILINK_DEFS(codec,
|
||||
+ DAILINK_COMP_ARRAY(COMP_CPU("ETDM")),
|
||||
+ DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "wm8960-hifi")),
|
||||
+ DAILINK_COMP_ARRAY(COMP_EMPTY()));
|
||||
+
|
||||
+static struct snd_soc_dai_link mt7986_wm8960_dai_links[] = {
|
||||
+ /* FE */
|
||||
+ {
|
||||
+ .name = "wm8960-playback",
|
||||
+ .stream_name = "wm8960-playback",
|
||||
+ .trigger = {SND_SOC_DPCM_TRIGGER_POST,
|
||||
+ SND_SOC_DPCM_TRIGGER_POST},
|
||||
+ .dynamic = 1,
|
||||
+ .dpcm_playback = 1,
|
||||
+ SND_SOC_DAILINK_REG(playback),
|
||||
+ },
|
||||
+ {
|
||||
+ .name = "wm8960-capture",
|
||||
+ .stream_name = "wm8960-capture",
|
||||
+ .trigger = {SND_SOC_DPCM_TRIGGER_POST,
|
||||
+ SND_SOC_DPCM_TRIGGER_POST},
|
||||
+ .dynamic = 1,
|
||||
+ .dpcm_capture = 1,
|
||||
+ SND_SOC_DAILINK_REG(capture),
|
||||
+ },
|
||||
+ /* BE */
|
||||
+ {
|
||||
+ .name = "wm8960-codec",
|
||||
+ .no_pcm = 1,
|
||||
+ .dai_fmt = SND_SOC_DAIFMT_I2S |
|
||||
+ SND_SOC_DAIFMT_NB_NF |
|
||||
+ SND_SOC_DAIFMT_CBS_CFS |
|
||||
+ SND_SOC_DAIFMT_GATED,
|
||||
+ .dpcm_playback = 1,
|
||||
+ .dpcm_capture = 1,
|
||||
+ SND_SOC_DAILINK_REG(codec),
|
||||
+ },
|
||||
+};
|
||||
+
|
||||
+static struct snd_soc_card mt7986_wm8960_card = {
|
||||
+ .name = "mt7986-wm8960",
|
||||
+ .owner = THIS_MODULE,
|
||||
+ .dai_link = mt7986_wm8960_dai_links,
|
||||
+ .num_links = ARRAY_SIZE(mt7986_wm8960_dai_links),
|
||||
+ .controls = mt7986_wm8960_controls,
|
||||
+ .num_controls = ARRAY_SIZE(mt7986_wm8960_controls),
|
||||
+ .dapm_widgets = mt7986_wm8960_widgets,
|
||||
+ .num_dapm_widgets = ARRAY_SIZE(mt7986_wm8960_widgets),
|
||||
+};
|
||||
+
|
||||
+static int mt7986_wm8960_machine_probe(struct platform_device *pdev)
|
||||
+{
|
||||
+ struct snd_soc_card *card = &mt7986_wm8960_card;
|
||||
+ struct snd_soc_dai_link *dai_link;
|
||||
+ struct device_node *platform, *codec;
|
||||
+ struct mt7986_wm8960_priv *priv;
|
||||
+ int ret, i;
|
||||
+
|
||||
+ priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
|
||||
+ if (!priv)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ platform = of_get_child_by_name(pdev->dev.of_node, "platform");
|
||||
+
|
||||
+ if (platform) {
|
||||
+ priv->platform_node = of_parse_phandle(platform, "sound-dai", 0);
|
||||
+ of_node_put(platform);
|
||||
+
|
||||
+ if (!priv->platform_node) {
|
||||
+ dev_err(&pdev->dev, "Failed to parse platform/sound-dai property\n");
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+ } else {
|
||||
+ dev_err(&pdev->dev, "Property 'platform' missing or invalid\n");
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+
|
||||
+ for_each_card_prelinks(card, i, dai_link) {
|
||||
+ if (dai_link->platforms->name)
|
||||
+ continue;
|
||||
+ dai_link->platforms->of_node = priv->platform_node;
|
||||
+ }
|
||||
+
|
||||
+ card->dev = &pdev->dev;
|
||||
+
|
||||
+ codec = of_get_child_by_name(pdev->dev.of_node, "codec");
|
||||
+
|
||||
+ if (codec) {
|
||||
+ priv->codec_node = of_parse_phandle(codec, "sound-dai", 0);
|
||||
+ of_node_put(codec);
|
||||
+
|
||||
+ if (!priv->codec_node) {
|
||||
+ of_node_put(priv->platform_node);
|
||||
+ dev_err(&pdev->dev, "Failed to parse codec/sound-dai property\n");
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+ } else {
|
||||
+ of_node_put(priv->platform_node);
|
||||
+ dev_err(&pdev->dev, "Property 'codec' missing or invalid\n");
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+
|
||||
+ for_each_card_prelinks(card, i, dai_link) {
|
||||
+ if (dai_link->codecs->name)
|
||||
+ continue;
|
||||
+ dai_link->codecs->of_node = priv->codec_node;
|
||||
+ }
|
||||
+
|
||||
+ ret = snd_soc_of_parse_audio_routing(card, "audio-routing");
|
||||
+ if (ret) {
|
||||
+ dev_err(&pdev->dev, "Failed to parse audio-routing: %d\n", ret);
|
||||
+ goto err_of_node_put;
|
||||
+ }
|
||||
+
|
||||
+ ret = devm_snd_soc_register_card(&pdev->dev, card);
|
||||
+ if (ret) {
|
||||
+ dev_err(&pdev->dev, "%s snd_soc_register_card fail: %d\n", __func__, ret);
|
||||
+ goto err_of_node_put;
|
||||
+ }
|
||||
+
|
||||
+err_of_node_put:
|
||||
+ of_node_put(priv->codec_node);
|
||||
+ of_node_put(priv->platform_node);
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static void mt7986_wm8960_machine_remove(struct platform_device *pdev)
|
||||
+{
|
||||
+ struct snd_soc_card *card = platform_get_drvdata(pdev);
|
||||
+ struct mt7986_wm8960_priv *priv = snd_soc_card_get_drvdata(card);
|
||||
+
|
||||
+ of_node_put(priv->codec_node);
|
||||
+ of_node_put(priv->platform_node);
|
||||
+}
|
||||
+
|
||||
+static const struct of_device_id mt7986_wm8960_machine_dt_match[] = {
|
||||
+ {.compatible = "mediatek,mt7986-wm8960-sound"},
|
||||
+ { /* sentinel */ }
|
||||
+};
|
||||
+MODULE_DEVICE_TABLE(of, mt7986_wm8960_machine_dt_match);
|
||||
+
|
||||
+static struct platform_driver mt7986_wm8960_machine = {
|
||||
+ .driver = {
|
||||
+ .name = "mt7986-wm8960",
|
||||
+ .of_match_table = mt7986_wm8960_machine_dt_match,
|
||||
+ },
|
||||
+ .probe = mt7986_wm8960_machine_probe,
|
||||
+ .remove_new = mt7986_wm8960_machine_remove,
|
||||
+};
|
||||
+
|
||||
+module_platform_driver(mt7986_wm8960_machine);
|
||||
+
|
||||
+/* Module information */
|
||||
+MODULE_DESCRIPTION("MT7986 WM8960 ALSA SoC machine driver");
|
||||
+MODULE_AUTHOR("Vic Wu <vic.wu@mediatek.com>");
|
||||
+MODULE_LICENSE("GPL");
|
||||
+MODULE_ALIAS("mt7986 wm8960 soc card");
|
@ -1,87 +0,0 @@
|
||||
From 72469f950b629e57e60fbcbefed45e083619b986 Mon Sep 17 00:00:00 2001
|
||||
From: Maso Huang <maso.huang@mediatek.com>
|
||||
Date: Thu, 17 Aug 2023 18:13:37 +0800
|
||||
Subject: [PATCH 5/9] ASoC: dt-bindings: mediatek,mt7986-wm8960: add
|
||||
mt7986-wm8960 document
|
||||
|
||||
Add document for mt7986 board with wm8960.
|
||||
|
||||
Signed-off-by: Maso Huang <maso.huang@mediatek.com>
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Link: https://lore.kernel.org/r/20230817101338.18782-6-maso.huang@mediatek.com
|
||||
Signed-off-by: Mark Brown <broonie@kernel.org>
|
||||
---
|
||||
.../sound/mediatek,mt7986-wm8960.yaml | 67 +++++++++++++++++++
|
||||
1 file changed, 67 insertions(+)
|
||||
create mode 100644 Documentation/devicetree/bindings/sound/mediatek,mt7986-wm8960.yaml
|
||||
|
||||
--- /dev/null
|
||||
+++ b/Documentation/devicetree/bindings/sound/mediatek,mt7986-wm8960.yaml
|
||||
@@ -0,0 +1,67 @@
|
||||
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
|
||||
+%YAML 1.2
|
||||
+---
|
||||
+$id: http://devicetree.org/schemas/sound/mediatek,mt7986-wm8960.yaml#
|
||||
+$schema: http://devicetree.org/meta-schemas/core.yaml#
|
||||
+
|
||||
+title: MediaTek MT7986 sound card with WM8960 codec
|
||||
+
|
||||
+maintainers:
|
||||
+ - Maso Huang <maso.huang@mediatek.com>
|
||||
+
|
||||
+allOf:
|
||||
+ - $ref: sound-card-common.yaml#
|
||||
+
|
||||
+properties:
|
||||
+ compatible:
|
||||
+ const: mediatek,mt7986-wm8960-sound
|
||||
+
|
||||
+ platform:
|
||||
+ type: object
|
||||
+ additionalProperties: false
|
||||
+ properties:
|
||||
+ sound-dai:
|
||||
+ description: The phandle of MT7986 platform.
|
||||
+ maxItems: 1
|
||||
+ required:
|
||||
+ - sound-dai
|
||||
+
|
||||
+ codec:
|
||||
+ type: object
|
||||
+ additionalProperties: false
|
||||
+ properties:
|
||||
+ sound-dai:
|
||||
+ description: The phandle of wm8960 codec.
|
||||
+ maxItems: 1
|
||||
+ required:
|
||||
+ - sound-dai
|
||||
+
|
||||
+unevaluatedProperties: false
|
||||
+
|
||||
+required:
|
||||
+ - compatible
|
||||
+ - audio-routing
|
||||
+ - platform
|
||||
+ - codec
|
||||
+
|
||||
+examples:
|
||||
+ - |
|
||||
+ sound {
|
||||
+ compatible = "mediatek,mt7986-wm8960-sound";
|
||||
+ model = "mt7986-wm8960";
|
||||
+ audio-routing =
|
||||
+ "Headphone", "HP_L",
|
||||
+ "Headphone", "HP_R",
|
||||
+ "LINPUT1", "AMIC",
|
||||
+ "RINPUT1", "AMIC";
|
||||
+
|
||||
+ platform {
|
||||
+ sound-dai = <&afe>;
|
||||
+ };
|
||||
+
|
||||
+ codec {
|
||||
+ sound-dai = <&wm8960>;
|
||||
+ };
|
||||
+ };
|
||||
+
|
||||
+...
|
@ -1,180 +0,0 @@
|
||||
From d16202eb38585adbc16e32d11188dbc2127015de Mon Sep 17 00:00:00 2001
|
||||
From: Maso Huang <maso.huang@mediatek.com>
|
||||
Date: Thu, 17 Aug 2023 18:13:38 +0800
|
||||
Subject: [PATCH 6/9] ASoC: dt-bindings: mediatek,mt7986-afe: add audio afe
|
||||
document
|
||||
|
||||
Add mt7986 audio afe document.
|
||||
|
||||
Signed-off-by: Maso Huang <maso.huang@mediatek.com>
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
Link: https://lore.kernel.org/r/20230817101338.18782-7-maso.huang@mediatek.com
|
||||
Signed-off-by: Mark Brown <broonie@kernel.org>
|
||||
---
|
||||
.../bindings/sound/mediatek,mt7986-afe.yaml | 160 ++++++++++++++++++
|
||||
1 file changed, 160 insertions(+)
|
||||
create mode 100644 Documentation/devicetree/bindings/sound/mediatek,mt7986-afe.yaml
|
||||
|
||||
--- /dev/null
|
||||
+++ b/Documentation/devicetree/bindings/sound/mediatek,mt7986-afe.yaml
|
||||
@@ -0,0 +1,160 @@
|
||||
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
|
||||
+%YAML 1.2
|
||||
+---
|
||||
+$id: http://devicetree.org/schemas/sound/mediatek,mt7986-afe.yaml#
|
||||
+$schema: http://devicetree.org/meta-schemas/core.yaml#
|
||||
+
|
||||
+title: MediaTek AFE PCM controller for MT7986
|
||||
+
|
||||
+maintainers:
|
||||
+ - Maso Huang <maso.huang@mediatek.com>
|
||||
+
|
||||
+properties:
|
||||
+ compatible:
|
||||
+ oneOf:
|
||||
+ - const: mediatek,mt7986-afe
|
||||
+ - items:
|
||||
+ - enum:
|
||||
+ - mediatek,mt7981-afe
|
||||
+ - mediatek,mt7988-afe
|
||||
+ - const: mediatek,mt7986-afe
|
||||
+
|
||||
+ reg:
|
||||
+ maxItems: 1
|
||||
+
|
||||
+ interrupts:
|
||||
+ maxItems: 1
|
||||
+
|
||||
+ clocks:
|
||||
+ minItems: 5
|
||||
+ items:
|
||||
+ - description: audio bus clock
|
||||
+ - description: audio 26M clock
|
||||
+ - description: audio intbus clock
|
||||
+ - description: audio hopping clock
|
||||
+ - description: audio pll clock
|
||||
+ - description: mux for pcm_mck
|
||||
+ - description: audio i2s/pcm mck
|
||||
+
|
||||
+ clock-names:
|
||||
+ minItems: 5
|
||||
+ items:
|
||||
+ - const: bus_ck
|
||||
+ - const: 26m_ck
|
||||
+ - const: l_ck
|
||||
+ - const: aud_ck
|
||||
+ - const: eg2_ck
|
||||
+ - const: sel
|
||||
+ - const: i2s_m
|
||||
+
|
||||
+required:
|
||||
+ - compatible
|
||||
+ - reg
|
||||
+ - interrupts
|
||||
+ - clocks
|
||||
+ - clock-names
|
||||
+
|
||||
+allOf:
|
||||
+ - if:
|
||||
+ properties:
|
||||
+ compatible:
|
||||
+ contains:
|
||||
+ const: mediatek,mt7986-afe
|
||||
+ then:
|
||||
+ properties:
|
||||
+ clocks:
|
||||
+ items:
|
||||
+ - description: audio bus clock
|
||||
+ - description: audio 26M clock
|
||||
+ - description: audio intbus clock
|
||||
+ - description: audio hopping clock
|
||||
+ - description: audio pll clock
|
||||
+ clock-names:
|
||||
+ items:
|
||||
+ - const: bus_ck
|
||||
+ - const: 26m_ck
|
||||
+ - const: l_ck
|
||||
+ - const: aud_ck
|
||||
+ - const: eg2_ck
|
||||
+
|
||||
+ - if:
|
||||
+ properties:
|
||||
+ compatible:
|
||||
+ contains:
|
||||
+ const: mediatek,mt7981-afe
|
||||
+ then:
|
||||
+ properties:
|
||||
+ clocks:
|
||||
+ items:
|
||||
+ - description: audio bus clock
|
||||
+ - description: audio 26M clock
|
||||
+ - description: audio intbus clock
|
||||
+ - description: audio hopping clock
|
||||
+ - description: audio pll clock
|
||||
+ - description: mux for pcm_mck
|
||||
+ clock-names:
|
||||
+ items:
|
||||
+ - const: bus_ck
|
||||
+ - const: 26m_ck
|
||||
+ - const: l_ck
|
||||
+ - const: aud_ck
|
||||
+ - const: eg2_ck
|
||||
+ - const: sel
|
||||
+
|
||||
+ - if:
|
||||
+ properties:
|
||||
+ compatible:
|
||||
+ contains:
|
||||
+ const: mediatek,mt7988-afe
|
||||
+ then:
|
||||
+ properties:
|
||||
+ clocks:
|
||||
+ items:
|
||||
+ - description: audio bus clock
|
||||
+ - description: audio 26M clock
|
||||
+ - description: audio intbus clock
|
||||
+ - description: audio hopping clock
|
||||
+ - description: audio pll clock
|
||||
+ - description: mux for pcm_mck
|
||||
+ - description: audio i2s/pcm mck
|
||||
+ clock-names:
|
||||
+ items:
|
||||
+ - const: bus_ck
|
||||
+ - const: 26m_ck
|
||||
+ - const: l_ck
|
||||
+ - const: aud_ck
|
||||
+ - const: eg2_ck
|
||||
+ - const: sel
|
||||
+ - const: i2s_m
|
||||
+
|
||||
+additionalProperties: false
|
||||
+
|
||||
+examples:
|
||||
+ - |
|
||||
+ #include <dt-bindings/interrupt-controller/arm-gic.h>
|
||||
+ #include <dt-bindings/interrupt-controller/irq.h>
|
||||
+ #include <dt-bindings/clock/mt7986-clk.h>
|
||||
+
|
||||
+ afe@11210000 {
|
||||
+ compatible = "mediatek,mt7986-afe";
|
||||
+ reg = <0x11210000 0x9000>;
|
||||
+ interrupts = <GIC_SPI 106 IRQ_TYPE_LEVEL_HIGH>;
|
||||
+ clocks = <&infracfg_ao CLK_INFRA_AUD_BUS_CK>,
|
||||
+ <&infracfg_ao CLK_INFRA_AUD_26M_CK>,
|
||||
+ <&infracfg_ao CLK_INFRA_AUD_L_CK>,
|
||||
+ <&infracfg_ao CLK_INFRA_AUD_AUD_CK>,
|
||||
+ <&infracfg_ao CLK_INFRA_AUD_EG2_CK>;
|
||||
+ clock-names = "bus_ck",
|
||||
+ "26m_ck",
|
||||
+ "l_ck",
|
||||
+ "aud_ck",
|
||||
+ "eg2_ck";
|
||||
+ assigned-clocks = <&topckgen CLK_TOP_A1SYS_SEL>,
|
||||
+ <&topckgen CLK_TOP_AUD_L_SEL>,
|
||||
+ <&topckgen CLK_TOP_A_TUNER_SEL>;
|
||||
+ assigned-clock-parents = <&topckgen CLK_TOP_APLL2_D4>,
|
||||
+ <&apmixedsys CLK_APMIXED_APLL2>,
|
||||
+ <&topckgen CLK_TOP_APLL2_D4>;
|
||||
+ };
|
||||
+
|
||||
+...
|
Loading…
x
Reference in New Issue
Block a user