Skip to contentSkip to conversation

Add ethernet support for Orange Pi 3

PATCH Superseded [email protected] 4 participants 18 messages Aug 20, 2019

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

cover Add ethernet support for Orange Pi 3

From: Ondrej Jirman <[email protected]>

This series implements ethernet support for Xunlong Orange Pi 3 board, by:

- making small cleanups of existing dwmac-sun8i code
- adding DT bindings docummentation
- adding support for phy-io-supply to dwmac-sun8i code
- adding DT configuration for Orange Pi 3 board

For some people, ethernet doesn't work after reboot because u-boot doesn't support AXP805 PMIC, and will not turn off the etherent PHY regulators. So the regulator controlled by gpio will be shut down, but the other one controlled by the AXP PMIC will not.

This is a problem only when running with a builtin driver. This needs to be fixed in u-boot and should not prevent these patches from being merged.

This evolved out of the Orange Pi 3 patches series, as I didn't want to stretch that out any longer.

Please take a look.

thank you and regards,
Ondrej Jirman

Ondrej Jirman (6):
dt-bindings: net: sun8i-a83t-emac: Add phy-supply property
dt-bindings: net: sun8i-a83t-emac: Add phy-io-supply property
net: stmmac: sun8i: Use devm_regulator_get for PHY regulator
net: stmmac: sun8i: Rename PHY regulator variable to regulator_phy
net: stmmac: sun8i: Add support for enabling a regulator for PHY I/O
pins
arm64: dts: allwinner: orange-pi-3: Enable ethernet

 .../net/allwinner,sun8i-a83t-emac.yaml        |  8 ++
 .../dts/allwinner/sun50i-h6-orangepi-3.dts    | 40 ++++++++++
 .../net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 74 ++++++++++++-------
 3 files changed, 96 insertions(+), 26 deletions(-)
Signature · 1 line
2.22.1
#1 lore raw

PATCH 1/6 dt-bindings: net: sun8i-a83t-emac: Add phy-supply property

From: Ondrej Jirman <[email protected]>

This is already supported by the driver, but is missing from the bindings.

---
 .../devicetree/bindings/net/allwinner,sun8i-a83t-emac.yaml    | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/net/allwinner,sun8i-a83t-emac.yaml +4 -0
index 3fb0714e761e..304f244e9ab5 100644
@@ -43,6 +43,10 @@ properties:
       Phandle to the device containing the EMAC or GMAC clock
       register
 
+  phy-supply:
+    description:
+      PHY regulator
+
 required:
   - compatible
   - reg
Signature · 1 line
2.22.1
#3 lore raw

PATCH 2/6 dt-bindings: net: sun8i-a83t-emac: Add phy-io-supply property

In reply to [email protected]

From: Ondrej Jirman <[email protected]>

Some PHYs require separate power supply for I/O pins in some modes of operation. Add phy-io-supply property, to allow enabling this power supply.

---
 .../devicetree/bindings/net/allwinner,sun8i-a83t-emac.yaml    | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/net/allwinner,sun8i-a83t-emac.yaml +4 -0
index 304f244e9ab5..782e202aa124 100644
@@ -47,6 +47,10 @@ properties:
     description:
       PHY regulator
 
+  phy-io-supply:
+    description:
+      PHY I/O pins regulator
+
 required:
   - compatible
   - reg
Signature · 1 line
2.22.1
#8 lore raw

PATCH 3/6 net: stmmac: sun8i: Use devm_regulator_get for PHY regulator

In reply to [email protected]

From: Ondrej Jirman <[email protected]>

Use devm_regulator_get instead of devm_regulator_get_optional and rely on dummy supply. This avoids NULL checks before regulator_enable/disable calls.

This path also improves error reporting, because we now report both use of dummy supply and error during registration with more detail, instead of generic info level message "No regulator found" that was reported previously on errors and lack of regulator property in DT.

Finally, we'll be adding further optional regulators, and the overall code will be simpler.

---
 .../net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 23 ++++++++-----------
 1 file changed, 10 insertions(+), 13 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c +10 -13
index 4083019c547a..3e951a11aec3 100644
@@ -528,12 +528,10 @@ static int sun8i_dwmac_init(struct platform_device *pdev, void *priv)
 	struct sunxi_priv_data *gmac = priv;
 	int ret;
 
