4 * DSP-BIOS Bridge driver support functions for TI OMAP processors.
6 * Global definitions and constants for DSP/BIOS Bridge.
8 * Copyright (C) 2005-2006 Texas Instruments, Inc.
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.
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.
22 #include <linux/types.h>
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 */
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))
33 /* API return value and calling convention */
36 /* Infinite time value for the utimeout parameter to DSPStream_Select() */
37 #define DSP_FOREVER (-1)
39 /* Maximum length of node name, used in dsp_ndbprops */
40 #define DSP_MAXNAMELEN 32
42 /* notify_type values for the RegisterNotify() functions. */
43 #define DSP_SIGNALEVENT 0x00000001
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
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
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
64 /* Types of events for streams */
65 #define DSP_STREAMDONE 0x00001000
66 #define DSP_STREAMIOCOMPLETION 0x00002000
68 /* Handle definition representing the GPP node in DSPNode_Connect() calls */
69 #define DSP_HGPPNODE 0xFFFFFFFF
71 /* Node directions used in DSPNode_Connect() */
73 #define DSP_FROMNODE 2
75 /* Define Node Minimum and Maximum Priorities */
76 #define DSP_NODE_MIN_PRIORITY 1
77 #define DSP_NODE_MAX_PRIORITY 15
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
86 /* Shared memory identifier for MEM segment named "SHMSEG0" */
87 #define DSP_SHMSEG0 (u32)(-1)
89 /* Processor ID numbers */
93 #define DSPWORD unsigned char
94 #define DSPWORDSIZE sizeof(DSPWORD)
96 /* Success & Failure macros */
97 #define DSP_SUCCEEDED(Status) likely((s32)(Status) >= 0)
98 #define DSP_FAILED(Status) unlikely((s32)(Status) < 0)
100 /* Power control enumerations */
101 #define PROC_PWRCONTROL 0x8070
103 #define PROC_PWRMGT_ENABLE (PROC_PWRCONTROL + 0x3)
104 #define PROC_PWRMGT_DISABLE (PROC_PWRCONTROL + 0x4)
106 /* Bridge Code Version */
107 #define BRIDGE_VERSION_CODE 333
109 #define MAX_PROFILES 16
112 #define DSPTYPE64 0x99
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 | \
122 DSP_STREAMIOCOMPLETION | \
127 !((x) & ~(DSP_PROCESSORSTATECHANGE | \
128 DSP_PROCESSORATTACH | \
129 DSP_PROCESSORDETACH | \
130 DSP_PROCESSORRESTART | \
131 DSP_NODESTATECHANGE | \
133 DSP_STREAMIOCOMPLETION | \
139 #define IS_VALID_NODE_EVENT(x) (((x) == 0) || \
140 (((x) & (DSP_NODESTATECHANGE | DSP_NODEMESSAGEREADY)) && \
141 !((x) & ~(DSP_NODESTATECHANGE | DSP_NODEMESSAGEREADY))))
143 #define IS_VALID_STRM_EVENT(x) (((x) == 0) || (((x) & (DSP_STREAMDONE | \
144 DSP_STREAMIOCOMPLETION)) && \
145 !((x) & ~(DSP_STREAMDONE | \
146 DSP_STREAMIOCOMPLETION))))
148 #define IS_VALID_NOTIFY_MASK(x) ((x) & DSP_SIGNALEVENT)
150 /* The Node UUID structure */
161 enum dsp_dcdobjtype {
163 DSP_DCDPROCESSORTYPE,
165 DSP_DCDCREATELIBTYPE,
166 DSP_DCDEXECUTELIBTYPE,
167 DSP_DCDDELETELIBTYPE,
168 /* DSP_DCDMAXOBJTYPE is meant to be the last DCD object type */
172 /* Processor states */
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.
195 * ======== node_state ========
196 * Internal node states.
212 enum dsp_streamstate {
219 /* Stream connect types */
220 enum dsp_connecttype {
221 CONNECTTYPE_NODEOUTPUT,
222 CONNECTTYPE_GPPOUTPUT,
223 CONNECTTYPE_NODEINPUT,
227 /* Stream mode types */
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 */
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
244 /* Memory Segment Types */
252 /* Memory Flush Types */
254 PROC_INVALIDATE_MEM = 0,
256 PROC_WRITEBACK_INVALIDATE_MEM,
259 /* Memory Segment Status Values */
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;
268 /* Processor Load information Values */
269 struct dsp_procloadstat {
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 */
286 u32 udma_priority; /* DMA channel priority 0=lowest, >0=high */
289 /* The dsp_cbdata structure */
295 /* The dsp_msg structure */
302 /* The dsp_resourcereqmts structure for node's resource requirements */
303 struct dsp_resourcereqmts {
305 u32 static_data_size;
306 u32 global_data_size;
307 u32 program_mem_size;
308 u32 uwc_execution_time;
311 u32 avg_exection_time;
316 * The dsp_streamconnect structure describes a stream connection
317 * between two nodes, or between a node and the GPP
319 struct dsp_streamconnect {
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;
328 struct dsp_nodeprofs {
332 /* The dsp_ndbprops structure reports the attributes of a node */
333 struct dsp_ndbprops {
335 struct dsp_uuid ui_node_id;
336 char ac_name[DSP_MAXNAMELEN];
337 enum node_type ntype;
339 struct dsp_resourcereqmts dsp_resource_reqmts;
345 u32 num_input_streams;
346 u32 num_output_streams;
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 */
354 /* The dsp_nodeattrin structure describes the attributes of a
356 struct dsp_nodeattrin {
361 /* Reserved, for Bridge Internal use only */
363 void *pgpp_virt_addr; /* Reserved, for Bridge Internal use only */
366 /* The dsp_nodeinfo structure is used to retrieve information
368 struct dsp_nodeinfo {
370 struct dsp_ndbprops nb_node_database_props;
371 u32 execution_priority;
372 enum node_state ns_execution_state;
375 struct dsp_streamconnect sc_stream_connection[16];
379 /* The dsp_nodeattr structure describes the attributes of a node */
380 struct dsp_nodeattr {
382 struct dsp_nodeattrin in_node_attr_in;
383 u32 node_attr_inputs;
384 u32 node_attr_outputs;
385 struct dsp_nodeinfo node_info;
389 * Notification type: either the name of an opened event, or an event or
392 struct dsp_notification {
397 /* The dsp_processorattrin structure describes the attributes of a processor */
398 struct dsp_processorattrin {
403 * The dsp_processorinfo structure describes basic capabilities of a
406 struct dsp_processorinfo {
408 int processor_family;
411 u32 ul_internal_mem_size;
412 u32 ul_external_mem_size;
415 s32 node_min_priority;
416 s32 node_max_priority;
419 /* Error information of last DSP exception signalled to the GPP */
420 struct dsp_errorinfo {
427 /* The dsp_processorstate structure describes the state of a DSP processor */
428 struct dsp_processorstate {
430 enum dsp_procstate proc_state;
434 * The dsp_resourceinfo structure is used to retrieve information about a
435 * processor's resources
437 struct dsp_resourceinfo {
439 enum dsp_resourceinfotype resource_type;
442 struct dsp_memstat mem_stat;
443 struct dsp_procloadstat proc_load_stat;
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
452 struct dsp_streamattrin {
458 enum dsp_strmmode strm_mode;
463 /* The dsp_bufferattr structure describes the attributes of a data buffer */
464 struct dsp_bufferattr {
471 * The dsp_streaminfo structure is used to retrieve information
474 struct dsp_streaminfo {
476 u32 number_bufs_allowed;
477 u32 number_bufs_in_stream;
479 void *sync_object_handle;
480 enum dsp_streamstate ss_stream_state;
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)
493 bit 14 - Input (read only) buffer
494 bit 15 - Output (writeable) buffer
497 /* Types of mapping attributes */
499 /* MPU address is virtual and needs to be translated to physical addr */
500 #define DSP_MAPVIRTUALADDR 0x00000000
501 #define DSP_MAPPHYSICALADDR 0x00000001
503 /* Mapped data is big endian */
504 #define DSP_MAPBIGENDIAN 0x00000002
505 #define DSP_MAPLITTLEENDIAN 0x00000000
507 /* Element size is based on DSP r/w access size */
508 #define DSP_MAPMIXEDELEMSIZE 0x00000004
511 * Element size for MMU mapping (8, 16, 32, or 64 bit)
512 * Ignored if DSP_MAPMIXEDELEMSIZE enabled
514 #define DSP_MAPELEMSIZE8 0x00000008
515 #define DSP_MAPELEMSIZE16 0x00000010
516 #define DSP_MAPELEMSIZE32 0x00000020
517 #define DSP_MAPELEMSIZE64 0x00000040
519 #define DSP_MAPVMALLOCADDR 0x00000080
521 #define DSP_MAPDONOTLOCK 0x00000100
523 #define DSP_MAP_DIR_MASK 0x3FFF
525 #define GEM_CACHE_LINE_SIZE 128
526 #define GEM_L1P_PREFETCH_SIZE 128
529 * Definitions from dbreg.h
532 #define DSPPROCTYPE_C64 6410
533 #define IVAPROCTYPE_ARM7 470
535 #define REG_MGR_OBJECT 1
536 #define REG_DRV_OBJECT 2
539 #define DRVOBJECT "DrvObject"
540 #define MGROBJECT "MgrObject"
542 /* Max registry path length. Also the max registry value length. */
543 #define MAXREGPATHLENGTH 255