@@ -609,4 +609,12 @@ GS_DECLARE_RW_REG(imr, imr);
GS_DECLARE_RW_REG(busdir, busdir);
GS_DECLARE_RW_REG(siglblid, siglblid);
+/**
+ * gs_xorq_imr - exclusive or (XOR) value with the IMR register
+ * @value: value to XOR with the IMR register
+ *
+ * Return: the resulting IMR value
+ */
+u64 gs_xorq_imr(u64 value);
+
#endif /* __ASM_MACH_PS2_GS_REGISTERS_H */
@@ -167,6 +167,23 @@ GS_DEFINE_WO_REG(imr, imr, GS_IMR);
GS_DEFINE_WO_REG(busdir, busdir, GS_BUSDIR);
GS_DEFINE_RW_REG(siglblid, siglblid, GS_SIGLBLID); /* Read-write */
+u64 gs_xorq_imr(u64 value)
+{
+ unsigned long flags;
+
+ spin_lock_irqsave(&gs_registers.lock, flags);
+
+ WARN_ON_ONCE(!gs_registers.imr.valid);
+ value = value ^ gs_registers.imr.value;
+ gs_registers.imr.value = value;
+ outq(value, GS_IMR);
+
+ spin_unlock_irqrestore(&gs_registers.lock, flags);
+
+ return value;
+}
+EXPORT_SYMBOL_GPL(gs_xorq_imr);
+
MODULE_DESCRIPTION("PlayStation 2 privileged Graphics Synthesizer registers");
MODULE_AUTHOR("Fredrik Noring");
MODULE_LICENSE("GPL");
Signed-off-by: Fredrik Noring <noring@nocrew.org> --- Perhaps this function could have a better name? --- arch/mips/include/asm/mach-ps2/gs-registers.h | 8 ++++++++ drivers/ps2/gs-registers.c | 17 +++++++++++++++++ 2 files changed, 25 insertions(+)