Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Intel SST generic IPC Support
0004  *
0005  * Copyright (C) 2015, Intel Corporation. All rights reserved.
0006  */
0007 
0008 #ifndef __SST_GENERIC_IPC_H
0009 #define __SST_GENERIC_IPC_H
0010 
0011 #include <linux/types.h>
0012 #include <linux/kernel.h>
0013 #include <linux/wait.h>
0014 #include <linux/list.h>
0015 #include <linux/workqueue.h>
0016 #include <linux/sched.h>
0017 
0018 struct sst_ipc_message {
0019     u64 header;
0020     void *data;
0021     size_t size;
0022 };
0023 
0024 struct ipc_message {
0025     struct list_head list;
0026     struct sst_ipc_message tx;
0027     struct sst_ipc_message rx;
0028 
0029     wait_queue_head_t waitq;
0030     bool pending;
0031     bool complete;
0032     bool wait;
0033     int errno;
0034 };
0035 
0036 struct sst_generic_ipc;
0037 struct sst_dsp;
0038 
0039 struct sst_plat_ipc_ops {
0040     void (*tx_msg)(struct sst_generic_ipc *, struct ipc_message *);
0041     void (*shim_dbg)(struct sst_generic_ipc *, const char *);
0042     void (*tx_data_copy)(struct ipc_message *, char *, size_t);
0043     u64  (*reply_msg_match)(u64 header, u64 *mask);
0044     bool (*is_dsp_busy)(struct sst_dsp *dsp);
0045     int (*check_dsp_lp_on)(struct sst_dsp *dsp, bool state);
0046 };
0047 
0048 /* SST generic IPC data */
0049 struct sst_generic_ipc {
0050     struct device *dev;
0051     struct sst_dsp *dsp;
0052 
0053     /* IPC messaging */
0054     struct list_head tx_list;
0055     struct list_head rx_list;
0056     struct list_head empty_list;
0057     wait_queue_head_t wait_txq;
0058     struct task_struct *tx_thread;
0059     struct work_struct kwork;
0060     bool pending;
0061     struct ipc_message *msg;
0062     int tx_data_max_size;
0063     int rx_data_max_size;
0064 
0065     struct sst_plat_ipc_ops ops;
0066 };
0067 
0068 int sst_ipc_tx_message_wait(struct sst_generic_ipc *ipc,
0069     struct sst_ipc_message request, struct sst_ipc_message *reply);
0070 
0071 int sst_ipc_tx_message_nowait(struct sst_generic_ipc *ipc,
0072     struct sst_ipc_message request);
0073 
0074 int sst_ipc_tx_message_nopm(struct sst_generic_ipc *ipc,
0075     struct sst_ipc_message request, struct sst_ipc_message *reply);
0076 
0077 struct ipc_message *sst_ipc_reply_find_msg(struct sst_generic_ipc *ipc,
0078     u64 header);
0079 
0080 void sst_ipc_tx_msg_reply_complete(struct sst_generic_ipc *ipc,
0081     struct ipc_message *msg);
0082 
0083 int sst_ipc_init(struct sst_generic_ipc *ipc);
0084 void sst_ipc_fini(struct sst_generic_ipc *ipc);
0085 
0086 #endif