make oldconfig will rebuild these...
[linux-2.4.21-pre4.git] / drivers / video / ibmlcds.c
1 /*
2  * drivers/video/ibmlcds.c -- 
3  *    Database of known LCD panels' specs for use with 
4  *    IBM Liquid Crystal Display Controller core
5  *    - original use in PowerPC 405LP embedded platform
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  *
21  *  Copyright (C) 2001 David T. Eger   <eger@cc.gatech.edu>
22  *                     Matthew Helsley <mhelsle@us.ibm.com>
23  *                     Bishop Brock    <bcbrock@us.ibm.com>
24  *
25  */
26 /*
27  * Below is a collection of structures, each one defining the capabilities
28  * and default video mode for an LCD.  The values you enter here for resolution
29  * are taken to be the exact capabilities of the LCD, and cannot be changed at
30  * run time.  Some of the other characteristics, such as bit-depth and virtual
31  * resolution can be changed at run time.  
32  *
33  * In order to add a new profile, you need to do two things:
34  *    (1) Create a new structure describing your LCD panel
35  *        This involves getting the proper values to write to the
36  *        LCDC's registers.  A lot of them you can figure out, most of them,
37  *        you'll need to consult:
38  *         - "Liquid Crystal Display Controller Core" 
39  *            SA14-2342-00 IBM Microelectronics Division
40  *            (NOTE: IBM Confidential)
41  *         - linux/drivers/video/ibmlcd.h - contains definition of the 
42  *            par structure used here, what the fields mean,  and what 
43  *            ranges are valid for the given fields.
44  *    (2) Add your structure, and one or more unique aliases to it to 
45  *        ibmlcd_configs at the bottom of this file.
46  *    (3) Use the alias as a command line argument to the kernel.
47  *
48  * TODO: + Change the timing information presented here from precise values,
49  *         to a usable range, for use with frequency-scaling and dynamic 
50  *         reprogramming of clock dividers
51  *       + Pass the physical screen size in mm width and height, to put in
52  *         the var struct.
53  */
54
55 #include "ibmlcd.h"
56 #include <linux/kernel.h>
57 #include <linux/autoconf.h>
58
59 #ifdef CONFIG_BEECH
60 static const struct ibmlcdfb_par HITACHI_QVGA_STN = {
61         /* DCR */
62         .reduced_horiz_blanking         = 1,
63         .tft_multiplex_ratio            = 1,
64         .FPSHIFT_clocks                 = 1,
65         .pixel_clock_per_shift_clock    = 3,
66         .n_scan_mode                    = 1,
67         .LCD_panel_size                 = STN_8BIT,
68         .LCD_panel_type                 = IBMLCD_COLOR_STN,
69
70         /* DFRMR */
71         .FRM_bits                       = 4,
72         .dither_bits                    = 2,
73         .native_resolution_bits         = 1,
74
75         /* PSR */
76         .FPSHIFT_delay                  = 12,
77         .FPFRAME_delay                  = 12,
78         .FP_VEE_EN_delay                = 13,
79         .FP_EN_delay                    = 14,
80
81         /* ADSR */
82         .horiz_pixels                   = 320,
83         .vert_pixels                    = 240,
84
85         /* TDSR */
86         .total_horiz_pixels             = 328,
87         .total_vert_pixels              = 245,
88
89         .FPLINE_mask_during_v_blank     = 0,
90         .FPLINE_polarity_negative       = 0,
91
92         .FPLINE_hoff_start              = 122,
93                 /* 122 * 8/3 =  325; Yes this looks strange. */
94                 /* Basic idea - setting hoff_start to zero resulted in screen
95                  * being shifted to the right several pixels.  To correct this,
96                  * we set the value here to the equivalent of -3 pixels in the
97                  * data stream.  -3 = 325 mod 328.
98                  * Why the 8/3?  The Controller sees 8 bit values, but sends
99                  * 3 bit values packed to the LCD.  Yeah, funky, like I said.
100                  * Koji Ishii was the mastermind to figure this value out */
101         .FPLINE_hoff_end                = 0,
102
103         .FPFRAME_hoff                   = 1,
104         .FPFRAME_polarity_negative      = 0,
105
106         .FPFRAME_voff_start             = 0,
107         .FPFRAME_voff_end               = 1,
108
109         .FPSHIFT_masking                = IBMLCD_FPSHIFT_NO_MASKING,
110         .FPSHIFT_valid_at_positive_edge = 0,
111
112         .FPDRDY_polarity_negative       = 0,
113         .FPDATA_polarity_negative       = 0,
114
115         .pixels_big_endian              = 1,
116         .pixel_packing                  = IBMLCD_RGB,
117         .pixel_size                     = IBMLCD_PIX_16BPP,
118         .pixel_index_size               = IBMLCD_PAL_8BPP,
119         .palette_enable                 = 0,
120         .enable_surface                 = 1,
121
122         .fb_base_address                = 0, /* dummy value */
123         .stride                         = 320 * 2, /* 320 pixels, 2 bytes per pixel */
124         .cursor_enable                  = 0,
125         .cursor_base_address            = 0, /* dummy value */
126         .cursor_x                       = 0,
127         .cursor_y                       = 0,
128
129         .cc0r                           = 0,
130         .cc0g                           = 0,
131         .cc0b                           = 0,
132
133         .cc1r                           = 0xFF,
134         .cc1g                           = 0xFF,
135         .cc1b                           = 0xFF,
136
137         /* The Hitachi STN is specified for a Pixel clock in the range of 
138            6 MHz to 8 Mhz.  CLock frequencies are in KHz */
139         .pixclk_min                     = 6000,
140         .pixclk_max                     = 8000
141 };
142
143 static const struct ibmlcdfb_par TOSHIBA_VGA_TFT = {
144         /* DCR */
145         .reduced_horiz_blanking         = 1,
146         .tft_multiplex_ratio            = 1,
147         .FPSHIFT_clocks                 = 1,
148         .pixel_clock_per_shift_clock    = 1,
149         .n_scan_mode                    = 1,
150         .LCD_panel_size                 = TFT_18BIT,
151         .LCD_panel_type                 = IBMLCD_COLOR_TFT,
152
153         /* FRMR */
154         .FRM_bits                       = 0,
155         .dither_bits                    = 0,
156         .native_resolution_bits         = 6,
157
158         /* PSR */
159         .FPSHIFT_delay                  = 12,
160         .FPFRAME_delay                  = 12,
161         .FP_VEE_EN_delay                = 13,
162         .FP_EN_delay                    = 14,
163
164         /* ADSR */
165         .horiz_pixels                   = 640,
166         .vert_pixels                    = 480,
167
168         /* TDSR */
169         .total_horiz_pixels             = 800,
170         .total_vert_pixels              = 525,
171
172         .FPLINE_mask_during_v_blank     = 1,
173         .FPLINE_polarity_negative       = 1,
174
175         .FPLINE_hoff_start              = 640, /* See comment in the first configuration */
176         .FPLINE_hoff_end                = 0,
177
178         .FPFRAME_hoff                   = 1,
179         .FPFRAME_polarity_negative      = 1,
180
181         .FPFRAME_voff_start             = 480,
182         .FPFRAME_voff_end               = 0,
183
184         .FPSHIFT_masking                = IBMLCD_FPSHIFT_NO_MASKING,
185         .FPSHIFT_valid_at_positive_edge = 0,
186
187         .FPDRDY_polarity_negative       = 0,
188         .FPDATA_polarity_negative       = 0,
189
190         .pixels_big_endian              = 1,
191         .pixel_packing                  = IBMLCD_RGB,
192         .pixel_size                     = IBMLCD_PIX_16BPP,
193         .pixel_index_size               = IBMLCD_PAL_8BPP,
194         .palette_enable                 = 0,
195         .enable_surface                 = 1,
196
197         .fb_base_address                = 0, /* dummy value */
198         .stride                         = 640 * 2, /* 640 pixels, 2 bytes per pixel */
199         .cursor_enable                  = 0,
200         .cursor_base_address            = 0, /* dummy value */
201         .cursor_x                       = 0,
202         .cursor_y                       = 0,
203
204         .cc0r                           = 0,
205         .cc0g                           = 0,
206         .cc0b                           = 0,
207
208         .cc1r                           = 0xFF,
209         .cc1g                           = 0xFF,
210         .cc1b                           = 0xFF,
211
212         /* The Toshiba TFT is specified for a Pixel clock in the range of 
213            21.5 MHz to 28.6 Mhz.  Clock frequencies are in KHz */
214         .pixclk_min                     = 21500,
215         .pixclk_max                     = 28600
216 };
217
218 #endif /* CONFIG_BEECH */
219
220 #if defined(CONFIG_ARCTIC2)
221 static const struct ibmlcdfb_par TOSHIBA_LCD_CONFIGA2 = {
222         /* DCR */
223         .reduced_horiz_blanking         = 0,
224         .tft_multiplex_ratio            = 0,
225         .FPSHIFT_clocks                 = 0,
226         .pixel_clock_per_shift_clock    = 1,
227         .n_scan_mode                    = 1,
228         .LCD_panel_size                 = TFT_15BIT,
229         .LCD_panel_type                 = IBMLCD_COLOR_TFT,
230
231         /* FRMR */
232         .FRM_bits                       = 0,
233         .dither_bits                    = 0,
234         .native_resolution_bits         = 6,
235
236         /* PSR */
237         .FPSHIFT_delay                  = 12,
238         .FPFRAME_delay                  = 0,
239         .FP_VEE_EN_delay                = 13,
240         .FP_EN_delay                    = 14,
241
242         /* ADSR */
243         .horiz_pixels                   = 240,
244         .vert_pixels                    = 319,
245
246         /* TDSR */
247         .total_horiz_pixels             = 280,
248         .total_vert_pixels              = 440,
249
250         .FPLINE_mask_during_v_blank     = 0,
251         .FPLINE_polarity_negative       = 1,
252
253         .FPLINE_hoff_start              = 252, /* See comment in the first configuration */
254         .FPLINE_hoff_end                = 268,
255
256         .FPFRAME_hoff                   = 1,
257         .FPFRAME_polarity_negative      = 1,
258
259         .FPFRAME_voff_start             = 0x14D,        
260         .FPFRAME_voff_end               = 438,
261
262         .FPSHIFT_masking                = IBMLCD_FPSHIFT_NO_MASKING,
263         .FPSHIFT_valid_at_positive_edge = 0,
264
265         .FPDRDY_polarity_negative       = 0,
266         .FPDATA_polarity_negative       = 0,
267
268         .pixels_big_endian              = 1,
269         .pixel_packing                  = IBMLCD_RGB,
270         .pixel_size                     = IBMLCD_PIX_16BPP,
271         .pixel_index_size               = IBMLCD_PAL_8BPP,
272         .palette_enable                 = 0,
273         .enable_surface                 = 1,
274
275         .fb_base_address                = 0, /* dummy value */
276         .stride                         = 240*2, /* 240 pixels, 2 bytes per pixel */
277         .cursor_enable                  = 0,
278         .cursor_base_address            = 0, /* dummy value */
279         .cursor_x                       = 0,
280         .cursor_y                       = 0,
281
282         .cc0r                           = 0,
283         .cc0g                           = 0,
284         .cc0b                           = 0,
285
286         .cc1r                           = 0xFF,
287         .cc1g                           = 0xFF,
288         .cc1b                           = 0xFF,
289
290         /* The Toshiba TFT is specified for a Pixel clock in the range of
291            XX MHz to YY MHz.  CLock frequencies are in KHz */
292         .pixclk_min                     = 5000,
293         .pixclk_max                     = 6000,
294 };
295 #endif
296
297 /* Format: A sequence of database entries, terminated by two consecutive NULLs
298  *      Each entry consists of:
299  *      + a pointer to a (constant) par description for the LCD,
300  *      + 1 or more pointers to (constant) descriptive strings / aliases,
301  *      + a NULL
302  */
303 static const void *ibmlcd_configs[] = {
304 #ifdef CONFIG_BEECH
305         /* First Entry */
306         &HITACHI_QVGA_STN,
307         "HitachiQVGA-STN",
308         "HitachiSC09Q002-AZA",
309         NULL,
310         /* Second Entry */
311         &TOSHIBA_VGA_TFT,
312         "ToshibaVGA-TFT",
313         "ToshibaLTM04C380K",
314         NULL,
315 #endif /* CONFIG_BEECH */
316
317 #ifdef CONFIG_ARCTIC2
318         &TOSHIBA_LCD_CONFIGA2,
319         "ToshibaTFTA2",
320         NULL,
321 #endif
322         /* Last Entry */
323         NULL,
324 };
325
326 const struct ibmlcdfb_par *ibmlcd_config_matching(char *description)
327 {
328         void **entry = (void **)ibmlcd_configs;
329         while ((*entry) != NULL) {
330                 char ** name = (char **)entry;
331
332                 while (*(++name) != NULL)
333                         if (strcmp(description, *name) == 0) {
334                                 printk(KERN_INFO
335                                        "ibmlcdfb: Configuring for panel %s\n",
336                                        *name);
337                                 return *entry;
338                         }
339                 entry = (void **)(++name);
340         }
341         return NULL;
342 }
343
344 const char *ibmlcd_config_name(const struct ibmlcdfb_par *par)
345 {
346         const void **entry;
347
348         for (entry = ibmlcd_configs; (*entry) != NULL; entry++) {
349                 if ((*entry) == par)
350                         return *(entry+1);
351                 else while (*entry != NULL) 
352                         entry++;
353         }
354         return "Invalid LCD Description";
355 }
356
357 /*
358  * Local variables:
359  * c-basic-offset: 8
360  * End:
361  */