dp_parser.h 6.9 KB

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