blob: 8af1ea0aa4df83b9d8c61b0b031dae9e9659e666 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Stelian Pop7d42a222008-01-31 21:15:53 +00002/*
3 * (C) Copyright 2007
Stelian Pop5ee0c7f2011-11-01 00:00:39 +01004 * Stelian Pop <stelian@popies.net>
Stelian Pop7d42a222008-01-31 21:15:53 +00005 * Lead Tech Design <www.leadtechdesign.com>
Stelian Pop7d42a222008-01-31 21:15:53 +00006 */
7#ifndef __ASM_ARM_DMA_MAPPING_H
8#define __ASM_ARM_DMA_MAPPING_H
9
Vignesh Raghavendra4a81a212020-01-16 14:23:45 +053010#include <asm/cache.h>
11#include <cpu_func.h>
Masahiro Yamadaef205ea2017-08-26 00:50:17 +090012#include <linux/dma-direction.h>
Simon Glass1e268642020-05-10 11:39:55 -060013#include <linux/kernel.h>
Masahiro Yamada7167d672020-02-14 16:40:17 +090014#include <linux/types.h>
Vignesh Raghavendra4a81a212020-01-16 14:23:45 +053015#include <malloc.h>
Kishon Vijay Abraham Icec6d1c2015-02-23 18:39:56 +053016
Kishon Vijay Abraham I14841502015-02-23 18:39:49 +053017static inline void *dma_alloc_coherent(size_t len, unsigned long *handle)
Stelian Pop7d42a222008-01-31 21:15:53 +000018{
Ye Li054f7792019-01-04 09:24:14 +000019 *handle = (unsigned long)memalign(ARCH_DMA_MINALIGN, ROUND(len, ARCH_DMA_MINALIGN));
Stelian Pop7d42a222008-01-31 21:15:53 +000020 return (void *)*handle;
21}
22
Kishon Vijay Abraham Icec6d1c2015-02-23 18:39:56 +053023static inline void dma_free_coherent(void *addr)
24{
25 free(addr);
26}
27
Stelian Pop7d42a222008-01-31 21:15:53 +000028#endif /* __ASM_ARM_DMA_MAPPING_H */