Merge remote-tracking branch 'mailbox/mailbox-for-next'
[deliverable/linux.git] / drivers / gpu / drm / bridge / analogix / analogix_dp_core.h
CommitLineData
3424e3a4
YY
1/*
2 * Header file for Analogix DP (Display Port) core 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
13#ifndef _ANALOGIX_DP_CORE_H
14#define _ANALOGIX_DP_CORE_H
15
16#include <drm/drm_crtc.h>
17#include <drm/drm_dp_helper.h>
18
19#define DP_TIMEOUT_LOOP_COUNT 100
20#define MAX_CR_LOOP 5
21#define MAX_EQ_LOOP 5
22
398a3995
YY
23/* I2C EDID Chip ID, Slave Address */
24#define I2C_EDID_DEVICE_ADDR 0x50
25#define I2C_E_EDID_DEVICE_ADDR 0x30
26
27#define EDID_BLOCK_LENGTH 0x80
28#define EDID_HEADER_PATTERN 0x00
29#define EDID_EXTENSION_FLAG 0x7e
30#define EDID_CHECKSUM 0x7f
31
32/* DP_MAX_LANE_COUNT */
33#define DPCD_ENHANCED_FRAME_CAP(x) (((x) >> 7) & 0x1)
34#define DPCD_MAX_LANE_COUNT(x) ((x) & 0x1f)
35
36/* DP_LANE_COUNT_SET */
37#define DPCD_LANE_COUNT_SET(x) ((x) & 0x1f)
38
39/* DP_TRAINING_LANE0_SET */
40#define DPCD_PRE_EMPHASIS_SET(x) (((x) & 0x3) << 3)
41#define DPCD_PRE_EMPHASIS_GET(x) (((x) >> 3) & 0x3)
42#define DPCD_VOLTAGE_SWING_SET(x) (((x) & 0x3) << 0)
43#define DPCD_VOLTAGE_SWING_GET(x) (((x) >> 0) & 0x3)
44
3424e3a4
YY
45enum link_lane_count_type {
46 LANE_COUNT1 = 1,
47 LANE_COUNT2 = 2,
48 LANE_COUNT4 = 4
49};
50
51enum link_training_state {
52 START,
53 CLOCK_RECOVERY,
54 EQUALIZER_TRAINING,
55 FINISHED,
56 FAILED
57};
58
59enum voltage_swing_level {
60 VOLTAGE_LEVEL_0,
61 VOLTAGE_LEVEL_1,
62 VOLTAGE_LEVEL_2,
63 VOLTAGE_LEVEL_3,
64};
65
66enum pre_emphasis_level {
67 PRE_EMPHASIS_LEVEL_0,
68 PRE_EMPHASIS_LEVEL_1,
69 PRE_EMPHASIS_LEVEL_2,
70 PRE_EMPHASIS_LEVEL_3,
71};
72
73enum pattern_set {
74 PRBS7,
75 D10_2,
76 TRAINING_PTN1,
77 TRAINING_PTN2,
78 DP_NONE
79};
80
81enum color_space {
82 COLOR_RGB,
83 COLOR_YCBCR422,
84 COLOR_YCBCR444
85};
86
87enum color_depth {
88 COLOR_6,
89 COLOR_8,
90 COLOR_10,
91 COLOR_12
92};
93
94enum color_coefficient {
95 COLOR_YCBCR601,
96 COLOR_YCBCR709
97};
98
99enum dynamic_range {
100 VESA,
101 CEA
102};
103
104enum pll_status {
105 PLL_UNLOCKED,
106 PLL_LOCKED
107};
108
109enum clock_recovery_m_value_type {
110 CALCULATED_M,
111 REGISTER_M
112};
113
114enum video_timing_recognition_type {
115 VIDEO_TIMING_FROM_CAPTURE,
116 VIDEO_TIMING_FROM_REGISTER
117};
118
119enum analog_power_block {
120 AUX_BLOCK,
121 CH0_BLOCK,
122 CH1_BLOCK,
123 CH2_BLOCK,
124 CH3_BLOCK,
125 ANALOG_TOTAL,
126 POWER_ALL
127};
128
129enum dp_irq_type {
7608a9fb
YY
130 DP_IRQ_TYPE_HP_CABLE_IN = BIT(0),
131 DP_IRQ_TYPE_HP_CABLE_OUT = BIT(1),
132 DP_IRQ_TYPE_HP_CHANGE = BIT(2),
133 DP_IRQ_TYPE_UNKNOWN = BIT(3),
3424e3a4
YY
134};
135
136struct video_info {
137 char *name;
138
139 bool h_sync_polarity;
140 bool v_sync_polarity;
141 bool interlaced;
142
143 enum color_space color_space;
144 enum dynamic_range dynamic_range;
145 enum color_coefficient ycbcr_coeff;
146 enum color_depth color_depth;
147
0d0abd89
YY
148 int max_link_rate;
149 enum link_lane_count_type max_lane_count;
3424e3a4
YY
150};
151
152struct link_train {
153 int eq_loop;
154 int cr_loop[4];
155
156 u8 link_rate;
157 u8 lane_count;
158 u8 training_lane[4];
159
160 enum link_training_state lt_state;
161};
162
163struct analogix_dp_device {
164 struct drm_encoder *encoder;
165 struct device *dev;
166 struct drm_device *drm_dev;
167 struct drm_connector connector;
168 struct drm_bridge *bridge;
169 struct clk *clock;
170 unsigned int irq;
171 void __iomem *reg_base;
172
793ce4eb 173 struct video_info video_info;
3424e3a4 174 struct link_train link_train;
3424e3a4
YY
175 struct phy *phy;
176 int dpms_mode;
177 int hpd_gpio;
5cff007c 178 bool force_hpd;
398a3995 179 unsigned char edid[EDID_BLOCK_LENGTH * 2];
5b3f84f2 180 bool psr_support;
3424e3a4 181
0b8b059a
SP
182 struct mutex panel_lock;
183 bool panel_is_modeset;
184
3424e3a4
YY
185 struct analogix_dp_plat_data *plat_data;
186};
187
188/* analogix_dp_reg.c */
189void analogix_dp_enable_video_mute(struct analogix_dp_device *dp, bool enable);
190void analogix_dp_stop_video(struct analogix_dp_device *dp);
191void analogix_dp_lane_swap(struct analogix_dp_device *dp, bool enable);
192void analogix_dp_init_analog_param(struct analogix_dp_device *dp);
193void analogix_dp_init_interrupt(struct analogix_dp_device *dp);
194void analogix_dp_reset(struct analogix_dp_device *dp);
195void analogix_dp_swreset(struct analogix_dp_device *dp);
196void analogix_dp_config_interrupt(struct analogix_dp_device *dp);
7b4b7a8d
YY
197void analogix_dp_mute_hpd_interrupt(struct analogix_dp_device *dp);
198void analogix_dp_unmute_hpd_interrupt(struct analogix_dp_device *dp);
3424e3a4
YY
199enum pll_status analogix_dp_get_pll_lock_status(struct analogix_dp_device *dp);
200void analogix_dp_set_pll_power_down(struct analogix_dp_device *dp, bool enable);
201void analogix_dp_set_analog_power_down(struct analogix_dp_device *dp,
202 enum analog_power_block block,
203 bool enable);
204void analogix_dp_init_analog_func(struct analogix_dp_device *dp);
205void analogix_dp_init_hpd(struct analogix_dp_device *dp);
5cff007c 206void analogix_dp_force_hpd(struct analogix_dp_device *dp);
3424e3a4
YY
207enum dp_irq_type analogix_dp_get_irq_type(struct analogix_dp_device *dp);
208void analogix_dp_clear_hotplug_interrupts(struct analogix_dp_device *dp);
209void analogix_dp_reset_aux(struct analogix_dp_device *dp);
210void analogix_dp_init_aux(struct analogix_dp_device *dp);
211int analogix_dp_get_plug_in_status(struct analogix_dp_device *dp);
212void analogix_dp_enable_sw_function(struct analogix_dp_device *dp);
213int analogix_dp_start_aux_transaction(struct analogix_dp_device *dp);
214int analogix_dp_write_byte_to_dpcd(struct analogix_dp_device *dp,
bcbb7033
YY
215 unsigned int reg_addr,
216 unsigned char data);
3424e3a4 217int analogix_dp_read_byte_from_dpcd(struct analogix_dp_device *dp,
bcbb7033
YY
218 unsigned int reg_addr,
219 unsigned char *data);
3424e3a4 220int analogix_dp_write_bytes_to_dpcd(struct analogix_dp_device *dp,
bcbb7033
YY
221 unsigned int reg_addr,
222 unsigned int count,
223 unsigned char data[]);
3424e3a4 224int analogix_dp_read_bytes_from_dpcd(struct analogix_dp_device *dp,
bcbb7033
YY
225 unsigned int reg_addr,
226 unsigned int count,
227 unsigned char data[]);
3424e3a4 228int analogix_dp_select_i2c_device(struct analogix_dp_device *dp,
bcbb7033
YY
229 unsigned int device_addr,
230 unsigned int reg_addr);
3424e3a4 231int analogix_dp_read_byte_from_i2c(struct analogix_dp_device *dp,
bcbb7033
YY
232 unsigned int device_addr,
233 unsigned int reg_addr,
234 unsigned int *data);
3424e3a4 235int analogix_dp_read_bytes_from_i2c(struct analogix_dp_device *dp,
bcbb7033
YY
236 unsigned int device_addr,
237 unsigned int reg_addr,
238 unsigned int count,
239 unsigned char edid[]);
3424e3a4
YY
240void analogix_dp_set_link_bandwidth(struct analogix_dp_device *dp, u32 bwtype);
241void analogix_dp_get_link_bandwidth(struct analogix_dp_device *dp, u32 *bwtype);
242void analogix_dp_set_lane_count(struct analogix_dp_device *dp, u32 count);
243void analogix_dp_get_lane_count(struct analogix_dp_device *dp, u32 *count);
bcbb7033
YY
244void analogix_dp_enable_enhanced_mode(struct analogix_dp_device *dp,
245 bool enable);
3424e3a4 246void analogix_dp_set_training_pattern(struct analogix_dp_device *dp,
bcbb7033
YY
247 enum pattern_set pattern);
248void analogix_dp_set_lane0_pre_emphasis(struct analogix_dp_device *dp,
249 u32 level);
250void analogix_dp_set_lane1_pre_emphasis(struct analogix_dp_device *dp,
251 u32 level);
252void analogix_dp_set_lane2_pre_emphasis(struct analogix_dp_device *dp,
253 u32 level);
254void analogix_dp_set_lane3_pre_emphasis(struct analogix_dp_device *dp,
255 u32 level);
3424e3a4 256void analogix_dp_set_lane0_link_training(struct analogix_dp_device *dp,
bcbb7033 257 u32 training_lane);
3424e3a4 258void analogix_dp_set_lane1_link_training(struct analogix_dp_device *dp,
bcbb7033 259 u32 training_lane);
3424e3a4 260void analogix_dp_set_lane2_link_training(struct analogix_dp_device *dp,
bcbb7033 261 u32 training_lane);
3424e3a4 262void analogix_dp_set_lane3_link_training(struct analogix_dp_device *dp,
bcbb7033 263 u32 training_lane);
3424e3a4
YY
264u32 analogix_dp_get_lane0_link_training(struct analogix_dp_device *dp);
265u32 analogix_dp_get_lane1_link_training(struct analogix_dp_device *dp);
266u32 analogix_dp_get_lane2_link_training(struct analogix_dp_device *dp);
267u32 analogix_dp_get_lane3_link_training(struct analogix_dp_device *dp);
268void analogix_dp_reset_macro(struct analogix_dp_device *dp);
269void analogix_dp_init_video(struct analogix_dp_device *dp);
270
271void analogix_dp_set_video_color_format(struct analogix_dp_device *dp);
272int analogix_dp_is_slave_video_stream_clock_on(struct analogix_dp_device *dp);
273void analogix_dp_set_video_cr_mn(struct analogix_dp_device *dp,
bcbb7033
YY
274 enum clock_recovery_m_value_type type,
275 u32 m_value,
276 u32 n_value);
3424e3a4 277void analogix_dp_set_video_timing_mode(struct analogix_dp_device *dp, u32 type);
bcbb7033
YY
278void analogix_dp_enable_video_master(struct analogix_dp_device *dp,
279 bool enable);
3424e3a4
YY
280void analogix_dp_start_video(struct analogix_dp_device *dp);
281int analogix_dp_is_video_stream_on(struct analogix_dp_device *dp);
282void analogix_dp_config_video_slave_mode(struct analogix_dp_device *dp);
283void analogix_dp_enable_scrambling(struct analogix_dp_device *dp);
284void analogix_dp_disable_scrambling(struct analogix_dp_device *dp);
5b3f84f2
YY
285void analogix_dp_enable_psr_crc(struct analogix_dp_device *dp);
286void analogix_dp_send_psr_spd(struct analogix_dp_device *dp,
287 struct edp_vsc_psr *vsc);
288
3424e3a4 289#endif /* _ANALOGIX_DP_CORE_H */
This page took 0.057061 seconds and 5 git commands to generate.