dp_parser.h 7.0 KB

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