MIPS: implement dma_sync_* functions
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Peter Mamonov <pmamonov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
0076383a13
commit
28e71b932d
|
@ -6,6 +6,7 @@ config MIPS
|
|||
select HAS_KALLSYMS
|
||||
select HAVE_CONFIGURABLE_MEMORY_LAYOUT
|
||||
select HAVE_CONFIGURABLE_TEXT_BASE
|
||||
select HAS_DMA
|
||||
default y
|
||||
|
||||
config SYS_SUPPORTS_BIG_ENDIAN
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
#ifndef _ASM_DMA_MAPPING_H
|
||||
#define _ASM_DMA_MAPPING_H
|
||||
|
||||
#include <common.h>
|
||||
#include <xfuncs.h>
|
||||
#include <asm/addrspace.h>
|
||||
#include <asm/types.h>
|
||||
#include <malloc.h>
|
||||
#include <asm/io.h>
|
||||
|
||||
static inline void *dma_alloc_coherent(size_t size, dma_addr_t *dma_handle)
|
||||
{
|
||||
|
@ -12,16 +14,23 @@ static inline void *dma_alloc_coherent(size_t size, dma_addr_t *dma_handle)
|
|||
|
||||
ret = xmemalign(PAGE_SIZE, size);
|
||||
|
||||
memset(ret, 0, size);
|
||||
|
||||
if (dma_handle)
|
||||
*dma_handle = CPHYSADDR(ret);
|
||||
|
||||
dma_flush_range((unsigned long)ret, (unsigned long)(ret + size));
|
||||
|
||||
return (void *)CKSEG1ADDR(ret);
|
||||
}
|
||||
|
||||
static inline void dma_free_coherent(void *vaddr, dma_addr_t dma_handle,
|
||||
size_t size)
|
||||
{
|
||||
free(vaddr);
|
||||
if (IS_ENABLED(CONFIG_MMU))
|
||||
free((void *)CKSEG0ADDR(vaddr));
|
||||
else
|
||||
free(vaddr);
|
||||
}
|
||||
|
||||
#endif /* _ASM_DMA_MAPPING_H */
|
||||
|
|
|
@ -7,6 +7,7 @@ obj-y += cpu-probe.o
|
|||
obj-y += traps.o
|
||||
obj-y += genex.o
|
||||
obj-y += shutdown.o
|
||||
obj-y += dma-default.o
|
||||
|
||||
obj-$(CONFIG_MIPS_OPTIMIZED_STRING_FUNCTIONS) += memcpy.o
|
||||
obj-$(CONFIG_MIPS_OPTIMIZED_STRING_FUNCTIONS) += memset.o
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* (C) Copyright 2015, 2016 Peter Mamonov <pmamonov@gmail.com>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <dma.h>
|
||||
#include <asm/io.h>
|
||||
|
||||
#if defined(CONFIG_CPU_MIPS32) || \
|
||||
defined(CONFIG_CPU_MIPS64)
|
||||
static inline void __dma_sync_mips(unsigned long addr, size_t size,
|
||||
enum dma_data_direction direction)
|
||||
{
|
||||
switch (direction) {
|
||||
case DMA_TO_DEVICE:
|
||||
dma_flush_range(addr, addr + size);
|
||||
break;
|
||||
|
||||
case DMA_FROM_DEVICE:
|
||||
dma_inv_range(addr, addr + size);
|
||||
break;
|
||||
|
||||
case DMA_BIDIRECTIONAL:
|
||||
dma_flush_range(addr, addr + size);
|
||||
break;
|
||||
|
||||
default:
|
||||
BUG();
|
||||
}
|
||||
}
|
||||
#else
|
||||
static inline void __dma_sync_mips(void *addr, size_t size,
|
||||
enum dma_data_direction direction)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
void dma_sync_single_for_cpu(unsigned long address, size_t size,
|
||||
enum dma_data_direction dir)
|
||||
{
|
||||
__dma_sync_mips(address, size, dir);
|
||||
}
|
||||
|
||||
void dma_sync_single_for_device(unsigned long address, size_t size,
|
||||
enum dma_data_direction dir)
|
||||
{
|
||||
__dma_sync_mips(address, size, dir);
|
||||
}
|
Loading…
Reference in New Issue