Skip to content

Commit d76556d

Browse files
Ansuelkuba-moo
authored andcommitted
net: dsa: mt7530: Add AN7583 support
Add Airoha AN7583 Switch support. This is based on Airoha EN7581 that is based on Mediatek MT7988 Switch. Airoha AN7583 require additional tweak to the GEPHY_CONN_CFG register to make the internal PHY work. Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Link: https://patch.msgid.link/20250522165313.6411-3-ansuelsmth@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent fef1848 commit d76556d

File tree

3 files changed

+37
-6
lines changed

3 files changed

+37
-6
lines changed

drivers/net/dsa/mt7530-mmio.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "mt7530.h"
1212

1313
static const struct of_device_id mt7988_of_match[] = {
14+
{ .compatible = "airoha,an7583-switch", .data = &mt753x_table[ID_AN7583], },
1415
{ .compatible = "airoha,en7581-switch", .data = &mt753x_table[ID_EN7581], },
1516
{ .compatible = "mediatek,mt7988-switch", .data = &mt753x_table[ID_MT7988], },
1617
{ /* sentinel */ },

drivers/net/dsa/mt7530.c

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,7 +1298,7 @@ mt753x_cpu_port_enable(struct dsa_switch *ds, int port)
12981298
* is affine to the inbound user port.
12991299
*/
13001300
if (priv->id == ID_MT7531 || priv->id == ID_MT7988 ||
1301-
priv->id == ID_EN7581)
1301+
priv->id == ID_EN7581 || priv->id == ID_AN7583)
13021302
mt7530_set(priv, MT7531_CFC, MT7531_CPU_PMAP(BIT(port)));
13031303

13041304
/* CPU port gets connected to all user ports of
@@ -2612,7 +2612,7 @@ mt7531_setup_common(struct dsa_switch *ds)
26122612
mt7530_set(priv, MT753X_AGC, LOCAL_EN);
26132613

26142614
/* Enable Special Tag for rx frames */
2615-
if (priv->id == ID_EN7581)
2615+
if (priv->id == ID_EN7581 || priv->id == ID_AN7583)
26162616
mt7530_write(priv, MT753X_CPORT_SPTAG_CFG,
26172617
CPORT_SW2FE_STAG_EN | CPORT_FE2SW_STAG_EN);
26182618

@@ -3236,6 +3236,16 @@ static int mt7988_setup(struct dsa_switch *ds)
32363236
reset_control_deassert(priv->rstc);
32373237
usleep_range(20, 50);
32383238

3239+
/* AN7583 require additional tweak to CONN_CFG */
3240+
if (priv->id == ID_AN7583)
3241+
mt7530_rmw(priv, AN7583_GEPHY_CONN_CFG,
3242+
AN7583_CSR_DPHY_CKIN_SEL |
3243+
AN7583_CSR_PHY_CORE_REG_CLK_SEL |
3244+
AN7583_CSR_ETHER_AFE_PWD,
3245+
AN7583_CSR_DPHY_CKIN_SEL |
3246+
AN7583_CSR_PHY_CORE_REG_CLK_SEL |
3247+
FIELD_PREP(AN7583_CSR_ETHER_AFE_PWD, 0));
3248+
32393249
/* Reset the switch PHYs */
32403250
mt7530_write(priv, MT7530_SYS_CTRL, SYS_CTRL_PHY_RST);
32413251

@@ -3344,6 +3354,16 @@ const struct mt753x_info mt753x_table[] = {
33443354
.phy_write_c45 = mt7531_ind_c45_phy_write,
33453355
.mac_port_get_caps = en7581_mac_port_get_caps,
33463356
},
3357+
[ID_AN7583] = {
3358+
.id = ID_AN7583,
3359+
.pcs_ops = &mt7530_pcs_ops,
3360+
.sw_setup = mt7988_setup,
3361+
.phy_read_c22 = mt7531_ind_c22_phy_read,
3362+
.phy_write_c22 = mt7531_ind_c22_phy_write,
3363+
.phy_read_c45 = mt7531_ind_c45_phy_read,
3364+
.phy_write_c45 = mt7531_ind_c45_phy_write,
3365+
.mac_port_get_caps = en7581_mac_port_get_caps,
3366+
},
33473367
};
33483368
EXPORT_SYMBOL_GPL(mt753x_table);
33493369

drivers/net/dsa/mt7530.h

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ enum mt753x_id {
2020
ID_MT7531 = 2,
2121
ID_MT7988 = 3,
2222
ID_EN7581 = 4,
23+
ID_AN7583 = 5,
2324
};
2425

2526
#define NUM_TRGMII_CTRL 5
@@ -66,7 +67,8 @@ enum mt753x_id {
6667

6768
#define MT753X_MIRROR_REG(id) ((id == ID_MT7531 || \
6869
id == ID_MT7988 || \
69-
id == ID_EN7581) ? \
70+
id == ID_EN7581 || \
71+
id == ID_AN7583) ? \
7072
MT7531_CFC : MT753X_MFC)
7173

7274
#define MT753X_MIRROR_EN(id) ((id == ID_MT7531 || \
@@ -76,19 +78,22 @@ enum mt753x_id {
7678

7779
#define MT753X_MIRROR_PORT_MASK(id) ((id == ID_MT7531 || \
7880
id == ID_MT7988 || \
79-
id == ID_EN7581) ? \
81+
id == ID_EN7581 || \
82+
id == ID_AN7583) ? \
8083
MT7531_MIRROR_PORT_MASK : \
8184
MT7530_MIRROR_PORT_MASK)
8285

8386
#define MT753X_MIRROR_PORT_GET(id, val) ((id == ID_MT7531 || \
8487
id == ID_MT7988 || \
85-
id == ID_EN7581) ? \
88+
id == ID_EN7581 || \
89+
id == ID_AN7583) ? \
8690
MT7531_MIRROR_PORT_GET(val) : \
8791
MT7530_MIRROR_PORT_GET(val))
8892

8993
#define MT753X_MIRROR_PORT_SET(id, val) ((id == ID_MT7531 || \
9094
id == ID_MT7988 || \
91-
id == ID_EN7581) ? \
95+
id == ID_EN7581 || \
96+
id == ID_AN7583) ? \
9297
MT7531_MIRROR_PORT_SET(val) : \
9398
MT7530_MIRROR_PORT_SET(val))
9499

@@ -673,6 +678,11 @@ enum mt7531_xtal_fsel {
673678
#define CPORT_SW2FE_STAG_EN BIT(1)
674679
#define CPORT_FE2SW_STAG_EN BIT(0)
675680

681+
#define AN7583_GEPHY_CONN_CFG 0x7c14
682+
#define AN7583_CSR_DPHY_CKIN_SEL BIT(31)
683+
#define AN7583_CSR_PHY_CORE_REG_CLK_SEL BIT(30)
684+
#define AN7583_CSR_ETHER_AFE_PWD GENMASK(28, 24)
685+
676686
/* Registers for LED GPIO control (MT7530 only)
677687
* All registers follow this pattern:
678688
* [ 2: 0] port 0

0 commit comments

Comments
 (0)