Skip to contentSkip to conversation

net: stmmac: Detect PHY location with phy-is-integrated

PATCH Superseded Corentin Labbe 1 participant 8 messages Aug 17, 2017 – Aug 18, 2017

Subsystems (6)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover net: stmmac: Detect PHY location with phy-is-integrated

Hello

The current way to find if the phy is internal is to compare DT phy-mode and emac_variant/internal_phy.
But it will negate a possible future SoC where an external PHY use the same phy mode than the integrated one.

This patchs series adds a new way to find if the PHY is integrated, via the phy-is-integrated DT property.

Since it exists both integrated and external ethernet-phy at 1, they are merged in the final DTB and so share all properties.
For avoiding this, the phy-is-integrated is added only to board DT.

The first five patchs should go via the sunxi tree.
the last one should go via the net tree.
Note that this serie will need backporting the patch "Documentation: net: phy: Add phy-is-integrated binding" which is in net-next

Thanks
Regards

Changes since v1:
- Dropped phy-is-integrated documentation patch since another same patch was already merged
- Moved phy-is-integrated from SoC dtsi to final board DT.

Corentin Labbe (6):
ARM: sun8i: orangepipc: Set phy-is-integrated to the internal phy node
ARM: sun8i: beelink-x2: Set phy-is-integrated to the internal phy node
ARM: sun8i: nanopi-neo: Set phy-is-integrated to the internal phy node
ARM: sun8i: orangepi-2: Set phy-is-integrated to the internal phy node
ARM: sun8i: orangepi-one: Set phy-is-integrated to the internal phy
node
net: stmmac: dwmac-sun8i: choose internal PHY via phy-is-integrated

 arch/arm/boot/dts/sun8i-h3-beelink-x2.dts         |  4 ++++
 arch/arm/boot/dts/sun8i-h3-nanopi-neo.dts         |  4 ++++
 arch/arm/boot/dts/sun8i-h3-orangepi-2.dts         |  4 ++++
 arch/arm/boot/dts/sun8i-h3-orangepi-one.dts       |  4 ++++
 arch/arm/boot/dts/sun8i-h3-orangepi-pc.dts        |  4 ++++
 drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 16 ++++++++--------
 6 files changed, 28 insertions(+), 8 deletions(-)
Signature · 1 line
2.13.0
#1 lore raw

PATCH v2 1/6 ARM: sun8i: orangepipc: Set phy-is-integrated to the internal phy node

This patch add the new phy-is-integrated property to the internal PHY node.

---
 arch/arm/boot/dts/sun8i-h3-orangepi-pc.dts | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm/boot/dts/sun8i-h3-orangepi-pc.dts +4 -0
index f5f0f15a2088..68a618b5f18c 100644
@@ -131,6 +131,10 @@
 	status = "okay";
 };
 
+&int_mii_phy {
+	phy-is-integrated;
+};
+
 &mmc0 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&mmc0_pins_a>, <&mmc0_cd_pin>;
Signature · 1 line
2.13.0
#2 lore raw

PATCH v2 2/6 ARM: sun8i: beelink-x2: Set phy-is-integrated to the internal phy node

In reply to Corentin Labbe

This patch add the new phy-is-integrated property to the internal PHY node.

---
 arch/arm/boot/dts/sun8i-h3-beelink-x2.dts | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm/boot/dts/sun8i-h3-beelink-x2.dts +4 -0
index 546837ccd8af..d0517240d5e3 100644
@@ -121,6 +121,10 @@
 	status = "okay";
 };
 
+&int_mii_phy {
+	phy-is-integrated;
+};
+
 &mmc0 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&mmc0_pins_a>, <&mmc0_cd_pin>;
Signature · 1 line
2.13.0
#3 lore raw

PATCH v2 3/6 ARM: sun8i: nanopi-neo: Set phy-is-integrated to the internal phy node

In reply to Corentin Labbe

This patch add the new phy-is-integrated property to the internal PHY node.

