diff mbox series

[065/120] MIPS: PS2: IOP: I/O processor memory support

Message ID e1dc0dbb3cfb4a71aeab681f647c220da10fd445.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, 4:03 p.m. UTC
Signed-off-by: Fredrik Noring <noring@nocrew.org>
---
 arch/mips/include/asm/mach-ps2/iop-memory.h | 21 ++++++++
 drivers/ps2/Makefile                        |  1 +
 drivers/ps2/iop-memory.c                    | 56 +++++++++++++++++++++
 3 files changed, 78 insertions(+)
 create mode 100644 arch/mips/include/asm/mach-ps2/iop-memory.h
 create mode 100644 drivers/ps2/iop-memory.c
diff mbox series

Patch

diff --git a/arch/mips/include/asm/mach-ps2/iop-memory.h b/arch/mips/include/asm/mach-ps2/iop-memory.h
new file mode 100644
index 000000000000..6efdb490c7b9
--- /dev/null
+++ b/arch/mips/include/asm/mach-ps2/iop-memory.h
@@ -0,0 +1,21 @@ 
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * PlayStation 2 I/O processor (IOP) memory
+ *
+ * Copyright (C) 2018 Fredrik Noring
+ */
+
+#ifndef __ASM_MACH_PS2_IOP_MEMORY_H
+#define __ASM_MACH_PS2_IOP_MEMORY_H
+
+#include <linux/types.h>
+
+#include <asm/mach-ps2/iop.h>
+
+iop_addr_t iop_phys_to_bus(phys_addr_t paddr);
+
+phys_addr_t iop_bus_to_phys(iop_addr_t baddr);
+
+void *iop_bus_to_virt(iop_addr_t baddr);
+
+#endif /* __ASM_MACH_PS2_IOP_MEMORY_H */
diff --git a/drivers/ps2/Makefile b/drivers/ps2/Makefile
index ef561a802bdd..6f193007ebc6 100644
--- a/drivers/ps2/Makefile
+++ b/drivers/ps2/Makefile
@@ -1,2 +1,3 @@ 
+obj-m				+= iop-memory.o
 obj-m				+= iop-registers.o
 obj-m				+= sif.o
diff --git a/drivers/ps2/iop-memory.c b/drivers/ps2/iop-memory.c
new file mode 100644
index 000000000000..829d7174da0e
--- /dev/null
+++ b/drivers/ps2/iop-memory.c
@@ -0,0 +1,56 @@ 
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * PlayStation 2 input/output processor (IOP) memory
+ *
+ * Copyright (C) 2018 Fredrik Noring
+ */
+
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/module.h>
+#include <linux/dma-mapping.h>
+
+#include <asm/mach-ps2/iop-memory.h>
+
+/**
+ * iop_phys_to_bus - kernel physical to I/O processor (IOP) bus address
+ * @paddr: kernel physical address
+ *
+ * Context: any
+ * Return: I/O processor (IOP) bus address
+ */
+iop_addr_t iop_phys_to_bus(phys_addr_t paddr)
+{
+	return (u32)paddr - IOP_RAM_BASE;
+}
+EXPORT_SYMBOL(iop_phys_to_bus);
+
+/**
+ * iop_bus_to_phys - I/O processor (IOP) bus address to kernel physical
+ * @baddr: I/O processor (IOP) bus address
+ *
+ * Context: any
+ * Return: kernel physical address
+ */
+phys_addr_t iop_bus_to_phys(iop_addr_t baddr)
+{
+	return (u32)baddr + IOP_RAM_BASE;
+}
+EXPORT_SYMBOL(iop_bus_to_phys);
+
+/**
+ * iop_bus_to_virt - I/O processor (IOP) bus address to kernel virtual
+ * @baddr: I/O processor (IOP) bus address
+ *
+ * Context: any
+ * Return: kernel virtual address
+ */
+void *iop_bus_to_virt(iop_addr_t baddr)
+{
+	return phys_to_virt(iop_bus_to_phys(baddr));
+}
+EXPORT_SYMBOL(iop_bus_to_virt);
+
+MODULE_DESCRIPTION("PlayStation 2 input/output processor (IOP) memory");
+MODULE_AUTHOR("Fredrik Noring");
+MODULE_LICENSE("GPL");