public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Maxime Chevallier <maxime.chevallier@bootlin.com>
To: davem@davemloft.net, Andrew Lunn <andrew@lunn.ch>,
	Jakub Kicinski <kuba@kernel.org>,
	Eric Dumazet <edumazet@google.com>,
	Paolo Abeni <pabeni@redhat.com>,
	Russell King <linux@armlinux.org.uk>,
	Jonas Jelonek <jelonek.jonas@gmail.com>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Heiner Kallweit <hkallweit1@gmail.com>
Cc: "Maxime Chevallier" <maxime.chevallier@bootlin.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	thomas.petazzoni@bootlin.com, "Simon Horman" <horms@kernel.org>,
	"Romain Gantois" <romain.gantois@bootlin.com>,
	"Marek Behún" <kabel@kernel.org>,
	bcm-kernel-feedback-list@broadcom.com
Subject: [PATCH net-next 5/6] net: mdio: mdio-i2c: Add single-byte C22 MDIO protocol
Date: Wed, 14 Jan 2026 23:57:27 +0100	[thread overview]
Message-ID: <20260114225731.811993-6-maxime.chevallier@bootlin.com> (raw)
In-Reply-To: <20260114225731.811993-1-maxime.chevallier@bootlin.com>

In commit d4bd3aca33c2 ("net: mdio: mdio-i2c: Add support for single-byte
SMBus operations"), we introduced single-byte SMBus support for the
mdio-i2c. This was intended to deal with the case where the I2C adapter
that accesses the SFP module is limited to single-byte smbus accesses.
We find this type of adapters in some PHY devices such as the VSC8552.

It was discovered that some SFP modules have a built-in PHY that only
reply to single-byte smbus accesses. This is the case for the Prolabs
GLC-GE-100FX-C SGMII to 100FX module, which contains a Broadcom BCM5461
PHY.

In that case, trying to access the PHY with regular 16-bit transactions
with the mdio-i2c driver causes the PHY to stall the i2c bus completely,
without any way to recover. Accessing it in single-byte mode however,
works fine.

Add a dedicated MDIO_I2C_SINGLE_BYTE_C22 protocol type, so that we can
setup the mdio-i2c driver accordingly. The good news here is that this
should work on pretty much every setup, as a true I2C adapter is also
capable of single-byte accesses thanks to the i2c smbus emulation layer.

Some care will need to be taken should we add support for word-only
smbus adapters.

Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
---
 drivers/net/mdio/mdio-i2c.c   | 12 ++++++++----
 drivers/net/phy/sfp.c         |  1 +
 include/linux/mdio/mdio-i2c.h |  1 +
 3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/net/mdio/mdio-i2c.c b/drivers/net/mdio/mdio-i2c.c
index ed20352a589a..86ae8a5c0ebd 100644
--- a/drivers/net/mdio/mdio-i2c.c
+++ b/drivers/net/mdio/mdio-i2c.c
@@ -452,7 +452,8 @@ static bool mdio_i2c_check_functionality(struct i2c_adapter *i2c,
 		return true;
 
 	if (i2c_check_functionality(i2c, I2C_FUNC_SMBUS_BYTE_DATA) &&
-	    protocol == MDIO_I2C_MARVELL_C22)
+	    (protocol == MDIO_I2C_MARVELL_C22 ||
+	     protocol == MDIO_I2C_SINGLE_BYTE_C22))
 		return true;
 
 	return false;
@@ -475,9 +476,12 @@ struct mii_bus *mdio_i2c_alloc(struct device *parent, struct i2c_adapter *i2c,
 	mii->parent = parent;
 	mii->priv = i2c;
 
-	/* Only use SMBus if we have no other choice */
-	if (i2c_check_functionality(i2c, I2C_FUNC_SMBUS_BYTE_DATA) &&
-	    !i2c_check_functionality(i2c, I2C_FUNC_I2C)) {
+	/* Only use single-byte SMBus if explicitly asked, or if we have no
+	 * other choice.
+	 */
+	if (protocol == MDIO_I2C_SINGLE_BYTE_C22 ||
+	    (i2c_check_functionality(i2c, I2C_FUNC_SMBUS_BYTE_DATA) &&
+	    !i2c_check_functionality(i2c, I2C_FUNC_I2C))) {
 		mii->read = smbus_byte_mii_read_default_c22;
 		mii->write = smbus_byte_mii_write_default_c22;
 		return mii;
diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
index 1f9112efef62..bff91735f681 100644
--- a/drivers/net/phy/sfp.c
+++ b/drivers/net/phy/sfp.c
@@ -2016,6 +2016,7 @@ static int sfp_sm_probe_for_phy(struct sfp *sfp)
 		break;
 
 	case MDIO_I2C_MARVELL_C22:
+	case MDIO_I2C_SINGLE_BYTE_C22:
 		err = sfp_sm_probe_phy(sfp, SFP_PHY_ADDR, false);
 		break;
 
diff --git a/include/linux/mdio/mdio-i2c.h b/include/linux/mdio/mdio-i2c.h
index 65b550a6fc32..f51c474da5b1 100644
--- a/include/linux/mdio/mdio-i2c.h
+++ b/include/linux/mdio/mdio-i2c.h
@@ -16,6 +16,7 @@ enum mdio_i2c_proto {
 	MDIO_I2C_MARVELL_C22,
 	MDIO_I2C_C45,
 	MDIO_I2C_ROLLBALL,
+	MDIO_I2C_SINGLE_BYTE_C22,
 };
 
 struct mii_bus *mdio_i2c_alloc(struct device *parent, struct i2c_adapter *i2c,
-- 
2.49.0


  parent reply	other threads:[~2026-01-14 22:58 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-14 22:57 [PATCH net-next 0/6] net: sfp: Add support for SGMII to 100FX modules Maxime Chevallier
2026-01-14 22:57 ` [PATCH net-next 1/6] " Maxime Chevallier
2026-01-14 22:57 ` [PATCH net-next 2/6] net: phylink: Allow more interfaces in SFP interface selection Maxime Chevallier
2026-01-14 23:30   ` Russell King (Oracle)
2026-01-15  7:49     ` Maxime Chevallier
2026-02-13  8:41     ` Maxime Chevallier
2026-03-05 15:05       ` Russell King (Oracle)
2026-03-05 16:35         ` Maxime Chevallier
2026-03-05 16:44           ` Russell King (Oracle)
2026-03-06  7:18             ` Maxime Chevallier
2026-01-14 22:57 ` [PATCH net-next 3/6] net: phy: Store module caps for PHYs embedded in SFP Maxime Chevallier
2026-01-14 22:57 ` [PATCH net-next 4/6] net: phy: broadcom: Support SGMII to 100FX on BCM5461 Maxime Chevallier
2026-01-14 22:57 ` Maxime Chevallier [this message]
2026-01-14 22:57 ` [PATCH net-next 6/6] net: sfp: Add support for some BCM5461-based SGMII to 100FX modules Maxime Chevallier

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=20260114225731.811993-6-maxime.chevallier@bootlin.com \
    --to=maxime.chevallier@bootlin.com \
    --cc=andrew@lunn.ch \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=hkallweit1@gmail.com \
    --cc=horms@kernel.org \
    --cc=jelonek.jonas@gmail.com \
    --cc=kabel@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=romain.gantois@bootlin.com \
    --cc=thomas.petazzoni@bootlin.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox