blob: 21925bfdaff7018d6522c16428f6ae251542b38f [file] [log] [blame]
Chris Zankel9a8fd552005-06-23 22:01:26 -07001/*
Chris Zankel9a8fd552005-06-23 22:01:26 -07002 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2003 - 2005 Tensilica Inc.
Max Filippovc75959a2015-05-25 06:55:05 +03007 * Copyright (C) 2015 Cadence Design Systems Inc.
Chris Zankel9a8fd552005-06-23 22:01:26 -07008 */
9
10#ifndef _XTENSA_DMA_MAPPING_H
11#define _XTENSA_DMA_MAPPING_H
12
Chris Zankel9a8fd552005-06-23 22:01:26 -070013#include <asm/cache.h>
14#include <asm/io.h>
Max Filippovc75959a2015-05-25 06:55:05 +030015
16#include <asm-generic/dma-coherent.h>
17
Chris Zankel9a8fd552005-06-23 22:01:26 -070018#include <linux/mm.h>
Jens Axboe8c7837c2007-10-24 13:28:40 +020019#include <linux/scatterlist.h>
Chris Zankel9a8fd552005-06-23 22:01:26 -070020
Max Filippov35b16a92012-11-01 18:38:27 +040021#define DMA_ERROR_CODE (~(dma_addr_t)0x0)
22
Max Filippovc75959a2015-05-25 06:55:05 +030023extern struct dma_map_ops xtensa_dma_map_ops;
Chris Zankel9a8fd552005-06-23 22:01:26 -070024
Max Filippovc75959a2015-05-25 06:55:05 +030025static inline struct dma_map_ops *get_dma_ops(struct device *dev)
Chris Zankel9a8fd552005-06-23 22:01:26 -070026{
Max Filippovc75959a2015-05-25 06:55:05 +030027 if (dev && dev->archdata.dma_ops)
28 return dev->archdata.dma_ops;
29 else
30 return &xtensa_dma_map_ops;
Chris Zankel9a8fd552005-06-23 22:01:26 -070031}
32
Max Filippovc75959a2015-05-25 06:55:05 +030033#include <asm-generic/dma-mapping-common.h>
34
Chris Zankel9a8fd552005-06-23 22:01:26 -070035static inline int
Chris Zankel9a8fd552005-06-23 22:01:26 -070036dma_supported(struct device *dev, u64 mask)
37{
38 return 1;
39}
40
41static inline int
42dma_set_mask(struct device *dev, u64 mask)
43{
44 if(!dev->dma_mask || !dma_supported(dev, mask))
45 return -EIO;
46
47 *dev->dma_mask = mask;
48
49 return 0;
50}
51
Max Filippovc75959a2015-05-25 06:55:05 +030052void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
53 enum dma_data_direction direction);
Guenter Roecke74993a2015-05-04 15:30:47 -070054
Chris Zankel9a8fd552005-06-23 22:01:26 -070055#endif /* _XTENSA_DMA_MAPPING_H */