blob: 2475c91adc98c69be42a889c914e46ffeb062baa [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>
11
John Keller175add12008-11-24 16:47:17 -060012#define ARCH_HAS_DMA_GET_REQUIRED_MASK
13
FUJITA Tomonori160c1d82009-01-05 23:59:02 +090014extern struct dma_map_ops *dma_ops;
Fenghua Yu62fdd762008-10-17 12:14:13 -070015extern struct ia64_machine_vector ia64_mv;
16extern void set_iommu_machvec(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070017
FUJITA Tomonoric2990302009-01-07 02:13:42 +090018extern void machvec_dma_sync_single(struct device *, dma_addr_t, size_t,
19 enum dma_data_direction);
20extern void machvec_dma_sync_sg(struct device *, struct scatterlist *, int,
21 enum dma_data_direction);
22
FUJITA Tomonorib7ea6e92009-01-05 23:36:13 +090023static inline void *dma_alloc_coherent(struct device *dev, size_t size,
24 dma_addr_t *daddr, gfp_t gfp)
25{
FUJITA Tomonori160c1d82009-01-05 23:59:02 +090026 struct dma_map_ops *ops = platform_dma_get_ops(dev);
Yasunori Goto0d688da2009-02-03 10:52:03 +090027 return ops->alloc_coherent(dev, size, daddr, gfp);
FUJITA Tomonorib7ea6e92009-01-05 23:36:13 +090028}
FUJITA Tomonori3a80b6a2008-09-08 18:10:10 +090029
FUJITA Tomonorib7ea6e92009-01-05 23:36:13 +090030static inline void dma_free_coherent(struct device *dev, size_t size,
31 void *caddr, dma_addr_t daddr)
Roland Dreierb7de8e72007-02-14 00:32:53 -080032{
FUJITA Tomonori160c1d82009-01-05 23:59:02 +090033 struct dma_map_ops *ops = platform_dma_get_ops(dev);
FUJITA Tomonoric190ab02009-01-05 23:36:16 +090034 ops->free_coherent(dev, size, caddr, daddr);
Roland Dreierb7de8e72007-02-14 00:32:53 -080035}
FUJITA Tomonorib7ea6e92009-01-05 23:36:13 +090036
37#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
38#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
39
FUJITA Tomonorid6d0a6a2009-06-17 16:28:13 -070040#define get_dma_ops(dev) platform_dma_get_ops(dev)
41#define flush_write_buffers()
FUJITA Tomonorib7ea6e92009-01-05 23:36:13 +090042
FUJITA Tomonorid6d0a6a2009-06-17 16:28:13 -070043#include <asm-generic/dma-mapping-common.h>
FUJITA Tomonorib7ea6e92009-01-05 23:36:13 +090044
45static inline int dma_mapping_error(struct device *dev, dma_addr_t daddr)
46{
FUJITA Tomonori160c1d82009-01-05 23:59:02 +090047 struct dma_map_ops *ops = platform_dma_get_ops(dev);
FUJITA Tomonoric190ab02009-01-05 23:36:16 +090048 return ops->mapping_error(dev, daddr);
FUJITA Tomonorib7ea6e92009-01-05 23:36:13 +090049}
Linus Torvalds1da177e2005-04-16 15:20:36 -070050
FUJITA Tomonorib7ea6e92009-01-05 23:36:13 +090051static inline int dma_supported(struct device *dev, u64 mask)
52{
FUJITA Tomonori160c1d82009-01-05 23:59:02 +090053 struct dma_map_ops *ops = platform_dma_get_ops(dev);
54 return ops->dma_supported(dev, mask);
FUJITA Tomonorib7ea6e92009-01-05 23:36:13 +090055}
Linus Torvalds1da177e2005-04-16 15:20:36 -070056
57static inline int
58dma_set_mask (struct device *dev, u64 mask)
59{
60 if (!dev->dma_mask || !dma_supported(dev, mask))
61 return -EIO;
62 *dev->dma_mask = mask;
63 return 0;
64}
65
John W. Linvillee1531b42005-11-07 00:57:54 -080066extern int dma_get_cache_alignment(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070067
68static inline void
Ralf Baechled3fa72e2006-12-06 20:38:56 -080069dma_cache_sync (struct device *dev, void *vaddr, size_t size,
70 enum dma_data_direction dir)
Linus Torvalds1da177e2005-04-16 15:20:36 -070071{
72 /*
73 * IA-64 is cache-coherent, so this is mostly a no-op. However, we do need to
74 * ensure that dma_cache_sync() enforces order, hence the mb().
75 */
76 mb();
77}
78
Ralf Baechlef67637e2006-12-06 20:38:54 -080079#define dma_is_consistent(d, h) (1) /* all we do is coherent memory... */
Linus Torvalds1da177e2005-04-16 15:20:36 -070080
Linus Torvalds1da177e2005-04-16 15:20:36 -070081#endif /* _ASM_IA64_DMA_MAPPING_H */