]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/plat-omap/dsp/dsp.h
48974ad271a0cf502c141b356bba625f2137d740
[linux-2.6-omap-h63xx.git] / arch / arm / plat-omap / dsp / dsp.h
1 /*
2  * linux/arch/arm/mach-omap/dsp/dsp.h
3  *
4  * Header for OMAP DSP driver
5  *
6  * Copyright (C) 2002-2005 Nokia Corporation
7  *
8  * Written by Toshihiro Kobayashi <toshihiro.kobayashi@nokia.com>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23  *
24  * 2005/06/09:  DSP Gateway version 3.3
25  */
26
27 #include "hardware_dsp.h"
28 #include "dsp_common.h"
29
30 #define OLD_BINARY_SUPPORT      y
31
32 #ifdef OLD_BINARY_SUPPORT
33 #define MBREV_3_0       0x0017
34 #define MBREV_3_2       0x0018
35 #endif
36
37 #define DSP_INIT_PAGE   0xfff000
38 /* idle program will be placed at IDLEPG_BASE. */
39 #define IDLEPG_BASE     0xfffe00
40 #define IDLEPG_SIZE     0x100
41
42 /* timeout value for DSP response */
43 #define DSP_TIMEOUT     (10 * HZ)
44
45 enum dsp_mem_type_e {
46         MEM_TYPE_CROSSING = -1,
47         MEM_TYPE_NONE = 0,
48         MEM_TYPE_DARAM,
49         MEM_TYPE_SARAM,
50         MEM_TYPE_EXTERN,
51 };
52
53 enum arm_dsp_dir {
54         DIR_A2D,
55         DIR_D2A,
56 };
57
58 /*
59  * INT_D2A_MB value definition
60  *   INT_DSP_MAILBOX1: use Mailbox 1 (INT 10) for DSP->ARM mailbox
61  *   INT_DSP_MAILBOX2: use Mailbox 2 (INT 11) for DSP->ARM mailbox
62  */
63 #define INT_D2A_MB1     INT_DSP_MAILBOX1
64
65 /* keep 2 entries for OMAP_DSP_TID_FREE and OMAP_DSP_TID_ANON */
66 #define TASKDEV_MAX     254
67
68 #define MKLONG(uw,lw)   (((unsigned long)(uw)) << 16 | (lw))
69 #define MKVIRT(uw,lw)   dspword_to_virt(MKLONG((uw), (lw)));
70 #define MBCMD(nm)       OMAP_DSP_MBCMD_##nm
71
72 struct sync_seq {
73         unsigned short da_dsp;
74         unsigned short da_arm;
75         unsigned short ad_dsp;
76         unsigned short ad_arm;
77 };
78
79 struct mem_sync_struct {
80         struct sync_seq *DARAM;
81         struct sync_seq *SARAM;
82         struct sync_seq *SDRAM;
83 };
84
85 /* struct mbcmd and struct mbcmd_hw must be compatible */
86 struct mbcmd {
87         unsigned short cmd_l:8;
88         unsigned short cmd_h:7;
89         unsigned short seq:1;
90         unsigned short data;
91 };
92
93 struct mbcmd_hw {
94         unsigned short cmd;
95         unsigned short data;
96 };
97
98 #define mbcmd_set(mb, h, l, d) \
99         do { \
100                 (mb).cmd_h = (h); \
101                 (mb).cmd_l = (l); \
102                 (mb).data  = (d); \
103         } while(0)
104
105 struct mb_exarg {
106         unsigned char tid;
107         int argc;
108         unsigned short *argv;
109 };
110
111 extern void dsp_mb_start(void);
112 extern void dsp_mb_stop(void);
113 extern int dsp_mb_config(void *p);
114 extern int sync_with_dsp(unsigned short *syncwd, unsigned short tid,
115                          int try_cnt);
116 extern int __mbcmd_send(struct mbcmd *mb);
117 extern int __dsp_mbcmd_send(struct mbcmd *mb, struct mb_exarg *arg,
118                             int recovery_flag);
119 #define dsp_mbcmd_send(mb)              __dsp_mbcmd_send(mb, NULL, 0)
120 #define dsp_mbcmd_send_exarg(mb, arg)   __dsp_mbcmd_send(mb, arg, 0)
121 extern int __dsp_mbcmd_send_and_wait(struct mbcmd *mb, struct mb_exarg *arg,
122                                      wait_queue_head_t *q);
123 #define dsp_mbcmd_send_and_wait(mb, q) \
124         __dsp_mbcmd_send_and_wait(mb, NULL, q)
125 #define dsp_mbcmd_send_and_wait_exarg(mb, arg, q) \
126         __dsp_mbcmd_send_and_wait(mb, arg, q)
127 int __dsp_mbsend(unsigned char cmdh, unsigned char cmdl, unsigned short data,
128                  int recovery_flag);
129 #define dsp_mbsend(cmdh, cmdl, data) \
130         __dsp_mbsend(cmdh, cmdl, data, 0)
131 #define dsp_mbsend_recovery(cmdh, cmdl, data) \
132         __dsp_mbsend(cmdh, cmdl, data, 1)
133
134 extern void ipbuf_start(void);
135 extern void ipbuf_stop(void);
136 extern int ipbuf_config(unsigned short ln, unsigned short lsz, void *base);
137 extern int ipbuf_sys_config(void *p, enum arm_dsp_dir dir);
138 extern int ipbuf_p_validate(void *p, enum arm_dsp_dir dir);
139 extern unsigned short get_free_ipbuf(unsigned char tid);
140 extern void unuse_ipbuf_nowait(unsigned short bid);
141 extern void unuse_ipbuf(unsigned short bid);
142 extern void release_ipbuf(unsigned short bid);
143 extern void balance_ipbuf(void);
144
145 #define release_ipbuf_pvt(ipbuf_pvt) \
146         do { \
147                 (ipbuf_pvt)->s = OMAP_DSP_TID_FREE; \
148         } while(0)
149
150 extern int mbx_revision;
151
152 extern int dsp_is_ready(void);
153 extern int dspuncfg(void);
154 extern void dsp_runlevel(unsigned char level);
155 extern int dsp_suspend(void);
156 extern int dsp_resume(void);
157
158 extern int dsp_task_config_all(unsigned char n);
159 extern void dsp_task_unconfig_all(void);
160 extern unsigned char dsp_task_count(void);
161 extern int dsp_taskmod_busy(void);
162 extern int dsp_mkdev(char *name);
163 extern int dsp_rmdev(char *name);
164 extern int dsp_tadd(unsigned char minor, unsigned long adr);
165 extern int dsp_tdel(unsigned char minor);
166 extern int dsp_tkill(unsigned char minor);
167 extern long taskdev_state_stale(unsigned char minor);
168 extern int dsp_dbg_config(short *buf, unsigned short sz, unsigned short lsz);
169 extern void dsp_dbg_stop(void);
170
171 extern int ipbuf_is_held(unsigned char tid, unsigned short bid);
172
173 extern int dsp_mem_sync_inc(void);
174 extern int dsp_mem_sync_config(struct mem_sync_struct *sync);
175 extern enum dsp_mem_type_e dsp_mem_type(void *vadr, size_t len);
176 extern int dsp_address_validate(void *p, size_t len, char *fmt, ...);
177 extern int dsp_mem_enable(void *adr);
178 extern void dsp_mem_disable(void *adr);
179 extern void dsp_mem_usecount_clear(void);
180 extern void exmap_use(void *vadr, size_t len);
181 extern void exmap_unuse(void *vadr, size_t len);
182 extern unsigned long dsp_virt_to_phys(void *vadr, size_t *len);
183 extern void dsp_mem_start(void);
184 extern void dsp_mem_stop(void);
185
186 extern void dsp_twch_start(void);
187 extern void dsp_twch_stop(void);
188 extern void dsp_twch_touch(void);
189
190 extern void dsp_err_start(void);
191 extern void dsp_err_stop(void);
192 extern void dsp_err_mmu_set(unsigned long adr);
193 extern void dsp_err_mmu_clear(void);
194 extern int dsp_err_mmu_isset(void);
195 extern void dsp_err_wdt_clear(void);
196 extern int dsp_err_wdt_isset(void);
197
198 enum cmd_l_type {
199         CMD_L_TYPE_NULL,
200         CMD_L_TYPE_TID,
201         CMD_L_TYPE_SUBCMD,
202 };
203
204 struct cmdinfo {
205         char *name;
206         enum cmd_l_type cmd_l_type;
207         void (*handler)(struct mbcmd *mb);
208 };
209
210 extern const struct cmdinfo *cmdinfo[];
211
212 #define cmd_name(mb)    (cmdinfo[(mb).cmd_h]->name)
213 extern char *subcmd_name(struct mbcmd *mb);
214
215 extern void mblog_add(struct mbcmd *mb, enum arm_dsp_dir dir);
216 #ifdef CONFIG_OMAP_DSP_MBCMD_VERBOSE
217 extern void mblog_printcmd(struct mbcmd *mb, enum arm_dsp_dir dir);
218 #else /* CONFIG_OMAP_DSP_MBCMD_VERBOSE */
219 #define mblog_printcmd(mb, dir) do {} while(0)
220 #endif /* CONFIG_OMAP_DSP_MBCMD_VERBOSE */
221
222 #ifdef CONFIG_PROC_FS
223 extern struct proc_dir_entry *procdir_dsp;
224 #endif /* CONFIG_PROC_FS */
225
226 extern struct platform_device dsp_device;