linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RESEND v4 PATCH 0/1] arm64: dts: mt8195: Add Ethernet controller
@ 2022-12-21  2:25 Biao Huang
  2022-12-21  2:25 ` [RESEND PATCH v4] " Biao Huang
  0 siblings, 1 reply; 6+ messages in thread
From: Biao Huang @ 2022-12-21  2:25 UTC (permalink / raw)
  To: AngeloGioacchino Del Regno, Rob Herring, Krzysztof Kozlowski,
	Matthias Brugger
  Cc: devicetree, linux-arm-kernel, linux-mediatek, linux-kernel,
	Biao Huang, macpaul.lin

Resend v4, please review it, thanks~

Changes in v4:
1. remove {address,size}-cells = <0> to avoid warning as Angelo's feedback.
2. Add reviewd-by as Angelo's comments.

Changes in v3:
1. move stmmac-axi-config, rx-queues-config, tx-queues-configs inside ethernet node
as Angelo's comments.
2. add {address,size}-cells = <0> in ethernet node as Angelo's comments.

Changes in v2:
1. modify pinctrl node used by ethernet to match rules in pinctrl-mt8195.yaml,
which is pointed by Krzysztof.
2. remove "mac-address" property in ethernet node as comments of Krzysztof.

Changes in v1:
add dts node for MT8195 Ethernet controller

Biao Huang (1):
  arm64: dts: mt8195: Add Ethernet controller

 arch/arm64/boot/dts/mediatek/mt8195-demo.dts | 88 ++++++++++++++++++++
 arch/arm64/boot/dts/mediatek/mt8195.dtsi     | 86 +++++++++++++++++++
 2 files changed, 174 insertions(+)

-- 
2.18.0



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [RESEND PATCH v4] arm64: dts: mt8195: Add Ethernet controller
  2022-12-21  2:25 [RESEND v4 PATCH 0/1] arm64: dts: mt8195: Add Ethernet controller Biao Huang
@ 2022-12-21  2:25 ` Biao Huang
  2022-12-21 10:13   ` AngeloGioacchino Del Regno
  2022-12-21 13:16   ` Andrew Lunn
  0 siblings, 2 replies; 6+ messages in thread
From: Biao Huang @ 2022-12-21  2:25 UTC (permalink / raw)
  To: AngeloGioacchino Del Regno, Rob Herring, Krzysztof Kozlowski,
	Matthias Brugger
  Cc: devicetree, linux-arm-kernel, linux-mediatek, linux-kernel,
	Biao Huang, macpaul.lin

Add Ethernet controller node for mt8195.

Signed-off-by: Biao Huang <biao.huang@mediatek.com>
---
 arch/arm64/boot/dts/mediatek/mt8195-demo.dts | 88 ++++++++++++++++++++
 arch/arm64/boot/dts/mediatek/mt8195.dtsi     | 86 +++++++++++++++++++
 2 files changed, 174 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8195-demo.dts b/arch/arm64/boot/dts/mediatek/mt8195-demo.dts
