18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Intel SST generic IPC Support 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2015, Intel Corporation. All rights reserved. 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#ifndef __SST_GENERIC_IPC_H 98c2ecf20Sopenharmony_ci#define __SST_GENERIC_IPC_H 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#include <linux/types.h> 128c2ecf20Sopenharmony_ci#include <linux/kernel.h> 138c2ecf20Sopenharmony_ci#include <linux/wait.h> 148c2ecf20Sopenharmony_ci#include <linux/list.h> 158c2ecf20Sopenharmony_ci#include <linux/workqueue.h> 168c2ecf20Sopenharmony_ci#include <linux/sched.h> 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_cistruct sst_ipc_message { 198c2ecf20Sopenharmony_ci u64 header; 208c2ecf20Sopenharmony_ci void *data; 218c2ecf20Sopenharmony_ci size_t size; 228c2ecf20Sopenharmony_ci}; 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_cistruct ipc_message { 258c2ecf20Sopenharmony_ci struct list_head list; 268c2ecf20Sopenharmony_ci struct sst_ipc_message tx; 278c2ecf20Sopenharmony_ci struct sst_ipc_message rx; 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci wait_queue_head_t waitq; 308c2ecf20Sopenharmony_ci bool pending; 318c2ecf20Sopenharmony_ci bool complete; 328c2ecf20Sopenharmony_ci bool wait; 338c2ecf20Sopenharmony_ci int errno; 348c2ecf20Sopenharmony_ci}; 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_cistruct sst_generic_ipc; 378c2ecf20Sopenharmony_cistruct sst_dsp; 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_cistruct sst_plat_ipc_ops { 408c2ecf20Sopenharmony_ci void (*tx_msg)(struct sst_generic_ipc *, struct ipc_message *); 418c2ecf20Sopenharmony_ci void (*shim_dbg)(struct sst_generic_ipc *, const char *); 428c2ecf20Sopenharmony_ci void (*tx_data_copy)(struct ipc_message *, char *, size_t); 438c2ecf20Sopenharmony_ci u64 (*reply_msg_match)(u64 header, u64 *mask); 448c2ecf20Sopenharmony_ci bool (*is_dsp_busy)(struct sst_dsp *dsp); 458c2ecf20Sopenharmony_ci int (*check_dsp_lp_on)(struct sst_dsp *dsp, bool state); 468c2ecf20Sopenharmony_ci}; 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci/* SST generic IPC data */ 498c2ecf20Sopenharmony_cistruct sst_generic_ipc { 508c2ecf20Sopenharmony_ci struct device *dev; 518c2ecf20Sopenharmony_ci struct sst_dsp *dsp; 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci /* IPC messaging */ 548c2ecf20Sopenharmony_ci struct list_head tx_list; 558c2ecf20Sopenharmony_ci struct list_head rx_list; 568c2ecf20Sopenharmony_ci struct list_head empty_list; 578c2ecf20Sopenharmony_ci wait_queue_head_t wait_txq; 588c2ecf20Sopenharmony_ci struct task_struct *tx_thread; 598c2ecf20Sopenharmony_ci struct work_struct kwork; 608c2ecf20Sopenharmony_ci bool pending; 618c2ecf20Sopenharmony_ci struct ipc_message *msg; 628c2ecf20Sopenharmony_ci int tx_data_max_size; 638c2ecf20Sopenharmony_ci int rx_data_max_size; 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci struct sst_plat_ipc_ops ops; 668c2ecf20Sopenharmony_ci}; 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ciint sst_ipc_tx_message_wait(struct sst_generic_ipc *ipc, 698c2ecf20Sopenharmony_ci struct sst_ipc_message request, struct sst_ipc_message *reply); 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ciint sst_ipc_tx_message_nowait(struct sst_generic_ipc *ipc, 728c2ecf20Sopenharmony_ci struct sst_ipc_message request); 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ciint sst_ipc_tx_message_nopm(struct sst_generic_ipc *ipc, 758c2ecf20Sopenharmony_ci struct sst_ipc_message request, struct sst_ipc_message *reply); 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_cistruct ipc_message *sst_ipc_reply_find_msg(struct sst_generic_ipc *ipc, 788c2ecf20Sopenharmony_ci u64 header); 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_civoid sst_ipc_tx_msg_reply_complete(struct sst_generic_ipc *ipc, 818c2ecf20Sopenharmony_ci struct ipc_message *msg); 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ciint sst_ipc_init(struct sst_generic_ipc *ipc); 848c2ecf20Sopenharmony_civoid sst_ipc_fini(struct sst_generic_ipc *ipc); 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_ci#endif 87