mtk-adsp-ipc.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (c) 2022 MediaTek Inc.
  4. */
  5. #ifndef MTK_ADSP_IPC_H
  6. #define MTK_ADSP_IPC_H
  7. #include <linux/device.h>
  8. #include <linux/types.h>
  9. #include <linux/mailbox_controller.h>
  10. #include <linux/mailbox_client.h>
  11. #define MTK_ADSP_IPC_REQ 0
  12. #define MTK_ADSP_IPC_RSP 1
  13. #define MTK_ADSP_IPC_OP_REQ 0x1
  14. #define MTK_ADSP_IPC_OP_RSP 0x2
  15. enum {
  16. MTK_ADSP_MBOX_REPLY,
  17. MTK_ADSP_MBOX_REQUEST,
  18. MTK_ADSP_MBOX_NUM,
  19. };
  20. struct mtk_adsp_ipc;
  21. struct mtk_adsp_ipc_ops {
  22. void (*handle_reply)(struct mtk_adsp_ipc *ipc);
  23. void (*handle_request)(struct mtk_adsp_ipc *ipc);
  24. };
  25. struct mtk_adsp_chan {
  26. struct mtk_adsp_ipc *ipc;
  27. struct mbox_client cl;
  28. struct mbox_chan *ch;
  29. char *name;
  30. int idx;
  31. };
  32. struct mtk_adsp_ipc {
  33. struct mtk_adsp_chan chans[MTK_ADSP_MBOX_NUM];
  34. struct device *dev;
  35. struct mtk_adsp_ipc_ops *ops;
  36. void *private_data;
  37. };
  38. static inline void mtk_adsp_ipc_set_data(struct mtk_adsp_ipc *ipc, void *data)
  39. {
  40. if (!ipc)
  41. return;
  42. ipc->private_data = data;
  43. }
  44. static inline void *mtk_adsp_ipc_get_data(struct mtk_adsp_ipc *ipc)
  45. {
  46. if (!ipc)
  47. return NULL;
  48. return ipc->private_data;
  49. }
  50. int mtk_adsp_ipc_send(struct mtk_adsp_ipc *ipc, unsigned int idx, uint32_t op);
  51. #endif /* MTK_ADSP_IPC_H */