[U-Boot] [PATCH v1 1/2] arch: sandbox: Provide working writeX/readX functions

Jean-Jacques Hiblot jjhiblot at ti.com
Wed Oct 2 09:28:34 UTC 2019


Those functions are used by the regmap core. Without them regmaps are
not working on sandbox.
The implementation is taken from arch/x86/include/asm/io.h.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot at ti.com>
---

 arch/sandbox/include/asm/io.h | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/arch/sandbox/include/asm/io.h b/arch/sandbox/include/asm/io.h
index 2a350a826c..504aac0691 100644
--- a/arch/sandbox/include/asm/io.h
+++ b/arch/sandbox/include/asm/io.h
@@ -38,18 +38,18 @@ static inline void unmap_sysmem(const void *vaddr)
 /* Map from a pointer to our RAM buffer */
 phys_addr_t map_to_sysmem(const void *ptr);
 
-/* Define nops for sandbox I/O access */
-#define readb(addr) ((void)addr, 0)
-#define readw(addr) ((void)addr, 0)
-#define readl(addr) ((void)addr, 0)
+#define readb(addr) (*(volatile u8 *)(uintptr_t)(addr))
+#define readw(addr) (*(volatile u16 *)(uintptr_t)(addr))
+#define readl(addr) (*(volatile u32 *)(uintptr_t)(addr))
 #ifdef CONFIG_SANDBOX64
-#define readq(addr) ((void)addr, 0)
+#define readq(addr) (*(volatile u64 *)(uintptr_t)(addr))
 #endif
-#define writeb(v, addr) ((void)addr)
-#define writew(v, addr) ((void)addr)
-#define writel(v, addr) ((void)addr)
+
+#define writeb(b, addr) (*(volatile u8 *)(addr) = (b))
+#define writew(b, addr) (*(volatile u16 *)(addr) = (b))
+#define writel(b, addr) (*(volatile u32 *)(addr) = (b))
 #ifdef CONFIG_SANDBOX64
-#define writeq(v, addr) ((void)addr)
+#define writeq(b, addr) (*(volatile u64 *)(addr) = (b))
 #endif
 
 /*
-- 
2.17.1



More information about the U-Boot mailing list