aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2/board-44xx-tablet-panel.c
blob: f1cdc6241dab25b6e9afc8c5631e8846153b5027 (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
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
/*
 * arch/arm/mach-omap2/board-44xx-tablet-panel.c
 *
 * Copyright (C) 2011 Texas Instruments
 *
 * This software is licensed under the terms of the GNU General Public
 * License version 2, as published by the Free Software Foundation, and
 * may be copied, distributed, and modified under those terms.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 */

#include <linux/delay.h>
#include <linux/kernel.h>
#include <linux/gpio.h>
#include <linux/i2c.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/leds-omap4430sdp-display.h>
#include <linux/platform_device.h>
#include <linux/omapfb.h>
#include <video/omapdss.h>
#include <video/omap-panel-tc358765.h>

#include <linux/i2c/twl.h>

#include <plat/android-display.h>
#include <plat/vram.h>
#include <plat/omap_apps_brd_id.h>

#include "board-44xx-tablet.h"
#include "control.h"
#include "mux.h"

#define DP_4430_GPIO_59         59
#define DSI2_GPIO_59		59

#define HDMI_GPIO_CT_CP_HPD             60
#define HDMI_GPIO_HPD                   63  /* Hot plug pin for HDMI */

#define HDMI_GPIO_LS_OE 41 /* Level shifter for HDMI */
#define LCD_BL_GPIO		59 /*27*/	/* LCD Backlight GPIO */
/* PWM2 and TOGGLE3 register offsets */
#define LED_PWM2ON		0x03
#define LED_PWM2OFF		0x04
#define TWL6030_TOGGLE3		0x92

#define OMAP_HDMI_HPD_ADDR      0x4A100098
#define OMAP_HDMI_PULLTYPE_MASK 0x00000010

static enum omap_44xx_tablet_panel_type {
	LCD_DEFAULT,
	TC35876x_SHARP_LQ101K1LYxx_WXGA,/* TC35876x + Sharp LCD */
	TC35876x_SAMSUNG_HYDIS_WUXGA,	/* TC35876x + Samsung or HYDIS */
	LD089WU1_LG_WUXGA,
} tablet_panel_type = LCD_DEFAULT;

struct omap_tablet_panel_data {
	struct omap_dss_board_info *board_info;
	struct dsscomp_platform_data *dsscomp_data;
	struct sgx_omaplfb_platform_data *omaplfb_data;
};

static void omap4_tablet_init_display_led(void)
{
	twl_i2c_write_u8(TWL_MODULE_PWM, 0xFF, LED_PWM2ON);
	twl_i2c_write_u8(TWL_MODULE_PWM, 0x7F, LED_PWM2OFF);
	twl_i2c_write_u8(TWL6030_MODULE_ID1, 0x30, TWL6030_TOGGLE3);
}

static void omap4_tablet_set_primary_brightness(u8 brightness)
{
	if (brightness > 1) {
		if (brightness == 255)
			brightness = 0x7f;
		else
			brightness = (~(brightness/2)) & 0x7f;

		twl_i2c_write_u8(TWL6030_MODULE_ID1, 0x30, TWL6030_TOGGLE3);
		twl_i2c_write_u8(TWL_MODULE_PWM, brightness, LED_PWM2ON);
	} else if (brightness <= 1) {
		twl_i2c_write_u8(TWL6030_MODULE_ID1, 0x08, TWL6030_TOGGLE3);
		twl_i2c_write_u8(TWL6030_MODULE_ID1, 0x38, TWL6030_TOGGLE3);
	}
}

static struct omap4430_sdp_disp_led_platform_data sdp4430_disp_led_data = {
	.flags = LEDS_CTRL_AS_ONE_DISPLAY,
	.display_led_init = omap4_tablet_init_display_led,
	.primary_display_set = omap4_tablet_set_primary_brightness,
	.secondary_display_set = NULL,
};

static struct platform_device omap4_tablet_disp_led = {
	.name	=	"display_led",
	.id	=	-1,
	.dev	= {
		.platform_data = &sdp4430_disp_led_data,
	},
};

static struct gpio tablet_hdmi_gpios[] = {
	{HDMI_GPIO_CT_CP_HPD,  GPIOF_OUT_INIT_HIGH,    "hdmi_gpio_hpd"   },
	{HDMI_GPIO_LS_OE,      GPIOF_OUT_INIT_HIGH,    "hdmi_gpio_ls_oe" },
};

static void tablet_hdmi_mux_init(void)
{
	u32 r;
	int status;
	/* PAD0_HDMI_HPD_PAD1_HDMI_CEC */
	omap_mux_init_signal("hdmi_hpd.hdmi_hpd",
				OMAP_PIN_INPUT_PULLDOWN);
	omap_mux_init_signal("gpmc_wait2.gpio_100",
			OMAP_PIN_INPUT_PULLDOWN);
	omap_mux_init_signal("hdmi_cec.hdmi_cec",
			OMAP_PIN_INPUT_PULLUP);
	/* PAD0_HDMI_DDC_SCL_PAD1_HDMI_DDC_SDA */
	omap_mux_init_signal("hdmi_ddc_scl.hdmi_ddc_scl",
			OMAP_PIN_INPUT_PULLUP);
	omap_mux_init_signal("hdmi_ddc_sda.hdmi_ddc_sda",
			OMAP_PIN_INPUT_PULLUP);

	/* strong pullup on DDC lines using unpublished register */
	r = ((1 << 24) | (1 << 28)) ;
	omap4_ctrl_pad_writel(r, OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_I2C_1);

	gpio_request(HDMI_GPIO_HPD, NULL);
	omap_mux_init_gpio(HDMI_GPIO_HPD, OMAP_PIN_INPUT | OMAP_PULL_ENA);
	gpio_direction_input(HDMI_GPIO_HPD);

	status = gpio_request_array(tablet_hdmi_gpios,
			ARRAY_SIZE(tablet_hdmi_gpios));
	if (status)
		pr_err("%s: Cannot request HDMI GPIOs %x\n", __func__, status);
}

static struct tc358765_board_data dsi_data_tc35876x_sharp_lq101k1lyxx = {
	.lp_time	= 0x4,
	.clrsipo	= 0x3,
	.lv_is		= 0x1,
	.lv_nd		= 0x6,
	.vtgen		= 0x0,
	.vsdelay	= 0xf02,
	.pclkdiv	= 0x0,
	.pclksel	= 0x0,
	.lvdlink	= 0x0,
	.msf		= 0x0,
	.evtmode	= 0x1,
};

static struct tc358765_board_data dsi_data_tc35876x_samhyd_wuxga = {
	.lp_time	= 0x7,
	.clrsipo	= 0x7,
	.lv_is		= 0x2,
	.lv_nd		= 0x6,
	.vtgen		= 0x0,
	.vsdelay	= 0x0,
	.pclkdiv	= 0x1,
	.pclksel	= 0x0,
	.lvdlink	= 0x1,
	.msf		= 0x1,
	.evtmode	= 0x1,
};

static struct omap_dsi_timings dsi_timings_tc35876x_samhyd_wuxga = {
	.hbp		= 0,
	.hfp		= 24,
	.hsa		= 0,
	.vbp		= 9,
	.vfp		= 10,
	.vsa		= 1,
	.vact		= 1200,
	.tl		= 1107,
	.hsa_hs_int	= 0,
	.hfp_hs_int	= 0,
	.hbp_hs_int	= 0,
	.hsa_lp_int	= 130,
	.hfp_lp_int	= 223,
	.hbp_lp_int	= 59,
	.bl_lp_int	= 0,
	.bl_hs_int	= 1038,
	.exit_lat	= 20,
	.enter_lat	= 23,
};

static struct omap_video_timings dispc_timings_tc35876x_samhyd_wuxga = {
	.x_res		= 1920,
	.y_res		= 1200,
	.hfp		= 4,
	.hsw		= 5,
	.hbp		= 39,
	.vfp		= 9,
	.vsw		= 1,
	.vbp		= 10,
};

static struct omap_dsi_timings dsi_timings_ld089wu1_lg_wuxga = {
	.hbp		= 10,
	.hfp		= 35,
	.hsa		= 0,
	.vbp		= 9,
	.vfp		= 10,
	.vsa		= 1,
	.vact		= 1200,
	.tl		= 1488,
	.hsa_hs_int	= 0,
	.hfp_hs_int	= 0,
	.hbp_hs_int	= 0,
	.hsa_lp_int	= 0,
	.hfp_lp_int	= 0,
	.hbp_lp_int	= 0,
	.bl_lp_int	= 12,
	.bl_hs_int	= 1402,
	.exit_lat	= 25,
	.enter_lat	= 29,
};

static struct omap_dsi_timings dsi_timings_tc35876x = {
	.hbp		= 3,
	.hfp		= 4,
	.hsa		= 0,
	.vbp		= 4,
	.vfp		= 6,
	.vsa		= 2,
	.vact		= 800,
	.tl		= 970,
	.hsa_hs_int	= 72,
	.hfp_hs_int	= 114,
	.hbp_hs_int	= 150,
	.hsa_lp_int	= 130,
	.hfp_lp_int	= 223,
	.hbp_lp_int	= 59,
	.bl_lp_int	= 0x31d1,
	.bl_hs_int	= 0x7a67,
	.exit_lat	= 15,
	.enter_lat	= 18,
};

static struct omap_video_timings dispc_timings_ld089wu1_lg_wuxga = {
	.x_res		= 1920,
	.y_res		= 1200,
	.hfp		= 8,
	.hsw		= 5,
	.hbp		= 51,
	.vfp		= 9,
	.vsw		= 2,
	.vbp		= 9,
};

static struct omap_video_timings dispc_timings_tc35876x = {
		.x_res = 1280,
		.y_res = 800,
		.hfp = 243,
		.hsw = 9,
		.hbp = 20,
		.vfp = 6,
		.vsw = 2,
		.vbp = 4,

};

static struct omap_dss_device lcd_tc35876x_sharp_lq101k1lyxx = {
	.name                   = "lcd",
	.driver_name            = "tc358765",
	.type                   = OMAP_DISPLAY_TYPE_DSI,
	.data			= &dsi_data_tc35876x_sharp_lq101k1lyxx,
	.phy.dsi                = {
		.clk_lane       = 1,
		.clk_pol        = 0,
		.data1_lane     = 2,
		.data1_pol      = 0,
		.data2_lane     = 3,
		.data2_pol      = 0,
		.data3_lane     = 4,
		.data3_pol      = 0,
		.data4_lane     = 5,
		.data4_pol      = 0,

		.type = OMAP_DSS_DSI_TYPE_VIDEO_MODE,
		.line_bufs	= 2,
	},

	.clocks = {
		.dispc = {
			 .channel = {
				.lck_div        = 1,
				.pck_div        = 2,
				.lcd_clk_src    = OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC,
			},
			.dispc_fclk_src = OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC,
		},

		.dsi = {
			.regn           = 38,
			.regm           = 441,
			.regm_dispc     = 6,
			.regm_dsi       = 9,
			.lp_clk_div     = 5,
			.offset_ddr_clk = 0,
			.dsi_fclk_src   = OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DSI,
			.tlpx	= 12,
			.tclk = {
				.zero	 = 58,
				.prepare = 15,
				.trail	 = 16,
			},
			.ths = {
				.zero	 = 23,
				.prepare = 18,
				.exit	 = 33,
				.trail	 = 19,
			},
		},
	},

	.panel = {
		.timings = {
			.x_res		= 1280,
			.y_res		= 800,
			.pixel_clock	= 63530,
			.hfp		= 6,
			.hsw		= 12,
			.hbp		= 6,
			.vfp		= 4,
			.vsw		= 4,
			.vbp		= 4,
		},
		.width_in_um = 217000,
		.height_in_um = 135600,
	},

	.ctrl = {
		.pixel_size = 24,
	},

	.reset_gpio     = 102,
	.channel = OMAP_DSS_CHANNEL_LCD,
	.skip_init = false,

	.platform_enable = NULL,
	.platform_disable = NULL,
	.dispc_timings = &dispc_timings_tc35876x,
	.dsi_timings = &dsi_timings_tc35876x,
};

static struct omap_dss_device lcd_tc35876x_samhyd_wuxga = {
	.name                   = "lcd",
	.driver_name            = "tc358765",
	.type                   = OMAP_DISPLAY_TYPE_DSI,
	.data			= &dsi_data_tc35876x_samhyd_wuxga,
	.phy.dsi                = {
		.clk_lane       = 1,
		.clk_pol        = 0,
		.data1_lane     = 2,
		.data1_pol      = 0,
		.data2_lane     = 3,
		.data2_pol      = 0,
		.data3_lane     = 4,
		.data3_pol      = 0,
		.data4_lane     = 5,
		.data4_pol      = 0,

		.type = OMAP_DSS_DSI_TYPE_VIDEO_MODE,
		.line_bufs	= 0,
	},

	.clocks = {
		.dispc = {
			 .channel = {
				.lck_div        = 1,
				.pck_div        = 1,
				.lcd_clk_src    = OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC,
			},
			.dispc_fclk_src = OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC,
		},

		.dsi = {
			.regn           = 17,
			.regm           = 287,
			.regm_dispc     = 9,
			.regm_dsi       = 7,
			.lp_clk_div     = 19,
			.offset_ddr_clk = 0,
			.dsi_fclk_src   = OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DSI,
			.tlpx	= 18,
			.tclk = {
				.zero	 = 86,
				.prepare = 22,
				.trail	 = 22,
			},
			.ths = {
				.zero	 = 34,
				.prepare = 25,
				.exit	 = 47,
				.trail	 = 25,
			},
		},
	},

	.panel = {
		.timings = {
			.x_res		= 1920,
			.y_res		= 1200,
			.pixel_clock	= 162071,
			.hfp		= 40,
			.hsw		= 6,
			.hbp		= 248,
			.vfp		= 8,
			.vsw		= 6,
			.vbp		= 6,
		},
		.width_in_um = 191520,
		.height_in_um = 119700,
	},

	.ctrl = {
		.pixel_size = 18,
	},

	.reset_gpio     = 102,
	.channel = OMAP_DSS_CHANNEL_LCD,
	.skip_init = false,

	.platform_enable = NULL,
	.platform_disable = NULL,

	.dispc_timings = &dispc_timings_tc35876x_samhyd_wuxga,
	.dsi_timings = &dsi_timings_tc35876x_samhyd_wuxga,
};

static struct omap_dss_device lcd_ld089wu1_lg_wuxga = {
	.name                   = "lcd",
	.driver_name            = "ld089wu1",
	.type                   = OMAP_DISPLAY_TYPE_DSI,
	.phy.dsi                = {
		.clk_lane       = 3,
		.clk_pol        = 0,
		.data1_lane     = 1,
		.data1_pol      = 0,
		.data2_lane     = 2,
		.data2_pol      = 0,
		.data3_lane     = 4,
		.data3_pol      = 0,
		.data4_lane     = 5,
		.data4_pol      = 0,

		.type = OMAP_DSS_DSI_TYPE_VIDEO_MODE,
		.line_bufs	= 0,
	},

	.clocks = {
		.dispc = {
			 .channel = {
				.lck_div        = 1,
				.pck_div        = 1,
				.lcd_clk_src    =
					OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC,
			},
			.dispc_fclk_src = OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC,
		},

		.dsi = {
			.regn           = 16,
			.regm           = 363,
			.regm_dispc     = 12,
			.regm_dsi       = 10,
			.lp_clk_div     = 18,
			.offset_ddr_clk = 0,
			.dsi_fclk_src   = OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DSI,
			.tlpx	= 24,
			.tclk = {
				.zero	 = 116,
				.prepare = 29,
				.trail	 = 29,
			},
			.ths = {
				.zero	 = 46,
				.prepare = 33,
				.exit	 = 64,
				.trail	 = 32,
			},
		},
	},

	.panel = {
		.timings = {
			.x_res		= 1920,
			.y_res		= 1200,
			.pixel_clock	= 162071,
			.hfp		= 40,
			.hsw		= 6,
			.hbp		= 248,
			.vfp		= 8,
			.vsw		= 6,
			.vbp		= 6,
		},
		.width_in_um = 191520,
		.height_in_um = 119700,
	},

	.ctrl = {
		.pixel_size = 24,
	},

	.reset_gpio     = 102,
	.channel = OMAP_DSS_CHANNEL_LCD,
	.skip_init = false,

	.platform_enable = NULL,
	.platform_disable = NULL,

	.dispc_timings = &dispc_timings_ld089wu1_lg_wuxga,
	.dsi_timings = &dsi_timings_ld089wu1_lg_wuxga,
};

static struct omap_dss_device tablet_hdmi_device = {
	.name = "hdmi",
	.driver_name = "hdmi_panel",
	.type = OMAP_DISPLAY_TYPE_HDMI,
	.panel = {
		.hdmi_default_cea_code = 34,
		.timings = {
			.x_res = 1920,
			.y_res = 1080,
			.pixel_clock = 74250,
			.hsw = 44,
			.hfp = 88,
			.hbp = 148,
			.vsw = 5,
			.vfp = 4,
			.vbp = 36,
		},
	},
	.clocks	= {
		.dispc	= {
			.dispc_fclk_src	= OMAP_DSS_CLK_SRC_FCK,
		},
		.hdmi	= {
			.regn	= 15,
			.regm2	= 1,
			.max_pixclk_khz = 148500,
		},
	},
	.reset_gpio = -EINVAL,
	.hpd_gpio = HDMI_GPIO_HPD,
	.channel = OMAP_DSS_CHANNEL_DIGIT,
};

static struct omap_dss_device *dss_devices_tc35876x_samhyd_wuxga[] = {
	&lcd_tc35876x_samhyd_wuxga, /* LCD device has to be first */
	&tablet_hdmi_device,
};

static struct omap_dss_device *dss_devices_tc35876x_sharp_lq101k1lyxx[] = {
	&lcd_tc35876x_sharp_lq101k1lyxx, /* LCD device has to be first */
	&tablet_hdmi_device,
};

static struct omap_dss_device *dss_devices_ld089wu1_lg_wuxga[] = {
	&lcd_ld089wu1_lg_wuxga, /* LCD device has to be first */
	&tablet_hdmi_device,
};

static struct omap_dss_device *dss_devices_hdmi_default_display[] = {
	&tablet_hdmi_device,
};

static struct omap_dss_board_info tablet_dss_data_tc35876x_samhyd_wuxga = {
	.num_devices	= ARRAY_SIZE(dss_devices_tc35876x_samhyd_wuxga),
	.devices	= dss_devices_tc35876x_samhyd_wuxga,
	.default_device = &lcd_tc35876x_samhyd_wuxga,
};

static struct omap_dss_board_info tablet_dss_data_tc35876x_sharp_lq101k1lyxx = {
	.num_devices	= ARRAY_SIZE(dss_devices_tc35876x_sharp_lq101k1lyxx),
	.devices	= dss_devices_tc35876x_sharp_lq101k1lyxx,
	.default_device = &lcd_tc35876x_sharp_lq101k1lyxx,
};

static struct omap_dss_board_info tablet_dss_data_ld089wu1_lg_wuxga = {
	.num_devices	= ARRAY_SIZE(dss_devices_ld089wu1_lg_wuxga),
	.devices	= dss_devices_ld089wu1_lg_wuxga,
	.default_device	= &lcd_ld089wu1_lg_wuxga,
};

static struct omap_dss_board_info tablet_dss_data_hdmi_default_display = {
	.num_devices	= ARRAY_SIZE(dss_devices_hdmi_default_display),
	.devices	= dss_devices_hdmi_default_display,
	.default_device	= &tablet_hdmi_device,
};
/* Allocate ( 18 + 9 ) MB for TILER1D slot size for WUXGA panel, total of
 * 54 MB of TILER1D
 */
static struct dsscomp_platform_data dsscomp_config_tc35876x_samhyd_wuxga = {
		.tiler1d_slotsz = (SZ_16M + SZ_2M + SZ_8M + SZ_1M),
};

static struct dsscomp_platform_data dsscomp_config_ld089wu1_lg_wuxga = {
		.tiler1d_slotsz = (SZ_16M + SZ_2M + SZ_8M + SZ_1M),
};

static struct dsscomp_platform_data dsscomp_config_hdmi_display = {
		.tiler1d_slotsz = (SZ_16M + SZ_2M + SZ_8M + SZ_1M),
};

#ifdef CONFIG_FB_OMAP2_NUM_FBS
#define OMAPLFB_NUM_DEV CONFIG_FB_OMAP2_NUM_FBS
#else
#define OMAPLFB_NUM_DEV 1
#endif

static struct sgx_omaplfb_config omaplfb_config_tc35876x_samhyd_wuxga[OMAPLFB_NUM_DEV] = {
	{
	.vram_buffers = 2,
	.swap_chain_length = 2,
	}
};

static struct sgx_omaplfb_config
			omaplfb_config_ld089wu1_lg_wuxga[OMAPLFB_NUM_DEV] = {
	{
	.vram_buffers = 2,
	.swap_chain_length = 2,
	}
};

static struct sgx_omaplfb_config omaplfb_config_hdmi_default_display[OMAPLFB_NUM_DEV] = {
	{
	.vram_buffers = 2,
	.swap_chain_length = 2,
	}
};

static struct sgx_omaplfb_platform_data omaplfb_plat_data_tc35876x_samhyd_wuxga = {
	.num_configs = OMAPLFB_NUM_DEV,
	.configs = omaplfb_config_tc35876x_samhyd_wuxga,
};

static struct sgx_omaplfb_platform_data omaplfb_plat_data_ld089wu1_lg_wuxga = {
	.num_configs = OMAPLFB_NUM_DEV,
	.configs = omaplfb_config_ld089wu1_lg_wuxga,
};

static struct sgx_omaplfb_platform_data omaplfb_plat_data_hdmi_default_display = {
	.num_configs = OMAPLFB_NUM_DEV,
	.configs = omaplfb_config_hdmi_default_display,
};

static struct omap_tablet_panel_data panel_data_tc35876x_samhyd_wuxga = {
	.board_info = &tablet_dss_data_tc35876x_samhyd_wuxga,
	.dsscomp_data = &dsscomp_config_tc35876x_samhyd_wuxga,
	.omaplfb_data = &omaplfb_plat_data_tc35876x_samhyd_wuxga,
};

static struct omap_tablet_panel_data panel_data_ld089wu1_lg_wuxga = {
	.board_info = &tablet_dss_data_ld089wu1_lg_wuxga,
	.dsscomp_data = &dsscomp_config_ld089wu1_lg_wuxga,
	.omaplfb_data = &omaplfb_plat_data_ld089wu1_lg_wuxga,
};

static struct omap_tablet_panel_data panel_data_tc35876x_sharp_lq101k1lyxx = {
	.board_info = &tablet_dss_data_tc35876x_sharp_lq101k1lyxx,
	.dsscomp_data = NULL,
	.omaplfb_data = NULL,
};

static struct omap_tablet_panel_data panel_data_hdmi_default_display  = {
	.board_info = &tablet_dss_data_hdmi_default_display,
	.dsscomp_data = &dsscomp_config_hdmi_display,
	.omaplfb_data = &omaplfb_plat_data_hdmi_default_display,
};

static struct omap_tablet_panel_data *get_panel_data(enum omap_44xx_tablet_panel_type panel_type)
{

	if (omap_android_display_is_default(&tablet_hdmi_device)) {
		return &panel_data_hdmi_default_display;
	}

	switch (panel_type) {
	case TC35876x_SAMSUNG_HYDIS_WUXGA: /* HYDIS & Samsung equivalent */
		return &panel_data_tc35876x_samhyd_wuxga;
		break;
	case LD089WU1_LG_WUXGA:
		return &panel_data_ld089wu1_lg_wuxga;
		break;
	case TC35876x_SHARP_LQ101K1LYxx_WXGA:
	default:
		if (omap_is_board_version(OMAP4_TABLET_1_0) ||
		    omap_is_board_version(OMAP4_TABLET_1_1) ||
		    omap_is_board_version(OMAP4_TABLET_1_2)) {
			/* keep compatibility with old Tablet1 devices */
			lcd_tc35876x_sharp_lq101k1lyxx.panel.timings.x_res = 1024;
			lcd_tc35876x_sharp_lq101k1lyxx.panel.timings.y_res = 768;
			lcd_tc35876x_sharp_lq101k1lyxx.panel.timings.pixel_clock = 65183;
			lcd_tc35876x_sharp_lq101k1lyxx.panel.timings.hfp = 10;
			lcd_tc35876x_sharp_lq101k1lyxx.panel.timings.hsw = 20;
			lcd_tc35876x_sharp_lq101k1lyxx.panel.timings.hbp = 10;
			lcd_tc35876x_sharp_lq101k1lyxx.dsi_timings = NULL;
			lcd_tc35876x_sharp_lq101k1lyxx.dispc_timings = NULL;
		}
		return &panel_data_tc35876x_sharp_lq101k1lyxx;
	}
}

static void tablet_lcd_init(void)
{
	u32 reg;
	int status;

	/* Enable 3 lanes in DSI1 module, disable pull down */
	reg = omap4_ctrl_pad_readl(OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_DSIPHY);
	reg &= ~OMAP4_DSI1_LANEENABLE_MASK;
	reg |= 0x1f << OMAP4_DSI1_LANEENABLE_SHIFT;
	reg &= ~OMAP4_DSI1_PIPD_MASK;
	reg |= 0x1f << OMAP4_DSI1_PIPD_SHIFT;
	omap4_ctrl_pad_writel(reg, OMAP4_CTRL_MODULE_PAD_CORE_CONTROL_DSIPHY);

	status = gpio_request_one(get_panel_data(tablet_panel_type)->board_info->devices[0]->reset_gpio,
				GPIOF_OUT_INIT_LOW, "lcd_reset_gpio");
	if (status)
		pr_err("%s: Could not get lcd_reset_gpio\n", __func__);
}

static struct omapfb_platform_data tablet_fb_pdata = {
	.mem_desc = {
		.region_cnt = 1,
	},
};

static struct i2c_board_info __initdata omap4xx_i2c_bus2_d2l_info[] = {
	{
		I2C_BOARD_INFO("tc358765_i2c_driver", 0x0f),
	},
};

static int __init set_tablet_panel_type(char *str)
{
	int retval = 0;
	if (!strncmp("2202-002", str, 8) ||
	    !strncmp("2102-002", str, 8))
		tablet_panel_type = TC35876x_SAMSUNG_HYDIS_WUXGA;
	else if (!strncmp("2202-003", str, 8))
		tablet_panel_type = LD089WU1_LG_WUXGA;
	else if (!strncmp("2156-003", str, 8))
		tablet_panel_type = TC35876x_SHARP_LQ101K1LYxx_WXGA;
	else {
		pr_err("%s: No valid omapdss.board_id sent from bootloader, "
		       "will default to TC35876x_SHARP_LQ101K1LYxx_WXGA\n",
			__func__);
		retval = 1;
	}
	return retval;
}

early_param("omapdss.board_id", set_tablet_panel_type);

void tablet_android_display_setup(struct omap_ion_platform_data *ion)
{
	struct omap_tablet_panel_data *panel_data = get_panel_data(tablet_panel_type);
	omap_android_display_setup(panel_data->board_info,
				   panel_data->dsscomp_data,
				   panel_data->omaplfb_data,
				   &tablet_fb_pdata,
				   ion);
}

int __init tablet_panel_init(void)
{
	tablet_lcd_init();
	tablet_hdmi_mux_init();

	omapfb_set_platform_data(&tablet_fb_pdata);

	omap_display_init(get_panel_data(tablet_panel_type)->board_info);
	platform_device_register(&omap4_tablet_disp_led);

	i2c_register_board_info(2, omap4xx_i2c_bus2_d2l_info,
		ARRAY_SIZE(omap4xx_i2c_bus2_d2l_info));

	return 0;
}