Skip to content

Commit 1c2fa5f

Browse files
montjoiedavem330
authored andcommitted
net: stmmac: support future possible different internal phy mode
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 <[email protected]> Signed-off-by: Corentin Labbe <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent eac306b commit 1c2fa5f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ static int sun8i_dwmac_set_syscon(struct stmmac_priv *priv)
638638
{
639639
struct sunxi_priv_data *gmac = priv->plat->bsp_priv;
640640
struct device_node *node = priv->device->of_node;
641-
int ret;
641+
int ret, phy_interface;
642642
u32 reg, val;
643643

644644
regmap_read(gmac->regmap, SYSCON_EMAC_REG, &val);
@@ -718,7 +718,11 @@ static int sun8i_dwmac_set_syscon(struct stmmac_priv *priv)
718718
if (gmac->variant->support_rmii)
719719
reg &= ~SYSCON_RMII_EN;
720720

721-
switch (priv->plat->interface) {
721+
phy_interface = priv->plat->interface;
722+
/* if PHY is internal, select the mode (xMII) used by the SoC */
723+
if (gmac->use_internal_phy)
724+
phy_interface = gmac->variant->internal_phy;
725+
switch (phy_interface) {
722726
case PHY_INTERFACE_MODE_MII:
723727
/* default */
724728
break;
@@ -932,7 +936,7 @@ static int sun8i_dwmac_probe(struct platform_device *pdev)
932936
}
933937

934938
plat_dat->interface = of_get_phy_mode(dev->of_node);
935-
if (plat_dat->interface == gmac->variant->internal_phy) {
939+
if (plat_dat->interface == PHY_INTERFACE_MODE_INTERNAL) {
936940
dev_info(&pdev->dev, "Will use internal PHY\n");
937941
gmac->use_internal_phy = true;
938942
gmac->ephy_clk = of_clk_get(plat_dat->phy_node, 0);

0 commit comments

Comments
 (0)