Microchip-Ethernet / EVB-KSZ9477

Repository for using Microchip EVB-KSZ9477 board. Product Supported: KSZ9477, KSZ9567, KSZ9897, KSZ9896, KSZ8567, KSZ8565, KSZ9893, KSZ9563, KSZ8563, LAN9646, Phys(KSZ9031/9131, LAN8770
76 stars 78 forks source link

KSZ9897 and iMX8 via I2C #79

Open tvothang opened 2 years ago

tvothang commented 2 years ago

Hi,

We are designing a custom board using imx8mn and ksz9897, connected via I2C.

We are presently using two EVK's, the i.MX8MNano-LPDDR4-EVK and the EVB-KSZ9897. They are I2C connected via an I2c level translator PCA9396.

Our linux kernel is imx_5.4.70_2.3.0 and we have integrated the KSZ9897 driver for linux-5.4 (commit 147cfab54313d214ddecfe0bbbb4ffbeb434f791).

At boot time the FEC driver start before the KSZ9897 driver. The FEC driver fail to locate the virtual PHY that represents the switch: sw.0:00. [ 1.280659] libphy: fec_enet_mii_bus: probed [ 1.284953] libphy: PHY sw.0:00 not found

The KSZ driver start and detect the switch and configure it as per configuration in bootargs. [ 2.525206] ksz9897 2-005f: chip id 0x00989700 [ 2.573593] libphy: Switch MII bus: probed [ 2.582495] - [ 2.584081] 98 97 [ 2.584081] avb=0 rr=0 giga=1 [ 2.584081] compatible: ksz9897 [ 2.584081] ports: 7f [ 2.584081] 0: 1:3:1 m=0007 v=033 00000000 [ 2.584081] 1: 4:3:4 m=0038 v=034 00000000 [ 2.584081] features: 2a0010 m:1 a:0 s:0

When Linux is started the virtual MDIO bus is populated with PHY's representing the switch and the ports. root@imx8mn-vega:/sys/class/mdio_bus/sw.0# ls consumers device power subsystem suppliers sw.0:00 sw.0:01 sw.0:02 sw.0:03 sw.0:04 sw.0:05 sw.0:06 sw.0:07 uevent

However the ethernet interface is not populated with the "sw". root@imx8mn-vega:/sys/class/net/eth0# ls addr_assign_type broadcast carrier_down_count dev_id dormant gro_flush_timeout iflink name_assign_type phydev phys_switch_id queues subsystem type addr_len carrier carrier_up_count dev_port duplex ifalias link_mode netdev_group phys_port_id power speed suppliers uevent address carrier_changes consumers device flags ifindex mtu operstate phys_port_name proto_down statistics tx_queue_len root@imx8mn-vega:/sys/class/net/eth0#

Question: Should the FEC driver start probing after the KSZ driver has done its probing?

If so, how can I change the probing sequence? 
I have modified the "drivers" Makefile to set "i2c" before "spi" and "net".
    obj-$(CONFIG_MTD)       += mtd/
    obj-y               += i2c/ i3c/ media/
    obj-$(CONFIG_SPI)       += spi/
    obj-$(CONFIG_SPMI)      += spmi/
    obj-$(CONFIG_HSI)       += hsi/
    obj-$(CONFIG_SLIMBUS)       += slimbus/
    obj-y               += net/
    obj-$(CONFIG_ATM)       += atm/ 
I have also modified the "net" Makefile to set "micrel" before "freescale".

Have I missed anything?

Uboot_BootTime_regsbin_ls.txt

Many thanks for your helps, Thanh

manolitox commented 2 years ago

Hi

I do have the same problem with kernel 5.10.72 and KSZ version 1.2.6. Everything is loaded properly, the ethernet interface works fine, but libphy does not detect sw.0.00 and no sw directory is in /sys/class/net/eth

[ 1.380708] libphy: Fixed MDIO Bus: probed [ 2.355908] libphy: fec_enet_mii_bus: probed [ 2.369238] libphy: PHY sw.0:00 not found [ 2.598212] libphy: PHY sw.0:00 not found [ 6.816025] libphy: Switch MII bus: probed

Any suggestion?

Thanks in advance, M

triha2work commented 2 years ago

In some kernels the driver probing order is no longer as expected. The only fix is to embed the switch driver code in the MAC driver. This was already supported by using i2c-ksz9897.c rather than spi-ksz9897.c. This configuration can be done through kernel configuration.

tvothang commented 2 years ago

Hi @manolitox

We stopped trying to integrate the KSZ9897 driver to Linux 5.4.

Instead, we are now using the KSZ DSA driver provided in mainline Linux 5.4. It does support the KSZ9897 even though it is labelled KSZ9477.

Please refer to the following documentation for the KSZ DSA driver. http://ww1.microchip.com/downloads/en/Appnotes/AN3761-KSZ-DSA-Driver-Utilization-00003761A.pdf

Hope that helps, Thanh

manolitox commented 2 years ago

Hi

Thank you very much for your response. The KSZ DSA driver does not provide all the features that are in this driver, it works well for configuring the interfaces or making a bridge, etc., but it has no hardware support for HSR, for example.

Configuring this driver as a module the sw directory in /sys is created in kernel 5.4; but it does not work fine for FEC driver.

Best regards, M