2019-05-26 23:55:21 -07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2015-04-06 18:33:30 -07:00
|
|
|
/*
|
|
|
|
* Intel SST generic IPC Support
|
|
|
|
*
|
2024-05-03 07:03:53 -07:00
|
|
|
* Copyright (C) 2015, Intel Corporation
|
2015-04-06 18:33:30 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __SST_GENERIC_IPC_H
|
|
|
|
#define __SST_GENERIC_IPC_H
|
|
|
|
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/wait.h>
|
|
|
|
#include <linux/list.h>
|
|
|
|
#include <linux/workqueue.h>
|
|
|
|
#include <linux/sched.h>
|
|
|
|
|
2019-07-23 07:43:40 -07:00
|
|
|
struct sst_ipc_message {
|
2015-04-06 18:33:30 -07:00
|
|
|
u64 header;
|
2019-07-23 07:43:40 -07:00
|
|
|
void *data;
|
|
|
|
size_t size;
|
|
|
|
};
|
2015-04-06 18:33:30 -07:00
|
|
|
|
2019-07-23 07:43:40 -07:00
|
|
|
struct ipc_message {
|
|
|
|
struct list_head list;
|
|
|
|
struct sst_ipc_message tx;
|
|
|
|
struct sst_ipc_message rx;
|
2015-04-06 18:33:30 -07:00
|
|
|
|
|
|
|
wait_queue_head_t waitq;
|
|
|
|
bool pending;
|
|
|
|
bool complete;
|
|
|
|
bool wait;
|
|
|
|
int errno;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct sst_generic_ipc;
|
2019-07-23 07:58:48 -07:00
|
|
|
struct sst_dsp;
|
2015-04-06 18:33:30 -07:00
|
|
|
|
|
|
|
struct sst_plat_ipc_ops {
|
|
|
|
void (*tx_msg)(struct sst_generic_ipc *, struct ipc_message *);
|
|
|
|
void (*shim_dbg)(struct sst_generic_ipc *, const char *);
|
|
|
|
void (*tx_data_copy)(struct ipc_message *, char *, size_t);
|
|
|
|
u64 (*reply_msg_match)(u64 header, u64 *mask);
|
2015-05-19 02:30:33 -07:00
|
|
|
bool (*is_dsp_busy)(struct sst_dsp *dsp);
|
2016-09-25 22:35:28 -07:00
|
|
|
int (*check_dsp_lp_on)(struct sst_dsp *dsp, bool state);
|
2015-04-06 18:33:30 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
/* SST generic IPC data */
|
|
|
|
struct sst_generic_ipc {
|
|
|
|
struct device *dev;
|
|
|
|
struct sst_dsp *dsp;
|
|
|
|
|
|
|
|
/* IPC messaging */
|
|
|
|
struct list_head tx_list;
|
|
|
|
struct list_head rx_list;
|
|
|
|
struct list_head empty_list;
|
|
|
|
wait_queue_head_t wait_txq;
|
|
|
|
struct task_struct *tx_thread;
|
2016-11-28 08:32:19 -07:00
|
|
|
struct work_struct kwork;
|
2015-04-06 18:33:30 -07:00
|
|
|
bool pending;
|
|
|
|
struct ipc_message *msg;
|
2015-05-19 02:30:37 -07:00
|
|
|
int tx_data_max_size;
|
|
|
|
int rx_data_max_size;
|
2015-04-06 18:33:30 -07:00
|
|
|
|
|
|
|
struct sst_plat_ipc_ops ops;
|
|
|
|
};
|
|
|
|
|
2019-07-23 07:43:40 -07:00
|
|
|
int sst_ipc_tx_message_wait(struct sst_generic_ipc *ipc,
|
|
|
|
struct sst_ipc_message request, struct sst_ipc_message *reply);
|
2015-04-06 18:33:30 -07:00
|
|
|
|
2019-07-23 07:43:40 -07:00
|
|
|
int sst_ipc_tx_message_nowait(struct sst_generic_ipc *ipc,
|
|
|
|
struct sst_ipc_message request);
|
2015-04-06 18:33:30 -07:00
|
|
|
|
2019-07-23 07:43:40 -07:00
|
|
|
int sst_ipc_tx_message_nopm(struct sst_generic_ipc *ipc,
|
|
|
|
struct sst_ipc_message request, struct sst_ipc_message *reply);
|
2016-11-03 04:37:14 -07:00
|
|
|
|
2015-04-06 18:33:30 -07:00
|
|
|
struct ipc_message *sst_ipc_reply_find_msg(struct sst_generic_ipc *ipc,
|
|
|
|
u64 header);
|
|
|
|
|
|
|
|
void sst_ipc_tx_msg_reply_complete(struct sst_generic_ipc *ipc,
|
|
|
|
struct ipc_message *msg);
|
|
|
|
|
|
|
|
int sst_ipc_init(struct sst_generic_ipc *ipc);
|
|
|
|
void sst_ipc_fini(struct sst_generic_ipc *ipc);
|
|
|
|
|
|
|
|
#endif
|