aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/intel/sst-dsp-priv.h
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/intel/sst-dsp-priv.h')
-rw-r--r--sound/soc/intel/sst-dsp-priv.h136
1 files changed, 92 insertions, 44 deletions
diff --git a/sound/soc/intel/sst-dsp-priv.h b/sound/soc/intel/sst-dsp-priv.h
index ffb308bd81ce..b9da030e312d 100644
--- a/sound/soc/intel/sst-dsp-priv.h
+++ b/sound/soc/intel/sst-dsp-priv.h
@@ -26,6 +26,9 @@ struct sst_mem_block;
26struct sst_module; 26struct sst_module;
27struct sst_fw; 27struct sst_fw;
28 28
29/* do we need to remove or keep */
30#define DSP_DRAM_ADDR_OFFSET 0x400000
31
29/* 32/*
30 * DSP Operations exported by platform Audio DSP driver. 33 * DSP Operations exported by platform Audio DSP driver.
31 */ 34 */
@@ -33,6 +36,9 @@ struct sst_ops {
33 /* DSP core boot / reset */ 36 /* DSP core boot / reset */
34 void (*boot)(struct sst_dsp *); 37 void (*boot)(struct sst_dsp *);
35 void (*reset)(struct sst_dsp *); 38 void (*reset)(struct sst_dsp *);
39 int (*wake)(struct sst_dsp *);
40 void (*sleep)(struct sst_dsp *);
41 void (*stall)(struct sst_dsp *);
36 42
37 /* Shim IO */ 43 /* Shim IO */
38 void (*write)(void __iomem *addr, u32 offset, u32 value); 44 void (*write)(void __iomem *addr, u32 offset, u32 value);
@@ -67,6 +73,8 @@ struct sst_addr {
67 u32 shim_offset; 73 u32 shim_offset;
68 u32 iram_offset; 74 u32 iram_offset;
69 u32 dram_offset; 75 u32 dram_offset;
76 u32 dsp_iram_offset;
77 u32 dsp_dram_offset;
70 void __iomem *lpe; 78 void __iomem *lpe;
71 void __iomem *shim; 79 void __iomem *shim;
72 void __iomem *pci_cfg; 80 void __iomem *pci_cfg;
@@ -84,15 +92,6 @@ struct sst_mailbox {
84}; 92};
85 93
86/* 94/*
87 * Audio DSP Firmware data types.
88 */
89enum sst_data_type {
90 SST_DATA_M = 0, /* module block data */
91 SST_DATA_P = 1, /* peristant data (text, data) */
92 SST_DATA_S = 2, /* scratch data (usually buffers) */
93};
94
95/*
96 * Audio DSP memory block types. 95 * Audio DSP memory block types.
97 */ 96 */
98enum sst_mem_type { 97enum sst_mem_type {
@@ -125,23 +124,6 @@ struct sst_fw {
125}; 124};
126 125
127/* 126/*
128 * Audio DSP Generic Module data.
129 *
130 * This is used to dsecribe any sections of persistent (text and data) and
131 * scratch (buffers) of module data in ADSP memory space.
132 */
133struct sst_module_data {
134
135 enum sst_mem_type type; /* destination memory type */
136 enum sst_data_type data_type; /* type of module data */
137
138 u32 size; /* size in bytes */
139 int32_t offset; /* offset in FW file */
140 u32 data_offset; /* offset in ADSP memory space */
141 void *data; /* module data */
142};
143
144/*
145 * Audio DSP Generic Module Template. 127 * Audio DSP Generic Module Template.
146 * 128 *
147 * Used to define and register a new FW module. This data is extracted from 129 * Used to define and register a new FW module. This data is extracted from
@@ -150,15 +132,52 @@ struct sst_module_data {
150struct sst_module_template { 132struct sst_module_template {
151 u32 id; 133 u32 id;
152 u32 entry; /* entry point */ 134 u32 entry; /* entry point */
153 struct sst_module_data s; /* scratch data */ 135 u32 scratch_size;
154 struct sst_module_data p; /* peristant data */ 136 u32 persistent_size;
137};
138
139/*
140 * Block Allocator - Used to allocate blocks of DSP memory.
141 */
142struct sst_block_allocator {
143 u32 id;
144 u32 offset;
145 int size;
146 enum sst_mem_type type;
147};
148
149/*
150 * Runtime Module Instance - A module object can be instanciated multiple
151 * times within the DSP FW.
152 */
153struct sst_module_runtime {
154 struct sst_dsp *dsp;
155 int id;
156 struct sst_module *module; /* parent module we belong too */
157
158 u32 persistent_offset; /* private memory offset */
159 void *private;
160
161 struct list_head list;
162 struct list_head block_list; /* list of blocks used */
163};
164
165/*
166 * Runtime Module Context - The runtime context must be manually stored by the
167 * driver prior to enter S3 and restored after leaving S3. This should really be
168 * part of the memory context saved by the enter D3 message IPC ???
169 */
170struct sst_module_runtime_context {
171 dma_addr_t dma_buffer;
172 u32 *buffer;
155}; 173};
156 174
157/* 175/*
158 * Audio DSP Generic Module. 176 * Audio DSP Generic Module.
159 * 177 *
160 * Each Firmware file can consist of 1..N modules. A module can span multiple 178 * Each Firmware file can consist of 1..N modules. A module can span multiple
161 * ADSP memory blocks. The simplest FW will be a file with 1 module. 179 * ADSP memory blocks. The simplest FW will be a file with 1 module. A module
180 * can be instanciated multiple times in the DSP.
162 */ 181 */
163struct sst_module { 182struct sst_module {
164 struct sst_dsp *dsp; 183 struct sst_dsp *dsp;
@@ -167,10 +186,13 @@ struct sst_module {
167 /* module configuration */ 186 /* module configuration */
168 u32 id; 187 u32 id;
169 u32 entry; /* module entry point */ 188 u32 entry; /* module entry point */
170 u32 offset; /* module offset in firmware file */ 189 s32 offset; /* module offset in firmware file */
171 u32 size; /* module size */ 190 u32 size; /* module size */
172 struct sst_module_data s; /* scratch data */ 191 u32 scratch_size; /* global scratch memory required */
173 struct sst_module_data p; /* peristant data */ 192 u32 persistent_size; /* private memory required */
193 enum sst_mem_type type; /* destination memory type */
194 u32 data_offset; /* offset in ADSP memory space */
195 void *data; /* module data */
174 196
175 /* runtime */ 197 /* runtime */
176 u32 usage_count; /* can be unloaded if count == 0 */ 198 u32 usage_count; /* can be unloaded if count == 0 */
@@ -180,6 +202,7 @@ struct sst_module {
180 struct list_head block_list; /* Module list of blocks in use */ 202 struct list_head block_list; /* Module list of blocks in use */
181 struct list_head list; /* DSP list of modules */ 203 struct list_head list; /* DSP list of modules */
182 struct list_head list_fw; /* FW list of modules */ 204 struct list_head list_fw; /* FW list of modules */
205 struct list_head runtime_list; /* list of runtime module objects*/
183}; 206};
184 207
185/* 208/*
@@ -208,7 +231,6 @@ struct sst_mem_block {
208 struct sst_block_ops *ops; /* block operations, if any */ 231 struct sst_block_ops *ops; /* block operations, if any */
209 232
210 /* block status */ 233 /* block status */
211 enum sst_data_type data_type; /* data type held in this block */
212 u32 bytes_used; /* bytes in use by modules */ 234 u32 bytes_used; /* bytes in use by modules */
213 void *private; /* generic core does not touch this */ 235 void *private; /* generic core does not touch this */
214 int users; /* number of modules using this block */ 236 int users; /* number of modules using this block */
@@ -253,6 +275,11 @@ struct sst_dsp {
253 struct list_head module_list; 275 struct list_head module_list;
254 struct list_head fw_list; 276 struct list_head fw_list;
255 277
278 /* scratch buffer */
279 struct list_head scratch_block_list;
280 u32 scratch_offset;
281 u32 scratch_size;
282
256 /* platform data */ 283 /* platform data */
257 struct sst_pdata *pdata; 284 struct sst_pdata *pdata;
258 285
@@ -290,18 +317,33 @@ void sst_fw_unload(struct sst_fw *sst_fw);
290/* Create/Free firmware modules */ 317/* Create/Free firmware modules */
291struct sst_module *sst_module_new(struct sst_fw *sst_fw, 318struct sst_module *sst_module_new(struct sst_fw *sst_fw,
292 struct sst_module_template *template, void *private); 319 struct sst_module_template *template, void *private);
293void sst_module_free(struct sst_module *sst_module); 320void sst_module_free(struct sst_module *module);
294int sst_module_insert(struct sst_module *sst_module);
295int sst_module_remove(struct sst_module *sst_module);
296int sst_module_insert_fixed_block(struct sst_module *module,
297 struct sst_module_data *data);
298struct sst_module *sst_module_get_from_id(struct sst_dsp *dsp, u32 id); 321struct sst_module *sst_module_get_from_id(struct sst_dsp *dsp, u32 id);
299 322int sst_module_alloc_blocks(struct sst_module *module);
300/* allocate/free pesistent/scratch memory regions managed by drv */ 323int sst_module_free_blocks(struct sst_module *module);
301struct sst_module *sst_mem_block_alloc_scratch(struct sst_dsp *dsp); 324
302void sst_mem_block_free_scratch(struct sst_dsp *dsp, 325/* Create/Free firmware module runtime instances */
303 struct sst_module *scratch); 326struct sst_module_runtime *sst_module_runtime_new(struct sst_module *module,
304int sst_block_module_remove(struct sst_module *module); 327 int id, void *private);
328void sst_module_runtime_free(struct sst_module_runtime *runtime);
329struct sst_module_runtime *sst_module_runtime_get_from_id(
330 struct sst_module *module, u32 id);
331int sst_module_runtime_alloc_blocks(struct sst_module_runtime *runtime,
332 int offset);
333int sst_module_runtime_free_blocks(struct sst_module_runtime *runtime);
334int sst_module_runtime_save(struct sst_module_runtime *runtime,
335 struct sst_module_runtime_context *context);
336int sst_module_runtime_restore(struct sst_module_runtime *runtime,
337 struct sst_module_runtime_context *context);
338
339/* generic block allocation */
340int sst_alloc_blocks(struct sst_dsp *dsp, struct sst_block_allocator *ba,
341 struct list_head *block_list);
342int sst_free_blocks(struct sst_dsp *dsp, struct list_head *block_list);
343
344/* scratch allocation */
345int sst_block_alloc_scratch(struct sst_dsp *dsp);
346void sst_block_free_scratch(struct sst_dsp *dsp);
305 347
306/* Register the DSPs memory blocks - would be nice to read from ACPI */ 348/* Register the DSPs memory blocks - would be nice to read from ACPI */
307struct sst_mem_block *sst_mem_block_register(struct sst_dsp *dsp, u32 offset, 349struct sst_mem_block *sst_mem_block_register(struct sst_dsp *dsp, u32 offset,
@@ -309,4 +351,10 @@ struct sst_mem_block *sst_mem_block_register(struct sst_dsp *dsp, u32 offset,
309 void *private); 351 void *private);
310void sst_mem_block_unregister_all(struct sst_dsp *dsp); 352void sst_mem_block_unregister_all(struct sst_dsp *dsp);
311 353
354/* Create/Free DMA resources */
355int sst_dma_new(struct sst_dsp *sst);
356void sst_dma_free(struct sst_dma *dma);
357
358u32 sst_dsp_get_offset(struct sst_dsp *dsp, u32 offset,
359 enum sst_mem_type type);
312#endif 360#endif