diff mbox series

[051/120] MIPS: PS2: IOP: I/O processor DMA register PCR2 set and clear

Message ID ea6398e79f28fc4f77fcd85b5258393fa7c9a07b.1567326213.git.noring@nocrew.org (mailing list archive)
State RFC
Headers show
Series Linux for the PlayStation 2 | expand

Commit Message

Fredrik Noring Sept. 1, 2019, 3:56 p.m. UTC
Signed-off-by: Fredrik Noring <noring@nocrew.org>
---
The documentation for the DEV9 is rather poor, unfortunately.
---
 .../mips/include/asm/mach-ps2/iop-registers.h | 19 +++++++++
 drivers/ps2/Makefile                          |  1 +
 drivers/ps2/iop-registers.c                   | 39 +++++++++++++++++++
 3 files changed, 59 insertions(+)
 create mode 100644 arch/mips/include/asm/mach-ps2/iop-registers.h
 create mode 100644 drivers/ps2/Makefile
 create mode 100644 drivers/ps2/iop-registers.c
diff mbox series

Patch

diff --git a/arch/mips/include/asm/mach-ps2/iop-registers.h b/arch/mips/include/asm/mach-ps2/iop-registers.h
new file mode 100644
index 000000000000..b4db423150de
--- /dev/null
+++ b/arch/mips/include/asm/mach-ps2/iop-registers.h
@@ -0,0 +1,19 @@ 
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * PlayStation 2 I/O processor (IOP) registers
+ *
+ * Copyright (C) 2017-2019 Fredrik Noring
+ */
+
+#ifndef __ASM_MACH_PS2_IOP_REGISTERS_H
+#define __ASM_MACH_PS2_IOP_REGISTERS_H
+
+#include <linux/types.h>
+
+#define IOP_DMA_DPCR2_OHCI	0x08000000	/* USB OHCI */
+#define IOP_DMA_DPCR2_DEV9	0x00000080	/* DEV9 (Expansion Bay, USB) */
+
+void iop_set_dma_dpcr2(const u32 mask);
+void iop_clr_dma_dpcr2(const u32 mask);
+
+#endif /* __ASM_MACH_PS2_IOP_REGISTERS_H */
diff --git a/drivers/ps2/Makefile b/drivers/ps2/Makefile
new file mode 100644
index 000000000000..e53976ddb3e4
--- /dev/null
+++ b/drivers/ps2/Makefile
@@ -0,0 +1 @@ 
+obj-m				+= iop-registers.o
diff --git a/drivers/ps2/iop-registers.c b/drivers/ps2/iop-registers.c
new file mode 100644
index 000000000000..0ea7603b91a3
--- /dev/null
+++ b/drivers/ps2/iop-registers.c
@@ -0,0 +1,39 @@ 
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * PlayStation 2 I/O processor (IOP) registers
+ *
+ * Copyright (C) 2019 Fredrik Noring
+ */
+
+#include <linux/module.h>
+#include <linux/spinlock.h>
+
+#include <asm/io.h>
+
+#include <asm/mach-ps2/iop-registers.h>
+
+#define IOP_DMA_DPCR2	0x1f801570
+
+static DEFINE_SPINLOCK(reg_lock);
+
+void iop_set_dma_dpcr2(const u32 mask)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(&reg_lock, flags);
+	outl(inl(IOP_DMA_DPCR2) | mask, IOP_DMA_DPCR2);
+	spin_unlock_irqrestore(&reg_lock, flags);
+}
+EXPORT_SYMBOL_GPL(iop_set_dma_dpcr2);
+
+void iop_clr_dma_dpcr2(const u32 mask)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(&reg_lock, flags);
+	outl(inl(IOP_DMA_DPCR2) & ~mask, IOP_DMA_DPCR2);
+	spin_unlock_irqrestore(&reg_lock, flags);
+}
+EXPORT_SYMBOL_GPL(iop_clr_dma_dpcr2);
+
+MODULE_LICENSE("GPL");