blob: 77d651e888f91e1c7c11331c900c19aa504538e3 [file] [log] [blame]
David Brazdil0f672f62019-12-10 10:32:29 +00001/* SPDX-License-Identifier: GPL-2.0-only */
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00002/*
3 * Intel SST generic IPC Support
4 *
5 * Copyright (C) 2015, Intel Corporation. All rights reserved.
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00006 */
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
David Brazdil0f672f62019-12-10 10:32:29 +000018struct sst_ipc_message {
19 u64 header;
20 void *data;
21 size_t size;
22};
23
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000024struct ipc_message {
25 struct list_head list;
David Brazdil0f672f62019-12-10 10:32:29 +000026 struct sst_ipc_message tx;
27 struct sst_ipc_message rx;
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000028
29 wait_queue_head_t waitq;
30 bool pending;
31 bool complete;
32 bool wait;
33 int errno;
34};
35
36struct sst_generic_ipc;
David Brazdil0f672f62019-12-10 10:32:29 +000037struct sst_dsp;
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000038
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/* SST generic IPC data */
49struct sst_generic_ipc {
50 struct device *dev;
51 struct sst_dsp *dsp;
52
53 /* IPC messaging */
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
David Brazdil0f672f62019-12-10 10:32:29 +000068int sst_ipc_tx_message_wait(struct sst_generic_ipc *ipc,
69 struct sst_ipc_message request, struct sst_ipc_message *reply);
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000070
David Brazdil0f672f62019-12-10 10:32:29 +000071int sst_ipc_tx_message_nowait(struct sst_generic_ipc *ipc,
72 struct sst_ipc_message request);
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000073
David Brazdil0f672f62019-12-10 10:32:29 +000074int sst_ipc_tx_message_nopm(struct sst_generic_ipc *ipc,
75 struct sst_ipc_message request, struct sst_ipc_message *reply);
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000076
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
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000083int sst_ipc_init(struct sst_generic_ipc *ipc);
84void sst_ipc_fini(struct sst_generic_ipc *ipc);
85
86#endif