sst-ipc.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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[IPC_MAX_MAILBOX_BYTES];
  31. size_t tx_size;
  32. char rx_data[IPC_MAX_MAILBOX_BYTES];
  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. };
  47. /* SST generic IPC data */
  48. struct sst_generic_ipc {
  49. struct device *dev;
  50. struct sst_dsp *dsp;
  51. /* IPC messaging */
  52. struct list_head tx_list;
  53. struct list_head rx_list;
  54. struct list_head empty_list;
  55. wait_queue_head_t wait_txq;
  56. struct task_struct *tx_thread;
  57. struct kthread_worker kworker;
  58. struct kthread_work kwork;
  59. bool pending;
  60. struct ipc_message *msg;
  61. struct sst_plat_ipc_ops ops;
  62. };
  63. int sst_ipc_tx_message_wait(struct sst_generic_ipc *ipc, u64 header,
  64. void *tx_data, size_t tx_bytes, void *rx_data, size_t rx_bytes);
  65. int sst_ipc_tx_message_nowait(struct sst_generic_ipc *ipc, u64 header,
  66. void *tx_data, size_t tx_bytes);
  67. struct ipc_message *sst_ipc_reply_find_msg(struct sst_generic_ipc *ipc,
  68. u64 header);
  69. void sst_ipc_tx_msg_reply_complete(struct sst_generic_ipc *ipc,
  70. struct ipc_message *msg);
  71. void sst_ipc_drop_all(struct sst_generic_ipc *ipc);
  72. int sst_ipc_init(struct sst_generic_ipc *ipc);
  73. void sst_ipc_fini(struct sst_generic_ipc *ipc);
  74. #endif