Skip to content

Commit 6ef05eb

Browse files
lunndavem330
authored andcommitted
net: phy: marvell: Refactor setting downshift into a helper
The 1116r has code to set downshift. Refactor this into a helper, so in future other marvell PHYs can use it. Signed-off-by: Andrew Lunn <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent fecd5e9 commit 6ef05eb

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

drivers/net/phy/marvell.c

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
#define MII_M1011_PHY_SCR 0x10
5959
#define MII_M1011_PHY_SCR_DOWNSHIFT_EN BIT(11)
6060
#define MII_M1011_PHY_SCR_DOWNSHIFT_SHIFT 12
61+
#define MII_M1011_PHY_SRC_DOWNSHIFT_MASK 0x7800
6162
#define MII_M1011_PHY_SCR_MDI (0x0 << 5)
6263
#define MII_M1011_PHY_SCR_MDI_X (0x1 << 5)
6364
#define MII_M1011_PHY_SCR_AUTO_CROSS (0x3 << 5)
@@ -263,6 +264,23 @@ static int marvell_set_polarity(struct phy_device *phydev, int polarity)
263264
return 0;
264265
}
265266

267+
static int marvell_set_downshift(struct phy_device *phydev, bool enable,
268+
u8 retries)
269+
{
270+
int reg;
271+
272+
reg = phy_read(phydev, MII_M1011_PHY_SCR);
273+
if (reg < 0)
274+
return reg;
275+
276+
reg &= MII_M1011_PHY_SRC_DOWNSHIFT_MASK;
277+
reg |= ((retries - 1) << MII_M1011_PHY_SCR_DOWNSHIFT_SHIFT);
278+
if (enable)
279+
reg |= MII_M1011_PHY_SCR_DOWNSHIFT_EN;
280+
281+
return phy_write(phydev, MII_M1011_PHY_SCR, reg);
282+
}
283+
266284
static int marvell_config_aneg(struct phy_device *phydev)
267285
{
268286
int err;
@@ -643,7 +661,6 @@ static int marvell_config_init(struct phy_device *phydev)
643661

644662
static int m88e1116r_config_init(struct phy_device *phydev)
645663
{
646-
int temp;
647664
int err;
648665

649666
err = genphy_soft_reset(phydev);
@@ -660,10 +677,7 @@ static int m88e1116r_config_init(struct phy_device *phydev)
660677
if (err < 0)
661678
return err;
662679

663-
temp = phy_read(phydev, MII_M1011_PHY_SCR);
664-
temp |= (7 << MII_M1011_PHY_SCR_DOWNSHIFT_SHIFT);
665-
temp |= MII_M1011_PHY_SCR_DOWNSHIFT_EN;
666-
err = phy_write(phydev, MII_M1011_PHY_SCR, temp);
680+
err = marvell_set_downshift(phydev, true, 8);
667681
if (err < 0)
668682
return err;
669683

0 commit comments

Comments
 (0)