dsi_catalog.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2015-2021, The Linux Foundation. All rights reserved.
  4. */
  5. #include <linux/errno.h>
  6. #include "dsi_catalog.h"
  7. /**
  8. * dsi_catalog_cmn_init() - catalog init for dsi controller v1.4
  9. */
  10. static void dsi_catalog_cmn_init(struct dsi_ctrl_hw *ctrl,
  11. enum dsi_ctrl_version version)
  12. {
  13. /* common functions */
  14. ctrl->ops.host_setup = dsi_ctrl_hw_cmn_host_setup;
  15. ctrl->ops.video_engine_en = dsi_ctrl_hw_cmn_video_engine_en;
  16. ctrl->ops.video_engine_setup = dsi_ctrl_hw_cmn_video_engine_setup;
  17. ctrl->ops.set_video_timing = dsi_ctrl_hw_cmn_set_video_timing;
  18. ctrl->ops.set_timing_db = dsi_ctrl_hw_cmn_set_timing_db;
  19. ctrl->ops.cmd_engine_setup = dsi_ctrl_hw_cmn_cmd_engine_setup;
  20. ctrl->ops.setup_cmd_stream = dsi_ctrl_hw_cmn_setup_cmd_stream;
  21. ctrl->ops.ctrl_en = dsi_ctrl_hw_cmn_ctrl_en;
  22. ctrl->ops.cmd_engine_en = dsi_ctrl_hw_cmn_cmd_engine_en;
  23. ctrl->ops.phy_sw_reset = dsi_ctrl_hw_cmn_phy_sw_reset;
  24. ctrl->ops.soft_reset = dsi_ctrl_hw_cmn_soft_reset;
  25. ctrl->ops.kickoff_command = dsi_ctrl_hw_cmn_kickoff_command;
  26. ctrl->ops.kickoff_fifo_command = dsi_ctrl_hw_cmn_kickoff_fifo_command;
  27. ctrl->ops.reset_cmd_fifo = dsi_ctrl_hw_cmn_reset_cmd_fifo;
  28. ctrl->ops.trigger_command_dma = dsi_ctrl_hw_cmn_trigger_command_dma;
  29. ctrl->ops.get_interrupt_status = dsi_ctrl_hw_cmn_get_interrupt_status;
  30. ctrl->ops.poll_dma_status = dsi_ctrl_hw_cmn_poll_dma_status;
  31. ctrl->ops.get_error_status = dsi_ctrl_hw_cmn_get_error_status;
  32. ctrl->ops.clear_error_status = dsi_ctrl_hw_cmn_clear_error_status;
  33. ctrl->ops.clear_interrupt_status =
  34. dsi_ctrl_hw_cmn_clear_interrupt_status;
  35. ctrl->ops.enable_status_interrupts =
  36. dsi_ctrl_hw_cmn_enable_status_interrupts;
  37. ctrl->ops.enable_error_interrupts =
  38. dsi_ctrl_hw_cmn_enable_error_interrupts;
  39. ctrl->ops.video_test_pattern_setup =
  40. dsi_ctrl_hw_cmn_video_test_pattern_setup;
  41. ctrl->ops.cmd_test_pattern_setup =
  42. dsi_ctrl_hw_cmn_cmd_test_pattern_setup;
  43. ctrl->ops.test_pattern_enable = dsi_ctrl_hw_cmn_test_pattern_enable;
  44. ctrl->ops.trigger_cmd_test_pattern =
  45. dsi_ctrl_hw_cmn_trigger_cmd_test_pattern;
  46. ctrl->ops.clear_phy0_ln_err = dsi_ctrl_hw_dln0_phy_err;
  47. ctrl->ops.phy_reset_config = dsi_ctrl_hw_cmn_phy_reset_config;
  48. ctrl->ops.setup_misr = dsi_ctrl_hw_cmn_setup_misr;
  49. ctrl->ops.collect_misr = dsi_ctrl_hw_cmn_collect_misr;
  50. ctrl->ops.get_cmd_read_data = dsi_ctrl_hw_cmn_get_cmd_read_data;
  51. ctrl->ops.clear_rdbk_register = dsi_ctrl_hw_cmn_clear_rdbk_reg;
  52. ctrl->ops.ctrl_reset = dsi_ctrl_hw_cmn_ctrl_reset;
  53. ctrl->ops.mask_error_intr = dsi_ctrl_hw_cmn_mask_error_intr;
  54. ctrl->ops.error_intr_ctrl = dsi_ctrl_hw_cmn_error_intr_ctrl;
  55. ctrl->ops.get_error_mask = dsi_ctrl_hw_cmn_get_error_mask;
  56. ctrl->ops.get_hw_version = dsi_ctrl_hw_cmn_get_hw_version;
  57. ctrl->ops.wait_for_cmd_mode_mdp_idle =
  58. dsi_ctrl_hw_cmn_wait_for_cmd_mode_mdp_idle;
  59. ctrl->ops.setup_avr = dsi_ctrl_hw_cmn_setup_avr;
  60. ctrl->ops.set_continuous_clk = dsi_ctrl_hw_cmn_set_continuous_clk;
  61. ctrl->ops.wait4dynamic_refresh_done =
  62. dsi_ctrl_hw_cmn_wait4dynamic_refresh_done;
  63. ctrl->ops.hs_req_sel = dsi_ctrl_hw_cmn_hs_req_sel;
  64. ctrl->ops.vid_engine_busy = dsi_ctrl_hw_cmn_vid_engine_busy;
  65. switch (version) {
  66. case DSI_CTRL_VERSION_2_2:
  67. case DSI_CTRL_VERSION_2_3:
  68. case DSI_CTRL_VERSION_2_4:
  69. case DSI_CTRL_VERSION_2_5:
  70. case DSI_CTRL_VERSION_2_6:
  71. ctrl->ops.phy_reset_config = dsi_ctrl_hw_22_phy_reset_config;
  72. ctrl->ops.config_clk_gating = dsi_ctrl_hw_22_config_clk_gating;
  73. ctrl->ops.setup_lane_map = dsi_ctrl_hw_22_setup_lane_map;
  74. ctrl->ops.wait_for_lane_idle =
  75. dsi_ctrl_hw_22_wait_for_lane_idle;
  76. ctrl->ops.reg_dump_to_buffer =
  77. dsi_ctrl_hw_22_reg_dump_to_buffer;
  78. ctrl->ops.ulps_ops.ulps_request = dsi_ctrl_hw_cmn_ulps_request;
  79. ctrl->ops.ulps_ops.ulps_exit = dsi_ctrl_hw_cmn_ulps_exit;
  80. ctrl->ops.ulps_ops.get_lanes_in_ulps =
  81. dsi_ctrl_hw_cmn_get_lanes_in_ulps;
  82. ctrl->ops.clamp_enable = NULL;
  83. ctrl->ops.clamp_disable = NULL;
  84. ctrl->ops.schedule_dma_cmd = dsi_ctrl_hw_22_schedule_dma_cmd;
  85. ctrl->ops.kickoff_command_non_embedded_mode =
  86. dsi_ctrl_hw_kickoff_non_embedded_mode;
  87. ctrl->ops.configure_cmddma_window =
  88. dsi_ctrl_hw_22_configure_cmddma_window;
  89. ctrl->ops.reset_trig_ctrl =
  90. dsi_ctrl_hw_22_reset_trigger_controls;
  91. ctrl->ops.log_line_count = dsi_ctrl_hw_22_log_line_count;
  92. ctrl->ops.splitlink_cmd_setup = dsi_ctrl_hw_22_configure_splitlink;
  93. break;
  94. default:
  95. break;
  96. }
  97. }
  98. /**
  99. * dsi_catalog_ctrl_setup() - return catalog info for dsi controller
  100. * @ctrl: Pointer to DSI controller hw object.
  101. * @version: DSI controller version.
  102. * @index: DSI controller instance ID.
  103. * @phy_isolation_enabled: DSI controller works isolated from phy.
  104. * @null_insertion_enabled: DSI controller inserts null packet.
  105. *
  106. * This function setups the catalog information in the dsi_ctrl_hw object.
  107. *
  108. * return: error code for failure and 0 for success.
  109. */
  110. int dsi_catalog_ctrl_setup(struct dsi_ctrl_hw *ctrl,
  111. enum dsi_ctrl_version version, u32 index,
  112. bool phy_isolation_enabled, bool null_insertion_enabled)
  113. {
  114. int rc = 0;
  115. if (version == DSI_CTRL_VERSION_UNKNOWN ||
  116. version >= DSI_CTRL_VERSION_MAX) {
  117. DSI_ERR("Unsupported version: %d\n", version);
  118. return -ENOTSUPP;
  119. }
  120. ctrl->index = index;
  121. ctrl->null_insertion_enabled = null_insertion_enabled;
  122. set_bit(DSI_CTRL_VIDEO_TPG, ctrl->feature_map);
  123. set_bit(DSI_CTRL_CMD_TPG, ctrl->feature_map);
  124. set_bit(DSI_CTRL_VARIABLE_REFRESH_RATE, ctrl->feature_map);
  125. set_bit(DSI_CTRL_DYNAMIC_REFRESH, ctrl->feature_map);
  126. set_bit(DSI_CTRL_DESKEW_CALIB, ctrl->feature_map);
  127. set_bit(DSI_CTRL_DPHY, ctrl->feature_map);
  128. switch (version) {
  129. case DSI_CTRL_VERSION_2_2:
  130. case DSI_CTRL_VERSION_2_3:
  131. case DSI_CTRL_VERSION_2_4:
  132. ctrl->phy_isolation_enabled = phy_isolation_enabled;
  133. dsi_catalog_cmn_init(ctrl, version);
  134. break;
  135. case DSI_CTRL_VERSION_2_5:
  136. case DSI_CTRL_VERSION_2_6:
  137. ctrl->widebus_support = true;
  138. ctrl->phy_isolation_enabled = phy_isolation_enabled;
  139. dsi_catalog_cmn_init(ctrl, version);
  140. break;
  141. default:
  142. return -ENOTSUPP;
  143. }
  144. return rc;
  145. }
  146. /**
  147. * dsi_catalog_phy_3_0_init() - catalog init for DSI PHY 10nm
  148. */
  149. static void dsi_catalog_phy_3_0_init(struct dsi_phy_hw *phy)
  150. {
  151. phy->ops.regulator_enable = dsi_phy_hw_v3_0_regulator_enable;
  152. phy->ops.regulator_disable = dsi_phy_hw_v3_0_regulator_disable;
  153. phy->ops.enable = dsi_phy_hw_v3_0_enable;
  154. phy->ops.disable = dsi_phy_hw_v3_0_disable;
  155. phy->ops.calculate_timing_params =
  156. dsi_phy_hw_calculate_timing_params;
  157. phy->ops.ulps_ops.wait_for_lane_idle =
  158. dsi_phy_hw_v3_0_wait_for_lane_idle;
  159. phy->ops.ulps_ops.ulps_request =
  160. dsi_phy_hw_v3_0_ulps_request;
  161. phy->ops.ulps_ops.ulps_exit =
  162. dsi_phy_hw_v3_0_ulps_exit;
  163. phy->ops.ulps_ops.get_lanes_in_ulps =
  164. dsi_phy_hw_v3_0_get_lanes_in_ulps;
  165. phy->ops.ulps_ops.is_lanes_in_ulps =
  166. dsi_phy_hw_v3_0_is_lanes_in_ulps;
  167. phy->ops.phy_timing_val = dsi_phy_hw_timing_val_v3_0;
  168. phy->ops.clamp_ctrl = dsi_phy_hw_v3_0_clamp_ctrl;
  169. phy->ops.phy_lane_reset = dsi_phy_hw_v3_0_lane_reset;
  170. phy->ops.toggle_resync_fifo = dsi_phy_hw_v3_0_toggle_resync_fifo;
  171. phy->ops.dyn_refresh_ops.dyn_refresh_config =
  172. dsi_phy_hw_v3_0_dyn_refresh_config;
  173. phy->ops.dyn_refresh_ops.dyn_refresh_pipe_delay =
  174. dsi_phy_hw_v3_0_dyn_refresh_pipe_delay;
  175. phy->ops.dyn_refresh_ops.dyn_refresh_helper =
  176. dsi_phy_hw_v3_0_dyn_refresh_helper;
  177. phy->ops.dyn_refresh_ops.dyn_refresh_trigger_sel = NULL;
  178. phy->ops.dyn_refresh_ops.cache_phy_timings =
  179. dsi_phy_hw_v3_0_cache_phy_timings;
  180. }
  181. /**
  182. * dsi_catalog_phy_4_0_init() - catalog init for DSI PHY 7nm
  183. */
  184. static void dsi_catalog_phy_4_0_init(struct dsi_phy_hw *phy)
  185. {
  186. phy->ops.regulator_enable = NULL;
  187. phy->ops.regulator_disable = NULL;
  188. phy->ops.enable = dsi_phy_hw_v4_0_enable;
  189. phy->ops.disable = dsi_phy_hw_v4_0_disable;
  190. phy->ops.calculate_timing_params =
  191. dsi_phy_hw_calculate_timing_params;
  192. phy->ops.ulps_ops.wait_for_lane_idle =
  193. dsi_phy_hw_v4_0_wait_for_lane_idle;
  194. phy->ops.ulps_ops.ulps_request =
  195. dsi_phy_hw_v4_0_ulps_request;
  196. phy->ops.ulps_ops.ulps_exit =
  197. dsi_phy_hw_v4_0_ulps_exit;
  198. phy->ops.ulps_ops.get_lanes_in_ulps =
  199. dsi_phy_hw_v4_0_get_lanes_in_ulps;
  200. phy->ops.ulps_ops.is_lanes_in_ulps =
  201. dsi_phy_hw_v4_0_is_lanes_in_ulps;
  202. phy->ops.phy_timing_val = dsi_phy_hw_timing_val_v4_0;
  203. phy->ops.phy_lane_reset = dsi_phy_hw_v4_0_lane_reset;
  204. phy->ops.toggle_resync_fifo = dsi_phy_hw_v4_0_toggle_resync_fifo;
  205. phy->ops.reset_clk_en_sel = dsi_phy_hw_v4_0_reset_clk_en_sel;
  206. phy->ops.dyn_refresh_ops.dyn_refresh_config =
  207. dsi_phy_hw_v4_0_dyn_refresh_config;
  208. phy->ops.dyn_refresh_ops.dyn_refresh_pipe_delay =
  209. dsi_phy_hw_v4_0_dyn_refresh_pipe_delay;
  210. phy->ops.dyn_refresh_ops.dyn_refresh_helper =
  211. dsi_phy_hw_v4_0_dyn_refresh_helper;
  212. phy->ops.dyn_refresh_ops.dyn_refresh_trigger_sel =
  213. dsi_phy_hw_v4_0_dyn_refresh_trigger_sel;
  214. phy->ops.dyn_refresh_ops.cache_phy_timings =
  215. dsi_phy_hw_v4_0_cache_phy_timings;
  216. phy->ops.set_continuous_clk = dsi_phy_hw_v4_0_set_continuous_clk;
  217. phy->ops.commit_phy_timing = dsi_phy_hw_v4_0_commit_phy_timing;
  218. }
  219. /**
  220. * dsi_catalog_phy_setup() - return catalog info for dsi phy hardware
  221. * @ctrl: Pointer to DSI PHY hw object.
  222. * @version: DSI PHY version.
  223. * @index: DSI PHY instance ID.
  224. *
  225. * This function setups the catalog information in the dsi_phy_hw object.
  226. *
  227. * return: error code for failure and 0 for success.
  228. */
  229. int dsi_catalog_phy_setup(struct dsi_phy_hw *phy,
  230. enum dsi_phy_version version,
  231. u32 index)
  232. {
  233. int rc = 0;
  234. if (version == DSI_PHY_VERSION_UNKNOWN ||
  235. version >= DSI_PHY_VERSION_MAX) {
  236. DSI_ERR("Unsupported version: %d\n", version);
  237. return -ENOTSUPP;
  238. }
  239. phy->index = index;
  240. phy->version = version;
  241. set_bit(DSI_PHY_DPHY, phy->feature_map);
  242. dsi_phy_timing_calc_init(phy, version);
  243. switch (version) {
  244. case DSI_PHY_VERSION_3_0:
  245. dsi_catalog_phy_3_0_init(phy);
  246. break;
  247. case DSI_PHY_VERSION_4_0:
  248. case DSI_PHY_VERSION_4_1:
  249. case DSI_PHY_VERSION_4_2:
  250. case DSI_PHY_VERSION_4_3:
  251. dsi_catalog_phy_4_0_init(phy);
  252. break;
  253. default:
  254. return -ENOTSUPP;
  255. }
  256. return rc;
  257. }
  258. int dsi_catalog_phy_pll_setup(struct dsi_phy_hw *phy, u32 pll_ver)
  259. {
  260. int rc = 0;
  261. if (pll_ver >= DSI_PLL_VERSION_UNKNOWN) {
  262. DSI_ERR("Unsupported version: %d\n", pll_ver);
  263. return -EOPNOTSUPP;
  264. }
  265. switch (pll_ver) {
  266. case DSI_PLL_VERSION_5NM:
  267. phy->ops.configure = dsi_pll_5nm_configure;
  268. phy->ops.pll_toggle = dsi_pll_5nm_toggle;
  269. break;
  270. default:
  271. phy->ops.configure = NULL;
  272. phy->ops.pll_toggle = NULL;
  273. break;
  274. }
  275. return rc;
  276. }