From: "Marek Behún" <kabel@kernel.org>
To: Andrew Lunn <andrew@lunn.ch>
Cc: netdev@vger.kernel.org, Russell King <rmk+kernel@armlinux.org.uk>,
Jakub Kicinski <kuba@kernel.org>,
davem@davemloft.net, pali@kernel.org
Subject: Re: [PATCH net-next v4 1/4] net: phy: mdio-i2c: support I2C MDIO protocol for RollBall SFP modules
Date: Tue, 12 Jan 2021 21:53:13 +0100 [thread overview]
Message-ID: <20210112215313.2b2f5523@kernel.org> (raw)
In-Reply-To: <X/4J8cB1ITZmesN5@lunn.ch>
On Tue, 12 Jan 2021 21:43:29 +0100
Andrew Lunn <andrew@lunn.ch> wrote:
> > +/* RollBall SFPs do not access internal PHY via I2C address 0x56, but
> > + * instead via address 0x51, when SFP page is set to 0x03 and password to
> > + * 0xffffffff.
> > + * Since current SFP code does not modify SFP_PAGE, we set it to 0x03 only at
> > + * bus creation time, and expect it to remain set to 0x03 throughout the
> > + * lifetime of the module plugged into the system. If the SFP code starts
> > + * modifying SFP_PAGE in the future, this code will need to change.
>
> ...
>
> > +/* In order to not interfere with other SFP code (which possibly may manipulate
> > + * SFP_PAGE), for every transfer we do this:
> > + * 1. lock the bus
> > + * 2. save content of SFP_PAGE
> > + * 3. set SFP_PAGE to 3
> > + * 4. do the transfer
> > + * 5. restore original SFP_PAGE
> > + * 6. unlock the bus
>
> These two comments seem to contradict each other?
I forgot about the first comment. I will rewrite it and send again.
>
> > +static int i2c_rollball_mii_poll(struct mii_bus *bus, int bus_addr, u8 *buf,
> > + size_t len)
> > +{
> > + struct i2c_adapter *i2c = bus->priv;
> > + struct i2c_msg msgs[2];
> > + u8 cmd_addr, tmp, *res;
> > + int i, ret;
> > +
> > + cmd_addr = ROLLBALL_CMD_ADDR;
> > +
> > + res = buf ? buf : &tmp;
> > + len = buf ? len : 1;
> > +
> > + msgs[0].addr = bus_addr;
> > + msgs[0].flags = 0;
> > + msgs[0].len = 1;
> > + msgs[0].buf = &cmd_addr;
> > +
> > + msgs[1].addr = bus_addr;
> > + msgs[1].flags = I2C_M_RD;
> > + msgs[1].len = len;
> > + msgs[1].buf = res;
> > +
> > + /* By experiment it takes up to 70 ms to access a register for these
> > + * SFPs. Sleep 20ms between iteratios and try 10 times.
> > + */
>
> iterations
THX.
>
> > +static int i2c_mii_read_rollball(struct mii_bus *bus, int phy_id, int reg)
> > +{
> > + u8 buf[4], res[6];
> > + int bus_addr, ret;
> > + u16 val;
> > +
> > + if (!(reg & MII_ADDR_C45))
> > + return -EOPNOTSUPP;
> > +
> > + bus_addr = i2c_mii_phy_addr(phy_id);
> > + if (bus_addr != ROLLBALL_PHY_I2C_ADDR)
> > + return 0xffff;
> > +
> > + buf[0] = ROLLBALL_DATA_ADDR;
> > + buf[1] = (reg >> 16) & 0x1f;
> > + buf[2] = (reg >> 8) & 0xff;
> > + buf[3] = reg & 0xff;
>
> This looks odd. There are only 32 registers for C22 transactions, so
> it fits in one byte. You can set buf[1] and buf[2] to zero.
C22 is not supported by this protocol. A few line above there is
if (!(reg & MII_ADDR_C45))
return -EOPNOTSUPP;
> C45 transactions allow for 65536 registers, and has the devtype field,
> so would need 3 bytes. Which suggests that C45 might actually be
> supported? At least by the protocol, if not the device.
> > + dev_dbg(&bus->dev, "read reg %02x:%04x = %04x\n", (reg >> 16) & 0x1f,
> > + reg & 0xffff, val);
>
> There is a tracepoint that allows access to this information, so you
> can probably remove this.
>
> Andrew
OK then, I will remove this.
Thanks, Andrew.
next prev parent reply other threads:[~2021-01-12 21:41 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-11 5:00 [PATCH net-next v4 0/4] Support for RollBall 10G copper SFP modules Marek Behún
2021-01-11 5:00 ` [PATCH net-next v4 1/4] net: phy: mdio-i2c: support I2C MDIO protocol for RollBall " Marek Behún
2021-01-12 8:42 ` Heiner Kallweit
2021-01-12 14:02 ` Andrew Lunn
2021-01-12 14:40 ` Heiner Kallweit
2021-01-12 17:49 ` Marek Behún
2021-01-12 19:22 ` Russell King - ARM Linux admin
2021-01-18 12:13 ` Pali Rohár
2021-01-18 15:45 ` Russell King - ARM Linux admin
2021-01-12 20:20 ` Andrew Lunn
2021-01-12 20:43 ` Andrew Lunn
2021-01-12 20:53 ` Marek Behún [this message]
2021-01-12 20:55 ` Andrew Lunn
2021-01-12 20:54 ` Andrew Lunn
2021-01-12 21:01 ` Marek Behún
2021-01-13 10:51 ` Pali Rohár
2021-01-12 21:22 ` Russell King - ARM Linux admin
2021-01-13 11:22 ` Pali Rohár
2021-01-13 13:56 ` Andrew Lunn
2021-01-13 13:58 ` Pali Rohár
2021-01-13 16:14 ` Russell King - ARM Linux admin
2021-01-11 5:00 ` [PATCH net-next v4 2/4] net: phylink: allow attaching phy for SFP modules on 802.3z mode Marek Behún
2021-01-13 10:38 ` Pali Rohár
2021-01-11 5:00 ` [PATCH net-next v4 3/4] net: sfp: create/destroy I2C mdiobus before PHY probe/after PHY release Marek Behún
2021-01-13 10:41 ` Pali Rohár
2021-01-11 5:00 ` [PATCH net-next v4 4/4] net: sfp: add support for multigig RollBall transceivers Marek Behún
2021-01-13 10:49 ` Pali Rohár
2021-01-13 11:08 ` Russell King - ARM Linux admin
2021-01-13 11:26 ` Pali Rohár
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=20210112215313.2b2f5523@kernel.org \
--to=kabel@kernel.org \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pali@kernel.org \
--cc=rmk+kernel@armlinux.org.uk \
/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).