-	if (gmac->regulator) {
-		ret = regulator_enable(gmac->regulator);
-		if (ret) {
-			dev_err(&pdev->dev, "Fail to enable regulator\n");
-			return ret;
-		}
+	ret = regulator_enable(gmac->regulator);
+	if (ret) {
+		dev_err(&pdev->dev, "Fail to enable regulator\n");
+		return ret;
 	}
 
 	ret = clk_prepare_enable(gmac->tx_clk);
@@ -992,8 +990,7 @@ static void sun8i_dwmac_exit(struct platform_device *pdev, void *priv)
 
 	clk_disable_unprepare(gmac->tx_clk);
 
-	if (gmac->regulator)
-		regulator_disable(gmac->regulator);
+	regulator_disable(gmac->regulator);
 }
 
 static void sun8i_dwmac_set_mac_loopback(void __iomem *ioaddr, bool enable)
@@ -1129,12 +1126,12 @@ static int sun8i_dwmac_probe(struct platform_device *pdev)
 	}
 
 	/* Optional regulator for PHY */
-	gmac->regulator = devm_regulator_get_optional(dev, "phy");
+	gmac->regulator = devm_regulator_get(dev, "phy");
 	if (IS_ERR(gmac->regulator)) {
-		if (PTR_ERR(gmac->regulator) == -EPROBE_DEFER)
-			return -EPROBE_DEFER;
-		dev_info(dev, "No regulator found\n");
-		gmac->regulator = NULL;
+		ret = PTR_ERR(gmac->regulator);
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "Failed to get PHY regulator (%d)\n", ret);
+		return ret;
 	}
 
 	/* The "GMAC clock control" register might be located in the
Signature · 1 line
2.22.1
#14 lore raw

PATCH 4/6 net: stmmac: sun8i: Rename PHY regulator variable to regulator_phy

In reply to [email protected]

From: Ondrej Jirman <[email protected]>

We'll be adding further optional regulators, and this makes it clearer what the regulator is for.

---
 .../net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 32 ++++++++++---------
 1 file changed, 17 insertions(+), 15 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c +17 -15
index 3e951a11aec3..e7df30d3cab1 100644
@@ -57,19 +57,21 @@ struct emac_variant {
 };
 
 /* struct sunxi_priv_data - hold all sunxi private data
- * @tx_clk:	reference to MAC TX clock
- * @ephy_clk:	reference to the optional EPHY clock for the internal PHY
- * @regulator:	reference to the optional regulator
- * @rst_ephy:	reference to the optional EPHY reset for the internal PHY
- * @variant:	reference to the current board variant
- * @regmap:	regmap for using the syscon
- * @internal_phy_powered: Does the internal PHY is enabled
- * @mux_handle:	Internal pointer used by mdio-mux lib
+ * @tx_clk:			reference to MAC TX clock
+ * @ephy_clk:			reference to the optional EPHY clock for
+ *				the internal PHY
+ * @regulator_phy:		reference to the optional regulator
+ * @rst_ephy:			reference to the optional EPHY reset for
+ *				the internal PHY
+ * @variant:			reference to the current board variant
+ * @regmap:			regmap for using the syscon
+ * @internal_phy_powered:	Does the internal PHY is enabled
+ * @mux_handle:			Internal pointer used by mdio-mux lib
  */
 struct sunxi_priv_data {
 	struct clk *tx_clk;
 	struct clk *ephy_clk;
-	struct regulator *regulator;
+	struct regulator *regulator_phy;
 	struct reset_control *rst_ephy;
 	const struct emac_variant *variant;
 	struct regmap_field *regmap_field;
@@ -528,9 +530,9 @@ static int sun8i_dwmac_init(struct platform_device *pdev, void *priv)
 	struct sunxi_priv_data *gmac = priv;
 	int ret;
 
-	ret = regulator_enable(gmac->regulator);
+	ret = regulator_enable(gmac->regulator_phy);
 	if (ret) {
-		dev_err(&pdev->dev, "Fail to enable regulator\n");
+		dev_err(&pdev->dev, "Fail to enable PHY regulator\n");
 		return ret;
 	}
 
@@ -990,7 +992,7 @@ static void sun8i_dwmac_exit(struct platform_device *pdev, void *priv)
 
 	clk_disable_unprepare(gmac->tx_clk);
 
-	regulator_disable(gmac->regulator);
+	regulator_disable(gmac->regulator_phy);
 }
 
 static void sun8i_dwmac_set_mac_loopback(void __iomem *ioaddr, bool enable)
@@ -1126,9 +1128,9 @@ static int sun8i_dwmac_probe(struct platform_device *pdev)
 	}
 
 	/* Optional regulator for PHY */
-	gmac->regulator = devm_regulator_get(dev, "phy");
-	if (IS_ERR(gmac->regulator)) {
-		ret = PTR_ERR(gmac->regulator);
+	gmac->regulator_phy = devm_regulator_get(dev, "phy");
+	if (IS_ERR(gmac->regulator_phy)) {
+		ret = PTR_ERR(gmac->regulator_phy);
 		if (ret != -EPROBE_DEFER)
 			dev_err(dev, "Failed to get PHY regulator (%d)\n", ret);
 		return ret;
Signature · 1 line
2.22.1
#15 lore raw

PATCH 5/6 net: stmmac: sun8i: Add support for enabling a regulator for PHY I/O pins

In reply to [email protected]

From: Ondrej Jirman <[email protected]>

Orange Pi 3 has two regulators that power the Realtek RTL8211E. According to the phy datasheet, both regulators need to be enabled at the same time.

Add support for the second optional regulator, "phy-io", to the glue driver.

---
 .../net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 31 ++++++++++++++++---
 1 file changed, 27 insertions(+), 4 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c +27 -4
index e7df30d3cab1..e96337b7cd12 100644
@@ -61,6 +61,8 @@ struct emac_variant {
  * @ephy_clk:			reference to the optional EPHY clock for
  *				the internal PHY
  * @regulator_phy:		reference to the optional regulator
+ * @regulator_phy_io:		reference to the optional regulator for
+ *				PHY I/O pins
  * @rst_ephy:			reference to the optional EPHY reset for
  *				the internal PHY
  * @variant:			reference to the current board variant
@@ -72,6 +74,7 @@ struct sunxi_priv_data {
 	struct clk *tx_clk;
 	struct clk *ephy_clk;
 	struct regulator *regulator_phy;
+	struct regulator *regulator_phy_io;
 	struct reset_control *rst_ephy;
 	const struct emac_variant *variant;
 	struct regmap_field *regmap_field;
@@ -530,21 +533,30 @@ static int sun8i_dwmac_init(struct platform_device *pdev, void *priv)
 	struct sunxi_priv_data *gmac = priv;
 	int ret;
 
+	ret = regulator_enable(gmac->regulator_phy_io);
+	if (ret) {
+		dev_err(&pdev->dev, "Fail to enable PHY I/O regulator\n");
+		return ret;
+	}
+
 	ret = regulator_enable(gmac->regulator_phy);
 	if (ret) {
 		dev_err(&pdev->dev, "Fail to enable PHY regulator\n");
-		return ret;
+		goto err_disable_regulator_phy_io;
 	}
 
 	ret = clk_prepare_enable(gmac->tx_clk);
 	if (ret) {
-		if (gmac->regulator)
-			regulator_disable(gmac->regulator);
 		dev_err(&pdev->dev, "Could not enable AHB clock\n");
-		return ret;
+		goto err_disable_regulator_phy;
 	}
 
 	return 0;
+err_disable_regulator_phy:
+	regulator_disable(gmac->regulator_phy);
+err_disable_regulator_phy_io:
+	regulator_disable(gmac->regulator_phy_io);
+	return ret;
 }
 
 static void sun8i_dwmac_core_init(struct mac_device_info *hw,
@@ -993,6 +1005,7 @@ static void sun8i_dwmac_exit(struct platform_device *pdev, void *priv)
 	clk_disable_unprepare(gmac->tx_clk);
 
 	regulator_disable(gmac->regulator_phy);
+	regulator_disable(gmac->regulator_phy_io);
 }
 
 static void sun8i_dwmac_set_mac_loopback(void __iomem *ioaddr, bool enable)
@@ -1136,6 +1149,16 @@ static int sun8i_dwmac_probe(struct platform_device *pdev)
 		return ret;
 	}
 
+	/* Optional regulator for PHY I/O pins */
+	gmac->regulator_phy_io = devm_regulator_get(dev, "phy-io");
+	if (IS_ERR(gmac->regulator_phy_io)) {
+		ret = PTR_ERR(gmac->regulator_phy_io);
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "Failed to get PHY I/O regulator (%d)\n",
+				ret);
+		return ret;
+	}
+
 	/* The "GMAC clock control" register might be located in the
 	 * CCU address range (on the R40), or the system control address
 	 * range (on most other sun8i and later SoCs).
Signature · 1 line
2.22.1
#16 lore raw

PATCH 6/6 arm64: dts: allwinner: orange-pi-3: Enable ethernet

In reply to [email protected]

From: Ondrej Jirman <[email protected]>

Orange Pi 3 has two regulators that power the Realtek RTL8211E PHY. According to the datasheet, both regulators need to be enabled at the same time, or that "phy-io" should be enabled slightly earlier than "phy" regulator.

RTL8211E/RTL8211EG datasheet says:

Note 4: 2.5V (or 1.8/1.5V) RGMII power should be risen simultaneously or slightly earlier than 3.3V power. Rising 2.5V (or 1.8/1.5V) power later than 3.3V power may lead to errors.

The driver ensures the regulator enable ordering. The timing is set in DT via startup-delay-us.

We also need to wait at least 30ms after power-up/reset, before accessing the PHY registers.

All values of RX/TX delay were tested exhaustively and a middle one of the range of working values was chosen.

---
 .../dts/allwinner/sun50i-h6-orangepi-3.dts    | 40 +++++++++++++++++++
 1 file changed, 40 insertions(+)
arch/arm64/boot/dts/allwinner/sun50i-h6-orangepi-3.dts +40 -0
index eda9d5f640b9..18349e60b8c6 100644
@@ -15,6 +15,7 @@
 
 	aliases {
 		serial0 = &uart0;
+		ethernet0 = &emac;
 	};
 
 	chosen {
@@ -56,6 +57,15 @@
 		regulator-max-microvolt = <5000000>;
 		regulator-always-on;
 	};
+
+	reg_gmac_2v5: gmac-2v5 {
+		compatible = "regulator-fixed";
+		regulator-name = "gmac-2v5";
+		regulator-min-microvolt = <2500000>;
+		regulator-max-microvolt = <2500000>;
+		enable-active-high;
+		gpio = <&pio 3 6 GPIO_ACTIVE_HIGH>; /* PD6 */
+	};
 };
 
 &cpu0 {
@@ -74,6 +84,35 @@
 	status = "okay";
 };
 
