sde_rsc_priv.h 7.7 KB

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