arm64: add ethernet to orange pi 3
Subsystems (8)
cover arm64: add ethernet to orange pi 3
Hello
2 sunxi board still does not have ethernet working, orangepi 1+ and orangepi 3.
This is due to the fact thoses boards have a PHY which need 2 regulators.
A first attempt was made to support them was made by adding support in stmmac driver:
https://lore.kernel.org/lkml/[email protected]/
Proposal rejected, since regulators need to be handled by the PHY core.
This serie try to handle this.
This serie was tested on whole range of board and PHY architecture:
- internal PHY
* sun8i-h3-orangepi-pc
- external PHY
* sun50i-h6-pine-h64
* sun8i-r40-bananapi-m2-ultra
* sun8i-a83t-bananapi-m3
* sun50i-a64-bananapi-m64
* sun50i-h6-orangepi-3
* sun50i-h5-nanopi-neo-plus2
The resume/suspend of PHY was tested.
Regards
Corentin Labbe (5):
phy: handle optional regulator for PHY
net: stmmac: dwmac-sun8i: remove regulator
dt-bindings: net: Add documentation for phy-supply
ARM: dts: sunxi: move phy regulator in PHY node
arm64: dts: allwinner: move phy regulator in PHY node
Ondřej Jirman (1):
arm64: dts: allwinner: orange-pi-3: Enable ethernet
.../devicetree/bindings/net/ethernet-phy.yaml | 10 +++++ arch/arm/boot/dts/sun8i-a83t-bananapi-m3.dts | 2 +- .../boot/dts/sun8i-a83t-cubietruck-plus.dts | 2 +- arch/arm/boot/dts/sun8i-h3-nanopi-m1-plus.dts | 2 +- arch/arm/boot/dts/sun8i-h3-nanopi-r1.dts | 2 +- arch/arm/boot/dts/sun8i-h3-orangepi-plus.dts | 2 +- .../arm/boot/dts/sun8i-h3-orangepi-plus2e.dts | 2 +- arch/arm/boot/dts/sun8i-h3-zeropi.dts | 2 +- .../boot/dts/sun8i-r40-bananapi-m2-ultra.dts | 2 +- arch/arm/boot/dts/sun8i-r40-oka40i-c.dts | 2 +- .../boot/dts/sun8i-v40-bananapi-m2-berry.dts | 2 +- arch/arm/boot/dts/sun9i-a80-cubieboard4.dts | 2 +- arch/arm/boot/dts/sun9i-a80-optimus.dts | 2 +- arch/arm/boot/dts/sunxi-bananapi-m2-plus.dtsi | 2 +- .../dts/allwinner/sun50i-a64-bananapi-m64.dts | 2 +- .../dts/allwinner/sun50i-a64-nanopi-a64.dts | 2 +- .../sun50i-a64-oceanic-5205-5inmfd.dts | 2 +- .../dts/allwinner/sun50i-a64-olinuxino.dts | 2 +- .../dts/allwinner/sun50i-a64-orangepi-win.dts | 2 +- .../boot/dts/allwinner/sun50i-a64-pine64.dts | 2 +- .../allwinner/sun50i-a64-sopine-baseboard.dts | 2 +- .../sun50i-h5-libretech-all-h5-cc.dts | 2 +- .../allwinner/sun50i-h5-nanopi-neo-plus2.dts | 2 +- .../dts/allwinner/sun50i-h5-nanopi-neo2.dts | 2 +- .../dts/allwinner/sun50i-h5-nanopi-r1s-h5.dts | 2 +- .../dts/allwinner/sun50i-h5-orangepi-pc2.dts | 2 +- .../allwinner/sun50i-h5-orangepi-prime.dts | 2 +- .../sun50i-h5-orangepi-zero-plus.dts | 2 +- .../dts/allwinner/sun50i-h6-beelink-gs1.dts | 2 +- .../dts/allwinner/sun50i-h6-orangepi-3.dts | 38 +++++++++++++++++++ .../allwinner/sun50i-h6-pine-h64-model-b.dts | 8 ++-- .../boot/dts/allwinner/sun50i-h6-pine-h64.dts | 2 +- .../net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 37 +----------------- drivers/net/mdio/fwnode_mdio.c | 32 ++++++++++++++++ drivers/net/phy/phy_device.c | 20 ++++++++++ include/linux/phy.h | 3 ++ 36 files changed, 138 insertions(+), 68 deletions(-)
Signature · 1 line
2.35.1
PATCH 1/6 phy: handle optional regulator for PHY
Add handling of optional regulators for PHY. Regulators need to be enabled before PHY scanning, so MDIO bus initiate this task.
--- drivers/net/mdio/fwnode_mdio.c | 32 ++++++++++++++++++++++++++++++++ drivers/net/phy/phy_device.c | 20 ++++++++++++++++++++ include/linux/phy.h | 3 +++ 3 files changed, 55 insertions(+)
drivers/net/mdio/fwnode_mdio.c +32 -0
@@ -10,6 +10,7 @@#include <linux/fwnode_mdio.h> #include <linux/of.h> #include <linux/phy.h> +#include <linux/regulator/consumer.h> MODULE_AUTHOR ("Calvin Johnson <[email protected]>" );MODULE_LICENSE ("GPL" );
@@ -95,6 +96,8 @@ int fwnode_mdiobus_register_phy(struct mii_bus *bus,bool is_c45 = false;u32 phy_id;int rc; +struct regulator *regulator_phy; +struct regulator *regulator_phy_io; mii_ts =fwnode_find_mii_timestamper (child);if (IS_ERR (mii_ts))
@@ -104,6 +107,32 @@ int fwnode_mdiobus_register_phy(struct mii_bus *bus, "ethernet-phy-ieee802.3-c45");if (rc >=0 ) is_c45 = true; + regulator_phy_io =devm_regulator_get_optional (&bus->dev,"phy-io" ); +if (IS_ERR (regulator_phy_io)) { + rc =PTR_ERR (regulator_phy_io); +if (rc == -ENODEV ) + regulator_phy_io =NULL ; +else +return rc; + } + regulator_phy =devm_regulator_get_optional (&bus->dev,"phy" ); +if (IS_ERR (regulator_phy)) { + rc =PTR_ERR (regulator_phy); +if (rc == -ENODEV ) + regulator_phy =NULL ; +else +return rc; + } +if (regulator_phy_io) { + rc =regulator_enable (regulator_phy_io); +if (rc) +return rc; + } +if (regulator_phy) { + rc =regulator_enable (regulator_phy); +if (rc) +return rc; + }if (is_c45 ||fwnode_get_phy_id (child, &phy_id)) phy =get_phy_device (bus, addr, is_c45);
@@ -114,6 +143,9 @@ int fwnode_mdiobus_register_phy(struct mii_bus *bus,return PTR_ERR (phy); } + phy->regulator_phy = regulator_phy; + phy->regulator_phy_io = regulator_phy_io; +if (is_acpi_node (child)) { phy->irq = bus->irq[addr];
drivers/net/phy/phy_device.c +20 -0
@@ -27,6 +27,7 @@#include <linux/phy.h> #include <linux/phy_led_triggers.h> #include <linux/property.h> +#include <linux/regulator/consumer.h> #include <linux/sfp.h> #include <linux/skbuff.h> #include <linux/slab.h>
@@ -1785,6 +1786,11 @@ int phy_suspend(struct phy_device *phydev)if (!ret) phydev->suspended = true; +if (phydev->regulator_phy) +regulator_disable (phydev->regulator_phy); +if (phydev->regulator_phy_io) +regulator_disable (phydev->regulator_phy_io); +return ret; }EXPORT_SYMBOL (phy_suspend);
@@ -1811,6 +1817,20 @@ int phy_resume(struct phy_device *phydev) {int ret; +if (phydev->regulator_phy_io) { + ret =regulator_enable (phydev->regulator_phy_io); +if (ret) +return ret; + } +if (phydev->regulator_phy) { + ret =regulator_enable (phydev->regulator_phy); +if (ret) { +if (phydev->regulator_phy_io) +regulator_disable (phydev->regulator_phy_io); +return ret; + } + } +mutex_lock (&phydev->lock); ret =__phy_resume (phydev);mutex_unlock (&phydev->lock);
include/linux/phy.h +3 -0
@@ -704,6 +704,9 @@ struct phy_device {void (*phy_link_change)(struct phy_device *phydev,bool up);void (*adjust_link)(struct net_device *dev); +struct regulator *regulator_phy; +struct regulator *regulator_phy_io; +#if IS_ENABLED (CONFIG_MACSEC )/* MACsec management functions */ const struct macsec_ops *macsec_ops;
Signature · 1 line
2.35.1
PATCH 2/6 net: stmmac: dwmac-sun8i: remove regulator
In reply to Corentin LabbeNow regulator is handled by phy core, there is no need to handle it in stmmac driver.
--- .../net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 37 +------------------ 1 file changed, 2 insertions(+), 35 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c +2 -35
@@ -17,7 +17,6 @@#include <linux/phy.h> #include <linux/platform_device.h> #include <linux/pm_runtime.h> -#include <linux/regulator/consumer.h> #include <linux/regmap.h> #include <linux/stmmac.h>
@@ -59,7 +58,6 @@ struct emac_variant {/* struct sunxi_priv_data - hold all sunxi private data * @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
@@ -69,7 +67,6 @@ struct emac_variant {*/ struct sunxi_priv_data {struct clk *ephy_clk; -struct regulator *regulator;struct reset_control *rst_ephy;const struct emac_variant *variant;struct regmap_field *regmap_field;
@@ -568,29 +565,11 @@ static int sun8i_dwmac_init(struct platform_device *pdev, void *priv) {struct net_device *ndev =platform_get_drvdata (pdev);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; - } - } - -if (gmac->use_internal_phy) { - ret =sun8i_dwmac_power_internal_phy (netdev_priv (ndev)); -if (ret) - goto err_disable_regulator; - } +if (gmac->use_internal_phy) +return sun8i_dwmac_power_internal_phy (netdev_priv (ndev));return 0 ; - -err_disable_regulator: -if (gmac->regulator) -regulator_disable (gmac->regulator); - -return ret; } static void sun8i_dwmac_core_init(struct mac_device_info *hw,
@@ -1034,9 +1013,6 @@ static void sun8i_dwmac_exit(struct platform_device *pdev, void *priv)if (gmac->variant->soc_has_internal_phy)sun8i_dwmac_unpower_internal_phy (gmac); - -if (gmac->regulator) -regulator_disable (gmac->regulator); }static void sun8i_dwmac_set_mac_loopback (void __iomem *ioaddr,bool enable)
@@ -1157,15 +1133,6 @@ static int sun8i_dwmac_probe(struct platform_device *pdev)return -EINVAL ; } -/* Optional regulator for PHY */ - gmac->regulator =devm_regulator_get_optional (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 ; - } -/* 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.35.1
PATCH 3/6 dt-bindings: net: Add documentation for phy-supply
In reply to Corentin LabbeAdd entries for the 2 new phy-supply and phy-io-supply.
--- .../devicetree/bindings/net/ethernet-phy.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+)
Documentation/devicetree/bindings/net/ethernet-phy.yaml +10 -0
@@ -153,6 +153,16 @@ properties: used. The absence of this property indicates the muxers should be configured so that the external PHY is used. + phy-supply: + description: + Phandle to a regulator that provides power to the PHY. This + regulator will be managed during the PHY power on/off sequence. + + phy-io-supply: + description: + Phandle to a regulator that provides power to the PHY. This + regulator will be managed during the PHY power on/off sequence. + resets: maxItems: 1
Signature · 1 line
2.35.1
PATCH 4/6 ARM: dts: sunxi: move phy regulator in PHY node
In reply to Corentin LabbeNow that PHY core can handle regulators, move regulator handle in PHY node.
--- arch/arm/boot/dts/sun8i-a83t-bananapi-m3.dts | 2 +- arch/arm/boot/dts/sun8i-a83t-cubietruck-plus.dts | 2 +- arch/arm/boot/dts/sun8i-h3-nanopi-m1-plus.dts | 2 +- arch/arm/boot/dts/sun8i-h3-nanopi-r1.dts | 2 +- arch/arm/boot/dts/sun8i-h3-orangepi-plus.dts | 2 +- arch/arm/boot/dts/sun8i-h3-orangepi-plus2e.dts | 2 +- arch/arm/boot/dts/sun8i-h3-zeropi.dts | 2 +- arch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dts | 2 +- arch/arm/boot/dts/sun8i-r40-oka40i-c.dts | 2 +- arch/arm/boot/dts/sun8i-v40-bananapi-m2-berry.dts | 2 +- arch/arm/boot/dts/sun9i-a80-cubieboard4.dts | 2 +- arch/arm/boot/dts/sun9i-a80-optimus.dts | 2 +- arch/arm/boot/dts/sunxi-bananapi-m2-plus.dtsi | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-)
arch/arm/boot/dts/sun8i-a83t-bananapi-m3.dts +1 -1
@@ -129,7 +129,6 @@ &ehci0 { &emac { pinctrl-names = "default"; pinctrl-0 = <&emac_rgmii_pins>; - phy-supply = <®_sw>; phy-handle = <&rgmii_phy>; phy-mode = "rgmii-id"; allwinner,rx-delay-ps = <700>;
@@ -151,6 +150,7 @@ &mdio { rgmii_phy: ethernet-phy@1 { compatible = "ethernet-phy-ieee802.3-c22"; reg = <1>; + phy-supply = <®_sw>; }; };
arch/arm/boot/dts/sun8i-a83t-cubietruck-plus.dts +1 -1
@@ -181,7 +181,6 @@ &ehci1 { &emac { pinctrl-names = "default"; pinctrl-0 = <&emac_rgmii_pins>; - phy-supply = <®_dldo4>; phy-handle = <&rgmii_phy>; phy-mode = "rgmii-id"; status = "okay";
@@ -201,6 +200,7 @@ &mdio { rgmii_phy: ethernet-phy@1 { compatible = "ethernet-phy-ieee802.3-c22"; reg = <1>; + phy-supply = <®_dldo4>; }; };
arch/arm/boot/dts/sun8i-h3-nanopi-m1-plus.dts +1 -1
@@ -103,7 +103,6 @@ &ehci2 { &emac { pinctrl-names = "default"; pinctrl-0 = <&emac_rgmii_pins>; - phy-supply = <®_gmac_3v3>; phy-handle = <&ext_rgmii_phy>; phy-mode = "rgmii";
@@ -114,6 +113,7 @@ &external_mdio { ext_rgmii_phy: ethernet-phy@1 { compatible = "ethernet-phy-ieee802.3-c22"; reg = <7>; + phy-supply = <®_gmac_3v3>; }; };
arch/arm/boot/dts/sun8i-h3-nanopi-r1.dts +1 -1
@@ -80,7 +80,6 @@ &ehci2 { &emac { pinctrl-names = "default"; pinctrl-0 = <&emac_rgmii_pins>; - phy-supply = <®_gmac_3v3>; phy-handle = <&ext_rgmii_phy>; phy-mode = "rgmii-id"; status = "okay";
@@ -90,6 +89,7 @@ &external_mdio { ext_rgmii_phy: ethernet-phy@7 { compatible = "ethernet-phy-ieee802.3-c22"; reg = <7>; + phy-supply = <®_gmac_3v3>; }; };
arch/arm/boot/dts/sun8i-h3-orangepi-plus.dts +1 -1
@@ -83,7 +83,6 @@ &ehci3 { &emac { pinctrl-names = "default"; pinctrl-0 = <&emac_rgmii_pins>; - phy-supply = <®_gmac_3v3>; phy-handle = <&ext_rgmii_phy>; phy-mode = "rgmii-id";
@@ -94,6 +93,7 @@ &external_mdio { ext_rgmii_phy: ethernet-phy@1 { compatible = "ethernet-phy-ieee802.3-c22"; reg = <0>; + phy-supply = <®_gmac_3v3>; }; };
arch/arm/boot/dts/sun8i-h3-orangepi-plus2e.dts +1 -1
@@ -65,7 +65,6 @@ reg_gmac_3v3: gmac-3v3 { &emac { pinctrl-names = "default"; pinctrl-0 = <&emac_rgmii_pins>; - phy-supply = <®_gmac_3v3>; phy-handle = <&ext_rgmii_phy>; phy-mode = "rgmii-id"; status = "okay";
@@ -75,5 +74,6 @@ &external_mdio { ext_rgmii_phy: ethernet-phy@1 { compatible = "ethernet-phy-ieee802.3-c22"; reg = <1>; + phy-supply = <®_gmac_3v3>; }; };
arch/arm/boot/dts/sun8i-h3-zeropi.dts +1 -1
@@ -65,13 +65,13 @@ &external_mdio { ext_rgmii_phy: ethernet-phy@7 { compatible = "ethernet-phy-ieee802.3-c22"; reg = <7>; + phy-supply = <®_gmac_3v3>; }; }; &emac { pinctrl-names = "default"; pinctrl-0 = <&emac_rgmii_pins>; - phy-supply = <®_gmac_3v3>; phy-handle = <&ext_rgmii_phy>; phy-mode = "rgmii-id";
arch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dts +1 -1
@@ -130,7 +130,6 @@ &gmac { pinctrl-0 = <&gmac_rgmii_pins>; phy-handle = <&phy1>; phy-mode = "rgmii-id"; - phy-supply = <®_dc1sw>; status = "okay"; };
@@ -138,6 +137,7 @@ &gmac_mdio { phy1: ethernet-phy@1 { compatible = "ethernet-phy-ieee802.3-c22"; reg = <1>; + phy-supply = <®_dc1sw>; }; };
arch/arm/boot/dts/sun8i-r40-oka40i-c.dts +1 -1
@@ -93,7 +93,6 @@ &gmac { pinctrl-0 = <&gmac_rgmii_pins>; phy-handle = <&phy1>; phy-mode = "rgmii-id"; - phy-supply = <®_dcdc1>; status = "okay"; };
@@ -101,6 +100,7 @@ &gmac_mdio { phy1: ethernet-phy@1 { compatible = "ethernet-phy-ieee802.3-c22"; reg = <1>; + phy-supply = <®_dcdc1>; }; };
arch/arm/boot/dts/sun8i-v40-bananapi-m2-berry.dts +1 -1
@@ -121,7 +121,6 @@ &gmac { pinctrl-0 = <&gmac_rgmii_pins>; phy-handle = <&phy1>; phy-mode = "rgmii-id"; - phy-supply = <®_dc1sw>; status = "okay"; };
@@ -129,6 +128,7 @@ &gmac_mdio { phy1: ethernet-phy@1 { compatible = "ethernet-phy-ieee802.3-c22"; reg = <1>; + phy-supply = <®_dc1sw>; }; };
arch/arm/boot/dts/sun9i-a80-cubieboard4.dts +1 -1
@@ -130,7 +130,6 @@ &gmac { pinctrl-0 = <&gmac_rgmii_pins>; phy-handle = <&phy1>; phy-mode = "rgmii-id"; - phy-supply = <®_cldo1>; status = "okay"; };
@@ -142,6 +141,7 @@ &i2c3 { &mdio { phy1: ethernet-phy@1 { + phy-supply = <®_cldo1>; reg = <1>; }; };
arch/arm/boot/dts/sun9i-a80-optimus.dts +1 -1
@@ -125,13 +125,13 @@ &gmac { pinctrl-0 = <&gmac_rgmii_pins>; phy-handle = <&phy1>; phy-mode = "rgmii-id"; - phy-supply = <®_cldo1>; status = "okay"; }; &mdio { phy1: ethernet-phy@1 { reg = <1>; + phy-supply = <®_cldo1>; }; };
arch/arm/boot/dts/sunxi-bananapi-m2-plus.dtsi +1 -1
@@ -125,7 +125,6 @@ &ehci2 { &emac { pinctrl-names = "default"; pinctrl-0 = <&emac_rgmii_pins>; - phy-supply = <®_gmac_3v3>; phy-handle = <&ext_rgmii_phy>; phy-mode = "rgmii-id";
@@ -136,6 +135,7 @@ &external_mdio { ext_rgmii_phy: ethernet-phy@1 { compatible = "ethernet-phy-ieee802.3-c22"; reg = <1>; + phy-supply = <®_gmac_3v3>; }; };
Signature · 1 line
2.35.1
PATCH 5/6 arm64: dts: allwinner: move phy regulator in PHY node
In reply to Corentin LabbeNow that PHY core can handle regulators, move regulator handle in PHY node.
--- arch/arm64/boot/dts/allwinner/sun50i-a64-bananapi-m64.dts | 2 +- arch/arm64/boot/dts/allwinner/sun50i-a64-nanopi-a64.dts | 2 +- .../boot/dts/allwinner/sun50i-a64-oceanic-5205-5inmfd.dts | 2 +- arch/arm64/boot/dts/allwinner/sun50i-a64-olinuxino.dts | 2 +- arch/arm64/boot/dts/allwinner/sun50i-a64-orangepi-win.dts | 2 +- arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts | 2 +- .../boot/dts/allwinner/sun50i-a64-sopine-baseboard.dts | 2 +- .../boot/dts/allwinner/sun50i-h5-libretech-all-h5-cc.dts | 2 +- .../boot/dts/allwinner/sun50i-h5-nanopi-neo-plus2.dts | 2 +- arch/arm64/boot/dts/allwinner/sun50i-h5-nanopi-neo2.dts | 2 +- arch/arm64/boot/dts/allwinner/sun50i-h5-nanopi-r1s-h5.dts | 2 +- arch/arm64/boot/dts/allwinner/sun50i-h5-orangepi-pc2.dts | 2 +- .../arm64/boot/dts/allwinner/sun50i-h5-orangepi-prime.dts | 2 +- .../boot/dts/allwinner/sun50i-h5-orangepi-zero-plus.dts | 2 +- arch/arm64/boot/dts/allwinner/sun50i-h6-beelink-gs1.dts | 2 +- .../boot/dts/allwinner/sun50i-h6-pine-h64-model-b.dts | 8 ++++---- arch/arm64/boot/dts/allwinner/sun50i-h6-pine-h64.dts | 2 +- 17 files changed, 20 insertions(+), 20 deletions(-)
arch/arm64/boot/dts/allwinner/sun50i-a64-bananapi-m64.dts +1 -1
@@ -107,7 +107,6 @@ &emac { pinctrl-0 = <&rgmii_pins>; phy-mode = "rgmii-id"; phy-handle = <&ext_rgmii_phy>; - phy-supply = <®_dc1sw>; status = "okay"; };
@@ -134,6 +133,7 @@ &mdio { ext_rgmii_phy: ethernet-phy@1 { compatible = "ethernet-phy-ieee802.3-c22"; reg = <1>; + phy-supply = <®_dc1sw>; }; };
arch/arm64/boot/dts/allwinner/sun50i-a64-nanopi-a64.dts +1 -1
@@ -82,7 +82,6 @@ &emac { pinctrl-0 = <&rgmii_pins>; phy-mode = "rgmii"; phy-handle = <&ext_rgmii_phy>; - phy-supply = <®_dcdc1>; status = "okay"; };
@@ -106,6 +105,7 @@ &mdio { ext_rgmii_phy: ethernet-phy@1 { compatible = "ethernet-phy-ieee802.3-c22"; reg = <7>; + phy-supply = <®_dcdc1>; }; };
arch/arm64/boot/dts/allwinner/sun50i-a64-oceanic-5205-5inmfd.dts +1 -1
@@ -30,7 +30,6 @@ &emac { pinctrl-0 = <&rgmii_pins>; phy-mode = "rgmii"; phy-handle = <&ext_rgmii_phy>; - phy-supply = <®_dc1sw>; allwinner,tx-delay-ps = <600>; status = "okay"; };
@@ -55,6 +54,7 @@ &mdio { ext_rgmii_phy: ethernet-phy@1 { compatible = "ethernet-phy-ieee802.3-c22"; reg = <1>; + phy-supply = <®_dc1sw>; }; };
arch/arm64/boot/dts/allwinner/sun50i-a64-olinuxino.dts +1 -1
@@ -104,7 +104,6 @@ &emac { pinctrl-0 = <&rgmii_pins>; phy-mode = "rgmii"; phy-handle = <&ext_rgmii_phy>; - phy-supply = <®_dcdc1>; allwinner,tx-delay-ps = <600>; status = "okay"; };
@@ -124,6 +123,7 @@ &mdio { ext_rgmii_phy: ethernet-phy@1 { compatible = "ethernet-phy-ieee802.3-c22"; reg = <1>; + phy-supply = <®_dcdc1>; }; };
arch/arm64/boot/dts/allwinner/sun50i-a64-orangepi-win.dts +1 -1
@@ -122,7 +122,6 @@ &emac { pinctrl-0 = <&rgmii_pins>; phy-mode = "rgmii-id"; phy-handle = <&ext_rgmii_phy>; - phy-supply = <®_gmac_3v3>; status = "okay"; };
@@ -141,6 +140,7 @@ &mdio { ext_rgmii_phy: ethernet-phy@1 { compatible = "ethernet-phy-ieee802.3-c22"; reg = <1>; + phy-supply = <®_gmac_3v3>; }; };
arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts +1 -1
@@ -83,7 +83,6 @@ &emac { pinctrl-0 = <&rmii_pins>; phy-mode = "rmii"; phy-handle = <&ext_rmii_phy1>; - phy-supply = <®_dc1sw>; status = "okay"; };
@@ -111,6 +110,7 @@ &mdio { ext_rmii_phy1: ethernet-phy@1 { compatible = "ethernet-phy-ieee802.3-c22"; reg = <1>; + phy-supply = <®_dc1sw>; }; };
arch/arm64/boot/dts/allwinner/sun50i-a64-sopine-baseboard.dts +1 -1
@@ -81,7 +81,6 @@ &emac { pinctrl-0 = <&rgmii_pins>; phy-mode = "rgmii-txid"; phy-handle = <&ext_rgmii_phy>; - phy-supply = <®_dc1sw>; status = "okay"; };
@@ -100,6 +99,7 @@ &mdio { ext_rgmii_phy: ethernet-phy@1 { compatible = "ethernet-phy-ieee802.3-c22"; reg = <1>; + phy-supply = <®_dc1sw>; }; };
arch/arm64/boot/dts/allwinner/sun50i-h5-libretech-all-h5-cc.dts +1 -1
@@ -34,7 +34,6 @@ &codec { &emac { pinctrl-names = "default"; pinctrl-0 = <&emac_rgmii_pins>; - phy-supply = <®_gmac_3v3>; phy-handle = <&ext_rgmii_phy>; phy-mode = "rgmii-id"; /delete-property/ allwinner,leds-active-low;
@@ -45,6 +44,7 @@ &external_mdio { ext_rgmii_phy: ethernet-phy@1 { compatible = "ethernet-phy-ieee802.3-c22"; reg = <1>; + phy-supply = <®_gmac_3v3>; }; };
arch/arm64/boot/dts/allwinner/sun50i-h5-nanopi-neo-plus2.dts +1 -1
@@ -94,7 +94,6 @@ &ehci3 { &emac { pinctrl-names = "default"; pinctrl-0 = <&emac_rgmii_pins>; - phy-supply = <®_gmac_3v3>; phy-handle = <&ext_rgmii_phy>; phy-mode = "rgmii-id"; status = "okay";
@@ -104,6 +103,7 @@ &external_mdio { ext_rgmii_phy: ethernet-phy@7 { compatible = "ethernet-phy-ieee802.3-c22"; reg = <7>; + phy-supply = <®_gmac_3v3>; }; };
arch/arm64/boot/dts/allwinner/sun50i-h5-nanopi-neo2.dts +1 -1
@@ -73,7 +73,6 @@ &ehci3 { &emac { pinctrl-names = "default"; pinctrl-0 = <&emac_rgmii_pins>; - phy-supply = <®_gmac_3v3>; phy-handle = <&ext_rgmii_phy>; phy-mode = "rgmii-id"; status = "okay";
@@ -83,6 +82,7 @@ &external_mdio { ext_rgmii_phy: ethernet-phy@7 { compatible = "ethernet-phy-ieee802.3-c22"; reg = <7>; + phy-supply = <®_gmac_3v3>; }; };
arch/arm64/boot/dts/allwinner/sun50i-h5-nanopi-r1s-h5.dts +1 -1
@@ -125,7 +125,6 @@ &ehci2 { &emac { pinctrl-names = "default"; pinctrl-0 = <&emac_rgmii_pins>; - phy-supply = <®_gmac_3v3>; phy-handle = <&ext_rgmii_phy>; phy-mode = "rgmii-id"; status = "okay";
@@ -135,6 +134,7 @@ &external_mdio { ext_rgmii_phy: ethernet-phy@7 { compatible = "ethernet-phy-ieee802.3-c22"; reg = <7>; + phy-supply = <®_gmac_3v3>; }; };
arch/arm64/boot/dts/allwinner/sun50i-h5-orangepi-pc2.dts +1 -1
@@ -121,7 +121,6 @@ &ehci3 { &emac { pinctrl-names = "default"; pinctrl-0 = <&emac_rgmii_pins>; - phy-supply = <®_gmac_3v3>; phy-handle = <&ext_rgmii_phy>; phy-mode = "rgmii-id"; status = "okay";
@@ -131,6 +130,7 @@ &external_mdio { ext_rgmii_phy: ethernet-phy@1 { compatible = "ethernet-phy-ieee802.3-c22"; reg = <1>; + phy-supply = <®_gmac_3v3>; }; };
arch/arm64/boot/dts/allwinner/sun50i-h5-orangepi-prime.dts +1 -1
@@ -122,7 +122,6 @@ &ehci3 { &emac { pinctrl-names = "default"; pinctrl-0 = <&emac_rgmii_pins>; - phy-supply = <®_gmac_3v3>; phy-handle = <&ext_rgmii_phy>; phy-mode = "rgmii-id"; status = "okay";
@@ -132,6 +131,7 @@ &external_mdio { ext_rgmii_phy: ethernet-phy@1 { compatible = "ethernet-phy-ieee802.3-c22"; reg = <1>; + phy-supply = <®_gmac_3v3>; }; };
arch/arm64/boot/dts/allwinner/sun50i-h5-orangepi-zero-plus.dts +1 -1
@@ -67,7 +67,6 @@ &ehci1 { &emac { pinctrl-names = "default"; pinctrl-0 = <&emac_rgmii_pins>; - phy-supply = <®_gmac_3v3>; phy-handle = <&ext_rgmii_phy>; phy-mode = "rgmii-id"; status = "okay";
@@ -77,6 +76,7 @@ &external_mdio { ext_rgmii_phy: ethernet-phy@1 { compatible = "ethernet-phy-ieee802.3-c22"; reg = <1>; + phy-supply = <®_gmac_3v3>; }; };
arch/arm64/boot/dts/allwinner/sun50i-h6-beelink-gs1.dts +1 -1
@@ -99,7 +99,6 @@ &emac { pinctrl-0 = <&ext_rgmii_pins>; phy-mode = "rgmii-id"; phy-handle = <&ext_rgmii_phy>; - phy-supply = <®_aldo2>; status = "okay"; };
@@ -122,6 +121,7 @@ &mdio { ext_rgmii_phy: ethernet-phy@1 { compatible = "ethernet-phy-ieee802.3-c22"; reg = <1>; + phy-supply = <®_aldo2>; }; };
arch/arm64/boot/dts/allwinner/sun50i-h6-pine-h64-model-b.dts +4 -4
@@ -18,12 +18,12 @@ wifi_pwrseq: wifi_pwrseq { }; }; -&hdmi_connector { - /delete-property/ ddc-en-gpios; +&ext_rgmii_phy { + phy-supply = <®_aldo2>; }; -&emac { - phy-supply = <®_aldo2>; +&hdmi_connector { + /delete-property/ ddc-en-gpios; }; &mmc1 {
arch/arm64/boot/dts/allwinner/sun50i-h6-pine-h64.dts +1 -1
@@ -102,7 +102,6 @@ &emac { pinctrl-0 = <&ext_rgmii_pins>; phy-mode = "rgmii-id"; phy-handle = <&ext_rgmii_phy>; - phy-supply = <®_gmac_3v3>; allwinner,rx-delay-ps = <200>; allwinner,tx-delay-ps = <200>; status = "okay";
@@ -127,6 +126,7 @@ &mdio { ext_rgmii_phy: ethernet-phy@1 { compatible = "ethernet-phy-ieee802.3-c22"; reg = <1>; + phy-supply = <®_gmac_3v3>; }; };
Signature · 1 line
2.35.1
PATCH 6/6 arm64: dts: allwinner: orange-pi-3: Enable ethernet
In reply to Corentin LabbeFrom: Ondřej 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 timing is set in DT via startup-delay-us.
--- .../dts/allwinner/sun50i-h6-orangepi-3.dts | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+)
arch/arm64/boot/dts/allwinner/sun50i-h6-orangepi-3.dts +38 -0
@@ -13,6 +13,7 @@ / { compatible = "xunlong,orangepi-3", "allwinner,sun50i-h6"; aliases { + ethernet0 = &emac; serial0 = &uart0; serial1 = &uart1; };
@@ -55,6 +56,15 @@ led-1 { }; }; + 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 */ + }; + reg_vcc5v: vcc5v { /* board wide 5V supply directly from the DC jack */ compatible = "regulator-fixed";
@@ -113,6 +123,33 @@ &ehci3 { status = "okay"; }; +&emac { + pinctrl-names = "default"; + pinctrl-0 = <&ext_rgmii_pins>; + phy-mode = "rgmii-id"; + phy-handle = <&ext_rgmii_phy>; + status = "okay"; +}; + +&mdio { + ext_rgmii_phy: ethernet-phy@1 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <1>; + /* + * 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-io-supply = <®_gmac_2v5>; + phy-supply = <®_aldo2>; + + reset-gpios = <&pio 3 14 GPIO_ACTIVE_LOW>; /* PD14 */ + reset-assert-us = <15000>; + reset-deassert-us = <40000>; + }; +}; + &gpu { mali-supply = <®_dcdcc>; status = "okay";
@@ -211,6 +248,7 @@ reg_aldo2: aldo2 { 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.35.1
Re: [PATCH 4/6] ARM: dts: sunxi: move phy regulator in PHY node
In reply to Corentin LabbeOn Mon, 9 May 2022 07:48:55 +0000
Corentin Labbe <[email protected]> wrote:
Hi!
Quoted 2 lines
Now that PHY core can handle regulators, move regulator handle in PHY node.
Other than this is somewhat more "correct", is it really needed for those boards? Because it breaks compatibility with older kernels, so when we update the DTs in U-Boot, we run into problems (again).
IIUC this series is about the OPi3 & friends, which didn't work with older kernels anyway, so can we just skip this patch (and 5/6), to just enable the boards that didn't work before?
Cheers,
Andre
Quoted 275 lines
Signed-off-by Corentin Labbe <[email protected]>--- arch/arm/boot/dts/sun8i-a83t-bananapi-m3.dts | 2 +- arch/arm/boot/dts/sun8i-a83t-cubietruck-plus.dts | 2 +- arch/arm/boot/dts/sun8i-h3-nanopi-m1-plus.dts | 2 +- arch/arm/boot/dts/sun8i-h3-nanopi-r1.dts | 2 +- arch/arm/boot/dts/sun8i-h3-orangepi-plus.dts | 2 +- arch/arm/boot/dts/sun8i-h3-orangepi-plus2e.dts | 2 +- arch/arm/boot/dts/sun8i-h3-zeropi.dts | 2 +- arch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dts | 2 +- arch/arm/boot/dts/sun8i-r40-oka40i-c.dts | 2 +- arch/arm/boot/dts/sun8i-v40-bananapi-m2-berry.dts | 2 +- arch/arm/boot/dts/sun9i-a80-cubieboard4.dts | 2 +- arch/arm/boot/dts/sun9i-a80-optimus.dts | 2 +- arch/arm/boot/dts/sunxi-bananapi-m2-plus.dtsi | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-)arch/arm/boot/dts/sun8i-a83t-bananapi-m3.dts +1
-1@@ -129,7 +129,6 @@ &ehci0 { &emac { pinctrl-names = "default"; pinctrl-0 = <&emac_rgmii_pins>; - phy-supply = <®_sw>; phy-handle = <&rgmii_phy>; phy-mode = "rgmii-id"; allwinner,rx-delay-ps = <700>;@@ -151,6 +150,7 @@ &mdio { rgmii_phy: ethernet-phy@1 { compatible = "ethernet-phy-ieee802.3-c22"; reg = <1>; + phy-supply = <®_sw>; }; };arch/arm/boot/dts/sun8i-a83t-cubietruck-plus.dts +1
-1@@ -181,7 +181,6 @@ &ehci1 { &emac { pinctrl-names = "default"; pinctrl-0 = <&emac_rgmii_pins>; - phy-supply = <®_dldo4>; phy-handle = <&rgmii_phy>; phy-mode = "rgmii-id"; status = "okay";@@ -201,6 +200,7 @@ &mdio { rgmii_phy: ethernet-phy@1 { compatible = "ethernet-phy-ieee802.3-c22"; reg = <1>; + phy-supply = <®_dldo4>; }; };arch/arm/boot/dts/sun8i-h3-nanopi-m1-plus.dts +1
-1@@ -103,7 +103,6 @@ &ehci2 { &emac { pinctrl-names = "default"; pinctrl-0 = <&emac_rgmii_pins>; - phy-supply = <®_gmac_3v3>; phy-handle = <&ext_rgmii_phy>; phy-mode = "rgmii";@@ -114,6 +113,7 @@ &external_mdio { ext_rgmii_phy: ethernet-phy@1 { compatible = "ethernet-phy-ieee802.3-c22"; reg = <7>; + phy-supply = <®_gmac_3v3>; }; };arch/arm/boot/dts/sun8i-h3-nanopi-r1.dts +1
-1@@ -80,7 +80,6 @@ &ehci2 { &emac { pinctrl-names = "default"; pinctrl-0 = <&emac_rgmii_pins>; - phy-supply = <®_gmac_3v3>; phy-handle = <&ext_rgmii_phy>; phy-mode = "rgmii-id"; status = "okay";@@ -90,6 +89,7 @@ &external_mdio { ext_rgmii_phy: ethernet-phy@7 { compatible = "ethernet-phy-ieee802.3-c22"; reg = <7>; + phy-supply = <®_gmac_3v3>; }; };arch/arm/boot/dts/sun8i-h3-orangepi-plus.dts +1
-1@@ -83,7 +83,6 @@ &ehci3 { &emac { pinctrl-names = "default"; pinctrl-0 = <&emac_rgmii_pins>; - phy-supply = <®_gmac_3v3>; phy-handle = <&ext_rgmii_phy>; phy-mode = "rgmii-id";@@ -94,6 +93,7 @@ &external_mdio { ext_rgmii_phy: ethernet-phy@1 { compatible = "ethernet-phy-ieee802.3-c22"; reg = <0>; + phy-supply = <®_gmac_3v3>; }; };arch/arm/boot/dts/sun8i-h3-orangepi-plus2e.dts +1
-1@@ -65,7 +65,6 @@ reg_gmac_3v3: gmac-3v3 { &emac { pinctrl-names = "default"; pinctrl-0 = <&emac_rgmii_pins>; - phy-supply = <®_gmac_3v3>; phy-handle = <&ext_rgmii_phy>; phy-mode = "rgmii-id"; status = "okay";@@ -75,5 +74,6 @@ &external_mdio { ext_rgmii_phy: ethernet-phy@1 { compatible = "ethernet-phy-ieee802.3-c22"; reg = <1>; + phy-supply = <®_gmac_3v3>; }; };arch/arm/boot/dts/sun8i-h3-zeropi.dts +1
-1@@ -65,13 +65,13 @@ &external_mdio { ext_rgmii_phy: ethernet-phy@7 { compatible = "ethernet-phy-ieee802.3-c22"; reg = <7>; + phy-supply = <®_gmac_3v3>; }; }; &emac { pinctrl-names = "default"; pinctrl-0 = <&emac_rgmii_pins>; - phy-supply = <®_gmac_3v3>; phy-handle = <&ext_rgmii_phy>; phy-mode = "rgmii-id";arch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dts +1
-1@@ -130,7 +130,6 @@ &gmac { pinctrl-0 = <&gmac_rgmii_pins>; phy-handle = <&phy1>; phy-mode = "rgmii-id"; - phy-supply = <®_dc1sw>; status = "okay"; };@@ -138,6 +137,7 @@ &gmac_mdio { phy1: ethernet-phy@1 { compatible = "ethernet-phy-ieee802.3-c22"; reg = <1>; + phy-supply = <®_dc1sw>; }; };arch/arm/boot/dts/sun8i-r40-oka40i-c.dts +1
-1@@ -93,7 +93,6 @@ &gmac { pinctrl-0 = <&gmac_rgmii_pins>; phy-handle = <&phy1>; phy-mode = "rgmii-id"; - phy-supply = <®_dcdc1>; status = "okay"; };@@ -101,6 +100,7 @@ &gmac_mdio { phy1: ethernet-phy@1 { compatible = "ethernet-phy-ieee802.3-c22"; reg = <1>; + phy-supply = <®_dcdc1>; }; };arch/arm/boot/dts/sun8i-v40-bananapi-m2-berry.dts +1
-1@@ -121,7 +121,6 @@ &gmac { pinctrl-0 = <&gmac_rgmii_pins>; phy-handle = <&phy1>; phy-mode = "rgmii-id"; - phy-supply = <®_dc1sw>; status = "okay"; };@@ -129,6 +128,7 @@ &gmac_mdio { phy1: ethernet-phy@1 { compatible = "ethernet-phy-ieee802.3-c22"; reg = <1>; + phy-supply = <®_dc1sw>; }; };arch/arm/boot/dts/sun9i-a80-cubieboard4.dts +1
-1@@ -130,7 +130,6 @@ &gmac { pinctrl-0 = <&gmac_rgmii_pins>; phy-handle = <&phy1>; phy-mode = "rgmii-id"; - phy-supply = <®_cldo1>; status = "okay"; };@@ -142,6 +141,7 @@ &i2c3 { &mdio { phy1: ethernet-phy@1 { + phy-supply = <®_cldo1>; reg = <1>; }; };arch/arm/boot/dts/sun9i-a80-optimus.dts +1
-1@@ -125,13 +125,13 @@ &gmac { pinctrl-0 = <&gmac_rgmii_pins>; phy-handle = <&phy1>; phy-mode = "rgmii-id"; - phy-supply = <®_cldo1>; status = "okay"; }; &mdio { phy1: ethernet-phy@1 { reg = <1>; + phy-supply = <®_cldo1>; }; };arch/arm/boot/dts/sunxi-bananapi-m2-plus.dtsi +1
-1@@ -125,7 +125,6 @@ &ehci2 { &emac { pinctrl-names = "default"; pinctrl-0 = <&emac_rgmii_pins>; - phy-supply = <®_gmac_3v3>; phy-handle = <&ext_rgmii_phy>; phy-mode = "rgmii-id";@@ -136,6 +135,7 @@ &external_mdio { ext_rgmii_phy: ethernet-phy@1 { compatible = "ethernet-phy-ieee802.3-c22"; reg = <1>; + phy-supply = <®_gmac_3v3>; }; };
Re: [PATCH 4/6] ARM: dts: sunxi: move phy regulator in PHY node
Quoted 12 lines · Andre Przywara
On Mon, 9 May 2022 07:48:55 +0000
Corentin Labbe <[email protected]> wrote:Hi!
Quoted 2 lines
Now that PHY core can handle regulators, move regulator handle in PHY node.
Other than this is somewhat more "correct", is it really needed for those boards? Because it breaks compatibility with older kernels, so when we update the DTs in U-Boot, we run into problems (again).
Quoted 7 lines
IIUC this series is about the OPi3 & friends, which didn't work with older kernels anyway, so can we just skip this patch (and 5/6), to just enable the boards that didn't work before?
Cheers,
Andre
We could have a situation where stmmac handle phy for older boards, and PHY core handle them for new boards. Up to maintainers to see if they want a split situation or not.
Andrew Lunn
maintainerRe: [PATCH 3/6] dt-bindings: net: Add documentation for phy-supply
In reply to Corentin LabbeQuoted 14 lines · Corentin Labbe
Add entries for the 2 new phy-supply and phy-io-supply.
Signed-off-by Corentin Labbe <[email protected]>--- .../devicetree/bindings/net/ethernet-phy.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+)Documentation/devicetree/bindings/net/ethernet-phy.yaml +0
-0@@ -153,6 +153,16 @@ properties: used. The absence of this property indicates the muxers should be configured so that the external PHY is used.
Documentation/devicetree/bindings/net/ethernet-phy.yaml properties: · line 164
Quoted 10 lines
Documentation/devicetree/bindings/net/ethernet-phy.yaml +9
-0+ phy-supply: + description: + Phandle to a regulator that provides power to the PHY. This + regulator will be managed during the PHY power on/off sequence. + + phy-io-supply: + description: + Phandle to a regulator that provides power to the PHY. This + regulator will be managed during the PHY power on/off sequence.
If you need two differently named regulators, you need to make it clear how they differ. My _guess_ would be, you only need the io variant in order to talk to the PHY registers. However, to talk to a link partner, you need the other one enabled as well. Which means handling that regulator probably should be in the PHY driver, so it is enabled only when the interface is configured up.
Andrew
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Andrew Lunn
maintainerQuoted 5 lines · Corentin Labbe
Hello
2 sunxi board still does not have ethernet working, orangepi 1+ and orangepi 3.
This is due to the fact thoses boards have a PHY which need 2 regulators.
Why PHY make/module is it which is causing problems?
Andrew
Re: [PATCH 3/6] dt-bindings: net: Add documentation for phy-supply
In reply to Andrew LunnQuoted 16 lines · Andrew Lunn
Quoted 15 lines · Corentin Labbe
Add entries for the 2 new phy-supply and phy-io-supply.
Signed-off-by Corentin Labbe <[email protected]>--- .../devicetree/bindings/net/ethernet-phy.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+)Documentation/devicetree/bindings/net/ethernet-phy.yaml +0
-0@@ -153,6 +153,16 @@ properties: used. The absence of this property indicates the muxers should be configured so that the external PHY is used.
Quoted 17 lines
Documentation/devicetree/bindings/net/ethernet-phy.yaml properties: · line 164
Quoted 9 lines
Documentation/devicetree/bindings/net/ethernet-phy.yaml +9
-0+ phy-supply: + description: + Phandle to a regulator that provides power to the PHY. This + regulator will be managed during the PHY power on/off sequence. + + phy-io-supply: + description: + Phandle to a regulator that provides power to the PHY. This + regulator will be managed during the PHY power on/off sequence.If you need two differently named regulators, you need to make it clear how they differ. My _guess_ would be, you only need the io variant in order to talk to the PHY registers. However, to talk to a link partner, you need the other one enabled as well. Which means handling that regulator probably should be in the PHY driver, so it is enabled only when the interface is configured up.
If I enable only the IO one, stmmac fail to reset, so both are needed to be up.
I tried also to keep the "phy" one handled by stmmac (by removing patch 2), this lead to the PHY to not be found by MDIO scan. Proably because stmmac enable the "phy" before the "phy-io".
For the difference between the 2, according to my basic read (I am bad a it) of the shematic
https://linux-sunxi.org/images/5/50/OrangePi_3_Schematics_v1.5.pdf
phy-io(ephy-vdd25) seems to (at least) power MDIO bus.
Quoted 9 lines · Andrew Lunn
Quoted 5 lines · Corentin Labbe
Hello
2 sunxi board still does not have ethernet working, orangepi 1+ and orangepi 3.
This is due to the fact thoses boards have a PHY which need 2 regulators.Why PHY make/module is it which is causing problems?
The problem was stmmac support only one regulator for PHY.
Re: [PATCH 2/6] net: stmmac: dwmac-sun8i: remove regulator
In reply to Corentin LabbeOn Mon, 9 May 2022 07:48:53 +0000
Corentin Labbe <[email protected]> wrote:
Hi,
Quoted 2 lines
Now regulator is handled by phy core, there is no need to handle it in stmmac driver.
I don't think you can do that, since we definitely need to maintain compatibility with *older* DTs.
Is there a real need for this patch, or is it just a cleanup? I mean we should be able to keep both approaches in, and the respective board and DT version selects which it is using.
Cheers,
Andre
Quoted 91 lines
Signed-off-by Corentin Labbe <[email protected]>--- .../net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 37 +------------------ 1 file changed, 2 insertions(+), 35 deletions(-)drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c +2
-35@@ -17,7 +17,6 @@#include <linux/phy.h> #include <linux/platform_device.h> #include <linux/pm_runtime.h> -#include <linux/regulator/consumer.h> #include <linux/regmap.h> #include <linux/stmmac.h> @@ -59,7 +58,6 @@ struct emac_variant {/* struct sunxi_priv_data - hold all sunxi private data * @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 @@ -69,7 +67,6 @@ struct emac_variant {*/ struct sunxi_priv_data {struct clk *ephy_clk; -struct regulator *regulator;struct reset_control *rst_ephy;const struct emac_variant *variant;struct regmap_field *regmap_field;@@ -568,29 +565,11 @@ static int sun8i_dwmac_init(struct platform_device *pdev, void *priv) {struct net_device *ndev =platform_get_drvdata (pdev);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; - } - } - -if (gmac->use_internal_phy) { - ret =sun8i_dwmac_power_internal_phy (netdev_priv (ndev)); -if (ret) - goto err_disable_regulator; - } +if (gmac->use_internal_phy) +return sun8i_dwmac_power_internal_phy (netdev_priv (ndev));return 0 ; - -err_disable_regulator: -if (gmac->regulator) -regulator_disable (gmac->regulator); - -return ret; } static void sun8i_dwmac_core_init(struct mac_device_info *hw,@@ -1034,9 +1013,6 @@ static void sun8i_dwmac_exit(struct platform_device *pdev, void *priv)if (gmac->variant->soc_has_internal_phy)sun8i_dwmac_unpower_internal_phy (gmac); - -if (gmac->regulator) -regulator_disable (gmac->regulator); }static void sun8i_dwmac_set_mac_loopback (void __iomem *ioaddr,bool enable)@@ -1157,15 +1133,6 @@ static int sun8i_dwmac_probe(struct platform_device *pdev)return -EINVAL ; } -/* Optional regulator for PHY */ - gmac->regulator =devm_regulator_get_optional (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 ; - } -/* 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).
Re: [PATCH 2/6] net: stmmac: dwmac-sun8i: remove regulator
Quoted 8 lines · Andre Przywara
On Mon, 9 May 2022 07:48:53 +0000
Corentin Labbe <[email protected]> wrote:Hi,
Quoted 2 lines
Now regulator is handled by phy core, there is no need to handle it in stmmac driver.
Quoted 9 lines
I don't think you can do that, since we definitely need to maintain compatibility with *older* DTs.
Is there a real need for this patch, or is it just a cleanup? I mean we should be able to keep both approaches in, and the respective board and DT version selects which it is using.Cheers,
Andre
It is just a cleanup. But yes, probably keeping it will be necessary for easy compatibility.
Andrew Lunn
maintainerQuoted 4 lines · LABBE Corentin
Quoted 3 lines · Andrew Lunn
Quoted 2 lines · Corentin Labbe
Hello
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
2 sunxi board still does not have ethernet working, orangepi 1+ and orangepi 3.
This is due to the fact thoses boards have a PHY which need 2 regulators.Why PHY make/module is it which is causing problems?
The problem was stmmac support only one regulator for PHY.
I'm trying to understand the differences between the two different regulators. If you tell me what the PHY is, i might be able to find the data sheet, and then understand why two regulators are needed and if one needs to be controlled by the PHY driver, not the MDIO bus driver.
Andrew
Quoted 12 lines · Andrew Lunn
Quoted 11 lines · LABBE Corentin
Quoted 9 lines · Andrew Lunn
Quoted 5 lines · Corentin Labbe
Hello
2 sunxi board still does not have ethernet working, orangepi 1+ and orangepi 3.
This is due to the fact thoses boards have a PHY which need 2 regulators.Why PHY make/module is it which is causing problems?
Quoted 7 lines
Quoted 1 line
The problem was stmmac support only one regulator for PHY.
I'm trying to understand the differences between the two different regulators. If you tell me what the PHY is, i might be able to find the data sheet, and then understand why two regulators are needed and if one needs to be controlled by the PHY driver, not the MDIO bus driver.
The schematic for the board is https://linux-sunxi.org/images/5/50/OrangePi_3_Schematics_v1.5.pdf
Which show a RTL8211E.
Mark Brown
maintainerQuoted 10 lines · LABBE Corentin
Quoted 5 lines · Andrew Lunn
I'm trying to understand the differences between the two different regulators. If you tell me what the PHY is, i might be able to find the data sheet, and then understand why two regulators are needed and if one needs to be controlled by the PHY driver, not the MDIO bus driver.
The schematic for the board is https://linux-sunxi.org/images/5/50/OrangePi_3_Schematics_v1.5.pdf
Which show a RTL8211E.
Most hardware will want all the regulators for the device turned on or off en masse (possibly in a specific sequence) - it's rare for devices to support only having some of their supplies enabled for extended periods, I'd be surprised if something like a PHY did that.
Andrew Lunn
maintainerRe: [PATCH 3/6] dt-bindings: net: Add documentation for phy-supply
In reply to LABBE CorentinQuoted 35 lines · LABBE Corentin
Quoted 16 lines · Andrew Lunn
Quoted 15 lines · Corentin Labbe
Add entries for the 2 new phy-supply and phy-io-supply.
Signed-off-by Corentin Labbe <[email protected]>--- .../devicetree/bindings/net/ethernet-phy.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+)Documentation/devicetree/bindings/net/ethernet-phy.yaml +0
-0@@ -153,6 +153,16 @@ properties: used. The absence of this property indicates the muxers should be configured so that the external PHY is used.Quoted 17 lines
Documentation/devicetree/bindings/net/ethernet-phy.yaml properties: · line 164
Quoted 9 lines
Documentation/devicetree/bindings/net/ethernet-phy.yaml +9
-0+ phy-supply: + description: + Phandle to a regulator that provides power to the PHY. This + regulator will be managed during the PHY power on/off sequence. + + phy-io-supply: + description: + Phandle to a regulator that provides power to the PHY. This + regulator will be managed during the PHY power on/off sequence.If you need two differently named regulators, you need to make it clear how they differ. My _guess_ would be, you only need the io variant in order to talk to the PHY registers. However, to talk to a link partner, you need the other one enabled as well. Which means handling that regulator probably should be in the PHY driver, so it is enabled only when the interface is configured up.
Quoted 7 lines
If I enable only the IO one, stmmac fail to reset, so both are needed to be up.
I tried also to keep the "phy" one handled by stmmac (by removing patch 2), this lead to the PHY to not be found by MDIO scan. Proably because stmmac enable the "phy" before the "phy-io".For the difference between the 2, according to my basic read (I am bad a it) of the shematic
https://linux-sunxi.org/images/5/50/OrangePi_3_Schematics_v1.5.pdf
phy-io(ephy-vdd25) seems to (at least) power MDIO bus.
So there is nothing in the data sheet of the RTL8211E to suggest you can uses these different power supplies independently. The naming 'phy-io-supply' is very specific to RTL8211E, but you are defining a generic binding here. I don't know the regulator binding, it is possible to make phy-supply a list?
Andrew
Mark Brown
maintainerRe: [PATCH 3/6] dt-bindings: net: Add documentation for phy-supply
Quoted 11 lines · Andrew Lunn
Quoted 3 lines · LABBE Corentin
For the difference between the 2, according to my basic read (I am bad a it) of the shematic
https://linux-sunxi.org/images/5/50/OrangePi_3_Schematics_v1.5.pdf
phy-io(ephy-vdd25) seems to (at least) power MDIO bus.So there is nothing in the data sheet of the RTL8211E to suggest you can uses these different power supplies independently. The naming 'phy-io-supply' is very specific to RTL8211E, but you are defining a generic binding here. I don't know the regulator binding, it is possible to make phy-supply a list?
No, that's not a thing - the supplies are individual, named properties and even if there were a list we'd still want them to be named so it's clear what's going on.
Andrew Lunn
maintainerRe: [PATCH 3/6] dt-bindings: net: Add documentation for phy-supply
Quoted 3 lines
No, that's not a thing - the supplies are individual, named properties and even if there were a list we'd still want them to be named so it's clear what's going on.
So we have a collection of regulators, varying in numbers between different PHYs, with different vendor names and purposes. In general, they all should be turned on. Yet we want them named so it is clear what is going on.
Is there a generic solution here so that the phylib core can somehow enumerate them and turn them on, without actually knowing what they are called because they have vendor specific names in order to be clear what they are?
There must be a solution to this, phylib cannot be the first subsystem to have this requirement, so if you could point to an example, that would be great.
Thanks
Andrew
Mark Brown
maintainerRe: [PATCH 3/6] dt-bindings: net: Add documentation for phy-supply
Quoted 5 lines · Andrew Lunn
So we have a collection of regulators, varying in numbers between different PHYs, with different vendor names and purposes. In general, they all should be turned on. Yet we want them named so it is clear what is going on.
Quoted 8 lines
Is there a generic solution here so that the phylib core can somehow enumerate them and turn them on, without actually knowing what they are called because they have vendor specific names in order to be clear what they are?
There must be a solution to this, phylib cannot be the first subsystem to have this requirement, so if you could point to an example, that would be great.
No, it's not really come up much before - generally things with regulator control that have generic drivers tend not to be sophisticated enough to have more than one supply, or to be on an enumerable bus where the power is part of the bus specification so have the power specified as part of the bus. You'd need to extend the regulator bindings to support parallel array of phandles and array of names properties like clocks have as an option like you were asking for, which would doubtless be fun for validation but is probably the thing here.
Re: [PATCH 3/6] dt-bindings: net: Add documentation for phy-supply
Quoted 16 lines · Mark Brown
Quoted 5 lines · Andrew Lunn
So we have a collection of regulators, varying in numbers between different PHYs, with different vendor names and purposes. In general, they all should be turned on. Yet we want them named so it is clear what is going on.
Quoted 8 lines
Is there a generic solution here so that the phylib core can somehow enumerate them and turn them on, without actually knowing what they are called because they have vendor specific names in order to be clear what they are?
There must be a solution to this, phylib cannot be the first subsystem to have this requirement, so if you could point to an example, that would be great.
Quoted 8 lines
No, it's not really come up much before - generally things with regulator control that have generic drivers tend not to be sophisticated enough to have more than one supply, or to be on an enumerable bus where the power is part of the bus specification so have the power specified as part of the bus. You'd need to extend the regulator bindings to support parallel array of phandles and array of names properties like clocks have as an option like you were asking for, which would doubtless be fun for validation but is probably the thing here.
Does you mean something like this:
drivers/regulator/core.c +39 -4
@@ -351,6 +351,32 @@ static void regulator_lock_dependent(struct regulator_dev *rdev,mutex_unlock (®ulator_list_mutex); } +/** +* of_get_regulator_from_list - get a regulator device node based on supply name +* from a DT regulators list +* @dev: Device pointer for the consumer (of regulator) device +* @supply: regulator supply name +* +* Extract the regulator device node corresponding to the supply name. +* returns the device node corresponding to the regulator if found, else +* returns NULL. +*/ +static struct device_node *of_get_regulator_from_list (struct device *dev, +struct device_node *np, +const char *supply) +{ +int index, ret; +struct of_phandle_args regspec; + + index =of_property_match_string (np,"regulator-names" , supply); +if (index >=0 ) { + ret =of_parse_phandle_with_args (np,"regulators" ,NULL , index, ®spec); +if (ret ==0 ) +return regspec.np; + } +return NULL ; +} +/** * of_get_child_regulator - get a child regulator device node * based on supply name
@@ -362,17 +388,23 @@ static void regulator_lock_dependent(struct regulator_dev *rdev,* returns the device node corresponding to the regulator if found, else * returns NULL. */ -static struct device_node *of_get_child_regulator (struct device_node *parent, -const char *prop_name) +static struct device_node *of_get_child_regulator (struct device *dev, +struct device_node *parent, +const char *supply) {struct device_node *regnode =NULL ;struct device_node *child =NULL ; +char prop_name[64 ];/* 64 is max size of property name */ +snprintf (prop_name,64 ,"%s-supply" , supply);for_each_child_of_node (parent, child) { + regnode =of_get_regulator_from_list (dev, child, supply); +if (regnode) +return regnode; regnode =of_parse_phandle (child, prop_name,0 );if (!regnode) { - regnode =of_get_child_regulator (child, prop_name); + regnode =of_get_child_regulator (dev, child, prop_name);if (regnode) goto err_node_put; }else {
@@ -401,12 +433,15 @@ static struct device_node *of_get_regulator(struct device *dev, const char *suppchar prop_name[64 ];/* 64 is max size of property name */ dev_dbg (dev,"Looking up %s-supply from device tree\n" , supply); + regnode =of_get_regulator_from_list (dev, dev->of_node, supply); +if (regnode) +return regnode;snprintf (prop_name,64 ,"%s-supply" , supply); regnode =of_parse_phandle (dev->of_node, prop_name,0 );if (!regnode) { - regnode =of_get_child_regulator (dev->of_node, prop_name); + regnode =of_get_child_regulator (dev, dev->of_node, supply);if (regnode)return regnode;
And then for our case, a regulator_get_bulk will be needed. Does I well understood what you mean ?
Mark Brown
maintainerRe: [PATCH 3/6] dt-bindings: net: Add documentation for phy-supply
Quoted 8 lines · LABBE Corentin
Quoted 4 lines · Mark Brown
as part of the bus. You'd need to extend the regulator bindings to support parallel array of phandles and array of names properties like clocks have as an option like you were asking for, which would doubtless be fun for validation but is probably the thing here.
Does you mean something like this:
...
Quoted 2 lines
And then for our case, a
regulator_get_bulkwill be needed. Does I well understood what you mean ?
Yes.
Rob Herring
maintainerRe: [PATCH 3/6] dt-bindings: net: Add documentation for phy-supply
In reply to Andrew LunnQuoted 8 lines · Andrew Lunn
Quoted 3 lines
No, that's not a thing - the supplies are individual, named properties and even if there were a list we'd still want them to be named so it's clear what's going on.
So we have a collection of regulators, varying in numbers between different PHYs, with different vendor names and purposes. In general, they all should be turned on. Yet we want them named so it is clear what is going on.
In what order do we turn the supplies on? How much time in between each one? Does an external clock need to be running before or after (and how long after). Oh, and what about resets and the order and timing of them relative to everything else?
This always happens in the same order. First, it's just one resource like a regulator or reset. Then one more. Then another device with some timing constraints. If we wanted a generic solution in DT, it would need to be able to describe any power sequencing waveform. But we don't have that because we don't want it.
Quoted 4 lines
Is there a generic solution here so that the phylib core can somehow enumerate them and turn them on, without actually knowing what they are called because they have vendor specific names in order to be clear what they are?
Other devices have specific compatibles so that the device can be identified and powered up. Once again, MDIO should not be special here.
Quoted 3 lines
There must be a solution to this, phylib cannot be the first subsystem to have this requirement, so if you could point to an example, that would be great.
Well, no one seems to want to make non-discoverable devices on 'discoverable' buses work. Still an issue for PCI and USB. I thought MDIO had a solution here to probe any devices in the DT even if not discovered.
Rob