0001
0002
0003
0004
0005
0006
0007
0008 #ifndef _IMX_DSP_IPC_H
0009 #define _IMX_DSP_IPC_H
0010
0011 #include <linux/device.h>
0012 #include <linux/types.h>
0013 #include <linux/mailbox_client.h>
0014
0015 #define DSP_MU_CHAN_NUM 4
0016
0017 struct imx_dsp_chan {
0018 struct imx_dsp_ipc *ipc;
0019 struct mbox_client cl;
0020 struct mbox_chan *ch;
0021 char *name;
0022 int idx;
0023 };
0024
0025 struct imx_dsp_ops {
0026 void (*handle_reply)(struct imx_dsp_ipc *ipc);
0027 void (*handle_request)(struct imx_dsp_ipc *ipc);
0028 };
0029
0030 struct imx_dsp_ipc {
0031
0032 struct imx_dsp_chan chans[DSP_MU_CHAN_NUM];
0033 struct device *dev;
0034 struct imx_dsp_ops *ops;
0035 void *private_data;
0036 };
0037
0038 static inline void imx_dsp_set_data(struct imx_dsp_ipc *ipc, void *data)
0039 {
0040 if (!ipc)
0041 return;
0042
0043 ipc->private_data = data;
0044 }
0045
0046 static inline void *imx_dsp_get_data(struct imx_dsp_ipc *ipc)
0047 {
0048 if (!ipc)
0049 return NULL;
0050
0051 return ipc->private_data;
0052 }
0053
0054 #if IS_ENABLED(CONFIG_IMX_DSP)
0055
0056 int imx_dsp_ring_doorbell(struct imx_dsp_ipc *dsp, unsigned int chan_idx);
0057
0058 struct mbox_chan *imx_dsp_request_channel(struct imx_dsp_ipc *ipc, int idx);
0059 void imx_dsp_free_channel(struct imx_dsp_ipc *ipc, int idx);
0060
0061 #else
0062
0063 static inline int imx_dsp_ring_doorbell(struct imx_dsp_ipc *ipc,
0064 unsigned int chan_idx)
0065 {
0066 return -ENOTSUPP;
0067 }
0068
0069 struct mbox_chan *imx_dsp_request_channel(struct imx_dsp_ipc *ipc, int idx)
0070 {
0071 return ERR_PTR(-EOPNOTSUPP);
0072 }
0073
0074 void imx_dsp_free_channel(struct imx_dsp_ipc *ipc, int idx) { }
0075
0076 #endif
0077 #endif