host1x01_hardware.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*
  2. * Tegra host1x Register Offsets for Tegra20 and Tegra30
  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_HOST1X01_HARDWARE_H
  19. #define __HOST1X_HOST1X01_HARDWARE_H
  20. #include <linux/types.h>
  21. #include <linux/bitops.h>
  22. #include "hw_host1x01_channel.h"
  23. #include "hw_host1x01_sync.h"
  24. #include "hw_host1x01_uclass.h"
  25. static inline u32 host1x_class_host_wait_syncpt(
  26. unsigned indx, unsigned threshold)
  27. {
  28. return host1x_uclass_wait_syncpt_indx_f(indx)
  29. | host1x_uclass_wait_syncpt_thresh_f(threshold);
  30. }
  31. static inline u32 host1x_class_host_load_syncpt_base(
  32. unsigned indx, unsigned threshold)
  33. {
  34. return host1x_uclass_load_syncpt_base_base_indx_f(indx)
  35. | host1x_uclass_load_syncpt_base_value_f(threshold);
  36. }
  37. static inline u32 host1x_class_host_wait_syncpt_base(
  38. unsigned indx, unsigned base_indx, unsigned offset)
  39. {
  40. return host1x_uclass_wait_syncpt_base_indx_f(indx)
  41. | host1x_uclass_wait_syncpt_base_base_indx_f(base_indx)
  42. | host1x_uclass_wait_syncpt_base_offset_f(offset);
  43. }
  44. static inline u32 host1x_class_host_incr_syncpt_base(
  45. unsigned base_indx, unsigned offset)
  46. {
  47. return host1x_uclass_incr_syncpt_base_base_indx_f(base_indx)
  48. | host1x_uclass_incr_syncpt_base_offset_f(offset);
  49. }
  50. static inline u32 host1x_class_host_incr_syncpt(
  51. unsigned cond, unsigned indx)
  52. {
  53. return host1x_uclass_incr_syncpt_cond_f(cond)
  54. | host1x_uclass_incr_syncpt_indx_f(indx);
  55. }
  56. static inline u32 host1x_class_host_indoff_reg_write(
  57. unsigned mod_id, unsigned offset, bool auto_inc)
  58. {
  59. u32 v = host1x_uclass_indoff_indbe_f(0xf)
  60. | host1x_uclass_indoff_indmodid_f(mod_id)
  61. | host1x_uclass_indoff_indroffset_f(offset);
  62. if (auto_inc)
  63. v |= host1x_uclass_indoff_autoinc_f(1);
  64. return v;
  65. }
  66. static inline u32 host1x_class_host_indoff_reg_read(
  67. unsigned mod_id, unsigned offset, bool auto_inc)
  68. {
  69. u32 v = host1x_uclass_indoff_indmodid_f(mod_id)
  70. | host1x_uclass_indoff_indroffset_f(offset)
  71. | host1x_uclass_indoff_rwn_read_v();
  72. if (auto_inc)
  73. v |= host1x_uclass_indoff_autoinc_f(1);
  74. return v;
  75. }
  76. /* cdma opcodes */
  77. static inline u32 host1x_opcode_setclass(
  78. unsigned class_id, unsigned offset, unsigned mask)
  79. {
  80. return (0 << 28) | (offset << 16) | (class_id << 6) | mask;
  81. }
  82. static inline u32 host1x_opcode_incr(unsigned offset, unsigned count)
  83. {
  84. return (1 << 28) | (offset << 16) | count;
  85. }
  86. static inline u32 host1x_opcode_nonincr(unsigned offset, unsigned count)
  87. {
  88. return (2 << 28) | (offset << 16) | count;
  89. }
  90. static inline u32 host1x_opcode_mask(unsigned offset, unsigned mask)
  91. {
  92. return (3 << 28) | (offset << 16) | mask;
  93. }
  94. static inline u32 host1x_opcode_imm(unsigned offset, unsigned value)
  95. {
  96. return (4 << 28) | (offset << 16) | value;
  97. }
  98. static inline u32 host1x_opcode_imm_incr_syncpt(unsigned cond, unsigned indx)
  99. {
  100. return host1x_opcode_imm(host1x_uclass_incr_syncpt_r(),
  101. host1x_class_host_incr_syncpt(cond, indx));
  102. }
  103. static inline u32 host1x_opcode_restart(unsigned address)
  104. {
  105. return (5 << 28) | (address >> 4);
  106. }
  107. static inline u32 host1x_opcode_gather(unsigned count)
  108. {
  109. return (6 << 28) | count;
  110. }
  111. static inline u32 host1x_opcode_gather_nonincr(unsigned offset, unsigned count)
  112. {
  113. return (6 << 28) | (offset << 16) | BIT(15) | count;
  114. }
  115. static inline u32 host1x_opcode_gather_incr(unsigned offset, unsigned count)
  116. {
  117. return (6 << 28) | (offset << 16) | BIT(15) | BIT(14) | count;
  118. }
  119. #define HOST1X_OPCODE_NOP host1x_opcode_nonincr(0, 0)
  120. #endif