Skip to content

Commit 5c6bc51

Browse files
hkallweitdavem330
authored andcommitted
net: phy: marvell: add downshift support for M88E1111
This patch adds downshift support for M88E1111. This PHY version uses another register for downshift configuration, reading downshift status is possible via the same register as for other PHY versions. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 911af5e commit 5c6bc51

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

drivers/net/phy/marvell.c

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@
6666
#define MII_M1111_PHY_LED_DIRECT 0x4100
6767
#define MII_M1111_PHY_LED_COMBINE 0x411c
6868
#define MII_M1111_PHY_EXT_CR 0x14
69+
#define MII_M1111_PHY_EXT_CR_DOWNSHIFT_MASK GENMASK(11, 9)
70+
#define MII_M1111_PHY_EXT_CR_DOWNSHIFT_MAX 8
71+
#define MII_M1111_PHY_EXT_CR_DOWNSHIFT_EN BIT(8)
6972
#define MII_M1111_RGMII_RX_DELAY BIT(7)
7073
#define MII_M1111_RGMII_TX_DELAY BIT(1)
7174
#define MII_M1111_PHY_EXT_SR 0x1b
@@ -784,6 +787,64 @@ static int m88e1111_config_init(struct phy_device *phydev)
784787
return genphy_soft_reset(phydev);
785788
}
786789

790+
static int m88e1111_get_downshift(struct phy_device *phydev, u8 *data)
791+
{
792+
int val, cnt, enable;
793+
794+
val = phy_read(phydev, MII_M1111_PHY_EXT_CR);
795+
if (val < 0)
796+
return val;
797+
798+
enable = FIELD_GET(MII_M1111_PHY_EXT_CR_DOWNSHIFT_EN, val);
799+
cnt = FIELD_GET(MII_M1111_PHY_EXT_CR_DOWNSHIFT_MASK, val) + 1;
800+
801+
*data = enable ? cnt : DOWNSHIFT_DEV_DISABLE;
802+
803+
return 0;
804+
}
805+
806+
static int m88e1111_set_downshift(struct phy_device *phydev, u8 cnt)
807+
{
808+
int val;
809+
810+
if (cnt > MII_M1111_PHY_EXT_CR_DOWNSHIFT_MAX)
811+
return -E2BIG;
812+
813+
if (!cnt)
814+
return phy_clear_bits(phydev, MII_M1111_PHY_EXT_CR,
815+
MII_M1111_PHY_EXT_CR_DOWNSHIFT_EN);
816+
817+
val = MII_M1111_PHY_EXT_CR_DOWNSHIFT_EN;
818+
val |= FIELD_PREP(MII_M1111_PHY_EXT_CR_DOWNSHIFT_MASK, cnt - 1);
819+
820+
return phy_modify(phydev, MII_M1111_PHY_EXT_CR,
821+
MII_M1111_PHY_EXT_CR_DOWNSHIFT_EN |
822+
MII_M1111_PHY_EXT_CR_DOWNSHIFT_MASK,
823+
val);
824+
}
825+
826+
static int m88e1111_get_tunable(struct phy_device *phydev,
827+
struct ethtool_tunable *tuna, void *data)
828+
{
829+
switch (tuna->id) {
830+
case ETHTOOL_PHY_DOWNSHIFT:
831+
return m88e1111_get_downshift(phydev, data);
832+
default:
833+
return -EOPNOTSUPP;
834+
}
835+
}
836+
837+
static int m88e1111_set_tunable(struct phy_device *phydev,
838+
struct ethtool_tunable *tuna, const void *data)
839+
{
840+
switch (tuna->id) {
841+
case ETHTOOL_PHY_DOWNSHIFT:
842+
return m88e1111_set_downshift(phydev, *(const u8 *)data);
843+
default:
844+
return -EOPNOTSUPP;
845+
}
846+
}
847+
787848
static int m88e1011_get_downshift(struct phy_device *phydev, u8 *data)
788849
{
789850
int val, cnt, enable;
@@ -2245,6 +2306,9 @@ static struct phy_driver marvell_drivers[] = {
22452306
.get_sset_count = marvell_get_sset_count,
22462307
.get_strings = marvell_get_strings,
22472308
.get_stats = marvell_get_stats,
2309+
.get_tunable = m88e1111_get_tunable,
2310+
.set_tunable = m88e1111_set_tunable,
2311+
.link_change_notify = m88e1011_link_change_notify,
22482312
},
22492313
{
22502314
.phy_id = MARVELL_PHY_ID_88E1118,

0 commit comments

Comments
 (0)