Commit 76a4cb75 authored by Russell King (Oracle)'s avatar Russell King (Oracle) Committed by Paolo Abeni

net: ethernet: mtk_eth_soc: remove incorrect PLL configuration

MT7623 GMAC0 attempts to configure the system clocking according to the
required speed in the .mac_config callback for non-SGMII, non-baseX and
non-TRGMII modes.

state->speed setting has never been reliable in the .mac_config
callback - there are cases where this is not the link speed,
particularly via ethtool paths, so this has always been unreliable (as
detailed in phylink's documentation.)

There is the additional issue that mtk_gmac0_rgmii_adjust() will only
be called if state->interface changes, which means it only configures
the system clocking on the very first .mac_config call, which will be
made when the network device is first brought up before any link is
established.

Essentially, this code is incredibly buggy, and probably never worked.

Moreover, checking the in-kernel DT files, it seems no platform makes
use of this code path.

Therefore, let's remove it, and disable interface modes for port 0 that
are not SGMII, 1000base-X, 2500base-X or TRGMII on the MT7623.
Reviewed-by: default avatarDaniel Golle <daniel@makrotopia.org>
Tested-by: default avatarDaniel Golle <daniel@makrotopia.org>
Tested-by: default avatarFrank Wunderlich <frank-w@public-files.de>
Signed-off-by: default avatarRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent ec87f054
...@@ -385,10 +385,8 @@ static int mt7621_gmac0_rgmii_adjust(struct mtk_eth *eth, ...@@ -385,10 +385,8 @@ static int mt7621_gmac0_rgmii_adjust(struct mtk_eth *eth,
} }
static void mtk_gmac0_rgmii_adjust(struct mtk_eth *eth, static void mtk_gmac0_rgmii_adjust(struct mtk_eth *eth,
phy_interface_t interface, int speed) phy_interface_t interface)
{ {
unsigned long rate;
u32 tck, rck, intf;
int ret; int ret;
if (interface == PHY_INTERFACE_MODE_TRGMII) { if (interface == PHY_INTERFACE_MODE_TRGMII) {
...@@ -399,30 +397,7 @@ static void mtk_gmac0_rgmii_adjust(struct mtk_eth *eth, ...@@ -399,30 +397,7 @@ static void mtk_gmac0_rgmii_adjust(struct mtk_eth *eth,
return; return;
} }
if (speed == SPEED_1000) { dev_err(eth->dev, "Missing PLL configuration, ethernet may not work\n");
intf = INTF_MODE_RGMII_1000;
rate = 250000000;
rck = RCK_CTRL_RGMII_1000;
tck = TCK_CTRL_RGMII_1000;
} else {
intf = INTF_MODE_RGMII_10_100;
rate = 500000000;
rck = RCK_CTRL_RGMII_10_100;
tck = TCK_CTRL_RGMII_10_100;
}
mtk_w32(eth, intf, INTF_MODE);
regmap_update_bits(eth->ethsys, ETHSYS_CLKCFG0,
ETHSYS_TRGMII_CLK_SEL362_5,
ETHSYS_TRGMII_CLK_SEL362_5);
ret = clk_set_rate(eth->clks[MTK_CLK_TRGPLL], rate);
if (ret)
dev_err(eth->dev, "Failed to set trgmii pll: %d\n", ret);
mtk_w32(eth, rck, TRGMII_RCK_CTRL);
mtk_w32(eth, tck, TRGMII_TCK_CTRL);
} }
static struct phylink_pcs *mtk_mac_select_pcs(struct phylink_config *config, static struct phylink_pcs *mtk_mac_select_pcs(struct phylink_config *config,
...@@ -498,17 +473,8 @@ static void mtk_mac_config(struct phylink_config *config, unsigned int mode, ...@@ -498,17 +473,8 @@ static void mtk_mac_config(struct phylink_config *config, unsigned int mode,
state->interface)) state->interface))
goto err_phy; goto err_phy;
} else { } else {
/* FIXME: this is incorrect. Not only does it
* use state->speed (which is not guaranteed
* to be correct) but it also makes use of it
* in a code path that will only be reachable
* when the PHY interface mode changes, not
* when the speed changes. Consequently, RGMII
* is probably broken.
*/
mtk_gmac0_rgmii_adjust(mac->hw, mtk_gmac0_rgmii_adjust(mac->hw,
state->interface, state->interface);
state->speed);
/* mt7623_pad_clk_setup */ /* mt7623_pad_clk_setup */
for (i = 0 ; i < NUM_TRGMII_CTRL; i++) for (i = 0 ; i < NUM_TRGMII_CTRL; i++)
...@@ -4366,13 +4332,19 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np) ...@@ -4366,13 +4332,19 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np)
mac->phylink_config.mac_capabilities = MAC_ASYM_PAUSE | MAC_SYM_PAUSE | mac->phylink_config.mac_capabilities = MAC_ASYM_PAUSE | MAC_SYM_PAUSE |
MAC_10 | MAC_100 | MAC_1000 | MAC_2500FD; MAC_10 | MAC_100 | MAC_1000 | MAC_2500FD;
__set_bit(PHY_INTERFACE_MODE_MII, /* MT7623 gmac0 is now missing its speed-specific PLL configuration
mac->phylink_config.supported_interfaces); * in its .mac_config method (since state->speed is not valid there.
__set_bit(PHY_INTERFACE_MODE_GMII, * Disable support for MII, GMII and RGMII.
mac->phylink_config.supported_interfaces); */
if (!mac->hw->soc->disable_pll_modes || mac->id != 0) {
__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)) if (MTK_HAS_CAPS(mac->hw->soc->caps, MTK_RGMII))
phy_interface_set_rgmii(mac->phylink_config.supported_interfaces); phy_interface_set_rgmii(mac->phylink_config.supported_interfaces);
}
if (MTK_HAS_CAPS(mac->hw->soc->caps, MTK_TRGMII) && !mac->id) if (MTK_HAS_CAPS(mac->hw->soc->caps, MTK_TRGMII) && !mac->id)
__set_bit(PHY_INTERFACE_MODE_TRGMII, __set_bit(PHY_INTERFACE_MODE_TRGMII,
...@@ -4845,6 +4817,7 @@ static const struct mtk_soc_data mt7623_data = { ...@@ -4845,6 +4817,7 @@ static const struct mtk_soc_data mt7623_data = {
.offload_version = 1, .offload_version = 1,
.hash_offset = 2, .hash_offset = 2,
.foe_entry_size = MTK_FOE_ENTRY_V1_SIZE, .foe_entry_size = MTK_FOE_ENTRY_V1_SIZE,
.disable_pll_modes = true,
.txrx = { .txrx = {
.txd_size = sizeof(struct mtk_tx_dma), .txd_size = sizeof(struct mtk_tx_dma),
.rxd_size = sizeof(struct mtk_rx_dma), .rxd_size = sizeof(struct mtk_rx_dma),
......
...@@ -1030,6 +1030,7 @@ struct mtk_soc_data { ...@@ -1030,6 +1030,7 @@ struct mtk_soc_data {
u16 foe_entry_size; u16 foe_entry_size;
netdev_features_t hw_features; netdev_features_t hw_features;
bool has_accounting; bool has_accounting;
bool disable_pll_modes;
struct { struct {
u32 txd_size; u32 txd_size;
u32 rxd_size; u32 rxd_size;
......
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