Commit 0abccaf0 authored by Jakub Kicinski's avatar Jakub Kicinski

Merge branch 'net-phylink-rearrange-ovr_an_inband-support'

Russell King says:

====================
net: phylink: rearrange ovr_an_inband support

This series addresses the use of the ovr_an_inband flag, which is used
by two drivers to indicate to phylink that they wish to use inband mode
without firmware specifying inband mode.

The issue with ovr_an_inband is that it overrides not only PHY mode,
but also fixed-link mode. Both of the drivers that set this flag
contain code to detect when fixed-link mode will be used, and then
either avoid setting it or explicitly clear the flag. This is
wasteful when phylink already knows this.

Therefore, the approach taken in this patch set is to replace the
ovr_an_inband flag with a default_an_inband flag which means that
phylink defaults to MLO_AN_INBAND instead of MLO_AN_PHY, and will
allow that default to be overriden if firmware specifies a fixed-link.
This allows users of ovr_an_inband to be simplified.

What's more is this requires minimal changes in phylink to allow this
new mode of operation.

This series changes phylink, and also updates the two drivers
(fman_memac and stmmac), and then removes the unnecessary complexity
from the drivers.

This series may depend on the stmmac cleanup series I've posted
earlier - this is something I have not checked, but I currently have
these patches on top of that series.
====================

