OpenCores
URL https://opencores.org/ocsvn/test_project/test_project/trunk

Subversion Repositories test_project

[/] [test_project/] [trunk/] [linux_sd_driver/] [include/] [linux/] [dma-mapping.h] - Blame information for rev 81

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 62 marcus.erl
#ifndef _ASM_LINUX_DMA_MAPPING_H
2
#define _ASM_LINUX_DMA_MAPPING_H
3
 
4
#include <linux/device.h>
5
#include <linux/err.h>
6
 
7 81 tac2
 
8
 #include <linux/scatterlist.h>
9
 
10 62 marcus.erl
/* These definitions mirror those in pci.h, so they can be used
11
 * interchangeably with their PCI_ counterparts */
12
enum dma_data_direction {
13
        DMA_BIDIRECTIONAL = 0,
14
        DMA_TO_DEVICE = 1,
15
        DMA_FROM_DEVICE = 2,
16
        DMA_NONE = 3,
17
};
18
 
19
#define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
20
 
21
/*
22
 * NOTE: do not use the below macros in new code and do not add new definitions
23
 * here.
24
 *
25
 * Instead, just open-code DMA_BIT_MASK(n) within your driver
26
 */
27
#define DMA_64BIT_MASK  DMA_BIT_MASK(64)
28
#define DMA_48BIT_MASK  DMA_BIT_MASK(48)
29
#define DMA_47BIT_MASK  DMA_BIT_MASK(47)
30
#define DMA_40BIT_MASK  DMA_BIT_MASK(40)
31
#define DMA_39BIT_MASK  DMA_BIT_MASK(39)
32
#define DMA_35BIT_MASK  DMA_BIT_MASK(35)
33
#define DMA_32BIT_MASK  DMA_BIT_MASK(32)
34
#define DMA_31BIT_MASK  DMA_BIT_MASK(31)
35
#define DMA_30BIT_MASK  DMA_BIT_MASK(30)
36
#define DMA_29BIT_MASK  DMA_BIT_MASK(29)
37
#define DMA_28BIT_MASK  DMA_BIT_MASK(28)
38
#define DMA_24BIT_MASK  DMA_BIT_MASK(24)
39
 
40
#define DMA_MASK_NONE   0x0ULL
41
 
42
static inline int valid_dma_direction(int dma_direction)
43
{
44
        return ((dma_direction == DMA_BIDIRECTIONAL) ||
45
                (dma_direction == DMA_TO_DEVICE) ||
46
                (dma_direction == DMA_FROM_DEVICE));
47
}
48
 
49
static inline int is_device_dma_capable(struct device *dev)
50
{
51
        return dev->dma_mask != NULL && *dev->dma_mask != DMA_MASK_NONE;
52
}
53
 
54
#ifdef CONFIG_HAS_DMA
55
#include <asm/dma-mapping.h>
56
#else
57
#include <asm-generic/dma-mapping-broken.h>
58
#endif
59
 
60
/* Backwards compat, remove in 2.7.x */
61
#define dma_sync_single         dma_sync_single_for_cpu
62
#define dma_sync_sg             dma_sync_sg_for_cpu
63
 
64
extern u64 dma_get_required_mask(struct device *dev);
65
 
66
/* flags for the coherent memory api */
67
#define DMA_MEMORY_MAP                  0x01
68
#define DMA_MEMORY_IO                   0x02
69
#define DMA_MEMORY_INCLUDES_CHILDREN    0x04
70
#define DMA_MEMORY_EXCLUSIVE            0x08
71
 
72
#ifndef ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY
73
static inline int
74
dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
75
                            dma_addr_t device_addr, size_t size, int flags)
76
{
77
        return 0;
78
}
79
 
80
static inline void
81
dma_release_declared_memory(struct device *dev)
82
{
83
}
84
 
85
static inline void *
86
dma_mark_declared_memory_occupied(struct device *dev,
87
                                  dma_addr_t device_addr, size_t size)
88
{
89
        return ERR_PTR(-EBUSY);
90
}
91
#endif
92
 
93
/*
94
 * Managed DMA API
95
 */
96
extern void *dmam_alloc_coherent(struct device *dev, size_t size,
97
                                 dma_addr_t *dma_handle, gfp_t gfp);
98
extern void dmam_free_coherent(struct device *dev, size_t size, void *vaddr,
99
                               dma_addr_t dma_handle);
100
extern void *dmam_alloc_noncoherent(struct device *dev, size_t size,
101
                                    dma_addr_t *dma_handle, gfp_t gfp);
102
extern void dmam_free_noncoherent(struct device *dev, size_t size, void *vaddr,
103
                                  dma_addr_t dma_handle);
104
#ifdef ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY
105
extern int dmam_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
106
                                        dma_addr_t device_addr, size_t size,
107
                                        int flags);
108
extern void dmam_release_declared_memory(struct device *dev);
109
#else /* ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY */
110
static inline int dmam_declare_coherent_memory(struct device *dev,
111
                                dma_addr_t bus_addr, dma_addr_t device_addr,
112
                                size_t size, gfp_t gfp)
113
{
114
        return 0;
115
}
116
 
117
static inline void dmam_release_declared_memory(struct device *dev)
118
{
119
}
120
#endif /* ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY */
121
 
122
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.