msm_vidc_dt.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2020, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef _MSM_VIDC_DT_H_
  6. #define _MSM_VIDC_DT_H_
  7. #include <linux/platform_device.h>
  8. #include <linux/soc/qcom/llcc-qcom.h>
  9. #include "msm_vidc_internal.h"
  10. /*
  11. * These are helper macros to iterate over various lists within
  12. * msm_vidc_core->dt. The intention is to cut down on a lot of boiler-plate
  13. * code
  14. */
  15. /* Read as "for each 'thing' in a set of 'thingies'" */
  16. #define venus_hfi_for_each_thing(__device, __thing, __thingy) \
  17. venus_hfi_for_each_thing_continue(__device, __thing, __thingy, 0)
  18. #define venus_hfi_for_each_thing_reverse(__device, __thing, __thingy) \
  19. venus_hfi_for_each_thing_reverse_continue(__device, __thing, __thingy, \
  20. (__device)->dt->__thingy##_set.count - 1)
  21. /* TODO: the __from parameter technically not required since we can figure it
  22. * out with some pointer magic (i.e. __thing - __thing##_tbl[0]). If this macro
  23. * sees extensive use, probably worth cleaning it up but for now omitting it
  24. * since it introduces unnecessary complexity.
  25. */
  26. #define venus_hfi_for_each_thing_continue(__device, __thing, __thingy, __from) \
  27. for (__thing = &(__device)->dt->\
  28. __thingy##_set.__thingy##_tbl[__from]; \
  29. __thing < &(__device)->dt->__thingy##_set.__thingy##_tbl[0] + \
  30. ((__device)->dt->__thingy##_set.count - __from); \
  31. ++__thing)
  32. #define venus_hfi_for_each_thing_reverse_continue(__device, __thing, __thingy, \
  33. __from) \
  34. for (__thing = &(__device)->dt->\
  35. __thingy##_set.__thingy##_tbl[__from]; \
  36. __thing >= &(__device)->dt->__thingy##_set.__thingy##_tbl[0]; \
  37. --__thing)
  38. /* Regular set helpers */
  39. #define venus_hfi_for_each_regulator(__device, __rinfo) \
  40. venus_hfi_for_each_thing(__device, __rinfo, regulator)
  41. #define venus_hfi_for_each_regulator_reverse(__device, __rinfo) \
  42. venus_hfi_for_each_thing_reverse(__device, __rinfo, regulator)
  43. #define venus_hfi_for_each_regulator_reverse_continue(__device, __rinfo, \
  44. __from) \
  45. venus_hfi_for_each_thing_reverse_continue(__device, __rinfo, \
  46. regulator, __from)
  47. /* Clock set helpers */
  48. #define venus_hfi_for_each_clock(__device, __cinfo) \
  49. venus_hfi_for_each_thing(__device, __cinfo, clock)
  50. #define venus_hfi_for_each_clock_reverse(__device, __cinfo) \
  51. venus_hfi_for_each_thing_reverse(__device, __cinfo, clock)
  52. #define venus_hfi_for_each_clock_reverse_continue(__device, __rinfo, \
  53. __from) \
  54. venus_hfi_for_each_thing_reverse_continue(__device, __rinfo, \
  55. clock, __from)
  56. /* Bus set helpers */
  57. #define venus_hfi_for_each_bus(__device, __binfo) \
  58. venus_hfi_for_each_thing(__device, __binfo, bus)
  59. #define venus_hfi_for_each_bus_reverse(__device, __binfo) \
  60. venus_hfi_for_each_thing_reverse(__device, __binfo, bus)
  61. /* Subcache set helpers */
  62. #define venus_hfi_for_each_subcache(__device, __sinfo) \
  63. venus_hfi_for_each_thing(__device, __sinfo, subcache)
  64. #define venus_hfi_for_each_subcache_reverse(__device, __sinfo) \
  65. venus_hfi_for_each_thing_reverse(__device, __sinfo, subcache)
  66. struct reg_value_pair {
  67. u32 reg;
  68. u32 value;
  69. u32 mask;
  70. };
  71. struct reg_set {
  72. struct reg_value_pair *reg_tbl;
  73. u32 count;
  74. };
  75. struct addr_range {
  76. u32 start;
  77. u32 size;
  78. };
  79. struct addr_set {
  80. struct addr_range *addr_tbl;
  81. u32 count;
  82. };
  83. struct context_bank_info {
  84. struct list_head list;
  85. const char *name;
  86. u32 buffer_type;
  87. bool is_secure;
  88. struct addr_range addr_range;
  89. struct device *dev;
  90. struct iommu_domain *domain;
  91. };
  92. struct buffer_usage_table {
  93. u32 buffer_type;
  94. u32 tz_usage;
  95. };
  96. struct buffer_usage_set {
  97. struct buffer_usage_table *buffer_usage_tbl;
  98. u32 count;
  99. };
  100. struct regulator_info {
  101. struct regulator *regulator;
  102. bool has_hw_power_collapse;
  103. char *name;
  104. };
  105. struct regulator_set {
  106. struct regulator_info *regulator_tbl;
  107. u32 count;
  108. };
  109. struct clock_info {
  110. const char *name;
  111. struct clk *clk;
  112. u32 count;
  113. bool has_scaling;
  114. bool has_mem_retention;
  115. u64 prev;
  116. };
  117. struct clock_set {
  118. struct clock_info *clock_tbl;
  119. u32 count;
  120. };
  121. struct bus_info {
  122. const char *name;
  123. u32 range[2];
  124. struct device *dev;
  125. struct icc_path *path;
  126. };
  127. struct bus_set {
  128. struct bus_info *bus_tbl;
  129. u32 count;
  130. };
  131. struct reset_info {
  132. struct reset_control *rst;
  133. const char *name;
  134. };
  135. struct reset_set {
  136. struct reset_info *reset_tbl;
  137. u32 count;
  138. };
  139. struct allowed_clock_rates_table {
  140. u32 clock_rate;
  141. };
  142. struct clock_profile_entry {
  143. u32 codec_mask;
  144. u32 vpp_cycles;
  145. u32 vsp_cycles;
  146. u32 low_power_cycles;
  147. };
  148. struct clock_freq_table {
  149. struct clock_profile_entry *clk_prof_entries;
  150. u32 count;
  151. };
  152. struct subcache_info {
  153. const char *name;
  154. bool isactive;
  155. bool isset;
  156. struct llcc_slice_desc *subcache;
  157. };
  158. struct subcache_set {
  159. struct subcache_info *subcache_tbl;
  160. u32 count;
  161. };
  162. struct msm_vidc_dt {
  163. void *core;
  164. phys_addr_t register_base;
  165. u32 register_size;
  166. u32 irq;
  167. u32 sku_version;
  168. struct allowed_clock_rates_table *allowed_clks_tbl;
  169. u32 allowed_clks_tbl_size;
  170. struct clock_freq_table clock_freq_tbl;
  171. bool sys_cache_present;
  172. bool sys_cache_res_set;
  173. struct subcache_set subcache_set;
  174. struct reg_set reg_set;
  175. struct addr_set qdss_addr_set;
  176. struct buffer_usage_set buffer_usage_set;
  177. struct regulator_set regulator_set;
  178. struct clock_set clock_set;
  179. struct bus_set bus_set;
  180. struct reset_set reset_set;
  181. struct list_head context_banks;
  182. struct mutex cb_lock;
  183. const char *fw_name;
  184. int fw_cookie;
  185. };
  186. int msm_vidc_init_dt(struct platform_device *pdev);
  187. int msm_vidc_read_context_bank_resources_from_dt(struct platform_device *pdev);
  188. void msm_vidc_deinit_dt(struct platform_device *pdev);
  189. #endif // _MSM_VIDC_DT_H_