~ubuntu-branches/ubuntu/saucy/linux-ti-omap4/saucy-proposed

« back to all changes in this revision

Viewing changes to arch/openrisc/include/asm/dma-mapping.h

  • Committer: Package Import Robot
  • Author(s): Paolo Pisati, Paolo Pisati, Stefan Bader, Upstream Kernel Changes
  • Date: 2012-08-15 17:17:43 UTC
  • Revision ID: package-import@ubuntu.com-20120815171743-h5wnuf51xe7pvdid
Tags: 3.5.0-207.13
[ Paolo Pisati ]

* Start new release

[ Stefan Bader ]

* (config) Enable getabis to use local package copies

[ Upstream Kernel Changes ]

* fixup: gargabe collect iva_seq[0|1] init
* [Config] enable all SND_OMAP_SOC_*s
* fixup: cm2xxx_3xxx.o is needed for omap2_cm_read|write_reg
* fixup: add some snd_soc_dai* helper functions
* fixup: s/snd_soc_dpcm_params/snd_soc_dpcm/g
* fixup: typo, no_host_mode and useless SDP4430 init
* fixup: enable again aess hwmod

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
/*
21
21
 * See Documentation/DMA-API-HOWTO.txt and
22
22
 * Documentation/DMA-API.txt for documentation.
23
 
 *
24
 
 * This file is written with the intention of eventually moving over
25
 
 * to largely using asm-generic/dma-mapping-common.h in its place.
26
23
 */
27
24
 
28
25
#include <linux/dma-debug.h>
29
26
#include <asm-generic/dma-coherent.h>
30
27
#include <linux/kmemcheck.h>
 
28
#include <linux/dma-mapping.h>
31
29
 
32
30
#define DMA_ERROR_CODE          (~(dma_addr_t)0x0)
33
31
 
34
 
 
35
 
#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
36
 
#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
37
 
 
38
 
void *or1k_dma_alloc_coherent(struct device *dev, size_t size,
39
 
                              dma_addr_t *dma_handle, gfp_t flag);
40
 
void or1k_dma_free_coherent(struct device *dev, size_t size, void *vaddr,
41
 
                            dma_addr_t dma_handle);
42
 
dma_addr_t or1k_map_page(struct device *dev, struct page *page,
43
 
                         unsigned long offset, size_t size,
44
 
                         enum dma_data_direction dir,
45
 
                         struct dma_attrs *attrs);
46
 
void or1k_unmap_page(struct device *dev, dma_addr_t dma_handle,
47
 
                     size_t size, enum dma_data_direction dir,
48
 
                     struct dma_attrs *attrs);
49
 
int or1k_map_sg(struct device *dev, struct scatterlist *sg,
50
 
                int nents, enum dma_data_direction dir,
51
 
                struct dma_attrs *attrs);
52
 
void or1k_unmap_sg(struct device *dev, struct scatterlist *sg,
53
 
                   int nents, enum dma_data_direction dir,
54
 
                   struct dma_attrs *attrs);
55
 
void or1k_sync_single_for_cpu(struct device *dev,
56
 
                              dma_addr_t dma_handle, size_t size,
57
 
                              enum dma_data_direction dir);
58
 
void or1k_sync_single_for_device(struct device *dev,
59
 
                                 dma_addr_t dma_handle, size_t size,
60
 
                                 enum dma_data_direction dir);
61
 
 
62
 
static inline void *dma_alloc_coherent(struct device *dev, size_t size,
63
 
                                        dma_addr_t *dma_handle, gfp_t flag)
64
 
