intr.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * Tegra host1x Interrupt Management
  3. *
  4. * Copyright (c) 2010-2013, NVIDIA Corporation.
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms and conditions of the GNU General Public License,
  8. * version 2, as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope it will be useful, but WITHOUT
  11. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  13. * more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #ifndef __HOST1X_INTR_H
  19. #define __HOST1X_INTR_H
  20. #include <linux/interrupt.h>
  21. #include <linux/workqueue.h>
  22. struct host1x_syncpt;
  23. struct host1x;
  24. enum host1x_intr_action {
  25. /*
  26. * Perform cleanup after a submit has completed.
  27. * 'data' points to a channel
  28. */
  29. HOST1X_INTR_ACTION_SUBMIT_COMPLETE = 0,
  30. /*
  31. * Wake up a task.
  32. * 'data' points to a wait_queue_head_t
  33. */
  34. HOST1X_INTR_ACTION_WAKEUP,
  35. /*
  36. * Wake up a interruptible task.
  37. * 'data' points to a wait_queue_head_t
  38. */
  39. HOST1X_INTR_ACTION_WAKEUP_INTERRUPTIBLE,
  40. HOST1X_INTR_ACTION_COUNT
  41. };
  42. struct host1x_syncpt_intr {
  43. spinlock_t lock;
  44. struct list_head wait_head;
  45. char thresh_irq_name[12];
  46. struct work_struct work;
  47. };
  48. struct host1x_waitlist {
  49. struct list_head list;
  50. struct kref refcount;
  51. u32 thresh;
  52. enum host1x_intr_action action;
  53. atomic_t state;
  54. void *data;
  55. int count;
  56. };
  57. /*
  58. * Schedule an action to be taken when a sync point reaches the given threshold.
  59. *
  60. * @id the sync point
  61. * @thresh the threshold
  62. * @action the action to take
  63. * @data a pointer to extra data depending on action, see above
  64. * @waiter waiter structure - assumes ownership
  65. * @ref must be passed if cancellation is possible, else NULL
  66. *
  67. * This is a non-blocking api.
  68. */
  69. int host1x_intr_add_action(struct host1x *host, struct host1x_syncpt *syncpt,
  70. u32 thresh, enum host1x_intr_action action,
  71. void *data, struct host1x_waitlist *waiter,
  72. void **ref);
  73. /*
  74. * Unreference an action submitted to host1x_intr_add_action().
  75. * You must call this if you passed non-NULL as ref.
  76. * @ref the ref returned from host1x_intr_add_action()
  77. */
  78. void host1x_intr_put_ref(struct host1x *host, unsigned int id, void *ref);
  79. /* Initialize host1x sync point interrupt */
  80. int host1x_intr_init(struct host1x *host, unsigned int irq_sync);
  81. /* Deinitialize host1x sync point interrupt */
  82. void host1x_intr_deinit(struct host1x *host);
  83. /* Enable host1x sync point interrupt */
  84. void host1x_intr_start(struct host1x *host);
  85. /* Disable host1x sync point interrupt */
  86. void host1x_intr_stop(struct host1x *host);
  87. irqreturn_t host1x_syncpt_thresh_fn(void *dev_id);
  88. #endif