Skip to content

Commit 5ab3121

Browse files
tlendackydavem330
authored andcommitted
amd-xgbe: Fix mdio access for non-zero ports and clause 45 PHYs
The XGBE hardware has support for performing MDIO operations using an MDIO command request. The driver mistakenly uses the mdio port address as the MDIO command request device address instead of the MDIO command request port address. Additionally, the driver does not properly check for and create a clause 45 MDIO command. Check the supplied MDIO register to determine if the request is a clause 45 operation (MII_ADDR_C45). For a clause 45 operation, extract the device address and register number from the supplied MDIO register and use them to set the MDIO command request device address and register number fields. For a clause 22 operation, the MDIO request device address is set to zero and the MDIO command request register number is set to the supplied MDIO register. In either case, the supplied MDIO port address is used as the MDIO command request port address. Fixes: 732f2ab ("amd-xgbe: Add support for MDIO attached PHYs") Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com> Tested-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 40f89eb commit 5ab3121

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

drivers/net/ethernet/amd/xgbe/xgbe-common.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,6 @@
431431
#define MAC_MDIOSCAR_PA_WIDTH 5
432432
#define MAC_MDIOSCAR_RA_INDEX 0
433433
#define MAC_MDIOSCAR_RA_WIDTH 16
434-
#define MAC_MDIOSCAR_REG_INDEX 0
435-
#define MAC_MDIOSCAR_REG_WIDTH 21
436434
#define MAC_MDIOSCCDR_BUSY_INDEX 22
437435
#define MAC_MDIOSCCDR_BUSY_WIDTH 1
438436
#define MAC_MDIOSCCDR_CMD_INDEX 16

drivers/net/ethernet/amd/xgbe/xgbe-dev.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,16 +1284,28 @@ static void xgbe_write_mmd_regs(struct xgbe_prv_data *pdata, int prtad,
12841284
}
12851285
}
12861286

1287+
static unsigned int xgbe_create_mdio_sca(int port, int reg)
1288+
{
1289+
unsigned int mdio_sca, da;
1290+
1291+
da = (reg & MII_ADDR_C45) ? reg >> 16 : 0;
1292+
1293+
mdio_sca = 0;
1294+
XGMAC_SET_BITS(mdio_sca, MAC_MDIOSCAR, RA, reg);
1295+
XGMAC_SET_BITS(mdio_sca, MAC_MDIOSCAR, PA, port);
1296+
XGMAC_SET_BITS(mdio_sca, MAC_MDIOSCAR, DA, da);
1297+
1298+
return mdio_sca;
1299+
}
1300+
12871301
static int xgbe_write_ext_mii_regs(struct xgbe_prv_data *pdata, int addr,
12881302
int reg, u16 val)
12891303
{
12901304
unsigned int mdio_sca, mdio_sccd;
12911305

12921306
reinit_completion(&pdata->mdio_complete);
12931307

1294-
mdio_sca = 0;
1295-
XGMAC_SET_BITS(mdio_sca, MAC_MDIOSCAR, REG, reg);
1296-
XGMAC_SET_BITS(mdio_sca, MAC_MDIOSCAR, DA, addr);
1308+
mdio_sca = xgbe_create_mdio_sca(addr, reg);
12971309
XGMAC_IOWRITE(pdata, MAC_MDIOSCAR, mdio_sca);
12981310

12991311
mdio_sccd = 0;
@@ -1317,9 +1329,7 @@ static int xgbe_read_ext_mii_regs(struct xgbe_prv_data *pdata, int addr,
13171329

13181330
reinit_completion(&pdata->mdio_complete);
13191331

1320-
mdio_sca = 0;
1321-
XGMAC_SET_BITS(mdio_sca, MAC_MDIOSCAR, REG, reg);
1322-
XGMAC_SET_BITS(mdio_sca, MAC_MDIOSCAR, DA, addr);
1332+
mdio_sca = xgbe_create_mdio_sca(addr, reg);
13231333
XGMAC_IOWRITE(pdata, MAC_MDIOSCAR, mdio_sca);
13241334

13251335
mdio_sccd = 0;

0 commit comments

Comments
 (0)