net: phylink: Add helpers for c22 registers without MDIO
authorSean Anderson <sean.anderson@seco.com>
Fri, 19 Nov 2021 15:58:09 +0000 (10:58 -0500)
committerDavid S. Miller <davem@davemloft.net>
Mon, 22 Nov 2021 13:15:33 +0000 (13:15 +0000)
commit291dcae39bc482f7edc91a50d97027327e0cf5f9
tree2ca01813920412033f73399836589b5cd417abd9
parent6d872df3e3b91532b142de9044e5b4984017a55f
net: phylink: Add helpers for c22 registers without MDIO

Some devices expose memory-mapped c22-compliant PHYs. Because these
devices do not have an MDIO bus, we cannot use the existing helpers.
Refactor the existing helpers to allow supplying the values for c22
registers directly, instead of using MDIO to access them. Only get_state
and set_advertisement are converted, since they contain the most complex
logic. Because set_advertisement is never actually used outside
phylink_mii_c22_pcs_config, move the MDIO-writing part into that
function. Because some modes do not need the advertisement register set
at all, we use -EINVAL for this purpose.

Additionally, a new function phylink_pcs_enable_an is provided to
determine whether to enable autonegotiation.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/phy/phylink.c
include/linux/phylink.h