cgs_linux.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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 src_id,
  66. unsigned num_types,
  67. cgs_irq_source_set_func_t set,
  68. cgs_irq_handler_func_t handler,
  69. void *private_data);
  70. /**
  71. * cgs_irq_get() - Request enabling an IRQ source and type
  72. * @cgs_device: opaque device handle
  73. * @src_id: interrupt source ID
  74. * @type: interrupt type
  75. *
  76. * cgs_irq_get and cgs_irq_put calls must be balanced. They count
  77. * "references" to IRQ sources.
  78. *
  79. * Return: 0 on success, -errno otherwise
  80. */
  81. typedef int (*cgs_irq_get_t)(void *cgs_device, unsigned src_id, unsigned type);
  82. /**
  83. * cgs_irq_put() - Indicate IRQ source is no longer needed
  84. * @cgs_device: opaque device handle
  85. * @src_id: interrupt source ID
  86. * @type: interrupt type
  87. *
  88. * cgs_irq_get and cgs_irq_put calls must be balanced. They count
  89. * "references" to IRQ sources. Even after cgs_irq_put is called, the
  90. * IRQ handler may still be called if there are more refecences to
  91. * the IRQ source.
  92. *
  93. * Return: 0 on success, -errno otherwise
  94. */
  95. typedef int (*cgs_irq_put_t)(void *cgs_device, unsigned src_id, unsigned type);
  96. struct cgs_os_ops {
  97. /* IRQ handling */
  98. cgs_add_irq_source_t add_irq_source;
  99. cgs_irq_get_t irq_get;
  100. cgs_irq_put_t irq_put;
  101. };
  102. #define cgs_add_irq_source(dev,src_id,num_types,set,handler,private_data) \
  103. CGS_OS_CALL(add_irq_source,dev,src_id,num_types,set,handler, \
  104. private_data)
  105. #define cgs_irq_get(dev,src_id,type) \
  106. CGS_OS_CALL(irq_get,dev,src_id,type)
  107. #define cgs_irq_put(dev,src_id,type) \
  108. CGS_OS_CALL(irq_put,dev,src_id,type)
  109. #endif /* _CGS_LINUX_H */