summaryrefslogtreecommitdiff
path: root/drivers/video/nexell_display.c
blob: 5595796a678b6d4b34a0dce6dac9d305e8e5b22e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
// SPDX-License-Identifier: GPL-2.0+
/*
 * Copyright (C) 2016  Nexell Co., Ltd.
 *
 * Author: junghyun, kim <jhkim@nexell.co.kr>
 *
 * Copyright (C) 2020  Stefan Bosch <stefan_b@posteo.net>
 */

#include <config.h>
#include <common.h>
#include <command.h>
#include <dm.h>
#include <mapmem.h>
#include <malloc.h>
#include <linux/compat.h>
#include <linux/err.h>
#include <video.h>		/* For struct video_uc_plat */
#include <asm/global_data.h>
#include <asm/io.h>
#include <asm/arch/display.h>
#include <asm/arch/display_dev.h>
#include "videomodes.h"

DECLARE_GLOBAL_DATA_PTR;

#if !defined(CONFIG_DM) && !defined(CONFIG_OF_CONTROL)
static struct nx_display_dev *dp_dev;
#endif

static char *const dp_dev_str[] = {
	[DP_DEVICE_RESCONV] = "RESCONV",
	[DP_DEVICE_RGBLCD] = "LCD",
	[DP_DEVICE_HDMI] = "HDMI",
	[DP_DEVICE_MIPI] = "MiPi",
	[DP_DEVICE_LVDS] = "LVDS",
	[DP_DEVICE_CVBS] = "TVOUT",
	[DP_DEVICE_DP0] = "DP0",
	[DP_DEVICE_DP1] = "DP1",
};

#if CONFIG_IS_ENABLED(OF_CONTROL)
static void nx_display_parse_dp_sync(ofnode node, struct dp_sync_info *sync)
{
	sync->h_active_len = ofnode_read_s32_default(node, "h_active_len", 0);
	sync->h_sync_width = ofnode_read_s32_default(node, "h_sync_width", 0);
	sync->h_back_porch = ofnode_read_s32_default(node, "h_back_porch", 0);
	sync->h_front_porch = ofnode_read_s32_default(node, "h_front_porch", 0);
	sync->h_sync_invert = ofnode_read_s32_default(node, "h_sync_invert", 0);
	sync->v_active_len = ofnode_read_s32_default(node, "v_active_len", 0);
	sync->v_sync_width = ofnode_read_s32_default(node, "v_sync_width", 0);
	sync->v_back_porch = ofnode_read_s32_default(node, "v_back_porch", 0);
	sync->v_front_porch = ofnode_read_s32_default(node, "v_front_porch", 0);
	sync->v_sync_invert = ofnode_read_s32_default(node, "v_sync_invert", 0);
	sync->pixel_clock_hz = ofnode_read_s32_default(node, "pixel_clock_hz", 0);

	debug("DP: sync ->\n");
	debug("ha:%d, hs:%d, hb:%d, hf:%d, hi:%d\n",
	      sync->h_active_len, sync->h_sync_width,
	      sync->h_back_porch, sync->h_front_porch, sync->h_sync_invert);
	debug("va:%d, vs:%d, vb:%d, vf:%d, vi:%d\n",
	      sync->v_active_len, sync->v_sync_width,
	      sync->v_back_porch, sync->v_front_porch, sync->v_sync_invert);
}

