Skip to content

Commit

Permalink
drivers/net/ksz9477.c: SGMII register dump support
Browse files Browse the repository at this point in the history
  • Loading branch information
jpaali committed Nov 20, 2024
1 parent 44adec2 commit 0161c16
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/net/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
41 changes: 41 additions & 0 deletions drivers/net/ksz9477.c
Original file line number Diff line number Diff line change
Expand Up @@ -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],
&regval16, 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;
Expand Down Expand Up @@ -728,6 +765,10 @@ int ksz9477_init(ksz9477_port_t master_port)
&regval16, 1);
}

#ifdef CONFIG_NET_KSZ9477_DUMP_SGMII
sgmii_reg_dump();
#endif

/* Configure the static port-based VLANs */

#ifdef CONFIG_NET_KSZ9477_PORT_VLAN
Expand Down

0 comments on commit 0161c16

Please sign in to comment.