[U-Boot] [PATCH 28/39] x86: Add clr/setbits functions
Simon Glass
sjg at chromium.org
Thu Nov 6 21:20:20 CET 2014
These are available on other architectures. Make them available on x86 also.
Signed-off-by: Simon Glass <sjg at chromium.org>
---
arch/x86/include/asm/io.h | 49 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
index 86bac90..fcd9aa9 100644
--- a/arch/x86/include/asm/io.h
+++ b/arch/x86/include/asm/io.h
@@ -69,6 +69,55 @@
#define memcpy_fromio(a,b,c) memcpy((a),(b),(c))
#define memcpy_toio(a,b,c) memcpy((a),(b),(c))
+#define write_arch(type, endian, a, v) __raw_write##type(cpu_to_##endian(v), a)
+#define read_arch(type, endian, a) endian##_to_cpu(__raw_read##type(a))
+
+#define write_le64(a, v) write_arch(q, le64, a, v)
+#define write_le32(a, v) write_arch(l, le32, a, v)
+#define write_le16(a, v) write_arch(w, le16, a, v)
+
+#define read_le64(a) read_arch(q, le64, a)
+#define read_le32(a) read_arch(l, le32, a)
+#define read_le16(a) read_arch(w, le16, a)
+
+#define write_be32(a, v) write_arch(l, be32, a, v)
+#define write_be16(a, v) write_arch(w, be16, a, v)
+
+#define read_be32(a) read_arch(l, be32, a)
+#define read_be16(a) read_arch(w, be16, a)
+
+#define write_8(a, v) __raw_writeb(v, a)
+#define read_8(a) __raw_readb(a)
+
+#define clrbits(type, addr, clear) \
+ write_##type((addr), read_##type(addr) & ~(clear))
+
+#define setbits(type, addr, set) \
+ write_##type((addr), read_##type(addr) | (set))
+
+#define clrsetbits(type, addr, clear, set) \
+ write_##type((addr), (read_##type(addr) & ~(clear)) | (set))
+
+#define clrbits_be32(addr, clear) clrbits(be32, addr, clear)
+#define setbits_be32(addr, set) setbits(be32, addr, set)
+#define clrsetbits_be32(addr, clear, set) clrsetbits(be32, addr, clear, set)
+
+#define clrbits_le32(addr, clear) clrbits(le32, addr, clear)
+#define setbits_le32(addr, set) setbits(le32, addr, set)
+#define clrsetbits_le32(addr, clear, set) clrsetbits(le32, addr, clear, set)
+
+#define clrbits_be16(addr, clear) clrbits(be16, addr, clear)
+#define setbits_be16(addr, set) setbits(be16, addr, set)
+#define clrsetbits_be16(addr, clear, set) clrsetbits(be16, addr, clear, set)
+
+#define clrbits_le16(addr, clear) clrbits(le16, addr, clear)
+#define setbits_le16(addr, set) setbits(le16, addr, set)
+#define clrsetbits_le16(addr, clear, set) clrsetbits(le16, addr, clear, set)
+
+#define clrbits_8(addr, clear) clrbits(8, addr, clear)
+#define setbits_8(addr, set) setbits(8, addr, set)
+#define clrsetbits_8(addr, clear, set) clrsetbits(8, addr, clear, set)
+
/*
* ISA space is 'always mapped' on a typical x86 system, no need to
* explicitly ioremap() it. The fact that the ISA IO space is mapped
--
2.1.0.rc2.206.gedb03e5
More information about the U-Boot
mailing list