static void nx_display_parse_dp_ctrl(ofnode node, struct dp_ctrl_info *ctrl)
{
	/* clock gen */
	ctrl->clk_src_lv0 = ofnode_read_s32_default(node, "clk_src_lv0", 0);
	ctrl->clk_div_lv0 = ofnode_read_s32_default(node, "clk_div_lv0", 0);
	ctrl->clk_src_lv1 = ofnode_read_s32_default(node, "clk_src_lv1", 0);
	ctrl->clk_div_lv1 = ofnode_read_s32_default(node, "clk_div_lv1", 0);

	/* scan format */
	ctrl->interlace = ofnode_read_s32_default(node, "interlace", 0);

	/* syncgen format */
	ctrl->out_format = ofnode_read_s32_default(node, "out_format", 0);
	ctrl->invert_field = ofnode_read_s32_default(node, "invert_field", 0);
	ctrl->swap_RB = ofnode_read_s32_default(node, "swap_RB", 0);
	ctrl->yc_order = ofnode_read_s32_default(node, "yc_order", 0);

	/* extern sync delay */
	ctrl->delay_mask = ofnode_read_s32_default(node, "delay_mask", 0);
	ctrl->d_rgb_pvd = ofnode_read_s32_default(node, "d_rgb_pvd", 0);
	ctrl->d_hsync_cp1 = ofnode_read_s32_default(node, "d_hsync_cp1", 0);
	ctrl->d_vsync_fram = ofnode_read_s32_default(node, "d_vsync_fram", 0);
	ctrl->d_de_cp2 = ofnode_read_s32_default(node, "d_de_cp2", 0);

	/* extern sync delay */
	ctrl->vs_start_offset =
	    ofnode_read_s32_default(node, "vs_start_offset", 0);
	ctrl->vs_end_offset = ofnode_read_s32_default(node, "vs_end_offset", 0);
	ctrl->ev_start_offset =
	    ofnode_read_s32_default(node, "ev_start_offset", 0);
	ctrl->ev_end_offset = ofnode_read_s32_default(node, "ev_end_offset", 0);

	/* pad clock seletor */
	ctrl->vck_select = ofnode_read_s32_default(node, "vck_select", 0);
	ctrl->clk_inv_lv0 = ofnode_read_s32_default(node, "clk_inv_lv0", 0);
	ctrl->clk_delay_lv0 = ofnode_read_s32_default(node, "clk_delay_lv0", 0);
	ctrl->clk_inv_lv1 = ofnode_read_s32_default(node, "clk_inv_lv1", 0);
	ctrl->clk_delay_lv1 = ofnode_read_s32_default(node, "clk_delay_lv1", 0);
	ctrl->clk_sel_div1 = ofnode_read_s32_default(node, "clk_sel_div1", 0);

	debug("DP: ctrl [%s] ->\n",
	      ctrl->interlace ? "Interlace" : " Progressive");
	debug("cs0:%d, cd0:%d, cs1:%d, cd1:%d\n",
	      ctrl->clk_src_lv0, ctrl->clk_div_lv0,
	      ctrl->clk_src_lv1, ctrl->clk_div_lv1);
	debug("fmt:0x%x, inv:%d, swap:%d, yb:0x%x\n",
	      ctrl->out_format, ctrl->invert_field,
	      ctrl->swap_RB, ctrl->yc_order);
	debug("dm:0x%x, drp:%d, dhs:%d, dvs:%d, dde:0x%x\n",
	      ctrl->delay_mask, ctrl->d_rgb_pvd,
	      ctrl->d_hsync_cp1, ctrl->d_vsync_fram, ctrl->d_de_cp2);
	debug("vss:%d, vse:%d, evs:%d, eve:%d\n",
	      ctrl->vs_start_offset, ctrl->vs_end_offset,
	      ctrl->ev_start_offset, ctrl->ev_end_offset);
	debug("sel:%d, i0:%d, d0:%d, i1:%d, d1:%d, s1:%d\n",
	      ctrl->vck_select, ctrl->clk_inv_lv0, ctrl->clk_delay_lv0,
	      ctrl->clk_inv_lv1, ctrl->clk_delay_lv1, ctrl->clk_sel_div1);
}

static void nx_display_parse_dp_top_layer(ofnode node, struct dp_plane_top *top)
{
	top->screen_width = ofnode_read_s32_default(node, "screen_width", 0);
	top->screen_height = ofnode_read_s32_default(node, "screen_height", 0);
	top->video_prior = ofnode_read_s32_default(node, "video_prior", 0);
	top->interlace = ofnode_read_s32_default(node, "interlace", 0);
	top->back_color = ofnode_read_s32_default(node, "back_color", 0);
	top->plane_num = DP_PLANS_NUM;

	debug("DP: top [%s] ->\n",
	      top->interlace ? "Interlace" : " Progressive");
	debug("w:%d, h:%d, prior:%d, bg:0x%x\n",
	      top->screen_width, top->screen_height,
	      top->video_prior, top->back_color);
}

