Commit e8b6f79b authored by Florian Fainelli's avatar Florian Fainelli Committed by Jakub Kicinski

net: phy: broadcom: Add LPI counter

Add the ability to read the PHY maintained LPI counter which is in the
Clause 45 vendor space, device address 7, offset 0x803F. The counter is
cleared on read.
Signed-off-by: default avatarFlorian Fainelli <florian.fainelli@broadcom.com>
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Link: https://lore.kernel.org/r/20230531231729.1873932-1-florian.fainelli@broadcom.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 733b3e27
...@@ -496,18 +496,20 @@ EXPORT_SYMBOL_GPL(bcm_phy_downshift_set); ...@@ -496,18 +496,20 @@ EXPORT_SYMBOL_GPL(bcm_phy_downshift_set);
struct bcm_phy_hw_stat { struct bcm_phy_hw_stat {
const char *string; const char *string;
u8 reg; int devad;
u16 reg;
u8 shift; u8 shift;
u8 bits; u8 bits;
}; };
/* Counters freeze at either 0xffff or 0xff, better than nothing */ /* Counters freeze at either 0xffff or 0xff, better than nothing */
static const struct bcm_phy_hw_stat bcm_phy_hw_stats[] = { static const struct bcm_phy_hw_stat bcm_phy_hw_stats[] = {
{ "phy_receive_errors", MII_BRCM_CORE_BASE12, 0, 16 }, { "phy_receive_errors", -1, MII_BRCM_CORE_BASE12, 0, 16 },
{ "phy_serdes_ber_errors", MII_BRCM_CORE_BASE13, 8, 8 }, { "phy_serdes_ber_errors", -1, MII_BRCM_CORE_BASE13, 8, 8 },
{ "phy_false_carrier_sense_errors", MII_BRCM_CORE_BASE13, 0, 8 }, { "phy_false_carrier_sense_errors", -1, MII_BRCM_CORE_BASE13, 0, 8 },
{ "phy_local_rcvr_nok", MII_BRCM_CORE_BASE14, 8, 8 }, { "phy_local_rcvr_nok", -1, MII_BRCM_CORE_BASE14, 8, 8 },
{ "phy_remote_rcv_nok", MII_BRCM_CORE_BASE14, 0, 8 }, { "phy_remote_rcv_nok", -1, MII_BRCM_CORE_BASE14, 0, 8 },
{ "phy_lpi_count", MDIO_MMD_AN, BRCM_CL45VEN_EEE_LPI_CNT, 0, 16 },
}; };
int bcm_phy_get_sset_count(struct phy_device *phydev) int bcm_phy_get_sset_count(struct phy_device *phydev)
...@@ -536,7 +538,10 @@ static u64 bcm_phy_get_stat(struct phy_device *phydev, u64 *shadow, ...@@ -536,7 +538,10 @@ static u64 bcm_phy_get_stat(struct phy_device *phydev, u64 *shadow,
int val; int val;
u64 ret; u64 ret;
val = phy_read(phydev, stat.reg); if (stat.devad < 0)
val = phy_read(phydev, stat.reg);
else
val = phy_read_mmd(phydev, stat.devad, stat.reg);
if (val < 0) { if (val < 0) {
ret = U64_MAX; ret = U64_MAX;
} else { } else {
......
...@@ -359,6 +359,8 @@ ...@@ -359,6 +359,8 @@
#define LPI_FEATURE_EN 0x8000 #define LPI_FEATURE_EN 0x8000
#define LPI_FEATURE_EN_DIG1000X 0x4000 #define LPI_FEATURE_EN_DIG1000X 0x4000
#define BRCM_CL45VEN_EEE_LPI_CNT 0x803f
/* Core register definitions*/ /* Core register definitions*/
#define MII_BRCM_CORE_BASE12 0x12 #define MII_BRCM_CORE_BASE12 0x12
#define MII_BRCM_CORE_BASE13 0x13 #define MII_BRCM_CORE_BASE13 0x13
......
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