msm_vidc_dt.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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. /* Bus set helpers */
  54. #define venus_hfi_for_each_bus(__device, __binfo) \
  55. venus_hfi_for_each_thing(__device, __binfo, bus)
  56. #define venus_hfi_for_each_bus_reverse(__device, __binfo) \
  57. venus_hfi_for_each_thing_reverse(__device, __binfo, bus)
  58. /* Subcache set helpers */
  59. #define venus_hfi_for_each_subcache(__device, __sinfo) \
  60. venus_hfi_for_each_thing(__device, __sinfo, subcache)
  61. #define venus_hfi_for_each_subcache_reverse(__device, __sinfo) \
  62. venus_hfi_for_each_thing_reverse(__device, __sinfo, subcache)
  63. struct reg_value_pair {
  64. u32 reg;
  65. u32 value;
  66. u32 mask;
  67. };
  68. struct reg_set {
  69. struct reg_value_pair *reg_tbl;
  70. u32 count;
  71. };
  72. struct addr_range {
  73. u32 start;
  74. u32 size;
  75. };
  76. struct addr_set {
  77. struct addr_range *addr_tbl;
  78. u32 count;
  79. };
  80. struct context_bank_info {
  81. struct list_head list;
  82. const char *name;
  83. bool is_secure;
  84. struct addr_range addr_range;
  85. struct device *dev;
  86. struct iommu_domain *domain;
  87. };
  88. struct buffer_usage_table {
  89. u32 buffer_type;
  90. u32 tz_usage;
  91. };
  92. struct buffer_usage_set {
  93. struct buffer_usage_table *buffer_usage_tbl;
  94. u32 count;
  95. };
  96. struct regulator_info {
  97. struct regulator *regulator;
  98. bool has_hw_power_collapse;
  99. char *name;
  100. };
  101. struct regulator_set {
  102. struct regulator_info *regulator_tbl;
  103. u32 count;
  104. };
  105. struct clock_info {
  106. const char *name;
  107. u32 clk_id;
  108. struct clk *clk;
  109. u32 count;
  110. bool has_scaling;
  111. bool has_mem_retention;
  112. u64 prev;
  113. struct mmrm_client *mmrm_client;
  114. };
  115. struct clock_set {
  116. struct clock_info *clock_tbl;
  117. u32 count;
  118. };
  119. struct bus_info {
  120. const char *name;
  121. u32 range[2];
  122. struct device *dev;
  123. struct icc_path *path;
  124. };
  125. struct bus_set {
  126. struct bus_info *bus_tbl;
  127. u32 count;
  128. };
  129. struct reset_info {
  130. struct reset_control *rst;
  131. const char *name;
  132. };
  133. struct reset_set {
  134. struct reset_info *reset_tbl;
  135. u32 count;
  136. };
  137. struct allowed_clock_rates_table {
  138. u32 clock_rate;
  139. };
  140. struct clock_profile_entry {
  141. u32 codec_mask;
  142. u32 vpp_cycles;
  143. u32 vsp_cycles;
  144. u32 low_power_cycles;
  145. };
  146. struct clock_freq_table {
  147. struct clock_profile_entry *clk_prof_entries;
  148. u32 count;
  149. };
  150. struct subcache_info {
  151. const char *name;
  152. bool isactive;
  153. bool isset;
  154. struct llcc_slice_desc *subcache;
  155. };
  156. struct subcache_set {
  157. struct subcache_info *subcache_tbl;
  158. u32 count;
  159. };
  160. struct msm_vidc_dt {
  161. void *core;
  162. phys_addr_t register_base;
  163. u32 register_size;
  164. u32 irq;
  165. struct allowed_clock_rates_table *allowed_clks_tbl;
  166. u32 allowed_clks_tbl_size;
  167. struct clock_freq_table clock_freq_tbl;
  168. bool sys_cache_present;
  169. bool sys_cache_res_set;
  170. struct subcache_set subcache_set;
  171. struct reg_set reg_set;
  172. struct addr_set qdss_addr_set;
  173. struct buffer_usage_set buffer_usage_set;
  174. struct regulator_set regulator_set;
  175. struct clock_set clock_set;
  176. struct bus_set bus_set;
  177. struct reset_set reset_set;
  178. struct list_head context_banks;
  179. struct mutex cb_lock;
  180. const char *fw_name;
  181. int fw_cookie;
  182. };
  183. int msm_vidc_init_dt(struct platform_device *pdev);
  184. int msm_vidc_read_context_bank_resources_from_dt(struct platform_device *pdev);
  185. void msm_vidc_deinit_dt(struct platform_device *pdev);
  186. /* A comparator to compare loads (needed later on) */
  187. static inline int cmp(const void *a, const void *b)
  188. {
  189. /* want to sort in reverse so flip the comparison */
  190. return ((struct allowed_clock_rates_table *)b)->clock_rate -
  191. ((struct allowed_clock_rates_table *)a)->clock_rate;
  192. }
  193. #endif // _MSM_VIDC_DT_H_