cam_cpas_soc.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef _CAM_CPAS_SOC_H_
  6. #define _CAM_CPAS_SOC_H_
  7. #include <linux/soc/qcom/llcc-qcom.h>
  8. #include "cam_soc_util.h"
  9. #include "cam_cpas_hw.h"
  10. #define CAM_REGULATOR_LEVEL_MAX 16
  11. #define CAM_CPAS_MAX_TREE_NODES 56
  12. #define CAM_CPAS_MAX_FUSE_FEATURE 10
  13. /**
  14. * struct cam_cpas_vdd_ahb_mapping : Voltage to ahb level mapping
  15. *
  16. * @vdd_corner : Voltage corner value
  17. * @ahb_level : AHB vote level corresponds to this vdd_corner
  18. *
  19. */
  20. struct cam_cpas_vdd_ahb_mapping {
  21. unsigned int vdd_corner;
  22. enum cam_vote_level ahb_level;
  23. };
  24. /**
  25. * struct cpas_tree_node: Generic cpas tree node for BW voting
  26. *
  27. * @cell_idx: Index to identify node from device tree and its parent
  28. * @level_idx: Index to identify at what level the node is present
  29. * @axi_port_idx: Index to identify which axi port to vote the consolidated bw
  30. * @camnoc_axi_port_idx: Index to find which axi port to vote consolidated bw
  31. * @path_data_type: Traffic type info from device tree (ife-vid, ife-disp etc)
  32. * @path_trans_type: Transaction type info from device tree (rd, wr)
  33. * @merge_type: Traffic merge type (calculation info) from device tree
  34. * @bus_width_factor: Factor for accounting bus width in CAMNOC bw calculation
  35. * @camnoc_bw: CAMNOC bw value at current node
  36. * @mnoc_ab_bw: MNOC AB bw value at current node
  37. * @mnoc_ib_bw: MNOC IB bw value at current node
  38. * @ddr_ab_bw: DDR AB bw value at current node
  39. * @ddr_ib_bw: DDR IB bw value at current node
  40. * @camnoc_max_needed: If node is needed for CAMNOC BW calculation then true
  41. * @constituent_paths: Constituent paths presence info from device tree
  42. * Ex: For CAM_CPAS_PATH_DATA_IFE_UBWC_STATS, index corresponding to
  43. * CAM_CPAS_PATH_DATA_IFE_VID, CAM_CPAS_PATH_DATA_IFE_DISP and
  44. * CAM_CPAS_PATH_DATA_IFE_STATS
  45. * @tree_dev_node: Device node from devicetree for current tree node
  46. * @parent_node: Pointer to node one or more level above the current level
  47. * (starting from end node of cpas client)
  48. *
  49. */
  50. struct cam_cpas_tree_node {
  51. uint32_t cell_idx;
  52. int level_idx;
  53. int axi_port_idx;
  54. int camnoc_axi_port_idx;
  55. const char *node_name;
  56. uint32_t path_data_type;
  57. uint32_t path_trans_type;
  58. uint32_t merge_type;
  59. uint32_t bus_width_factor;
  60. uint64_t camnoc_bw;
  61. uint64_t mnoc_ab_bw;
  62. uint64_t mnoc_ib_bw;
  63. uint64_t ddr_ab_bw;
  64. uint64_t ddr_ib_bw;
  65. bool camnoc_max_needed;
  66. bool constituent_paths[CAM_CPAS_PATH_DATA_MAX];
  67. struct device_node *tree_dev_node;
  68. struct cam_cpas_tree_node *parent_node;
  69. };
  70. /**
  71. * struct cam_cpas_feature_info : CPAS fuse feature info
  72. * @feature: Identifier for feature
  73. * @type: Type of feature
  74. * @value: Fuse value
  75. * @enable: Feature enable or disable
  76. * @hw_map: Each bit position indicates if the hw_id for the feature
  77. */
  78. struct cam_cpas_feature_info {
  79. uint32_t feature;
  80. uint32_t type;
  81. uint32_t value;
  82. bool enable;
  83. uint32_t hw_map;
  84. };
  85. /**
  86. * struct cam_sys_cache_info : Last level camera cache info
  87. *
  88. * @ref_cnt: Ref cnt activate/deactivate cache
  89. * @type: cache type small/large etc.
  90. * @uid: Client user ID
  91. * @size: Cache size
  92. * @scid: Slice ID
  93. * @slic_desc: Slice descriptor
  94. */
  95. struct cam_sys_cache_info {
  96. uint32_t ref_cnt;
  97. enum cam_sys_cache_config_types type;
  98. uint32_t uid;
  99. size_t size;
  100. int32_t scid;
  101. const char *name;
  102. struct llcc_slice_desc *slic_desc;
  103. };
  104. /**
  105. * struct cam_cpas_private_soc : CPAS private DT info
  106. *
  107. * @arch_compat: ARCH compatible string
  108. * @client_id_based: Whether clients are id based
  109. * @bus_icc_based: Interconnect based bus interaction
  110. * @num_clients: Number of clients supported
  111. * @client_name: Client names
  112. * @tree_node: Array of pointers to all tree nodes required to calculate
  113. * axi bw, arranged with help of cell index in device tree
  114. * @camera_bus_node: Device tree node from cpas node
  115. * @level_node: Device tree node for each level in camera_bus_node
  116. * @num_vdd_ahb_mapping : Number of vdd to ahb level mapping supported
  117. * @vdd_ahb : AHB level mapping info for the supported vdd levels
  118. * @control_camnoc_axi_clk : Whether CPAS driver need to set camnoc axi clk freq
  119. * @camnoc_bus_width : CAMNOC Bus width
  120. * @camnoc_axi_clk_bw_margin : BW Margin in percentage to add while calculating
  121. * camnoc axi clock
  122. * @camnoc_axi_min_ib_bw: Min camnoc BW which varies based on target
  123. * @fuse_info: fuse information
  124. * @rpmh_info: RPMH BCM info
  125. * @num_feature_info: number of feature_info entries
  126. * @feature_info: Structure for storing feature information
  127. * @num_caches: Number of last level caches
  128. * @llcc_info: Cache info
  129. */
  130. struct cam_cpas_private_soc {
  131. const char *arch_compat;
  132. bool client_id_based;
  133. bool bus_icc_based;
  134. uint32_t num_clients;
  135. const char *client_name[CAM_CPAS_MAX_CLIENTS];
  136. struct cam_cpas_tree_node *tree_node[CAM_CPAS_MAX_TREE_NODES];
  137. struct device_node *camera_bus_node;
  138. struct device_node *level_node[CAM_CPAS_MAX_TREE_LEVELS];
  139. uint32_t num_vdd_ahb_mapping;
  140. struct cam_cpas_vdd_ahb_mapping vdd_ahb[CAM_REGULATOR_LEVEL_MAX];
  141. bool control_camnoc_axi_clk;
  142. uint32_t camnoc_bus_width;
  143. uint32_t camnoc_axi_clk_bw_margin;
  144. uint64_t camnoc_axi_min_ib_bw;
  145. struct cam_cpas_fuse_info fuse_info;
  146. uint32_t rpmh_info[CAM_RPMH_BCM_INFO_MAX];
  147. uint32_t num_feature_info;
  148. struct cam_cpas_feature_info feature_info[CAM_CPAS_MAX_FUSE_FEATURE];
  149. uint32_t num_caches;
  150. struct cam_sys_cache_info *llcc_info;
  151. };
  152. void cam_cpas_util_debug_parse_data(struct cam_cpas_private_soc *soc_private);
  153. void cam_cpas_dump_axi_vote_info(
  154. const struct cam_cpas_client *cpas_client,
  155. const char *identifier,
  156. struct cam_axi_vote *axi_vote);
  157. int cam_cpas_node_tree_cleanup(struct cam_cpas *cpas_core,
  158. struct cam_cpas_private_soc *soc_private);
  159. int cam_cpas_soc_init_resources(struct cam_hw_soc_info *soc_info,
  160. irq_handler_t vfe_irq_handler, struct cam_hw_info *cpas_hw);
  161. int cam_cpas_soc_deinit_resources(struct cam_hw_soc_info *soc_info);
  162. int cam_cpas_soc_enable_resources(struct cam_hw_soc_info *soc_info,
  163. enum cam_vote_level default_level);
  164. int cam_cpas_soc_disable_resources(struct cam_hw_soc_info *soc_info,
  165. bool disable_clocks, bool disable_irq);
  166. int cam_cpas_soc_disable_irq(struct cam_hw_soc_info *soc_info);
  167. #endif /* _CAM_CPAS_SOC_H_ */