lkml.org 
[lkml]   [2019]   [Dec]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v2 1/3] net: macb: fix for fixed-link mode
    Date
    This patch fix the issue with fixed link. With fixed-link
    device opening fails due to macb_phylink_connect not
    handling fixed-link mode, in which case no MAC-PHY connection
    is needed and phylink_connect return success (0), however
    in current driver attempt is made to search and connect to
    PHY even for fixed-link.

    Signed-off-by: Milind Parab <mparab@cadence.com>
    ---
    drivers/net/ethernet/cadence/macb_main.c | 25 +++++++++++++++---------
    1 file changed, 16 insertions(+), 9 deletions(-)

    diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
    index 9c767ee252ac..8c1812f39927 100644
    --- a/drivers/net/ethernet/cadence/macb_main.c
    +++ b/drivers/net/ethernet/cadence/macb_main.c
    @@ -611,21 +611,25 @@ static const struct phylink_mac_ops macb_phylink_ops = {
    .mac_link_up = macb_mac_link_up,
    };

    +static bool macb_phy_handle_exists(struct device_node *dn)
    +{
    + dn = of_parse_phandle(dn, "phy-handle", 0);
    + of_node_put(dn);
    + return dn != NULL;
    +}
    +
    +
    static int macb_phylink_connect(struct macb *bp)
    {
    struct net_device *dev = bp->dev;
    struct phy_device *phydev;
    + struct device_node *dn = bp->pdev->dev.of_node;
    int ret;

    - if (bp->pdev->dev.of_node &&
    - of_parse_phandle(bp->pdev->dev.of_node, "phy-handle", 0)) {
    - ret = phylink_of_phy_connect(bp->phylink, bp->pdev->dev.of_node,
    - 0);
    - if (ret) {
    - netdev_err(dev, "Could not attach PHY (%d)\n", ret);
    - return ret;
    - }
    - } else {
    + if (dn)
    + ret = phylink_of_phy_connect(bp->phylink, dn, 0);
    +
    + if (!dn || (ret && !macb_phy_handle_exists(dn))) {
    phydev = phy_find_first(bp->mii_bus);
    if (!phydev) {
    netdev_err(dev, "no PHY found\n");
    @@ -638,6 +642,9 @@ static int macb_phylink_connect(struct macb *bp)
    netdev_err(dev, "Could not attach to PHY (%d)\n", ret);
    return ret;
    }
    + } else if (ret) {
    + netdev_err(dev, "Could not attach PHY (%d)\n", ret);
    + return ret;
    }

    phylink_start(bp->phylink);
    --
    2.17.1
    \
     
     \ /
      Last update: 2019-12-13 10:42    [W:3.948 / U:0.080 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site