cam_cpas_soc.h 4.8 KB

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