dsi_phy.h 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef _DSI_PHY_H_
  6. #define _DSI_PHY_H_
  7. #include "dsi_defs.h"
  8. #include "dsi_clk.h"
  9. #include "dsi_pwr.h"
  10. #include "dsi_phy_hw.h"
  11. struct dsi_ver_spec_info {
  12. enum dsi_phy_version version;
  13. u32 lane_cfg_count;
  14. u32 strength_cfg_count;
  15. u32 regulator_cfg_count;
  16. u32 timing_cfg_count;
  17. };
  18. /**
  19. * struct dsi_phy_power_info - digital and analog power supplies for DSI PHY
  20. * @digital: Digital power supply for DSI PHY.
  21. * @phy_pwr: Analog power supplies for DSI PHY to work.
  22. */
  23. struct dsi_phy_power_info {
  24. struct dsi_regulator_info digital;
  25. struct dsi_regulator_info phy_pwr;
  26. };
  27. /**
  28. * enum phy_engine_state - define engine status for dsi phy.
  29. * @DSI_PHY_ENGINE_OFF: Engine is turned off.
  30. * @DSI_PHY_ENGINE_ON: Engine is turned on.
  31. * @DSI_PHY_ENGINE_MAX: Maximum value.
  32. */
  33. enum phy_engine_state {
  34. DSI_PHY_ENGINE_OFF = 0,
  35. DSI_PHY_ENGINE_ON,
  36. DSI_PHY_ENGINE_MAX,
  37. };
  38. /**
  39. * enum phy_ulps_return_type - define set_ulps return type for dsi phy.
  40. * @DSI_PHY_ULPS_HANDLED: ulps is handled in phy.
  41. * @DSI_PHY_ULPS_NOT_HANDLED: ulps is not handled in phy.
  42. * @DSI_PHY_ULPS_ERROR: ulps request failed in phy.
  43. */
  44. enum phy_ulps_return_type {
  45. DSI_PHY_ULPS_HANDLED = 0,
  46. DSI_PHY_ULPS_NOT_HANDLED,
  47. DSI_PHY_ULPS_ERROR,
  48. };
  49. /**
  50. * struct msm_dsi_phy - DSI PHY object
  51. * @pdev: Pointer to platform device.
  52. * @index: Instance id.
  53. * @name: Name of the PHY instance.
  54. * @refcount: Reference count.
  55. * @phy_lock: Mutex for hardware and object access.
  56. * @ver_info: Version specific phy parameters.
  57. * @hw: DSI PHY hardware object.
  58. * @pwr_info: Power information.
  59. * @cfg: DSI phy configuration.
  60. * @clk_cb: structure containing call backs for clock control
  61. * @power_state: True if PHY is powered on.
  62. * @dsi_phy_state: PHY state information.
  63. * @mode: Current mode.
  64. * @data_lanes: Number of data lanes used.
  65. * @dst_format: Destination format.
  66. * @allow_phy_power_off: True if PHY is allowed to power off when idle
  67. * @regulator_min_datarate_bps: Minimum per lane data rate to turn on regulator
  68. * @regulator_required: True if phy regulator is required
  69. */
  70. struct msm_dsi_phy {
  71. struct platform_device *pdev;
  72. int index;
  73. const char *name;
  74. u32 refcount;
  75. struct mutex phy_lock;
  76. const struct dsi_ver_spec_info *ver_info;
  77. struct dsi_phy_hw hw;
  78. struct dsi_phy_power_info pwr_info;
  79. struct dsi_phy_cfg cfg;
  80. struct clk_ctrl_cb clk_cb;
  81. enum phy_engine_state dsi_phy_state;
  82. bool power_state;
  83. struct dsi_mode_info mode;
  84. enum dsi_data_lanes data_lanes;
  85. enum dsi_pixel_format dst_format;
  86. bool allow_phy_power_off;
  87. u32 regulator_min_datarate_bps;
  88. bool regulator_required;
  89. };
  90. /**
  91. * dsi_phy_get() - get a dsi phy handle from device node
  92. * @of_node: device node for dsi phy controller
  93. *
  94. * Gets the DSI PHY handle for the corresponding of_node. The ref count is
  95. * incremented to one all subsequents get will fail until the original client
  96. * calls a put.
  97. *
  98. * Return: DSI PHY handle or an error code.
  99. */
  100. struct msm_dsi_phy *dsi_phy_get(struct device_node *of_node);
  101. /**
  102. * dsi_phy_put() - release dsi phy handle
  103. * @dsi_phy: DSI PHY handle.
  104. *
  105. * Release the DSI PHY hardware. Driver will clean up all resources and puts
  106. * back the DSI PHY into reset state.
  107. */
  108. void dsi_phy_put(struct msm_dsi_phy *dsi_phy);
  109. /**
  110. * dsi_phy_drv_init() - initialize dsi phy driver
  111. * @dsi_phy: DSI PHY handle.
  112. *
  113. * Initializes DSI PHY driver. Should be called after dsi_phy_get().
  114. *
  115. * Return: error code.
  116. */
  117. int dsi_phy_drv_init(struct msm_dsi_phy *dsi_phy);
  118. /**
  119. * dsi_phy_drv_deinit() - de-initialize dsi phy driver
  120. * @dsi_phy: DSI PHY handle.
  121. *
  122. * Release all resources acquired by dsi_phy_drv_init().
  123. *
  124. * Return: error code.
  125. */
  126. int dsi_phy_drv_deinit(struct msm_dsi_phy *dsi_phy);
  127. /**
  128. * dsi_phy_validate_mode() - validate a display mode
  129. * @dsi_phy: DSI PHY handle.
  130. * @mode: Mode information.
  131. *
  132. * Validation will fail if the mode cannot be supported by the PHY driver or
  133. * hardware.
  134. *
  135. * Return: error code.
  136. */
  137. int dsi_phy_validate_mode(struct msm_dsi_phy *dsi_phy,
  138. struct dsi_mode_info *mode);
  139. /**
  140. * dsi_phy_set_power_state() - enable/disable dsi phy power supplies
  141. * @dsi_phy: DSI PHY handle.
  142. * @enable: Boolean flag to enable/disable.
  143. *
  144. * Return: error code.
  145. */
  146. int dsi_phy_set_power_state(struct msm_dsi_phy *dsi_phy, bool enable);
  147. /**
  148. * dsi_phy_enable() - enable DSI PHY hardware
  149. * @dsi_phy: DSI PHY handle.
  150. * @config: DSI host configuration.
  151. * @pll_source: Source PLL for PHY clock.
  152. * @skip_validation: Validation will not be performed on parameters.
  153. * @is_cont_splash_enabled: check whether continuous splash enabled.
  154. *
  155. * Validates and enables DSI PHY.
  156. *
  157. * Return: error code.
  158. */
  159. int dsi_phy_enable(struct msm_dsi_phy *dsi_phy,
  160. struct dsi_host_config *config,
  161. enum dsi_phy_pll_source pll_source,
  162. bool skip_validation,
  163. bool is_cont_splash_enabled);
  164. /**
  165. * dsi_phy_disable() - disable DSI PHY hardware.
  166. * @phy: DSI PHY handle.
  167. *
  168. * Return: error code.
  169. */
  170. int dsi_phy_disable(struct msm_dsi_phy *phy);
  171. /**
  172. * dsi_phy_set_ulps() - set ulps state for DSI pHY
  173. * @phy: DSI PHY handle
  174. * @config: DSi host configuration information.
  175. * @enable: Enable/Disable
  176. * @clamp_enabled: mmss_clamp enabled/disabled
  177. *
  178. * Return: error code.
  179. */
  180. int dsi_phy_set_ulps(struct msm_dsi_phy *phy, struct dsi_host_config *config,
  181. bool enable, bool clamp_enabled);
  182. /**
  183. * dsi_phy_clk_cb_register() - Register PHY clock control callback
  184. * @phy: DSI PHY handle
  185. * @clk_cb: Structure containing call back for clock control
  186. *
  187. * Return: error code.
  188. */
  189. int dsi_phy_clk_cb_register(struct msm_dsi_phy *phy,
  190. struct clk_ctrl_cb *clk_cb);
  191. /**
  192. * dsi_phy_idle_ctrl() - enable/disable DSI PHY during idle screen
  193. * @phy: DSI PHY handle
  194. * @enable: boolean to specify PHY enable/disable.
  195. *
  196. * Return: error code.
  197. */
  198. int dsi_phy_idle_ctrl(struct msm_dsi_phy *phy, bool enable);
  199. /**
  200. * dsi_phy_set_clamp_state() - configure clamps for DSI lanes
  201. * @phy: DSI PHY handle.
  202. * @enable: boolean to specify clamp enable/disable.
  203. *
  204. * Return: error code.
  205. */
  206. int dsi_phy_set_clamp_state(struct msm_dsi_phy *phy, bool enable);
  207. /**
  208. * dsi_phy_set_clk_freq() - set DSI PHY clock frequency setting
  209. * @phy: DSI PHY handle
  210. * @clk_freq: link clock frequency
  211. *
  212. * Return: error code.
  213. */
  214. int dsi_phy_set_clk_freq(struct msm_dsi_phy *phy,
  215. struct link_clk_freq *clk_freq);
  216. /**
  217. * dsi_phy_set_timing_params() - timing parameters for the panel
  218. * @phy: DSI PHY handle
  219. * @timing: array holding timing params.
  220. * @size: size of the array.
  221. *
  222. * When PHY timing calculator is not implemented, this array will be used to
  223. * pass PHY timing information.
  224. *
  225. * Return: error code.
  226. */
  227. int dsi_phy_set_timing_params(struct msm_dsi_phy *phy,
  228. u32 *timing, u32 size);
  229. /**
  230. * dsi_phy_lane_reset() - Reset DSI PHY lanes in case of error
  231. * @phy: DSI PHY handle
  232. *
  233. * Return: error code.
  234. */
  235. int dsi_phy_lane_reset(struct msm_dsi_phy *phy);
  236. /**
  237. * dsi_phy_toggle_resync_fifo() - toggle resync retime FIFO
  238. * @phy: DSI PHY handle
  239. *
  240. * Toggle the resync retime FIFO to synchronize the data paths.
  241. * This should be done everytime there is a change in the link clock
  242. * rate
  243. */
  244. void dsi_phy_toggle_resync_fifo(struct msm_dsi_phy *phy);
  245. /**
  246. * dsi_phy_reset_clk_en_sel() - reset clk_en_select on cmn_clk_cfg1 register
  247. * @phy: DSI PHY handle
  248. *
  249. * After toggling resync fifo regiater, clk_en_sel bit on cmn_clk_cfg1
  250. * register has to be reset
  251. */
  252. void dsi_phy_reset_clk_en_sel(struct msm_dsi_phy *phy);
  253. /**
  254. * dsi_phy_drv_register() - register platform driver for dsi phy
  255. */
  256. void dsi_phy_drv_register(void);
  257. /**
  258. * dsi_phy_drv_unregister() - unregister platform driver
  259. */
  260. void dsi_phy_drv_unregister(void);
  261. /**
  262. * dsi_phy_update_phy_timings() - Update dsi phy timings
  263. * @phy: DSI PHY handle
  264. * @config: DSI Host config parameters
  265. *
  266. * Return: error code.
  267. */
  268. int dsi_phy_update_phy_timings(struct msm_dsi_phy *phy,
  269. struct dsi_host_config *config);
  270. /**
  271. * dsi_phy_config_dynamic_refresh() - Configure dynamic refresh registers
  272. * @phy: DSI PHY handle
  273. * @delay: pipe delays for dynamic refresh
  274. * @is_master: Boolean to indicate if for master or slave
  275. */
  276. void dsi_phy_config_dynamic_refresh(struct msm_dsi_phy *phy,
  277. struct dsi_dyn_clk_delay *delay,
  278. bool is_master);
  279. /**
  280. * dsi_phy_dynamic_refresh_trigger() - trigger dynamic refresh
  281. * @phy: DSI PHY handle
  282. * @is_master: Boolean to indicate if for master or slave.
  283. */
  284. void dsi_phy_dynamic_refresh_trigger(struct msm_dsi_phy *phy, bool is_master);
  285. /**
  286. * dsi_phy_dynamic_refresh_clear() - clear dynamic refresh config
  287. * @phy: DSI PHY handle
  288. */
  289. void dsi_phy_dynamic_refresh_clear(struct msm_dsi_phy *phy);
  290. /**
  291. * dsi_phy_dyn_refresh_cache_phy_timings - cache the phy timings calculated
  292. * as part of dynamic refresh.
  293. * @phy: DSI PHY Handle.
  294. * @dst: Pointer to cache location.
  295. * @size: Number of phy lane settings.
  296. */
  297. int dsi_phy_dyn_refresh_cache_phy_timings(struct msm_dsi_phy *phy,
  298. u32 *dst, u32 size);
  299. /**
  300. * dsi_phy_set_continuous_clk() - API to set/unset force clock lane HS request.
  301. * @phy: DSI PHY Handle.
  302. * @enable: variable to control continuous clock.
  303. */
  304. void dsi_phy_set_continuous_clk(struct msm_dsi_phy *phy, bool enable);
  305. #endif /* _DSI_PHY_H_ */