Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * Copyright (c) 2022 MediaTek Inc.
0004  */
0005 
0006 #ifndef MTK_ADSP_IPC_H
0007 #define MTK_ADSP_IPC_H
0008 
0009 #include <linux/device.h>
0010 #include <linux/types.h>
0011 #include <linux/mailbox_controller.h>
0012 #include <linux/mailbox_client.h>
0013 
0014 #define MTK_ADSP_IPC_REQ 0
0015 #define MTK_ADSP_IPC_RSP 1
0016 #define MTK_ADSP_IPC_OP_REQ 0x1
0017 #define MTK_ADSP_IPC_OP_RSP 0x2
0018 
0019 enum {
0020     MTK_ADSP_MBOX_REPLY,
0021     MTK_ADSP_MBOX_REQUEST,
0022     MTK_ADSP_MBOX_NUM,
0023 };
0024 
0025 struct mtk_adsp_ipc;
0026 
0027 struct mtk_adsp_ipc_ops {
0028     void (*handle_reply)(struct mtk_adsp_ipc *ipc);
0029     void (*handle_request)(struct mtk_adsp_ipc *ipc);
0030 };
0031 
0032 struct mtk_adsp_chan {
0033     struct mtk_adsp_ipc *ipc;
0034     struct mbox_client cl;
0035     struct mbox_chan *ch;
0036     char *name;
0037     int idx;
0038 };
0039 
0040 struct mtk_adsp_ipc {
0041     struct mtk_adsp_chan chans[MTK_ADSP_MBOX_NUM];
0042     struct device *dev;
0043     struct mtk_adsp_ipc_ops *ops;
0044     void *private_data;
0045 };
0046 
0047 static inline void mtk_adsp_ipc_set_data(struct mtk_adsp_ipc *ipc, void *data)
0048 {
0049     if (!ipc)
0050         return;
0051 
0052     ipc->private_data = data;
0053 }
0054 
0055 static inline void *mtk_adsp_ipc_get_data(struct mtk_adsp_ipc *ipc)
0056 {
0057     if (!ipc)
0058         return NULL;
0059 
0060     return ipc->private_data;
0061 }
0062 
0063 int mtk_adsp_ipc_send(struct mtk_adsp_ipc *ipc, unsigned int idx, uint32_t op);
0064 
0065 #endif /* MTK_ADSP_IPC_H */