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