amdgpu_irq.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * Copyright 2014 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. #ifndef __AMDGPU_IRQ_H__
  24. #define __AMDGPU_IRQ_H__
  25. #include "amdgpu_ih.h"
  26. #define AMDGPU_MAX_IRQ_SRC_ID 0x100
  27. struct amdgpu_device;
  28. struct amdgpu_iv_entry;
  29. enum amdgpu_interrupt_state {
  30. AMDGPU_IRQ_STATE_DISABLE,
  31. AMDGPU_IRQ_STATE_ENABLE,
  32. };
  33. struct amdgpu_irq_src {
  34. unsigned num_types;
  35. atomic_t *enabled_types;
  36. const struct amdgpu_irq_src_funcs *funcs;
  37. void *data;
  38. };
  39. /* provided by interrupt generating IP blocks */
  40. struct amdgpu_irq_src_funcs {
  41. int (*set)(struct amdgpu_device *adev, struct amdgpu_irq_src *source,
  42. unsigned type, enum amdgpu_interrupt_state state);
  43. int (*process)(struct amdgpu_device *adev,
  44. struct amdgpu_irq_src *source,
  45. struct amdgpu_iv_entry *entry);
  46. };
  47. struct amdgpu_irq {
  48. bool installed;
  49. spinlock_t lock;
  50. /* interrupt sources */
  51. struct amdgpu_irq_src *sources[AMDGPU_MAX_IRQ_SRC_ID];
  52. /* status, etc. */
  53. bool msi_enabled; /* msi enabled */
  54. /* interrupt ring */
  55. struct amdgpu_ih_ring ih;
  56. const struct amdgpu_ih_funcs *ih_funcs;
  57. };
  58. void amdgpu_irq_preinstall(struct drm_device *dev);
  59. int amdgpu_irq_postinstall(struct drm_device *dev);
  60. void amdgpu_irq_uninstall(struct drm_device *dev);
  61. irqreturn_t amdgpu_irq_handler(int irq, void *arg);
  62. int amdgpu_irq_init(struct amdgpu_device *adev);
  63. void amdgpu_irq_fini(struct amdgpu_device *adev);
  64. int amdgpu_irq_add_id(struct amdgpu_device *adev, unsigned src_id,
  65. struct amdgpu_irq_src *source);
  66. void amdgpu_irq_dispatch(struct amdgpu_device *adev,
  67. struct amdgpu_iv_entry *entry);
  68. int amdgpu_irq_update(struct amdgpu_device *adev, struct amdgpu_irq_src *src,
  69. unsigned type);
  70. int amdgpu_irq_get(struct amdgpu_device *adev, struct amdgpu_irq_src *src,
  71. unsigned type);
  72. bool amdgpu_irq_get_delayed(struct amdgpu_device *adev,
  73. struct amdgpu_irq_src *src,
  74. unsigned type);
  75. int amdgpu_irq_put(struct amdgpu_device *adev, struct amdgpu_irq_src *src,
  76. unsigned type);
  77. bool amdgpu_irq_enabled(struct amdgpu_device *adev, struct amdgpu_irq_src *src,
  78. unsigned type);
  79. #endif