blob: 02602a8254c49213aad0adbfd4047b326202569b [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>
21#include <linux/gpio.h>
Inki Daef37cd5e2014-05-09 14:25:20 +090022#include <linux/component.h>
Jingoo Han8114fab2013-10-16 21:58:16 +053023#include <linux/phy/phy.h>
Sean Paul1417f102014-01-30 16:19:23 -050024#include <video/of_display_timing.h>
25#include <video/of_videomode.h>
Jingoo Hane9474be2012-02-03 18:01:55 +090026
Sean Paul1417f102014-01-30 16:19:23 -050027#include <drm/drmP.h>
Sean Paulcaa5d1e2014-01-30 16:19:30 -050028#include <drm/drm_crtc.h>
29#include <drm/drm_crtc_helper.h>
Ajay Kumar5f1dcd82014-07-31 23:12:14 +053030#include <drm/drm_panel.h>
Sean Paul1634ba22014-02-24 19:20:15 +090031#include <drm/bridge/ptn3460.h>
Sean Paul1417f102014-01-30 16:19:23 -050032
33#include "exynos_drm_drv.h"
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
Sean Paul1634ba22014-02-24 19:20:15 +090039struct bridge_init {
40 struct i2c_client *client;
41 struct device_node *node;
42};
43
Ajay Kumar5f1dcd82014-07-31 23:12:14 +053044static void exynos_dp_init_dp(struct exynos_dp_device *dp)
Jingoo Hane9474be2012-02-03 18:01:55 +090045{
46 exynos_dp_reset(dp);
47
Jingoo Han24db03a2012-05-25 16:21:08 +090048 exynos_dp_swreset(dp);
49
Jingoo Han75435c72012-08-23 19:55:13 +090050 exynos_dp_init_analog_param(dp);
51 exynos_dp_init_interrupt(dp);
52
Jingoo Hane9474be2012-02-03 18:01:55 +090053 /* SW defined function Normal operation */
54 exynos_dp_enable_sw_function(dp);
55
56 exynos_dp_config_interrupt(dp);
57 exynos_dp_init_analog_func(dp);
58
59 exynos_dp_init_hpd(dp);
60 exynos_dp_init_aux(dp);
Jingoo Hane9474be2012-02-03 18:01:55 +090061}
62
63static int exynos_dp_detect_hpd(struct exynos_dp_device *dp)
64{
65 int timeout_loop = 0;
66
Jingoo Hane9474be2012-02-03 18:01:55 +090067 while (exynos_dp_get_plug_in_status(dp) != 0) {
68 timeout_loop++;
69 if (DP_TIMEOUT_LOOP_COUNT < timeout_loop) {
70 dev_err(dp->dev, "failed to get hpd plug status\n");
71 return -ETIMEDOUT;
72 }
Jingoo Hana2c81bc2012-07-18 18:50:59 +090073 usleep_range(10, 11);
Jingoo Hane9474be2012-02-03 18:01:55 +090074 }
75
76 return 0;
77}
78
79static unsigned char exynos_dp_calc_edid_check_sum(unsigned char *edid_data)
80{
81 int i;
82 unsigned char sum = 0;
83
84 for (i = 0; i < EDID_BLOCK_LENGTH; i++)
85 sum = sum + edid_data[i];
86
87 return sum;
88}
89
90static int exynos_dp_read_edid(struct exynos_dp_device *dp)
91{
92 unsigned char edid[EDID_BLOCK_LENGTH * 2];
93 unsigned int extend_block = 0;
94 unsigned char sum;
95 unsigned char test_vector;
96 int retval;
97
98 /*
99 * EDID device address is 0x50.
100 * However, if necessary, you must have set upper address
101 * into E-EDID in I2C device, 0x30.
102 */
103
104 /* Read Extension Flag, Number of 128-byte EDID extension blocks */
Sean Paul99f54152012-11-01 02:13:00 +0000105 retval = exynos_dp_read_byte_from_i2c(dp, I2C_EDID_DEVICE_ADDR,
Jingoo Hane9474be2012-02-03 18:01:55 +0900106 EDID_EXTENSION_FLAG,
107 &extend_block);
Sean Paul99f54152012-11-01 02:13:00 +0000108 if (retval)
109 return retval;
Jingoo Hane9474be2012-02-03 18:01:55 +0900110
111 if (extend_block > 0) {
112 dev_dbg(dp->dev, "EDID data includes a single extension!\n");
113
114 /* Read EDID data */
115 retval = exynos_dp_read_bytes_from_i2c(dp, I2C_EDID_DEVICE_ADDR,
116 EDID_HEADER_PATTERN,
117 EDID_BLOCK_LENGTH,
118 &edid[EDID_HEADER_PATTERN]);
119 if (retval != 0) {
120 dev_err(dp->dev, "EDID Read failed!\n");
121 return -EIO;
122 }
123 sum = exynos_dp_calc_edid_check_sum(edid);
124 if (sum != 0) {
125 dev_err(dp->dev, "EDID bad checksum!\n");
126 return -EIO;
127 }
128
129 /* Read additional EDID data */
130 retval = exynos_dp_read_bytes_from_i2c(dp,
131 I2C_EDID_DEVICE_ADDR,
132 EDID_BLOCK_LENGTH,
133 EDID_BLOCK_LENGTH,
134 &edid[EDID_BLOCK_LENGTH]);
135 if (retval != 0) {
136 dev_err(dp->dev, "EDID Read failed!\n");
137 return -EIO;
138 }
139 sum = exynos_dp_calc_edid_check_sum(&edid[EDID_BLOCK_LENGTH]);
140 if (sum != 0) {
141 dev_err(dp->dev, "EDID bad checksum!\n");
142 return -EIO;
143 }
144
Jingoo Han073ea2a2014-05-07 20:44:51 +0900145 exynos_dp_read_byte_from_dpcd(dp, DP_TEST_REQUEST,
Jingoo Hane9474be2012-02-03 18:01:55 +0900146 &test_vector);
Jingoo Han073ea2a2014-05-07 20:44:51 +0900147 if (test_vector & DP_TEST_LINK_EDID_READ) {
Jingoo Hane9474be2012-02-03 18:01:55 +0900148 exynos_dp_write_byte_to_dpcd(dp,
Jingoo Han073ea2a2014-05-07 20:44:51 +0900149 DP_TEST_EDID_CHECKSUM,
Jingoo Hane9474be2012-02-03 18:01:55 +0900150 edid[EDID_BLOCK_LENGTH + EDID_CHECKSUM]);
151 exynos_dp_write_byte_to_dpcd(dp,
Jingoo Han073ea2a2014-05-07 20:44:51 +0900152 DP_TEST_RESPONSE,
153 DP_TEST_EDID_CHECKSUM_WRITE);
Jingoo Hane9474be2012-02-03 18:01:55 +0900154 }
155 } else {
156 dev_info(dp->dev, "EDID data does not include any extensions.\n");
157
158 /* Read EDID data */
159 retval = exynos_dp_read_bytes_from_i2c(dp,
160 I2C_EDID_DEVICE_ADDR,
161 EDID_HEADER_PATTERN,
162 EDID_BLOCK_LENGTH,
163 &edid[EDID_HEADER_PATTERN]);
164 if (retval != 0) {
165 dev_err(dp->dev, "EDID Read failed!\n");
166 return -EIO;
167 }
168 sum = exynos_dp_calc_edid_check_sum(edid);
169 if (sum != 0) {
170 dev_err(dp->dev, "EDID bad checksum!\n");
171 return -EIO;
172 }
173
174 exynos_dp_read_byte_from_dpcd(dp,
Jingoo Han073ea2a2014-05-07 20:44:51 +0900175 DP_TEST_REQUEST,
Jingoo Hane9474be2012-02-03 18:01:55 +0900176 &test_vector);
Jingoo Han073ea2a2014-05-07 20:44:51 +0900177 if (test_vector & DP_TEST_LINK_EDID_READ) {
Jingoo Hane9474be2012-02-03 18:01:55 +0900178 exynos_dp_write_byte_to_dpcd(dp,
Jingoo Han073ea2a2014-05-07 20:44:51 +0900179 DP_TEST_EDID_CHECKSUM,
Jingoo Hane9474be2012-02-03 18:01:55 +0900180 edid[EDID_CHECKSUM]);
181 exynos_dp_write_byte_to_dpcd(dp,
Jingoo Han073ea2a2014-05-07 20:44:51 +0900182 DP_TEST_RESPONSE,
183 DP_TEST_EDID_CHECKSUM_WRITE);
Jingoo Hane9474be2012-02-03 18:01:55 +0900184 }
185 }
186
187 dev_err(dp->dev, "EDID Read success!\n");
188 return 0;
189}
190
191static int exynos_dp_handle_edid(struct exynos_dp_device *dp)
192{
193 u8 buf[12];
194 int i;
195 int retval;
196
Jingoo Han073ea2a2014-05-07 20:44:51 +0900197 /* Read DPCD DP_DPCD_REV~RECEIVE_PORT1_CAP_1 */
198 retval = exynos_dp_read_bytes_from_dpcd(dp, DP_DPCD_REV,
Sean Paul99f54152012-11-01 02:13:00 +0000199 12, buf);
200 if (retval)
201 return retval;
Jingoo Hane9474be2012-02-03 18:01:55 +0900202
203 /* Read EDID */
204 for (i = 0; i < 3; i++) {
205 retval = exynos_dp_read_edid(dp);
Sean Paul99f54152012-11-01 02:13:00 +0000206 if (!retval)
Jingoo Hane9474be2012-02-03 18:01:55 +0900207 break;
208 }
209
210 return retval;
211}
212
213static void exynos_dp_enable_rx_to_enhanced_mode(struct exynos_dp_device *dp,
214 bool enable)
215{
216 u8 data;
217
Jingoo Han073ea2a2014-05-07 20:44:51 +0900218 exynos_dp_read_byte_from_dpcd(dp, DP_LANE_COUNT_SET, &data);
Jingoo Hane9474be2012-02-03 18:01:55 +0900219
220 if (enable)
Jingoo Han073ea2a2014-05-07 20:44:51 +0900221 exynos_dp_write_byte_to_dpcd(dp, DP_LANE_COUNT_SET,
222 DP_LANE_COUNT_ENHANCED_FRAME_EN |
Jingoo Hane9474be2012-02-03 18:01:55 +0900223 DPCD_LANE_COUNT_SET(data));
224 else
Jingoo Han073ea2a2014-05-07 20:44:51 +0900225 exynos_dp_write_byte_to_dpcd(dp, DP_LANE_COUNT_SET,
Jingoo Hane9474be2012-02-03 18:01:55 +0900226 DPCD_LANE_COUNT_SET(data));
227}
228
229static int exynos_dp_is_enhanced_mode_available(struct exynos_dp_device *dp)
230{
231 u8 data;
232 int retval;
233
Jingoo Han073ea2a2014-05-07 20:44:51 +0900234 exynos_dp_read_byte_from_dpcd(dp, DP_MAX_LANE_COUNT, &data);
Jingoo Hane9474be2012-02-03 18:01:55 +0900235 retval = DPCD_ENHANCED_FRAME_CAP(data);
236
237 return retval;
238}
239
240static void exynos_dp_set_enhanced_mode(struct exynos_dp_device *dp)
241{
242 u8 data;
243
244 data = exynos_dp_is_enhanced_mode_available(dp);
245 exynos_dp_enable_rx_to_enhanced_mode(dp, data);
246 exynos_dp_enable_enhanced_mode(dp, data);
247}
248
249static void exynos_dp_training_pattern_dis(struct exynos_dp_device *dp)
250{
251 exynos_dp_set_training_pattern(dp, DP_NONE);
252
253 exynos_dp_write_byte_to_dpcd(dp,
Jingoo Han073ea2a2014-05-07 20:44:51 +0900254 DP_TRAINING_PATTERN_SET,
255 DP_TRAINING_PATTERN_DISABLE);
Jingoo Hane9474be2012-02-03 18:01:55 +0900256}
257
258static void exynos_dp_set_lane_lane_pre_emphasis(struct exynos_dp_device *dp,
259 int pre_emphasis, int lane)
260{
261 switch (lane) {
262 case 0:
263 exynos_dp_set_lane0_pre_emphasis(dp, pre_emphasis);
264 break;
265 case 1:
266 exynos_dp_set_lane1_pre_emphasis(dp, pre_emphasis);
267 break;
268
269 case 2:
270 exynos_dp_set_lane2_pre_emphasis(dp, pre_emphasis);
271 break;
272
273 case 3:
274 exynos_dp_set_lane3_pre_emphasis(dp, pre_emphasis);
275 break;
276 }
277}
278
Sean Paulace2d7f2012-10-31 23:21:00 +0000279static int exynos_dp_link_start(struct exynos_dp_device *dp)
Jingoo Hane9474be2012-02-03 18:01:55 +0900280{
Jingoo Hand5c0eed2012-07-19 13:52:59 +0900281 u8 buf[4];
Sean Paul49ce41f2012-10-31 23:21:00 +0000282 int lane, lane_count, pll_tries, retval;
Jingoo Hane9474be2012-02-03 18:01:55 +0900283
284 lane_count = dp->link_train.lane_count;
285
286 dp->link_train.lt_state = CLOCK_RECOVERY;
287 dp->link_train.eq_loop = 0;
288
289 for (lane = 0; lane < lane_count; lane++)
290 dp->link_train.cr_loop[lane] = 0;
291
Jingoo Hane9474be2012-02-03 18:01:55 +0900292 /* Set link rate and count as you want to establish*/
293 exynos_dp_set_link_bandwidth(dp, dp->link_train.link_rate);
294 exynos_dp_set_lane_count(dp, dp->link_train.lane_count);
295
296 /* Setup RX configuration */
297 buf[0] = dp->link_train.link_rate;
298 buf[1] = dp->link_train.lane_count;
Jingoo Han073ea2a2014-05-07 20:44:51 +0900299 retval = exynos_dp_write_bytes_to_dpcd(dp, DP_LINK_BW_SET,
Jingoo Hane9474be2012-02-03 18:01:55 +0900300 2, buf);
Sean Paulace2d7f2012-10-31 23:21:00 +0000301 if (retval)
302 return retval;
Jingoo Hane9474be2012-02-03 18:01:55 +0900303
304 /* Set TX pre-emphasis to minimum */
305 for (lane = 0; lane < lane_count; lane++)
306 exynos_dp_set_lane_lane_pre_emphasis(dp,
307 PRE_EMPHASIS_LEVEL_0, lane);
308
Sean Paul49ce41f2012-10-31 23:21:00 +0000309 /* Wait for PLL lock */
310 pll_tries = 0;
311 while (exynos_dp_get_pll_lock_status(dp) == PLL_UNLOCKED) {
312 if (pll_tries == DP_TIMEOUT_LOOP_COUNT) {
313 dev_err(dp->dev, "Wait for PLL lock timed out\n");
314 return -ETIMEDOUT;
315 }
316
317 pll_tries++;
318 usleep_range(90, 120);
319 }
320
Jingoo Hane9474be2012-02-03 18:01:55 +0900321 /* Set training pattern 1 */
322 exynos_dp_set_training_pattern(dp, TRAINING_PTN1);
323
324 /* Set RX training pattern */
Sean Paulfadec4b2012-10-31 23:21:00 +0000325 retval = exynos_dp_write_byte_to_dpcd(dp,
Jingoo Han073ea2a2014-05-07 20:44:51 +0900326 DP_TRAINING_PATTERN_SET,
327 DP_LINK_SCRAMBLING_DISABLE | DP_TRAINING_PATTERN_1);
Sean Paulfadec4b2012-10-31 23:21:00 +0000328 if (retval)
329 return retval;
Jingoo Hane9474be2012-02-03 18:01:55 +0900330
331 for (lane = 0; lane < lane_count; lane++)
Sonika Jindal0ded9252014-08-08 16:23:42 +0530332 buf[lane] = DP_TRAIN_PRE_EMPH_LEVEL_0 |
333 DP_TRAIN_VOLTAGE_SWING_LEVEL_0;
Sean Paulfadec4b2012-10-31 23:21:00 +0000334
Jingoo Han073ea2a2014-05-07 20:44:51 +0900335 retval = exynos_dp_write_bytes_to_dpcd(dp, DP_TRAINING_LANE0_SET,
Sean Paulfadec4b2012-10-31 23:21:00 +0000336 lane_count, buf);
Sean Paulace2d7f2012-10-31 23:21:00 +0000337
338 return retval;
Jingoo Hane9474be2012-02-03 18:01:55 +0900339}
340
Jingoo Hand5c0eed2012-07-19 13:52:59 +0900341static unsigned char exynos_dp_get_lane_status(u8 link_status[2], int lane)
Jingoo Hane9474be2012-02-03 18:01:55 +0900342{
343 int shift = (lane & 1) * 4;
344 u8 link_value = link_status[lane>>1];
345
346 return (link_value >> shift) & 0xf;
347}
348
Jingoo Hand5c0eed2012-07-19 13:52:59 +0900349static int exynos_dp_clock_recovery_ok(u8 link_status[2], int lane_count)
Jingoo Hane9474be2012-02-03 18:01:55 +0900350{
351 int lane;
352 u8 lane_status;
353
354 for (lane = 0; lane < lane_count; lane++) {
355 lane_status = exynos_dp_get_lane_status(link_status, lane);
Jingoo Han073ea2a2014-05-07 20:44:51 +0900356 if ((lane_status & DP_LANE_CR_DONE) == 0)
Jingoo Hane9474be2012-02-03 18:01:55 +0900357 return -EINVAL;
358 }
359 return 0;
360}
361
Sean Paulfadec4b2012-10-31 23:21:00 +0000362static int exynos_dp_channel_eq_ok(u8 link_status[2], u8 link_align,
363 int lane_count)
Jingoo Hane9474be2012-02-03 18:01:55 +0900364{
365 int lane;
Jingoo Hane9474be2012-02-03 18:01:55 +0900366 u8 lane_status;
367
Jingoo Han073ea2a2014-05-07 20:44:51 +0900368 if ((link_align & DP_INTERLANE_ALIGN_DONE) == 0)
Jingoo Hane9474be2012-02-03 18:01:55 +0900369 return -EINVAL;
370
371 for (lane = 0; lane < lane_count; lane++) {
Sean Paulfadec4b2012-10-31 23:21:00 +0000372 lane_status = exynos_dp_get_lane_status(link_status, lane);
Jingoo Han073ea2a2014-05-07 20:44:51 +0900373 lane_status &= DP_CHANNEL_EQ_BITS;
374 if (lane_status != DP_CHANNEL_EQ_BITS)
Jingoo Hane9474be2012-02-03 18:01:55 +0900375 return -EINVAL;
376 }
Jingoo Hand5c0eed2012-07-19 13:52:59 +0900377
Jingoo Hane9474be2012-02-03 18:01:55 +0900378 return 0;
379}
380
381static unsigned char exynos_dp_get_adjust_request_voltage(u8 adjust_request[2],
382 int lane)
383{
384 int shift = (lane & 1) * 4;
385 u8 link_value = adjust_request[lane>>1];
386
387 return (link_value >> shift) & 0x3;
388}
389
390static unsigned char exynos_dp_get_adjust_request_pre_emphasis(
391 u8 adjust_request[2],
392 int lane)
393{
394 int shift = (lane & 1) * 4;
395 u8 link_value = adjust_request[lane>>1];
396
397 return ((link_value >> shift) & 0xc) >> 2;
398}
399
400static void exynos_dp_set_lane_link_training(struct exynos_dp_device *dp,
401 u8 training_lane_set, int lane)
402{
403 switch (lane) {
404 case 0:
405 exynos_dp_set_lane0_link_training(dp, training_lane_set);
406 break;
407 case 1:
408 exynos_dp_set_lane1_link_training(dp, training_lane_set);
409 break;
410
411 case 2:
412 exynos_dp_set_lane2_link_training(dp, training_lane_set);
413 break;
414
415 case 3:
416 exynos_dp_set_lane3_link_training(dp, training_lane_set);
417 break;
418 }
419}
420
421static unsigned int exynos_dp_get_lane_link_training(
422 struct exynos_dp_device *dp,
423 int lane)
424{
425 u32 reg;
426
427 switch (lane) {
428 case 0:
429 reg = exynos_dp_get_lane0_link_training(dp);
430 break;
431 case 1:
432 reg = exynos_dp_get_lane1_link_training(dp);
433 break;
434 case 2:
435 reg = exynos_dp_get_lane2_link_training(dp);
436 break;
437 case 3:
438 reg = exynos_dp_get_lane3_link_training(dp);
439 break;
Jingoo Han64c43df2012-06-20 10:25:48 +0900440 default:
441 WARN_ON(1);
442 return 0;
Jingoo Hane9474be2012-02-03 18:01:55 +0900443 }
444
445 return reg;
446}
447
448static void exynos_dp_reduce_link_rate(struct exynos_dp_device *dp)
449{
Jingoo Hand5c0eed2012-07-19 13:52:59 +0900450 exynos_dp_training_pattern_dis(dp);
451 exynos_dp_set_enhanced_mode(dp);
Jingoo Hane9474be2012-02-03 18:01:55 +0900452
Jingoo Hand5c0eed2012-07-19 13:52:59 +0900453 dp->link_train.lt_state = FAILED;
Jingoo Hane9474be2012-02-03 18:01:55 +0900454}
455
Sean Paulfadec4b2012-10-31 23:21:00 +0000456static void exynos_dp_get_adjust_training_lane(struct exynos_dp_device *dp,
457 u8 adjust_request[2])
458{
459 int lane, lane_count;
460 u8 voltage_swing, pre_emphasis, training_lane;
461
462 lane_count = dp->link_train.lane_count;
463 for (lane = 0; lane < lane_count; lane++) {
464 voltage_swing = exynos_dp_get_adjust_request_voltage(
465 adjust_request, lane);
466 pre_emphasis = exynos_dp_get_adjust_request_pre_emphasis(
467 adjust_request, lane);
468 training_lane = DPCD_VOLTAGE_SWING_SET(voltage_swing) |
469 DPCD_PRE_EMPHASIS_SET(pre_emphasis);
470
471 if (voltage_swing == VOLTAGE_LEVEL_3)
Jingoo Han073ea2a2014-05-07 20:44:51 +0900472 training_lane |= DP_TRAIN_MAX_SWING_REACHED;
Sean Paulfadec4b2012-10-31 23:21:00 +0000473 if (pre_emphasis == PRE_EMPHASIS_LEVEL_3)
Jingoo Han073ea2a2014-05-07 20:44:51 +0900474 training_lane |= DP_TRAIN_MAX_PRE_EMPHASIS_REACHED;
Sean Paulfadec4b2012-10-31 23:21:00 +0000475
476 dp->link_train.training_lane[lane] = training_lane;
477 }
478}
479
Jingoo Hane9474be2012-02-03 18:01:55 +0900480static int exynos_dp_process_clock_recovery(struct exynos_dp_device *dp)
481{
Sean Paulace2d7f2012-10-31 23:21:00 +0000482 int lane, lane_count, retval;
Sean Paulfadec4b2012-10-31 23:21:00 +0000483 u8 voltage_swing, pre_emphasis, training_lane;
484 u8 link_status[2], adjust_request[2];
Jingoo Hane9474be2012-02-03 18:01:55 +0900485
Jingoo Hana2c81bc2012-07-18 18:50:59 +0900486 usleep_range(100, 101);
Jingoo Hane9474be2012-02-03 18:01:55 +0900487
Jingoo Hane9474be2012-02-03 18:01:55 +0900488 lane_count = dp->link_train.lane_count;
489
Sean Paulfadec4b2012-10-31 23:21:00 +0000490 retval = exynos_dp_read_bytes_from_dpcd(dp,
Jingoo Han073ea2a2014-05-07 20:44:51 +0900491 DP_LANE0_1_STATUS, 2, link_status);
Sean Paulfadec4b2012-10-31 23:21:00 +0000492 if (retval)
493 return retval;
494
495 retval = exynos_dp_read_bytes_from_dpcd(dp,
Jingoo Han073ea2a2014-05-07 20:44:51 +0900496 DP_ADJUST_REQUEST_LANE0_1, 2, adjust_request);
Sean Paulace2d7f2012-10-31 23:21:00 +0000497 if (retval)
498 return retval;
Jingoo Hand5c0eed2012-07-19 13:52:59 +0900499
Jingoo Hane9474be2012-02-03 18:01:55 +0900500 if (exynos_dp_clock_recovery_ok(link_status, lane_count) == 0) {
501 /* set training pattern 2 for EQ */
502 exynos_dp_set_training_pattern(dp, TRAINING_PTN2);
503
Sean Paulace2d7f2012-10-31 23:21:00 +0000504 retval = exynos_dp_write_byte_to_dpcd(dp,
Jingoo Han073ea2a2014-05-07 20:44:51 +0900505 DP_TRAINING_PATTERN_SET,
506 DP_LINK_SCRAMBLING_DISABLE |
507 DP_TRAINING_PATTERN_2);
Sean Paulace2d7f2012-10-31 23:21:00 +0000508 if (retval)
509 return retval;
Jingoo Hand5c0eed2012-07-19 13:52:59 +0900510
511 dev_info(dp->dev, "Link Training Clock Recovery success\n");
512 dp->link_train.lt_state = EQUALIZER_TRAINING;
513 } else {
514 for (lane = 0; lane < lane_count; lane++) {
515 training_lane = exynos_dp_get_lane_link_training(
516 dp, lane);
Jingoo Hand5c0eed2012-07-19 13:52:59 +0900517 voltage_swing = exynos_dp_get_adjust_request_voltage(
518 adjust_request, lane);
519 pre_emphasis = exynos_dp_get_adjust_request_pre_emphasis(
520 adjust_request, lane);
521
Sean Paulfadec4b2012-10-31 23:21:00 +0000522 if (DPCD_VOLTAGE_SWING_GET(training_lane) ==
523 voltage_swing &&
524 DPCD_PRE_EMPHASIS_GET(training_lane) ==
525 pre_emphasis)
Jingoo Hand5c0eed2012-07-19 13:52:59 +0900526 dp->link_train.cr_loop[lane]++;
Sean Paulfadec4b2012-10-31 23:21:00 +0000527
528 if (dp->link_train.cr_loop[lane] == MAX_CR_LOOP ||
529 voltage_swing == VOLTAGE_LEVEL_3 ||
530 pre_emphasis == PRE_EMPHASIS_LEVEL_3) {
531 dev_err(dp->dev, "CR Max reached (%d,%d,%d)\n",
532 dp->link_train.cr_loop[lane],
533 voltage_swing, pre_emphasis);
534 exynos_dp_reduce_link_rate(dp);
535 return -EIO;
Jingoo Hand5c0eed2012-07-19 13:52:59 +0900536 }
Jingoo Hane9474be2012-02-03 18:01:55 +0900537 }
538 }
539
Sean Paulfadec4b2012-10-31 23:21:00 +0000540 exynos_dp_get_adjust_training_lane(dp, adjust_request);
Jingoo Hand5c0eed2012-07-19 13:52:59 +0900541
Sean Paulfadec4b2012-10-31 23:21:00 +0000542 for (lane = 0; lane < lane_count; lane++)
543 exynos_dp_set_lane_link_training(dp,
544 dp->link_train.training_lane[lane], lane);
545
546 retval = exynos_dp_write_bytes_to_dpcd(dp,
Jingoo Han073ea2a2014-05-07 20:44:51 +0900547 DP_TRAINING_LANE0_SET, lane_count,
Sean Paulfadec4b2012-10-31 23:21:00 +0000548 dp->link_train.training_lane);
549 if (retval)
550 return retval;
551
552 return retval;
Jingoo Hane9474be2012-02-03 18:01:55 +0900553}
554
555static int exynos_dp_process_equalizer_training(struct exynos_dp_device *dp)
556{
Sean Paulace2d7f2012-10-31 23:21:00 +0000557 int lane, lane_count, retval;
Jingoo Hane9474be2012-02-03 18:01:55 +0900558 u32 reg;
Sean Paulfadec4b2012-10-31 23:21:00 +0000559 u8 link_align, link_status[2], adjust_request[2];
Jingoo Hane9474be2012-02-03 18:01:55 +0900560
Jingoo Hana2c81bc2012-07-18 18:50:59 +0900561 usleep_range(400, 401);
Jingoo Hane9474be2012-02-03 18:01:55 +0900562
Jingoo Hane9474be2012-02-03 18:01:55 +0900563 lane_count = dp->link_train.lane_count;
564
Sean Paulfadec4b2012-10-31 23:21:00 +0000565 retval = exynos_dp_read_bytes_from_dpcd(dp,
Jingoo Han073ea2a2014-05-07 20:44:51 +0900566 DP_LANE0_1_STATUS, 2, link_status);
Sean Paulace2d7f2012-10-31 23:21:00 +0000567 if (retval)
568 return retval;
Jingoo Hand5c0eed2012-07-19 13:52:59 +0900569
Sean Paulfadec4b2012-10-31 23:21:00 +0000570 if (exynos_dp_clock_recovery_ok(link_status, lane_count)) {
571 exynos_dp_reduce_link_rate(dp);
572 return -EIO;
Jingoo Hane9474be2012-02-03 18:01:55 +0900573 }
574
Sean Paulfadec4b2012-10-31 23:21:00 +0000575 retval = exynos_dp_read_bytes_from_dpcd(dp,
Jingoo Han073ea2a2014-05-07 20:44:51 +0900576 DP_ADJUST_REQUEST_LANE0_1, 2, adjust_request);
Sean Paulfadec4b2012-10-31 23:21:00 +0000577 if (retval)
578 return retval;
Jingoo Hand5c0eed2012-07-19 13:52:59 +0900579
Sean Paulfadec4b2012-10-31 23:21:00 +0000580 retval = exynos_dp_read_byte_from_dpcd(dp,
Jingoo Han073ea2a2014-05-07 20:44:51 +0900581 DP_LANE_ALIGN_STATUS_UPDATED, &link_align);
Sean Paulfadec4b2012-10-31 23:21:00 +0000582 if (retval)
583 return retval;
584
585 exynos_dp_get_adjust_training_lane(dp, adjust_request);
586
587 if (!exynos_dp_channel_eq_ok(link_status, link_align, lane_count)) {
588 /* traing pattern Set to Normal */
589 exynos_dp_training_pattern_dis(dp);
590
591 dev_info(dp->dev, "Link Training success!\n");
592
593 exynos_dp_get_link_bandwidth(dp, &reg);
594 dp->link_train.link_rate = reg;
595 dev_dbg(dp->dev, "final bandwidth = %.2x\n",
596 dp->link_train.link_rate);
597
598 exynos_dp_get_lane_count(dp, &reg);
599 dp->link_train.lane_count = reg;
600 dev_dbg(dp->dev, "final lane count = %.2x\n",
601 dp->link_train.lane_count);
602
603 /* set enhanced mode if available */
604 exynos_dp_set_enhanced_mode(dp);
605 dp->link_train.lt_state = FINISHED;
606
607 return 0;
608 }
609
610 /* not all locked */
611 dp->link_train.eq_loop++;
612
613 if (dp->link_train.eq_loop > MAX_EQ_LOOP) {
614 dev_err(dp->dev, "EQ Max loop\n");
615 exynos_dp_reduce_link_rate(dp);
616 return -EIO;
617 }
618
619 for (lane = 0; lane < lane_count; lane++)
620 exynos_dp_set_lane_link_training(dp,
621 dp->link_train.training_lane[lane], lane);
622
Jingoo Han073ea2a2014-05-07 20:44:51 +0900623 retval = exynos_dp_write_bytes_to_dpcd(dp, DP_TRAINING_LANE0_SET,
Sean Paulfadec4b2012-10-31 23:21:00 +0000624 lane_count, dp->link_train.training_lane);
625
626 return retval;
Jingoo Hane9474be2012-02-03 18:01:55 +0900627}
628
629static void exynos_dp_get_max_rx_bandwidth(struct exynos_dp_device *dp,
Jingoo Hand5c0eed2012-07-19 13:52:59 +0900630 u8 *bandwidth)
Jingoo Hane9474be2012-02-03 18:01:55 +0900631{
632 u8 data;
633
634 /*
635 * For DP rev.1.1, Maximum link rate of Main Link lanes
636 * 0x06 = 1.62 Gbps, 0x0a = 2.7 Gbps
637 */
Jingoo Han073ea2a2014-05-07 20:44:51 +0900638 exynos_dp_read_byte_from_dpcd(dp, DP_MAX_LINK_RATE, &data);
Jingoo Hane9474be2012-02-03 18:01:55 +0900639 *bandwidth = data;
640}
641
642static void exynos_dp_get_max_rx_lane_count(struct exynos_dp_device *dp,
Jingoo Hand5c0eed2012-07-19 13:52:59 +0900643 u8 *lane_count)
Jingoo Hane9474be2012-02-03 18:01:55 +0900644{
645 u8 data;
646
647 /*
648 * For DP rev.1.1, Maximum number of Main Link lanes
649 * 0x01 = 1 lane, 0x02 = 2 lanes, 0x04 = 4 lanes
650 */
Jingoo Han073ea2a2014-05-07 20:44:51 +0900651 exynos_dp_read_byte_from_dpcd(dp, DP_MAX_LANE_COUNT, &data);
Jingoo Hane9474be2012-02-03 18:01:55 +0900652 *lane_count = DPCD_MAX_LANE_COUNT(data);
653}
654
655static void exynos_dp_init_training(struct exynos_dp_device *dp,
656 enum link_lane_count_type max_lane,
657 enum link_rate_type max_rate)
658{
659 /*
660 * MACRO_RST must be applied after the PLL_LOCK to avoid
661 * the DP inter pair skew issue for at least 10 us
662 */
663 exynos_dp_reset_macro(dp);
664
665 /* Initialize by reading RX's DPCD */
666 exynos_dp_get_max_rx_bandwidth(dp, &dp->link_train.link_rate);
667 exynos_dp_get_max_rx_lane_count(dp, &dp->link_train.lane_count);
668
669 if ((dp->link_train.link_rate != LINK_RATE_1_62GBPS) &&
670 (dp->link_train.link_rate != LINK_RATE_2_70GBPS)) {
671 dev_err(dp->dev, "Rx Max Link Rate is abnormal :%x !\n",
672 dp->link_train.link_rate);
673 dp->link_train.link_rate = LINK_RATE_1_62GBPS;
674 }
675
676 if (dp->link_train.lane_count == 0) {
677 dev_err(dp->dev, "Rx Max Lane count is abnormal :%x !\n",
678 dp->link_train.lane_count);
679 dp->link_train.lane_count = (u8)LANE_COUNT1;
680 }
681
682 /* Setup TX lane count & rate */
683 if (dp->link_train.lane_count > max_lane)
684 dp->link_train.lane_count = max_lane;
685 if (dp->link_train.link_rate > max_rate)
686 dp->link_train.link_rate = max_rate;
687
688 /* All DP analog module power up */
689 exynos_dp_set_analog_power_down(dp, POWER_ALL, 0);
690}
691
692static int exynos_dp_sw_link_training(struct exynos_dp_device *dp)
693{
Sean Paulace2d7f2012-10-31 23:21:00 +0000694 int retval = 0, training_finished = 0;
Jingoo Hane9474be2012-02-03 18:01:55 +0900695
696 dp->link_train.lt_state = START;
697
698 /* Process here */
Sean Paulace2d7f2012-10-31 23:21:00 +0000699 while (!retval && !training_finished) {
Jingoo Hane9474be2012-02-03 18:01:55 +0900700 switch (dp->link_train.lt_state) {
701 case START:
Sean Paulace2d7f2012-10-31 23:21:00 +0000702 retval = exynos_dp_link_start(dp);
703 if (retval)
704 dev_err(dp->dev, "LT link start failed!\n");
Jingoo Hane9474be2012-02-03 18:01:55 +0900705 break;
706 case CLOCK_RECOVERY:
Jingoo Hand5c0eed2012-07-19 13:52:59 +0900707 retval = exynos_dp_process_clock_recovery(dp);
708 if (retval)
709 dev_err(dp->dev, "LT CR failed!\n");
Jingoo Hane9474be2012-02-03 18:01:55 +0900710 break;
711 case EQUALIZER_TRAINING:
Jingoo Hand5c0eed2012-07-19 13:52:59 +0900712 retval = exynos_dp_process_equalizer_training(dp);
713 if (retval)
714 dev_err(dp->dev, "LT EQ failed!\n");
Jingoo Hane9474be2012-02-03 18:01:55 +0900715 break;
716 case FINISHED:
717 training_finished = 1;
718 break;
719 case FAILED:
720 return -EREMOTEIO;
721 }
722 }
Sean Paulace2d7f2012-10-31 23:21:00 +0000723 if (retval)
724 dev_err(dp->dev, "eDP link training failed (%d)\n", retval);
Jingoo Hane9474be2012-02-03 18:01:55 +0900725
726 return retval;
727}
728
729static int exynos_dp_set_link_train(struct exynos_dp_device *dp,
730 u32 count,
731 u32 bwtype)
732{
733 int i;
734 int retval;
735
736 for (i = 0; i < DP_TIMEOUT_LOOP_COUNT; i++) {
737 exynos_dp_init_training(dp, count, bwtype);
738 retval = exynos_dp_sw_link_training(dp);
739 if (retval == 0)
740 break;
741
Jingoo Hana2c81bc2012-07-18 18:50:59 +0900742 usleep_range(100, 110);
Jingoo Hane9474be2012-02-03 18:01:55 +0900743 }
744
745 return retval;
746}
747
Ajay Kumar3fcb6eb2012-11-09 14:05:06 +0900748static int exynos_dp_config_video(struct exynos_dp_device *dp)
Jingoo Hane9474be2012-02-03 18:01:55 +0900749{
750 int retval = 0;
751 int timeout_loop = 0;
752 int done_count = 0;
753
Ajay Kumar3fcb6eb2012-11-09 14:05:06 +0900754 exynos_dp_config_video_slave_mode(dp);
Jingoo Hane9474be2012-02-03 18:01:55 +0900755
Ajay Kumar3fcb6eb2012-11-09 14:05:06 +0900756 exynos_dp_set_video_color_format(dp);
Jingoo Hane9474be2012-02-03 18:01:55 +0900757
758 if (exynos_dp_get_pll_lock_status(dp) == PLL_UNLOCKED) {
759 dev_err(dp->dev, "PLL is not locked yet.\n");
760 return -EINVAL;
761 }
762
763 for (;;) {
764 timeout_loop++;
765 if (exynos_dp_is_slave_video_stream_clock_on(dp) == 0)
766 break;
767 if (DP_TIMEOUT_LOOP_COUNT < timeout_loop) {
768 dev_err(dp->dev, "Timeout of video streamclk ok\n");
769 return -ETIMEDOUT;
770 }
771
Jingoo Hana2c81bc2012-07-18 18:50:59 +0900772 usleep_range(1, 2);
Jingoo Hane9474be2012-02-03 18:01:55 +0900773 }
774
775 /* Set to use the register calculated M/N video */
776 exynos_dp_set_video_cr_mn(dp, CALCULATED_M, 0, 0);
777
778 /* For video bist, Video timing must be generated by register */
779 exynos_dp_set_video_timing_mode(dp, VIDEO_TIMING_FROM_CAPTURE);
780
781 /* Disable video mute */
782 exynos_dp_enable_video_mute(dp, 0);
783
784 /* Configure video slave mode */
785 exynos_dp_enable_video_master(dp, 0);
786
787 /* Enable video */
788 exynos_dp_start_video(dp);
789
790 timeout_loop = 0;
791
792 for (;;) {
793 timeout_loop++;
794 if (exynos_dp_is_video_stream_on(dp) == 0) {
795 done_count++;
796 if (done_count > 10)
797 break;
798 } else if (done_count) {
799 done_count = 0;
800 }
801 if (DP_TIMEOUT_LOOP_COUNT < timeout_loop) {
802 dev_err(dp->dev, "Timeout of video streamclk ok\n");
803 return -ETIMEDOUT;
804 }
805
Jingoo Hana2c81bc2012-07-18 18:50:59 +0900806 usleep_range(1000, 1001);
Jingoo Hane9474be2012-02-03 18:01:55 +0900807 }
808
809 if (retval != 0)
810 dev_err(dp->dev, "Video stream is not detected!\n");
811
812 return retval;
813}
814
815static void exynos_dp_enable_scramble(struct exynos_dp_device *dp, bool enable)
816{
817 u8 data;
818
819 if (enable) {
820 exynos_dp_enable_scrambling(dp);
821
822 exynos_dp_read_byte_from_dpcd(dp,
Jingoo Han073ea2a2014-05-07 20:44:51 +0900823 DP_TRAINING_PATTERN_SET,
Jingoo Hane9474be2012-02-03 18:01:55 +0900824 &data);
825 exynos_dp_write_byte_to_dpcd(dp,
Jingoo Han073ea2a2014-05-07 20:44:51 +0900826 DP_TRAINING_PATTERN_SET,
827 (u8)(data & ~DP_LINK_SCRAMBLING_DISABLE));
Jingoo Hane9474be2012-02-03 18:01:55 +0900828 } else {
829 exynos_dp_disable_scrambling(dp);
830
831 exynos_dp_read_byte_from_dpcd(dp,
Jingoo Han073ea2a2014-05-07 20:44:51 +0900832 DP_TRAINING_PATTERN_SET,
Jingoo Hane9474be2012-02-03 18:01:55 +0900833 &data);
834 exynos_dp_write_byte_to_dpcd(dp,
Jingoo Han073ea2a2014-05-07 20:44:51 +0900835 DP_TRAINING_PATTERN_SET,
836 (u8)(data | DP_LINK_SCRAMBLING_DISABLE));
Jingoo Hane9474be2012-02-03 18:01:55 +0900837 }
838}
839
840static irqreturn_t exynos_dp_irq_handler(int irq, void *arg)
841{
842 struct exynos_dp_device *dp = arg;
843
Sean Paulc30ffb92012-11-01 19:13:46 +0900844 enum dp_irq_type irq_type;
845
846 irq_type = exynos_dp_get_irq_type(dp);
847 switch (irq_type) {
848 case DP_IRQ_TYPE_HP_CABLE_IN:
849 dev_dbg(dp->dev, "Received irq - cable in\n");
850 schedule_work(&dp->hotplug_work);
851 exynos_dp_clear_hotplug_interrupts(dp);
852 break;
853 case DP_IRQ_TYPE_HP_CABLE_OUT:
854 dev_dbg(dp->dev, "Received irq - cable out\n");
855 exynos_dp_clear_hotplug_interrupts(dp);
856 break;
857 case DP_IRQ_TYPE_HP_CHANGE:
858 /*
859 * We get these change notifications once in a while, but there
860 * is nothing we can do with them. Just ignore it for now and
861 * only handle cable changes.
862 */
863 dev_dbg(dp->dev, "Received irq - hotplug change; ignoring.\n");
864 exynos_dp_clear_hotplug_interrupts(dp);
865 break;
866 default:
867 dev_err(dp->dev, "Received irq - unknown type!\n");
868 break;
869 }
Jingoo Hane9474be2012-02-03 18:01:55 +0900870 return IRQ_HANDLED;
871}
872
Sean Paul784fa9a2012-11-09 13:55:08 +0900873static void exynos_dp_hotplug(struct work_struct *work)
874{
875 struct exynos_dp_device *dp;
Sean Paul784fa9a2012-11-09 13:55:08 +0900876
877 dp = container_of(work, struct exynos_dp_device, hotplug_work);
878
Ajay Kumar4deabfa2014-07-31 23:12:13 +0530879 if (dp->drm_dev)
880 drm_helper_hpd_irq_event(dp->drm_dev);
881}
882
883static void exynos_dp_commit(struct exynos_drm_display *display)
884{
885 struct exynos_dp_device *dp = display->ctx;
886 int ret;
887
Ajay Kumar5f1dcd82014-07-31 23:12:14 +0530888 /* Keep the panel disabled while we configure video */
889 if (dp->panel) {
890 if (drm_panel_disable(dp->panel))
891 DRM_ERROR("failed to disable the panel\n");
892 }
893
Sean Paul784fa9a2012-11-09 13:55:08 +0900894 ret = exynos_dp_detect_hpd(dp);
895 if (ret) {
Sean Paulc30ffb92012-11-01 19:13:46 +0900896 /* Cable has been disconnected, we're done */
Sean Paul784fa9a2012-11-09 13:55:08 +0900897 return;
898 }
899
900 ret = exynos_dp_handle_edid(dp);
901 if (ret) {
902 dev_err(dp->dev, "unable to handle edid\n");
903 return;
904 }
905
906 ret = exynos_dp_set_link_train(dp, dp->video_info->lane_count,
907 dp->video_info->link_rate);
908 if (ret) {
909 dev_err(dp->dev, "unable to do link train\n");
910 return;
911 }
912
913 exynos_dp_enable_scramble(dp, 1);
914 exynos_dp_enable_rx_to_enhanced_mode(dp, 1);
915 exynos_dp_enable_enhanced_mode(dp, 1);
916
917 exynos_dp_set_lane_count(dp, dp->video_info->lane_count);
918 exynos_dp_set_link_bandwidth(dp, dp->video_info->link_rate);
919
920 exynos_dp_init_video(dp);
Ajay Kumar3fcb6eb2012-11-09 14:05:06 +0900921 ret = exynos_dp_config_video(dp);
Sean Paul784fa9a2012-11-09 13:55:08 +0900922 if (ret)
923 dev_err(dp->dev, "unable to config video\n");
Ajay Kumar5f1dcd82014-07-31 23:12:14 +0530924
925 /* Safe to enable the panel now */
926 if (dp->panel) {
927 if (drm_panel_enable(dp->panel))
928 DRM_ERROR("failed to enable the panel\n");
929 }
Sean Paul784fa9a2012-11-09 13:55:08 +0900930}
931
Sean Paulcaa5d1e2014-01-30 16:19:30 -0500932static enum drm_connector_status exynos_dp_detect(
933 struct drm_connector *connector, bool force)
Sean Paul1417f102014-01-30 16:19:23 -0500934{
Sean Paulcaa5d1e2014-01-30 16:19:30 -0500935 return connector_status_connected;
Sean Paul1417f102014-01-30 16:19:23 -0500936}
937
Sean Paulcaa5d1e2014-01-30 16:19:30 -0500938static void exynos_dp_connector_destroy(struct drm_connector *connector)
939{
940}
941
942static struct drm_connector_funcs exynos_dp_connector_funcs = {
943 .dpms = drm_helper_connector_dpms,
944 .fill_modes = drm_helper_probe_single_connector_modes,
945 .detect = exynos_dp_detect,
946 .destroy = exynos_dp_connector_destroy,
947};
948
949static int exynos_dp_get_modes(struct drm_connector *connector)
950{
951 struct exynos_dp_device *dp = ctx_from_connector(connector);
952 struct drm_display_mode *mode;
953
Ajay Kumar5f1dcd82014-07-31 23:12:14 +0530954 if (dp->panel)
955 return drm_panel_get_modes(dp->panel);
956
Sean Paulcaa5d1e2014-01-30 16:19:30 -0500957 mode = drm_mode_create(connector->dev);
958 if (!mode) {
959 DRM_ERROR("failed to create a new display mode.\n");
960 return 0;
961 }
962
Ajay Kumar5f1dcd82014-07-31 23:12:14 +0530963 drm_display_mode_from_videomode(&dp->priv.vm, mode);
964 mode->width_mm = dp->priv.width_mm;
965 mode->height_mm = dp->priv.height_mm;
Sean Paulcaa5d1e2014-01-30 16:19:30 -0500966 connector->display_info.width_mm = mode->width_mm;
967 connector->display_info.height_mm = mode->height_mm;
968
969 mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
970 drm_mode_set_name(mode);
971 drm_mode_probed_add(connector, mode);
972
973 return 1;
974}
975
Sean Paulcaa5d1e2014-01-30 16:19:30 -0500976static struct drm_encoder *exynos_dp_best_encoder(
977 struct drm_connector *connector)
978{
979 struct exynos_dp_device *dp = ctx_from_connector(connector);
980
981 return dp->encoder;
982}
983
984static struct drm_connector_helper_funcs exynos_dp_connector_helper_funcs = {
985 .get_modes = exynos_dp_get_modes,
Sean Paulcaa5d1e2014-01-30 16:19:30 -0500986 .best_encoder = exynos_dp_best_encoder,
987};
988
Sean Paul1634ba22014-02-24 19:20:15 +0900989static bool find_bridge(const char *compat, struct bridge_init *bridge)
990{
991 bridge->client = NULL;
992 bridge->node = of_find_compatible_node(NULL, NULL, compat);
993 if (!bridge->node)
994 return false;
995
996 bridge->client = of_find_i2c_device_by_node(bridge->node);
997 if (!bridge->client)
998 return false;
999
1000 return true;
1001}
1002
1003/* returns the number of bridges attached */
1004static int exynos_drm_attach_lcd_bridge(struct drm_device *dev,
1005 struct drm_encoder *encoder)
1006{
1007 struct bridge_init bridge;
1008 int ret;
1009
1010 if (find_bridge("nxp,ptn3460", &bridge)) {
1011 ret = ptn3460_init(dev, encoder, bridge.client, bridge.node);
1012 if (!ret)
1013 return 1;
1014 }
1015 return 0;
1016}
1017
Sean Paulcaa5d1e2014-01-30 16:19:30 -05001018static int exynos_dp_create_connector(struct exynos_drm_display *display,
1019 struct drm_encoder *encoder)
Sean Paul1417f102014-01-30 16:19:23 -05001020{
Sean Paulcaa5d1e2014-01-30 16:19:30 -05001021 struct exynos_dp_device *dp = display->ctx;
1022 struct drm_connector *connector = &dp->connector;
1023 int ret;
1024
1025 dp->encoder = encoder;
Sean Paul1634ba22014-02-24 19:20:15 +09001026
1027 /* Pre-empt DP connector creation if there's a bridge */
1028 ret = exynos_drm_attach_lcd_bridge(dp->drm_dev, encoder);
1029 if (ret)
1030 return 0;
1031
Sean Paulcaa5d1e2014-01-30 16:19:30 -05001032 connector->polled = DRM_CONNECTOR_POLL_HPD;
1033
1034 ret = drm_connector_init(dp->drm_dev, connector,
1035 &exynos_dp_connector_funcs, DRM_MODE_CONNECTOR_eDP);
1036 if (ret) {
1037 DRM_ERROR("Failed to initialize connector with drm\n");
1038 return ret;
1039 }
1040
1041 drm_connector_helper_add(connector, &exynos_dp_connector_helper_funcs);
Thomas Wood34ea3d32014-05-29 16:57:41 +01001042 drm_connector_register(connector);
Sean Paulcaa5d1e2014-01-30 16:19:30 -05001043 drm_mode_connector_attach_encoder(connector, encoder);
1044
Ajay Kumar5f1dcd82014-07-31 23:12:14 +05301045 if (dp->panel)
1046 ret = drm_panel_attach(dp->panel, &dp->connector);
1047
1048 return ret;
Sean Paul1417f102014-01-30 16:19:23 -05001049}
1050
Sean Paul12f5ad62014-01-30 16:19:25 -05001051static void exynos_dp_phy_init(struct exynos_dp_device *dp)
1052{
1053 if (dp->phy) {
1054 phy_power_on(dp->phy);
1055 } else if (dp->phy_addr) {
1056 u32 reg;
1057
1058 reg = __raw_readl(dp->phy_addr);
1059 reg |= dp->enable_mask;
1060 __raw_writel(reg, dp->phy_addr);
1061 }
1062}
1063
1064static void exynos_dp_phy_exit(struct exynos_dp_device *dp)
1065{
1066 if (dp->phy) {
1067 phy_power_off(dp->phy);
1068 } else if (dp->phy_addr) {
1069 u32 reg;
1070
1071 reg = __raw_readl(dp->phy_addr);
1072 reg &= ~(dp->enable_mask);
1073 __raw_writel(reg, dp->phy_addr);
1074 }
1075}
1076
Ajay Kumar4deabfa2014-07-31 23:12:13 +05301077static void exynos_dp_poweron(struct exynos_drm_display *display)
Sean Paul12f5ad62014-01-30 16:19:25 -05001078{
Ajay Kumar4deabfa2014-07-31 23:12:13 +05301079 struct exynos_dp_device *dp = display->ctx;
1080
Sean Paul12f5ad62014-01-30 16:19:25 -05001081 if (dp->dpms_mode == DRM_MODE_DPMS_ON)
1082 return;
1083
Ajay Kumar5f1dcd82014-07-31 23:12:14 +05301084 if (dp->panel) {
1085 if (drm_panel_prepare(dp->panel)) {
1086 DRM_ERROR("failed to setup the panel\n");
1087 return;
1088 }
1089 }
1090
Sean Paul12f5ad62014-01-30 16:19:25 -05001091 clk_prepare_enable(dp->clock);
1092 exynos_dp_phy_init(dp);
1093 exynos_dp_init_dp(dp);
1094 enable_irq(dp->irq);
Ajay Kumar4deabfa2014-07-31 23:12:13 +05301095 exynos_dp_commit(display);
Sean Paul12f5ad62014-01-30 16:19:25 -05001096}
1097
Ajay Kumar4deabfa2014-07-31 23:12:13 +05301098static void exynos_dp_poweroff(struct exynos_drm_display *display)
Sean Paul12f5ad62014-01-30 16:19:25 -05001099{
Ajay Kumar4deabfa2014-07-31 23:12:13 +05301100 struct exynos_dp_device *dp = display->ctx;
1101
Sean Paul12f5ad62014-01-30 16:19:25 -05001102 if (dp->dpms_mode != DRM_MODE_DPMS_ON)
1103 return;
1104
Ajay Kumar5f1dcd82014-07-31 23:12:14 +05301105 if (dp->panel) {
1106 if (drm_panel_disable(dp->panel)) {
1107 DRM_ERROR("failed to disable the panel\n");
1108 return;
1109 }
1110 }
1111
Sean Paul12f5ad62014-01-30 16:19:25 -05001112 disable_irq(dp->irq);
1113 flush_work(&dp->hotplug_work);
1114 exynos_dp_phy_exit(dp);
1115 clk_disable_unprepare(dp->clock);
Ajay Kumar5f1dcd82014-07-31 23:12:14 +05301116
1117 if (dp->panel) {
1118 if (drm_panel_unprepare(dp->panel))
1119 DRM_ERROR("failed to turnoff the panel\n");
1120 }
Sean Paul12f5ad62014-01-30 16:19:25 -05001121}
1122
1123static void exynos_dp_dpms(struct exynos_drm_display *display, int mode)
1124{
1125 struct exynos_dp_device *dp = display->ctx;
1126
1127 switch (mode) {
1128 case DRM_MODE_DPMS_ON:
Ajay Kumar4deabfa2014-07-31 23:12:13 +05301129 exynos_dp_poweron(display);
Sean Paul12f5ad62014-01-30 16:19:25 -05001130 break;
1131 case DRM_MODE_DPMS_STANDBY:
1132 case DRM_MODE_DPMS_SUSPEND:
1133 case DRM_MODE_DPMS_OFF:
Ajay Kumar4deabfa2014-07-31 23:12:13 +05301134 exynos_dp_poweroff(display);
Sean Paul12f5ad62014-01-30 16:19:25 -05001135 break;
1136 default:
1137 break;
Damien Lespiau10d9b4e2014-06-09 14:21:08 +01001138 }
Sean Paul12f5ad62014-01-30 16:19:25 -05001139 dp->dpms_mode = mode;
1140}
1141
Sean Paul1417f102014-01-30 16:19:23 -05001142static struct exynos_drm_display_ops exynos_dp_display_ops = {
Sean Paulcaa5d1e2014-01-30 16:19:30 -05001143 .create_connector = exynos_dp_create_connector,
Sean Paul12f5ad62014-01-30 16:19:25 -05001144 .dpms = exynos_dp_dpms,
Ajay Kumar4deabfa2014-07-31 23:12:13 +05301145 .commit = exynos_dp_commit,
Sean Paul1417f102014-01-30 16:19:23 -05001146};
1147
1148static struct exynos_drm_display exynos_dp_display = {
1149 .type = EXYNOS_DISPLAY_TYPE_LCD,
1150 .ops = &exynos_dp_display_ops,
1151};
1152
Jingoo Hanf9b1e012013-10-16 21:58:15 +05301153static struct video_info *exynos_dp_dt_parse_pdata(struct device *dev)
Ajay Kumarc4e235c2012-10-13 05:48:00 +09001154{
1155 struct device_node *dp_node = dev->of_node;
Ajay Kumarc4e235c2012-10-13 05:48:00 +09001156 struct video_info *dp_video_config;
1157
Ajay Kumarc4e235c2012-10-13 05:48:00 +09001158 dp_video_config = devm_kzalloc(dev,
1159 sizeof(*dp_video_config), GFP_KERNEL);
Jingoo Han7a5b68272014-04-17 19:08:14 +09001160 if (!dp_video_config)
Ajay Kumarc4e235c2012-10-13 05:48:00 +09001161 return ERR_PTR(-ENOMEM);
Ajay Kumarc4e235c2012-10-13 05:48:00 +09001162
1163 dp_video_config->h_sync_polarity =
1164 of_property_read_bool(dp_node, "hsync-active-high");
1165
1166 dp_video_config->v_sync_polarity =
1167 of_property_read_bool(dp_node, "vsync-active-high");
1168
1169 dp_video_config->interlaced =
1170 of_property_read_bool(dp_node, "interlaced");
1171
1172 if (of_property_read_u32(dp_node, "samsung,color-space",
1173 &dp_video_config->color_space)) {
1174 dev_err(dev, "failed to get color-space\n");
1175 return ERR_PTR(-EINVAL);
1176 }
1177
1178 if (of_property_read_u32(dp_node, "samsung,dynamic-range",
1179 &dp_video_config->dynamic_range)) {
1180 dev_err(dev, "failed to get dynamic-range\n");
1181 return ERR_PTR(-EINVAL);
1182 }
1183
1184 if (of_property_read_u32(dp_node, "samsung,ycbcr-coeff",
1185 &dp_video_config->ycbcr_coeff)) {
1186 dev_err(dev, "failed to get ycbcr-coeff\n");
1187 return ERR_PTR(-EINVAL);
1188 }
1189
1190 if (of_property_read_u32(dp_node, "samsung,color-depth",
1191 &dp_video_config->color_depth)) {
1192 dev_err(dev, "failed to get color-depth\n");
1193 return ERR_PTR(-EINVAL);
1194 }
1195
1196 if (of_property_read_u32(dp_node, "samsung,link-rate",
1197 &dp_video_config->link_rate)) {
1198 dev_err(dev, "failed to get link-rate\n");
1199 return ERR_PTR(-EINVAL);
1200 }
1201
1202 if (of_property_read_u32(dp_node, "samsung,lane-count",
1203 &dp_video_config->lane_count)) {
1204 dev_err(dev, "failed to get lane-count\n");
1205 return ERR_PTR(-EINVAL);
1206 }
1207
Jingoo Hanf9b1e012013-10-16 21:58:15 +05301208 return dp_video_config;
Ajay Kumarc4e235c2012-10-13 05:48:00 +09001209}
1210
1211static int exynos_dp_dt_parse_phydata(struct exynos_dp_device *dp)
1212{
Jingoo Hand3ed9702013-02-21 16:42:37 -08001213 struct device_node *dp_phy_node = of_node_get(dp->dev->of_node);
Ajay Kumarc4e235c2012-10-13 05:48:00 +09001214 u32 phy_base;
Jingoo Hand3ed9702013-02-21 16:42:37 -08001215 int ret = 0;
Ajay Kumarc4e235c2012-10-13 05:48:00 +09001216
Jingoo Hand3ed9702013-02-21 16:42:37 -08001217 dp_phy_node = of_find_node_by_name(dp_phy_node, "dptx-phy");
Ajay Kumarc4e235c2012-10-13 05:48:00 +09001218 if (!dp_phy_node) {
Jingoo Han8114fab2013-10-16 21:58:16 +05301219 dp->phy = devm_phy_get(dp->dev, "dp");
Sachin Kamat97f98a32014-05-29 11:26:24 +05301220 return PTR_ERR_OR_ZERO(dp->phy);
Ajay Kumarc4e235c2012-10-13 05:48:00 +09001221 }
1222
1223 if (of_property_read_u32(dp_phy_node, "reg", &phy_base)) {
Masanari Iida1051e9b2013-03-31 01:23:50 +09001224 dev_err(dp->dev, "failed to get reg for dptx-phy\n");
Jingoo Hand3ed9702013-02-21 16:42:37 -08001225 ret = -EINVAL;
1226 goto err;
Ajay Kumarc4e235c2012-10-13 05:48:00 +09001227 }
1228
1229 if (of_property_read_u32(dp_phy_node, "samsung,enable-mask",
1230 &dp->enable_mask)) {
Masanari Iida1051e9b2013-03-31 01:23:50 +09001231 dev_err(dp->dev, "failed to get enable-mask for dptx-phy\n");
Jingoo Hand3ed9702013-02-21 16:42:37 -08001232 ret = -EINVAL;
1233 goto err;
Ajay Kumarc4e235c2012-10-13 05:48:00 +09001234 }
1235
1236 dp->phy_addr = ioremap(phy_base, SZ_4);
1237 if (!dp->phy_addr) {
1238 dev_err(dp->dev, "failed to ioremap dp-phy\n");
Jingoo Hand3ed9702013-02-21 16:42:37 -08001239 ret = -ENOMEM;
1240 goto err;
Ajay Kumarc4e235c2012-10-13 05:48:00 +09001241 }
1242
Jingoo Hand3ed9702013-02-21 16:42:37 -08001243err:
1244 of_node_put(dp_phy_node);
1245
1246 return ret;
Ajay Kumarc4e235c2012-10-13 05:48:00 +09001247}
1248
Sean Paul1417f102014-01-30 16:19:23 -05001249static int exynos_dp_dt_parse_panel(struct exynos_dp_device *dp)
1250{
1251 int ret;
1252
Ajay Kumar5f1dcd82014-07-31 23:12:14 +05301253 ret = of_get_videomode(dp->dev->of_node, &dp->priv.vm,
Sean Paul1417f102014-01-30 16:19:23 -05001254 OF_USE_NATIVE_MODE);
1255 if (ret) {
1256 DRM_ERROR("failed: of_get_videomode() : %d\n", ret);
1257 return ret;
1258 }
1259 return 0;
1260}
1261
Inki Daef37cd5e2014-05-09 14:25:20 +09001262static int exynos_dp_bind(struct device *dev, struct device *master, void *data)
Jingoo Hane9474be2012-02-03 18:01:55 +09001263{
Inki Daef37cd5e2014-05-09 14:25:20 +09001264 struct platform_device *pdev = to_platform_device(dev);
1265 struct drm_device *drm_dev = data;
Jingoo Hane9474be2012-02-03 18:01:55 +09001266 struct resource *res;
Ajay Kumar5f1dcd82014-07-31 23:12:14 +05301267 struct exynos_dp_device *dp = exynos_dp_display.ctx;
Andrew Brestickerb8b52472014-04-22 04:09:10 +05301268 unsigned int irq_flags;
Jingoo Hane9474be2012-02-03 18:01:55 +09001269 int ret = 0;
1270
Jingoo Hane9474be2012-02-03 18:01:55 +09001271 dp->dev = &pdev->dev;
Sean Paul12f5ad62014-01-30 16:19:25 -05001272 dp->dpms_mode = DRM_MODE_DPMS_OFF;
Jingoo Hane9474be2012-02-03 18:01:55 +09001273
Jingoo Hanf9b1e012013-10-16 21:58:15 +05301274 dp->video_info = exynos_dp_dt_parse_pdata(&pdev->dev);
1275 if (IS_ERR(dp->video_info))
1276 return PTR_ERR(dp->video_info);
Ajay Kumarc4e235c2012-10-13 05:48:00 +09001277
Jingoo Hanf9b1e012013-10-16 21:58:15 +05301278 ret = exynos_dp_dt_parse_phydata(dp);
1279 if (ret)
1280 return ret;
Ajay Kumarc4e235c2012-10-13 05:48:00 +09001281
Ajay Kumar5f1dcd82014-07-31 23:12:14 +05301282 if (!dp->panel) {
1283 ret = exynos_dp_dt_parse_panel(dp);
1284 if (ret)
1285 return ret;
1286 }
Sean Paul1417f102014-01-30 16:19:23 -05001287
Damien Cassoud913f362012-08-01 18:20:39 +02001288 dp->clock = devm_clk_get(&pdev->dev, "dp");
Jingoo Hane9474be2012-02-03 18:01:55 +09001289 if (IS_ERR(dp->clock)) {
1290 dev_err(&pdev->dev, "failed to get clock\n");
Jingoo Han4d10ecf82012-05-25 16:20:45 +09001291 return PTR_ERR(dp->clock);
Jingoo Hane9474be2012-02-03 18:01:55 +09001292 }
1293
Jingoo Han37414fb2012-10-04 15:45:14 +09001294 clk_prepare_enable(dp->clock);
Jingoo Hane9474be2012-02-03 18:01:55 +09001295
1296 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
Jingoo Hane9474be2012-02-03 18:01:55 +09001297
Thierry Redingbc3bad12013-01-21 11:09:23 +01001298 dp->reg_base = devm_ioremap_resource(&pdev->dev, res);
1299 if (IS_ERR(dp->reg_base))
1300 return PTR_ERR(dp->reg_base);
Jingoo Hane9474be2012-02-03 18:01:55 +09001301
Andrew Brestickerb8b52472014-04-22 04:09:10 +05301302 dp->hpd_gpio = of_get_named_gpio(dev->of_node, "samsung,hpd-gpio", 0);
1303
1304 if (gpio_is_valid(dp->hpd_gpio)) {
1305 /*
1306 * Set up the hotplug GPIO from the device tree as an interrupt.
1307 * Simply specifying a different interrupt in the device tree
1308 * doesn't work since we handle hotplug rather differently when
1309 * using a GPIO. We also need the actual GPIO specifier so
1310 * that we can get the current state of the GPIO.
1311 */
1312 ret = devm_gpio_request_one(&pdev->dev, dp->hpd_gpio, GPIOF_IN,
1313 "hpd_gpio");
1314 if (ret) {
1315 dev_err(&pdev->dev, "failed to get hpd gpio\n");
1316 return ret;
1317 }
1318 dp->irq = gpio_to_irq(dp->hpd_gpio);
1319 irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING;
1320 } else {
1321 dp->hpd_gpio = -ENODEV;
1322 dp->irq = platform_get_irq(pdev, 0);
1323 irq_flags = 0;
1324 }
1325
Sean Paul1cefc1d2012-10-31 23:21:00 +00001326 if (dp->irq == -ENXIO) {
Jingoo Hane9474be2012-02-03 18:01:55 +09001327 dev_err(&pdev->dev, "failed to get irq\n");
Damien Cassoud913f362012-08-01 18:20:39 +02001328 return -ENODEV;
Jingoo Hane9474be2012-02-03 18:01:55 +09001329 }
1330
Sean Paul784fa9a2012-11-09 13:55:08 +09001331 INIT_WORK(&dp->hotplug_work, exynos_dp_hotplug);
1332
Jingoo Hanf9b1e012013-10-16 21:58:15 +05301333 exynos_dp_phy_init(dp);
Jingoo Hane9474be2012-02-03 18:01:55 +09001334
1335 exynos_dp_init_dp(dp);
1336
Andrew Brestickerb8b52472014-04-22 04:09:10 +05301337 ret = devm_request_irq(&pdev->dev, dp->irq, exynos_dp_irq_handler,
1338 irq_flags, "exynos-dp", dp);
Ajay Kumar22ce19c2012-11-09 13:59:09 +09001339 if (ret) {
1340 dev_err(&pdev->dev, "failed to request irq\n");
1341 return ret;
1342 }
Sean Paul12f5ad62014-01-30 16:19:25 -05001343 disable_irq(dp->irq);
Jingoo Hane9474be2012-02-03 18:01:55 +09001344
Inki Daef37cd5e2014-05-09 14:25:20 +09001345 dp->drm_dev = drm_dev;
Sean Paul12f5ad62014-01-30 16:19:25 -05001346
1347 platform_set_drvdata(pdev, &exynos_dp_display);
Sean Paul1417f102014-01-30 16:19:23 -05001348
Inki Daef37cd5e2014-05-09 14:25:20 +09001349 return exynos_drm_create_enc_conn(drm_dev, &exynos_dp_display);
1350}
1351
1352static void exynos_dp_unbind(struct device *dev, struct device *master,
1353 void *data)
1354{
1355 struct exynos_drm_display *display = dev_get_drvdata(dev);
1356 struct exynos_dp_device *dp = display->ctx;
1357 struct drm_encoder *encoder = dp->encoder;
1358
1359 exynos_dp_dpms(display, DRM_MODE_DPMS_OFF);
1360
1361 encoder->funcs->destroy(encoder);
1362 drm_connector_cleanup(&dp->connector);
1363}
1364
1365static const struct component_ops exynos_dp_ops = {
1366 .bind = exynos_dp_bind,
1367 .unbind = exynos_dp_unbind,
1368};
1369
1370static int exynos_dp_probe(struct platform_device *pdev)
1371{
Ajay Kumar5f1dcd82014-07-31 23:12:14 +05301372 struct device *dev = &pdev->dev;
1373 struct device_node *panel_node;
1374 struct exynos_dp_device *dp;
Inki Daedf5225b2014-05-29 18:28:02 +09001375 int ret;
1376
1377 ret = exynos_drm_component_add(&pdev->dev, EXYNOS_DEVICE_TYPE_CONNECTOR,
1378 exynos_dp_display.type);
1379 if (ret)
1380 return ret;
1381
Ajay Kumar5f1dcd82014-07-31 23:12:14 +05301382 dp = devm_kzalloc(&pdev->dev, sizeof(struct exynos_dp_device),
1383 GFP_KERNEL);
1384 if (!dp)
1385 return -ENOMEM;
1386
1387 panel_node = of_parse_phandle(dev->of_node, "panel", 0);
1388 if (panel_node) {
1389 dp->panel = of_drm_find_panel(panel_node);
1390 of_node_put(panel_node);
1391 if (!dp->panel)
1392 return -EPROBE_DEFER;
1393 }
1394
1395 exynos_dp_display.ctx = dp;
1396
Inki Daedf5225b2014-05-29 18:28:02 +09001397 ret = component_add(&pdev->dev, &exynos_dp_ops);
1398 if (ret)
1399 exynos_drm_component_del(&pdev->dev,
1400 EXYNOS_DEVICE_TYPE_CONNECTOR);
1401
1402 return ret;
Jingoo Hane9474be2012-02-03 18:01:55 +09001403}
1404
Greg Kroah-Hartman48c68c42012-12-21 13:07:39 -08001405static int exynos_dp_remove(struct platform_device *pdev)
Jingoo Hane9474be2012-02-03 18:01:55 +09001406{
Inki Daedf5225b2014-05-29 18:28:02 +09001407 component_del(&pdev->dev, &exynos_dp_ops);
1408 exynos_drm_component_del(&pdev->dev, EXYNOS_DEVICE_TYPE_CONNECTOR);
1409
Jingoo Hane9474be2012-02-03 18:01:55 +09001410 return 0;
1411}
1412
1413#ifdef CONFIG_PM_SLEEP
1414static int exynos_dp_suspend(struct device *dev)
1415{
Sean Paul12f5ad62014-01-30 16:19:25 -05001416 struct platform_device *pdev = to_platform_device(dev);
1417 struct exynos_drm_display *display = platform_get_drvdata(pdev);
Jingoo Hane9474be2012-02-03 18:01:55 +09001418
Sean Paul12f5ad62014-01-30 16:19:25 -05001419 exynos_dp_dpms(display, DRM_MODE_DPMS_OFF);
Jingoo Hane9474be2012-02-03 18:01:55 +09001420 return 0;
1421}
1422
1423static int exynos_dp_resume(struct device *dev)
1424{
Sean Paul12f5ad62014-01-30 16:19:25 -05001425 struct platform_device *pdev = to_platform_device(dev);
1426 struct exynos_drm_display *display = platform_get_drvdata(pdev);
Jingoo Hane9474be2012-02-03 18:01:55 +09001427
Sean Paul12f5ad62014-01-30 16:19:25 -05001428 exynos_dp_dpms(display, DRM_MODE_DPMS_ON);
Jingoo Hane9474be2012-02-03 18:01:55 +09001429 return 0;
1430}
1431#endif
1432
1433static const struct dev_pm_ops exynos_dp_pm_ops = {
1434 SET_SYSTEM_SLEEP_PM_OPS(exynos_dp_suspend, exynos_dp_resume)
1435};
1436
Ajay Kumarc4e235c2012-10-13 05:48:00 +09001437static const struct of_device_id exynos_dp_match[] = {
1438 { .compatible = "samsung,exynos5-dp" },
1439 {},
1440};
Sjoerd Simonsbd024b82014-07-30 11:29:41 +09001441MODULE_DEVICE_TABLE(of, exynos_dp_match);
Ajay Kumarc4e235c2012-10-13 05:48:00 +09001442
Sean Paul1417f102014-01-30 16:19:23 -05001443struct platform_driver dp_driver = {
Jingoo Hane9474be2012-02-03 18:01:55 +09001444 .probe = exynos_dp_probe,
Greg Kroah-Hartman48c68c42012-12-21 13:07:39 -08001445 .remove = exynos_dp_remove,
Jingoo Hane9474be2012-02-03 18:01:55 +09001446 .driver = {
1447 .name = "exynos-dp",
1448 .owner = THIS_MODULE,
1449 .pm = &exynos_dp_pm_ops,
Jingoo Hanf9b1e012013-10-16 21:58:15 +05301450 .of_match_table = exynos_dp_match,
Jingoo Hane9474be2012-02-03 18:01:55 +09001451 },
1452};
1453
Jingoo Hane9474be2012-02-03 18:01:55 +09001454MODULE_AUTHOR("Jingoo Han <jg1.han@samsung.com>");
1455MODULE_DESCRIPTION("Samsung SoC DP Driver");
Jingoo Han8f589bb2014-06-03 21:46:11 +09001456MODULE_LICENSE("GPL v2");