Changes in v8:
1. add acked-by in "stmmac: dwmac-mediatek: add platform level clocks
management" patch
Changes in v7:
1. fix uninitialized warning as Jakub's comments.
Changes in v6:
1. update commit message as Jakub's comments.
2. split mt8195 eth dts patch("arm64: dts: mt8195: add ethernet device
node") from this series, since mt8195 dtsi/dts basic patches is still
under reviewing.
https://patchwork.kernel.org/project/linux-mediatek/list/?series=579071
we'll resend mt8195 eth dts patch once all the dependent patches are
accepted.
Changes in v5:
1. remove useless inclusion in dwmac-mediatek.c as Angelo's comments.
2. add acked-by in "net-next: stmmac: dwmac-mediatek: add support for
mt8195" patch
Changes in v4:
1. add changes in commit message in "net-next: dt-bindings: dwmac:
Convert mediatek-dwmac to DT schema" patch.
2. remove ethernet-controller.yaml since snps,dwmac.yaml already include it.
Changes in v3:
1. Add prefix "net-next" to support new IC as Denis's suggestion.
2. Split dt-bindings to two patches, one for conversion, and the other for
new IC.
3. add a new patch to update device node in mt2712-evb.dts to accommodate to
changes in driver.
4. remove unnecessary wrapper as Angelo's suggestion.
5. Add acked-by in "net-next: stmmac: dwmac-mediatek: Reuse more common
features" patch.
Changes in v2:
1. fix errors/warnings in mediatek-dwmac.yaml with upgraded dtschema tools
This series include 5 patches:
1. add platform level clocks management for dwmac-mediatek
2. resue more common features defined in stmmac_platform.c
3. add ethernet entry for mt8195
4. convert mediatek-dwmac.txt to mediatek-dwmac.yaml
Biao Huang (6):
stmmac: dwmac-mediatek: add platform level clocks management
stmmac: dwmac-mediatek: Reuse more common features
arm64: dts: mt2712: update ethernet device node
net: dt-bindings: dwmac: Convert mediatek-dwmac to DT schema
stmmac: dwmac-mediatek: add support for mt8195
net: dt-bindings: dwmac: add support for mt8195
.../bindings/net/mediatek-dwmac.txt | 91 ------
.../bindings/net/mediatek-dwmac.yaml | 210 ++++++++++++
arch/arm64/boot/dts/mediatek/mt2712-evb.dts | 1 +
arch/arm64/boot/dts/mediatek/mt2712e.dtsi | 14 +-
.../ethernet/stmicro/stmmac/dwmac-mediatek.c | 306 ++++++++++++++++--
5 files changed, 503 insertions(+), 119 deletions(-)
delete mode 100644 Documentation/devicetree/bindings/net/mediatek-dwmac.txt
create mode 100644 Documentation/devicetree/bindings/net/mediatek-dwmac.yaml
--
2.18.0
Since there are some changes in ethernet driver,
update ethernet device node in dts to accommodate to it.
Signed-off-by: Biao Huang <redacted>
---
arch/arm64/boot/dts/mediatek/mt2712-evb.dts | 1 +
arch/arm64/boot/dts/mediatek/mt2712e.dtsi | 14 +++++++++-----
2 files changed, 10 insertions(+), 5 deletions(-)
This patch makes dwmac-mediatek reuse more features
supported by stmmac_platform.c.
Signed-off-by: Biao Huang <redacted>
Acked-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
---
.../ethernet/stmicro/stmmac/dwmac-mediatek.c | 32 +++++++++----------
1 file changed, 15 insertions(+), 17 deletions(-)
@@ -334,22 +334,20 @@ static int mediatek_dwmac_init(struct platform_device *pdev, void *priv)conststructmediatek_dwmac_variant*variant=plat->variant;intret;-ret=dma_set_mask_and_coherent(plat->dev,DMA_BIT_MASK(variant->dma_bit_mask));-if(ret){-dev_err(plat->dev,"No suitable DMA available, err = %d\n",ret);-returnret;-}--ret=variant->dwmac_set_phy_interface(plat);-if(ret){-dev_err(plat->dev,"failed to set phy interface, err = %d\n",ret);-returnret;+if(variant->dwmac_set_phy_interface){+ret=variant->dwmac_set_phy_interface(plat);+if(ret){+dev_err(plat->dev,"failed to set phy interface, err = %d\n",ret);+returnret;+}}-ret=variant->dwmac_set_delay(plat);-if(ret){-dev_err(plat->dev,"failed to set delay value, err = %d\n",ret);-returnret;+if(variant->dwmac_set_delay){+ret=variant->dwmac_set_delay(plat);+if(ret){+dev_err(plat->dev,"failed to set delay value, err = %d\n",ret);+returnret;+}}ret=clk_bulk_prepare_enable(plat->num_clks_to_config,plat->clks);
@@ -422,15 +420,15 @@ static int mediatek_dwmac_probe(struct platform_device *pdev)returnPTR_ERR(plat_dat);plat_dat->interface=priv_plat->phy_mode;-plat_dat->has_gmac4=1;-plat_dat->has_gmac=0;-plat_dat->pmt=0;+plat_dat->use_phy_wol=1;plat_dat->riwt_off=1;plat_dat->maxmtu=ETH_DATA_LEN;+plat_dat->addr64=priv_plat->variant->dma_bit_mask;plat_dat->bsp_priv=priv_plat;plat_dat->init=mediatek_dwmac_init;plat_dat->exit=mediatek_dwmac_exit;plat_dat->clks_config=mediatek_dwmac_clks_config;+mediatek_dwmac_init(pdev,priv_plat);ret=stmmac_dvr_probe(&pdev->dev,plat_dat,&stmmac_res);
@@ -19,11 +19,67 @@ select:contains:enum:-mediatek,mt2712-gmac+-mediatek,mt8195-gmacrequired:-compatibleallOf:-$ref:"snps,dwmac.yaml#"+-if:+properties:+compatible:+contains:+enum:+-mediatek,mt2712-gmac++then:+properties:+clocks:+minItems:5+items:+-description:AXI clock+-description:APB clock+-description:MAC Main clock+-description:PTP clock+-description:RMII reference clock provided by MAC++clock-names:+minItems:5+items:+-const:axi+-const:apb+-const:mac_main+-const:ptp_ref+-const:rmii_internal++-if:+properties:+compatible:+contains:+enum:+-mediatek,mt8195-gmac++then:+properties:+clocks:+minItems:6+items:+-description:AXI clock+-description:APB clock+-description:MAC clock gate+-description:MAC Main clock+-description:PTP clock+-description:RMII reference clock provided by MAC++clock-names:+minItems:6+items:+-const:axi+-const:apb+-const:mac_cg+-const:mac_main+-const:ptp_ref+-const:rmii_internalproperties:compatible:
@@ -32,22 +88,10 @@ properties:-enum:-mediatek,mt2712-gmac-const:snps,dwmac-4.20a--clocks:-items:--description:AXI clock--description:APB clock--description:MAC Main clock--description:PTP clock--description:RMII reference clock provided by MAC--clock-names:-items:--const:axi--const:apb--const:mac_main--const:ptp_ref--const:rmii_internal+-items:+-enum:+-mediatek,mt8195-gmac+-const:snps,dwmac-5.10amediatek,pericfg:$ref:/schemas/types.yaml#/definitions/phandle
@@ -62,6 +106,8 @@ properties:or will round down. Range 0~31*170.For MT2712 RMII/MII interface, Allowed value need to be a multiple of 550,or will round down. Range 0~31*550.+For MT8195 RGMII/RMII/MII interface, Allowed value need to be a multiple of 290,+or will round down. Range 0~31*290.mediatek,rx-delay-ps:description:
@@ -70,6 +116,8 @@ properties:or will round down. Range 0~31*170.For MT2712 RMII/MII interface, Allowed value need to be a multiple of 550,or will round down. Range 0~31*550.+For MT8195 RGMII/RMII/MII interface, Allowed value need to be a multiple+of 290, or will round down. Range 0~31*290.mediatek,rmii-rxc:type:boolean
@@ -103,6 +151,12 @@ properties:3. the inside clock, which be sent to MAC, will be inversed in RMII case whenthe reference clock is from MAC.+mediatek,mac-wol:+type:boolean+description:+If present, indicates that MAC supports WOL(Wake-On-LAN), and MAC WOL will be enabled.+Otherwise, PHY WOL is perferred.+required:-compatible-reg
Convert mediatek-dwmac to DT schema, and delete old mediatek-dwmac.txt.
And there are some changes in .yaml than .txt, others almost keep the same:
1. compatible "const: snps,dwmac-4.20".
2. delete "snps,reset-active-low;" in example, since driver remove this
property long ago.
3. add "snps,reset-delay-us = <0 10000 10000>" in example.
4. the example is for rgmii interface, keep related properties only.
Signed-off-by: Biao Huang <redacted>
---
.../bindings/net/mediatek-dwmac.txt | 91 ----------
.../bindings/net/mediatek-dwmac.yaml | 156 ++++++++++++++++++
2 files changed, 156 insertions(+), 91 deletions(-)
delete mode 100644 Documentation/devicetree/bindings/net/mediatek-dwmac.txt
create mode 100644 Documentation/devicetree/bindings/net/mediatek-dwmac.yaml
@@ -1,91 +0,0 @@-MediaTek DWMAC glue layer controller--This file documents platform glue layer for stmmac.-Please see stmmac.txt for the other unchanged properties.--The device node has following properties.--Required properties:-- compatible: Should be "mediatek,mt2712-gmac" for MT2712 SoC-- reg: Address and length of the register set for the device-- interrupts: Should contain the MAC interrupts-- interrupt-names: Should contain a list of interrupt names corresponding to- the interrupts in the interrupts property, if available.- Should be "macirq" for the main MAC IRQ-- clocks: Must contain a phandle for each entry in clock-names.-- clock-names: The name of the clock listed in the clocks property. These are- "axi", "apb", "mac_main", "ptp_ref", "rmii_internal" for MT2712 SoC.-- mac-address: See ethernet.txt in the same directory-- phy-mode: See ethernet.txt in the same directory-- mediatek,pericfg: A phandle to the syscon node that control ethernet- interface and timing delay.--Optional properties:-- mediatek,tx-delay-ps: TX clock delay macro value. Default is 0.- It should be defined for RGMII/MII interface.- It should be defined for RMII interface when the reference clock is from MT2712 SoC.-- mediatek,rx-delay-ps: RX clock delay macro value. Default is 0.- It should be defined for RGMII/MII interface.- It should be defined for RMII interface.-Both delay properties need to be a multiple of 170 for RGMII interface,-or will round down. Range 0~31*170.-Both delay properties need to be a multiple of 550 for MII/RMII interface,-or will round down. Range 0~31*550.--- mediatek,rmii-rxc: boolean property, if present indicates that the RMII- reference clock, which is from external PHYs, is connected to RXC pin- on MT2712 SoC.- Otherwise, is connected to TXC pin.-- mediatek,rmii-clk-from-mac: boolean property, if present indicates that- MT2712 SoC provides the RMII reference clock, which outputs to TXC pin only.-- mediatek,txc-inverse: boolean property, if present indicates that- 1. tx clock will be inversed in MII/RGMII case,- 2. tx clock inside MAC will be inversed relative to reference clock- which is from external PHYs in RMII case, and it rarely happen.- 3. the reference clock, which outputs to TXC pin will be inversed in RMII case- when the reference clock is from MT2712 SoC.-- mediatek,rxc-inverse: boolean property, if present indicates that- 1. rx clock will be inversed in MII/RGMII case.- 2. reference clock will be inversed when arrived at MAC in RMII case, when- the reference clock is from external PHYs.- 3. the inside clock, which be sent to MAC, will be inversed in RMII case when- the reference clock is from MT2712 SoC.-- assigned-clocks: mac_main and ptp_ref clocks-- assigned-clock-parents: parent clocks of the assigned clocks--Example:- eth: ethernet@1101c000 {- compatible = "mediatek,mt2712-gmac";- reg = <0 0x1101c000 0 0x1300>;- interrupts = <GIC_SPI 237 IRQ_TYPE_LEVEL_LOW>;- interrupt-names = "macirq";- phy-mode ="rgmii-rxid";- mac-address = [00 55 7b b5 7d f7];- clock-names = "axi",- "apb",- "mac_main",- "ptp_ref",- "rmii_internal";- clocks = <&pericfg CLK_PERI_GMAC>,- <&pericfg CLK_PERI_GMAC_PCLK>,- <&topckgen CLK_TOP_ETHER_125M_SEL>,- <&topckgen CLK_TOP_ETHER_50M_SEL>,- <&topckgen CLK_TOP_ETHER_50M_RMII_SEL>;- assigned-clocks = <&topckgen CLK_TOP_ETHER_125M_SEL>,- <&topckgen CLK_TOP_ETHER_50M_SEL>,- <&topckgen CLK_TOP_ETHER_50M_RMII_SEL>;- assigned-clock-parents = <&topckgen CLK_TOP_ETHERPLL_125M>,- <&topckgen CLK_TOP_APLL1_D3>,- <&topckgen CLK_TOP_ETHERPLL_50M>;- power-domains = <&scpsys MT2712_POWER_DOMAIN_AUDIO>;- mediatek,pericfg = <&pericfg>;- mediatek,tx-delay-ps = <1530>;- mediatek,rx-delay-ps = <1530>;- mediatek,rmii-rxc;- mediatek,txc-inverse;- mediatek,rxc-inverse;- snps,txpbl = <1>;- snps,rxpbl = <1>;- snps,reset-gpio = <&pio 87 GPIO_ACTIVE_LOW>;- snps,reset-active-low;- };
@@ -0,0 +1,156 @@+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)+%YAML1.2+---+$id:http://devicetree.org/schemas/net/mediatek-dwmac.yaml#+$schema:http://devicetree.org/meta-schemas/core.yaml#++title:MediaTek DWMAC glue layer controller++maintainers:+-Biao Huang <biao.huang@mediatek.com>++description:+This file documents platform glue layer for stmmac.++# We need a select here so we don't match all nodes with 'snps,dwmac'+select:+properties:+compatible:+contains:+enum:+-mediatek,mt2712-gmac+required:+-compatible++allOf:+-$ref:"snps,dwmac.yaml#"++properties:+compatible:+oneOf:+-items:+-enum:+-mediatek,mt2712-gmac+-const:snps,dwmac-4.20a++clocks:+items:+-description:AXI clock+-description:APB clock+-description:MAC Main clock+-description:PTP clock+-description:RMII reference clock provided by MAC++clock-names:+items:+-const:axi+-const:apb+-const:mac_main+-const:ptp_ref+-const:rmii_internal++mediatek,pericfg:+$ref:/schemas/types.yaml#/definitions/phandle+description:+The phandle to the syscon node that control ethernet+interface and timing delay.++mediatek,tx-delay-ps:+description:+The internal TX clock delay (provided by this driver) in nanoseconds.+For MT2712 RGMII interface, Allowed value need to be a multiple of 170,+or will round down. Range 0~31*170.+For MT2712 RMII/MII interface, Allowed value need to be a multiple of 550,+or will round down. Range 0~31*550.++mediatek,rx-delay-ps:+description:+The internal RX clock delay (provided by this driver) in nanoseconds.+For MT2712 RGMII interface, Allowed value need to be a multiple of 170,+or will round down. Range 0~31*170.+For MT2712 RMII/MII interface, Allowed value need to be a multiple of 550,+or will round down. Range 0~31*550.++mediatek,rmii-rxc:+type:boolean+description:+If present, indicates that the RMII reference clock, which is from external+PHYs, is connected to RXC pin. Otherwise, is connected to TXC pin.++mediatek,rmii-clk-from-mac:+type:boolean+description:+If present, indicates that MAC provides the RMII reference clock, which+outputs to TXC pin only.++mediatek,txc-inverse:+type:boolean+description:+If present, indicates that+1. tx clock will be inversed in MII/RGMII case,+2. tx clock inside MAC will be inversed relative to reference clock+which is from external PHYs in RMII case, and it rarely happen.+3. the reference clock, which outputs to TXC pin will be inversed in RMII case+when the reference clock is from MAC.++mediatek,rxc-inverse:+type:boolean+description:+If present, indicates that+1. rx clock will be inversed in MII/RGMII case.+2. reference clock will be inversed when arrived at MAC in RMII case, when+the reference clock is from external PHYs.+3. the inside clock, which be sent to MAC, will be inversed in RMII case when+the reference clock is from MAC.++required:+-compatible+-reg+-interrupts+-interrupt-names+-clocks+-clock-names+-phy-mode+-mediatek,pericfg++unevaluatedProperties:false++examples:+-|+#include <dt-bindings/clock/mt2712-clk.h>+#include <dt-bindings/gpio/gpio.h>+#include <dt-bindings/interrupt-controller/arm-gic.h>+#include <dt-bindings/interrupt-controller/irq.h>+#include <dt-bindings/power/mt2712-power.h>++eth:ethernet@1101c000 {+compatible = "mediatek,mt2712-gmac", "snps,dwmac-4.20a";+reg = <0x1101c000 0x1300>;+interrupts = <GIC_SPI 237 IRQ_TYPE_LEVEL_LOW>;+interrupt-names = "macirq";+phy-mode ="rgmii-rxid";+mac-address = [00 55 7b b5 7d f7];+clock-names = "axi",+"apb",+"mac_main",+"ptp_ref",+"rmii_internal";+clocks = <&pericfg CLK_PERI_GMAC>,+<&pericfg CLK_PERI_GMAC_PCLK>,+<&topckgen CLK_TOP_ETHER_125M_SEL>,+<&topckgen CLK_TOP_ETHER_50M_SEL>,+<&topckgen CLK_TOP_ETHER_50M_RMII_SEL>;+assigned-clocks = <&topckgen CLK_TOP_ETHER_125M_SEL>,+<&topckgen CLK_TOP_ETHER_50M_SEL>,+<&topckgen CLK_TOP_ETHER_50M_RMII_SEL>;+assigned-clock-parents = <&topckgen CLK_TOP_ETHERPLL_125M>,+<&topckgen CLK_TOP_APLL1_D3>,+<&topckgen CLK_TOP_ETHERPLL_50M>;+power-domains = <&scpsys MT2712_POWER_DOMAIN_AUDIO>;+mediatek,pericfg = <&pericfg>;+mediatek,tx-delay-ps = <1530>;+snps,txpbl = <1>;+snps,rxpbl = <1>;+snps,reset-gpio = <&pio 87 GPIO_ACTIVE_LOW>;+snps,reset-delays-us = <0 10000 10000>;+};
@@ -267,6 +300,204 @@ static const struct mediatek_dwmac_variant mt2712_gmac_variant = {.tx_delay_max=17600,};+staticintmt8195_set_interface(structmediatek_dwmac_plat_data*plat)+{+intrmii_clk_from_mac=plat->rmii_clk_from_mac?MT8195_RMII_CLK_SRC_INTERNAL:0;+intrmii_rxc=plat->rmii_rxc?MT8195_RMII_CLK_SRC_RXC:0;+u32intf_val=0;++/* The clock labeled as "rmii_internal" in mt8195_dwmac_clk_l is needed+*onlyinRMII(whenMACprovidesthereferenceclock),anduselessfor+*RGMII/MII/RMII(whenPHYprovidesthereferenceclock).+*num_clks_to_configindicatestherealnumberofclocksshouldbe+*configured,equalsto(plat->variant->num_clks-1)indefaultforallthecase,+*then+1forrmii_clk_from_maccase.+*/+plat->num_clks_to_config=plat->variant->num_clks-1;++/* select phy interface in top control domain */+switch(plat->phy_mode){+casePHY_INTERFACE_MODE_MII:+intf_val|=FIELD_PREP(MT8195_ETH_INTF_SEL,PHY_INTF_MII);+break;+casePHY_INTERFACE_MODE_RMII:+if(plat->rmii_clk_from_mac)+plat->num_clks_to_config++;+intf_val|=(rmii_rxc|rmii_clk_from_mac);+intf_val|=FIELD_PREP(MT8195_ETH_INTF_SEL,PHY_INTF_RMII);+break;+casePHY_INTERFACE_MODE_RGMII:+casePHY_INTERFACE_MODE_RGMII_TXID:+casePHY_INTERFACE_MODE_RGMII_RXID:+casePHY_INTERFACE_MODE_RGMII_ID:+intf_val|=FIELD_PREP(MT8195_ETH_INTF_SEL,PHY_INTF_RGMII);+break;+default:+dev_err(plat->dev,"phy interface not supported\n");+return-EINVAL;+}++/* MT8195 only support external PHY */+intf_val|=MT8195_EXT_PHY_MODE;++regmap_write(plat->peri_regmap,MT8195_PERI_ETH_CTRL0,intf_val);++return0;+}++staticvoidmt8195_delay_ps2stage(structmediatek_dwmac_plat_data*plat)+{+structmac_delay_struct*mac_delay=&plat->mac_delay;++/* 290ps per stage */+mac_delay->tx_delay/=290;+mac_delay->rx_delay/=290;+}++staticvoidmt8195_delay_stage2ps(structmediatek_dwmac_plat_data*plat)+{+structmac_delay_struct*mac_delay=&plat->mac_delay;++/* 290ps per stage */+mac_delay->tx_delay*=290;+mac_delay->rx_delay*=290;+}++staticintmt8195_set_delay(structmediatek_dwmac_plat_data*plat)+{+structmac_delay_struct*mac_delay=&plat->mac_delay;+u32gtxc_delay_val=0,delay_val=0,rmii_delay_val=0;++mt8195_delay_ps2stage(plat);++switch(plat->phy_mode){+casePHY_INTERFACE_MODE_MII:+delay_val|=FIELD_PREP(MT8195_DLY_TXC_ENABLE,!!mac_delay->tx_delay);+delay_val|=FIELD_PREP(MT8195_DLY_TXC_STAGES,mac_delay->tx_delay);+delay_val|=FIELD_PREP(MT8195_DLY_TXC_INV,mac_delay->tx_inv);++delay_val|=FIELD_PREP(MT8195_DLY_RXC_ENABLE,!!mac_delay->rx_delay);+delay_val|=FIELD_PREP(MT8195_DLY_RXC_STAGES,mac_delay->rx_delay);+delay_val|=FIELD_PREP(MT8195_DLY_RXC_INV,mac_delay->rx_inv);+break;+casePHY_INTERFACE_MODE_RMII:+if(plat->rmii_clk_from_mac){+/* case 1: mac provides the rmii reference clock,+*andtheclockoutputtoTXCpin.+*TheegresstimingcanbeadjustedbyRMII_TXCdelaymacrocircuit.+*TheingresstimingcanbeadjustedbyRMII_RXCdelaymacrocircuit.+*/+rmii_delay_val|=FIELD_PREP(MT8195_DLY_RMII_TXC_ENABLE,+!!mac_delay->tx_delay);+rmii_delay_val|=FIELD_PREP(MT8195_DLY_RMII_TXC_STAGES,+mac_delay->tx_delay);+rmii_delay_val|=FIELD_PREP(MT8195_DLY_RMII_TXC_INV,+mac_delay->tx_inv);++rmii_delay_val|=FIELD_PREP(MT8195_DLY_RMII_RXC_ENABLE,+!!mac_delay->rx_delay);+rmii_delay_val|=FIELD_PREP(MT8195_DLY_RMII_RXC_STAGES,+mac_delay->rx_delay);+rmii_delay_val|=FIELD_PREP(MT8195_DLY_RMII_RXC_INV,+mac_delay->rx_inv);+}else{+/* case 2: the rmii reference clock is from external phy,+*andtheproperty"rmii_rxc"indicateswhichpin(TXC/RXC)+*thereferenceclkisconnectedto.Thereferenceclockisa+*receivedsignal,sorx_delay/rx_invareusedtoindicate+*thereferenceclocktimingadjustment+*/+if(plat->rmii_rxc){+/* the rmii reference clock from outside is connected+*toRXCpin,thereferenceclockwillbeadjusted+*byRXCdelaymacrocircuit.+*/+delay_val|=FIELD_PREP(MT8195_DLY_RXC_ENABLE,+!!mac_delay->rx_delay);+delay_val|=FIELD_PREP(MT8195_DLY_RXC_STAGES,+mac_delay->rx_delay);+delay_val|=FIELD_PREP(MT8195_DLY_RXC_INV,+mac_delay->rx_inv);+}else{+/* the rmii reference clock from outside is connected+*toTXCpin,thereferenceclockwillbeadjusted+*byTXCdelaymacrocircuit.+*/+delay_val|=FIELD_PREP(MT8195_DLY_TXC_ENABLE,+!!mac_delay->rx_delay);+delay_val|=FIELD_PREP(MT8195_DLY_TXC_STAGES,+mac_delay->rx_delay);+delay_val|=FIELD_PREP(MT8195_DLY_TXC_INV,+mac_delay->rx_inv);+}+}+break;+casePHY_INTERFACE_MODE_RGMII:+casePHY_INTERFACE_MODE_RGMII_TXID:+casePHY_INTERFACE_MODE_RGMII_RXID:+casePHY_INTERFACE_MODE_RGMII_ID:+gtxc_delay_val|=FIELD_PREP(MT8195_DLY_GTXC_ENABLE,!!mac_delay->tx_delay);+gtxc_delay_val|=FIELD_PREP(MT8195_DLY_GTXC_STAGES,mac_delay->tx_delay);+gtxc_delay_val|=FIELD_PREP(MT8195_DLY_GTXC_INV,mac_delay->tx_inv);++delay_val|=FIELD_PREP(MT8195_DLY_RXC_ENABLE,!!mac_delay->rx_delay);+delay_val|=FIELD_PREP(MT8195_DLY_RXC_STAGES,mac_delay->rx_delay);+delay_val|=FIELD_PREP(MT8195_DLY_RXC_INV,mac_delay->rx_inv);++break;+default:+dev_err(plat->dev,"phy interface not supported\n");+return-EINVAL;+}++regmap_update_bits(plat->peri_regmap,+MT8195_PERI_ETH_CTRL0,+MT8195_RGMII_TXC_PHASE_CTRL|+MT8195_DLY_GTXC_INV|+MT8195_DLY_GTXC_ENABLE|+MT8195_DLY_GTXC_STAGES,+gtxc_delay_val);+regmap_write(plat->peri_regmap,MT8195_PERI_ETH_CTRL1,delay_val);+regmap_write(plat->peri_regmap,MT8195_PERI_ETH_CTRL2,rmii_delay_val);++mt8195_delay_stage2ps(plat);++return0;+}++staticvoidmt8195_fix_mac_speed(void*priv,unsignedintspeed)+{+structmediatek_dwmac_plat_data*priv_plat=priv;++if((phy_interface_mode_is_rgmii(priv_plat->phy_mode))){+/* prefer 2ns fixed delay which is controlled by TXC_PHASE_CTRL,+*whenlinkspeedis1GbpswithRGMIIinterface,+*Fallbacktodelaymacrocircuitfor10/100Mbpslinkspeed.+*/+if(speed==SPEED_1000)+regmap_update_bits(priv_plat->peri_regmap,+MT8195_PERI_ETH_CTRL0,+MT8195_RGMII_TXC_PHASE_CTRL|+MT8195_DLY_GTXC_ENABLE|+MT8195_DLY_GTXC_INV|+MT8195_DLY_GTXC_STAGES,+MT8195_RGMII_TXC_PHASE_CTRL);+else+mt8195_set_delay(priv_plat);+}+}++staticconststructmediatek_dwmac_variantmt8195_gmac_variant={+.dwmac_set_phy_interface=mt8195_set_interface,+.dwmac_set_delay=mt8195_set_delay,+.dwmac_fix_mac_speed=mt8195_fix_mac_speed,+.clk_list=mt8195_dwmac_clk_l,+.num_clks=ARRAY_SIZE(mt8195_dwmac_clk_l),+.dma_bit_mask=35,+.rx_delay_max=9280,+.tx_delay_max=9280,+};+staticintmediatek_dwmac_config_dt(structmediatek_dwmac_plat_data*plat){structmac_delay_struct*mac_delay=&plat->mac_delay;
@@ -307,6 +538,7 @@ static int mediatek_dwmac_config_dt(struct mediatek_dwmac_plat_data *plat)mac_delay->rx_inv=of_property_read_bool(plat->np,"mediatek,rxc-inverse");plat->rmii_rxc=of_property_read_bool(plat->np,"mediatek,rmii-rxc");plat->rmii_clk_from_mac=of_property_read_bool(plat->np,"mediatek,rmii-clk-from-mac");+plat->mac_wol=of_property_read_bool(plat->np,"mediatek,mac-wol");return0;}
@@ -383,6 +615,7 @@ static int mediatek_dwmac_clks_config(void *priv, bool enabled)returnret;}+staticintmediatek_dwmac_probe(structplatform_device*pdev){structmediatek_dwmac_plat_data*priv_plat;
@@ -420,7 +653,7 @@ static int mediatek_dwmac_probe(struct platform_device *pdev)returnPTR_ERR(plat_dat);plat_dat->interface=priv_plat->phy_mode;-plat_dat->use_phy_wol=1;+plat_dat->use_phy_wol=priv_plat->mac_wol?0:1;plat_dat->riwt_off=1;plat_dat->maxmtu=ETH_DATA_LEN;plat_dat->addr64=priv_plat->variant->dma_bit_mask;
@@ -428,7 +661,23 @@ static int mediatek_dwmac_probe(struct platform_device *pdev)plat_dat->init=mediatek_dwmac_init;plat_dat->exit=mediatek_dwmac_exit;plat_dat->clks_config=mediatek_dwmac_clks_config;+if(priv_plat->variant->dwmac_fix_mac_speed)+plat_dat->fix_mac_speed=priv_plat->variant->dwmac_fix_mac_speed;+plat_dat->safety_feat_cfg=devm_kzalloc(&pdev->dev,+sizeof(*plat_dat->safety_feat_cfg),+GFP_KERNEL);+if(!plat_dat->safety_feat_cfg)+return-ENOMEM;+plat_dat->safety_feat_cfg->tsoee=1;+plat_dat->safety_feat_cfg->mrxpee=0;+plat_dat->safety_feat_cfg->mestee=1;+plat_dat->safety_feat_cfg->mrxee=1;+plat_dat->safety_feat_cfg->mtxee=1;+plat_dat->safety_feat_cfg->epsi=0;+plat_dat->safety_feat_cfg->edpp=1;+plat_dat->safety_feat_cfg->prtyen=1;+plat_dat->safety_feat_cfg->tmouten=1;mediatek_dwmac_init(pdev,priv_plat);ret=stmmac_dvr_probe(&pdev->dev,plat_dat,&stmmac_res);
@@ -443,6 +692,8 @@ static int mediatek_dwmac_probe(struct platform_device *pdev)staticconststructof_device_idmediatek_dwmac_match[]={{.compatible="mediatek,mt2712-gmac",.data=&mt2712_gmac_variant},+{.compatible="mediatek,mt8195-gmac",+.data=&mt8195_gmac_variant},{}};
From: Rob Herring <robh@kernel.org> Date: 2021-12-10 14:03:10
On Fri, 10 Dec 2021 09:31:29 +0800, Biao Huang wrote:
Add binding document for the ethernet on mt8195.
Signed-off-by: Biao Huang <redacted>
---
.../bindings/net/mediatek-dwmac.yaml | 86 +++++++++++++++----
1 file changed, 70 insertions(+), 16 deletions(-)
Running 'make dtbs_check' with the schema in this patch gives the
following warnings. Consider if they are expected or the schema is
incorrect. These may not be new warnings.
Note that it is not yet a requirement to have 0 warnings for dtbs_check.
This will change in the future.
Full log is available here: https://patchwork.ozlabs.org/patch/1566168
ethernet@1101c000: clock-names: ['axi', 'apb', 'mac_main', 'ptp_ref'] is too short
arch/arm64/boot/dts/mediatek/mt2712-evb.dt.yaml
ethernet@1101c000: clocks: [[27, 34], [27, 37], [6, 154], [6, 155]] is too short
arch/arm64/boot/dts/mediatek/mt2712-evb.dt.yaml
ethernet@1101c000: compatible: ['mediatek,mt2712-gmac'] does not contain items matching the given schema
arch/arm64/boot/dts/mediatek/mt2712-evb.dt.yaml
ethernet@1101c000: compatible: 'oneOf' conditional failed, one must be fixed:
arch/arm64/boot/dts/mediatek/mt2712-evb.dt.yaml
ethernet@1101c000: Unevaluated properties are not allowed ('compatible', 'reg', 'interrupts', 'interrupt-names', 'mac-address', 'clock-names', 'clocks', 'assigned-clocks', 'assigned-clock-parents', 'power-domains', 'snps,axi-config', 'snps,mtl-rx-config', 'snps,mtl-tx-config', 'snps,txpbl', 'snps,rxpbl', 'clk_csr', 'phy-mode', 'phy-handle', 'snps,reset-gpio', 'mdio' were unexpected)
arch/arm64/boot/dts/mediatek/mt2712-evb.dt.yaml
From: Rob Herring <robh@kernel.org> Date: 2021-12-10 14:03:12
On Fri, 10 Dec 2021 09:31:27 +0800, Biao Huang wrote:
Convert mediatek-dwmac to DT schema, and delete old mediatek-dwmac.txt.
And there are some changes in .yaml than .txt, others almost keep the same:
1. compatible "const: snps,dwmac-4.20".
2. delete "snps,reset-active-low;" in example, since driver remove this
property long ago.
3. add "snps,reset-delay-us = <0 10000 10000>" in example.
4. the example is for rgmii interface, keep related properties only.
Signed-off-by: Biao Huang <redacted>
---
.../bindings/net/mediatek-dwmac.txt | 91 ----------
.../bindings/net/mediatek-dwmac.yaml | 156 ++++++++++++++++++
2 files changed, 156 insertions(+), 91 deletions(-)
delete mode 100644 Documentation/devicetree/bindings/net/mediatek-dwmac.txt
create mode 100644 Documentation/devicetree/bindings/net/mediatek-dwmac.yaml
Running 'make dtbs_check' with the schema in this patch gives the
following warnings. Consider if they are expected or the schema is
incorrect. These may not be new warnings.
Note that it is not yet a requirement to have 0 warnings for dtbs_check.
This will change in the future.
Full log is available here: https://patchwork.ozlabs.org/patch/1566169
ethernet@1101c000: clock-names: ['axi', 'apb', 'mac_main', 'ptp_ref'] is too short
arch/arm64/boot/dts/mediatek/mt2712-evb.dt.yaml
ethernet@1101c000: clocks: [[27, 34], [27, 37], [6, 154], [6, 155]] is too short
arch/arm64/boot/dts/mediatek/mt2712-evb.dt.yaml
ethernet@1101c000: compatible: ['mediatek,mt2712-gmac'] does not contain items matching the given schema
arch/arm64/boot/dts/mediatek/mt2712-evb.dt.yaml
ethernet@1101c000: compatible: 'oneOf' conditional failed, one must be fixed:
arch/arm64/boot/dts/mediatek/mt2712-evb.dt.yaml
ethernet@1101c000: Unevaluated properties are not allowed ('compatible', 'reg', 'interrupts', 'interrupt-names', 'mac-address', 'clock-names', 'clocks', 'power-domains', 'snps,axi-config', 'snps,mtl-rx-config', 'snps,mtl-tx-config', 'snps,txpbl', 'snps,rxpbl', 'clk_csr', 'phy-mode', 'phy-handle', 'snps,reset-gpio', 'mdio' were unexpected)
arch/arm64/boot/dts/mediatek/mt2712-evb.dt.yaml
From: Rob Herring <robh@kernel.org> Date: 2021-12-10 18:49:21
On Fri, Dec 10, 2021 at 09:31:27AM +0800, Biao Huang wrote:
quoted hunk
Convert mediatek-dwmac to DT schema, and delete old mediatek-dwmac.txt.
And there are some changes in .yaml than .txt, others almost keep the same:
1. compatible "const: snps,dwmac-4.20".
2. delete "snps,reset-active-low;" in example, since driver remove this
property long ago.
3. add "snps,reset-delay-us = <0 10000 10000>" in example.
4. the example is for rgmii interface, keep related properties only.
Signed-off-by: Biao Huang <redacted>
---
.../bindings/net/mediatek-dwmac.txt | 91 ----------
.../bindings/net/mediatek-dwmac.yaml | 156 ++++++++++++++++++
2 files changed, 156 insertions(+), 91 deletions(-)
delete mode 100644 Documentation/devicetree/bindings/net/mediatek-dwmac.txt
create mode 100644 Documentation/devicetree/bindings/net/mediatek-dwmac.yaml
@@ -1,91 +0,0 @@-MediaTek DWMAC glue layer controller--This file documents platform glue layer for stmmac.-Please see stmmac.txt for the other unchanged properties.--The device node has following properties.--Required properties:-- compatible: Should be "mediatek,mt2712-gmac" for MT2712 SoC-- reg: Address and length of the register set for the device-- interrupts: Should contain the MAC interrupts-- interrupt-names: Should contain a list of interrupt names corresponding to- the interrupts in the interrupts property, if available.- Should be "macirq" for the main MAC IRQ-- clocks: Must contain a phandle for each entry in clock-names.-- clock-names: The name of the clock listed in the clocks property. These are- "axi", "apb", "mac_main", "ptp_ref", "rmii_internal" for MT2712 SoC.-- mac-address: See ethernet.txt in the same directory-- phy-mode: See ethernet.txt in the same directory-- mediatek,pericfg: A phandle to the syscon node that control ethernet- interface and timing delay.--Optional properties:-- mediatek,tx-delay-ps: TX clock delay macro value. Default is 0.- It should be defined for RGMII/MII interface.- It should be defined for RMII interface when the reference clock is from MT2712 SoC.-- mediatek,rx-delay-ps: RX clock delay macro value. Default is 0.- It should be defined for RGMII/MII interface.- It should be defined for RMII interface.-Both delay properties need to be a multiple of 170 for RGMII interface,-or will round down. Range 0~31*170.-Both delay properties need to be a multiple of 550 for MII/RMII interface,-or will round down. Range 0~31*550.--- mediatek,rmii-rxc: boolean property, if present indicates that the RMII- reference clock, which is from external PHYs, is connected to RXC pin- on MT2712 SoC.- Otherwise, is connected to TXC pin.-- mediatek,rmii-clk-from-mac: boolean property, if present indicates that- MT2712 SoC provides the RMII reference clock, which outputs to TXC pin only.-- mediatek,txc-inverse: boolean property, if present indicates that- 1. tx clock will be inversed in MII/RGMII case,- 2. tx clock inside MAC will be inversed relative to reference clock- which is from external PHYs in RMII case, and it rarely happen.- 3. the reference clock, which outputs to TXC pin will be inversed in RMII case- when the reference clock is from MT2712 SoC.-- mediatek,rxc-inverse: boolean property, if present indicates that- 1. rx clock will be inversed in MII/RGMII case.- 2. reference clock will be inversed when arrived at MAC in RMII case, when- the reference clock is from external PHYs.- 3. the inside clock, which be sent to MAC, will be inversed in RMII case when- the reference clock is from MT2712 SoC.-- assigned-clocks: mac_main and ptp_ref clocks-- assigned-clock-parents: parent clocks of the assigned clocks--Example:- eth: ethernet@1101c000 {- compatible = "mediatek,mt2712-gmac";- reg = <0 0x1101c000 0 0x1300>;- interrupts = <GIC_SPI 237 IRQ_TYPE_LEVEL_LOW>;- interrupt-names = "macirq";- phy-mode ="rgmii-rxid";- mac-address = [00 55 7b b5 7d f7];- clock-names = "axi",- "apb",- "mac_main",- "ptp_ref",- "rmii_internal";- clocks = <&pericfg CLK_PERI_GMAC>,- <&pericfg CLK_PERI_GMAC_PCLK>,- <&topckgen CLK_TOP_ETHER_125M_SEL>,- <&topckgen CLK_TOP_ETHER_50M_SEL>,- <&topckgen CLK_TOP_ETHER_50M_RMII_SEL>;- assigned-clocks = <&topckgen CLK_TOP_ETHER_125M_SEL>,- <&topckgen CLK_TOP_ETHER_50M_SEL>,- <&topckgen CLK_TOP_ETHER_50M_RMII_SEL>;- assigned-clock-parents = <&topckgen CLK_TOP_ETHERPLL_125M>,- <&topckgen CLK_TOP_APLL1_D3>,- <&topckgen CLK_TOP_ETHERPLL_50M>;- power-domains = <&scpsys MT2712_POWER_DOMAIN_AUDIO>;- mediatek,pericfg = <&pericfg>;- mediatek,tx-delay-ps = <1530>;- mediatek,rx-delay-ps = <1530>;- mediatek,rmii-rxc;- mediatek,txc-inverse;- mediatek,rxc-inverse;- snps,txpbl = <1>;- snps,rxpbl = <1>;- snps,reset-gpio = <&pio 87 GPIO_ACTIVE_LOW>;- snps,reset-active-low;- };
@@ -0,0 +1,156 @@+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)+%YAML1.2+---+$id:http://devicetree.org/schemas/net/mediatek-dwmac.yaml#+$schema:http://devicetree.org/meta-schemas/core.yaml#++title:MediaTek DWMAC glue layer controller++maintainers:+-Biao Huang <biao.huang@mediatek.com>++description:+This file documents platform glue layer for stmmac.++# We need a select here so we don't match all nodes with 'snps,dwmac'+select:+properties:+compatible:+contains:+enum:+-mediatek,mt2712-gmac+required:+-compatible++allOf:+-$ref:"snps,dwmac.yaml#"++properties:+compatible:+oneOf:+-items:
Don't need oneOf for 1 entry.
quoted hunk
+ - enum:+ - mediatek,mt2712-gmac+ - const: snps,dwmac-4.20a++ clocks:+ items:+ - description: AXI clock+ - description: APB clock+ - description: MAC Main clock+ - description: PTP clock+ - description: RMII reference clock provided by MAC
Seems you need 'minItems: 4' or are the DT files wrong?
+
+ clock-names:
+ items:
+ - const: axi
+ - const: apb
+ - const: mac_main
+ - const: ptp_ref
+ - const: rmii_internal
+
+ mediatek,pericfg:
+ $ref: /schemas/types.yaml#/definitions/phandle
+ description:
+ The phandle to the syscon node that control ethernet
+ interface and timing delay.
+
+ mediatek,tx-delay-ps:
+ description:
+ The internal TX clock delay (provided by this driver) in nanoseconds.
+ For MT2712 RGMII interface, Allowed value need to be a multiple of 170,
+ or will round down. Range 0~31*170.
+ For MT2712 RMII/MII interface, Allowed value need to be a multiple of 550,
+ or will round down. Range 0~31*550.
+
+ mediatek,rx-delay-ps:
+ description:
+ The internal RX clock delay (provided by this driver) in nanoseconds.
+ For MT2712 RGMII interface, Allowed value need to be a multiple of 170,
+ or will round down. Range 0~31*170.
+ For MT2712 RMII/MII interface, Allowed value need to be a multiple of 550,
+ or will round down. Range 0~31*550.
+
+ mediatek,rmii-rxc:
+ type: boolean
+ description:
+ If present, indicates that the RMII reference clock, which is from external
+ PHYs, is connected to RXC pin. Otherwise, is connected to TXC pin.
+
+ mediatek,rmii-clk-from-mac:
+ type: boolean
+ description:
+ If present, indicates that MAC provides the RMII reference clock, which
+ outputs to TXC pin only.
+
+ mediatek,txc-inverse:
+ type: boolean
+ description:
+ If present, indicates that
+ 1. tx clock will be inversed in MII/RGMII case,
+ 2. tx clock inside MAC will be inversed relative to reference clock
+ which is from external PHYs in RMII case, and it rarely happen.
+ 3. the reference clock, which outputs to TXC pin will be inversed in RMII case
+ when the reference clock is from MAC.
+
+ mediatek,rxc-inverse:
+ type: boolean
+ description:
+ If present, indicates that
+ 1. rx clock will be inversed in MII/RGMII case.
+ 2. reference clock will be inversed when arrived at MAC in RMII case, when
+ the reference clock is from external PHYs.
+ 3. the inside clock, which be sent to MAC, will be inversed in RMII case when
+ the reference clock is from MAC.
+
+required:
+ - compatible
+ - reg
+ - interrupts
+ - interrupt-names
+ - clocks
+ - clock-names
+ - phy-mode
+ - mediatek,pericfg
+
+unevaluatedProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/clock/mt2712-clk.h>
+ #include <dt-bindings/gpio/gpio.h>
+ #include <dt-bindings/interrupt-controller/arm-gic.h>
+ #include <dt-bindings/interrupt-controller/irq.h>
+ #include <dt-bindings/power/mt2712-power.h>
+
+ eth: ethernet@1101c000 {
+ compatible = "mediatek,mt2712-gmac", "snps,dwmac-4.20a";
+ reg = <0x1101c000 0x1300>;
+ interrupts = <GIC_SPI 237 IRQ_TYPE_LEVEL_LOW>;
+ interrupt-names = "macirq";
+ phy-mode ="rgmii-rxid";
+ mac-address = [00 55 7b b5 7d f7];
+ clock-names = "axi",
+ "apb",
+ "mac_main",
+ "ptp_ref",
+ "rmii_internal";
+ clocks = <&pericfg CLK_PERI_GMAC>,
+ <&pericfg CLK_PERI_GMAC_PCLK>,
+ <&topckgen CLK_TOP_ETHER_125M_SEL>,
+ <&topckgen CLK_TOP_ETHER_50M_SEL>,
+ <&topckgen CLK_TOP_ETHER_50M_RMII_SEL>;
+ assigned-clocks = <&topckgen CLK_TOP_ETHER_125M_SEL>,
+ <&topckgen CLK_TOP_ETHER_50M_SEL>,
+ <&topckgen CLK_TOP_ETHER_50M_RMII_SEL>;
+ assigned-clock-parents = <&topckgen CLK_TOP_ETHERPLL_125M>,
+ <&topckgen CLK_TOP_APLL1_D3>,
+ <&topckgen CLK_TOP_ETHERPLL_50M>;
+ power-domains = <&scpsys MT2712_POWER_DOMAIN_AUDIO>;
+ mediatek,pericfg = <&pericfg>;
+ mediatek,tx-delay-ps = <1530>;
+ snps,txpbl = <1>;
+ snps,rxpbl = <1>;
+ snps,reset-gpio = <&pio 87 GPIO_ACTIVE_LOW>;
+ snps,reset-delays-us = <0 10000 10000>;
+ };
--
2.25.1
@@ -62,6 +106,8 @@ properties: or will round down. Range 0~31*170. For MT2712 RMII/MII interface, Allowed value need to be a multiple of 550, or will round down. Range 0~31*550.+ For MT8195 RGMII/RMII/MII interface, Allowed value need to be a multiple of 290,+ or will round down. Range 0~31*290. mediatek,rx-delay-ps: description:
@@ -70,6 +116,8 @@ properties: or will round down. Range 0~31*170. For MT2712 RMII/MII interface, Allowed value need to be a multiple of 550, or will round down. Range 0~31*550.+ For MT8195 RGMII/RMII/MII interface, Allowed value need to be a multiple+ of 290, or will round down. Range 0~31*290. mediatek,rmii-rxc: type: boolean
@@ -103,6 +151,12 @@ properties: 3. the inside clock, which be sent to MAC, will be inversed in RMII case when the reference clock is from MAC.+ mediatek,mac-wol:+ type: boolean+ description:+ If present, indicates that MAC supports WOL(Wake-On-LAN), and MAC WOL will be enabled.+ Otherwise, PHY WOL is perferred.+ required: - compatible - reg
@@ -19,11 +19,67 @@ select:contains:enum:-mediatek,mt2712-gmac+-mediatek,mt8195-gmacrequired:-compatibleallOf:-$ref:"snps,dwmac.yaml#"+-if:+properties:+compatible:+contains:+enum:+-mediatek,mt2712-gmac++then:+properties:+clocks:+minItems:5+items:+-description:AXI clock+-description:APB clock+-description:MAC Main clock+-description:PTP clock+-description:RMII reference clock provided by MAC++clock-names:+minItems:5+items:+-const:axi+-const:apb+-const:mac_main+-const:ptp_ref+-const:rmii_internal++-if:+properties:+compatible:+contains:+enum:+-mediatek,mt8195-gmac++then:+properties:+clocks:+minItems:6+items:+-description:AXI clock+-description:APB clock+-description:MAC clock gate
Add new clocks on to the end of existing clocks. That will simplify
the
binding as here you will just need 'minItems: 6'.
The "rmii_internal" clock is a special one we put it to the end on
purpose, and will turn it on/off in driver according to whether
phy_mode is rmii or not.
So the "mac_cg" clock, which is new for mt8195, and not used in mt2712,
can't put it to the end for simplicity.
Can we just keep it this way? or other suggestions?
[v3 reply]
http://lists.infradead.org/pipermail/linux-mediatek/2021-November/031951.html
@@ -62,6 +106,8 @@ properties: or will round down. Range 0~31*170. For MT2712 RMII/MII interface, Allowed value need to be a
multiple of 550,
or will round down. Range 0~31*550.
+ For MT8195 RGMII/RMII/MII interface, Allowed value need to
be a multiple of 290,
+ or will round down. Range 0~31*290.
mediatek,rx-delay-ps:
description:
@@ -70,6 +116,8 @@ properties: or will round down. Range 0~31*170. For MT2712 RMII/MII interface, Allowed value need to be a
multiple of 550,
or will round down. Range 0~31*550.
+ For MT8195 RGMII/RMII/MII interface, Allowed value need to
be a multiple
+ of 290, or will round down. Range 0~31*290.
mediatek,rmii-rxc:
type: boolean
@@ -103,6 +151,12 @@ properties: 3. the inside clock, which be sent to MAC, will be inversed
in RMII case when
the reference clock is from MAC.
+ mediatek,mac-wol:
+ type: boolean
+ description:
+ If present, indicates that MAC supports WOL(Wake-On-LAN),
and MAC WOL will be enabled.
+ Otherwise, PHY WOL is perferred.
+
required:
- compatible
- reg
--
2.25.1
Dear Rob,
Thanks for your comments~
On Fri, 2021-12-10 at 12:49 -0600, Rob Herring wrote:
On Fri, Dec 10, 2021 at 09:31:27AM +0800, Biao Huang wrote:
quoted
Convert mediatek-dwmac to DT schema, and delete old mediatek-
dwmac.txt.
And there are some changes in .yaml than .txt, others almost keep
the same:
1. compatible "const: snps,dwmac-4.20".
2. delete "snps,reset-active-low;" in example, since driver
remove this
property long ago.
3. add "snps,reset-delay-us = <0 10000 10000>" in example.
4. the example is for rgmii interface, keep related properties
only.
Signed-off-by: Biao Huang <redacted>
---
.../bindings/net/mediatek-dwmac.txt | 91 ----------
.../bindings/net/mediatek-dwmac.yaml | 156
++++++++++++++++++
2 files changed, 156 insertions(+), 91 deletions(-)
delete mode 100644 Documentation/devicetree/bindings/net/mediatek-
dwmac.txt
create mode 100644 Documentation/devicetree/bindings/net/mediatek-
dwmac.yaml
@@ -1,91 +0,0 @@-MediaTek DWMAC glue layer controller--This file documents platform glue layer for stmmac.-Please see stmmac.txt for the other unchanged properties.--The device node has following properties.--Required properties:-- compatible: Should be "mediatek,mt2712-gmac" for MT2712 SoC-- reg: Address and length of the register set for the device-- interrupts: Should contain the MAC interrupts-- interrupt-names: Should contain a list of interrupt names
corresponding to
- the interrupts in the interrupts property, if available.
- Should be "macirq" for the main MAC IRQ
-- clocks: Must contain a phandle for each entry in clock-names.
-- clock-names: The name of the clock listed in the clocks
property. These are
- "axi", "apb", "mac_main", "ptp_ref", "rmii_internal" for MT2712
SoC.
-- mac-address: See ethernet.txt in the same directory
-- phy-mode: See ethernet.txt in the same directory
-- mediatek,pericfg: A phandle to the syscon node that control
ethernet
- interface and timing delay.
-
-Optional properties:
-- mediatek,tx-delay-ps: TX clock delay macro value. Default is 0.
- It should be defined for RGMII/MII interface.
- It should be defined for RMII interface when the reference
clock is from MT2712 SoC.
-- mediatek,rx-delay-ps: RX clock delay macro value. Default is 0.
- It should be defined for RGMII/MII interface.
- It should be defined for RMII interface.
-Both delay properties need to be a multiple of 170 for RGMII
interface,
-or will round down. Range 0~31*170.
-Both delay properties need to be a multiple of 550 for MII/RMII
interface,
-or will round down. Range 0~31*550.
-
-- mediatek,rmii-rxc: boolean property, if present indicates that
the RMII
- reference clock, which is from external PHYs, is connected to
RXC pin
- on MT2712 SoC.
- Otherwise, is connected to TXC pin.
-- mediatek,rmii-clk-from-mac: boolean property, if present
indicates that
- MT2712 SoC provides the RMII reference clock, which outputs to
TXC pin only.
-- mediatek,txc-inverse: boolean property, if present indicates
that
- 1. tx clock will be inversed in MII/RGMII case,
- 2. tx clock inside MAC will be inversed relative to reference
clock
- which is from external PHYs in RMII case, and it rarely
happen.
- 3. the reference clock, which outputs to TXC pin will be
inversed in RMII case
- when the reference clock is from MT2712 SoC.
-- mediatek,rxc-inverse: boolean property, if present indicates
that
- 1. rx clock will be inversed in MII/RGMII case.
- 2. reference clock will be inversed when arrived at MAC in RMII
case, when
- the reference clock is from external PHYs.
- 3. the inside clock, which be sent to MAC, will be inversed in
RMII case when
- the reference clock is from MT2712 SoC.
-- assigned-clocks: mac_main and ptp_ref clocks
-- assigned-clock-parents: parent clocks of the assigned clocks
-
-Example:
- eth: ethernet@1101c000 {
- compatible = "mediatek,mt2712-gmac";
- reg = <0 0x1101c000 0 0x1300>;
- interrupts = <GIC_SPI 237 IRQ_TYPE_LEVEL_LOW>;
- interrupt-names = "macirq";
- phy-mode ="rgmii-rxid";
- mac-address = [00 55 7b b5 7d f7];
- clock-names = "axi",
- "apb",
- "mac_main",
- "ptp_ref",
- "rmii_internal";
- clocks = <&pericfg CLK_PERI_GMAC>,
- <&pericfg CLK_PERI_GMAC_PCLK>,
- <&topckgen CLK_TOP_ETHER_125M_SEL>,
- <&topckgen CLK_TOP_ETHER_50M_SEL>,
- <&topckgen CLK_TOP_ETHER_50M_RMII_SEL>;
- assigned-clocks = <&topckgen CLK_TOP_ETHER_125M_SEL>,
- <&topckgen CLK_TOP_ETHER_50M_SEL>,
- <&topckgen
CLK_TOP_ETHER_50M_RMII_SEL>;
- assigned-clock-parents = <&topckgen
CLK_TOP_ETHERPLL_125M>,
- <&topckgen CLK_TOP_APLL1_D3>,
- <&topckgen
CLK_TOP_ETHERPLL_50M>;
- power-domains = <&scpsys MT2712_POWER_DOMAIN_AUDIO>;
- mediatek,pericfg = <&pericfg>;
- mediatek,tx-delay-ps = <1530>;
- mediatek,rx-delay-ps = <1530>;
- mediatek,rmii-rxc;
- mediatek,txc-inverse;
- mediatek,rxc-inverse;
- snps,txpbl = <1>;
- snps,rxpbl = <1>;
- snps,reset-gpio = <&pio 87 GPIO_ACTIVE_LOW>;
- snps,reset-active-low;
- };
@@ -0,0 +1,156 @@+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)+%YAML1.2+---+$id:http://devicetree.org/schemas/net/mediatek-dwmac.yaml#+$schema:http://devicetree.org/meta-schemas/core.yaml#++title:MediaTek DWMAC glue layer controller++maintainers:+-Biao Huang <biao.huang@mediatek.com>++description:+This file documents platform glue layer for stmmac.++# We need a select here so we don't match all nodes with
+ - enum:+ - mediatek,mt2712-gmac+ - const: snps,dwmac-4.20a++ clocks:+ items:+ - description: AXI clock+ - description: APB clock+ - description: MAC Main clock+ - description: PTP clock+ - description: RMII reference clock provided by MAC
Seems you need 'minItems: 4' or are the DT files wrong?
The current eth device node in mt2712.dtsi should be updated,
and there is a patch in this series for it:
"[PATCH net-next v8 3/6] arm64: dts: mt2712: update ethernet device
node"
quoted
+
+ clock-names:
+ items:
+ - const: axi
+ - const: apb
+ - const: mac_main
+ - const: ptp_ref
+ - const: rmii_internal
+
+ mediatek,pericfg:
+ $ref: /schemas/types.yaml#/definitions/phandle
+ description:
+ The phandle to the syscon node that control ethernet
+ interface and timing delay.
+
+ mediatek,tx-delay-ps:
+ description:
+ The internal TX clock delay (provided by this driver) in
nanoseconds.
+ For MT2712 RGMII interface, Allowed value need to be a
multiple of 170,
+ or will round down. Range 0~31*170.
+ For MT2712 RMII/MII interface, Allowed value need to be a
multiple of 550,
+ or will round down. Range 0~31*550.
+
+ mediatek,rx-delay-ps:
+ description:
+ The internal RX clock delay (provided by this driver) in
nanoseconds.
+ For MT2712 RGMII interface, Allowed value need to be a
multiple of 170,
+ or will round down. Range 0~31*170.
+ For MT2712 RMII/MII interface, Allowed value need to be a
multiple of 550,
+ or will round down. Range 0~31*550.
+
+ mediatek,rmii-rxc:
+ type: boolean
+ description:
+ If present, indicates that the RMII reference clock, which
is from external
+ PHYs, is connected to RXC pin. Otherwise, is connected to
TXC pin.
+
+ mediatek,rmii-clk-from-mac:
+ type: boolean
+ description:
+ If present, indicates that MAC provides the RMII reference
clock, which
+ outputs to TXC pin only.
+
+ mediatek,txc-inverse:
+ type: boolean
+ description:
+ If present, indicates that
+ 1. tx clock will be inversed in MII/RGMII case,
+ 2. tx clock inside MAC will be inversed relative to
reference clock
+ which is from external PHYs in RMII case, and it rarely
happen.
+ 3. the reference clock, which outputs to TXC pin will be
inversed in RMII case
+ when the reference clock is from MAC.
+
+ mediatek,rxc-inverse:
+ type: boolean
+ description:
+ If present, indicates that
+ 1. rx clock will be inversed in MII/RGMII case.
+ 2. reference clock will be inversed when arrived at MAC in
RMII case, when
+ the reference clock is from external PHYs.
+ 3. the inside clock, which be sent to MAC, will be inversed
in RMII case when
+ the reference clock is from MAC.
+
+required:
+ - compatible
+ - reg
+ - interrupts
+ - interrupt-names
+ - clocks
+ - clock-names
+ - phy-mode
+ - mediatek,pericfg
+
+unevaluatedProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/clock/mt2712-clk.h>
+ #include <dt-bindings/gpio/gpio.h>
+ #include <dt-bindings/interrupt-controller/arm-gic.h>
+ #include <dt-bindings/interrupt-controller/irq.h>
+ #include <dt-bindings/power/mt2712-power.h>
+
+ eth: ethernet@1101c000 {
+ compatible = "mediatek,mt2712-gmac", "snps,dwmac-4.20a";
+ reg = <0x1101c000 0x1300>;
+ interrupts = <GIC_SPI 237 IRQ_TYPE_LEVEL_LOW>;
+ interrupt-names = "macirq";
+ phy-mode ="rgmii-rxid";
+ mac-address = [00 55 7b b5 7d f7];
+ clock-names = "axi",
+ "apb",
+ "mac_main",
+ "ptp_ref",
+ "rmii_internal";
+ clocks = <&pericfg CLK_PERI_GMAC>,
+ <&pericfg CLK_PERI_GMAC_PCLK>,
+ <&topckgen CLK_TOP_ETHER_125M_SEL>,
+ <&topckgen CLK_TOP_ETHER_50M_SEL>,
+ <&topckgen CLK_TOP_ETHER_50M_RMII_SEL>;
+ assigned-clocks = <&topckgen CLK_TOP_ETHER_125M_SEL>,
+ <&topckgen CLK_TOP_ETHER_50M_SEL>,
+ <&topckgen CLK_TOP_ETHER_50M_RMII_SEL>;
+ assigned-clock-parents = <&topckgen
CLK_TOP_ETHERPLL_125M>,
+ <&topckgen CLK_TOP_APLL1_D3>,
+ <&topckgen CLK_TOP_ETHERPLL_50M>;
+ power-domains = <&scpsys MT2712_POWER_DOMAIN_AUDIO>;
+ mediatek,pericfg = <&pericfg>;
+ mediatek,tx-delay-ps = <1530>;
+ snps,txpbl = <1>;
+ snps,rxpbl = <1>;
+ snps,reset-gpio = <&pio 87 GPIO_ACTIVE_LOW>;
+ snps,reset-delays-us = <0 10000 10000>;
+ };
--
2.25.1
Since there are some changes in ethernet driver,
update ethernet device node in dts to accommodate to it.
I have a hard time to understand how the first two patches are related to this one. Please be more specific in your commit message.
Also please beware that we should make sure that a newer driver version should still work properly with an older device tree, which does not have your changes.
Regards,
Matthias
Dear Matthias,
Thanks for your comments~
On Wed, 2021-12-15 at 20:22 +0100, Matthias Brugger wrote:
On 10/12/2021 02:31, Biao Huang wrote:
quoted
Since there are some changes in ethernet driver,
update ethernet device node in dts to accommodate to it.
I have a hard time to understand how the first two patches are
related to this
one. Please be more specific in your commit message.
This dts patch is not related to previous two patches in this series.
Actually, this patch should be sent with commit
"71a55a2315b047352b3d65e2d24724207be85ae2", which added extra RMII
support in driver. But unfortunately, we missed it out.
Is there any proper way to relate this patch to commit
"71a55a2315b047352b3d65e2d24724207be85ae2"? (Fixed tag seems not a good
choice, or just add more details in commit message?)
Also please beware that we should make sure that a newer driver
version should
still work properly with an older device tree, which does not have
your changes.
Regards,
Matthias
Since there are some changes in ethernet driver,
update ethernet device node in dts to accommodate to it.
I have a hard time to understand how the changes in 1/6 and 2/6 are related to that.
Please explain better what has changed. Also beware that we shouldn't introduce any non-backward compatible DTS changes. That means, the device should work with the new driver but an older device tree.
Regards,
Matthias
Dear Matthias,
Thanks for your comments~
On Wed, 2021-12-15 at 20:20 +0100, Matthias Brugger wrote:
On 10/12/2021 02:31, Biao Huang wrote:
quoted
Since there are some changes in ethernet driver,
update ethernet device node in dts to accommodate to it.
I have a hard time to understand how the changes in 1/6 and 2/6 are
related to
that.
Please explain better what has changed. Also beware that we shouldn't
introduce
any non-backward compatible DTS changes. That means, the device
should work with
the new driver but an older device tree.
Regards,
Matthias