{
 
32
extern struct dma_map_ops or1k_dma_map_ops;
 
33
 
 
34
static inline struct dma_map_ops *get_dma_ops(struct device *dev)
 
35
{
 
36
        return &or1k_dma_map_ops;
 
37
}
 
38
 
 
39
#include <asm-generic/dma-mapping-common.h>
 
40
 
 
41
#define dma_alloc_coherent(d,s,h,f) dma_alloc_attrs(d,s,h,f,NULL) 
 
42
 
 
43
static inline void *dma_alloc_attrs(struct device *dev, size_t size,
 
44
                                    dma_addr_t *dma_handle, gfp_t gfp,
 
45
                                    struct dma_attrs *attrs)
 
46
{
 
47
        struct dma_map_ops *ops = get_dma_ops(dev);
65
48
        void *memory;
66
49
 
67
 
        memory = or1k_dma_alloc_coherent(dev, size, dma_handle, flag);
 
50
        memory = ops->alloc(dev, size, dma_handle, gfp, attrs);
68
51
 
69
52
        debug_dma_alloc_coherent(dev, size, *dma_handle, memory);
 
53
 
70
54
        return memory;
71
55
}
72
56
 
73
 
static inline void dma_free_coherent(struct device *dev, size_t size,
74
 
                                     void *cpu_addr, dma_addr_t dma_handle)
 
57
#define dma_free_coherent(d,s,c,h) dma_free_attrs(d,s,c,h,NULL)
 
58
 
 
59
static inline void dma_free_attrs(struct device *dev, size_t size,
 
60
                                  void *cpu_addr, dma_addr_t dma_handle,
 
61
                                  struct dma_attrs *attrs)
75
62
{
 
63
        struct dma_map_ops *ops = get_dma_ops(dev);
 
64
 
76
65
        debug_dma_free_coherent(dev, size, cpu_addr, dma_handle);
77
 
        or1k_dma_free_coherent(dev, size, cpu_addr, dma_handle);
78
 
}
79
 
 
80
 
static inline dma_addr_t dma_map_single(struct device *dev, void *ptr,
81
 
                                        size_t size,
82
 
                                        enum dma_data_direction dir)
83
 
{
84
 
        dma_addr_t addr;
85
 
 
86
 
        kmemcheck_mark_initialized(ptr, size);
87
 
        BUG_ON(!valid_dma_direction(dir));
88
 
        addr = or1k_map_page(dev, virt_to_page(ptr),
89
 
                             (unsigned long)ptr & ~PAGE_MASK, size,
90
 
                             dir, NULL);
91
 
        debug_dma_map_page(dev, virt_to_page(ptr),
92
 
                           (unsigned long)ptr & ~PAGE_MASK, size,
93
 
                           dir, addr, true);
94
 
        return addr;
95
 
}
96
 
 
97
 
static inline void dma_unmap_single(struct device *dev, dma_addr_t addr,
98
 
                                          size_t size,
99
 
                                          enum dma_data_direction dir)
100
 
{
101
 
        BUG_ON(!valid_dma_direction(dir));
102
 
        or1k_unmap_page(dev, addr, size, dir, NULL);
103
 
        debug_dma_unmap_page(dev, addr, size, dir, true);
104
 
}
105
 
 
106
 
static inline int dma_map_sg(struct device *dev, struct scatterlist *sg,
107
 
                                   int nents, enum dma_data_direction dir)
108
 
{
109
 
        int i, ents;
110
 
        struct scatterlist *s;
111
 
 
112
 
        for_each_sg(sg, s, nents, i)
113
 
                kmemcheck_mark_initialized(sg_virt(s), s->length);
114
 
        BUG_ON(!valid_dma_direction(dir));
115
 
        ents = or1k_map_sg(dev, sg, nents, dir, NULL);
116
 
        debug_dma_map_sg(dev, sg, nents, ents, dir);
117
 
 
118
 
        return ents;
119
 
}
120
 
 
121
 
static inline void dma_unmap_sg(struct device *dev, struct scatterlist *sg,
122
 
                                      int nents, enum dma_data_direction dir)
123
 
{
124
 
        BUG_ON(!valid_dma_direction(dir));
125
 
        debug_dma_unmap_sg(dev, sg, nents, dir);
126
 
        or1k_unmap_sg(dev, sg, nents, dir, NULL);
127
 
}
128
 
 
129
 
static inline dma_addr_t dma_map_page(struct device *dev, struct page *page,
130
 
                                      size_t offset, size_t size,
131
 
                                      enum dma_data_direction dir)
132
 
{
133
 
        dma_addr_t addr;
134
 
 
135
 
        kmemcheck_mark_initialized(page_address(page) + offset, size);
136
 
        BUG_ON(!valid_dma_direction(dir));
137
 
        addr = or1k_map_page(dev, page, offset, size, dir, NULL);
138
 
        debug_dma_map_page(dev, page, offset, size, dir, addr, false);
139
 
 
140
 
        return addr;
141
 
}
142
 
 
143
 
static inline void dma_unmap_page(struct device *dev, dma_addr_t addr,
144
 
                                  size_t size, enum dma_data_direction dir)
145
 
{
146
 
        BUG_ON(!valid_dma_direction(dir));
147
 
        or1k_unmap_page(dev, addr, size, dir, NULL);
148
 
        debug_dma_unmap_page(dev, addr, size, dir, true);
149
 
}
150
 
 
151
 
static inline void dma_sync_single_for_cpu(struct device *dev, dma_addr_t addr,
152
 
                                           size_t size,
153
 
                                           enum dma_data_direction dir)
154
 
{
155
 
        BUG_ON(!valid_dma_direction(dir));
156
 
        or1k_sync_single_for_cpu(dev, addr, size, dir);
157
 
        debug_dma_sync_single_for_cpu(dev, addr, size, dir);
158
 
}
159
 
 
160
 
static inline void dma_sync_single_for_device(struct device *dev,
161
 
                                              dma_addr_t addr, size_t size,
162
 
                                              enum dma_data_direction dir)
163
 
{
164
 
        BUG_ON(!valid_dma_direction(dir));
165
 
        or1k_sync_single_for_device(dev, addr, size, dir);
166
 
        debug_dma_sync_single_for_device(dev, addr, size, dir);
 
66
 
 
67
        ops->free(dev, size, cpu_addr, dma_handle, attrs);
 
68
}
 
69
 
 
70
static inline void *dma_alloc_noncoherent(struct device *dev, size_t size,
 
71
                                          dma_addr_t *dma_handle, gfp_t gfp)
 
72
{
 
73
        struct dma_attrs attrs;
 
74
 
 
75
        dma_set_attr(DMA_ATTR_NON_CONSISTENT, &attrs);
 
76
 
 
77
        return dma_alloc_attrs(dev, size, dma_handle, gfp, &attrs);
 
78
}
 
79
 
 
80
static inline void dma_free_noncoherent(struct device *dev, size_t size,
 
81
                                         void *cpu_addr, dma_addr_t dma_handle)
 
82
{
 
83
        struct dma_attrs attrs;
 
84
 
 
85
        dma_set_attr(DMA_ATTR_NON_CONSISTENT, &attrs);
 
86
 
 
87
        dma_free_attrs(dev, size, cpu_addr, dma_handle, &attrs);
167
88
}
168
89
 
169
90
static inline int dma_supported(struct device *dev, u64 dma_mask)