+&emac {
+	pinctrl-names = "default";
+	pinctrl-0 = <&ext_rgmii_pins>;
+	phy-mode = "rgmii";
+	phy-handle = <&ext_rgmii_phy>;
+	/*
+	 * The board uses 2.5V RGMII signalling. Power sequence to enable
+	 * the phy is to enable GMAC-2V5 and GMAC-3V (aldo2) power rails
+	 * at the same time and to wait 100ms. The driver enables phy-io
+	 * first. Delay is achieved with enable-ramp-delay on reg_aldo2.
+	 */
+	phy-supply = <&reg_aldo2>;
+	phy-io-supply = <&reg_gmac_2v5>;
+	allwinner,rx-delay-ps = <1500>;
+	allwinner,tx-delay-ps = <700>;
+	status = "okay";
+};
+
+&mdio {
+	ext_rgmii_phy: ethernet-phy@1 {
+		compatible = "ethernet-phy-ieee802.3-c22";
+		reg = <1>;
+
+		reset-gpios = <&pio 3 14 GPIO_ACTIVE_LOW>; /* PD14 */
+		reset-assert-us = <15000>;
+		reset-deassert-us = <40000>;
+	};
+};
+
 &hdmi {
 	status = "okay";
 };
@@ -136,6 +175,7 @@
 				regulator-min-microvolt = <3300000>;
 				regulator-max-microvolt = <3300000>;
 				regulator-name = "vcc33-audio-tv-ephy-mac";
+				regulator-enable-ramp-delay = <100000>;
 			};
 
 			/* ALDO3 is shorted to CLDO1 */
Signature · 1 line
2.22.1
#9 lore raw

Re: [PATCH 3/6] net: stmmac: sun8i: Use devm_regulator_get for PHY regulator

In reply to [email protected]
Quoted 5 lines · On Tue, Aug 20, 2019 at 04:53:40PM +0200, [email protected] wrote:

From: Ondrej Jirman <[email protected]>

Use devm_regulator_get instead of devm_regulator_get_optional and rely on dummy supply. This avoids NULL checks before regulator_enable/disable calls.

