cam_cpas_soc.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2022, Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef _CAM_CPAS_SOC_H_
  7. #define _CAM_CPAS_SOC_H_
  8. #include <linux/soc/qcom/llcc-qcom.h>
  9. #include "cam_soc_util.h"
  10. #include "cam_cpas_hw.h"
  11. #define CAM_REGULATOR_LEVEL_MAX 16
  12. #define CAM_CPAS_MAX_TREE_NODES 63
  13. #define CAM_CPAS_MAX_FUSE_FEATURE 10
  14. /**
  15. * struct cpas_tree_node: Generic cpas tree node for BW voting
  16. *
  17. * @cell_idx: Index to identify node from device tree and its parent
  18. * @level_idx: Index to identify at what level the node is present
  19. * @axi_port_idx_arr: Index to identify which axi port to vote the consolidated bw.
  20. * It can point to multiple indexes in case of camera DRV
  21. * @drv_voting_idx: Specifies the index to which the child node would finally vote.
  22. * @camnoc_axi_port_idx: Index to find which axi port to vote consolidated bw
  23. * @path_data_type: Traffic type info from device tree (ife-vid, ife-disp etc)
  24. * @path_trans_type: Transaction type info from device tree (rd, wr)
  25. * @merge_type: Traffic merge type (calculation info) from device tree
  26. * @bus_width_factor: Factor for accounting bus width in CAMNOC bw calculation
  27. * @camnoc_bw: CAMNOC bw value at current node
  28. * @bw_info: AXI BW info for all drv ports
  29. * @camnoc_max_needed: If node is needed for CAMNOC BW calculation then true
  30. * @constituent_paths: Constituent paths presence info from device tree
  31. * Ex: For CAM_CPAS_PATH_DATA_IFE_UBWC_STATS, index corresponding to
  32. * CAM_CPAS_PATH_DATA_IFE_VID, CAM_CPAS_PATH_DATA_IFE_DISP and
  33. * CAM_CPAS_PATH_DATA_IFE_STATS
  34. * @tree_dev_node: Device node from devicetree for current tree node
  35. * @parent_node: Pointer to node one or more level above the current level
  36. * (starting from end node of cpas client)
  37. * @pri_lut_low_offset: Register offset value for priority lut low.
  38. * Valid only for level1 nodes (representing NIUs)
  39. * @pri_lut_high_offset: Register offset value for priority lut high.
  40. * Valid only for level1 nodes (representing NIUs)
  41. * @niu_size: Size of NIU that this node represents. Size in KB
  42. * @curr_priority_low: New calculated priority lut low values
  43. * @curr_priority_high: New calculated priority lut high values
  44. * @applied_priority_low: Currently applied priority lut low values
  45. * @applied_priority_high: Currently applied priority lut high values
  46. *
  47. */
  48. struct cam_cpas_tree_node {
  49. uint32_t cell_idx;
  50. int level_idx;
  51. int *axi_port_idx_arr;
  52. int drv_voting_idx;
  53. int camnoc_axi_port_idx;
  54. const char *node_name;
  55. uint32_t path_data_type;
  56. uint32_t path_trans_type;
  57. uint32_t merge_type;
  58. uint32_t bus_width_factor;
  59. uint64_t camnoc_bw;
  60. struct cam_cpas_axi_bw_info *bw_info;
  61. bool camnoc_max_needed;
  62. bool constituent_paths[CAM_CPAS_PATH_DATA_MAX];
  63. struct device_node *tree_dev_node;
  64. struct cam_cpas_tree_node *parent_node;
  65. uint32_t pri_lut_low_offset;
  66. uint32_t pri_lut_high_offset;
  67. uint32_t niu_size;
  68. uint32_t curr_priority_low;
  69. uint32_t curr_priority_high;
  70. uint32_t applied_priority_low;
  71. uint32_t applied_priority_high;
  72. };
  73. /**
  74. * struct cam_cpas_feature_info : CPAS fuse feature info
  75. * @feature: Identifier for feature
  76. * @type: Type of feature
  77. * @value: Fuse value
  78. * @enable: Feature enable or disable
  79. * @hw_map: Each bit position indicates if the hw_id for the feature
  80. */
  81. struct cam_cpas_feature_info {
  82. uint32_t feature;
  83. uint32_t type;
  84. uint32_t value;
  85. bool enable;
  86. uint32_t hw_map;
  87. };
  88. /**
  89. * struct cam_sys_cache_info : Last level camera cache info
  90. *
  91. * @ref_cnt: Ref cnt activate/deactivate cache
  92. * @type: cache type small/large etc.
  93. * @uid: Client user ID
  94. * @size: Cache size
  95. * @scid: Slice ID
  96. * @slic_desc: Slice descriptor
  97. */
  98. struct cam_sys_cache_info {
  99. uint32_t ref_cnt;
  100. enum cam_sys_cache_config_types type;
  101. uint32_t uid;
  102. size_t size;
  103. int32_t scid;
  104. const char *name;
  105. struct llcc_slice_desc *slic_desc;
  106. };
  107. /**
  108. * struct cam_cpas_smart_qos_info : Smart QOS info
  109. *
  110. * @rt_wr_priority_min: Minimum priority value for rt write nius
  111. * @rt_wr_priority_max: Maximum priority value for rt write nius
  112. * @rt_wr_priority_clamp: Clamp priority value for rt write nius
  113. * @rt_wr_slope_factor: Slope factor value for rt write nius
  114. * @leaststressed_clamp_th: Leaststressed clamp threshold value for rt write nius
  115. * @moststressed_clamp_th: Moststressed clamp threshold value for rt write nius
  116. * @highstress_indicator_th: Highstress indicator threshold value for rt write nius
  117. * @lowstress_indicator_th: Lowstress indicator threshold value for rt write nius
  118. * @bw_ratio_scale_factor: BW ratio scale factor value for rt write nius
  119. * @num_rt_wr_nius: Number of rt write nius
  120. * @rt_wr_niu_node: List of level1 nodes representing rt write nius
  121. */
  122. struct cam_cpas_smart_qos_info {
  123. uint8_t rt_wr_priority_min;
  124. uint8_t rt_wr_priority_max;
  125. uint8_t rt_wr_priority_clamp;
  126. uint8_t rt_wr_slope_factor;
  127. uint8_t leaststressed_clamp_th;
  128. uint8_t moststressed_clamp_th;
  129. uint8_t highstress_indicator_th;
  130. uint8_t lowstress_indicator_th;
  131. uint8_t bw_ratio_scale_factor;
  132. uint8_t num_rt_wr_nius;
  133. struct cam_cpas_tree_node *rt_wr_niu_node[CAM_CPAS_MAX_RT_WR_NIU_NODES];
  134. };
  135. /**
  136. * struct cam_cpas_domain_id_mapping : Domain id mapping
  137. *
  138. * @domain_type: Domain type, currently defined as two,
  139. * secure/non-secure. This will be expanded
  140. * later to more types, and correspnding ID
  141. * @mapping_id: ID of domain type
  142. */
  143. struct cam_cpas_domain_id_mapping {
  144. uint32_t domain_type;
  145. uint32_t mapping_id;
  146. };
  147. /**
  148. * struct cam_cpas_domain_id_info : Stores all information related
  149. * to domain-id support
  150. * @domain_id_entries: Stores mapping between domain types and their IDs
  151. * @num_domain_ids: Num of domain id types found from dtsi
  152. * @domain_id_supported: Whether domain id is supported
  153. */
  154. struct cam_cpas_domain_id_info {
  155. struct cam_cpas_domain_id_mapping *domain_id_entries;
  156. uint32_t num_domain_ids;
  157. bool domain_id_supported;
  158. };
  159. /**
  160. * struct cam_cpas_domain_id_support_clks : Stores all information
  161. * related to clocks
  162. * needed to turn on SWIs
  163. * for domain id programming
  164. * @clk_names: Clock names as declared in DT
  165. * @clk_idx: Corresponding clk index as declared in DT
  166. * @number_clks: Number of clocks declared to turn all CSIDs
  167. */
  168. struct cam_cpas_domain_id_support_clks {
  169. const char *clk_names[CAM_SOC_MAX_OPT_CLK];
  170. int32_t clk_idx[CAM_SOC_MAX_OPT_CLK];
  171. int number_clks;
  172. };
  173. /**
  174. * struct cam_cpas_private_soc : CPAS private DT info
  175. *
  176. * @arch_compat: ARCH compatible string
  177. * @client_id_based: Whether clients are id based
  178. * @bus_icc_based: Interconnect based bus interaction
  179. * @num_clients: Number of clients supported
  180. * @client_name: Client names
  181. * @tree_node: Array of pointers to all tree nodes required to calculate
  182. * axi bw, arranged with help of cell index in device tree
  183. * @camera_bus_node: Device tree node from cpas node
  184. * @level_node: Device tree node for each level in camera_bus_node
  185. * @num_vdd_ahb_mapping : Number of vdd to ahb level mapping supported
  186. * @vdd_ahb : AHB level mapping info for the supported vdd levels
  187. * @control_camnoc_axi_clk : Whether CPAS driver need to set camnoc axi clk freq
  188. * @camnoc_bus_width : CAMNOC Bus width
  189. * @camnoc_axi_clk_bw_margin : BW Margin in percentage to add while calculating
  190. * camnoc axi clock
  191. * @camnoc_axi_min_ib_bw: Min camnoc BW which varies based on target
  192. * @fuse_info: fuse information
  193. * @rpmh_info: RPMH BCM info
  194. * @num_feature_info: number of feature_info entries
  195. * @feature_info: Structure for storing feature information
  196. * @num_caches: Number of last level caches
  197. * @llcc_info: Cache info
  198. * @enable_smart_qos: Whether to enable Smart QoS mechanism on current chipset
  199. * @enable_cam_ddr_drv: Whether to enable Camera DDR DRV on current chipset
  200. * @smart_qos_info: Pointer to smart qos info
  201. * @icp_clk_index: Index of optional icp clk
  202. * @domain_id_info: Stores all information related to domain id support
  203. * @domain_id_clks: All clock related information for domain id support
  204. */
  205. struct cam_cpas_private_soc {
  206. const char *arch_compat;
  207. bool client_id_based;
  208. bool bus_icc_based;
  209. uint32_t num_clients;
  210. const char *client_name[CAM_CPAS_MAX_CLIENTS];
  211. struct cam_cpas_tree_node *tree_node[CAM_CPAS_MAX_TREE_NODES];
  212. struct device_node *camera_bus_node;
  213. struct device_node *level_node[CAM_CPAS_MAX_TREE_LEVELS];
  214. uint32_t num_vdd_ahb_mapping;
  215. struct cam_cpas_vdd_ahb_mapping vdd_ahb[CAM_REGULATOR_LEVEL_MAX];
  216. bool control_camnoc_axi_clk;
  217. uint32_t camnoc_bus_width;
  218. uint32_t camnoc_axi_clk_bw_margin;
  219. uint64_t camnoc_axi_min_ib_bw;
  220. struct cam_cpas_fuse_info fuse_info;
  221. uint32_t rpmh_info[CAM_RPMH_BCM_INFO_MAX];
  222. uint32_t num_feature_info;
  223. struct cam_cpas_feature_info feature_info[CAM_CPAS_MAX_FUSE_FEATURE];
  224. uint32_t num_caches;
  225. struct cam_sys_cache_info *llcc_info;
  226. bool enable_smart_qos;
  227. bool enable_cam_ddr_drv;
  228. struct cam_cpas_smart_qos_info *smart_qos_info;
  229. int32_t icp_clk_index;
  230. struct cam_cpas_domain_id_info domain_id_info;
  231. struct cam_cpas_domain_id_support_clks *domain_id_clks;
  232. };
  233. void cam_cpas_dump_tree_vote_info(const struct cam_cpas_tree_node *tree_node,
  234. const char *identifier, int drv_voting_idx);
  235. void cam_cpas_util_debug_parse_data(struct cam_cpas_private_soc *soc_private);
  236. void cam_cpas_dump_axi_vote_info(
  237. const struct cam_cpas_client *cpas_client,
  238. const char *identifier,
  239. struct cam_axi_vote *axi_vote);
  240. int cam_cpas_node_tree_cleanup(struct cam_cpas *cpas_core,
  241. struct cam_cpas_private_soc *soc_private);
  242. int cam_cpas_soc_init_resources(struct cam_hw_soc_info *soc_info,
  243. irq_handler_t vfe_irq_handler, struct cam_hw_info *cpas_hw);
  244. int cam_cpas_soc_deinit_resources(struct cam_hw_soc_info *soc_info);
  245. int cam_cpas_soc_enable_resources(struct cam_hw_soc_info *soc_info,
  246. enum cam_vote_level default_level);
  247. int cam_cpas_soc_disable_resources(struct cam_hw_soc_info *soc_info,
  248. bool disable_clocks, bool disable_irq);
  249. int cam_cpas_soc_disable_irq(struct cam_hw_soc_info *soc_info);
  250. #endif /* _CAM_CPAS_SOC_H_ */