]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - drivers/video/omap/lcd_h2.c
omapfb: Add support for omap framebuffer
[linux-2.6-omap-h63xx.git] / drivers / video / omap / lcd_h2.c
1 /*
2  * File: drivers/video/omap/lcd-h2.c
3  *
4  * LCD panel support for the TI OMAP H2 board
5  *
6  * Copyright (C) 2004 Nokia Corporation
7  * Author: Imre Deak <imre.deak@nokia.com>
8  *
9  * This program is free software; you can redistribute it and/or modify it
10  * under the terms of the GNU General Public License as published by the
11  * Free Software Foundation; either version 2 of the License, or (at your
12  * option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License along
20  * with this program; if not, write to the Free Software Foundation, Inc.,
21  * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22  */
23
24 #include <linux/module.h>
25 #include <linux/platform_device.h>
26
27 #include <asm/arch/mux.h>
28 #include <asm/arch/omapfb.h>
29
30 #include "../drivers/ssi/omap-uwire.h"
31
32 #define MODULE_NAME             "omapfb-lcd_h2"
33 #define TSC2101_UWIRE_CS        1
34
35 #define pr_err(fmt, args...) printk(KERN_ERR MODULE_NAME ": " fmt, ## args)
36
37 static int tsc2101_write_reg(int page, int reg, u16 data)
38 {
39         u16     cmd;
40         int     r;
41
42         cmd = ((page & 3) << 11) | ((reg & 0x3f) << 5);
43         if (omap_uwire_data_transfer(TSC2101_UWIRE_CS, cmd, 16, 0, NULL, 1))
44                 r = -1;
45         else
46                 r = omap_uwire_data_transfer(TSC2101_UWIRE_CS, data, 16, 0,
47                                              NULL, 0);
48
49         return r;
50 }
51
52 static int h2_panel_init(struct lcd_panel *panel, struct omapfb_device *fbdev)
53 {
54         unsigned long uwire_flags;
55
56          /* Configure N15 pin to be uWire CS1 */
57         omap_cfg_reg(N15_1610_UWIRE_CS1);
58         uwire_flags = UWIRE_READ_RISING_EDGE | UWIRE_WRITE_RISING_EDGE;
59         uwire_flags |= UWIRE_FREQ_DIV_8;
60         omap_uwire_configure_mode(TSC2101_UWIRE_CS, uwire_flags);
61
62         return 0;
63 }
64
65 static void h2_panel_cleanup(struct lcd_panel *panel)
66 {
67 }
68
69 static int h2_panel_enable(struct lcd_panel *panel)
70 {
71         int r;
72
73         /* Assert LCD_EN, BKLIGHT_EN pins on LCD panel
74          * page2, GPIO config reg, GPIO(0,1) to out and asserted
75          */
76         r = tsc2101_write_reg(2, 0x23, 0xCC00) ? -1 : 0;
77
78         return r;
79 }
80
81 static void h2_panel_disable(struct lcd_panel *panel)
82 {
83         /* Deassert LCD_EN and BKLIGHT_EN pins on LCD panel
84          * page2, GPIO config reg, GPIO(0,1) to out and deasserted
85          */
86         if (tsc2101_write_reg(2, 0x23, 0x8800))
87                 pr_err("failed to disable LCD panel\n");
88 }
89
90 static unsigned long h2_panel_get_caps(struct lcd_panel *panel)
91 {
92         return 0;
93 }
94
95 struct lcd_panel h2_panel = {
96         .name           = "h2",
97         .config         = OMAP_LCDC_PANEL_TFT,
98
99         .bpp            = 16,
100         .data_lines     = 16,
101         .x_res          = 240,
102         .y_res          = 320,
103         .pixel_clock    = 5000,
104         .hsw            = 12,
105         .hfp            = 12,
106         .hbp            = 46,
107         .vsw            = 1,
108         .vfp            = 1,
109         .vbp            = 0,
110
111         .init           = h2_panel_init,
112         .cleanup        = h2_panel_cleanup,
113         .enable         = h2_panel_enable,
114         .disable        = h2_panel_disable,
115         .get_caps       = h2_panel_get_caps,
116 };
117
118 static int h2_panel_probe(struct platform_device *pdev)
119 {
120         omapfb_register_panel(&h2_panel);
121         return 0;
122 }
123
124 static int h2_panel_remove(struct platform_device *pdev)
125 {
126         return 0;
127 }
128
129 static int h2_panel_suspend(struct platform_device *pdev, pm_message_t mesg)
130 {
131         return 0;
132 }
133
134 static int h2_panel_resume(struct platform_device *pdev)
135 {
136         return 0;
137 }
138
139 struct platform_driver h2_panel_driver = {
140         .probe          = h2_panel_probe,
141         .remove         = h2_panel_remove,
142         .suspend        = h2_panel_suspend,
143         .resume         = h2_panel_resume,
144         .driver         = {
145                 .name   = "lcd_h2",
146                 .owner  = THIS_MODULE,
147         },
148 };
149
150 static int h2_panel_drv_init(void)
151 {
152         return platform_driver_register(&h2_panel_driver);
153 }
154
155 static void h2_panel_drv_cleanup(void)
156 {
157         platform_driver_unregister(&h2_panel_driver);
158 }
159
160 module_init(h2_panel_drv_init);
161 module_exit(h2_panel_drv_cleanup);
162