|
@@ -163,16 +163,6 @@ void bcmgenet_mii_setup(struct net_device *dev)
|
|
|
phy_print_status(phydev);
|
|
phy_print_status(phydev);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void bcmgenet_mii_reset(struct net_device *dev)
|
|
|
|
|
-{
|
|
|
|
|
- struct bcmgenet_priv *priv = netdev_priv(dev);
|
|
|
|
|
-
|
|
|
|
|
- if (priv->phydev) {
|
|
|
|
|
- phy_init_hw(priv->phydev);
|
|
|
|
|
- phy_start_aneg(priv->phydev);
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
void bcmgenet_phy_power_set(struct net_device *dev, bool enable)
|
|
void bcmgenet_phy_power_set(struct net_device *dev, bool enable)
|
|
|
{
|
|
{
|
|
|
struct bcmgenet_priv *priv = netdev_priv(dev);
|
|
struct bcmgenet_priv *priv = netdev_priv(dev);
|
|
@@ -215,7 +205,6 @@ static void bcmgenet_internal_phy_setup(struct net_device *dev)
|
|
|
reg = bcmgenet_ext_readl(priv, EXT_EXT_PWR_MGMT);
|
|
reg = bcmgenet_ext_readl(priv, EXT_EXT_PWR_MGMT);
|
|
|
reg |= EXT_PWR_DN_EN_LD;
|
|
reg |= EXT_PWR_DN_EN_LD;
|
|
|
bcmgenet_ext_writel(priv, reg, EXT_EXT_PWR_MGMT);
|
|
bcmgenet_ext_writel(priv, reg, EXT_EXT_PWR_MGMT);
|
|
|
- bcmgenet_mii_reset(dev);
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static void bcmgenet_moca_phy_setup(struct bcmgenet_priv *priv)
|
|
static void bcmgenet_moca_phy_setup(struct bcmgenet_priv *priv)
|
|
@@ -228,7 +217,7 @@ static void bcmgenet_moca_phy_setup(struct bcmgenet_priv *priv)
|
|
|
bcmgenet_sys_writel(priv, reg, SYS_PORT_CTRL);
|
|
bcmgenet_sys_writel(priv, reg, SYS_PORT_CTRL);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-int bcmgenet_mii_config(struct net_device *dev, bool init)
|
|
|
|
|
|
|
+int bcmgenet_mii_config(struct net_device *dev)
|
|
|
{
|
|
{
|
|
|
struct bcmgenet_priv *priv = netdev_priv(dev);
|
|
struct bcmgenet_priv *priv = netdev_priv(dev);
|
|
|
struct phy_device *phydev = priv->phydev;
|
|
struct phy_device *phydev = priv->phydev;
|
|
@@ -238,10 +227,10 @@ int bcmgenet_mii_config(struct net_device *dev, bool init)
|
|
|
u32 port_ctrl;
|
|
u32 port_ctrl;
|
|
|
u32 reg;
|
|
u32 reg;
|
|
|
|
|
|
|
|
- priv->ext_phy = !phy_is_internal(priv->phydev) &&
|
|
|
|
|
|
|
+ priv->ext_phy = !priv->internal_phy &&
|
|
|
(priv->phy_interface != PHY_INTERFACE_MODE_MOCA);
|
|
(priv->phy_interface != PHY_INTERFACE_MODE_MOCA);
|
|
|
|
|
|
|
|
- if (phy_is_internal(priv->phydev))
|
|
|
|
|
|
|
+ if (priv->internal_phy)
|
|
|
priv->phy_interface = PHY_INTERFACE_MODE_NA;
|
|
priv->phy_interface = PHY_INTERFACE_MODE_NA;
|
|
|
|
|
|
|
|
switch (priv->phy_interface) {
|
|
switch (priv->phy_interface) {
|
|
@@ -259,7 +248,7 @@ int bcmgenet_mii_config(struct net_device *dev, bool init)
|
|
|
|
|
|
|
|
bcmgenet_sys_writel(priv, port_ctrl, SYS_PORT_CTRL);
|
|
bcmgenet_sys_writel(priv, port_ctrl, SYS_PORT_CTRL);
|
|
|
|
|
|
|
|
- if (phy_is_internal(priv->phydev)) {
|
|
|
|
|
|
|
+ if (priv->internal_phy) {
|
|
|
phy_name = "internal PHY";
|
|
phy_name = "internal PHY";
|
|
|
bcmgenet_internal_phy_setup(dev);
|
|
bcmgenet_internal_phy_setup(dev);
|
|
|
} else if (priv->phy_interface == PHY_INTERFACE_MODE_MOCA) {
|
|
} else if (priv->phy_interface == PHY_INTERFACE_MODE_MOCA) {
|
|
@@ -321,13 +310,12 @@ int bcmgenet_mii_config(struct net_device *dev, bool init)
|
|
|
bcmgenet_ext_writel(priv, reg, EXT_RGMII_OOB_CTRL);
|
|
bcmgenet_ext_writel(priv, reg, EXT_RGMII_OOB_CTRL);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (init)
|
|
|
|
|
- dev_info(kdev, "configuring instance for %s\n", phy_name);
|
|
|
|
|
|
|
+ dev_info_once(kdev, "configuring instance for %s\n", phy_name);
|
|
|
|
|
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-static int bcmgenet_mii_probe(struct net_device *dev)
|
|
|
|
|
|
|
+int bcmgenet_mii_probe(struct net_device *dev)
|
|
|
{
|
|
{
|
|
|
struct bcmgenet_priv *priv = netdev_priv(dev);
|
|
struct bcmgenet_priv *priv = netdev_priv(dev);
|
|
|
struct device_node *dn = priv->pdev->dev.of_node;
|
|
struct device_node *dn = priv->pdev->dev.of_node;
|
|
@@ -345,22 +333,6 @@ static int bcmgenet_mii_probe(struct net_device *dev)
|
|
|
priv->old_pause = -1;
|
|
priv->old_pause = -1;
|
|
|
|
|
|
|
|
if (dn) {
|
|
if (dn) {
|
|
|
- if (priv->phydev) {
|
|
|
|
|
- pr_info("PHY already attached\n");
|
|
|
|
|
- return 0;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /* In the case of a fixed PHY, the DT node associated
|
|
|
|
|
- * to the PHY is the Ethernet MAC DT node.
|
|
|
|
|
- */
|
|
|
|
|
- if (!priv->phy_dn && of_phy_is_fixed_link(dn)) {
|
|
|
|
|
- ret = of_phy_register_fixed_link(dn);
|
|
|
|
|
- if (ret)
|
|
|
|
|
- return ret;
|
|
|
|
|
-
|
|
|
|
|
- priv->phy_dn = of_node_get(dn);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
phydev = of_phy_connect(dev, priv->phy_dn, bcmgenet_mii_setup,
|
|
phydev = of_phy_connect(dev, priv->phy_dn, bcmgenet_mii_setup,
|
|
|
phy_flags, priv->phy_interface);
|
|
phy_flags, priv->phy_interface);
|
|
|
if (!phydev) {
|
|
if (!phydev) {
|
|
@@ -386,7 +358,7 @@ static int bcmgenet_mii_probe(struct net_device *dev)
|
|
|
* PHY speed which is needed for bcmgenet_mii_config() to configure
|
|
* PHY speed which is needed for bcmgenet_mii_config() to configure
|
|
|
* things appropriately.
|
|
* things appropriately.
|
|
|
*/
|
|
*/
|
|
|
- ret = bcmgenet_mii_config(dev, true);
|
|
|
|
|
|
|
+ ret = bcmgenet_mii_config(dev);
|
|
|
if (ret) {
|
|
if (ret) {
|
|
|
phy_disconnect(priv->phydev);
|
|
phy_disconnect(priv->phydev);
|
|
|
return ret;
|
|
return ret;
|
|
@@ -397,14 +369,11 @@ static int bcmgenet_mii_probe(struct net_device *dev)
|
|
|
/* The internal PHY has its link interrupts routed to the
|
|
/* The internal PHY has its link interrupts routed to the
|
|
|
* Ethernet MAC ISRs
|
|
* Ethernet MAC ISRs
|
|
|
*/
|
|
*/
|
|
|
- if (phy_is_internal(priv->phydev))
|
|
|
|
|
|
|
+ if (priv->internal_phy)
|
|
|
priv->mii_bus->irq[phydev->addr] = PHY_IGNORE_INTERRUPT;
|
|
priv->mii_bus->irq[phydev->addr] = PHY_IGNORE_INTERRUPT;
|
|
|
else
|
|
else
|
|
|
priv->mii_bus->irq[phydev->addr] = PHY_POLL;
|
|
priv->mii_bus->irq[phydev->addr] = PHY_POLL;
|
|
|
|
|
|
|
|
- pr_info("attached PHY at address %d [%s]\n",
|
|
|
|
|
- phydev->addr, phydev->drv->name);
|
|
|
|
|
-
|
|
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -490,7 +459,9 @@ 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 device *kdev = &priv->pdev->dev;
|
|
|
|
|
+ const char *phy_mode_str = NULL;
|
|
|
char *compat;
|
|
char *compat;
|
|
|
|
|
+ int phy_mode;
|
|
|
int ret;
|
|
int ret;
|
|
|
|
|
|
|
|
compat = kasprintf(GFP_KERNEL, "brcm,genet-mdio-v%d", priv->version);
|
|
compat = kasprintf(GFP_KERNEL, "brcm,genet-mdio-v%d", priv->version);
|
|
@@ -513,8 +484,36 @@ static int bcmgenet_mii_of_init(struct bcmgenet_priv *priv)
|
|
|
/* Fetch the PHY phandle */
|
|
/* Fetch the PHY phandle */
|
|
|
priv->phy_dn = of_parse_phandle(dn, "phy-handle", 0);
|
|
priv->phy_dn = of_parse_phandle(dn, "phy-handle", 0);
|
|
|
|
|
|
|
|
|
|
+ /* In the case of a fixed PHY, the DT node associated
|
|
|
|
|
+ * to the PHY is the Ethernet MAC DT node.
|
|
|
|
|
+ */
|
|
|
|
|
+ if (!priv->phy_dn && of_phy_is_fixed_link(dn)) {
|
|
|
|
|
+ ret = of_phy_register_fixed_link(dn);
|
|
|
|
|
+ if (ret)
|
|
|
|
|
+ return ret;
|
|
|
|
|
+
|
|
|
|
|
+ priv->phy_dn = of_node_get(dn);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/* Get the link mode */
|
|
/* Get the link mode */
|
|
|
- priv->phy_interface = of_get_phy_mode(dn);
|
|
|
|
|
|
|
+ phy_mode = of_get_phy_mode(dn);
|
|
|
|
|
+ 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 (phy_mode < 0) {
|
|
|
|
|
+ ret = of_property_read_string(dn, "phy-mode", &phy_mode_str);
|
|
|
|
|
+ if (ret < 0) {
|
|
|
|
|
+ dev_err(kdev, "invalid PHY mode property\n");
|
|
|
|
|
+ return ret;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ priv->phy_interface = PHY_INTERFACE_MODE_NA;
|
|
|
|
|
+ if (!strcasecmp(phy_mode_str, "internal"))
|
|
|
|
|
+ priv->internal_phy = true;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
@@ -614,10 +613,6 @@ int bcmgenet_mii_init(struct net_device *dev)
|
|
|
return ret;
|
|
return ret;
|
|
|
|
|
|
|
|
ret = bcmgenet_mii_bus_init(priv);
|
|
ret = bcmgenet_mii_bus_init(priv);
|
|
|
- if (ret)
|
|
|
|
|
- goto out_free;
|
|
|
|
|
-
|
|
|
|
|
- ret = bcmgenet_mii_probe(dev);
|
|
|
|
|
if (ret)
|
|
if (ret)
|
|
|
goto out;
|
|
goto out;
|
|
|
|
|
|
|
@@ -626,7 +621,6 @@ int bcmgenet_mii_init(struct net_device *dev)
|
|
|
out:
|
|
out:
|
|
|
of_node_put(priv->phy_dn);
|
|
of_node_put(priv->phy_dn);
|
|
|
mdiobus_unregister(priv->mii_bus);
|
|
mdiobus_unregister(priv->mii_bus);
|
|
|
-out_free:
|
|
|
|
|
kfree(priv->mii_bus->irq);
|
|
kfree(priv->mii_bus->irq);
|
|
|
mdiobus_free(priv->mii_bus);
|
|
mdiobus_free(priv->mii_bus);
|
|
|
return ret;
|
|
return ret;
|