exynos_dp_core.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. /*
  2. * Header file for Samsung DP (Display Port) interface driver.
  3. *
  4. * Copyright (C) 2012 Samsung Electronics Co., Ltd.
  5. * Author: Jingoo Han <jg1.han@samsung.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the
  9. * Free Software Foundation; either version 2 of the License, or (at your
  10. * option) any later version.
  11. */
  12. #ifndef _EXYNOS_DP_CORE_H
  13. #define _EXYNOS_DP_CORE_H
  14. #include <drm/drm_crtc.h>
  15. #include <drm/drm_dp_helper.h>
  16. #include <drm/exynos_drm.h>
  17. #include "exynos_drm_drv.h"
  18. #define DP_TIMEOUT_LOOP_COUNT 100
  19. #define MAX_CR_LOOP 5
  20. #define MAX_EQ_LOOP 5
  21. enum link_rate_type {
  22. LINK_RATE_1_62GBPS = 0x06,
  23. LINK_RATE_2_70GBPS = 0x0a
  24. };
  25. enum link_lane_count_type {
  26. LANE_COUNT1 = 1,
  27. LANE_COUNT2 = 2,
  28. LANE_COUNT4 = 4
  29. };
  30. enum link_training_state {
  31. START,
  32. CLOCK_RECOVERY,
  33. EQUALIZER_TRAINING,
  34. FINISHED,
  35. FAILED
  36. };
  37. enum voltage_swing_level {
  38. VOLTAGE_LEVEL_0,
  39. VOLTAGE_LEVEL_1,
  40. VOLTAGE_LEVEL_2,
  41. VOLTAGE_LEVEL_3,
  42. };
  43. enum pre_emphasis_level {
  44. PRE_EMPHASIS_LEVEL_0,
  45. PRE_EMPHASIS_LEVEL_1,
  46. PRE_EMPHASIS_LEVEL_2,
  47. PRE_EMPHASIS_LEVEL_3,
  48. };
  49. enum pattern_set {
  50. PRBS7,
  51. D10_2,
  52. TRAINING_PTN1,
  53. TRAINING_PTN2,
  54. DP_NONE
  55. };
  56. enum color_space {
  57. COLOR_RGB,
  58. COLOR_YCBCR422,
  59. COLOR_YCBCR444
  60. };
  61. enum color_depth {
  62. COLOR_6,
  63. COLOR_8,
  64. COLOR_10,
  65. COLOR_12
  66. };
  67. enum color_coefficient {
  68. COLOR_YCBCR601,
  69. COLOR_YCBCR709
  70. };
  71. enum dynamic_range {
  72. VESA,
  73. CEA
  74. };
  75. enum pll_status {
  76. PLL_UNLOCKED,
  77. PLL_LOCKED
  78. };
  79. enum clock_recovery_m_value_type {
  80. CALCULATED_M,
  81. REGISTER_M
  82. };
  83. enum video_timing_recognition_type {
  84. VIDEO_TIMING_FROM_CAPTURE,
  85. VIDEO_TIMING_FROM_REGISTER
  86. };
  87. enum analog_power_block {
  88. AUX_BLOCK,
  89. CH0_BLOCK,
  90. CH1_BLOCK,
  91. CH2_BLOCK,
  92. CH3_BLOCK,
  93. ANALOG_TOTAL,
  94. POWER_ALL
  95. };
  96. enum dp_irq_type {
  97. DP_IRQ_TYPE_HP_CABLE_IN,
  98. DP_IRQ_TYPE_HP_CABLE_OUT,
  99. DP_IRQ_TYPE_HP_CHANGE,
  100. DP_IRQ_TYPE_UNKNOWN,
  101. };
  102. struct video_info {
  103. char *name;
  104. bool h_sync_polarity;
  105. bool v_sync_polarity;
  106. bool interlaced;
  107. enum color_space color_space;
  108. enum dynamic_range dynamic_range;
  109. enum color_coefficient ycbcr_coeff;
  110. enum color_depth color_depth;
  111. enum link_rate_type link_rate;
  112. enum link_lane_count_type lane_count;
  113. };
  114. struct link_train {
  115. int eq_loop;
  116. int cr_loop[4];
  117. u8 link_rate;
  118. u8 lane_count;
  119. u8 training_lane[4];
  120. enum link_training_state lt_state;
  121. };
  122. struct exynos_dp_device {
  123. struct drm_encoder encoder;
  124. struct device *dev;
  125. struct drm_device *drm_dev;
  126. struct drm_connector connector;
  127. struct drm_panel *panel;
  128. struct drm_bridge *bridge;
  129. struct clk *clock;
  130. unsigned int irq;
  131. void __iomem *reg_base;
  132. struct video_info *video_info;
  133. struct link_train link_train;
  134. struct work_struct hotplug_work;
  135. struct phy *phy;
  136. int dpms_mode;
  137. int hpd_gpio;
  138. struct exynos_drm_panel_info priv;
  139. };
  140. /* exynos_dp_reg.c */
  141. void exynos_dp_enable_video_mute(struct exynos_dp_device *dp, bool enable);
  142. void exynos_dp_stop_video(struct exynos_dp_device *dp);
  143. void exynos_dp_lane_swap(struct exynos_dp_device *dp, bool enable);
  144. void exynos_dp_init_analog_param(struct exynos_dp_device *dp);
  145. void exynos_dp_init_interrupt(struct exynos_dp_device *dp);
  146. void exynos_dp_reset(struct exynos_dp_device *dp);
  147. void exynos_dp_swreset(struct exynos_dp_device *dp);
  148. void exynos_dp_config_interrupt(struct exynos_dp_device *dp);
  149. enum pll_status exynos_dp_get_pll_lock_status(struct exynos_dp_device *dp);
  150. void exynos_dp_set_pll_power_down(struct exynos_dp_device *dp, bool enable);
  151. void exynos_dp_set_analog_power_down(struct exynos_dp_device *dp,
  152. enum analog_power_block block,
  153. bool enable);
  154. void exynos_dp_init_analog_func(struct exynos_dp_device *dp);
  155. void exynos_dp_init_hpd(struct exynos_dp_device *dp);
  156. enum dp_irq_type exynos_dp_get_irq_type(struct exynos_dp_device *dp);
  157. void exynos_dp_clear_hotplug_interrupts(struct exynos_dp_device *dp);
  158. void exynos_dp_reset_aux(struct exynos_dp_device *dp);
  159. void exynos_dp_init_aux(struct exynos_dp_device *dp);
  160. int exynos_dp_get_plug_in_status(struct exynos_dp_device *dp);
  161. void exynos_dp_enable_sw_function(struct exynos_dp_device *dp);
  162. int exynos_dp_start_aux_transaction(struct exynos_dp_device *dp);
  163. int exynos_dp_write_byte_to_dpcd(struct exynos_dp_device *dp,
  164. unsigned int reg_addr,
  165. unsigned char data);
  166. int exynos_dp_read_byte_from_dpcd(struct exynos_dp_device *dp,
  167. unsigned int reg_addr,
  168. unsigned char *data);
  169. int exynos_dp_write_bytes_to_dpcd(struct exynos_dp_device *dp,
  170. unsigned int reg_addr,
  171. unsigned int count,
  172. unsigned char data[]);
  173. int exynos_dp_read_bytes_from_dpcd(struct exynos_dp_device *dp,
  174. unsigned int reg_addr,
  175. unsigned int count,
  176. unsigned char data[]);
  177. int exynos_dp_select_i2c_device(struct exynos_dp_device *dp,
  178. unsigned int device_addr,
  179. unsigned int reg_addr);
  180. int exynos_dp_read_byte_from_i2c(struct exynos_dp_device *dp,
  181. unsigned int device_addr,
  182. unsigned int reg_addr,
  183. unsigned int *data);
  184. int exynos_dp_read_bytes_from_i2c(struct exynos_dp_device *dp,
  185. unsigned int device_addr,
  186. unsigned int reg_addr,
  187. unsigned int count,
  188. unsigned char edid[]);
  189. void exynos_dp_set_link_bandwidth(struct exynos_dp_device *dp, u32 bwtype);
  190. void exynos_dp_get_link_bandwidth(struct exynos_dp_device *dp, u32 *bwtype);
  191. void exynos_dp_set_lane_count(struct exynos_dp_device *dp, u32 count);
  192. void exynos_dp_get_lane_count(struct exynos_dp_device *dp, u32 *count);
  193. void exynos_dp_enable_enhanced_mode(struct exynos_dp_device *dp, bool enable);
  194. void exynos_dp_set_training_pattern(struct exynos_dp_device *dp,
  195. enum pattern_set pattern);
  196. void exynos_dp_set_lane0_pre_emphasis(struct exynos_dp_device *dp, u32 level);
  197. void exynos_dp_set_lane1_pre_emphasis(struct exynos_dp_device *dp, u32 level);
  198. void exynos_dp_set_lane2_pre_emphasis(struct exynos_dp_device *dp, u32 level);
  199. void exynos_dp_set_lane3_pre_emphasis(struct exynos_dp_device *dp, u32 level);
  200. void exynos_dp_set_lane0_link_training(struct exynos_dp_device *dp,
  201. u32 training_lane);
  202. void exynos_dp_set_lane1_link_training(struct exynos_dp_device *dp,
  203. u32 training_lane);
  204. void exynos_dp_set_lane2_link_training(struct exynos_dp_device *dp,
  205. u32 training_lane);
  206. void exynos_dp_set_lane3_link_training(struct exynos_dp_device *dp,
  207. u32 training_lane);
  208. u32 exynos_dp_get_lane0_link_training(struct exynos_dp_device *dp);
  209. u32 exynos_dp_get_lane1_link_training(struct exynos_dp_device *dp);
  210. u32 exynos_dp_get_lane2_link_training(struct exynos_dp_device *dp);
  211. u32 exynos_dp_get_lane3_link_training(struct exynos_dp_device *dp);
  212. void exynos_dp_reset_macro(struct exynos_dp_device *dp);
  213. void exynos_dp_init_video(struct exynos_dp_device *dp);
  214. void exynos_dp_set_video_color_format(struct exynos_dp_device *dp);
  215. int exynos_dp_is_slave_video_stream_clock_on(struct exynos_dp_device *dp);
  216. void exynos_dp_set_video_cr_mn(struct exynos_dp_device *dp,
  217. enum clock_recovery_m_value_type type,
  218. u32 m_value,
  219. u32 n_value);
  220. void exynos_dp_set_video_timing_mode(struct exynos_dp_device *dp, u32 type);
  221. void exynos_dp_enable_video_master(struct exynos_dp_device *dp, bool enable);
  222. void exynos_dp_start_video(struct exynos_dp_device *dp);
  223. int exynos_dp_is_video_stream_on(struct exynos_dp_device *dp);
  224. void exynos_dp_config_video_slave_mode(struct exynos_dp_device *dp);
  225. void exynos_dp_enable_scrambling(struct exynos_dp_device *dp);
  226. void exynos_dp_disable_scrambling(struct exynos_dp_device *dp);
  227. /* I2C EDID Chip ID, Slave Address */
  228. #define I2C_EDID_DEVICE_ADDR 0x50
  229. #define I2C_E_EDID_DEVICE_ADDR 0x30
  230. #define EDID_BLOCK_LENGTH 0x80
  231. #define EDID_HEADER_PATTERN 0x00
  232. #define EDID_EXTENSION_FLAG 0x7e
  233. #define EDID_CHECKSUM 0x7f
  234. /* DP_MAX_LANE_COUNT */
  235. #define DPCD_ENHANCED_FRAME_CAP(x) (((x) >> 7) & 0x1)
  236. #define DPCD_MAX_LANE_COUNT(x) ((x) & 0x1f)
  237. /* DP_LANE_COUNT_SET */
  238. #define DPCD_LANE_COUNT_SET(x) ((x) & 0x1f)
  239. /* DP_TRAINING_LANE0_SET */
  240. #define DPCD_PRE_EMPHASIS_SET(x) (((x) & 0x3) << 3)
  241. #define DPCD_PRE_EMPHASIS_GET(x) (((x) >> 3) & 0x3)
  242. #define DPCD_VOLTAGE_SWING_SET(x) (((x) & 0x3) << 0)
  243. #define DPCD_VOLTAGE_SWING_GET(x) (((x) >> 0) & 0x3)
  244. #endif /* _EXYNOS_DP_CORE_H */