Skip to contentSkip to conversation

Add mmc-support for mt7986

PATCH Superseded Frank Wunderlich 2 participants 8 messages Oct 22, 2022

Subsystems (4)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v2 cover Add mmc-support for mt7986

From: Frank Wunderlich <[email protected]>

I've noticed the mtk-sd binding needs a bit more work get into a more clean state.

There are 2 properties missing that maybe need to be added later or dropped from devicetrees:
drv-type (which is used in mt8183-kukui.dtsi and set to <2>) and
r_smpl (used in mt7622-rfb1.dts and mt7622-bananapi-bpi-r64.dts, both times set to <1>)

i don't know their function and boundaries and i do not find them in driver. I guess they are added by accident, but before removing them i want to fix the other problems.

Frank Wunderlich (2):
arm64: dts: mediatek: mt2712e: swap last 2 clocks to match binding
dt-bindings: mmc: mtk-sd: add mt7986

Nícolas F. R. A. Prado (1):
dt-bindings: mmc: mtk-sd: Set clocks based on compatible

Sam Shih (2):
dt-bindings: mmc: Add compatible for Mediatek MT7986
mmc: mediatek: add support for MT7986 SoC

 .../devicetree/bindings/mmc/mtk-sd.yaml       | 140 ++++++++++++++----
 arch/arm64/boot/dts/mediatek/mt2712e.dtsi     |   6 +-
 drivers/mmc/host/mtk-sd.c                     |  14 ++
 3 files changed, 127 insertions(+), 33 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH v2 1/5 dt-bindings: mmc: Add compatible for Mediatek MT7986

From: Sam Shih <[email protected]>

This commit adds dt-binding documentation of mmc for Mediatek MT7986 SoC Platform.

---
 Documentation/devicetree/bindings/mmc/mtk-sd.yaml | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/mmc/mtk-sd.yaml +1 -0
index d8e1e2e9adf2..3cbf0208f1b4 100644
@@ -23,6 +23,7 @@ properties:
           - mediatek,mt6795-mmc
           - mediatek,mt7620-mmc
           - mediatek,mt7622-mmc
+          - mediatek,mt7986-mmc
           - mediatek,mt8135-mmc
           - mediatek,mt8173-mmc
           - mediatek,mt8183-mmc
Signature · 1 line
2.34.1
#5 lore raw

PATCH v2 4/5 arm64: dts: mediatek: mt2712e: swap last 2 clocks to match binding

In reply to Frank Wunderlich

From: Frank Wunderlich <[email protected]>

First 3 clocks for mt2712 need to be "source", "hclk", "source_cg" so swap last 2 of mmc0 to match the binding.

---
 arch/arm64/boot/dts/mediatek/mt2712e.dtsi | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm64/boot/dts/mediatek/mt2712e.dtsi +3 -3
index e6d7453e56e0..9dc0794fcd2e 100644
@@ -766,9 +766,9 @@ mmc0: mmc@11230000 {
 		interrupts = <GIC_SPI 79 IRQ_TYPE_LEVEL_LOW>;
 		clocks = <&pericfg CLK_PERI_MSDC30_0>,
 			 <&pericfg CLK_PERI_MSDC50_0_HCLK_EN>,
-			 <&pericfg CLK_PERI_MSDC30_0_QTR_EN>,
-			 <&pericfg CLK_PERI_MSDC50_0_EN>;
-		clock-names = "source", "hclk", "bus_clk", "source_cg";
+			 <&pericfg CLK_PERI_MSDC50_0_EN>,
+			 <&pericfg CLK_PERI_MSDC30_0_QTR_EN>;
+		clock-names = "source", "hclk", "source_cg", "bus_clk";
 		status = "disabled";
 	};
 
Signature · 1 line
2.34.1
#6 lore raw

PATCH v2 5/5 dt-bindings: mmc: mtk-sd: add mt7986

In reply to Frank Wunderlich

From: Frank Wunderlich <[email protected]>

Add SoC specific section for defining clock configuration.

Add compatible in "not" section to avoid override the settings again.

---
 .../devicetree/bindings/mmc/mtk-sd.yaml       | 28 +++++++++++++++++++
 1 file changed, 28 insertions(+)
Documentation/devicetree/bindings/mmc/mtk-sd.yaml +28 -0
index c7bcf0c3dd5d..9df63c461f1f 100644
@@ -229,6 +229,33 @@ allOf:
             - const: hclk
             - const: source_cg
             - const: bus_clk
