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 79 forks source link

KSZ9477 port 7 (SGMII) not up if ethernet not pluged in another port #58

Open jeghub opened 3 years ago

jeghub commented 3 years ago

Hi,

Sorry my question is not related to a code issue, but as documentation is also supplied in git and I've been through it all I hope this is still relevant as an issue.

In our custom board, and on the EVK, if we plug an SFP (fiber) then the ports remain down and communication don't work. Plug an ethernet port and then all port are up and communication is working well. Is there a way to use the SGMII without any ethernet port ?

triha2work commented 3 years ago

There is a driver parameter called sgmii which can dictates how the SGMII port is setup. Setting it to 0 like sgmii=0 means the SGMII port is connected directly. However it may not work with the evaluation board as it requires a module for communication. Setting it to 1 means a fiber module is being used. The driver variable sgmii_mode will be set to 1 initially. The driver then tries to detect whether a copper module is inserted or not. If so that variable is set to 2. Now it seems the code in port_sgmii_detect does not detect the fiber module is inserted. Or maybe the other part of the driver cannot detect the port is connected. You may want to check the code in port_sgmii_detect to see whether sgmii_mode is set to 1 or 2. The port_sgmii_setup function will setup the SGMII port depending on those settings. At one time the fiber module was tested but there may be incorrect code in the current driver.

jeghub commented 3 years ago

Hi,

Thanks to your you informations it now works. I now set correctly SGMII to '1' at boot (maybe that work without it but we will always use 1000-fx sfp so I set it) and I've add one line to mask the SR_MII_AUTO_NEG_COMPLETE_INTR bit. When fiber=1 there was condition with !data and this is never true because this bit was alwaysset.


--- a/drivers/net/ethernet/micrel/ksz_sw_9897.c
+++ b/drivers/net/ethernet/micrel/ksz_sw_9897.c
@@ -7808,6 +7808,9 @@ static int sgmii_port_get_speed(struct ksz_sw *sw, uint p, bool force_link)
    port_sgmii_r(sw, p, SR_MII, MMD_SR_MII_STATUS, &status, 1);
    port_sgmii_r(sw, p, SR_MII, MMD_SR_MII_AUTO_NEG_STATUS, &data, 1);

+    /* ignore Auto-Negotiation Complete Interrupt first  bit*/
+    data &= ~SR_MII_AUTO_NEG_COMPLETE_INTR;
+    
    /* Running in fiber mode. */
    if (info->fiber && (status & PORT_LINK_STATUS) && !data) {
        data = SR_MII_STAT_LINK_UP |