public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/6] net: stmmac: support future possible different internal phy mode
@ 2017-06-27  9:28 Corentin Labbe
  2017-06-27  9:28 ` [PATCH 2/6] arm: sun8i: orangepipc: use internal phy-mode Corentin Labbe
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: Corentin Labbe @ 2017-06-27  9:28 UTC (permalink / raw)
  To: robh+dt, mark.rutland, linux, maxime.ripard, wens,
	peppe.cavallaro, alexandre.torgue, andre.przywara
  Cc: devicetree, linux-arm-kernel, linux-kernel, netdev, linux-sunxi,
	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.

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(-)

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);
-- 
2.13.0

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2017-06-29 20:05 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-27  9:28 [PATCH 1/6] net: stmmac: support future possible different internal phy mode Corentin Labbe
2017-06-27  9:28 ` [PATCH 2/6] arm: sun8i: orangepipc: use internal phy-mode Corentin Labbe
2017-06-27  9:28 ` [PATCH 3/6] arm: sun8i: orangepi-zero: " Corentin Labbe
2017-06-27  9:28 ` [PATCH 4/6] arm: sun8i: orangepi-one: " Corentin Labbe
2017-06-27  9:28 ` [PATCH 5/6] arm: sun8i: nanopi-neo: " Corentin Labbe
2017-06-27  9:28 ` [PATCH 6/6] arm: sun8i: orangepi-2: " Corentin Labbe
2017-06-29 16:23 ` [PATCH 1/6] net: stmmac: support future possible different internal phy mode David Miller
2017-06-29 16:46   ` [linux-sunxi] " icenowy
2017-06-29 17:02   ` Corentin Labbe
2017-06-29 20:05     ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox