From: Ramon Fried <rfried.dev@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 2/2] MIPS: add dma-mapping.h implementation
Date: Mon, 10 Jun 2019 21:05:25 +0300 [thread overview]
Message-ID: <20190610180526.11262-2-rfried.dev@gmail.com> (raw)
In-Reply-To: <20190610180526.11262-1-rfried.dev@gmail.com>
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>
---
v2: fix warning caused by missing casts.
arch/mips/include/asm/dma-mapping.h | 48 +++++++++++++++++++++++++++++
1 file changed, 48 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..387427c13b
--- /dev/null
+++ b/arch/mips/include/asm/dma-mapping.h
@@ -0,0 +1,48 @@
+/* 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((unsigned long)vaddr,
+ (unsigned long)vaddr + len);
+ if (dir == DMA_FROM_DEVICE)
+ invalidate_dcache_range((unsigned long)vaddr,
+ (unsigned long)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
next prev parent reply other threads:[~2019-06-10 18:05 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-10 18:05 [U-Boot] [PATCH v2 1/2] MIPS: add empty arch/clk.h Ramon Fried
2019-06-10 18:05 ` Ramon Fried [this message]
2019-06-17 12:01 ` [U-Boot] [PATCH v2 2/2] MIPS: add dma-mapping.h implementation Daniel Schwierzeck
2019-06-10 18:05 ` [U-Boot] [PATCH] MIPS: add compile time definition of L2 cache size Ramon Fried
2019-10-18 11:03 ` Daniel Schwierzeck
2019-06-17 11:42 ` [U-Boot] [PATCH v2 1/2] MIPS: add empty arch/clk.h Daniel Schwierzeck
2019-06-17 19:24 ` Ramon Fried
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190610180526.11262-2-rfried.dev@gmail.com \
--to=rfried.dev@gmail.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.