Skip to content

Commit 8aba95b

Browse files
committed
Fix the mxl862xx_downstream driver mismatch for MDIO and MXL port.
This caused an "off by one" issue for link status for the ports where lan_n would report a link if lan_n+1 is connected. Also adjust the dsa tag name to be compatible with the new drivers.
1 parent 1466910 commit 8aba95b

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

drivers/net/dsa/mxl862xx_downstream/mxl862xx.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@
3333
#define MXL862XX_API_READ(dev, cmd, data) \
3434
mxl862xx_api_wrap(dev, cmd, &(data), sizeof((data)), true)
3535

36-
/* DSA port index is 0 based, the MXL FW has 1 as the base index */
36+
/* DSA port index is 1 based (i.e., port 0 is unused), matching MXL FW */
3737
#define DSA_MXL_PORT(port) ((port))
38+
/* MDIO port index is 0 based, adjust to DSA */
39+
#define DSA_MDIO_PORT(port) ((port - 1))
3840

3941
#define MXL862XX_SDMA_PCTRLP(p) (0xBC0 + ((p) * 0x6))
4042
#define MXL862XX_SDMA_PCTRL_EN BIT(0) /* SDMA Port Enable */
@@ -129,8 +131,10 @@ static const struct mxl862xx_mibs mxl862xx_mibs_tx[] = {
129131

130132
static int mxl862xx_phy_read_mmd(struct mxl862xx_priv *priv, int port, int devadd, int reg)
131133
{
134+
if (port<1)
135+
return -EINVAL;
132136
struct mdio_relay_data param = {
133-
.phy = port,
137+
.phy = DSA_MDIO_PORT(port),
134138
.mmd = devadd,
135139
.reg = reg & 0xffff,
136140
};
@@ -146,8 +150,10 @@ static int mxl862xx_phy_read_mmd(struct mxl862xx_priv *priv, int port, int devad
146150
static int mxl862xx_phy_write_mmd(struct mxl862xx_priv *priv, int port,
147151
int devadd, int reg, u16 data)
148152
{
153+
if (port<1)
154+
return -EINVAL;
149155
struct mdio_relay_data param = {
150-
.phy = port,
156+
.phy = DSA_MDIO_PORT(port),
151157
.mmd = devadd,
152158
.reg = reg,
153159
.data = data,
@@ -367,7 +373,7 @@ static enum dsa_tag_protocol mxl862_parse_tag_proto(struct dsa_switch *ds, uint8
367373

368374
if (!strcmp(user_protocol, "mxl862"))
369375
tag_proto = DSA_TAG_PROTO_MXL862;
370-
else if (!strcmp(user_protocol, "mxl862_8021q"))
376+
else if (!strcmp(user_protocol, "mxl862xx-8021q"))
371377
tag_proto = DSA_TAG_PROTO_MXL862_8021Q;
372378
else
373379
dev_warn(ds->dev,

0 commit comments

Comments
 (0)