1
2
3
4
5
6
7
8#ifndef __SST_GENERIC_IPC_H
9#define __SST_GENERIC_IPC_H
10
11#include <linux/types.h>
12#include <linux/kernel.h>
13#include <linux/wait.h>
14#include <linux/list.h>
15#include <linux/workqueue.h>
16#include <linux/sched.h>
17
18#define IPC_MAX_MAILBOX_BYTES 256
19
20struct ipc_message {
21 struct list_head list;
22 u64 header;
23
24
25 char *tx_data;
26 size_t tx_size;
27 char *rx_data;
28 size_t rx_size;
29
30 wait_queue_head_t waitq;
31 bool pending;
32 bool complete;
33 bool wait;
34 int errno;
35};
36
37struct sst_generic_ipc;
38
39struct sst_plat_ipc_ops {
40 void (*tx_msg)(struct sst_generic_ipc *, struct ipc_message *);
41 void (*shim_dbg)(struct sst_generic_ipc *, const char *);
42 void (*tx_data_copy)(struct ipc_message *, char *, size_t);
43 u64 (*reply_msg_match)(u64 header, u64 *mask);
44 bool (*is_dsp_busy)(struct sst_dsp *dsp);
45 int (*check_dsp_lp_on)(struct sst_dsp *dsp, bool state);
46};
47
48
49struct sst_generic_ipc {
50 struct device *dev;
51 struct sst_dsp *dsp;
52
53
54 struct list_head tx_list;
55 struct list_head rx_list;
56 struct list_head empty_list;
57 wait_queue_head_t wait_txq;
58 struct task_struct *tx_thread;
59 struct work_struct kwork;
60 bool pending;
61 struct ipc_message *msg;
62 int tx_data_max_size;
63 int rx_data_max_size;
64
65 struct sst_plat_ipc_ops ops;
66};
67
68int sst_ipc_tx_message_wait(struct sst_generic_ipc *ipc, u64 header,
69 void *tx_data, size_t tx_bytes, void *rx_data, size_t rx_bytes);
70
71int sst_ipc_tx_message_nowait(struct sst_generic_ipc *ipc, u64 header,
72 void *tx_data, size_t tx_bytes);
73
74int sst_ipc_tx_message_nopm(struct sst_generic_ipc *ipc, u64 header,
75 void *tx_data, size_t tx_bytes, void *rx_data, size_t rx_bytes);
76
77struct ipc_message *sst_ipc_reply_find_msg(struct sst_generic_ipc *ipc,
78 u64 header);
79
80void sst_ipc_tx_msg_reply_complete(struct sst_generic_ipc *ipc,
81 struct ipc_message *msg);
82
83void sst_ipc_drop_all(struct sst_generic_ipc *ipc);
84int sst_ipc_init(struct sst_generic_ipc *ipc);
85void sst_ipc_fini(struct sst_generic_ipc *ipc);
86
87#endif
88