Hi Ondrej

What do you mean by a dummy supply? I'm just trying to make sure you are not breaking backwards compatibility.

Thanks
Andrew

#10 lore raw

Re: [PATCH 3/6] net: stmmac: sun8i: Use devm_regulator_get for PHY regulator

Hi Andrew,

Quoted 11 lines · Andrew Lunn
Quoted 5 lines · On Tue, Aug 20, 2019 at 04:53:40PM +0200, [email protected] wrote:

From: Ondrej Jirman <[email protected]>

Use devm_regulator_get instead of devm_regulator_get_optional and rely on dummy supply. This avoids NULL checks before regulator_enable/disable calls.

Hi Ondrej

What do you mean by a dummy supply? I'm just trying to make sure you are not breaking backwards compatibility.

Sorry, I mean dummy regulator. See:

https://elixir.bootlin.com/linux/latest/source/drivers/regulator/core.c#L1874

On systems that use DT (i.e. have_full_constraints() == true), when the regulator is not found (ENODEV, not specified in DT), regulator_get will return a fake dummy regulator that can be enabled/disabled, but doesn't do anything real.

This can be used to avoid NULL checks and make the code simpler.

regards,
Ondrej

Quoted 2 lines

Thanks
Andrew

#13 lore raw

Re: [PATCH 3/6] net: stmmac: sun8i: Use devm_regulator_get for PHY regulator

In reply to Andrew Lunn
Quoted 11 lines · Andrew Lunn
Quoted 5 lines · On Tue, Aug 20, 2019 at 04:53:40PM +0200, [email protected] wrote:

From: Ondrej Jirman <[email protected]>

Use devm_regulator_get instead of devm_regulator_get_optional and rely on dummy supply. This avoids NULL checks before regulator_enable/disable calls.

Hi Ondrej

What do you mean by a dummy supply? I'm just trying to make sure you are not breaking backwards compatibility.

I have tested it on Orange Pi PC 2, that uses only phy-supply, but not phy-io-supply, and the kernel now prints:

[    1.410137] dwmac-sun8i 1c30000.ethernet: 1c30000.ethernet supply phy-io not found, using dummy regulator

I have also tested it on Orange Pi PC, that doesn't use external phy, and instead of:

[    1.081378] dwmac-sun8i 1c30000.ethernet: No regulator found

The kernel now prints:

[    1.112752] dwmac-sun8i 1c30000.ethernet: 1c30000.ethernet supply phy not found, using dummy regulator
[    1.112814] dwmac-sun8i 1c30000.ethernet: 1c30000.ethernet supply phy-io not found, using dummy regulator

Ethernet works in both cases, so that should cover all existing combinations. :)

regards,
Ondrej

Quoted 2 lines

Thanks
Andrew

#11 lore raw

Re: [PATCH 3/6] net: stmmac: sun8i: Use devm_regulator_get for PHY regulator

In reply to Ondřej Jirman
Quoted 15 lines · Ondřej Jirman

Hi Andrew,

Quoted 11 lines · Andrew Lunn
Quoted 5 lines · On Tue, Aug 20, 2019 at 04:53:40PM +0200, [email protected] wrote:

From: Ondrej Jirman <[email protected]>

Use devm_regulator_get instead of devm_regulator_get_optional and rely on dummy supply. This avoids NULL checks before regulator_enable/disable calls.

Hi Ondrej

What do you mean by a dummy supply? I'm just trying to make sure you are not breaking backwards compatibility.

Quoted 8 lines

Sorry, I mean dummy regulator. See:

https://elixir.bootlin.com/linux/latest/source/drivers/regulator/core.c#L1874

On systems that use DT (i.e. have_full_constraints() == true), when the regulator is not found (ENODEV, not specified in DT), regulator_get will return a fake dummy regulator that can be enabled/disabled, but doesn't do anything real.

Hi Ondrej

But we also gain a new warning:

	dev_warn(dev,
		 "%s supply %s not found, using dummy regulator\n",
	         devname, id);

This regulator is clearly optional, so there should not be a warning.

Maybe you can add a new get_type, OPTIONAL_GET, which does not issue the warning, but does give back a dummy regulator.

Thanks
Andrew

Reviewed-by on v1 1/6
#2 lore raw

Re: [PATCH 1/6] dt-bindings: net: sun8i-a83t-emac: Add phy-supply property

