sde_hw_top.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  4. * Copyright (c) 2015-2021, The Linux Foundation. All rights reserved.
  5. */
  6. #ifndef _SDE_HW_TOP_H
  7. #define _SDE_HW_TOP_H
  8. #include "sde_hw_catalog.h"
  9. #include "sde_hw_mdss.h"
  10. #include "sde_hw_util.h"
  11. struct sde_hw_mdp;
  12. struct sde_hw_sid;
  13. /**
  14. * struct traffic_shaper_cfg: traffic shaper configuration
  15. * @en : enable/disable traffic shaper
  16. * @rd_client : true if read client; false if write client
  17. * @client_id : client identifier
  18. * @bpc_denom : denominator of byte per clk
  19. * @bpc_numer : numerator of byte per clk
  20. */
  21. struct traffic_shaper_cfg {
  22. bool en;
  23. bool rd_client;
  24. u32 client_id;
  25. u32 bpc_denom;
  26. u64 bpc_numer;
  27. };
  28. /**
  29. * struct split_pipe_cfg - pipe configuration for dual display panels
  30. * @en : Enable/disable dual pipe confguration
  31. * @mode : Panel interface mode
  32. * @intf : Interface id for main control path
  33. * @pp_split_slave: Slave interface for ping pong split, INTF_MAX to disable
  34. * @pp_split_idx: Ping pong index for ping pong split
  35. * @split_flush_en: Allows both the paths to be flushed when master path is
  36. * flushed
  37. * @split_link_en: Check if split link is enabled
  38. */
  39. struct split_pipe_cfg {
  40. bool en;
  41. enum sde_intf_mode mode;
  42. enum sde_intf intf;
  43. enum sde_intf pp_split_slave;
  44. u32 pp_split_index;
  45. bool split_flush_en;
  46. bool split_link_en;
  47. };
  48. /**
  49. * struct cdm_output_cfg: output configuration for cdm
  50. * @wb_en : enable/disable writeback output
  51. * @intf_en : enable/disable interface output
  52. */
  53. struct cdm_output_cfg {
  54. bool wb_en;
  55. bool intf_en;
  56. };
  57. /**
  58. * struct sde_danger_safe_status: danger and safe status signals
  59. * @mdp: top level status
  60. * @sspp: source pipe status
  61. * @wb: writebck output status
  62. */
  63. struct sde_danger_safe_status {
  64. u8 mdp;
  65. u8 sspp[SSPP_MAX];
  66. u8 wb[WB_MAX];
  67. };
  68. /**
  69. * struct sde_vsync_source_cfg - configure vsync source and configure the
  70. * watchdog timers if required.
  71. * @pp_count: number of ping pongs active
  72. * @frame_rate: Display frame rate
  73. * @ppnumber: ping pong index array
  74. * @vsync_source: vsync source selection
  75. */
  76. struct sde_vsync_source_cfg {
  77. u32 pp_count;
  78. u32 frame_rate;
  79. u32 ppnumber[PINGPONG_MAX];
  80. u32 vsync_source;
  81. };
  82. /**
  83. * struct sde_hw_mdp_ops - interface to the MDP TOP Hw driver functions
  84. * Assumption is these functions will be called after clocks are enabled.
  85. * @setup_split_pipe : Programs the pipe control registers
  86. * @setup_pp_split : Programs the pp split control registers
  87. * @setup_cdm_output : programs cdm control
  88. * @setup_traffic_shaper : programs traffic shaper control
  89. */
  90. struct sde_hw_mdp_ops {
  91. /** setup_split_pipe() : Regsiters are not double buffered, thisk
  92. * function should be called before timing control enable
  93. * @mdp : mdp top context driver
  94. * @cfg : upper and lower part of pipe configuration
  95. */
  96. void (*setup_split_pipe)(struct sde_hw_mdp *mdp,
  97. struct split_pipe_cfg *p);
  98. /** setup_pp_split() : Configure pp split related registers
  99. * @mdp : mdp top context driver
  100. * @cfg : upper and lower part of pipe configuration
  101. */
  102. void (*setup_pp_split)(struct sde_hw_mdp *mdp,
  103. struct split_pipe_cfg *cfg);
  104. /**
  105. * setup_cdm_output() : Setup selection control of the cdm data path
  106. * @mdp : mdp top context driver
  107. * @cfg : cdm output configuration
  108. */
  109. void (*setup_cdm_output)(struct sde_hw_mdp *mdp,
  110. struct cdm_output_cfg *cfg);
  111. /**
  112. * setup_traffic_shaper() : Setup traffic shaper control
  113. * @mdp : mdp top context driver
  114. * @cfg : traffic shaper configuration
  115. */
  116. void (*setup_traffic_shaper)(struct sde_hw_mdp *mdp,
  117. struct traffic_shaper_cfg *cfg);
  118. /**
  119. * setup_clk_force_ctrl - set clock force control
  120. * @mdp: mdp top context driver
  121. * @clk_ctrl: clock to be controlled
  122. * @enable: force on enable
  123. * @return: if the clock is forced-on by this function
  124. */
  125. bool (*setup_clk_force_ctrl)(struct sde_hw_mdp *mdp,
  126. enum sde_clk_ctrl_type clk_ctrl, bool enable);
  127. /**
  128. * get_clk_ctrl_status - get clock control status
  129. * @mdp: mdp top context driver
  130. * @clk_ctrl: clock to be controlled
  131. * @status: returns true if clock is on
  132. * @return: 0 if success, otherwise return code
  133. */
  134. int (*get_clk_ctrl_status)(struct sde_hw_mdp *mdp,
  135. enum sde_clk_ctrl_type clk_ctrl, bool *status);
  136. /**
  137. * setup_vsync_source - setup vsync source configuration details
  138. * @mdp: mdp top context driver
  139. * @cfg: vsync source selection configuration
  140. */
  141. void (*setup_vsync_source)(struct sde_hw_mdp *mdp,
  142. struct sde_vsync_source_cfg *cfg);
  143. /**
  144. * reset_ubwc - reset top level UBWC configuration
  145. * @mdp: mdp top context driver
  146. * @m: pointer to mdss catalog data
  147. */
  148. void (*reset_ubwc)(struct sde_hw_mdp *mdp, struct sde_mdss_cfg *m);
  149. /**
  150. * intf_audio_select - select the external interface for audio
  151. * @mdp: mdp top context driver
  152. */
  153. void (*intf_audio_select)(struct sde_hw_mdp *mdp);
  154. /**
  155. * set_mdp_hw_events - enable qdss hardware events for mdp
  156. * @mdp: mdp top context driver
  157. * @enable: enable/disable hw events
  158. */
  159. void (*set_mdp_hw_events)(struct sde_hw_mdp *mdp, bool enable);
  160. /**
  161. * set_cwb_ppb_cntl - select the data point for CWB
  162. * @mdp: mdp top context driver
  163. * @dual: indicates if dual pipe line needs to be programmed
  164. * @dspp_out : true if dspp output required. LM is default tap point
  165. */
  166. void (*set_cwb_ppb_cntl)(struct sde_hw_mdp *mdp,
  167. bool dual, bool dspp_out);
  168. /**
  169. * set_hdr_plus_metadata - program the dynamic hdr metadata
  170. * @mdp: mdp top context driver
  171. * @payload: pointer to payload data
  172. * @len: size of the valid data within payload
  173. * @stream_id: stream ID for MST (0 or 1)
  174. */
  175. void (*set_hdr_plus_metadata)(struct sde_hw_mdp *mdp,
  176. u8 *payload, u32 len, u32 stream_id);
  177. /**
  178. * get_autorefresh_status - get autorefresh status
  179. * @mdp: mdp top context driver
  180. * @intf_idx: intf block index for relative information
  181. */
  182. u32 (*get_autorefresh_status)(struct sde_hw_mdp *mdp,
  183. u32 intf_idx);
  184. };
  185. struct sde_hw_mdp {
  186. struct sde_hw_blk_reg_map hw;
  187. /* top */
  188. enum sde_mdp idx;
  189. const struct sde_mdp_cfg *caps;
  190. /* ops */
  191. struct sde_hw_mdp_ops ops;
  192. };
  193. /**
  194. * struct sde_hw_sid_ops - callback functions for SID HW programming
  195. */
  196. struct sde_hw_sid_ops {
  197. /**
  198. * set_vm_sid - programs SID HW during VM transition
  199. * @sid: sde_hw_sid passed from kms
  200. * @vm: vm id to set for SIDs
  201. * @m: Pointer to mdss catalog data
  202. */
  203. void (*set_vm_sid)(struct sde_hw_sid *sid, u32 vm,
  204. struct sde_mdss_cfg *m);
  205. };
  206. struct sde_hw_sid {
  207. /* rotator base */
  208. struct sde_hw_blk_reg_map hw;
  209. /* ops */
  210. struct sde_hw_sid_ops ops;
  211. };
  212. /**
  213. * sde_hw_sid_init - initialize the sid blk reg map
  214. * @addr: Mapped register io address
  215. * @sid_len: Length of block
  216. * @m: Pointer to mdss catalog data
  217. */
  218. struct sde_hw_sid *sde_hw_sid_init(void __iomem *addr,
  219. u32 sid_len, const struct sde_mdss_cfg *m);
  220. /**
  221. * sde_hw_set_rotator_sid - set sid values for rotator
  222. * sid: sde_hw_sid passed from kms
  223. */
  224. void sde_hw_set_rotator_sid(struct sde_hw_sid *sid);
  225. /**
  226. * sde_hw_set_sspp_sid - set sid values for the pipes
  227. * sid: sde_hw_sid passed from kms
  228. * pipe: sspp id
  229. * vm: vm id to set for SIDs
  230. * @m: Pointer to mdss catalog data
  231. */
  232. void sde_hw_set_sspp_sid(struct sde_hw_sid *sid, u32 pipe, u32 vm, struct sde_mdss_cfg *m);
  233. /**
  234. * sde_hw_mdptop_init - initializes the top driver for the passed idx
  235. * @idx: Interface index for which driver object is required
  236. * @addr: Mapped register io address of MDP
  237. * @m: Pointer to mdss catalog data
  238. */
  239. struct sde_hw_mdp *sde_hw_mdptop_init(enum sde_mdp idx,
  240. void __iomem *addr,
  241. const struct sde_mdss_cfg *m);
  242. void sde_hw_mdp_destroy(struct sde_hw_mdp *mdp);
  243. #endif /*_SDE_HW_TOP_H */