introduce WED RX support to MT7986 SoC
Subsystems (5)
Lorenzo Bianconi
maintainerv3 cover introduce WED RX support to MT7986 SoC
Similar to TX counterpart available on MT7622 and MT7986, introduce RX Wireless Ethernet Dispatch available on MT7986 SoC in order to offload traffic received by wlan nic to the wired interfaces (lan/wan).
Changes since v2:
- rely on of_reserved_mem APIs in mcu code
- add some dts fixes
- rename {tx,rx}_wdma in {rx,tx}_wdma
- update entry in maintainers file
Changes since v1:
- fix sparse warnings
- rely on memory-region property in mt7622-wed.yaml
- some more binding fixes
Lorenzo Bianconi (7):
arm64: dts: mediatek: mt7986: add support for RX Wireless Ethernet
Dispatch
dt-bindings: net: mediatek: add WED RX binding for MT7986 eth driver
net: ethernet: mtk_wed: introduce wed wo support
net: ethernet: mtk_wed: rename tx_wdma array in rx_wdma
net: ethernet: mtk_wed: add configure wed wo support
net: ethernet: mtk_wed: add rx mib counters
MAINTAINERS: update MEDIATEK ETHERNET entry
Sujuan Chen (1):
net: ethernet: mtk_wed: introduce wed mcu support
.../arm/mediatek/mediatek,mt7622-wed.yaml | 62 +- .../arm/mediatek/mediatek,mt7986-wo-boot.yaml | 47 ++ .../arm/mediatek/mediatek,mt7986-wo-ccif.yaml | 50 ++ .../arm/mediatek/mediatek,mt7986-wo-dlm.yaml | 50 ++ MAINTAINERS | 1 + arch/arm64/boot/dts/mediatek/mt7986a.dtsi | 75 +++ drivers/net/ethernet/mediatek/Makefile | 2 +- drivers/net/ethernet/mediatek/mtk_wed.c | 609 ++++++++++++++++-- drivers/net/ethernet/mediatek/mtk_wed.h | 21 + .../net/ethernet/mediatek/mtk_wed_debugfs.c | 87 +++ drivers/net/ethernet/mediatek/mtk_wed_mcu.c | 392 +++++++++++ drivers/net/ethernet/mediatek/mtk_wed_regs.h | 129 +++- drivers/net/ethernet/mediatek/mtk_wed_wo.c | 508 +++++++++++++++ drivers/net/ethernet/mediatek/mtk_wed_wo.h | 284 ++++++++ include/linux/soc/mediatek/mtk_wed.h | 106 ++- 15 files changed, 2366 insertions(+), 57 deletions(-) create mode 100644 Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-boot.yaml create mode 100644 Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-ccif.yaml create mode 100644 Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-dlm.yaml create mode 100644 drivers/net/ethernet/mediatek/mtk_wed_mcu.c create mode 100644 drivers/net/ethernet/mediatek/mtk_wed_wo.c create mode 100644 drivers/net/ethernet/mediatek/mtk_wed_wo.h
Signature · 1 line
2.38.1
Lorenzo Bianconi
maintainerPATCH v3 1/8 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.
--- arch/arm64/boot/dts/mediatek/mt7986a.dtsi | 75 +++++++++++++++++++++++ 1 file changed, 75 insertions(+)
arch/arm64/boot/dts/mediatek/mt7986a.dtsi +75 -0
@@ -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/reset/ti-syscon.h> / { interrupt-parent = <&gic>;
@@ -76,6 +77,31 @@ wmcpu_emi: wmcpu-reserved@4fc00000 { 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; + }; }; timer {
@@ -226,6 +252,12 @@ ethsys: syscon@15000000 { reg = <0 0x15000000 0 0x1000>; #clock-cells = <1>; #reset-cells = <1>; + + ethsysrst: reset-controller { + compatible = "ti,syscon-reset"; + #reset-cells = <1>; + ti,reset-bits = <0x34 4 0x34 4 0x34 4 (ASSERT_SET | DEASSERT_CLEAR | STATUS_SET)>; + }; }; wed_pcie: wed-pcie@10003000 {
@@ -240,6 +272,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_ilm0>, <&wo_data>; + memory-region-names = "wo-emi", "wo-ilm", "wo-data"; + mediatek,wo-ccif = <&wo_ccif0>; + mediatek,wo-boot = <&wo_boot>; + mediatek,wo-dlm = <&wo_dlm0>; }; wed1: wed@15011000 {
@@ -248,6 +285,44 @@ 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_data>; + memory-region-names = "wo-emi", "wo-ilm", "wo-data"; + mediatek,wo-ccif = <&wo_ccif1>; + mediatek,wo-boot = <&wo_boot>; + mediatek,wo-dlm = <&wo_dlm1>; + }; + + 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>; + }; + + wo_dlm0: wo-dlm@151e8000 { + compatible = "mediatek,mt7986-wo-dlm"; + reg = <0 0x151e8000 0 0x2000>; + resets = <ðsysrst 0>; + reset-names = "wocpu_rst"; + }; + + wo_dlm1: wo-dlm@151f8000 { + compatible = "mediatek,mt7986-wo-dlm"; + reg = <0 0x151f8000 0 0x2000>; + resets = <ðsysrst 0>; + reset-names = "wocpu_rst"; + }; + + wo_boot: syscon@15194000 { + compatible = "mediatek,mt7986-wo-boot", "syscon"; + reg = <0 0x15194000 0 0x1000>; }; eth: ethernet@15100000 {
Signature · 1 line
2.38.1
AngeloGioacchino Del Regno
maintainerRe: [PATCH v3 net-next 1/8] arm64: dts: mediatek: mt7986: add support for RX Wireless Ethernet Dispatch
Il 03/11/22 10:28, Lorenzo Bianconi ha scritto:
Quoted 7 lines
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 <[email protected]>Signed-off-by Sujuan Chen <[email protected]>Signed-off-by Lorenzo Bianconi <[email protected]>
Hello Lorenzo,
thanks for the patch! However, there's something to improve...
Quoted 8 lines
--- arch/arm64/boot/dts/mediatek/mt7986a.dtsi | 75 +++++++++++++++++++++++ 1 file changed, 75 insertions(+)arch/arm64/boot/dts/mediatek/mt7986a.dtsi +0
-0
..snip..
arch/arm64/boot/dts/mediatek/mt7986a.dtsi ethsys: syscon@15000000 { · line 256
Quoted 6 lines
arch/arm64/boot/dts/mediatek/mt7986a.dtsi +2
-0@@ -226,6 +252,12 @@ ethsys: syscon@15000000 { reg = <0 0x15000000 0 0x1000>; #clock-cells = <1>; #reset-cells = <1>; + + ethsysrst: reset-controller {
That's not right. It works, yes, but your ethsys rightfully declares #reset-cells, because it is supposed to also be a reset controller (even though I don't see any reset controller registering action in clk-mt7986-eth.c).
Please document the ethernet reset in the appropriate dt-bindings header and register the reset controller in clk-mt7986-eth.c.
Finally, you won't need any "ti,syscon-reset" node, and resets will look like
resets = <ðsys MT7986_ETHSYS_SOMETHING_SWRST>;
If you need any hint about how to do that, please check clk-mt8195-infra_ao.c.
Regards,
Angelo
Lorenzo Bianconi
maintainerRe: [PATCH v3 net-next 1/8] arm64: dts: mediatek: mt7986: add support for RX Wireless Ethernet Dispatch
Quoted 34 lines
Il 03/11/22 10:28, Lorenzo Bianconi ha scritto:
Quoted 7 lines
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 <[email protected]>Signed-off-by Sujuan Chen <[email protected]>Signed-off-by Lorenzo Bianconi <[email protected]>Hello Lorenzo,
thanks for the patch! However, there's something to improve...Quoted 8 lines
--- arch/arm64/boot/dts/mediatek/mt7986a.dtsi | 75 +++++++++++++++++++++++ 1 file changed, 75 insertions(+)arch/arm64/boot/dts/mediatek/mt7986a.dtsi +0
-0..snip..
arch/arm64/boot/dts/mediatek/mt7986a.dtsi ethsys: syscon@15000000 { · line 256
Quoted 6 lines
arch/arm64/boot/dts/mediatek/mt7986a.dtsi +2
-0@@ -226,6 +252,12 @@ ethsys: syscon@15000000 { reg = <0 0x15000000 0 0x1000>; #clock-cells = <1>; #reset-cells = <1>; + + ethsysrst: reset-controller {That's not right. It works, yes, but your ethsys rightfully declares #reset-cells, because it is supposed to also be a reset controller (even though I don't see any reset controller registering action in
clk-mt7986-eth.c).
Quoted 8 lines
Please document the ethernet reset in the appropriate dt-bindings header and register the reset controller in
clk-mt7986-eth.c.Finally, you won't need any "ti,syscon-reset" node, and resets will look like
resets = <ðsys MT7986_ETHSYS_SOMETHING_SWRST>;If you need any hint about how to do that, please check
clk-mt8195-infra_ao.c.
Hi Angelo,
Thx for the review. This is not strictly related to the wed rx support added in this series, anyway I will look into it in the next revision.
Regards,
Lorenzo
Quoted 4 lines
Regards,
Angelo
Lorenzo Bianconi
maintainerRe: [PATCH v3 net-next 1/8] arm64: dts: mediatek: mt7986: add support for RX Wireless Ethernet Dispatch
In reply to AngeloGioacchino Del RegnoQuoted 10 lines
Il 03/11/22 10:28, Lorenzo Bianconi ha scritto:
Quoted 7 lines
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 <[email protected]>Signed-off-by Sujuan Chen <[email protected]>Signed-off-by Lorenzo Bianconi <[email protected]>Hello Lorenzo,
Hi Angelo,
Quoted 24 lines
thanks for the patch! However, there's something to improve...
Quoted 8 lines
--- arch/arm64/boot/dts/mediatek/mt7986a.dtsi | 75 +++++++++++++++++++++++ 1 file changed, 75 insertions(+)arch/arm64/boot/dts/mediatek/mt7986a.dtsi +0
-0..snip..
arch/arm64/boot/dts/mediatek/mt7986a.dtsi ethsys: syscon@15000000 { · line 256
Quoted 6 lines
arch/arm64/boot/dts/mediatek/mt7986a.dtsi +2
-0@@ -226,6 +252,12 @@ ethsys: syscon@15000000 { reg = <0 0x15000000 0 0x1000>; #clock-cells = <1>; #reset-cells = <1>; + + ethsysrst: reset-controller {That's not right. It works, yes, but your ethsys rightfully declares #reset-cells, because it is supposed to also be a reset controller (even though I don't see any reset controller registering action in
clk-mt7986-eth.c).
Quoted 8 lines
Please document the ethernet reset in the appropriate dt-bindings header and register the reset controller in
clk-mt7986-eth.c.Finally, you won't need any "ti,syscon-reset" node, and resets will look like
resets = <ðsys MT7986_ETHSYS_SOMETHING_SWRST>;If you need any hint about how to do that, please check
clk-mt8195-infra_ao.c.
reviewing the code I think we do not have any mt7986-eth reset line consumer at the moment, since:
- mtk_eth_soc driver rely on syscon for resetting the chip writing directly in the register in ethsys_reset()
- we do not rely on reset api in wed wo code.
I think we can just drop reset support in ethsys/wo-dlm nodes at the moment (since it is not used in this series) and convert the driver to reset api as soon as we have proper support in clk-mt7986-eth.c (AFAIU sam will work on it).
Regards,
Lorenzo
Quoted 4 lines
Regards,
Angelo
AngeloGioacchino Del Regno
maintainerRe: [PATCH v3 net-next 1/8] arm64: dts: mediatek: mt7986: add support for RX Wireless Ethernet Dispatch
Il 04/11/22 10:05, Lorenzo Bianconi ha scritto:
Quoted 42 lines
Quoted 10 lines
Il 03/11/22 10:28, Lorenzo Bianconi ha scritto:
Quoted 7 lines
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 <[email protected]>Signed-off-by Sujuan Chen <[email protected]>Signed-off-by Lorenzo Bianconi <[email protected]>Hello Lorenzo,
Hi Angelo,
Quoted 29 lines
thanks for the patch! However, there's something to improve...
Quoted 8 lines
--- arch/arm64/boot/dts/mediatek/mt7986a.dtsi | 75 +++++++++++++++++++++++ 1 file changed, 75 insertions(+)arch/arm64/boot/dts/mediatek/mt7986a.dtsi +0
-0..snip..
arch/arm64/boot/dts/mediatek/mt7986a.dtsi ethsys: syscon@15000000 { · line 256
Quoted 6 lines
arch/arm64/boot/dts/mediatek/mt7986a.dtsi +2
-0@@ -226,6 +252,12 @@ ethsys: syscon@15000000 { reg = <0 0x15000000 0 0x1000>; #clock-cells = <1>; #reset-cells = <1>; + + ethsysrst: reset-controller {That's not right. It works, yes, but your ethsys rightfully declares #reset-cells, because it is supposed to also be a reset controller (even though I don't see any reset controller registering action in
clk-mt7986-eth.c).Please document the ethernet reset in the appropriate dt-bindings header and register the reset controller in
clk-mt7986-eth.c.Finally, you won't need any "ti,syscon-reset" node, and resets will look like
Quoted 8 lines
Quoted 3 lines
resets = <ðsys MT7986_ETHSYS_SOMETHING_SWRST>;If you need any hint about how to do that, please check
clk-mt8195-infra_ao.c.reviewing the code I think we do not have any mt7986-eth reset line consumer at the moment, since:
-mtk_eth_socdriver rely on syscon for resetting the chip writing directly in the register inethsys_reset()
Ouch :-)
Quoted 6 lines
- we do not rely on reset api in wed wo code.
I think we can just drop reset support in ethsys/wo-dlm nodes at the moment (since it is not used in this series) and convert the driver to reset api as soon as we have proper support in
clk-mt7986-eth.c(AFAIU sam will work on it).
If you don't need to add resets to devicetree... then I guess dropping it is ok, let's go with that.
Regards,
Angelo
Lorenzo Bianconi
maintainerPATCH v3 2/8 dt-bindings: net: mediatek: add WED RX binding for MT7986 eth driver
In reply to Lorenzo BianconiDocument the binding for the RX Wireless Ethernet Dispatch core on the MT7986 ethernet driver used to offload traffic received by WLAN NIC and forwarded to LAN/WAN one.
--- .../arm/mediatek/mediatek,mt7622-wed.yaml | 62 ++++++++++++++++++- .../arm/mediatek/mediatek,mt7986-wo-boot.yaml | 47 ++++++++++++++ .../arm/mediatek/mediatek,mt7986-wo-ccif.yaml | 50 +++++++++++++++ .../arm/mediatek/mediatek,mt7986-wo-dlm.yaml | 50 +++++++++++++++ 4 files changed, 206 insertions(+), 3 deletions(-) create mode 100644 Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-boot.yaml create mode 100644 Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-ccif.yaml create mode 100644 Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-dlm.yaml
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7622-wed.yaml +59 -3
@@ -1,8 +1,8 @@ # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) %YAML 1.2 --- -$id: "http://devicetree.org/schemas/arm/mediatek/mediatek,mt7622-wed.yaml#" -$schema: "http://devicetree.org/meta-schemas/core.yaml#" +$id: http://devicetree.org/schemas/arm/mediatek/mediatek,mt7622-wed.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# title: MediaTek Wireless Ethernet Dispatch Controller for MT7622
@@ -29,6 +29,50 @@ properties: interrupts: maxItems: 1 + memory-region: + items: + - description: + Phandle for the node used to run firmware EMI region + - description: + Phandle for the node used to run firmware ILM region + - description: + Phandle for the node used to run firmware CPU DATA region + + memory-region-names: + items: + - const: wo-emi + - const: wo-ilm + - const: wo-data + + mediatek,wo-ccif: + $ref: /schemas/types.yaml#/definitions/phandle + description: + Phandle to the mediatek wed-wo controller. + + mediatek,wo-boot: + $ref: /schemas/types.yaml#/definitions/phandle + description: + Phandle to the mediatek wed-wo boot interface. + + mediatek,wo-dlm: + $ref: /schemas/types.yaml#/definitions/phandle + description: + Phandle to the mediatek wed-wo rx hw ring. + +allOf: + - if: + properties: + compatible: + contains: + const: mediatek,mt7622-wed + then: + properties: + memory-region-names: false + memory-region: false + mediatek,wo-boot: false + mediatek,wo-ccif: false + mediatek,wo-dlm: false + required: - compatible - reg
@@ -44,8 +88,20 @@ examples: #address-cells = <2>; #size-cells = <2>; wed0: wed@1020a000 { - compatible = "mediatek,mt7622-wed","syscon"; + compatible = "mediatek,mt7622-wed", "syscon"; reg = <0 0x1020a000 0 0x1000>; interrupts = <GIC_SPI 214 IRQ_TYPE_LEVEL_LOW>; }; + + wed1: wed@15010000 { + compatible = "mediatek,mt7986-wed", "syscon"; + reg = <0 0x15010000 0 0x1000>; + interrupts = <GIC_SPI 205 IRQ_TYPE_LEVEL_HIGH>; + + memory-region = <&wo_emi>, <&wo_data>, <&wo_ilm>; + memory-region-names = "wo-emi", "wo-ilm", "wo-data"; + mediatek,wo-ccif = <&wo_ccif0>; + mediatek,wo-boot = <&wo_boot>; + mediatek,wo-dlm = <&wo_dlm0>; + }; };
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-boot.yaml new file +47 -0
47 lines not on this page · raw message
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-ccif.yaml new file +50 -0
50 lines not on this page · raw message
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-dlm.yaml new file +50 -0
50 lines not on this page · raw message
Signature · 1 line
2.38.1
Re: [PATCH v3 net-next 2/8] dt-bindings: net: mediatek: add WED RX binding for MT7986 eth driver
Quoted 20 lines · Lorenzo Bianconi
Document the binding for the RX Wireless Ethernet Dispatch core on the MT7986 ethernet driver used to offload traffic received by WLAN NIC and forwarded to LAN/WAN one.
Signed-off-by Lorenzo Bianconi <[email protected]>--- .../arm/mediatek/mediatek,mt7622-wed.yaml | 62 ++++++++++++++++++- .../arm/mediatek/mediatek,mt7986-wo-boot.yaml | 47 ++++++++++++++ .../arm/mediatek/mediatek,mt7986-wo-ccif.yaml | 50 +++++++++++++++ .../arm/mediatek/mediatek,mt7986-wo-dlm.yaml | 50 +++++++++++++++ 4 files changed, 206 insertions(+), 3 deletions(-) create mode 100644 Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-boot.yaml create mode 100644 Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-ccif.yaml create mode 100644 Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-dlm.yamlDocumentation/devicetree/bindings/arm/mediatek/mediatek,mt7622-wed.yaml +0
-0
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7622-wed.yaml line 5
Quoted 7 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7622-wed.yaml +2
-2@@ -1,8 +1,8 @@ # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) %YAML 1.2 --- -$id: "http://devicetree.org/schemas/arm/mediatek/mediatek,mt7622-wed.yaml#" -$schema: "http://devicetree.org/meta-schemas/core.yaml#" +$id: http://devicetree.org/schemas/arm/mediatek/mediatek,mt7622-wed.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml#
Split the cleanups from essential/functional changes.
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7622-wed.yaml properties: · line 35
Quoted 11 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7622-wed.yaml +4
-0title: MediaTek Wireless Ethernet Dispatch Controller for MT7622@@ -29,6 +29,50 @@ properties: interrupts: maxItems: 1 + memory-region: + items: + - description: + Phandle for the node used to run firmware EMI region
Merge above two lines. Drop "phandle for the node used to run"
Quoted 5 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7622-wed.yaml +5
-0+ - description: + Phandle for the node used to run firmware ILM region + - description: + Phandle for the node used to run firmware CPU DATA region +
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7622-wed.yaml properties: · line 50
Quoted 10 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7622-wed.yaml +10
-0+ memory-region-names: + items: + - const: wo-emi + - const: wo-ilm + - const: wo-data + + mediatek,wo-ccif: + $ref: /schemas/types.yaml#/definitions/phandle + description: + Phandle to the mediatek wed-wo controller.
Drop "Phandle to". Same in other cases.
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7622-wed.yaml properties: · line 60
Quoted 10 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7622-wed.yaml +10
-0+ + mediatek,wo-boot: + $ref: /schemas/types.yaml#/definitions/phandle + description: + Phandle to the mediatek wed-wo boot interface. + + mediatek,wo-dlm: + $ref: /schemas/types.yaml#/definitions/phandle + description: + Phandle to the mediatek wed-wo rx hw ring.
rx->RX?hw->HW?
Quoted 19 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7622-wed.yaml +15
-0+ +allOf: + - if: + properties: + compatible: + contains: + const: mediatek,mt7622-wed + then: + properties: + memory-region-names: false + memory-region: false + mediatek,wo-boot: false + mediatek,wo-ccif: false + mediatek,wo-dlm: false + required: - compatible - reg
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7622-wed.yaml examples: · line 96
Quoted 10 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7622-wed.yaml +3
-1@@ -44,8 +88,20 @@ examples: #address-cells = <2>; #size-cells = <2>; wed0: wed@1020a000 { - compatible = "mediatek,mt7622-wed","syscon"; + compatible = "mediatek,mt7622-wed", "syscon"; reg = <0 0x1020a000 0 0x1000>; interrupts = <GIC_SPI 214 IRQ_TYPE_LEVEL_LOW>; }; + + wed1: wed@15010000 {
That's a separate example. - |
Drop wed1 label.
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7622-wed.yaml examples: · line 97
Quoted 1 line
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7622-wed.yaml +1
-0+ compatible = "mediatek,mt7986-wed", "syscon";
And where is the compatible added?
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-boot.yaml
Quoted 15 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7622-wed.yaml +9
-0+ reg = <0 0x15010000 0 0x1000>; + interrupts = <GIC_SPI 205 IRQ_TYPE_LEVEL_HIGH>; + + memory-region = <&wo_emi>, <&wo_data>, <&wo_ilm>; + memory-region-names = "wo-emi", "wo-ilm", "wo-data"; + mediatek,wo-ccif = <&wo_ccif0>; + mediatek,wo-boot = <&wo_boot>; + mediatek,wo-dlm = <&wo_dlm0>; + }; };Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-boot.yaml new file +0
-0
arm is only for top-level stuff. Choose appropriate subsystem, soc as last resort.
Quoted 7 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-boot.yaml new file +6
-0@@ -0,0 +1,47 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/arm/mediatek/mediatek,mt7986-wo-boot.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# +
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-boot.yaml line 16
Quoted 10 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-boot.yaml new file +10
-0+title: + MediaTek Wireless Ethernet Dispatch WO boot controller interface for MT7986 + +maintainers: + - Lorenzo Bianconi <[email protected]> + - Felix Fietkau <[email protected]> + +description: + The mediatek wo-boot provides a configuration interface for WED WO + boot controller on MT7986 soc.
And what is "WED WO boot controller?
Quoted 42 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-boot.yaml new file +31
-0+ +properties: + compatible: + items: + - enum: + - mediatek,mt7986-wo-boot + - const: syscon + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + soc { + #address-cells = <2>; + #size-cells = <2>; + + wo_boot: syscon@15194000 { + compatible = "mediatek,mt7986-wo-boot", "syscon"; + reg = <0 0x15194000 0 0x1000>; + }; + };Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-ccif.yaml new file +5
-0@@ -0,0 +1,50 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/arm/mediatek/mediatek,mt7986-wo-ccif.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml#
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-ccif.yaml line 15
Quoted 10 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-ccif.yaml new file +10
-0+ +title: MediaTek Wireless Ethernet Dispatch WO controller interface for MT7986 + +maintainers: + - Lorenzo Bianconi <[email protected]> + - Felix Fietkau <[email protected]> + +description: + The mediatek wo-ccif provides a configuration interface for WED WO + controller on MT7986 soc.
All previous comments apply.
Quoted 75 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-ccif.yaml new file +35
-0+ +properties: + compatible: + items: + - enum: + - mediatek,mt7986-wo-ccif + - const: syscon + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + +required: + - compatible + - reg + - interrupts + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/interrupt-controller/irq.h> + soc { + #address-cells = <2>; + #size-cells = <2>; + + wo_ccif0: syscon@151a5000 { + compatible = "mediatek,mt7986-wo-ccif", "syscon"; + reg = <0 0x151a5000 0 0x1000>; + interrupts = <GIC_SPI 205 IRQ_TYPE_LEVEL_HIGH>; + }; + };Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-dlm.yaml new file +34
-0@@ -0,0 +1,50 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/arm/mediatek/mediatek,mt7986-wo-dlm.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: MediaTek Wireless Ethernet Dispatch WO hw rx ring interface for MT7986 + +maintainers: + - Lorenzo Bianconi <[email protected]> + - Felix Fietkau <[email protected]> + +description: + The mediatek wo-dlm provides a configuration interface for WED WO + rx ring on MT7986 soc. + +properties: + compatible: + const: mediatek,mt7986-wo-dlm + + reg: + maxItems: 1 + + resets: + maxItems: 1 + + reset-names: + maxItems: 1 + +required: + - compatible + - reg + - resets + - reset-names
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-dlm.yaml line 44
Quoted 10 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-dlm.yaml new file +10
-0+ +additionalProperties: false + +examples: + - | + soc { + #address-cells = <2>; + #size-cells = <2>; + + wo_dlm0: wo-dlm@151e8000 {
Node names should be generic.
https://devicetree-specification.readthedocs.io/en/latest/chapter2-devicetree-basics.html#generic-names-recommendation
Best regards,
Krzysztof
Re: [PATCH v3 net-next 2/8] dt-bindings: net: mediatek: add WED RX binding for MT7986 eth driver
Quoted 16 lines · Lorenzo Bianconi
Quoted 15 lines
Document the binding for the RX Wireless Ethernet Dispatch core on the MT7986 ethernet driver used to offload traffic received by WLAN NIC and forwarded to LAN/WAN one.
Signed-off-by Lorenzo Bianconi <[email protected]>--- .../arm/mediatek/mediatek,mt7622-wed.yaml | 62 ++++++++++++++++++- .../arm/mediatek/mediatek,mt7986-wo-boot.yaml | 47 ++++++++++++++ .../arm/mediatek/mediatek,mt7986-wo-ccif.yaml | 50 +++++++++++++++ .../arm/mediatek/mediatek,mt7986-wo-dlm.yaml | 50 +++++++++++++++ 4 files changed, 206 insertions(+), 3 deletions(-) create mode 100644 Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-boot.yaml create mode 100644 Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-ccif.yaml create mode 100644 Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-dlm.yaml
Quoted 14 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7622-wed.yaml line 5
Quoted 12 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7622-wed.yaml +2
-2@@ -1,8 +1,8 @@ # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) %YAML 1.2 --- -$id: "http://devicetree.org/schemas/arm/mediatek/mediatek,mt7622-wed.yaml#" -$schema: "http://devicetree.org/meta-schemas/core.yaml#" +$id: http://devicetree.org/schemas/arm/mediatek/mediatek,mt7622-wed.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml#Split the cleanups from essential/functional changes.
ack, I will fix it in v4
Quoted 8 lines
Quoted 8 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7622-wed.yaml +0
-0title: MediaTek Wireless Ethernet Dispatch Controller for MT7622@@ -29,6 +29,50 @@ properties: interrupts: maxItems: 1
Quoted 6 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7622-wed.yaml properties: · line 35
Quoted 4 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7622-wed.yaml +4
-0+ memory-region: + items: + - description: + Phandle for the node used to run firmware EMI regionMerge above two lines. Drop "phandle for the node used to run"
ack, I will fix it in v4
Quoted 10 lines
Quoted 10 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7622-wed.yaml +9
-0+ - description: + Phandle for the node used to run firmware ILM region + - description: + Phandle for the node used to run firmware CPU DATA region + + memory-region-names: + items: + - const: wo-emi + - const: wo-ilm
Quoted 8 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7622-wed.yaml properties: · line 50
Quoted 6 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7622-wed.yaml +6
-0+ - const: wo-data + + mediatek,wo-ccif: + $ref: /schemas/types.yaml#/definitions/phandle + description: + Phandle to the mediatek wed-wo controller.Drop "Phandle to". Same in other cases.
ack, I will fix it in v4
Quoted 14 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7622-wed.yaml properties: · line 60
Quoted 11 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7622-wed.yaml +10
-0+ + mediatek,wo-boot: + $ref: /schemas/types.yaml#/definitions/phandle + description: + Phandle to the mediatek wed-wo boot interface. + + mediatek,wo-dlm: + $ref: /schemas/types.yaml#/definitions/phandle + description: + Phandle to the mediatek wed-wo rx hw ring.
rx->RX?hw->HW?
ack, I will fix it in v4
Quoted 25 lines
Quoted 25 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7622-wed.yaml +16
-1+ +allOf: + - if: + properties: + compatible: + contains: + const: mediatek,mt7622-wed + then: + properties: + memory-region-names: false + memory-region: false + mediatek,wo-boot: false + mediatek,wo-ccif: false + mediatek,wo-dlm: false + required: - compatible - reg@@ -44,8 +88,20 @@ examples: #address-cells = <2>; #size-cells = <2>; wed0: wed@1020a000 { - compatible = "mediatek,mt7622-wed","syscon"; + compatible = "mediatek,mt7622-wed", "syscon";
Quoted 8 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7622-wed.yaml examples: · line 96
Quoted 5 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7622-wed.yaml +2
-0reg = <0 0x1020a000 0 0x1000>; interrupts = <GIC_SPI 214 IRQ_TYPE_LEVEL_LOW>; }; + + wed1: wed@15010000 {That's a separate example. - |
Drop wed1 label.
ack, I will fix it in v4
Quoted 15 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7622-wed.yaml examples: · line 97
Quoted 2 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7622-wed.yaml +1
-0+ compatible = "mediatek,mt7986-wed", "syscon";And where is the compatible added?
Quoted 10 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7622-wed.yaml +9
-0+ reg = <0 0x15010000 0 0x1000>; + interrupts = <GIC_SPI 205 IRQ_TYPE_LEVEL_HIGH>; + + memory-region = <&wo_emi>, <&wo_data>, <&wo_ilm>; + memory-region-names = "wo-emi", "wo-ilm", "wo-data"; + mediatek,wo-ccif = <&wo_ccif0>; + mediatek,wo-boot = <&wo_boot>; + mediatek,wo-dlm = <&wo_dlm0>; + }; };
Quoted 8 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-boot.yaml
Quoted 5 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-boot.yaml new file +0
-0arm is only for top-level stuff. Choose appropriate subsystem, soc as last resort.
these chips are used only for networking so is net folder fine?
Quoted 12 lines
Quoted 12 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-boot.yaml new file +10
-0@@ -0,0 +1,47 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/arm/mediatek/mediatek,mt7986-wo-boot.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: + MediaTek Wireless Ethernet Dispatch WO boot controller interface for MT7986 + +maintainers:
Quoted 8 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-boot.yaml line 16
Quoted 6 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-boot.yaml new file +6
-0+ - Lorenzo Bianconi <[email protected]> + - Felix Fietkau <[email protected]> + +description: + The mediatek wo-boot provides a configuration interface for WED WO + boot controller on MT7986 soc.And what is "WED WO boot controller?
WED WO is a chip used for networking packet processing offloaded to the Soc (e.g. packet reordering). WED WO boot is the memory used to store start address of wo firmware. Anyway I will let Sujuan comment on this.
Quoted 136 lines
Quoted 43 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-boot.yaml new file +31
-0+ +properties: + compatible: + items: + - enum: + - mediatek,mt7986-wo-boot + - const: syscon + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + soc { + #address-cells = <2>; + #size-cells = <2>; + + wo_boot: syscon@15194000 { + compatible = "mediatek,mt7986-wo-boot", "syscon"; + reg = <0 0x15194000 0 0x1000>; + }; + };Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-ccif.yaml new file +5
-0@@ -0,0 +1,50 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/arm/mediatek/mediatek,mt7986-wo-ccif.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml#Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-ccif.yaml line 15
Quoted 10 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-ccif.yaml new file +10
-0+ +title: MediaTek Wireless Ethernet Dispatch WO controller interface for MT7986 + +maintainers: + - Lorenzo Bianconi <[email protected]> + - Felix Fietkau <[email protected]> + +description: + The mediatek wo-ccif provides a configuration interface for WED WO + controller on MT7986 soc.All previous comments apply.
Quoted 80 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-ccif.yaml new file +35
-0+ +properties: + compatible: + items: + - enum: + - mediatek,mt7986-wo-ccif + - const: syscon + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + +required: + - compatible + - reg + - interrupts + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/interrupt-controller/irq.h> + soc { + #address-cells = <2>; + #size-cells = <2>; + + wo_ccif0: syscon@151a5000 { + compatible = "mediatek,mt7986-wo-ccif", "syscon"; + reg = <0 0x151a5000 0 0x1000>; + interrupts = <GIC_SPI 205 IRQ_TYPE_LEVEL_HIGH>; + }; + };Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-dlm.yaml new file +39
-0@@ -0,0 +1,50 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/arm/mediatek/mediatek,mt7986-wo-dlm.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: MediaTek Wireless Ethernet Dispatch WO hw rx ring interface for MT7986 + +maintainers: + - Lorenzo Bianconi <[email protected]> + - Felix Fietkau <[email protected]> + +description: + The mediatek wo-dlm provides a configuration interface for WED WO + rx ring on MT7986 soc. + +properties: + compatible: + const: mediatek,mt7986-wo-dlm + + reg: + maxItems: 1 + + resets: + maxItems: 1 + + reset-names: + maxItems: 1 + +required: + - compatible + - reg + - resets + - reset-names + +additionalProperties: false + +examples: + - |
Quoted 8 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-dlm.yaml line 44
Quoted 5 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-dlm.yaml new file +5
-0+ soc { + #address-cells = <2>; + #size-cells = <2>; + + wo_dlm0: wo-dlm@151e8000 {Node names should be generic.
https://devicetree-specification.readthedocs.io/en/latest/chapter2-devicetree-basics.html#generic-names-recommendation
DLM is a chip used to store the data rx ring of wo firmware. I do not have a better node name (naming is always hard). Can you please suggest a better name?
Regards,
Lorenzo
Quoted 5 lines
Best regards,
Krzysztof
Re: [PATCH v3 net-next 2/8] dt-bindings: net: mediatek: add WED RX binding for MT7986 eth driver
Quoted 10 lines · Lorenzo Bianconi
Quoted 8 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-boot.yaml
Quoted 5 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-boot.yaml new file +0
-0arm is only for top-level stuff. Choose appropriate subsystem, soc as last resort.
these chips are used only for networking so is net folder fine?
So this is some MMIO and no actual device? Then rather soc.
Quoted 22 lines
Quoted 13 lines
Quoted 13 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-boot.yaml new file +10
-0@@ -0,0 +1,47 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/arm/mediatek/mediatek,mt7986-wo-boot.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: + MediaTek Wireless Ethernet Dispatch WO boot controller interface for MT7986 + +maintainers:Quoted 8 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-boot.yaml line 16
Quoted 6 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-boot.yaml new file +6
-0+ - Lorenzo Bianconi <[email protected]> + - Felix Fietkau <[email protected]> + +description: + The mediatek wo-boot provides a configuration interface for WED WO + boot controller on MT7986 soc.And what is "WED WO boot controller?
Quoted 3 lines
WED WO is a chip used for networking packet processing offloaded to the Soc (e.g. packet reordering). WED WO boot is the memory used to store start address of wo firmware. Anyway I will let Sujuan comment on this.
A bit more should be in description.
Quoted 146 lines
Quoted 137 lines
Quoted 44 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-boot.yaml new file +31
-0+ +properties: + compatible: + items: + - enum: + - mediatek,mt7986-wo-boot + - const: syscon + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + soc { + #address-cells = <2>; + #size-cells = <2>; + + wo_boot: syscon@15194000 { + compatible = "mediatek,mt7986-wo-boot", "syscon"; + reg = <0 0x15194000 0 0x1000>; + }; + };Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-ccif.yaml new file +5
-0@@ -0,0 +1,50 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/arm/mediatek/mediatek,mt7986-wo-ccif.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml#Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-ccif.yaml line 15
Quoted 10 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-ccif.yaml new file +10
-0+ +title: MediaTek Wireless Ethernet Dispatch WO controller interface for MT7986 + +maintainers: + - Lorenzo Bianconi <[email protected]> + - Felix Fietkau <[email protected]> + +description: + The mediatek wo-ccif provides a configuration interface for WED WO + controller on MT7986 soc.All previous comments apply.
Quoted 80 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-ccif.yaml new file +35
-0+ +properties: + compatible: + items: + - enum: + - mediatek,mt7986-wo-ccif + - const: syscon + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + +required: + - compatible + - reg + - interrupts + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/interrupt-controller/irq.h> + soc { + #address-cells = <2>; + #size-cells = <2>; + + wo_ccif0: syscon@151a5000 { + compatible = "mediatek,mt7986-wo-ccif", "syscon"; + reg = <0 0x151a5000 0 0x1000>; + interrupts = <GIC_SPI 205 IRQ_TYPE_LEVEL_HIGH>; + }; + };Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-dlm.yaml new file +39
-0@@ -0,0 +1,50 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/arm/mediatek/mediatek,mt7986-wo-dlm.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: MediaTek Wireless Ethernet Dispatch WO hw rx ring interface for MT7986 + +maintainers: + - Lorenzo Bianconi <[email protected]> + - Felix Fietkau <[email protected]> + +description: + The mediatek wo-dlm provides a configuration interface for WED WO + rx ring on MT7986 soc. + +properties: + compatible: + const: mediatek,mt7986-wo-dlm + + reg: + maxItems: 1 + + resets: + maxItems: 1 + + reset-names: + maxItems: 1 + +required: + - compatible + - reg + - resets + - reset-names + +additionalProperties: false + +examples: + - |Quoted 8 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-dlm.yaml line 44
Quoted 5 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-dlm.yaml new file +5
-0+ soc { + #address-cells = <2>; + #size-cells = <2>; + + wo_dlm0: wo-dlm@151e8000 {Node names should be generic.
https://devicetree-specification.readthedocs.io/en/latest/chapter2-devicetree-basics.html#generic-names-recommendation
Quoted 2 lines
DLM is a chip used to store the data rx ring of wo firmware. I do not have a better node name (naming is always hard). Can you please suggest a better name?
The problem is that you added three new devices which seem to be for the same device - WED. It looks like some hacky way of avoid proper hardware description - let's model everything as MMIO and syscons...
For such model - register addresses exposed as separate devices - I do not have appropriate name, but the real problem is not in the name. It's in the hardware description.
Best regards,
Krzysztof
Lorenzo Bianconi
maintainerRe: [PATCH v3 net-next 2/8] dt-bindings: net: mediatek: add WED RX binding for MT7986 eth driver
Quoted 6 lines · Lorenzo Bianconi
Quoted 5 lines
Quoted 5 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-boot.yaml
Quoted 5 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-boot.yaml new file +0
-0
Regarding "mediatek,mt7986-wed" compatible string it has been added to mt7986a.dtsi in the commit below:
commit 00b9903996b3e1e287c748928606d738944e45de
Author: Lorenzo Bianconi <[email protected]> Date: Tue Sep 20 12:11:13 2022 +0200
arm64: dts: mediatek: mt7986: add support for Wireless Ethernet Dispatch
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
arm is only for top-level stuff. Choose appropriate subsystem, soc as last resort.
these chips are used only for networking so is net folder fine?
So this is some MMIO and no actual device? Then rather soc.
ack, I will move them there
Quoted 23 lines
Quoted 23 lines
Quoted 22 lines
Quoted 10 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-boot.yaml new file +6
-0@@ -0,0 +1,47 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/arm/mediatek/mediatek,mt7986-wo-boot.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# +Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-boot.yaml line 16
Quoted 10 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-boot.yaml new file +10
-0+title: + MediaTek Wireless Ethernet Dispatch WO boot controller interface for MT7986 + +maintainers: + - Lorenzo Bianconi <[email protected]> + - Felix Fietkau <[email protected]> + +description: + The mediatek wo-boot provides a configuration interface for WED WO + boot controller on MT7986 soc.And what is "WED WO boot controller?
Quoted 5 lines
Quoted 3 lines
WED WO is a chip used for networking packet processing offloaded to the Soc (e.g. packet reordering). WED WO boot is the memory used to store start address of wo firmware. Anyway I will let Sujuan comment on this.
A bit more should be in description.
I will let Sujuan adding more details (since I do not have them :))
Quoted 147 lines
Quoted 147 lines
Quoted 146 lines
Quoted 45 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-boot.yaml new file +31
-0+ +properties: + compatible: + items: + - enum: + - mediatek,mt7986-wo-boot + - const: syscon + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + soc { + #address-cells = <2>; + #size-cells = <2>; + + wo_boot: syscon@15194000 { + compatible = "mediatek,mt7986-wo-boot", "syscon"; + reg = <0 0x15194000 0 0x1000>; + }; + };Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-ccif.yaml new file +5
-0@@ -0,0 +1,50 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/arm/mediatek/mediatek,mt7986-wo-ccif.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml#Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-ccif.yaml line 15
Quoted 10 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-ccif.yaml new file +10
-0+ +title: MediaTek Wireless Ethernet Dispatch WO controller interface for MT7986 + +maintainers: + - Lorenzo Bianconi <[email protected]> + - Felix Fietkau <[email protected]> + +description: + The mediatek wo-ccif provides a configuration interface for WED WO + controller on MT7986 soc.All previous comments apply.
Quoted 75 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-ccif.yaml new file +35
-0+ +properties: + compatible: + items: + - enum: + - mediatek,mt7986-wo-ccif + - const: syscon + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + +required: + - compatible + - reg + - interrupts + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/interrupt-controller/irq.h> + soc { + #address-cells = <2>; + #size-cells = <2>; + + wo_ccif0: syscon@151a5000 { + compatible = "mediatek,mt7986-wo-ccif", "syscon"; + reg = <0 0x151a5000 0 0x1000>; + interrupts = <GIC_SPI 205 IRQ_TYPE_LEVEL_HIGH>; + }; + };Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-dlm.yaml new file +34
-0@@ -0,0 +1,50 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/arm/mediatek/mediatek,mt7986-wo-dlm.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: MediaTek Wireless Ethernet Dispatch WO hw rx ring interface for MT7986 + +maintainers: + - Lorenzo Bianconi <[email protected]> + - Felix Fietkau <[email protected]> + +description: + The mediatek wo-dlm provides a configuration interface for WED WO + rx ring on MT7986 soc. + +properties: + compatible: + const: mediatek,mt7986-wo-dlm + + reg: + maxItems: 1 + + resets: + maxItems: 1 + + reset-names: + maxItems: 1 + +required: + - compatible + - reg + - resets + - reset-namesDocumentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-dlm.yaml line 44
Quoted 10 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-dlm.yaml new file +10
-0+ +additionalProperties: false + +examples: + - | + soc { + #address-cells = <2>; + #size-cells = <2>; + + wo_dlm0: wo-dlm@151e8000 {Node names should be generic.
https://devicetree-specification.readthedocs.io/en/latest/chapter2-devicetree-basics.html#generic-names-recommendation
Quoted 6 lines
Quoted 2 lines
DLM is a chip used to store the data rx ring of wo firmware. I do not have a better node name (naming is always hard). Can you please suggest a better name?
The problem is that you added three new devices which seem to be for the same device - WED. It looks like some hacky way of avoid proper hardware description - let's model everything as MMIO and syscons...
is it fine to use syscon as node name even if we do not declare it in compatible string for dlm?
Regards,
Lorenzo
Quoted 9 lines
For such model - register addresses exposed as separate devices - I do not have appropriate name, but the real problem is not in the name. It's in the hardware description.
Best regards,
Krzysztof
Re: [PATCH v3 net-next 2/8] dt-bindings: net: mediatek: add WED RX binding for MT7986 eth driver
Quoted 207 lines · Lorenzo Bianconi
Quoted 6 lines · Lorenzo Bianconi
Quoted 5 lines
Quoted 5 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-boot.yaml
Quoted 5 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-boot.yaml new file +0
-0Regarding "mediatek,mt7986-wed" compatible string it has been added to
mt7986a.dtsiin the commit below:commit
00b9903996b3e1e287c748928606d738944e45deAuthor: Lorenzo Bianconi <[email protected]> Date: Tue Sep 20 12:11:13 2022 +0200arm64: dts: mediatek: mt7986: add support for Wireless Ethernet Dispatch
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
arm is only for top-level stuff. Choose appropriate subsystem, soc as last resort.
these chips are used only for networking so is net folder fine?
So this is some MMIO and no actual device? Then rather soc.
ack, I will move them there
Quoted 23 lines
Quoted 23 lines
Quoted 22 lines
Quoted 10 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-boot.yaml new file +6
-0@@ -0,0 +1,47 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/arm/mediatek/mediatek,mt7986-wo-boot.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# +Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-boot.yaml line 16
Quoted 10 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-boot.yaml new file +10
-0+title: + MediaTek Wireless Ethernet Dispatch WO boot controller interface for MT7986 + +maintainers: + - Lorenzo Bianconi <[email protected]> + - Felix Fietkau <[email protected]> + +description: + The mediatek wo-boot provides a configuration interface for WED WO + boot controller on MT7986 soc.And what is "WED WO boot controller?
Quoted 5 lines
Quoted 3 lines
WED WO is a chip used for networking packet processing offloaded to the Soc (e.g. packet reordering). WED WO boot is the memory used to store start address of wo firmware. Anyway I will let Sujuan comment on this.
A bit more should be in description.
I will let Sujuan adding more details (since I do not have them :))
Quoted 150 lines
Quoted 149 lines
Quoted 138 lines
Quoted 45 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-boot.yaml new file +31
-0+ +properties: + compatible: + items: + - enum: + - mediatek,mt7986-wo-boot + - const: syscon + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + soc { + #address-cells = <2>; + #size-cells = <2>; + + wo_boot: syscon@15194000 { + compatible = "mediatek,mt7986-wo-boot", "syscon"; + reg = <0 0x15194000 0 0x1000>; + }; + };Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-ccif.yaml new file +5
-0@@ -0,0 +1,50 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/arm/mediatek/mediatek,mt7986-wo-ccif.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml#Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-ccif.yaml line 15
Quoted 10 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-ccif.yaml new file +10
-0+ +title: MediaTek Wireless Ethernet Dispatch WO controller interface for MT7986 + +maintainers: + - Lorenzo Bianconi <[email protected]> + - Felix Fietkau <[email protected]> + +description: + The mediatek wo-ccif provides a configuration interface for WED WO + controller on MT7986 soc.All previous comments apply.
Quoted 80 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-ccif.yaml new file +35
-0+ +properties: + compatible: + items: + - enum: + - mediatek,mt7986-wo-ccif + - const: syscon + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + +required: + - compatible + - reg + - interrupts + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/interrupt-controller/irq.h> + soc { + #address-cells = <2>; + #size-cells = <2>; + + wo_ccif0: syscon@151a5000 { + compatible = "mediatek,mt7986-wo-ccif", "syscon"; + reg = <0 0x151a5000 0 0x1000>; + interrupts = <GIC_SPI 205 IRQ_TYPE_LEVEL_HIGH>; + }; + };Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-dlm.yaml new file +39
-0@@ -0,0 +1,50 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/arm/mediatek/mediatek,mt7986-wo-dlm.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: MediaTek Wireless Ethernet Dispatch WO hw rx ring interface for MT7986 + +maintainers: + - Lorenzo Bianconi <[email protected]> + - Felix Fietkau <[email protected]> + +description: + The mediatek wo-dlm provides a configuration interface for WED WO + rx ring on MT7986 soc. + +properties: + compatible: + const: mediatek,mt7986-wo-dlm + + reg: + maxItems: 1 + + resets: + maxItems: 1 + + reset-names: + maxItems: 1 + +required: + - compatible + - reg + - resets + - reset-names + +additionalProperties: false + +examples: + - |Quoted 8 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-dlm.yaml line 44
Quoted 5 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-dlm.yaml new file +5
-0+ soc { + #address-cells = <2>; + #size-cells = <2>; + + wo_dlm0: wo-dlm@151e8000 {Node names should be generic.
https://devicetree-specification.readthedocs.io/en/latest/chapter2-devicetree-basics.html#generic-names-recommendationDLM is a chip used to store the data rx ring of wo firmware. I do not have a better node name (naming is always hard). Can you please suggest a better name?
Quoted 7 lines
Quoted 3 lines
The problem is that you added three new devices which seem to be for the same device - WED. It looks like some hacky way of avoid proper hardware description - let's model everything as MMIO and syscons...
is it fine to use syscon as node name even if we do not declare it in compatible string for dlm?
No, rather not. It's a shortcut and if used without actual syscon it would be confusing. You could still call it system-controller, though.
Best regards,
Krzysztof
Lorenzo Bianconi
maintainerRe: [PATCH v3 net-next 2/8] dt-bindings: net: mediatek: add WED RX binding for MT7986 eth driver
Quoted 212 lines · Lorenzo Bianconi
Quoted 211 lines
Quoted 6 lines · Lorenzo Bianconi
Quoted 5 lines
Quoted 5 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-boot.yaml
Quoted 5 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-boot.yaml new file +0
-0Regarding "mediatek,mt7986-wed" compatible string it has been added to
mt7986a.dtsiin the commit below:commit
00b9903996b3e1e287c748928606d738944e45deAuthor: Lorenzo Bianconi <[email protected]> Date: Tue Sep 20 12:11:13 2022 +0200arm64: dts: mediatek: mt7986: add support for Wireless Ethernet Dispatch
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
arm is only for top-level stuff. Choose appropriate subsystem, soc as last resort.
these chips are used only for networking so is net folder fine?
So this is some MMIO and no actual device? Then rather soc.
ack, I will move them there
Quoted 23 lines
Quoted 23 lines
Quoted 22 lines
Quoted 10 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-boot.yaml new file +6
-0@@ -0,0 +1,47 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/arm/mediatek/mediatek,mt7986-wo-boot.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# +Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-boot.yaml line 16
Quoted 10 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-boot.yaml new file +10
-0+title: + MediaTek Wireless Ethernet Dispatch WO boot controller interface for MT7986 + +maintainers: + - Lorenzo Bianconi <[email protected]> + - Felix Fietkau <[email protected]> + +description: + The mediatek wo-boot provides a configuration interface for WED WO + boot controller on MT7986 soc.And what is "WED WO boot controller?
Quoted 5 lines
Quoted 3 lines
WED WO is a chip used for networking packet processing offloaded to the Soc (e.g. packet reordering). WED WO boot is the memory used to store start address of wo firmware. Anyway I will let Sujuan comment on this.
A bit more should be in description.
I will let Sujuan adding more details (since I do not have them :))
Quoted 153 lines
Quoted 147 lines
Quoted 138 lines
Quoted 45 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-boot.yaml new file +31
-0+ +properties: + compatible: + items: + - enum: + - mediatek,mt7986-wo-boot + - const: syscon + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + soc { + #address-cells = <2>; + #size-cells = <2>; + + wo_boot: syscon@15194000 { + compatible = "mediatek,mt7986-wo-boot", "syscon"; + reg = <0 0x15194000 0 0x1000>; + }; + };Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-ccif.yaml new file +5
-0@@ -0,0 +1,50 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/arm/mediatek/mediatek,mt7986-wo-ccif.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml#Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-ccif.yaml line 15
Quoted 10 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-ccif.yaml new file +10
-0+ +title: MediaTek Wireless Ethernet Dispatch WO controller interface for MT7986 + +maintainers: + - Lorenzo Bianconi <[email protected]> + - Felix Fietkau <[email protected]> + +description: + The mediatek wo-ccif provides a configuration interface for WED WO + controller on MT7986 soc.All previous comments apply.
Quoted 80 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-ccif.yaml new file +35
-0+ +properties: + compatible: + items: + - enum: + - mediatek,mt7986-wo-ccif + - const: syscon + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + +required: + - compatible + - reg + - interrupts + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/interrupt-controller/irq.h> + soc { + #address-cells = <2>; + #size-cells = <2>; + + wo_ccif0: syscon@151a5000 { + compatible = "mediatek,mt7986-wo-ccif", "syscon"; + reg = <0 0x151a5000 0 0x1000>; + interrupts = <GIC_SPI 205 IRQ_TYPE_LEVEL_HIGH>; + }; + };Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-dlm.yaml new file +39
-0@@ -0,0 +1,50 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/arm/mediatek/mediatek,mt7986-wo-dlm.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: MediaTek Wireless Ethernet Dispatch WO hw rx ring interface for MT7986 + +maintainers: + - Lorenzo Bianconi <[email protected]> + - Felix Fietkau <[email protected]> + +description: + The mediatek wo-dlm provides a configuration interface for WED WO + rx ring on MT7986 soc. + +properties: + compatible: + const: mediatek,mt7986-wo-dlm + + reg: + maxItems: 1 + + resets: + maxItems: 1 + + reset-names: + maxItems: 1 + +required: + - compatible + - reg + - resets + - reset-names + +additionalProperties: false + +examples: + - |Quoted 8 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-dlm.yaml line 44
Quoted 5 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-dlm.yaml new file +5
-0+ soc { + #address-cells = <2>; + #size-cells = <2>; + + wo_dlm0: wo-dlm@151e8000 {Node names should be generic.
https://devicetree-specification.readthedocs.io/en/latest/chapter2-devicetree-basics.html#generic-names-recommendationQuoted 2 lines
DLM is a chip used to store the data rx ring of wo firmware. I do not have a better node name (naming is always hard). Can you please suggest a better name?
The problem is that you added three new devices which seem to be for the same device - WED. It looks like some hacky way of avoid proper hardware description - let's model everything as MMIO and syscons...
Quoted 6 lines
Quoted 3 lines
is it fine to use syscon as node name even if we do not declare it in compatible string for dlm?
No, rather not. It's a shortcut and if used without actual syscon it would be confusing. You could still call it system-controller, though.
ack, I used a different approach in v4 since I figured out I can move dlm node in memory-region.
Regards,
Lorenzo
Quoted 4 lines
Best regards,
Krzysztof
Re: [PATCH v3 net-next 2/8] dt-bindings: net: mediatek: add WED RX binding for MT7986 eth driver
In reply to Krzysztof KozlowskiQuoted 71 lines · Krzysztof Kozlowski
Quoted 70 lines · Lorenzo Bianconi
Quoted 12 lines · Lorenzo Bianconi
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
diff --git a/Documentation/devicetree/bindings/arm/mediatek/mediatek,m
t7986-wo-boot.yamlb/Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-boot.yaml
new file mode 100644
index 000000000000..6c3c514c48ef
---/dev/null
+++
b/Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-boot.yamlRegarding "mediatek,mt7986-wed" compatible string it has been added to
mt7986a.dtsiin the commit below:commit
00b9903996b3e1e287c748928606d738944e45deAuthor: Lorenzo Bianconi <[email protected]> Date: Tue Sep 20 12:11:13 2022 +0200arm64: dts: mediatek: mt7986: add support for Wireless Ethernet Dispatch
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
arm is only for top-level stuff. Choose appropriate subsystem, soc as
last resort.these chips are used only for networking so is net folder fine?
So this is some MMIO and no actual device? Then rather soc.
ack, I will move them there
Quoted 35 lines
Quoted 34 lines
Quoted 13 lines
Quoted 13 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-boot.yaml new file +4
-0@@ -0,0 +1,47 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id:Quoted 15 lines
Quoted 11 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-boot.yaml new file +3
-0+ +title: + MediaTek Wireless Ethernet Dispatch WO boot controllerinterface for MT7986
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-boot.yaml new file +7
-0+ +maintainers: + - Lorenzo Bianconi <[email protected]> + - Felix Fietkau <[email protected]> + +description: + The mediatek wo-boot provides a configuration interfaceQuoted 2 lines
for WED WO
+ boot controller on MT7986 soc.And what is "WED WO boot controller?
WED WO is a chip used for networking packet processing offloaded to the Soc
(e.g. packet reordering). WED WO boot is the memory used to store start address
of wo firmware. Anyway I will let Sujuan comment on this.
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
A bit more should be in description.
I will let Sujuan adding more details (since I do not have them :))
The mcu of wo borrows a part of dram to store and boot its firmware. the right entry point address of the firmware must be passed to the mcu to boot correctly, so we need to write the dram address of the entry point to the boot register, In addition, there are some registers that need to be set to control the reset of the mcu.
Quoted 162 lines
Quoted 162 lines
Quoted 162 lines
Quoted 162 lines
Quoted 162 lines
Quoted 65 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-boot.yaml new file +31
-0+ +properties: + compatible: + items: + - enum: + - mediatek,mt7986-wo-boot + - const: syscon + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + soc { + #address-cells = <2>; + #size-cells = <2>; + + wo_boot: syscon@15194000 { + compatible = "mediatek,mt7986-wo-boot", "syscon"; + reg = <0 0x15194000 0 0x1000>; + }; + };diff --git a/Documentation/devicetree/bindings/arm/mediatek/mediatek,m
t7986-wo-ccif.yamlb/Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-ccif.yaml
new file mode 100644
index 000000000000..6357a206587a
---/dev/null
+++
b/Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-ccif.yamlDocumentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-boot.yaml new file +4
-0@@ -0,0 +1,50 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id:(quoted diff) +2
-0+ +title: MediaTek Wireless Ethernet Dispatch WO controllerinterface for MT7986
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-boot.yaml new file +7
-0+ +maintainers: + - Lorenzo Bianconi <[email protected]> + - Felix Fietkau <[email protected]> + +description: + The mediatek wo-ccif provides a configuration interfaceQuoted 2 lines
for WED WO
+ controller on MT7986 soc.All previous comments apply.
Quoted 92 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-ccif.yaml new file +35
-0+ +properties: + compatible: + items: + - enum: + - mediatek,mt7986-wo-ccif + - const: syscon + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + +required: + - compatible + - reg + - interrupts + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/interrupt-controller/irq.h> + soc { + #address-cells = <2>; + #size-cells = <2>; + + wo_ccif0: syscon@151a5000 { + compatible = "mediatek,mt7986-wo-ccif", "syscon"; + reg = <0 0x151a5000 0 0x1000>; + interrupts = <GIC_SPI 205 IRQ_TYPE_LEVEL_HIGH>; + }; + };diff --git a/Documentation/devicetree/bindings/arm/mediatek/mediatek,m
t7986-wo-dlm.yamlb/Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-dlm.yaml
new file mode 100644
index 000000000000..a499956d9e07
---/dev/null
+++
b/Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-dlm.yamlDocumentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-boot.yaml new file +4
-0@@ -0,0 +1,50 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id:(quoted diff) +2
-0+ +title: MediaTek Wireless Ethernet Dispatch WO hw rx ringinterface for MT7986
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-boot.yaml new file +7
-0+ +maintainers: + - Lorenzo Bianconi <[email protected]> + - Felix Fietkau <[email protected]> + +description: + The mediatek wo-dlm provides a configuration interfacefor WED WO
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-dlm.yaml new file +25
-0+ rx ring on MT7986 soc. + +properties: + compatible: + const: mediatek,mt7986-wo-dlm + + reg: + maxItems: 1 + + resets: + maxItems: 1 + + reset-names: + maxItems: 1 + +required: + - compatible + - reg + - resets + - reset-names + +additionalProperties: false + +examples: + - |
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-dlm.yaml line 44
Quoted 5 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mt7986-wo-dlm.yaml new file +5
-0+ soc { + #address-cells = <2>; + #size-cells = <2>; + + wo_dlm0: wo-dlm@151e8000 {Node names should be generic.
Quoted 25 lines
Quoted 13 lines
Quoted 7 lines
Quoted 6 lines
Quoted 1 line
DLM is a chip used to store the data rx ring of wo firmware. I do not have a
better node name (naming is always hard). Can you please suggest a better name?Quoted 5 lines
The problem is that you added three new devices which seem to be for the
same device - WED. It looks like some hacky way of avoid proper hardware
description - let's model everything as MMIO and syscons...Quoted 4 lines
is it fine to use syscon as node name even if we do not declare it in compatible
string for dlm?No, rather not. It's a shortcut and if used without actual syscon it would be confusing. You could still call it system-controller, though.
Best regards,
Krzysztof
Lorenzo Bianconi
maintainerPATCH v3 3/8 net: ethernet: mtk_wed: introduce wed mcu support
In reply to Lorenzo BianconiFrom: Sujuan Chen <[email protected]>
Introduce WED mcu support used to configure WED WO chip. This is a preliminary patch in order to add RX Wireless Ethernet Dispatch available on MT7986 SoC.
--- drivers/net/ethernet/mediatek/Makefile | 2 +- drivers/net/ethernet/mediatek/mtk_wed_mcu.c | 364 +++++++++++++++++++ drivers/net/ethernet/mediatek/mtk_wed_regs.h | 1 + drivers/net/ethernet/mediatek/mtk_wed_wo.h | 152 ++++++++ include/linux/soc/mediatek/mtk_wed.h | 29 ++ 5 files changed, 547 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/mediatek/mtk_wed_mcu.c create mode 100644 drivers/net/ethernet/mediatek/mtk_wed_wo.h
drivers/net/ethernet/mediatek/Makefile +1 -1
@@ -5,7 +5,7 @@ obj-$(CONFIG_NET_MEDIATEK_SOC) += mtk_eth.o mtk_eth-y := mtk_eth_soc.o mtk_sgmii.o mtk_eth_path.o mtk_ppe.o mtk_ppe_debugfs.o mtk_ppe_offload.o -mtk_eth-$(CONFIG_NET_MEDIATEK_SOC_WED) += mtk_wed.o +mtk_eth-$(CONFIG_NET_MEDIATEK_SOC_WED) += mtk_wed.o mtk_wed_mcu.o ifdef CONFIG_DEBUG_FS mtk_eth-$(CONFIG_NET_MEDIATEK_SOC_WED) += mtk_wed_debugfs.o endif
drivers/net/ethernet/mediatek/mtk_wed_mcu.c new file +364 -0
364 lines not on this page · raw message
drivers/net/ethernet/mediatek/mtk_wed_regs.h +1 -0
@@ -152,6 +152,7 @@ struct mtk_wdma_desc {#define MTK_WED_RING_RX (_n) (0x400 + (_n) * 0x10) +#define MTK_WED_SCR0 0x3c0#define MTK_WED_WPDMA_INT_TRIGGER 0x504#define MTK_WED_WPDMA_INT_TRIGGER_RX_DONE BIT(1)#define MTK_WED_WPDMA_INT_TRIGGER_TX_DONE GENMASK(5, 4)
drivers/net/ethernet/mediatek/mtk_wed_wo.h new file +152 -0
152 lines not on this page · raw message
include/linux/soc/mediatek/mtk_wed.h +29 -0
@@ -11,6 +11,35 @@struct mtk_wed_hw ;struct mtk_wdma_desc ; +enum mtk_wed_wo_cmd { +MTK_WED_WO_CMD_WED_CFG , +MTK_WED_WO_CMD_WED_RX_STAT , +MTK_WED_WO_CMD_RRO_SER , +MTK_WED_WO_CMD_DBG_INFO , +MTK_WED_WO_CMD_DEV_INFO , +MTK_WED_WO_CMD_BSS_INFO , +MTK_WED_WO_CMD_STA_REC , +MTK_WED_WO_CMD_DEV_INFO_DUMP , +MTK_WED_WO_CMD_BSS_INFO_DUMP , +MTK_WED_WO_CMD_STA_REC_DUMP , +MTK_WED_WO_CMD_BA_INFO_DUMP , +MTK_WED_WO_CMD_FBCMD_Q_DUMP , +MTK_WED_WO_CMD_FW_LOG_CTRL , +MTK_WED_WO_CMD_LOG_FLUSH , +MTK_WED_WO_CMD_CHANGE_STATE , +MTK_WED_WO_CMD_CPU_STATS_ENABLE , +MTK_WED_WO_CMD_CPU_STATS_DUMP , +MTK_WED_WO_CMD_EXCEPTION_INIT , +MTK_WED_WO_CMD_PROF_CTRL , +MTK_WED_WO_CMD_STA_BA_DUMP , +MTK_WED_WO_CMD_BA_CTRL_DUMP , +MTK_WED_WO_CMD_RXCNT_CTRL , +MTK_WED_WO_CMD_RXCNT_INFO , +MTK_WED_WO_CMD_SET_CAP , +MTK_WED_WO_CMD_CCIF_RING_DUMP , +MTK_WED_WO_CMD_WED_END +}; +enum mtk_wed_bus_tye {MTK_WED_BUS_PCIE ,MTK_WED_BUS_AXI ,
Signature · 1 line
2.38.1
AngeloGioacchino Del Regno
maintainerRe: [PATCH v3 net-next 3/8] net: ethernet: mtk_wed: introduce wed mcu support
Il 03/11/22 10:28, Lorenzo Bianconi ha scritto:
Quoted 38 lines
From: Sujuan Chen <[email protected]>
Introduce WED mcu support used to configure WED WO chip. This is a preliminary patch in order to add RX Wireless Ethernet Dispatch available on MT7986 SoC.
Tested-by Daniel Golle <[email protected]>Co-developed-by Lorenzo Bianconi <[email protected]>Signed-off-by Lorenzo Bianconi <[email protected]>Signed-off-by Sujuan Chen <[email protected]>--- drivers/net/ethernet/mediatek/Makefile | 2 +- drivers/net/ethernet/mediatek/mtk_wed_mcu.c | 364 +++++++++++++++++++ drivers/net/ethernet/mediatek/mtk_wed_regs.h | 1 + drivers/net/ethernet/mediatek/mtk_wed_wo.h | 152 ++++++++ include/linux/soc/mediatek/mtk_wed.h | 29 ++ 5 files changed, 547 insertions(+), 1 deletion(-)create mode 100644
drivers/net/ethernet/mediatek/mtk_wed_mcu.ccreate mode 100644drivers/net/ethernet/mediatek/mtk_wed_wo.hdrivers/net/ethernet/mediatek/Makefile +1
-1@@ -5,7 +5,7 @@ obj-$(CONFIG_NET_MEDIATEK_SOC) += mtk_eth.o mtk_eth-y := mtk_eth_soc.o mtk_sgmii.o mtk_eth_path.o mtk_ppe.o mtk_ppe_debugfs.o mtk_ppe_offload.o -mtk_eth-$(CONFIG_NET_MEDIATEK_SOC_WED) += mtk_wed.o +mtk_eth-$(CONFIG_NET_MEDIATEK_SOC_WED) += mtk_wed.o mtk_wed_mcu.o ifdef CONFIG_DEBUG_FS mtk_eth-$(CONFIG_NET_MEDIATEK_SOC_WED) += mtk_wed_debugfs.o endifdrivers/net/ethernet/mediatek/mtk_wed_mcu.c new file +0
-0
..snip..
Quoted 9 lines
drivers/net/ethernet/mediatek/mtk_wed_mcu.c new file +9
-0+ +int mtk_wed_mcu_init (struct mtk_wed_wo *wo) +{ +u32 val; +int ret; + +skb_queue_head_init (&wo->mcu.res_q); +init_waitqueue_head (&wo->mcu.wait); +mutex_init (&wo->mcu.mutex);
drivers/net/ethernet/mediatek/mtk_wed_mcu.c line 358
Quoted 10 lines
drivers/net/ethernet/mediatek/mtk_wed_mcu.c new file +10
-0+ + ret =mtk_wed_mcu_load_firmware (wo); +if (ret) +return ret; + +do { +/* get dummy cr */ + val =wed_r32 (wo->hw->wed_dev, +MTK_WED_SCR0 +4 *MTK_WED_DUMMY_CR_FWDL ); + }while (val && !time_after (jiffies, jiffies +MTK_FW_DL_TIMEOUT ));
Here you can use readx_poll_timeout() instead: please do so.
Quoted 24 lines
drivers/net/ethernet/mediatek/mtk_wed_mcu.c new file +6
-0+ +return val ? -EBUSY :0 ; +} + +MODULE_FIRMWARE (MT7986_FIRMWARE_WO0 ); +MODULE_FIRMWARE (MT7986_FIRMWARE_WO1 );drivers/net/ethernet/mediatek/mtk_wed_regs.h +1
-0@@ -152,6 +152,7 @@ struct mtk_wdma_desc {#define MTK_WED_RING_RX (_n) (0x400 + (_n) * 0x10) +#define MTK_WED_SCR0 0x3c0#define MTK_WED_WPDMA_INT_TRIGGER 0x504#define MTK_WED_WPDMA_INT_TRIGGER_RX_DONE BIT(1)#define MTK_WED_WPDMA_INT_TRIGGER_TX_DONE GENMASK(5, 4)drivers/net/ethernet/mediatek/mtk_wed_wo.h new file +0
-0@@ -0,0 +1,152 @@
..snip..
drivers/net/ethernet/mediatek/mtk_wed_wo.h line 67
Quoted 2 lines
drivers/net/ethernet/mediatek/mtk_wed_wo.h new file +2
-0+ +#define MTK_WO_MCU_CFG_LS_BASE 0/* XXX: 0x15194000 */
Since that definition is zero, you can safely remove it: like so, the ones following will be a bit more readable.
Quoted 10 lines
drivers/net/ethernet/mediatek/mtk_wed_wo.h new file +10
-0+#define MTK_WO_MCU_CFG_LS_HW_VER_ADDR (MTK_WO_MCU_CFG_LS_BASE + 0x000) +#define MTK_WO_MCU_CFG_LS_FW_VER_ADDR (MTK_WO_MCU_CFG_LS_BASE + 0x004) +#define MTK_WO_MCU_CFG_LS_CFG_DBG1_ADDR (MTK_WO_MCU_CFG_LS_BASE + 0x00c) +#define MTK_WO_MCU_CFG_LS_CFG_DBG2_ADDR (MTK_WO_MCU_CFG_LS_BASE + 0x010) +#define MTK_WO_MCU_CFG_LS_WF_MCCR_ADDR (MTK_WO_MCU_CFG_LS_BASE + 0x014) +#define MTK_WO_MCU_CFG_LS_WF_MCCR_SET_ADDR (MTK_WO_MCU_CFG_LS_BASE + 0x018) +#define MTK_WO_MCU_CFG_LS_WF_MCCR_CLR_ADDR (MTK_WO_MCU_CFG_LS_BASE + 0x01c) +#define MTK_WO_MCU_CFG_LS_WF_MCU_CFG_WM_WA_ADDR (MTK_WO_MCU_CFG_LS_BASE + 0x050) +#define MTK_WO_MCU_CFG_LS_WM_BOOT_ADDR_ADDR (MTK_WO_MCU_CFG_LS_BASE + 0x060) +#define MTK_WO_MCU_CFG_LS_WA_BOOT_ADDR_ADDR (MTK_WO_MCU_CFG_LS_BASE + 0x064)
..snip..
drivers/net/ethernet/mediatek/mtk_wed_wo.h line 133
Quoted 7 lines
drivers/net/ethernet/mediatek/mtk_wed_wo.h new file +7
-0+ +static inline int +mtk_wed_mcu_check_msg (struct mtk_wed_wo *wo,struct sk_buff *skb) +{ +struct mtk_wed_mcu_hdr *hdr = (struct mtk_wed_mcu_hdr *)skb->data; + +if (hdr->version)
if (hdr->version || skb->len < sizeof(*hdr) || skb->len != le16_to_cpu(hdr->length)) return -EINVAL;
drivers/net/ethernet/mediatek/mtk_wed_wo.h line 144
Quoted 11 lines
drivers/net/ethernet/mediatek/mtk_wed_wo.h new file +11
-0+return -EINVAL ; + +if (skb->len <sizeof (*hdr)) +return -EINVAL ; + +if (skb->len !=le16_to_cpu (hdr->length)) +return -EINVAL ; + +return 0 ; +} +
Regards,
Angelo
Lorenzo Bianconi
maintainerRe: [PATCH v3 net-next 3/8] net: ethernet: mtk_wed: introduce wed mcu support
Quoted 54 lines
Il 03/11/22 10:28, Lorenzo Bianconi ha scritto:
Quoted 37 lines
From: Sujuan Chen <[email protected]>
Introduce WED mcu support used to configure WED WO chip. This is a preliminary patch in order to add RX Wireless Ethernet Dispatch available on MT7986 SoC.
Tested-by Daniel Golle <[email protected]>Co-developed-by Lorenzo Bianconi <[email protected]>Signed-off-by Lorenzo Bianconi <[email protected]>Signed-off-by Sujuan Chen <[email protected]>--- drivers/net/ethernet/mediatek/Makefile | 2 +- drivers/net/ethernet/mediatek/mtk_wed_mcu.c | 364 +++++++++++++++++++ drivers/net/ethernet/mediatek/mtk_wed_regs.h | 1 + drivers/net/ethernet/mediatek/mtk_wed_wo.h | 152 ++++++++ include/linux/soc/mediatek/mtk_wed.h | 29 ++ 5 files changed, 547 insertions(+), 1 deletion(-)create mode 100644
drivers/net/ethernet/mediatek/mtk_wed_mcu.ccreate mode 100644drivers/net/ethernet/mediatek/mtk_wed_wo.hdrivers/net/ethernet/mediatek/Makefile +1
-1@@ -5,7 +5,7 @@ obj-$(CONFIG_NET_MEDIATEK_SOC) += mtk_eth.o mtk_eth-y := mtk_eth_soc.o mtk_sgmii.o mtk_eth_path.o mtk_ppe.o mtk_ppe_debugfs.o mtk_ppe_offload.o -mtk_eth-$(CONFIG_NET_MEDIATEK_SOC_WED) += mtk_wed.o +mtk_eth-$(CONFIG_NET_MEDIATEK_SOC_WED) += mtk_wed.o mtk_wed_mcu.o ifdef CONFIG_DEBUG_FS mtk_eth-$(CONFIG_NET_MEDIATEK_SOC_WED) += mtk_wed_debugfs.o endifdrivers/net/ethernet/mediatek/mtk_wed_mcu.c new file +0
-0..snip..
Quoted 13 lines
drivers/net/ethernet/mediatek/mtk_wed_mcu.c new file +13
-0+ +int mtk_wed_mcu_init (struct mtk_wed_wo *wo) +{ +u32 val; +int ret; + +skb_queue_head_init (&wo->mcu.res_q); +init_waitqueue_head (&wo->mcu.wait); +mutex_init (&wo->mcu.mutex); + + ret =mtk_wed_mcu_load_firmware (wo); +if (ret) +return ret;
Quoted 8 lines
drivers/net/ethernet/mediatek/mtk_wed_mcu.c line 358
Quoted 6 lines
drivers/net/ethernet/mediatek/mtk_wed_mcu.c new file +6
-0+ +do { +/* get dummy cr */ + val =wed_r32 (wo->hw->wed_dev, +MTK_WED_SCR0 +4 *MTK_WED_DUMMY_CR_FWDL ); + }while (val && !time_after (jiffies, jiffies +MTK_FW_DL_TIMEOUT ));Here you can use
readx_poll_timeout()instead: please do so.
ack, I will fix it in v4
Quoted 27 lines
Quoted 23 lines
drivers/net/ethernet/mediatek/mtk_wed_mcu.c new file +6
-0+ +return val ? -EBUSY :0 ; +} + +MODULE_FIRMWARE (MT7986_FIRMWARE_WO0 ); +MODULE_FIRMWARE (MT7986_FIRMWARE_WO1 );drivers/net/ethernet/mediatek/mtk_wed_regs.h +1
-0@@ -152,6 +152,7 @@ struct mtk_wdma_desc {#define MTK_WED_RING_RX (_n) (0x400 + (_n) * 0x10) +#define MTK_WED_SCR0 0x3c0#define MTK_WED_WPDMA_INT_TRIGGER 0x504#define MTK_WED_WPDMA_INT_TRIGGER_RX_DONE BIT(1)#define MTK_WED_WPDMA_INT_TRIGGER_TX_DONE GENMASK(5, 4)drivers/net/ethernet/mediatek/mtk_wed_wo.h new file +0
-0@@ -0,0 +1,152 @@..snip..
Quoted 5 lines
drivers/net/ethernet/mediatek/mtk_wed_wo.h line 67
Quoted 2 lines
drivers/net/ethernet/mediatek/mtk_wed_wo.h new file +2
-0+ +#define MTK_WO_MCU_CFG_LS_BASE 0/* XXX: 0x15194000 */ Since that definition is zero, you can safely remove it: like so, the ones following will be a bit more readable.
(removing the XXX) this is a pattern already used in the driver and in mt76. I would prefer to keep it as it is.
Quoted 14 lines
Quoted 11 lines
drivers/net/ethernet/mediatek/mtk_wed_wo.h new file +10
-0+#define MTK_WO_MCU_CFG_LS_HW_VER_ADDR (MTK_WO_MCU_CFG_LS_BASE + 0x000) +#define MTK_WO_MCU_CFG_LS_FW_VER_ADDR (MTK_WO_MCU_CFG_LS_BASE + 0x004) +#define MTK_WO_MCU_CFG_LS_CFG_DBG1_ADDR (MTK_WO_MCU_CFG_LS_BASE + 0x00c) +#define MTK_WO_MCU_CFG_LS_CFG_DBG2_ADDR (MTK_WO_MCU_CFG_LS_BASE + 0x010) +#define MTK_WO_MCU_CFG_LS_WF_MCCR_ADDR (MTK_WO_MCU_CFG_LS_BASE + 0x014) +#define MTK_WO_MCU_CFG_LS_WF_MCCR_SET_ADDR (MTK_WO_MCU_CFG_LS_BASE + 0x018) +#define MTK_WO_MCU_CFG_LS_WF_MCCR_CLR_ADDR (MTK_WO_MCU_CFG_LS_BASE + 0x01c) +#define MTK_WO_MCU_CFG_LS_WF_MCU_CFG_WM_WA_ADDR (MTK_WO_MCU_CFG_LS_BASE + 0x050) +#define MTK_WO_MCU_CFG_LS_WM_BOOT_ADDR_ADDR (MTK_WO_MCU_CFG_LS_BASE + 0x060) +#define MTK_WO_MCU_CFG_LS_WA_BOOT_ADDR_ADDR (MTK_WO_MCU_CFG_LS_BASE + 0x064)..snip..
Quoted 10 lines
drivers/net/ethernet/mediatek/mtk_wed_wo.h line 133
Quoted 7 lines
drivers/net/ethernet/mediatek/mtk_wed_wo.h new file +7
-0+ +static inline int +mtk_wed_mcu_check_msg (struct mtk_wed_wo *wo,struct sk_buff *skb) +{ +struct mtk_wed_mcu_hdr *hdr = (struct mtk_wed_mcu_hdr *)skb->data; + +if (hdr->version)if (hdr->version || skb->len < sizeof(*hdr) || skb->len != le16_to_cpu(hdr->length)) return -EINVAL;
This is just a matter of test, I would prefer as it is.
Quoted 17 lines
drivers/net/ethernet/mediatek/mtk_wed_wo.h line 144
Quoted 13 lines
drivers/net/ethernet/mediatek/mtk_wed_wo.h new file +11
-0+return -EINVAL ; + +if (skb->len <sizeof (*hdr)) +return -EINVAL ; + +if (skb->len !=le16_to_cpu (hdr->length)) +return -EINVAL ; + +return 0 ; +} +Regards,
Angelo
Re: [PATCH v3 net-next 3/8] net: ethernet: mtk_wed: introduce wed mcu support
In reply to Lorenzo BianconiHi Lorenzo,
I found a potential typo in the print output during probe. See below.
Quoted 344 lines · Lorenzo Bianconi
From: Sujuan Chen <[email protected]>
Introduce WED mcu support used to configure WED WO chip. This is a preliminary patch in order to add RX Wireless Ethernet Dispatch available on MT7986 SoC.
Tested-by Daniel Golle <[email protected]>Co-developed-by Lorenzo Bianconi <[email protected]>Signed-off-by Lorenzo Bianconi <[email protected]>Signed-off-by Sujuan Chen <[email protected]>--- drivers/net/ethernet/mediatek/Makefile | 2 +- drivers/net/ethernet/mediatek/mtk_wed_mcu.c | 364 +++++++++++++++++++ drivers/net/ethernet/mediatek/mtk_wed_regs.h | 1 + drivers/net/ethernet/mediatek/mtk_wed_wo.h | 152 ++++++++ include/linux/soc/mediatek/mtk_wed.h | 29 ++ 5 files changed, 547 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/mediatek/mtk_wed_mcu.c create mode 100644 drivers/net/ethernet/mediatek/mtk_wed_wo.hdrivers/net/ethernet/mediatek/Makefile +1
-1@@ -5,7 +5,7 @@ obj-$(CONFIG_NET_MEDIATEK_SOC) += mtk_eth.o mtk_eth-y := mtk_eth_soc.o mtk_sgmii.o mtk_eth_path.o mtk_ppe.o mtk_ppe_debugfs.o mtk_ppe_offload.o -mtk_eth-$(CONFIG_NET_MEDIATEK_SOC_WED) += mtk_wed.o +mtk_eth-$(CONFIG_NET_MEDIATEK_SOC_WED) += mtk_wed.o mtk_wed_mcu.o ifdef CONFIG_DEBUG_FS mtk_eth-$(CONFIG_NET_MEDIATEK_SOC_WED) += mtk_wed_debugfs.o endifdrivers/net/ethernet/mediatek/mtk_wed_mcu.c new file +305
-0@@ -0,0 +1,364 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* Copyright (C) 2022 MediaTek Inc. +* +* Author: Lorenzo Bianconi <[email protected]> +* Sujuan Chen <[email protected]> +*/ + +#include <linux/firmware.h> +#include <linux/of_address.h> +#include <linux/of_reserved_mem.h> +#include <linux/mfd/syscon.h> +#include <linux/soc/mediatek/mtk_wed.h> + +#include "mtk_wed_regs.h" +#include "mtk_wed_wo.h" +#include "mtk_wed.h" + +static u32 wo_r32 (struct mtk_wed_wo *wo,u32 reg) +{ +u32 val; + +if (regmap_read (wo->boot, reg, &val)) + val = ~0 ; + +return val; +} + +static void wo_w32 (struct mtk_wed_wo *wo,u32 reg,u32 val) +{ +regmap_write (wo->boot, reg, val); +} + +static struct sk_buff * +mtk_wed_mcu_msg_alloc (const void *data,int data_len) +{ +int length =sizeof (struct mtk_wed_mcu_hdr ) + data_len; +struct sk_buff *skb; + + skb =alloc_skb (length,GFP_KERNEL ); +if (!skb) +return NULL ; + +memset (skb->head,0 , length); +skb_reserve (skb,sizeof (struct mtk_wed_mcu_hdr )); +if (data && data_len) +skb_put_data (skb, data, data_len); + +return skb; +} + +static struct sk_buff * +mtk_wed_mcu_get_response (struct mtk_wed_wo *wo,unsigned long expires) +{ +if (!time_is_after_jiffies (expires)) +return NULL ; + +wait_event_timeout (wo->mcu.wait, !skb_queue_empty (&wo->mcu.res_q), + expires - jiffies); +return skb_dequeue (&wo->mcu.res_q); +} + +void mtk_wed_mcu_rx_event (struct mtk_wed_wo *wo,struct sk_buff *skb) +{ +skb_queue_tail (&wo->mcu.res_q, skb); +wake_up (&wo->mcu.wait); +} + +void mtk_wed_mcu_rx_unsolicited_event (struct mtk_wed_wo *wo, +struct sk_buff *skb) +{ +struct mtk_wed_mcu_hdr *hdr = (struct mtk_wed_mcu_hdr *)skb->data; + +switch (hdr->cmd) { +case MTK_WED_WO_EVT_LOG_DUMP : { +const char *msg = (const char *)(skb->data +sizeof (*hdr)); + +dev_notice (wo->hw->dev,"%s\n" , msg); +break ; + } +case MTK_WED_WO_EVT_PROFILING : { +struct mtk_wed_wo_log_info *info; +u32 count = (skb->len -sizeof (*hdr)) /sizeof (*info); +int i; + + info = (struct mtk_wed_wo_log_info *)(skb->data +sizeof (*hdr)); +for (i =0 ; i < count ; i++) +dev_notice (wo->hw->dev, +"SN:%u latency: total=%u, rro:%u, mod:%u\n" , +le32_to_cpu (info[i].sn), +le32_to_cpu (info[i].total), +le32_to_cpu (info[i].rro), +le32_to_cpu (info[i].mod)); +break ; + } +case MTK_WED_WO_EVT_RXCNT_INFO : +break ; +default : +break ; + } + +dev_kfree_skb (skb); +} + +static int +mtk_wed_mcu_skb_send_msg (struct mtk_wed_wo *wo,struct sk_buff *skb, +int id,int cmd,u16 *wait_seq,bool wait_resp) +{ +struct mtk_wed_mcu_hdr *hdr; + +/* TODO: make it dynamic based on cmd */ + wo->mcu.timeout =20 *HZ ; + + hdr = (struct mtk_wed_mcu_hdr *)skb_push (skb,sizeof (*hdr)); + hdr->cmd = cmd; + hdr->length =cpu_to_le16 (skb->len); + +if (wait_resp && wait_seq) { +u16 seq = ++wo->mcu.seq; + +if (!seq) + seq = ++wo->mcu.seq; + *wait_seq = seq; + + hdr->flag |=cpu_to_le16 (MTK_WED_WARP_CMD_FLAG_NEED_RSP ); + hdr->seq =cpu_to_le16 (seq); + } +if (id ==MTK_WED_MODULE_ID_WO ) + hdr->flag |=cpu_to_le16 (MTK_WED_WARP_CMD_FLAG_FROM_TO_WO ); + +dev_kfree_skb (skb); +return 0 ; +} + +static int +mtk_wed_mcu_parse_response (struct mtk_wed_wo *wo,struct sk_buff *skb, +int cmd,int seq) +{ +struct mtk_wed_mcu_hdr *hdr; + +if (!skb) { +dev_err (wo->hw->dev,"Message %08x (seq %d) timeout\n" , + cmd, seq); +return -ETIMEDOUT ; + } + + hdr = (struct mtk_wed_mcu_hdr *)skb->data; +if (le16_to_cpu (hdr->seq) != seq) +return -EAGAIN ; + +skb_pull (skb,sizeof (*hdr)); +switch (cmd) { +case MTK_WED_WO_CMD_RXCNT_INFO : +default : +break ; + } + +return 0 ; +} + +int mtk_wed_mcu_send_msg (struct mtk_wed_wo *wo,int id,int cmd, +const void *data,int len,bool wait_resp) +{ +unsigned long expires; +struct sk_buff *skb; +u16 seq; +int ret; + + skb =mtk_wed_mcu_msg_alloc (data, len); +if (!skb) +return -ENOMEM ; + +mutex_lock (&wo->mcu.mutex); + + ret =mtk_wed_mcu_skb_send_msg (wo, skb, id, cmd, &seq, wait_resp); +if (ret || !wait_resp) + goto unlock; + + expires = jiffies + wo->mcu.timeout; +do { + skb =mtk_wed_mcu_get_response (wo, expires); + ret =mtk_wed_mcu_parse_response (wo, skb, cmd, seq); +dev_kfree_skb (skb); + }while (ret == -EAGAIN ); + +unlock: +mutex_unlock (&wo->mcu.mutex); + +return ret; +} + +static int +mtk_wed_get_memory_region (struct mtk_wed_wo *wo, +struct mtk_wed_wo_memory_region *region) +{ +struct reserved_mem *rmem; +struct device_node *np; +int index; + + index =of_property_match_string (wo->hw->node,"memory-region-names" , + region->name); +if (index <0 ) +return index; + + np =of_parse_phandle (wo->hw->node,"memory-region" , index); +if (!np) +return -ENODEV ; + + rmem =of_reserved_mem_lookup (np); +of_node_put (np); + +if (!rmem) +return -ENODEV ; + + region->phy_addr = rmem->base; + region->size = rmem->size; + region->addr =devm_ioremap (wo->hw->dev, region->phy_addr, region->size); +if (!region->addr) +return -EINVAL ; + +return 0 ; +} + +static int +mtk_wed_mcu_run_firmware (struct mtk_wed_wo *wo,const struct firmware *fw, +struct mtk_wed_wo_memory_region *region) +{ +const u8 *first_region_ptr, *region_ptr, *trailer_ptr, *ptr = fw->data; +const struct mtk_wed_fw_trailer *trailer; +const struct mtk_wed_fw_region *fw_region; + + trailer_ptr = fw->data + fw->size -sizeof (*trailer); + trailer = (const struct mtk_wed_fw_trailer *)trailer_ptr; + region_ptr = trailer_ptr - trailer->num_region *sizeof (*fw_region); + first_region_ptr = region_ptr; + +while (region_ptr < trailer_ptr) { +u32 length; + + fw_region = (const struct mtk_wed_fw_region *)region_ptr; + length =le32_to_cpu (fw_region->len); + +if (region->phy_addr !=le32_to_cpu (fw_region->addr)) + goto next; + +if (region->size < length) + goto next; + +if (first_region_ptr < ptr + length) + goto next; + +if (region->shared && region->consumed) +return 0 ; + +if (!region->shared || !region->consumed) { +memcpy_toio (region->addr, ptr, length); + region->consumed = true; +return 0 ; + } +next: + region_ptr +=sizeof (*fw_region); + ptr += length; + } + +return -EINVAL ; +} + +static int +mtk_wed_mcu_load_firmware (struct mtk_wed_wo *wo) +{ +static struct mtk_wed_wo_memory_region mem_region[] = { + [MTK_WED_WO_REGION_EMI ] = { + .name ="wo-emi" , + }, + [MTK_WED_WO_REGION_ILM ] = { + .name ="wo-ilm" , + }, + [MTK_WED_WO_REGION_DATA ] = { + .name ="wo-data" , + .shared = true, + }, + }; +const struct mtk_wed_fw_trailer *trailer; +const struct firmware *fw; +const char *fw_name; +u32 val, boot_cr; +int ret, i; + +/* load firmware region metadata */ +for (i =0 ; i <ARRAY_SIZE (mem_region); i++) { + ret =mtk_wed_get_memory_region (wo, &mem_region[i]); +if (ret) +return ret; + } + + wo->boot =syscon_regmap_lookup_by_phandle (wo->hw->node, +"mediatek,wo-boot" ); +if (IS_ERR_OR_NULL (wo->boot)) +return PTR_ERR (wo->boot); + +/* set dummy cr */ +wed_w32 (wo->hw->wed_dev,MTK_WED_SCR0 +4 *MTK_WED_DUMMY_CR_FWDL , + wo->hw->index +1 ); + +/* load firmware */ + fw_name = wo->hw->index ?MT7986_FIRMWARE_WO1 :MT7986_FIRMWARE_WO0 ;
drivers/net/ethernet/mediatek/mtk_wed_mcu.c line 315
Quoted 10 lines
drivers/net/ethernet/mediatek/mtk_wed_mcu.c new file +10
-0+ ret =request_firmware (&fw, fw_name, wo->hw->dev); +if (ret) +return ret; + + trailer = (void *)(fw->data + fw->size - +sizeof (struct mtk_wed_fw_trailer )); +dev_info (wo->hw->dev, +"MTK WED WO Firmware Version: %.10s, Build Time: %.15s\n" , + trailer->fw_ver, trailer->build_date); + dev_info(wo->hw->dev, "MTK WED WO Chid ID %02x Region %d\n",
-Chid
+Chip
?
Quoted 263 lines
drivers/net/ethernet/mediatek/mtk_wed_mcu.c new file +49
-0+ trailer->chip_id, trailer->num_region); + +for (i =0 ; i <ARRAY_SIZE (mem_region); i++) { + ret =mtk_wed_mcu_run_firmware (wo, fw, &mem_region[i]); +if (ret) + goto out; + } + +/* set the start address */ + boot_cr = wo->hw->index ?MTK_WO_MCU_CFG_LS_WA_BOOT_ADDR_ADDR + :MTK_WO_MCU_CFG_LS_WM_BOOT_ADDR_ADDR ; +wo_w32 (wo, boot_cr, mem_region[MTK_WED_WO_REGION_EMI ].phy_addr >>16 ); +/* wo firmware reset */ +wo_w32 (wo,MTK_WO_MCU_CFG_LS_WF_MCCR_CLR_ADDR ,0xc00 ); + + val =wo_r32 (wo,MTK_WO_MCU_CFG_LS_WF_MCU_CFG_WM_WA_ADDR ); + val |= wo->hw->index ?MTK_WO_MCU_CFG_LS_WF_WM_WA_WA_CPU_RSTB_MASK + :MTK_WO_MCU_CFG_LS_WF_WM_WA_WM_CPU_RSTB_MASK ; +wo_w32 (wo,MTK_WO_MCU_CFG_LS_WF_MCU_CFG_WM_WA_ADDR , val); +out: +release_firmware (fw); + +return ret; +} + +int mtk_wed_mcu_init (struct mtk_wed_wo *wo) +{ +u32 val; +int ret; + +skb_queue_head_init (&wo->mcu.res_q); +init_waitqueue_head (&wo->mcu.wait); +mutex_init (&wo->mcu.mutex); + + ret =mtk_wed_mcu_load_firmware (wo); +if (ret) +return ret; + +do { +/* get dummy cr */ + val =wed_r32 (wo->hw->wed_dev, +MTK_WED_SCR0 +4 *MTK_WED_DUMMY_CR_FWDL ); + }while (val && !time_after (jiffies, jiffies +MTK_FW_DL_TIMEOUT )); + +return val ? -EBUSY :0 ; +} + +MODULE_FIRMWARE (MT7986_FIRMWARE_WO0 ); +MODULE_FIRMWARE (MT7986_FIRMWARE_WO1 );drivers/net/ethernet/mediatek/mtk_wed_regs.h +1
-0@@ -152,6 +152,7 @@ struct mtk_wdma_desc {#define MTK_WED_RING_RX (_n) (0x400 + (_n) * 0x10) +#define MTK_WED_SCR0 0x3c0#define MTK_WED_WPDMA_INT_TRIGGER 0x504#define MTK_WED_WPDMA_INT_TRIGGER_RX_DONE BIT(1)#define MTK_WED_WPDMA_INT_TRIGGER_TX_DONE GENMASK(5, 4)drivers/net/ethernet/mediatek/mtk_wed_wo.h new file +152
-0@@ -0,0 +1,152 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* Copyright (C) 2022 Lorenzo Bianconi <[email protected]> */ + +#ifndef __MTK_WED_WO_H +#define __MTK_WED_WO_H + +#include <linux/skbuff.h> +#include <linux/netdevice.h> + +struct mtk_wed_hw ; + +struct mtk_wed_mcu_hdr { +/* DW0 */ +u8 version; +u8 cmd; +__le16 length; + +/* DW1 */ +__le16 seq; +__le16 flag; + +/* DW2 */ +__le32 status; + +/* DW3 */ +u8 rsv[20 ]; +}; + +struct mtk_wed_wo_log_info { +__le32 sn; +__le32 total; +__le32 rro; +__le32 mod; +}; + +enum mtk_wed_wo_event { +MTK_WED_WO_EVT_LOG_DUMP =0x1 , +MTK_WED_WO_EVT_PROFILING =0x2 , +MTK_WED_WO_EVT_RXCNT_INFO =0x3 , +}; + +#define MTK_WED_MODULE_ID_WO 1 +#define MTK_FW_DL_TIMEOUT (4 * HZ) +#define MTK_WOCPU_TIMEOUT (2 * HZ) + +enum { +MTK_WED_WARP_CMD_FLAG_RSP =BIT (0 ), +MTK_WED_WARP_CMD_FLAG_NEED_RSP =BIT (1 ), +MTK_WED_WARP_CMD_FLAG_FROM_TO_WO =BIT (2 ), +}; + +enum { +MTK_WED_WO_REGION_EMI , +MTK_WED_WO_REGION_ILM , +MTK_WED_WO_REGION_DATA , + __MTK_WED_WO_REGION_MAX, +}; + +enum mtk_wed_dummy_cr_idx { +MTK_WED_DUMMY_CR_FWDL , +MTK_WED_DUMMY_CR_WO_STATUS , +}; + +#define MT7986_FIRMWARE_WO0 "mediatek/mt7986_wo_0.bin" +#define MT7986_FIRMWARE_WO1 "mediatek/mt7986_wo_1.bin" + +#define MTK_WO_MCU_CFG_LS_BASE 0/* XXX: 0x15194000 */ +#define MTK_WO_MCU_CFG_LS_HW_VER_ADDR (MTK_WO_MCU_CFG_LS_BASE + 0x000) +#define MTK_WO_MCU_CFG_LS_FW_VER_ADDR (MTK_WO_MCU_CFG_LS_BASE + 0x004) +#define MTK_WO_MCU_CFG_LS_CFG_DBG1_ADDR (MTK_WO_MCU_CFG_LS_BASE + 0x00c) +#define MTK_WO_MCU_CFG_LS_CFG_DBG2_ADDR (MTK_WO_MCU_CFG_LS_BASE + 0x010) +#define MTK_WO_MCU_CFG_LS_WF_MCCR_ADDR (MTK_WO_MCU_CFG_LS_BASE + 0x014) +#define MTK_WO_MCU_CFG_LS_WF_MCCR_SET_ADDR (MTK_WO_MCU_CFG_LS_BASE + 0x018) +#define MTK_WO_MCU_CFG_LS_WF_MCCR_CLR_ADDR (MTK_WO_MCU_CFG_LS_BASE + 0x01c) +#define MTK_WO_MCU_CFG_LS_WF_MCU_CFG_WM_WA_ADDR (MTK_WO_MCU_CFG_LS_BASE + 0x050) +#define MTK_WO_MCU_CFG_LS_WM_BOOT_ADDR_ADDR (MTK_WO_MCU_CFG_LS_BASE + 0x060) +#define MTK_WO_MCU_CFG_LS_WA_BOOT_ADDR_ADDR (MTK_WO_MCU_CFG_LS_BASE + 0x064) + +#define MTK_WO_MCU_CFG_LS_WF_WM_WA_WM_CPU_RSTB_MASK BIT(5) +#define MTK_WO_MCU_CFG_LS_WF_WM_WA_WA_CPU_RSTB_MASK BIT(0) + +struct mtk_wed_wo_memory_region { +const char *name; +void __iomem *addr; +phys_addr_t phy_addr; +u32 size; +bool shared:1 ; +bool consumed:1 ; +}; + +struct mtk_wed_fw_region { +__le32 decomp_crc; +__le32 decomp_len; +__le32 decomp_blk_sz; +u8 rsv0[4 ]; +__le32 addr; +__le32 len; +u8 feature_set; +u8 rsv1[15 ]; +} __packed; + +struct mtk_wed_fw_trailer { +u8 chip_id; +u8 eco_code; +u8 num_region; +u8 format_ver; +u8 format_flag; +u8 rsv[2 ]; +char fw_ver[10 ]; +char build_date[15 ]; +u32 crc; +}; + +struct mtk_wed_wo { +struct mtk_wed_hw *hw; +struct regmap *boot; + +struct { +struct mutex mutex; +int timeout; +u16 seq; + +struct sk_buff_head res_q; +wait_queue_head_t wait; + } mcu; +}; + +static inline int +mtk_wed_mcu_check_msg (struct mtk_wed_wo *wo,struct sk_buff *skb) +{ +struct mtk_wed_mcu_hdr *hdr = (struct mtk_wed_mcu_hdr *)skb->data; + +if (hdr->version) +return -EINVAL ; + +if (skb->len <sizeof (*hdr)) +return -EINVAL ; + +if (skb->len !=le16_to_cpu (hdr->length)) +return -EINVAL ; + +return 0 ; +} + +void mtk_wed_mcu_rx_event (struct mtk_wed_wo *wo,struct sk_buff *skb); +void mtk_wed_mcu_rx_unsolicited_event (struct mtk_wed_wo *wo, +struct sk_buff *skb); +int mtk_wed_mcu_send_msg (struct mtk_wed_wo *wo,int id,int cmd, +const void *data,int len,bool wait_resp); +int mtk_wed_mcu_init (struct mtk_wed_wo *wo); + +#endif /* __MTK_WED_WO_H */ include/linux/soc/mediatek/mtk_wed.h +29
-0@@ -11,6 +11,35 @@struct mtk_wed_hw ;struct mtk_wdma_desc ; +enum mtk_wed_wo_cmd { +MTK_WED_WO_CMD_WED_CFG , +MTK_WED_WO_CMD_WED_RX_STAT , +MTK_WED_WO_CMD_RRO_SER , +MTK_WED_WO_CMD_DBG_INFO , +MTK_WED_WO_CMD_DEV_INFO , +MTK_WED_WO_CMD_BSS_INFO , +MTK_WED_WO_CMD_STA_REC , +MTK_WED_WO_CMD_DEV_INFO_DUMP , +MTK_WED_WO_CMD_BSS_INFO_DUMP , +MTK_WED_WO_CMD_STA_REC_DUMP , +MTK_WED_WO_CMD_BA_INFO_DUMP , +MTK_WED_WO_CMD_FBCMD_Q_DUMP , +MTK_WED_WO_CMD_FW_LOG_CTRL , +MTK_WED_WO_CMD_LOG_FLUSH , +MTK_WED_WO_CMD_CHANGE_STATE , +MTK_WED_WO_CMD_CPU_STATS_ENABLE , +MTK_WED_WO_CMD_CPU_STATS_DUMP , +MTK_WED_WO_CMD_EXCEPTION_INIT , +MTK_WED_WO_CMD_PROF_CTRL , +MTK_WED_WO_CMD_STA_BA_DUMP , +MTK_WED_WO_CMD_BA_CTRL_DUMP , +MTK_WED_WO_CMD_RXCNT_CTRL , +MTK_WED_WO_CMD_RXCNT_INFO , +MTK_WED_WO_CMD_SET_CAP , +MTK_WED_WO_CMD_CCIF_RING_DUMP , +MTK_WED_WO_CMD_WED_END +}; +enum mtk_wed_bus_tye {MTK_WED_BUS_PCIE ,MTK_WED_BUS_AXI ,Signature · 1 line
2.38.1
Lorenzo Bianconi
maintainerRe: [PATCH v3 net-next 3/8] net: ethernet: mtk_wed: introduce wed mcu support
Quoted 1 line
Hi Lorenzo,
Hi Daniel,
Quoted 362 lines
I found a potential typo in the print output during probe. See below.
Quoted 354 lines · Lorenzo Bianconi
From: Sujuan Chen <[email protected]>
Introduce WED mcu support used to configure WED WO chip. This is a preliminary patch in order to add RX Wireless Ethernet Dispatch available on MT7986 SoC.
Tested-by Daniel Golle <[email protected]>Co-developed-by Lorenzo Bianconi <[email protected]>Signed-off-by Lorenzo Bianconi <[email protected]>Signed-off-by Sujuan Chen <[email protected]>--- drivers/net/ethernet/mediatek/Makefile | 2 +- drivers/net/ethernet/mediatek/mtk_wed_mcu.c | 364 +++++++++++++++++++ drivers/net/ethernet/mediatek/mtk_wed_regs.h | 1 + drivers/net/ethernet/mediatek/mtk_wed_wo.h | 152 ++++++++ include/linux/soc/mediatek/mtk_wed.h | 29 ++ 5 files changed, 547 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/mediatek/mtk_wed_mcu.c create mode 100644 drivers/net/ethernet/mediatek/mtk_wed_wo.hdrivers/net/ethernet/mediatek/Makefile +1
-1@@ -5,7 +5,7 @@ obj-$(CONFIG_NET_MEDIATEK_SOC) += mtk_eth.o mtk_eth-y := mtk_eth_soc.o mtk_sgmii.o mtk_eth_path.o mtk_ppe.o mtk_ppe_debugfs.o mtk_ppe_offload.o -mtk_eth-$(CONFIG_NET_MEDIATEK_SOC_WED) += mtk_wed.o +mtk_eth-$(CONFIG_NET_MEDIATEK_SOC_WED) += mtk_wed.o mtk_wed_mcu.o ifdef CONFIG_DEBUG_FS mtk_eth-$(CONFIG_NET_MEDIATEK_SOC_WED) += mtk_wed_debugfs.o endifdrivers/net/ethernet/mediatek/mtk_wed_mcu.c new file +315
-0@@ -0,0 +1,364 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* Copyright (C) 2022 MediaTek Inc. +* +* Author: Lorenzo Bianconi <[email protected]> +* Sujuan Chen <[email protected]> +*/ + +#include <linux/firmware.h> +#include <linux/of_address.h> +#include <linux/of_reserved_mem.h> +#include <linux/mfd/syscon.h> +#include <linux/soc/mediatek/mtk_wed.h> + +#include "mtk_wed_regs.h" +#include "mtk_wed_wo.h" +#include "mtk_wed.h" + +static u32 wo_r32 (struct mtk_wed_wo *wo,u32 reg) +{ +u32 val; + +if (regmap_read (wo->boot, reg, &val)) + val = ~0 ; + +return val; +} + +static void wo_w32 (struct mtk_wed_wo *wo,u32 reg,u32 val) +{ +regmap_write (wo->boot, reg, val); +} + +static struct sk_buff * +mtk_wed_mcu_msg_alloc (const void *data,int data_len) +{ +int length =sizeof (struct mtk_wed_mcu_hdr ) + data_len; +struct sk_buff *skb; + + skb =alloc_skb (length,GFP_KERNEL ); +if (!skb) +return NULL ; + +memset (skb->head,0 , length); +skb_reserve (skb,sizeof (struct mtk_wed_mcu_hdr )); +if (data && data_len) +skb_put_data (skb, data, data_len); + +return skb; +} + +static struct sk_buff * +mtk_wed_mcu_get_response (struct mtk_wed_wo *wo,unsigned long expires) +{ +if (!time_is_after_jiffies (expires)) +return NULL ; + +wait_event_timeout (wo->mcu.wait, !skb_queue_empty (&wo->mcu.res_q), + expires - jiffies); +return skb_dequeue (&wo->mcu.res_q); +} + +void mtk_wed_mcu_rx_event (struct mtk_wed_wo *wo,struct sk_buff *skb) +{ +skb_queue_tail (&wo->mcu.res_q, skb); +wake_up (&wo->mcu.wait); +} + +void mtk_wed_mcu_rx_unsolicited_event (struct mtk_wed_wo *wo, +struct sk_buff *skb) +{ +struct mtk_wed_mcu_hdr *hdr = (struct mtk_wed_mcu_hdr *)skb->data; + +switch (hdr->cmd) { +case MTK_WED_WO_EVT_LOG_DUMP : { +const char *msg = (const char *)(skb->data +sizeof (*hdr)); + +dev_notice (wo->hw->dev,"%s\n" , msg); +break ; + } +case MTK_WED_WO_EVT_PROFILING : { +struct mtk_wed_wo_log_info *info; +u32 count = (skb->len -sizeof (*hdr)) /sizeof (*info); +int i; + + info = (struct mtk_wed_wo_log_info *)(skb->data +sizeof (*hdr)); +for (i =0 ; i < count ; i++) +dev_notice (wo->hw->dev, +"SN:%u latency: total=%u, rro:%u, mod:%u\n" , +le32_to_cpu (info[i].sn), +le32_to_cpu (info[i].total), +le32_to_cpu (info[i].rro), +le32_to_cpu (info[i].mod)); +break ; + } +case MTK_WED_WO_EVT_RXCNT_INFO : +break ; +default : +break ; + } + +dev_kfree_skb (skb); +} + +static int +mtk_wed_mcu_skb_send_msg (struct mtk_wed_wo *wo,struct sk_buff *skb, +int id,int cmd,u16 *wait_seq,bool wait_resp) +{ +struct mtk_wed_mcu_hdr *hdr; + +/* TODO: make it dynamic based on cmd */ + wo->mcu.timeout =20 *HZ ; + + hdr = (struct mtk_wed_mcu_hdr *)skb_push (skb,sizeof (*hdr)); + hdr->cmd = cmd; + hdr->length =cpu_to_le16 (skb->len); + +if (wait_resp && wait_seq) { +u16 seq = ++wo->mcu.seq; + +if (!seq) + seq = ++wo->mcu.seq; + *wait_seq = seq; + + hdr->flag |=cpu_to_le16 (MTK_WED_WARP_CMD_FLAG_NEED_RSP ); + hdr->seq =cpu_to_le16 (seq); + } +if (id ==MTK_WED_MODULE_ID_WO ) + hdr->flag |=cpu_to_le16 (MTK_WED_WARP_CMD_FLAG_FROM_TO_WO ); + +dev_kfree_skb (skb); +return 0 ; +} + +static int +mtk_wed_mcu_parse_response (struct mtk_wed_wo *wo,struct sk_buff *skb, +int cmd,int seq) +{ +struct mtk_wed_mcu_hdr *hdr; + +if (!skb) { +dev_err (wo->hw->dev,"Message %08x (seq %d) timeout\n" , + cmd, seq); +return -ETIMEDOUT ; + } + + hdr = (struct mtk_wed_mcu_hdr *)skb->data; +if (le16_to_cpu (hdr->seq) != seq) +return -EAGAIN ; + +skb_pull (skb,sizeof (*hdr)); +switch (cmd) { +case MTK_WED_WO_CMD_RXCNT_INFO : +default : +break ; + } + +return 0 ; +} + +int mtk_wed_mcu_send_msg (struct mtk_wed_wo *wo,int id,int cmd, +const void *data,int len,bool wait_resp) +{ +unsigned long expires; +struct sk_buff *skb; +u16 seq; +int ret; + + skb =mtk_wed_mcu_msg_alloc (data, len); +if (!skb) +return -ENOMEM ; + +mutex_lock (&wo->mcu.mutex); + + ret =mtk_wed_mcu_skb_send_msg (wo, skb, id, cmd, &seq, wait_resp); +if (ret || !wait_resp) + goto unlock; + + expires = jiffies + wo->mcu.timeout; +do { + skb =mtk_wed_mcu_get_response (wo, expires); + ret =mtk_wed_mcu_parse_response (wo, skb, cmd, seq); +dev_kfree_skb (skb); + }while (ret == -EAGAIN ); + +unlock: +mutex_unlock (&wo->mcu.mutex); + +return ret; +} + +static int +mtk_wed_get_memory_region (struct mtk_wed_wo *wo, +struct mtk_wed_wo_memory_region *region) +{ +struct reserved_mem *rmem; +struct device_node *np; +int index; + + index =of_property_match_string (wo->hw->node,"memory-region-names" , + region->name); +if (index <0 ) +return index; + + np =of_parse_phandle (wo->hw->node,"memory-region" , index); +if (!np) +return -ENODEV ; + + rmem =of_reserved_mem_lookup (np); +of_node_put (np); + +if (!rmem) +return -ENODEV ; + + region->phy_addr = rmem->base; + region->size = rmem->size; + region->addr =devm_ioremap (wo->hw->dev, region->phy_addr, region->size); +if (!region->addr) +return -EINVAL ; + +return 0 ; +} + +static int +mtk_wed_mcu_run_firmware (struct mtk_wed_wo *wo,const struct firmware *fw, +struct mtk_wed_wo_memory_region *region) +{ +const u8 *first_region_ptr, *region_ptr, *trailer_ptr, *ptr = fw->data; +const struct mtk_wed_fw_trailer *trailer; +const struct mtk_wed_fw_region *fw_region; + + trailer_ptr = fw->data + fw->size -sizeof (*trailer); + trailer = (const struct mtk_wed_fw_trailer *)trailer_ptr; + region_ptr = trailer_ptr - trailer->num_region *sizeof (*fw_region); + first_region_ptr = region_ptr; + +while (region_ptr < trailer_ptr) { +u32 length; + + fw_region = (const struct mtk_wed_fw_region *)region_ptr; + length =le32_to_cpu (fw_region->len); + +if (region->phy_addr !=le32_to_cpu (fw_region->addr)) + goto next; + +if (region->size < length) + goto next; + +if (first_region_ptr < ptr + length) + goto next; + +if (region->shared && region->consumed) +return 0 ; + +if (!region->shared || !region->consumed) { +memcpy_toio (region->addr, ptr, length); + region->consumed = true; +return 0 ; + } +next: + region_ptr +=sizeof (*fw_region); + ptr += length; + } + +return -EINVAL ; +} + +static int +mtk_wed_mcu_load_firmware (struct mtk_wed_wo *wo) +{ +static struct mtk_wed_wo_memory_region mem_region[] = { + [MTK_WED_WO_REGION_EMI ] = { + .name ="wo-emi" , + }, + [MTK_WED_WO_REGION_ILM ] = { + .name ="wo-ilm" , + }, + [MTK_WED_WO_REGION_DATA ] = { + .name ="wo-data" , + .shared = true, + }, + }; +const struct mtk_wed_fw_trailer *trailer; +const struct firmware *fw; +const char *fw_name; +u32 val, boot_cr; +int ret, i; + +/* load firmware region metadata */ +for (i =0 ; i <ARRAY_SIZE (mem_region); i++) { + ret =mtk_wed_get_memory_region (wo, &mem_region[i]); +if (ret) +return ret; + } + + wo->boot =syscon_regmap_lookup_by_phandle (wo->hw->node, +"mediatek,wo-boot" ); +if (IS_ERR_OR_NULL (wo->boot)) +return PTR_ERR (wo->boot); + +/* set dummy cr */ +wed_w32 (wo->hw->wed_dev,MTK_WED_SCR0 +4 *MTK_WED_DUMMY_CR_FWDL , + wo->hw->index +1 ); + +/* load firmware */ + fw_name = wo->hw->index ?MT7986_FIRMWARE_WO1 :MT7986_FIRMWARE_WO0 ; + ret =request_firmware (&fw, fw_name, wo->hw->dev); +if (ret) +return ret; + + trailer = (void *)(fw->data + fw->size - +sizeof (struct mtk_wed_fw_trailer )); +dev_info (wo->hw->dev, +"MTK WED WO Firmware Version: %.10s, Build Time: %.15s\n" , + trailer->fw_ver, trailer->build_date); + dev_info(wo->hw->dev, "MTK WED WO Chid ID %02x Region %d\n",(quoted diff) +1
-1-Chid +Chip
Quoted 1 line
?
ack, I will fix it.
Regards,
Lorenzo
Quoted 265 lines
Quoted 265 lines
drivers/net/ethernet/mediatek/mtk_wed_mcu.c new file +49
-0+ trailer->chip_id, trailer->num_region); + +for (i =0 ; i <ARRAY_SIZE (mem_region); i++) { + ret =mtk_wed_mcu_run_firmware (wo, fw, &mem_region[i]); +if (ret) + goto out; + } + +/* set the start address */ + boot_cr = wo->hw->index ?MTK_WO_MCU_CFG_LS_WA_BOOT_ADDR_ADDR + :MTK_WO_MCU_CFG_LS_WM_BOOT_ADDR_ADDR ; +wo_w32 (wo, boot_cr, mem_region[MTK_WED_WO_REGION_EMI ].phy_addr >>16 ); +/* wo firmware reset */ +wo_w32 (wo,MTK_WO_MCU_CFG_LS_WF_MCCR_CLR_ADDR ,0xc00 ); + + val =wo_r32 (wo,MTK_WO_MCU_CFG_LS_WF_MCU_CFG_WM_WA_ADDR ); + val |= wo->hw->index ?MTK_WO_MCU_CFG_LS_WF_WM_WA_WA_CPU_RSTB_MASK + :MTK_WO_MCU_CFG_LS_WF_WM_WA_WM_CPU_RSTB_MASK ; +wo_w32 (wo,MTK_WO_MCU_CFG_LS_WF_MCU_CFG_WM_WA_ADDR , val); +out: +release_firmware (fw); + +return ret; +} + +int mtk_wed_mcu_init (struct mtk_wed_wo *wo) +{ +u32 val; +int ret; + +skb_queue_head_init (&wo->mcu.res_q); +init_waitqueue_head (&wo->mcu.wait); +mutex_init (&wo->mcu.mutex); + + ret =mtk_wed_mcu_load_firmware (wo); +if (ret) +return ret; + +do { +/* get dummy cr */ + val =wed_r32 (wo->hw->wed_dev, +MTK_WED_SCR0 +4 *MTK_WED_DUMMY_CR_FWDL ); + }while (val && !time_after (jiffies, jiffies +MTK_FW_DL_TIMEOUT )); + +return val ? -EBUSY :0 ; +} + +MODULE_FIRMWARE (MT7986_FIRMWARE_WO0 ); +MODULE_FIRMWARE (MT7986_FIRMWARE_WO1 );drivers/net/ethernet/mediatek/mtk_wed_regs.h +1
-0@@ -152,6 +152,7 @@ struct mtk_wdma_desc {#define MTK_WED_RING_RX (_n) (0x400 + (_n) * 0x10) +#define MTK_WED_SCR0 0x3c0#define MTK_WED_WPDMA_INT_TRIGGER 0x504#define MTK_WED_WPDMA_INT_TRIGGER_RX_DONE BIT(1)#define MTK_WED_WPDMA_INT_TRIGGER_TX_DONE GENMASK(5, 4)drivers/net/ethernet/mediatek/mtk_wed_wo.h new file +152
-0@@ -0,0 +1,152 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* Copyright (C) 2022 Lorenzo Bianconi <[email protected]> */ + +#ifndef __MTK_WED_WO_H +#define __MTK_WED_WO_H + +#include <linux/skbuff.h> +#include <linux/netdevice.h> + +struct mtk_wed_hw ; + +struct mtk_wed_mcu_hdr { +/* DW0 */ +u8 version; +u8 cmd; +__le16 length; + +/* DW1 */ +__le16 seq; +__le16 flag; + +/* DW2 */ +__le32 status; + +/* DW3 */ +u8 rsv[20 ]; +}; + +struct mtk_wed_wo_log_info { +__le32 sn; +__le32 total; +__le32 rro; +__le32 mod; +}; + +enum mtk_wed_wo_event { +MTK_WED_WO_EVT_LOG_DUMP =0x1 , +MTK_WED_WO_EVT_PROFILING =0x2 , +MTK_WED_WO_EVT_RXCNT_INFO =0x3 , +}; + +#define MTK_WED_MODULE_ID_WO 1 +#define MTK_FW_DL_TIMEOUT (4 * HZ) +#define MTK_WOCPU_TIMEOUT (2 * HZ) + +enum { +MTK_WED_WARP_CMD_FLAG_RSP =BIT (0 ), +MTK_WED_WARP_CMD_FLAG_NEED_RSP =BIT (1 ), +MTK_WED_WARP_CMD_FLAG_FROM_TO_WO =BIT (2 ), +}; + +enum { +MTK_WED_WO_REGION_EMI , +MTK_WED_WO_REGION_ILM , +MTK_WED_WO_REGION_DATA , + __MTK_WED_WO_REGION_MAX, +}; + +enum mtk_wed_dummy_cr_idx { +MTK_WED_DUMMY_CR_FWDL , +MTK_WED_DUMMY_CR_WO_STATUS , +}; + +#define MT7986_FIRMWARE_WO0 "mediatek/mt7986_wo_0.bin" +#define MT7986_FIRMWARE_WO1 "mediatek/mt7986_wo_1.bin" + +#define MTK_WO_MCU_CFG_LS_BASE 0/* XXX: 0x15194000 */ +#define MTK_WO_MCU_CFG_LS_HW_VER_ADDR (MTK_WO_MCU_CFG_LS_BASE + 0x000) +#define MTK_WO_MCU_CFG_LS_FW_VER_ADDR (MTK_WO_MCU_CFG_LS_BASE + 0x004) +#define MTK_WO_MCU_CFG_LS_CFG_DBG1_ADDR (MTK_WO_MCU_CFG_LS_BASE + 0x00c) +#define MTK_WO_MCU_CFG_LS_CFG_DBG2_ADDR (MTK_WO_MCU_CFG_LS_BASE + 0x010) +#define MTK_WO_MCU_CFG_LS_WF_MCCR_ADDR (MTK_WO_MCU_CFG_LS_BASE + 0x014) +#define MTK_WO_MCU_CFG_LS_WF_MCCR_SET_ADDR (MTK_WO_MCU_CFG_LS_BASE + 0x018) +#define MTK_WO_MCU_CFG_LS_WF_MCCR_CLR_ADDR (MTK_WO_MCU_CFG_LS_BASE + 0x01c) +#define MTK_WO_MCU_CFG_LS_WF_MCU_CFG_WM_WA_ADDR (MTK_WO_MCU_CFG_LS_BASE + 0x050) +#define MTK_WO_MCU_CFG_LS_WM_BOOT_ADDR_ADDR (MTK_WO_MCU_CFG_LS_BASE + 0x060) +#define MTK_WO_MCU_CFG_LS_WA_BOOT_ADDR_ADDR (MTK_WO_MCU_CFG_LS_BASE + 0x064) + +#define MTK_WO_MCU_CFG_LS_WF_WM_WA_WM_CPU_RSTB_MASK BIT(5) +#define MTK_WO_MCU_CFG_LS_WF_WM_WA_WA_CPU_RSTB_MASK BIT(0) + +struct mtk_wed_wo_memory_region { +const char *name; +void __iomem *addr; +phys_addr_t phy_addr; +u32 size; +bool shared:1 ; +bool consumed:1 ; +}; + +struct mtk_wed_fw_region { +__le32 decomp_crc; +__le32 decomp_len; +__le32 decomp_blk_sz; +u8 rsv0[4 ]; +__le32 addr; +__le32 len; +u8 feature_set; +u8 rsv1[15 ]; +} __packed; + +struct mtk_wed_fw_trailer { +u8 chip_id; +u8 eco_code; +u8 num_region; +u8 format_ver; +u8 format_flag; +u8 rsv[2 ]; +char fw_ver[10 ]; +char build_date[15 ]; +u32 crc; +}; + +struct mtk_wed_wo { +struct mtk_wed_hw *hw; +struct regmap *boot; + +struct { +struct mutex mutex; +int timeout; +u16 seq; + +struct sk_buff_head res_q; +wait_queue_head_t wait; + } mcu; +}; + +static inline int +mtk_wed_mcu_check_msg (struct mtk_wed_wo *wo,struct sk_buff *skb) +{ +struct mtk_wed_mcu_hdr *hdr = (struct mtk_wed_mcu_hdr *)skb->data; + +if (hdr->version) +return -EINVAL ; + +if (skb->len <sizeof (*hdr)) +return -EINVAL ; + +if (skb->len !=le16_to_cpu (hdr->length)) +return -EINVAL ; + +return 0 ; +} + +void mtk_wed_mcu_rx_event (struct mtk_wed_wo *wo,struct sk_buff *skb); +void mtk_wed_mcu_rx_unsolicited_event (struct mtk_wed_wo *wo, +struct sk_buff *skb); +int mtk_wed_mcu_send_msg (struct mtk_wed_wo *wo,int id,int cmd, +const void *data,int len,bool wait_resp); +int mtk_wed_mcu_init (struct mtk_wed_wo *wo); + +#endif /* __MTK_WED_WO_H */ include/linux/soc/mediatek/mtk_wed.h +29
-0@@ -11,6 +11,35 @@struct mtk_wed_hw ;struct mtk_wdma_desc ; +enum mtk_wed_wo_cmd { +MTK_WED_WO_CMD_WED_CFG , +MTK_WED_WO_CMD_WED_RX_STAT , +MTK_WED_WO_CMD_RRO_SER , +MTK_WED_WO_CMD_DBG_INFO , +MTK_WED_WO_CMD_DEV_INFO , +MTK_WED_WO_CMD_BSS_INFO , +MTK_WED_WO_CMD_STA_REC , +MTK_WED_WO_CMD_DEV_INFO_DUMP , +MTK_WED_WO_CMD_BSS_INFO_DUMP , +MTK_WED_WO_CMD_STA_REC_DUMP , +MTK_WED_WO_CMD_BA_INFO_DUMP , +MTK_WED_WO_CMD_FBCMD_Q_DUMP , +MTK_WED_WO_CMD_FW_LOG_CTRL , +MTK_WED_WO_CMD_LOG_FLUSH , +MTK_WED_WO_CMD_CHANGE_STATE , +MTK_WED_WO_CMD_CPU_STATS_ENABLE , +MTK_WED_WO_CMD_CPU_STATS_DUMP , +MTK_WED_WO_CMD_EXCEPTION_INIT , +MTK_WED_WO_CMD_PROF_CTRL , +MTK_WED_WO_CMD_STA_BA_DUMP , +MTK_WED_WO_CMD_BA_CTRL_DUMP , +MTK_WED_WO_CMD_RXCNT_CTRL , +MTK_WED_WO_CMD_RXCNT_INFO , +MTK_WED_WO_CMD_SET_CAP , +MTK_WED_WO_CMD_CCIF_RING_DUMP , +MTK_WED_WO_CMD_WED_END +}; +enum mtk_wed_bus_tye {MTK_WED_BUS_PCIE ,MTK_WED_BUS_AXI ,Signature · 1 line
2.38.1
Lorenzo Bianconi
maintainerPATCH v3 4/8 net: ethernet: mtk_wed: introduce wed wo support
In reply to Lorenzo BianconiIntroduce WO chip support to mtk wed driver. MTK WED WO is used to implement RX Wireless Ethernet Dispatch and offload traffic received by wlan nic to the wired interface.
--- drivers/net/ethernet/mediatek/Makefile | 2 +- drivers/net/ethernet/mediatek/mtk_wed.c | 7 +- drivers/net/ethernet/mediatek/mtk_wed.h | 2 + drivers/net/ethernet/mediatek/mtk_wed_mcu.c | 3 +- drivers/net/ethernet/mediatek/mtk_wed_wo.c | 508 ++++++++++++++++++++ drivers/net/ethernet/mediatek/mtk_wed_wo.h | 104 ++++ 6 files changed, 622 insertions(+), 4 deletions(-) create mode 100644 drivers/net/ethernet/mediatek/mtk_wed_wo.c
drivers/net/ethernet/mediatek/Makefile +1 -1
@@ -5,7 +5,7 @@ obj-$(CONFIG_NET_MEDIATEK_SOC) += mtk_eth.o mtk_eth-y := mtk_eth_soc.o mtk_sgmii.o mtk_eth_path.o mtk_ppe.o mtk_ppe_debugfs.o mtk_ppe_offload.o -mtk_eth-$(CONFIG_NET_MEDIATEK_SOC_WED) += mtk_wed.o mtk_wed_mcu.o +mtk_eth-$(CONFIG_NET_MEDIATEK_SOC_WED) += mtk_wed.o mtk_wed_mcu.o mtk_wed_wo.o ifdef CONFIG_DEBUG_FS mtk_eth-$(CONFIG_NET_MEDIATEK_SOC_WED) += mtk_wed_debugfs.o endif
drivers/net/ethernet/mediatek/mtk_wed.c +6 -1
@@ -16,6 +16,7 @@#include "mtk_wed_regs.h" #include "mtk_wed.h" #include "mtk_ppe.h" +#include "mtk_wed_wo.h" #define MTK_PCIE_BASE (n) (0x1a143000 + (n) * 0x2000)
@@ -355,6 +356,8 @@ mtk_wed_detach(struct mtk_wed_device *dev)mtk_wed_free_buffer (dev);mtk_wed_free_tx_rings (dev); +if (hw->version !=1 ) +mtk_wed_wo_deinit (hw);if (dev->wlan.bus_type ==MTK_WED_BUS_PCIE ) {struct device_node *wlan_node;
@@ -878,9 +881,11 @@ mtk_wed_attach(struct mtk_wed_device *dev) }mtk_wed_hw_init_early (dev); -if (hw->hifsys) +if (hw->version ==1 )regmap_update_bits (hw->hifsys,HIFSYS_DMA_AG_MAP ,BIT (hw->index),0 ); +else + ret =mtk_wed_wo_init (hw); out:mutex_unlock (&hw_lock);
drivers/net/ethernet/mediatek/mtk_wed.h +2 -0
@@ -10,6 +10,7 @@#include <linux/netdevice.h> struct mtk_eth ; +struct mtk_wed_wo ;struct mtk_wed_hw {struct device_node *node;
@@ -22,6 +23,7 @@ struct mtk_wed_hw {struct regmap *mirror;struct dentry *debugfs_dir;struct mtk_wed_device *wed_dev; +struct mtk_wed_wo *wed_wo;u32 debugfs_reg;u32 num_flows;u8 version;
drivers/net/ethernet/mediatek/mtk_wed_mcu.c +1 -2
@@ -127,8 +127,7 @@ mtk_wed_mcu_skb_send_msg(struct mtk_wed_wo *wo, struct sk_buff *skb,if (id ==MTK_WED_MODULE_ID_WO ) hdr->flag |=cpu_to_le16 (MTK_WED_WARP_CMD_FLAG_FROM_TO_WO ); -dev_kfree_skb (skb); -return 0 ; +return mtk_wed_wo_queue_tx_skb (wo, &wo->q_tx, skb); } static int
drivers/net/ethernet/mediatek/mtk_wed_wo.c new file +508 -0
508 lines not on this page · raw message
drivers/net/ethernet/mediatek/mtk_wed_wo.h +104 -0
131 lines not on this page · raw message
Signature · 1 line
2.38.1
Lorenzo Bianconi
maintainerPATCH v3 5/8 net: ethernet: mtk_wed: rename tx_wdma array in rx_wdma
In reply to Lorenzo BianconiRename tx_wdma queue array in rx_wdma since this is rx side of wdma soc. Moreover rename mtk_wed_wdma_ring_setup routine in mtk_wed_wdma_rx_ring_setup()
--- drivers/net/ethernet/mediatek/mtk_wed.c | 16 ++++++++-------- include/linux/soc/mediatek/mtk_wed.h | 3 ++- 2 files changed, 10 insertions(+), 9 deletions(-)
drivers/net/ethernet/mediatek/mtk_wed.c +8 -8
@@ -253,8 +253,8 @@ mtk_wed_free_tx_rings(struct mtk_wed_device *dev)for (i =0 ; i <ARRAY_SIZE (dev->tx_ring); i++)mtk_wed_free_ring (dev, &dev->tx_ring[i]); -for (i =0 ; i <ARRAY_SIZE (dev->tx_wdma); i++) -mtk_wed_free_ring (dev, &dev->tx_wdma[i]); +for (i =0 ; i <ARRAY_SIZE (dev->rx_wdma); i++) +mtk_wed_free_ring (dev, &dev->rx_wdma[i]); } static void
@@ -688,10 +688,10 @@ mtk_wed_ring_alloc(struct mtk_wed_device *dev, struct mtk_wed_ring *ring, }static int -mtk_wed_wdma_ring_setup (struct mtk_wed_device *dev,int idx,int size) +mtk_wed_wdma_rx_ring_setup (struct mtk_wed_device *dev,int idx,int size) {u32 desc_size =sizeof (struct mtk_wdma_desc ) * dev->hw->version; -struct mtk_wed_ring *wdma = &dev->tx_wdma[idx]; +struct mtk_wed_ring *wdma = &dev->rx_wdma[idx];if (mtk_wed_ring_alloc (dev, wdma,MTK_WED_WDMA_RING_SIZE , desc_size))return -ENOMEM ;
@@ -805,9 +805,9 @@ mtk_wed_start(struct mtk_wed_device *dev, u32 irq_mask) {int i; -for (i =0 ; i <ARRAY_SIZE (dev->tx_wdma); i++) -if (!dev->tx_wdma[i].desc) -mtk_wed_wdma_ring_setup (dev, i,16 ); +for (i =0 ; i <ARRAY_SIZE (dev->rx_wdma); i++) +if (!dev->rx_wdma[i].desc) +mtk_wed_wdma_rx_ring_setup (dev, i,16 );mtk_wed_hw_init (dev);mtk_wed_configure_irq (dev, irq_mask);
@@ -916,7 +916,7 @@ mtk_wed_tx_ring_setup(struct mtk_wed_device *dev, int idx, void __iomem *regs) sizeof(*ring->desc)))return -ENOMEM ; -if (mtk_wed_wdma_ring_setup (dev, idx,MTK_WED_WDMA_RING_SIZE )) +if (mtk_wed_wdma_rx_ring_setup (dev, idx,MTK_WED_WDMA_RING_SIZE ))return -ENOMEM ; ring->reg_base =MTK_WED_RING_TX (idx);
include/linux/soc/mediatek/mtk_wed.h +2 -1
@@ -7,6 +7,7 @@#include <linux/pci.h> #define MTK_WED_TX_QUEUES 2 +#define MTK_WED_RX_QUEUES 2struct mtk_wed_hw ;struct mtk_wdma_desc ;
@@ -66,7 +67,7 @@ struct mtk_wed_device {struct mtk_wed_ring tx_ring[MTK_WED_TX_QUEUES ];struct mtk_wed_ring txfree_ring; -struct mtk_wed_ring tx_wdma[MTK_WED_TX_QUEUES ]; +struct mtk_wed_ring rx_wdma[MTK_WED_RX_QUEUES ];struct {int size;
Signature · 1 line
2.38.1
Lorenzo Bianconi
maintainerPATCH v3 6/8 net: ethernet: mtk_wed: add configure wed wo support
In reply to Lorenzo BianconiEnable RX Wireless Ethernet Dispatch available on MT7986 Soc.
--- drivers/net/ethernet/mediatek/mtk_wed.c | 590 +++++++++++++++++-- drivers/net/ethernet/mediatek/mtk_wed.h | 19 + drivers/net/ethernet/mediatek/mtk_wed_mcu.c | 45 +- drivers/net/ethernet/mediatek/mtk_wed_regs.h | 128 +++- drivers/net/ethernet/mediatek/mtk_wed_wo.h | 28 + include/linux/soc/mediatek/mtk_wed.h | 76 ++- 6 files changed, 832 insertions(+), 54 deletions(-)
drivers/net/ethernet/mediatek/mtk_wed.c +547 -43
@@ -23,6 +23,7 @@#define MTK_WED_PKT_SIZE 1900#define MTK_WED_BUF_SIZE 2048#define MTK_WED_BUF_PER_PAGE (PAGE_SIZE / 2048) +#define MTK_WED_RX_RING_SIZE 1536#define MTK_WED_TX_RING_SIZE 2048#define MTK_WED_WDMA_RING_SIZE 1024
@@ -31,6 +32,10 @@#define MTK_WED_PER_GROUP_PKT 128#define MTK_WED_FBUF_SIZE 128 +#define MTK_WED_MIOD_CNT 16 +#define MTK_WED_FB_CMD_CNT 1024 +#define MTK_WED_RRO_QUE_CNT 8192 +#define MTK_WED_MIOD_ENTRY_CNT 128static struct mtk_wed_hw *hw_list[2 ];static DEFINE_MUTEX (hw_lock);
@@ -65,12 +70,76 @@ wdma_set(struct mtk_wed_device *dev, u32 reg, u32 mask)wdma_m32 (dev, reg,0 , mask); } +static void +wdma_clr (struct mtk_wed_device *dev,u32 reg,u32 mask) +{ +wdma_m32 (dev, reg, mask,0 ); +} + +static u32 +wifi_r32 (struct mtk_wed_device *dev,u32 reg) +{ +return readl (dev->wlan.base + reg); +} + +static void +wifi_w32 (struct mtk_wed_device *dev,u32 reg,u32 val) +{ +writel (val, dev->wlan.base + reg); +} +static u32 mtk_wed_read_reset (struct mtk_wed_device *dev) {return wed_r32 (dev,MTK_WED_RESET ); } +static u32 +mtk_wdma_read_reset (struct mtk_wed_device *dev) +{ +return wdma_r32 (dev,MTK_WDMA_GLO_CFG ); +} + +static void +mtk_wdma_rx_reset (struct mtk_wed_device *dev) +{ +u32 status, mask =MTK_WDMA_GLO_CFG_RX_DMA_BUSY ; +int i; + +wdma_clr (dev,MTK_WDMA_GLO_CFG ,MTK_WDMA_GLO_CFG_RX_DMA_EN ); +if (readx_poll_timeout (mtk_wdma_read_reset, dev, status, + !(status & mask),0 ,1000 )) +dev_err (dev->hw->dev,"rx reset failed\n" ); + +for (i =0 ; i <ARRAY_SIZE (dev->rx_wdma); i++) { +if (dev->rx_wdma[i].desc) +continue ; + +wdma_w32 (dev, +MTK_WDMA_RING_RX (i) +MTK_WED_RING_OFS_CPU_IDX ,0 ); + } +} + +static void +mtk_wdma_tx_reset (struct mtk_wed_device *dev) +{ +u32 status, mask =MTK_WDMA_GLO_CFG_TX_DMA_BUSY ; +int i; + +wdma_clr (dev,MTK_WDMA_GLO_CFG ,MTK_WDMA_GLO_CFG_TX_DMA_EN ); +if (readx_poll_timeout (mtk_wdma_read_reset, dev, status, + !(status & mask),0 ,1000 )) +dev_err (dev->hw->dev,"tx reset failed\n" ); + +for (i =0 ; i <ARRAY_SIZE (dev->tx_wdma); i++) { +if (dev->tx_wdma[i].desc) +continue ; + +wdma_w32 (dev, +MTK_WDMA_RING_TX (i) +MTK_WED_RING_OFS_CPU_IDX ,0 ); + } +} +static void mtk_wed_reset (struct mtk_wed_device *dev,u32 mask) {
@@ -82,6 +151,50 @@ mtk_wed_reset(struct mtk_wed_device *dev, u32 mask)WARN_ON_ONCE (1 ); } +static void +mtk_wed_wo_reset (struct mtk_wed_device *dev) +{ +unsigned long timeout = jiffies +MTK_WOCPU_TIMEOUT ; +struct mtk_wed_wo *wo = dev->hw->wed_wo; +u8 state =MTK_WED_WO_STATE_DISABLE ; +void __iomem *reg; +u32 val; + +mtk_wdma_tx_reset (dev); +mtk_wed_reset (dev,MTK_WED_RESET_WED ); + +mtk_wed_mcu_send_msg (wo,MTK_WED_MODULE_ID_WO , +MTK_WED_WO_CMD_CHANGE_STATE , &state, +sizeof (state), false); +do { + val =wed_r32 (dev, +MTK_WED_SCR0 +4 *MTK_WED_DUMMY_CR_WO_STATUS ); +usleep_range (100 ,200 ); + }while (val !=MTK_WED_WOIF_DISABLE_DONE && + !time_after (jiffies, timeout)); + + reg =ioremap (MTK_WED_WO_CPU_MCUSYS_RESET_ADDR ,4 ); + + val =readl (reg); +switch (dev->hw->index) { +case 0 : + val |=MTK_WED_WO_CPU_WO0_MCUSYS_RESET_MASK ; +writel (val, reg); + val &= ~MTK_WED_WO_CPU_WO0_MCUSYS_RESET_MASK ; +writel (val, reg); +break ; +case 1 : + val |=MTK_WED_WO_CPU_WO1_MCUSYS_RESET_MASK ; +writel (val, reg); + val &= ~MTK_WED_WO_CPU_WO1_MCUSYS_RESET_MASK ; +writel (val, reg); +break ; +default : +break ; + } +iounmap (reg); +} +static struct mtk_wed_hw *mtk_wed_assign (struct mtk_wed_device *dev) {
@@ -116,7 +229,7 @@ mtk_wed_assign(struct mtk_wed_device *dev) }static int -mtk_wed_buffer_alloc (struct mtk_wed_device *dev) +mtk_wed_tx_buffer_alloc (struct mtk_wed_device *dev) {struct mtk_wdma_desc *desc;dma_addr_t desc_phys;
@@ -133,16 +246,16 @@ mtk_wed_buffer_alloc(struct mtk_wed_device *dev)if (!page_list)return -ENOMEM ; - dev->buf_ring.size = ring_size; - dev->buf_ring.pages = page_list; + dev->tx_buf_ring.size = ring_size; + dev->tx_buf_ring.pages = page_list; desc =dma_alloc_coherent (dev->hw->dev, ring_size *sizeof (*desc), &desc_phys,GFP_KERNEL );if (!desc)return -ENOMEM ; - dev->buf_ring.desc = desc; - dev->buf_ring.desc_phys = desc_phys; + dev->tx_buf_ring.desc = desc; + dev->tx_buf_ring.desc_phys = desc_phys;for (i =0 , page_idx =0 ; i < ring_size; i +=MTK_WED_BUF_PER_PAGE ) {dma_addr_t page_phys, buf_phys;
@@ -203,10 +316,10 @@ mtk_wed_buffer_alloc(struct mtk_wed_device *dev) }static void -mtk_wed_free_buffer (struct mtk_wed_device *dev) +mtk_wed_free_tx_buffer (struct mtk_wed_device *dev) { -struct mtk_wdma_desc *desc = dev->buf_ring.desc; -void **page_list = dev->buf_ring.pages; +struct mtk_wdma_desc *desc = dev->tx_buf_ring.desc; +void **page_list = dev->tx_buf_ring.pages;int page_idx;int i;
@@ -216,7 +329,8 @@ mtk_wed_free_buffer(struct mtk_wed_device *dev)if (!desc) goto free_pagelist; -for (i =0 , page_idx =0 ; i < dev->buf_ring.size; i +=MTK_WED_BUF_PER_PAGE ) { +for (i =0 , page_idx =0 ; i < dev->tx_buf_ring.size; + i +=MTK_WED_BUF_PER_PAGE ) {void *page = page_list[page_idx++];dma_addr_t buf_addr;
@@ -229,13 +343,59 @@ mtk_wed_free_buffer(struct mtk_wed_device *dev)__free_page (page); } -dma_free_coherent (dev->hw->dev, dev->buf_ring.size *sizeof (*desc), - desc, dev->buf_ring.desc_phys); +dma_free_coherent (dev->hw->dev, dev->tx_buf_ring.size *sizeof (*desc), + desc, dev->tx_buf_ring.desc_phys); free_pagelist:kfree (page_list); } +static int +mtk_wed_rx_buffer_alloc (struct mtk_wed_device *dev) +{ +struct mtk_rxbm_desc *desc; +dma_addr_t desc_phys; + + dev->rx_buf_ring.size = dev->wlan.rx_nbuf; + desc =dma_alloc_coherent (dev->hw->dev, + dev->wlan.rx_nbuf *sizeof (*desc), + &desc_phys,GFP_KERNEL ); +if (!desc) +return -ENOMEM ; + + dev->rx_buf_ring.desc = desc; + dev->rx_buf_ring.desc_phys = desc_phys; + dev->wlan.init_rx_buf (dev, dev->wlan.rx_npkt); + +return 0 ; +} + +static void +mtk_wed_free_rx_buffer (struct mtk_wed_device *dev) +{ +struct mtk_rxbm_desc *desc = dev->rx_buf_ring.desc; + +if (!desc) +return ; + + dev->wlan.release_rx_buf (dev); +dma_free_coherent (dev->hw->dev, dev->rx_buf_ring.size *sizeof (*desc), + desc, dev->rx_buf_ring.desc_phys); +} + +static void +mtk_wed_rx_buffer_hw_init (struct mtk_wed_device *dev) +{ +wed_w32 (dev,MTK_WED_RX_BM_RX_DMAD , +FIELD_PREP (MTK_WED_RX_BM_RX_DMAD_SDL0 , dev->wlan.rx_size)); +wed_w32 (dev,MTK_WED_RX_BM_BASE , dev->rx_buf_ring.desc_phys); +wed_w32 (dev,MTK_WED_RX_BM_INIT_PTR ,MTK_WED_RX_BM_INIT_SW_TAIL | +FIELD_PREP (MTK_WED_RX_BM_SW_TAIL , dev->wlan.rx_npkt)); +wed_w32 (dev,MTK_WED_RX_BM_DYN_ALLOC_TH , +FIELD_PREP (MTK_WED_RX_BM_DYN_ALLOC_TH_H ,0xffff )); +wed_set (dev,MTK_WED_CTRL ,MTK_WED_CTRL_WED_RX_BM_EN ); +} +static void mtk_wed_free_ring (struct mtk_wed_device *dev,struct mtk_wed_ring *ring) {
@@ -246,6 +406,13 @@ mtk_wed_free_ring(struct mtk_wed_device *dev, struct mtk_wed_ring *ring) ring->desc, ring->desc_phys); } +static void +mtk_wed_free_rx_rings (struct mtk_wed_device *dev) +{ +mtk_wed_free_rx_buffer (dev); +mtk_wed_free_ring (dev, &dev->rro.ring); +} +static void mtk_wed_free_tx_rings (struct mtk_wed_device *dev) {
@@ -291,6 +458,38 @@ mtk_wed_set_512_support(struct mtk_wed_device *dev, bool enable) } } +#define MTK_WFMDA_RX_DMA_EN BIT(2) +static void +mtk_wed_check_wfdma_rx_fill (struct mtk_wed_device *dev,int idx) +{ +u32 val; +int i; + +if (!(dev->rx_ring[idx].flags &MTK_WED_RING_CONFIGURED )) +return ;/* queue is not configured by mt76 */ + +for (i =0 ; i <3 ; i++) { +u32 cur_idx; + + cur_idx =wed_r32 (dev, +MTK_WED_WPDMA_RING_RX_DATA (idx) + +MTK_WED_RING_OFS_CPU_IDX ); +if (cur_idx ==MTK_WED_RX_RING_SIZE -1 ) +break ; + +usleep_range (100000 ,200000 ); + } + +if (i ==3 ) { +dev_err (dev->hw->dev,"rx dma enable failed\n" ); +return ; + } + + val =wifi_r32 (dev, dev->wlan.wpdma_rx_glo - dev->wlan.phy_base) | +MTK_WFMDA_RX_DMA_EN ; +wifi_w32 (dev, dev->wlan.wpdma_rx_glo - dev->wlan.phy_base, val); +} +static void mtk_wed_dma_disable (struct mtk_wed_device *dev) {
@@ -304,20 +503,25 @@ mtk_wed_dma_disable(struct mtk_wed_device *dev)MTK_WED_GLO_CFG_TX_DMA_EN | MTK_WED_GLO_CFG_RX_DMA_EN); -wdma_m32 (dev,MTK_WDMA_GLO_CFG , +wdma_clr (dev,MTK_WDMA_GLO_CFG ,MTK_WDMA_GLO_CFG_TX_DMA_EN |MTK_WDMA_GLO_CFG_RX_INFO1_PRERES | -MTK_WDMA_GLO_CFG_RX_INFO2_PRERES ,0 ); +MTK_WDMA_GLO_CFG_RX_INFO2_PRERES );if (dev->hw->version ==1 ) {regmap_write (dev->hw->mirror, dev->hw->index *4 ,0 ); -wdma_m32 (dev,MTK_WDMA_GLO_CFG , -MTK_WDMA_GLO_CFG_RX_INFO3_PRERES ,0 ); +wdma_clr (dev,MTK_WDMA_GLO_CFG , +MTK_WDMA_GLO_CFG_RX_INFO3_PRERES ); }else {wed_clr (dev,MTK_WED_WPDMA_GLO_CFG ,MTK_WED_WPDMA_GLO_CFG_RX_DRV_R0_PKT_PROC |MTK_WED_WPDMA_GLO_CFG_RX_DRV_R0_CRX_SYNC ); +wed_clr (dev,MTK_WED_WPDMA_RX_D_GLO_CFG , +MTK_WED_WPDMA_RX_D_RX_DRV_EN ); +wed_clr (dev,MTK_WED_WDMA_GLO_CFG , +MTK_WED_WDMA_GLO_CFG_TX_DDONE_CHK ); +mtk_wed_set_512_support (dev, false); } }
@@ -338,6 +542,13 @@ mtk_wed_stop(struct mtk_wed_device *dev)wdma_w32 (dev,MTK_WDMA_INT_MASK ,0 );wdma_w32 (dev,MTK_WDMA_INT_GRP2 ,0 );wed_w32 (dev,MTK_WED_WPDMA_INT_MASK ,0 ); + +if (dev->hw->version ==1 ) +return ; + +wed_w32 (dev,MTK_WED_EXT_INT_MASK1 ,0 ); +wed_w32 (dev,MTK_WED_EXT_INT_MASK2 ,0 ); +wed_clr (dev,MTK_WED_CTRL ,MTK_WED_CTRL_WED_RX_BM_EN ); } static void
@@ -353,11 +564,21 @@ mtk_wed_detach(struct mtk_wed_device *dev)wdma_w32 (dev,MTK_WDMA_RESET_IDX ,0 );mtk_wed_reset (dev,MTK_WED_RESET_WED ); +if (mtk_wed_get_rx_capa (dev)) { +wdma_clr (dev,MTK_WDMA_GLO_CFG ,MTK_WDMA_GLO_CFG_TX_DMA_EN ); +wdma_w32 (dev,MTK_WDMA_RESET_IDX ,MTK_WDMA_RESET_IDX_TX ); +wdma_w32 (dev,MTK_WDMA_RESET_IDX ,0 ); + } -mtk_wed_free_buffer (dev); +mtk_wed_free_tx_buffer (dev);mtk_wed_free_tx_rings (dev); -if (hw->version !=1 ) + +if (mtk_wed_get_rx_capa (dev)) { +mtk_wed_wo_reset (dev); +mtk_wed_free_rx_rings (dev);mtk_wed_wo_deinit (hw); +mtk_wdma_rx_reset (dev); + }if (dev->wlan.bus_type ==MTK_WED_BUS_PCIE ) {struct device_node *wlan_node;
@@ -434,10 +655,12 @@ mtk_wed_set_wpdma(struct mtk_wed_device *dev) }else {mtk_wed_bus_init (dev); -wed_w32 (dev,MTK_WED_WPDMA_CFG_BASE , dev->wlan.wpdma_int); -wed_w32 (dev,MTK_WED_WPDMA_CFG_INT_MASK , dev->wlan.wpdma_mask); -wed_w32 (dev,MTK_WED_WPDMA_CFG_TX , dev->wlan.wpdma_tx); -wed_w32 (dev,MTK_WED_WPDMA_CFG_TX_FREE , dev->wlan.wpdma_txfree); +wed_w32 (dev,MTK_WED_WPDMA_CFG_BASE , dev->wlan.wpdma_int); +wed_w32 (dev,MTK_WED_WPDMA_CFG_INT_MASK , dev->wlan.wpdma_mask); +wed_w32 (dev,MTK_WED_WPDMA_CFG_TX , dev->wlan.wpdma_tx); +wed_w32 (dev,MTK_WED_WPDMA_CFG_TX_FREE , dev->wlan.wpdma_txfree); +wed_w32 (dev,MTK_WED_WPDMA_RX_GLO_CFG , dev->wlan.wpdma_rx_glo); +wed_w32 (dev,MTK_WED_WPDMA_RX_RING , dev->wlan.wpdma_rx); } }
@@ -487,6 +710,127 @@ mtk_wed_hw_init_early(struct mtk_wed_device *dev) } } +static int +mtk_wed_rro_ring_alloc (struct mtk_wed_device *dev,struct mtk_wed_ring *ring, +int size) +{ + ring->desc =dma_alloc_coherent (dev->hw->dev, + size *sizeof (*ring->desc), + &ring->desc_phys,GFP_KERNEL ); +if (!ring->desc) +return -ENOMEM ; + + ring->desc_size =sizeof (*ring->desc); + ring->size = size; +memset (ring->desc,0 , size); + +return 0 ; +} + +#define MTK_WED_MIOD_COUNT (MTK_WED_MIOD_ENTRY_CNT * MTK_WED_MIOD_CNT) +static int +mtk_wed_rro_alloc (struct mtk_wed_device *dev) +{ +struct device_node *np; +struct resource res; +int ret; + + np =of_parse_phandle (dev->hw->node,"mediatek,wo-dlm" ,0 ); +if (!np) +return -ENODEV ; + + ret =of_address_to_resource (np,0 , &res); +if (ret) +return ret; + + dev->rro.miod_phys = res.start; + dev->rro.fdbk_phys =MTK_WED_MIOD_COUNT + dev->rro.miod_phys; + +if (mtk_wed_rro_ring_alloc (dev, &dev->rro.ring,MTK_WED_RRO_QUE_CNT )) +return -ENOMEM ; + +return 0 ; +} + +static int +mtk_wed_rro_cfg (struct mtk_wed_device *dev) +{ +struct mtk_wed_wo *wo = dev->hw->wed_wo; +struct { +struct { +__le32 base; +__le32 cnt; +__le32 unit; + } ring[2 ]; +__le32 wed; +u8 version; + } req = { + .ring[0 ] = { + .base =cpu_to_le32 (MTK_WED_WOCPU_VIEW_MIOD_BASE ), + .cnt =cpu_to_le32 (MTK_WED_MIOD_CNT ), + .unit =cpu_to_le32 (MTK_WED_MIOD_ENTRY_CNT ), + }, + .ring[1 ] = { + .base =cpu_to_le32 (MTK_WED_WOCPU_VIEW_MIOD_BASE + +MTK_WED_MIOD_COUNT ), + .cnt =cpu_to_le32 (MTK_WED_FB_CMD_CNT ), + .unit =cpu_to_le32 (4 ), + }, + }; + +return mtk_wed_mcu_send_msg (wo,MTK_WED_MODULE_ID_WO , +MTK_WED_WO_CMD_WED_CFG , + &req,sizeof (req), true); +} + +static void +mtk_wed_rro_hw_init (struct mtk_wed_device *dev) +{ +wed_w32 (dev,MTK_WED_RROQM_MIOD_CFG , +FIELD_PREP (MTK_WED_RROQM_MIOD_MID_DW ,0x70 >>2 ) | +FIELD_PREP (MTK_WED_RROQM_MIOD_MOD_DW ,0x10 >>2 ) | +FIELD_PREP (MTK_WED_RROQM_MIOD_ENTRY_DW , +MTK_WED_MIOD_ENTRY_CNT >>2 )); + +wed_w32 (dev,MTK_WED_RROQM_MIOD_CTRL0 , dev->rro.miod_phys); +wed_w32 (dev,MTK_WED_RROQM_MIOD_CTRL1 , +FIELD_PREP (MTK_WED_RROQM_MIOD_CNT ,MTK_WED_MIOD_CNT )); +wed_w32 (dev,MTK_WED_RROQM_FDBK_CTRL0 , dev->rro.fdbk_phys); +wed_w32 (dev,MTK_WED_RROQM_FDBK_CTRL1 , +FIELD_PREP (MTK_WED_RROQM_FDBK_CNT ,MTK_WED_FB_CMD_CNT )); +wed_w32 (dev,MTK_WED_RROQM_FDBK_CTRL2 ,0 ); +wed_w32 (dev,MTK_WED_RROQ_BASE_L , dev->rro.ring.desc_phys); + +wed_set (dev,MTK_WED_RROQM_RST_IDX , +MTK_WED_RROQM_RST_IDX_MIOD | +MTK_WED_RROQM_RST_IDX_FDBK ); + +wed_w32 (dev,MTK_WED_RROQM_RST_IDX ,0 ); +wed_w32 (dev,MTK_WED_RROQM_MIOD_CTRL2 ,MTK_WED_MIOD_CNT -1 ); +wed_set (dev,MTK_WED_CTRL ,MTK_WED_CTRL_RX_RRO_QM_EN ); +} + +static void +mtk_wed_route_qm_hw_init (struct mtk_wed_device *dev) +{ +wed_w32 (dev,MTK_WED_RESET ,MTK_WED_RESET_RX_ROUTE_QM ); + +for (;;) { +usleep_range (100 ,200 ); +if (!(wed_r32 (dev,MTK_WED_RESET ) &MTK_WED_RESET_RX_ROUTE_QM )) +break ; + } + +/* configure RX_ROUTE_QM */ +wed_clr (dev,MTK_WED_RTQM_GLO_CFG ,MTK_WED_RTQM_Q_RST ); +wed_clr (dev,MTK_WED_RTQM_GLO_CFG ,MTK_WED_RTQM_TXDMAD_FPORT ); +wed_set (dev,MTK_WED_RTQM_GLO_CFG , +FIELD_PREP (MTK_WED_RTQM_TXDMAD_FPORT ,0x3 + dev->hw->index)); +wed_clr (dev,MTK_WED_RTQM_GLO_CFG ,MTK_WED_RTQM_Q_RST ); +/* enable RX_ROUTE_QM */ +wed_set (dev,MTK_WED_CTRL ,MTK_WED_CTRL_RX_ROUTE_QM_EN ); +} +static void mtk_wed_hw_init (struct mtk_wed_device *dev) {
@@ -498,11 +842,11 @@ mtk_wed_hw_init(struct mtk_wed_device *dev)wed_w32 (dev,MTK_WED_TX_BM_CTRL ,MTK_WED_TX_BM_CTRL_PAUSE |FIELD_PREP (MTK_WED_TX_BM_CTRL_VLD_GRP_NUM , - dev->buf_ring.size /128 ) | + dev->tx_buf_ring.size /128 ) |FIELD_PREP (MTK_WED_TX_BM_CTRL_RSV_GRP_NUM ,MTK_WED_TX_RING_SIZE /256 )); -wed_w32 (dev,MTK_WED_TX_BM_BASE , dev->buf_ring.desc_phys); +wed_w32 (dev,MTK_WED_TX_BM_BASE , dev->tx_buf_ring.desc_phys);wed_w32 (dev,MTK_WED_TX_BM_BUF_LEN ,MTK_WED_PKT_SIZE );
@@ -529,9 +873,9 @@ mtk_wed_hw_init(struct mtk_wed_device *dev)wed_w32 (dev,MTK_WED_TX_TKID_CTRL ,MTK_WED_TX_TKID_CTRL_PAUSE |FIELD_PREP (MTK_WED_TX_TKID_CTRL_VLD_GRP_NUM , - dev->buf_ring.size /128 ) | + dev->tx_buf_ring.size /128 ) |FIELD_PREP (MTK_WED_TX_TKID_CTRL_RSV_GRP_NUM , - dev->buf_ring.size /128 )); + dev->tx_buf_ring.size /128 ));wed_w32 (dev,MTK_WED_TX_TKID_DYN_THR ,FIELD_PREP (MTK_WED_TX_TKID_DYN_THR_LO ,0 ) |MTK_WED_TX_TKID_DYN_THR_HI );
@@ -539,18 +883,28 @@ mtk_wed_hw_init(struct mtk_wed_device *dev)mtk_wed_reset (dev,MTK_WED_RESET_TX_BM ); -if (dev->hw->version ==1 ) +if (dev->hw->version ==1 ) {wed_set (dev,MTK_WED_CTRL ,MTK_WED_CTRL_WED_TX_BM_EN |MTK_WED_CTRL_WED_TX_FREE_AGENT_EN ); -else + }else {wed_clr (dev,MTK_WED_TX_TKID_CTRL ,MTK_WED_TX_TKID_CTRL_PAUSE ); +/* rx hw init */ +wed_w32 (dev,MTK_WED_WPDMA_RX_D_RST_IDX , +MTK_WED_WPDMA_RX_D_RST_CRX_IDX | +MTK_WED_WPDMA_RX_D_RST_DRV_IDX ); +wed_w32 (dev,MTK_WED_WPDMA_RX_D_RST_IDX ,0 ); + +mtk_wed_rx_buffer_hw_init (dev); +mtk_wed_rro_hw_init (dev); +mtk_wed_route_qm_hw_init (dev); + }wed_clr (dev,MTK_WED_TX_BM_CTRL ,MTK_WED_TX_BM_CTRL_PAUSE ); }static void -mtk_wed_ring_reset (struct mtk_wed_ring *ring,int size) +mtk_wed_ring_reset (struct mtk_wed_ring *ring,int size,bool tx) {void *head = (void *)ring->desc;int i;
@@ -560,7 +914,10 @@ mtk_wed_ring_reset(struct mtk_wed_ring *ring, int size) desc = (struct mtk_wdma_desc *)(head + i * ring->desc_size); desc->buf0 =0 ; - desc->ctrl =cpu_to_le32 (MTK_WDMA_DESC_CTRL_DMA_DONE ); +if (tx) + desc->ctrl =cpu_to_le32 (MTK_WDMA_DESC_CTRL_DMA_DONE ); +else + desc->ctrl =cpu_to_le32 (MTK_WFDMA_DESC_CTRL_TO_HOST ); desc->buf1 =0 ; desc->info =0 ; }
@@ -616,7 +973,8 @@ mtk_wed_reset_dma(struct mtk_wed_device *dev)if (!dev->tx_ring[i].desc)continue ; -mtk_wed_ring_reset (&dev->tx_ring[i],MTK_WED_TX_RING_SIZE ); +mtk_wed_ring_reset (&dev->tx_ring[i],MTK_WED_TX_RING_SIZE , + true); }if (mtk_wed_poll_busy (dev))
@@ -634,6 +992,9 @@ mtk_wed_reset_dma(struct mtk_wed_device *dev)wdma_w32 (dev,MTK_WDMA_RESET_IDX ,MTK_WDMA_RESET_IDX_RX );wdma_w32 (dev,MTK_WDMA_RESET_IDX ,0 ); +if (mtk_wed_get_rx_capa (dev)) +mtk_wdma_rx_reset (dev); +if (busy) {mtk_wed_reset (dev,MTK_WED_RESET_WDMA_INT_AGENT );mtk_wed_reset (dev,MTK_WED_RESET_WDMA_RX_DRV );
@@ -668,12 +1029,11 @@ mtk_wed_reset_dma(struct mtk_wed_device *dev) MTK_WED_WPDMA_RESET_IDX_RX);wed_w32 (dev,MTK_WED_WPDMA_RESET_IDX ,0 ); } - }static int mtk_wed_ring_alloc (struct mtk_wed_device *dev,struct mtk_wed_ring *ring, -int size,u32 desc_size) +int size,u32 desc_size,bool tx) { ring->desc =dma_alloc_coherent (dev->hw->dev, size * desc_size, &ring->desc_phys,GFP_KERNEL );
@@ -682,7 +1042,7 @@ mtk_wed_ring_alloc(struct mtk_wed_device *dev, struct mtk_wed_ring *ring, ring->desc_size = desc_size; ring->size = size; -mtk_wed_ring_reset (ring, size); +mtk_wed_ring_reset (ring, size, tx);return 0 ; }
@@ -691,9 +1051,14 @@ static int mtk_wed_wdma_rx_ring_setup(struct mtk_wed_device *dev, int idx, int size) { u32 desc_size = sizeof(struct mtk_wdma_desc) * dev->hw->version; -struct mtk_wed_ring *wdma = &dev->rx_wdma[idx]; +struct mtk_wed_ring *wdma; + +if (idx >=ARRAY_SIZE (dev->rx_wdma)) +return -EINVAL ; -if (mtk_wed_ring_alloc (dev, wdma,MTK_WED_WDMA_RING_SIZE , desc_size)) + wdma = &dev->rx_wdma[idx]; +if (mtk_wed_ring_alloc (dev, wdma,MTK_WED_WDMA_RING_SIZE , desc_size, + true))return -ENOMEM ; wdma_w32(dev, MTK_WDMA_RING_RX(idx) + MTK_WED_RING_OFS_BASE,
@@ -710,6 +1075,60 @@ mtk_wed_wdma_rx_ring_setup(struct mtk_wed_device *dev, int idx, int size)return 0 ; } +static int +mtk_wed_wdma_tx_ring_setup (struct mtk_wed_device *dev,int idx,int size) +{ +u32 desc_size =sizeof (struct mtk_wdma_desc ) * dev->hw->version; +struct mtk_wed_ring *wdma; + +if (idx >=ARRAY_SIZE (dev->tx_wdma)) +return -EINVAL ; + + wdma = &dev->tx_wdma[idx]; +if (mtk_wed_ring_alloc (dev, wdma,MTK_WED_WDMA_RING_SIZE , desc_size, + true)) +return -ENOMEM ; + +wdma_w32 (dev,MTK_WDMA_RING_TX (idx) +MTK_WED_RING_OFS_BASE , + wdma->desc_phys); +wdma_w32 (dev,MTK_WDMA_RING_TX (idx) +MTK_WED_RING_OFS_COUNT , + size); +wdma_w32 (dev,MTK_WDMA_RING_TX (idx) +MTK_WED_RING_OFS_CPU_IDX ,0 ); +wdma_w32 (dev,MTK_WDMA_RING_TX (idx) +MTK_WED_RING_OFS_DMA_IDX ,0 ); + +if (!idx) { +wed_w32 (dev,MTK_WED_WDMA_RING_TX +MTK_WED_RING_OFS_BASE , + wdma->desc_phys); +wed_w32 (dev,MTK_WED_WDMA_RING_TX +MTK_WED_RING_OFS_COUNT , + size); +wed_w32 (dev,MTK_WED_WDMA_RING_TX +MTK_WED_RING_OFS_CPU_IDX , +0 ); +wed_w32 (dev,MTK_WED_WDMA_RING_TX +MTK_WED_RING_OFS_DMA_IDX , +0 ); + } + +return 0 ; +} + +static void +mtk_wed_ppe_check (struct mtk_wed_device *dev,struct sk_buff *skb, +u32 reason,u32 hash) +{ +struct mtk_eth *eth = dev->hw->eth; +struct ethhdr *eh; + +if (!skb) +return ; + +if (reason !=MTK_PPE_CPU_REASON_HIT_UNBIND_RATE_REACHED ) +return ; + +skb_set_mac_header (skb,0 ); + eh =eth_hdr (skb); + skb->protocol = eh->h_proto; +mtk_ppe_check_skb (eth->ppe[dev->hw->index], skb, hash); +} +static void mtk_wed_configure_irq (struct mtk_wed_device *dev,u32 irq_mask) {
@@ -732,6 +1151,8 @@ mtk_wed_configure_irq(struct mtk_wed_device *dev, u32 irq_mask)wed_clr (dev,MTK_WED_WDMA_INT_CTRL , wdma_mask); }else { + wdma_mask |=FIELD_PREP (MTK_WDMA_INT_MASK_TX_DONE , +GENMASK (1 ,0 ));/* initail tx interrupt trigger */ wed_w32(dev, MTK_WED_WPDMA_INT_CTRL_TX, MTK_WED_WPDMA_INT_CTRL_TX0_DONE_EN |
@@ -750,6 +1171,16 @@ mtk_wed_configure_irq(struct mtk_wed_device *dev, u32 irq_mask)FIELD_PREP (MTK_WED_WPDMA_INT_CTRL_TX_FREE_DONE_TRIG , dev->wlan.txfree_tbit)); +wed_w32 (dev,MTK_WED_WPDMA_INT_CTRL_RX , +MTK_WED_WPDMA_INT_CTRL_RX0_EN | +MTK_WED_WPDMA_INT_CTRL_RX0_CLR | +MTK_WED_WPDMA_INT_CTRL_RX1_EN | +MTK_WED_WPDMA_INT_CTRL_RX1_CLR | +FIELD_PREP (MTK_WED_WPDMA_INT_CTRL_RX0_DONE_TRIG , + dev->wlan.rx_tbit[0 ]) | +FIELD_PREP (MTK_WED_WPDMA_INT_CTRL_RX1_DONE_TRIG , + dev->wlan.rx_tbit[1 ])); +wed_w32 (dev,MTK_WED_WDMA_INT_CLR , wdma_mask); wed_set(dev, MTK_WED_WDMA_INT_CTRL, FIELD_PREP(MTK_WED_WDMA_INT_CTRL_POLL_SRC_SEL,
@@ -787,9 +1218,15 @@ mtk_wed_dma_enable(struct mtk_wed_device *dev)wdma_set (dev,MTK_WDMA_GLO_CFG ,MTK_WDMA_GLO_CFG_RX_INFO3_PRERES ); }else { +int i; +wed_set (dev,MTK_WED_WPDMA_CTRL ,MTK_WED_WPDMA_CTRL_SDL1_FIXED ); +wed_set (dev,MTK_WED_WDMA_GLO_CFG , +MTK_WED_WDMA_GLO_CFG_TX_DRV_EN | +MTK_WED_WDMA_GLO_CFG_TX_DDONE_CHK ); +wed_set (dev,MTK_WED_WPDMA_GLO_CFG ,MTK_WED_WPDMA_GLO_CFG_RX_DRV_R0_PKT_PROC |MTK_WED_WPDMA_GLO_CFG_RX_DRV_R0_CRX_SYNC );
@@ -797,6 +1234,15 @@ mtk_wed_dma_enable(struct mtk_wed_device *dev)wed_clr (dev,MTK_WED_WPDMA_GLO_CFG ,MTK_WED_WPDMA_GLO_CFG_TX_TKID_KEEP |MTK_WED_WPDMA_GLO_CFG_TX_DMAD_DW3_PREV ); + +wed_set (dev,MTK_WED_WPDMA_RX_D_GLO_CFG , +MTK_WED_WPDMA_RX_D_RX_DRV_EN | +FIELD_PREP (MTK_WED_WPDMA_RX_D_RXD_READ_LEN ,0x18 ) | +FIELD_PREP (MTK_WED_WPDMA_RX_D_INIT_PHASE_RXEN_SEL , +0x2 )); + +for (i =0 ; i <MTK_WED_RX_QUEUES ; i++) +mtk_wed_check_wfdma_rx_fill (dev, i); } }
@@ -822,7 +1268,19 @@ mtk_wed_start(struct mtk_wed_device *dev, u32 irq_mask) val |=BIT (0 ) | (BIT (1 ) * !!dev->hw->index);regmap_write (dev->hw->mirror, dev->hw->index *4 , val); }else { -mtk_wed_set_512_support (dev, true); +/* driver set mid ready and only once */ +wed_w32 (dev,MTK_WED_EXT_INT_MASK1 , +MTK_WED_EXT_INT_STATUS_WPDMA_MID_RDY ); +wed_w32 (dev,MTK_WED_EXT_INT_MASK2 , +MTK_WED_EXT_INT_STATUS_WPDMA_MID_RDY ); + +wed_r32 (dev,MTK_WED_EXT_INT_MASK1 ); +wed_r32 (dev,MTK_WED_EXT_INT_MASK2 ); + +if (mtk_wed_rro_cfg (dev)) +return ; + +mtk_wed_set_512_support (dev, dev->wlan.wcid_512); }mtk_wed_dma_enable (dev);
@@ -856,7 +1314,7 @@ mtk_wed_attach(struct mtk_wed_device *dev)if (!hw) {module_put (THIS_MODULE ); ret = -ENODEV ; - goto out; + goto unlock; } device = dev->wlan.bus_type ==MTK_WED_BUS_PCIE
@@ -869,15 +1327,24 @@ mtk_wed_attach(struct mtk_wed_device *dev) dev->dev = hw->dev; dev->irq = hw->irq; dev->wdma_idx = hw->index; + dev->version = hw->version;if (hw->eth->dma_dev == hw->eth->dev &&of_dma_is_coherent (hw->eth->dev->of_node))mtk_eth_set_dma_device (hw->eth, hw->dev); - ret =mtk_wed_buffer_alloc (dev); -if (ret) { -mtk_wed_detach (dev); + ret =mtk_wed_tx_buffer_alloc (dev); +if (ret) goto out; + +if (mtk_wed_get_rx_capa (dev)) { + ret =mtk_wed_rx_buffer_alloc (dev); +if (ret) + goto out; + + ret =mtk_wed_rro_alloc (dev); +if (ret) + goto out; }mtk_wed_hw_init_early (dev);
@@ -886,8 +1353,10 @@ mtk_wed_attach(struct mtk_wed_device *dev) BIT(hw->index), 0); else ret =mtk_wed_wo_init (hw); - out: +if (ret) +mtk_wed_detach (dev); +unlock:mutex_unlock (&hw_lock);return ret;
@@ -910,10 +1379,11 @@ mtk_wed_tx_ring_setup(struct mtk_wed_device *dev, int idx, void __iomem *regs)* WDMA RX. */ -BUG_ON (idx >=ARRAY_SIZE (dev->tx_ring)); +if (WARN_ON (idx >=ARRAY_SIZE (dev->tx_ring))) +return -EINVAL ;if (mtk_wed_ring_alloc (dev, ring,MTK_WED_TX_RING_SIZE , -sizeof (*ring->desc))) +sizeof (*ring->desc), true))return -ENOMEM ;if (mtk_wed_wdma_rx_ring_setup (dev, idx,MTK_WED_WDMA_RING_SIZE ))
@@ -960,6 +1430,37 @@ mtk_wed_txfree_ring_setup(struct mtk_wed_device *dev, void __iomem *regs)return 0 ; } +static int +mtk_wed_rx_ring_setup (struct mtk_wed_device *dev,int idx,void __iomem *regs) +{ +struct mtk_wed_ring *ring = &dev->rx_ring[idx]; + +if (WARN_ON (idx >=ARRAY_SIZE (dev->rx_ring))) +return -EINVAL ; + +if (mtk_wed_ring_alloc (dev, ring,MTK_WED_RX_RING_SIZE , +sizeof (*ring->desc), false)) +return -ENOMEM ; + +if (mtk_wed_wdma_tx_ring_setup (dev, idx,MTK_WED_WDMA_RING_SIZE )) +return -ENOMEM ; + + ring->reg_base =MTK_WED_RING_RX_DATA (idx); + ring->wpdma = regs; + ring->flags |=MTK_WED_RING_CONFIGURED ; + +/* WPDMA -> WED */ +wpdma_rx_w32 (dev, idx,MTK_WED_RING_OFS_BASE , ring->desc_phys); +wpdma_rx_w32 (dev, idx,MTK_WED_RING_OFS_COUNT ,MTK_WED_RX_RING_SIZE ); + +wed_w32 (dev,MTK_WED_WPDMA_RING_RX_DATA (idx) +MTK_WED_RING_OFS_BASE , + ring->desc_phys); +wed_w32 (dev,MTK_WED_WPDMA_RING_RX_DATA (idx) +MTK_WED_RING_OFS_COUNT , +MTK_WED_RX_RING_SIZE ); + +return 0 ; +} +static u32 mtk_wed_irq_get (struct mtk_wed_device *dev,u32 mask) {
@@ -1056,7 +1557,9 @@ void mtk_wed_add_hw(struct device_node *np, struct mtk_eth *eth,static const struct mtk_wed_ops wed_ops = { .attach = mtk_wed_attach, .tx_ring_setup = mtk_wed_tx_ring_setup, + .rx_ring_setup = mtk_wed_rx_ring_setup, .txfree_ring_setup = mtk_wed_txfree_ring_setup, + .msg_update = mtk_wed_mcu_msg_update, .start = mtk_wed_start, .stop = mtk_wed_stop, .reset_dma = mtk_wed_reset_dma,
@@ -1065,6 +1568,7 @@ void mtk_wed_add_hw(struct device_node *np, struct mtk_eth *eth, .irq_get = mtk_wed_irq_get, .irq_set_mask = mtk_wed_irq_set_mask, .detach = mtk_wed_detach, + .ppe_check = mtk_wed_ppe_check, };struct device_node *eth_np = eth->dev->of_node;struct platform_device *pdev;
drivers/net/ethernet/mediatek/mtk_wed.h +19 -0
@@ -86,6 +86,24 @@ wpdma_tx_w32(struct mtk_wed_device *dev, int ring, u32 reg, u32 val)writel (val, dev->tx_ring[ring].wpdma + reg); } +static inline u32 +wpdma_rx_r32 (struct mtk_wed_device *dev,int ring,u32 reg) +{ +if (!dev->rx_ring[ring].wpdma) +return 0 ; + +return readl (dev->rx_ring[ring].wpdma + reg); +} + +static inline void +wpdma_rx_w32 (struct mtk_wed_device *dev,int ring,u32 reg,u32 val) +{ +if (!dev->rx_ring[ring].wpdma) +return ; + +writel (val, dev->rx_ring[ring].wpdma + reg); +} +static inline u32 wpdma_txfree_r32 (struct mtk_wed_device *dev,u32 reg) {
@@ -128,6 +146,7 @@ static inline int mtk_wed_flow_add(int index)static inline void mtk_wed_flow_remove (int index) { } +#endif #ifdef CONFIG_DEBUG_FS
drivers/net/ethernet/mediatek/mtk_wed_mcu.c +37 -8
85 lines not on this page · raw message
drivers/net/ethernet/mediatek/mtk_wed_regs.h +126 -2
198 lines not on this page · raw message
drivers/net/ethernet/mediatek/mtk_wed_wo.h +28 -0
@@ -49,6 +49,10 @@ enum { MTK_WED_WARP_CMD_FLAG_FROM_TO_WO = BIT(2), }; +#define MTK_WED_WO_CPU_MCUSYS_RESET_ADDR 0x15194050 +#define MTK_WED_WO_CPU_WO0_MCUSYS_RESET_MASK 0x20 +#define MTK_WED_WO_CPU_WO1_MCUSYS_RESET_MASK 0x1 +enum {MTK_WED_WO_REGION_EMI ,MTK_WED_WO_REGION_ILM ,
@@ -56,6 +60,28 @@ enum { __MTK_WED_WO_REGION_MAX, }; +enum mtk_wed_wo_state { +MTK_WED_WO_STATE_UNDEFINED , +MTK_WED_WO_STATE_INIT , +MTK_WED_WO_STATE_ENABLE , +MTK_WED_WO_STATE_DISABLE , +MTK_WED_WO_STATE_HALT , +MTK_WED_WO_STATE_GATING , +MTK_WED_WO_STATE_SER_RESET , +MTK_WED_WO_STATE_WF_RESET , +}; + +enum mtk_wed_wo_done_state { +MTK_WED_WOIF_UNDEFINED , +MTK_WED_WOIF_DISABLE_DONE , +MTK_WED_WOIF_TRIGGER_ENABLE , +MTK_WED_WOIF_ENABLE_DONE , +MTK_WED_WOIF_TRIGGER_GATING , +MTK_WED_WOIF_GATING_DONE , +MTK_WED_WOIF_TRIGGER_HALT , +MTK_WED_WOIF_HALT_DONE , +}; +enum mtk_wed_dummy_cr_idx {MTK_WED_DUMMY_CR_FWDL ,MTK_WED_DUMMY_CR_WO_STATUS ,
@@ -247,6 +273,8 @@ void mtk_wed_mcu_rx_unsolicited_event(struct mtk_wed_wo *wo, struct sk_buff *skb);int mtk_wed_mcu_send_msg (struct mtk_wed_wo *wo,int id,int cmd,const void *data,int len,bool wait_resp); +int mtk_wed_mcu_msg_update (struct mtk_wed_device *dev,int id,void *data, +int len);int mtk_wed_mcu_init (struct mtk_wed_wo *wo);int mtk_wed_wo_init (struct mtk_wed_hw *hw);void mtk_wed_wo_deinit (struct mtk_wed_hw *hw);
include/linux/soc/mediatek/mtk_wed.h +75 -1
171 lines not on this page · raw message
Signature · 1 line
2.38.1
Lorenzo Bianconi
maintainerPATCH v3 7/8 net: ethernet: mtk_wed: add rx mib counters
In reply to Lorenzo BianconiIntroduce WED RX MIB counters support available on MT7986a SoC.
--- .../net/ethernet/mediatek/mtk_wed_debugfs.c | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+)
drivers/net/ethernet/mediatek/mtk_wed_debugfs.c +87 -0
@@ -2,6 +2,7 @@/* Copyright (C) 2021 Felix Fietkau <[email protected]> */ #include <linux/seq_file.h> +#include <linux/soc/mediatek/mtk_wed.h> #include "mtk_wed.h" #include "mtk_wed_regs.h"
@@ -18,6 +19,8 @@ enum {DUMP_TYPE_WDMA ,DUMP_TYPE_WPDMA_TX ,DUMP_TYPE_WPDMA_TXFREE , +DUMP_TYPE_WPDMA_RX , + DUMP_TYPE_WED_RRO, };#define DUMP_STR (_str) { _str, 0, DUMP_TYPE_STRING }
@@ -36,6 +39,9 @@ enum {#define DUMP_WPDMA_TX_RING (_n) DUMP_RING("WPDMA_TX" #_n, 0, DUMP_TYPE_WPDMA_TX, _n)#define DUMP_WPDMA_TXFREE_RING DUMP_RING("WPDMA_RX1", 0, DUMP_TYPE_WPDMA_TXFREE) +#define DUMP_WPDMA_RX_RING (_n) DUMP_RING("WPDMA_RX" #_n, 0, DUMP_TYPE_WPDMA_RX, _n) +#define DUMP_WED_RRO_RING (_base)DUMP_RING("WED_RRO_MIOD", MTK_##_base, DUMP_TYPE_WED_RRO) +#define DUMP_WED_RRO_FDBK (_base)DUMP_RING("WED_RRO_FDBK", MTK_##_base, DUMP_TYPE_WED_RRO)static void print_reg_val (struct seq_file *s,const char *name,u32 val)
@@ -57,6 +63,7 @@ dump_wed_regs(struct seq_file *s, struct mtk_wed_device *dev, cur > regs ?"\n" :"" , cur->name);continue ; +case DUMP_TYPE_WED_RRO :case DUMP_TYPE_WED : val =wed_r32 (dev, cur->offset);break ;
@@ -69,6 +76,9 @@ dump_wed_regs(struct seq_file *s, struct mtk_wed_device *dev,case DUMP_TYPE_WPDMA_TXFREE : val =wpdma_txfree_r32 (dev, cur->offset);break ; +case DUMP_TYPE_WPDMA_RX : + val =wpdma_rx_r32 (dev, cur->base, cur->offset); +break ; }print_reg_val (s, cur->name, val); }
@@ -132,6 +142,80 @@ wed_txinfo_show(struct seq_file *s, void *data) }DEFINE_SHOW_ATTRIBUTE (wed_txinfo); +static int +wed_rxinfo_show (struct seq_file *s,void *data) +{ +static const struct reg_dump regs[] = { +DUMP_STR ("WPDMA RX" ), +DUMP_WPDMA_RX_RING (0 ), +DUMP_WPDMA_RX_RING (1 ), + +DUMP_STR ("WPDMA RX" ), +DUMP_WED (WED_WPDMA_RX_D_MIB (0 )), +DUMP_WED_RING (WED_WPDMA_RING_RX_DATA (0 )), +DUMP_WED (WED_WPDMA_RX_D_PROCESSED_MIB (0 )), +DUMP_WED (WED_WPDMA_RX_D_MIB (1 )), +DUMP_WED_RING (WED_WPDMA_RING_RX_DATA (1 )), +DUMP_WED (WED_WPDMA_RX_D_PROCESSED_MIB (1 )), +DUMP_WED (WED_WPDMA_RX_D_COHERENT_MIB ), + +DUMP_STR ("WED RX" ), +DUMP_WED_RING (WED_RING_RX_DATA (0 )), +DUMP_WED_RING (WED_RING_RX_DATA (1 )), + +DUMP_STR ("WED RRO" ), +DUMP_WED_RRO_RING (WED_RROQM_MIOD_CTRL0 ), +DUMP_WED (WED_RROQM_MID_MIB ), +DUMP_WED (WED_RROQM_MOD_MIB ), +DUMP_WED (WED_RROQM_MOD_COHERENT_MIB ), +DUMP_WED_RRO_FDBK (WED_RROQM_FDBK_CTRL0 ), +DUMP_WED (WED_RROQM_FDBK_IND_MIB ), +DUMP_WED (WED_RROQM_FDBK_ENQ_MIB ), +DUMP_WED (WED_RROQM_FDBK_ANC_MIB ), +DUMP_WED (WED_RROQM_FDBK_ANC2H_MIB ), + +DUMP_STR ("WED Route QM" ), +DUMP_WED (WED_RTQM_R2H_MIB (0 )), +DUMP_WED (WED_RTQM_R2Q_MIB (0 )), +DUMP_WED (WED_RTQM_Q2H_MIB (0 )), +DUMP_WED (WED_RTQM_R2H_MIB (1 )), +DUMP_WED (WED_RTQM_R2Q_MIB (1 )), +DUMP_WED (WED_RTQM_Q2H_MIB (1 )), +DUMP_WED (WED_RTQM_Q2N_MIB ), +DUMP_WED (WED_RTQM_Q2B_MIB ), +DUMP_WED (WED_RTQM_PFDBK_MIB ), + +DUMP_STR ("WED WDMA TX" ), +DUMP_WED (WED_WDMA_TX_MIB ), +DUMP_WED_RING (WED_WDMA_RING_TX ), + +DUMP_STR ("WDMA TX" ), +DUMP_WDMA (WDMA_GLO_CFG ), +DUMP_WDMA_RING (WDMA_RING_TX (0 )), +DUMP_WDMA_RING (WDMA_RING_TX (1 )), + +DUMP_STR ("WED RX BM" ), +DUMP_WED (WED_RX_BM_BASE ), +DUMP_WED (WED_RX_BM_RX_DMAD ), +DUMP_WED (WED_RX_BM_PTR ), +DUMP_WED (WED_RX_BM_TKID_MIB ), +DUMP_WED (WED_RX_BM_BLEN ), +DUMP_WED (WED_RX_BM_STS ), +DUMP_WED (WED_RX_BM_INTF2 ), +DUMP_WED (WED_RX_BM_INTF ), +DUMP_WED (WED_RX_BM_ERR_STS ), + }; +struct mtk_wed_hw *hw = s->private; +struct mtk_wed_device *dev = hw->wed_dev; + +if (!dev) +return 0 ; + +dump_wed_regs (s, dev, regs,ARRAY_SIZE (regs)); + +return 0 ; +} +DEFINE_SHOW_ATTRIBUTE (wed_rxinfo);static int mtk_wed_reg_set (void *data,u64 val)
@@ -175,4 +259,7 @@ void mtk_wed_hw_add_debugfs(struct mtk_wed_hw *hw)debugfs_create_u32 ("regidx" ,0600 , dir, &hw->debugfs_reg);debugfs_create_file_unsafe ("regval" ,0600 , dir, hw, &fops_regval);debugfs_create_file_unsafe ("txinfo" ,0400 , dir, hw, &wed_txinfo_fops); +if (hw->version !=1 ) +debugfs_create_file_unsafe ("rxinfo" ,0400 , dir, hw, + &wed_rxinfo_fops); }
Signature · 1 line
2.38.1
Lorenzo Bianconi
maintainerPATCH v3 8/8 MAINTAINERS: update MEDIATEK ETHERNET entry
In reply to Lorenzo BianconiUpdate MEDIATEK ETHERNET driver maintainer file enty adding myself to maintainers list
--- MAINTAINERS | 1 + 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
@@ -12920,6 +12920,7 @@ M: Felix Fietkau <[email protected]> M: John Crispin <[email protected]> M: Sean Wang <[email protected]> M: Mark Lee <[email protected]> +M: Lorenzo Bianconi <[email protected]> L: [email protected] S: Maintained F: drivers/net/ethernet/mediatek/
Signature · 1 line
2.38.1