sst-ipc.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * Intel SST generic IPC Support
  3. *
  4. * Copyright (C) 2015, Intel Corporation. All rights reserved.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License version
  8. * 2 as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. */
  16. #ifndef __SST_GENERIC_IPC_H
  17. #define __SST_GENERIC_IPC_H
  18. #include <linux/types.h>
  19. #include <linux/kernel.h>
  20. #include <linux/wait.h>
  21. #include <linux/list.h>
  22. #include <linux/workqueue.h>
  23. #include <linux/sched.h>
  24. #include <linux/kthread.h>
  25. #define IPC_MAX_MAILBOX_BYTES 256
  26. struct ipc_message {
  27. struct list_head list;
  28. u64 header;
  29. /* direction wrt host CPU */
  30. char *tx_data;
  31. size_t tx_size;
  32. char *rx_data;
  33. size_t rx_size;
  34. wait_queue_head_t waitq;
  35. bool pending;
  36. bool complete;
  37. bool wait;
  38. int errno;
  39. };
  40. struct sst_generic_ipc;
  41. struct sst_plat_ipc_ops {
  42. void (*tx_msg)(struct sst_generic_ipc *, struct ipc_message *);
  43. void (*shim_dbg)(struct sst_generic_ipc *, const char *);
  44. void (*tx_data_copy)(struct ipc_message *, char *, size_t);
  45. u64 (*reply_msg_match)(u64 header, u64 *mask);
  46. bool (*is_dsp_busy)(struct sst_dsp *dsp);
  47. };
  48. /* SST generic IPC data */
  49. struct sst_generic_ipc {
  50. struct device *dev;
  51. struct sst_dsp *dsp;
  52. /* IPC messaging */
  53. struct list_head tx_list;
  54. struct list_head rx_list;
  55. struct list_head empty_list;
  56. wait_queue_head_t wait_txq;
  57. struct task_struct *tx_thread;
  58. struct kthread_worker kworker;
  59. struct kthread_work kwork;
  60. bool pending;
  61. struct ipc_message *msg;
  62. int tx_data_max_size;
  63. int rx_data_max_size;
  64. struct sst_plat_ipc_ops ops;
  65. };
  66. int sst_ipc_tx_message_wait(struct sst_generic_ipc *ipc, u64 header,
  67. void *tx_data, size_t tx_bytes, void *rx_data, size_t rx_bytes);
  68. int sst_ipc_tx_message_nowait(struct sst_generic_ipc *ipc, u64 header,
  69. void *tx_data, size_t tx_bytes);
  70. struct ipc_message *sst_ipc_reply_find_msg(struct sst_generic_ipc *ipc,
  71. u64 header);
  72. void sst_ipc_tx_msg_reply_complete(struct sst_generic_ipc *ipc,
  73. struct ipc_message *msg);
  74. void sst_ipc_drop_all(struct sst_generic_ipc *ipc);
  75. int sst_ipc_init(struct sst_generic_ipc *ipc);
  76. void sst_ipc_fini(struct sst_generic_ipc *ipc);
  77. #endif