sde_hw_wb.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2015-2021, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef _SDE_HW_WB_H
  6. #define _SDE_HW_WB_H
  7. #include "sde_hw_catalog.h"
  8. #include "sde_hw_mdss.h"
  9. #include "sde_hw_top.h"
  10. #include "sde_hw_util.h"
  11. #include "sde_hw_pingpong.h"
  12. #include "sde_hw_vbif.h"
  13. struct sde_hw_wb;
  14. struct sde_hw_wb_cfg {
  15. struct sde_hw_fmt_layout dest;
  16. enum sde_intf_mode intf_mode;
  17. struct sde_rect roi;
  18. struct sde_rect crop;
  19. bool is_secure;
  20. };
  21. /**
  22. * enum CDP preload ahead address size
  23. */
  24. enum {
  25. SDE_WB_CDP_PRELOAD_AHEAD_32,
  26. SDE_WB_CDP_PRELOAD_AHEAD_64
  27. };
  28. /**
  29. * struct sde_hw_wb_cdp_cfg : CDP configuration
  30. * @enable: true to enable CDP
  31. * @ubwc_meta_enable: true to enable ubwc metadata preload
  32. * @tile_amortize_enable: true to enable amortization control for tile format
  33. * @preload_ahead: number of request to preload ahead
  34. * SDE_WB_CDP_PRELOAD_AHEAD_32,
  35. * SDE_WB_CDP_PRELOAD_AHEAD_64
  36. */
  37. struct sde_hw_wb_cdp_cfg {
  38. bool enable;
  39. bool ubwc_meta_enable;
  40. bool tile_amortize_enable;
  41. u32 preload_ahead;
  42. };
  43. /**
  44. * struct sde_hw_wb_qos_cfg : Writeback pipe QoS configuration
  45. * @danger_lut: LUT for generate danger level based on fill level
  46. * @safe_lut: LUT for generate safe level based on fill level
  47. * @creq_lut: LUT for generate creq level based on fill level
  48. * @danger_safe_en: enable danger safe generation
  49. */
  50. struct sde_hw_wb_qos_cfg {
  51. u32 danger_lut;
  52. u32 safe_lut;
  53. u64 creq_lut;
  54. bool danger_safe_en;
  55. };
  56. /**
  57. * struct sde_hw_wb_sc_cfg - system cache configuration
  58. * @wr_en: system cache read enable
  59. * @wr_scid: system cache read block id
  60. * @wr_noallocate: system cache read no allocate attribute
  61. * @wr_op_type: system cache read operation type
  62. * @flags: dirty flags to change the configuration
  63. * @type: sys cache type
  64. */
  65. struct sde_hw_wb_sc_cfg {
  66. bool wr_en;
  67. u32 wr_scid;
  68. bool wr_noallocate;
  69. u32 wr_op_type;
  70. u32 flags;
  71. enum sde_sys_cache_type type;
  72. };
  73. /**
  74. *
  75. * struct sde_hw_wb_ops : Interface to the wb Hw driver functions
  76. * Assumption is these functions will be called after clocks are enabled
  77. */
  78. struct sde_hw_wb_ops {
  79. void (*setup_csc_data)(struct sde_hw_wb *ctx,
  80. struct sde_csc_cfg *data);
  81. void (*setup_outaddress)(struct sde_hw_wb *ctx,
  82. struct sde_hw_wb_cfg *wb);
  83. void (*setup_outformat)(struct sde_hw_wb *ctx,
  84. struct sde_hw_wb_cfg *wb);
  85. void (*setup_rotator)(struct sde_hw_wb *ctx,
  86. struct sde_hw_wb_cfg *wb);
  87. void (*setup_dither)(struct sde_hw_wb *ctx,
  88. struct sde_hw_wb_cfg *wb);
  89. void (*setup_cdwn)(struct sde_hw_wb *ctx,
  90. struct sde_hw_wb_cfg *wb);
  91. void (*setup_trafficshaper)(struct sde_hw_wb *ctx,
  92. struct sde_hw_wb_cfg *wb);
  93. void (*setup_roi)(struct sde_hw_wb *ctx,
  94. struct sde_hw_wb_cfg *wb);
  95. void (*setup_crop)(struct sde_hw_wb *ctx,
  96. struct sde_hw_wb_cfg *wb, bool crop);
  97. /**
  98. * setup_qos_lut - setup danger, safe, creq, etc. LUTs
  99. * @ctx: Pointer to pipe context
  100. * @cfg: Pointer to pipe QoS configuration
  101. */
  102. void (*setup_qos_lut)(struct sde_hw_wb *ctx,
  103. struct sde_hw_wb_qos_cfg *cfg);
  104. /**
  105. * setup_cdp - setup CDP
  106. * @ctx: Pointer to pipe context
  107. * @cfg: Pointer to pipe CDP configuration
  108. */
  109. void (*setup_cdp)(struct sde_hw_wb *ctx,
  110. struct sde_hw_wb_cdp_cfg *cfg);
  111. /**
  112. * bind_pingpong_blk - enable/disable the connection with pp
  113. * @ctx: Pointer to wb context
  114. * @enable: enable/disable connection
  115. * @pp: pingpong blk id
  116. */
  117. void (*bind_pingpong_blk)(struct sde_hw_wb *ctx,
  118. bool enable,
  119. const enum sde_pingpong pp);
  120. /**
  121. * bind_dcwb_pp_blk - enable/disable the connection with cwb pp
  122. * @ctx: Pointer to wb context
  123. * @enable: enable/disable connection
  124. * @pp: pingpong blk id
  125. */
  126. void (*bind_dcwb_pp_blk)(struct sde_hw_wb *ctx,
  127. bool enable,
  128. const enum sde_pingpong pp);
  129. /**
  130. * program_cwb_ctrl - program cwb block configp
  131. * @ctx: Pointer to wb context
  132. * @pp_idx: Current CWB block index to poram
  133. * @data_src: Source CWB/PingPong block index
  134. * @dspp_out: Tap dspp output or default LM output
  135. * @enable: enable or disable the CWB path to tap the output
  136. */
  137. void (*program_cwb_ctrl)(struct sde_hw_wb *ctx, const enum sde_cwb cwb,
  138. const enum sde_cwb data_src, bool dspp_out, bool enable);
  139. /**
  140. * program_dcwb_ctrl - program cwb block configp
  141. * @ctx: Pointer to wb context
  142. * @pp_idx: Current CWB block index to poram
  143. * @data_src: Source CWB/PingPong block index
  144. * @tap_location: Tap LM output, dspp output or Demura output
  145. * @enable: enable or disable the CWB path to tap the output
  146. */
  147. void (*program_dcwb_ctrl)(struct sde_hw_wb *ctx, const enum sde_dcwb cwb,
  148. const enum sde_cwb data_src, int tap_location, bool enable);
  149. /**
  150. * setup_sys_cache - setup system cache configuration
  151. * @ctx: Pointer to wb context
  152. * @cfg: Pointer to wb system cache configuration
  153. */
  154. void (*setup_sys_cache)(struct sde_hw_wb *ctx, struct sde_hw_wb_sc_cfg *cfg);
  155. /**
  156. * program_cwb_dither_ctrl - program cwb dither block config
  157. * @ctx: Pointer to wb context
  158. * @dcwb_idx: Current Ping-Pong CWB block index to program
  159. * @cfg: cwb dither data
  160. * @len: the size of cwb dither data
  161. * @enable: enable or disable the cwb dither
  162. */
  163. void (*program_cwb_dither_ctrl)(struct sde_hw_wb *ctx,
  164. const enum sde_dcwb dcwb_idx, void *cfg, size_t len, bool enable);
  165. /**
  166. * get_line_count - get current wb output linecount
  167. * @ctx: Pointer to wb context
  168. */
  169. u32 (*get_line_count)(struct sde_hw_wb *ctx);
  170. /**
  171. * set_prog_line_count - set wb programmable line
  172. * @ctx: Pointer to wb context
  173. * @line_count: programmable line-count value
  174. */
  175. void (*set_prog_line_count)(struct sde_hw_wb *ctx, u32 line_count);
  176. /**
  177. * get_ubwc_error - get ubwc error status
  178. * @ctx: Pointer to wb context
  179. */
  180. u32 (*get_ubwc_error)(struct sde_hw_wb *ctx);
  181. /**
  182. * clear_ubwc_error - clear ubwc error status
  183. * @ctx: Pointer to wb context
  184. */
  185. void (*clear_ubwc_error)(struct sde_hw_wb *ctx);
  186. };
  187. /**
  188. * struct sde_hw_wb : WB driver object
  189. * @base: hardware block base structure
  190. * @hw: block hardware details
  191. * @catalog: back pointer to catalog
  192. * @mdp: pointer to associated mdp portion of the catalog
  193. * @idx: hardware index number within type
  194. * @wb_hw_caps: hardware capabilities
  195. * @ops: function pointers
  196. * @hw_mdp: MDP top level hardware block
  197. * @cwb_hw: CWB control hwio details
  198. * @dcwb_hw: DCWB control hwio details
  199. * @dcwb_pp_hw: DCWB PingPong control hwio details
  200. */
  201. struct sde_hw_wb {
  202. struct sde_hw_blk_reg_map hw;
  203. struct sde_mdss_cfg *catalog;
  204. struct sde_mdp_cfg *mdp;
  205. /* wb path */
  206. int idx;
  207. const struct sde_wb_cfg *caps;
  208. /* ops */
  209. struct sde_hw_wb_ops ops;
  210. struct sde_hw_mdp *hw_mdp;
  211. struct sde_hw_blk_reg_map cwb_hw;
  212. struct sde_hw_blk_reg_map dcwb_hw;
  213. struct sde_hw_pingpong dcwb_pp_hw[DCWB_MAX - DCWB_0];
  214. };
  215. /**
  216. * to_sde_hw_wb - convert base hw object to sde_hw_wb container
  217. * @hw: Pointer to hardware block register map object
  218. * return: Pointer to hardware block container
  219. */
  220. static inline struct sde_hw_wb *to_sde_hw_wb(struct sde_hw_blk_reg_map *hw)
  221. {
  222. return container_of(hw, struct sde_hw_wb, hw);
  223. }
  224. /**
  225. * sde_hw_wb_init(): Initializes and return writeback hw driver object.
  226. * @idx: wb_path index for which driver object is required
  227. * @addr: mapped register io address of MDP
  228. * @m : pointer to mdss catalog data
  229. * @hw_mdp: pointer to mdp top hw driver object
  230. * @clk_client: pointer to vbif clk client info
  231. */
  232. struct sde_hw_blk_reg_map *sde_hw_wb_init(enum sde_wb idx,
  233. void __iomem *addr,
  234. struct sde_mdss_cfg *m,
  235. struct sde_hw_mdp *hw_mdp,
  236. struct sde_vbif_clk_client *clk_client);
  237. /**
  238. * sde_hw_wb_destroy(): Destroy writeback hw driver object.
  239. * @hw: Pointer to hardware block register map object
  240. */
  241. void sde_hw_wb_destroy(struct sde_hw_blk_reg_map *hw);
  242. #endif /*_SDE_HW_WB_H */