cam_cpas_soc.h 5.5 KB

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