static void nx_display_parse_dp_layer(ofnode node, struct dp_plane_info *plane)
{
	plane->left = ofnode_read_s32_default(node, "left", 0);
	plane->width = ofnode_read_s32_default(node, "width", 0);
	plane->top = ofnode_read_s32_default(node, "top", 0);
	plane->height = ofnode_read_s32_default(node, "height", 0);
	plane->pixel_byte = ofnode_read_s32_default(node, "pixel_byte", 0);
	plane->format = ofnode_read_s32_default(node, "format", 0);
	plane->alpha_on = ofnode_read_s32_default(node, "alpha_on", 0);
	plane->alpha_depth = ofnode_read_s32_default(node, "alpha", 0);
	plane->tp_on = ofnode_read_s32_default(node, "tp_on", 0);
	plane->tp_color = ofnode_read_s32_default(node, "tp_color", 0);

	/* enable layer */
	if (plane->fb_base)
		plane->enable = 1;
	else
		plane->enable = 0;

	if (plane->fb_base == 0) {
		printf("fail : dp plane.%d invalid fb base [0x%x] ->\n",
		       plane->layer, plane->fb_base);
		return;
	}

	debug("DP: plane.%d [0x%x] ->\n", plane->layer, plane->fb_base);
	debug("f:0x%x, l:%d, t:%d, %d * %d, bpp:%d, a:%d(%d), t:%d(0x%x)\n",
	      plane->format, plane->left, plane->top, plane->width,
	      plane->height, plane->pixel_byte, plane->alpha_on,
	      plane->alpha_depth, plane->tp_on, plane->tp_color);
}

static void nx_display_parse_dp_planes(ofnode node,
				       struct nx_display_dev *dp,
				       struct video_uc_plat *plat)
{
	const char *name;
	ofnode subnode;

	ofnode_for_each_subnode(subnode, node) {
		name = ofnode_get_name(subnode);

		if (strcmp(name, "layer_top") == 0)
			nx_display_parse_dp_top_layer(subnode, &dp->top);

		/*
		 * TODO: Is it sure that only one layer is used? Otherwise
		 * fb_base must be different?
		 */
		if (strcmp(name, "layer_0") == 0) {
			dp->planes[0].fb_base =
			      (uint)map_sysmem(plat->base, plat->size);
			debug("%s(): dp->planes[0].fb_base == 0x%x\n", __func__,
			      (uint)dp->planes[0].fb_base);
			nx_display_parse_dp_layer(subnode, &dp->planes[0]);
		}

		if (strcmp(name, "layer_1") == 0) {
			dp->planes[1].fb_base =
			      (uint)map_sysmem(plat->base, plat->size);
			debug("%s(): dp->planes[1].fb_base == 0x%x\n", __func__,
			      (uint)dp->planes[1].fb_base);
			nx_display_parse_dp_layer(subnode, &dp->planes[1]);
		}

		if (strcmp(name, "layer_2") == 0) {
			dp->planes[2].fb_base =
			      (uint)map_sysmem(plat->base, plat->size);
			debug("%s(): dp->planes[2].fb_base == 0x%x\n", __func__,
			      (uint)dp->planes[2].fb_base);
			nx_display_parse_dp_layer(subnode, &dp->planes[2]);
		}
	}
}

