Commit 5b5168c7 authored by David S. Miller's avatar David S. Miller

Merge branch 'net-phy-marvell-fix-and-extend-downshift-support'

Heiner Kallweit says:

====================
net: phy: marvell: fix and extend downshift support

This series includes two fixes and two extensions for downshift support.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents e528afb7 262caf47
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
#define MII_M1011_PHY_SCR 0x10 #define MII_M1011_PHY_SCR 0x10
#define MII_M1011_PHY_SCR_DOWNSHIFT_EN BIT(11) #define MII_M1011_PHY_SCR_DOWNSHIFT_EN BIT(11)
#define MII_M1011_PHY_SRC_DOWNSHIFT_MASK GENMASK(14, 12) #define MII_M1011_PHY_SCR_DOWNSHIFT_MASK GENMASK(14, 12)
#define MII_M1011_PHY_SCR_DOWNSHIFT_MAX 8 #define MII_M1011_PHY_SCR_DOWNSHIFT_MAX 8
#define MII_M1011_PHY_SCR_MDI (0x0 << 5) #define MII_M1011_PHY_SCR_MDI (0x0 << 5)
#define MII_M1011_PHY_SCR_MDI_X (0x1 << 5) #define MII_M1011_PHY_SCR_MDI_X (0x1 << 5)
...@@ -66,6 +66,9 @@ ...@@ -66,6 +66,9 @@
#define MII_M1111_PHY_LED_DIRECT 0x4100 #define MII_M1111_PHY_LED_DIRECT 0x4100
#define MII_M1111_PHY_LED_COMBINE 0x411c #define MII_M1111_PHY_LED_COMBINE 0x411c
#define MII_M1111_PHY_EXT_CR 0x14 #define MII_M1111_PHY_EXT_CR 0x14
#define MII_M1111_PHY_EXT_CR_DOWNSHIFT_MASK GENMASK(11, 9)
#define MII_M1111_PHY_EXT_CR_DOWNSHIFT_MAX 8
#define MII_M1111_PHY_EXT_CR_DOWNSHIFT_EN BIT(8)
#define MII_M1111_RGMII_RX_DELAY BIT(7) #define MII_M1111_RGMII_RX_DELAY BIT(7)
#define MII_M1111_RGMII_TX_DELAY BIT(1) #define MII_M1111_RGMII_TX_DELAY BIT(1)
#define MII_M1111_PHY_EXT_SR 0x1b #define MII_M1111_PHY_EXT_SR 0x1b
...@@ -788,19 +791,77 @@ static int m88e1111_get_downshift(struct phy_device *phydev, u8 *data) ...@@ -788,19 +791,77 @@ static int m88e1111_get_downshift(struct phy_device *phydev, u8 *data)
{ {
int val, cnt, enable; int val, cnt, enable;
val = phy_read(phydev, MII_M1111_PHY_EXT_CR);
if (val < 0)
return val;
enable = FIELD_GET(MII_M1111_PHY_EXT_CR_DOWNSHIFT_EN, val);
cnt = FIELD_GET(MII_M1111_PHY_EXT_CR_DOWNSHIFT_MASK, val) + 1;
*data = enable ? cnt : DOWNSHIFT_DEV_DISABLE;
return 0;
}
static int m88e1111_set_downshift(struct phy_device *phydev, u8 cnt)
{
int val;
if (cnt > MII_M1111_PHY_EXT_CR_DOWNSHIFT_MAX)
return -E2BIG;
if (!cnt)
return phy_clear_bits(phydev, MII_M1111_PHY_EXT_CR,
MII_M1111_PHY_EXT_CR_DOWNSHIFT_EN);
val = MII_M1111_PHY_EXT_CR_DOWNSHIFT_EN;
val |= FIELD_PREP(MII_M1111_PHY_EXT_CR_DOWNSHIFT_MASK, cnt - 1);
return phy_modify(phydev, MII_M1111_PHY_EXT_CR,
MII_M1111_PHY_EXT_CR_DOWNSHIFT_EN |
MII_M1111_PHY_EXT_CR_DOWNSHIFT_MASK,
val);
}
static int m88e1111_get_tunable(struct phy_device *phydev,
struct ethtool_tunable *tuna, void *data)
{
switch (tuna->id) {
case ETHTOOL_PHY_DOWNSHIFT:
return m88e1111_get_downshift(phydev, data);
default:
return -EOPNOTSUPP;
}
}
static int m88e1111_set_tunable(struct phy_device *phydev,
struct ethtool_tunable *tuna, const void *data)
{
switch (tuna->id) {
case ETHTOOL_PHY_DOWNSHIFT:
return m88e1111_set_downshift(phydev, *(const u8 *)data);
default:
return -EOPNOTSUPP;
}
}
static int m88e1011_get_downshift(struct phy_device *phydev, u8 *data)
{
int val, cnt, enable;
val = phy_read(phydev, MII_M1011_PHY_SCR); val = phy_read(phydev, MII_M1011_PHY_SCR);
if (val < 0) if (val < 0)
return val; return val;
enable = FIELD_GET(MII_M1011_PHY_SCR_DOWNSHIFT_EN, val); enable = FIELD_GET(MII_M1011_PHY_SCR_DOWNSHIFT_EN, val);
cnt = FIELD_GET(MII_M1011_PHY_SRC_DOWNSHIFT_MASK, val) + 1; cnt = FIELD_GET(MII_M1011_PHY_SCR_DOWNSHIFT_MASK, val) + 1;
*data = enable ? cnt : DOWNSHIFT_DEV_DISABLE; *data = enable ? cnt : DOWNSHIFT_DEV_DISABLE;
return 0; return 0;
} }
static int m88e1111_set_downshift(struct phy_device *phydev, u8 cnt) static int m88e1011_set_downshift(struct phy_device *phydev, u8 cnt)
{ {
int val; int val;
...@@ -812,37 +873,37 @@ static int m88e1111_set_downshift(struct phy_device *phydev, u8 cnt) ...@@ -812,37 +873,37 @@ static int m88e1111_set_downshift(struct phy_device *phydev, u8 cnt)
MII_M1011_PHY_SCR_DOWNSHIFT_EN); MII_M1011_PHY_SCR_DOWNSHIFT_EN);
val = MII_M1011_PHY_SCR_DOWNSHIFT_EN; val = MII_M1011_PHY_SCR_DOWNSHIFT_EN;
val |= FIELD_PREP(MII_M1011_PHY_SRC_DOWNSHIFT_MASK, cnt - 1); val |= FIELD_PREP(MII_M1011_PHY_SCR_DOWNSHIFT_MASK, cnt - 1);
return phy_modify(phydev, MII_M1011_PHY_SCR, return phy_modify(phydev, MII_M1011_PHY_SCR,
MII_M1011_PHY_SCR_DOWNSHIFT_EN | MII_M1011_PHY_SCR_DOWNSHIFT_EN |
MII_M1011_PHY_SRC_DOWNSHIFT_MASK, MII_M1011_PHY_SCR_DOWNSHIFT_MASK,
val); val);
} }
static int m88e1111_get_tunable(struct phy_device *phydev, static int m88e1011_get_tunable(struct phy_device *phydev,
struct ethtool_tunable *tuna, void *data) struct ethtool_tunable *tuna, void *data)
{ {
switch (tuna->id) { switch (tuna->id) {
case ETHTOOL_PHY_DOWNSHIFT: case ETHTOOL_PHY_DOWNSHIFT:
return m88e1111_get_downshift(phydev, data); return m88e1011_get_downshift(phydev, data);
default: default:
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
} }
static int m88e1111_set_tunable(struct phy_device *phydev, static int m88e1011_set_tunable(struct phy_device *phydev,
struct ethtool_tunable *tuna, const void *data) struct ethtool_tunable *tuna, const void *data)
{ {
switch (tuna->id) { switch (tuna->id) {
case ETHTOOL_PHY_DOWNSHIFT: case ETHTOOL_PHY_DOWNSHIFT:
return m88e1111_set_downshift(phydev, *(const u8 *)data); return m88e1011_set_downshift(phydev, *(const u8 *)data);
default: default:
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
} }
static void m88e1111_link_change_notify(struct phy_device *phydev) static void m88e1011_link_change_notify(struct phy_device *phydev)
{ {
int status; int status;
...@@ -875,7 +936,7 @@ static int m88e1116r_config_init(struct phy_device *phydev) ...@@ -875,7 +936,7 @@ static int m88e1116r_config_init(struct phy_device *phydev)
if (err < 0) if (err < 0)
return err; return err;
err = m88e1111_set_downshift(phydev, 8); err = m88e1011_set_downshift(phydev, 8);
if (err < 0) if (err < 0)
return err; return err;
...@@ -1177,7 +1238,7 @@ static int m88e1540_get_tunable(struct phy_device *phydev, ...@@ -1177,7 +1238,7 @@ static int m88e1540_get_tunable(struct phy_device *phydev,
case ETHTOOL_PHY_FAST_LINK_DOWN: case ETHTOOL_PHY_FAST_LINK_DOWN:
return m88e1540_get_fld(phydev, data); return m88e1540_get_fld(phydev, data);
case ETHTOOL_PHY_DOWNSHIFT: case ETHTOOL_PHY_DOWNSHIFT:
return m88e1111_get_downshift(phydev, data); return m88e1011_get_downshift(phydev, data);
default: default:
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
...@@ -1190,7 +1251,7 @@ static int m88e1540_set_tunable(struct phy_device *phydev, ...@@ -1190,7 +1251,7 @@ static int m88e1540_set_tunable(struct phy_device *phydev,
case ETHTOOL_PHY_FAST_LINK_DOWN: case ETHTOOL_PHY_FAST_LINK_DOWN:
return m88e1540_set_fld(phydev, data); return m88e1540_set_fld(phydev, data);
case ETHTOOL_PHY_DOWNSHIFT: case ETHTOOL_PHY_DOWNSHIFT:
return m88e1111_set_downshift(phydev, *(const u8 *)data); return m88e1011_set_downshift(phydev, *(const u8 *)data);
default: default:
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
...@@ -2226,6 +2287,9 @@ static struct phy_driver marvell_drivers[] = { ...@@ -2226,6 +2287,9 @@ static struct phy_driver marvell_drivers[] = {
.get_sset_count = marvell_get_sset_count, .get_sset_count = marvell_get_sset_count,
.get_strings = marvell_get_strings, .get_strings = marvell_get_strings,
.get_stats = marvell_get_stats, .get_stats = marvell_get_stats,
.get_tunable = m88e1011_get_tunable,
.set_tunable = m88e1011_set_tunable,
.link_change_notify = m88e1011_link_change_notify,
}, },
{ {
.phy_id = MARVELL_PHY_ID_88E1111, .phy_id = MARVELL_PHY_ID_88E1111,
...@@ -2245,6 +2309,9 @@ static struct phy_driver marvell_drivers[] = { ...@@ -2245,6 +2309,9 @@ static struct phy_driver marvell_drivers[] = {
.get_sset_count = marvell_get_sset_count, .get_sset_count = marvell_get_sset_count,
.get_strings = marvell_get_strings, .get_strings = marvell_get_strings,
.get_stats = marvell_get_stats, .get_stats = marvell_get_stats,
.get_tunable = m88e1111_get_tunable,
.set_tunable = m88e1111_set_tunable,
.link_change_notify = m88e1011_link_change_notify,
}, },
{ {
.phy_id = MARVELL_PHY_ID_88E1118, .phy_id = MARVELL_PHY_ID_88E1118,
...@@ -2283,9 +2350,9 @@ static struct phy_driver marvell_drivers[] = { ...@@ -2283,9 +2350,9 @@ static struct phy_driver marvell_drivers[] = {
.get_sset_count = marvell_get_sset_count, .get_sset_count = marvell_get_sset_count,
.get_strings = marvell_get_strings, .get_strings = marvell_get_strings,
.get_stats = marvell_get_stats, .get_stats = marvell_get_stats,
.get_tunable = m88e1111_get_tunable, .get_tunable = m88e1011_get_tunable,
.set_tunable = m88e1111_set_tunable, .set_tunable = m88e1011_set_tunable,
.link_change_notify = m88e1111_link_change_notify, .link_change_notify = m88e1011_link_change_notify,
}, },
{ {
.phy_id = MARVELL_PHY_ID_88E1318S, .phy_id = MARVELL_PHY_ID_88E1318S,
...@@ -2380,6 +2447,9 @@ static struct phy_driver marvell_drivers[] = { ...@@ -2380,6 +2447,9 @@ static struct phy_driver marvell_drivers[] = {
.get_sset_count = marvell_get_sset_count, .get_sset_count = marvell_get_sset_count,
.get_strings = marvell_get_strings, .get_strings = marvell_get_strings,
.get_stats = marvell_get_stats, .get_stats = marvell_get_stats,
.get_tunable = m88e1011_get_tunable,
.set_tunable = m88e1011_set_tunable,
.link_change_notify = m88e1011_link_change_notify,
}, },
{ {
.phy_id = MARVELL_PHY_ID_88E1510, .phy_id = MARVELL_PHY_ID_88E1510,
...@@ -2403,6 +2473,9 @@ static struct phy_driver marvell_drivers[] = { ...@@ -2403,6 +2473,9 @@ static struct phy_driver marvell_drivers[] = {
.get_strings = marvell_get_strings, .get_strings = marvell_get_strings,
.get_stats = marvell_get_stats, .get_stats = marvell_get_stats,
.set_loopback = genphy_loopback, .set_loopback = genphy_loopback,
.get_tunable = m88e1011_get_tunable,
.set_tunable = m88e1011_set_tunable,
.link_change_notify = m88e1011_link_change_notify,
}, },
{ {
.phy_id = MARVELL_PHY_ID_88E1540, .phy_id = MARVELL_PHY_ID_88E1540,
...@@ -2425,7 +2498,7 @@ static struct phy_driver marvell_drivers[] = { ...@@ -2425,7 +2498,7 @@ static struct phy_driver marvell_drivers[] = {
.get_stats = marvell_get_stats, .get_stats = marvell_get_stats,
.get_tunable = m88e1540_get_tunable, .get_tunable = m88e1540_get_tunable,
.set_tunable = m88e1540_set_tunable, .set_tunable = m88e1540_set_tunable,
.link_change_notify = m88e1111_link_change_notify, .link_change_notify = m88e1011_link_change_notify,
}, },
{ {
.phy_id = MARVELL_PHY_ID_88E1545, .phy_id = MARVELL_PHY_ID_88E1545,
...@@ -2446,6 +2519,9 @@ static struct phy_driver marvell_drivers[] = { ...@@ -2446,6 +2519,9 @@ static struct phy_driver marvell_drivers[] = {
.get_sset_count = marvell_get_sset_count, .get_sset_count = marvell_get_sset_count,
.get_strings = marvell_get_strings, .get_strings = marvell_get_strings,
.get_stats = marvell_get_stats, .get_stats = marvell_get_stats,
.get_tunable = m88e1540_get_tunable,
.set_tunable = m88e1540_set_tunable,
.link_change_notify = m88e1011_link_change_notify,
}, },
{ {
.phy_id = MARVELL_PHY_ID_88E3016, .phy_id = MARVELL_PHY_ID_88E3016,
...@@ -2488,7 +2564,7 @@ static struct phy_driver marvell_drivers[] = { ...@@ -2488,7 +2564,7 @@ static struct phy_driver marvell_drivers[] = {
.get_stats = marvell_get_stats, .get_stats = marvell_get_stats,
.get_tunable = m88e1540_get_tunable, .get_tunable = m88e1540_get_tunable,
.set_tunable = m88e1540_set_tunable, .set_tunable = m88e1540_set_tunable,
.link_change_notify = m88e1111_link_change_notify, .link_change_notify = m88e1011_link_change_notify,
}, },
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment