sst-ipc.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Intel SST generic IPC Support
  4. *
  5. * Copyright (C) 2015, Intel Corporation. All rights reserved.
  6. */
  7. #ifndef __SST_GENERIC_IPC_H
  8. #define __SST_GENERIC_IPC_H
  9. #include <linux/types.h>
  10. #include <linux/kernel.h>
  11. #include <linux/wait.h>
  12. #include <linux/list.h>
  13. #include <linux/workqueue.h>
  14. #include <linux/sched.h>
  15. struct sst_ipc_message {
  16. u64 header;
  17. void *data;
  18. size_t size;
  19. };
  20. struct ipc_message {
  21. struct list_head list;
  22. struct sst_ipc_message tx;
  23. struct sst_ipc_message rx;
  24. wait_queue_head_t waitq;
  25. bool pending;
  26. bool complete;
  27. bool wait;
  28. int errno;
  29. };
  30. struct sst_generic_ipc;
  31. struct sst_dsp;
  32. struct sst_plat_ipc_ops {
  33. void (*tx_msg)(struct sst_generic_ipc *, struct ipc_message *);
  34. void (*shim_dbg)(struct sst_generic_ipc *, const char *);
  35. void (*tx_data_copy)(struct ipc_message *, char *, size_t);
  36. u64 (*reply_msg_match)(u64 header, u64 *mask);
  37. bool (*is_dsp_busy)(struct sst_dsp *dsp);
  38. int (*check_dsp_lp_on)(struct sst_dsp *dsp, bool state);
  39. };
  40. /* SST generic IPC data */
  41. struct sst_generic_ipc {
  42. struct device *dev;
  43. struct sst_dsp *dsp;
  44. /* IPC messaging */
  45. struct list_head tx_list;
  46. struct list_head rx_list;
  47. struct list_head empty_list;
  48. wait_queue_head_t wait_txq;
  49. struct task_struct *tx_thread;
  50. struct work_struct kwork;
  51. bool pending;
  52. struct ipc_message *msg;
  53. int tx_data_max_size;
  54. int rx_data_max_size;
  55. struct sst_plat_ipc_ops ops;
  56. };
  57. int sst_ipc_tx_message_wait(struct sst_generic_ipc *ipc,
  58. struct sst_ipc_message request, struct sst_ipc_message *reply);
  59. int sst_ipc_tx_message_nowait(struct sst_generic_ipc *ipc,
  60. struct sst_ipc_message request);
  61. int sst_ipc_tx_message_nopm(struct sst_generic_ipc *ipc,
  62. struct sst_ipc_message request, struct sst_ipc_message *reply);
  63. struct ipc_message *sst_ipc_reply_find_msg(struct sst_generic_ipc *ipc,
  64. u64 header);
  65. void sst_ipc_tx_msg_reply_complete(struct sst_generic_ipc *ipc,
  66. struct ipc_message *msg);
  67. int sst_ipc_init(struct sst_generic_ipc *ipc);
  68. void sst_ipc_fini(struct sst_generic_ipc *ipc);
  69. #endif