dsi_catalog.c 12 KB

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