Commit 29afb83a authored by Vladimir Oltean's avatar Vladimir Oltean Committed by David S. Miller

net: dsa: sja1105: apply RGMII delays based on the fixed-link property

The sja1105 driver has an intermediate way of determining whether the
RGMII delays should be applied by the PHY or by itself: by looking at
the port role (PHY or MAC). The port can be put in the PHY role either
explicitly (sja1105,role-phy) or implicitly (fixed-link).

We want to deprecate the sja1105,role-phy property, so all that remains
is the fixed-link property. Introduce a "fixed_link" array of booleans
in the driver, and use that to determine whether RGMII delays must be
applied or not.
Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c858d436
...@@ -226,6 +226,7 @@ struct sja1105_private { ...@@ -226,6 +226,7 @@ struct sja1105_private {
bool rgmii_rx_delay[SJA1105_MAX_NUM_PORTS]; bool rgmii_rx_delay[SJA1105_MAX_NUM_PORTS];
bool rgmii_tx_delay[SJA1105_MAX_NUM_PORTS]; bool rgmii_tx_delay[SJA1105_MAX_NUM_PORTS];
phy_interface_t phy_mode[SJA1105_MAX_NUM_PORTS]; phy_interface_t phy_mode[SJA1105_MAX_NUM_PORTS];
bool fixed_link[SJA1105_MAX_NUM_PORTS];
bool best_effort_vlan_filtering; bool best_effort_vlan_filtering;
unsigned long learn_ena; unsigned long learn_ena;
unsigned long ucast_egress_floods; unsigned long ucast_egress_floods;
......
...@@ -799,26 +799,25 @@ static int sja1105_static_config_load(struct sja1105_private *priv, ...@@ -799,26 +799,25 @@ static int sja1105_static_config_load(struct sja1105_private *priv,
return sja1105_static_config_upload(priv); return sja1105_static_config_upload(priv);
} }
static int sja1105_parse_rgmii_delays(struct sja1105_private *priv, static int sja1105_parse_rgmii_delays(struct sja1105_private *priv)
const struct sja1105_dt_port *ports)
{ {
struct dsa_switch *ds = priv->ds; struct dsa_switch *ds = priv->ds;
int i; int port;
for (i = 0; i < ds->num_ports; i++) { for (port = 0; port < ds->num_ports; port++) {
if (ports[i].role == XMII_MAC) if (!priv->fixed_link[port])
continue; continue;
if (ports[i].phy_mode == PHY_INTERFACE_MODE_RGMII_RXID || if (priv->phy_mode[port] == PHY_INTERFACE_MODE_RGMII_RXID ||
ports[i].phy_mode == PHY_INTERFACE_MODE_RGMII_ID) priv->phy_mode[port] == PHY_INTERFACE_MODE_RGMII_ID)
priv->rgmii_rx_delay[i] = true; priv->rgmii_rx_delay[port] = true;
if (ports[i].phy_mode == PHY_INTERFACE_MODE_RGMII_TXID || if (priv->phy_mode[port] == PHY_INTERFACE_MODE_RGMII_TXID ||
ports[i].phy_mode == PHY_INTERFACE_MODE_RGMII_ID) priv->phy_mode[port] == PHY_INTERFACE_MODE_RGMII_ID)
priv->rgmii_tx_delay[i] = true; priv->rgmii_tx_delay[port] = true;
if ((priv->rgmii_rx_delay[i] || priv->rgmii_tx_delay[i]) && if ((priv->rgmii_rx_delay[port] || priv->rgmii_tx_delay[port]) &&
!priv->info->setup_rgmii_delay) !priv->info->setup_rgmii_delay)
return -EINVAL; return -EINVAL;
} }
return 0; return 0;
...@@ -867,6 +866,7 @@ static int sja1105_parse_ports_node(struct sja1105_private *priv, ...@@ -867,6 +866,7 @@ static int sja1105_parse_ports_node(struct sja1105_private *priv,
/* phy-handle is missing, but fixed-link isn't. /* phy-handle is missing, but fixed-link isn't.
* So it's a fixed link. Default to PHY role. * So it's a fixed link. Default to PHY role.
*/ */
priv->fixed_link[index] = true;
ports[index].role = XMII_PHY; ports[index].role = XMII_PHY;
} else { } else {
/* phy-handle present => put port in MAC role */ /* phy-handle present => put port in MAC role */
...@@ -3021,7 +3021,7 @@ static int sja1105_setup(struct dsa_switch *ds) ...@@ -3021,7 +3021,7 @@ static int sja1105_setup(struct dsa_switch *ds)
/* Error out early if internal delays are required through DT /* Error out early if internal delays are required through DT
* and we can't apply them. * and we can't apply them.
*/ */
rc = sja1105_parse_rgmii_delays(priv, ports); rc = sja1105_parse_rgmii_delays(priv);
if (rc < 0) { if (rc < 0) {
dev_err(ds->dev, "RGMII delay not supported\n"); dev_err(ds->dev, "RGMII delay not supported\n");
return rc; return rc;
......
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