linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Jiawen Wu" <jiawenwu@trustnetic.com>
To: "'Andrew Lunn'" <andrew@lunn.ch>
Cc: <netdev@vger.kernel.org>, <linux@armlinux.org.uk>,
	<linux-i2c@vger.kernel.org>, <linux-gpio@vger.kernel.org>,
	<olteanv@gmail.com>, <mengyuanlou@net-swift.com>,
	"'Jarkko Nikula'" <jarkko.nikula@linux.intel.com>
Subject: RE: [PATCH net-next v3 2/8] i2c: designware: Add driver support for Wangxun 10Gb NIC
Date: Fri, 21 Apr 2023 10:20:17 +0800	[thread overview]
Message-ID: <03f501d973f7$d0c889a0$72599ce0$@trustnetic.com> (raw)
In-Reply-To: <72703dc2-0ee1-41b2-9618-2a3185869cbf@lunn.ch>

On Thursday, April 20, 2023 9:23 PM, Andrew Lunn wrote:
> On Thu, Apr 20, 2023 at 06:29:11PM +0800, Jiawen Wu wrote:
> > On Thursday, April 20, 2023 4:58 AM, Andrew Lunn wrote:
> > > On Wed, Apr 19, 2023 at 04:27:33PM +0800, Jiawen Wu wrote:
> > > > Wangxun 10Gb ethernet chip is connected to Designware I2C, to communicate
> > > > with SFP.
> > > >
> > > > Add platform data to pass IOMEM base address, board flag and other
> > > > parameters, since resource address was mapped on ethernet driver.
> > > >
> > > > The exists IP limitations are dealt as workarounds:
> > > > - IP does not support interrupt mode, it works on polling mode.
> > > > - I2C cannot read continuously, only one byte can at a time.
> > >
> > > Are you really sure about that?
> > >
> > > It is a major limitation for SFP devices. It means you cannot access
> > > the diagnostics, since you need to perform an atomic 2 byte read.
> > >
> > > Or maybe i'm understanding you wrong.
> > >
> > >    Andrew
> > >
> >
> > Maybe I'm a little confused about this. Every time I read a byte info, I have to
> > write a 'read command'. It can normally get the information for SFP devices.
> > But I'm not sure if this is regular I2C behavior.
> 
> I don't know this hardware, so i cannot say what a 'read command'
> actually does. Can you put a bus pirate or similar sort of device on
> the bus and look at the actual I2C signals. Is it performing one I2C
> transaction per byte? If so, that is not good.
> 
> The diagnostic values, things like temperature sensor, voltage sensor,
> received signal power are all 16 bits. You cannot read them using two
> time one byte reads. Say the first read sees a 16bit value of 0x00FF,
> but only reads the first byte. The second read sees a 16bit value of
> 0x0100 but only reads the second byte. You end up with 0x0000. When
> you do a multi byte read, the SFP should do an atomic read of the
> sensor, so you would see either 0x00FF, or 0x0100.
> 
> If your hardware can only do single byte reads, please make sure the
> I2C framework knows this. The SFP driver should then refuse to access
> the diagnostic parts of the SFP, because your I2C bus master hardware
> is too broken. The rest of the SFP should still work.
> 
> 	Andrew.
> 

You may have misunderstood. If you want to read a 16-bit message, the
size of 'i2c_msg.len' is set to 2 in the array that 'flags = I2C_M_RD'.

For example in sfp_i2c_read(), block_size limits the message length of every
time call i2c_transfer() to read, usually it is 16. The one-byte read limit I
mentioned means that during the 16-byte read, I2C device needs to write a
read command and then read the message 16 times to fill the 16-byte buffer,
instead of reading 16 bytes at once after stop command writes.

Before I thought this behavior might be strange, so I mentioned in the commit.


  reply	other threads:[~2023-04-21  2:21 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-19  8:27 [PATCH net-next v3 0/8] TXGBE PHYLINK support Jiawen Wu
2023-04-19  8:27 ` [PATCH net-next v3 1/8] net: txgbe: Add software nodes to support phylink Jiawen Wu
2023-04-19 20:53   ` Andrew Lunn
2023-04-19  8:27 ` [PATCH net-next v3 2/8] i2c: designware: Add driver support for Wangxun 10Gb NIC Jiawen Wu
2023-04-19 14:36   ` Jarkko Nikula
2023-04-20 10:49     ` Jiawen Wu
2023-04-19 20:58   ` Andrew Lunn
2023-04-20 10:29     ` Jiawen Wu
2023-04-20 13:22       ` Andrew Lunn
2023-04-21  2:20         ` Jiawen Wu [this message]
2023-04-21 12:15           ` Andrew Lunn
2023-04-21  6:52       ` Jarkko Nikula
2023-04-21 12:22         ` Andrew Lunn
2023-04-21 13:00           ` Jarkko Nikula
2023-04-19  8:27 ` [PATCH net-next v3 3/8] net: txgbe: Register I2C platform device Jiawen Wu
2023-04-19  8:27 ` [PATCH net-next v3 4/8] net: txgbe: Add SFP module identify Jiawen Wu
2023-04-19 13:55   ` Vladimir Oltean
2023-04-19  8:27 ` [PATCH net-next v3 5/8] net: txgbe: Support GPIO to SFP socket Jiawen Wu
2023-04-19  8:27 ` [PATCH net-next v3 6/8] net: pcs: Add 10GBASE-R mode for Synopsys Designware XPCS Jiawen Wu
2023-04-19 13:19   ` Vladimir Oltean
2023-04-20  1:56     ` Jiawen Wu
2023-04-20  8:03       ` Vladimir Oltean
2023-04-20  8:38         ` Jiawen Wu
2023-04-20  8:52           ` Vladimir Oltean
2023-04-20  9:32             ` Jiawen Wu
2023-04-19  8:27 ` [PATCH net-next v3 7/8] net: txgbe: Implement phylink pcs Jiawen Wu
2023-04-19  8:27 ` [PATCH net-next v3 8/8] net: txgbe: Support phylink MAC layer Jiawen Wu
2023-04-19 13:39 ` [PATCH net-next v3 0/8] TXGBE PHYLINK support Vladimir Oltean

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='03f501d973f7$d0c889a0$72599ce0$@trustnetic.com' \
    --to=jiawenwu@trustnetic.com \
    --cc=andrew@lunn.ch \
    --cc=jarkko.nikula@linux.intel.com \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=mengyuanlou@net-swift.com \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.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;
as well as URLs for NNTP newsgroup(s).