Chris Zankel | 9a8fd55 | 2005-06-23 22:01:26 -0700 | [diff] [blame] | 1 | /* |
Chris Zankel | 9a8fd55 | 2005-06-23 22:01:26 -0700 | [diff] [blame] | 2 | * 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 Filippov | c75959a | 2015-05-25 06:55:05 +0300 | [diff] [blame] | 7 | * Copyright (C) 2015 Cadence Design Systems Inc. |
Chris Zankel | 9a8fd55 | 2005-06-23 22:01:26 -0700 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #ifndef _XTENSA_DMA_MAPPING_H |
| 11 | #define _XTENSA_DMA_MAPPING_H |
| 12 | |
Chris Zankel | 9a8fd55 | 2005-06-23 22:01:26 -0700 | [diff] [blame] | 13 | #include <asm/cache.h> |
| 14 | #include <asm/io.h> |
Max Filippov | c75959a | 2015-05-25 06:55:05 +0300 | [diff] [blame] | 15 | |
| 16 | #include <asm-generic/dma-coherent.h> |
| 17 | |
Chris Zankel | 9a8fd55 | 2005-06-23 22:01:26 -0700 | [diff] [blame] | 18 | #include <linux/mm.h> |
Jens Axboe | 8c7837c | 2007-10-24 13:28:40 +0200 | [diff] [blame] | 19 | #include <linux/scatterlist.h> |
Chris Zankel | 9a8fd55 | 2005-06-23 22:01:26 -0700 | [diff] [blame] | 20 | |
Max Filippov | 35b16a9 | 2012-11-01 18:38:27 +0400 | [diff] [blame] | 21 | #define DMA_ERROR_CODE (~(dma_addr_t)0x0) |
| 22 | |
Max Filippov | c75959a | 2015-05-25 06:55:05 +0300 | [diff] [blame] | 23 | extern struct dma_map_ops xtensa_dma_map_ops; |
Chris Zankel | 9a8fd55 | 2005-06-23 22:01:26 -0700 | [diff] [blame] | 24 | |
Max Filippov | c75959a | 2015-05-25 06:55:05 +0300 | [diff] [blame] | 25 | static inline struct dma_map_ops *get_dma_ops(struct device *dev) |
Chris Zankel | 9a8fd55 | 2005-06-23 22:01:26 -0700 | [diff] [blame] | 26 | { |
Max Filippov | c75959a | 2015-05-25 06:55:05 +0300 | [diff] [blame] | 27 | if (dev && dev->archdata.dma_ops) |
| 28 | return dev->archdata.dma_ops; |
| 29 | else |
| 30 | return &xtensa_dma_map_ops; |
Chris Zankel | 9a8fd55 | 2005-06-23 22:01:26 -0700 | [diff] [blame] | 31 | } |
| 32 | |
Max Filippov | c75959a | 2015-05-25 06:55:05 +0300 | [diff] [blame] | 33 | #include <asm-generic/dma-mapping-common.h> |
| 34 | |
Chris Zankel | 9a8fd55 | 2005-06-23 22:01:26 -0700 | [diff] [blame] | 35 | static inline int |
Chris Zankel | 9a8fd55 | 2005-06-23 22:01:26 -0700 | [diff] [blame] | 36 | dma_supported(struct device *dev, u64 mask) |
| 37 | { |
| 38 | return 1; |
| 39 | } |
| 40 | |
| 41 | static inline int |
| 42 | dma_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 Filippov | c75959a | 2015-05-25 06:55:05 +0300 | [diff] [blame] | 52 | void dma_cache_sync(struct device *dev, void *vaddr, size_t size, |
| 53 | enum dma_data_direction direction); |
Guenter Roeck | e74993a | 2015-05-04 15:30:47 -0700 | [diff] [blame] | 54 | |
Chris Zankel | 9a8fd55 | 2005-06-23 22:01:26 -0700 | [diff] [blame] | 55 | #endif /* _XTENSA_DMA_MAPPING_H */ |