mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-26 10:49:33 +00:00
net: phy: introduce phydev->port
[ Upstream commit 4217a64e18
]
At the moment, PORT_MII is reported in the ethtool ops. This is odd
because it is an interface between the MAC and the PHY and no external
port. Some network card drivers will overwrite the port to twisted pair
or fiber, though. Even worse, the MDI/MDIX setting is only used by
ethtool if the port is twisted pair.
Set the port to PORT_TP by default because most PHY drivers are copper
ones. If there is fibre support and it is enabled, the PHY driver will
set it to PORT_FIBRE.
This will change reporting PORT_MII to either PORT_TP or PORT_FIBRE;
except for the genphy fallback driver.
Suggested-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
c4934e65c8
commit
9a5267264f
10 changed files with 36 additions and 4 deletions
|
@ -505,6 +505,8 @@ static int bcm54616s_probe(struct phy_device *phydev)
|
||||||
*/
|
*/
|
||||||
if (!(val & BCM54616S_100FX_MODE))
|
if (!(val & BCM54616S_100FX_MODE))
|
||||||
phydev->dev_flags |= PHY_BCM_FLAGS_MODE_1000BX;
|
phydev->dev_flags |= PHY_BCM_FLAGS_MODE_1000BX;
|
||||||
|
|
||||||
|
phydev->port = PORT_FIBRE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -534,6 +534,9 @@ static int dp83822_probe(struct phy_device *phydev)
|
||||||
|
|
||||||
dp83822_of_init(phydev);
|
dp83822_of_init(phydev);
|
||||||
|
|
||||||
|
if (dp83822->fx_enabled)
|
||||||
|
phydev->port = PORT_FIBRE;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -821,6 +821,10 @@ static int dp83869_probe(struct phy_device *phydev)
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
if (dp83869->mode == DP83869_RGMII_100_BASE ||
|
||||||
|
dp83869->mode == DP83869_RGMII_1000_BASE)
|
||||||
|
phydev->port = PORT_FIBRE;
|
||||||
|
|
||||||
return dp83869_config_init(phydev);
|
return dp83869_config_init(phydev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -218,6 +218,7 @@ static int lxt973_probe(struct phy_device *phydev)
|
||||||
phy_write(phydev, MII_BMCR, val);
|
phy_write(phydev, MII_BMCR, val);
|
||||||
/* Remember that the port is in fiber mode. */
|
/* Remember that the port is in fiber mode. */
|
||||||
phydev->priv = lxt973_probe;
|
phydev->priv = lxt973_probe;
|
||||||
|
phydev->port = PORT_FIBRE;
|
||||||
} else {
|
} else {
|
||||||
phydev->priv = NULL;
|
phydev->priv = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1449,6 +1449,7 @@ static int marvell_read_status_page(struct phy_device *phydev, int page)
|
||||||
phydev->asym_pause = 0;
|
phydev->asym_pause = 0;
|
||||||
phydev->speed = SPEED_UNKNOWN;
|
phydev->speed = SPEED_UNKNOWN;
|
||||||
phydev->duplex = DUPLEX_UNKNOWN;
|
phydev->duplex = DUPLEX_UNKNOWN;
|
||||||
|
phydev->port = fiber ? PORT_FIBRE : PORT_TP;
|
||||||
|
|
||||||
if (phydev->autoneg == AUTONEG_ENABLE)
|
if (phydev->autoneg == AUTONEG_ENABLE)
|
||||||
err = marvell_read_status_page_an(phydev, fiber, status);
|
err = marvell_read_status_page_an(phydev, fiber, status);
|
||||||
|
|
|
@ -631,6 +631,7 @@ static int mv3310_read_status_10gbaser(struct phy_device *phydev)
|
||||||
phydev->link = 1;
|
phydev->link = 1;
|
||||||
phydev->speed = SPEED_10000;
|
phydev->speed = SPEED_10000;
|
||||||
phydev->duplex = DUPLEX_FULL;
|
phydev->duplex = DUPLEX_FULL;
|
||||||
|
phydev->port = PORT_FIBRE;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -690,6 +691,7 @@ static int mv3310_read_status_copper(struct phy_device *phydev)
|
||||||
|
|
||||||
phydev->duplex = cssr1 & MV_PCS_CSSR1_DUPLEX_FULL ?
|
phydev->duplex = cssr1 & MV_PCS_CSSR1_DUPLEX_FULL ?
|
||||||
DUPLEX_FULL : DUPLEX_HALF;
|
DUPLEX_FULL : DUPLEX_HALF;
|
||||||
|
phydev->port = PORT_TP;
|
||||||
phydev->mdix = cssr1 & MV_PCS_CSSR1_MDIX ?
|
phydev->mdix = cssr1 & MV_PCS_CSSR1_MDIX ?
|
||||||
ETH_TP_MDI_X : ETH_TP_MDI;
|
ETH_TP_MDI_X : ETH_TP_MDI;
|
||||||
|
|
||||||
|
|
|
@ -308,14 +308,19 @@ static int kszphy_config_init(struct phy_device *phydev)
|
||||||
return kszphy_config_reset(phydev);
|
return kszphy_config_reset(phydev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int ksz8041_fiber_mode(struct phy_device *phydev)
|
||||||
|
{
|
||||||
|
struct device_node *of_node = phydev->mdio.dev.of_node;
|
||||||
|
|
||||||
|
return of_property_read_bool(of_node, "micrel,fiber-mode");
|
||||||
|
}
|
||||||
|
|
||||||
static int ksz8041_config_init(struct phy_device *phydev)
|
static int ksz8041_config_init(struct phy_device *phydev)
|
||||||
{
|
{
|
||||||
__ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
|
__ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
|
||||||
|
|
||||||
struct device_node *of_node = phydev->mdio.dev.of_node;
|
|
||||||
|
|
||||||
/* Limit supported and advertised modes in fiber mode */
|
/* Limit supported and advertised modes in fiber mode */
|
||||||
if (of_property_read_bool(of_node, "micrel,fiber-mode")) {
|
if (ksz8041_fiber_mode(phydev)) {
|
||||||
phydev->dev_flags |= MICREL_PHY_FXEN;
|
phydev->dev_flags |= MICREL_PHY_FXEN;
|
||||||
linkmode_set_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT, mask);
|
linkmode_set_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT, mask);
|
||||||
linkmode_set_bit(ETHTOOL_LINK_MODE_100baseT_Half_BIT, mask);
|
linkmode_set_bit(ETHTOOL_LINK_MODE_100baseT_Half_BIT, mask);
|
||||||
|
@ -1143,6 +1148,9 @@ static int kszphy_probe(struct phy_device *phydev)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ksz8041_fiber_mode(phydev))
|
||||||
|
phydev->port = PORT_FIBRE;
|
||||||
|
|
||||||
/* Support legacy board-file configuration */
|
/* Support legacy board-file configuration */
|
||||||
if (phydev->dev_flags & MICREL_PHY_50MHZ_CLK) {
|
if (phydev->dev_flags & MICREL_PHY_50MHZ_CLK) {
|
||||||
priv->rmii_ref_clk_sel = true;
|
priv->rmii_ref_clk_sel = true;
|
||||||
|
|
|
@ -327,7 +327,7 @@ void phy_ethtool_ksettings_get(struct phy_device *phydev,
|
||||||
if (phydev->interface == PHY_INTERFACE_MODE_MOCA)
|
if (phydev->interface == PHY_INTERFACE_MODE_MOCA)
|
||||||
cmd->base.port = PORT_BNC;
|
cmd->base.port = PORT_BNC;
|
||||||
else
|
else
|
||||||
cmd->base.port = PORT_MII;
|
cmd->base.port = phydev->port;
|
||||||
cmd->base.transceiver = phy_is_internal(phydev) ?
|
cmd->base.transceiver = phy_is_internal(phydev) ?
|
||||||
XCVR_INTERNAL : XCVR_EXTERNAL;
|
XCVR_INTERNAL : XCVR_EXTERNAL;
|
||||||
cmd->base.phy_address = phydev->mdio.addr;
|
cmd->base.phy_address = phydev->mdio.addr;
|
||||||
|
|
|
@ -576,6 +576,7 @@ struct phy_device *phy_device_create(struct mii_bus *bus, int addr, u32 phy_id,
|
||||||
dev->pause = 0;
|
dev->pause = 0;
|
||||||
dev->asym_pause = 0;
|
dev->asym_pause = 0;
|
||||||
dev->link = 0;
|
dev->link = 0;
|
||||||
|
dev->port = PORT_TP;
|
||||||
dev->interface = PHY_INTERFACE_MODE_GMII;
|
dev->interface = PHY_INTERFACE_MODE_GMII;
|
||||||
|
|
||||||
dev->autoneg = AUTONEG_ENABLE;
|
dev->autoneg = AUTONEG_ENABLE;
|
||||||
|
@ -1384,6 +1385,14 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
|
||||||
|
|
||||||
phydev->state = PHY_READY;
|
phydev->state = PHY_READY;
|
||||||
|
|
||||||
|
/* Port is set to PORT_TP by default and the actual PHY driver will set
|
||||||
|
* it to different value depending on the PHY configuration. If we have
|
||||||
|
* the generic PHY driver we can't figure it out, thus set the old
|
||||||
|
* legacy PORT_MII value.
|
||||||
|
*/
|
||||||
|
if (using_genphy)
|
||||||
|
phydev->port = PORT_MII;
|
||||||
|
|
||||||
/* Initial carrier state is off as the phy is about to be
|
/* Initial carrier state is off as the phy is about to be
|
||||||
* (re)initialized.
|
* (re)initialized.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -499,6 +499,7 @@ struct macsec_ops;
|
||||||
*
|
*
|
||||||
* @speed: Current link speed
|
* @speed: Current link speed
|
||||||
* @duplex: Current duplex
|
* @duplex: Current duplex
|
||||||
|
* @port: Current port
|
||||||
* @pause: Current pause
|
* @pause: Current pause
|
||||||
* @asym_pause: Current asymmetric pause
|
* @asym_pause: Current asymmetric pause
|
||||||
* @supported: Combined MAC/PHY supported linkmodes
|
* @supported: Combined MAC/PHY supported linkmodes
|
||||||
|
@ -577,6 +578,7 @@ struct phy_device {
|
||||||
*/
|
*/
|
||||||
int speed;
|
int speed;
|
||||||
int duplex;
|
int duplex;
|
||||||
|
int port;
|
||||||
int pause;
|
int pause;
|
||||||
int asym_pause;
|
int asym_pause;
|
||||||
u8 master_slave_get;
|
u8 master_slave_get;
|
||||||
|
|
Loading…
Reference in a new issue