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 /* Maximum length of node name, used in dsp_ndbprops */
35 #define DSP_MAXNAMELEN 32
37 /* notify_type values for the RegisterNotify() functions. */
38 #define DSP_SIGNALEVENT 0x00000001
40 /* Types of events for processors */
41 #define DSP_PROCESSORSTATECHANGE 0x00000001
42 #define DSP_PROCESSORATTACH 0x00000002
43 #define DSP_PROCESSORDETACH 0x00000004
44 #define DSP_PROCESSORRESTART 0x00000008
46 /* DSP exception events (DSP/BIOS and DSP MMU fault) */
47 #define DSP_MMUFAULT 0x00000010
48 #define DSP_SYSERROR 0x00000020
49 #define DSP_EXCEPTIONABORT 0x00000300
50 #define DSP_PWRERROR 0x00000080
51 #define DSP_WDTOVERFLOW 0x00000040
53 /* IVA exception events (IVA MMU fault) */
54 #define IVA_MMUFAULT 0x00000040
55 /* Types of events for nodes */
56 #define DSP_NODESTATECHANGE 0x00000100
57 #define DSP_NODEMESSAGEREADY 0x00000200
59 /* Types of events for streams */
60 #define DSP_STREAMDONE 0x00001000
61 #define DSP_STREAMIOCOMPLETION 0x00002000
63 /* Handle definition representing the GPP node in DSPNode_Connect() calls */
64 #define DSP_HGPPNODE 0xFFFFFFFF
66 /* Node directions used in DSPNode_Connect() */
68 #define DSP_FROMNODE 2
70 /* Define Node Minimum and Maximum Priorities */
71 #define DSP_NODE_MIN_PRIORITY 1
72 #define DSP_NODE_MAX_PRIORITY 15
74 /* msg_ctrl contains SM buffer description */
75 #define DSP_RMSBUFDESC RMS_BUFDESC
77 /* Processor ID numbers */
81 #define DSPWORD unsigned char
82 #define DSPWORDSIZE sizeof(DSPWORD)
84 #define MAX_PROFILES 16
87 #define DSPTYPE64 0x99
90 #define VALID_PROC_EVENT (DSP_PROCESSORSTATECHANGE | DSP_PROCESSORATTACH | \
91 DSP_PROCESSORDETACH | DSP_PROCESSORRESTART | DSP_NODESTATECHANGE | \
92 DSP_STREAMDONE | DSP_STREAMIOCOMPLETION | DSP_MMUFAULT | \
93 DSP_SYSERROR | DSP_WDTOVERFLOW | DSP_PWRERROR)
95 static inline bool is_valid_proc_event(u32 x)
97 return (x == 0 || (x & VALID_PROC_EVENT && !(x & ~VALID_PROC_EVENT)));
100 /* The Node UUID structure */
111 enum dsp_dcdobjtype {
113 DSP_DCDPROCESSORTYPE,
115 DSP_DCDCREATELIBTYPE,
116 DSP_DCDEXECUTELIBTYPE,
117 DSP_DCDDELETELIBTYPE,
118 /* DSP_DCDMAXOBJTYPE is meant to be the last DCD object type */
122 /* Processor states */
131 * Node types: Message node, task node, xDAIS socket node, and
132 * device node. _NODE_GPP is used when defining a stream connection
133 * between a task or socket node and the GPP.
145 * ======== node_state ========
146 * Internal node states.
162 enum dsp_streamstate {
169 /* Stream connect types */
170 enum dsp_connecttype {
171 CONNECTTYPE_NODEOUTPUT,
172 CONNECTTYPE_GPPOUTPUT,
173 CONNECTTYPE_NODEINPUT,
177 /* Stream mode types */
179 STRMMODE_PROCCOPY, /* Processor(s) copy stream data payloads */
180 STRMMODE_ZEROCOPY, /* Strm buffer ptrs swapped no data copied */
181 STRMMODE_LDMA, /* Local DMA : OMAP's System-DMA device */
182 STRMMODE_RDMA /* Remote DMA: OMAP's DSP-DMA device */
186 enum dsp_resourceinfotype {
187 DSP_RESOURCE_DYNDARAM = 0,
188 DSP_RESOURCE_DYNSARAM,
189 DSP_RESOURCE_DYNEXTERNAL,
190 DSP_RESOURCE_DYNSRAM,
191 DSP_RESOURCE_PROCLOAD
194 /* Memory Segment Types */
202 /* Memory Flush Types */
204 PROC_INVALIDATE_MEM = 0,
206 PROC_WRITEBACK_INVALIDATE_MEM,
209 /* Memory Segment Status Values */
213 u32 len_max_free_block;
215 u32 num_alloc_blocks;
218 /* Processor Load information Values */
219 struct dsp_procloadstat {
226 /* Attributes for STRM connections between nodes */
227 struct dsp_strmattr {
228 u32 seg_id; /* Memory segment on DSP to allocate buffers */
229 u32 buf_size; /* Buffer size (DSP words) */
230 u32 num_bufs; /* Number of buffers */
231 u32 buf_alignment; /* Buffer alignment */
232 u32 timeout; /* Timeout for blocking STRM calls */
233 enum dsp_strmmode strm_mode; /* mode of stream when opened */
234 /* DMA chnl id if dsp_strmmode is LDMA or RDMA */
236 u32 dma_priority; /* DMA channel priority 0=lowest, >0=high */
239 /* The dsp_cbdata structure */
245 /* The dsp_msg structure */
252 /* The dsp_resourcereqmts structure for node's resource requirements */
253 struct dsp_resourcereqmts {
255 u32 static_data_size;
256 u32 global_data_size;
257 u32 program_mem_size;
258 u32 wc_execution_time;
261 u32 avg_exection_time;
266 * The dsp_streamconnect structure describes a stream connection
267 * between two nodes, or between a node and the GPP
269 struct dsp_streamconnect {
271 enum dsp_connecttype connect_type;
272 u32 this_node_stream_index;
273 void *connected_node;
274 struct dsp_uuid ui_connected_node_id;
275 u32 connected_node_stream_index;
278 struct dsp_nodeprofs {
282 /* The dsp_ndbprops structure reports the attributes of a node */
283 struct dsp_ndbprops {
285 struct dsp_uuid ui_node_id;
286 char ac_name[DSP_MAXNAMELEN];
287 enum node_type ntype;
289 struct dsp_resourcereqmts dsp_resource_reqmts;
295 u32 num_input_streams;
296 u32 num_output_streams;
298 u32 count_profiles; /* Number of supported profiles */
299 /* Array of profiles */
300 struct dsp_nodeprofs node_profiles[MAX_PROFILES];
301 u32 stack_seg_name; /* Stack Segment Name */
304 /* The dsp_nodeattrin structure describes the attributes of a
306 struct dsp_nodeattrin {
311 /* Reserved, for Bridge Internal use only */
313 void *pgpp_virt_addr; /* Reserved, for Bridge Internal use only */
316 /* The dsp_nodeinfo structure is used to retrieve information
318 struct dsp_nodeinfo {
320 struct dsp_ndbprops nb_node_database_props;
321 u32 execution_priority;
322 enum node_state ns_execution_state;
325 struct dsp_streamconnect sc_stream_connection[16];
329 /* The dsp_nodeattr structure describes the attributes of a node */
330 struct dsp_nodeattr {
332 struct dsp_nodeattrin in_node_attr_in;
333 u32 node_attr_inputs;
334 u32 node_attr_outputs;
335 struct dsp_nodeinfo node_info;
339 * Notification type: either the name of an opened event, or an event or
342 struct dsp_notification {
347 /* The dsp_processorattrin structure describes the attributes of a processor */
348 struct dsp_processorattrin {
353 * The dsp_processorinfo structure describes basic capabilities of a
356 struct dsp_processorinfo {
358 int processor_family;
361 u32 internal_mem_size;
362 u32 external_mem_size;
365 s32 node_min_priority;
366 s32 node_max_priority;
369 /* Error information of last DSP exception signalled to the GPP */
370 struct dsp_errorinfo {
377 /* The dsp_processorstate structure describes the state of a DSP processor */
378 struct dsp_processorstate {
380 enum dsp_procstate proc_state;
384 * The dsp_resourceinfo structure is used to retrieve information about a
385 * processor's resources
387 struct dsp_resourceinfo {
389 enum dsp_resourceinfotype resource_type;
392 struct dsp_memstat mem_stat;
393 struct dsp_procloadstat proc_load_stat;
398 * The dsp_streamattrin structure describes the attributes of a stream,
399 * including segment and alignment of data buffers allocated with
400 * DSPStream_AllocateBuffers(), if applicable
402 struct dsp_streamattrin {
408 enum dsp_strmmode strm_mode;
413 /* The dsp_bufferattr structure describes the attributes of a data buffer */
414 struct dsp_bufferattr {
421 * The dsp_streaminfo structure is used to retrieve information
424 struct dsp_streaminfo {
426 u32 number_bufs_allowed;
427 u32 number_bufs_in_stream;
429 void *sync_object_handle;
430 enum dsp_streamstate ss_stream_state;
433 /* DMM MAP attributes
434 It is a bit mask with each bit value indicating a specific attribute
435 bit 0 - GPP address type (user virtual=0, physical=1)
436 bit 1 - MMU Endianism (Big Endian=1, Little Endian=0)
437 bit 2 - MMU mixed page attribute (Mixed/ CPUES=1, TLBES =0)
438 bit 3 - MMU element size = 8bit (valid only for non mixed page entries)
439 bit 4 - MMU element size = 16bit (valid only for non mixed page entries)
440 bit 5 - MMU element size = 32bit (valid only for non mixed page entries)
441 bit 6 - MMU element size = 64bit (valid only for non mixed page entries)
443 bit 14 - Input (read only) buffer
444 bit 15 - Output (writeable) buffer
447 /* Types of mapping attributes */
449 /* MPU address is virtual and needs to be translated to physical addr */
450 #define DSP_MAPVIRTUALADDR 0x00000000
451 #define DSP_MAPPHYSICALADDR 0x00000001
453 /* Mapped data is big endian */
454 #define DSP_MAPBIGENDIAN 0x00000002
455 #define DSP_MAPLITTLEENDIAN 0x00000000
457 /* Element size is based on DSP r/w access size */
458 #define DSP_MAPMIXEDELEMSIZE 0x00000004
461 * Element size for MMU mapping (8, 16, 32, or 64 bit)
462 * Ignored if DSP_MAPMIXEDELEMSIZE enabled
464 #define DSP_MAPELEMSIZE8 0x00000008
465 #define DSP_MAPELEMSIZE16 0x00000010
466 #define DSP_MAPELEMSIZE32 0x00000020
467 #define DSP_MAPELEMSIZE64 0x00000040
469 #define DSP_MAPVMALLOCADDR 0x00000080
471 #define DSP_MAPDONOTLOCK 0x00000100
473 #define DSP_MAP_DIR_MASK 0x3FFF
475 #define GEM_CACHE_LINE_SIZE 128
476 #define GEM_L1P_PREFETCH_SIZE 128
479 * Definitions from dbreg.h
482 #define DSPPROCTYPE_C64 6410
483 #define IVAPROCTYPE_ARM7 470
485 /* Max registry path length. Also the max registry value length. */
486 #define MAXREGPATHLENGTH 255