diff mbox

[1/6] net: stmmac: support future possible different internal phy mode

Message ID 20170627092806.28181-1-clabbe.montjoie@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Corentin Labbe June 27, 2017, 9:28 a.m. UTC
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.

By using phy-mode = "internal" we permit to have an external PHY with
the same mode than the internal one.

Reported-by: André Przywara <andre.przywara@arm.com>
Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Comments

David Miller June 29, 2017, 4:23 p.m. UTC | #1
From: Corentin Labbe <clabbe.montjoie@gmail.com>
Date: Tue, 27 Jun 2017 11:28:01 +0200

> 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.
> 
> By using phy-mode = "internal" we permit to have an external PHY with
> the same mode than the internal one.
> 
> Reported-by: André Przywara <andre.przywara@arm.com>
> Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>

Series applied.

Please provide a proper "[PATCH 0/n] " header posting next time.
Icenowy Zheng June 29, 2017, 4:46 p.m. UTC | #2
在 2017-06-30 00:23,David Miller 写道:
> From: Corentin Labbe <clabbe.montjoie@gmail.com>
> Date: Tue, 27 Jun 2017 11:28:01 +0200
> 
>> 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.
>> 
>> By using phy-mode = "internal" we permit to have an external PHY with
>> the same mode than the internal one.
>> 
>> Reported-by: André Przywara <andre.przywara@arm.com>
>> Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
> 
> Series applied.

I think there's still some problems around for this patchset...
The definition of "internal" is internal *proprietary* PHY, but the
internal PHY of Allwinner SoCs seem to be MII...

See [1].

[1] 
http://lists.infradead.org/pipermail/linux-arm-kernel/2017-June/516159.html

> 
> Please provide a proper "[PATCH 0/n] " header posting next time.
Corentin Labbe June 29, 2017, 5:02 p.m. UTC | #3
On Thu, Jun 29, 2017 at 12:23:49PM -0400, David Miller wrote:
> From: Corentin Labbe <clabbe.montjoie@gmail.com>
> Date: Tue, 27 Jun 2017 11:28:01 +0200
> 
> > 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.
> > 
> > By using phy-mode = "internal" we permit to have an external PHY with
> > the same mode than the internal one.
> > 
> > Reported-by: André Przywara <andre.przywara@arm.com>
> > Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
> 
> Series applied.
> 
> Please provide a proper "[PATCH 0/n] " header posting next time.

Sorry could you wait for applying, there are a parallel thread (http://www.spinics.net/lists/devicetree/msg183520.html) and it seems finaly that internal could not be the good way to do it.

Regards
Sorry again, I should have sent a comment for waiting.
David Miller June 29, 2017, 8:05 p.m. UTC | #4
From: Corentin Labbe <clabbe.montjoie@gmail.com>
Date: Thu, 29 Jun 2017 19:02:38 +0200

> On Thu, Jun 29, 2017 at 12:23:49PM -0400, David Miller wrote:
>> From: Corentin Labbe <clabbe.montjoie@gmail.com>
>> Date: Tue, 27 Jun 2017 11:28:01 +0200
>> 
>> > 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.
>> > 
>> > By using phy-mode = "internal" we permit to have an external PHY with
>> > the same mode than the internal one.
>> > 
>> > Reported-by: André Przywara <andre.przywara@arm.com>
>> > Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
>> 
>> Series applied.
>> 
>> Please provide a proper "[PATCH 0/n] " header posting next time.
> 
> Sorry could you wait for applying, there are a parallel thread (http://www.spinics.net/lists/devicetree/msg183520.html) and it seems finaly that internal could not be the good way to do it.
> 
> Regards
> Sorry again, I should have sent a comment for waiting.

Please send me a revert patch, when I say I've applied it I already pushed
it out to my GIT tree.
diff mbox

Patch

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
index fffd6d5fc907..6c2d1da05588 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
@@ -638,7 +638,7 @@  static int sun8i_dwmac_set_syscon(struct stmmac_priv *priv)
 {
 	struct sunxi_priv_data *gmac = priv->plat->bsp_priv;
 	struct device_node *node = priv->device->of_node;
-	int ret;
+	int ret, phy_interface;
 	u32 reg, val;
 
 	regmap_read(gmac->regmap, SYSCON_EMAC_REG, &val);
@@ -718,7 +718,11 @@  static int sun8i_dwmac_set_syscon(struct stmmac_priv *priv)
 	if (gmac->variant->support_rmii)
 		reg &= ~SYSCON_RMII_EN;
 
-	switch (priv->plat->interface) {
+	phy_interface = priv->plat->interface;
+	/* if PHY is internal, select the mode (xMII) used by the SoC */
+	if (gmac->use_internal_phy)
+		phy_interface = gmac->variant->internal_phy;
+	switch (phy_interface) {
 	case PHY_INTERFACE_MODE_MII:
 		/* default */
 		break;
@@ -932,7 +936,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 (plat_dat->interface == PHY_INTERFACE_MODE_INTERNAL) {
 		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);