diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 6cc7e5fcea592..7c4ba8d36ddf2 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -505,6 +505,11 @@ config NET_KSZ9477_PORT_SNIFF All the packets received on port A and/or transmitted on port B can be mirrored on the sniffer port. +config NET_KSZ9477_DUMP_SGMII + bool "Enable SGMII register dump on init" + depends on NET_KSZ9477 + default n + menuconfig NET_LAN9250 bool "Microchip LAN9250 support" default n diff --git a/drivers/net/ksz9477.c b/drivers/net/ksz9477.c index 118daaa7595d6..4edf2e416c0a5 100644 --- a/drivers/net/ksz9477.c +++ b/drivers/net/ksz9477.c @@ -341,6 +341,43 @@ static int ksz9477_mmd_write_indirect(ksz9477_port_t port, uint8_t dev, return ret; } +#ifdef CONFIG_NET_KSZ9477_DUMP_SGMII +static void sgmii_reg_dump() +{ + int ret = OK; + int i = 0; + uint16_t regval16; + uint32_t regs[11] = {KSZ9477_SGMII_CONTROL, + KSZ9477_SGMII_STATUS, + KSZ9477_SGMII_ID1, + KSZ9477_SGMII_ID2, + KSZ9477_SGMII_AUTONEG_ADVERTISE, + KSZ9477_SGMII_LINK_PARTNER_ABILITY, + KSZ9477_SGMII_AUTONEG_EXPANSION, + KSZ9477_SGMII_DIGITAL_CONTROL, + KSZ9477_SGMII_AUTONEG_CONTROL, + KSZ9477_SGMII_AUTONEG_STATUS, + 0 + }; + + + + while (regs[i] != 0) + { + ret = ksz9477_sgmii_read_indirect(regs[i], + ®val16, 1); + if (ret != OK) + { + _alert("Failed to fetch SGMII reg value.\n"); + break; + } + + _alert("%i: 0x%04x\n", i, regval16); + i++; + } +} +#endif + static int ksz9477_custom_error_fixes(ksz9477_port_t port) { int ret = OK; @@ -728,6 +765,10 @@ int ksz9477_init(ksz9477_port_t master_port) ®val16, 1); } +#ifdef CONFIG_NET_KSZ9477_DUMP_SGMII + sgmii_reg_dump(); +#endif + /* Configure the static port-based VLANs */ #ifdef CONFIG_NET_KSZ9477_PORT_VLAN