Support for Serial Management Interface (SMI)

krajaan
Posts: 16
Joined: Mon Mar 20, 2017 5:59 pm

Support for Serial Management Interface (SMI)

Postby krajaan » Thu Oct 31, 2019 2:39 pm

Hi,

The ethernet switch KSZ8863RLL(http://ww1.microchip.com/downloads/en/D ... 02335B.pdf) requires a non standard SMI interface to have full access to all control/status registers. This differs from the standard MDIO interface supported by ESP32 by 2 parameters: the Read/Write OP Code and PHY Address fields in the frame format, as shown in tables 3-8 and 3-9 in the switch datasheet on page 24.

I need to be able to set the OP Code to 00 and bit 4 of the PHY address to 0 or 1 (R/W). I have tried modifying the write function

Code: Select all

void esp_eth_smi_write(uint32_t reg_num, uint16_t value)
{
    uint32_t phy_num = emac_config.phy_addr;

    while (REG_GET_BIT(EMAC_GMIIADDR_REG, EMAC_MIIBUSY) == 1) {
    }

    REG_WRITE(EMAC_MIIDATA_REG, value);
    REG_WRITE(EMAC_GMIIADDR_REG, 0x3 | ((reg_num & 0x1f) << 6) | ((phy_num & 0x1f) << 11) | ((0x3) << 2));

    while (REG_GET_BIT(EMAC_GMIIADDR_REG, EMAC_MIIBUSY) == 1) {
    }
}
so that it meets these requirements, but I am unable to do so.
I am not sure what value I need to write into the

Code: Select all

EMAC_GMIIADDR_REG
register on line

Code: Select all

REG_WRITE(EMAC_GMIIADDR_REG, 0x3 | ((reg_num & 0x1f) << 6) | ((phy_num & 0x1f) << 11) | ((0x3) << 2));
I have tried playing around with the values 0x3 and ((0x3) << 2), which seem to decide whether the operation is read or write but I cannot change the OP Code to 00 in any way.

Can this be done somehow or is it not supported at all?

vjacobs
Posts: 10
Joined: Mon May 20, 2019 8:34 am

Re: Support for Serial Management Interface (SMI)

Postby vjacobs » Fri Nov 01, 2019 11:39 am

Hi @Krajaan,

We're using the same PHY in our project. The SMI messages are generated through the hardware MAC contained in the ESP32. As such, you can't alter the message structure, which you would need for this PHY. You will have to use I2C to communicate with the chip, this will allow you to access all the registers of the switch. You will need to strap two pins on the KSZ8863 in order for it to startup as a I2C slave (look in the docs for that). The same 2 pins that are normally reserved for MDIO access (18 & 23) have now to be used as SDA (18) and SCL (23). Make sure to comment out

Code: Select all

phy_rmii_smi_configure_pins(PIN_SMI_MDC, PIN_SMI_MDIO);
in the

Code: Select all

static void eth_gpio_config_rmii(void)
function.

Best
Vincent

krajaan
Posts: 16
Joined: Mon Mar 20, 2017 5:59 pm

Re: Support for Serial Management Interface (SMI)

Postby krajaan » Mon Nov 04, 2019 1:53 pm

Hi vjacobs,

Thank you for your reply.
Yes, after digging around in the esp32 technical reference manual, I arrived at the same conclusion. I switched over to I2C and now I have access to all the registers.

However, the reason I created this topic was that I am unable to obtain an IP with the esp32. It is related to another topic I made about it (viewtopic.php?f=13&t=12935&p=51169#p51169). Even after changing some extended register values, I'm still facing the same problem.

Do you have some tips or example configuration to share if you have a working solution?

Who is online

Users browsing this forum: No registered users and 389 guests