net: ethernet: mtk_eth_soc: add basic support for MT7988 SoC
Subsystems (5)
v2 cover net: ethernet: mtk_eth_soc: add basic support for MT7988 SoC
The MediaTek MT7988 SoC introduces a new version (3) of the NETSYS block and comes with three instead of two MACs.
The first MAC can be internally connected to a built-in Gigabit Ethernet switch with four 1000M/100M/10M twisted pair user ports.
The second MAC can be internally connected to a built-in 2500Base-T Ethernet PHY.
There are two SerDes units which can be operated in USXGMII, 10GBase-(K)R, 5GBase-R, 2500Base-X, 1000Base-X or SGMII interface mode.
This series adds initial support for NETSYS v3 and the first MAC of the MT7988 SoC connecting the built-in DSA switch.
The switch is supported since commit 110c18bfed414 ("net: dsa: mt7530:
introduce driver for MT7988 built-in switch").
Basic support for the 1000M/100M/10M built-in PHYs connected to the switch ports is present since commit ("98c485eaf509b net: phy: add driver for MediaTek SoC built-in GE PHYs").
Changes since v1:
* Set MTK_MAX_DEVS to 3 instead of converting to dynamic number of Ethernet MACs.
* use mtk_m32 when ever possible
* more small improvements and minor comments addressed
Daniel Golle (3):
dt-bindings: net: mediatek,net: add missing mediatek,mt7621-eth
dt-bindings: net: mediatek,net: add mt7988-eth binding
net: ethernet: mtk_eth_soc: convert clock bitmap to u64
Lorenzo Bianconi (6):
net: ethernet: mtk_eth_soc: add MTK_NETSYS_V1 capability bit
net: ethernet: mtk_eth_soc: increase MAX_DEVS to 3
net: ethernet: mtk_eth_soc: rely on MTK_MAX_DEVS and remove
MTK_MAC_COUNT
net: ethernet: mtk_eth_soc: add MTK_NETSYS_V3 capability bit
net: ethernet: mtk_eth_soc: convert caps in mtk_soc_data struct to u64
net: ethernet: mtk_eth_soc: add basic support for MT7988 SoC
.../devicetree/bindings/net/mediatek,net.yaml | 138 ++++++- drivers/net/ethernet/mediatek/mtk_eth_path.c | 36 +- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 380 ++++++++++++++---- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 327 ++++++++++----- 4 files changed, 678 insertions(+), 203 deletions(-)
Signature · 1 line
2.41.0
PATCH v2 1/9 dt-bindings: net: mediatek,net: add missing mediatek,mt7621-eth
Document the Ethernet controller found in the MediaTek MT7621 MIPS SoC family which is supported by the mtk_eth_soc driver.
--- .../devicetree/bindings/net/mediatek,net.yaml | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/net/mediatek,net.yaml +26 -1
@@ -19,6 +19,7 @@ properties: enum: - mediatek,mt2701-eth - mediatek,mt7623-eth + - mediatek,mt7621-eth - mediatek,mt7622-eth - mediatek,mt7629-eth - mediatek,mt7981-eth
@@ -32,7 +33,7 @@ properties: clock-names: true interrupts: - minItems: 3 + minItems: 1 maxItems: 4 power-domains:
@@ -131,6 +132,30 @@ allOf: mediatek,wed-pcie: false + - if: + properties: + compatible: + contains: + enum: + - mediatek,mt7621-eth + then: + properties: + interrupts: + maxItems: 1 + + clocks: + minItems: 2 + maxItems: 2 + + clock-names: + items: + - const: ethif + - const: fe + + mediatek,wed: false + + mediatek,wed-pcie: false + - if: properties: compatible:
Signature · 1 line
2.41.0
Re: [PATCH v2 net-next 1/9] dt-bindings: net: mediatek,net: add missing mediatek,mt7621-eth
Quoted 6 lines · Daniel Golle
Document the Ethernet controller found in the MediaTek MT7621 MIPS SoC family which is supported by the
mtk_eth_socdriver.Fixes 889bcbdeee57 ("net: ethernet: mediatek: support MT7621 SoC ethernet hardware")Signed-off-by Daniel Golle <[email protected]>---
Best regards,
Krzysztof
PATCH v2 2/9 dt-bindings: net: mediatek,net: add mt7988-eth binding
In reply to Daniel GolleIntroduce DT bindings for the MT7988 SoC to mediatek,net.yaml. The MT7988 SoC got 3 Ethernet MACs operating at a maximum of 10 Gigabit/sec supported by 2 packet processor engines for offloading tasks.
The first MAC is hard-wired to a built-in switch which exposes four 1000Base-T PHYs as user ports.
It also comes with built-in 2500Base-T PHY which can be used with the 2nd GMAC.
The 2nd and 3rd GMAC can be connected to external PHYs or provide SFP(+) cages attached via SGMII, 1000Base-X, 2500Base-X, USXGMII, 5GBase-R or 10GBase-KR.
--- .../devicetree/bindings/net/mediatek,net.yaml | 111 ++++++++++++++++++ 1 file changed, 111 insertions(+)
Documentation/devicetree/bindings/net/mediatek,net.yaml +111 -0
@@ -24,6 +24,7 @@ properties: - mediatek,mt7629-eth - mediatek,mt7981-eth - mediatek,mt7986-eth + - mediatek,mt7988-eth - ralink,rt5350-eth reg:
@@ -71,6 +72,22 @@ properties: A list of phandle to the syscon node that handles the SGMII setup which is required for those SoCs equipped with SGMII. + mediatek,toprgu + $ref: /schemas/types.yaml#/definitions/phandle + description: + Phandle to the mediatek toprgu controller used to provide various clocks + and reset to the system. + + mediatek,usxgmiisys: + $ref: /schemas/types.yaml#/definitions/phandle-array + minItems: 2 + maxItems: 2 + items: + maxItems: 1 + description: + A list of phandle to the syscon node that handles the USXGMII setup which is required for + those SoCs equipped with USXGMII. + mediatek,wed: $ref: /schemas/types.yaml#/definitions/phandle-array minItems: 2
@@ -85,6 +102,21 @@ properties: description: Phandle to the mediatek wed-pcie controller. + mediatek,xfi_pextp: + $ref: /schemas/types.yaml#/definitions/phandle-array + minItems: 2 + maxItems: 2 + items: + maxItems: 1 + description: + A list of phandle to the syscon node that handles the XFI setup which is required for + those SoCs equipped with XFI. + + mediatek,xfi_pll: + $ref: /schemas/types.yaml#/definitions/phandle + description: + Phandle to the XFI PLL unit. + dma-coherent: true mdio-bus:
@@ -315,6 +347,85 @@ allOf: minItems: 2 maxItems: 2 + - if: + properties: + compatible: + contains: + const: mediatek,mt7988-eth + then: + properties: + interrupts: + minItems: 4 + + clocks: + minItems: 34 + maxItems: 34 + + clock-names: + items: + - const: crypto + - const: fe + - const: gp2 + - const: gp1 + - const: gp3 + - const: ethwarp_wocpu2 + - const: ethwarp_wocpu1 + - const: ethwarp_wocpu0 + - const: esw + - const: netsys0 + - const: netsys1 + - const: sgmii_tx250m + - const: sgmii_rx250m + - const: sgmii2_tx250m + - const: sgmii2_rx250m + - const: top_usxgmii0_sel + - const: top_usxgmii1_sel + - const: top_sgm0_sel + - const: top_sgm1_sel + - const: top_xfi_phy0_xtal_sel + - const: top_xfi_phy1_xtal_sel + - const: top_eth_gmii_sel + - const: top_eth_refck_50m_sel + - const: top_eth_sys_200m_sel + - const: top_eth_sys_sel + - const: top_eth_xgmii_sel + - const: top_eth_mii_sel + - const: top_netsys_sel + - const: top_netsys_500m_sel + - const: top_netsys_pao_2x_sel + - const: top_netsys_sync_250m_sel + - const: top_netsys_ppefb_250m_sel + - const: top_netsys_warp_sel + - const: wocpu1 + - const: wocpu0 + - const: xgp1 + - const: xgp2 + - const: xgp3 + + mediatek,sgmiisys: + minItems: 2 + maxItems: 2 + + mediatek,usxgmiisys: + minItems: 2 + maxItems: 2 + + mediatek,xfi_pextp: + minItems: 2 + maxItems: 2 + + mediatek,xfi_pll: + minItems: 1 + maxItems: 1 + + mediatek,infracfg + minItems: 1 + maxItems: 1 + + mediatek,toprgu + minItems: 1 + maxItems: 1 + patternProperties: "^mac@[0-1]$": type: object
Signature · 1 line
2.41.0
Rob Herring
maintainerRe: [PATCH v2 net-next 2/9] dt-bindings: net: mediatek,net: add mt7988-eth binding
Quoted 12 lines · Daniel Golle
Introduce DT bindings for the MT7988 SoC to mediatek,net.yaml. The MT7988 SoC got 3 Ethernet MACs operating at a maximum of 10 Gigabit/sec supported by 2 packet processor engines for offloading tasks.
The first MAC is hard-wired to a built-in switch which exposes four 1000Base-T PHYs as user ports.
It also comes with built-in 2500Base-T PHY which can be used with the 2nd GMAC.
The 2nd and 3rd GMAC can be connected to external PHYs or provide SFP(+) cages attached via SGMII, 1000Base-X, 2500Base-X, USXGMII, 5GBase-R or 10GBase-KR.
Quoted 5 lines
Signed-off-by Daniel Golle <[email protected]>--- .../devicetree/bindings/net/mediatek,net.yaml | 111 ++++++++++++++++++ 1 file changed, 111 insertions(+)
My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13):
yamllint warnings/errors:./Documentation/devicetree/bindings/net/mediatek,net.yaml:76:9: [error] syntax error: could not find expected ':' (syntax)
dtschema/dtc warnings/errors:
make[2]: *** Deleting file 'Documentation/devicetree/bindings/net/mediatek,net.example.dts' Documentation/devicetree/bindings/net/mediatek,net.yaml:76:9: could not find expected ':'
make[2]: *** [Documentation/devicetree/bindings/Makefile:26: Documentation/devicetree/bindings/net/mediatek,net.example.dts] Error 1 make[2]: *** Waiting for unfinished jobs...../Documentation/devicetree/bindings/net/mediatek,net.yaml:76:9: could not find expected ':' /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/net/mediatek,net.yaml: ignoring, error parsing file make[1]: *** [/builds/robherring/dt-review-ci/linux/Makefile:1500: dt_binding_check] Error 2
make: *** [Makefile:234: __sub-make] Error 2
doc reference errors (make refcheckdocs):
The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.
If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:
pip3 install dtschema --upgrade
Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.
Re: [PATCH v2 net-next 2/9] dt-bindings: net: mediatek,net: add mt7988-eth binding
In reply to Daniel GolleQuoted 12 lines · Daniel Golle
Introduce DT bindings for the MT7988 SoC to mediatek,net.yaml. The MT7988 SoC got 3 Ethernet MACs operating at a maximum of 10 Gigabit/sec supported by 2 packet processor engines for offloading tasks.
The first MAC is hard-wired to a built-in switch which exposes four 1000Base-T PHYs as user ports.
It also comes with built-in 2500Base-T PHY which can be used with the 2nd GMAC.
The 2nd and 3rd GMAC can be connected to external PHYs or provide SFP(+) cages attached via SGMII, 1000Base-X, 2500Base-X, USXGMII, 5GBase-R or 10GBase-KR.
Quoted 1 line
Signed-off-by Daniel Golle <[email protected]>
It does not look like you tested the bindings, at least after quick look. Please run make dt_binding_check (see Documentation/devicetree/bindings/writing-schema.rst for instructions). Maybe you need to update your dtschema and yamllint.
Beside that:
1. no underscores in property names.
2. Don't use syscon as an excuse for laziness. PLL is a clock, not syscon.
Best regards,
Krzysztof
PATCH v2 3/9 net: ethernet: mtk_eth_soc: add MTK_NETSYS_V1 capability bit
In reply to Daniel GolleFrom: Lorenzo Bianconi <[email protected]>
Introduce MTK_NETSYS_V1 bit in the device capabilities for MT7621/MT7622/MT7623/MT7628/MT7629 SoCs.
Use !MTK_NETSYS_V1 instead of MTK_NETSYS_V2 in the driver codebase. This is a preliminary patch to introduce support for MT7988 SoC.
--- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 28 ++++++------- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 45 ++++++++++++--------- 2 files changed, 40 insertions(+), 33 deletions(-)
drivers/net/ethernet/mediatek/mtk_eth_soc.c +14 -14
@@ -659,7 +659,7 @@ static void mtk_set_queue_speed(struct mtk_eth *eth, unsigned int idx,FIELD_PREP (MTK_QTX_SCH_MIN_RATE_MAN ,1 ) |FIELD_PREP (MTK_QTX_SCH_MIN_RATE_EXP ,4 ) |MTK_QTX_SCH_LEAKY_BUCKET_SIZE ; -if (!MTK_HAS_CAPS (eth->soc->caps,MTK_NETSYS_V2 )) +if (MTK_HAS_CAPS (eth->soc->caps,MTK_NETSYS_V1 )) val |=MTK_QTX_SCH_LEAKY_BUCKET_EN ;if (IS_ENABLED (CONFIG_SOC_MT7621 )) {
@@ -1037,7 +1037,7 @@ static bool mtk_rx_get_desc(struct mtk_eth *eth, struct mtk_rx_dma_v2 *rxd, rxd->rxd1 =READ_ONCE (dma_rxd->rxd1); rxd->rxd3 =READ_ONCE (dma_rxd->rxd3); rxd->rxd4 =READ_ONCE (dma_rxd->rxd4); -if (MTK_HAS_CAPS (eth->soc->caps,MTK_NETSYS_V2 )) { +if (!MTK_HAS_CAPS (eth->soc->caps,MTK_NETSYS_V1 )) { rxd->rxd5 =READ_ONCE (dma_rxd->rxd5); rxd->rxd6 =READ_ONCE (dma_rxd->rxd6); }
@@ -1095,7 +1095,7 @@ static int mtk_init_fq_dma(struct mtk_eth *eth) txd->txd3 =TX_DMA_PLEN0 (MTK_QDMA_PAGE_SIZE ); txd->txd4 =0 ; -if (MTK_HAS_CAPS (soc->caps,MTK_NETSYS_V2 )) { +if (!MTK_HAS_CAPS (soc->caps,MTK_NETSYS_V1 )) { txd->txd5 =0 ; txd->txd6 =0 ; txd->txd7 =0 ;
@@ -1286,7 +1286,7 @@ static void mtk_tx_set_dma_desc(struct net_device *dev, void *txd,struct mtk_mac *mac =netdev_priv (dev);struct mtk_eth *eth = mac->hw; -if (MTK_HAS_CAPS (eth->soc->caps,MTK_NETSYS_V2 )) +if (!MTK_HAS_CAPS (eth->soc->caps,MTK_NETSYS_V1 ))mtk_tx_set_dma_desc_v2 (dev, txd, info);else mtk_tx_set_dma_desc_v1 (dev, txd, info);
@@ -1935,7 +1935,7 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget,break ;/* find out which mac the packet come from. values start at 1 */ -if (MTK_HAS_CAPS (eth->soc->caps,MTK_NETSYS_V2 )) +if (!MTK_HAS_CAPS (eth->soc->caps,MTK_NETSYS_V1 )) mac =RX_DMA_GET_SPORT_V2 (trxd.rxd5) -1 ;else if (!MTK_HAS_CAPS (eth->soc->caps,MTK_SOC_MT7628 ) && !(trxd.rxd4 &RX_DMA_SPECIAL_TAG ))
@@ -2031,7 +2031,7 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget, skb->dev = netdev; bytes += skb->len; -if (MTK_HAS_CAPS (eth->soc->caps,MTK_NETSYS_V2 )) { +if (!MTK_HAS_CAPS (eth->soc->caps,MTK_NETSYS_V1 )) { reason =FIELD_GET (MTK_RXD5_PPE_CPU_REASON , trxd.rxd5); hash = trxd.rxd5 &MTK_RXD5_FOE_ENTRY ;if (hash !=MTK_RXD5_FOE_ENTRY )
@@ -2367,7 +2367,7 @@ static int mtk_tx_alloc(struct mtk_eth *eth) txd->txd2 = next_ptr; txd->txd3 =TX_DMA_LS0 |TX_DMA_OWNER_CPU ; txd->txd4 =0 ; -if (MTK_HAS_CAPS (soc->caps,MTK_NETSYS_V2 )) { +if (!MTK_HAS_CAPS (soc->caps,MTK_NETSYS_V1 )) { txd->txd5 =0 ; txd->txd6 =0 ; txd->txd7 =0 ;
@@ -2420,7 +2420,7 @@ static int mtk_tx_alloc(struct mtk_eth *eth)FIELD_PREP (MTK_QTX_SCH_MIN_RATE_MAN ,1 ) |FIELD_PREP (MTK_QTX_SCH_MIN_RATE_EXP ,4 ) |MTK_QTX_SCH_LEAKY_BUCKET_SIZE ; -if (!MTK_HAS_CAPS (eth->soc->caps,MTK_NETSYS_V2 )) +if (MTK_HAS_CAPS (eth->soc->caps,MTK_NETSYS_V1 )) val |=MTK_QTX_SCH_LEAKY_BUCKET_EN ;mtk_w32 (eth, val, soc->reg_map->qdma.qtx_sch + ofs); ofs +=MTK_QTX_OFFSET ;
@@ -2556,7 +2556,7 @@ static int mtk_rx_alloc(struct mtk_eth *eth, int ring_no, int rx_flag) rxd->rxd3 =0 ; rxd->rxd4 =0 ; -if (MTK_HAS_CAPS (eth->soc->caps,MTK_NETSYS_V2 )) { +if (!MTK_HAS_CAPS (eth->soc->caps,MTK_NETSYS_V1 )) { rxd->rxd5 =0 ; rxd->rxd6 =0 ; rxd->rxd7 =0 ;
@@ -3104,7 +3104,7 @@ static int mtk_start_dma(struct mtk_eth *eth)MTK_TX_BT_32DWORDS |MTK_NDP_CO_PRO |MTK_RX_2B_OFFSET |MTK_TX_WB_DDONE ; -if (MTK_HAS_CAPS (eth->soc->caps,MTK_NETSYS_V2 )) +if (!MTK_HAS_CAPS (eth->soc->caps,MTK_NETSYS_V1 )) val |=MTK_MUTLI_CNT |MTK_RESV_BUF |MTK_WCOMP_EN |MTK_DMAD_WR_WDONE |MTK_CHK_DDONE_EN |MTK_LEAKY_BUCKET_EN ;
@@ -3516,7 +3516,7 @@ static void mtk_hw_reset(struct mtk_eth *eth) {u32 val; -if (MTK_HAS_CAPS (eth->soc->caps,MTK_NETSYS_V2 )) { +if (!MTK_HAS_CAPS (eth->soc->caps,MTK_NETSYS_V1 )) {regmap_write (eth->ethsys,ETHSYS_FE_RST_CHK_IDLE_EN ,0 ); val =RSTCTRL_PPE0_V2 ; }else {
@@ -3528,7 +3528,7 @@ static void mtk_hw_reset(struct mtk_eth *eth)ethsys_reset (eth,RSTCTRL_ETH |RSTCTRL_FE | val); -if (MTK_HAS_CAPS (eth->soc->caps,MTK_NETSYS_V2 )) +if (!MTK_HAS_CAPS (eth->soc->caps,MTK_NETSYS_V1 ))regmap_write (eth->ethsys,ETHSYS_FE_RST_CHK_IDLE_EN ,0x3ffffff ); }
@@ -3724,7 +3724,7 @@ static int mtk_hw_init(struct mtk_eth *eth, bool reset)else mtk_hw_reset (eth); -if (MTK_HAS_CAPS (eth->soc->caps,MTK_NETSYS_V2 )) { +if (!MTK_HAS_CAPS (eth->soc->caps,MTK_NETSYS_V1 )) {/* Set FE to PDMAv2 if necessary */ val =mtk_r32 (eth,MTK_FE_GLO_MISC );mtk_w32 (eth, val |BIT (4 ),MTK_FE_GLO_MISC );
@@ -3761,7 +3761,7 @@ static int mtk_hw_init(struct mtk_eth *eth, bool reset)*/ val =mtk_r32 (eth,MTK_CDMQ_IG_CTRL );mtk_w32 (eth, val |MTK_CDMQ_STAG_EN ,MTK_CDMQ_IG_CTRL ); -if (!MTK_HAS_CAPS (eth->soc->caps,MTK_NETSYS_V2 )) { +if (MTK_HAS_CAPS (eth->soc->caps,MTK_NETSYS_V1 )) { val =mtk_r32 (eth,MTK_CDMP_IG_CTRL );mtk_w32 (eth, val |MTK_CDMP_STAG_EN ,MTK_CDMP_IG_CTRL );
drivers/net/ethernet/mediatek/mtk_eth_soc.h +26 -19
63 lines not on this page · raw message
Signature · 1 line
2.41.0
Re: [PATCH v2 net-next 3/9] net: ethernet: mtk_eth_soc: add MTK_NETSYS_V1 capability bit
Quoted 6 lines · Daniel Golle
From: Lorenzo Bianconi <[email protected]>
Introduce
MTK_NETSYS_V1bit in the device capabilities for MT7621/MT7622/MT7623/MT7628/MT7629 SoCs.
Use !MTK_NETSYS_V1 instead ofMTK_NETSYS_V2in the driver codebase. This is a preliminary patch to introduce support for MT7988 SoC.
Rather than using capability bits for versions, would it make more sense to use an integer for this, so you can do:
if (eth->soc->netsys_version >= 2) {
version 2 and later stuff
} else {
previous version stuff
}?
I'm just thinking ahead to when we end up with stuff that v1 and v2 need but v3 and later don't.
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Re: [PATCH v2 net-next 3/9] net: ethernet: mtk_eth_soc: add MTK_NETSYS_V1 capability bit
Quoted 17 lines · Daniel Golle
Quoted 6 lines
From: Lorenzo Bianconi <[email protected]>
Introduce
MTK_NETSYS_V1bit in the device capabilities for MT7621/MT7622/MT7623/MT7628/MT7629 SoCs.
Use !MTK_NETSYS_V1 instead ofMTK_NETSYS_V2in the driver codebase. This is a preliminary patch to introduce support for MT7988 SoC.Rather than using capability bits for versions, would it make more sense to use an integer for this, so you can do:
if (eth->soc->netsys_version >= 2) { version 2 and later stuff } else { previous version stuff }
Quoted 4 lines
?
I'm just thinking ahead to when we end up with stuff that v1 and v2 need but v3 and later don't.
ack, I will fix it.
Regards,
Lorenzo
Quoted 5 lines
Signature · 3 lines
-- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
PATCH v2 4/9 net: ethernet: mtk_eth_soc: increase MAX_DEVS to 3
In reply to Daniel GolleFrom: Lorenzo Bianconi <[email protected]>
This is a preliminary patch to add MT7988 SoC support since it runs 3 macs instead of 2.
--- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 6 +++++- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-)
drivers/net/ethernet/mediatek/mtk_eth_soc.c +5 -1
@@ -4030,8 +4030,12 @@ static void mtk_sgmii_destroy(struct mtk_eth *eth) {int i; -for (i =0 ; i <MTK_MAX_DEVS ; i++) +for (i =0 ; i <MTK_MAX_DEVS ; i++) { +if (!eth->sgmii_pcs[i]) +continue ; +mtk_pcs_lynxi_destroy (eth->sgmii_pcs[i]); + } }static int mtk_cleanup (struct mtk_eth *eth)
drivers/net/ethernet/mediatek/mtk_eth_soc.h +2 -2
@@ -1049,8 +1049,8 @@ struct mtk_soc_data {#define MTK_DMA_MONITOR_TIMEOUT msecs_to_jiffies(1000) -/* currently no SoC has more than 2 macs */ -#define MTK_MAX_DEVS 2 +/* currently no SoC has more than 3 macs */ +#define MTK_MAX_DEVS 3/* struct mtk_eth - This is the main datasructure for holding the state * of the driver
Signature · 1 line
2.41.0
Re: [PATCH v2 net-next 4/9] net: ethernet: mtk_eth_soc: increase MAX_DEVS to 3
Quoted 17 lines · Daniel Golle
From: Lorenzo Bianconi <[email protected]>
This is a preliminary patch to add MT7988 SoC support since it runs 3 macs instead of 2.
Signed-off-by Lorenzo Bianconi <[email protected]>Signed-off-by Daniel Golle <[email protected]>--- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 6 +++++- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-)drivers/net/ethernet/mediatek/mtk_eth_soc.c +0
-0
drivers/net/ethernet/mediatek/mtk_eth_soc.c static void mtk_sgmii_destroy(struct mtk_eth *eth) · line 4038
Quoted 10 lines
drivers/net/ethernet/mediatek/mtk_eth_soc.c +5
-1@@ -4030,8 +4030,12 @@ static void mtk_sgmii_destroy(struct mtk_eth *eth) {int i; -for (i =0 ; i <MTK_MAX_DEVS ; i++) +for (i =0 ; i <MTK_MAX_DEVS ; i++) { +if (!eth->sgmii_pcs[i]) +continue ; +mtk_pcs_lynxi_destroy (eth->sgmii_pcs[i]); + }
Please instead arrange for mtk_pcs_lynxi_destroy() to be a no-op if it's passed a NULL pointer, which makes it easier to use in error paths (it means mtk_pcs_lynxi_destroy() can be called without checks - like kfree() etc.)
Since error paths don't get often tested, we need to do as much as possible to make error paths trivial.
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Re: [PATCH v2 net-next 4/9] net: ethernet: mtk_eth_soc: increase MAX_DEVS to 3
Quoted 34 lines · Russell King (Oracle)
Quoted 17 lines · Daniel Golle
From: Lorenzo Bianconi <[email protected]>
This is a preliminary patch to add MT7988 SoC support since it runs 3 macs instead of 2.
Signed-off-by Lorenzo Bianconi <[email protected]>Signed-off-by Daniel Golle <[email protected]>--- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 6 +++++- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-)drivers/net/ethernet/mediatek/mtk_eth_soc.c +0
-0drivers/net/ethernet/mediatek/mtk_eth_soc.c static void mtk_sgmii_destroy(struct mtk_eth *eth) · line 4038
Quoted 10 lines
drivers/net/ethernet/mediatek/mtk_eth_soc.c +5
-1@@ -4030,8 +4030,12 @@ static void mtk_sgmii_destroy(struct mtk_eth *eth) {int i; -for (i =0 ; i <MTK_MAX_DEVS ; i++) +for (i =0 ; i <MTK_MAX_DEVS ; i++) { +if (!eth->sgmii_pcs[i]) +continue ; +mtk_pcs_lynxi_destroy (eth->sgmii_pcs[i]); + }Please instead arrange for
mtk_pcs_lynxi_destroy()to be a no-op if it's passed a NULL pointer, which makes it easier to use in error paths (it meansmtk_pcs_lynxi_destroy()can be called without checks - likekfree()etc.)
Quoted 2 lines
Since error paths don't get often tested, we need to do as much as possible to make error paths trivial.
This is the case already, so the above if-clause can be dropped. I will do so in v3.
PATCH v2 5/9 net: ethernet: mtk_eth_soc: rely on MTK_MAX_DEVS and remove MTK_MAC_COUNT
In reply to Daniel GolleFrom: Lorenzo Bianconi <[email protected]>
Get rid of MTK_MAC_COUNT since it is a duplicated of MTK_MAX_DEVS.
--- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 49 ++++++++++++--------- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 1 - 2 files changed, 27 insertions(+), 23 deletions(-)
drivers/net/ethernet/mediatek/mtk_eth_soc.c +27 -22
@@ -963,7 +963,7 @@ static void mtk_stats_update(struct mtk_eth *eth) {int i; -for (i =0 ; i <MTK_MAC_COUNT ; i++) { +for (i =0 ; i <MTK_MAX_DEVS ; i++) {if (!eth->mac[i] || !eth->mac[i]->hw_stats)continue ;if (spin_trylock (ð->mac[i]->hw_stats->stats_lock)) {
@@ -1468,7 +1468,7 @@ static int mtk_queue_stopped(struct mtk_eth *eth) {int i; -for (i =0 ; i <MTK_MAC_COUNT ; i++) { +for (i =0 ; i <MTK_MAX_DEVS ; i++) {if (!eth->netdev[i])continue ;if (netif_queue_stopped (eth->netdev[i]))
@@ -1482,7 +1482,7 @@ static void mtk_wake_queue(struct mtk_eth *eth) {int i; -for (i =0 ; i <MTK_MAC_COUNT ; i++) { +for (i =0 ; i <MTK_MAX_DEVS ; i++) {if (!eth->netdev[i])continue ;netif_tx_wake_all_queues (eth->netdev[i]);
@@ -1941,7 +1941,7 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget, !(trxd.rxd4 & RX_DMA_SPECIAL_TAG)) mac =RX_DMA_GET_SPORT (trxd.rxd4) -1 ; -if (unlikely (mac <0 || mac >=MTK_MAC_COUNT || +if (unlikely (mac <0 || mac >=MTK_MAX_DEVS || !eth->netdev[mac])) goto release_desc;
@@ -2978,7 +2978,7 @@ static void mtk_dma_free(struct mtk_eth *eth)const struct mtk_soc_data *soc = eth->soc;int i; -for (i =0 ; i <MTK_MAC_COUNT ; i++) +for (i =0 ; i <MTK_MAX_DEVS ; i++)if (eth->netdev[i])netdev_reset_queue (eth->netdev[i]);if (eth->scratch_ring) {
@@ -3132,8 +3132,13 @@ static void mtk_gdm_config(struct mtk_eth *eth, u32 config)if (MTK_HAS_CAPS (eth->soc->caps,MTK_SOC_MT7628 ))return ; -for (i =0 ; i <MTK_MAC_COUNT ; i++) { -u32 val =mtk_r32 (eth,MTK_GDMA_FWD_CFG (i)); +for (i =0 ; i <MTK_MAX_DEVS ; i++) { +u32 val; + +if (!eth->netdev[i]) +continue ; + + val =mtk_r32 (eth,MTK_GDMA_FWD_CFG (i));/* default setup the forward port to send frame to PDMA */ val &= ~0xffff ;
@@ -3143,7 +3148,7 @@ static void mtk_gdm_config(struct mtk_eth *eth, u32 config) val |= config; -if (eth->netdev[i] &&netdev_uses_dsa (eth->netdev[i])) +if (netdev_uses_dsa (eth->netdev[i])) val |=MTK_GDMA_SPECIAL_TAG ;mtk_w32 (eth, val,MTK_GDMA_FWD_CFG (i));
@@ -3745,15 +3750,15 @@ static int mtk_hw_init(struct mtk_eth *eth, bool reset)* up with the more appropriate value when mtk_mac_config call is being * invoked. */ -for (i =0 ; i <MTK_MAC_COUNT ; i++) { +for (i =0 ; i <MTK_MAX_DEVS ; i++) {struct net_device *dev = eth->netdev[i]; -mtk_w32 (eth,MAC_MCR_FORCE_LINK_DOWN ,MTK_MAC_MCR (i)); -if (dev) { -struct mtk_mac *mac =netdev_priv (dev); +if (!dev) +continue ; -mtk_set_mcr_max_rx (mac, dev->mtu +MTK_RX_ETH_HLEN ); - } +mtk_w32 (eth,MAC_MCR_FORCE_LINK_DOWN ,MTK_MAC_MCR (i)); +mtk_set_mcr_max_rx (netdev_priv (dev), + dev->mtu +MTK_RX_ETH_HLEN ); }/* Indicates CDM to parse the MTK special tag from CPU
@@ -3950,7 +3955,7 @@ static void mtk_pending_work(struct work_struct *work)mtk_prepare_for_reset (eth);/* stop all devices to make sure that dma is properly shut down */ -for (i =0 ; i <MTK_MAC_COUNT ; i++) { +for (i =0 ; i <MTK_MAX_DEVS ; i++) {if (!eth->netdev[i] || !netif_running (eth->netdev[i]))continue ;
@@ -3966,8 +3971,8 @@ static void mtk_pending_work(struct work_struct *work)mtk_hw_init (eth, true);/* restart DMA and enable IRQs */ -for (i =0 ; i <MTK_MAC_COUNT ; i++) { -if (!test_bit (i, &restart)) +for (i =0 ; i <MTK_MAX_DEVS ; i++) { +if (!eth->netdev[i] || !test_bit (i, &restart))continue ;if (mtk_open (eth->netdev[i])) {
@@ -3994,7 +3999,7 @@ static int mtk_free_dev(struct mtk_eth *eth) {int i; -for (i =0 ; i <MTK_MAC_COUNT ; i++) { +for (i =0 ; i <MTK_MAX_DEVS ; i++) {if (!eth->netdev[i])continue ;free_netdev (eth->netdev[i]);
@@ -4013,7 +4018,7 @@ static int mtk_unreg_dev(struct mtk_eth *eth) {int i; -for (i =0 ; i <MTK_MAC_COUNT ; i++) { +for (i =0 ; i <MTK_MAX_DEVS ; i++) {struct mtk_mac *mac;if (!eth->netdev[i])continue ;
@@ -4320,7 +4325,7 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) } id =be32_to_cpup (_id); -if (id >=MTK_MAC_COUNT ) { +if (id >=MTK_MAX_DEVS ) {dev_err (eth->dev,"%d is not a valid mac id\n" , id);return -EINVAL ; }
@@ -4465,7 +4470,7 @@ void mtk_eth_set_dma_device(struct mtk_eth *eth, struct device *dma_dev)rtnl_lock (); -for (i =0 ; i <MTK_MAC_COUNT ; i++) { +for (i =0 ; i <MTK_MAX_DEVS ; i++) { dev = eth->netdev[i];if (!dev || !(dev->flags &IFF_UP ))
@@ -4772,7 +4777,7 @@ static int mtk_remove(struct platform_device *pdev)int i;/* stop all devices to make sure that dma is properly shut down */ -for (i =0 ; i <MTK_MAC_COUNT ; i++) { +for (i =0 ; i <MTK_MAX_DEVS ; i++) {if (!eth->netdev[i])continue ;mtk_stop (eth->netdev[i]);
drivers/net/ethernet/mediatek/mtk_eth_soc.h +0 -1
@@ -33,7 +33,6 @@#define MTK_TX_DMA_BUF_LEN_V2 0xffff#define MTK_QDMA_RING_SIZE 2048#define MTK_DMA_SIZE 512 -#define MTK_MAC_COUNT 2#define MTK_RX_ETH_HLEN (ETH_HLEN + ETH_FCS_LEN)#define MTK_RX_HLEN (NET_SKB_PAD + MTK_RX_ETH_HLEN + NET_IP_ALIGN)#define MTK_DMA_DUMMY_DESC 0xffffffff
Signature · 1 line
2.41.0
PATCH v2 6/9 net: ethernet: mtk_eth_soc: add MTK_NETSYS_V3 capability bit
In reply to Daniel GolleFrom: Lorenzo Bianconi <[email protected]>
Introduce MTK_NETSYS_V3 bit in the device capabilities. This is a preliminary patch to introduce support for MT7988 SoC.
--- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 106 ++++++++++++++------ drivers/net/ethernet/mediatek/mtk_eth_soc.h | 45 +++++++-- 2 files changed, 114 insertions(+), 37 deletions(-)
drivers/net/ethernet/mediatek/mtk_eth_soc.c +78 -28
@@ -943,17 +943,32 @@ void mtk_stats_update_mac(struct mtk_mac *mac)mtk_r32 (mac->hw, reg_map->gdm1_cnt +0x20 + offs); hw_stats->rx_flow_control_packets +=mtk_r32 (mac->hw, reg_map->gdm1_cnt +0x24 + offs); - hw_stats->tx_skip += -mtk_r32 (mac->hw, reg_map->gdm1_cnt +0x28 + offs); - hw_stats->tx_collisions += -mtk_r32 (mac->hw, reg_map->gdm1_cnt +0x2c + offs); - hw_stats->tx_bytes += -mtk_r32 (mac->hw, reg_map->gdm1_cnt +0x30 + offs); - stats =mtk_r32 (mac->hw, reg_map->gdm1_cnt +0x34 + offs); -if (stats) - hw_stats->tx_bytes += (stats <<32 ); - hw_stats->tx_packets += -mtk_r32 (mac->hw, reg_map->gdm1_cnt +0x38 + offs); + +if (MTK_HAS_CAPS (eth->soc->caps,MTK_NETSYS_V3 )) { + hw_stats->tx_skip += +mtk_r32 (mac->hw, reg_map->gdm1_cnt +0x50 + offs); + hw_stats->tx_collisions += +mtk_r32 (mac->hw, reg_map->gdm1_cnt +0x54 + offs); + hw_stats->tx_bytes += +mtk_r32 (mac->hw, reg_map->gdm1_cnt +0x40 + offs); + stats =mtk_r32 (mac->hw, reg_map->gdm1_cnt +0x44 + offs); +if (stats) + hw_stats->tx_bytes += (stats <<32 ); + hw_stats->tx_packets += +mtk_r32 (mac->hw, reg_map->gdm1_cnt +0x48 + offs); + }else { + hw_stats->tx_skip += +mtk_r32 (mac->hw, reg_map->gdm1_cnt +0x28 + offs); + hw_stats->tx_collisions += +mtk_r32 (mac->hw, reg_map->gdm1_cnt +0x2c + offs); + hw_stats->tx_bytes += +mtk_r32 (mac->hw, reg_map->gdm1_cnt +0x30 + offs); + stats =mtk_r32 (mac->hw, reg_map->gdm1_cnt +0x34 + offs); +if (stats) + hw_stats->tx_bytes += (stats <<32 ); + hw_stats->tx_packets += +mtk_r32 (mac->hw, reg_map->gdm1_cnt +0x38 + offs); + } }u64_stats_update_end (&hw_stats->syncp);
@@ -1257,7 +1272,10 @@ static void mtk_tx_set_dma_desc_v2(struct net_device *dev, void *txd, data |=TX_DMA_LS0 ;WRITE_ONCE (desc->txd3, data); - data = (mac->id +1 ) <<TX_DMA_FPORT_SHIFT_V2 ;/* forward port */ +if (mac->id ==MTK_GMAC3_ID ) + data =PSE_GDM3_PORT ; +else + data = (mac->id +1 ) <<TX_DMA_FPORT_SHIFT_V2 ;/* forward port */ data |=TX_DMA_SWC_V2 |QID_BITS_V2 (info->qid);WRITE_ONCE (desc->txd4, data);
@@ -1268,6 +1286,9 @@ static void mtk_tx_set_dma_desc_v2(struct net_device *dev, void *txd,/* tx checksum offload */ if (info->csum) data |=TX_DMA_CHKSUM_V2 ; +if (MTK_HAS_CAPS (eth->soc->caps,MTK_NETSYS_V3 ) && +netdev_uses_dsa (dev)) + data |=TX_DMA_SPTAG_V3 ; }WRITE_ONCE (desc->txd5, data);
@@ -1333,8 +1354,7 @@ static int mtk_tx_map(struct sk_buff *skb, struct net_device *dev,mtk_tx_set_dma_desc (dev, itxd, &txd_info); itx_buf->flags |=MTK_TX_FLAGS_SINGLE0 ; - itx_buf->flags |= (!mac->id) ?MTK_TX_FLAGS_FPORT0 : -MTK_TX_FLAGS_FPORT1 ; + itx_buf->mac_id = mac->id;setup_tx_buf (eth, itx_buf, itxd_pdma, txd_info.addr, txd_info.size, k++);
@@ -1382,8 +1402,7 @@ static int mtk_tx_map(struct sk_buff *skb, struct net_device *dev,memset (tx_buf,0 ,sizeof (*tx_buf)); tx_buf->data = (void *)MTK_DMA_DUMMY_DESC ; tx_buf->flags |=MTK_TX_FLAGS_PAGE0 ; - tx_buf->flags |= (!mac->id) ?MTK_TX_FLAGS_FPORT0 : -MTK_TX_FLAGS_FPORT1 ; + tx_buf->mac_id = mac->id;setup_tx_buf (eth, tx_buf, txd_pdma, txd_info.addr, txd_info.size, k++);
@@ -1685,7 +1704,7 @@ static int mtk_xdp_frame_map(struct mtk_eth *eth, struct net_device *dev, }mtk_tx_set_dma_desc (dev, txd, txd_info); - tx_buf->flags |= !mac->id ?MTK_TX_FLAGS_FPORT0 :MTK_TX_FLAGS_FPORT1 ; + tx_buf->mac_id = mac->id; tx_buf->type = dma_map ?MTK_TYPE_XDP_NDO :MTK_TYPE_XDP_TX ; tx_buf->data = (void *)MTK_DMA_DUMMY_DESC ;
@@ -1935,11 +1954,24 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget,break ;/* find out which mac the packet come from. values start at 1 */ -if (!MTK_HAS_CAPS (eth->soc->caps,MTK_NETSYS_V1 )) - mac =RX_DMA_GET_SPORT_V2 (trxd.rxd5) -1 ; -else if (!MTK_HAS_CAPS (eth->soc->caps,MTK_SOC_MT7628 ) && - !(trxd.rxd4 &RX_DMA_SPECIAL_TAG )) +if (!MTK_HAS_CAPS (eth->soc->caps,MTK_NETSYS_V1 )) { +u32 val =RX_DMA_GET_SPORT_V2 (trxd.rxd5); + +switch (val) { +case PSE_GDM1_PORT : +case PSE_GDM2_PORT : + mac = val -1 ; +break ; +case PSE_GDM3_PORT : + mac =MTK_GMAC3_ID ; +break ; +default : +break ; + } + }else if (!MTK_HAS_CAPS (eth->soc->caps,MTK_SOC_MT7628 ) && + !(trxd.rxd4 &RX_DMA_SPECIAL_TAG )) { mac =RX_DMA_GET_SPORT (trxd.rxd4) -1 ; + }if (unlikely (mac <0 || mac >=MTK_MAX_DEVS || !eth->netdev[mac]))
@@ -2161,7 +2193,6 @@ static int mtk_poll_tx_qdma(struct mtk_eth *eth, int budget,while ((cpu != dma) && budget) {u32 next_cpu = desc->txd2; -int mac =0 ; desc =mtk_qdma_phys_to_virt (ring, desc->txd2);if ((desc->txd3 &TX_DMA_OWNER_CPU ) ==0 )
@@ -2169,15 +2200,13 @@ static int mtk_poll_tx_qdma(struct mtk_eth *eth, int budget, tx_buf =mtk_desc_to_tx_buf (ring, desc, eth->soc->txrx.txd_size); -if (tx_buf->flags &MTK_TX_FLAGS_FPORT1 ) - mac =1 ; -if (!tx_buf->data)break ;if (tx_buf->data != (void *)MTK_DMA_DUMMY_DESC ) {if (tx_buf->type ==MTK_TYPE_SKB ) -mtk_poll_tx_done (eth, state, mac, tx_buf->data); +mtk_poll_tx_done (eth, state, tx_buf->mac_id, + tx_buf->data); budget--; }
@@ -3788,7 +3817,24 @@ static int mtk_hw_init(struct mtk_eth *eth, bool reset)mtk_w32 (eth, eth->soc->txrx.rx_irq_done_mask, reg_map->qdma.int_grp +4 );mtk_w32 (eth,0x21021000 ,MTK_FE_INT_GRP ); -if (MTK_HAS_CAPS (eth->soc->caps,MTK_NETSYS_V2 )) { +if (MTK_HAS_CAPS (eth->soc->caps,MTK_NETSYS_V3 )) { +/* PSE should not drop port1, port8 and port9 packets */ +mtk_w32 (eth,0x00000302 ,PSE_DROP_CFG ); + +/* GDM and CDM Threshold */ +mtk_w32 (eth,0x00000707 ,MTK_CDMW0_THRES ); +mtk_w32 (eth,0x00000077 ,MTK_CDMW1_THRES ); + +/* Disable GDM1 RX CRC stripping */ +mtk_m32 (eth,MTK_GDMA_STRP_CRC ,0 ,MTK_GDMA_FWD_CFG (0 )); + +/* PSE GDM3 MIB counter has incorrect hw default values, +* so the driver ought to read clear the values beforehand +* in case ethtool retrieve wrong mib values. +*/ +for (i =0 ; i <0x80 ; i +=0x4 ) +mtk_r32 (eth, reg_map->gdm1_cnt +0x100 + i); + }else if (MTK_HAS_CAPS (eth->soc->caps,MTK_NETSYS_V2 )) {/* PSE should not drop port8 and port9 packets from WDMA Tx */ mtk_w32 (eth,0x00000300 ,PSE_DROP_CFG );
@@ -4362,7 +4408,11 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) }spin_lock_init (&mac->hw_stats->stats_lock);u64_stats_init (&mac->hw_stats->syncp); - mac->hw_stats->reg_offset = id *MTK_STAT_OFFSET ; + +if (MTK_HAS_CAPS (eth->soc->caps,MTK_NETSYS_V3 )) + mac->hw_stats->reg_offset = id *0x80 ; +else + mac->hw_stats->reg_offset = id *0x40 ;/* phylink create */ err =of_get_phy_mode (np, &phy_mode);
drivers/net/ethernet/mediatek/mtk_eth_soc.h +36 -9
93 lines not on this page · raw message
Signature · 1 line
2.41.0
Re: [PATCH v2 net-next 6/9] net: ethernet: mtk_eth_soc: add MTK_NETSYS_V3 capability bit
Review
Quoted 2 lines · daniel golle
(quoted diff) +2
-0+ + if (mtk_has_caps(eth->soc->caps, mtk_netsys_v3)) {
this is a case in point for one of my previous comments...
this code started out believing that testing for mtk_netsys_v2 for v2 features would be sufficient. your first patch ended up having to change that to !v1. how long until this becomes !v1 && !v2 because it gets used on v3 and v4 etc?
this is why i think an integer version field would be a much saner approach.
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Re: [PATCH v2 net-next 6/9] net: ethernet: mtk_eth_soc: add MTK_NETSYS_V3 capability bit
Quoted 6 lines
Review
Quoted 2 lines · daniel golle
(quoted diff) +2
-0+ + if (mtk_has_caps(eth->soc->caps, mtk_netsys_v3)) {this is a case in point for one of my previous comments...
Quoted 7 lines
this code started out believing that testing for
mtk_netsys_v2for v2 features would be sufficient. your first patch ended up having to change that to !v1. how long until this becomes !v1 && !v2 because it gets used on v3 and v4 etc?this is why i think an integer version field would be a much saner approach.
ack, I will fix it.
Regards,
Lorenzo
Quoted 5 lines
Signature · 3 lines
-- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
PATCH v2 7/9 net: ethernet: mtk_eth_soc: convert caps in mtk_soc_data struct to u64
In reply to Daniel GolleFrom: Lorenzo Bianconi <[email protected]>
This is a preliminary patch to introduce support for MT7988 SoC.
--- drivers/net/ethernet/mediatek/mtk_eth_path.c | 22 +++---- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 62 ++++++++++---------- 2 files changed, 42 insertions(+), 42 deletions(-)
drivers/net/ethernet/mediatek/mtk_eth_path.c +11 -11
@@ -15,10 +15,10 @@struct mtk_eth_muxc {const char *name;int cap_bit; -int (*set_path)(struct mtk_eth *eth,int path); +int (*set_path)(struct mtk_eth *eth,u64 path); }; -static const char *mtk_eth_path_name (int path) +static const char *mtk_eth_path_name (u64 path) {switch (path) {case MTK_ETH_PATH_GMAC1_RGMII :
@@ -40,7 +40,7 @@ static const char *mtk_eth_path_name(int path) } } -static int set_mux_gdm1_to_gmac1_esw (struct mtk_eth *eth,int path) +static int set_mux_gdm1_to_gmac1_esw (struct mtk_eth *eth,u64 path) {bool updated = true;u32 val, mask, set;
@@ -71,7 +71,7 @@ static int set_mux_gdm1_to_gmac1_esw(struct mtk_eth *eth, int path)return 0 ; } -static int set_mux_gmac2_gmac0_to_gephy (struct mtk_eth *eth,int path) +static int set_mux_gmac2_gmac0_to_gephy (struct mtk_eth *eth,u64 path) {unsigned int val =0 ;bool updated = true;
@@ -94,7 +94,7 @@ static int set_mux_gmac2_gmac0_to_gephy(struct mtk_eth *eth, int path)return 0 ; } -static int set_mux_u3_gmac2_to_qphy (struct mtk_eth *eth,int path) +static int set_mux_u3_gmac2_to_qphy (struct mtk_eth *eth,u64 path) {unsigned int val =0 , mask =0 , reg =0 ;bool updated = true;
@@ -125,7 +125,7 @@ static int set_mux_u3_gmac2_to_qphy(struct mtk_eth *eth, int path)return 0 ; } -static int set_mux_gmac1_gmac2_to_sgmii_rgmii (struct mtk_eth *eth,int path) +static int set_mux_gmac1_gmac2_to_sgmii_rgmii (struct mtk_eth *eth,u64 path) {unsigned int val =0 ;bool updated = true;
@@ -163,7 +163,7 @@ static int set_mux_gmac1_gmac2_to_sgmii_rgmii(struct mtk_eth *eth, int path)return 0 ; } -static int set_mux_gmac12_to_gephy_sgmii (struct mtk_eth *eth,int path) +static int set_mux_gmac12_to_gephy_sgmii (struct mtk_eth *eth,u64 path) {unsigned int val =0 ;bool updated = true;
@@ -218,7 +218,7 @@ static const struct mtk_eth_muxc mtk_eth_muxc[] = { }, }; -static int mtk_eth_mux_setup (struct mtk_eth *eth,int path) +static int mtk_eth_mux_setup (struct mtk_eth *eth,u64 path) {int i, err =0 ;
@@ -249,7 +249,7 @@ static int mtk_eth_mux_setup(struct mtk_eth *eth, int path)int mtk_gmac_sgmii_path_setup (struct mtk_eth *eth,int mac_id) { -int path; +u64 path; path = (mac_id ==0 ) ?MTK_ETH_PATH_GMAC1_SGMII :MTK_ETH_PATH_GMAC2_SGMII ;
@@ -260,7 +260,7 @@ int mtk_gmac_sgmii_path_setup(struct mtk_eth *eth, int mac_id)int mtk_gmac_gephy_path_setup (struct mtk_eth *eth,int mac_id) { -int path =0 ; +u64 path =0 ;if (mac_id ==1 ) path =MTK_ETH_PATH_GMAC2_GEPHY ;
@@ -274,7 +274,7 @@ int mtk_gmac_gephy_path_setup(struct mtk_eth *eth, int mac_id)int mtk_gmac_rgmii_path_setup (struct mtk_eth *eth,int mac_id) { -int path; +u64 path; path = (mac_id ==0 ) ?MTK_ETH_PATH_GMAC1_RGMII :MTK_ETH_PATH_GMAC2_RGMII ;
drivers/net/ethernet/mediatek/mtk_eth_soc.h +31 -31
82 lines not on this page · raw message
Signature · 1 line
2.41.0
PATCH v2 8/9 net: ethernet: mtk_eth_soc: convert clock bitmap to u64
In reply to Daniel GolleThe to-be-added MT7988 SoC adds many new clocks which need to be controlled by the Ethernet driver, which will result in their total number exceeding 32.
Prepare by converting clock bitmaps into 64-bit types.
--- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 96 +++++++++++---------- 1 file changed, 49 insertions(+), 47 deletions(-)
drivers/net/ethernet/mediatek/mtk_eth_soc.h +49 -47
@@ -666,54 +666,56 @@ enum mtk_clks_map {MTK_CLK_MAX }; -#define MT7623_CLKS_BITMAP (BIT(MTK_CLK_ETHIF) | BIT(MTK_CLK_ESW) | \ - BIT(MTK_CLK_GP1) | BIT(MTK_CLK_GP2) | \ - BIT(MTK_CLK_TRGPLL)) -#define MT7622_CLKS_BITMAP (BIT(MTK_CLK_ETHIF) | BIT(MTK_CLK_ESW) | \ - BIT(MTK_CLK_GP0) | BIT(MTK_CLK_GP1) | \ - BIT(MTK_CLK_GP2) | \ - BIT(MTK_CLK_SGMII_TX_250M) | \ - BIT(MTK_CLK_SGMII_RX_250M) | \ - BIT(MTK_CLK_SGMII_CDR_REF) | \ - BIT(MTK_CLK_SGMII_CDR_FB) | \ - BIT(MTK_CLK_SGMII_CK) | \ - BIT(MTK_CLK_ETH2PLL)) +#define MT7623_CLKS_BITMAP (BIT_ULL(MTK_CLK_ETHIF) | BIT_ULL(MTK_CLK_ESW) | \ + BIT_ULL(MTK_CLK_GP1) | BIT_ULL(MTK_CLK_GP2) | \ + BIT_ULL(MTK_CLK_TRGPLL)) +#define MT7622_CLKS_BITMAP (BIT_ULL(MTK_CLK_ETHIF) | BIT_ULL(MTK_CLK_ESW) | \ + BIT_ULL(MTK_CLK_GP0) | BIT_ULL(MTK_CLK_GP1) | \ + BIT_ULL(MTK_CLK_GP2) | \ + BIT_ULL(MTK_CLK_SGMII_TX_250M) | \ + BIT_ULL(MTK_CLK_SGMII_RX_250M) | \ + BIT_ULL(MTK_CLK_SGMII_CDR_REF) | \ + BIT_ULL(MTK_CLK_SGMII_CDR_FB) | \ + BIT_ULL(MTK_CLK_SGMII_CK) | \ + BIT_ULL(MTK_CLK_ETH2PLL))#define MT7621_CLKS_BITMAP (0)#define MT7628_CLKS_BITMAP (0) -#define MT7629_CLKS_BITMAP (BIT(MTK_CLK_ETHIF) | BIT(MTK_CLK_ESW) | \ - BIT(MTK_CLK_GP0) | BIT(MTK_CLK_GP1) | \ - BIT(MTK_CLK_GP2) | BIT(MTK_CLK_FE) | \ - BIT(MTK_CLK_SGMII_TX_250M) | \ - BIT(MTK_CLK_SGMII_RX_250M) | \ - BIT(MTK_CLK_SGMII_CDR_REF) | \ - BIT(MTK_CLK_SGMII_CDR_FB) | \ - BIT(MTK_CLK_SGMII2_TX_250M) | \ - BIT(MTK_CLK_SGMII2_RX_250M) | \ - BIT(MTK_CLK_SGMII2_CDR_REF) | \ - BIT(MTK_CLK_SGMII2_CDR_FB) | \ - BIT(MTK_CLK_SGMII_CK) | \ - BIT(MTK_CLK_ETH2PLL) | BIT(MTK_CLK_SGMIITOP)) -#define MT7981_CLKS_BITMAP (BIT(MTK_CLK_FE) | BIT(MTK_CLK_GP2) | BIT(MTK_CLK_GP1) | \ - BIT(MTK_CLK_WOCPU0) | \ - BIT(MTK_CLK_SGMII_TX_250M) | \ - BIT(MTK_CLK_SGMII_RX_250M) | \ - BIT(MTK_CLK_SGMII_CDR_REF) | \ - BIT(MTK_CLK_SGMII_CDR_FB) | \ - BIT(MTK_CLK_SGMII2_TX_250M) | \ - BIT(MTK_CLK_SGMII2_RX_250M) | \ - BIT(MTK_CLK_SGMII2_CDR_REF) | \ - BIT(MTK_CLK_SGMII2_CDR_FB) | \ - BIT(MTK_CLK_SGMII_CK)) -#define MT7986_CLKS_BITMAP (BIT(MTK_CLK_FE) | BIT(MTK_CLK_GP2) | BIT(MTK_CLK_GP1) | \ - BIT(MTK_CLK_WOCPU1) | BIT(MTK_CLK_WOCPU0) | \ - BIT(MTK_CLK_SGMII_TX_250M) | \ - BIT(MTK_CLK_SGMII_RX_250M) | \ - BIT(MTK_CLK_SGMII_CDR_REF) | \ - BIT(MTK_CLK_SGMII_CDR_FB) | \ - BIT(MTK_CLK_SGMII2_TX_250M) | \ - BIT(MTK_CLK_SGMII2_RX_250M) | \ - BIT(MTK_CLK_SGMII2_CDR_REF) | \ - BIT(MTK_CLK_SGMII2_CDR_FB)) +#define MT7629_CLKS_BITMAP (BIT_ULL(MTK_CLK_ETHIF) | BIT_ULL(MTK_CLK_ESW) | \ + BIT_ULL(MTK_CLK_GP0) | BIT_ULL(MTK_CLK_GP1) | \ + BIT_ULL(MTK_CLK_GP2) | BIT_ULL(MTK_CLK_FE) | \ + BIT_ULL(MTK_CLK_SGMII_TX_250M) | \ + BIT_ULL(MTK_CLK_SGMII_RX_250M) | \ + BIT_ULL(MTK_CLK_SGMII_CDR_REF) | \ + BIT_ULL(MTK_CLK_SGMII_CDR_FB) | \ + BIT_ULL(MTK_CLK_SGMII2_TX_250M) | \ + BIT_ULL(MTK_CLK_SGMII2_RX_250M) | \ + BIT_ULL(MTK_CLK_SGMII2_CDR_REF) | \ + BIT_ULL(MTK_CLK_SGMII2_CDR_FB) | \ + BIT_ULL(MTK_CLK_SGMII_CK) | \ + BIT_ULL(MTK_CLK_ETH2PLL) | BIT_ULL(MTK_CLK_SGMIITOP)) +#define MT7981_CLKS_BITMAP (BIT_ULL(MTK_CLK_FE) | BIT_ULL(MTK_CLK_GP2) | \ + BIT_ULL(MTK_CLK_GP1) | \ + BIT_ULL(MTK_CLK_WOCPU0) | \ + BIT_ULL(MTK_CLK_SGMII_TX_250M) | \ + BIT_ULL(MTK_CLK_SGMII_RX_250M) | \ + BIT_ULL(MTK_CLK_SGMII_CDR_REF) | \ + BIT_ULL(MTK_CLK_SGMII_CDR_FB) | \ + BIT_ULL(MTK_CLK_SGMII2_TX_250M) | \ + BIT_ULL(MTK_CLK_SGMII2_RX_250M) | \ + BIT_ULL(MTK_CLK_SGMII2_CDR_REF) | \ + BIT_ULL(MTK_CLK_SGMII2_CDR_FB) | \ + BIT_ULL(MTK_CLK_SGMII_CK)) +#define MT7986_CLKS_BITMAP (BIT_ULL(MTK_CLK_FE) | BIT_ULL(MTK_CLK_GP2) | \ + BIT_ULL(MTK_CLK_GP1) | \ + BIT_ULL(MTK_CLK_WOCPU1) | BIT_ULL(MTK_CLK_WOCPU0) | \ + BIT_ULL(MTK_CLK_SGMII_TX_250M) | \ + BIT_ULL(MTK_CLK_SGMII_RX_250M) | \ + BIT_ULL(MTK_CLK_SGMII_CDR_REF) | \ + BIT_ULL(MTK_CLK_SGMII_CDR_FB) | \ + BIT_ULL(MTK_CLK_SGMII2_TX_250M) | \ + BIT_ULL(MTK_CLK_SGMII2_RX_250M) | \ + BIT_ULL(MTK_CLK_SGMII2_CDR_REF) | \ + BIT_ULL(MTK_CLK_SGMII2_CDR_FB))enum mtk_dev_state {MTK_HW_INIT ,
@@ -1056,7 +1058,7 @@ struct mtk_soc_data {const struct mtk_reg_map *reg_map;u32 ana_rgc3;u64 caps; -u32 required_clks; +u64 required_clks;bool required_pctl;u8 offload_version;u8 hash_offset;
Signature · 1 line
2.41.0
PATCH v2 9/9 net: ethernet: mtk_eth_soc: add basic support for MT7988 SoC
In reply to Daniel GolleFrom: Lorenzo Bianconi <[email protected]>
Introduce support for ethernet chip available in MT7988 SoC to mtk_eth_soc driver. As a first step support only the first GMAC which is hard-wired to the internal DSA switch having 4 built-in gigabit Ethernet PHYs.
--- drivers/net/ethernet/mediatek/mtk_eth_path.c | 14 +- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 201 +++++++++++++++++-- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 86 +++++++- 3 files changed, 273 insertions(+), 28 deletions(-)
drivers/net/ethernet/mediatek/mtk_eth_path.c +8 -6
@@ -43,7 +43,7 @@ static const char *mtk_eth_path_name(u64 path)static int set_mux_gdm1_to_gmac1_esw (struct mtk_eth *eth,u64 path) {bool updated = true; -u32 val, mask, set; +u32 mask, set, reg;switch (path) {case MTK_ETH_PATH_GMAC1_SGMII :
@@ -59,11 +59,13 @@ static int set_mux_gdm1_to_gmac1_esw(struct mtk_eth *eth, u64 path)break ; } -if (updated) { - val =mtk_r32 (eth,MTK_MAC_MISC ); - val = (val & mask) | set; -mtk_w32 (eth, val,MTK_MAC_MISC ); - } +if (MTK_HAS_CAPS (eth->soc->caps,MTK_NETSYS_V3 )) + reg =MTK_MAC_MISC_V3 ; +else + reg =MTK_MAC_MISC ; + +if (updated) +mtk_m32 (eth, mask, set, reg);dev_dbg (eth->dev,"path %s in %s updated = %d\n" ,mtk_eth_path_name (path), __func__, updated);
drivers/net/ethernet/mediatek/mtk_eth_soc.c +180 -21
268 lines not on this page · raw message
drivers/net/ethernet/mediatek/mtk_eth_soc.h +85 -1
135 lines not on this page · raw message
Signature · 1 line
2.41.0