In reply to [email protected]
Quoted 5 lines · On Tue, Aug 20, 2019 at 9:53 AM <[email protected]> wrote:

From: Ondrej Jirman <[email protected]>

This is already supported by the driver, but is missing from the bindings.

Really, the supply for the phy should be in the phy's node...

Quoted 5 lines
---
 .../devicetree/bindings/net/allwinner,sun8i-a83t-emac.yaml    | 4 ++++
 1 file changed, 4 insertions(+)
#4 lore raw

Re: [PATCH 2/6] dt-bindings: net: sun8i-a83t-emac: Add phy-io-supply property

In reply to [email protected]
Quoted 6 lines · On Tue, Aug 20, 2019 at 9:53 AM <[email protected]> wrote:

From: Ondrej Jirman <[email protected]>

Some PHYs require separate power supply for I/O pins in some modes of operation. Add phy-io-supply property, to allow enabling this power supply.

Perhaps since this is new, such phys should have *-supply in their nodes.

Quoted 5 lines
---
 .../devicetree/bindings/net/allwinner,sun8i-a83t-emac.yaml    | 4 ++++
 1 file changed, 4 insertions(+)
#12 lore raw

Re: [PATCH 3/6] net: stmmac: sun8i: Use devm_regulator_get for PHY regulator

In reply to Andrew Lunn

Hi,

Quoted 29 lines · Andrew Lunn
Quoted 15 lines · Ondřej Jirman

Hi Andrew,

Quoted 11 lines · Andrew Lunn
Quoted 5 lines · On Tue, Aug 20, 2019 at 04:53:40PM +0200, [email protected] wrote:

From: Ondrej Jirman <[email protected]>

Use devm_regulator_get instead of devm_regulator_get_optional and rely on dummy supply. This avoids NULL checks before regulator_enable/disable calls.

Hi Ondrej

What do you mean by a dummy supply? I'm just trying to make sure you are not breaking backwards compatibility.

Quoted 8 lines

Sorry, I mean dummy regulator. See:

https://elixir.bootlin.com/linux/latest/source/drivers/regulator/core.c#L1874

On systems that use DT (i.e. have_full_constraints() == true), when the regulator is not found (ENODEV, not specified in DT), regulator_get will return a fake dummy regulator that can be enabled/disabled, but doesn't do anything real.

Hi Ondrej

But we also gain a new warning:

Quoted 8 lines
	dev_warn(dev,
		 "%s supply %s not found, using dummy regulator\n",
	         devname, id);

This regulator is clearly optional, so there should not be a warning.

Maybe you can add a new get_type, OPTIONAL_GET, which does not issue the warning, but does give back a dummy regulator.

We already had a info message. See my other e-mail with the dmesg output.

IMO, that warning is useful during development, and more informative than the previous one.

regards,

	o.
Quoted 7 lines

Thanks
Andrew

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#5 lore raw

Re: [PATCH 2/6] dt-bindings: net: sun8i-a83t-emac: Add phy-io-supply property

In reply to Rob Herring
Quoted 9 lines · Rob Herring
Quoted 6 lines · On Tue, Aug 20, 2019 at 9:53 AM <[email protected]> wrote:

From: Ondrej Jirman <[email protected]>

Some PHYs require separate power supply for I/O pins in some modes of operation. Add phy-io-supply property, to allow enabling this power supply.

Perhaps since this is new, such phys should have *-supply in their nodes.

Yes, I just don't understand, since external ethernet phys are so common, and they require power, how there's no fairly generic mechanism for this already in the PHY subsystem, or somewhere?

It looks like other ethernet mac drivers also implement supplies on phys on the EMAC nodes. Just grep phy-supply through dt-bindings/net.

Historical reasons, or am I missing something? It almost seems like I must be missing something, since putting these properties to phy nodes seems so obvious.

thank you and regards,
Ondrej

Quoted 5 lines
Quoted 5 lines
---
 .../devicetree/bindings/net/allwinner,sun8i-a83t-emac.yaml    | 4 ++++
 1 file changed, 4 insertions(+)
#6 lore raw

Re: [PATCH 2/6] dt-bindings: net: sun8i-a83t-emac: Add phy-io-supply property

Quoted 10 lines · Ondřej Jirman
Quoted 8 lines · Rob Herring
Quoted 6 lines · On Tue, Aug 20, 2019 at 9:53 AM <[email protected]> wrote:

