This completes support for describing the XPCS in the device tree,
rather than just the case where sja1105_fill_device_tree() populates it.
Having it in the device tree is necessary when configuring lane polarity.
Cc: Rob Herring <robh@kernel.org>
Cc: Krzysztof Kozlowski <krzk+dt@kernel.org>
Cc: Conor Dooley <conor+dt@kernel.org>
Cc: devicetree@vger.kernel.org
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
drivers/net/dsa/sja1105/sja1105_main.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c
index 70aecdf9fd0e..e62b2facc1be 100644
--- a/drivers/net/dsa/sja1105/sja1105_main.c
+++ b/drivers/net/dsa/sja1105/sja1105_main.c
@@ -3035,14 +3035,26 @@ static int sja1105_port_bridge_flags(struct dsa_switch *ds, int port,
static int sja1105_create_pcs(struct dsa_switch *ds, int port)
{
+ struct dsa_port *dp = dsa_to_port(ds, port);
struct sja1105_private *priv = ds->priv;
+ struct fwnode_handle *pcs_fwnode;
struct phylink_pcs *pcs;
if (priv->phy_mode[port] != PHY_INTERFACE_MODE_SGMII &&
priv->phy_mode[port] != PHY_INTERFACE_MODE_2500BASEX)
return 0;
- pcs = xpcs_create_pcs_fwnode(priv->pcs_fwnode[port]);
+ pcs_fwnode = fwnode_handle_get(priv->pcs_fwnode[port]);
+ /* priv->pcs_fwnode[port] is only set if the PCS is absent
+ * from the device tree source. If present, there needs to
+ * be a pcs-handle to it.
+ */
+ if (!pcs_fwnode)
+ pcs_fwnode = fwnode_find_reference(of_fwnode_handle(dp->dn),
+ "pcs-handle", 0);
+
+ pcs = xpcs_create_pcs_fwnode(pcs_fwnode);
+ fwnode_handle_put(pcs_fwnode);
if (IS_ERR(pcs))
return PTR_ERR(pcs);
--
2.34.1