mbox series

[net-next,v2,0/6] TXGBE PHYLINK support

Message ID 20230411092725.104992-1-jiawenwu@trustnetic.com
Headers show
Series TXGBE PHYLINK support | expand

Message

Jiawen Wu April 11, 2023, 9:27 a.m. UTC
Implement I2C, SFP, GPIO and PHYLINK to setup TXGBE link and switch link
rate based on optical module information.

v1 -> v2:
- add comments to indicate GPIO lines
- add I2C write operation support
- modify GPIO direction functions
- rename functions related to PHY interface
- add condition on interface changing to re-config PCS
- add to set advertise and fix to get status for 1000BASE-X mode
- other redundant codes remove

Jiawen Wu (6):
  net: txgbe: Add software nodes to support phylink
  net: txgbe: Implement I2C bus master driver
  net: txgbe: Add SFP module identify
  net: txgbe: Support GPIO to SFP socket
  net: txgbe: Implement phylink pcs
  net: txgbe: Support phylink MAC layer

 drivers/net/ethernet/wangxun/Kconfig          |   5 +
 drivers/net/ethernet/wangxun/libwx/wx_lib.c   |   3 +-
 drivers/net/ethernet/wangxun/libwx/wx_type.h  |   3 +
 drivers/net/ethernet/wangxun/txgbe/Makefile   |   1 +
 .../ethernet/wangxun/txgbe/txgbe_ethtool.c    |  34 +
 .../net/ethernet/wangxun/txgbe/txgbe_main.c   |  58 +-
 .../net/ethernet/wangxun/txgbe/txgbe_phy.c    | 980 ++++++++++++++++++
 .../net/ethernet/wangxun/txgbe/txgbe_phy.h    |  10 +
 .../net/ethernet/wangxun/txgbe/txgbe_type.h   | 157 +++
 9 files changed, 1219 insertions(+), 32 deletions(-)
 create mode 100644 drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c
 create mode 100644 drivers/net/ethernet/wangxun/txgbe/txgbe_phy.h

Comments

Jarkko Nikula April 11, 2023, 10:08 a.m. UTC | #1
Hi

On 4/11/23 12:32, Jiawen Wu wrote:
> +Cc: Jarkko Nikula <jarkko.nikula@linux.intel.com>
> 
>> -----Original Message-----
>> From: Jiawen Wu <jiawenwu@trustnetic.com>
>> Sent: Tuesday, April 11, 2023 5:27 PM
>> To: netdev@vger.kernel.org; linux@armlinux.org.uk
>> Cc: linux-i2c@vger.kernel.org; linux-gpio@vger.kernel.org;
>> mengyuanlou@net-swift.com; Jiawen Wu <jiawenwu@trustnetic.com>
>> Subject: [PATCH net-next v2 2/6] net: txgbe: Implement I2C bus master
>> driver
>>
>> Implement I2C bus driver to send and receive I2C messages.
>>
>> This I2C license the IP of Synopsys Designware, but without interrupt
>> support on the hardware design. It seems that polling mode needs to be
>> added in Synopsys Designware I2C driver. But currently it can only be
>> driven by this I2C bus master driver.
>>
>> Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
>> ---
>>   drivers/net/ethernet/wangxun/Kconfig          |   1 +
>>   .../net/ethernet/wangxun/txgbe/txgbe_phy.c    | 153
>> ++++++++++++++++++
>>   .../net/ethernet/wangxun/txgbe/txgbe_type.h   |  23 +++
>>   3 files changed, 177 insertions(+)
>>
Looks like your use case has similarities with the commit 17631e8ca2d3 
("i2c: designware: Add driver support for AMD NAVI GPU").
Andrew Lunn April 11, 2023, 12:52 p.m. UTC | #2
On Tue, Apr 11, 2023 at 05:27:22PM +0800, Jiawen Wu wrote:
> Register SFP platform device to get modules information.
> 
> Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew
Wolfram Sang April 13, 2023, 4:28 p.m. UTC | #3
> > > Implement I2C bus driver to send and receive I2C messages.
> > > 
> > > This I2C license the IP of Synopsys Designware, but without interrupt
> > > support on the hardware design. It seems that polling mode needs to be
> > > added in Synopsys Designware I2C driver. But currently it can only be
> > > driven by this I2C bus master driver.
> > > 
> > > Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
> > > ---
> > >   drivers/net/ethernet/wangxun/Kconfig          |   1 +
> > >   .../net/ethernet/wangxun/txgbe/txgbe_phy.c    | 153
> > > ++++++++++++++++++
> > >   .../net/ethernet/wangxun/txgbe/txgbe_type.h   |  23 +++
> > >   3 files changed, 177 insertions(+)
> > > 
> Looks like your use case has similarities with the commit 17631e8ca2d3
> ("i2c: designware: Add driver support for AMD NAVI GPU").

