summaryrefslogtreecommitdiff
path: root/packages/linux/linux-omap/omap3evm/omap3evm-dss2.diff
blob: 60832e72cad6adc90f785f8e61a81ba3e88e5801 (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
From: hvaibhav@ti.com
To: linux-fbdev-devel@lists.sourceforge.net, linux-omap@vger.kernel.org
Cc: Vaibhav Hiremath <hvaibhav@ti.com>
Subject: [REVIEW PATCH] Added OMAP3EVM support on Tomis FBDEV/DSS Patches
Date: 	Fri, 14 Nov 2008 12:02:32 +0530

From: Vaibhav Hiremath <hvaibhav@ti.com>

Tested LCD, TV, DVI (480P) out on OMAP3EVM board.

Please make sure that you change the option
CONFIG_FB_OMAP_CONSISTENT_DMA_SIZE=7  and apply the
Mans Rullgard clock patches to support set_rate and round_rate API.

Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
---
 arch/arm/mach-omap2/board-omap3evm.c |  224 ++++++++++++++++++++++++++++++++--
 drivers/video/omap2/Kconfig          |    5 +
 drivers/video/omap2/Makefile         |    1 +
 drivers/video/omap2/panel-omap3evm.c |  110 +++++++++++++++++
 5 files changed, 341 insertions(+), 53 deletions(-)
 create mode 100644 drivers/video/omap2/panel-omap3evm.c

diff --git a/arch/arm/mach-omap2/board-omap3evm.c b/arch/arm/mach-omap2/board-omap3evm.c
index 42ab826..e244fa7 100644
--- a/arch/arm/mach-omap2/board-omap3evm.c
+++ b/arch/arm/mach-omap2/board-omap3evm.c
@@ -37,6 +37,8 @@
 #include <mach/usb-ehci.h>
 #include <mach/common.h>
 #include <mach/mcspi.h>
+#include <mach/omapfb.h>
+#include <mach/display.h>

 #include "sdram-micron-mt46h32m32lf-6.h"
 #include "twl4030-generic-scripts.h"
@@ -161,14 +163,215 @@ static int __init omap3_evm_i2c_init(void)
 	omap_register_i2c_bus(3, 400, NULL, 0);
 	return 0;
 }
+static struct omap_fbmem_config evm_fbmem0_config = {
+		.size = 480*720*4,
+		.start = OMAPFB_MEMTYPE_SDRAM,
+};