From: Ondrej Jirman <[email protected]>

Some PHYs require separate power supply for I/O pins in some modes of operation. Add phy-io-supply property, to allow enabling this power supply.

Quoted 5 lines
Quoted 1 line

Perhaps since this is new, such phys should have *-supply in their nodes.

Yes, I just don't understand, since external ethernet phys are so common, and they require power, how there's no fairly generic mechanism for this already in the PHY subsystem, or somewhere?

Because generic mechanisms for this don't work. For example, what happens when the 2 supplies need to be turned on in a certain order and with certain timings? And then add in reset or control lines into the mix... You can see in the bindings we already have some of that.

Quoted 6 lines

It looks like other ethernet mac drivers also implement supplies on phys on the EMAC nodes. Just grep phy-supply through dt-bindings/net.

Historical reasons, or am I missing something? It almost seems like I must be missing something, since putting these properties to phy nodes seems so obvious.

Things get added one by one and one new property isn't that controversial. We've generally learned the lesson and avoid this pattern now, but ethernet phys are one of the older bindings.

Rob

maintainer
#17 lore raw
In reply to [email protected]

It looks like there will be some updates to this series either involving adding -supply to the property names or adjusting some of the kernel log messages.

Seriously, I would prefer less verbiage in the logs rather than more.

#7 lore raw

Re: [PATCH 2/6] dt-bindings: net: sun8i-a83t-emac: Add phy-io-supply property

In reply to Rob Herring
Quoted 13 lines · Rob Herring
Quoted 12 lines · Ondřej Jirman
Quoted 9 lines · Rob Herring
Quoted 6 lines · On Tue, Aug 20, 2019 at 9:53 AM <[email protected]> wrote:

From: Ondrej Jirman <[email protected]>

Some PHYs require separate power supply for I/O pins in some modes of operation. Add phy-io-supply property, to allow enabling this power supply.

Perhaps since this is new, such phys should have *-supply in their nodes.

Quoted 8 lines
Quoted 3 lines

Yes, I just don't understand, since external ethernet phys are so common, and they require power, how there's no fairly generic mechanism for this already in the PHY subsystem, or somewhere?

Because generic mechanisms for this don't work. For example, what happens when the 2 supplies need to be turned on in a certain order and with certain timings? And then add in reset or control lines into the mix... You can see in the bindings we already have some of that.

I've looked at the emac bindings that have phy-supply, and don't see reason why this can't be generic for the phy. Just like there's generic reset properties for phys, now. Some bindings, like fsl-fec.txt even list custom reset properties for phy as deprecated, and recommend using generic ones.

Quoted 1 line

From the point of the view of the emac driver, it just wants to power on/power

off the phy, and wait until it's ready to be communicated with.

It's probably better to have power supplies of the phy covered by generic phy code, because then you don't have to duplicate all this special power up logic in every emac driver, whenever a HW designer decides to combine such emac with external phy that requires some special hadnling on powerup.

At the moment, this lack of flexibility is hacked around by adding multiple regulators to the DTS, and making them dependent on each other (even if one doesn't supply the other), just because this makes the regulator core driver enable them all. Power up delays for the PHY are described as enable-ramp-delays on the regulators (actual regulator ramp delay + wait time for PHY to initialize).

Basically just hacking the DT so that the Linux kernel in the end does what's necessary, instead of DT describing the actual HW.

Adding a single supply property to the phy node, as you suggest will do nothing to help this situation. It will just result in a more complicated dwmac-sun8i driver and will not help anyone in the future.

So I think, maybe phy powerup should be moved to generic code, just like the phy reset code was. Generic code can have multiple supplies and some generic way to specify power up order and timings.

But I guess, this patch series is a dead end.

Quoted 10 lines
Quoted 6 lines

It looks like other ethernet mac drivers also implement supplies on phys on the EMAC nodes. Just grep phy-supply through dt-bindings/net.

Historical reasons, or am I missing something? It almost seems like I must be missing something, since putting these properties to phy nodes seems so obvious.

Things get added one by one and one new property isn't that controversial. We've generally learned the lesson and avoid this pattern now, but ethernet phys are one of the older bindings.

Understood. So maybe the solution suggested above would improve the situation eventually?

regards,

	o.
Quoted 6 lines

Rob

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel