Skip to content

Commit 2441ba4

Browse files
hkallweitdavem330
authored andcommitted
net: phy: swphy: emulate register MII_ESTATUS
When the genphy driver binds to a swphy it will call genphy_read_abilites that will try to read MII_ESTATUS if BMSR_ESTATEN is set in MII_BMSR. So far this would read the default value 0xffff and 1000FD and 1000HD are reported as supported just by chance. Better add explicit support for emulating MII_ESTATUS. Signed-off-by: Heiner Kallweit <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 916e571 commit 2441ba4

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

drivers/net/phy/swphy.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ struct swmii_regs {
2222
u16 bmsr;
2323
u16 lpa;
2424
u16 lpagb;
25+
u16 estat;
2526
};
2627

2728
enum {
@@ -48,6 +49,7 @@ static const struct swmii_regs speed[] = {
4849
[SWMII_SPEED_1000] = {
4950
.bmsr = BMSR_ESTATEN,
5051
.lpagb = LPA_1000FULL | LPA_1000HALF,
52+
.estat = ESTATUS_1000_TFULL | ESTATUS_1000_THALF,
5153
},
5254
};
5355

@@ -56,11 +58,13 @@ static const struct swmii_regs duplex[] = {
5658
.bmsr = BMSR_ESTATEN | BMSR_100HALF,
5759
.lpa = LPA_10HALF | LPA_100HALF,
5860
.lpagb = LPA_1000HALF,
61+
.estat = ESTATUS_1000_THALF,
5962
},
6063
[SWMII_DUPLEX_FULL] = {
6164
.bmsr = BMSR_ESTATEN | BMSR_100FULL,
6265
.lpa = LPA_10FULL | LPA_100FULL,
6366
.lpagb = LPA_1000FULL,
67+
.estat = ESTATUS_1000_TFULL,
6468
},
6569
};
6670

@@ -112,6 +116,7 @@ int swphy_read_reg(int reg, const struct fixed_phy_status *state)
112116
{
113117
int speed_index, duplex_index;
114118
u16 bmsr = BMSR_ANEGCAPABLE;
119+
u16 estat = 0;
115120
u16 lpagb = 0;
116121
u16 lpa = 0;
117122

@@ -125,6 +130,7 @@ int swphy_read_reg(int reg, const struct fixed_phy_status *state)
125130
duplex_index = state->duplex ? SWMII_DUPLEX_FULL : SWMII_DUPLEX_HALF;
126131

127132
bmsr |= speed[speed_index].bmsr & duplex[duplex_index].bmsr;
133+
estat |= speed[speed_index].estat & duplex[duplex_index].estat;
128134

129135
if (state->link) {
130136
bmsr |= BMSR_LSTATUS | BMSR_ANEGCOMPLETE;
@@ -151,6 +157,8 @@ int swphy_read_reg(int reg, const struct fixed_phy_status *state)
151157
return lpa;
152158
case MII_STAT1000:
153159
return lpagb;
160+
case MII_ESTATUS:
161+
return estat;
154162

155163
/*
156164
* We do not support emulating Clause 45 over Clause 22 register

0 commit comments

Comments
 (0)