-static struct platform_device omap3_evm_lcd_device = {
-	.name		= "omap3evm_lcd",
-	.id		= -1,
+static struct omap_fbmem_config evm_fbmem1_config = {
+		.size = 480*720*4,
+		.start = OMAPFB_MEMTYPE_SDRAM,
 };

-static struct omap_lcd_config omap3_evm_lcd_config __initdata = {
-	.ctrl_name	= "internal",
+static struct omap_fbmem_config evm_fbmem2_config = {
+		.size = 480*720*4,
+		.start = OMAPFB_MEMTYPE_SDRAM,
+};
+#define LCD_PANEL_LR		2
+#define LCD_PANEL_UD		3
+#define LCD_PANEL_INI		152
+#define LCD_PANEL_ENABLE_GPIO	153
+#define LCD_PANEL_QVGA		154
+#define LCD_PANEL_RESB		155
+
+#define ENABLE_VDAC_DEDICATED	0x03
+#define ENABLE_VDAC_DEV_GRP	0x20
+#define ENABLE_VPLL2_DEDICATED	0x05
+#define ENABLE_VPLL2_DEV_GRP	0xE0
+
+#define TWL4030_GPIODATA_IN3	0x03
+#define TWL4030_GPIODATA_DIR3	0x06
+#define TWL4030_VPLL2_DEV_GRP	0x33
+#define TWL4030_VPLL2_DEDICATED	0x36
+
+static int lcd_enabled;
+static int dvi_enabled;
+
+static void __init evm_display_init(void)
+{
+	int r;
+	r = gpio_request(LCD_PANEL_LR, "lcd_panel_lr");
+	if (r) {
+		printk(KERN_ERR "failed to get LCD_PANEL_LR\n");
+		return;
+	}
+	r = gpio_request(LCD_PANEL_UD, "lcd_panel_ud");
+	if (r) {
+		printk(KERN_ERR "failed to get LCD_PANEL_UD\n");
+		goto err_1;
+	}
+
+	r = gpio_request(LCD_PANEL_INI, "lcd_panel_ini");
+	if (r) {
+		printk(KERN_ERR "failed to get LCD_PANEL_INI\n");
+		goto err_2;
+	}
+	r = gpio_request(LCD_PANEL_RESB, "lcd_panel_resb");
+	if (r) {
+		printk(KERN_ERR "failed to get LCD_PANEL_RESB\n");
+		goto err_3;
+	}
+	r = gpio_request(LCD_PANEL_QVGA, "lcd_panel_qvga");
+	if (r) {
+		printk(KERN_ERR "failed to get LCD_PANEL_QVGA\n");
+		goto err_4;
+	}
+
+	gpio_direction_output(LCD_PANEL_LR, 0);
+	gpio_direction_output(LCD_PANEL_UD, 0);
+	gpio_direction_output(LCD_PANEL_INI, 0);
+	gpio_direction_output(LCD_PANEL_RESB, 0);
+	gpio_direction_output(LCD_PANEL_QVGA, 0);
+
+#define TWL_LED_LEDEN           0x00
+#define TWL_PWMA_PWMAON         0x00
+#define TWL_PWMA_PWMAOFF        0x01
+
+	twl4030_i2c_write_u8(TWL4030_MODULE_LED, 0x11, TWL_LED_LEDEN);
+	twl4030_i2c_write_u8(TWL4030_MODULE_PWMA, 0x01, TWL_PWMA_PWMAON);
+	twl4030_i2c_write_u8(TWL4030_MODULE_PWMA, 0x02, TWL_PWMA_PWMAOFF);
+
+	gpio_direction_output(LCD_PANEL_RESB, 1);
+	gpio_direction_output(LCD_PANEL_INI, 1);
+	gpio_direction_output(LCD_PANEL_QVGA, 0);
+	gpio_direction_output(LCD_PANEL_LR, 1);
+	gpio_direction_output(LCD_PANEL_UD, 1);
+
+	return;
+
+err_4:
+	gpio_free(LCD_PANEL_RESB);
+err_3:
+	gpio_free(LCD_PANEL_INI);
+err_2:
+	gpio_free(LCD_PANEL_UD);
+err_1:
+	gpio_free(LCD_PANEL_LR);
+
+}
+
+static int panel_enable_lcd(struct omap_display *display)
+{
+	if (dvi_enabled) {
+		printk(KERN_ERR "cannot enable LCD, DVI is enabled\n");
+		return -EINVAL;
+	}
+	if (omap_rev() > OMAP3430_REV_ES1_0) {
+		twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
+			ENABLE_VPLL2_DEDICATED, TWL4030_VPLL2_DEDICATED);
+		twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
+			ENABLE_VPLL2_DEV_GRP, TWL4030_VPLL2_DEV_GRP);
+	}
+	gpio_direction_output(LCD_PANEL_ENABLE_GPIO, 0);
+	lcd_enabled = 1;
+	return 0;
+}
+
+static void panel_disable_lcd(struct omap_display *display)
+{
+	if (omap_rev() > OMAP3430_REV_ES1_0) {
+		twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0x0,
+				TWL4030_VPLL2_DEDICATED);
+		twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0x0,
+				TWL4030_VPLL2_DEV_GRP);
+	}
+	gpio_set_value(LCD_PANEL_ENABLE_GPIO, 1);
+	lcd_enabled = 0;
+}
+
+static struct omap_display_data evm_display_data = {
+	.type = OMAP_DISPLAY_TYPE_DPI,
+	.name = "lcd",
+	.panel_name = "panel-sdp3430",
+	.u.dpi.data_lines = 16,
+	.panel_enable = panel_enable_lcd,
+	.panel_disable = panel_disable_lcd,
+};
+
+static int panel_enable_tv(struct omap_display *display)
+{
+	twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
+			ENABLE_VDAC_DEDICATED, TWL4030_VDAC_DEDICATED);
+	twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
+			ENABLE_VDAC_DEV_GRP, TWL4030_VDAC_DEV_GRP);
+	return 0;
+}
+
+static void panel_disable_tv(struct omap_display *display)
+{
+	twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0x00,
+			TWL4030_VDAC_DEDICATED);
+	twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0x00,
+			TWL4030_VDAC_DEV_GRP);
+}
+
+static struct omap_display_data evm_display_data_tv = {
+	.type = OMAP_DISPLAY_TYPE_VENC,
+	.name = "tv",
+	.u.venc.type = OMAP_DSS_VENC_TYPE_SVIDEO,
+	.panel_enable = panel_enable_tv,
+	.panel_disable = panel_disable_tv,
+};
+
+
+static int panel_enable_dvi(struct omap_display *display)
+{
+	if (lcd_enabled) {
+		printk(KERN_ERR "cannot enable DVI, LCD is enabled\n");
+		return -EINVAL;
+	}
+	twl4030_i2c_write_u8(TWL4030_MODULE_GPIO, 0x80,
+			TWL4030_GPIODATA_IN3);
+	twl4030_i2c_write_u8(TWL4030_MODULE_GPIO, 0x80,
+			TWL4030_GPIODATA_DIR3);
+	dvi_enabled = 1;
+
+	return 0;
+}
+
+static void panel_disable_dvi(struct omap_display *display)
+{
+	twl4030_i2c_write_u8(TWL4030_MODULE_GPIO, 0x00,
+			TWL4030_GPIODATA_IN3);
+	twl4030_i2c_write_u8(TWL4030_MODULE_GPIO, 0x00,
+			TWL4030_GPIODATA_DIR3);
+	dvi_enabled = 0;
+}
+
+
+static struct omap_display_data evm_display_data_dvi = {
+	.type = OMAP_DISPLAY_TYPE_DPI,
+	.name = "dvi",
+	.panel_name = "panel-dvi",
+	.u.dpi.data_lines = 24,
+	.panel_enable = panel_enable_dvi,
+	.panel_disable = panel_disable_dvi,
+};
+
+static struct omap_dss_platform_data evm_dss_data = {
+	.num_displays = 3,
+	.displays = {
+		&evm_display_data,
+		&evm_display_data_dvi,
+		&evm_display_data_tv,
+	}
+};
+static struct platform_device evm_dss_device = {
+	.name		= "omap-dss",
+	.id		= -1,
+	.dev            = {
+		.platform_data = &evm_dss_data,
+	},
 };

 static void ads7846_dev_init(void)