---
 arch/arm/boot/dts/sun8i-h3-nanopi-neo.dts | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm/boot/dts/sun8i-h3-nanopi-neo.dts +4 -0
index 78f6c24952dd..e77b51c98374 100644
@@ -53,3 +53,7 @@
 	allwinner,leds-active-low;
 	status = "okay";
 };
+
+&int_mii_phy {
+	phy-is-integrated;
+};
Signature · 1 line
2.13.0
#4 lore raw

PATCH v2 4/6 ARM: sun8i: orangepi-2: Set phy-is-integrated to the internal phy node

In reply to Corentin Labbe

This patch add the new phy-is-integrated property to the internal PHY node.

---
 arch/arm/boot/dts/sun8i-h3-orangepi-2.dts | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm/boot/dts/sun8i-h3-orangepi-2.dts +4 -0
index 17cdeae19c6f..0801c808c5e5 100644
@@ -131,6 +131,10 @@
 	status = "okay";
 };
 
+&int_mii_phy {
+	phy-is-integrated;
+};
+
 &mmc0 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&mmc0_pins_a>, <&mmc0_cd_pin>;
Signature · 1 line
2.13.0
#5 lore raw

PATCH v2 5/6 ARM: sun8i: orangepi-one: Set phy-is-integrated to the internal phy node

In reply to Corentin Labbe

This patch add the new phy-is-integrated property to the internal PHY node.

---
 arch/arm/boot/dts/sun8i-h3-orangepi-one.dts | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm/boot/dts/sun8i-h3-orangepi-one.dts +4 -0
index 6880268e8b87..22c471473909 100644
@@ -105,6 +105,10 @@
 	status = "okay";
 };
 
+&int_mii_phy {
+	phy-is-integrated;
+};
+
 &mmc0 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&mmc0_pins_a>, <&mmc0_cd_pin>;
Signature · 1 line
2.13.0
#6 lore raw

PATCH v2 6/6 net: stmmac: dwmac-sun8i: choose internal PHY via phy-is-integrated

In reply to Corentin Labbe

The current way to find if the phy is internal is to compare DT phy-mode and emac_variant/internal_phy.
But it will negate a possible future SoC where an external PHY use the same phy mode than the internal one.

This patch adds a new way to find if the PHY is internal, via the phy-is-integrated property.

Since the internal_phy variable does not need anymore to contain the xMII mode used by the internal PHY, it is still used for knowing the presence of an internal PHY, so it is modified to a boolean soc_has_internal_phy.

---
 drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c +8 -8
index fffd6d5fc907..672553b652bd 100644
@@ -41,14 +41,14 @@
  *				This value is used for disabling properly EMAC
  *				and used as a good starting value in case of the
  *				boot process(uboot) leave some stuff.
