]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[dwmac] Show core version in debug messages coverity_scan master 1505/head
authorMichael Brown <mcb30@ipxe.org>
Wed, 30 Jul 2025 14:59:38 +0000 (15:59 +0100)
committerMichael Brown <mcb30@ipxe.org>
Wed, 30 Jul 2025 14:59:38 +0000 (15:59 +0100)
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 <mcb30@ipxe.org>
src/drivers/net/dwmac.c
src/drivers/net/dwmac.h

index 67656e7f109b8648fc1196ba8723297e754c8813..f581a48a47eef3e163c4db4bbc373894396914a8 100644 (file)
@@ -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 ) {
index d36bfd4dab3317c59944f6325222b2ab1adcb98e..4de62b0ce86dda0451766e7c4ad3c6659dfa742b 100644 (file)
@@ -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 )