From: "Jiawen Wu" <jiawenwu@trustnetic•com>
To: "'Andrew Lunn'" <andrew@lunn•ch>
Cc: "'Mengyuan Lou'" <mengyuanlou@net-swift•com>, <netdev@vger•kernel.org>
Subject: RE: [PATCH net-next 1/5] net: txgbe: Identify PHY and SFP module
Date: Mon, 14 Nov 2022 17:34:49 +0800 [thread overview]
Message-ID: <005c01d8f80c$574c16d0$05e44470$@trustnetic.com> (raw)
In-Reply-To: <Y2uqk9BwVjPcEtPP@lunn.ch>
On Wednesday, November 9, 2022 9:27 PM, Andrew Lunn wrote:
> > > So it looks like you have Linux driving the SFP, not firmware. In
> > > that case, please throw all this
> > code away.
> > > Implement a standard Linux I2C bus master driver, and make use of driver/net/phy/sfp*.[ch].
> > >
> > > Andrew
> > >
> >
> > I don't quite understand how to use driver/net/phy/sfp* files. In
> > txgbe driver, I2C infos are read from CAB registers, then SFP type identified.
> > Perhaps implement 'struct sfp_upstream_ops' ? And could you please
> > guide me an example driver of some docs?
>
> The SFP driver is currently device tree only, but it should be easy to add support for a platform
device and
> platform data. That driver needs to be told about a standard Linux i2c master device, and
optionally a
> collection of GPIO which connect to the SFP socket.
>
> So you need to implement a standard Linux I2C bus master. Which basically means being able to send
> and receive an I2C message. Take a look at for example drivers/net/ethernet/mellanox/mlxsw/i2c.c .
> This driver however does not use it with the SFP driver, since the Mellanox devices have firmware
> controlling the SFP. But it will give you the idea how you can embed an I2C bus driver inside
another
> driver.
>
> For the GPIOs to the SFP socket, TX Enable, LOS, MODDEF etc, you want a standard Linux GPIO
driver.
> For an example, look at drivers/net/dsa/vitesse-vsc73xx-core.c.
>
> https://github.com/lunn/linux/blob/v5.0.7-rap/drivers/platform/x86/zii-rap.c
> contains an example of registering a bit-bang MDIO controller. zii_rap_mdio_gpiod_table would
become
> a list of SFP GPIOs. zii_rap_mdio_init() registers a platform devices which instantiaces an MDIO
bus. You
> would register a platform device which instantiates an SFP device.
>
> Once you have an SFP devices you need to extend phylink with a platform data binding. So you can
pass it
> your SFP device.
>
> This should all be reasonably simple code.
>
> Andrew
>
When ethernet driver does a reset to the hardware, like 'txgbe_reset_hw', the I2C configuration will
be reset.
It needs to be reconfigured once. So how could I call the I2C function here? Can I treat the I2C
driver as a lib?
next prev parent reply other threads:[~2022-11-14 9:36 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-08 11:19 [PATCH net-next 0/5] net: WangXun ethernet drivers Mengyuan Lou
2022-11-08 11:19 ` [PATCH net-next 1/5] net: txgbe: Identify PHY and SFP module Mengyuan Lou
2022-11-08 20:52 ` Andrew Lunn
2022-11-09 6:32 ` Jiawen Wu
2022-11-09 13:26 ` Andrew Lunn
2022-11-14 9:34 ` Jiawen Wu [this message]
2022-11-14 13:25 ` Andrew Lunn
2022-11-29 8:20 ` Jiawen Wu
2022-11-14 15:34 ` Alexander Lobakin
2022-11-14 20:18 ` Andrew Lunn
2022-11-08 11:19 ` [PATCH net-next 2/5] net: txgbe: Initialize service task Mengyuan Lou
2022-11-08 23:55 ` Jakub Kicinski
2022-11-09 2:16 ` Jiawen Wu
2022-11-09 2:36 ` Andrew Lunn
2022-11-14 15:39 ` Alexander Lobakin
2022-11-08 11:19 ` [PATCH net-next 3/5] net: txgbe: Support to setup link Mengyuan Lou
2022-11-08 21:03 ` Andrew Lunn
2022-11-14 15:48 ` Alexander Lobakin
2022-11-14 20:20 ` Andrew Lunn
2022-11-08 11:19 ` [PATCH net-next 4/5] net: ngbe: Initialize phy information Mengyuan Lou
2022-11-08 21:10 ` Andrew Lunn
2022-11-11 3:13 ` mengyuanlou
2022-11-11 3:28 ` Andrew Lunn
2022-11-14 16:16 ` Alexander Lobakin
2022-11-08 11:19 ` [PATCH net-next 5/5] net: ngbe: Initialize service task Mengyuan Lou
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='005c01d8f80c$574c16d0$05e44470$@trustnetic.com' \
--to=jiawenwu@trustnetic$(echo .)com \
--cc=andrew@lunn$(echo .)ch \
--cc=mengyuanlou@net-swift$(echo .)com \
--cc=netdev@vger$(echo .)kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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