dp_parser.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2021-2023, Qualcomm Innovation Center, Inc. All rights reserved.
  4. * Copyright (c) 2012-2021, The Linux Foundation. All rights reserved.
  5. */
  6. #ifndef _DP_PARSER_H_
  7. #define _DP_PARSER_H_
  8. #include <linux/sde_io_util.h>
  9. #define DP_LABEL "MDSS DP DISPLAY"
  10. #define AUX_CFG_LEN 10
  11. #define DP_MAX_PIXEL_CLK_KHZ 675000
  12. #define DP_MAX_LINK_CLK_KHZ 810000
  13. #define MAX_DP_MST_STREAMS 2
  14. #define MAX_SWING_LEVELS 4
  15. #define MAX_PRE_EMP_LEVELS 4
  16. enum dp_pm_type {
  17. DP_CORE_PM,
  18. DP_CTRL_PM,
  19. DP_PHY_PM,
  20. DP_STREAM0_PM,
  21. DP_STREAM1_PM,
  22. DP_LINK_PM,
  23. DP_PLL_PM,
  24. DP_MAX_PM
  25. };
  26. static inline const char *dp_parser_pm_name(enum dp_pm_type module)
  27. {
  28. switch (module) {
  29. case DP_CORE_PM: return "DP_CORE_PM";
  30. case DP_CTRL_PM: return "DP_CTRL_PM";
  31. case DP_PHY_PM: return "DP_PHY_PM";
  32. case DP_STREAM0_PM: return "DP_STREAM0_PM";
  33. case DP_STREAM1_PM: return "DP_STREAM1_PM";
  34. case DP_LINK_PM: return "DP_LINK_PM";
  35. case DP_PLL_PM: return "DP_PLL_PM";
  36. default: return "???";
  37. }
  38. }
  39. /**
  40. * struct dp_display_data - display related device tree data.
  41. *
  42. * @ctrl_node: referece to controller device
  43. * @phy_node: reference to phy device
  44. * @is_active: is the controller currently active
  45. * @name: name of the display
  46. * @display_type: type of the display
  47. */
  48. struct dp_display_data {
  49. struct device_node *ctrl_node;
  50. struct device_node *phy_node;
  51. bool is_active;
  52. const char *name;
  53. const char *display_type;
  54. };
  55. /**
  56. * struct dp_io_data - data structure to store DP IO related info
  57. * @name: name of the IO
  58. * @buf: buffer corresponding to IO for debugging
  59. * @io: io data which give len and mapped address
  60. */
  61. struct dp_io_data {
  62. const char *name;
  63. u8 *buf;
  64. struct dss_io_data io;
  65. };
  66. /**
  67. * struct dp_io - data struct to store array of DP IO info
  68. * @len: total number of IOs
  69. * @data: pointer to an array of DP IO data structures.
  70. */
  71. struct dp_io {
  72. u32 len;
  73. struct dp_io_data *data;
  74. };
  75. /**
  76. * struct dp_pinctrl - DP's pin control
  77. *
  78. * @pin: pin-controller's instance
  79. * @state_active: active state pin control
  80. * @state_hpd_active: hpd active state pin control
  81. * @state_suspend: suspend state pin control
  82. */
  83. struct dp_pinctrl {
  84. struct pinctrl *pin;
  85. struct pinctrl_state *state_active;
  86. struct pinctrl_state *state_hpd_active;
  87. struct pinctrl_state *state_hpd_tlmm;
  88. struct pinctrl_state *state_hpd_ctrl;
  89. struct pinctrl_state *state_suspend;
  90. };
  91. #define DP_ENUM_STR(x) #x
  92. #define DP_AUX_CFG_MAX_VALUE_CNT 3
  93. /**
  94. * struct dp_aux_cfg - DP's AUX configuration settings
  95. *
  96. * @cfg_cnt: count of the configurable settings for the AUX register
  97. * @current_index: current index of the AUX config lut
  98. * @offset: register offset of the AUX config register
  99. * @lut: look up table for the AUX config values for this register
  100. */
  101. struct dp_aux_cfg {
  102. u32 cfg_cnt;
  103. u32 current_index;
  104. u32 offset;
  105. u32 lut[DP_AUX_CFG_MAX_VALUE_CNT];
  106. };
  107. /* PHY AUX config registers */
  108. enum dp_phy_aux_config_type {
  109. PHY_AUX_CFG0,
  110. PHY_AUX_CFG1,
  111. PHY_AUX_CFG2,
  112. PHY_AUX_CFG3,
  113. PHY_AUX_CFG4,
  114. PHY_AUX_CFG5,
  115. PHY_AUX_CFG6,
  116. PHY_AUX_CFG7,
  117. PHY_AUX_CFG8,
  118. PHY_AUX_CFG9,
  119. PHY_AUX_CFG_MAX,
  120. };
  121. /**
  122. * enum dp_phy_version - version of the dp phy
  123. * @DP_PHY_VERSION_UNKNOWN: Unknown controller version
  124. * @DP_PHY_VERSION_4_2_0: DP phy v4.2.0 controller
  125. * @DP_PHY_VERSION_6_0_0: DP phy v6.0.0 controller
  126. * @DP_PHY_VERSION_MAX: max version
  127. */
  128. enum dp_phy_version {
  129. DP_PHY_VERSION_UNKNOWN,
  130. DP_PHY_VERSION_2_0_0 = 0x200,
  131. DP_PHY_VERSION_4_2_0 = 0x420,
  132. DP_PHY_VERSION_6_0_0 = 0x600,
  133. DP_PHY_VERSION_MAX
  134. };
  135. /**
  136. * struct dp_hw_cfg - DP HW specific configuration
  137. *
  138. * @phy_version: DP PHY HW version
  139. */
  140. struct dp_hw_cfg {
  141. enum dp_phy_version phy_version;
  142. };
  143. static inline char *dp_phy_aux_config_type_to_string(u32 cfg_type)
  144. {
  145. switch (cfg_type) {
  146. case PHY_AUX_CFG0:
  147. return DP_ENUM_STR(PHY_AUX_CFG0);
  148. case PHY_AUX_CFG1:
  149. return DP_ENUM_STR(PHY_AUX_CFG1);
  150. case PHY_AUX_CFG2:
  151. return DP_ENUM_STR(PHY_AUX_CFG2);
  152. case PHY_AUX_CFG3:
  153. return DP_ENUM_STR(PHY_AUX_CFG3);
  154. case PHY_AUX_CFG4:
  155. return DP_ENUM_STR(PHY_AUX_CFG4);
  156. case PHY_AUX_CFG5:
  157. return DP_ENUM_STR(PHY_AUX_CFG5);
  158. case PHY_AUX_CFG6:
  159. return DP_ENUM_STR(PHY_AUX_CFG6);
  160. case PHY_AUX_CFG7:
  161. return DP_ENUM_STR(PHY_AUX_CFG7);
  162. case PHY_AUX_CFG8:
  163. return DP_ENUM_STR(PHY_AUX_CFG8);
  164. case PHY_AUX_CFG9:
  165. return DP_ENUM_STR(PHY_AUX_CFG9);
  166. default:
  167. return "unknown";
  168. }
  169. }
  170. /**
  171. * struct dp_parser - DP parser's data exposed to clients
  172. *
  173. * @pdev: platform data of the client
  174. * @msm_hdcp_dev: device pointer for the HDCP driver
  175. * @mp: gpio, regulator and clock related data
  176. * @pinctrl: pin-control related data
  177. * @disp_data: controller's display related data
  178. * @l_pnswap: P/N swap status on each lane
  179. * @max_pclk_khz: maximum pixel clock supported for the platform
  180. * @max_lclk_khz: maximum link clock supported for the platform
  181. * @hw_cfg: DP HW specific settings
  182. * @has_mst: MST feature enable status
  183. * @has_mst_sideband: MST sideband feature enable status
  184. * @gpio_aux_switch: presence GPIO AUX switch status
  185. * @dsc_feature_enable: DSC feature enable status
  186. * @fec_feature_enable: FEC feature enable status
  187. * @dsc_continuous_pps: PPS sent every frame by HW
  188. * @has_widebus: widebus (2PPC) feature eanble status
  189. *@mst_fixed_port: mst port_num reserved for fixed topology
  190. * @qos_cpu_mask: CPU mask for QOS
  191. * @qos_cpu_latency: CPU Latency setting for QOS
  192. * @swing_hbr2_3: Voltage swing levels for HBR2 and HBR3 rates
  193. * @pre_emp_hbr2_3: Pre-emphasis for HBR2 and HBR3 rates
  194. * @swing_hbr_rbr: Voltage swing levels for HBR and RBR rates
  195. * @pre_emp_hbr_rbr: Pre-emphasis for HBR and RBR rates
  196. * @valid_lt_params: valid lt params
  197. * @parse: function to be called by client to parse device tree.
  198. * @get_io: function to be called by client to get io data.
  199. * @get_io_buf: function to be called by client to get io buffers.
  200. * @clear_io_buf: function to be called by client to clear io buffers.
  201. */
  202. struct dp_parser {
  203. struct platform_device *pdev;
  204. struct device *msm_hdcp_dev;
  205. struct dss_module_power mp[DP_MAX_PM];
  206. struct dp_pinctrl pinctrl;
  207. struct dp_io io;
  208. struct dp_display_data disp_data;
  209. u8 l_map[4];
  210. u8 l_pnswap;
  211. struct dp_aux_cfg aux_cfg[AUX_CFG_LEN];
  212. u32 max_pclk_khz;
  213. u32 max_lclk_khz;
  214. struct dp_hw_cfg hw_cfg;
  215. bool has_mst;
  216. bool has_mst_sideband;
  217. bool dsc_feature_enable;
  218. bool fec_feature_enable;
  219. bool dsc_continuous_pps;
  220. bool has_widebus;
  221. bool gpio_aux_switch;
  222. u32 mst_fixed_port[MAX_DP_MST_STREAMS];
  223. u32 qos_cpu_mask;
  224. unsigned long qos_cpu_latency;
  225. u8 *swing_hbr2_3;
  226. u8 *pre_emp_hbr2_3;
  227. u8 *swing_hbr_rbr;
  228. u8 *pre_emp_hbr_rbr;
  229. bool valid_lt_params;
  230. int (*parse)(struct dp_parser *parser);
  231. struct dp_io_data *(*get_io)(struct dp_parser *parser, char *name);
  232. void (*get_io_buf)(struct dp_parser *parser, char *name);
  233. void (*clear_io_buf)(struct dp_parser *parser);
  234. };
  235. enum dp_phy_lane_num {
  236. DP_PHY_LN0 = 0,
  237. DP_PHY_LN1 = 1,
  238. DP_PHY_LN2 = 2,
  239. DP_PHY_LN3 = 3,
  240. DP_MAX_PHY_LN = 4,
  241. };
  242. enum dp_mainlink_lane_num {
  243. DP_ML0 = 0,
  244. DP_ML1 = 1,
  245. DP_ML2 = 2,
  246. DP_ML3 = 3,
  247. };
  248. /**
  249. * dp_parser_get() - get the DP's device tree parser module
  250. *
  251. * @pdev: platform data of the client
  252. * return: pointer to dp_parser structure.
  253. *
  254. * This function provides client capability to parse the
  255. * device tree and populate the data structures. The data
  256. * related to clock, regulators, pin-control and other
  257. * can be parsed using this module.
  258. */
  259. struct dp_parser *dp_parser_get(struct platform_device *pdev);
  260. /**
  261. * dp_parser_put() - cleans the dp_parser module
  262. *
  263. * @parser: pointer to the parser's data.
  264. */
  265. void dp_parser_put(struct dp_parser *parser);
  266. #endif