Skip to content

Commit

Permalink
net: dpaa2: add support for retimer runtime configuration
Browse files Browse the repository at this point in the history
Extend the dpaa2-eth driver so that it's able to get a handle to a
PHY retimer device and to reconnfigure it in case the interface type
changes.

Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
  • Loading branch information
IoanaCiornei committed Apr 27, 2023
1 parent 37f1cf5 commit 627c5f6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
17 changes: 17 additions & 0 deletions drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,13 @@ static void dpaa2_mac_config(struct phylink_config *config, unsigned int mode,
err = phy_set_mode_ext(mac->serdes_phy, PHY_MODE_ETHERNET, state->interface);
if (err)
netdev_err(mac->net_dev, "phy_set_mode_ext() = %d\n", err);

if (!mac->retimer_phy)
return;

err = phy_set_mode_ext(mac->retimer_phy, PHY_MODE_ETHERNET, state->interface);
if (err)
netdev_err(mac->net_dev, "phy_set_mode_ext() on retimer = %d\n", err);
}

static void dpaa2_mac_link_up(struct phylink_config *config,
Expand Down Expand Up @@ -364,6 +371,7 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac)
{
struct net_device *net_dev = mac->net_dev;
struct fwnode_handle *dpmac_node;
struct phy *retimer_phy = NULL;
struct phy *serdes_phy = NULL;
struct phylink *phylink;
int err;
Expand Down Expand Up @@ -392,8 +400,17 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac)
return PTR_ERR(serdes_phy);
else
phy_init(serdes_phy);

retimer_phy = of_phy_get(to_of_node(dpmac_node), "retimer");
if (retimer_phy == ERR_PTR(-ENODEV))
retimer_phy = NULL;
else if (IS_ERR(retimer_phy))
return PTR_ERR(retimer_phy);
else
phy_init(retimer_phy);
}
mac->serdes_phy = serdes_phy;
mac->retimer_phy = retimer_phy;

/* The MAC does not have the capability to add RGMII delays so
* error out if the interface mode requests them and there is no PHY
Expand Down
2 changes: 2 additions & 0 deletions drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ struct dpaa2_mac {
struct fwnode_handle *fw_node;

struct phy *serdes_phy;
struct phy *retimer_phy;

int phy_req_state;
};

Expand Down

0 comments on commit 627c5f6

Please sign in to comment.