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/rms_sh.h> /* Types shared between GPP and DSP */
26 #define PG_SIZE4K 4096
27 #define PG_MASK(pg_size) (~((pg_size)-1))
28 #define PG_ALIGN_LOW(addr, pg_size) ((addr) & PG_MASK(pg_size))
29 #define PG_ALIGN_HIGH(addr, pg_size) (((addr)+(pg_size)-1) & PG_MASK(pg_size))
31 /* API return value and calling convention */
34 /* Infinite time value for the utimeout parameter to DSPStream_Select() */
35 #define DSP_FOREVER (-1)
37 /* Maximum length of node name, used in dsp_ndbprops */
38 #define DSP_MAXNAMELEN 32
40 /* notify_type values for the RegisterNotify() functions. */
41 #define DSP_SIGNALEVENT 0x00000001
43 /* Types of events for processors */
44 #define DSP_PROCESSORSTATECHANGE 0x00000001
45 #define DSP_PROCESSORATTACH 0x00000002
46 #define DSP_PROCESSORDETACH 0x00000004
47 #define DSP_PROCESSORRESTART 0x00000008
49 /* DSP exception events (DSP/BIOS and DSP MMU fault) */
50 #define DSP_MMUFAULT 0x00000010
51 #define DSP_SYSERROR 0x00000020
52 #define DSP_EXCEPTIONABORT 0x00000300
53 #define DSP_PWRERROR 0x00000080
54 #define DSP_WDTOVERFLOW 0x00000040
56 /* IVA exception events (IVA MMU fault) */
57 #define IVA_MMUFAULT 0x00000040
58 /* Types of events for nodes */
59 #define DSP_NODESTATECHANGE 0x00000100
60 #define DSP_NODEMESSAGEREADY 0x00000200
62 /* Types of events for streams */
63 #define DSP_STREAMDONE 0x00001000
64 #define DSP_STREAMIOCOMPLETION 0x00002000
66 /* Handle definition representing the GPP node in DSPNode_Connect() calls */
67 #define DSP_HGPPNODE 0xFFFFFFFF
69 /* Node directions used in DSPNode_Connect() */
71 #define DSP_FROMNODE 2
73 /* Define Node Minimum and Maximum Priorities */
74 #define DSP_NODE_MIN_PRIORITY 1
75 #define DSP_NODE_MAX_PRIORITY 15
77 /* Pre-Defined Message Command Codes available to user: */
78 #define DSP_RMSUSERCODESTART RMS_USER /* Start of RMS user cmd codes */
79 /* end of user codes */
80 #define DSP_RMSUSERCODEEND (RMS_USER + RMS_MAXUSERCODES);
81 /* msg_ctrl contains SM buffer description */
82 #define DSP_RMSBUFDESC RMS_BUFDESC
84 /* Shared memory identifier for MEM segment named "SHMSEG0" */
85 #define DSP_SHMSEG0 (u32)(-1)
87 /* Processor ID numbers */
91 #define DSPWORD unsigned char
92 #define DSPWORDSIZE sizeof(DSPWORD)
94 /* Power control enumerations */
95 #define PROC_PWRCONTROL 0x8070
97 #define PROC_PWRMGT_ENABLE (PROC_PWRCONTROL + 0x3)
98 #define PROC_PWRMGT_DISABLE (PROC_PWRCONTROL + 0x4)
100 /* Bridge Code Version */
101 #define BRIDGE_VERSION_CODE 333
103 #define MAX_PROFILES 16
106 #define DSPTYPE64 0x99
109 #define VALID_PROC_EVENT (DSP_PROCESSORSTATECHANGE | DSP_PROCESSORATTACH | \
110 DSP_PROCESSORDETACH | DSP_PROCESSORRESTART | DSP_NODESTATECHANGE | \
111 DSP_STREAMDONE | DSP_STREAMIOCOMPLETION | DSP_MMUFAULT | \
112 DSP_SYSERROR | DSP_WDTOVERFLOW | DSP_PWRERROR)
114 static inline bool is_valid_proc_event(u32 x
)
116 return (x
== 0 || (x
& VALID_PROC_EVENT
&& !(x
& ~VALID_PROC_EVENT
)));
119 /* The Node UUID structure */
130 enum dsp_dcdobjtype
{
132 DSP_DCDPROCESSORTYPE
,
134 DSP_DCDCREATELIBTYPE
,
135 DSP_DCDEXECUTELIBTYPE
,
136 DSP_DCDDELETELIBTYPE
,
137 /* DSP_DCDMAXOBJTYPE is meant to be the last DCD object type */
141 /* Processor states */
150 * Node types: Message node, task node, xDAIS socket node, and
151 * device node. _NODE_GPP is used when defining a stream connection
152 * between a task or socket node and the GPP.
164 * ======== node_state ========
165 * Internal node states.
181 enum dsp_streamstate
{
188 /* Stream connect types */
189 enum dsp_connecttype
{
190 CONNECTTYPE_NODEOUTPUT
,
191 CONNECTTYPE_GPPOUTPUT
,
192 CONNECTTYPE_NODEINPUT
,
196 /* Stream mode types */
198 STRMMODE_PROCCOPY
, /* Processor(s) copy stream data payloads */
199 STRMMODE_ZEROCOPY
, /* Strm buffer ptrs swapped no data copied */
200 STRMMODE_LDMA
, /* Local DMA : OMAP's System-DMA device */
201 STRMMODE_RDMA
/* Remote DMA: OMAP's DSP-DMA device */
205 enum dsp_resourceinfotype
{
206 DSP_RESOURCE_DYNDARAM
= 0,
207 DSP_RESOURCE_DYNSARAM
,
208 DSP_RESOURCE_DYNEXTERNAL
,
209 DSP_RESOURCE_DYNSRAM
,
210 DSP_RESOURCE_PROCLOAD
213 /* Memory Segment Types */
221 /* Memory Flush Types */
223 PROC_INVALIDATE_MEM
= 0,
225 PROC_WRITEBACK_INVALIDATE_MEM
,
228 /* Memory Segment Status Values */
231 u32 ul_total_free_size
;
232 u32 ul_len_max_free_block
;
233 u32 ul_num_free_blocks
;
234 u32 ul_num_alloc_blocks
;
237 /* Processor Load information Values */
238 struct dsp_procloadstat
{
245 /* Attributes for STRM connections between nodes */
246 struct dsp_strmattr
{
247 u32 seg_id
; /* Memory segment on DSP to allocate buffers */
248 u32 buf_size
; /* Buffer size (DSP words) */
249 u32 num_bufs
; /* Number of buffers */
250 u32 buf_alignment
; /* Buffer alignment */
251 u32 utimeout
; /* Timeout for blocking STRM calls */
252 enum dsp_strmmode strm_mode
; /* mode of stream when opened */
253 /* DMA chnl id if dsp_strmmode is LDMA or RDMA */
255 u32 udma_priority
; /* DMA channel priority 0=lowest, >0=high */
258 /* The dsp_cbdata structure */
264 /* The dsp_msg structure */
271 /* The dsp_resourcereqmts structure for node's resource requirements */
272 struct dsp_resourcereqmts
{
274 u32 static_data_size
;
275 u32 global_data_size
;
276 u32 program_mem_size
;
277 u32 uwc_execution_time
;
280 u32 avg_exection_time
;
285 * The dsp_streamconnect structure describes a stream connection
286 * between two nodes, or between a node and the GPP
288 struct dsp_streamconnect
{
290 enum dsp_connecttype connect_type
;
291 u32 this_node_stream_index
;
292 void *connected_node
;
293 struct dsp_uuid ui_connected_node_id
;
294 u32 connected_node_stream_index
;
297 struct dsp_nodeprofs
{
301 /* The dsp_ndbprops structure reports the attributes of a node */
302 struct dsp_ndbprops
{
304 struct dsp_uuid ui_node_id
;
305 char ac_name
[DSP_MAXNAMELEN
];
306 enum node_type ntype
;
308 struct dsp_resourcereqmts dsp_resource_reqmts
;
314 u32 num_input_streams
;
315 u32 num_output_streams
;
317 u32 count_profiles
; /* Number of supported profiles */
318 /* Array of profiles */
319 struct dsp_nodeprofs node_profiles
[MAX_PROFILES
];
320 u32 stack_seg_name
; /* Stack Segment Name */
323 /* The dsp_nodeattrin structure describes the attributes of a
325 struct dsp_nodeattrin
{
330 /* Reserved, for Bridge Internal use only */
332 void *pgpp_virt_addr
; /* Reserved, for Bridge Internal use only */
335 /* The dsp_nodeinfo structure is used to retrieve information
337 struct dsp_nodeinfo
{
339 struct dsp_ndbprops nb_node_database_props
;
340 u32 execution_priority
;
341 enum node_state ns_execution_state
;
344 struct dsp_streamconnect sc_stream_connection
[16];
348 /* The dsp_nodeattr structure describes the attributes of a node */
349 struct dsp_nodeattr
{
351 struct dsp_nodeattrin in_node_attr_in
;
352 u32 node_attr_inputs
;
353 u32 node_attr_outputs
;
354 struct dsp_nodeinfo node_info
;
358 * Notification type: either the name of an opened event, or an event or
361 struct dsp_notification
{
366 /* The dsp_processorattrin structure describes the attributes of a processor */
367 struct dsp_processorattrin
{
372 * The dsp_processorinfo structure describes basic capabilities of a
375 struct dsp_processorinfo
{
377 int processor_family
;
380 u32 ul_internal_mem_size
;
381 u32 ul_external_mem_size
;
384 s32 node_min_priority
;
385 s32 node_max_priority
;
388 /* Error information of last DSP exception signalled to the GPP */
389 struct dsp_errorinfo
{
396 /* The dsp_processorstate structure describes the state of a DSP processor */
397 struct dsp_processorstate
{
399 enum dsp_procstate proc_state
;
403 * The dsp_resourceinfo structure is used to retrieve information about a
404 * processor's resources
406 struct dsp_resourceinfo
{
408 enum dsp_resourceinfotype resource_type
;
411 struct dsp_memstat mem_stat
;
412 struct dsp_procloadstat proc_load_stat
;
417 * The dsp_streamattrin structure describes the attributes of a stream,
418 * including segment and alignment of data buffers allocated with
419 * DSPStream_AllocateBuffers(), if applicable
421 struct dsp_streamattrin
{
427 enum dsp_strmmode strm_mode
;
432 /* The dsp_bufferattr structure describes the attributes of a data buffer */
433 struct dsp_bufferattr
{
440 * The dsp_streaminfo structure is used to retrieve information
443 struct dsp_streaminfo
{
445 u32 number_bufs_allowed
;
446 u32 number_bufs_in_stream
;
448 void *sync_object_handle
;
449 enum dsp_streamstate ss_stream_state
;
452 /* DMM MAP attributes
453 It is a bit mask with each bit value indicating a specific attribute
454 bit 0 - GPP address type (user virtual=0, physical=1)
455 bit 1 - MMU Endianism (Big Endian=1, Little Endian=0)
456 bit 2 - MMU mixed page attribute (Mixed/ CPUES=1, TLBES =0)
457 bit 3 - MMU element size = 8bit (valid only for non mixed page entries)
458 bit 4 - MMU element size = 16bit (valid only for non mixed page entries)
459 bit 5 - MMU element size = 32bit (valid only for non mixed page entries)
460 bit 6 - MMU element size = 64bit (valid only for non mixed page entries)
462 bit 14 - Input (read only) buffer
463 bit 15 - Output (writeable) buffer
466 /* Types of mapping attributes */
468 /* MPU address is virtual and needs to be translated to physical addr */
469 #define DSP_MAPVIRTUALADDR 0x00000000
470 #define DSP_MAPPHYSICALADDR 0x00000001
472 /* Mapped data is big endian */
473 #define DSP_MAPBIGENDIAN 0x00000002
474 #define DSP_MAPLITTLEENDIAN 0x00000000
476 /* Element size is based on DSP r/w access size */
477 #define DSP_MAPMIXEDELEMSIZE 0x00000004
480 * Element size for MMU mapping (8, 16, 32, or 64 bit)
481 * Ignored if DSP_MAPMIXEDELEMSIZE enabled
483 #define DSP_MAPELEMSIZE8 0x00000008
484 #define DSP_MAPELEMSIZE16 0x00000010
485 #define DSP_MAPELEMSIZE32 0x00000020
486 #define DSP_MAPELEMSIZE64 0x00000040
488 #define DSP_MAPVMALLOCADDR 0x00000080
490 #define DSP_MAPDONOTLOCK 0x00000100
492 #define DSP_MAP_DIR_MASK 0x3FFF
494 #define GEM_CACHE_LINE_SIZE 128
495 #define GEM_L1P_PREFETCH_SIZE 128
498 * Definitions from dbreg.h
501 #define DSPPROCTYPE_C64 6410
502 #define IVAPROCTYPE_ARM7 470
504 #define REG_MGR_OBJECT 1
505 #define REG_DRV_OBJECT 2
508 #define DRVOBJECT "DrvObject"
509 #define MGROBJECT "MgrObject"
511 /* Max registry path length. Also the max registry value length. */
512 #define MAXREGPATHLENGTH 255