sde_rsc_priv.h 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2016-2020, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef _SDE_RSC_PRIV_H_
  6. #define _SDE_RSC_PRIV_H_
  7. #include <linux/kernel.h>
  8. #include <linux/sde_io_util.h>
  9. #include <linux/sde_rsc.h>
  10. #include <soc/qcom/tcs.h>
  11. #include "sde_power_handle.h"
  12. #define SDE_RSC_COMPATIBLE "disp_rscc"
  13. #define MAX_RSC_COUNT 5
  14. #define ALL_MODES_DISABLED 0x0
  15. #define ONLY_MODE_0_ENABLED 0x1
  16. #define ONLY_MODE_0_1_ENABLED 0x3
  17. #define ALL_MODES_ENABLED 0x7
  18. #define MAX_COUNT_SIZE_SUPPORTED 128
  19. #define SDE_RSC_REV_1 0x1
  20. #define SDE_RSC_REV_2 0x2
  21. #define SDE_RSC_REV_3 0x3
  22. #define SDE_RSC_REV_4 0x4
  23. #define SDE_RSC_HW_MAJOR_MINOR_STEP(major, minor, step) \
  24. (((major & 0xff) << 16) |\
  25. ((minor & 0xff) << 8) | \
  26. (step & 0xff))
  27. struct sde_rsc_priv;
  28. /**
  29. * rsc_mode_req: sde rsc mode request information
  30. * MODE_READ: read vsync status
  31. * MODE_UPDATE: mode timeslot update
  32. * 0x0: all modes are disabled.
  33. * 0x1: Mode-0 is enabled and other two modes are disabled.
  34. * 0x3: Mode-0 & Mode-1 are enabled and mode-2 is disabled.
  35. * 0x7: all modes are enabled.
  36. */
  37. enum rsc_mode_req {
  38. MODE_READ,
  39. MODE_UPDATE = 0x1,
  40. };
  41. /**
  42. * rsc_vsync_req: sde rsc vsync request information
  43. * VSYNC_READ: read vsync status
  44. * VSYNC_READ_VSYNC0: read value vsync0 timestamp (cast to int from u32)
  45. * VSYNC_ENABLE: enable rsc wrapper vsync status
  46. * VSYNC_DISABLE: disable rsc wrapper vsync status
  47. */
  48. enum rsc_vsync_req {
  49. VSYNC_READ,
  50. VSYNC_READ_VSYNC0,
  51. VSYNC_ENABLE,
  52. VSYNC_DISABLE,
  53. };
  54. /**
  55. * struct sde_rsc_hw_ops - sde resource state coordinator hardware ops
  56. * @init: Initialize the sequencer, solver, qtimer,
  57. etc. hardware blocks on RSC.
  58. * @timer_update: update the static wrapper time and pdc/rsc
  59. backoff time.
  60. * @tcs_wait: Waits for TCS block OK to allow sending a
  61. * TCS command.
  62. * @hw_vsync: Enables the vsync on RSC block.
  63. * @tcs_use_ok: set TCS set to high to allow RSC to use it.
  64. * @bwi_status: It updates the BW increase/decrease status.
  65. * @is_amc_mode: Check current amc mode status
  66. * @debug_dump: dump debug bus registers or enable debug bus
  67. * @state_update: Enable/override the solver based on rsc state
  68. * status (command/video)
  69. * @debug_show: Show current debug status.
  70. * @mode_ctrl: shows current mode status, mode0/1/2
  71. * @setup_counters: Enable/disable RSC profiling counters
  72. * @get_counters: Get current status of profiling counters
  73. */
  74. struct sde_rsc_hw_ops {
  75. int (*init)(struct sde_rsc_priv *rsc);
  76. int (*timer_update)(struct sde_rsc_priv *rsc);
  77. int (*tcs_wait)(struct sde_rsc_priv *rsc);
  78. int (*hw_vsync)(struct sde_rsc_priv *rsc, enum rsc_vsync_req request,
  79. char *buffer, int buffer_size, u32 mode);
  80. int (*tcs_use_ok)(struct sde_rsc_priv *rsc);
  81. int (*bwi_status)(struct sde_rsc_priv *rsc, bool bw_indication);
  82. bool (*is_amc_mode)(struct sde_rsc_priv *rsc);
  83. void (*debug_dump)(struct sde_rsc_priv *rsc, u32 mux_sel);
  84. int (*state_update)(struct sde_rsc_priv *rsc, enum sde_rsc_state state);
  85. int (*debug_show)(struct seq_file *s, struct sde_rsc_priv *rsc);
  86. int (*mode_ctrl)(struct sde_rsc_priv *rsc, enum rsc_mode_req request,
  87. char *buffer, int buffer_size, u32 mode);
  88. int (*setup_counters)(struct sde_rsc_priv *rsc, bool enable);
  89. int (*get_counters)(struct sde_rsc_priv *rsc, u32 *counters);
  90. };
  91. /**
  92. * struct sde_rsc_timer_config: this is internal configuration between
  93. * rsc and rsc_hw API.
  94. *
  95. * @static_wakeup_time_ns: wrapper backoff time in nano seconds
  96. * @rsc_backoff_time_ns: rsc backoff time in nano seconds
  97. * @pdc_backoff_time_ns: pdc backoff time in nano seconds
  98. * @rsc_mode_threshold_time_ns: rsc mode threshold time in nano seconds
  99. * @rsc_time_slot_0_ns: mode-0 time slot threshold in nano seconds
  100. * @rsc_time_slot_1_ns: mode-1 time slot threshold in nano seconds
  101. * @rsc_time_slot_2_ns: mode-2 time slot threshold in nano seconds
  102. *
  103. * @min_threshold_time_ns: minimum time required to enter & exit mode0
  104. * @bwi_threshold_time_ns: worst case time to increase the BW vote
  105. */
  106. struct sde_rsc_timer_config {
  107. u32 static_wakeup_time_ns;
  108. u32 rsc_backoff_time_ns;
  109. u32 pdc_backoff_time_ns;
  110. u32 rsc_mode_threshold_time_ns;
  111. u32 rsc_time_slot_0_ns;
  112. u32 rsc_time_slot_1_ns;
  113. u32 rsc_time_slot_2_ns;
  114. u32 min_threshold_time_ns;
  115. u32 bwi_threshold_time_ns;
  116. };
  117. /**
  118. * struct sde_rsc_bw_config: bandwidth configuration
  119. *
  120. * @ab_vote: Stored ab_vote for SDE_POWER_HANDLE_DBUS_ID_MAX
  121. * @ib_vote: Stored ib_vote for SDE_POWER_HANDLE_DBUS_ID_MAX
  122. * @new_ab_vote: ab_vote for incoming frame.
  123. * @new_ib_vote: ib_vote for incoming frame.
  124. */
  125. struct sde_rsc_bw_config {
  126. u64 ab_vote[SDE_POWER_HANDLE_DBUS_ID_MAX];
  127. u64 ib_vote[SDE_POWER_HANDLE_DBUS_ID_MAX];
  128. u64 new_ab_vote[SDE_POWER_HANDLE_DBUS_ID_MAX];
  129. u64 new_ib_vote[SDE_POWER_HANDLE_DBUS_ID_MAX];
  130. };
  131. /**
  132. * struct sde_rsc_priv: sde resource state coordinator(rsc) private handle
  133. * @version: rsc sequence version
  134. * @hw_drv_ver: rscc hw version
  135. * @phandle: module power handle for clocks
  136. * @fs: "MDSS GDSC" handle
  137. * @sw_fs_enabled: track "MDSS GDSC" sw vote during probe
  138. *
  139. * @rpmh_dev: rpmh device node
  140. * @drv_io: sde drv io data mapping
  141. * @wrapper_io: wrapper io data mapping
  142. *
  143. * @client_list: current rsc client list handle
  144. * @event_list: current rsc event list handle
  145. * @client_lock: current rsc client synchronization lock
  146. *
  147. * timer_config: current rsc timer configuration
  148. * cmd_config: current panel config
  149. * current_state: current rsc state (video/command), solver
  150. * override/enabled.
  151. * vsync_source: Interface index to provide the vsync ticks
  152. * debug_mode: enables the logging for each register read/write
  153. * debugfs_root: debugfs file system root node
  154. *
  155. * hw_ops: sde rsc hardware operations
  156. * power_collapse: if all clients are in IDLE state then it enters in
  157. * mode2 state and enable the power collapse state
  158. * power_collapse_block:By default, rsc move to mode-2 if all clients are in
  159. * invalid state. It can be blocked by this boolean entry.
  160. * primary_client: A client which is allowed to make command state request
  161. * and ab/ib vote on display rsc
  162. * single_tcs_execution_time: worst case time to execute one tcs vote
  163. * (sleep/wake)
  164. * backoff_time_ns: time to only wake tcs in any mode
  165. * mode_threshold_time_ns: time to wake TCS in mode-0, must be greater than
  166. * backoff time
  167. * time_slot_0_ns: time for sleep & wake TCS in mode-1
  168. * master_drm: Primary client waits for vsync on this drm object based
  169. * on crtc id
  170. * rsc_vsync_wait: Refcount to indicate if we have to wait for the vsync.
  171. * rsc_vsync_waitq: Queue to wait for the vsync.
  172. * bw_config: check sde_rsc_bw_config structure description.
  173. * dev: rsc device node
  174. * resource_refcount: Track rsc resource refcount
  175. * profiling_supp: Indicates if HW has support for profiling counters
  176. * profiling_en: Flag for rsc lpm profiling counters, true=enabled
  177. * post_poms: bool if a panel mode change occurred
  178. */
  179. struct sde_rsc_priv {
  180. u32 version;
  181. u32 hw_drv_ver;
  182. struct sde_power_handle phandle;
  183. struct regulator *fs;
  184. bool sw_fs_enabled;
  185. struct device *rpmh_dev;
  186. struct dss_io_data drv_io;
  187. struct dss_io_data wrapper_io;
  188. struct list_head client_list;
  189. struct list_head event_list;
  190. struct mutex client_lock;
  191. struct sde_rsc_timer_config timer_config;
  192. struct sde_rsc_cmd_config cmd_config;
  193. u32 current_state;
  194. u32 vsync_source;
  195. u32 debug_mode;
  196. struct dentry *debugfs_root;
  197. struct sde_rsc_hw_ops hw_ops;
  198. bool power_collapse;
  199. bool power_collapse_block;
  200. struct sde_rsc_client *primary_client;
  201. u32 single_tcs_execution_time;
  202. u32 backoff_time_ns;
  203. u32 mode_threshold_time_ns;
  204. u32 time_slot_0_ns;
  205. struct drm_device *master_drm;
  206. atomic_t rsc_vsync_wait;
  207. wait_queue_head_t rsc_vsync_waitq;
  208. struct sde_rsc_bw_config bw_config;
  209. struct device *dev;
  210. atomic_t resource_refcount;
  211. bool profiling_supp;
  212. bool profiling_en;
  213. bool post_poms;
  214. };
  215. /**
  216. * sde_rsc_hw_register() - register hardware API. It manages V1 and V2 support.
  217. *
  218. * @client: Client pointer provided by sde_rsc_client_create().
  219. *
  220. * Return: error code.
  221. */
  222. int sde_rsc_hw_register(struct sde_rsc_priv *rsc);
  223. /**
  224. * sde_rsc_hw_register_v3() - register hardware API. It manages V3 support.
  225. *
  226. * @client: Client pointer provided by sde_rsc_client_create().
  227. *
  228. * Return: error code.
  229. */
  230. int sde_rsc_hw_register_v3(struct sde_rsc_priv *rsc);
  231. #endif /* _SDE_RSC_PRIV_H_ */