index 4fbd99eb496a..0e8496d837ef 100644
--- a/arch/arm64/boot/dts/mediatek/mt8195-demo.dts
+++ b/arch/arm64/boot/dts/mediatek/mt8195-demo.dts
@@ -258,6 +258,72 @@ &mt6359_vsram_others_ldo_reg {
 };
 
 &pio {
+	eth_default_pins: eth-default-pins {
+		pins-txd {
+			pinmux = <PINMUX_GPIO77__FUNC_GBE_TXD3>,
+				 <PINMUX_GPIO78__FUNC_GBE_TXD2>,
+				 <PINMUX_GPIO79__FUNC_GBE_TXD1>,
+				 <PINMUX_GPIO80__FUNC_GBE_TXD0>;
+			drive-strength = <MTK_DRIVE_8mA>;
+		};
+		pins-cc {
+			pinmux = <PINMUX_GPIO85__FUNC_GBE_TXC>,
+				 <PINMUX_GPIO88__FUNC_GBE_TXEN>,
+				 <PINMUX_GPIO87__FUNC_GBE_RXDV>,
+				 <PINMUX_GPIO86__FUNC_GBE_RXC>;
+			drive-strength = <MTK_DRIVE_8mA>;
+		};
+		pins-rxd {
+			pinmux = <PINMUX_GPIO81__FUNC_GBE_RXD3>,
+				 <PINMUX_GPIO82__FUNC_GBE_RXD2>,
+				 <PINMUX_GPIO83__FUNC_GBE_RXD1>,
+				 <PINMUX_GPIO84__FUNC_GBE_RXD0>;
+		};
+		pins-mdio {
+			pinmux = <PINMUX_GPIO89__FUNC_GBE_MDC>,
+				 <PINMUX_GPIO90__FUNC_GBE_MDIO>;
+			input-enable;
+		};
+		pins-power {
+			pinmux = <PINMUX_GPIO91__FUNC_GPIO91>,
+				 <PINMUX_GPIO92__FUNC_GPIO92>;
+			output-high;
+		};
+	};
+
+	eth_sleep_pins: eth-sleep-pins {
+		pins-txd {
+			pinmux = <PINMUX_GPIO77__FUNC_GPIO77>,
+				 <PINMUX_GPIO78__FUNC_GPIO78>,
+				 <PINMUX_GPIO79__FUNC_GPIO79>,
+				 <PINMUX_GPIO80__FUNC_GPIO80>;
+		};
+		pins-cc {
+			pinmux = <PINMUX_GPIO85__FUNC_GPIO85>,
+				 <PINMUX_GPIO88__FUNC_GPIO88>,
+				 <PINMUX_GPIO87__FUNC_GPIO87>,
+				 <PINMUX_GPIO86__FUNC_GPIO86>;
+		};
+		pins-rxd {
+			pinmux = <PINMUX_GPIO81__FUNC_GPIO81>,
+				 <PINMUX_GPIO82__FUNC_GPIO82>,
+				 <PINMUX_GPIO83__FUNC_GPIO83>,
+				 <PINMUX_GPIO84__FUNC_GPIO84>;
+		};
+		pins-mdio {
+			pinmux = <PINMUX_GPIO89__FUNC_GPIO89>,
+				 <PINMUX_GPIO90__FUNC_GPIO90>;
+			input-disable;
+			bias-disable;
+		};
+		pins-power {
+			pinmux = <PINMUX_GPIO91__FUNC_GPIO91>,
+				 <PINMUX_GPIO92__FUNC_GPIO92>;
+			input-disable;
+			bias-disable;
+		};
+	};
+
 	gpio_keys_pins: gpio-keys-pins {
 		pins {
 			pinmux = <PINMUX_GPIO106__FUNC_GPIO106>;
@@ -434,6 +500,28 @@ &xhci0 {
 	status = "okay";
 };
 
+&eth {
+	phy-mode ="rgmii-rxid";
+	phy-handle = <&ethernet_phy0>;
+	snps,reset-gpio = <&pio 93 GPIO_ACTIVE_HIGH>;
+	snps,reset-delays-us = <0 10000 10000>;
+	mediatek,tx-delay-ps = <2030>;
+	pinctrl-names = "default", "sleep";
+	pinctrl-0 = <&eth_default_pins>;
+	pinctrl-1 = <&eth_sleep_pins>;
+	status = "okay";
+
+	mdio {
+		compatible = "snps,dwmac-mdio";
+		#address-cells = <1>;
+		#size-cells = <0>;
+		ethernet_phy0: ethernet-phy@1 {
+			compatible = "ethernet-phy-id001c.c916";
+			reg = <0x1>;
+		};
+	};
+};
+
 &xhci1 {
 	vusb33-supply = <&mt6359_vusb_ldo_reg>;
 	status = "okay";
diff --git a/arch/arm64/boot/dts/mediatek/mt8195.dtsi b/arch/arm64/boot/dts/mediatek/mt8195.dtsi
index 5d31536f4c48..02112bbf2bdf 100644
--- a/arch/arm64/boot/dts/mediatek/mt8195.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8195.dtsi
@@ -1046,6 +1046,92 @@ spis1: spi@1101e000 {
 			status = "disabled";
 		};
 
+		eth: ethernet@11021000 {
+			compatible = "mediatek,mt8195-gmac", "snps,dwmac-5.10a";
+			reg = <0 0x11021000 0 0x4000>;
+			interrupts = <GIC_SPI 716 IRQ_TYPE_LEVEL_HIGH 0>;
+			interrupt-names = "macirq";
+			clock-names = "axi",
+				      "apb",
+				      "mac_cg",
+				      "mac_main",
+				      "ptp_ref",
+				      "rmii_internal";
+			clocks = <&pericfg_ao CLK_PERI_AO_ETHERNET>,
+				 <&pericfg_ao CLK_PERI_AO_ETHERNET_BUS>,
+				 <&pericfg_ao CLK_PERI_AO_ETHERNET_MAC>,
+				 <&topckgen CLK_TOP_SNPS_ETH_250M>,
+				 <&topckgen CLK_TOP_SNPS_ETH_62P4M_PTP>,
+				 <&topckgen CLK_TOP_SNPS_ETH_50M_RMII>;
+			assigned-clocks = <&topckgen CLK_TOP_SNPS_ETH_250M>,
+					  <&topckgen CLK_TOP_SNPS_ETH_62P4M_PTP>,
+					  <&topckgen CLK_TOP_SNPS_ETH_50M_RMII>;
+			assigned-clock-parents = <&topckgen CLK_TOP_ETHPLL_D2>,
+						 <&topckgen CLK_TOP_ETHPLL_D8>,
+						 <&topckgen CLK_TOP_ETHPLL_D10>;
+			power-domains = <&spm MT8195_POWER_DOMAIN_ETHER>;
+			mediatek,pericfg = <&infracfg_ao>;
+			snps,axi-config = <&stmmac_axi_setup>;
+			snps,mtl-rx-config = <&mtl_rx_setup>;
+			snps,mtl-tx-config = <&mtl_tx_setup>;
+			snps,txpbl = <16>;
+			snps,rxpbl = <16>;
+			snps,clk-csr = <0>;
+			status = "disabled";
+
+			stmmac_axi_setup: stmmac-axi-config {
+				snps,wr_osr_lmt = <0x7>;
+				snps,rd_osr_lmt = <0x7>;
+				snps,blen = <0 0 0 0 16 8 4>;
+			};
+
+			mtl_rx_setup: rx-queues-config {
+				snps,rx-queues-to-use = <4>;
+				snps,rx-sched-sp;
+				queue0 {
+					snps,dcb-algorithm;
+					snps,map-to-dma-channel = <0x0>;
+				};
+				queue1 {
+					snps,dcb-algorithm;
+					snps,map-to-dma-channel = <0x0>;
+				};
+				queue2 {
+					snps,dcb-algorithm;
+					snps,map-to-dma-channel = <0x0>;
+				};
+				queue3 {
+					snps,dcb-algorithm;
+					snps,map-to-dma-channel = <0x0>;
+				};
+			};
+
+			mtl_tx_setup: tx-queues-config {
+				snps,tx-queues-to-use = <4>;
+				snps,tx-sched-wrr;
+				queue0 {
+					snps,weight = <0x10>;
+					snps,dcb-algorithm;
+					snps,priority = <0x0>;
+				};
+				queue1 {
+					snps,weight = <0x11>;
+					snps,dcb-algorithm;
+					snps,priority = <0x1>;
+				};
+				queue2 {
+					snps,weight = <0x12>;
+					snps,dcb-algorithm;
+					snps,priority = <0x2>;
+				};
+				queue3 {
+					snps,weight = <0x13>;
+					snps,dcb-algorithm;
+					snps,priority = <0x3>;
+				};
+			};
+		};
+
 		xhci0: usb@11200000 {
 			compatible = "mediatek,mt8195-xhci",
 				     "mediatek,mtk-xhci";
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [RESEND PATCH v4] arm64: dts: mt8195: Add Ethernet controller
  2022-12-21  2:25 ` [RESEND PATCH v4] " Biao Huang
@ 2022-12-21 10:13   ` AngeloGioacchino Del Regno
  2022-12-22  1:43     ` Biao Huang (黄彪)
  2022-12-21 13:16   ` Andrew Lunn
  1 sibling, 1 reply; 6+ messages in thread
From: AngeloGioacchino Del Regno @ 2022-12-21 10:13 UTC (permalink / raw)
  To: Biao Huang, Rob Herring, Krzysztof Kozlowski, Matthias Brugger
  Cc: devicetree, linux-arm-kernel, linux-mediatek, linux-kernel, macpaul.lin

Il 21/12/22 03:25, Biao Huang ha scritto:
> Add Ethernet controller node for mt8195.
> 
> Signed-off-by: Biao Huang <biao.huang@mediatek.com>
> ---
>   arch/arm64/boot/dts/mediatek/mt8195-demo.dts | 88 ++++++++++++++++++++
>   arch/arm64/boot/dts/mediatek/mt8195.dtsi     | 86 +++++++++++++++++++
>   2 files changed, 174 insertions(+)
> 

..snip..

> diff --git a/arch/arm64/boot/dts/mediatek/mt8195.dtsi b/arch/arm64/boot/dts/mediatek/mt8195.dtsi
> index 5d31536f4c48..02112bbf2bdf 100644
> --- a/arch/arm64/boot/dts/mediatek/mt8195.dtsi
> +++ b/arch/arm64/boot/dts/mediatek/mt8195.dtsi
> @@ -1046,6 +1046,92 @@ spis1: spi@1101e000 {
>   			status = "disabled";
>   		};
>   
> +		eth: ethernet@11021000 {
> +			compatible = "mediatek,mt8195-gmac", "snps,dwmac-5.10a";
> +			reg = <0 0x11021000 0 0x4000>;
> +			interrupts = <GIC_SPI 716 IRQ_TYPE_LEVEL_HIGH 0>;
> +			interrupt-names = "macirq";
> +			clock-names = "axi",
> +				      "apb",
> +				      "mac_cg",

mac_cg goes as last clock, as specified in the binding.

Order: axi, apb, mac_main, ptp_ref, rmii_internal, mac_cg.

Please fix.

Regards,
Angelo

> +				      "mac_main",
> +				      "ptp_ref",
> +				      "rmii_internal";
> +			clocks = <&pericfg_ao CLK_PERI_AO_ETHERNET>,
> +				 <&pericfg_ao CLK_PERI_AO_ETHERNET_BUS>,
> +				 <&pericfg_ao CLK_PERI_AO_ETHERNET_MAC>,
> +				 <&topckgen CLK_TOP_SNPS_ETH_250M>,
> +				 <&topckgen CLK_TOP_SNPS_ETH_62P4M_PTP>,
> +				 <&topckgen CLK_TOP_SNPS_ETH_50M_RMII>;


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RESEND PATCH v4] arm64: dts: mt8195: Add Ethernet controller
  2022-12-21  2:25 ` [RESEND PATCH v4] " Biao Huang
  2022-12-21 10:13   ` AngeloGioacchino Del Regno
@ 2022-12-21 13:16   ` Andrew Lunn
  2022-12-22  1:56     ` Biao Huang (黄彪)
  1 sibling, 1 reply; 6+ messages in thread
From: Andrew Lunn @ 2022-12-21 13:16 UTC (permalink / raw)
  To: Biao Huang
  Cc: AngeloGioacchino Del Regno, Rob Herring, Krzysztof Kozlowski,
	Matthias Brugger, devicetree, linux-arm-kernel, linux-mediatek,
	linux-kernel, macpaul.lin

> +&eth {
> +	phy-mode ="rgmii-rxid";

That is pretty unusual. You don't see rxid, or txid very often, it is
normally rgmii, or rgmii-id.

> +	phy-handle = <&ethernet_phy0>;
> +	snps,reset-gpio = <&pio 93 GPIO_ACTIVE_HIGH>;
> +	snps,reset-delays-us = <0 10000 10000>;
> +	mediatek,tx-delay-ps = <2030>;

How important is the 30 here?

You appear to have the PHY doing the RX delay, and the MAC doing the
TX delay. Normally we have the PHY do both. Can you actually do

phy-mode = "rgmii-id", and mediatek,tx-delay-ps = <30> ? That would
then have the PHY doing the basic 2ns delay, and the MAC doing the
fine tuning needed for TX?

     Andrew

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RESEND PATCH v4] arm64: dts: mt8195: Add Ethernet controller
  2022-12-21 10:13   ` AngeloGioacchino Del Regno
@ 2022-12-22  1:43     ` Biao Huang (黄彪)
  0 siblings, 0 replies; 6+ messages in thread
From: Biao Huang (黄彪) @ 2022-12-22  1:43 UTC (permalink / raw)
  To: matthias.bgg, angelogioacchino.delregno, robh+dt, krzysztof.kozlowski+dt
  Cc: linux-arm-kernel, linux-kernel, linux-mediatek,
	Macpaul Lin (林智斌),
	devicetree

Dear Angelo,
	Thanks for your comments!

On Wed, 2022-12-21 at 11:13 +0100, AngeloGioacchino Del Regno wrote:
> Il 21/12/22 03:25, Biao Huang ha scritto:
> > Add Ethernet controller node for mt8195.
> > 
> > Signed-off-by: Biao Huang <biao.huang@mediatek.com>
> > ---
> >   arch/arm64/boot/dts/mediatek/mt8195-demo.dts | 88
> > ++++++++++++++++++++
> >   arch/arm64/boot/dts/mediatek/mt8195.dtsi     | 86
> > +++++++++++++++++++
> >   2 files changed, 174 insertions(+)
> > 
> 
> ..snip..
> 
> > diff --git a/arch/arm64/boot/dts/mediatek/mt8195.dtsi
> > b/arch/arm64/boot/dts/mediatek/mt8195.dtsi
> > index 5d31536f4c48..02112bbf2bdf 100644
> > --- a/arch/arm64/boot/dts/mediatek/mt8195.dtsi
> > +++ b/arch/arm64/boot/dts/mediatek/mt8195.dtsi
> > @@ -1046,6 +1046,92 @@ spis1: spi@1101e000 {
> >   			status = "disabled";
> >   		};
> >   
> > +		eth: ethernet@11021000 {
> > +			compatible = "mediatek,mt8195-gmac",
> > "snps,dwmac-5.10a";
> > +			reg = <0 0x11021000 0 0x4000>;
> > +			interrupts = <GIC_SPI 716 IRQ_TYPE_LEVEL_HIGH
> > 0>;
> > +			interrupt-names = "macirq";
> > +			clock-names = "axi",
> > +				      "apb",
> > +				      "mac_cg",
> 
> mac_cg goes as last clock, as specified in the binding.
> 
> Order: axi, apb, mac_main, ptp_ref, rmii_internal, mac_cg.
> 
> Please fix.
OK, will fix in next send.
> 
> Regards,
> Angelo
> 
> > +				      "mac_main",
> > +				      "ptp_ref",
> > +				      "rmii_internal";
> > +			clocks = <&pericfg_ao CLK_PERI_AO_ETHERNET>,
> > +				 <&pericfg_ao
> > CLK_PERI_AO_ETHERNET_BUS>,
> > +				 <&pericfg_ao
> > CLK_PERI_AO_ETHERNET_MAC>,
> > +				 <&topckgen CLK_TOP_SNPS_ETH_250M>,
> > +				 <&topckgen
> > CLK_TOP_SNPS_ETH_62P4M_PTP>,
> > +				 <&topckgen CLK_TOP_SNPS_ETH_50M_RMII>;
> 
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [RESEND PATCH v4] arm64: dts: mt8195: Add Ethernet controller
  2022-12-21 13:16   ` Andrew Lunn
@ 2022-12-22  1:56     ` Biao Huang (黄彪)
  0 siblings, 0 replies; 6+ messages in thread
From: Biao Huang (黄彪) @ 2022-12-22  1:56 UTC (permalink / raw)
  To: andrew
  Cc: linux-mediatek, linux-kernel, robh+dt, devicetree,
	Macpaul Lin (林智斌),
	linux-arm-kernel, krzysztof.kozlowski+dt, matthias.bgg,
	angelogioacchino.delregno

Dear Andrew,
	Thanks for your comments~

On Wed, 2022-12-21 at 14:16 +0100, Andrew Lunn wrote:
> > +&eth {
> > +	phy-mode ="rgmii-rxid";
> 
> That is pretty unusual. You don't see rxid, or txid very often, it is
> normally rgmii, or rgmii-id.
We didn't notice that, and in our design, we can ensure 2ns delay in tx
direction, so we pick rgmii-rxid.
Theoretically, we should support all the cases, and we'll set phy-mode
to "rgmii-id" in next send.
> 
> > +	phy-handle = <&ethernet_phy0>;
> > +	snps,reset-gpio = <&pio 93 GPIO_ACTIVE_HIGH>;
> > +	snps,reset-delays-us = <0 10000 10000>;
> > +	mediatek,tx-delay-ps = <2030>;
> 
> How important is the 30 here?
As documented in yaml, "For MT8188/MT8195 RGMII/RMII/MII interface,
Allowed value need to be a multiple of 290, or will round down. Range
0~31*290.
"
so the 2030 is chosen here.
> 
> You appear to have the PHY doing the RX delay, and the MAC doing the
> TX delay. Normally we have the PHY do both. Can you actually do
> 
> phy-mode = "rgmii-id", and mediatek,tx-delay-ps = <30> ? That would
> then have the PHY doing the basic 2ns delay, and the MAC doing the
> fine tuning needed for TX?
Yes, we can do phy-mode = "rgmii-id".
DTS and driver modification will send together in next send.
Thanks for your valuable comments~
> 
>      Andrew

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-12-22  1:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-21  2:25 [RESEND v4 PATCH 0/1] arm64: dts: mt8195: Add Ethernet controller Biao Huang
2022-12-21  2:25 ` [RESEND PATCH v4] " Biao Huang
2022-12-21 10:13   ` AngeloGioacchino Del Regno
2022-12-22  1:43     ` Biao Huang (黄彪)
2022-12-21 13:16   ` Andrew Lunn
2022-12-22  1:56     ` Biao Huang (黄彪)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).