dsi_phy.h 10 KB

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