Commit b193f2ed authored by Ioana Ciornei's avatar Ioana Ciornei Committed by David S. Miller

dpaa2-eth: setup the of_node field of the device

When the DPNI object is connected to a DPMAC, setup the of_node to point
to the DTS device node of that specific MAC. This enables other drivers,
for example the DSA subsystem, to find the net_device by its device
node.
Signed-off-by: default avatarIoana Ciornei <ioana.ciornei@nxp.com>
Reviewed-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
Tested-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f07b300c
...@@ -289,17 +289,15 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac) ...@@ -289,17 +289,15 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac)
mac->if_link_type = mac->attr.link_type; mac->if_link_type = mac->attr.link_type;
dpmac_node = dpaa2_mac_get_node(mac->attr.id); dpmac_node = mac->of_node;
if (!dpmac_node) { if (!dpmac_node) {
netdev_err(net_dev, "No dpmac@%d node found.\n", mac->attr.id); netdev_err(net_dev, "No dpmac@%d node found.\n", mac->attr.id);
return -ENODEV; return -ENODEV;
} }
err = dpaa2_mac_get_if_mode(dpmac_node, mac->attr); err = dpaa2_mac_get_if_mode(dpmac_node, mac->attr);
if (err < 0) { if (err < 0)
err = -EINVAL; return -EINVAL;
goto err_put_node;
}
mac->if_mode = err; mac->if_mode = err;
/* The MAC does not have the capability to add RGMII delays so /* The MAC does not have the capability to add RGMII delays so
...@@ -311,8 +309,7 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac) ...@@ -311,8 +309,7 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac)
mac->if_mode == PHY_INTERFACE_MODE_RGMII_RXID || mac->if_mode == PHY_INTERFACE_MODE_RGMII_RXID ||
mac->if_mode == PHY_INTERFACE_MODE_RGMII_TXID)) { mac->if_mode == PHY_INTERFACE_MODE_RGMII_TXID)) {
netdev_err(net_dev, "RGMII delay not supported\n"); netdev_err(net_dev, "RGMII delay not supported\n");
err = -EINVAL; return -EINVAL;
goto err_put_node;
} }
if ((mac->attr.link_type == DPMAC_LINK_TYPE_PHY && if ((mac->attr.link_type == DPMAC_LINK_TYPE_PHY &&
...@@ -320,7 +317,7 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac) ...@@ -320,7 +317,7 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac)
mac->attr.link_type == DPMAC_LINK_TYPE_BACKPLANE) { mac->attr.link_type == DPMAC_LINK_TYPE_BACKPLANE) {
err = dpaa2_pcs_create(mac, dpmac_node, mac->attr.id); err = dpaa2_pcs_create(mac, dpmac_node, mac->attr.id);
if (err) if (err)
goto err_put_node; return err;
} }
mac->phylink_config.dev = &net_dev->dev; mac->phylink_config.dev = &net_dev->dev;
...@@ -344,16 +341,12 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac) ...@@ -344,16 +341,12 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac)
goto err_phylink_destroy; goto err_phylink_destroy;
} }
of_node_put(dpmac_node);
return 0; return 0;
err_phylink_destroy: err_phylink_destroy:
phylink_destroy(mac->phylink); phylink_destroy(mac->phylink);
err_pcs_destroy: err_pcs_destroy:
dpaa2_pcs_destroy(mac); dpaa2_pcs_destroy(mac);
err_put_node:
of_node_put(dpmac_node);
return err; return err;
} }
...@@ -388,6 +381,12 @@ int dpaa2_mac_open(struct dpaa2_mac *mac) ...@@ -388,6 +381,12 @@ int dpaa2_mac_open(struct dpaa2_mac *mac)
goto err_close_dpmac; goto err_close_dpmac;
} }
/* Find the device node representing the MAC device and link the device
* behind the associated netdev to it.
*/
mac->of_node = dpaa2_mac_get_node(mac->attr.id);
net_dev->dev.of_node = mac->of_node;
return 0; return 0;
err_close_dpmac: err_close_dpmac:
...@@ -400,6 +399,8 @@ void dpaa2_mac_close(struct dpaa2_mac *mac) ...@@ -400,6 +399,8 @@ void dpaa2_mac_close(struct dpaa2_mac *mac)
struct fsl_mc_device *dpmac_dev = mac->mc_dev; struct fsl_mc_device *dpmac_dev = mac->mc_dev;
dpmac_close(mac->mc_io, 0, dpmac_dev->mc_handle); dpmac_close(mac->mc_io, 0, dpmac_dev->mc_handle);
if (mac->of_node)
of_node_put(mac->of_node);
} }
static char dpaa2_mac_ethtool_stats[][ETH_GSTRING_LEN] = { static char dpaa2_mac_ethtool_stats[][ETH_GSTRING_LEN] = {
......
...@@ -24,6 +24,7 @@ struct dpaa2_mac { ...@@ -24,6 +24,7 @@ struct dpaa2_mac {
phy_interface_t if_mode; phy_interface_t if_mode;
enum dpmac_link_type if_link_type; enum dpmac_link_type if_link_type;
struct lynx_pcs *pcs; struct lynx_pcs *pcs;
struct device_node *of_node;
}; };
bool dpaa2_mac_is_type_fixed(struct fsl_mc_device *dpmac_dev, bool dpaa2_mac_is_type_fixed(struct fsl_mc_device *dpmac_dev,
......
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