From: Russell King <rmk+kernel@armlinux•org.uk>
To: Andrew Lunn <andrew@lunn•ch>,
Florian Fainelli <f.fainelli@gmail•com>,
Heiner Kallweit <hkallweit1@gmail•com>,
Ioana Ciornei <ioana.ciornei@nxp•com>
Cc: "David S. Miller" <davem@davemloft•net>,
netdev@vger•kernel.org,
Alexandru Marginean <alexandru.marginean@nxp•com>,
Claudiu Manoil <claudiu.manoil@nxp•com>,
"michael@walle•cc" <michael@walle•cc>,
"olteanv@gmail•com" <olteanv@gmail•com>,
Vladimir Oltean <vladimir.oltean@nxp•com>,
Jakub Kicinski <kuba@kernel•org>
Subject: [PATCH net-next 14/14] net: phylink: add interface to configure clause 22 PCS PHY
Date: Tue, 21 Jul 2020 12:04:51 +0100 [thread overview]
Message-ID: <E1jxq4p-0004Te-Rq@rmk-PC.armlinux.org.uk> (raw)
In-Reply-To: <20200721110152.GY1551@shell.armlinux.org.uk>
Add an interface to configure the advertisement for a clause 22 PCS
PHY, and set the AN enable flag in the BMCR appropriately.
Reviewed-by: Ioana Ciornei <ioana.ciornei@nxp•com>
Signed-off-by: Russell King <rmk+kernel@armlinux•org.uk>
---
drivers/net/phy/phylink.c | 37 +++++++++++++++++++++++++++++++++++++
include/linux/phylink.h | 3 +++
2 files changed, 40 insertions(+)
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index b57cd2142786..32b4bd6a5b55 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -2442,6 +2442,43 @@ int phylink_mii_c22_pcs_set_advertisement(struct mdio_device *pcs,
}
EXPORT_SYMBOL_GPL(phylink_mii_c22_pcs_set_advertisement);
+/**
+ * phylink_mii_c22_pcs_config() - configure clause 22 PCS
+ * @pcs: a pointer to a &struct mdio_device.
+ * @mode: link autonegotiation mode
+ * @interface: the PHY interface mode being configured
+ * @advertising: the ethtool advertisement mask
+ *
+ * Configure a Clause 22 PCS PHY with the appropriate negotiation
+ * parameters for the @mode, @interface and @advertising parameters.
+ * Returns negative error number on failure, zero if the advertisement
+ * has not changed, or positive if there is a change.
+ */
+int phylink_mii_c22_pcs_config(struct mdio_device *pcs, unsigned int mode,
+ phy_interface_t interface,
+ const unsigned long *advertising)
+{
+ bool changed;
+ u16 bmcr;
+ int ret;
+
+ ret = phylink_mii_c22_pcs_set_advertisement(pcs, interface,
+ advertising);
+ if (ret < 0)
+ return ret;
+
+ changed = ret > 0;
+
+ bmcr = mode == MLO_AN_INBAND ? BMCR_ANENABLE : 0;
+ ret = mdiobus_modify(pcs->bus, pcs->addr, MII_BMCR,
+ BMCR_ANENABLE, bmcr);
+ if (ret < 0)
+ return ret;
+
+ return changed ? 1 : 0;
+}
+EXPORT_SYMBOL_GPL(phylink_mii_c22_pcs_config);
+
/**
* phylink_mii_c22_pcs_an_restart() - restart 802.3z autonegotiation
* @pcs: a pointer to a &struct mdio_device.
diff --git a/include/linux/phylink.h b/include/linux/phylink.h
index 057f78263a46..1aad2aea4610 100644
--- a/include/linux/phylink.h
+++ b/include/linux/phylink.h
@@ -478,6 +478,9 @@ void phylink_mii_c22_pcs_get_state(struct mdio_device *pcs,
int phylink_mii_c22_pcs_set_advertisement(struct mdio_device *pcs,
phy_interface_t interface,
const unsigned long *advertising);
+int phylink_mii_c22_pcs_config(struct mdio_device *pcs, unsigned int mode,
+ phy_interface_t interface,
+ const unsigned long *advertising);
void phylink_mii_c22_pcs_an_restart(struct mdio_device *pcs);
void phylink_mii_c45_pcs_get_state(struct mdio_device *pcs,
--
2.20.1
next prev parent reply other threads:[~2020-07-21 11:04 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-21 11:01 [PATCH net-next 00/14] Phylink PCS updates Russell King - ARM Linux admin
2020-07-21 11:03 ` [PATCH net-next 01/14] net: phylink: update ethtool reporting for fixed-link modes Russell King
2020-07-21 11:03 ` [PATCH net-next 02/14] net: phylink: rejig link state tracking Russell King
2020-07-21 11:03 ` [PATCH net-next 03/14] net: phylink: rearrange resolve mac_config() call Russell King
2020-07-21 11:04 ` [PATCH net-next 04/14] net: phylink: ensure link is down when changing interface Russell King
2020-07-21 11:04 ` [PATCH net-next 05/14] net: phylink: update PCS when changing interface during resolution Russell King
2020-07-21 11:04 ` [PATCH net-next 06/14] net: phylink: avoid mac_config calls Russell King
2020-07-21 11:04 ` [PATCH net-next 07/14] net: phylink: simplify ksettings_set() implementation Russell King
2020-07-21 11:04 ` [PATCH net-next 08/14] net: phylink: simplify phy case for ksettings_set method Russell King
2020-07-21 11:04 ` [PATCH net-next 09/14] net: phylink: use config.an_enabled in " Russell King
2020-07-21 11:04 ` [PATCH net-next 10/14] net: phylink: simplify fixed-link case for " Russell King
2020-07-21 11:04 ` [PATCH net-next 11/14] net: phylink: in-band pause mode advertisement update for PCS Russell King
2020-07-21 11:04 ` [PATCH net-next 12/14] net: phylink: re-implement interface configuration with PCS Russell King
2020-07-21 11:04 ` [PATCH net-next 13/14] net: phylink: add struct phylink_pcs Russell King
2020-07-21 11:04 ` Russell King [this message]
2020-07-21 22:47 ` [PATCH net-next 00/14] Phylink PCS updates David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1jxq4p-0004Te-Rq@rmk-PC.armlinux.org.uk \
--to=rmk+kernel@armlinux$(echo .)org.uk \
--cc=alexandru.marginean@nxp$(echo .)com \
--cc=andrew@lunn$(echo .)ch \
--cc=claudiu.manoil@nxp$(echo .)com \
--cc=davem@davemloft$(echo .)net \
--cc=f.fainelli@gmail$(echo .)com \
--cc=hkallweit1@gmail$(echo .)com \
--cc=ioana.ciornei@nxp$(echo .)com \
--cc=kuba@kernel$(echo .)org \
--cc=michael@walle$(echo .)cc \
--cc=netdev@vger$(echo .)kernel.org \
--cc=olteanv@gmail$(echo .)com \
--cc=vladimir.oltean@nxp$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox