Skip to contentSkip to conversation

ARM: dts: sun8i: h3: Enable EMAC with external PHY on NanoPi M1 Plus

PATCH New Luis Araneda 2 participants 3 messages Aug 1, 2017 – Aug 2, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: dts: sun8i: h3: Enable EMAC with external PHY on NanoPi M1 Plus

The Nanopi M1 Plus uses an external Realtek RTL8211E PHY in RGMII mode, enabled by a GPIO-based regulator.

---
 arch/arm/boot/dts/sun8i-h3-nanopi-m1-plus.dts | 31 +++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
arch/arm/boot/dts/sun8i-h3-nanopi-m1-plus.dts +31 -0
index 8ddd1b2cc..54727990c 100644
@@ -45,6 +45,20 @@
 / {
 	model = "FriendlyArm NanoPi M1 Plus";
 	compatible = "friendlyarm,nanopi-m1-plus", "allwinner,sun8i-h3";
+
+	aliases {
+		ethernet0 = &emac;
+	};
+
+	reg_gmac_3v3: gmac-3v3 {
+		compatible = "regulator-fixed";
+		regulator-name = "gmac-3v3";
+		regulator-min-microvolt = <3300000>;
+		regulator-max-microvolt = <3300000>;
+		startup-delay-us = <100000>;
+		enable-active-high;
+		gpio = <&pio 3 6 GPIO_ACTIVE_HIGH>; /* PD6 */
+	};
 };
 
 &ehci1 {
@@ -55,6 +69,23 @@
 	status = "okay";
 };
 
+&emac {
+	pinctrl-names = "default";
+	pinctrl-0 = <&emac_rgmii_pins>;
+	phy-supply = <&reg_gmac_3v3>;
+	phy-handle = <&ext_rgmii_phy>;
+	phy-mode = "rgmii";
+	allwinner,leds-active-low;
+	status = "okay";
+};
+
+&mdio {
+	ext_rgmii_phy: ethernet-phy at 1 {
+		compatible = "ethernet-phy-ieee802.3-c22";
+		reg = <0>;
+	};
+};
+
 &ohci1 {
 	status = "okay";
 };
Signature · 1 line
2.13.3
#1 lore raw

PATCH 1/1 ARM: dts: sun8i: h3: Enable EMAC with external PHY on NanoPi M1 Plus

Quoted 34 lines · Luis Araneda

The Nanopi M1 Plus uses an external Realtek RTL8211E PHY in RGMII mode, enabled by a GPIO-based regulator.

---
 arch/arm/boot/dts/sun8i-h3-nanopi-m1-plus.dts | 31 +++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
arch/arm/boot/dts/sun8i-h3-nanopi-m1-plus.dts +14 -0
index 8ddd1b2cc..54727990c 100644
@@ -45,6 +45,20 @@
 / {
        model = "FriendlyArm NanoPi M1 Plus";
        compatible = "friendlyarm,nanopi-m1-plus", "allwinner,sun8i-h3";
+
+       aliases {
+               ethernet0 = &emac;
+       };
+
+       reg_gmac_3v3: gmac-3v3 {
+               compatible = "regulator-fixed";
+               regulator-name = "gmac-3v3";
+               regulator-min-microvolt = <3300000>;
+               regulator-max-microvolt = <3300000>;
+               startup-delay-us = <100000>;
+               enable-active-high;
+               gpio = <&pio 3 6 GPIO_ACTIVE_HIGH>; /* PD6 */
+       };
 };
 
 &ehci1 {

arch/arm/boot/dts/sun8i-h3-nanopi-m1-plus.dts line 78

Quoted 10 lines
arch/arm/boot/dts/sun8i-h3-nanopi-m1-plus.dts +7 -0
@@ -55,6 +69,23 @@
        status = "okay";
 };
 
+&emac {
+       pinctrl-names = "default";
+       pinctrl-0 = <&emac_rgmii_pins>;
+       phy-supply = <&reg_gmac_3v3>;
+       phy-handle = <&ext_rgmii_phy>;
+       phy-mode = "rgmii";
+       allwinner,leds-active-low;

This property is for the internal PHY. You should not be using it with an external PHY.

arch/arm/boot/dts/sun8i-h3-nanopi-m1-plus.dts line 85

Quoted 7 lines
arch/arm/boot/dts/sun8i-h3-nanopi-m1-plus.dts +7 -0
+       status = "okay";
+};
+
+&mdio {
+       ext_rgmii_phy: ethernet-phy at 1 {
+               compatible = "ethernet-phy-ieee802.3-c22";
+               reg = <0>;

Value in reg should match the address part of the node name.

ChenYu

Quoted 9 lines
arch/arm/boot/dts/sun8i-h3-nanopi-m1-plus.dts +3 -1
+       };
+};
+
 &ohci1 {
        status = "okay";
 };
--

2.13.3

#2 lore raw

PATCH 1/1 ARM: dts: sun8i: h3: Enable EMAC with external PHY on NanoPi M1 Plus

Hi,

Quoted 11 lines · Chen-Yu Tsai

arch/arm/boot/dts/sun8i-h3-nanopi-m1-plus.dts line 78

Quoted 7 lines · Luis Araneda

+&emac {

arch/arm/boot/dts/sun8i-h3-nanopi-m1-plus.dts +6 -0
+       pinctrl-names = "default";
+       pinctrl-0 = <&emac_rgmii_pins>;
+       phy-supply = <&reg_gmac_3v3>;
+       phy-handle = <&ext_rgmii_phy>;
+       phy-mode = "rgmii";
+       allwinner,leds-active-low;

This property is for the internal PHY. You should not be using it with an external PHY.

You're right. When reading the file "dwmac-sun8i.txt" I thought EPHY meant External PHY, but it means Ethernet PHY (integrated).
I've tested the board without the property and the LEDs are working fine.

Quoted 10 lines

arch/arm/boot/dts/sun8i-h3-nanopi-m1-plus.dts line 85

Quoted 8 lines
arch/arm/boot/dts/sun8i-h3-nanopi-m1-plus.dts +7 -0
+       status = "okay";
+};
+
+&mdio {
+       ext_rgmii_phy: ethernet-phy at 1 {
+               compatible = "ethernet-phy-ieee802.3-c22";
+               reg = <0>;

Value in reg should match the address part of the node name.

Ok.

I'll be sending a v2 with the suggested changes.

Cheers,

Luis Araneda.