blob: 6c84bfbcff9771473c37ccf962a9adc36c253889 [file] [log] [blame]
Jingoo Hane9474be2012-02-03 18:01:55 +09001/*
2 * Samsung SoC 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
13#include <linux/module.h>
14#include <linux/platform_device.h>
Jingoo Hane9474be2012-02-03 18:01:55 +090015#include <linux/err.h>
16#include <linux/clk.h>
17#include <linux/io.h>
18#include <linux/interrupt.h>
Ajay Kumarc4e235c2012-10-13 05:48:00 +090019#include <linux/of.h>
Andrew Brestickerb8b52472014-04-22 04:09:10 +053020#include <linux/of_gpio.h>
Ajay Kumar80185562015-01-20 22:08:46 +053021#include <linux/of_graph.h>
Andrew Brestickerb8b52472014-04-22 04:09:10 +053022#include <linux/gpio.h>
Inki Daef37cd5e2014-05-09 14:25:20 +090023#include <linux/component.h>
Jingoo Han8114fab2013-10-16 21:58:16 +053024#include <linux/phy/phy.h>
Sean Paul1417f102014-01-30 16:19:23 -050025#include <video/of_display_timing.h>
26#include <video/of_videomode.h>
Jingoo Hane9474be2012-02-03 18:01:55 +090027
Sean Paul1417f102014-01-30 16:19:23 -050028#include <drm/drmP.h>
Sean Paulcaa5d1e2014-01-30 16:19:30 -050029#include <drm/drm_crtc.h>
30#include <drm/drm_crtc_helper.h>
Gustavo Padovan4ea95262015-06-01 12:04:44 -030031#include <drm/drm_atomic_helper.h>
Ajay Kumar5f1dcd82014-07-31 23:12:14 +053032#include <drm/drm_panel.h>
Sean Paul1417f102014-01-30 16:19:23 -050033
Jingoo Hane9474be2012-02-03 18:01:55 +090034#include "exynos_dp_core.h"
35
Sean Paulcaa5d1e2014-01-30 16:19:30 -050036#define ctx_from_connector(c) container_of(c, struct exynos_dp_device, \
37 connector)
38
Krzysztof Kozlowski1c363c72015-04-07 22:28:50 +090039static inline struct exynos_drm_crtc *dp_to_crtc(struct exynos_dp_device *dp)
40{
Gustavo Padovancf67cc92015-08-11 17:38:06 +090041 return to_exynos_crtc(dp->encoder.base.crtc);
Krzysztof Kozlowski1c363c72015-04-07 22:28:50 +090042}
43
Gustavo Padovancf67cc92015-08-11 17:38:06 +090044static inline struct exynos_dp_device *encoder_to_dp(
45 struct exynos_drm_encoder *e)
Andrzej Hajda63b3be32014-11-17 09:54:25 +010046{
Gustavo Padovancf67cc92015-08-11 17:38:06 +090047 return container_of(e, struct exynos_dp_device, encoder);
Andrzej Hajda63b3be32014-11-17 09:54:25 +010048}
49
Sean Paul1634ba22014-02-24 19:20:15 +090050struct bridge_init {
51 struct i2c_client *client;
52 struct device_node *node;
53};
54
Ajay Kumar5f1dcd82014-07-31 23:12:14 +053055static void exynos_dp_init_dp(struct exynos_dp_device *dp)
Jingoo Hane9474be2012-02-03 18:01:55 +090056{
57 exynos_dp_reset(dp);
58
Jingoo Han24db03a2012-05-25 16:21:08 +090059 exynos_dp_swreset(dp);
60
Jingoo Han75435c72012-08-23 19:55:13 +090061 exynos_dp_init_analog_param(dp);
62 exynos_dp_init_interrupt(dp);
63
Jingoo Hane9474be2012-02-03 18:01:55 +090064 /* SW defined function Normal operation */
65 exynos_dp_enable_sw_function(dp);
66
67 exynos_dp_config_interrupt(dp);
68 exynos_dp_init_analog_func(dp);
69
70 exynos_dp_init_hpd(dp);
71 exynos_dp_init_aux(dp);
Jingoo Hane9474be2012-02-03 18:01:55 +090072}
73
74static int exynos_dp_detect_hpd(struct exynos_dp_device *dp)
75{
76 int timeout_loop = 0;
77
Jingoo Hane9474be2012-02-03 18:01:55 +090078 while (exynos_dp_get_plug_in_status(dp) != 0) {
79 timeout_loop++;
80 if (DP_TIMEOUT_LOOP_COUNT < timeout_loop) {
81 dev_err(dp->dev, "failed to get hpd plug status\n");
82 return -ETIMEDOUT;
83 }
Jingoo Hana2c81bc2012-07-18 18:50:59 +090084 usleep_range(10, 11);
Jingoo Hane9474be2012-02-03 18:01:55 +090085 }
86
87 return 0;
88}
89
90static unsigned char exynos_dp_calc_edid_check_sum(unsigned char *edid_data)
91{
92 int i;
93 unsigned char sum = 0;
94
95 for (i = 0; i < EDID_BLOCK_LENGTH; i++)
96 sum = sum + edid_data[i];
97
98 return sum;
99}
100
101static int exynos_dp_read_edid(struct exynos_dp_device *dp)
102{
103 unsigned char edid[EDID_BLOCK_LENGTH * 2];
104 unsigned int extend_block = 0;
105 unsigned char sum;
106 unsigned char test_vector;
107 int retval;
108
109 /*
110 * EDID device address is 0x50.
111 * However, if necessary, you must have set upper address
112 * into E-EDID in I2C device, 0x30.
113 */
114
115 /* Read Extension Flag, Number of 128-byte EDID extension blocks */
Sean Paul99f54152012-11-01 02:13:00 +0000116 retval = exynos_dp_read_byte_from_i2c(dp, I2C_EDID_DEVICE_ADDR,
Jingoo Hane9474be2012-02-03 18:01:55 +0900117 EDID_EXTENSION_FLAG,
118 &extend_block);
Sean Paul99f54152012-11-01 02:13:00 +0000119 if (retval)
120 return retval;
Jingoo Hane9474be2012-02-03 18:01:55 +0900121
122 if (extend_block > 0) {
123 dev_dbg(dp->dev, "EDID data includes a single extension!\n");
124
125 /* Read EDID data */
126 retval = exynos_dp_read_bytes_from_i2c(dp, I2C_EDID_DEVICE_ADDR,
127 EDID_HEADER_PATTERN,
128 EDID_BLOCK_LENGTH,
129 &edid[EDID_HEADER_PATTERN]);
130 if (retval != 0) {
131 dev_err(dp->dev, "EDID Read failed!\n");
132 return -EIO;
133 }
134 sum = exynos_dp_calc_edid_check_sum(edid);
135 if (sum != 0) {
136 dev_err(dp->dev, "EDID bad checksum!\n");
137 return -EIO;
138 }
139
140 /* Read additional EDID data */
141 retval = exynos_dp_read_bytes_from_i2c(dp,
142 I2C_EDID_DEVICE_ADDR,
143 EDID_BLOCK_LENGTH,
144 EDID_BLOCK_LENGTH,
145 &edid[EDID_BLOCK_LENGTH]);
146 if (retval != 0) {
147 dev_err(dp->dev, "EDID Read failed!\n");
148 return -EIO;
149 }
150 sum = exynos_dp_calc_edid_check_sum(&edid[EDID_BLOCK_LENGTH]);
151 if (sum != 0) {
152 dev_err(dp->dev, "EDID bad checksum!\n");
153 return -EIO;
154 }
155
Jingoo Han073ea2a2014-05-07 20:44:51 +0900156 exynos_dp_read_byte_from_dpcd(dp, DP_TEST_REQUEST,
Jingoo Hane9474be2012-02-03 18:01:55 +0900157 &test_vector);
Jingoo Han073ea2a2014-05-07 20:44:51 +0900158 if (test_vector & DP_TEST_LINK_EDID_READ) {
Jingoo Hane9474be2012-02-03 18:01:55 +0900159 exynos_dp_write_byte_to_dpcd(dp,
Jingoo Han073ea2a2014-05-07 20:44:51 +0900160 DP_TEST_EDID_CHECKSUM,
Jingoo Hane9474be2012-02-03 18:01:55 +0900161 edid[EDID_BLOCK_LENGTH + EDID_CHECKSUM]);
162 exynos_dp_write_byte_to_dpcd(dp,
Jingoo Han073ea2a2014-05-07 20:44:51 +0900163 DP_TEST_RESPONSE,
164 DP_TEST_EDID_CHECKSUM_WRITE);
Jingoo Hane9474be2012-02-03 18:01:55 +0900165 }
166 } else {
167 dev_info(dp->dev, "EDID data does not include any extensions.\n");
168
169 /* Read EDID data */
170 retval = exynos_dp_read_bytes_from_i2c(dp,
171 I2C_EDID_DEVICE_ADDR,
172 EDID_HEADER_PATTERN,
173 EDID_BLOCK_LENGTH,
174 &edid[EDID_HEADER_PATTERN]);
175 if (retval != 0) {
176 dev_err(dp->dev, "EDID Read failed!\n");
177 return -EIO;
178 }
179 sum = exynos_dp_calc_edid_check_sum(edid);
180 if (sum != 0) {
181 dev_err(dp->dev, "EDID bad checksum!\n");
182 return -EIO;
183 }
184
185 exynos_dp_read_byte_from_dpcd(dp,
Jingoo Han073ea2a2014-05-07 20:44:51 +0900186 DP_TEST_REQUEST,
Jingoo Hane9474be2012-02-03 18:01:55 +0900187 &test_vector);
Jingoo Han073ea2a2014-05-07 20:44:51 +0900188 if (test_vector & DP_TEST_LINK_EDID_READ) {
Jingoo Hane9474be2012-02-03 18:01:55 +0900189 exynos_dp_write_byte_to_dpcd(dp,
Jingoo Han073ea2a2014-05-07 20:44:51 +0900190 DP_TEST_EDID_CHECKSUM,
Jingoo Hane9474be2012-02-03 18:01:55 +0900191 edid[EDID_CHECKSUM]);
192 exynos_dp_write_byte_to_dpcd(dp,
Jingoo Han073ea2a2014-05-07 20:44:51 +0900193 DP_TEST_RESPONSE,
194 DP_TEST_EDID_CHECKSUM_WRITE);
Jingoo Hane9474be2012-02-03 18:01:55 +0900195 }
196 }
197
Krzysztof Kozlowskib0f155a2015-05-14 09:03:06 +0900198 dev_dbg(dp->dev, "EDID Read success!\n");
Jingoo Hane9474be2012-02-03 18:01:55 +0900199 return 0;
200}
201
202static int exynos_dp_handle_edid(struct exynos_dp_device *dp)
203{
204 u8 buf[12];
205 int i;
206 int retval;
207
Jingoo Han073ea2a2014-05-07 20:44:51 +0900208 /* Read DPCD DP_DPCD_REV~RECEIVE_PORT1_CAP_1 */
209 retval = exynos_dp_read_bytes_from_dpcd(dp, DP_DPCD_REV,
Sean Paul99f54152012-11-01 02:13:00 +0000210 12, buf);
211 if (retval)
212 return retval;
Jingoo Hane9474be2012-02-03 18:01:55 +0900213
214 /* Read EDID */
215 for (i = 0; i < 3; i++) {
216 retval = exynos_dp_read_edid(dp);
Sean Paul99f54152012-11-01 02:13:00 +0000217 if (!retval)
Jingoo Hane9474be2012-02-03 18:01:55 +0900218 break;
219 }
220
221 return retval;
222}
223
224static void exynos_dp_enable_rx_to_enhanced_mode(struct exynos_dp_device *dp,
225 bool enable)
226{
227 u8 data;
228
Jingoo Han073ea2a2014-05-07 20:44:51 +0900229 exynos_dp_read_byte_from_dpcd(dp, DP_LANE_COUNT_SET, &data);
Jingoo Hane9474be2012-02-03 18:01:55 +0900230
231 if (enable)
Jingoo Han073ea2a2014-05-07 20:44:51 +0900232 exynos_dp_write_byte_to_dpcd(dp, DP_LANE_COUNT_SET,
233 DP_LANE_COUNT_ENHANCED_FRAME_EN |
Jingoo Hane9474be2012-02-03 18:01:55 +0900234 DPCD_LANE_COUNT_SET(data));
235 else
Jingoo Han073ea2a2014-05-07 20:44:51 +0900236 exynos_dp_write_byte_to_dpcd(dp, DP_LANE_COUNT_SET,
Jingoo Hane9474be2012-02-03 18:01:55 +0900237 DPCD_LANE_COUNT_SET(data));
238}
239
240static int exynos_dp_is_enhanced_mode_available(struct exynos_dp_device *dp)
241{
242 u8 data;
243 int retval;
244
Jingoo Han073ea2a2014-05-07 20:44:51 +0900245 exynos_dp_read_byte_from_dpcd(dp, DP_MAX_LANE_COUNT, &data);
Jingoo Hane9474be2012-02-03 18:01:55 +0900246 retval = DPCD_ENHANCED_FRAME_CAP(data);
247
248 return retval;
249}
250
251static void exynos_dp_set_enhanced_mode(struct exynos_dp_device *dp)
252{
253 u8 data;
254
255 data = exynos_dp_is_enhanced_mode_available(dp);
256 exynos_dp_enable_rx_to_enhanced_mode(dp, data);
257 exynos_dp_enable_enhanced_mode(dp, data);
258}
259
260static void exynos_dp_training_pattern_dis(struct exynos_dp_device *dp)
261{
262 exynos_dp_set_training_pattern(dp, DP_NONE);
263
264 exynos_dp_write_byte_to_dpcd(dp,
Jingoo Han073ea2a2014-05-07 20:44:51 +0900265 DP_TRAINING_PATTERN_SET,
266 DP_TRAINING_PATTERN_DISABLE);
Jingoo Hane9474be2012-02-03 18:01:55 +0900267}
268
269static void exynos_dp_set_lane_lane_pre_emphasis(struct exynos_dp_device *dp,
270 int pre_emphasis, int lane)
271{
272 switch (lane) {
273 case 0:
274 exynos_dp_set_lane0_pre_emphasis(dp, pre_emphasis);
275 break;
276 case 1:
277 exynos_dp_set_lane1_pre_emphasis(dp, pre_emphasis);
278 break;
279
280 case 2:
281 exynos_dp_set_lane2_pre_emphasis(dp, pre_emphasis);
282 break;
283
284 case 3:
285 exynos_dp_set_lane3_pre_emphasis(dp, pre_emphasis);
286 break;
287 }
288}
289
Sean Paulace2d7f2012-10-31 23:21:00 +0000290static int exynos_dp_link_start(struct exynos_dp_device *dp)
Jingoo Hane9474be2012-02-03 18:01:55 +0900291{
Jingoo Hand5c0eed2012-07-19 13:52:59 +0900292 u8 buf[4];
Sean Paul49ce41f2012-10-31 23:21:00 +0000293 int lane, lane_count, pll_tries, retval;
Jingoo Hane9474be2012-02-03 18:01:55 +0900294
295 lane_count = dp->link_train.lane_count;
296
297 dp->link_train.lt_state = CLOCK_RECOVERY;
298 dp->link_train.eq_loop = 0;
299
300 for (lane = 0; lane < lane_count; lane++)
301 dp->link_train.cr_loop[lane] = 0;
302
Jingoo Hane9474be2012-02-03 18:01:55 +0900303 /* Set link rate and count as you want to establish*/
304 exynos_dp_set_link_bandwidth(dp, dp->link_train.link_rate);
305 exynos_dp_set_lane_count(dp, dp->link_train.lane_count);
306
307 /* Setup RX configuration */
308 buf[0] = dp->link_train.link_rate;
309 buf[1] = dp->link_train.lane_count;
Jingoo Han073ea2a2014-05-07 20:44:51 +0900310 retval = exynos_dp_write_bytes_to_dpcd(dp, DP_LINK_BW_SET,
Jingoo Hane9474be2012-02-03 18:01:55 +0900311 2, buf);
Sean Paulace2d7f2012-10-31 23:21:00 +0000312 if (retval)
313 return retval;
Jingoo Hane9474be2012-02-03 18:01:55 +0900314
315 /* Set TX pre-emphasis to minimum */
316 for (lane = 0; lane < lane_count; lane++)
317 exynos_dp_set_lane_lane_pre_emphasis(dp,
318 PRE_EMPHASIS_LEVEL_0, lane);
319
Sean Paul49ce41f2012-10-31 23:21:00 +0000320 /* Wait for PLL lock */
321 pll_tries = 0;
322 while (exynos_dp_get_pll_lock_status(dp) == PLL_UNLOCKED) {
323 if (pll_tries == DP_TIMEOUT_LOOP_COUNT) {
324 dev_err(dp->dev, "Wait for PLL lock timed out\n");
325 return -ETIMEDOUT;
326 }
327
328 pll_tries++;
329 usleep_range(90, 120);
330 }
331
Jingoo Hane9474be2012-02-03 18:01:55 +0900332 /* Set training pattern 1 */
333 exynos_dp_set_training_pattern(dp, TRAINING_PTN1);
334
335 /* Set RX training pattern */
Sean Paulfadec4b2012-10-31 23:21:00 +0000336 retval = exynos_dp_write_byte_to_dpcd(dp,
Jingoo Han073ea2a2014-05-07 20:44:51 +0900337 DP_TRAINING_PATTERN_SET,
338 DP_LINK_SCRAMBLING_DISABLE | DP_TRAINING_PATTERN_1);
Sean Paulfadec4b2012-10-31 23:21:00 +0000339 if (retval)
340 return retval;
Jingoo Hane9474be2012-02-03 18:01:55 +0900341
342 for (lane = 0; lane < lane_count; lane++)
Sonika Jindal0ded9252014-08-08 16:23:42 +0530343 buf[lane] = DP_TRAIN_PRE_EMPH_LEVEL_0 |
344 DP_TRAIN_VOLTAGE_SWING_LEVEL_0;
Sean Paulfadec4b2012-10-31 23:21:00 +0000345
Jingoo Han073ea2a2014-05-07 20:44:51 +0900346 retval = exynos_dp_write_bytes_to_dpcd(dp, DP_TRAINING_LANE0_SET,
Sean Paulfadec4b2012-10-31 23:21:00 +0000347 lane_count, buf);
Sean Paulace2d7f2012-10-31 23:21:00 +0000348
349 return retval;
Jingoo Hane9474be2012-02-03 18:01:55 +0900350}
351
Jingoo Hand5c0eed2012-07-19 13:52:59 +0900352static unsigned char exynos_dp_get_lane_status(u8 link_status[2], int lane)
Jingoo Hane9474be2012-02-03 18:01:55 +0900353{
354 int shift = (lane & 1) * 4;
355 u8 link_value = link_status[lane>>1];
356
357 return (link_value >> shift) & 0xf;
358}
359
Jingoo Hand5c0eed2012-07-19 13:52:59 +0900360static int exynos_dp_clock_recovery_ok(u8 link_status[2], int lane_count)
Jingoo Hane9474be2012-02-03 18:01:55 +0900361{
362 int lane;
363 u8 lane_status;
364
365 for (lane = 0; lane < lane_count; lane++) {
366 lane_status = exynos_dp_get_lane_status(link_status, lane);
Jingoo Han073ea2a2014-05-07 20:44:51 +0900367 if ((lane_status & DP_LANE_CR_DONE) == 0)
Jingoo Hane9474be2012-02-03 18:01:55 +0900368 return -EINVAL;
369 }
370 return 0;
371}
372
Sean Paulfadec4b2012-10-31 23:21:00 +0000373static int exynos_dp_channel_eq_ok(u8 link_status[2], u8 link_align,
374 int lane_count)
Jingoo Hane9474be2012-02-03 18:01:55 +0900375{
376 int lane;
Jingoo Hane9474be2012-02-03 18:01:55 +0900377 u8 lane_status;
378
Jingoo Han073ea2a2014-05-07 20:44:51 +0900379 if ((link_align & DP_INTERLANE_ALIGN_DONE) == 0)
Jingoo Hane9474be2012-02-03 18:01:55 +0900380 return -EINVAL;
381
382 for (lane = 0; lane < lane_count; lane++) {
Sean Paulfadec4b2012-10-31 23:21:00 +0000383 lane_status = exynos_dp_get_lane_status(link_status, lane);
Jingoo Han073ea2a2014-05-07 20:44:51 +0900384 lane_status &= DP_CHANNEL_EQ_BITS;
385 if (lane_status != DP_CHANNEL_EQ_BITS)
Jingoo Hane9474be2012-02-03 18:01:55 +0900386 return -EINVAL;
387 }
Jingoo Hand5c0eed2012-07-19 13:52:59 +0900388
Jingoo Hane9474be2012-02-03 18:01:55 +0900389 return 0;
390}
391
392static unsigned char exynos_dp_get_adjust_request_voltage(u8 adjust_request[2],
393 int lane)
394{
395 int shift = (lane & 1) * 4;
396 u8 link_value = adjust_request[lane>>1];
397
398 return (link_value >> shift) & 0x3;
399}
400
401static unsigned char exynos_dp_get_adjust_request_pre_emphasis(
402 u8 adjust_request[2],
403 int lane)
404{
405 int shift = (lane & 1) * 4;
406 u8 link_value = adjust_request[lane>>1];
407
408 return ((link_value >> shift) & 0xc) >> 2;
409}
410
411static void exynos_dp_set_lane_link_training(struct exynos_dp_device *dp,
412 u8 training_lane_set, int lane)
413{
414 switch (lane) {
415 case 0:
416 exynos_dp_set_lane0_link_training(dp, training_lane_set);
417 break;
418 case 1:
419 exynos_dp_set_lane1_link_training(dp, training_lane_set);
420 break;
421
422 case 2:
423 exynos_dp_set_lane2_link_training(dp, training_lane_set);
424 break;
425
426 case 3:
427 exynos_dp_set_lane3_link_training(dp, training_lane_set);
428 break;
429 }
430}
431
432static unsigned int exynos_dp_get_lane_link_training(
433 struct exynos_dp_device *dp,
434 int lane)
435{
436 u32 reg;
437
438 switch (lane) {
439 case 0:
440 reg = exynos_dp_get_lane0_link_training(dp);
441 break;
442 case 1:
443 reg = exynos_dp_get_lane1_link_training(dp);
444 break;
445 case 2:
446 reg = exynos_dp_get_lane2_link_training(dp);
447 break;
448 case 3:
449 reg = exynos_dp_get_lane3_link_training(dp);
450 break;
Jingoo Han64c43df2012-06-20 10:25:48 +0900451 default:
452 WARN_ON(1);
453 return 0;
Jingoo Hane9474be2012-02-03 18:01:55 +0900454 }
455
456 return reg;
457}
458
459static void exynos_dp_reduce_link_rate(struct exynos_dp_device *dp)
460{
Jingoo Hand5c0eed2012-07-19 13:52:59 +0900461 exynos_dp_training_pattern_dis(dp);
462 exynos_dp_set_enhanced_mode(dp);
Jingoo Hane9474be2012-02-03 18:01:55 +0900463
Jingoo Hand5c0eed2012-07-19 13:52:59 +0900464 dp->link_train.lt_state = FAILED;
Jingoo Hane9474be2012-02-03 18:01:55 +0900465}
466
Sean Paulfadec4b2012-10-31 23:21:00 +0000467static void exynos_dp_get_adjust_training_lane(struct exynos_dp_device *dp,
468 u8 adjust_request[2])
469{
470 int lane, lane_count;
471 u8 voltage_swing, pre_emphasis, training_lane;
472
473 lane_count = dp->link_train.lane_count;
474 for (lane = 0; lane < lane_count; lane++) {
475 voltage_swing = exynos_dp_get_adjust_request_voltage(
476 adjust_request, lane);
477 pre_emphasis = exynos_dp_get_adjust_request_pre_emphasis(
478 adjust_request, lane);
479 training_lane = DPCD_VOLTAGE_SWING_SET(voltage_swing) |
480 DPCD_PRE_EMPHASIS_SET(pre_emphasis);
481
482 if (voltage_swing == VOLTAGE_LEVEL_3)
Jingoo Han073ea2a2014-05-07 20:44:51 +0900483 training_lane |= DP_TRAIN_MAX_SWING_REACHED;
Sean Paulfadec4b2012-10-31 23:21:00 +0000484 if (pre_emphasis == PRE_EMPHASIS_LEVEL_3)
Jingoo Han073ea2a2014-05-07 20:44:51 +0900485 training_lane |= DP_TRAIN_MAX_PRE_EMPHASIS_REACHED;
Sean Paulfadec4b2012-10-31 23:21:00 +0000486
487 dp->link_train.training_lane[lane] = training_lane;
488 }
489}
490
Jingoo Hane9474be2012-02-03 18:01:55 +0900491static int exynos_dp_process_clock_recovery(struct exynos_dp_device *dp)
492{
Sean Paulace2d7f2012-10-31 23:21:00 +0000493 int lane, lane_count, retval;
Sean Paulfadec4b2012-10-31 23:21:00 +0000494 u8 voltage_swing, pre_emphasis, training_lane;
495 u8 link_status[2], adjust_request[2];
Jingoo Hane9474be2012-02-03 18:01:55 +0900496
Jingoo Hana2c81bc2012-07-18 18:50:59 +0900497 usleep_range(100, 101);
Jingoo Hane9474be2012-02-03 18:01:55 +0900498
Jingoo Hane9474be2012-02-03 18:01:55 +0900499 lane_count = dp->link_train.lane_count;
500
Sean Paulfadec4b2012-10-31 23:21:00 +0000501 retval = exynos_dp_read_bytes_from_dpcd(dp,
Jingoo Han073ea2a2014-05-07 20:44:51 +0900502 DP_LANE0_1_STATUS, 2, link_status);
Sean Paulfadec4b2012-10-31 23:21:00 +0000503 if (retval)
504 return retval;
505
506 retval = exynos_dp_read_bytes_from_dpcd(dp,
Jingoo Han073ea2a2014-05-07 20:44:51 +0900507 DP_ADJUST_REQUEST_LANE0_1, 2, adjust_request);
Sean Paulace2d7f2012-10-31 23:21:00 +0000508 if (retval)
509 return retval;
Jingoo Hand5c0eed2012-07-19 13:52:59 +0900510
Jingoo Hane9474be2012-02-03 18:01:55 +0900511 if (exynos_dp_clock_recovery_ok(link_status, lane_count) == 0) {
512 /* set training pattern 2 for EQ */
513 exynos_dp_set_training_pattern(dp, TRAINING_PTN2);
514
Sean Paulace2d7f2012-10-31 23:21:00 +0000515 retval = exynos_dp_write_byte_to_dpcd(dp,
Jingoo Han073ea2a2014-05-07 20:44:51 +0900516 DP_TRAINING_PATTERN_SET,
517 DP_LINK_SCRAMBLING_DISABLE |
518 DP_TRAINING_PATTERN_2);
Sean Paulace2d7f2012-10-31 23:21:00 +0000519 if (retval)
520 return retval;
Jingoo Hand5c0eed2012-07-19 13:52:59 +0900521
522 dev_info(dp->dev, "Link Training Clock Recovery success\n");
523 dp->link_train.lt_state = EQUALIZER_TRAINING;
524 } else {
525 for (lane = 0; lane < lane_count; lane++) {
526 training_lane = exynos_dp_get_lane_link_training(
527 dp, lane);
Jingoo Hand5c0eed2012-07-19 13:52:59 +0900528 voltage_swing = exynos_dp_get_adjust_request_voltage(
529 adjust_request, lane);
530 pre_emphasis = exynos_dp_get_adjust_request_pre_emphasis(
531 adjust_request, lane);
532
Sean Paulfadec4b2012-10-31 23:21:00 +0000533 if (DPCD_VOLTAGE_SWING_GET(training_lane) ==
534 voltage_swing &&
535 DPCD_PRE_EMPHASIS_GET(training_lane) ==
536 pre_emphasis)
Jingoo Hand5c0eed2012-07-19 13:52:59 +0900537 dp->link_train.cr_loop[lane]++;
Sean Paulfadec4b2012-10-31 23:21:00 +0000538
539 if (dp->link_train.cr_loop[lane] == MAX_CR_LOOP ||
540 voltage_swing == VOLTAGE_LEVEL_3 ||
541 pre_emphasis == PRE_EMPHASIS_LEVEL_3) {
542 dev_err(dp->dev, "CR Max reached (%d,%d,%d)\n",
543 dp->link_train.cr_loop[lane],
544 voltage_swing, pre_emphasis);
545 exynos_dp_reduce_link_rate(dp);
546 return -EIO;
Jingoo Hand5c0eed2012-07-19 13:52:59 +0900547 }
Jingoo Hane9474be2012-02-03 18:01:55 +0900548 }
549 }
550
Sean Paulfadec4b2012-10-31 23:21:00 +0000551 exynos_dp_get_adjust_training_lane(dp, adjust_request);
Jingoo Hand5c0eed2012-07-19 13:52:59 +0900552
Sean Paulfadec4b2012-10-31 23:21:00 +0000553 for (lane = 0; lane < lane_count; lane++)
554 exynos_dp_set_lane_link_training(dp,
555 dp->link_train.training_lane[lane], lane);
556
557 retval = exynos_dp_write_bytes_to_dpcd(dp,
Jingoo Han073ea2a2014-05-07 20:44:51 +0900558 DP_TRAINING_LANE0_SET, lane_count,
Sean Paulfadec4b2012-10-31 23:21:00 +0000559 dp->link_train.training_lane);
560 if (retval)
561 return retval;
562
563 return retval;
Jingoo Hane9474be2012-02-03 18:01:55 +0900564}
565
566static int exynos_dp_process_equalizer_training(struct exynos_dp_device *dp)
567{
Sean Paulace2d7f2012-10-31 23:21:00 +0000568 int lane, lane_count, retval;
Jingoo Hane9474be2012-02-03 18:01:55 +0900569 u32 reg;
Sean Paulfadec4b2012-10-31 23:21:00 +0000570 u8 link_align, link_status[2], adjust_request[2];
Jingoo Hane9474be2012-02-03 18:01:55 +0900571
Jingoo Hana2c81bc2012-07-18 18:50:59 +0900572 usleep_range(400, 401);
Jingoo Hane9474be2012-02-03 18:01:55 +0900573
Jingoo Hane9474be2012-02-03 18:01:55 +0900574 lane_count = dp->link_train.lane_count;
575
Sean Paulfadec4b2012-10-31 23:21:00 +0000576 retval = exynos_dp_read_bytes_from_dpcd(dp,
Jingoo Han073ea2a2014-05-07 20:44:51 +0900577 DP_LANE0_1_STATUS, 2, link_status);
Sean Paulace2d7f2012-10-31 23:21:00 +0000578 if (retval)
579 return retval;
Jingoo Hand5c0eed2012-07-19 13:52:59 +0900580
Sean Paulfadec4b2012-10-31 23:21:00 +0000581 if (exynos_dp_clock_recovery_ok(link_status, lane_count)) {
582 exynos_dp_reduce_link_rate(dp);
583 return -EIO;
Jingoo Hane9474be2012-02-03 18:01:55 +0900584 }
585
Sean Paulfadec4b2012-10-31 23:21:00 +0000586 retval = exynos_dp_read_bytes_from_dpcd(dp,
Jingoo Han073ea2a2014-05-07 20:44:51 +0900587 DP_ADJUST_REQUEST_LANE0_1, 2, adjust_request);
Sean Paulfadec4b2012-10-31 23:21:00 +0000588 if (retval)
589 return retval;
Jingoo Hand5c0eed2012-07-19 13:52:59 +0900590
Sean Paulfadec4b2012-10-31 23:21:00 +0000591 retval = exynos_dp_read_byte_from_dpcd(dp,
Jingoo Han073ea2a2014-05-07 20:44:51 +0900592 DP_LANE_ALIGN_STATUS_UPDATED, &link_align);
Sean Paulfadec4b2012-10-31 23:21:00 +0000593 if (retval)
594 return retval;
595
596 exynos_dp_get_adjust_training_lane(dp, adjust_request);
597
598 if (!exynos_dp_channel_eq_ok(link_status, link_align, lane_count)) {
599 /* traing pattern Set to Normal */
600 exynos_dp_training_pattern_dis(dp);
601
602 dev_info(dp->dev, "Link Training success!\n");
603
604 exynos_dp_get_link_bandwidth(dp, &reg);
605 dp->link_train.link_rate = reg;
606 dev_dbg(dp->dev, "final bandwidth = %.2x\n",
607 dp->link_train.link_rate);
608
609 exynos_dp_get_lane_count(dp, &reg);
610 dp->link_train.lane_count = reg;
611 dev_dbg(dp->dev, "final lane count = %.2x\n",
612 dp->link_train.lane_count);
613
614 /* set enhanced mode if available */
615 exynos_dp_set_enhanced_mode(dp);
616 dp->link_train.lt_state = FINISHED;
617
618 return 0;
619 }
620
621 /* not all locked */
622 dp->link_train.eq_loop++;
623
624 if (dp->link_train.eq_loop > MAX_EQ_LOOP) {
625 dev_err(dp->dev, "EQ Max loop\n");
626 exynos_dp_reduce_link_rate(dp);
627 return -EIO;
628 }
629
630 for (lane = 0; lane < lane_count; lane++)
631 exynos_dp_set_lane_link_training(dp,
632 dp->link_train.training_lane[lane], lane);
633
Jingoo Han073ea2a2014-05-07 20:44:51 +0900634 retval = exynos_dp_write_bytes_to_dpcd(dp, DP_TRAINING_LANE0_SET,
Sean Paulfadec4b2012-10-31 23:21:00 +0000635 lane_count, dp->link_train.training_lane);
636
637 return retval;
Jingoo Hane9474be2012-02-03 18:01:55 +0900638}
639
640static void exynos_dp_get_max_rx_bandwidth(struct exynos_dp_device *dp,
Jingoo Hand5c0eed2012-07-19 13:52:59 +0900641 u8 *bandwidth)
Jingoo Hane9474be2012-02-03 18:01:55 +0900642{
643 u8 data;
644
645 /*
646 * For DP rev.1.1, Maximum link rate of Main Link lanes
647 * 0x06 = 1.62 Gbps, 0x0a = 2.7 Gbps
648 */
Jingoo Han073ea2a2014-05-07 20:44:51 +0900649 exynos_dp_read_byte_from_dpcd(dp, DP_MAX_LINK_RATE, &data);
Jingoo Hane9474be2012-02-03 18:01:55 +0900650 *bandwidth = data;
651}
652
653static void exynos_dp_get_max_rx_lane_count(struct exynos_dp_device *dp,
Jingoo Hand5c0eed2012-07-19 13:52:59 +0900654 u8 *lane_count)
Jingoo Hane9474be2012-02-03 18:01:55 +0900655{
656 u8 data;
657
658 /*
659 * For DP rev.1.1, Maximum number of Main Link lanes
660 * 0x01 = 1 lane, 0x02 = 2 lanes, 0x04 = 4 lanes
661 */
Jingoo Han073ea2a2014-05-07 20:44:51 +0900662 exynos_dp_read_byte_from_dpcd(dp, DP_MAX_LANE_COUNT, &data);
Jingoo Hane9474be2012-02-03 18:01:55 +0900663 *lane_count = DPCD_MAX_LANE_COUNT(data);
664}
665
666static void exynos_dp_init_training(struct exynos_dp_device *dp,
667 enum link_lane_count_type max_lane,
668 enum link_rate_type max_rate)
669{
670 /*
671 * MACRO_RST must be applied after the PLL_LOCK to avoid
672 * the DP inter pair skew issue for at least 10 us
673 */
674 exynos_dp_reset_macro(dp);
675
676 /* Initialize by reading RX's DPCD */
677 exynos_dp_get_max_rx_bandwidth(dp, &dp->link_train.link_rate);
678 exynos_dp_get_max_rx_lane_count(dp, &dp->link_train.lane_count);
679
680 if ((dp->link_train.link_rate != LINK_RATE_1_62GBPS) &&
681 (dp->link_train.link_rate != LINK_RATE_2_70GBPS)) {
682 dev_err(dp->dev, "Rx Max Link Rate is abnormal :%x !\n",
683 dp->link_train.link_rate);
684 dp->link_train.link_rate = LINK_RATE_1_62GBPS;
685 }
686
687 if (dp->link_train.lane_count == 0) {
688 dev_err(dp->dev, "Rx Max Lane count is abnormal :%x !\n",
689 dp->link_train.lane_count);
690 dp->link_train.lane_count = (u8)LANE_COUNT1;
691 }
692
693 /* Setup TX lane count & rate */
694 if (dp->link_train.lane_count > max_lane)
695 dp->link_train.lane_count = max_lane;
696 if (dp->link_train.link_rate > max_rate)
697 dp->link_train.link_rate = max_rate;
698
699 /* All DP analog module power up */
700 exynos_dp_set_analog_power_down(dp, POWER_ALL, 0);
701}
702
703static int exynos_dp_sw_link_training(struct exynos_dp_device *dp)
704{
Sean Paulace2d7f2012-10-31 23:21:00 +0000705 int retval = 0, training_finished = 0;
Jingoo Hane9474be2012-02-03 18:01:55 +0900706
707 dp->link_train.lt_state = START;
708
709 /* Process here */
Sean Paulace2d7f2012-10-31 23:21:00 +0000710 while (!retval && !training_finished) {
Jingoo Hane9474be2012-02-03 18:01:55 +0900711 switch (dp->link_train.lt_state) {
712 case START:
Sean Paulace2d7f2012-10-31 23:21:00 +0000713 retval = exynos_dp_link_start(dp);
714 if (retval)
715 dev_err(dp->dev, "LT link start failed!\n");
Jingoo Hane9474be2012-02-03 18:01:55 +0900716 break;
717 case CLOCK_RECOVERY:
Jingoo Hand5c0eed2012-07-19 13:52:59 +0900718 retval = exynos_dp_process_clock_recovery(dp);
719 if (retval)
720 dev_err(dp->dev, "LT CR failed!\n");
Jingoo Hane9474be2012-02-03 18:01:55 +0900721 break;
722 case EQUALIZER_TRAINING:
Jingoo Hand5c0eed2012-07-19 13:52:59 +0900723 retval = exynos_dp_process_equalizer_training(dp);
724 if (retval)
725 dev_err(dp->dev, "LT EQ failed!\n");
Jingoo Hane9474be2012-02-03 18:01:55 +0900726 break;
727 case FINISHED:
728 training_finished = 1;
729 break;
730 case FAILED:
731 return -EREMOTEIO;
732 }
733 }
Sean Paulace2d7f2012-10-31 23:21:00 +0000734 if (retval)
735 dev_err(dp->dev, "eDP link training failed (%d)\n", retval);
Jingoo Hane9474be2012-02-03 18:01:55 +0900736
737 return retval;
738}
739
740static int exynos_dp_set_link_train(struct exynos_dp_device *dp,
741 u32 count,
742 u32 bwtype)
743{
744 int i;
745 int retval;
746
747 for (i = 0; i < DP_TIMEOUT_LOOP_COUNT; i++) {
748 exynos_dp_init_training(dp, count, bwtype);
749 retval = exynos_dp_sw_link_training(dp);
750 if (retval == 0)
751 break;
752
Jingoo Hana2c81bc2012-07-18 18:50:59 +0900753 usleep_range(100, 110);
Jingoo Hane9474be2012-02-03 18:01:55 +0900754 }
755
756 return retval;
757}
758
Ajay Kumar3fcb6eb2012-11-09 14:05:06 +0900759static int exynos_dp_config_video(struct exynos_dp_device *dp)
Jingoo Hane9474be2012-02-03 18:01:55 +0900760{
761 int retval = 0;
762 int timeout_loop = 0;
763 int done_count = 0;
764
Ajay Kumar3fcb6eb2012-11-09 14:05:06 +0900765 exynos_dp_config_video_slave_mode(dp);
Jingoo Hane9474be2012-02-03 18:01:55 +0900766
Ajay Kumar3fcb6eb2012-11-09 14:05:06 +0900767 exynos_dp_set_video_color_format(dp);
Jingoo Hane9474be2012-02-03 18:01:55 +0900768
769 if (exynos_dp_get_pll_lock_status(dp) == PLL_UNLOCKED) {
770 dev_err(dp->dev, "PLL is not locked yet.\n");
771 return -EINVAL;
772 }
773
774 for (;;) {
775 timeout_loop++;
776 if (exynos_dp_is_slave_video_stream_clock_on(dp) == 0)
777 break;
778 if (DP_TIMEOUT_LOOP_COUNT < timeout_loop) {
779 dev_err(dp->dev, "Timeout of video streamclk ok\n");
780 return -ETIMEDOUT;
781 }
782
Jingoo Hana2c81bc2012-07-18 18:50:59 +0900783 usleep_range(1, 2);
Jingoo Hane9474be2012-02-03 18:01:55 +0900784 }
785
786 /* Set to use the register calculated M/N video */
787 exynos_dp_set_video_cr_mn(dp, CALCULATED_M, 0, 0);
788
789 /* For video bist, Video timing must be generated by register */
790 exynos_dp_set_video_timing_mode(dp, VIDEO_TIMING_FROM_CAPTURE);
791
792 /* Disable video mute */
793 exynos_dp_enable_video_mute(dp, 0);
794
795 /* Configure video slave mode */
796 exynos_dp_enable_video_master(dp, 0);
797
Jingoo Hane9474be2012-02-03 18:01:55 +0900798 timeout_loop = 0;
799
800 for (;;) {
801 timeout_loop++;
802 if (exynos_dp_is_video_stream_on(dp) == 0) {
803 done_count++;
804 if (done_count > 10)
805 break;
806 } else if (done_count) {
807 done_count = 0;
808 }
809 if (DP_TIMEOUT_LOOP_COUNT < timeout_loop) {
810 dev_err(dp->dev, "Timeout of video streamclk ok\n");
811 return -ETIMEDOUT;
812 }
813
Jingoo Hana2c81bc2012-07-18 18:50:59 +0900814 usleep_range(1000, 1001);
Jingoo Hane9474be2012-02-03 18:01:55 +0900815 }
816
817 if (retval != 0)
818 dev_err(dp->dev, "Video stream is not detected!\n");
819
820 return retval;
821}
822
823static void exynos_dp_enable_scramble(struct exynos_dp_device *dp, bool enable)
824{
825 u8 data;
826
827 if (enable) {
828 exynos_dp_enable_scrambling(dp);
829
830 exynos_dp_read_byte_from_dpcd(dp,
Jingoo Han073ea2a2014-05-07 20:44:51 +0900831 DP_TRAINING_PATTERN_SET,
Jingoo Hane9474be2012-02-03 18:01:55 +0900832 &data);
833 exynos_dp_write_byte_to_dpcd(dp,
Jingoo Han073ea2a2014-05-07 20:44:51 +0900834 DP_TRAINING_PATTERN_SET,
835 (u8)(data & ~DP_LINK_SCRAMBLING_DISABLE));
Jingoo Hane9474be2012-02-03 18:01:55 +0900836 } else {
837 exynos_dp_disable_scrambling(dp);
838
839 exynos_dp_read_byte_from_dpcd(dp,
Jingoo Han073ea2a2014-05-07 20:44:51 +0900840 DP_TRAINING_PATTERN_SET,
Jingoo Hane9474be2012-02-03 18:01:55 +0900841 &data);
842 exynos_dp_write_byte_to_dpcd(dp,
Jingoo Han073ea2a2014-05-07 20:44:51 +0900843 DP_TRAINING_PATTERN_SET,
844 (u8)(data | DP_LINK_SCRAMBLING_DISABLE));
Jingoo Hane9474be2012-02-03 18:01:55 +0900845 }
846}
847
848static irqreturn_t exynos_dp_irq_handler(int irq, void *arg)
849{
850 struct exynos_dp_device *dp = arg;
851
Sean Paulc30ffb92012-11-01 19:13:46 +0900852 enum dp_irq_type irq_type;
853
854 irq_type = exynos_dp_get_irq_type(dp);
855 switch (irq_type) {
856 case DP_IRQ_TYPE_HP_CABLE_IN:
857 dev_dbg(dp->dev, "Received irq - cable in\n");
858 schedule_work(&dp->hotplug_work);
859 exynos_dp_clear_hotplug_interrupts(dp);
860 break;
861 case DP_IRQ_TYPE_HP_CABLE_OUT:
862 dev_dbg(dp->dev, "Received irq - cable out\n");
863 exynos_dp_clear_hotplug_interrupts(dp);
864 break;
865 case DP_IRQ_TYPE_HP_CHANGE:
866 /*
867 * We get these change notifications once in a while, but there
868 * is nothing we can do with them. Just ignore it for now and
869 * only handle cable changes.
870 */
871 dev_dbg(dp->dev, "Received irq - hotplug change; ignoring.\n");
872 exynos_dp_clear_hotplug_interrupts(dp);
873 break;
874 default:
875 dev_err(dp->dev, "Received irq - unknown type!\n");
876 break;
877 }
Jingoo Hane9474be2012-02-03 18:01:55 +0900878 return IRQ_HANDLED;
879}
880
Sean Paul784fa9a2012-11-09 13:55:08 +0900881static void exynos_dp_hotplug(struct work_struct *work)
882{
883 struct exynos_dp_device *dp;
Sean Paul784fa9a2012-11-09 13:55:08 +0900884
885 dp = container_of(work, struct exynos_dp_device, hotplug_work);
886
Ajay Kumar4deabfa2014-07-31 23:12:13 +0530887 if (dp->drm_dev)
888 drm_helper_hpd_irq_event(dp->drm_dev);
889}
890
Gustavo Padovancf67cc92015-08-11 17:38:06 +0900891static void exynos_dp_commit(struct exynos_drm_encoder *encoder)
Ajay Kumar4deabfa2014-07-31 23:12:13 +0530892{
Gustavo Padovancf67cc92015-08-11 17:38:06 +0900893 struct exynos_dp_device *dp = encoder_to_dp(encoder);
Ajay Kumar4deabfa2014-07-31 23:12:13 +0530894 int ret;
895
Ajay Kumar5f1dcd82014-07-31 23:12:14 +0530896 /* Keep the panel disabled while we configure video */
897 if (dp->panel) {
898 if (drm_panel_disable(dp->panel))
899 DRM_ERROR("failed to disable the panel\n");
900 }
901
Sean Paul784fa9a2012-11-09 13:55:08 +0900902 ret = exynos_dp_detect_hpd(dp);
903 if (ret) {
Sean Paulc30ffb92012-11-01 19:13:46 +0900904 /* Cable has been disconnected, we're done */
Sean Paul784fa9a2012-11-09 13:55:08 +0900905 return;
906 }
907
908 ret = exynos_dp_handle_edid(dp);
909 if (ret) {
910 dev_err(dp->dev, "unable to handle edid\n");
911 return;
912 }
913
914 ret = exynos_dp_set_link_train(dp, dp->video_info->lane_count,
915 dp->video_info->link_rate);
916 if (ret) {
917 dev_err(dp->dev, "unable to do link train\n");
918 return;
919 }
920
921 exynos_dp_enable_scramble(dp, 1);
922 exynos_dp_enable_rx_to_enhanced_mode(dp, 1);
923 exynos_dp_enable_enhanced_mode(dp, 1);
924
925 exynos_dp_set_lane_count(dp, dp->video_info->lane_count);
926 exynos_dp_set_link_bandwidth(dp, dp->video_info->link_rate);
927
928 exynos_dp_init_video(dp);
Ajay Kumar3fcb6eb2012-11-09 14:05:06 +0900929 ret = exynos_dp_config_video(dp);
Sean Paul784fa9a2012-11-09 13:55:08 +0900930 if (ret)
931 dev_err(dp->dev, "unable to config video\n");
Ajay Kumar5f1dcd82014-07-31 23:12:14 +0530932
933 /* Safe to enable the panel now */
934 if (dp->panel) {
935 if (drm_panel_enable(dp->panel))
936 DRM_ERROR("failed to enable the panel\n");
937 }
Gustavo Padovan07fd6e12015-08-05 20:24:18 -0300938
939 /* Enable video */
940 exynos_dp_start_video(dp);
Sean Paul784fa9a2012-11-09 13:55:08 +0900941}
942
Sean Paulcaa5d1e2014-01-30 16:19:30 -0500943static enum drm_connector_status exynos_dp_detect(
944 struct drm_connector *connector, bool force)
Sean Paul1417f102014-01-30 16:19:23 -0500945{
Sean Paulcaa5d1e2014-01-30 16:19:30 -0500946 return connector_status_connected;
Sean Paul1417f102014-01-30 16:19:23 -0500947}
948
Sean Paulcaa5d1e2014-01-30 16:19:30 -0500949static void exynos_dp_connector_destroy(struct drm_connector *connector)
950{
Andrzej Hajda7c61b1e2014-09-09 15:16:12 +0200951 drm_connector_unregister(connector);
952 drm_connector_cleanup(connector);
Sean Paulcaa5d1e2014-01-30 16:19:30 -0500953}
954
955static struct drm_connector_funcs exynos_dp_connector_funcs = {
Gustavo Padovan63498e32015-06-01 12:04:53 -0300956 .dpms = drm_atomic_helper_connector_dpms,
Sean Paulcaa5d1e2014-01-30 16:19:30 -0500957 .fill_modes = drm_helper_probe_single_connector_modes,
958 .detect = exynos_dp_detect,
959 .destroy = exynos_dp_connector_destroy,
Gustavo Padovan4ea95262015-06-01 12:04:44 -0300960 .reset = drm_atomic_helper_connector_reset,
961 .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
962 .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
Sean Paulcaa5d1e2014-01-30 16:19:30 -0500963};
964
965static int exynos_dp_get_modes(struct drm_connector *connector)
966{
967 struct exynos_dp_device *dp = ctx_from_connector(connector);
968 struct drm_display_mode *mode;
969
Ajay Kumar5f1dcd82014-07-31 23:12:14 +0530970 if (dp->panel)
971 return drm_panel_get_modes(dp->panel);
972
Sean Paulcaa5d1e2014-01-30 16:19:30 -0500973 mode = drm_mode_create(connector->dev);
974 if (!mode) {
975 DRM_ERROR("failed to create a new display mode.\n");
976 return 0;
977 }
978
Ajay Kumar5f1dcd82014-07-31 23:12:14 +0530979 drm_display_mode_from_videomode(&dp->priv.vm, mode);
980 mode->width_mm = dp->priv.width_mm;
981 mode->height_mm = dp->priv.height_mm;
Sean Paulcaa5d1e2014-01-30 16:19:30 -0500982 connector->display_info.width_mm = mode->width_mm;
983 connector->display_info.height_mm = mode->height_mm;
984
985 mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
986 drm_mode_set_name(mode);
987 drm_mode_probed_add(connector, mode);
988
989 return 1;
990}
991
Sean Paulcaa5d1e2014-01-30 16:19:30 -0500992static struct drm_encoder *exynos_dp_best_encoder(
993 struct drm_connector *connector)
994{
995 struct exynos_dp_device *dp = ctx_from_connector(connector);
996
Gustavo Padovancf67cc92015-08-11 17:38:06 +0900997 return &dp->encoder.base;
Sean Paulcaa5d1e2014-01-30 16:19:30 -0500998}
999
1000static struct drm_connector_helper_funcs exynos_dp_connector_helper_funcs = {
1001 .get_modes = exynos_dp_get_modes,
Sean Paulcaa5d1e2014-01-30 16:19:30 -05001002 .best_encoder = exynos_dp_best_encoder,
1003};
1004
Sean Paul1634ba22014-02-24 19:20:15 +09001005/* returns the number of bridges attached */
Ajay Kumar80185562015-01-20 22:08:46 +05301006static int exynos_drm_attach_lcd_bridge(struct exynos_dp_device *dp,
Sean Paul1634ba22014-02-24 19:20:15 +09001007 struct drm_encoder *encoder)
1008{
Ajay Kumar80185562015-01-20 22:08:46 +05301009 int ret;
1010
1011 encoder->bridge = dp->bridge;
1012 dp->bridge->encoder = encoder;
1013 ret = drm_bridge_attach(encoder->dev, dp->bridge);
1014 if (ret) {
1015 DRM_ERROR("Failed to attach bridge to drm\n");
1016 return ret;
1017 }
1018
Sean Paul1634ba22014-02-24 19:20:15 +09001019 return 0;
1020}
1021
Gustavo Padovancf67cc92015-08-11 17:38:06 +09001022static int exynos_dp_create_connector(struct exynos_drm_encoder *exynos_encoder)
Sean Paul1417f102014-01-30 16:19:23 -05001023{
Gustavo Padovancf67cc92015-08-11 17:38:06 +09001024 struct exynos_dp_device *dp = encoder_to_dp(exynos_encoder);
1025 struct drm_encoder *encoder = &exynos_encoder->base;
Sean Paulcaa5d1e2014-01-30 16:19:30 -05001026 struct drm_connector *connector = &dp->connector;
1027 int ret;
1028
Sean Paul1634ba22014-02-24 19:20:15 +09001029 /* Pre-empt DP connector creation if there's a bridge */
Ajay Kumar80185562015-01-20 22:08:46 +05301030 if (dp->bridge) {
1031 ret = exynos_drm_attach_lcd_bridge(dp, encoder);
1032 if (!ret)
1033 return 0;
1034 }
Sean Paul1634ba22014-02-24 19:20:15 +09001035
Sean Paulcaa5d1e2014-01-30 16:19:30 -05001036 connector->polled = DRM_CONNECTOR_POLL_HPD;
1037
1038 ret = drm_connector_init(dp->drm_dev, connector,
1039 &exynos_dp_connector_funcs, DRM_MODE_CONNECTOR_eDP);
1040 if (ret) {
1041 DRM_ERROR("Failed to initialize connector with drm\n");
1042 return ret;
1043 }
1044
1045 drm_connector_helper_add(connector, &exynos_dp_connector_helper_funcs);
Thomas Wood34ea3d32014-05-29 16:57:41 +01001046 drm_connector_register(connector);
Sean Paulcaa5d1e2014-01-30 16:19:30 -05001047 drm_mode_connector_attach_encoder(connector, encoder);
1048
Ajay Kumar5f1dcd82014-07-31 23:12:14 +05301049 if (dp->panel)
1050 ret = drm_panel_attach(dp->panel, &dp->connector);
1051
1052 return ret;
Sean Paul1417f102014-01-30 16:19:23 -05001053}
1054
Gustavo Padovancf67cc92015-08-11 17:38:06 +09001055static void exynos_dp_enable(struct exynos_drm_encoder *encoder)
Sean Paul12f5ad62014-01-30 16:19:25 -05001056{
Gustavo Padovancf67cc92015-08-11 17:38:06 +09001057 struct exynos_dp_device *dp = encoder_to_dp(encoder);
Krzysztof Kozlowski48107d72015-05-07 09:04:44 +09001058 struct exynos_drm_crtc *crtc = dp_to_crtc(dp);
1059
Sean Paul12f5ad62014-01-30 16:19:25 -05001060 if (dp->dpms_mode == DRM_MODE_DPMS_ON)
1061 return;
1062
Ajay Kumar5f1dcd82014-07-31 23:12:14 +05301063 if (dp->panel) {
1064 if (drm_panel_prepare(dp->panel)) {
1065 DRM_ERROR("failed to setup the panel\n");
1066 return;
1067 }
1068 }
1069
Krzysztof Kozlowski48107d72015-05-07 09:04:44 +09001070 if (crtc->ops->clock_enable)
1071 crtc->ops->clock_enable(dp_to_crtc(dp), true);
Krzysztof Kozlowski1c363c72015-04-07 22:28:50 +09001072
Sean Paul12f5ad62014-01-30 16:19:25 -05001073 clk_prepare_enable(dp->clock);
Gustavo Padovanb6f3c362015-08-05 20:24:13 -03001074 phy_power_on(dp->phy);
Sean Paul12f5ad62014-01-30 16:19:25 -05001075 exynos_dp_init_dp(dp);
1076 enable_irq(dp->irq);
Gustavo Padovancf67cc92015-08-11 17:38:06 +09001077 exynos_dp_commit(&dp->encoder);
Gustavo Padovanb6595dc2015-08-10 21:37:04 -03001078
1079 dp->dpms_mode = DRM_MODE_DPMS_ON;
Sean Paul12f5ad62014-01-30 16:19:25 -05001080}
1081
Gustavo Padovancf67cc92015-08-11 17:38:06 +09001082static void exynos_dp_disable(struct exynos_drm_encoder *encoder)
Sean Paul12f5ad62014-01-30 16:19:25 -05001083{
Gustavo Padovancf67cc92015-08-11 17:38:06 +09001084 struct exynos_dp_device *dp = encoder_to_dp(encoder);
Krzysztof Kozlowski48107d72015-05-07 09:04:44 +09001085 struct exynos_drm_crtc *crtc = dp_to_crtc(dp);
1086
Sean Paul12f5ad62014-01-30 16:19:25 -05001087 if (dp->dpms_mode != DRM_MODE_DPMS_ON)
1088 return;
1089
Ajay Kumar5f1dcd82014-07-31 23:12:14 +05301090 if (dp->panel) {
1091 if (drm_panel_disable(dp->panel)) {
1092 DRM_ERROR("failed to disable the panel\n");
1093 return;
1094 }
1095 }
1096
Sean Paul12f5ad62014-01-30 16:19:25 -05001097 disable_irq(dp->irq);
1098 flush_work(&dp->hotplug_work);
Gustavo Padovanb6f3c362015-08-05 20:24:13 -03001099 phy_power_off(dp->phy);
Sean Paul12f5ad62014-01-30 16:19:25 -05001100 clk_disable_unprepare(dp->clock);
Ajay Kumar5f1dcd82014-07-31 23:12:14 +05301101
Krzysztof Kozlowski48107d72015-05-07 09:04:44 +09001102 if (crtc->ops->clock_enable)
1103 crtc->ops->clock_enable(dp_to_crtc(dp), false);
Krzysztof Kozlowski1c363c72015-04-07 22:28:50 +09001104
Ajay Kumar5f1dcd82014-07-31 23:12:14 +05301105 if (dp->panel) {
1106 if (drm_panel_unprepare(dp->panel))
1107 DRM_ERROR("failed to turnoff the panel\n");
1108 }
Sean Paul12f5ad62014-01-30 16:19:25 -05001109
Gustavo Padovanb6595dc2015-08-10 21:37:04 -03001110 dp->dpms_mode = DRM_MODE_DPMS_OFF;
Sean Paul12f5ad62014-01-30 16:19:25 -05001111}
1112
Gustavo Padovancf67cc92015-08-11 17:38:06 +09001113static struct exynos_drm_encoder_ops exynos_dp_encoder_ops = {
Sean Paulcaa5d1e2014-01-30 16:19:30 -05001114 .create_connector = exynos_dp_create_connector,
Gustavo Padovanb6595dc2015-08-10 21:37:04 -03001115 .enable = exynos_dp_enable,
1116 .disable = exynos_dp_disable,
Sean Paul1417f102014-01-30 16:19:23 -05001117};
1118
Jingoo Hanf9b1e012013-10-16 21:58:15 +05301119static struct video_info *exynos_dp_dt_parse_pdata(struct device *dev)
Ajay Kumarc4e235c2012-10-13 05:48:00 +09001120{
1121 struct device_node *dp_node = dev->of_node;
Ajay Kumarc4e235c2012-10-13 05:48:00 +09001122 struct video_info *dp_video_config;
1123
Ajay Kumarc4e235c2012-10-13 05:48:00 +09001124 dp_video_config = devm_kzalloc(dev,
1125 sizeof(*dp_video_config), GFP_KERNEL);
Jingoo Han7a5b68272014-04-17 19:08:14 +09001126 if (!dp_video_config)
Ajay Kumarc4e235c2012-10-13 05:48:00 +09001127 return ERR_PTR(-ENOMEM);
Ajay Kumarc4e235c2012-10-13 05:48:00 +09001128
1129 dp_video_config->h_sync_polarity =
1130 of_property_read_bool(dp_node, "hsync-active-high");
1131
1132 dp_video_config->v_sync_polarity =
1133 of_property_read_bool(dp_node, "vsync-active-high");
1134
1135 dp_video_config->interlaced =
1136 of_property_read_bool(dp_node, "interlaced");
1137
1138 if (of_property_read_u32(dp_node, "samsung,color-space",
1139 &dp_video_config->color_space)) {
1140 dev_err(dev, "failed to get color-space\n");
1141 return ERR_PTR(-EINVAL);
1142 }
1143
1144 if (of_property_read_u32(dp_node, "samsung,dynamic-range",
1145 &dp_video_config->dynamic_range)) {
1146 dev_err(dev, "failed to get dynamic-range\n");
1147 return ERR_PTR(-EINVAL);
1148 }
1149
1150 if (of_property_read_u32(dp_node, "samsung,ycbcr-coeff",
1151 &dp_video_config->ycbcr_coeff)) {
1152 dev_err(dev, "failed to get ycbcr-coeff\n");
1153 return ERR_PTR(-EINVAL);
1154 }
1155
1156 if (of_property_read_u32(dp_node, "samsung,color-depth",
1157 &dp_video_config->color_depth)) {
1158 dev_err(dev, "failed to get color-depth\n");
1159 return ERR_PTR(-EINVAL);
1160 }
1161
1162 if (of_property_read_u32(dp_node, "samsung,link-rate",
1163 &dp_video_config->link_rate)) {
1164 dev_err(dev, "failed to get link-rate\n");
1165 return ERR_PTR(-EINVAL);
1166 }
1167
1168 if (of_property_read_u32(dp_node, "samsung,lane-count",
1169 &dp_video_config->lane_count)) {
1170 dev_err(dev, "failed to get lane-count\n");
1171 return ERR_PTR(-EINVAL);
1172 }
1173
Jingoo Hanf9b1e012013-10-16 21:58:15 +05301174 return dp_video_config;
Ajay Kumarc4e235c2012-10-13 05:48:00 +09001175}
1176
Sean Paul1417f102014-01-30 16:19:23 -05001177static int exynos_dp_dt_parse_panel(struct exynos_dp_device *dp)
1178{
1179 int ret;
1180
Ajay Kumar5f1dcd82014-07-31 23:12:14 +05301181 ret = of_get_videomode(dp->dev->of_node, &dp->priv.vm,
Sean Paul1417f102014-01-30 16:19:23 -05001182 OF_USE_NATIVE_MODE);
1183 if (ret) {
1184 DRM_ERROR("failed: of_get_videomode() : %d\n", ret);
1185 return ret;
1186 }
1187 return 0;
1188}
1189
Inki Daef37cd5e2014-05-09 14:25:20 +09001190static int exynos_dp_bind(struct device *dev, struct device *master, void *data)
Jingoo Hane9474be2012-02-03 18:01:55 +09001191{
Andrzej Hajda1df6e5f2014-11-17 09:54:24 +01001192 struct exynos_dp_device *dp = dev_get_drvdata(dev);
Inki Daef37cd5e2014-05-09 14:25:20 +09001193 struct platform_device *pdev = to_platform_device(dev);
1194 struct drm_device *drm_dev = data;
Jingoo Hane9474be2012-02-03 18:01:55 +09001195 struct resource *res;
Andrew Brestickerb8b52472014-04-22 04:09:10 +05301196 unsigned int irq_flags;
Jingoo Hane9474be2012-02-03 18:01:55 +09001197 int ret = 0;
1198
Jingoo Hane9474be2012-02-03 18:01:55 +09001199 dp->dev = &pdev->dev;
Sean Paul12f5ad62014-01-30 16:19:25 -05001200 dp->dpms_mode = DRM_MODE_DPMS_OFF;
Jingoo Hane9474be2012-02-03 18:01:55 +09001201
Jingoo Hanf9b1e012013-10-16 21:58:15 +05301202 dp->video_info = exynos_dp_dt_parse_pdata(&pdev->dev);
1203 if (IS_ERR(dp->video_info))
1204 return PTR_ERR(dp->video_info);
Ajay Kumarc4e235c2012-10-13 05:48:00 +09001205
Vivek Gautamb128aef2014-11-12 15:12:10 +05301206 dp->phy = devm_phy_get(dp->dev, "dp");
1207 if (IS_ERR(dp->phy)) {
1208 dev_err(dp->dev, "no DP phy configured\n");
1209 ret = PTR_ERR(dp->phy);
1210 if (ret) {
1211 /*
1212 * phy itself is not enabled, so we can move forward
1213 * assigning NULL to phy pointer.
1214 */
1215 if (ret == -ENOSYS || ret == -ENODEV)
1216 dp->phy = NULL;
1217 else
1218 return ret;
1219 }
1220 }
Ajay Kumarc4e235c2012-10-13 05:48:00 +09001221
Ajay Kumar80185562015-01-20 22:08:46 +05301222 if (!dp->panel && !dp->bridge) {
Ajay Kumar5f1dcd82014-07-31 23:12:14 +05301223 ret = exynos_dp_dt_parse_panel(dp);
1224 if (ret)
1225 return ret;
1226 }
Sean Paul1417f102014-01-30 16:19:23 -05001227
Damien Cassoud913f362012-08-01 18:20:39 +02001228 dp->clock = devm_clk_get(&pdev->dev, "dp");
Jingoo Hane9474be2012-02-03 18:01:55 +09001229 if (IS_ERR(dp->clock)) {
1230 dev_err(&pdev->dev, "failed to get clock\n");
Jingoo Han4d10ecf82012-05-25 16:20:45 +09001231 return PTR_ERR(dp->clock);
Jingoo Hane9474be2012-02-03 18:01:55 +09001232 }
1233
Jingoo Han37414fb2012-10-04 15:45:14 +09001234 clk_prepare_enable(dp->clock);
Jingoo Hane9474be2012-02-03 18:01:55 +09001235
1236 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
Jingoo Hane9474be2012-02-03 18:01:55 +09001237
Thierry Redingbc3bad12013-01-21 11:09:23 +01001238 dp->reg_base = devm_ioremap_resource(&pdev->dev, res);
1239 if (IS_ERR(dp->reg_base))
1240 return PTR_ERR(dp->reg_base);
Jingoo Hane9474be2012-02-03 18:01:55 +09001241
Andrew Brestickerb8b52472014-04-22 04:09:10 +05301242 dp->hpd_gpio = of_get_named_gpio(dev->of_node, "samsung,hpd-gpio", 0);
1243
1244 if (gpio_is_valid(dp->hpd_gpio)) {
1245 /*
1246 * Set up the hotplug GPIO from the device tree as an interrupt.
1247 * Simply specifying a different interrupt in the device tree
1248 * doesn't work since we handle hotplug rather differently when
1249 * using a GPIO. We also need the actual GPIO specifier so
1250 * that we can get the current state of the GPIO.
1251 */
1252 ret = devm_gpio_request_one(&pdev->dev, dp->hpd_gpio, GPIOF_IN,
1253 "hpd_gpio");
1254 if (ret) {
1255 dev_err(&pdev->dev, "failed to get hpd gpio\n");
1256 return ret;
1257 }
1258 dp->irq = gpio_to_irq(dp->hpd_gpio);
1259 irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING;
1260 } else {
1261 dp->hpd_gpio = -ENODEV;
1262 dp->irq = platform_get_irq(pdev, 0);
1263 irq_flags = 0;
1264 }
1265
Sean Paul1cefc1d2012-10-31 23:21:00 +00001266 if (dp->irq == -ENXIO) {
Jingoo Hane9474be2012-02-03 18:01:55 +09001267 dev_err(&pdev->dev, "failed to get irq\n");
Damien Cassoud913f362012-08-01 18:20:39 +02001268 return -ENODEV;
Jingoo Hane9474be2012-02-03 18:01:55 +09001269 }
1270
Sean Paul784fa9a2012-11-09 13:55:08 +09001271 INIT_WORK(&dp->hotplug_work, exynos_dp_hotplug);
1272
Gustavo Padovanb6f3c362015-08-05 20:24:13 -03001273 phy_power_on(dp->phy);
Jingoo Hane9474be2012-02-03 18:01:55 +09001274
1275 exynos_dp_init_dp(dp);
1276
Andrew Brestickerb8b52472014-04-22 04:09:10 +05301277 ret = devm_request_irq(&pdev->dev, dp->irq, exynos_dp_irq_handler,
1278 irq_flags, "exynos-dp", dp);
Ajay Kumar22ce19c2012-11-09 13:59:09 +09001279 if (ret) {
1280 dev_err(&pdev->dev, "failed to request irq\n");
1281 return ret;
1282 }
Sean Paul12f5ad62014-01-30 16:19:25 -05001283 disable_irq(dp->irq);
Jingoo Hane9474be2012-02-03 18:01:55 +09001284
Inki Daef37cd5e2014-05-09 14:25:20 +09001285 dp->drm_dev = drm_dev;
Sean Paul12f5ad62014-01-30 16:19:25 -05001286
Gustavo Padovancf67cc92015-08-11 17:38:06 +09001287 return exynos_drm_create_enc_conn(drm_dev, &dp->encoder,
1288 EXYNOS_DISPLAY_TYPE_LCD);
Inki Daef37cd5e2014-05-09 14:25:20 +09001289}
1290
1291static void exynos_dp_unbind(struct device *dev, struct device *master,
1292 void *data)
1293{
Andrzej Hajda1df6e5f2014-11-17 09:54:24 +01001294 struct exynos_dp_device *dp = dev_get_drvdata(dev);
Inki Daef37cd5e2014-05-09 14:25:20 +09001295
Gustavo Padovancf67cc92015-08-11 17:38:06 +09001296 exynos_dp_disable(&dp->encoder);
Inki Daef37cd5e2014-05-09 14:25:20 +09001297}
1298
1299static const struct component_ops exynos_dp_ops = {
1300 .bind = exynos_dp_bind,
1301 .unbind = exynos_dp_unbind,
1302};
1303
1304static int exynos_dp_probe(struct platform_device *pdev)
1305{
Ajay Kumar5f1dcd82014-07-31 23:12:14 +05301306 struct device *dev = &pdev->dev;
Ajay Kumar80185562015-01-20 22:08:46 +05301307 struct device_node *panel_node, *bridge_node, *endpoint;
Ajay Kumar5f1dcd82014-07-31 23:12:14 +05301308 struct exynos_dp_device *dp;
Inki Daedf5225b2014-05-29 18:28:02 +09001309
Ajay Kumar5f1dcd82014-07-31 23:12:14 +05301310 dp = devm_kzalloc(&pdev->dev, sizeof(struct exynos_dp_device),
1311 GFP_KERNEL);
1312 if (!dp)
1313 return -ENOMEM;
1314
Gustavo Padovancf67cc92015-08-11 17:38:06 +09001315 dp->encoder.ops = &exynos_dp_encoder_ops;
Andrzej Hajda1df6e5f2014-11-17 09:54:24 +01001316 platform_set_drvdata(pdev, dp);
1317
Ajay Kumar5f1dcd82014-07-31 23:12:14 +05301318 panel_node = of_parse_phandle(dev->of_node, "panel", 0);
1319 if (panel_node) {
1320 dp->panel = of_drm_find_panel(panel_node);
1321 of_node_put(panel_node);
1322 if (!dp->panel)
1323 return -EPROBE_DEFER;
1324 }
1325
Ajay Kumar80185562015-01-20 22:08:46 +05301326 endpoint = of_graph_get_next_endpoint(dev->of_node, NULL);
1327 if (endpoint) {
1328 bridge_node = of_graph_get_remote_port_parent(endpoint);
1329 if (bridge_node) {
1330 dp->bridge = of_drm_find_bridge(bridge_node);
1331 of_node_put(bridge_node);
1332 if (!dp->bridge)
1333 return -EPROBE_DEFER;
1334 } else
1335 return -EPROBE_DEFER;
1336 }
1337
Andrzej Hajda86650402015-06-11 23:23:37 +09001338 return component_add(&pdev->dev, &exynos_dp_ops);
Jingoo Hane9474be2012-02-03 18:01:55 +09001339}
1340
Greg Kroah-Hartman48c68c42012-12-21 13:07:39 -08001341static int exynos_dp_remove(struct platform_device *pdev)
Jingoo Hane9474be2012-02-03 18:01:55 +09001342{
Inki Daedf5225b2014-05-29 18:28:02 +09001343 component_del(&pdev->dev, &exynos_dp_ops);
Inki Daedf5225b2014-05-29 18:28:02 +09001344
Jingoo Hane9474be2012-02-03 18:01:55 +09001345 return 0;
1346}
1347
1348#ifdef CONFIG_PM_SLEEP
1349static int exynos_dp_suspend(struct device *dev)
1350{
Andrzej Hajda1df6e5f2014-11-17 09:54:24 +01001351 struct exynos_dp_device *dp = dev_get_drvdata(dev);
Jingoo Hane9474be2012-02-03 18:01:55 +09001352
Gustavo Padovancf67cc92015-08-11 17:38:06 +09001353 exynos_dp_disable(&dp->encoder);
Jingoo Hane9474be2012-02-03 18:01:55 +09001354 return 0;
1355}
1356
1357static int exynos_dp_resume(struct device *dev)
1358{
Andrzej Hajda1df6e5f2014-11-17 09:54:24 +01001359 struct exynos_dp_device *dp = dev_get_drvdata(dev);
Jingoo Hane9474be2012-02-03 18:01:55 +09001360
Gustavo Padovancf67cc92015-08-11 17:38:06 +09001361 exynos_dp_enable(&dp->encoder);
Jingoo Hane9474be2012-02-03 18:01:55 +09001362 return 0;
1363}
1364#endif
1365
1366static const struct dev_pm_ops exynos_dp_pm_ops = {
1367 SET_SYSTEM_SLEEP_PM_OPS(exynos_dp_suspend, exynos_dp_resume)
1368};
1369
Ajay Kumarc4e235c2012-10-13 05:48:00 +09001370static const struct of_device_id exynos_dp_match[] = {
1371 { .compatible = "samsung,exynos5-dp" },
1372 {},
1373};
Sjoerd Simonsbd024b82014-07-30 11:29:41 +09001374MODULE_DEVICE_TABLE(of, exynos_dp_match);
Ajay Kumarc4e235c2012-10-13 05:48:00 +09001375
Sean Paul1417f102014-01-30 16:19:23 -05001376struct platform_driver dp_driver = {
Jingoo Hane9474be2012-02-03 18:01:55 +09001377 .probe = exynos_dp_probe,
Greg Kroah-Hartman48c68c42012-12-21 13:07:39 -08001378 .remove = exynos_dp_remove,
Jingoo Hane9474be2012-02-03 18:01:55 +09001379 .driver = {
1380 .name = "exynos-dp",
1381 .owner = THIS_MODULE,
1382 .pm = &exynos_dp_pm_ops,
Jingoo Hanf9b1e012013-10-16 21:58:15 +05301383 .of_match_table = exynos_dp_match,
Jingoo Hane9474be2012-02-03 18:01:55 +09001384 },
1385};
1386
Jingoo Hane9474be2012-02-03 18:01:55 +09001387MODULE_AUTHOR("Jingoo Han <jg1.han@samsung.com>");
1388MODULE_DESCRIPTION("Samsung SoC DP Driver");
Jingoo Han8f589bb2014-06-03 21:46:11 +09001389MODULE_LICENSE("GPL v2");