Skip to content

Commit 5b5168c

Browse files
committed
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: David S. Miller <[email protected]>
2 parents e528afb + 262caf4 commit 5b5168c

File tree

1 file changed

+94
-18
lines changed

1 file changed

+94
-18
lines changed

drivers/net/phy/marvell.c

Lines changed: 94 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353

5454
#define MII_M1011_PHY_SCR 0x10
5555
#define MII_M1011_PHY_SCR_DOWNSHIFT_EN BIT(11)
56-
#define MII_M1011_PHY_SRC_DOWNSHIFT_MASK GENMASK(14, 12)
56+
#define MII_M1011_PHY_SCR_DOWNSHIFT_MASK GENMASK(14, 12)
5757
#define MII_M1011_PHY_SCR_DOWNSHIFT_MAX 8
5858
#define MII_M1011_PHY_SCR_MDI (0x0 << 5)
5959
#define MII_M1011_PHY_SCR_MDI_X (0x1 << 5)
@@ -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
@@ -788,19 +791,77 @@ static int m88e1111_get_downshift(struct phy_device *phydev, u8 *data)
788791
{
789792
int val, cnt, enable;
790793

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+
848+
static int m88e1011_get_downshift(struct phy_device *phydev, u8 *data)
849+
{
850+
int val, cnt, enable;
851+
791852
val = phy_read(phydev, MII_M1011_PHY_SCR);
792853
if (val < 0)
793854
return val;
794855

795856
enable = FIELD_GET(MII_M1011_PHY_SCR_DOWNSHIFT_EN, val);
796-
cnt = FIELD_GET(MII_M1011_PHY_SRC_DOWNSHIFT_MASK, val) + 1;
857+
cnt = FIELD_GET(MII_M1011_PHY_SCR_DOWNSHIFT_MASK, val) + 1;
797858

798859
*data = enable ? cnt : DOWNSHIFT_DEV_DISABLE;
799860

800861
return 0;
801862
}
802863

803-
static int m88e1111_set_downshift(struct phy_device *phydev, u8 cnt)
864+
static int m88e1011_set_downshift(struct phy_device *phydev, u8 cnt)
804865
{
805866
int val;
806867

@@ -812,37 +873,37 @@ static int m88e1111_set_downshift(struct phy_device *phydev, u8 cnt)
812873
MII_M1011_PHY_SCR_DOWNSHIFT_EN);
813874

814875
val = MII_M1011_PHY_SCR_DOWNSHIFT_EN;
815-
val |= FIELD_PREP(MII_M1011_PHY_SRC_DOWNSHIFT_MASK, cnt - 1);
876+
val |= FIELD_PREP(MII_M1011_PHY_SCR_DOWNSHIFT_MASK, cnt - 1);
816877

817878
return phy_modify(phydev, MII_M1011_PHY_SCR,
818879
MII_M1011_PHY_SCR_DOWNSHIFT_EN |
819-
MII_M1011_PHY_SRC_DOWNSHIFT_MASK,
880+
MII_M1011_PHY_SCR_DOWNSHIFT_MASK,
820881
val);
821882
}
822883

