Commit a5e63c7d authored by Steve Bennett's avatar Steve Bennett Committed by David S. Miller

net: phy: micrel: Fix detection of ksz87xx switch

The logic for discerning between KSZ8051 and KSZ87XX PHYs is incorrect
such that the that KSZ87XX switch is not identified correctly.

ksz8051_ksz8795_match_phy_device() uses the parameter ksz_phy_id
to discriminate whether it was called from ksz8051_match_phy_device()
or from ksz8795_match_phy_device() but since PHY_ID_KSZ87XX is the
same value as PHY_ID_KSZ8051, this doesn't work.

Instead use a bool to discriminate the caller.

Without this patch, the KSZ8795 switch port identifies as:

ksz8795-switch spi3.1 ade1 (uninitialized): PHY [dsa-0.1:03] driver [Generic PHY]

With the patch, it identifies correctly:

ksz8795-switch spi3.1 ade1 (uninitialized): PHY [dsa-0.1:03] driver [Micrel KSZ87XX Switch]

Fixes: 8b95599c ("net: phy: micrel: Discern KSZ8051 and KSZ8795 PHYs")
Signed-off-by: default avatarSteve Bennett <steveb@workware.net.au>
Reviewed-by: default avatarMarek Vasut <marex@denx.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent cebb5103
...@@ -401,11 +401,11 @@ static int ksz8041_config_aneg(struct phy_device *phydev) ...@@ -401,11 +401,11 @@ static int ksz8041_config_aneg(struct phy_device *phydev)
} }
static int ksz8051_ksz8795_match_phy_device(struct phy_device *phydev, static int ksz8051_ksz8795_match_phy_device(struct phy_device *phydev,
const u32 ksz_phy_id) const bool ksz_8051)
{ {
int ret; int ret;
if ((phydev->phy_id & MICREL_PHY_ID_MASK) != ksz_phy_id) if ((phydev->phy_id & MICREL_PHY_ID_MASK) != PHY_ID_KSZ8051)
return 0; return 0;
ret = phy_read(phydev, MII_BMSR); ret = phy_read(phydev, MII_BMSR);
...@@ -418,7 +418,7 @@ static int ksz8051_ksz8795_match_phy_device(struct phy_device *phydev, ...@@ -418,7 +418,7 @@ static int ksz8051_ksz8795_match_phy_device(struct phy_device *phydev,
* the switch does not. * the switch does not.
*/ */
ret &= BMSR_ERCAP; ret &= BMSR_ERCAP;
if (ksz_phy_id == PHY_ID_KSZ8051) if (ksz_8051)
return ret; return ret;
else else
return !ret; return !ret;
...@@ -426,7 +426,7 @@ static int ksz8051_ksz8795_match_phy_device(struct phy_device *phydev, ...@@ -426,7 +426,7 @@ static int ksz8051_ksz8795_match_phy_device(struct phy_device *phydev,
static int ksz8051_match_phy_device(struct phy_device *phydev) static int ksz8051_match_phy_device(struct phy_device *phydev)
{ {
return ksz8051_ksz8795_match_phy_device(phydev, PHY_ID_KSZ8051); return ksz8051_ksz8795_match_phy_device(phydev, true);
} }
static int ksz8081_config_init(struct phy_device *phydev) static int ksz8081_config_init(struct phy_device *phydev)
...@@ -535,7 +535,7 @@ static int ksz8061_config_init(struct phy_device *phydev) ...@@ -535,7 +535,7 @@ static int ksz8061_config_init(struct phy_device *phydev)
static int ksz8795_match_phy_device(struct phy_device *phydev) static int ksz8795_match_phy_device(struct phy_device *phydev)
{ {
return ksz8051_ksz8795_match_phy_device(phydev, PHY_ID_KSZ87XX); return ksz8051_ksz8795_match_phy_device(phydev, false);
} }
static int ksz9021_load_values_from_of(struct phy_device *phydev, static int ksz9021_load_values_from_of(struct phy_device *phydev,
......
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