Skip to contentSkip to conversation

mtk: wed: move cpuboot, ilm and dlm in dedicated dts nodes

PATCH In review Lorenzo Bianconi 3 participants 16 messages Mar 31, 2023 – Apr 10, 2023

Subsystems (5)
lore
Share & tools
lore

Lorenzo Bianconi

author maintainer
#0 lore raw

v2 cover mtk: wed: move cpuboot, ilm and dlm in dedicated dts nodes

Since cpuboot, ilm and dlm memory region are not part of MT7986 SoC RAM, move them in dedicated mt7986a syscon dts nodes.
At the same time we keep backward-compatibility with older dts version where cpuboot, ilm and dlm were defined as reserved-memory child nodes.

Changes since v1:
- fix dts schema compilation error
- rebase on top of net-next

Lorenzo Bianconi (10):
net: ethernet: mtk_wed: rename mtk_wed_get_memory_region in
mtk_wed_get_reserved_memory_region
net: ethernet: mtk_wed: move cpuboot in a dedicated dts node
dt-bindings: soc: mediatek: move cpuboot in a dedicated dts node
arm64: dts: mt7986: move cpuboot in a dedicated node
net: ethernet: mtk_wed: move ilm a dedicated dts node
dt-bindings: soc: mediatek: move ilm in a dedicated dts node
arm64: dts: mt7986: move ilm in a dedicated node
net: ethernet: mtk_wed: move dlm a dedicated dts node
dt-bindings: soc: mediatek: move dlm in a dedicated dts node
arm64: dts: mt7986: move dlm in a dedicated node

 .../arm/mediatek/mediatek,mt7622-wed.yaml     | 30 ++++---
 .../mediatek/mediatek,mt7986-wo-cpuboot.yaml  | 45 ++++++++++
 .../soc/mediatek/mediatek,mt7986-wo-dlm.yaml  | 46 ++++++++++
 .../soc/mediatek/mediatek,mt7986-wo-ilm.yaml  | 45 ++++++++++
 arch/arm64/boot/dts/mediatek/mt7986a.dtsi     | 69 +++++++-------
 drivers/net/ethernet/mediatek/mtk_wed.c       | 19 ++++
 drivers/net/ethernet/mediatek/mtk_wed_mcu.c   | 89 ++++++++++++++++---
 drivers/net/ethernet/mediatek/mtk_wed_wo.h    |  3 +-
 8 files changed, 289 insertions(+), 57 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/soc/mediatek/mediatek,mt7986-wo-cpuboot.yaml
 create mode 100644 Documentation/devicetree/bindings/soc/mediatek/mediatek,mt7986-wo-dlm.yaml
 create mode 100644 Documentation/devicetree/bindings/soc/mediatek/mediatek,mt7986-wo-ilm.yaml
Signature · 1 line
2.39.2
author maintainer
#1 lore raw

PATCH v2 1/10 net: ethernet: mtk_wed: rename mtk_wed_get_memory_region in mtk_wed_get_reserved_memory_region

This is a preliminary patch to move Wireless Ethernet Dispatch (WED) ilm/dlm and cpuboot properties in dedicated dts nodes.

---
 drivers/net/ethernet/mediatek/mtk_wed_mcu.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/mediatek/mtk_wed_mcu.c +4 -4
index 6bad0d262f28..6624f6d6abdd 100644
@@ -215,8 +215,8 @@ int mtk_wed_mcu_msg_update(struct mtk_wed_device *dev, int id, void *data,
 }
 
 static int
-mtk_wed_get_memory_region(struct mtk_wed_wo *wo,
-			  struct mtk_wed_wo_memory_region *region)
+mtk_wed_get_reserved_memory_region(struct mtk_wed_wo *wo,
+				   struct mtk_wed_wo_memory_region *region)
 {
 	struct reserved_mem *rmem;
 	struct device_node *np;
@@ -311,13 +311,13 @@ mtk_wed_mcu_load_firmware(struct mtk_wed_wo *wo)
 
 	/* load firmware region metadata */
 	for (i = 0; i < ARRAY_SIZE(mem_region); i++) {
-		ret = mtk_wed_get_memory_region(wo, &mem_region[i]);
+		ret = mtk_wed_get_reserved_memory_region(wo, &mem_region[i]);
 		if (ret)
 			return ret;
 	}
 
 	wo->boot.name = "wo-boot";
-	ret = mtk_wed_get_memory_region(wo, &wo->boot);
+	ret = mtk_wed_get_reserved_memory_region(wo, &wo->boot);
 	if (ret)
 		return ret;
 
Signature · 1 line
2.39.2
author maintainer
#2 lore raw

PATCH v2 2/10 net: ethernet: mtk_wed: move cpuboot in a dedicated dts node

In reply to Lorenzo Bianconi

Since the cpuboot memory region is not part of the RAM MT7986 SoC, move cpuboot in a deidicated syscon node.
Keep backward-compatibility with older dts version where cpuboot was defined as reserved-memory child node.

---
 drivers/net/ethernet/mediatek/mtk_wed_mcu.c | 34 +++++++++++++++++----
 drivers/net/ethernet/mediatek/mtk_wed_wo.h  |  3 +-
 2 files changed, 30 insertions(+), 7 deletions(-)
drivers/net/ethernet/mediatek/mtk_wed_mcu.c +28 -6
index 6624f6d6abdd..797c3b412ab6 100644
@@ -18,12 +18,23 @@
 
 static u32 wo_r32(struct mtk_wed_wo *wo, u32 reg)
 {
-	return readl(wo->boot.addr + reg);
+	u32 val;
+
+	if (!wo->boot_regmap)
+		return readl(wo->boot.addr + reg);
+
+	if (regmap_read(wo->boot_regmap, reg, &val))
+		val = ~0;
+
+	return val;
 }
 
 static void wo_w32(struct mtk_wed_wo *wo, u32 reg, u32 val)
 {
-	writel(val, wo->boot.addr + reg);
+	if (wo->boot_regmap)
+		regmap_write(wo->boot_regmap, reg, val);
+	else
+		writel(val, wo->boot.addr + reg);
 }
 
 static struct sk_buff *
@@ -316,10 +327,21 @@ mtk_wed_mcu_load_firmware(struct mtk_wed_wo *wo)
 			return ret;
 	}
 
