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