summaryrefslogtreecommitdiff
path: root/arch/x86/include/asm/io.h
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2014-11-12 22:42:17 -0700
committerSimon Glass <sjg@chromium.org>2014-11-21 07:34:13 +0100
commit3f70a6f5773432c83429e33dbc062812113b1c50 (patch)
tree9aba468c3762efe694ab6380696ae80fc65b40d7 /arch/x86/include/asm/io.h
parent378a8634ad12981779c24e6ec29619deff88d19b (diff)
downloadu-boot-imx-3f70a6f5773432c83429e33dbc062812113b1c50.zip
u-boot-imx-3f70a6f5773432c83429e33dbc062812113b1c50.tar.gz
u-boot-imx-3f70a6f5773432c83429e33dbc062812113b1c50.tar.bz2
x86: Add clr/setbits functions
These are available on other architectures. Make them available on x86 also. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'arch/x86/include/asm/io.h')
-rw-r--r--arch/x86/include/asm/io.h49
1 files changed, 49 insertions, 0 deletions
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