staging: ti dspbridge: deh: remove err_info
[pandora-kernel.git] / drivers / staging / tidspbridge / include / dspbridge / dbdefs.h
1 /*
2  * dbdefs.h
3  *
4  * DSP-BIOS Bridge driver support functions for TI OMAP processors.
5  *
6  * Global definitions and constants for DSP/BIOS Bridge.
7  *
8  * Copyright (C) 2005-2006 Texas Instruments, Inc.
9  *
10  * This package is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License version 2 as
12  * published by the Free Software Foundation.
13  *
14  * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
15  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
16  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17  */
18
19 #ifndef DBDEFS_
20 #define DBDEFS_
21
22 #include <linux/types.h>
23
24 #include <dspbridge/dbtype.h>   /* GPP side type definitions */
25 #include <dspbridge/std.h>      /* DSP/BIOS type definitions */
26 #include <dspbridge/rms_sh.h>   /* Types shared between GPP and DSP */
27
28 #define PG_SIZE4K 4096
29 #define PG_MASK(pg_size) (~((pg_size)-1))
30 #define PG_ALIGN_LOW(addr, pg_size) ((addr) & PG_MASK(pg_size))
31 #define PG_ALIGN_HIGH(addr, pg_size) (((addr)+(pg_size)-1) & PG_MASK(pg_size))
32
33 /* API return value and calling convention */
34 #define DBAPI                       int
35
36 /* Infinite time value for the utimeout parameter to DSPStream_Select() */
37 #define DSP_FOREVER                 (-1)
38
39 /* Maximum length of node name, used in dsp_ndbprops */
40 #define DSP_MAXNAMELEN              32
41
42 /* notify_type values for the RegisterNotify() functions. */
43 #define DSP_SIGNALEVENT             0x00000001
44
45 /* Types of events for processors */
46 #define DSP_PROCESSORSTATECHANGE    0x00000001
47 #define DSP_PROCESSORATTACH         0x00000002
48 #define DSP_PROCESSORDETACH         0x00000004
49 #define DSP_PROCESSORRESTART        0x00000008
50
51 /* DSP exception events (DSP/BIOS and DSP MMU fault) */
52 #define DSP_MMUFAULT                0x00000010
53 #define DSP_SYSERROR                0x00000020
54 #define DSP_EXCEPTIONABORT          0x00000300
55 #define DSP_PWRERROR                0x00000080
56 #define DSP_WDTOVERFLOW 0x00000040
57
58 /* IVA exception events (IVA MMU fault) */
59 #define IVA_MMUFAULT                0x00000040
60 /* Types of events for nodes */
61 #define DSP_NODESTATECHANGE         0x00000100
62 #define DSP_NODEMESSAGEREADY        0x00000200
63
64 /* Types of events for streams */
65 #define DSP_STREAMDONE              0x00001000
66 #define DSP_STREAMIOCOMPLETION      0x00002000
67
68 /* Handle definition representing the GPP node in DSPNode_Connect() calls */
69 #define DSP_HGPPNODE                0xFFFFFFFF
70
71 /* Node directions used in DSPNode_Connect() */
72 #define DSP_TONODE                  1
73 #define DSP_FROMNODE                2
74
75 /* Define Node Minimum and Maximum Priorities */
76 #define DSP_NODE_MIN_PRIORITY       1
77 #define DSP_NODE_MAX_PRIORITY       15
78
79 /* Pre-Defined Message Command Codes available to user: */
80 #define DSP_RMSUSERCODESTART RMS_USER   /* Start of RMS user cmd codes */
81 /* end of user codes */
82 #define DSP_RMSUSERCODEEND (RMS_USER + RMS_MAXUSERCODES);
83 /* msg_ctrl contains SM buffer description */
84 #define DSP_RMSBUFDESC RMS_BUFDESC
85
86 /* Shared memory identifier for MEM segment named "SHMSEG0" */
87 #define DSP_SHMSEG0     (u32)(-1)
88
89 /* Processor ID numbers */
90 #define DSP_UNIT    0
91 #define IVA_UNIT    1
92
93 #define DSPWORD       unsigned char
94 #define DSPWORDSIZE     sizeof(DSPWORD)
95
96 /* Success & Failure macros */
97 #define DSP_SUCCEEDED(Status)      likely((s32)(Status) >= 0)
98 #define DSP_FAILED(Status)         unlikely((s32)(Status) < 0)
99
100 /* Power control enumerations */
101 #define PROC_PWRCONTROL             0x8070
102
103 #define PROC_PWRMGT_ENABLE          (PROC_PWRCONTROL + 0x3)
104 #define PROC_PWRMGT_DISABLE         (PROC_PWRCONTROL + 0x4)
105
106 /* Bridge Code Version */
107 #define BRIDGE_VERSION_CODE         333
108
109 #define    MAX_PROFILES     16
110
111 /* DSP chip type */
112 #define DSPTYPE64       0x99
113
114 /* Handy Macros */
115 #define IS_VALID_PROC_EVENT(x) (((x) == 0) || (((x) & \
116                                 (DSP_PROCESSORSTATECHANGE | \
117                                     DSP_PROCESSORATTACH | \
118                                     DSP_PROCESSORDETACH | \
119                                     DSP_PROCESSORRESTART | \
120                                     DSP_NODESTATECHANGE | \
121                                     DSP_STREAMDONE | \
122                                     DSP_STREAMIOCOMPLETION | \
123                                     DSP_MMUFAULT | \
124                                     DSP_SYSERROR | \
125                                     DSP_WDTOVERFLOW | \
126                                     DSP_PWRERROR)) && \
127                                 !((x) & ~(DSP_PROCESSORSTATECHANGE | \
128                                     DSP_PROCESSORATTACH | \
129                                     DSP_PROCESSORDETACH | \
130                                     DSP_PROCESSORRESTART | \
131                                     DSP_NODESTATECHANGE | \
132                                     DSP_STREAMDONE | \
133                                     DSP_STREAMIOCOMPLETION | \
134                                     DSP_MMUFAULT | \
135                                     DSP_SYSERROR | \
136                                     DSP_WDTOVERFLOW | \
137                                     DSP_PWRERROR))))
138
139 #define IS_VALID_NODE_EVENT(x)    (((x) == 0) || \
140         (((x) & (DSP_NODESTATECHANGE | DSP_NODEMESSAGEREADY)) && \
141         !((x) & ~(DSP_NODESTATECHANGE | DSP_NODEMESSAGEREADY))))
142
143 #define IS_VALID_STRM_EVENT(x)     (((x) == 0) || (((x) & (DSP_STREAMDONE | \
144                                 DSP_STREAMIOCOMPLETION)) && \
145                                 !((x) & ~(DSP_STREAMDONE | \
146                                 DSP_STREAMIOCOMPLETION))))
147
148 #define IS_VALID_NOTIFY_MASK(x)   ((x) & DSP_SIGNALEVENT)
149
150 /* The Node UUID structure */
151 struct dsp_uuid {
152         u32 ul_data1;
153         u16 us_data2;
154         u16 us_data3;
155         u8 uc_data4;
156         u8 uc_data5;
157         u8 uc_data6[6];
158 };
159
160 /* DCD types */
161 enum dsp_dcdobjtype {
162         DSP_DCDNODETYPE,
163         DSP_DCDPROCESSORTYPE,
164         DSP_DCDLIBRARYTYPE,
165         DSP_DCDCREATELIBTYPE,
166         DSP_DCDEXECUTELIBTYPE,
167         DSP_DCDDELETELIBTYPE,
168         /* DSP_DCDMAXOBJTYPE is meant to be the last DCD object type */
169         DSP_DCDMAXOBJTYPE
170 };
171
172 /* Processor states */
173 enum dsp_procstate {
174         PROC_STOPPED,
175         PROC_LOADED,
176         PROC_RUNNING,
177         PROC_ERROR
178 };
179
180 /*
181  *  Node types: Message node, task node, xDAIS socket node, and
182  *  device node. _NODE_GPP is used when defining a stream connection
183  *  between a task or socket node and the GPP.
184  *
185  */
186 enum node_type {
187         NODE_DEVICE,
188         NODE_TASK,
189         NODE_DAISSOCKET,
190         NODE_MESSAGE,
191         NODE_GPP
192 };
193
194 /*
195  *  ======== node_state ========
196  *  Internal node states.
197  */
198 enum node_state {
199         NODE_ALLOCATED,
200         NODE_CREATED,
201         NODE_RUNNING,
202         NODE_PAUSED,
203         NODE_DONE,
204         NODE_CREATING,
205         NODE_STARTING,
206         NODE_PAUSING,
207         NODE_TERMINATING,
208         NODE_DELETING,
209 };
210
211 /* Stream states */
212 enum dsp_streamstate {
213         STREAM_IDLE,
214         STREAM_READY,
215         STREAM_PENDING,
216         STREAM_DONE
217 };
218
219 /* Stream connect types */
220 enum dsp_connecttype {
221         CONNECTTYPE_NODEOUTPUT,
222         CONNECTTYPE_GPPOUTPUT,
223         CONNECTTYPE_NODEINPUT,
224         CONNECTTYPE_GPPINPUT
225 };
226
227 /* Stream mode types */
228 enum dsp_strmmode {
229         STRMMODE_PROCCOPY,      /* Processor(s) copy stream data payloads */
230         STRMMODE_ZEROCOPY,      /* Strm buffer ptrs swapped no data copied */
231         STRMMODE_LDMA,          /* Local DMA : OMAP's System-DMA device */
232         STRMMODE_RDMA           /* Remote DMA: OMAP's DSP-DMA device */
233 };
234
235 /* Resource Types */
236 enum dsp_resourceinfotype {
237         DSP_RESOURCE_DYNDARAM = 0,
238         DSP_RESOURCE_DYNSARAM,
239         DSP_RESOURCE_DYNEXTERNAL,
240         DSP_RESOURCE_DYNSRAM,
241         DSP_RESOURCE_PROCLOAD
242 };
243
244 /* Memory Segment Types */
245 enum dsp_memtype {
246         DSP_DYNDARAM = 0,
247         DSP_DYNSARAM,
248         DSP_DYNEXTERNAL,
249         DSP_DYNSRAM
250 };
251
252 /* Memory Flush Types */
253 enum dsp_flushtype {
254         PROC_INVALIDATE_MEM = 0,
255         PROC_WRITEBACK_MEM,
256         PROC_WRITEBACK_INVALIDATE_MEM,
257 };
258
259 /* Memory Segment Status Values */
260 struct dsp_memstat {
261         u32 ul_size;
262         u32 ul_total_free_size;
263         u32 ul_len_max_free_block;
264         u32 ul_num_free_blocks;
265         u32 ul_num_alloc_blocks;
266 };
267
268 /* Processor Load information Values */
269 struct dsp_procloadstat {
270         u32 curr_load;
271         u32 predicted_load;
272         u32 curr_dsp_freq;
273         u32 predicted_freq;
274 };
275
276 /* Attributes for STRM connections between nodes */
277 struct dsp_strmattr {
278         u32 seg_id;             /* Memory segment on DSP to allocate buffers */
279         u32 buf_size;           /* Buffer size (DSP words) */
280         u32 num_bufs;           /* Number of buffers */
281         u32 buf_alignment;      /* Buffer alignment */
282         u32 utimeout;           /* Timeout for blocking STRM calls */
283         enum dsp_strmmode strm_mode;    /* mode of stream when opened */
284         /* DMA chnl id if dsp_strmmode is LDMA or RDMA */
285         u32 udma_chnl_id;
286         u32 udma_priority;      /* DMA channel priority 0=lowest, >0=high */
287 };
288
289 /* The dsp_cbdata structure */
290 struct dsp_cbdata {
291         u32 cb_data;
292         u8 node_data[1];
293 };
294
295 /* The dsp_msg structure */
296 struct dsp_msg {
297         u32 dw_cmd;
298         u32 dw_arg1;
299         u32 dw_arg2;
300 };
301
302 /* The dsp_resourcereqmts structure for node's resource requirements */
303 struct dsp_resourcereqmts {
304         u32 cb_struct;
305         u32 static_data_size;
306         u32 global_data_size;
307         u32 program_mem_size;
308         u32 uwc_execution_time;
309         u32 uwc_period;
310         u32 uwc_deadline;
311         u32 avg_exection_time;
312         u32 minimum_period;
313 };
314
315 /*
316  * The dsp_streamconnect structure describes a stream connection
317  * between two nodes, or between a node and the GPP
318  */
319 struct dsp_streamconnect {
320         u32 cb_struct;
321         enum dsp_connecttype connect_type;
322         u32 this_node_stream_index;
323         void *connected_node;
324         struct dsp_uuid ui_connected_node_id;
325         u32 connected_node_stream_index;
326 };
327
328 struct dsp_nodeprofs {
329         u32 ul_heap_size;
330 };
331
332 /* The dsp_ndbprops structure reports the attributes of a node */
333 struct dsp_ndbprops {
334         u32 cb_struct;
335         struct dsp_uuid ui_node_id;
336         char ac_name[DSP_MAXNAMELEN];
337         enum node_type ntype;
338         u32 cache_on_gpp;
339         struct dsp_resourcereqmts dsp_resource_reqmts;
340         s32 prio;
341         u32 stack_size;
342         u32 sys_stack_size;
343         u32 stack_seg;
344         u32 message_depth;
345         u32 num_input_streams;
346         u32 num_output_streams;
347         u32 utimeout;
348         u32 count_profiles;     /* Number of supported profiles */
349         /* Array of profiles */
350         struct dsp_nodeprofs node_profiles[MAX_PROFILES];
351         u32 stack_seg_name;     /* Stack Segment Name */
352 };
353
354         /* The dsp_nodeattrin structure describes the attributes of a
355          * node client */
356 struct dsp_nodeattrin {
357         u32 cb_struct;
358         s32 prio;
359         u32 utimeout;
360         u32 profile_id;
361         /* Reserved, for Bridge Internal use only */
362         u32 heap_size;
363         void *pgpp_virt_addr;   /* Reserved, for Bridge Internal use only */
364 };
365
366         /* The dsp_nodeinfo structure is used to retrieve information
367          * about a node */
368 struct dsp_nodeinfo {
369         u32 cb_struct;
370         struct dsp_ndbprops nb_node_database_props;
371         u32 execution_priority;
372         enum node_state ns_execution_state;
373         void *device_owner;
374         u32 number_streams;
375         struct dsp_streamconnect sc_stream_connection[16];
376         u32 node_env;
377 };
378
379         /* The dsp_nodeattr structure describes the attributes of a node */
380 struct dsp_nodeattr {
381         u32 cb_struct;
382         struct dsp_nodeattrin in_node_attr_in;
383         u32 node_attr_inputs;
384         u32 node_attr_outputs;
385         struct dsp_nodeinfo node_info;
386 };
387
388 /*
389  *  Notification type: either the name of an opened event, or an event or
390  *  window handle.
391  */
392 struct dsp_notification {
393         char *ps_name;
394         void *handle;
395 };
396
397 /* The dsp_processorattrin structure describes the attributes of a processor */
398 struct dsp_processorattrin {
399         u32 cb_struct;
400         u32 utimeout;
401 };
402 /*
403  * The dsp_processorinfo structure describes basic capabilities of a
404  * DSP processor
405  */
406 struct dsp_processorinfo {
407         u32 cb_struct;
408         int processor_family;
409         int processor_type;
410         u32 clock_rate;
411         u32 ul_internal_mem_size;
412         u32 ul_external_mem_size;
413         u32 processor_id;
414         int ty_running_rtos;
415         s32 node_min_priority;
416         s32 node_max_priority;
417 };
418
419 /* Error information of last DSP exception signalled to the GPP */
420 struct dsp_errorinfo {
421         u32 dw_err_mask;
422         u32 dw_val1;
423         u32 dw_val2;
424         u32 dw_val3;
425 };
426
427 /* The dsp_processorstate structure describes the state of a DSP processor */
428 struct dsp_processorstate {
429         u32 cb_struct;
430         enum dsp_procstate proc_state;
431 };
432
433 /*
434  * The dsp_resourceinfo structure is used to retrieve information about a
435  * processor's resources
436  */
437 struct dsp_resourceinfo {
438         u32 cb_struct;
439         enum dsp_resourceinfotype resource_type;
440         union {
441                 u32 ul_resource;
442                 struct dsp_memstat mem_stat;
443                 struct dsp_procloadstat proc_load_stat;
444         } result;
445 };
446
447 /*
448  * The dsp_streamattrin structure describes the attributes of a stream,
449  * including segment and alignment of data buffers allocated with
450  * DSPStream_AllocateBuffers(), if applicable
451  */
452 struct dsp_streamattrin {
453         u32 cb_struct;
454         u32 utimeout;
455         u32 segment_id;
456         u32 buf_alignment;
457         u32 num_bufs;
458         enum dsp_strmmode strm_mode;
459         u32 udma_chnl_id;
460         u32 udma_priority;
461 };
462
463 /* The dsp_bufferattr structure describes the attributes of a data buffer */
464 struct dsp_bufferattr {
465         u32 cb_struct;
466         u32 segment_id;
467         u32 buf_alignment;
468 };
469
470 /*
471  *  The dsp_streaminfo structure is used to retrieve information
472  *  about a stream.
473  */
474 struct dsp_streaminfo {
475         u32 cb_struct;
476         u32 number_bufs_allowed;
477         u32 number_bufs_in_stream;
478         u32 ul_number_bytes;
479         void *sync_object_handle;
480         enum dsp_streamstate ss_stream_state;
481 };
482
483 /* DMM MAP attributes
484 It is a bit mask with each bit value indicating a specific attribute
485 bit 0 - GPP address type (user virtual=0, physical=1)
486 bit 1 - MMU Endianism (Big Endian=1, Little Endian=0)
487 bit 2 - MMU mixed page attribute (Mixed/ CPUES=1, TLBES =0)
488 bit 3 - MMU element size = 8bit (valid only for non mixed page entries)
489 bit 4 - MMU element size = 16bit (valid only for non mixed page entries)
490 bit 5 - MMU element size = 32bit (valid only for non mixed page entries)
491 bit 6 - MMU element size = 64bit (valid only for non mixed page entries)
492
493 bit 14 - Input (read only) buffer
494 bit 15 - Output (writeable) buffer
495 */
496
497 /* Types of mapping attributes */
498
499 /* MPU address is virtual and needs to be translated to physical addr */
500 #define DSP_MAPVIRTUALADDR          0x00000000
501 #define DSP_MAPPHYSICALADDR         0x00000001
502
503 /* Mapped data is big endian */
504 #define DSP_MAPBIGENDIAN            0x00000002
505 #define DSP_MAPLITTLEENDIAN         0x00000000
506
507 /* Element size is based on DSP r/w access size */
508 #define DSP_MAPMIXEDELEMSIZE        0x00000004
509
510 /*
511  * Element size for MMU mapping (8, 16, 32, or 64 bit)
512  * Ignored if DSP_MAPMIXEDELEMSIZE enabled
513  */
514 #define DSP_MAPELEMSIZE8            0x00000008
515 #define DSP_MAPELEMSIZE16           0x00000010
516 #define DSP_MAPELEMSIZE32           0x00000020
517 #define DSP_MAPELEMSIZE64           0x00000040
518
519 #define DSP_MAPVMALLOCADDR         0x00000080
520
521 #define DSP_MAPDONOTLOCK           0x00000100
522
523 #define DSP_MAP_DIR_MASK                0x3FFF
524
525 #define GEM_CACHE_LINE_SIZE     128
526 #define GEM_L1P_PREFETCH_SIZE   128
527
528 /*
529  * Definitions from dbreg.h
530  */
531
532 #define DSPPROCTYPE_C64         6410
533 #define IVAPROCTYPE_ARM7        470
534
535 #define REG_MGR_OBJECT  1
536 #define REG_DRV_OBJECT  2
537
538 /* registry */
539 #define DRVOBJECT       "DrvObject"
540 #define MGROBJECT       "MgrObject"
541
542 /* Max registry path length. Also the max registry value length. */
543 #define MAXREGPATHLENGTH        255
544
545 #endif /* DBDEFS_ */