]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
x86: Add functions to set and clear bits on MSRs
authorSimon Glass <sjg@chromium.org>
Thu, 30 Apr 2015 04:26:00 +0000 (22:26 -0600)
committerLothar Waßmann <LW@KARO-electronics.de>
Tue, 8 Sep 2015 20:35:17 +0000 (22:35 +0200)
Since we do these sorts of operations a lot, it is useful to have a simpler
API, similar to clrsetbits_le32().

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

index 1955a752b910c3dfdf987c75948c20f1f686587b..c480920d25688914e08e4eaf658cad7b96b2bddd 100644 (file)
@@ -128,6 +128,34 @@ static inline void wrmsr(unsigned msr, unsigned low, unsigned high)
 #define wrmsrl(msr, val)                                               \
        native_write_msr((msr), (u32)((u64)(val)), (u32)((u64)(val) >> 32))
 
+static inline void msr_clrsetbits_64(unsigned msr, u64 clear, u64 set)
+{
+       u64 val;
+
+       val = native_read_msr(msr);
+       val &= ~clear;
+       val |= set;
+       wrmsrl(msr, val);
+}
+
+static inline void msr_setbits_64(unsigned msr, u64 set)
+{
+       u64 val;
+
+       val = native_read_msr(msr);
+       val |= set;
+       wrmsrl(msr, val);
+}
+
+static inline void msr_clrbits_64(unsigned msr, u64 clear)
+{
+       u64 val;
+
+       val = native_read_msr(msr);
+       val &= ~clear;
+       wrmsrl(msr, val);
+}
+
 /* rdmsr with exception handling */
 #define rdmsr_safe(msr, p1, p2)                                        \
 ({                                                             \