blob: 3ce5ab4339f310460a94db3565fd490c874e3f8b [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _ASM_IA64_DMA_MAPPING_H
2#define _ASM_IA64_DMA_MAPPING_H
3
4/*
5 * Copyright (C) 2003-2004 Hewlett-Packard Co
6 * David Mosberger-Tang <davidm@hpl.hp.com>
7 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07008#include <asm/machvec.h>
Jens Axboe9b6eccf2007-10-16 11:27:26 +02009#include <linux/scatterlist.h>
Fenghua Yu62fdd762008-10-17 12:14:13 -070010#include <asm/swiotlb.h>
FUJITA Tomonori99162192009-06-17 16:28:14 -070011#include <linux/dma-debug.h>
Fenghua Yu62fdd762008-10-17 12:14:13 -070012
John Keller175add12008-11-24 16:47:17 -060013#define ARCH_HAS_DMA_GET_REQUIRED_MASK
14
Bart Van Assche52997092017-01-20 13:04:01 -080015extern const struct dma_map_ops *dma_ops;
Fenghua Yu62fdd762008-10-17 12:14:13 -070016extern struct ia64_machine_vector ia64_mv;
17extern void set_iommu_machvec(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070018
FUJITA Tomonoric2990302009-01-07 02:13:42 +090019extern void machvec_dma_sync_single(struct device *, dma_addr_t, size_t,
20 enum dma_data_direction);
21extern void machvec_dma_sync_sg(struct device *, struct scatterlist *, int,
22 enum dma_data_direction);
23
Bart Van Assche815dd182017-01-20 13:04:04 -080024static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
25{
26 return platform_dma_get_ops(NULL);
27}
FUJITA Tomonorib7ea6e92009-01-05 23:36:13 +090028
FUJITA Tomonoria0b00ca2009-07-10 10:04:56 +090029static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
30{
31 if (!dev->dma_mask)
32 return 0;
33
Jan Beulichac2b3e62009-12-15 16:47:43 -080034 return addr + size - 1 <= *dev->dma_mask;
FUJITA Tomonoria0b00ca2009-07-10 10:04:56 +090035}
36
FUJITA Tomonori8d4f5332009-07-10 10:05:01 +090037static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr)
38{
39 return paddr;
40}
41
42static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr)
43{
44 return daddr;
45}
46
Linus Torvalds1da177e2005-04-16 15:20:36 -070047static inline void
Ralf Baechled3fa72e2006-12-06 20:38:56 -080048dma_cache_sync (struct device *dev, void *vaddr, size_t size,
49 enum dma_data_direction dir)
Linus Torvalds1da177e2005-04-16 15:20:36 -070050{
51 /*
52 * IA-64 is cache-coherent, so this is mostly a no-op. However, we do need to
53 * ensure that dma_cache_sync() enforces order, hence the mb().
54 */
55 mb();
56}
57
Linus Torvalds1da177e2005-04-16 15:20:36 -070058#endif /* _ASM_IA64_DMA_MAPPING_H */