Skip to content

Commit d59098a

Browse files
Christoph Hellwigpaulburton
authored andcommitted
MIPS: bmips: use generic dma noncoherent ops
Provide phys_to_dma/dma_to_phys helpers, and the special arch_sync_dma_for_cpu_all hook, everything else is generic Signed-off-by: Christoph Hellwig <[email protected]> Patchwork: https://patchwork.linux-mips.org/patch/19550/ Signed-off-by: Paul Burton <[email protected]> Cc: Florian Fainelli <[email protected]> Cc: David Daney <[email protected]> Cc: Kevin Cernekee <[email protected]> Cc: Jiaxun Yang <[email protected]> Cc: Tom Bogendoerfer <[email protected]> Cc: Huacai Chen <[email protected]> Cc: [email protected] Cc: [email protected]
1 parent faef877 commit d59098a

File tree

4 files changed

+21
-84
lines changed

4 files changed

+21
-84
lines changed

arch/mips/Kconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ config ATH79
215215

216216
config BMIPS_GENERIC
217217
bool "Broadcom Generic BMIPS kernel"
218+
select ARCH_HAS_SYNC_DMA_FOR_CPU_ALL
219+
select ARCH_HAS_PHYS_TO_DMA
218220
select BOOT_RAW
219221
select NO_EXCEPT_FILL
220222
select USE_OF
@@ -227,7 +229,6 @@ config BMIPS_GENERIC
227229
select BCM7120_L2_IRQ
228230
select BRCMSTB_L2_IRQ
229231
select IRQ_MIPS_CPU
230-
select MIPS_DMA_DEFAULT
231232
select DMA_NONCOHERENT
232233
select SYS_SUPPORTS_32BIT_KERNEL
233234
select SYS_SUPPORTS_LITTLE_ENDIAN

arch/mips/bmips/dma.c

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include <linux/printk.h>
1818
#include <linux/slab.h>
1919
#include <linux/types.h>
20-
#include <dma-coherence.h>
20+
#include <asm/bmips.h>
2121

2222
/*
2323
* BCM338x has configurable address translation windows which allow the
@@ -40,7 +40,7 @@ static struct bmips_dma_range *bmips_dma_ranges;
4040

4141
#define FLUSH_RAC 0x100
4242

43-
static dma_addr_t bmips_phys_to_dma(struct device *dev, phys_addr_t pa)
43+
dma_addr_t __phys_to_dma(struct device *dev, phys_addr_t pa)
4444
{
4545
struct bmips_dma_range *r;
4646

@@ -52,17 +52,7 @@ static dma_addr_t bmips_phys_to_dma(struct device *dev, phys_addr_t pa)
5252
return pa;
5353
}
5454

55-
dma_addr_t plat_map_dma_mem(struct device *dev, void *addr, size_t size)
56-
{
57-
return bmips_phys_to_dma(dev, virt_to_phys(addr));
58-
}
59-
60-
dma_addr_t plat_map_dma_mem_page(struct device *dev, struct page *page)
61-
{
62-
return bmips_phys_to_dma(dev, page_to_phys(page));
63-
}
64-
65-
unsigned long plat_dma_addr_to_phys(struct device *dev, dma_addr_t dma_addr)
55+
phys_addr_t __dma_to_phys(struct device *dev, dma_addr_t dma_addr)
6656
{
6757
struct bmips_dma_range *r;
6858

@@ -74,6 +64,22 @@ unsigned long plat_dma_addr_to_phys(struct device *dev, dma_addr_t dma_addr)
7464
return dma_addr;
7565
}
7666

67+
void arch_sync_dma_for_cpu_all(struct device *dev)
68+
{
69+
void __iomem *cbr = BMIPS_GET_CBR();
70+
u32 cfg;
71+
72+
if (boot_cpu_type() != CPU_BMIPS3300 &&
73+
boot_cpu_type() != CPU_BMIPS4350 &&
74+
boot_cpu_type() != CPU_BMIPS4380)
75+
return;
76+
77+
/* Flush stale data out of the readahead cache */
78+
cfg = __raw_readl(cbr + BMIPS_RAC_CONFIG);
79+
__raw_writel(cfg | 0x100, cbr + BMIPS_RAC_CONFIG);
80+
__raw_readl(cbr + BMIPS_RAC_CONFIG);
81+
}
82+
7783
static int __init bmips_init_dma_ranges(void)
7884
{
7985
struct device_node *np =

arch/mips/include/asm/bmips.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -123,22 +123,6 @@ static inline void bmips_write_zscm_reg(unsigned int offset, unsigned long data)
123123
barrier();
124124
}
125125

126-
static inline void bmips_post_dma_flush(struct device *dev)
127-
{
128-
void __iomem *cbr = BMIPS_GET_CBR();
129-
u32 cfg;
130-
131-
if (boot_cpu_type() != CPU_BMIPS3300 &&
132-
boot_cpu_type() != CPU_BMIPS4350 &&
133-
boot_cpu_type() != CPU_BMIPS4380)
134-
return;
135-
136-
/* Flush stale data out of the readahead cache */
137-
cfg = __raw_readl(cbr + BMIPS_RAC_CONFIG);
138-
__raw_writel(cfg | 0x100, cbr + BMIPS_RAC_CONFIG);
139-
__raw_readl(cbr + BMIPS_RAC_CONFIG);
140-
}
141-
142126
#endif /* !defined(__ASSEMBLY__) */
143127

144128
#endif /* _ASM_BMIPS_H */

arch/mips/include/asm/mach-bmips/dma-coherence.h

Lines changed: 0 additions & 54 deletions
This file was deleted.

0 commit comments

Comments
 (0)