Commit 1c2fa5f8 authored by LABBE Corentin's avatar LABBE Corentin Committed by David S. Miller

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: default avatarAndré Przywara <andre.przywara@arm.com>
Signed-off-by: default avatarCorentin Labbe <clabbe.montjoie@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent eac306b4
...@@ -638,7 +638,7 @@ static int sun8i_dwmac_set_syscon(struct stmmac_priv *priv) ...@@ -638,7 +638,7 @@ static int sun8i_dwmac_set_syscon(struct stmmac_priv *priv)
{ {
struct sunxi_priv_data *gmac = priv->plat->bsp_priv; struct sunxi_priv_data *gmac = priv->plat->bsp_priv;
struct device_node *node = priv->device->of_node; struct device_node *node = priv->device->of_node;
int ret; int ret, phy_interface;
u32 reg, val; u32 reg, val;
regmap_read(gmac->regmap, SYSCON_EMAC_REG, &val); regmap_read(gmac->regmap, SYSCON_EMAC_REG, &val);
...@@ -718,7 +718,11 @@ static int sun8i_dwmac_set_syscon(struct stmmac_priv *priv) ...@@ -718,7 +718,11 @@ static int sun8i_dwmac_set_syscon(struct stmmac_priv *priv)
if (gmac->variant->support_rmii) if (gmac->variant->support_rmii)
reg &= ~SYSCON_RMII_EN; 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: case PHY_INTERFACE_MODE_MII:
/* default */ /* default */
break; break;
...@@ -932,7 +936,7 @@ static int sun8i_dwmac_probe(struct platform_device *pdev) ...@@ -932,7 +936,7 @@ static int sun8i_dwmac_probe(struct platform_device *pdev)
} }
plat_dat->interface = of_get_phy_mode(dev->of_node); 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"); dev_info(&pdev->dev, "Will use internal PHY\n");
gmac->use_internal_phy = true; gmac->use_internal_phy = true;
gmac->ephy_clk = of_clk_get(plat_dat->phy_node, 0); gmac->ephy_clk = of_clk_get(plat_dat->phy_node, 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment