summaryrefslogtreecommitdiffstats
path: root/include/linux/firmware/imx/dsp.h
blob: 7562099c9e4644189ecf8e67c87c92a19bfeefb6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/* SPDX-License-Identifier: GPL-2.0+ */
/*
 * Copyright 2019 NXP
 *
 * Header file for the DSP IPC implementation
 */

#ifndef _IMX_DSP_IPC_H
#define _IMX_DSP_IPC_H

#include <linux/device.h>
#include <linux/types.h>
#include <linux/mailbox_client.h>

#define DSP_MU_CHAN_NUM		4

struct imx_dsp_chan {
	struct imx_dsp_ipc *ipc;
	struct mbox_client cl;
	struct mbox_chan *ch;
	char *name;
	int idx;
};

struct imx_dsp_ops {
	void (*handle_reply)(struct imx_dsp_ipc *ipc);
	void (*handle_request)(struct imx_dsp_ipc *ipc);
};

struct imx_dsp_ipc {
	/* Host <-> DSP communication uses 2 txdb and 2 rxdb channels */
	struct imx_dsp_chan chans[DSP_MU_CHAN_NUM];
	struct device *dev;
	struct imx_dsp_ops *ops;
	void *private_data;
};

static inline void imx_dsp_set_data(struct imx_dsp_ipc *ipc, void *data)
{
	if (!ipc)
		return;

	ipc->private_data = data;
}

static inline void *imx_dsp_get_data(struct imx_dsp_ipc *ipc)
{
	if (!ipc)
		return NULL;

	return ipc->private_data;
}

#if IS_ENABLED(CONFIG_IMX_DSP)

int imx_dsp_ring_doorbell(struct imx_dsp_ipc *dsp, unsigned int chan_idx);

#else

static inline int imx_dsp_ring_doorbell(struct imx_dsp_ipc *ipc,
					unsigned int chan_idx)
{
	return -ENOTSUPP;
}

#endif
#endif /* _IMX_DSP_IPC_H */