823-
static int m88e1111_get_tunable(struct phy_device *phydev,
884+
static int m88e1011_get_tunable(struct phy_device *phydev,
824885
struct ethtool_tunable *tuna, void *data)
825886
{
826887
switch (tuna->id) {
827888
case ETHTOOL_PHY_DOWNSHIFT:
828-
return m88e1111_get_downshift(phydev, data);
889+
return m88e1011_get_downshift(phydev, data);
829890
default:
830891
return -EOPNOTSUPP;
831892
}
832893
}
833894

834-
static int m88e1111_set_tunable(struct phy_device *phydev,
895+
static int m88e1011_set_tunable(struct phy_device *phydev,
835896
struct ethtool_tunable *tuna, const void *data)
836897
{
837898
switch (tuna->id) {
838899
case ETHTOOL_PHY_DOWNSHIFT:
839-
return m88e1111_set_downshift(phydev, *(const u8 *)data);
900+
return m88e1011_set_downshift(phydev, *(const u8 *)data);
840901
default:
841902
return -EOPNOTSUPP;
842903
}
843904
}
844905

845-
static void m88e1111_link_change_notify(struct phy_device *phydev)
906+
static void m88e1011_link_change_notify(struct phy_device *phydev)
846907
{
847908
int status;
848909

@@ -875,7 +936,7 @@ static int m88e1116r_config_init(struct phy_device *phydev)
875936
if (err < 0)
876937
return err;
877938

878-
err = m88e1111_set_downshift(phydev, 8);
939+
err = m88e1011_set_downshift(phydev, 8);
879940
if (err < 0)
880941
return err;
881942

@@ -1177,7 +1238,7 @@ static int m88e1540_get_tunable(struct phy_device *phydev,
11771238
case ETHTOOL_PHY_FAST_LINK_DOWN:
11781239
return m88e1540_get_fld(phydev, data);
11791240
case ETHTOOL_PHY_DOWNSHIFT:
1180-
return m88e1111_get_downshift(phydev, data);
1241+
return m88e1011_get_downshift(phydev, data);
11811242
default:
11821243
return -EOPNOTSUPP;
11831244
}
@@ -1190,7 +1251,7 @@ static int m88e1540_set_tunable(struct phy_device *phydev,
11901251
case ETHTOOL_PHY_FAST_LINK_DOWN:
11911252
return m88e1540_set_fld(phydev, data);
11921253
case ETHTOOL_PHY_DOWNSHIFT:
1193-
return m88e1111_set_downshift(phydev, *(const u8 *)data);
1254+
return m88e1011_set_downshift(phydev, *(const u8 *)data);
11941255
default:
11951256
return -EOPNOTSUPP;
11961257
}
@@ -2226,6 +2287,9 @@ static struct phy_driver marvell_drivers[] = {
22262287
.get_sset_count = marvell_get_sset_count,
22272288
.get_strings = marvell_get_strings,
22282289
.get_stats = marvell_get_stats,
2290+
.get_tunable = m88e1011_get_tunable,
2291+
.set_tunable = m88e1011_set_tunable,
2292+
.link_change_notify = m88e1011_link_change_notify,
22292293
},
22302294
{
22312295
.phy_id = MARVELL_PHY_ID_88E1111,
@@ -2245,6 +2309,9 @@ static struct phy_driver marvell_drivers[] = {
22452309
.get_sset_count = marvell_get_sset_count,
22462310
.get_strings = marvell_get_strings,
22472311
.get_stats = marvell_get_stats,
2312+
.get_tunable = m88e1111_get_tunable,
2313+
.set_tunable = m88e1111_set_tunable,
2314+
.link_change_notify = m88e1011_link_change_notify,
22482315
},
22492316
{
22502317
.phy_id = MARVELL_PHY_ID_88E1118,
@@ -2283,9 +2350,9 @@ static struct phy_driver marvell_drivers[] = {
22832350
.get_sset_count = marvell_get_sset_count,
22842351
.get_strings = marvell_get_strings,
22852352
.get_stats = marvell_get_stats,
2286-
.get_tunable = m88e1111_get_tunable,
2287-
.set_tunable = m88e1111_set_tunable,
2288-
.link_change_notify = m88e1111_link_change_notify,
2353+
.get_tunable = m88e1011_get_tunable,
2354+
.set_tunable = m88e1011_set_tunable,
2355+
.link_change_notify = m88e1011_link_change_notify,
22892356
},
22902357
{
22912358
.phy_id = MARVELL_PHY_ID_88E1318S,
@@ -2380,6 +2447,9 @@ static struct phy_driver marvell_drivers[] = {
23802447
.get_sset_count = marvell_get_sset_count,
23812448
.get_strings = marvell_get_strings,
23822449
.get_stats = marvell_get_stats,
2450+
.get_tunable = m88e1011_get_tunable,
2451+
.set_tunable = m88e1011_set_tunable,
2452+
.link_change_notify = m88e1011_link_change_notify,
23832453
},
23842454
{
23852455
.phy_id = MARVELL_PHY_ID_88E1510,
@@ -2403,6 +2473,9 @@ static struct phy_driver marvell_drivers[] = {
24032473
.get_strings = marvell_get_strings,
24042474
.get_stats = marvell_get_stats,
24052475
.set_loopback = genphy_loopback,
2476+
.get_tunable = m88e1011_get_tunable,
2477+
.set_tunable = m88e1011_set_tunable,
2478+
.link_change_notify = m88e1011_link_change_notify,
24062479
},
24072480
{
24082481
.phy_id = MARVELL_PHY_ID_88E1540,
@@ -2425,7 +2498,7 @@ static struct phy_driver marvell_drivers[] = {
24252498
.get_stats = marvell_get_stats,
24262499
.get_tunable = m88e1540_get_tunable,
24272500
.set_tunable = m88e1540_set_tunable,
2428-
.link_change_notify = m88e1111_link_change_notify,
2501+
.link_change_notify = m88e1011_link_change_notify,
24292502
},
24302503
{
24312504
.phy_id = MARVELL_PHY_ID_88E1545,
@@ -2446,6 +2519,9 @@ static struct phy_driver marvell_drivers[] = {
24462519
.get_sset_count = marvell_get_sset_count,
24472520
.get_strings = marvell_get_strings,
24482521
.get_stats = marvell_get_stats,
2522+
.get_tunable = m88e1540_get_tunable,
2523+
.set_tunable = m88e1540_set_tunable,
2524+
.link_change_notify = m88e1011_link_change_notify,
24492525
},
24502526
{
24512527
.phy_id = MARVELL_PHY_ID_88E3016,
@@ -2488,7 +2564,7 @@ static struct phy_driver marvell_drivers[] = {
24882564
.get_stats = marvell_get_stats,
24892565
.get_tunable = m88e1540_get_tunable,
24902566
.set_tunable = m88e1540_set_tunable,
2491-
.link_change_notify = m88e1111_link_change_notify,
2567+
.link_change_notify = m88e1011_link_change_notify,
24922568
},
24932569
};
24942570

0 commit comments

Comments
 (0)