]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
arm: mach-k3: arm: mach-k3: Add writel_verify macro for register write verification
authorUdit Kumar <u-kumar1@ti.com>
Wed, 15 Apr 2026 15:21:50 +0000 (20:51 +0530)
committerTom Rini <trini@konsulko.com>
Mon, 11 May 2026 18:32:00 +0000 (12:32 -0600)
Add a helper macro to write and verify a 32-bit value to a memory-mapped
register. This is essential for hardware errata workarounds that require
confirmation that register writes have taken effect before proceeding with
initialization.

Signed-off-by: Udit Kumar <u-kumar1@ti.com>
arch/arm/mach-k3/include/mach/hardware.h

index 81b5f1fa45ea30456a43c6640aad01388ea6a3f2..b337a71956fb9846632e40582fe6a555eed94ae1 100644 (file)
@@ -126,4 +126,14 @@ struct rom_extended_boot_data {
 
 u32 get_boot_device(void);
 const char *get_reset_reason(void);
+
+#define writel_verify(val, addr) \
+do { \
+       u32 readback; \
+       writel(val, addr); \
+       readback = readl(addr); \
+       if (readback != val) \
+               printf("writel_verify failed: addr=0x%p, expected=0x%x, got=0x%x\n", \
+                      (void *)(addr), (val), readback); \
+} while (0)
 #endif /* _ASM_ARCH_HARDWARE_H_ */