sde_hw_ctl.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2015-2020, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef _SDE_HW_CTL_H
  6. #define _SDE_HW_CTL_H
  7. #include "sde_hw_mdss.h"
  8. #include "sde_hw_util.h"
  9. #include "sde_hw_catalog.h"
  10. #include "sde_hw_sspp.h"
  11. #include "sde_hw_blk.h"
  12. #define INVALID_CTL_STATUS 0xfffff88e
  13. #define CTL_MAX_DSPP_COUNT (DSPP_MAX - DSPP_0)
  14. /**
  15. * sde_ctl_mode_sel: Interface mode selection
  16. * SDE_CTL_MODE_SEL_VID: Video mode interface
  17. * SDE_CTL_MODE_SEL_CMD: Command mode interface
  18. */
  19. enum sde_ctl_mode_sel {
  20. SDE_CTL_MODE_SEL_VID = 0,
  21. SDE_CTL_MODE_SEL_CMD
  22. };
  23. /**
  24. * sde_ctl_rot_op_mode - inline rotation mode
  25. * SDE_CTL_ROT_OP_MODE_OFFLINE: offline rotation
  26. * SDE_CTL_ROT_OP_MODE_RESERVED: reserved
  27. * SDE_CTL_ROT_OP_MODE_INLINE_SYNC: inline rotation synchronous mode
  28. * SDE_CTL_ROT_OP_MODE_INLINE_ASYNC: inline rotation asynchronous mode
  29. */
  30. enum sde_ctl_rot_op_mode {
  31. SDE_CTL_ROT_OP_MODE_OFFLINE,
  32. SDE_CTL_ROT_OP_MODE_RESERVED,
  33. SDE_CTL_ROT_OP_MODE_INLINE_SYNC,
  34. SDE_CTL_ROT_OP_MODE_INLINE_ASYNC,
  35. };
  36. struct sde_hw_ctl;
  37. /**
  38. * struct sde_hw_stage_cfg - blending stage cfg
  39. * @stage : SSPP_ID at each stage
  40. * @multirect_index: index of the rectangle of SSPP.
  41. */
  42. struct sde_hw_stage_cfg {
  43. enum sde_sspp stage[SDE_STAGE_MAX][PIPES_PER_STAGE];
  44. enum sde_sspp_multirect_index multirect_index
  45. [SDE_STAGE_MAX][PIPES_PER_STAGE];
  46. };
  47. /**
  48. * struct sde_hw_intf_cfg :Describes how the SDE writes data to output interface
  49. * @intf : Interface id
  50. * @wb: Writeback id
  51. * @mode_3d: 3d mux configuration
  52. * @intf_mode_sel: Interface mode, cmd / vid
  53. * @stream_sel: Stream selection for multi-stream interfaces
  54. */
  55. struct sde_hw_intf_cfg {
  56. enum sde_intf intf;
  57. enum sde_wb wb;
  58. enum sde_3d_blend_mode mode_3d;
  59. enum sde_ctl_mode_sel intf_mode_sel;
  60. int stream_sel;
  61. };
  62. /**
  63. * struct sde_hw_intf_cfg_v1 :Describes the data strcuture to configure the
  64. * output interfaces for a particular display on a
  65. * platform which supports ctl path version 1.
  66. * @intf_count: No. of active interfaces for this display
  67. * @intf : Interface ids of active interfaces
  68. * @intf_mode_sel: Interface mode, cmd / vid
  69. * @intf_master: Master interface for split display
  70. * @wb_count: No. of active writebacks
  71. * @wb: Writeback ids of active writebacks
  72. * @merge_3d_count No. of active merge_3d blocks
  73. * @merge_3d: Id of the active merge 3d blocks
  74. * @cwb_count: No. of active concurrent writebacks
  75. * @cwb: Id of active cwb blocks
  76. * @cdm_count: No. of active chroma down module
  77. * @cdm: Id of active cdm blocks
  78. * @dsc_count: No. of active dsc blocks
  79. * @dsc: Id of active dsc blocks
  80. */
  81. struct sde_hw_intf_cfg_v1 {
  82. uint32_t intf_count;
  83. enum sde_intf intf[MAX_INTF_PER_CTL_V1];
  84. enum sde_ctl_mode_sel intf_mode_sel;
  85. enum sde_intf intf_master;
  86. uint32_t wb_count;
  87. enum sde_wb wb[MAX_WB_PER_CTL_V1];
  88. uint32_t merge_3d_count;
  89. enum sde_merge_3d merge_3d[MAX_MERGE_3D_PER_CTL_V1];
  90. uint32_t cwb_count;
  91. enum sde_cwb cwb[MAX_CWB_PER_CTL_V1];
  92. uint32_t cdm_count;
  93. enum sde_cdm cdm[MAX_CDM_PER_CTL_V1];
  94. uint32_t dsc_count;
  95. enum sde_dsc dsc[MAX_DSC_PER_CTL_V1];
  96. };
  97. /**
  98. * struct sde_ctl_flush_cfg - struct describing flush configuration managed
  99. * via set, trigger and clear ops.
  100. * set ops corresponding to the hw_block is called, when the block's
  101. * configuration is changed and needs to be committed on Hw. Flush mask caches
  102. * the different bits for the ongoing commit.
  103. * clear ops clears the bitmask and cancels the update to the corresponding
  104. * hw block.
  105. * trigger op will trigger the update on the hw for the blocks cached in the
  106. * pending flush mask.
  107. *
  108. * @pending_flush_mask: pending ctl_flush
  109. * CTL path version SDE_CTL_CFG_VERSION_1_0_0 has * two level flush mechanism
  110. * for lower pipe controls. individual control should be flushed before
  111. * exercising top level flush
  112. * @pending_intf_flush_mask: pending INTF flush
  113. * @pending_cdm_flush_mask: pending CDWN block flush
  114. * @pending_wb_flush_mask: pending writeback flush
  115. * @pending_dsc_flush_mask: pending dsc flush
  116. * @pending_merge_3d_flush_mask: pending 3d merge block flush
  117. * @pending_cwb_flush_mask: pending flush for concurrent writeback
  118. * @pending_periph_flush_mask: pending flush for peripheral module
  119. * @pending_dspp_flush_masks: pending flush masks for sub-blks of each DSPP
  120. */
  121. struct sde_ctl_flush_cfg {
  122. u32 pending_flush_mask;
  123. u32 pending_intf_flush_mask;
  124. u32 pending_cdm_flush_mask;
  125. u32 pending_wb_flush_mask;
  126. u32 pending_dsc_flush_mask;
  127. u32 pending_merge_3d_flush_mask;
  128. u32 pending_cwb_flush_mask;
  129. u32 pending_periph_flush_mask;
  130. u32 pending_dspp_flush_masks[CTL_MAX_DSPP_COUNT];
  131. };
  132. /**
  133. * struct sde_hw_ctl_ops - Interface to the wb Hw driver functions
  134. * Assumption is these functions will be called after clocks are enabled
  135. */
  136. struct sde_hw_ctl_ops {
  137. /**
  138. * kickoff hw operation for Sw controlled interfaces
  139. * DSI cmd mode and WB interface are SW controlled
  140. * @ctx : ctl path ctx pointer
  141. * @Return: error code
  142. */
  143. int (*trigger_start)(struct sde_hw_ctl *ctx);
  144. /**
  145. * kickoff prepare is in progress hw operation for sw
  146. * controlled interfaces: DSI cmd mode and WB interface
  147. * are SW controlled
  148. * @ctx : ctl path ctx pointer
  149. * @Return: error code
  150. */
  151. int (*trigger_pending)(struct sde_hw_ctl *ctx);
  152. /**
  153. * kickoff rotator operation for Sw controlled interfaces
  154. * DSI cmd mode and WB interface are SW controlled
  155. * @ctx : ctl path ctx pointer
  156. * @Return: error code
  157. */
  158. int (*trigger_rot_start)(struct sde_hw_ctl *ctx);
  159. /**
  160. * enable/disable UIDLE feature
  161. * @ctx : ctl path ctx pointer
  162. * @enable: true to enable the feature
  163. */
  164. void (*uidle_enable)(struct sde_hw_ctl *ctx, bool enable);
  165. /**
  166. * Clear the value of the cached pending_flush_mask
  167. * No effect on hardware
  168. * @ctx : ctl path ctx pointer
  169. * @Return: error code
  170. */
  171. int (*clear_pending_flush)(struct sde_hw_ctl *ctx);
  172. /**
  173. * Query the value of the cached pending_flush_mask
  174. * No effect on hardware
  175. * @ctx : ctl path ctx pointer
  176. * @cfg : current flush configuration
  177. * @Return: error code
  178. */
  179. int (*get_pending_flush)(struct sde_hw_ctl *ctx,
  180. struct sde_ctl_flush_cfg *cfg);
  181. /**
  182. * OR in the given flushbits to the flush_cfg
  183. * No effect on hardware
  184. * @ctx : ctl path ctx pointer
  185. * @cfg : flush configuration pointer
  186. * @Return: error code
  187. */
  188. int (*update_pending_flush)(struct sde_hw_ctl *ctx,
  189. struct sde_ctl_flush_cfg *cfg);
  190. /**
  191. * Write the value of the pending_flush_mask to hardware
  192. * @ctx : ctl path ctx pointer
  193. * @Return: error code
  194. */
  195. int (*trigger_flush)(struct sde_hw_ctl *ctx);
  196. /**
  197. * Read the value of the flush register
  198. * @ctx : ctl path ctx pointer
  199. * @Return: value of the ctl flush register.
  200. */
  201. u32 (*get_flush_register)(struct sde_hw_ctl *ctx);
  202. /**
  203. * Setup ctl_path interface config
  204. * @ctx
  205. * @cfg : interface config structure pointer
  206. * @Return: error code
  207. */
  208. int (*setup_intf_cfg)(struct sde_hw_ctl *ctx,
  209. struct sde_hw_intf_cfg *cfg);
  210. /**
  211. * Reset ctl_path interface config
  212. * @ctx : ctl path ctx pointer
  213. * @cfg : interface config structure pointer
  214. * @merge_3d_idx : index of merge3d blk
  215. * @Return: error code
  216. */
  217. int (*reset_post_disable)(struct sde_hw_ctl *ctx,
  218. struct sde_hw_intf_cfg_v1 *cfg, u32 merge_3d_idx);
  219. /** update cwb for ctl_path
  220. * @ctx : ctl path ctx pointer
  221. * @cfg : interface config structure pointer
  222. * @enable : enable/disable the dynamic sub-blocks in interface cfg
  223. * @Return: error code
  224. */
  225. int (*update_intf_cfg)(struct sde_hw_ctl *ctx,
  226. struct sde_hw_intf_cfg_v1 *cfg, bool enable);
  227. /**
  228. * Setup ctl_path interface config for SDE_CTL_ACTIVE_CFG
  229. * @ctx : ctl path ctx pointer
  230. * @cfg : interface config structure pointer
  231. * @Return: error code
  232. */
  233. int (*setup_intf_cfg_v1)(struct sde_hw_ctl *ctx,
  234. struct sde_hw_intf_cfg_v1 *cfg);
  235. /** Update the interface selection with input WB config
  236. * @ctx : ctl path ctx pointer
  237. * @cfg : pointer to input wb config
  238. * @enable : set if true, clear otherwise
  239. */
  240. void (*update_wb_cfg)(struct sde_hw_ctl *ctx,
  241. struct sde_hw_intf_cfg *cfg, bool enable);
  242. int (*reset)(struct sde_hw_ctl *c);
  243. /**
  244. * get_reset - check ctl reset status bit
  245. * @ctx : ctl path ctx pointer
  246. * Returns: current value of ctl reset status
  247. */
  248. u32 (*get_reset)(struct sde_hw_ctl *ctx);
  249. /**
  250. * get_scheduler_reset - check ctl scheduler status bit
  251. * @ctx : ctl path ctx pointer
  252. * Returns: current value of ctl scheduler and idle status
  253. */
  254. u32 (*get_scheduler_status)(struct sde_hw_ctl *ctx);
  255. /**
  256. * hard_reset - force reset on ctl_path
  257. * @ctx : ctl path ctx pointer
  258. * @enable : whether to enable/disable hard reset
  259. */
  260. void (*hard_reset)(struct sde_hw_ctl *c, bool enable);
  261. /*
  262. * wait_reset_status - checks ctl reset status
  263. * @ctx : ctl path ctx pointer
  264. *
  265. * This function checks the ctl reset status bit.
  266. * If the reset bit is set, it keeps polling the status till the hw
  267. * reset is complete.
  268. * Returns: 0 on success or -error if reset incomplete within interval
  269. */
  270. int (*wait_reset_status)(struct sde_hw_ctl *ctx);
  271. /**
  272. * update_bitmask_sspp: updates mask corresponding to sspp
  273. * @blk : blk id
  274. * @enable : true to enable, 0 to disable
  275. */
  276. int (*update_bitmask_sspp)(struct sde_hw_ctl *ctx,
  277. enum sde_sspp blk, bool enable);
  278. /**
  279. * update_bitmask_sspp: updates mask corresponding to sspp
  280. * @blk : blk id
  281. * @enable : true to enable, 0 to disable
  282. */
  283. int (*update_bitmask_mixer)(struct sde_hw_ctl *ctx,
  284. enum sde_lm blk, bool enable);
  285. /**
  286. * update_bitmask_sspp: updates mask corresponding to sspp
  287. * @blk : blk id
  288. * @enable : true to enable, 0 to disable
  289. */
  290. int (*update_bitmask_dspp)(struct sde_hw_ctl *ctx,
  291. enum sde_dspp blk, bool enable);
  292. /**
  293. * update_bitmask_sspp: updates mask corresponding to sspp
  294. * @blk : blk id
  295. * @enable : true to enable, 0 to disable
  296. */
  297. int (*update_bitmask_dspp_pavlut)(struct sde_hw_ctl *ctx,
  298. enum sde_dspp blk, bool enable);
  299. /**
  300. * Program DSPP sub block specific bit of dspp flush register.
  301. * @ctx : ctl path ctx pointer
  302. * @dspp : HW block ID of dspp block
  303. * @sub_blk : enum of DSPP sub block to flush
  304. * @enable : true to enable, 0 to disable
  305. *
  306. * This API is for CTL with DSPP flush hierarchy registers.
  307. */
  308. int (*update_bitmask_dspp_subblk)(struct sde_hw_ctl *ctx,
  309. enum sde_dspp dspp, u32 sub_blk, bool enable);
  310. /**
  311. * update_bitmask_sspp: updates mask corresponding to sspp
  312. * @blk : blk id
  313. * @enable : true to enable, 0 to disable
  314. */
  315. int (*update_bitmask_intf)(struct sde_hw_ctl *ctx,
  316. enum sde_intf blk, bool enable);
  317. /**
  318. * update_bitmask_sspp: updates mask corresponding to sspp
  319. * @blk : blk id
  320. * @enable : true to enable, 0 to disable
  321. */
  322. int (*update_bitmask_cdm)(struct sde_hw_ctl *ctx,
  323. enum sde_cdm blk, bool enable);
  324. /**
  325. * update_bitmask_sspp: updates mask corresponding to sspp
  326. * @blk : blk id
  327. * @enable : true to enable, 0 to disable
  328. */
  329. int (*update_bitmask_wb)(struct sde_hw_ctl *ctx,
  330. enum sde_wb blk, bool enable);
  331. /**
  332. * update_bitmask_sspp: updates mask corresponding to sspp
  333. * @blk : blk id
  334. * @enable : true to enable, 0 to disable
  335. */
  336. int (*update_bitmask_rot)(struct sde_hw_ctl *ctx,
  337. enum sde_rot blk, bool enable);
  338. /**
  339. * update_bitmask_dsc: updates mask corresponding to dsc
  340. * @blk : blk id
  341. * @enable : true to enable, 0 to disable
  342. */
  343. int (*update_bitmask_dsc)(struct sde_hw_ctl *ctx,
  344. enum sde_dsc blk, bool enable);
  345. /**
  346. * update_bitmask_merge3d: updates mask corresponding to merge_3d
  347. * @blk : blk id
  348. * @enable : true to enable, 0 to disable
  349. */
  350. int (*update_bitmask_merge3d)(struct sde_hw_ctl *ctx,
  351. enum sde_merge_3d blk, bool enable);
  352. /**
  353. * update_bitmask_cwb: updates mask corresponding to cwb
  354. * @blk : blk id
  355. * @enable : true to enable, 0 to disable
  356. */
  357. int (*update_bitmask_cwb)(struct sde_hw_ctl *ctx,
  358. enum sde_cwb blk, bool enable);
  359. /**
  360. * update_bitmask_periph: updates mask corresponding to peripheral
  361. * @blk : blk id
  362. * @enable : true to enable, 0 to disable
  363. */
  364. int (*update_bitmask_periph)(struct sde_hw_ctl *ctx,
  365. enum sde_intf blk, bool enable);
  366. /**
  367. * read CTL_TOP register value and return
  368. * the data.
  369. * @ctx : ctl path ctx pointer
  370. * @return : CTL top register value
  371. */
  372. u32 (*read_ctl_top)(struct sde_hw_ctl *ctx);
  373. /**
  374. * get interfaces for the active CTL .
  375. * @ctx : ctl path ctx pointer
  376. * @return : bit mask with the active interfaces for the CTL
  377. */
  378. u32 (*get_ctl_intf)(struct sde_hw_ctl *ctx);
  379. /**
  380. * read CTL layers register value and return
  381. * the data.
  382. * @ctx : ctl path ctx pointer
  383. * @index : layer index for this ctl path
  384. * @return : CTL layers register value
  385. */
  386. u32 (*read_ctl_layers)(struct sde_hw_ctl *ctx, int index);
  387. /**
  388. * read active register configuration for this block
  389. * @ctx : ctl path ctx pointer
  390. * @blk : hw blk type, supported blocks are DSC, MERGE_3D, INTF,
  391. * CDM, WB
  392. * @index : blk index
  393. * @return : true if blk at idx is active or false
  394. */
  395. bool (*read_active_status)(struct sde_hw_ctl *ctx,
  396. enum sde_hw_blk_type blk, int index);
  397. /**
  398. * Set all blend stages to disabled
  399. * @ctx : ctl path ctx pointer
  400. */
  401. void (*clear_all_blendstages)(struct sde_hw_ctl *ctx);
  402. /**
  403. * Configure layer mixer to pipe configuration
  404. * @ctx : ctl path ctx pointer
  405. * @lm : layer mixer enumeration
  406. * @cfg : blend stage configuration
  407. */
  408. void (*setup_blendstage)(struct sde_hw_ctl *ctx,
  409. enum sde_lm lm, struct sde_hw_stage_cfg *cfg);
  410. /**
  411. * Get all the sspp staged on a layer mixer
  412. * @ctx : ctl path ctx pointer
  413. * @lm : layer mixer enumeration
  414. * @info : array address to populate connected sspp index info
  415. * @info_max_cnt : maximum sspp info elements based on array size
  416. * @Return: count of sspps info elements populated
  417. */
  418. u32 (*get_staged_sspp)(struct sde_hw_ctl *ctx, enum sde_lm lm,
  419. struct sde_sspp_index_info *info, u32 info_max_cnt);
  420. /**
  421. * Flush the reg dma by sending last command.
  422. * @ctx : ctl path ctx pointer
  423. * @blocking : if set to true api will block until flush is done
  424. * @Return: error code
  425. */
  426. int (*reg_dma_flush)(struct sde_hw_ctl *ctx, bool blocking);
  427. /**
  428. * check if ctl start trigger state to confirm the frame pending
  429. * status
  430. * @ctx : ctl path ctx pointer
  431. * @Return: error code
  432. */
  433. int (*get_start_state)(struct sde_hw_ctl *ctx);
  434. };
  435. /**
  436. * struct sde_hw_ctl : CTL PATH driver object
  437. * @base: hardware block base structure
  438. * @hw: block register map object
  439. * @idx: control path index
  440. * @caps: control path capabilities
  441. * @mixer_count: number of mixers
  442. * @mixer_hw_caps: mixer hardware capabilities
  443. * @flush: storage for pending ctl_flush managed via ops
  444. * @ops: operation list
  445. */
  446. struct sde_hw_ctl {
  447. struct sde_hw_blk base;
  448. struct sde_hw_blk_reg_map hw;
  449. /* ctl path */
  450. int idx;
  451. const struct sde_ctl_cfg *caps;
  452. int mixer_count;
  453. const struct sde_lm_cfg *mixer_hw_caps;
  454. struct sde_ctl_flush_cfg flush;
  455. /* ops */
  456. struct sde_hw_ctl_ops ops;
  457. };
  458. /**
  459. * sde_hw_ctl - convert base object sde_hw_base to container
  460. * @hw: Pointer to base hardware block
  461. * return: Pointer to hardware block container
  462. */
  463. static inline struct sde_hw_ctl *to_sde_hw_ctl(struct sde_hw_blk *hw)
  464. {
  465. return container_of(hw, struct sde_hw_ctl, base);
  466. }
  467. /**
  468. * sde_hw_ctl_init(): Initializes the ctl_path hw driver object.
  469. * should be called before accessing every ctl path registers.
  470. * @idx: ctl_path index for which driver object is required
  471. * @addr: mapped register io address of MDP
  472. * @m : pointer to mdss catalog data
  473. */
  474. struct sde_hw_ctl *sde_hw_ctl_init(enum sde_ctl idx,
  475. void __iomem *addr,
  476. struct sde_mdss_cfg *m);
  477. /**
  478. * sde_hw_ctl_destroy(): Destroys ctl driver context
  479. * should be called to free the context
  480. */
  481. void sde_hw_ctl_destroy(struct sde_hw_ctl *ctx);
  482. #endif /*_SDE_HW_CTL_H */