Yes, can you please check if you can't use the current i2c designware
driver?
Jiawen Wu April 14, 2023, 11:04 a.m. UTC | #4
On Friday, April 14, 2023 12:29 AM, Wolfram Sang wrote:
> > > > Implement I2C bus driver to send and receive I2C messages.
> > > >
> > > > This I2C license the IP of Synopsys Designware, but without interrupt
> > > > support on the hardware design. It seems that polling mode needs to be
> > > > added in Synopsys Designware I2C driver. But currently it can only be
> > > > driven by this I2C bus master driver.
> > > >
> > > > Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
> > > > ---
> > > >   drivers/net/ethernet/wangxun/Kconfig          |   1 +
> > > >   .../net/ethernet/wangxun/txgbe/txgbe_phy.c    | 153
> > > > ++++++++++++++++++
> > > >   .../net/ethernet/wangxun/txgbe/txgbe_type.h   |  23 +++
> > > >   3 files changed, 177 insertions(+)
> > > >
> > Looks like your use case has similarities with the commit 17631e8ca2d3
> > ("i2c: designware: Add driver support for AMD NAVI GPU").
> 
> Yes, can you please check if you can't use the current i2c designware
> driver?

Hi Jarkko & Wolfram,

I read the i2c designware driver code, and found that 'dev->ss_hcnt' can
only be obtained by i2c_dw_acpi_configure() or calculated by clock rate.

I don't quite understand how to get the clock rate. I tried to add a software
node of clock with property ("clock-frequency", 100000) and referenced by
I2C node. But it didn't work.

Can I deliver 'dev->ss_hcnt' via platform data? Or how should I fill in the
software node?
Andrew Lunn April 15, 2023, 3:11 p.m. UTC | #5
> I don't quite understand how to get the clock rate. I tried to add a software
> node of clock with property ("clock-frequency", 100000) and referenced by
> I2C node. But it didn't work.

I've not spent the time to fully understand the code, so i could be
very wrong....
Jiawen Wu April 17, 2023, 1:46 a.m. UTC | #6
On Saturday, April 15, 2023 11:11 PM, Andrew Lunn wrote:
> > I don't quite understand how to get the clock rate. I tried to add a software
> > node of clock with property ("clock-frequency", 100000) and referenced by
> > I2C node. But it didn't work.
> 
> I've not spent the time to fully understand the code, so i could be
> very wrong....
> 
> From what you said above, you clock is fixed? So maybe you can do
> something like:
> 
> mfld_get_clk_rate_khz()
> 
> https://elixir.bootlin.com/linux/latest/source/drivers/i2c/busses/i2c-designware-pcidrv.c#L97
> 
> How are you instantiating the driver? Can you add to
> i2_designware_pci_ids[]?
> 
>     Andrew
> 

There is no PCI ID for our I2C device, so I register the platform I2C device.
Jiawen Wu April 17, 2023, 3:17 a.m. UTC | #7
On Friday, April 14, 2023 7:05 PM, Jiawen Wu wrote:
> On Friday, April 14, 2023 12:29 AM, Wolfram Sang wrote:
> > > > > Implement I2C bus driver to send and receive I2C messages.
> > > > >
> > > > > This I2C license the IP of Synopsys Designware, but without interrupt
> > > > > support on the hardware design. It seems that polling mode needs to be
> > > > > added in Synopsys Designware I2C driver. But currently it can only be
> > > > > driven by this I2C bus master driver.
> > > > >
> > > > > Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
> > > > > ---
> > > > >   drivers/net/ethernet/wangxun/Kconfig          |   1 +
> > > > >   .../net/ethernet/wangxun/txgbe/txgbe_phy.c    | 153
> > > > > ++++++++++++++++++
> > > > >   .../net/ethernet/wangxun/txgbe/txgbe_type.h   |  23 +++
> > > > >   3 files changed, 177 insertions(+)
> > > > >
> > > Looks like your use case has similarities with the commit 17631e8ca2d3
> > > ("i2c: designware: Add driver support for AMD NAVI GPU").
> >
> > Yes, can you please check if you can't use the current i2c designware
> > driver?
> 
> Hi Jarkko & Wolfram,
> 
> I read the i2c designware driver code, and found that 'dev->ss_hcnt' can
> only be obtained by i2c_dw_acpi_configure() or calculated by clock rate.
> 
> I don't quite understand how to get the clock rate. I tried to add a software
> node of clock with property ("clock-frequency", 100000) and referenced by
> I2C node. But it didn't work.
> 
> Can I deliver 'dev->ss_hcnt' via platform data? Or how should I fill in the
> software node?
> 

The above question is in the case of platform driver.

Moreover, why 'dev->fs_hcnt' and 'dev->fs_lcont' must be set when I use the
standard mode? Should it be set only if I2C_MAX_FAST_MODE_* ?