/drivers/video/tegra/host/chip_support.h

https://bitbucket.org/cyanogenmod/android_kernel_asus_tf300t · C Header · 180 lines · 144 code · 17 blank · 19 comment · 0 complexity · bcf399afeb8883b774eb64e0ac72f0ba MD5 · raw file

  1. /*
  2. * drivers/video/tegra/host/chip_support.h
  3. *
  4. * Tegra Graphics Host Chip Support
  5. *
  6. * Copyright (c) 2011-2012, NVIDIA Corporation.
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms and conditions of the GNU General Public License,
  10. * version 2, as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope it will be useful, but WITHOUT
  13. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  15. * more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #ifndef _NVHOST_CHIP_SUPPORT_H_
  21. #define _NVHOST_CHIP_SUPPORT_H_
  22. #include <linux/types.h>
  23. #include "bus.h"
  24. struct output;
  25. struct nvhost_master;
  26. struct nvhost_intr;
  27. struct nvhost_syncpt;
  28. struct nvhost_userctx_timeout;
  29. struct nvhost_channel;
  30. struct nvhost_hwctx;
  31. struct nvhost_cdma;
  32. struct nvhost_job;
  33. struct push_buffer;
  34. struct nvhost_syncpt;
  35. struct dentry;
  36. struct nvhost_job;
  37. struct nvhost_intr_syncpt;
  38. struct mem_handle;
  39. struct mem_mgr;
  40. struct nvhost_device;
  41. struct nvhost_channel_ops {
  42. int (*init)(struct nvhost_channel *,
  43. struct nvhost_master *,
  44. int chid);
  45. int (*submit)(struct nvhost_job *job);
  46. int (*read3dreg)(struct nvhost_channel *channel,
  47. struct nvhost_hwctx *hwctx,
  48. u32 offset,
  49. u32 *value);
  50. int (*save_context)(struct nvhost_channel *channel);
  51. int (*drain_read_fifo)(struct nvhost_channel *ch,
  52. u32 *ptr, unsigned int count, unsigned int *pending);
  53. };
  54. struct nvhost_cdma_ops {
  55. void (*start)(struct nvhost_cdma *);
  56. void (*stop)(struct nvhost_cdma *);
  57. void (*kick)(struct nvhost_cdma *);
  58. int (*timeout_init)(struct nvhost_cdma *,
  59. u32 syncpt_id);
  60. void (*timeout_destroy)(struct nvhost_cdma *);
  61. void (*timeout_teardown_begin)(struct nvhost_cdma *);
  62. void (*timeout_teardown_end)(struct nvhost_cdma *,
  63. u32 getptr);
  64. void (*timeout_cpu_incr)(struct nvhost_cdma *,
  65. u32 getptr,
  66. u32 syncpt_incrs,
  67. u32 syncval,
  68. u32 nr_slots,
  69. u32 waitbases);
  70. };
  71. struct nvhost_pushbuffer_ops {
  72. void (*reset)(struct push_buffer *);
  73. int (*init)(struct push_buffer *);
  74. void (*destroy)(struct push_buffer *);
  75. void (*push_to)(struct push_buffer *,
  76. struct mem_mgr *, struct mem_handle *,
  77. u32 op1, u32 op2);
  78. void (*pop_from)(struct push_buffer *,
  79. unsigned int slots);
  80. u32 (*space)(struct push_buffer *);
  81. u32 (*putptr)(struct push_buffer *);
  82. };
  83. struct nvhost_debug_ops {
  84. void (*debug_init)(struct dentry *de);
  85. void (*show_channel_cdma)(struct nvhost_master *,
  86. struct nvhost_channel *,
  87. struct output *,
  88. int chid);
  89. void (*show_channel_fifo)(struct nvhost_master *,
  90. struct nvhost_channel *,
  91. struct output *,
  92. int chid);
  93. void (*show_mlocks)(struct nvhost_master *m,
  94. struct output *o);
  95. };
  96. struct nvhost_syncpt_ops {
  97. void (*reset)(struct nvhost_syncpt *, u32 id);
  98. void (*reset_wait_base)(struct nvhost_syncpt *, u32 id);
  99. void (*read_wait_base)(struct nvhost_syncpt *, u32 id);
  100. u32 (*update_min)(struct nvhost_syncpt *, u32 id);
  101. void (*cpu_incr)(struct nvhost_syncpt *, u32 id);
  102. int (*patch_wait)(struct nvhost_syncpt *sp,
  103. void *patch_addr);
  104. void (*debug)(struct nvhost_syncpt *);
  105. const char * (*name)(struct nvhost_syncpt *, u32 id);
  106. int (*mutex_try_lock)(struct nvhost_syncpt *,
  107. unsigned int idx);
  108. void (*mutex_unlock)(struct nvhost_syncpt *,
  109. unsigned int idx);
  110. };
  111. struct nvhost_intr_ops {
  112. void (*init_host_sync)(struct nvhost_intr *);
  113. void (*set_host_clocks_per_usec)(
  114. struct nvhost_intr *, u32 clocks);
  115. void (*set_syncpt_threshold)(
  116. struct nvhost_intr *, u32 id, u32 thresh);
  117. void (*enable_syncpt_intr)(struct nvhost_intr *, u32 id);
  118. void (*disable_all_syncpt_intrs)(struct nvhost_intr *);
  119. int (*request_host_general_irq)(struct nvhost_intr *);
  120. void (*free_host_general_irq)(struct nvhost_intr *);
  121. int (*request_syncpt_irq)(struct nvhost_intr_syncpt *syncpt);
  122. };
  123. struct nvhost_dev_ops {
  124. struct nvhost_channel *(*alloc_nvhost_channel)(
  125. struct nvhost_device *dev);
  126. void (*free_nvhost_channel)(struct nvhost_channel *ch);
  127. };
  128. struct nvhost_mem_ops {
  129. struct mem_mgr *(*alloc_mgr)(void);
  130. void (*put_mgr)(struct mem_mgr *);
  131. struct mem_mgr *(*get_mgr)(struct mem_mgr *);
  132. struct mem_mgr *(*get_mgr_file)(int fd);
  133. struct mem_handle *(*alloc)(struct mem_mgr *,
  134. size_t size, size_t align,
  135. int flags);
  136. struct mem_handle *(*get)(struct mem_mgr *, u32 id);
  137. void (*put)(struct mem_mgr *, struct mem_handle *);
  138. phys_addr_t (*pin)(struct mem_mgr *, struct mem_handle *);
  139. void (*unpin)(struct mem_mgr *, struct mem_handle *);
  140. void *(*mmap)(struct mem_handle *);
  141. void (*munmap)(struct mem_handle *, void *);
  142. };
  143. struct nvhost_chip_support {
  144. struct nvhost_channel_ops channel;
  145. struct nvhost_cdma_ops cdma;
  146. struct nvhost_pushbuffer_ops push_buffer;
  147. struct nvhost_debug_ops debug;
  148. struct nvhost_syncpt_ops syncpt;
  149. struct nvhost_intr_ops intr;
  150. struct nvhost_dev_ops nvhost_dev;
  151. struct nvhost_mem_ops mem;
  152. };
  153. struct nvhost_chip_support *nvhost_get_chip_ops(void);
  154. #define host_device_op() nvhost_get_chip_ops()->nvhost_dev
  155. #define channel_cdma_op() nvhost_get_chip_ops()->cdma
  156. #define channel_op() nvhost_get_chip_ops()->channel
  157. #define syncpt_op() nvhost_get_chip_ops()->syncpt
  158. #define intr_op() nvhost_get_chip_ops()->intr
  159. #define cdma_op() nvhost_get_chip_ops()->cdma
  160. #define cdma_pb_op() nvhost_get_chip_ops()->push_buffer
  161. #define mem_op() (nvhost_get_chip_ops()->mem)
  162. int nvhost_init_chip_support(struct nvhost_master *);
  163. #endif /* _NVHOST_CHIP_SUPPORT_H_ */