Link: https://lore.kernel.org/r/ZlctinnTT8Xhemsm@shell.armlinux.org.ukSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 2f19a795 ab77c7aa
......@@ -1066,7 +1066,6 @@ int memac_initialization(struct mac_device *mac_dev,
struct fman_mac_params *params)
{
int err;
struct device_node *fixed;
struct phylink_pcs *pcs;
struct fman_mac *memac;
unsigned long capabilities;
......@@ -1222,18 +1221,15 @@ int memac_initialization(struct mac_device *mac_dev,
memac->rgmii_no_half_duplex = true;
/* Most boards should use MLO_AN_INBAND, but existing boards don't have
* a managed property. Default to MLO_AN_INBAND if nothing else is
* specified. We need to be careful and not enable this if we have a
* fixed link or if we are using MII or RGMII, since those
* configurations modes don't use in-band autonegotiation.
* a managed property. Default to MLO_AN_INBAND rather than MLO_AN_PHY.
* Phylink will allow this to be overriden by a fixed link. We need to
* be careful and not enable this if we are using MII or RGMII, since
* those configurations modes don't use in-band autonegotiation.
*/
fixed = of_get_child_by_name(mac_node, "fixed-link");
if (!fixed && !of_property_read_bool(mac_node, "fixed-link") &&
!of_property_read_bool(mac_node, "managed") &&
if (!of_property_read_bool(mac_node, "managed") &&
mac_dev->phy_if != PHY_INTERFACE_MODE_MII &&
!phy_interface_mode_is_rgmii(mac_dev->phy_if))
mac_dev->phylink_config.ovr_an_inband = true;
of_node_put(fixed);
mac_dev->phylink_config.default_an_inband = true;
err = memac_init(mac_dev->fman_mac);
if (err < 0)
......
......@@ -248,7 +248,7 @@ static void intel_speed_mode_2500(struct net_device *ndev, void *intel_data)
dev_info(priv->device, "Link Speed Mode: 2.5Gbps\n");
priv->plat->max_speed = 2500;
priv->plat->phy_interface = PHY_INTERFACE_MODE_2500BASEX;
priv->plat->mdio_bus_data->xpcs_an_inband = false;
priv->plat->mdio_bus_data->default_an_inband = false;
} else {
priv->plat->max_speed = 1000;
}
......@@ -586,18 +586,7 @@ static int intel_mgbe_common_data(struct pci_dev *pdev,
if (plat->phy_interface == PHY_INTERFACE_MODE_SGMII ||
plat->phy_interface == PHY_INTERFACE_MODE_1000BASEX) {
plat->mdio_bus_data->has_xpcs = true;
plat->mdio_bus_data->xpcs_an_inband = true;
}
/* For fixed-link setup, we clear xpcs_an_inband */
if (fwnode) {
struct fwnode_handle *fixed_node;
fixed_node = fwnode_get_named_child_node(fwnode, "fixed-link");
if (fixed_node)
plat->mdio_bus_data->xpcs_an_inband = false;
fwnode_handle_put(fixed_node);
plat->mdio_bus_data->default_an_inband = true;
}
/* Ensure mdio bus scan skips intel serdes and pcs-xpcs */
......
......@@ -1221,8 +1221,8 @@ static int stmmac_phy_setup(struct stmmac_priv *priv)
mdio_bus_data = priv->plat->mdio_bus_data;
if (mdio_bus_data)
priv->phylink_config.ovr_an_inband =
mdio_bus_data->xpcs_an_inband;
priv->phylink_config.default_an_inband =
mdio_bus_data->default_an_inband;
/* Set the platform/firmware specified interface mode. Note, phylink
* deals with the PHY interface mode, not the MAC interface mode.
......
......@@ -885,26 +885,31 @@ static int phylink_parse_mode(struct phylink *pl,
const char *managed;
unsigned long caps;
if (pl->config->default_an_inband)
pl->cfg_link_an_mode = MLO_AN_INBAND;
dn = fwnode_get_named_child_node(fwnode, "fixed-link");
if (dn || fwnode_property_present(fwnode, "fixed-link"))
pl->cfg_link_an_mode = MLO_AN_FIXED;
fwnode_handle_put(dn);
if ((fwnode_property_read_string(fwnode, "managed", &managed) == 0 &&
strcmp(managed, "in-band-status") == 0) ||
pl->config->ovr_an_inband) {
strcmp(managed, "in-band-status") == 0)) {
if (pl->cfg_link_an_mode == MLO_AN_FIXED) {
phylink_err(pl,
"can't use both fixed-link and in-band-status\n");
return -EINVAL;
}
pl->cfg_link_an_mode = MLO_AN_INBAND;
}
if (pl->cfg_link_an_mode == MLO_AN_INBAND) {
linkmode_zero(pl->supported);
phylink_set(pl->supported, MII);
phylink_set(pl->supported, Autoneg);
phylink_set(pl->supported, Asym_Pause);
phylink_set(pl->supported, Pause);
pl->cfg_link_an_mode = MLO_AN_INBAND;
switch (pl->link_config.interface) {
case PHY_INTERFACE_MODE_SGMII:
......
......@@ -141,7 +141,8 @@ enum phylink_op_type {
* @mac_requires_rxc: if true, the MAC always requires a receive clock from PHY.
* The PHY driver should start the clock signal as soon as
* possible and avoid stopping it during suspend events.
* @ovr_an_inband: if true, override PCS to MLO_AN_INBAND
* @default_an_inband: if true, defaults to MLO_AN_INBAND rather than
* MLO_AN_PHY. A fixed-link specification will override.
* @get_fixed_state: callback to execute to determine the fixed link state,
* if MAC link is at %MLO_AN_FIXED mode.
* @supported_interfaces: bitmap describing which PHY_INTERFACE_MODE_xxx
......@@ -154,7 +155,7 @@ struct phylink_config {
bool poll_fixed_state;
bool mac_managed_pm;
bool mac_requires_rxc;
bool ovr_an_inband;
bool default_an_inband;
void (*get_fixed_state)(struct phylink_config *config,
struct phylink_link_state *state);
DECLARE_PHY_INTERFACE_MASK(supported_interfaces);
......
......@@ -83,7 +83,7 @@ struct stmmac_priv;
struct stmmac_mdio_bus_data {
unsigned int phy_mask;
unsigned int has_xpcs;
unsigned int xpcs_an_inband;
unsigned int default_an_inband;
int *irqs;
int probed_phy_irq;
bool needs_reset;
......
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