-	wo->boot.name = "wo-boot";
-	ret = mtk_wed_get_reserved_memory_region(wo, &wo->boot);
-	if (ret)
-		return ret;
+	wo->boot_regmap = syscon_regmap_lookup_by_phandle(wo->hw->node,
+							  "mediatek,wo-cpuboot");
+	if (IS_ERR(wo->boot_regmap)) {
+		if (wo->boot_regmap != ERR_PTR(-ENODEV))
+			return PTR_ERR(wo->boot_regmap);
+
+		/* For backward compatibility, we need to check if cpu_boot
+		 * is defined through reserved memory property.
+		 */
+		wo->boot_regmap = NULL;
+		wo->boot.name = "wo-boot";
+		ret = mtk_wed_get_reserved_memory_region(wo, &wo->boot);
+		if (ret)
+			return ret;
+	}
 
 	/* set dummy cr */
 	wed_w32(wo->hw->wed_dev, MTK_WED_SCR0 + 4 * MTK_WED_DUMMY_CR_FWDL,
drivers/net/ethernet/mediatek/mtk_wed_wo.h +2 -1
index dbcf42ce9173..c03071203cc0 100644
@@ -227,7 +227,8 @@ struct mtk_wed_wo_queue {
 
 struct mtk_wed_wo {
 	struct mtk_wed_hw *hw;
-	struct mtk_wed_wo_memory_region boot;
+	struct mtk_wed_wo_memory_region boot; /* backward compatibility */
+	struct regmap *boot_regmap;
 
 	struct mtk_wed_wo_queue q_tx;
 	struct mtk_wed_wo_queue q_rx;
Signature · 1 line
2.39.2
maintainer
#3 lore raw

Re: [PATCH v2 net-next 02/10] net: ethernet: mtk_wed: move cpuboot in a dedicated dts node

Quoted 28 lines · Lorenzo Bianconi

Since the cpuboot memory region is not part of the RAM MT7986 SoC, move cpuboot in a deidicated syscon node.
Keep backward-compatibility with older dts version where cpuboot was defined as reserved-memory child node.

---
 drivers/net/ethernet/mediatek/mtk_wed_mcu.c | 34 +++++++++++++++++----
 drivers/net/ethernet/mediatek/mtk_wed_wo.h  |  3 +-
 2 files changed, 30 insertions(+), 7 deletions(-)
drivers/net/ethernet/mediatek/mtk_wed_mcu.c +8 -1
index 6624f6d6abdd..797c3b412ab6 100644
@@ -18,12 +18,23 @@
 
 static u32 wo_r32(struct mtk_wed_wo *wo, u32 reg)
 {
-	return readl(wo->boot.addr + reg);
+	u32 val;
+
+	if (!wo->boot_regmap)
+		return readl(wo->boot.addr + reg);
+
+	if (regmap_read(wo->boot_regmap, reg, &val))
+		val = ~0;
+

drivers/net/ethernet/mediatek/mtk_wed_mcu.c line 37

Quoted 10 lines
drivers/net/ethernet/mediatek/mtk_wed_mcu.c +5 -1
+	return val;
 }
 
 static void wo_w32(struct mtk_wed_wo *wo, u32 reg, u32 val)
 {
-	writel(val, wo->boot.addr + reg);
+	if (wo->boot_regmap)
+		regmap_write(wo->boot_regmap, reg, val);
+	else
+		writel(val, wo->boot.addr + reg);

Very minor nit: it would be more consistent with the read function above if you invert the 2 branches, e.g.:

	if (!wo->boot_regmap)
		writel(val, wo->boot.addr + reg);
	else
		regmap_write(wo->boot_regmap, reg, val);

No need to repost just for the above, just take into consideration if a new version will be needed for other reasons (DT)

Cheers,

Paolo

author maintainer
#4 lore raw

Re: [PATCH v2 net-next 02/10] net: ethernet: mtk_wed: move cpuboot in a dedicated dts node

Quoted 43 lines · Lorenzo Bianconi
Quoted 28 lines

Since the cpuboot memory region is not part of the RAM MT7986 SoC, move cpuboot in a deidicated syscon node.
Keep backward-compatibility with older dts version where cpuboot was defined as reserved-memory child node.

---
 drivers/net/ethernet/mediatek/mtk_wed_mcu.c | 34 +++++++++++++++++----
 drivers/net/ethernet/mediatek/mtk_wed_wo.h  |  3 +-
 2 files changed, 30 insertions(+), 7 deletions(-)
drivers/net/ethernet/mediatek/mtk_wed_mcu.c +8 -1
index 6624f6d6abdd..797c3b412ab6 100644
@@ -18,12 +18,23 @@
 
 static u32 wo_r32(struct mtk_wed_wo *wo, u32 reg)
 {
-	return readl(wo->boot.addr + reg);
+	u32 val;
+
+	if (!wo->boot_regmap)
+		return readl(wo->boot.addr + reg);
+
+	if (regmap_read(wo->boot_regmap, reg, &val))
+		val = ~0;
+

drivers/net/ethernet/mediatek/mtk_wed_mcu.c line 37

Quoted 10 lines
drivers/net/ethernet/mediatek/mtk_wed_mcu.c +5 -1
+	return val;
 }
 
 static void wo_w32(struct mtk_wed_wo *wo, u32 reg, u32 val)
 {
-	writel(val, wo->boot.addr + reg);
+	if (wo->boot_regmap)
+		regmap_write(wo->boot_regmap, reg, val);
+	else
+		writel(val, wo->boot.addr + reg);

Very minor nit: it would be more consistent with the read function above if you invert the 2 branches, e.g.:

Quoted 7 lines
	if (!wo->boot_regmap)
		writel(val, wo->boot.addr + reg);
	else
		regmap_write(wo->boot_regmap, reg, val);

No need to repost just for the above, just take into consideration if a new version will be needed for other reasons (DT)

ack, will do.

Regards,
Lorenzo

Quoted 5 lines

Cheers,

Paolo

author maintainer
#5 lore raw

PATCH v2 3/10 dt-bindings: soc: mediatek: move cpuboot in a dedicated dts node

In reply to Lorenzo Bianconi

Since the cpuboot memory region is not part of the MT7986 RAM SoC, move cpuboot in a deidicated syscon node.

---
 .../arm/mediatek/mediatek,mt7622-wed.yaml     | 12 +++--
 .../mediatek/mediatek,mt7986-wo-cpuboot.yaml  | 45 +++++++++++++++++++
 2 files changed, 53 insertions(+), 4 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/soc/mediatek/mediatek,mt7986-wo-cpuboot.yaml
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7622-wed.yaml +8 -4
index 5c223cb063d4..7f6638d43854 100644
@@ -35,7 +35,6 @@ properties:
       - description: firmware ILM region
       - description: firmware DLM region
       - description: firmware CPU DATA region
-      - description: firmware BOOT region
 
   memory-region-names:
     items:
@@ -43,12 +42,15 @@ properties:
       - const: wo-ilm
       - const: wo-dlm
       - const: wo-data
-      - const: wo-boot
 
   mediatek,wo-ccif:
     $ref: /schemas/types.yaml#/definitions/phandle
     description: mediatek wed-wo controller interface.
 
+  mediatek,wo-cpuboot:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description: mediatek wed-wo cpuboot controller interface.
+
 allOf:
   - if:
       properties:
@@ -60,6 +62,7 @@ allOf:
         memory-region-names: false
         memory-region: false
         mediatek,wo-ccif: false
+        mediatek,wo-cpuboot: false
 
 required:
   - compatible
@@ -95,9 +98,10 @@ examples:
         interrupts = <GIC_SPI 205 IRQ_TYPE_LEVEL_HIGH>;
 
         memory-region = <&wo_emi>, <&wo_ilm>, <&wo_dlm>,
-                        <&wo_data>, <&wo_boot>;
+                        <&wo_data>;
         memory-region-names = "wo-emi", "wo-ilm", "wo-dlm",
-                              "wo-data", "wo-boot";
+                              "wo-data";
         mediatek,wo-ccif = <&wo_ccif0>;
+        mediatek,wo-cpuboot = <&wo_cpuboot>;
       };
     };
Documentation/devicetree/bindings/soc/mediatek/mediatek,mt7986-wo-cpuboot.yaml new file +45 -0

45 lines not on this page · raw message

Signature · 1 line
2.39.2
author maintainer
#6 lore raw

PATCH v2 4/10 arm64: dts: mt7986: move cpuboot in a dedicated node

In reply to Lorenzo Bianconi

Since the cpuboot memory region is not part of the MT7986 RAM SoC, move cpuboot in a deidicated syscon node.

---
 arch/arm64/boot/dts/mediatek/mt7986a.dtsi | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)
arch/arm64/boot/dts/mediatek/mt7986a.dtsi +11 -10
index 51944690e790..668b6cfa6a3d 100644
@@ -113,12 +113,6 @@ 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 {
@@ -461,10 +455,11 @@ wed0: wed@15010000 {
 			interrupt-parent = <&gic>;
 			interrupts = <GIC_SPI 205 IRQ_TYPE_LEVEL_HIGH>;
 			memory-region = <&wo_emi0>, <&wo_ilm0>, <&wo_dlm0>,
-					<&wo_data>, <&wo_boot>;
+					<&wo_data>;
 			memory-region-names = "wo-emi", "wo-ilm", "wo-dlm",
-					      "wo-data", "wo-boot";
+					      "wo-data";
 			mediatek,wo-ccif = <&wo_ccif0>;
+			mediatek,wo-cpuboot = <&wo_cpuboot>;
 		};
 
 		wed1: wed@15011000 {
@@ -474,10 +469,11 @@ wed1: wed@15011000 {
 			interrupt-parent = <&gic>;
 			interrupts = <GIC_SPI 206 IRQ_TYPE_LEVEL_HIGH>;
 			memory-region = <&wo_emi1>, <&wo_ilm1>, <&wo_dlm1>,
-					<&wo_data>, <&wo_boot>;
+					<&wo_data>;
 			memory-region-names = "wo-emi", "wo-ilm", "wo-dlm",
-					      "wo-data", "wo-boot";
+					      "wo-data";
 			mediatek,wo-ccif = <&wo_ccif1>;
+			mediatek,wo-cpuboot = <&wo_cpuboot>;
 		};
 
 		wo_ccif0: syscon@151a5000 {
@@ -494,6 +490,11 @@ wo_ccif1: syscon@151ad000 {
 			interrupts = <GIC_SPI 212 IRQ_TYPE_LEVEL_HIGH>;
 		};
 
+		wo_cpuboot: syscon@15194000 {
+			compatible = "mediatek,mt7986-wo-cpuboot", "syscon";
+			reg = <0 0x15194000 0 0x1000>;
+		};
+
 		eth: ethernet@15100000 {
 			compatible = "mediatek,mt7986-eth";
 			reg = <0 0x15100000 0 0x80000>;
Signature · 1 line
2.39.2
author maintainer
#7 lore raw

PATCH v2 5/10 net: ethernet: mtk_wed: move ilm a dedicated dts node

In reply to Lorenzo Bianconi

Since the ilm memory region is not part of the MT7986 RAM SoC, move ilm in a deidicated syscon node.
Keep backward-compatibility with older dts version where ilm was defined as reserved-memory child node.

---
 drivers/net/ethernet/mediatek/mtk_wed_mcu.c | 55 ++++++++++++++++++---
 1 file changed, 49 insertions(+), 6 deletions(-)
drivers/net/ethernet/mediatek/mtk_wed_mcu.c +49 -6
index 797c3b412ab6..a19db914ebd2 100644
@@ -299,6 +299,52 @@ mtk_wed_mcu_run_firmware(struct mtk_wed_wo *wo, const struct firmware *fw,
 	return -EINVAL;
 }
 
+static int
+mtk_wed_mcu_load_memory_regions(struct mtk_wed_wo *wo,
+				struct mtk_wed_wo_memory_region *region)
+{
+	struct device_node *np;
+	int ret;
+
+	/* firmware EMI memory region */
+	ret = mtk_wed_get_reserved_memory_region(wo,
+			&region[MTK_WED_WO_REGION_EMI]);
+	if (ret)
+		return ret;
+
+	/* firmware DATA memory region */
+	ret = mtk_wed_get_reserved_memory_region(wo,
+			&region[MTK_WED_WO_REGION_DATA]);
+	if (ret)
+		return ret;
+
+	np = of_parse_phandle(wo->hw->node, "mediatek,wo-ilm", 0);
+	if (np) {
+		struct mtk_wed_wo_memory_region *ilm_region;
+		struct resource res;
+
+		ret = of_address_to_resource(np, 0, &res);
+		of_node_put(np);
+
+		if (ret < 0)
+			return ret;
+
+		ilm_region = &region[MTK_WED_WO_REGION_ILM];
+		ilm_region->phy_addr = res.start;
+		ilm_region->size = resource_size(&res);
+		ilm_region->addr = devm_ioremap(wo->hw->dev, ilm_region->phy_addr,
+						ilm_region->size);
+
+		return ilm_region->addr ? 0 : -ENOMEM;
+	}
+
+	/* For backward compatibility, we need to check if ILM
+	 * node is defined through reserved memory property.
+	 */
+	return mtk_wed_get_reserved_memory_region(wo,
+			&region[MTK_WED_WO_REGION_ILM]);
+}
+
 static int
 mtk_wed_mcu_load_firmware(struct mtk_wed_wo *wo)
 {
@@ -320,12 +366,9 @@ mtk_wed_mcu_load_firmware(struct mtk_wed_wo *wo)
 	u32 val, boot_cr;
 	int ret, i;
 
-	/* load firmware region metadata */
-	for (i = 0; i < ARRAY_SIZE(mem_region); i++) {
-		ret = mtk_wed_get_reserved_memory_region(wo, &mem_region[i]);
-		if (ret)
-			return ret;
-	}
+	ret = mtk_wed_mcu_load_memory_regions(wo, mem_region);
+	if (ret)
+		return ret;
 
 	wo->boot_regmap = syscon_regmap_lookup_by_phandle(wo->hw->node,
 							  "mediatek,wo-cpuboot");
Signature · 1 line
2.39.2
author maintainer
#8 lore raw

PATCH v2 6/10 dt-bindings: soc: mediatek: move ilm in a dedicated dts node

In reply to Lorenzo Bianconi

Since the ilm memory region is not part of the MT7986 RAM SoC, move ilm in a deidicated syscon node.

---
 .../arm/mediatek/mediatek,mt7622-wed.yaml     | 14 +++---
 .../soc/mediatek/mediatek,mt7986-wo-ilm.yaml  | 45 +++++++++++++++++++
 2 files changed, 53 insertions(+), 6 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/soc/mediatek/mediatek,mt7986-wo-ilm.yaml
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7622-wed.yaml +8 -6
index 7f6638d43854..e63fb22447c6 100644
@@ -32,14 +32,12 @@ properties:
   memory-region:
     items:
       - description: firmware EMI region
-      - description: firmware ILM region
       - description: firmware DLM region
       - description: firmware CPU DATA region
 
   memory-region-names:
     items:
       - const: wo-emi
-      - const: wo-ilm
       - const: wo-dlm
       - const: wo-data
 
@@ -51,6 +49,10 @@ properties:
     $ref: /schemas/types.yaml#/definitions/phandle
     description: mediatek wed-wo cpuboot controller interface.
 
+  mediatek,wo-ilm:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description: mediatek wed-wo ilm interface.
+
 allOf:
   - if:
       properties:
@@ -63,6 +65,7 @@ allOf:
         memory-region: false
         mediatek,wo-ccif: false
         mediatek,wo-cpuboot: false
+        mediatek,wo-ilm: false
 
 required:
   - compatible
@@ -97,11 +100,10 @@ examples:
         reg = <0 0x15010000 0 0x1000>;
         interrupts = <GIC_SPI 205 IRQ_TYPE_LEVEL_HIGH>;
 
-        memory-region = <&wo_emi>, <&wo_ilm>, <&wo_dlm>,
-                        <&wo_data>;
-        memory-region-names = "wo-emi", "wo-ilm", "wo-dlm",
-                              "wo-data";
+        memory-region = <&wo_emi>, <&wo_dlm>, <&wo_data>;
+        memory-region-names = "wo-emi", "wo-dlm", "wo-data";
         mediatek,wo-ccif = <&wo_ccif0>;
         mediatek,wo-cpuboot = <&wo_cpuboot>;
+        mediatek,wo-ilm = <&wo_ilm>;
       };
     };
Documentation/devicetree/bindings/soc/mediatek/mediatek,mt7986-wo-ilm.yaml new file +45 -0

45 lines not on this page · raw message

Signature · 1 line
2.39.2
maintainer
#9 lore raw

Re: [PATCH v2 net-next 06/10] dt-bindings: soc: mediatek: move ilm in a dedicated dts node

Quoted 104 lines · Lorenzo Bianconi

Since the ilm memory region is not part of the MT7986 RAM SoC, move ilm in a deidicated syscon node.

---
 .../arm/mediatek/mediatek,mt7622-wed.yaml     | 14 +++---
 .../soc/mediatek/mediatek,mt7986-wo-ilm.yaml  | 45 +++++++++++++++++++
 2 files changed, 53 insertions(+), 6 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/soc/mediatek/mediatek,mt7986-wo-ilm.yaml
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7622-wed.yaml +8 -6
index 7f6638d43854..e63fb22447c6 100644
@@ -32,14 +32,12 @@ properties:
   memory-region:
     items:
       - description: firmware EMI region
-      - description: firmware ILM region
       - description: firmware DLM region
       - description: firmware CPU DATA region
 
   memory-region-names:
     items:
       - const: wo-emi
-      - const: wo-ilm
       - const: wo-dlm
       - const: wo-data
 
@@ -51,6 +49,10 @@ properties:
     $ref: /schemas/types.yaml#/definitions/phandle
     description: mediatek wed-wo cpuboot controller interface.
 
+  mediatek,wo-ilm:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description: mediatek wed-wo ilm interface.
+
 allOf:
   - if:
       properties:
@@ -63,6 +65,7 @@ allOf:
         memory-region: false
         mediatek,wo-ccif: false
         mediatek,wo-cpuboot: false
+        mediatek,wo-ilm: false
 
 required:
   - compatible
@@ -97,11 +100,10 @@ examples:
         reg = <0 0x15010000 0 0x1000>;
         interrupts = <GIC_SPI 205 IRQ_TYPE_LEVEL_HIGH>;
 
-        memory-region = <&wo_emi>, <&wo_ilm>, <&wo_dlm>,
-                        <&wo_data>;
-        memory-region-names = "wo-emi", "wo-ilm", "wo-dlm",
-                              "wo-data";
+        memory-region = <&wo_emi>, <&wo_dlm>, <&wo_data>;
+        memory-region-names = "wo-emi", "wo-dlm", "wo-data";
         mediatek,wo-ccif = <&wo_ccif0>;
         mediatek,wo-cpuboot = <&wo_cpuboot>;
+        mediatek,wo-ilm = <&wo_ilm>;
       };
     };
Documentation/devicetree/bindings/soc/mediatek/mediatek,mt7986-wo-ilm.yaml new file +35 -0
new file mode 100644
index 000000000000..2a3775cd941e
@@ -0,0 +1,45 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/soc/mediatek/mediatek,mt7986-wo-ilm.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MediaTek Wireless Ethernet Dispatch (WED) WO ILM firmware interface for MT7986
+
+maintainers:
+  - Lorenzo Bianconi <[email protected]>
+  - Felix Fietkau <[email protected]>
+
+description:
+  The MediaTek wo-ilm (Information Lifecycle Management) provides a configuration
+  interface for WiFi critical data used by WED WO firmware. WED WO controller is
+  used to perform offload rx packet processing (e.g. 802.11 aggregation packet
+  reordering or rx header translation) on MT7986 soc.
+
+properties:
+  compatible:
+    items:
+      - enum:
+          - mediatek,mt7986-wo-ilm
+      - const: syscon
+
+  reg:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: false
+
+examples:

Documentation/devicetree/bindings/soc/mediatek/mediatek,mt7986-wo-ilm.yaml line 45

Quoted 10 lines
Documentation/devicetree/bindings/soc/mediatek/mediatek,mt7986-wo-ilm.yaml new file +10 -0
+  - |
+    soc {
+      #address-cells = <2>;
+      #size-cells = <2>;
+
+      syscon@151e0000 {
+        compatible = "mediatek,mt7986-wo-ilm", "syscon";
+        reg = <0 0x151e0000 0 0x8000>;
+      };
+    };

Hi Rob,

it's not clear to me if this version and Lorenzo's replies on the previous one address your doubts here. Do you have any further comments?

Thanks,

Paolo

author maintainer
#10 lore raw

PATCH v2 7/10 arm64: dts: mt7986: move ilm in a dedicated node

In reply to Lorenzo Bianconi

Since the ilm memory region is not part of the MT7986 RAM SoC, move ilm in a deidicated syscon node.

---
 arch/arm64/boot/dts/mediatek/mt7986a.dtsi | 34 +++++++++++------------
 1 file changed, 16 insertions(+), 18 deletions(-)
arch/arm64/boot/dts/mediatek/mt7986a.dtsi +16 -18
index 668b6cfa6a3d..a0d96d232ee5 100644
@@ -89,16 +89,6 @@ wo_emi1: wo-emi@4fd40000 {
 			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;
@@ -454,11 +444,10 @@ wed0: wed@15010000 {
 			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>;
-			memory-region-names = "wo-emi", "wo-ilm", "wo-dlm",
-					      "wo-data";
+			memory-region = <&wo_emi0>, <&wo_dlm0>, <&wo_data>;
+			memory-region-names = "wo-emi", "wo-dlm", "wo-data";
 			mediatek,wo-ccif = <&wo_ccif0>;
+			mediatek,wo-ilm = <&wo_ilm0>;
 			mediatek,wo-cpuboot = <&wo_cpuboot>;
 		};
 
@@ -468,11 +457,10 @@ wed1: wed@15011000 {
 			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>;
-			memory-region-names = "wo-emi", "wo-ilm", "wo-dlm",
-					      "wo-data";
+			memory-region = <&wo_emi1>, <&wo_dlm1>, <&wo_data>;
+			memory-region-names = "wo-emi", "wo-dlm", "wo-data";
 			mediatek,wo-ccif = <&wo_ccif1>;
+			mediatek,wo-ilm = <&wo_ilm1>;
 			mediatek,wo-cpuboot = <&wo_cpuboot>;
 		};
 
@@ -490,6 +478,16 @@ wo_ccif1: syscon@151ad000 {
 			interrupts = <GIC_SPI 212 IRQ_TYPE_LEVEL_HIGH>;
 		};
 
+		wo_ilm0: syscon@151e0000 {
+			compatible = "mediatek,mt7986-wo-ilm", "syscon";
+			reg = <0 0x151e0000 0 0x8000>;
+		};
+
+		wo_ilm1: syscon@151f0000 {
+			compatible = "mediatek,mt7986-wo-ilm", "syscon";
+			reg = <0 0x151f0000 0 0x8000>;
+		};
+
 		wo_cpuboot: syscon@15194000 {
 			compatible = "mediatek,mt7986-wo-cpuboot", "syscon";
 			reg = <0 0x15194000 0 0x1000>;
Signature · 1 line
2.39.2
author maintainer
#11 lore raw

PATCH v2 8/10 net: ethernet: mtk_wed: move dlm a dedicated dts node

In reply to Lorenzo Bianconi

Since the dlm memory region is not part of the MT7986 RAM SoC, move dlm in a deidicated syscon node.
Keep backward-compatibility with older dts version where dlm was defined as reserved-memory child node.

---
 drivers/net/ethernet/mediatek/mtk_wed.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
drivers/net/ethernet/mediatek/mtk_wed.c +19 -0
index 95d890870984..e479ff924ed6 100644
@@ -799,6 +799,24 @@ mtk_wed_rro_alloc(struct mtk_wed_device *dev)
 	struct device_node *np;
 	int index;
 
+	np = of_parse_phandle(dev->hw->node, "mediatek,wo-dlm", 0);
+	if (np) {
+		struct resource res;
+		int ret;
+
+		ret = of_address_to_resource(np, 0, &res);
+		of_node_put(np);
+
+		if (ret < 0)
+			return ret;
+
+		dev->rro.miod_phys = res.start;
+		goto out;
+	}
+
+	/* For backward compatibility, we need to check if DLM
+	 * node is defined through reserved memory property.
+	 */
 	index = of_property_match_string(dev->hw->node, "memory-region-names",
 					 "wo-dlm");
 	if (index < 0)
@@ -815,6 +833,7 @@ mtk_wed_rro_alloc(struct mtk_wed_device *dev)
 		return -ENODEV;
 
 	dev->rro.miod_phys = rmem->base;
+out:
 	dev->rro.fdbk_phys = MTK_WED_MIOD_COUNT + dev->rro.miod_phys;
 
 	return mtk_wed_rro_ring_alloc(dev, &dev->rro.ring,
Signature · 1 line
2.39.2
author maintainer
#12 lore raw

PATCH v2 9/10 dt-bindings: soc: mediatek: move dlm in a dedicated dts node

In reply to Lorenzo Bianconi

Since the dlm memory region is not part of the MT7986 RAM SoC, move dlm in a deidicated syscon node.

---
 .../arm/mediatek/mediatek,mt7622-wed.yaml     | 12 +++--
 .../soc/mediatek/mediatek,mt7986-wo-dlm.yaml  | 46 +++++++++++++++++++
 2 files changed, 54 insertions(+), 4 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/soc/mediatek/mediatek,mt7986-wo-dlm.yaml
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7622-wed.yaml +8 -4
index e63fb22447c6..e4707880eca7 100644
@@ -32,13 +32,11 @@ properties:
   memory-region:
     items:
       - description: firmware EMI region
-      - description: firmware DLM region
       - description: firmware CPU DATA region
 
   memory-region-names:
     items:
       - const: wo-emi
-      - const: wo-dlm
       - const: wo-data
 
   mediatek,wo-ccif:
@@ -53,6 +51,10 @@ properties:
     $ref: /schemas/types.yaml#/definitions/phandle
     description: mediatek wed-wo ilm interface.
 
+  mediatek,wo-dlm:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description: mediatek wed-wo dlm interface.
+
 allOf:
   - if:
       properties:
@@ -66,6 +68,7 @@ allOf:
         mediatek,wo-ccif: false
         mediatek,wo-cpuboot: false
         mediatek,wo-ilm: false
+        mediatek,wo-dlm: false
 
 required:
   - compatible
@@ -100,10 +103,11 @@ examples:
         reg = <0 0x15010000 0 0x1000>;
         interrupts = <GIC_SPI 205 IRQ_TYPE_LEVEL_HIGH>;
 
-        memory-region = <&wo_emi>, <&wo_dlm>, <&wo_data>;
-        memory-region-names = "wo-emi", "wo-dlm", "wo-data";
+        memory-region = <&wo_emi>, <&wo_data>;
+        memory-region-names = "wo-emi", "wo-data";
         mediatek,wo-ccif = <&wo_ccif0>;
         mediatek,wo-cpuboot = <&wo_cpuboot>;
         mediatek,wo-ilm = <&wo_ilm>;
+        mediatek,wo-dlm = <&wo_dlm>;
       };
     };
Documentation/devicetree/bindings/soc/mediatek/mediatek,mt7986-wo-dlm.yaml new file +46 -0

46 lines not on this page · raw message

Signature · 1 line
2.39.2
author maintainer
#13 lore raw

PATCH v2 10/10 arm64: dts: mt7986: move dlm in a dedicated node

In reply to Lorenzo Bianconi

Since the dlm memory region is not part of the RAM SoC, move dlm in a deidicated syscon node.

---
 arch/arm64/boot/dts/mediatek/mt7986a.dtsi | 30 ++++++++++++-----------
 1 file changed, 16 insertions(+), 14 deletions(-)
arch/arm64/boot/dts/mediatek/mt7986a.dtsi +16 -14
index a0d96d232ee5..0ae6aa59d3c6 100644
@@ -93,16 +93,6 @@ 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;
-		};
 	};
 
 	timer {
@@ -444,10 +434,11 @@ wed0: wed@15010000 {
 			reg = <0 0x15010000 0 0x1000>;
 			interrupt-parent = <&gic>;
 			interrupts = <GIC_SPI 205 IRQ_TYPE_LEVEL_HIGH>;
-			memory-region = <&wo_emi0>, <&wo_dlm0>, <&wo_data>;
-			memory-region-names = "wo-emi", "wo-dlm", "wo-data";
+			memory-region = <&wo_emi0>, <&wo_data>;
+			memory-region-names = "wo-emi", "wo-data";
 			mediatek,wo-ccif = <&wo_ccif0>;
 			mediatek,wo-ilm = <&wo_ilm0>;
+			mediatek,wo-dlm = <&wo_dlm0>;
 			mediatek,wo-cpuboot = <&wo_cpuboot>;
 		};
 
@@ -457,10 +448,11 @@ wed1: wed@15011000 {
 			reg = <0 0x15011000 0 0x1000>;
 			interrupt-parent = <&gic>;
 			interrupts = <GIC_SPI 206 IRQ_TYPE_LEVEL_HIGH>;
-			memory-region = <&wo_emi1>, <&wo_dlm1>, <&wo_data>;
-			memory-region-names = "wo-emi", "wo-dlm", "wo-data";
+			memory-region = <&wo_emi1>, <&wo_data>;
+			memory-region-names = "wo-emi", "wo-data";
 			mediatek,wo-ccif = <&wo_ccif1>;
 			mediatek,wo-ilm = <&wo_ilm1>;
+			mediatek,wo-dlm = <&wo_dlm1>;
 			mediatek,wo-cpuboot = <&wo_cpuboot>;
 		};
 
@@ -488,6 +480,16 @@ wo_ilm1: syscon@151f0000 {
 			reg = <0 0x151f0000 0 0x8000>;
 		};
 
+		wo_dlm0: syscon@151e8000 {
+			compatible = "mediatek,mt7986-wo-dlm", "syscon";
+			reg = <0 0x151e8000 0 0x2000>;
+		};
+
+		wo_dlm1: syscon@151f8000 {
+			compatible = "mediatek,mt7986-wo-dlm", "syscon";
+			reg = <0 0x151f8000 0 0x2000>;
+		};
+
 		wo_cpuboot: syscon@15194000 {
 			compatible = "mediatek,mt7986-wo-cpuboot", "syscon";
 			reg = <0 0x15194000 0 0x1000>;
Signature · 1 line
2.39.2
maintainer
#14 lore raw
In reply to Lorenzo Bianconi
Quoted 1 line · Lorenzo Bianconi

Since cpuboot, ilm and dlm memory region are not part of MT7986 SoC RAM,

That's not really a requirement. Is that the only "problem" here?

Certainly going from a standard binding to a custom phandle reference is not an improvement.

Quoted 1 line

move them in dedicated mt7986a syscon dts nodes.

What makes them a syscon? Are they memory or h/w registers? Can't be both...

Perhaps mmio-sram?

Quoted 2 lines

At the same time we keep backward-compatibility with older dts version where cpuboot, ilm and dlm were defined as reserved-memory child nodes.

Doesn't really seem big enough issue to justify carrying this.

Rob

author maintainer
#15 lore raw
Quoted 4 lines · Lorenzo Bianconi
Quoted 1 line

Since cpuboot, ilm and dlm memory region are not part of MT7986 SoC RAM,

That's not really a requirement. Is that the only "problem" here?

I would say this series allows to be closer to a standard binding and at the same time helps with uboot compatibility.

Quoted 11 lines

Certainly going from a standard binding to a custom phandle reference is not an improvement.

Quoted 1 line

move them in dedicated mt7986a syscon dts nodes.

What makes them a syscon? Are they memory or h/w registers? Can't be both...

Perhaps mmio-sram?

ilm and dlm do not have h/w registers afaik, they are chip memory used to store firmware information, syscon is just the closest binding I found. I did not find mmio-sram, my fault.

Regards,
Lorenzo

Quoted 7 lines
Quoted 3 lines

At the same time we keep backward-compatibility with older dts version where cpuboot, ilm and dlm were defined as reserved-memory child nodes.

Doesn't really seem big enough issue to justify carrying this.

Rob