hgsl_tcsr.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /* Copyright (c) 2019-2021, The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 and
  7. * only version 2 as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. */
  15. #ifndef __HGSL_TCSR_H
  16. #define __HGSL_TCSR_H
  17. #include <linux/device.h>
  18. #include <linux/irqreturn.h>
  19. #include <linux/platform_device.h>
  20. /*
  21. * Bit 0-5 are used for doorbell interrupt for each RB
  22. * Bit 8 is used for retire TS interrupt to GVM.
  23. */
  24. #define TCSR_KMD_TRIGGER_IRQ_ID_0 0
  25. #define TCSR_GMU_TRIGGER_IRQ_ID_0 8
  26. /* Define Source and Destination IRQ for KMD */
  27. #define TCSR_SRC_IRQ_ID_0 TCSR_KMD_TRIGGER_IRQ_ID_0
  28. #define TCSR_DEST_IRQ_ID_0 TCSR_GMU_TRIGGER_IRQ_ID_0
  29. #define TCSR_DEST_IRQ_MASK_0 (1 << TCSR_DEST_IRQ_ID_0)
  30. enum hgsl_tcsr_role {
  31. HGSL_TCSR_ROLE_SENDER = 0,
  32. HGSL_TCSR_ROLE_RECEIVER = 1,
  33. HGSL_TCSR_ROLE_MAX,
  34. };
  35. struct hgsl_tcsr;
  36. extern struct platform_driver hgsl_tcsr_driver;
  37. #if IS_ENABLED(CONFIG_QCOM_HGSL_TCSR_SIGNAL)
  38. struct hgsl_tcsr *hgsl_tcsr_request(struct platform_device *pdev,
  39. enum hgsl_tcsr_role role,
  40. struct device *client,
  41. irqreturn_t (*isr)(struct device *, u32));
  42. void hgsl_tcsr_free(struct hgsl_tcsr *tcsr);
  43. int hgsl_tcsr_enable(struct hgsl_tcsr *tcsr);
  44. void hgsl_tcsr_disable(struct hgsl_tcsr *tcsr);
  45. bool hgsl_tcsr_is_enabled(struct hgsl_tcsr *tcsr);
  46. void hgsl_tcsr_irq_trigger(struct hgsl_tcsr *tcsr, int irq_id);
  47. void hgsl_tcsr_irq_enable(struct hgsl_tcsr *tcsr, u32 mask, bool enable);
  48. #else
  49. static inline struct hgsl_tcsr *hgsl_tcsr_request(struct platform_device *pdev,
  50. enum hgsl_tcsr_role role,
  51. struct device *client,
  52. irqreturn_t (*isr)(struct device *, u32))
  53. {
  54. return NULL;
  55. }
  56. static inline void hgsl_tcsr_free(struct hgsl_tcsr *tcsr)
  57. {
  58. }
  59. static inline int hgsl_tcsr_enable(struct hgsl_tcsr *tcsr)
  60. {
  61. return -ENODEV;
  62. }
  63. static inline void hgsl_tcsr_disable(struct hgsl_tcsr *tcsr)
  64. {
  65. }
  66. static inline bool hgsl_tcsr_is_enabled(struct hgsl_tcsr *tcsr)
  67. {
  68. return false;
  69. }
  70. static inline void hgsl_tcsr_irq_trigger(struct hgsl_tcsr *tcsr, int irq_id)
  71. {
  72. }
  73. static inline void hgsl_tcsr_irq_enable(struct hgsl_tcsr *tcsr, u32 mask,
  74. bool enable)
  75. {
  76. }
  77. #endif
  78. #endif /* __HGSL_TCSR_H */