Merge branch 'mtk_eth_soc-phylink'
Russell King says: ==================== net: mtk_eth_soc: phylink validate implementation updates This series converts mtk_eth_soc to fill in the supported_interfaces member of phylink_config, cleans up the validate() implementation, and then converts to phylink_generic_validate(). ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
commit
c11239f355
@ -463,94 +463,8 @@ static void mtk_mac_link_up(struct phylink_config *config,
|
||||
mtk_w32(mac->hw, mcr, MTK_MAC_MCR(mac->id));
|
||||
}
|
||||
|
||||
static void mtk_validate(struct phylink_config *config,
|
||||
unsigned long *supported,
|
||||
struct phylink_link_state *state)
|
||||
{
|
||||
struct mtk_mac *mac = container_of(config, struct mtk_mac,
|
||||
phylink_config);
|
||||
__ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
|
||||
|
||||
if (state->interface != PHY_INTERFACE_MODE_NA &&
|
||||
state->interface != PHY_INTERFACE_MODE_MII &&
|
||||
state->interface != PHY_INTERFACE_MODE_GMII &&
|
||||
!(MTK_HAS_CAPS(mac->hw->soc->caps, MTK_RGMII) &&
|
||||
phy_interface_mode_is_rgmii(state->interface)) &&
|
||||
!(MTK_HAS_CAPS(mac->hw->soc->caps, MTK_TRGMII) &&
|
||||
!mac->id && state->interface == PHY_INTERFACE_MODE_TRGMII) &&
|
||||
!(MTK_HAS_CAPS(mac->hw->soc->caps, MTK_SGMII) &&
|
||||
(state->interface == PHY_INTERFACE_MODE_SGMII ||
|
||||
phy_interface_mode_is_8023z(state->interface)))) {
|
||||
linkmode_zero(supported);
|
||||
return;
|
||||
}
|
||||
|
||||
phylink_set_port_modes(mask);
|
||||
phylink_set(mask, Autoneg);
|
||||
|
||||
switch (state->interface) {
|
||||
case PHY_INTERFACE_MODE_TRGMII:
|
||||
phylink_set(mask, 1000baseT_Full);
|
||||
break;
|
||||
case PHY_INTERFACE_MODE_1000BASEX:
|
||||
case PHY_INTERFACE_MODE_2500BASEX:
|
||||
phylink_set(mask, 1000baseX_Full);
|
||||
phylink_set(mask, 2500baseX_Full);
|
||||
break;
|
||||
case PHY_INTERFACE_MODE_GMII:
|
||||
case PHY_INTERFACE_MODE_RGMII:
|
||||
case PHY_INTERFACE_MODE_RGMII_ID:
|
||||
case PHY_INTERFACE_MODE_RGMII_RXID:
|
||||
case PHY_INTERFACE_MODE_RGMII_TXID:
|
||||
phylink_set(mask, 1000baseT_Half);
|
||||
fallthrough;
|
||||
case PHY_INTERFACE_MODE_SGMII:
|
||||
phylink_set(mask, 1000baseT_Full);
|
||||
phylink_set(mask, 1000baseX_Full);
|
||||
fallthrough;
|
||||
case PHY_INTERFACE_MODE_MII:
|
||||
case PHY_INTERFACE_MODE_RMII:
|
||||
case PHY_INTERFACE_MODE_REVMII:
|
||||
case PHY_INTERFACE_MODE_NA:
|
||||
default:
|
||||
phylink_set(mask, 10baseT_Half);
|
||||
phylink_set(mask, 10baseT_Full);
|
||||
phylink_set(mask, 100baseT_Half);
|
||||
phylink_set(mask, 100baseT_Full);
|
||||
break;
|
||||
}
|
||||
|
||||
if (state->interface == PHY_INTERFACE_MODE_NA) {
|
||||
if (MTK_HAS_CAPS(mac->hw->soc->caps, MTK_SGMII)) {
|
||||
phylink_set(mask, 1000baseT_Full);
|
||||
phylink_set(mask, 1000baseX_Full);
|
||||
phylink_set(mask, 2500baseX_Full);
|
||||
}
|
||||
if (MTK_HAS_CAPS(mac->hw->soc->caps, MTK_RGMII)) {
|
||||
phylink_set(mask, 1000baseT_Full);
|
||||
phylink_set(mask, 1000baseT_Half);
|
||||
phylink_set(mask, 1000baseX_Full);
|
||||
}
|
||||
if (MTK_HAS_CAPS(mac->hw->soc->caps, MTK_GEPHY)) {
|
||||
phylink_set(mask, 1000baseT_Full);
|
||||
phylink_set(mask, 1000baseT_Half);
|
||||
}
|
||||
}
|
||||
|
||||
phylink_set(mask, Pause);
|
||||
phylink_set(mask, Asym_Pause);
|
||||
|
||||
linkmode_and(supported, supported, mask);
|
||||
linkmode_and(state->advertising, state->advertising, mask);
|
||||
|
||||
/* We can only operate at 2500BaseX or 1000BaseX. If requested
|
||||
* to advertise both, only report advertising at 2500BaseX.
|
||||
*/
|
||||
phylink_helper_basex_speed(state);
|
||||
}
|
||||
|
||||
static const struct phylink_mac_ops mtk_phylink_ops = {
|
||||
.validate = mtk_validate,
|
||||
.validate = phylink_generic_validate,
|
||||
.mac_pcs_get_state = mtk_mac_pcs_get_state,
|
||||
.mac_an_restart = mtk_mac_an_restart,
|
||||
.mac_config = mtk_mac_config,
|
||||
@ -3009,6 +2923,29 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np)
|
||||
|
||||
mac->phylink_config.dev = ð->netdev[id]->dev;
|
||||
mac->phylink_config.type = PHYLINK_NETDEV;
|
||||
mac->phylink_config.mac_capabilities = MAC_ASYM_PAUSE | MAC_SYM_PAUSE |
|
||||
MAC_10 | MAC_100 | MAC_1000 | MAC_2500FD;
|
||||
|
||||
__set_bit(PHY_INTERFACE_MODE_MII,
|
||||
mac->phylink_config.supported_interfaces);
|
||||
__set_bit(PHY_INTERFACE_MODE_GMII,
|
||||
mac->phylink_config.supported_interfaces);
|
||||
|
||||
if (MTK_HAS_CAPS(mac->hw->soc->caps, MTK_RGMII))
|
||||
phy_interface_set_rgmii(mac->phylink_config.supported_interfaces);
|
||||
|
||||
if (MTK_HAS_CAPS(mac->hw->soc->caps, MTK_TRGMII) && !mac->id)
|
||||
__set_bit(PHY_INTERFACE_MODE_TRGMII,
|
||||
mac->phylink_config.supported_interfaces);
|
||||
|
||||
if (MTK_HAS_CAPS(mac->hw->soc->caps, MTK_SGMII)) {
|
||||
__set_bit(PHY_INTERFACE_MODE_SGMII,
|
||||
mac->phylink_config.supported_interfaces);
|
||||
__set_bit(PHY_INTERFACE_MODE_1000BASEX,
|
||||
mac->phylink_config.supported_interfaces);
|
||||
__set_bit(PHY_INTERFACE_MODE_2500BASEX,
|
||||
mac->phylink_config.supported_interfaces);
|
||||
}
|
||||
|
||||
phylink = phylink_create(&mac->phylink_config,
|
||||
of_fwnode_handle(mac->of_node),
|
||||
|
Loading…
x
Reference in New Issue
Block a user