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>
Cc: "David S. Miller" <davem@davemloft.net>, netdev@vger.kernel.org
Subject: [PATCH net-next v3 14/14] net: sfp: add support for Clause 45 PHYs
Date: Wed, 11 Dec 2019 10:57:01 +0000 [thread overview]
Message-ID: <E1iezfx-0002z9-46@rmk-PC.armlinux.org.uk> (raw)
In-Reply-To: <20191211104821.GB25745@shell.armlinux.org.uk>
Some SFP+ modules have a Clause 45 PHY onboard, which is accessible via
the normal I2C address. Detect 10G BASE-T PHYs which may have an
accessible PHY and probe for it.
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
drivers/net/phy/sfp.c | 44 +++++++++++++++++++++++++++++++++++++++----
1 file changed, 40 insertions(+), 4 deletions(-)
diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
index d7d2c797c89c..bfe268028154 100644
--- a/drivers/net/phy/sfp.c
+++ b/drivers/net/phy/sfp.c
@@ -1402,12 +1402,12 @@ static void sfp_sm_phy_detach(struct sfp *sfp)
sfp->mod_phy = NULL;
}
-static void sfp_sm_probe_phy(struct sfp *sfp)
+static void sfp_sm_probe_phy(struct sfp *sfp, bool is_c45)
{
struct phy_device *phy;
int err;
- phy = mdiobus_scan(sfp->i2c_mii, SFP_PHY_ADDR);
+ phy = get_phy_device(sfp->i2c_mii, SFP_PHY_ADDR, is_c45);
if (phy == ERR_PTR(-ENODEV)) {
dev_info(sfp->dev, "no PHY detected\n");
return;
@@ -1417,6 +1417,13 @@ static void sfp_sm_probe_phy(struct sfp *sfp)
return;
}
+ err = phy_device_register(phy);
+ if (err) {
+ phy_device_free(phy);
+ dev_err(sfp->dev, "phy_device_register failed: %d\n", err);
+ return;
+ }
+
err = sfp_add_phy(sfp->sfp_bus, phy);
if (err) {
phy_device_remove(phy);
@@ -1487,10 +1494,32 @@ static void sfp_sm_fault(struct sfp *sfp, unsigned int next_state, bool warn)
}
}
+/* Probe a SFP for a PHY device if the module supports copper - the PHY
+ * normally sits at I2C bus address 0x56, and may either be a clause 22
+ * or clause 45 PHY.
+ *
+ * Clause 22 copper SFP modules normally operate in Cisco SGMII mode with
+ * negotiation enabled, but some may be in 1000base-X - which is for the
+ * PHY driver to determine.
+ *
+ * Clause 45 copper SFP+ modules (10G) appear to switch their interface
+ * mode according to the negotiated line speed.
+ */
static void sfp_sm_probe_for_phy(struct sfp *sfp)
{
- if (sfp->id.base.e1000_base_t)
- sfp_sm_probe_phy(sfp);
+ switch (sfp->id.base.extended_cc) {
+ case SFF8024_ECC_10GBASE_T_SFI:
+ case SFF8024_ECC_10GBASE_T_SR:
+ case SFF8024_ECC_5GBASE_T:
+ case SFF8024_ECC_2_5GBASE_T:
+ sfp_sm_probe_phy(sfp, true);
+ break;
+
+ default:
+ if (sfp->id.base.e1000_base_t)
+ sfp_sm_probe_phy(sfp, false);
+ break;
+ }
}
static int sfp_module_parse_power(struct sfp *sfp)
@@ -1550,6 +1579,13 @@ static int sfp_sm_mod_hpower(struct sfp *sfp, bool enable)
return -EAGAIN;
}
+ /* DM7052 reports as a high power module, responds to reads (with
+ * all bytes 0xff) at 0x51 but does not accept writes. In any case,
+ * if the bit is already set, we're already in high power mode.
+ */
+ if (!!(val & BIT(0)) == enable)
+ return 0;
+
if (enable)
val |= BIT(0);
else
--
2.20.1
next prev parent reply other threads:[~2019-12-11 10:57 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-11 10:48 [PATCH net-next v3 00/14] Add support for SFP+ copper modules Russell King - ARM Linux admin
2019-12-11 10:55 ` [PATCH net-next v3 01/14] net: sfp: remove incomplete 100BASE-FX and 100BASE-LX support Russell King
2019-12-11 10:55 ` [PATCH net-next v3 02/14] net: sfp: derive interface mode from ethtool link modes Russell King
2019-12-11 10:56 ` [PATCH net-next v3 03/14] net: sfp: add more extended compliance codes Russell King
2019-12-11 10:56 ` [PATCH net-next v3 04/14] net: sfp: add module start/stop upstream notifications Russell King
2019-12-11 10:56 ` [PATCH net-next v3 05/14] net: sfp: move phy_start()/phy_stop() to phylink Russell King
2019-12-11 10:56 ` [PATCH net-next v3 06/14] net: mdio-i2c: add support for Clause 45 accesses Russell King
2019-12-11 10:56 ` [PATCH net-next v3 07/14] net: phylink: re-split __phylink_connect_phy() Russell King
2019-12-11 10:56 ` [PATCH net-next v3 08/14] net: phylink: support Clause 45 PHYs on SFP+ modules Russell King
2019-12-11 10:56 ` [PATCH net-next v3 09/14] net: phylink: split link_an_mode configured and current settings Russell King
2019-12-11 10:56 ` [PATCH net-next v3 10/14] net: phylink: split phylink_sfp_module_insert() Russell King
2019-12-11 10:56 ` [PATCH net-next v3 11/14] net: phylink: delay MAC configuration for copper SFP modules Russell King
2019-12-11 10:56 ` [PATCH net-next v3 12/14] net: phylink: make Broadcom BCM84881 based SFPs work Russell King
2019-12-11 10:56 ` [PATCH net-next v3 13/14] net: phy: add Broadcom BCM84881 PHY driver Russell King
2019-12-11 10:57 ` Russell King [this message]
2019-12-11 19:53 ` [PATCH net-next v3 00/14] Add support for SFP+ copper modules 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=E1iezfx-0002z9-46@rmk-PC.armlinux.org.uk \
--to=rmk+kernel@armlinux.org.uk \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=hkallweit1@gmail.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.