1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#ifndef __SST_H__
25#define __SST_H__
26
27#include <linux/firmware.h>
28
29
30#define SST_DRV_NAME "intel_sst_driver"
31#define SST_MRFLD_PCI_ID 0x119A
32#define SST_BYT_ACPI_ID 0x80860F28
33#define SST_CHV_ACPI_ID 0x808622A8
34
35#define SST_SUSPEND_DELAY 2000
36#define FW_CONTEXT_MEM (64*1024)
37#define SST_ICCM_BOUNDARY 4
38#define SST_CONFIG_SSP_SIGN 0x7ffe8001
39
40#define MRFLD_FW_VIRTUAL_BASE 0xC0000000
41#define MRFLD_FW_DDR_BASE_OFFSET 0x0
42#define MRFLD_FW_FEATURE_BASE_OFFSET 0x4
43#define MRFLD_FW_BSS_RESET_BIT 0
44
45extern const struct dev_pm_ops intel_sst_pm;
46enum sst_states {
47 SST_FW_LOADING = 1,
48 SST_FW_RUNNING,
49 SST_RESET,
50 SST_SHUTDOWN,
51};
52
53enum sst_algo_ops {
54 SST_SET_ALGO = 0,
55 SST_GET_ALGO = 1,
56};
57
58#define SST_BLOCK_TIMEOUT 1000
59
60#define FW_SIGNATURE_SIZE 4
61#define FW_NAME_SIZE 32
62
63
64enum sst_stream_states {
65 STREAM_UN_INIT = 0,
66 STREAM_RUNNING = 1,
67 STREAM_PAUSED = 2,
68 STREAM_INIT = 3,
69};
70
71enum sst_ram_type {
72 SST_IRAM = 1,
73 SST_DRAM = 2,
74 SST_DDR = 5,
75 SST_CUSTOM_INFO = 7,
76};
77
78
79union interrupt_reg {
80 struct {
81 u64 done_interrupt:1;
82 u64 busy_interrupt:1;
83 u64 rsvd:62;
84 } part;
85 u64 full;
86};
87
88union sst_pisr_reg {
89 struct {
90 u32 pssp0:1;
91 u32 pssp1:1;
92 u32 rsvd0:3;
93 u32 dmac:1;
94 u32 rsvd1:26;
95 } part;
96 u32 full;
97};
98
99union sst_pimr_reg {
100 struct {
101 u32 ssp0:1;
102 u32 ssp1:1;
103 u32 rsvd0:3;
104 u32 dmac:1;
105 u32 rsvd1:10;
106 u32 ssp0_sc:1;
107 u32 ssp1_sc:1;
108 u32 rsvd2:3;
109 u32 dmac_sc:1;
110 u32 rsvd3:10;
111 } part;
112 u32 full;
113};
114
115union config_status_reg_mrfld {
116 struct {
117 u64 lpe_reset:1;
118 u64 lpe_reset_vector:1;
119 u64 runstall:1;
120 u64 pwaitmode:1;
121 u64 clk_sel:3;
122 u64 rsvd2:1;
123 u64 sst_clk:3;
124 u64 xt_snoop:1;
125 u64 rsvd3:4;
126 u64 clk_sel1:6;
127 u64 clk_enable:3;
128 u64 rsvd4:6;
129 u64 slim0baseclk:1;
130 u64 rsvd:32;
131 } part;
132 u64 full;
133};
134
135union interrupt_reg_mrfld {
136 struct {
137 u64 done_interrupt:1;
138 u64 busy_interrupt:1;
139 u64 rsvd:62;
140 } part;
141 u64 full;
142};
143
144union sst_imr_reg_mrfld {
145 struct {
146 u64 done_interrupt:1;
147 u64 busy_interrupt:1;
148 u64 rsvd:62;
149 } part;
150 u64 full;
151};
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166struct sst_block {
167 bool condition;
168 int ret_code;
169 void *data;
170 u32 size;
171 bool on;
172 u32 msg_id;
173 u32 drv_id;
174 struct list_head node;
175};
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191struct stream_info {
192 unsigned int status;
193 unsigned int prev;
194 unsigned int resume_status;
195 unsigned int resume_prev;
196 struct mutex lock;
197 struct snd_sst_alloc_mrfld alloc_param;
198
199 void *pcm_substream;
200 void (*period_elapsed)(void *pcm_substream);
201
202 unsigned int sfreq;
203 u32 cumm_bytes;
204
205 void *compr_cb_param;
206 void (*compr_cb)(void *compr_cb_param);
207
208 void *drain_cb_param;
209 void (*drain_notify)(void *drain_cb_param);
210
211 unsigned int num_ch;
212 unsigned int pipe_id;
213 unsigned int task_id;
214};
215
216#define SST_FW_SIGN "$SST"
217#define SST_FW_LIB_SIGN "$LIB"
218
219
220
221
222
223
224
225
226
227
228struct sst_fw_header {
229 unsigned char signature[FW_SIGNATURE_SIZE];
230 u32 file_size;
231 u32 modules;
232 u32 file_format;
233 u32 reserved[4];
234};
235
236
237
238
239
240
241
242
243
244
245struct fw_module_header {
246 unsigned char signature[FW_SIGNATURE_SIZE];
247 u32 mod_size;
248 u32 blocks;
249 u32 type;
250 u32 entry_point;
251};
252
253
254
255
256
257
258
259
260struct fw_block_info {
261 enum sst_ram_type type;
262 u32 size;
263 u32 ram_offset;
264 u32 rsvd;
265};
266
267struct sst_runtime_param {
268 struct snd_sst_runtime_params param;
269};
270
271struct sst_sg_list {
272 struct scatterlist *src;
273 struct scatterlist *dst;
274 int list_len;
275 unsigned int sg_idx;
276};
277
278struct sst_memcpy_list {
279 struct list_head memcpylist;
280 void *dstn;
281 const void *src;
282 u32 size;
283 bool is_io;
284};
285
286
287enum sst_lib_dwnld_status {
288 SST_LIB_NOT_FOUND = 0,
289 SST_LIB_FOUND,
290 SST_LIB_DOWNLOADED,
291};
292
293struct sst_module_info {
294 const char *name;
295 u32 id;
296 u32 entry_pt;
297 u8 status;
298 u8 rsvd1;
299 u16 rsvd2;
300};
301
302
303
304
305
306struct sst_mem_mgr {
307 phys_addr_t current_base;
308 int avail;
309 unsigned int count;
310};
311
312struct sst_ipc_reg {
313 int ipcx;
314 int ipcd;
315};
316
317struct sst_fw_save {
318 void *iram;
319 void *dram;
320 void *sram;
321 void *ddr;
322};
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359struct intel_sst_drv {
360 int sst_state;
361 int irq_num;
362 unsigned int dev_id;
363 void __iomem *ddr;
364 void __iomem *shim;
365 void __iomem *mailbox;
366 void __iomem *iram;
367 void __iomem *dram;
368 unsigned int mailbox_add;
369 unsigned int iram_base;
370 unsigned int dram_base;
371 unsigned int shim_phy_add;
372 unsigned int iram_end;
373 unsigned int dram_end;
374 unsigned int ddr_end;
375 unsigned int ddr_base;
376 unsigned int mailbox_recv_offset;
377 struct list_head block_list;
378 struct list_head ipc_dispatch_list;
379 struct sst_platform_info *pdata;
380 struct list_head rx_list;
381 struct work_struct ipc_post_msg_wq;
382 wait_queue_head_t wait_queue;
383 struct workqueue_struct *post_msg_wq;
384 unsigned int tstamp;
385
386 struct stream_info streams[MAX_NUM_STREAMS+1];
387 spinlock_t ipc_spin_lock;
388 spinlock_t block_lock;
389 spinlock_t rx_msg_lock;
390 struct pci_dev *pci;
391 struct device *dev;
392 volatile long unsigned pvt_id;
393 struct mutex sst_lock;
394 unsigned int stream_cnt;
395 unsigned int csr_value;
396 void *fw_in_mem;
397 struct sst_sg_list fw_sg_list, library_list;
398 struct intel_sst_ops *ops;
399 struct sst_info info;
400 struct pm_qos_request *qos;
401 unsigned int use_dma;
402 unsigned int use_lli;
403 atomic_t fw_clear_context;
404 bool lib_dwnld_reqd;
405 struct list_head memcpy_list;
406 struct sst_ipc_reg ipc_reg;
407 struct sst_mem_mgr lib_mem_mgr;
408
409
410
411
412 char firmware_name[FW_NAME_SIZE];
413
414 struct snd_sst_fw_version fw_version;
415 struct sst_fw_save *fw_save;
416};
417
418
419#define FW_DWNL_ID 0x01
420
421struct intel_sst_ops {
422 irqreturn_t (*interrupt)(int, void *);
423 irqreturn_t (*irq_thread)(int, void *);
424 void (*clear_interrupt)(struct intel_sst_drv *ctx);
425 int (*start)(struct intel_sst_drv *ctx);
426 int (*reset)(struct intel_sst_drv *ctx);
427 void (*process_reply)(struct intel_sst_drv *ctx, struct ipc_post *msg);
428 int (*post_message)(struct intel_sst_drv *ctx,
429 struct ipc_post *msg, bool sync);
430 void (*process_message)(struct ipc_post *msg);
431 void (*set_bypass)(bool set);
432 int (*save_dsp_context)(struct intel_sst_drv *sst);
433 void (*restore_dsp_context)(void);
434 int (*alloc_stream)(struct intel_sst_drv *ctx, void *params);
435 void (*post_download)(struct intel_sst_drv *sst);
436};
437
438int sst_realloc_stream(struct intel_sst_drv *sst_drv_ctx, int str_id);
439int sst_pause_stream(struct intel_sst_drv *sst_drv_ctx, int id);
440int sst_resume_stream(struct intel_sst_drv *sst_drv_ctx, int id);
441int sst_drop_stream(struct intel_sst_drv *sst_drv_ctx, int id);
442int sst_free_stream(struct intel_sst_drv *sst_drv_ctx, int id);
443int sst_start_stream(struct intel_sst_drv *sst_drv_ctx, int str_id);
444int sst_send_byte_stream_mrfld(struct intel_sst_drv *ctx,
445 struct snd_sst_bytes_v2 *sbytes);
446int sst_set_stream_param(int str_id, struct snd_sst_params *str_param);
447int sst_set_metadata(int str_id, char *params);
448int sst_get_stream(struct intel_sst_drv *sst_drv_ctx,
449 struct snd_sst_params *str_param);
450int sst_get_stream_allocated(struct intel_sst_drv *ctx,
451 struct snd_sst_params *str_param,
452 struct snd_sst_lib_download **lib_dnld);
453int sst_drain_stream(struct intel_sst_drv *sst_drv_ctx,
454 int str_id, bool partial_drain);
455int sst_post_message_mrfld(struct intel_sst_drv *ctx,
456 struct ipc_post *msg, bool sync);
457void sst_process_reply_mrfld(struct intel_sst_drv *ctx, struct ipc_post *msg);
458int sst_start_mrfld(struct intel_sst_drv *ctx);
459int intel_sst_reset_dsp_mrfld(struct intel_sst_drv *ctx);
460void intel_sst_clear_intr_mrfld(struct intel_sst_drv *ctx);
461
462int sst_load_fw(struct intel_sst_drv *ctx);
463int sst_load_library(struct snd_sst_lib_download *lib, u8 ops);
464void sst_post_download_mrfld(struct intel_sst_drv *ctx);
465int sst_get_block_stream(struct intel_sst_drv *sst_drv_ctx);
466void sst_memcpy_free_resources(struct intel_sst_drv *ctx);
467
468int sst_wait_interruptible(struct intel_sst_drv *sst_drv_ctx,
469 struct sst_block *block);
470int sst_wait_timeout(struct intel_sst_drv *sst_drv_ctx,
471 struct sst_block *block);
472int sst_create_ipc_msg(struct ipc_post **arg, bool large);
473int free_stream_context(struct intel_sst_drv *ctx, unsigned int str_id);
474void sst_clean_stream(struct stream_info *stream);
475int intel_sst_register_compress(struct intel_sst_drv *sst);
476int intel_sst_remove_compress(struct intel_sst_drv *sst);
477void sst_cdev_fragment_elapsed(struct intel_sst_drv *ctx, int str_id);
478int sst_send_sync_msg(int ipc, int str_id);
479int sst_get_num_channel(struct snd_sst_params *str_param);
480int sst_get_sfreq(struct snd_sst_params *str_param);
481int sst_alloc_stream_mrfld(struct intel_sst_drv *sst_drv_ctx, void *params);
482void sst_restore_fw_context(void);
483struct sst_block *sst_create_block(struct intel_sst_drv *ctx,
484 u32 msg_id, u32 drv_id);
485int sst_create_block_and_ipc_msg(struct ipc_post **arg, bool large,
486 struct intel_sst_drv *sst_drv_ctx, struct sst_block **block,
487 u32 msg_id, u32 drv_id);
488int sst_free_block(struct intel_sst_drv *ctx, struct sst_block *freed);
489int sst_wake_up_block(struct intel_sst_drv *ctx, int result,
490 u32 drv_id, u32 ipc, void *data, u32 size);
491int sst_request_firmware_async(struct intel_sst_drv *ctx);
492int sst_driver_ops(struct intel_sst_drv *sst);
493struct sst_platform_info *sst_get_acpi_driver_data(const char *hid);
494void sst_firmware_load_cb(const struct firmware *fw, void *context);
495int sst_prepare_and_post_msg(struct intel_sst_drv *sst,
496 int task_id, int ipc_msg, int cmd_id, int pipe_id,
497 size_t mbox_data_len, const void *mbox_data, void **data,
498 bool large, bool fill_dsp, bool sync, bool response);
499
500void sst_process_pending_msg(struct work_struct *work);
501int sst_assign_pvt_id(struct intel_sst_drv *sst_drv_ctx);
502int sst_validate_strid(struct intel_sst_drv *sst_drv_ctx, int str_id);
503struct stream_info *get_stream_info(struct intel_sst_drv *sst_drv_ctx,
504 int str_id);
505int get_stream_id_mrfld(struct intel_sst_drv *sst_drv_ctx,
506 u32 pipe_id);
507u32 relocate_imr_addr_mrfld(u32 base_addr);
508void sst_add_to_dispatch_list_and_post(struct intel_sst_drv *sst,
509 struct ipc_post *msg);
510int sst_pm_runtime_put(struct intel_sst_drv *sst_drv);
511int sst_shim_write(void __iomem *addr, int offset, int value);
512u32 sst_shim_read(void __iomem *addr, int offset);
513u64 sst_reg_read64(void __iomem *addr, int offset);
514int sst_shim_write64(void __iomem *addr, int offset, u64 value);
515u64 sst_shim_read64(void __iomem *addr, int offset);
516void sst_set_fw_state_locked(
517 struct intel_sst_drv *sst_drv_ctx, int sst_state);
518void sst_fill_header_mrfld(union ipc_header_mrfld *header,
519 int msg, int task_id, int large, int drv_id);
520void sst_fill_header_dsp(struct ipc_dsp_hdr *dsp, int msg,
521 int pipe_id, int len);
522
523int sst_register(struct device *);
524int sst_unregister(struct device *);
525
526int sst_alloc_drv_context(struct intel_sst_drv **ctx,
527 struct device *dev, unsigned int dev_id);
528int sst_context_init(struct intel_sst_drv *ctx);
529void sst_context_cleanup(struct intel_sst_drv *ctx);
530void sst_configure_runtime_pm(struct intel_sst_drv *ctx);
531void memcpy32_toio(void __iomem *dst, const void *src, int count);
532void memcpy32_fromio(void *dst, const void __iomem *src, int count);
533
534#endif
535