]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
x86: Add macros to clear and set I/O bits
authorSimon Glass <sjg@chromium.org>
Sat, 12 Mar 2016 05:07:06 +0000 (22:07 -0700)
committerBin Meng <bmeng.cn@gmail.com>
Thu, 17 Mar 2016 02:27:25 +0000 (10:27 +0800)
The clrsetbits_...() macros are useful for working with memory mapped I/O.
But they do not work with I/O space, as used on x86 machines.

Add some macros to provide similar features for I/O.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
arch/x86/include/asm/io.h

index e0b25619cd50e8f2877e774dc5c1f2bf5be01b4d..b99e4d645498f71ad560f37d62ddd6574e41346f 100644 (file)
@@ -254,6 +254,28 @@ __OUTS(b)
 __OUTS(w)
 __OUTS(l)
 
+/* IO space accessors */
+#define clrio(type, addr, clear) \
+       out##type(in##type(addr) & ~(clear), (addr))
+
+#define setio(type, addr, set) \
+       out##type(in##type(addr) | (set), (addr))
+
+#define clrsetio(type, addr, clear, set) \
+       out##type((in##type(addr) & ~(clear)) | (set), (addr))
+
+#define clrio_32(addr, clear) clrio(l, addr, clear)
+#define clrio_16(addr, clear) clrio(w, addr, clear)
+#define clrio_8(addr, clear) clrio(b, addr, clear)
+
+#define setio_32(addr, set) setio(l, addr, set)
+#define setio_16(addr, set) setio(w, addr, set)
+#define setio_8(addr, set) setio(b, addr, set)
+
+#define clrsetio_32(addr, clear, set) clrsetio(l, addr, clear, set)
+#define clrsetio_16(addr, clear, set) clrsetio(w, addr, clear, set)
+#define clrsetio_8(addr, clear, set) clrsetio(b, addr, clear, set)
+
 static inline void sync(void)
 {
 }