18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Intel SKL IPC Support 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2014-15, Intel Corporation. 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#ifndef __SKL_IPC_H 98c2ecf20Sopenharmony_ci#define __SKL_IPC_H 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#include <linux/irqreturn.h> 128c2ecf20Sopenharmony_ci#include "../common/sst-ipc.h" 138c2ecf20Sopenharmony_ci#include "skl-sst-dsp.h" 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_cistruct sst_dsp; 168c2ecf20Sopenharmony_cistruct sst_generic_ipc; 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_cienum skl_ipc_pipeline_state { 198c2ecf20Sopenharmony_ci PPL_INVALID_STATE = 0, 208c2ecf20Sopenharmony_ci PPL_UNINITIALIZED = 1, 218c2ecf20Sopenharmony_ci PPL_RESET = 2, 228c2ecf20Sopenharmony_ci PPL_PAUSED = 3, 238c2ecf20Sopenharmony_ci PPL_RUNNING = 4, 248c2ecf20Sopenharmony_ci PPL_ERROR_STOP = 5, 258c2ecf20Sopenharmony_ci PPL_SAVED = 6, 268c2ecf20Sopenharmony_ci PPL_RESTORED = 7 278c2ecf20Sopenharmony_ci}; 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_cistruct skl_ipc_dxstate_info { 308c2ecf20Sopenharmony_ci u32 core_mask; 318c2ecf20Sopenharmony_ci u32 dx_mask; 328c2ecf20Sopenharmony_ci}; 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_cistruct skl_ipc_header { 358c2ecf20Sopenharmony_ci u32 primary; 368c2ecf20Sopenharmony_ci u32 extension; 378c2ecf20Sopenharmony_ci}; 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_cistruct skl_dsp_cores { 408c2ecf20Sopenharmony_ci unsigned int count; 418c2ecf20Sopenharmony_ci enum skl_dsp_states *state; 428c2ecf20Sopenharmony_ci int *usage_count; 438c2ecf20Sopenharmony_ci}; 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci/** 468c2ecf20Sopenharmony_ci * skl_d0i3_data: skl D0i3 counters data struct 478c2ecf20Sopenharmony_ci * 488c2ecf20Sopenharmony_ci * @streaming: Count of usecases that can attempt streaming D0i3 498c2ecf20Sopenharmony_ci * @non_streaming: Count of usecases that can attempt non-streaming D0i3 508c2ecf20Sopenharmony_ci * @non_d0i3: Count of usecases that cannot attempt D0i3 518c2ecf20Sopenharmony_ci * @state: current state 528c2ecf20Sopenharmony_ci * @work: D0i3 worker thread 538c2ecf20Sopenharmony_ci */ 548c2ecf20Sopenharmony_cistruct skl_d0i3_data { 558c2ecf20Sopenharmony_ci int streaming; 568c2ecf20Sopenharmony_ci int non_streaming; 578c2ecf20Sopenharmony_ci int non_d0i3; 588c2ecf20Sopenharmony_ci enum skl_dsp_d0i3_states state; 598c2ecf20Sopenharmony_ci struct delayed_work work; 608c2ecf20Sopenharmony_ci}; 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci#define SKL_LIB_NAME_LENGTH 128 638c2ecf20Sopenharmony_ci#define SKL_MAX_LIB 16 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_cistruct skl_lib_info { 668c2ecf20Sopenharmony_ci char name[SKL_LIB_NAME_LENGTH]; 678c2ecf20Sopenharmony_ci const struct firmware *fw; 688c2ecf20Sopenharmony_ci}; 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_cistruct skl_ipc_init_instance_msg { 718c2ecf20Sopenharmony_ci u32 module_id; 728c2ecf20Sopenharmony_ci u32 instance_id; 738c2ecf20Sopenharmony_ci u16 param_data_size; 748c2ecf20Sopenharmony_ci u8 ppl_instance_id; 758c2ecf20Sopenharmony_ci u8 core_id; 768c2ecf20Sopenharmony_ci u8 domain; 778c2ecf20Sopenharmony_ci}; 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_cistruct skl_ipc_bind_unbind_msg { 808c2ecf20Sopenharmony_ci u32 module_id; 818c2ecf20Sopenharmony_ci u32 instance_id; 828c2ecf20Sopenharmony_ci u32 dst_module_id; 838c2ecf20Sopenharmony_ci u32 dst_instance_id; 848c2ecf20Sopenharmony_ci u8 src_queue; 858c2ecf20Sopenharmony_ci u8 dst_queue; 868c2ecf20Sopenharmony_ci bool bind; 878c2ecf20Sopenharmony_ci}; 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_cistruct skl_ipc_large_config_msg { 908c2ecf20Sopenharmony_ci u32 module_id; 918c2ecf20Sopenharmony_ci u32 instance_id; 928c2ecf20Sopenharmony_ci u32 large_param_id; 938c2ecf20Sopenharmony_ci u32 param_data_size; 948c2ecf20Sopenharmony_ci}; 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_cistruct skl_ipc_d0ix_msg { 978c2ecf20Sopenharmony_ci u32 module_id; 988c2ecf20Sopenharmony_ci u32 instance_id; 998c2ecf20Sopenharmony_ci u8 streaming; 1008c2ecf20Sopenharmony_ci u8 wake; 1018c2ecf20Sopenharmony_ci}; 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ci#define SKL_IPC_BOOT_MSECS 3000 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_ci#define SKL_IPC_D3_MASK 0 1068c2ecf20Sopenharmony_ci#define SKL_IPC_D0_MASK 3 1078c2ecf20Sopenharmony_ci 1088c2ecf20Sopenharmony_ciirqreturn_t skl_dsp_irq_thread_handler(int irq, void *context); 1098c2ecf20Sopenharmony_ci 1108c2ecf20Sopenharmony_ciint skl_ipc_create_pipeline(struct sst_generic_ipc *ipc, 1118c2ecf20Sopenharmony_ci u16 ppl_mem_size, u8 ppl_type, u8 instance_id, u8 lp_mode); 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_ciint skl_ipc_delete_pipeline(struct sst_generic_ipc *ipc, u8 instance_id); 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_ciint skl_ipc_set_pipeline_state(struct sst_generic_ipc *ipc, 1168c2ecf20Sopenharmony_ci u8 instance_id, enum skl_ipc_pipeline_state state); 1178c2ecf20Sopenharmony_ci 1188c2ecf20Sopenharmony_ciint skl_ipc_save_pipeline(struct sst_generic_ipc *ipc, 1198c2ecf20Sopenharmony_ci u8 instance_id, int dma_id); 1208c2ecf20Sopenharmony_ci 1218c2ecf20Sopenharmony_ciint skl_ipc_restore_pipeline(struct sst_generic_ipc *ipc, u8 instance_id); 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_ciint skl_ipc_init_instance(struct sst_generic_ipc *ipc, 1248c2ecf20Sopenharmony_ci struct skl_ipc_init_instance_msg *msg, void *param_data); 1258c2ecf20Sopenharmony_ci 1268c2ecf20Sopenharmony_ciint skl_ipc_bind_unbind(struct sst_generic_ipc *ipc, 1278c2ecf20Sopenharmony_ci struct skl_ipc_bind_unbind_msg *msg); 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_ciint skl_ipc_load_modules(struct sst_generic_ipc *ipc, 1308c2ecf20Sopenharmony_ci u8 module_cnt, void *data); 1318c2ecf20Sopenharmony_ci 1328c2ecf20Sopenharmony_ciint skl_ipc_unload_modules(struct sst_generic_ipc *ipc, 1338c2ecf20Sopenharmony_ci u8 module_cnt, void *data); 1348c2ecf20Sopenharmony_ci 1358c2ecf20Sopenharmony_ciint skl_ipc_set_dx(struct sst_generic_ipc *ipc, 1368c2ecf20Sopenharmony_ci u8 instance_id, u16 module_id, struct skl_ipc_dxstate_info *dx); 1378c2ecf20Sopenharmony_ci 1388c2ecf20Sopenharmony_ciint skl_ipc_set_large_config(struct sst_generic_ipc *ipc, 1398c2ecf20Sopenharmony_ci struct skl_ipc_large_config_msg *msg, u32 *param); 1408c2ecf20Sopenharmony_ci 1418c2ecf20Sopenharmony_ciint skl_ipc_get_large_config(struct sst_generic_ipc *ipc, 1428c2ecf20Sopenharmony_ci struct skl_ipc_large_config_msg *msg, 1438c2ecf20Sopenharmony_ci u32 **payload, size_t *bytes); 1448c2ecf20Sopenharmony_ci 1458c2ecf20Sopenharmony_ciint skl_sst_ipc_load_library(struct sst_generic_ipc *ipc, 1468c2ecf20Sopenharmony_ci u8 dma_id, u8 table_id, bool wait); 1478c2ecf20Sopenharmony_ci 1488c2ecf20Sopenharmony_ciint skl_ipc_set_d0ix(struct sst_generic_ipc *ipc, 1498c2ecf20Sopenharmony_ci struct skl_ipc_d0ix_msg *msg); 1508c2ecf20Sopenharmony_ci 1518c2ecf20Sopenharmony_ciint skl_ipc_check_D0i0(struct sst_dsp *dsp, bool state); 1528c2ecf20Sopenharmony_ci 1538c2ecf20Sopenharmony_civoid skl_ipc_int_enable(struct sst_dsp *ctx); 1548c2ecf20Sopenharmony_civoid skl_ipc_op_int_enable(struct sst_dsp *ctx); 1558c2ecf20Sopenharmony_civoid skl_ipc_op_int_disable(struct sst_dsp *ctx); 1568c2ecf20Sopenharmony_civoid skl_ipc_int_disable(struct sst_dsp *ctx); 1578c2ecf20Sopenharmony_ci 1588c2ecf20Sopenharmony_cibool skl_ipc_int_status(struct sst_dsp *ctx); 1598c2ecf20Sopenharmony_civoid skl_ipc_free(struct sst_generic_ipc *ipc); 1608c2ecf20Sopenharmony_ciint skl_ipc_init(struct device *dev, struct skl_dev *skl); 1618c2ecf20Sopenharmony_civoid skl_clear_module_cnt(struct sst_dsp *ctx); 1628c2ecf20Sopenharmony_ci 1638c2ecf20Sopenharmony_civoid skl_ipc_process_reply(struct sst_generic_ipc *ipc, 1648c2ecf20Sopenharmony_ci struct skl_ipc_header header); 1658c2ecf20Sopenharmony_ciint skl_ipc_process_notification(struct sst_generic_ipc *ipc, 1668c2ecf20Sopenharmony_ci struct skl_ipc_header header); 1678c2ecf20Sopenharmony_civoid skl_ipc_tx_data_copy(struct ipc_message *msg, char *tx_data, 1688c2ecf20Sopenharmony_ci size_t tx_size); 1698c2ecf20Sopenharmony_ci#endif /* __SKL_IPC_H */ 170