- * @internal_phy:		Does the MAC embed an internal PHY
+ * @soc_has_internal_phy:	Does the MAC embed an internal PHY
  * @support_mii:		Does the MAC handle MII
  * @support_rmii:		Does the MAC handle RMII
  * @support_rgmii:		Does the MAC handle RGMII
  */
 struct emac_variant {
 	u32 default_syscon_value;
-	int internal_phy;
+	bool soc_has_internal_phy;
 	bool support_mii;
 	bool support_rmii;
 	bool support_rgmii;
@@ -75,7 +75,7 @@ struct sunxi_priv_data {
 
 static const struct emac_variant emac_variant_h3 = {
 	.default_syscon_value = 0x58000,
-	.internal_phy = PHY_INTERFACE_MODE_MII,
+	.soc_has_internal_phy = true,
 	.support_mii = true,
 	.support_rmii = true,
 	.support_rgmii = true
@@ -83,20 +83,20 @@ static const struct emac_variant emac_variant_h3 = {
 
 static const struct emac_variant emac_variant_v3s = {
 	.default_syscon_value = 0x38000,
-	.internal_phy = PHY_INTERFACE_MODE_MII,
+	.soc_has_internal_phy = true,
 	.support_mii = true
 };
 
 static const struct emac_variant emac_variant_a83t = {
 	.default_syscon_value = 0,
-	.internal_phy = 0,
+	.soc_has_internal_phy = false,
 	.support_mii = true,
 	.support_rgmii = true
 };
 
 static const struct emac_variant emac_variant_a64 = {
 	.default_syscon_value = 0,
-	.internal_phy = 0,
+	.soc_has_internal_phy = false,
 	.support_mii = true,
 	.support_rmii = true,
 	.support_rgmii = true
@@ -648,7 +648,7 @@ static int sun8i_dwmac_set_syscon(struct stmmac_priv *priv)
 			 "Current syscon value is not the default %x (expect %x)\n",
 			 val, reg);
 
-	if (gmac->variant->internal_phy) {
+	if (gmac->variant->soc_has_internal_phy) {
 		if (!gmac->use_internal_phy) {
 			/* switch to external PHY interface */
 			reg &= ~H3_EPHY_SELECT;
@@ -932,7 +932,7 @@ static int sun8i_dwmac_probe(struct platform_device *pdev)
 	}
 
 	plat_dat->interface = of_get_phy_mode(dev->of_node);
-	if (plat_dat->interface == gmac->variant->internal_phy) {
+	if (of_property_read_bool(plat_dat->phy_node, "phy-is-integrated")) {
 		dev_info(&pdev->dev, "Will use internal PHY\n");
 		gmac->use_internal_phy = true;
 		gmac->ephy_clk = of_clk_get(plat_dat->phy_node, 0);
Signature · 1 line
2.13.0
#7 lore raw
In reply to Corentin Labbe
Quoted 35 lines · Corentin Labbe

Hello

The current way to find if the phy is internal is to compare DT phy-mode and emac_variant/internal_phy.
But it will negate a possible future SoC where an external PHY use the same phy mode than the integrated one.

This patchs series adds a new way to find if the PHY is integrated, via the phy-is-integrated DT property.

Since it exists both integrated and external ethernet-phy at 1, they are merged in the final DTB and so share all properties.
For avoiding this, the phy-is-integrated is added only to board DT.

The first five patchs should go via the sunxi tree.
the last one should go via the net tree.
Note that this serie will need backporting the patch "Documentation: net: phy: Add phy-is-integrated binding" which is in net-next

Thanks
Regards

Changes since v1:
- Dropped phy-is-integrated documentation patch since another same patch was already merged
- Moved phy-is-integrated from SoC dtsi to final board DT.

Corentin Labbe (6):
ARM: sun8i: orangepipc: Set phy-is-integrated to the internal phy node
ARM: sun8i: beelink-x2: Set phy-is-integrated to the internal phy node
ARM: sun8i: nanopi-neo: Set phy-is-integrated to the internal phy node
ARM: sun8i: orangepi-2: Set phy-is-integrated to the internal phy node
ARM: sun8i: orangepi-one: Set phy-is-integrated to the internal phy
node
net: stmmac: dwmac-sun8i: choose internal PHY via phy-is-integrated

Quoted 11 lines
 arch/arm/boot/dts/sun8i-h3-beelink-x2.dts         |  4 ++++
 arch/arm/boot/dts/sun8i-h3-nanopi-neo.dts         |  4 ++++
 arch/arm/boot/dts/sun8i-h3-orangepi-2.dts         |  4 ++++
 arch/arm/boot/dts/sun8i-h3-orangepi-one.dts       |  4 ++++
 arch/arm/boot/dts/sun8i-h3-orangepi-pc.dts        |  4 ++++
 drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 16 ++++++++--------
 6 files changed, 28 insertions(+), 8 deletions(-)
Signature · 1 line
2.13.0

Hello

Self NACK, the comment from Rob on previous series is pertinent. I will send a v3 which use a mdio-mux for solving all problems.

Regards