dp_parser.h 6.8 KB

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