From f7a1e9ef8e1dc22ebded786507b872a45e3fb05d Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 30 Jul 2025 15:59:38 +0100 Subject: [PATCH] [dwmac] Show core version in debug messages Read and display the core version immediately after mapping the MMIO registers, to provide a basic sanity check that the registers have been correctly mapped and the core is not held in reset. Signed-off-by: Michael Brown --- src/drivers/net/dwmac.c | 7 +++++++ src/drivers/net/dwmac.h | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/src/drivers/net/dwmac.c b/src/drivers/net/dwmac.c index 67656e7f1..f581a48a4 100644 --- a/src/drivers/net/dwmac.c +++ b/src/drivers/net/dwmac.c @@ -552,6 +552,7 @@ static int dwmac_probe ( struct dt_device *dt, unsigned int offset ) { struct net_device *netdev; struct dwmac *dwmac; union dwmac_mac mac; + uint32_t version; int rc; /* Allocate and initialise net device */ @@ -580,6 +581,12 @@ static int dwmac_probe ( struct dt_device *dt, unsigned int offset ) { rc = -ENODEV; goto err_ioremap; } + version = readl ( dwmac->regs + DWMAC_VER ); + DBGC ( dwmac, "DWMAC %s version %x.%x (user %x.%x)\n", dwmac->name, + DWMAC_VER_CORE_MAJOR ( version ), + DWMAC_VER_CORE_MINOR ( version ), + DWMAC_VER_USER_MAJOR ( version ), + DWMAC_VER_USER_MINOR ( version ) ); /* Fetch devicetree MAC address */ if ( ( rc = fdt_mac ( &sysfdt, offset, netdev ) ) != 0 ) { diff --git a/src/drivers/net/dwmac.h b/src/drivers/net/dwmac.h index d36bfd4da..4de62b0ce 100644 --- a/src/drivers/net/dwmac.h +++ b/src/drivers/net/dwmac.h @@ -38,6 +38,14 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); /** Version register */ #define DWMAC_VER DWMAC_MAC_REG ( 8 ) +#define DWMAC_VER_USER_MAJOR( x ) \ + ( ( (x) >> 12 ) & 0xf ) /**< User major version */ +#define DWMAC_VER_USER_MINOR( x ) \ + ( ( (x) >> 8 ) & 0xf ) /**< User minor version */ +#define DWMAC_VER_CORE_MAJOR( x ) \ + ( ( (x) >> 4 ) & 0xf ) /**< Core major version */ +#define DWMAC_VER_CORE_MINOR( x ) \ + ( ( (x) >> 0 ) & 0xf ) /**< Core minor version */ /** Debug register */ #define DWMAC_DEBUG DWMAC_MAC_REG ( 9 ) -- 2.47.2