@@ -227,11 +430,13 @@ static void __init omap3_evm_init_irq(void)

 static struct omap_board_config_kernel omap3_evm_config[] __initdata = {
 	{ OMAP_TAG_UART,	&omap3_evm_uart_config },
-	{ OMAP_TAG_LCD,		&omap3_evm_lcd_config },
+	{ OMAP_TAG_FBMEM,       &evm_fbmem0_config },
+	{ OMAP_TAG_FBMEM,       &evm_fbmem1_config },
+	{ OMAP_TAG_FBMEM,       &evm_fbmem2_config },
 };

 static struct platform_device *omap3_evm_devices[] __initdata = {
-	&omap3_evm_lcd_device,
+	&evm_dss_device,
 	&omap3evm_smc911x_device,
 };

@@ -250,8 +455,6 @@ static void __init omap3_evm_init(void)
 	omap3_evm_i2c_init();

 	platform_add_devices(omap3_evm_devices, ARRAY_SIZE(omap3_evm_devices));
-	omap_board_config = omap3_evm_config;
-	omap_board_config_size = ARRAY_SIZE(omap3_evm_config);

 	spi_register_board_info(omap3evm_spi_board_info,
 				ARRAY_SIZE(omap3evm_spi_board_info));
@@ -262,10 +465,13 @@ static void __init omap3_evm_init(void)
 	usb_ehci_init();
 	omap3evm_flash_init();
 	ads7846_dev_init();
+	evm_display_init();
 }

 static void __init omap3_evm_map_io(void)
 {
+	omap_board_config = omap3_evm_config;
+	omap_board_config_size = ARRAY_SIZE(omap3_evm_config);
 	omap2_set_globals_343x();
 	omap2_map_common_io();
 }
