diff options
author | Russell King <rmk+kernel@armlinux.org.uk> | 2020-03-17 14:52:41 +0000 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2020-03-17 22:51:16 -0700 |
commit | b8679ef8bedfe2bae90c97bc4c8a1826cfd98bba (patch) | |
tree | fd25a60497744832cafe42fdb2b8a68764b69e36 /drivers/net/phy | |
parent | 74db1c18d80aaacdc42e6d00d7aca2bb5c97c7ea (diff) | |
download | linux-stable-b8679ef8bedfe2bae90c97bc4c8a1826cfd98bba.tar.gz linux-stable-b8679ef8bedfe2bae90c97bc4c8a1826cfd98bba.tar.bz2 linux-stable-b8679ef8bedfe2bae90c97bc4c8a1826cfd98bba.zip |
net: phylink: pcs: add 802.3 clause 45 helpers
Implement helpers for PCS accessed via the MII bus using 802.3 clause
45 cycles for 10GBASE-R. Only link up/down is supported, 10G full
duplex is assumed.
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/phy')
-rw-r--r-- | drivers/net/phy/phylink.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index ced99e8fda31..fed0c5907c6a 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -2274,4 +2274,34 @@ void phylink_mii_c22_pcs_an_restart(struct mdio_device *pcs) } EXPORT_SYMBOL_GPL(phylink_mii_c22_pcs_an_restart); +#define C45_ADDR(d,a) (MII_ADDR_C45 | (d) << 16 | (a)) +void phylink_mii_c45_pcs_get_state(struct mdio_device *pcs, + struct phylink_link_state *state) +{ + struct mii_bus *bus = pcs->bus; + int addr = pcs->addr; + int stat; + + stat = mdiobus_read(bus, addr, C45_ADDR(MDIO_MMD_PCS, MDIO_STAT1)); + if (stat < 0) { + state->link = false; + return; + } + + state->link = !!(stat & MDIO_STAT1_LSTATUS); + if (!state->link) + return; + + switch (state->interface) { + case PHY_INTERFACE_MODE_10GBASER: + state->speed = SPEED_10000; + state->duplex = DUPLEX_FULL; + break; + + default: + break; + } +} +EXPORT_SYMBOL_GPL(phylink_mii_c45_pcs_get_state); + MODULE_LICENSE("GPL v2"); |