+  - if:
+      properties:
+        compatible:
+          contains:
+            enum:
+              - mediatek,mt7986-mmc
+    then:
+      properties:
+        assigned-clock-parents:
+          maxItems: 2
+        assigned-clocks:
+          maxItems: 2
+        clocks:
+          minItems: 3
+          items:
+            - description: source clock
+            - description: HCLK which used for host
+            - description: independent source clock gate
+            - description: bus clock used for internal register access
+            - description: msdc subsys clock gate
+        clock-names:
+          minItems: 3
+          items:
+            - const: source
+            - const: hclk
+            - const: axi_cg
+            - const: ahb_cg
   - if:
       not:
         properties:
@@ -237,6 +264,7 @@ allOf:
               enum:
                 - mediatek,mt2712-mmc
                 - mediatek,mt8192-mmc
+                - mediatek,mt7986-mmc
     then:
       properties:
         clocks:
Signature · 1 line
2.34.1
#2 lore raw

PATCH v2 2/5 mmc: mediatek: add support for MT7986 SoC

In reply to Frank Wunderlich

From: Sam Shih <[email protected]>

Adding mt7986 own characteristics and of_device_id to have support of MT7986 SoC.

---
 drivers/mmc/host/mtk-sd.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
drivers/mmc/host/mtk-sd.c +14 -0
index df941438aef5..3f7f3a1e0df8 100644
@@ -552,6 +552,19 @@ static const struct mtk_mmc_compatible mt7622_compat = {
 	.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_ids[] = {
 	{ .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},
Signature · 1 line
2.34.1
#3 lore raw

PATCH v2 3/5 dt-bindings: mmc: mtk-sd: Set clocks based on compatible

In reply to Frank Wunderlich

From: Nícolas F. R. A. Prado <[email protected]>

The binding was describing a single clock list for all platforms, but that's not really suitable: mt2712 requires an extra 'bus_clk' on some of its controllers, while mt8192 requires four different extra clocks. The rest of the platforms can share the same 3 clocks, with the third being optional as it's not present on all platforms.

Move the clock definitions inside if blocks that match on the compatibles. In practice this gets rid of dtbs_check warnings on mt8192, since the 'bus_clk' clock from mt2712 is no longer expected on this platform.

Fixes 59a23395d8aa ("dt-bindings: mmc: Add support for MT8192 SoC")
---
 .../devicetree/bindings/mmc/mtk-sd.yaml       | 111 +++++++++++++-----
 1 file changed, 81 insertions(+), 30 deletions(-)
Documentation/devicetree/bindings/mmc/mtk-sd.yaml +81 -30
index 3cbf0208f1b4..c7bcf0c3dd5d 100644
@@ -10,9 +10,6 @@ maintainers:
   - Chaotian Jing <[email protected]>
   - Wenbin Mei <[email protected]>
 
-allOf:
-  - $ref: mmc-controller.yaml#
-
 properties:
   compatible:
     oneOf:
@@ -49,27 +46,11 @@ properties:
     description:
       Should contain phandle for the clock feeding the MMC controller.
     minItems: 2
-    items:
-      - description: source clock (required).
-      - description: HCLK which used for host (required).
-      - description: independent source clock gate (required for MT2712).
-      - description: bus clock used for internal register access (required for MT2712 MSDC0/3).
-      - description: msdc subsys clock gate (required for MT8192).
-      - description: peripheral bus clock gate (required for MT8192).
-      - description: AXI bus clock gate (required for MT8192).
-      - description: AHB bus clock gate (required for MT8192).
+    maxItems: 7
 
   clock-names:
     minItems: 2
-    items:
-      - const: source
-      - const: hclk
-      - const: source_cg
-      - const: bus_clk
-      - const: sys_cg
-      - const: pclk_cg
-      - const: axi_cg
-      - const: ahb_cg
+    maxItems: 7
 
   interrupts:
     description:
@@ -191,15 +172,85 @@ required:
   - vmmc-supply
   - vqmmc-supply
 
-if:
-  properties:
-    compatible:
-      contains:
-        const: mediatek,mt8183-mmc
-then:
-  properties:
-    reg:
-      minItems: 2
+allOf:
+  - $ref: mmc-controller.yaml#
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: mediatek,mt8183-mmc
+    then:
+      properties:
+        reg:
+          minItems: 2
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: mediatek,mt8192-mmc
+    then:
+      properties:
+        clocks:
+          items:
+            - description: source clock
+            - description: HCLK which used for host
+            - description: independent source clock gate
+            - description: msdc subsys clock gate
+            - description: peripheral bus clock gate
+            - description: AXI bus clock gate
+            - description: AHB bus clock gate
+        clock-names:
+          items:
+            - const: source
+            - const: hclk
+            - const: source_cg
+            - const: sys_cg
+            - const: pclk_cg
+            - const: axi_cg
+            - const: ahb_cg
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: mediatek,mt2712-mmc
+    then:
+      properties:
+        clocks:
+          minItems: 3
+          items:
+            - description: source clock
+            - description: HCLK which used for host
+            - description: independent source clock gate
+            - description: bus clock used for internal register access (required for MSDC0/3).
+        clock-names:
+          minItems: 3
+          items:
+            - const: source
+            - const: hclk
+            - const: source_cg
+            - const: bus_clk
+  - if:
+      not:
+        properties:
+          compatible:
+            contains:
+              enum:
+                - mediatek,mt2712-mmc
+                - mediatek,mt8192-mmc
+    then:
+      properties:
+        clocks:
+          minItems: 2
+          items:
+            - description: source clock
+            - description: HCLK which used for host
+            - description: independent source clock gate
+        clock-names:
+          minItems: 2
+          items:
+            - const: source
+            - const: hclk
+            - const: source_cg
 
 unevaluatedProperties: false
 
Signature · 1 line
2.34.1
#4 lore raw

Re: [PATCH v2 3/5] dt-bindings: mmc: mtk-sd: Set clocks based on compatible

Quoted 7 lines · Frank Wunderlich

From: Nícolas F. R. A. Prado <[email protected]>

The binding was describing a single clock list for all platforms, but that's not really suitable: mt2712 requires an extra 'bus_clk' on some of its controllers, while mt8192 requires four different extra clocks. The rest of the platforms can share the same 3 clocks, with the third being optional as it's not present on all platforms.

It was also wrong...

Quoted 31 lines

Move the clock definitions inside if blocks that match on the compatibles. In practice this gets rid of dtbs_check warnings on mt8192, since the 'bus_clk' clock from mt2712 is no longer expected on this platform.

Fixes 59a23395d8aa ("dt-bindings: mmc: Add support for MT8192 SoC")
---
 .../devicetree/bindings/mmc/mtk-sd.yaml       | 111 +++++++++++++-----
 1 file changed, 81 insertions(+), 30 deletions(-)
Documentation/devicetree/bindings/mmc/mtk-sd.yaml +0 -3
index 3cbf0208f1b4..c7bcf0c3dd5d 100644
@@ -10,9 +10,6 @@ maintainers:
   - Chaotian Jing <[email protected]>
   - Wenbin Mei <[email protected]>
 
-allOf:
-  - $ref: mmc-controller.yaml#
-
 properties:
   compatible:
     oneOf:
@@ -49,27 +46,11 @@ properties:
     description:
       Should contain phandle for the clock feeding the MMC controller.
     minItems: 2

Documentation/devicetree/bindings/mmc/mtk-sd.yaml properties: · line 49

Quoted 10 lines
Documentation/devicetree/bindings/mmc/mtk-sd.yaml +1 -9
-    items:
-      - description: source clock (required).
-      - description: HCLK which used for host (required).
-      - description: independent source clock gate (required for MT2712).
-      - description: bus clock used for internal register access (required for MT2712 MSDC0/3).
-      - description: msdc subsys clock gate (required for MT8192).
-      - description: peripheral bus clock gate (required for MT8192).
-      - description: AXI bus clock gate (required for MT8192).
-      - description: AHB bus clock gate (required for MT8192).
+    maxItems: 7

Confusing to see 8 clocks replaced by 7, but I guess this is problem of old bindings.

Quoted 30 lines
Documentation/devicetree/bindings/mmc/mtk-sd.yaml +2 -18
   clock-names:
     minItems: 2
-    items:
-      - const: source
-      - const: hclk
-      - const: source_cg
-      - const: bus_clk
-      - const: sys_cg
-      - const: pclk_cg
-      - const: axi_cg
-      - const: ahb_cg
+    maxItems: 7
 
   interrupts:
     description:
@@ -191,15 +172,85 @@ required:
   - vmmc-supply
   - vqmmc-supply
 
-if:
-  properties:
-    compatible:
-      contains:
-        const: mediatek,mt8183-mmc
-then:
-  properties:
-    reg:
-      minItems: 2
+allOf:

Documentation/devicetree/bindings/mmc/mtk-sd.yaml required: · line 185

Quoted 10 lines
Documentation/devicetree/bindings/mmc/mtk-sd.yaml +10 -0
+  - $ref: mmc-controller.yaml#
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: mediatek,mt8183-mmc
+    then:
+      properties:
+        reg:
+          minItems: 2

Blank line

Quoted 15 lines
Documentation/devicetree/bindings/mmc/mtk-sd.yaml +15 -0
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: mediatek,mt8192-mmc
+    then:
+      properties:
+        clocks:
+          items:
+            - description: source clock
+            - description: HCLK which used for host
+            - description: independent source clock gate
+            - description: msdc subsys clock gate
+            - description: peripheral bus clock gate
+            - description: AXI bus clock gate

Documentation/devicetree/bindings/mmc/mtk-sd.yaml required: · line 210

Quoted 10 lines
Documentation/devicetree/bindings/mmc/mtk-sd.yaml +10 -0
+            - description: AHB bus clock gate
+        clock-names:
+          items:
+            - const: source
+            - const: hclk
+            - const: source_cg
+            - const: sys_cg
+            - const: pclk_cg
+            - const: axi_cg
+            - const: ahb_cg

Blank line

Quoted 11 lines
Documentation/devicetree/bindings/mmc/mtk-sd.yaml +11 -0
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: mediatek,mt2712-mmc
+    then:
+      properties:
+        clocks:
+          minItems: 3
+          items:
+            - description: source clock

Documentation/devicetree/bindings/mmc/mtk-sd.yaml required: · line 231

Quoted 10 lines
Documentation/devicetree/bindings/mmc/mtk-sd.yaml +10 -0
+            - description: HCLK which used for host
+            - description: independent source clock gate
+            - description: bus clock used for internal register access (required for MSDC0/3).
+        clock-names:
+          minItems: 3
+          items:
+            - const: source
+            - const: hclk
+            - const: source_cg
+            - const: bus_clk

Blank line

Documentation/devicetree/bindings/mmc/mtk-sd.yaml required: · line 233

Quoted 2 lines
Documentation/devicetree/bindings/mmc/mtk-sd.yaml +2 -0
+  - if:
+      not:

Can you not use negation, but list applicable compatibles? It would be easier to read, I think

Documentation/devicetree/bindings/mmc/mtk-sd.yaml required: · line 239

Quoted 6 lines
Documentation/devicetree/bindings/mmc/mtk-sd.yaml +6 -0
+        properties:
+          compatible:
+            contains:
+              enum:
+                - mediatek,mt2712-mmc
+                - mediatek,mt8192-mmc

Best regards,
Krzysztof

#7 lore raw

Re: [PATCH v2 5/5] dt-bindings: mmc: mtk-sd: add mt7986

In reply to Frank Wunderlich
Quoted 16 lines · Frank Wunderlich

From: Frank Wunderlich <[email protected]>

Add SoC specific section for defining clock configuration.

Add compatible in "not" section to avoid override the settings again.

---
 .../devicetree/bindings/mmc/mtk-sd.yaml       | 28 +++++++++++++++++++
 1 file changed, 28 insertions(+)
Documentation/devicetree/bindings/mmc/mtk-sd.yaml +0 -0
index c7bcf0c3dd5d..9df63c461f1f 100644

Documentation/devicetree/bindings/mmc/mtk-sd.yaml allOf: · line 231

Quoted 3 lines
Documentation/devicetree/bindings/mmc/mtk-sd.yaml +0 -0
@@ -229,6 +229,33 @@ allOf:
             - const: hclk
             - const: source_cg
             - const: bus_clk

Blank line

Documentation/devicetree/bindings/mmc/mtk-sd.yaml allOf: · line 243

Quoted 12 lines
Documentation/devicetree/bindings/mmc/mtk-sd.yaml +12 -0
+  - if:
+      properties:
+        compatible:
+          contains:
+            enum:
+              - mediatek,mt7986-mmc
+    then:
+      properties:
+        assigned-clock-parents:
+          maxItems: 2
+        assigned-clocks:
+          maxItems: 2

Define these two only if they are required for the hardware to operate and only such setup (two assigned parents) is allowed. Otherwise you put some constraints on board design.

Documentation/devicetree/bindings/mmc/mtk-sd.yaml allOf: · line 245

Quoted 2 lines
Documentation/devicetree/bindings/mmc/mtk-sd.yaml +2 -0
+        clocks:
+          minItems: 3

Best regards,
Krzysztof