diff --git a/drivers/video/omap2/Kconfig b/drivers/video/omap2/Kconfig
index 95691ad..8211ffd 100644
--- a/drivers/video/omap2/Kconfig
+++ b/drivers/video/omap2/Kconfig
@@ -51,4 +51,9 @@ config PANEL_SDP3430
         help
           SDP3430 LCD

+config PANEL_OMAP3EVM
+        tristate "OMAP3EVM Panel"
+        depends on OMAP2_DSS
+        help
+          OMAP3EVM LCD Panel
 endmenu
diff --git a/drivers/video/omap2/Makefile b/drivers/video/omap2/Makefile
index 73ab1c0..668e8c6 100644
--- a/drivers/video/omap2/Makefile
+++ b/drivers/video/omap2/Makefile
@@ -3,3 +3,4 @@ omapfb-y := omapfb-main.o omapfb-sysfs.o omapfb-ioctl.o

 obj-$(CONFIG_PANEL_DVI) += panel-dvi.o
 obj-$(CONFIG_PANEL_SDP3430) += panel-sdp3430.o
+obj-$(CONFIG_PANEL_OMAP3EVM) += panel-omap3evm.o
diff --git a/drivers/video/omap2/panel-omap3evm.c b/drivers/video/omap2/panel-omap3evm.c
new file mode 100644
index 0000000..4a00b02
--- /dev/null
+++ b/drivers/video/omap2/panel-omap3evm.c
@@ -0,0 +1,110 @@
+/*
+ * LCD panel support for the TI OMAP3EVM board
+ *
+ * Copyright (C) 2008 Texas Instruments, Inc.
+ * Author: Vaibhav Hiremath <hvaibhav@ti.com>
+ *
+ * Derived from drivers/video/omap2/panel-sdp3430.c
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <linux/module.h>
+#include <linux/delay.h>
+
+#include <mach/display.h>
+
+static int omap3evm_panel_init(struct omap_display *display)
+{
+	return 0;
+}
+
+static void omap3evm_panel_cleanup(struct omap_display *display)
+{
+}
+
+static int omap3evm_panel_enable(struct omap_display *display)
+{
+	int r = 0;
+
+	if (display->hw_config.panel_enable)
+		r = display->hw_config.panel_enable(display);
+
+	return r;
+}
+
+static void omap3evm_panel_disable(struct omap_display *display)
+{
+	if (display->hw_config.panel_disable)
+		display->hw_config.panel_disable(display);
+}
+
+static int omap3evm_panel_suspend(struct omap_display *display)
+{
+	omap3evm_panel_disable(display);
+	return 0;
+}
+
+static int omap3evm_panel_resume(struct omap_display *display)
+{
+	return omap3evm_panel_enable(display);
+}
+
+static struct omap_panel omap3evm_panel = {
+	.owner		= THIS_MODULE,
+	.name		= "panel-evm",
+	.init		= omap3evm_panel_init,
+	.cleanup	= omap3evm_panel_cleanup,
+	.enable		= omap3evm_panel_enable,
+	.disable	= omap3evm_panel_disable,
+	.suspend	= omap3evm_panel_suspend,
+	.resume		= omap3evm_panel_resume,
+	/*.set_mode	= omap3evm_set_mode, */
+
+	.timings = {
+		.pixel_clock	= 26000,
+
+		.hsw		= 4,
+		.hfp		= 4,
+		.hbp		= 40,
+
+		.vsw		= 2,
+		.vfp		= 2,
+		.vbp		= 7,
+	},
+
+	.acb		= 0x28,
+
+	.config		= OMAP_DSS_LCD_TFT | OMAP_DSS_LCD_IVS |
+		OMAP_DSS_LCD_IHS | OMAP_DSS_LCD_IPC,
+
+	.x_res = 480,
+	.y_res = 640,
+	.bpp = 18,
+};
+
+
+static int __init omap3evm_panel_drv_init(void)
+{
+	omap_dss_register_panel(&omap3evm_panel);
+	return 0;
+}
+
+static void __exit omap3evm_panel_drv_exit(void)
+{
+	omap_dss_unregister_panel(&omap3evm_panel);
+}
+
+module_init(omap3evm_panel_drv_init);
+module_exit(omap3evm_panel_drv_exit);
+MODULE_LICENSE("GPL");
--
1.5.6

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html