static int nx_display_parse_dp_lvds(ofnode node, struct nx_display_dev *dp)
{
	struct dp_lvds_dev *dev = kzalloc(sizeof(*dev), GFP_KERNEL);

	if (!dev) {
		printf("failed to allocate display LVDS object.\n");
		return -ENOMEM;
	}

	dp->device = dev;

	dev->lvds_format = ofnode_read_s32_default(node, "format", 0);
	dev->pol_inv_hs = ofnode_read_s32_default(node, "pol_inv_hs", 0);
	dev->pol_inv_vs = ofnode_read_s32_default(node, "pol_inv_vs", 0);
	dev->pol_inv_de = ofnode_read_s32_default(node, "pol_inv_de", 0);
	dev->pol_inv_ck = ofnode_read_s32_default(node, "pol_inv_ck", 0);
	dev->voltage_level = ofnode_read_s32_default(node, "voltage_level", 0);

	if (!dev->voltage_level)
		dev->voltage_level = DEF_VOLTAGE_LEVEL;

	debug("DP: LVDS -> %s, voltage LV:0x%x\n",
	      dev->lvds_format == DP_LVDS_FORMAT_VESA ? "VESA" :
	      dev->lvds_format == DP_LVDS_FORMAT_JEIDA ? "JEIDA" : "LOC",
	      dev->voltage_level);
	debug("pol inv hs:%d, vs:%d, de:%d, ck:%d\n",
	      dev->pol_inv_hs, dev->pol_inv_vs,
	      dev->pol_inv_de, dev->pol_inv_ck);

	return 0;
}

static int nx_display_parse_dp_rgb(ofnode node, struct nx_display_dev *dp)
{
	struct dp_rgb_dev *dev = kzalloc(sizeof(*dev), GFP_KERNEL);

	if (!dev) {
		printf("failed to allocate display RGB LCD object.\n");
		return -ENOMEM;
	}
	dp->device = dev;

	dev->lcd_mpu_type = ofnode_read_s32_default(node, "lcd_mpu_type", 0);

	debug("DP: RGB -> MPU[%s]\n", dev->lcd_mpu_type ? "O" : "X");
	return 0;
}

static int nx_display_parse_dp_mipi(ofnode node, struct nx_display_dev *dp)
{
	struct dp_mipi_dev *dev = kzalloc(sizeof(*dev), GFP_KERNEL);

	if (!dev) {
		printf("failed to allocate display MiPi object.\n");
		return -ENOMEM;
	}
	dp->device = dev;

	dev->lp_bitrate = ofnode_read_s32_default(node, "lp_bitrate", 0);
	dev->hs_bitrate = ofnode_read_s32_default(node, "hs_bitrate", 0);
	dev->lpm_trans = 1;
	dev->command_mode = 0;

	debug("DP: MIPI ->\n");
	debug("lp:%dmhz, hs:%dmhz\n", dev->lp_bitrate, dev->hs_bitrate);

	return 0;
}

static int nx_display_parse_dp_hdmi(ofnode node, struct nx_display_dev *dp)
{
	struct dp_hdmi_dev *dev = kzalloc(sizeof(*dev), GFP_KERNEL);

	if (!dev) {
		printf("failed to allocate display HDMI object.\n");
		return -ENOMEM;
	}
	dp->device = dev;

	dev->preset = ofnode_read_s32_default(node, "preset", 0);

	debug("DP: HDMI -> %d\n", dev->preset);

	return 0;
}

static int nx_display_parse_dp_lcds(ofnode node, const char *type,
				    struct nx_display_dev *dp)
{
	if (strcmp(type, "lvds") == 0) {
		dp->dev_type = DP_DEVICE_LVDS;
		return nx_display_parse_dp_lvds(node, dp);
	} else if (strcmp(type, "rgb") == 0) {
		dp->dev_type = DP_DEVICE_RGBLCD;
		return nx_display_parse_dp_rgb(node, dp);
	} else if (strcmp(type, "mipi") == 0) {
		dp->dev_type = DP_DEVICE_MIPI;
		return nx_display_parse_dp_mipi(node, dp);
	} else if (strcmp(type, "hdmi") == 0) {
		dp->dev_type = DP_DEVICE_HDMI;
		return nx_display_parse_dp_hdmi(node, dp);
	}

	printf("%s: node %s unknown display type\n", __func__,
	       ofnode_get_name(node));
	return -EINVAL;

	return 0;
}

#define	DT_SYNC		(1 << 0)
#define	DT_CTRL		(1 << 1)
#define	DT_PLANES	(1 << 2)
#define	DT_DEVICE	(1 << 3)

static int nx_display_parse_dt(struct udevice *dev,
			       struct nx_display_dev *dp,
			       struct video_uc_plat *plat)
{
	const char *name, *dtype;
	int ret = 0;
	unsigned int dt_status = 0;
	ofnode subnode;

	if (!dev)
		return -ENODEV;

	dp->module = dev_read_s32_default(dev, "module", -1);
	if (dp->module == -1)
		dp->module = dev_read_s32_default(dev, "index", 0);

	dtype = dev_read_string(dev, "lcd-type");

	ofnode_for_each_subnode(subnode, dev_ofnode(dev)) {
		name = ofnode_get_name(subnode);

		if (strcmp("dp-sync", name) == 0) {
			dt_status |= DT_SYNC;
			nx_display_parse_dp_sync(subnode, &dp->sync);
		}

		if (strcmp("dp-ctrl", name) == 0) {
			dt_status |= DT_CTRL;
			nx_display_parse_dp_ctrl(subnode, &dp->ctrl);
		}

		if (strcmp("dp-planes", name) == 0) {
			dt_status |= DT_PLANES;
			nx_display_parse_dp_planes(subnode, dp, plat);
		}

		if (strcmp("dp-device", name) == 0) {
			dt_status |= DT_DEVICE;
			ret = nx_display_parse_dp_lcds(subnode, dtype, dp);
		}
	}

	if (dt_status != (DT_SYNC | DT_CTRL | DT_PLANES | DT_DEVICE)) {
		printf("Not enough DT config for display [0x%x]\n", dt_status);
		return -ENODEV;
	}

	return ret;
}
#endif

__weak int nx_display_fixup_dp(struct nx_display_dev *dp)
{
	return 0;
}

static struct nx_display_dev *nx_display_setup(void)
{
	struct nx_display_dev *dp;
	int i, ret;
	int node = 0;
	struct video_uc_plat *plat = NULL;

	struct udevice *dev;

	/* call driver probe */
	debug("DT: uclass device call...\n");

	ret = uclass_get_device(UCLASS_VIDEO, 0, &dev);
	if (ret) {
		debug("%s(): uclass_get_device(UCLASS_VIDEO, 0, &dev) != 0 --> return NULL\n",
		      __func__);
		return NULL;
	}
	plat = dev_get_uclass_plat(dev);
	if (!dev) {
		debug("%s(): dev_get_uclass_plat(dev) == NULL --> return NULL\n",
		      __func__);
		return NULL;
	}
	dp = dev_get_priv(dev);
	if (!dp) {
		debug("%s(): dev_get_priv(dev) == NULL --> return NULL\n",
		      __func__);
		return NULL;
	}
	node = dev_ofnode(dev).of_offset;

	if (CONFIG_IS_ENABLED(OF_CONTROL)) {
		ret = nx_display_parse_dt(dev, dp, plat);
		if (ret)
			goto err_setup;
	}

	nx_display_fixup_dp(dp);

	for (i = 0; dp->top.plane_num > i; i++) {
		dp->planes[i].layer = i;
		if (dp->planes[i].enable && !dp->fb_plane) {
			dp->fb_plane = &dp->planes[i];
			dp->fb_addr = dp->fb_plane->fb_base;
			dp->depth = dp->fb_plane->pixel_byte;
		}
	}

	switch (dp->dev_type) {
#ifdef CONFIG_VIDEO_NX_RGB
	case DP_DEVICE_RGBLCD:
		nx_rgb_display(dp->module,
			       &dp->sync, &dp->ctrl, &dp->top,
			       dp->planes, (struct dp_rgb_dev *)dp->device);
		break;
#endif
#ifdef CONFIG_VIDEO_NX_LVDS
	case DP_DEVICE_LVDS:
		nx_lvds_display(dp->module,
				&dp->sync, &dp->ctrl, &dp->top,
				dp->planes, (struct dp_lvds_dev *)dp->device);
		break;
#endif
#ifdef CONFIG_VIDEO_NX_MIPI
	case DP_DEVICE_MIPI:
		nx_mipi_display(dp->module,
				&dp->sync, &dp->ctrl, &dp->top,
				dp->planes, (struct dp_mipi_dev *)dp->device);
		break;
#endif
#ifdef CONFIG_VIDEO_NX_HDMI
	case DP_DEVICE_HDMI:
		nx_hdmi_display(dp->module,
				&dp->sync, &dp->ctrl, &dp->top,
				dp->planes, (struct dp_hdmi_dev *)dp->device);
		break;
#endif
	default:
		printf("fail : not support lcd type %d !!!\n", dp->dev_type);
		goto err_setup;
	};

