sde_hw_top.h 8.7 KB

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