dsi_catalog.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2015-2019, The Linux Foundation. All rights reserved.
  4. */
  5. #define pr_fmt(fmt) "msm-dsi-catalog:[%s] " fmt, __func__
  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.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.debug_bus = dsi_ctrl_hw_cmn_debug_bus;
  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. switch (version) {
  65. case DSI_CTRL_VERSION_1_4:
  66. ctrl->ops.setup_lane_map = dsi_ctrl_hw_14_setup_lane_map;
  67. ctrl->ops.ulps_ops.ulps_request = dsi_ctrl_hw_cmn_ulps_request;
  68. ctrl->ops.ulps_ops.ulps_exit = dsi_ctrl_hw_cmn_ulps_exit;
  69. ctrl->ops.wait_for_lane_idle =
  70. dsi_ctrl_hw_14_wait_for_lane_idle;
  71. ctrl->ops.ulps_ops.get_lanes_in_ulps =
  72. dsi_ctrl_hw_cmn_get_lanes_in_ulps;
  73. ctrl->ops.clamp_enable = dsi_ctrl_hw_14_clamp_enable;
  74. ctrl->ops.clamp_disable = dsi_ctrl_hw_14_clamp_disable;
  75. ctrl->ops.reg_dump_to_buffer =
  76. dsi_ctrl_hw_14_reg_dump_to_buffer;
  77. ctrl->ops.schedule_dma_cmd = NULL;
  78. ctrl->ops.get_cont_splash_status = NULL;
  79. ctrl->ops.kickoff_command_non_embedded_mode = NULL;
  80. ctrl->ops.config_clk_gating = NULL;
  81. break;
  82. case DSI_CTRL_VERSION_2_0:
  83. ctrl->ops.setup_lane_map = dsi_ctrl_hw_20_setup_lane_map;
  84. ctrl->ops.wait_for_lane_idle =
  85. dsi_ctrl_hw_20_wait_for_lane_idle;
  86. ctrl->ops.reg_dump_to_buffer =
  87. dsi_ctrl_hw_20_reg_dump_to_buffer;
  88. ctrl->ops.ulps_ops.ulps_request = NULL;
  89. ctrl->ops.ulps_ops.ulps_exit = NULL;
  90. ctrl->ops.ulps_ops.get_lanes_in_ulps = NULL;
  91. ctrl->ops.clamp_enable = NULL;
  92. ctrl->ops.clamp_disable = NULL;
  93. ctrl->ops.schedule_dma_cmd = NULL;
  94. ctrl->ops.get_cont_splash_status = NULL;
  95. ctrl->ops.kickoff_command_non_embedded_mode = NULL;
  96. ctrl->ops.config_clk_gating = NULL;
  97. break;
  98. case DSI_CTRL_VERSION_2_2:
  99. case DSI_CTRL_VERSION_2_3:
  100. case DSI_CTRL_VERSION_2_4:
  101. ctrl->ops.phy_reset_config = dsi_ctrl_hw_22_phy_reset_config;
  102. ctrl->ops.config_clk_gating = dsi_ctrl_hw_22_config_clk_gating;
  103. ctrl->ops.get_cont_splash_status =
  104. dsi_ctrl_hw_22_get_cont_splash_status;
  105. ctrl->ops.setup_lane_map = dsi_ctrl_hw_20_setup_lane_map;
  106. ctrl->ops.wait_for_lane_idle =
  107. dsi_ctrl_hw_20_wait_for_lane_idle;
  108. ctrl->ops.reg_dump_to_buffer =
  109. dsi_ctrl_hw_20_reg_dump_to_buffer;
  110. ctrl->ops.ulps_ops.ulps_request = dsi_ctrl_hw_cmn_ulps_request;
  111. ctrl->ops.ulps_ops.ulps_exit = dsi_ctrl_hw_cmn_ulps_exit;
  112. ctrl->ops.ulps_ops.get_lanes_in_ulps =
  113. dsi_ctrl_hw_cmn_get_lanes_in_ulps;
  114. ctrl->ops.clamp_enable = NULL;
  115. ctrl->ops.clamp_disable = NULL;
  116. ctrl->ops.schedule_dma_cmd = dsi_ctrl_hw_22_schedule_dma_cmd;
  117. ctrl->ops.kickoff_command_non_embedded_mode =
  118. dsi_ctrl_hw_kickoff_non_embedded_mode;
  119. break;
  120. default:
  121. break;
  122. }
  123. }
  124. /**
  125. * dsi_catalog_ctrl_setup() - return catalog info for dsi controller
  126. * @ctrl: Pointer to DSI controller hw object.
  127. * @version: DSI controller version.
  128. * @index: DSI controller instance ID.
  129. * @phy_isolation_enabled: DSI controller works isolated from phy.
  130. * @null_insertion_enabled: DSI controller inserts null packet.
  131. *
  132. * This function setups the catalog information in the dsi_ctrl_hw object.
  133. *
  134. * return: error code for failure and 0 for success.
  135. */
  136. int dsi_catalog_ctrl_setup(struct dsi_ctrl_hw *ctrl,
  137. enum dsi_ctrl_version version, u32 index,
  138. bool phy_isolation_enabled, bool null_insertion_enabled)
  139. {
  140. int rc = 0;
  141. if (version == DSI_CTRL_VERSION_UNKNOWN ||
  142. version >= DSI_CTRL_VERSION_MAX) {
  143. pr_err("Unsupported version: %d\n", version);
  144. return -ENOTSUPP;
  145. }
  146. ctrl->index = index;
  147. ctrl->null_insertion_enabled = null_insertion_enabled;
  148. set_bit(DSI_CTRL_VIDEO_TPG, ctrl->feature_map);
  149. set_bit(DSI_CTRL_CMD_TPG, ctrl->feature_map);
  150. set_bit(DSI_CTRL_VARIABLE_REFRESH_RATE, ctrl->feature_map);
  151. set_bit(DSI_CTRL_DYNAMIC_REFRESH, ctrl->feature_map);
  152. set_bit(DSI_CTRL_DESKEW_CALIB, ctrl->feature_map);
  153. set_bit(DSI_CTRL_DPHY, ctrl->feature_map);
  154. switch (version) {
  155. case DSI_CTRL_VERSION_1_4:
  156. dsi_catalog_cmn_init(ctrl, version);
  157. break;
  158. case DSI_CTRL_VERSION_2_0:
  159. case DSI_CTRL_VERSION_2_2:
  160. case DSI_CTRL_VERSION_2_3:
  161. case DSI_CTRL_VERSION_2_4:
  162. ctrl->phy_isolation_enabled = phy_isolation_enabled;
  163. dsi_catalog_cmn_init(ctrl, version);
  164. break;
  165. default:
  166. return -ENOTSUPP;
  167. }
  168. return rc;
  169. }
  170. /**
  171. * dsi_catalog_phy_2_0_init() - catalog init for DSI PHY 14nm
  172. */
  173. static void dsi_catalog_phy_2_0_init(struct dsi_phy_hw *phy)
  174. {
  175. phy->ops.regulator_enable = dsi_phy_hw_v2_0_regulator_enable;
  176. phy->ops.regulator_disable = dsi_phy_hw_v2_0_regulator_disable;
  177. phy->ops.enable = dsi_phy_hw_v2_0_enable;
  178. phy->ops.disable = dsi_phy_hw_v2_0_disable;
  179. phy->ops.calculate_timing_params =
  180. dsi_phy_hw_calculate_timing_params;
  181. phy->ops.phy_idle_on = dsi_phy_hw_v2_0_idle_on;
  182. phy->ops.phy_idle_off = dsi_phy_hw_v2_0_idle_off;
  183. phy->ops.calculate_timing_params =
  184. dsi_phy_hw_calculate_timing_params;
  185. phy->ops.phy_timing_val = dsi_phy_hw_timing_val_v2_0;
  186. phy->ops.clamp_ctrl = dsi_phy_hw_v2_0_clamp_ctrl;
  187. }
  188. /**
  189. * dsi_catalog_phy_3_0_init() - catalog init for DSI PHY 10nm
  190. */
  191. static void dsi_catalog_phy_3_0_init(struct dsi_phy_hw *phy)
  192. {
  193. phy->ops.regulator_enable = dsi_phy_hw_v3_0_regulator_enable;
  194. phy->ops.regulator_disable = dsi_phy_hw_v3_0_regulator_disable;
  195. phy->ops.enable = dsi_phy_hw_v3_0_enable;
  196. phy->ops.disable = dsi_phy_hw_v3_0_disable;
  197. phy->ops.calculate_timing_params =
  198. dsi_phy_hw_calculate_timing_params;
  199. phy->ops.ulps_ops.wait_for_lane_idle =
  200. dsi_phy_hw_v3_0_wait_for_lane_idle;
  201. phy->ops.ulps_ops.ulps_request =
  202. dsi_phy_hw_v3_0_ulps_request;
  203. phy->ops.ulps_ops.ulps_exit =
  204. dsi_phy_hw_v3_0_ulps_exit;
  205. phy->ops.ulps_ops.get_lanes_in_ulps =
  206. dsi_phy_hw_v3_0_get_lanes_in_ulps;
  207. phy->ops.ulps_ops.is_lanes_in_ulps =
  208. dsi_phy_hw_v3_0_is_lanes_in_ulps;
  209. phy->ops.phy_timing_val = dsi_phy_hw_timing_val_v3_0;
  210. phy->ops.clamp_ctrl = dsi_phy_hw_v3_0_clamp_ctrl;
  211. phy->ops.phy_lane_reset = dsi_phy_hw_v3_0_lane_reset;
  212. phy->ops.toggle_resync_fifo = dsi_phy_hw_v3_0_toggle_resync_fifo;
  213. phy->ops.dyn_refresh_ops.dyn_refresh_config =
  214. dsi_phy_hw_v3_0_dyn_refresh_config;
  215. phy->ops.dyn_refresh_ops.dyn_refresh_pipe_delay =
  216. dsi_phy_hw_v3_0_dyn_refresh_pipe_delay;
  217. phy->ops.dyn_refresh_ops.dyn_refresh_helper =
  218. dsi_phy_hw_v3_0_dyn_refresh_helper;
  219. phy->ops.dyn_refresh_ops.cache_phy_timings =
  220. dsi_phy_hw_v3_0_cache_phy_timings;
  221. }
  222. /**
  223. * dsi_catalog_phy_4_0_init() - catalog init for DSI PHY 7nm
  224. */
  225. static void dsi_catalog_phy_4_0_init(struct dsi_phy_hw *phy)
  226. {
  227. phy->ops.regulator_enable = NULL;
  228. phy->ops.regulator_disable = NULL;
  229. phy->ops.enable = dsi_phy_hw_v4_0_enable;
  230. phy->ops.disable = dsi_phy_hw_v4_0_disable;
  231. phy->ops.calculate_timing_params =
  232. dsi_phy_hw_calculate_timing_params;
  233. phy->ops.ulps_ops.wait_for_lane_idle =
  234. dsi_phy_hw_v4_0_wait_for_lane_idle;
  235. phy->ops.ulps_ops.ulps_request =
  236. dsi_phy_hw_v4_0_ulps_request;
  237. phy->ops.ulps_ops.ulps_exit =
  238. dsi_phy_hw_v4_0_ulps_exit;
  239. phy->ops.ulps_ops.get_lanes_in_ulps =
  240. dsi_phy_hw_v4_0_get_lanes_in_ulps;
  241. phy->ops.ulps_ops.is_lanes_in_ulps =
  242. dsi_phy_hw_v4_0_is_lanes_in_ulps;
  243. phy->ops.phy_timing_val = dsi_phy_hw_timing_val_v4_0;
  244. phy->ops.phy_lane_reset = dsi_phy_hw_v4_0_lane_reset;
  245. phy->ops.toggle_resync_fifo = dsi_phy_hw_v4_0_toggle_resync_fifo;
  246. phy->ops.reset_clk_en_sel = dsi_phy_hw_v4_0_reset_clk_en_sel;
  247. }
  248. /**
  249. * dsi_catalog_phy_setup() - return catalog info for dsi phy hardware
  250. * @ctrl: Pointer to DSI PHY hw object.
  251. * @version: DSI PHY version.
  252. * @index: DSI PHY instance ID.
  253. *
  254. * This function setups the catalog information in the dsi_phy_hw object.
  255. *
  256. * return: error code for failure and 0 for success.
  257. */
  258. int dsi_catalog_phy_setup(struct dsi_phy_hw *phy,
  259. enum dsi_phy_version version,
  260. u32 index)
  261. {
  262. int rc = 0;
  263. if (version == DSI_PHY_VERSION_UNKNOWN ||
  264. version >= DSI_PHY_VERSION_MAX) {
  265. pr_err("Unsupported version: %d\n", version);
  266. return -ENOTSUPP;
  267. }
  268. phy->index = index;
  269. phy->version = version;
  270. set_bit(DSI_PHY_DPHY, phy->feature_map);
  271. dsi_phy_timing_calc_init(phy, version);
  272. switch (version) {
  273. case DSI_PHY_VERSION_2_0:
  274. dsi_catalog_phy_2_0_init(phy);
  275. break;
  276. case DSI_PHY_VERSION_3_0:
  277. dsi_catalog_phy_3_0_init(phy);
  278. break;
  279. case DSI_PHY_VERSION_4_0:
  280. case DSI_PHY_VERSION_4_1:
  281. dsi_catalog_phy_4_0_init(phy);
  282. break;
  283. case DSI_PHY_VERSION_0_0_HPM:
  284. case DSI_PHY_VERSION_0_0_LPM:
  285. case DSI_PHY_VERSION_1_0:
  286. default:
  287. return -ENOTSUPP;
  288. }
  289. return rc;
  290. }