]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/plat-omap/dsp/dsp.h
a5512dbbc5be80ed23110858dbb0542c45b97805
[linux-2.6-omap-h63xx.git] / arch / arm / plat-omap / dsp / dsp.h
1 /*
2  * This file is part of OMAP DSP driver (DSP Gateway version 3.3.1)
3  *
4  * Copyright (C) 2002-2006 Nokia Corporation. All rights reserved.
5  *
6  * Contact: Toshihiro Kobayashi <toshihiro.kobayashi@nokia.com>
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * version 2 as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20  * 02110-1301 USA
21  *
22  */
23
24 #ifndef __PLAT_OMAP_DSP_DSP_H
25 #define __PLAT_OMAP_DSP_DSP_H
26
27 #include "hardware_dsp.h"
28 #include "dsp_common.h"
29 #include <asm/arch/mmu.h>
30
31 /*
32  * MAJOR device number: !! allocated arbitrary !!
33  */
34 #define OMAP_DSP_CTL_MAJOR              96
35 #define OMAP_DSP_TASK_MAJOR             97
36
37 #define OLD_BINARY_SUPPORT      y
38
39 #ifdef OLD_BINARY_SUPPORT
40 #define MBREV_3_0       0x0017
41 #define MBREV_3_2       0x0018
42 #endif
43
44 #define DSP_INIT_PAGE   0xfff000
45
46 #ifdef CONFIG_ARCH_OMAP1
47 /* idle program will be placed at IDLEPG_BASE. */
48 #define IDLEPG_BASE     0xfffe00
49 #define IDLEPG_SIZE     0x100
50 #endif /* CONFIG_ARCH_OMAP1 */
51
52 /* timeout value for DSP response */
53 #define DSP_TIMEOUT     (10 * HZ)
54
55 enum dsp_mem_type_e {
56         MEM_TYPE_CROSSING = -1,
57         MEM_TYPE_NONE = 0,
58         MEM_TYPE_DARAM,
59         MEM_TYPE_SARAM,
60         MEM_TYPE_EXTERN,
61 };
62
63
64 typedef int __bitwise arm_dsp_dir_t;
65 #define DIR_A2D ((__force arm_dsp_dir_t) 1)
66 #define DIR_D2A ((__force arm_dsp_dir_t) 2)
67
68 enum cfgstat_e {
69         CFGSTAT_CLEAN = 0,
70         CFGSTAT_READY,
71         CFGSTAT_SUSPEND,
72         CFGSTAT_RESUME, /* request only */
73         CFGSTAT_MAX
74 };
75
76 enum errcode_e {
77         ERRCODE_WDT = 0,
78         ERRCODE_MMU,
79         ERRCODE_MAX
80 };
81
82 /* keep 2 entries for TID_FREE and TID_ANON */
83 #define TASKDEV_MAX     254
84
85 #define MK32(uw,lw)     (((u32)(uw)) << 16 | (lw))
86 #define MKLONG(uw,lw)   (((unsigned long)(uw)) << 16 | (lw))
87 #define MKVIRT(uw,lw)   dspword_to_virt(MKLONG((uw), (lw)));
88
89 struct sync_seq {
90         u16 da_dsp;
91         u16 da_arm;
92         u16 ad_dsp;
93         u16 ad_arm;
94 };
95
96 struct mem_sync_struct {
97         struct sync_seq *DARAM;
98         struct sync_seq *SARAM;
99         struct sync_seq *SDRAM;
100 };
101
102 /* struct mbcmd and union mbcmd_hw must be compatible */
103 struct mbcmd {
104         u32 data:16;
105         u32 cmd_l:8;
106         u32 cmd_h:7;
107         u32 seq:1;
108 };
109
110 #define MBCMD_INIT(h, l, d) { \
111                 .cmd_h = (h), \
112                 .cmd_l = (l), \
113                 .data  = (d), \
114         }
115
116 struct mb_exarg {
117         u8 tid;
118         int argc;
119         u16 *argv;
120 };
121
122 extern void dsp_mbox_start(void);
123 extern void dsp_mbox_stop(void);
124 extern int dsp_mbox_config(void *p);
125 extern int sync_with_dsp(u16 *syncwd, u16 tid, int try_cnt);
126 extern int __dsp_mbcmd_send_exarg(struct mbcmd *mb, struct mb_exarg *arg,
127                                   int recovery_flag);
128 #define dsp_mbcmd_send(mb)              __dsp_mbcmd_send_exarg((mb), NULL, 0)
129 #define dsp_mbcmd_send_exarg(mb, arg)   __dsp_mbcmd_send_exarg((mb), (arg), 0)
130 extern int dsp_mbcmd_send_and_wait_exarg(struct mbcmd *mb, struct mb_exarg *arg,
131                                          wait_queue_head_t *q);
132 #define dsp_mbcmd_send_and_wait(mb, q) \
133         dsp_mbcmd_send_and_wait_exarg((mb), NULL, (q))
134
135 static inline int __mbcompose_send_exarg(u8 cmd_h, u8 cmd_l, u16 data,
136                                              struct mb_exarg *arg,
137                                              int recovery_flag)
138 {
139         struct mbcmd mb = MBCMD_INIT(cmd_h, cmd_l, data);
140         return __dsp_mbcmd_send_exarg(&mb, arg, recovery_flag);
141 }
142 #define mbcompose_send(cmd_h, cmd_l, data) \
143         __mbcompose_send_exarg(MBOX_CMD_DSP_##cmd_h, (cmd_l), (data), NULL, 0)
144 #define mbcompose_send_exarg(cmd_h, cmd_l, data, arg) \
145         __mbcompose_send_exarg(MBOX_CMD_DSP_##cmd_h, (cmd_l), (data), arg, 0)
146 #define mbcompose_send_recovery(cmd_h, cmd_l, data) \
147         __mbcompose_send_exarg(MBOX_CMD_DSP_##cmd_h, (cmd_l), (data), NULL, 1)
148
149 static inline int __mbcompose_send_and_wait_exarg(u8 cmd_h, u8 cmd_l,
150                                                       u16 data,
151                                                       struct mb_exarg *arg,
152                                                       wait_queue_head_t *q)
153 {
154         struct mbcmd mb = MBCMD_INIT(cmd_h, cmd_l, data);
155         return dsp_mbcmd_send_and_wait_exarg(&mb, arg, q);
156 }
157 #define mbcompose_send_and_wait(cmd_h, cmd_l, data, q) \
158         __mbcompose_send_and_wait_exarg(MBOX_CMD_DSP_##cmd_h, (cmd_l), (data), \
159                                         NULL, (q))
160 #define mbcompose_send_and_wait_exarg(cmd_h, cmd_l, data, arg, q) \
161         __mbcompose_send_and_wait_exarg(MBOX_CMD_DSP_##cmd_h, (cmd_l), (data), \
162                                         (arg), (q))
163
164 extern struct ipbuf_head *bid_to_ipbuf(u16 bid);
165 extern void ipbuf_start(void);
166 extern void ipbuf_stop(void);
167 extern int ipbuf_config(u16 ln, u16 lsz, void *base);
168 extern int ipbuf_sys_config(void *p, arm_dsp_dir_t dir);
169 extern int ipbuf_p_validate(void *p, arm_dsp_dir_t dir);
170 extern struct ipbuf_head *get_free_ipbuf(u8 tid);
171 extern void release_ipbuf(struct ipbuf_head *ipb_h);
172 extern void balance_ipbuf(void);
173 extern void unuse_ipbuf(struct ipbuf_head *ipb_h);
174 extern void unuse_ipbuf_nowait(struct ipbuf_head *ipb_h);
175
176 #define release_ipbuf_pvt(ipbuf_pvt) \
177         do { \
178                 (ipbuf_pvt)->s = TID_FREE; \
179         } while(0)
180
181 extern int mbox_revision;
182
183 extern int dsp_cfgstat_request(enum cfgstat_e st);
184 extern enum cfgstat_e dsp_cfgstat_get_stat(void);
185 extern int dsp_set_runlevel(u8 level);
186
187 extern int dsp_task_config_all(u8 n);
188 extern void dsp_task_unconfig_all(void);
189 extern u8 dsp_task_count(void);
190 extern int dsp_taskmod_busy(void);
191 extern int dsp_mkdev(char *name);
192 extern int dsp_rmdev(char *name);
193 extern int dsp_tadd_minor(unsigned char minor, dsp_long_t adr);
194 extern int dsp_tdel_minor(unsigned char minor);
195 extern int dsp_tkill_minor(unsigned char minor);
196 extern long taskdev_state_stale(unsigned char minor);
197 extern int dsp_dbg_config(u16 *buf, u16 sz, u16 lsz);
198 extern void dsp_dbg_stop(void);
199
200 extern int ipbuf_is_held(u8 tid, u16 bid);
201
202 extern int dsp_mem_sync_inc(void);
203 extern int dsp_mem_sync_config(struct mem_sync_struct *sync);
204 extern enum dsp_mem_type_e dsp_mem_type(void *vadr, size_t len);
205 extern int dsp_address_validate(void *p, size_t len, char *fmt, ...);
206 #ifdef CONFIG_ARCH_OMAP1
207 extern void dsp_mem_usecount_clear(void);
208 #endif
209 extern void exmap_use(void *vadr, size_t len);
210 extern void exmap_unuse(void *vadr, size_t len);
211 extern unsigned long dsp_virt_to_phys(void *vadr, size_t *len);
212 extern void dsp_mem_start(void);
213 extern void dsp_mem_stop(void);
214
215 extern void dsp_twch_start(void);
216 extern void dsp_twch_stop(void);
217 extern void dsp_twch_touch(void);
218
219 extern void dsp_err_start(void);
220 extern void dsp_err_stop(void);
221 extern void dsp_err_set(enum errcode_e code, unsigned long arg);
222 extern void dsp_err_clear(enum errcode_e code);
223 extern int dsp_err_isset(enum errcode_e code);
224
225 enum cmd_l_type_e {
226         CMD_L_TYPE_NULL,
227         CMD_L_TYPE_TID,
228         CMD_L_TYPE_SUBCMD,
229 };
230
231 struct cmdinfo {
232         char *name;
233         enum cmd_l_type_e cmd_l_type;
234         void (*handler)(struct mbcmd *mb);
235 };
236
237 extern const struct cmdinfo *cmdinfo[];
238
239 #define cmd_name(mb)    (cmdinfo[(mb).cmd_h]->name)
240 extern char *subcmd_name(struct mbcmd *mb);
241
242 extern void mblog_add(struct mbcmd *mb, arm_dsp_dir_t dir);
243
244 extern struct omap_mmu dsp_mmu;
245
246 #define dsp_mem_enable(addr)    omap_mmu_mem_enable(&dsp_mmu, (addr))
247 #define dsp_mem_disable(addr)   omap_mmu_mem_disable(&dsp_mmu, (addr))
248
249 #endif /* __PLAT_OMAP_DSP_DSP_H */