msm_vidc_dt.h 5.5 KB

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