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 06/14] net: mdio-i2c: add support for Clause 45 accesses
Date: Mon, 09 Dec 2019 14:07:12 +0000 [thread overview]
Message-ID: <E1ieJgu-0004Om-63@rmk-PC.armlinux.org.uk> (raw)
In-Reply-To: <20191209140258.GI25745@shell.armlinux.org.uk>
Some SFP+ modules have PHYs on them just like SFP modules do, except
they are Clause 45 PHYs. The I2C protocol used to access them is
modified slightly in order to send the device address and 16-bit
register index.
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
drivers/net/phy/mdio-i2c.c | 28 ++++++++++++++++++++--------
1 file changed, 20 insertions(+), 8 deletions(-)
diff --git a/drivers/net/phy/mdio-i2c.c b/drivers/net/phy/mdio-i2c.c
index 0dce67672548..0746e2cc39ae 100644
--- a/drivers/net/phy/mdio-i2c.c
+++ b/drivers/net/phy/mdio-i2c.c
@@ -33,17 +33,24 @@ static int i2c_mii_read(struct mii_bus *bus, int phy_id, int reg)
{
struct i2c_adapter *i2c = bus->priv;
struct i2c_msg msgs[2];
- u8 data[2], dev_addr = reg;
+ u8 addr[3], data[2], *p;
int bus_addr, ret;
if (!i2c_mii_valid_phy_id(phy_id))
return 0xffff;
+ p = addr;
+ if (reg & MII_ADDR_C45) {
+ *p++ = 0x20 | ((reg >> 16) & 31);
+ *p++ = reg >> 8;
+ }
+ *p++ = reg;
+
bus_addr = i2c_mii_phy_addr(phy_id);
msgs[0].addr = bus_addr;
msgs[0].flags = 0;
- msgs[0].len = 1;
- msgs[0].buf = &dev_addr;
+ msgs[0].len = p - addr;
+ msgs[0].buf = addr;
msgs[1].addr = bus_addr;
msgs[1].flags = I2C_M_RD;
msgs[1].len = sizeof(data);
@@ -61,18 +68,23 @@ static int i2c_mii_write(struct mii_bus *bus, int phy_id, int reg, u16 val)
struct i2c_adapter *i2c = bus->priv;
struct i2c_msg msg;
int ret;
- u8 data[3];
+ u8 data[5], *p;
if (!i2c_mii_valid_phy_id(phy_id))
return 0;
- data[0] = reg;
- data[1] = val >> 8;
- data[2] = val;
+ p = data;
+ if (reg & MII_ADDR_C45) {
+ *p++ = (reg >> 16) & 31;
+ *p++ = reg >> 8;
+ }
+ *p++ = reg;
+ *p++ = val >> 8;
+ *p++ = val;
msg.addr = i2c_mii_phy_addr(phy_id);
msg.flags = 0;
- msg.len = 3;
+ msg.len = p - data;
msg.buf = data;
ret = i2c_transfer(i2c, &msg, 1);
--
2.20.1
next prev parent reply other threads:[~2019-12-09 14:07 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-09 14:02 [PATCH net-next 00/14] Add support for SFP+ copper modules Russell King - ARM Linux admin
2019-12-09 14:06 ` [PATCH net-next 01/14] net: sfp: remove incomplete 100BASE-FX and 100BASE-LX support Russell King
2019-12-09 14:06 ` [PATCH net-next 02/14] net: sfp: derive interface mode from ethtool link modes Russell King
2019-12-09 14:06 ` [PATCH net-next 03/14] net: sfp: add more extended compliance codes Russell King
2019-12-09 14:07 ` [PATCH net-next 04/14] net: sfp: add module start/stop upstream notifications Russell King
2019-12-09 14:07 ` [PATCH net-next 05/14] net: sfp: move phy_start()/phy_stop() to phylink Russell King
2019-12-09 14:07 ` Russell King [this message]
2019-12-09 14:07 ` [PATCH net-next 07/14] net: phylink: re-split __phylink_connect_phy() Russell King
2019-12-09 14:07 ` [PATCH net-next 08/14] net: phylink: support Clause 45 PHYs on SFP+ modules Russell King
2019-12-09 14:07 ` [PATCH net-next 09/14] net: phylink: split link_an_mode configured and current settings Russell King
2019-12-09 14:07 ` [PATCH net-next 10/14] net: phylink: split phylink_sfp_module_insert() Russell King
2019-12-09 14:07 ` [PATCH net-next 11/14] net: phylink: delay MAC configuration for copper SFP modules Russell King
2019-12-09 14:49 ` Russell King - ARM Linux admin
2019-12-09 14:07 ` [PATCH net-next 12/14] net: phylink: make Broadcom BCM84881 based SFPs work Russell King
2019-12-09 14:07 ` [PATCH net-next 13/14] net: phy: add Broadcom BCM84881 PHY driver Russell King
2019-12-09 14:07 ` [PATCH net-next 14/14] net: sfp: add support for Clause 45 PHYs Russell King
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=E1ieJgu-0004Om-63@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).