1 /*
2  * cmmdefs.h
3  *
4  * DSP-BIOS Bridge driver support functions for TI OMAP processors.
5  *
6  * Global MEM constants and types.
7  *
8  * Copyright (C) 2008 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 CMMDEFS_
20 #define CMMDEFS_
21 
22 
23 /* Cmm attributes used in cmm_create() */
24 struct cmm_mgrattrs {
25 	/* Minimum SM allocation; default 32 bytes. */
26 	u32 min_block_size;
27 };
28 
29 /* Attributes for CMM_AllocBuf() & CMM_AllocDesc() */
30 struct cmm_attrs {
31 	u32 seg_id;		/*  1,2... are SM segments. 0 is not. */
32 	u32 alignment;		/*  0,1,2,4....min_block_size */
33 };
34 
35 /*
36  *  DSPPa to GPPPa Conversion Factor.
37  *
38  *  For typical platforms:
39  *      converted Address = PaDSP + ( c_factor * addressToConvert).
40  */
41 #define CMM_SUBFROMDSPPA	-1
42 #define CMM_ADDTODSPPA		1
43 
44 #define CMM_ALLSEGMENTS         0xFFFFFF	/* All SegIds */
45 #define CMM_MAXGPPSEGS          1	/* Maximum # of SM segs */
46 
47 /*
48  *  SMSEGs are SM segments the DSP allocates from.
49  *
50  *  This info is used by the GPP to xlate DSP allocated PAs.
51  */
52 
53 struct cmm_seginfo {
54 	u32 seg_base_pa;	/* Start Phys address of SM segment */
55 	/* Total size in bytes of segment: DSP+GPP */
56 	u32 total_seg_size;
57 	u32 gpp_base_pa;	/* Start Phys addr of Gpp SM seg */
58 	u32 gpp_size;	/* Size of Gpp SM seg in bytes */
59 	u32 dsp_base_va;	/* DSP virt base byte address */
60 	u32 dsp_size;		/* DSP seg size in bytes */
61 	/* # of current GPP allocations from this segment */
62 	u32 in_use_cnt;
63 	u32 seg_base_va;	/* Start Virt address of SM seg */
64 
65 };
66 
67 /* CMM useful information */
68 struct cmm_info {
69 	/* # of SM segments registered with this Cmm. */
70 	u32 num_gppsm_segs;
71 	/* Total # of allocations outstanding for CMM */
72 	u32 total_in_use_cnt;
73 	/* Min SM block size allocation from cmm_create() */
74 	u32 min_block_size;
75 	/* Info per registered SM segment. */
76 	struct cmm_seginfo seg_info[CMM_MAXGPPSEGS];
77 };
78 
79 /* XlatorCreate attributes */
80 struct cmm_xlatorattrs {
81 	u32 seg_id;		/* segment Id used for SM allocations */
82 	u32 dsp_bufs;		/* # of DSP-side bufs */
83 	u32 dsp_buf_size;	/* size of DSP-side bufs in GPP bytes */
84 	/* Vm base address alloc'd in client process context */
85 	void *vm_base;
86 	/* vm_size must be >= (dwMaxNumBufs * dwMaxSize) */
87 	u32 vm_size;
88 };
89 
90 /*
91  * Cmm translation types. Use to map SM addresses to process context.
92  */
93 enum cmm_xlatetype {
94 	CMM_VA2PA = 0,		/* Virtual to GPP physical address xlation */
95 	CMM_PA2VA = 1,		/* GPP Physical to virtual */
96 	CMM_VA2DSPPA = 2,	/* Va to DSP Pa */
97 	CMM_PA2DSPPA = 3,	/* GPP Pa to DSP Pa */
98 	CMM_DSPPA2PA = 4,	/* DSP Pa to GPP Pa */
99 };
100 
101 struct cmm_object;
102 struct cmm_xlatorobject;
103 
104 #endif /* CMMDEFS_ */
105