Skip to content

Commit 91daa4f

Browse files
dangowrtkuba-moo
authored andcommitted
net: dsa: mt7530: fix support for MT7531BE
There are two variants of the MT7531 switch IC which got different features (and pins) regarding port 5: * MT7531AE: SGMII/1000Base-X/2500Base-X SerDes PCS * MT7531BE: RGMII Moving the creation of the SerDes PCS from mt753x_setup to mt7530_probe with commit 6de2852 ("net: dsa: mt7530: move SGMII PCS creation to mt7530_probe function") works fine for MT7531AE which got two instances of mtk-pcs-lynxi, however, MT7531BE requires mt7531_pll_setup to setup clocks before the single PCS on port 6 (usually used as CPU port) starts to work and hence the PCS creation failed on MT7531BE. Fix this by introducing a pointer to mt7531_create_sgmii function in struct mt7530_priv and call it again at the end of mt753x_setup like it was before commit 6de2852 ("net: dsa: mt7530: move SGMII PCS creation to mt7530_probe function"). Fixes: 6de2852 ("net: dsa: mt7530: move SGMII PCS creation to mt7530_probe function") Signed-off-by: Daniel Golle <daniel@makrotopia.org> Acked-by: Arınç ÜNAL <arinc.unal@arinc9.com> Link: https://lore.kernel.org/r/ZDvlLhhqheobUvOK@makrotopia.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 8e4c62c commit 91daa4f

3 files changed

Lines changed: 16 additions & 10 deletions

File tree

drivers/net/dsa/mt7530-mdio.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,17 @@ static const struct regmap_bus mt7530_regmap_bus = {
8181
};
8282

8383
static int
84-
mt7531_create_sgmii(struct mt7530_priv *priv)
84+
mt7531_create_sgmii(struct mt7530_priv *priv, bool dual_sgmii)
8585
{
86-
struct regmap_config *mt7531_pcs_config[2];
86+
struct regmap_config *mt7531_pcs_config[2] = {};
8787
struct phylink_pcs *pcs;
8888
struct regmap *regmap;
8989
int i, ret = 0;
9090

91-
for (i = 0; i < 2; i++) {
91+
/* MT7531AE has two SGMII units for port 5 and port 6
92+
* MT7531BE has only one SGMII unit for port 6
93+
*/
94+
for (i = dual_sgmii ? 0 : 1; i < 2; i++) {
9295
mt7531_pcs_config[i] = devm_kzalloc(priv->dev,
9396
sizeof(struct regmap_config),
9497
GFP_KERNEL);
@@ -208,11 +211,8 @@ mt7530_probe(struct mdio_device *mdiodev)
208211
if (IS_ERR(priv->regmap))
209212
return PTR_ERR(priv->regmap);
210213

211-
if (priv->id == ID_MT7531) {
212-
ret = mt7531_create_sgmii(priv);
213-
if (ret)
214-
return ret;
215-
}
214+
if (priv->id == ID_MT7531)
215+
priv->create_sgmii = mt7531_create_sgmii;
216216

217217
return dsa_register_switch(priv->ds);
218218
}

drivers/net/dsa/mt7530.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3018,6 +3018,12 @@ mt753x_setup(struct dsa_switch *ds)
30183018
if (ret && priv->irq)
30193019
mt7530_free_irq_common(priv);
30203020

3021+
if (priv->create_sgmii) {
3022+
ret = priv->create_sgmii(priv, mt7531_dual_sgmii_supported(priv));
3023+
if (ret && priv->irq)
3024+
mt7530_free_irq(priv);
3025+
}
3026+
30213027
return ret;
30223028
}
30233029

drivers/net/dsa/mt7530.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -748,10 +748,10 @@ struct mt753x_info {
748748
* registers
749749
* @p6_interface Holding the current port 6 interface
750750
* @p5_intf_sel: Holding the current port 5 interface select
751-
*
752751
* @irq: IRQ number of the switch
753752
* @irq_domain: IRQ domain of the switch irq_chip
754753
* @irq_enable: IRQ enable bits, synced to SYS_INT_EN
754+
* @create_sgmii: Pointer to function creating SGMII PCS instance(s)
755755
*/
756756
struct mt7530_priv {
757757
struct device *dev;
@@ -770,14 +770,14 @@ struct mt7530_priv {
770770
unsigned int p5_intf_sel;
771771
u8 mirror_rx;
772772
u8 mirror_tx;
773-
774773
struct mt7530_port ports[MT7530_NUM_PORTS];
775774
struct mt753x_pcs pcs[MT7530_NUM_PORTS];
776775
/* protect among processes for registers access*/
777776
struct mutex reg_mutex;
778777
int irq;
779778
struct irq_domain *irq_domain;
780779
u32 irq_enable;
780+
int (*create_sgmii)(struct mt7530_priv *priv, bool dual_sgmii);
781781
};
782782

783783
struct mt7530_hw_vlan_entry {

0 commit comments

Comments
 (0)