gh_msgq.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  5. *
  6. */
  7. #ifndef __GH_MSGQ_H
  8. #define __GH_MSGQ_H
  9. #include <linux/types.h>
  10. #include <linux/platform_device.h>
  11. #include "gh_common.h"
  12. enum gh_msgq_label {
  13. GH_MSGQ_LABEL_RM,
  14. GH_MSGQ_LABEL_MEMBUF,
  15. GH_MSGQ_LABEL_DISPLAY,
  16. GH_MSGQ_LABEL_VSOCK,
  17. GH_MSGQ_LABEL_TEST_TUIVM,
  18. GH_MSGQ_LABEL_TEST_OEMVM,
  19. GH_MSGQ_LABEL_MMRM,
  20. GH_MSGQ_LABEL_EVA,
  21. GH_MSGQ_VCPU_SCHED_TEST,
  22. GH_MSGQ_VCPU_SCHED_TEST_OEMVM,
  23. GH_MSGQ_LABEL_SMMU_PROXY,
  24. GH_MSGQ_LABEL_MAX
  25. };
  26. #define GH_MSGQ_MAX_MSG_SIZE_BYTES 240
  27. #define GH_MSGQ_DIRECTION_TX 0
  28. #define GH_MSGQ_DIRECTION_RX 1
  29. /* Possible flags to pass for Tx or Rx */
  30. #define GH_MSGQ_TX_PUSH BIT(0)
  31. #define GH_MSGQ_NONBLOCK BIT(32)
  32. #if IS_ENABLED(CONFIG_GH_MSGQ)
  33. void *gh_msgq_register(int label);
  34. int gh_msgq_unregister(void *msgq_client_desc);
  35. int gh_msgq_send(void *msgq_client_desc,
  36. void *buff, size_t size, unsigned long flags);
  37. int gh_msgq_recv(void *msgq_client_desc,
  38. void *buff, size_t buff_size,
  39. size_t *recv_size, unsigned long flags);
  40. int gh_msgq_populate_cap_info(int label, u64 cap_id,
  41. int direction, int irq);
  42. int gh_msgq_probe(struct platform_device *pdev, int label);
  43. int gh_msgq_reset_cap_info(enum gh_msgq_label label, int direction, int *irq);
  44. #else
  45. static inline void *gh_msgq_register(int label)
  46. {
  47. return ERR_PTR(-ENODEV);
  48. }
  49. static inline int gh_msgq_unregister(void *msgq_client_desc)
  50. {
  51. return -EINVAL;
  52. }
  53. static inline int gh_msgq_send(void *msgq_client_desc,
  54. void *buff, size_t size, unsigned long flags)
  55. {
  56. return -EINVAL;
  57. }
  58. static inline int gh_msgq_recv(void *msgq_client_desc,
  59. void *buff, size_t buff_size,
  60. size_t *recv_size, unsigned long flags)
  61. {
  62. return -EINVAL;
  63. }
  64. static inline int gh_msgq_populate_cap_info(int label, u64 cap_id,
  65. int direction, int irq)
  66. {
  67. return -EINVAL;
  68. }
  69. static inline
  70. int gh_msgq_reset_cap_info(enum gh_msgq_label label, int direction, int *irq)
  71. {
  72. return -EINVAL;
  73. }
  74. static inline int gh_msgq_probe(struct platform_device *pdev, int label)
  75. {
  76. return -ENODEV;
  77. }
  78. #endif
  79. #endif