]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - include/lcd.h
applied patches from Freescale and Ka-Ro
[karo-tx-uboot.git] / include / lcd.h
1 /*
2  * Copyright (C) 2004-2010 Freescale Semiconductor, Inc.
3  *
4  * MPC823 and PXA LCD Controller
5  *
6  * Modeled after video interface by Paolo Scaffardi
7  *
8  *
9  * (C) Copyright 2001
10  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
11  *
12  * See file CREDITS for list of people who contributed to this
13  * project.
14  *
15  * This program is free software; you can redistribute it and/or
16  * modify it under the terms of the GNU General Public License as
17  * published by the Free Software Foundation; either version 2 of
18  * the License, or (at your option) any later version.
19  *
20  * This program is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23  * GNU General Public License for more details.
24  *
25  * You should have received a copy of the GNU General Public License
26  * along with this program; if not, write to the Free Software
27  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
28  * MA 02111-1307 USA
29  */
30
31 #ifndef _LCD_H_
32 #define _LCD_H_
33
34 extern char lcd_is_enabled;
35
36 extern int lcd_line_length;
37 extern int lcd_color_fg;
38 extern int lcd_color_bg;
39
40 /*
41  * Frame buffer memory information
42  */
43 extern void *lcd_base;          /* Start of framebuffer memory  */
44 extern void *lcd_console_address;       /* Start of console buffer      */
45
46 extern short console_col;
47 extern short console_row;
48 extern struct vidinfo panel_info;
49
50 extern void lcd_ctrl_init (void *lcdbase);
51 extern void lcd_enable (void);
52
53 /* setcolreg used in 8bpp/16bpp; initcolregs used in monochrome */
54 extern void lcd_setcolreg (ushort regno,
55                                 ushort red, ushort green, ushort blue);
56 extern void lcd_initcolregs (void);
57
58 /* gunzip_bmp used if CONFIG_VIDEO_BMP_GZIP */
59 extern struct bmp_image *gunzip_bmp(unsigned long addr, unsigned long *lenp);
60
61 #if defined CONFIG_MPC823
62 /*
63  * LCD controller stucture for MPC823 CPU
64  */
65 typedef struct vidinfo {
66         ushort  vl_col;         /* Number of columns (i.e. 640) */
67         ushort  vl_row;         /* Number of rows (i.e. 480) */
68         ushort  vl_width;       /* Width of display area in millimeters */
69         ushort  vl_height;      /* Height of display area in millimeters */
70
71         /* LCD configuration register */
72         u_char  vl_clkp;        /* Clock polarity */
73         u_char  vl_oep;         /* Output Enable polarity */
74         u_char  vl_hsp;         /* Horizontal Sync polarity */
75         u_char  vl_vsp;         /* Vertical Sync polarity */
76         u_char  vl_dp;          /* Data polarity */
77         u_char  vl_bpix;        /* Bits per pixel, 0 = 1, 1 = 2, 2 = 4, 3 = 8 */
78         u_char  vl_lbw;         /* LCD Bus width, 0 = 4, 1 = 8 */
79         u_char  vl_splt;        /* Split display, 0 = single-scan, 1 = dual-scan */
80         u_char  vl_clor;        /* Color, 0 = mono, 1 = color */
81         u_char  vl_tft;         /* 0 = passive, 1 = TFT */
82
83         /* Horizontal control register. Timing from data sheet */
84         ushort  vl_wbl;         /* Wait between lines */
85
86         /* Vertical control register */
87         u_char  vl_vpw;         /* Vertical sync pulse width */
88         u_char  vl_lcdac;       /* LCD AC timing */
89         u_char  vl_wbf;         /* Wait between frames */
90 } vidinfo_t;
91
92 #elif defined CONFIG_PXA250
93 /*
94  * PXA LCD DMA descriptor
95  */
96 struct pxafb_dma_descriptor {
97         u_long  fdadr;          /* Frame descriptor address register */
98         u_long  fsadr;          /* Frame source address register */
99         u_long  fidr;           /* Frame ID register */
100         u_long  ldcmd;          /* Command register */
101 };
102
103 /*
104  * PXA LCD info
105  */
106 struct pxafb_info {
107
108         /* Misc registers */
109         u_long  reg_lccr3;
110         u_long  reg_lccr2;
111         u_long  reg_lccr1;
112         u_long  reg_lccr0;
113         u_long  fdadr0;
114         u_long  fdadr1;
115
116         /* DMA descriptors */
117         struct  pxafb_dma_descriptor *  dmadesc_fblow;
118         struct  pxafb_dma_descriptor *  dmadesc_fbhigh;
119         struct  pxafb_dma_descriptor *  dmadesc_palette;
120
121         u_long  screen;         /* physical address of frame buffer */
122         u_long  palette;        /* physical address of palette memory */
123         u_int   palette_size;
124 };
125
126 /*
127  * LCD controller stucture for PXA CPU
128  */
129 typedef struct vidinfo {
130         ushort  vl_col;         /* Number of columns (i.e. 640) */
131         ushort  vl_row;         /* Number of rows (i.e. 480) */
132         ushort  vl_width;       /* Width of display area in millimeters */
133         ushort  vl_height;      /* Height of display area in millimeters */
134
135         /* LCD configuration register */
136         u_char  vl_clkp;        /* Clock polarity */
137         u_char  vl_oep;         /* Output Enable polarity */
138         u_char  vl_hsp;         /* Horizontal Sync polarity */
139         u_char  vl_vsp;         /* Vertical Sync polarity */
140         u_char  vl_dp;          /* Data polarity */
141         u_char  vl_bpix;        /* Bits per pixel, 0 = 1, 1 = 2, 2 = 4, 3 = 8, 4 = 16 */
142         u_char  vl_lbw;         /* LCD Bus width, 0 = 4, 1 = 8 */
143         u_char  vl_splt;        /* Split display, 0 = single-scan, 1 = dual-scan */
144         u_char  vl_clor;        /* Color, 0 = mono, 1 = color */
145         u_char  vl_tft;         /* 0 = passive, 1 = TFT */
146
147         /* Horizontal control register. Timing from data sheet */
148         ushort  vl_hpw;         /* Horz sync pulse width */
149         u_char  vl_blw;         /* Wait before of line */
150         u_char  vl_elw;         /* Wait end of line */
151
152         /* Vertical control register. */
153         u_char  vl_vpw;         /* Vertical sync pulse width */
154         u_char  vl_bfw;         /* Wait before of frame */
155         u_char  vl_efw;         /* Wait end of frame */
156
157         /* PXA LCD controller params */
158         struct  pxafb_info pxa;
159 } vidinfo_t;
160
161 #elif defined(CONFIG_ATMEL_LCD)
162
163 typedef struct vidinfo {
164         u_long vl_col;          /* Number of columns (i.e. 640) */
165         u_long vl_row;          /* Number of rows (i.e. 480) */
166         u_long vl_clk;  /* pixel clock in ps    */
167
168         /* LCD configuration register */
169         u_long vl_sync;         /* Horizontal / vertical sync */
170         u_long vl_bpix;         /* Bits per pixel, 0 = 1, 1 = 2, 2 = 4, 3 = 8, 4 = 16 */
171         u_long vl_tft;          /* 0 = passive, 1 = TFT */
172
173         /* Horizontal control register. */
174         u_long vl_hsync_len;    /* Length of horizontal sync */
175         u_long vl_left_margin;  /* Time from sync to picture */
176         u_long vl_right_margin; /* Time from picture to sync */
177
178         /* Vertical control register. */
179         u_long vl_vsync_len;    /* Length of vertical sync */
180         u_long vl_upper_margin; /* Time from sync to picture */
181         u_long vl_lower_margin; /* Time from picture to sync */
182
183         u_long  mmio;           /* Memory mapped registers */
184 } vidinfo_t;
185
186 #elif defined(CONFIG_MXC2_LCD)
187
188 typedef struct vidinfo {
189         u_long vl_refresh;      /* Refresh Rate Hz */
190         u_long vl_row;          /* resolution in x */
191         u_long vl_col;          /* resolution in y */
192         u_long vl_pixclock;     /* pixel clock in picoseconds */
193         u_long vl_left_margin;  /* Horizontal back porch */
194         u_long vl_right_margin; /* Horizontal front porch */
195         u_long vl_upper_margin; /* Vertical back porch */
196         u_long vl_lower_margin; /* Vertical front porch */
197         u_long vl_hsync;        /* Horizontal sync pulse length */
198         u_long vl_vsync;        /* Vertical sync pulse length */
199         u_long vl_sync;         /* Polarity on data enable */
200         u_long vl_mode;         /* Video Mode */
201         u_long vl_flag;
202         u_char  vl_bpix;
203         ushort  *cmap;
204 } vidinfo_t;
205
206 #elif defined(CONFIG_MXC_EPDC)
207
208 struct waveform_modes {
209         int mode_init;
210         int mode_du;
211         int mode_gc4;
212         int mode_gc8;
213         int mode_gc16;
214         int mode_gc32;
215 };
216
217 struct epdc_data_struct {
218         /* EPDC buffer pointers */
219         u_long working_buf_addr;
220         u_long waveform_buf_addr;
221
222         /* Waveform mode definitions */
223         struct waveform_modes wv_modes;
224 };
225
226 typedef struct vidinfo {
227         u_long vl_refresh;      /* Refresh Rate Hz */
228         u_long vl_row;          /* resolution in x */
229         u_long vl_col;          /* resolution in y */
230         u_long vl_pixclock;     /* pixel clock in picoseconds */
231         u_long vl_left_margin;  /* Horizontal back porch */
232         u_long vl_right_margin; /* Horizontal front porch */
233         u_long vl_upper_margin; /* Vertical back porch */
234         u_long vl_lower_margin; /* Vertical front porch */
235         u_long vl_hsync;        /* Horizontal sync pulse length */
236         u_long vl_vsync;        /* Vertical sync pulse length */
237         u_long vl_sync;         /* Polarity on data enable */
238         u_long vl_mode;         /* Video Mode */
239         u_long vl_flag;
240         u_char  vl_bpix;
241         ushort  *cmap;
242         struct epdc_data_struct epdc_data;
243 } vidinfo_t;
244
245 #else
246
247 typedef struct vidinfo {
248         ushort  vl_col;         /* Number of columns (i.e. 160) */
249         ushort  vl_row;         /* Number of rows (i.e. 100) */
250
251         u_char  vl_bpix;        /* Bits per pixel, 0 = 1 */
252
253         ushort  *cmap;          /* Pointer to the colormap */
254
255         void    *priv;          /* Pointer to driver-specific data */
256 } vidinfo_t;
257
258 #endif /* CONFIG_MPC823, CONFIG_PXA250 or CONFIG_MCC200 or CONFIG_ATMEL_LCD */
259
260 extern vidinfo_t panel_info;
261
262 /* Video functions */
263
264 #if defined(CONFIG_RBC823)
265 void    lcd_disable     (void);
266 #endif
267
268
269 /* int  lcd_init        (void *lcdbase); */
270 void    lcd_putc        (const char c);
271 void    lcd_puts        (const char *s);
272 void    lcd_printf      (const char *fmt, ...);
273
274 /* Allow boards to customize the information displayed */
275 void lcd_show_board_info(void);
276
277 /************************************************************************/
278 /* ** BITMAP DISPLAY SUPPORT                                            */
279 /************************************************************************/
280 #if defined(CONFIG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN)
281 # include <bmp_layout.h>
282 # include <asm/byteorder.h>
283 #endif
284
285 /*
286  *  Information about displays we are using. This is for configuring
287  *  the LCD controller and memory allocation. Someone has to know what
288  *  is connected, as we can't autodetect anything.
289  */
290 #define CONFIG_SYS_HIGH 0       /* Pins are active high                 */
291 #define CONFIG_SYS_LOW          1       /* Pins are active low                  */
292
293 #define LCD_MONOCHROME  0
294 #define LCD_COLOR2      1
295 #define LCD_COLOR4      2
296 #define LCD_COLOR8      3
297 #define LCD_COLOR16     4
298
299 /*----------------------------------------------------------------------*/
300 #if defined(CONFIG_LCD_INFO_BELOW_LOGO)
301 # define LCD_INFO_X             0
302 # define LCD_INFO_Y             (BMP_LOGO_HEIGHT + VIDEO_FONT_HEIGHT)
303 #elif defined(CONFIG_LCD_LOGO)
304 # define LCD_INFO_X             (BMP_LOGO_WIDTH + 4 * VIDEO_FONT_WIDTH)
305 # define LCD_INFO_Y             (VIDEO_FONT_HEIGHT)
306 #else
307 # define LCD_INFO_X             (VIDEO_FONT_WIDTH)
308 # define LCD_INFO_Y             (VIDEO_FONT_HEIGHT)
309 #endif
310
311 /* Default to 8bpp if bit depth not specified */
312 #ifndef LCD_BPP
313 # define LCD_BPP                        LCD_COLOR8
314 #endif
315 #ifndef LCD_DF
316 # define LCD_DF                 1
317 #endif
318
319 /* Calculate nr. of bits per pixel  and nr. of colors */
320 #define NBITS(bit_code)         (1 << (bit_code))
321 #define NCOLORS(bit_code)       (1 << NBITS(bit_code))
322
323 /************************************************************************/
324 /* ** CONSOLE CONSTANTS                                                 */
325 /************************************************************************/
326 #if LCD_BPP == LCD_MONOCHROME
327
328 /*
329  * Simple black/white definitions
330  */
331 # define CONSOLE_COLOR_BLACK    0
332 # define CONSOLE_COLOR_WHITE    1       /* Must remain last / highest   */
333
334 #elif LCD_BPP == LCD_COLOR8
335
336 /*
337  * 8bpp color definitions
338  */
339 # define CONSOLE_COLOR_BLACK    0
340 # define CONSOLE_COLOR_RED      1
341 # define CONSOLE_COLOR_GREEN    2
342 # define CONSOLE_COLOR_YELLOW   3
343 # define CONSOLE_COLOR_BLUE     4
344 # define CONSOLE_COLOR_MAGENTA  5
345 # define CONSOLE_COLOR_CYAN     6
346 # define CONSOLE_COLOR_GREY     14
347 # define CONSOLE_COLOR_WHITE    15      /* Must remain last / highest   */
348
349 #else
350
351 /*
352  * 16bpp color definitions
353  */
354 # define CONSOLE_COLOR_BLACK    0x0000
355 # define CONSOLE_COLOR_WHITE    0xffff  /* Must remain last / highest   */
356
357 #endif /* color definitions */
358
359 /************************************************************************/
360 #ifndef PAGE_SIZE
361 # define PAGE_SIZE      4096
362 #endif
363
364 /************************************************************************/
365 /* ** CONSOLE DEFINITIONS & FUNCTIONS                                   */
366 /************************************************************************/
367 #if defined(CONFIG_LCD_LOGO) && !defined(CONFIG_LCD_INFO_BELOW_LOGO)
368 # define CONSOLE_ROWS           ((panel_info.vl_row-BMP_LOGO_HEIGHT) \
369                                         / VIDEO_FONT_HEIGHT)
370 #else
371 # define CONSOLE_ROWS           (panel_info.vl_row / VIDEO_FONT_HEIGHT)
372 #endif
373
374 #define CONSOLE_COLS            (panel_info.vl_col / VIDEO_FONT_WIDTH)
375 #define CONSOLE_ROW_SIZE        (VIDEO_FONT_HEIGHT * lcd_line_length)
376 #define CONSOLE_ROW_FIRST       (lcd_console_address)
377 #define CONSOLE_ROW_SECOND      (lcd_console_address + CONSOLE_ROW_SIZE)
378 #define CONSOLE_ROW_LAST        (lcd_console_address + CONSOLE_SIZE \
379                                         - CONSOLE_ROW_SIZE)
380 #define CONSOLE_SIZE            (CONSOLE_ROW_SIZE * CONSOLE_ROWS)
381 #define CONSOLE_SCROLL_SIZE     (CONSOLE_SIZE - CONSOLE_ROW_SIZE)
382
383 #if LCD_BPP == LCD_MONOCHROME
384 # define COLOR_MASK(c)          ((c)      | (c) << 1 | (c) << 2 | (c) << 3 | \
385                                  (c) << 4 | (c) << 5 | (c) << 6 | (c) << 7)
386 #elif (LCD_BPP == LCD_COLOR8) || (LCD_BPP == LCD_COLOR16)
387 # define COLOR_MASK(c)          (c)
388 #else
389 # error Unsupported LCD BPP.
390 #endif
391
392 /************************************************************************/
393
394 #endif  /* _LCD_H_ */