sst-ipc.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. #define IPC_MAX_MAILBOX_BYTES 256
  25. struct ipc_message {
  26. struct list_head list;
  27. u64 header;
  28. /* direction wrt host CPU */
  29. char *tx_data;
  30. size_t tx_size;
  31. char *rx_data;
  32. size_t rx_size;
  33. wait_queue_head_t waitq;
  34. bool pending;
  35. bool complete;
  36. bool wait;
  37. int errno;
  38. };
  39. struct sst_generic_ipc;
  40. struct sst_plat_ipc_ops {
  41. void (*tx_msg)(struct sst_generic_ipc *, struct ipc_message *);
  42. void (*shim_dbg)(struct sst_generic_ipc *, const char *);
  43. void (*tx_data_copy)(struct ipc_message *, char *, size_t);
  44. u64 (*reply_msg_match)(u64 header, u64 *mask);
  45. bool (*is_dsp_busy)(struct sst_dsp *dsp);
  46. int (*check_dsp_lp_on)(struct sst_dsp *dsp, bool state);
  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 work_struct kwork;
  59. bool pending;
  60. struct ipc_message *msg;
  61. int tx_data_max_size;
  62. int rx_data_max_size;
  63. struct sst_plat_ipc_ops ops;
  64. };
  65. int sst_ipc_tx_message_wait(struct sst_generic_ipc *ipc, u64 header,
  66. void *tx_data, size_t tx_bytes, void *rx_data, size_t rx_bytes);
  67. int sst_ipc_tx_message_nowait(struct sst_generic_ipc *ipc, u64 header,
  68. void *tx_data, size_t tx_bytes);
  69. int sst_ipc_tx_message_nopm(struct sst_generic_ipc *ipc, u64 header,
  70. void *tx_data, size_t tx_bytes, void *rx_data, size_t rx_bytes);
  71. struct ipc_message *sst_ipc_reply_find_msg(struct sst_generic_ipc *ipc,
  72. u64 header);
  73. void sst_ipc_tx_msg_reply_complete(struct sst_generic_ipc *ipc,
  74. struct ipc_message *msg);
  75. void sst_ipc_drop_all(struct sst_generic_ipc *ipc);
  76. int sst_ipc_init(struct sst_generic_ipc *ipc);
  77. void sst_ipc_fini(struct sst_generic_ipc *ipc);
  78. #endif