Skip to contentSkip to conversation

Make BMIPS dma-coherence usable outside of mach-bmips

PATCH New Florian Fainelli 1 participant 3 messages Apr 3, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Make BMIPS dma-coherence usable outside of mach-bmips

Hi Ralf,

This patch creates a bmips-dma-coherence.h file such that we can share it between mach-bmips and mach-bcm63xx, since they are both using BMIPS processors.

Patches against mips-for-linux-next.

Thanks!

Florian Fainelli (2):
MIPS: BMIPS: Create bmips-dma-coherence.h
MIPS: BCM63xx: Utilize bmips-dma-coherence.h

 arch/mips/include/asm/bmips-dma-coherence.h        | 68 ++++++++++++++++++++++
 arch/mips/include/asm/mach-bcm63xx/dma-coherence.h |  6 ++
 arch/mips/include/asm/mach-bmips/dma-coherence.h   | 64 +-------------------
 3 files changed, 75 insertions(+), 63 deletions(-)
 create mode 100644 arch/mips/include/asm/bmips-dma-coherence.h
 create mode 100644 arch/mips/include/asm/mach-bcm63xx/dma-coherence.h
Signature · 1 line
2.1.0
#1 lore raw

PATCH 1/2 MIPS: BMIPS: Create bmips-dma-coherence.h

arch/mips/include/asm/mach-bmips/dma-coherence.h contains a number of BMIPS-specific DMA coherency overrides which are not mach-bmips specific, but specific to the BMIPS CPUs, move this code to a common location such that BCM63xx can also utilize it.

---
 arch/mips/include/asm/bmips-dma-coherence.h      | 68 ++++++++++++++++++++++++
 arch/mips/include/asm/mach-bmips/dma-coherence.h | 64 +---------------------
 2 files changed, 69 insertions(+), 63 deletions(-)
 create mode 100644 arch/mips/include/asm/bmips-dma-coherence.h
arch/mips/include/asm/bmips-dma-coherence.h new file +68 -0
new file mode 100644
index 000000000000..bd4aac47b832
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2006 Ralf Baechle <[email protected]>
+ * Copyright (C) 2009 Broadcom Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef __ASM_BMIPS_DMA_COHERENCE_H
+#define __ASM_BMIPS_DMA_COHERENCE_H
+
+#include <asm/bmips.h>
+#include <asm/cpu-type.h>
+#include <asm/cpu.h>
+
+struct device;
+
+extern dma_addr_t plat_map_dma_mem(struct device *dev, void *addr, size_t size);
+extern dma_addr_t plat_map_dma_mem_page(struct device *dev, struct page *page);
+extern unsigned long plat_dma_addr_to_phys(struct device *dev,
+	dma_addr_t dma_addr);
+
+static inline void plat_unmap_dma_mem(struct device *dev, dma_addr_t dma_addr,
+	size_t size, enum dma_data_direction direction)
+{
+}
+
+static inline int plat_dma_supported(struct device *dev, u64 mask)
+{
+	/*
+	 * we fall back to GFP_DMA when the mask isn't all 1s,
+	 * so we can't guarantee allocations that must be
+	 * within a tighter range than GFP_DMA..
+	 */
+	if (mask < DMA_BIT_MASK(24))
+		return 0;
+
+	return 1;
+}
+
+static inline int plat_device_is_coherent(struct device *dev)
+{
+	return 0;
+}
+
+static inline void plat_post_dma_flush(struct device *dev)
+{
+	void __iomem *cbr = BMIPS_GET_CBR();
+	u32 cfg;
+
+	if (boot_cpu_type() != CPU_BMIPS3300 &&
+	    boot_cpu_type() != CPU_BMIPS4350 &&
+	    boot_cpu_type() != CPU_BMIPS4380)
+		return;
+
+	/* Flush stale data out of the readahead cache */
+	cfg = __raw_readl(cbr + BMIPS_RAC_CONFIG);
+	__raw_writel(cfg | 0x100, cbr + BMIPS_RAC_CONFIG);
+	__raw_readl(cbr + BMIPS_RAC_CONFIG);
+}
+
+#endif /* __ASM_BMIPS_DMA_COHERENCE_H */
arch/mips/include/asm/mach-bmips/dma-coherence.h +1 -63

69 lines not on this page · raw message

Signature · 1 line
2.1.0
#2 lore raw

PATCH 2/2 MIPS: BCM63xx: Utilize bmips-dma-coherence.h

In reply to Florian Fainelli

Create a dma-coherence.h file to make sure that we do get a plat_post_dma_flush() implementation since BCM63xx is using BMIPS CPUs.

---
 arch/mips/include/asm/mach-bcm63xx/dma-coherence.h | 6 ++++++
 1 file changed, 6 insertions(+)
 create mode 100644 arch/mips/include/asm/mach-bcm63xx/dma-coherence.h
arch/mips/include/asm/mach-bcm63xx/dma-coherence.h new file +6 -0
new file mode 100644
index 000000000000..932b2b38bbdf
@@ -0,0 +1,6 @@
+#ifndef __ASM_MACH_BCM63XX_DMA_COHERENCE_H
+#define __ASM_MACH_BCM63XX_DMA_COHERENCE_H
+
+#include <asm/bmips-dma-coherence.h>
+
+#endif /* __ASM_MACH_BCM63XX_DMA_COHERENCE_H */
Signature · 1 line
2.1.0