	printf("LCD:   [%s] dp.%d.%d %dx%d %dbpp FB:0x%08x\n",
	       dp_dev_str[dp->dev_type], dp->module, dp->fb_plane->layer,
	       dp->fb_plane->width, dp->fb_plane->height, dp->depth * 8,
	       dp->fb_addr);

	return dp;

err_setup:
	kfree(dp);

	return NULL;
}

static int nx_display_probe(struct udevice *dev)
{
	struct video_uc_plat *uc_plat = dev_get_uclass_plat(dev);
	struct video_priv *uc_priv = dev_get_uclass_priv(dev);
	struct nx_display_plat *plat = dev_get_plat(dev);
	char addr[64];

	debug("%s()\n", __func__);

	if (!dev)
		return -EINVAL;

	if (!uc_plat) {
		debug("%s(): video_uc_plat *plat == NULL --> return -EINVAL\n",
		      __func__);
		return -EINVAL;
	}

	if (!uc_priv) {
		debug("%s(): video_priv *uc_priv == NULL --> return -EINVAL\n",
		      __func__);
		return -EINVAL;
	}

	if (!plat) {
		debug("%s(): nx_display_plat *plat == NULL --> return -EINVAL\n",
		      __func__);
		return -EINVAL;
	}

	struct nx_display_dev *dp;

	dp = nx_display_setup();
	if (!dp) {
		debug("%s(): nx_display_setup() == 0 --> return -EINVAL\n",
		      __func__);
		return -EINVAL;
	}

	switch (dp->depth) {
	case 2:
		uc_priv->bpix = VIDEO_BPP16;
		break;
	case 3:
		/* There is no VIDEO_BPP24 because these values are of
		 * type video_log2_bpp
		 */
	case 4:
		uc_priv->bpix = VIDEO_BPP32;
		break;
	default:
		printf("fail : not support LCD bit per pixel %d\n",
		       dp->depth * 8);
		return -EINVAL;
	}

	uc_priv->xsize = dp->fb_plane->width;
	uc_priv->ysize = dp->fb_plane->height;
	uc_priv->rot = 0;

	/*
	 * set environment variable "fb_addr" (frame buffer address), required
	 * for splash image, which is not set if CONFIG_VIDEO is enabled).
	 */
	sprintf(addr, "0x%x", dp->fb_addr);
	debug("%s(): env_set(\"fb_addr\", %s) ...\n", __func__, addr);
	env_set("fb_addr", addr);

	return 0;
}

static int nx_display_bind(struct udevice *dev)
{
	struct video_uc_plat *plat = dev_get_uclass_plat(dev);

	debug("%s()\n", __func__);

	/* Datasheet S5p4418:
	 *   Resolution up to 2048 x 1280, up to 12 Bit per color (HDMI)
	 * Actual (max.) size is 0x1000000 because in U-Boot nanopi2-2016.01
	 * "#define CONFIG_FB_ADDR  0x77000000" and next address is
	 * "#define BMP_LOAD_ADDR  0x78000000"
	 */
	plat->size = 0x1000000;

	return 0;
}

static const struct udevice_id nx_display_ids[] = {
	{.compatible = "nexell,nexell-display", },
	{}
};

U_BOOT_DRIVER(nexell_display) = {
	.name = "nexell-display",
	.id = UCLASS_VIDEO,
	.of_match = nx_display_ids,
	.plat_auto	= sizeof(struct nx_display_plat),
	.bind = nx_display_bind,
	.probe = nx_display_probe,
	.priv_auto	= sizeof(struct nx_display_dev),
};