mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-28 11:18:45 +07:00
net: bcmgenet: refactor phy mode configuration
The DT phy mode is similar to what we want for ACPI lets factor it out of the of path, and change the of_ call to device_. Signed-off-by: Jeremy Linton <jeremy.linton@arm.com> Acked-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
ce69e2162f
commit
480ded2652
@ -477,12 +477,33 @@ static int bcmgenet_mii_register(struct bcmgenet_priv *priv)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int bcmgenet_phy_interface_init(struct bcmgenet_priv *priv)
|
||||||
|
{
|
||||||
|
struct device *kdev = &priv->pdev->dev;
|
||||||
|
int phy_mode = device_get_phy_mode(kdev);
|
||||||
|
|
||||||
|
if (phy_mode < 0) {
|
||||||
|
dev_err(kdev, "invalid PHY mode property\n");
|
||||||
|
return phy_mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
priv->phy_interface = phy_mode;
|
||||||
|
|
||||||
|
/* We need to specifically look up whether this PHY interface is
|
||||||
|
* internal or not *before* we even try to probe the PHY driver
|
||||||
|
* over MDIO as we may have shut down the internal PHY for power
|
||||||
|
* saving purposes.
|
||||||
|
*/
|
||||||
|
if (priv->phy_interface == PHY_INTERFACE_MODE_INTERNAL)
|
||||||
|
priv->internal_phy = true;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int bcmgenet_mii_of_init(struct bcmgenet_priv *priv)
|
static int bcmgenet_mii_of_init(struct bcmgenet_priv *priv)
|
||||||
{
|
{
|
||||||
struct device_node *dn = priv->pdev->dev.of_node;
|
struct device_node *dn = priv->pdev->dev.of_node;
|
||||||
struct device *kdev = &priv->pdev->dev;
|
|
||||||
struct phy_device *phydev;
|
struct phy_device *phydev;
|
||||||
phy_interface_t phy_mode;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Fetch the PHY phandle */
|
/* Fetch the PHY phandle */
|
||||||
@ -500,23 +521,12 @@ static int bcmgenet_mii_of_init(struct bcmgenet_priv *priv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Get the link mode */
|
/* Get the link mode */
|
||||||
ret = of_get_phy_mode(dn, &phy_mode);
|
ret = bcmgenet_phy_interface_init(priv);
|
||||||
if (ret) {
|
if (ret)
|
||||||
dev_err(kdev, "invalid PHY mode property\n");
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
|
||||||
|
|
||||||
priv->phy_interface = phy_mode;
|
|
||||||
|
|
||||||
/* We need to specifically look up whether this PHY interface is internal
|
|
||||||
* or not *before* we even try to probe the PHY driver over MDIO as we
|
|
||||||
* may have shut down the internal PHY for power saving purposes.
|
|
||||||
*/
|
|
||||||
if (priv->phy_interface == PHY_INTERFACE_MODE_INTERNAL)
|
|
||||||
priv->internal_phy = true;
|
|
||||||
|
|
||||||
/* Make sure we initialize MoCA PHYs with a link down */
|
/* Make sure we initialize MoCA PHYs with a link down */
|
||||||
if (phy_mode == PHY_INTERFACE_MODE_MOCA) {
|
if (priv->phy_interface == PHY_INTERFACE_MODE_MOCA) {
|
||||||
phydev = of_phy_find_device(dn);
|
phydev = of_phy_find_device(dn);
|
||||||
if (phydev) {
|
if (phydev) {
|
||||||
phydev->link = 0;
|
phydev->link = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user