dsi_catalog.c 11 KB

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