[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y2uqk9BwVjPcEtPP@lunn.ch>
Date: Wed, 9 Nov 2022 14:26:43 +0100
From: Andrew Lunn <andrew@...n.ch>
To: Jiawen Wu <jiawenwu@...stnetic.com>
Cc: 'Mengyuan Lou' <mengyuanlou@...-swift.com>, netdev@...r.kernel.org
Subject: Re: [PATCH net-next 1/5] net: txgbe: Identify PHY and SFP module
> > 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
Powered by blists - more mailing lists