]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - drivers/video/omap/lcd_h2.c
FB: OMAP: Add support for framebuffer
[linux-2.6-omap-h63xx.git] / drivers / video / omap / lcd_h2.c
1 /*
2  * File: drivers/video/omap_new/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
26 #include <asm/arch/mux.h>
27
28 #include "omapfb.h"
29
30 // #define OMAPFB_DBG 1
31
32 #include "debug.h"
33 #include "../drivers/ssi/omap-uwire.h"
34
35 #define TSC2101_UWIRE_CS        1
36
37 static int tsc2101_write_reg(int page, int reg, u16 data)
38 {
39         u16     cmd;
40         int     r;
41
42         DBGENTER(1);
43
44         cmd = ((page & 3) << 11) | ((reg & 0x3f) << 5);
45         if (omap_uwire_data_transfer(TSC2101_UWIRE_CS, cmd, 16, 0, NULL, 1))
46                 r = -1;
47         else
48                 r = omap_uwire_data_transfer(TSC2101_UWIRE_CS, data, 16, 0, NULL, 0);
49
50         DBGLEAVE(1);
51         return r;
52 }
53
54 static int h2_panel_init(struct lcd_panel *panel)
55 {
56         unsigned long uwire_flags;
57         DBGENTER(1);
58
59          /* Configure N15 pin to be uWire CS1 */
60         omap_cfg_reg(N15_1610_UWIRE_CS1);
61         uwire_flags = UWIRE_READ_RISING_EDGE | UWIRE_WRITE_RISING_EDGE;
62         uwire_flags |= UWIRE_FREQ_DIV_8;
63         omap_uwire_configure_mode(TSC2101_UWIRE_CS, uwire_flags);
64
65         DBGLEAVE(1);
66         return 0;
67 }
68
69 static void h2_panel_cleanup(struct lcd_panel *panel)
70 {
71         DBGENTER(1);
72         DBGLEAVE(1);
73 }
74
75 static int h2_panel_enable(struct lcd_panel *panel)
76 {
77         int r;
78
79         DBGENTER(1);
80
81         /* Assert LCD_EN, BKLIGHT_EN pins on LCD panel
82          * page2, GPIO config reg, GPIO(0,1) to out and asserted
83          */
84         r = tsc2101_write_reg(2, 0x23, 0xCC00) ? -1 : 0;
85
86         DBGLEAVE(1);
87         return r;
88 }
89
90 static void h2_panel_disable(struct lcd_panel *panel)
91 {
92         DBGENTER(1);
93
94         /* Deassert LCD_EN and BKLIGHT_EN pins on LCD panel
95          * page2, GPIO config reg, GPIO(0,1) to out and deasserted
96          */
97         if (tsc2101_write_reg(2, 0x23, 0x8800))
98                 PRNERR("failed to disable LCD panel\n");
99
100         DBGLEAVE(1);
101 }
102
103 static unsigned long h2_panel_get_caps(struct lcd_panel *panel)
104 {
105         return 0;
106 }
107
108 static struct lcdc_video_mode mode240x320 = {
109         .x_res = 240,
110         .y_res = 320,
111         .pixel_clock = 12500,
112         .bpp = 16,
113         .hsw = 12,
114         .hfp = 14,
115         .hbp = 72 - 12,
116         .vsw = 1,
117         .vfp = 1,
118         .vbp = 0,
119         .pcd = 12,
120 };
121
122 struct lcd_panel h2_panel = {
123         .name       = "h2",
124         .config     = LCD_PANEL_TFT,
125         .video_mode = &mode240x320,
126         
127         .init    = h2_panel_init,
128         .cleanup = h2_panel_cleanup,
129         .enable  = h2_panel_enable,
130         .disable = h2_panel_disable,
131         .get_caps= h2_panel_get_caps,
132 };
133