GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / arch / arm / plat-stmp3xxx / include / mach / dma.h
blob7c58557c67660c809ae0095e9e2c6f466d3a71b5
1 /*
2 * Freescale STMP37XX/STMP378X DMA helper interface
4 * Embedded Alley Solutions, Inc <source@embeddedalley.com>
6 * Copyright 2008 Freescale Semiconductor, Inc. All Rights Reserved.
7 * Copyright 2008 Embedded Alley Solutions, Inc All Rights Reserved.
8 */
11 * The code contained herein is licensed under the GNU General Public
12 * License. You may obtain a copy of the GNU General Public License
13 * Version 2 or later at the following locations:
15 * http://www.opensource.org/licenses/gpl-license.html
16 * http://www.gnu.org/copyleft/gpl.html
18 #ifndef __ASM_PLAT_STMP3XXX_DMA_H
19 #define __ASM_PLAT_STMP3XXX_DMA_H
21 #include <linux/platform_device.h>
22 #include <linux/dmapool.h>
24 #if !defined(MAX_PIO_WORDS)
25 #define MAX_PIO_WORDS (15)
26 #endif
28 #define STMP3XXX_BUS_APBH 0
29 #define STMP3XXX_BUS_APBX 1
30 #define STMP3XXX_DMA_MAX_CHANNEL 16
31 #define STMP3XXX_DMA_BUS(dma) ((dma) / 16)
32 #define STMP3XXX_DMA_CHANNEL(dma) ((dma) % 16)
33 #define STMP3XXX_DMA(channel, bus) ((bus) * 16 + (channel))
34 #define MAX_DMA_ADDRESS 0xffffffff
35 #define MAX_DMA_CHANNELS 32
37 struct stmp3xxx_dma_command {
38 u32 next;
39 u32 cmd;
40 union {
41 u32 buf_ptr;
42 u32 alternate;
44 u32 pio_words[MAX_PIO_WORDS];
47 struct stmp3xxx_dma_descriptor {
48 struct stmp3xxx_dma_command *command;
49 dma_addr_t handle;
51 /* The virtual address of the buffer pointer */
52 void *virtual_buf_ptr;
53 /* The next descriptor in a the DMA chain (optional) */
54 struct stmp3xxx_dma_descriptor *next_descr;
57 struct stmp37xx_circ_dma_chain {
58 unsigned total_count;
59 struct stmp3xxx_dma_descriptor *chain;
61 unsigned free_index;
62 unsigned free_count;
63 unsigned active_index;
64 unsigned active_count;
65 unsigned cooked_index;
66 unsigned cooked_count;
68 int bus;
69 unsigned channel;
72 static inline struct stmp3xxx_dma_descriptor
73 *stmp3xxx_dma_circ_get_free_head(struct stmp37xx_circ_dma_chain *chain)
75 return &(chain->chain[chain->free_index]);
78 static inline struct stmp3xxx_dma_descriptor
79 *stmp3xxx_dma_circ_get_cooked_head(struct stmp37xx_circ_dma_chain *chain)
81 return &(chain->chain[chain->cooked_index]);
84 int stmp3xxx_dma_request(int ch, struct device *dev, const char *name);
85 int stmp3xxx_dma_release(int ch);
86 int stmp3xxx_dma_allocate_command(int ch,
87 struct stmp3xxx_dma_descriptor *descriptor);
88 int stmp3xxx_dma_free_command(int ch,
89 struct stmp3xxx_dma_descriptor *descriptor);
90 void stmp3xxx_dma_continue(int channel, u32 semaphore);
91 void stmp3xxx_dma_go(int ch, struct stmp3xxx_dma_descriptor *head,
92 u32 semaphore);
93 int stmp3xxx_dma_running(int ch);
94 int stmp3xxx_dma_make_chain(int ch, struct stmp37xx_circ_dma_chain *chain,
95 struct stmp3xxx_dma_descriptor descriptors[],
96 unsigned items);
97 void stmp3xxx_dma_free_chain(struct stmp37xx_circ_dma_chain *chain);
98 void stmp37xx_circ_clear_chain(struct stmp37xx_circ_dma_chain *chain);
99 void stmp37xx_circ_advance_free(struct stmp37xx_circ_dma_chain *chain,
100 unsigned count);
101 void stmp37xx_circ_advance_active(struct stmp37xx_circ_dma_chain *chain,
102 unsigned count);
103 unsigned stmp37xx_circ_advance_cooked(struct stmp37xx_circ_dma_chain *chain);
104 int stmp3xxx_dma_read_semaphore(int ch);
105 void stmp3xxx_dma_init(void);
106 void stmp3xxx_dma_set_alt_target(int ch, int target);
107 void stmp3xxx_dma_suspend(void);
108 void stmp3xxx_dma_resume(void);
111 * STMP37xx and STMP378x have different DMA control
112 * registers layout
115 void stmp3xxx_arch_dma_freeze(int ch);
116 void stmp3xxx_arch_dma_unfreeze(int ch);
117 void stmp3xxx_arch_dma_reset_channel(int ch);
118 void stmp3xxx_arch_dma_enable_interrupt(int ch);
119 void stmp3xxx_arch_dma_clear_interrupt(int ch);
120 int stmp3xxx_arch_dma_is_interrupt(int ch);
122 static inline void stmp3xxx_dma_reset_channel(int ch)
124 stmp3xxx_arch_dma_reset_channel(ch);
128 static inline void stmp3xxx_dma_freeze(int ch)
130 stmp3xxx_arch_dma_freeze(ch);
133 static inline void stmp3xxx_dma_unfreeze(int ch)
135 stmp3xxx_arch_dma_unfreeze(ch);
138 static inline void stmp3xxx_dma_enable_interrupt(int ch)
140 stmp3xxx_arch_dma_enable_interrupt(ch);
143 static inline void stmp3xxx_dma_clear_interrupt(int ch)
145 stmp3xxx_arch_dma_clear_interrupt(ch);
148 static inline int stmp3xxx_dma_is_interrupt(int ch)
150 return stmp3xxx_arch_dma_is_interrupt(ch);
153 #endif /* __ASM_PLAT_STMP3XXX_DMA_H */