All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 2/2] MIPS: add dma-mapping.h implementation
@ 2019-06-09  4:52 Ramon Fried
  2019-06-10  6:28 ` Ramon Fried
  0 siblings, 1 reply; 2+ messages in thread
From: Ramon Fried @ 2019-06-09  4:52 UTC (permalink / raw)
  To: u-boot

add implementation for dma_alloc_coherent(),
dma_free_coherent(), dma_map_single() and dma_free_single()

Signed-off-by: Ramon Fried <rfried.dev@gmail.com>
---
 arch/mips/include/asm/dma-mapping.h | 46 +++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)
 create mode 100644 arch/mips/include/asm/dma-mapping.h

diff --git a/arch/mips/include/asm/dma-mapping.h b/arch/mips/include/asm/dma-mapping.h
new file mode 100644
index 0000000000..5c87c28ce8
--- /dev/null
+++ b/arch/mips/include/asm/dma-mapping.h
@@ -0,0 +1,46 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * (C) Copyright 2019
+ * Ramon Fried <rfried.dev@gmail.com>
+ */
+
+#ifndef __ASM_MIPS_DMA_MAPPING_H
+#define __ASM_MIPS_DMA_MAPPING_H
+
+#include <linux/dma-direction.h>
+#include <asm/addrspace.h>
+#define	dma_mapping_error(x, y)	0
+
+static inline void *dma_alloc_coherent(size_t len, unsigned long *handle)
+{
+	void *vaddr = memalign(ARCH_DMA_MINALIGN,
+			       ROUND(len, ARCH_DMA_MINALIGN));
+
+	*handle = CPHYSADDR((unsigned long)vaddr);
+	return (void *)(CKSEG1ADDR((unsigned long)vaddr));
+}
+
+static inline void dma_free_coherent(void *addr)
+{
+	free((void *)CPHYSADDR((unsigned long)addr));
+}
+
+static inline unsigned long dma_map_single(volatile void *vaddr, size_t len,
+					   enum dma_data_direction dir)
+{
+	unsigned long dma_addr = CPHYSADDR((unsigned long)vaddr);
+
+	if (dir == DMA_TO_DEVICE)
+		flush_dcache_range(vaddr, vaddr + len);
+	if (dir == DMA_FROM_DEVICE)
+		invalidate_dcache_range(vaddr, vaddr + len);
+
+	return dma_addr;
+}
+
+static inline void dma_unmap_single(volatile void *vaddr, size_t len,
+				    unsigned long paddr)
+{
+}
+
+#endif /* __ASM_MIPS_DMA_MAPPING_H */
-- 
2.21.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [U-Boot] [PATCH 2/2] MIPS: add dma-mapping.h implementation
  2019-06-09  4:52 [U-Boot] [PATCH 2/2] MIPS: add dma-mapping.h implementation Ramon Fried
@ 2019-06-10  6:28 ` Ramon Fried
  0 siblings, 0 replies; 2+ messages in thread
From: Ramon Fried @ 2019-06-10  6:28 UTC (permalink / raw)
  To: u-boot

Hi Daniel
Please wait with this patch, I'll send v2 shortly.
Sorry.
Ramon.

On Sun, Jun 9, 2019 at 7:52 AM Ramon Fried <rfried.dev@gmail.com> wrote:

> add implementation for dma_alloc_coherent(),
> dma_free_coherent(), dma_map_single() and dma_free_single()
>
> Signed-off-by: Ramon Fried <rfried.dev@gmail.com>
> ---
>  arch/mips/include/asm/dma-mapping.h | 46 +++++++++++++++++++++++++++++
>  1 file changed, 46 insertions(+)
>  create mode 100644 arch/mips/include/asm/dma-mapping.h
>
> diff --git a/arch/mips/include/asm/dma-mapping.h
> b/arch/mips/include/asm/dma-mapping.h
> new file mode 100644
> index 0000000000..5c87c28ce8
> --- /dev/null
> +++ b/arch/mips/include/asm/dma-mapping.h
> @@ -0,0 +1,46 @@
> +/* SPDX-License-Identifier: GPL-2.0+ */
> +/*
> + * (C) Copyright 2019
> + * Ramon Fried <rfried.dev@gmail.com>
> + */
> +
> +#ifndef __ASM_MIPS_DMA_MAPPING_H
> +#define __ASM_MIPS_DMA_MAPPING_H
> +
> +#include <linux/dma-direction.h>
> +#include <asm/addrspace.h>
> +#define        dma_mapping_error(x, y) 0
> +
> +static inline void *dma_alloc_coherent(size_t len, unsigned long *handle)
> +{
> +       void *vaddr = memalign(ARCH_DMA_MINALIGN,
> +                              ROUND(len, ARCH_DMA_MINALIGN));
> +
> +       *handle = CPHYSADDR((unsigned long)vaddr);
> +       return (void *)(CKSEG1ADDR((unsigned long)vaddr));
> +}
> +
> +static inline void dma_free_coherent(void *addr)
> +{
> +       free((void *)CPHYSADDR((unsigned long)addr));
> +}
> +
> +static inline unsigned long dma_map_single(volatile void *vaddr, size_t
> len,
> +                                          enum dma_data_direction dir)
> +{
> +       unsigned long dma_addr = CPHYSADDR((unsigned long)vaddr);
> +
> +       if (dir == DMA_TO_DEVICE)
> +               flush_dcache_range(vaddr, vaddr + len);
> +       if (dir == DMA_FROM_DEVICE)
> +               invalidate_dcache_range(vaddr, vaddr + len);
> +
> +       return dma_addr;
> +}
> +
> +static inline void dma_unmap_single(volatile void *vaddr, size_t len,
> +                                   unsigned long paddr)
> +{
> +}
> +
> +#endif /* __ASM_MIPS_DMA_MAPPING_H */
> --
> 2.21.0
>
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-06-10  6:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-09  4:52 [U-Boot] [PATCH 2/2] MIPS: add dma-mapping.h implementation Ramon Fried
2019-06-10  6:28 ` Ramon Fried

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.