dpu_hw_ctl.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. /* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. */
  12. #ifndef _DPU_HW_CTL_H
  13. #define _DPU_HW_CTL_H
  14. #include "dpu_hw_mdss.h"
  15. #include "dpu_hw_util.h"
  16. #include "dpu_hw_catalog.h"
  17. #include "dpu_hw_sspp.h"
  18. #include "dpu_hw_blk.h"
  19. /**
  20. * dpu_ctl_mode_sel: Interface mode selection
  21. * DPU_CTL_MODE_SEL_VID: Video mode interface
  22. * DPU_CTL_MODE_SEL_CMD: Command mode interface
  23. */
  24. enum dpu_ctl_mode_sel {
  25. DPU_CTL_MODE_SEL_VID = 0,
  26. DPU_CTL_MODE_SEL_CMD
  27. };
  28. struct dpu_hw_ctl;
  29. /**
  30. * struct dpu_hw_stage_cfg - blending stage cfg
  31. * @stage : SSPP_ID at each stage
  32. * @multirect_index: index of the rectangle of SSPP.
  33. */
  34. struct dpu_hw_stage_cfg {
  35. enum dpu_sspp stage[DPU_STAGE_MAX][PIPES_PER_STAGE];
  36. enum dpu_sspp_multirect_index multirect_index
  37. [DPU_STAGE_MAX][PIPES_PER_STAGE];
  38. };
  39. /**
  40. * struct dpu_hw_intf_cfg :Describes how the DPU writes data to output interface
  41. * @intf : Interface id
  42. * @mode_3d: 3d mux configuration
  43. * @intf_mode_sel: Interface mode, cmd / vid
  44. * @stream_sel: Stream selection for multi-stream interfaces
  45. */
  46. struct dpu_hw_intf_cfg {
  47. enum dpu_intf intf;
  48. enum dpu_3d_blend_mode mode_3d;
  49. enum dpu_ctl_mode_sel intf_mode_sel;
  50. int stream_sel;
  51. };
  52. /**
  53. * struct dpu_hw_ctl_ops - Interface to the wb Hw driver functions
  54. * Assumption is these functions will be called after clocks are enabled
  55. */
  56. struct dpu_hw_ctl_ops {
  57. /**
  58. * kickoff hw operation for Sw controlled interfaces
  59. * DSI cmd mode and WB interface are SW controlled
  60. * @ctx : ctl path ctx pointer
  61. */
  62. void (*trigger_start)(struct dpu_hw_ctl *ctx);
  63. /**
  64. * kickoff prepare is in progress hw operation for sw
  65. * controlled interfaces: DSI cmd mode and WB interface
  66. * are SW controlled
  67. * @ctx : ctl path ctx pointer
  68. */
  69. void (*trigger_pending)(struct dpu_hw_ctl *ctx);
  70. /**
  71. * Clear the value of the cached pending_flush_mask
  72. * No effect on hardware
  73. * @ctx : ctl path ctx pointer
  74. */
  75. void (*clear_pending_flush)(struct dpu_hw_ctl *ctx);
  76. /**
  77. * Query the value of the cached pending_flush_mask
  78. * No effect on hardware
  79. * @ctx : ctl path ctx pointer
  80. */
  81. u32 (*get_pending_flush)(struct dpu_hw_ctl *ctx);
  82. /**
  83. * OR in the given flushbits to the cached pending_flush_mask
  84. * No effect on hardware
  85. * @ctx : ctl path ctx pointer
  86. * @flushbits : module flushmask
  87. */
  88. void (*update_pending_flush)(struct dpu_hw_ctl *ctx,
  89. u32 flushbits);
  90. /**
  91. * Write the value of the pending_flush_mask to hardware
  92. * @ctx : ctl path ctx pointer
  93. */
  94. void (*trigger_flush)(struct dpu_hw_ctl *ctx);
  95. /**
  96. * Read the value of the flush register
  97. * @ctx : ctl path ctx pointer
  98. * @Return: value of the ctl flush register.
  99. */
  100. u32 (*get_flush_register)(struct dpu_hw_ctl *ctx);
  101. /**
  102. * Setup ctl_path interface config
  103. * @ctx
  104. * @cfg : interface config structure pointer
  105. */
  106. void (*setup_intf_cfg)(struct dpu_hw_ctl *ctx,
  107. struct dpu_hw_intf_cfg *cfg);
  108. int (*reset)(struct dpu_hw_ctl *c);
  109. /*
  110. * wait_reset_status - checks ctl reset status
  111. * @ctx : ctl path ctx pointer
  112. *
  113. * This function checks the ctl reset status bit.
  114. * If the reset bit is set, it keeps polling the status till the hw
  115. * reset is complete.
  116. * Returns: 0 on success or -error if reset incomplete within interval
  117. */
  118. int (*wait_reset_status)(struct dpu_hw_ctl *ctx);
  119. uint32_t (*get_bitmask_sspp)(struct dpu_hw_ctl *ctx,
  120. enum dpu_sspp blk);
  121. uint32_t (*get_bitmask_mixer)(struct dpu_hw_ctl *ctx,
  122. enum dpu_lm blk);
  123. int (*get_bitmask_intf)(struct dpu_hw_ctl *ctx,
  124. u32 *flushbits,
  125. enum dpu_intf blk);
  126. /**
  127. * Set all blend stages to disabled
  128. * @ctx : ctl path ctx pointer
  129. */
  130. void (*clear_all_blendstages)(struct dpu_hw_ctl *ctx);
  131. /**
  132. * Configure layer mixer to pipe configuration
  133. * @ctx : ctl path ctx pointer
  134. * @lm : layer mixer enumeration
  135. * @cfg : blend stage configuration
  136. */
  137. void (*setup_blendstage)(struct dpu_hw_ctl *ctx,
  138. enum dpu_lm lm, struct dpu_hw_stage_cfg *cfg);
  139. };
  140. /**
  141. * struct dpu_hw_ctl : CTL PATH driver object
  142. * @base: hardware block base structure
  143. * @hw: block register map object
  144. * @idx: control path index
  145. * @caps: control path capabilities
  146. * @mixer_count: number of mixers
  147. * @mixer_hw_caps: mixer hardware capabilities
  148. * @pending_flush_mask: storage for pending ctl_flush managed via ops
  149. * @ops: operation list
  150. */
  151. struct dpu_hw_ctl {
  152. struct dpu_hw_blk base;
  153. struct dpu_hw_blk_reg_map hw;
  154. /* ctl path */
  155. int idx;
  156. const struct dpu_ctl_cfg *caps;
  157. int mixer_count;
  158. const struct dpu_lm_cfg *mixer_hw_caps;
  159. u32 pending_flush_mask;
  160. /* ops */
  161. struct dpu_hw_ctl_ops ops;
  162. };
  163. /**
  164. * dpu_hw_ctl - convert base object dpu_hw_base to container
  165. * @hw: Pointer to base hardware block
  166. * return: Pointer to hardware block container
  167. */
  168. static inline struct dpu_hw_ctl *to_dpu_hw_ctl(struct dpu_hw_blk *hw)
  169. {
  170. return container_of(hw, struct dpu_hw_ctl, base);
  171. }
  172. /**
  173. * dpu_hw_ctl_init(): Initializes the ctl_path hw driver object.
  174. * should be called before accessing every ctl path registers.
  175. * @idx: ctl_path index for which driver object is required
  176. * @addr: mapped register io address of MDP
  177. * @m : pointer to mdss catalog data
  178. */
  179. struct dpu_hw_ctl *dpu_hw_ctl_init(enum dpu_ctl idx,
  180. void __iomem *addr,
  181. struct dpu_mdss_cfg *m);
  182. /**
  183. * dpu_hw_ctl_destroy(): Destroys ctl driver context
  184. * should be called to free the context
  185. */
  186. void dpu_hw_ctl_destroy(struct dpu_hw_ctl *ctx);
  187. #endif /*_DPU_HW_CTL_H */