cgs_linux.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. * Copyright 2015 Advanced Micro Devices, Inc.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  18. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  19. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. * OTHER DEALINGS IN THE SOFTWARE.
  21. *
  22. *
  23. */
  24. #ifndef _CGS_LINUX_H
  25. #define _CGS_LINUX_H
  26. #include "cgs_common.h"
  27. /**
  28. * cgs_irq_source_set_func() - Callback for enabling/disabling interrupt sources
  29. * @private_data: private data provided to cgs_add_irq_source
  30. * @src_id: interrupt source ID
  31. * @type: interrupt type
  32. * @enabled: 0 = disable source, non-0 = enable source
  33. *
  34. * Return: 0 on success, -errno otherwise
  35. */
  36. typedef int (*cgs_irq_source_set_func_t)(void *private_data,
  37. unsigned src_id, unsigned type,
  38. int enabled);
  39. /**
  40. * cgs_irq_handler_func() - Interrupt handler callback
  41. * @private_data: private data provided to cgs_add_irq_source
  42. * @src_id: interrupt source ID
  43. * @iv_entry: pointer to raw ih ring entry
  44. *
  45. * This callback runs in interrupt context.
  46. *
  47. * Return: 0 on success, -errno otherwise
  48. */
  49. typedef int (*cgs_irq_handler_func_t)(void *private_data,
  50. unsigned src_id, const uint32_t *iv_entry);
  51. /**
  52. * cgs_add_irq_source() - Add an IRQ source
  53. * @cgs_device: opaque device handle
  54. * @src_id: interrupt source ID
  55. * @num_types: number of interrupt types that can be independently enabled
  56. * @set: callback function to enable/disable an interrupt type
  57. * @handler: interrupt handler callback
  58. * @private_data: private data to pass to callback functions
  59. *
  60. * The same IRQ source can be added only once. Adding an IRQ source
  61. * indicates ownership of that IRQ source and all its IRQ types.
  62. *
  63. * Return: 0 on success, -errno otherwise
  64. */
  65. typedef int (*cgs_add_irq_source_t)(void *cgs_device, unsigned client_id,
  66. unsigned src_id,
  67. unsigned num_types,
  68. cgs_irq_source_set_func_t set,
  69. cgs_irq_handler_func_t handler,
  70. void *private_data);
  71. /**
  72. * cgs_irq_get() - Request enabling an IRQ source and type
  73. * @cgs_device: opaque device handle
  74. * @src_id: interrupt source ID
  75. * @type: interrupt type
  76. *
  77. * cgs_irq_get and cgs_irq_put calls must be balanced. They count
  78. * "references" to IRQ sources.
  79. *
  80. * Return: 0 on success, -errno otherwise
  81. */
  82. typedef int (*cgs_irq_get_t)(void *cgs_device, unsigned client_id, unsigned src_id, unsigned type);
  83. /**
  84. * cgs_irq_put() - Indicate IRQ source is no longer needed
  85. * @cgs_device: opaque device handle
  86. * @src_id: interrupt source ID
  87. * @type: interrupt type
  88. *
  89. * cgs_irq_get and cgs_irq_put calls must be balanced. They count
  90. * "references" to IRQ sources. Even after cgs_irq_put is called, the
  91. * IRQ handler may still be called if there are more refecences to
  92. * the IRQ source.
  93. *
  94. * Return: 0 on success, -errno otherwise
  95. */
  96. typedef int (*cgs_irq_put_t)(void *cgs_device, unsigned client_id, unsigned src_id, unsigned type);
  97. struct cgs_os_ops {
  98. /* IRQ handling */
  99. cgs_add_irq_source_t add_irq_source;
  100. cgs_irq_get_t irq_get;
  101. cgs_irq_put_t irq_put;
  102. };
  103. #define cgs_add_irq_source(dev,client_id,src_id,num_types,set,handler,private_data) \
  104. CGS_OS_CALL(add_irq_source,dev,client_id,src_id,num_types,set,handler, \
  105. private_data)
  106. #define cgs_irq_get(dev,client_id,src_id,type) \
  107. CGS_OS_CALL(irq_get,dev,client_id,src_id,type)
  108. #define cgs_irq_put(dev,client_id,src_id,type) \
  109. CGS_OS_CALL(irq_put,dev,client_id,src_id,type)
  110. #endif /* _CGS_LINUX_H */