xref: /openbmc/u-boot/common/lcd.c (revision a562e1bd)
1 /*
2  * Common LCD routines for supported CPUs
3  *
4  * (C) Copyright 2001-2002
5  * Wolfgang Denk, DENX Software Engineering -- wd@denx.de
6  *
7  * See file CREDITS for list of people who contributed to this
8  * project.
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License as
12  * published by the Free Software Foundation; either version 2 of
13  * the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
23  * MA 02111-1307 USA
24  */
25 
26 /************************************************************************/
27 /* ** HEADER FILES							*/
28 /************************************************************************/
29 
30 /* #define DEBUG */
31 
32 #include <config.h>
33 #include <common.h>
34 #include <command.h>
35 #include <version.h>
36 #include <stdarg.h>
37 #include <linux/types.h>
38 #include <devices.h>
39 #if defined(CONFIG_POST)
40 #include <post.h>
41 #endif
42 #include <lcd.h>
43 
44 #if defined(CONFIG_PXA250)
45 #include <asm/byteorder.h>
46 #endif
47 
48 #if defined(CONFIG_MPC823)
49 #include <watchdog.h>
50 #include <lcdvideo.h>
51 #endif
52 
53 
54 #ifdef CONFIG_LCD
55 
56 /************************************************************************/
57 /* ** FONT DATA								*/
58 /************************************************************************/
59 #include <video_font.h>		/* Get font data, width and height	*/
60 
61 
62 ulong lcd_setmem (ulong addr);
63 
64 static void lcd_drawchars (ushort x, ushort y, uchar *str, int count);
65 static inline void lcd_puts_xy (ushort x, ushort y, uchar *s);
66 static inline void lcd_putc_xy (ushort x, ushort y, uchar  c);
67 
68 static int lcd_init (void *lcdbase);
69 
70 static int lcd_clear (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]);
71 extern void lcd_ctrl_init (void *lcdbase);
72 extern void lcd_enable (void);
73 static void *lcd_logo (void);
74 
75 
76 #if LCD_BPP == LCD_COLOR8
77 extern void lcd_setcolreg (ushort regno,
78 				ushort red, ushort green, ushort blue);
79 #endif
80 #if LCD_BPP == LCD_MONOCHROME
81 extern void lcd_initcolregs (void);
82 #endif
83 
84 static int lcd_getbgcolor (void);
85 static void lcd_setfgcolor (int color);
86 static void lcd_setbgcolor (int color);
87 
88 char lcd_is_enabled = 0;
89 extern vidinfo_t panel_info;
90 
91 #ifdef	NOT_USED_SO_FAR
92 static void lcd_getcolreg (ushort regno,
93 				ushort *red, ushort *green, ushort *blue);
94 static int lcd_getfgcolor (void);
95 #endif	/* NOT_USED_SO_FAR */
96 
97 /************************************************************************/
98 
99 /*----------------------------------------------------------------------*/
100 
101 static void console_scrollup (void)
102 {
103 #if 1
104 	/* Copy up rows ignoring the first one */
105 	memcpy (CONSOLE_ROW_FIRST, CONSOLE_ROW_SECOND, CONSOLE_SCROLL_SIZE);
106 
107 	/* Clear the last one */
108 	memset (CONSOLE_ROW_LAST, COLOR_MASK(lcd_color_bg), CONSOLE_ROW_SIZE);
109 #else
110 	/*
111 	 * Poor attempt to optimize speed by moving "long"s.
112 	 * But the code is ugly, and not a bit faster :-(
113 	 */
114 	ulong *t = (ulong *)CONSOLE_ROW_FIRST;
115 	ulong *s = (ulong *)CONSOLE_ROW_SECOND;
116 	ulong    l = CONSOLE_SCROLL_SIZE / sizeof(ulong);
117 	uchar  c = lcd_color_bg & 0xFF;
118 	ulong val= (c<<24) | (c<<16) | (c<<8) | c;
119 
120 	while (l--)
121 		*t++ = *s++;
122 
123 	t = (ulong *)CONSOLE_ROW_LAST;
124 	l = CONSOLE_ROW_SIZE / sizeof(ulong);
125 
126 	while (l-- > 0)
127 		*t++ = val;
128 #endif
129 }
130 
131 /*----------------------------------------------------------------------*/
132 
133 static inline void console_back (void)
134 {
135 	if (--console_col < 0) {
136 		console_col = CONSOLE_COLS-1 ;
137 		if (--console_row < 0) {
138 			console_row = 0;
139 		}
140 	}
141 
142 	lcd_putc_xy (console_col * VIDEO_FONT_WIDTH,
143 		     console_row * VIDEO_FONT_HEIGHT,
144 		     ' ');
145 }
146 
147 /*----------------------------------------------------------------------*/
148 
149 static inline void console_newline (void)
150 {
151 	++console_row;
152 	console_col = 0;
153 
154 	/* Check if we need to scroll the terminal */
155 	if (console_row >= CONSOLE_ROWS) {
156 		/* Scroll everything up */
157 		console_scrollup () ;
158 		--console_row;
159 	}
160 }
161 
162 /*----------------------------------------------------------------------*/
163 
164 void lcd_putc (const char c)
165 {
166 	if (!lcd_is_enabled) {
167 		serial_putc(c);
168 		return;
169 	}
170 
171 	switch (c) {
172 	case '\r':	console_col = 0;
173 			return;
174 
175 	case '\n':	console_newline();
176 			return;
177 
178 	case '\t':	/* Tab (8 chars alignment) */
179 			console_col |=  8;
180 			console_col &= ~7;
181 
182 			if (console_col >= CONSOLE_COLS) {
183 				console_newline();
184 			}
185 			return;
186 
187 	case '\b':	console_back();
188 			return;
189 
190 	default:	lcd_putc_xy (console_col * VIDEO_FONT_WIDTH,
191 				     console_row * VIDEO_FONT_HEIGHT,
192 				     c);
193 			if (++console_col >= CONSOLE_COLS) {
194 				console_newline();
195 			}
196 			return;
197 	}
198 	/* NOTREACHED */
199 }
200 
201 /*----------------------------------------------------------------------*/
202 
203 void lcd_puts (const char *s)
204 {
205 	if (!lcd_is_enabled) {
206 		serial_puts (s);
207 		return;
208 	}
209 
210 	while (*s) {
211 		lcd_putc (*s++);
212 	}
213 }
214 
215 /************************************************************************/
216 /* ** Low-Level Graphics Routines					*/
217 /************************************************************************/
218 
219 static void lcd_drawchars (ushort x, ushort y, uchar *str, int count)
220 {
221 	uchar *dest;
222 	ushort off, row;
223 
224 	dest = (uchar *)(lcd_base + y * lcd_line_length + x * (1 << LCD_BPP) / 8);
225 	off  = x * (1 << LCD_BPP) % 8;
226 
227 	for (row=0;  row < VIDEO_FONT_HEIGHT;  ++row, dest += lcd_line_length)  {
228 		uchar *s = str;
229 		uchar *d = dest;
230 		int i;
231 
232 #if LCD_BPP == LCD_MONOCHROME
233 		uchar rest = *d & -(1 << (8-off));
234 		uchar sym;
235 #endif
236 		for (i=0; i<count; ++i) {
237 			uchar c, bits;
238 
239 			c = *s++;
240 			bits = video_fontdata[c * VIDEO_FONT_HEIGHT + row];
241 
242 #if LCD_BPP == LCD_MONOCHROME
243 			sym  = (COLOR_MASK(lcd_color_fg) & bits) |
244 			       (COLOR_MASK(lcd_color_bg) & ~bits);
245 
246 			*d++ = rest | (sym >> off);
247 			rest = sym << (8-off);
248 #elif LCD_BPP == LCD_COLOR8
249 			for (c=0; c<8; ++c) {
250 				*d++ = (bits & 0x80) ?
251 						lcd_color_fg : lcd_color_bg;
252 				bits <<= 1;
253 			}
254 #elif LCD_BPP == LCD_COLOR16
255 			for (c=0; c<16; ++c) {
256 				*d++ = (bits & 0x80) ?
257 						lcd_color_fg : lcd_color_bg;
258 				bits <<= 1;
259 			}
260 #endif
261 		}
262 #if LCD_BPP == LCD_MONOCHROME
263 		*d  = rest | (*d & ((1 << (8-off)) - 1));
264 #endif
265 	}
266 }
267 
268 /*----------------------------------------------------------------------*/
269 
270 static inline void lcd_puts_xy (ushort x, ushort y, uchar *s)
271 {
272 #if defined(CONFIG_LCD_LOGO) && !defined(LCD_INFO_BELOW_LOGO)
273 	lcd_drawchars (x, y+BMP_LOGO_HEIGHT, s, strlen (s));
274 #else
275 	lcd_drawchars (x, y, s, strlen (s));
276 #endif
277 }
278 
279 /*----------------------------------------------------------------------*/
280 
281 static inline void lcd_putc_xy (ushort x, ushort y, uchar c)
282 {
283 #if defined(CONFIG_LCD_LOGO) && !defined(LCD_INFO_BELOW_LOGO)
284 	lcd_drawchars (x, y+BMP_LOGO_HEIGHT, &c, 1);
285 #else
286 	lcd_drawchars (x, y, &c, 1);
287 #endif
288 }
289 
290 /************************************************************************/
291 /**  Small utility to check that you got the colours right		*/
292 /************************************************************************/
293 #ifdef LCD_TEST_PATTERN
294 
295 #define	N_BLK_VERT	2
296 #define	N_BLK_HOR	3
297 
298 static int test_colors[N_BLK_HOR*N_BLK_VERT] = {
299 	CONSOLE_COLOR_RED,	CONSOLE_COLOR_GREEN,	CONSOLE_COLOR_YELLOW,
300 	CONSOLE_COLOR_BLUE,	CONSOLE_COLOR_MAGENTA,	CONSOLE_COLOR_CYAN,
301 };
302 
303 static void test_pattern (void)
304 {
305 	ushort v_max  = panel_info.vl_row;
306 	ushort h_max  = panel_info.vl_col;
307 	ushort v_step = (v_max + N_BLK_VERT - 1) / N_BLK_VERT;
308 	ushort h_step = (h_max + N_BLK_HOR  - 1) / N_BLK_HOR;
309 	ushort v, h;
310 	uchar *pix = (uchar *)lcd_base;
311 
312 	printf ("[LCD] Test Pattern: %d x %d [%d x %d]\n",
313 		h_max, v_max, h_step, v_step);
314 
315 	/* WARNING: Code silently assumes 8bit/pixel */
316 	for (v=0; v<v_max; ++v) {
317 		uchar iy = v / v_step;
318 		for (h=0; h<h_max; ++h) {
319 			uchar ix = N_BLK_HOR * iy + (h/h_step);
320 			*pix++ = test_colors[ix];
321 		}
322 	}
323 }
324 #endif /* LCD_TEST_PATTERN */
325 
326 
327 /************************************************************************/
328 /* ** GENERIC Initialization Routines					*/
329 /************************************************************************/
330 
331 int drv_lcd_init (void)
332 {
333 	DECLARE_GLOBAL_DATA_PTR;
334 
335 	device_t lcddev;
336 	int rc;
337 
338 	lcd_base = (void *)(gd->fb_base);
339 
340 	lcd_line_length = (panel_info.vl_col * NBITS (panel_info.vl_bpix)) / 8;
341 
342 	lcd_init (lcd_base);		/* LCD initialization */
343 
344 	/* Device initialization */
345 	memset (&lcddev, 0, sizeof (lcddev));
346 
347 	strcpy (lcddev.name, "lcd");
348 	lcddev.ext   = 0;			/* No extensions */
349 	lcddev.flags = DEV_FLAGS_OUTPUT;	/* Output only */
350 	lcddev.putc  = lcd_putc;		/* 'putc' function */
351 	lcddev.puts  = lcd_puts;		/* 'puts' function */
352 
353 	rc = device_register (&lcddev);
354 
355 	return (rc == 0) ? 1 : rc;
356 }
357 
358 /*----------------------------------------------------------------------*/
359 static int lcd_clear (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
360 {
361 #if LCD_BPP == LCD_MONOCHROME
362 	/* Setting the palette */
363 	lcd_initcolregs();
364 
365 #elif LCD_BPP == LCD_COLOR8
366 	/* Setting the palette */
367 	lcd_setcolreg  (CONSOLE_COLOR_BLACK,       0,    0,    0);
368 	lcd_setcolreg  (CONSOLE_COLOR_RED,	0xFF,    0,    0);
369 	lcd_setcolreg  (CONSOLE_COLOR_GREEN,       0, 0xFF,    0);
370 	lcd_setcolreg  (CONSOLE_COLOR_YELLOW,	0xFF, 0xFF,    0);
371 	lcd_setcolreg  (CONSOLE_COLOR_BLUE,        0,    0, 0xFF);
372 	lcd_setcolreg  (CONSOLE_COLOR_MAGENTA,	0xFF,    0, 0xFF);
373 	lcd_setcolreg  (CONSOLE_COLOR_CYAN,	   0, 0xFF, 0xFF);
374 	lcd_setcolreg  (CONSOLE_COLOR_GREY,	0xAA, 0xAA, 0xAA);
375 	lcd_setcolreg  (CONSOLE_COLOR_WHITE,	0xFF, 0xFF, 0xFF);
376 #endif
377 
378 #ifndef CFG_WHITE_ON_BLACK
379 	lcd_setfgcolor (CONSOLE_COLOR_BLACK);
380 	lcd_setbgcolor (CONSOLE_COLOR_WHITE);
381 #else
382 	lcd_setfgcolor (CONSOLE_COLOR_WHITE);
383 	lcd_setbgcolor (CONSOLE_COLOR_BLACK);
384 #endif	/* CFG_WHITE_ON_BLACK */
385 
386 #ifdef	LCD_TEST_PATTERN
387 	test_pattern();
388 #else
389 	/* set framebuffer to background color */
390 	memset ((char *)lcd_base,
391 		COLOR_MASK(lcd_getbgcolor()),
392 		lcd_line_length*panel_info.vl_row);
393 #endif
394 	/* Paint the logo and retrieve LCD base address */
395 	debug ("[LCD] Drawing the logo...\n");
396 	lcd_console_address = lcd_logo ();
397 
398 	console_col = 0;
399 	console_row = 0;
400 
401 	return (0);
402 }
403 
404 U_BOOT_CMD(
405 	cls,	1,	1,	lcd_clear,
406 	"cls     - clear screen\n",
407 	NULL
408 );
409 
410 /*----------------------------------------------------------------------*/
411 
412 static int lcd_init (void *lcdbase)
413 {
414 	/* Initialize the lcd controller */
415 	debug ("[LCD] Initializing LCD frambuffer at %p\n", lcdbase);
416 
417 	lcd_ctrl_init (lcdbase);
418 	lcd_clear (NULL, 1, 1, NULL);	/* dummy args */
419 	lcd_enable ();
420 
421 	/* Initialize the console */
422 	console_col = 0;
423 #ifdef LCD_INFO_BELOW_LOGO
424 	console_row = 7 + BMP_LOGO_HEIGHT / VIDEO_FONT_HEIGHT;
425 #else
426 	console_row = 1;	/* leave 1 blank line below logo */
427 #endif
428 	lcd_is_enabled = 1;
429 
430 	return 0;
431 }
432 
433 
434 /************************************************************************/
435 /* ** ROM capable initialization part - needed to reserve FB memory	*/
436 /************************************************************************/
437 /*
438  * This is called early in the system initialization to grab memory
439  * for the LCD controller.
440  * Returns new address for monitor, after reserving LCD buffer memory
441  *
442  * Note that this is running from ROM, so no write access to global data.
443  */
444 ulong lcd_setmem (ulong addr)
445 {
446 	ulong size;
447 	int line_length = (panel_info.vl_col * NBITS (panel_info.vl_bpix)) / 8;
448 
449 	debug ("LCD panel info: %d x %d, %d bit/pix\n",
450 		panel_info.vl_col, panel_info.vl_row, NBITS (panel_info.vl_bpix) );
451 
452 	size = line_length * panel_info.vl_row;
453 
454 	/* Round up to nearest full page */
455 	size = (size + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1);
456 
457 	/* Allocate pages for the frame buffer. */
458 	addr -= size;
459 
460 	debug ("Reserving %ldk for LCD Framebuffer at: %08lx\n", size>>10, addr);
461 
462 	return (addr);
463 }
464 
465 /*----------------------------------------------------------------------*/
466 
467 static void lcd_setfgcolor (int color)
468 {
469 	lcd_color_fg = color & 0x0F;
470 }
471 
472 /*----------------------------------------------------------------------*/
473 
474 static void lcd_setbgcolor (int color)
475 {
476 	lcd_color_bg = color & 0x0F;
477 }
478 
479 /*----------------------------------------------------------------------*/
480 
481 #ifdef	NOT_USED_SO_FAR
482 static int lcd_getfgcolor (void)
483 {
484 	return lcd_color_fg;
485 }
486 #endif	/* NOT_USED_SO_FAR */
487 
488 /*----------------------------------------------------------------------*/
489 
490 static int lcd_getbgcolor (void)
491 {
492 	return lcd_color_bg;
493 }
494 
495 /*----------------------------------------------------------------------*/
496 
497 /************************************************************************/
498 /* ** Chipset depending Bitmap / Logo stuff...                          */
499 /************************************************************************/
500 #ifdef CONFIG_LCD_LOGO
501 void bitmap_plot (int x, int y)
502 {
503 	ushort *cmap;
504 	ushort i, j;
505 	uchar *bmap;
506 	uchar *fb;
507 	ushort *fb16;
508 #if defined(CONFIG_PXA250)
509 	struct pxafb_info *fbi = &panel_info.pxa;
510 #elif defined(CONFIG_MPC823)
511 	volatile immap_t *immr = (immap_t *) CFG_IMMR;
512 	volatile cpm8xx_t *cp = &(immr->im_cpm);
513 #endif
514 
515 	debug ("Logo: width %d  height %d  colors %d  cmap %d\n",
516 		BMP_LOGO_WIDTH, BMP_LOGO_HEIGHT, BMP_LOGO_COLORS,
517 		sizeof(bmp_logo_palette)/(sizeof(ushort)));
518 
519 	bmap = &bmp_logo_bitmap[0];
520 	fb   = (char *)(lcd_base + y * lcd_line_length + x);
521 
522 	if (NBITS(panel_info.vl_bpix) < 12) {
523 		/* Leave room for default color map */
524 #if defined(CONFIG_PXA250)
525 		cmap = (ushort *)fbi->palette;
526 #elif defined(CONFIG_MPC823)
527 		cmap = (ushort *)&(cp->lcd_cmap[BMP_LOGO_OFFSET*sizeof(ushort)]);
528 #endif
529 
530 		WATCHDOG_RESET();
531 
532 		/* Set color map */
533 		for (i=0; i<(sizeof(bmp_logo_palette)/(sizeof(ushort))); ++i) {
534 			ushort colreg = bmp_logo_palette[i];
535 #ifdef  CFG_INVERT_COLORS
536 			*cmap++ = 0xffff - colreg;
537 #else
538 			*cmap++ = colreg;
539 #endif
540 		}
541 
542 		WATCHDOG_RESET();
543 
544 		for (i=0; i<BMP_LOGO_HEIGHT; ++i) {
545 			memcpy (fb, bmap, BMP_LOGO_WIDTH);
546 			bmap += BMP_LOGO_WIDTH;
547 			fb   += panel_info.vl_col;
548 		}
549 	}
550 	else { /* true color mode */
551 		fb16 = (ushort *)(lcd_base + y * lcd_line_length + x);
552 		for (i=0; i<BMP_LOGO_HEIGHT; ++i) {
553 			for (j=0; j<BMP_LOGO_WIDTH; j++) {
554 				fb16[j] = bmp_logo_palette[(bmap[j])];
555 				}
556 			bmap += BMP_LOGO_WIDTH;
557 			fb16 += panel_info.vl_col;
558 		}
559 	}
560 
561 	WATCHDOG_RESET();
562 }
563 #endif /* CONFIG_LCD_LOGO */
564 
565 /*----------------------------------------------------------------------*/
566 #if (CONFIG_COMMANDS & CFG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN)
567 /*
568  * Display the BMP file located at address bmp_image.
569  * Only uncompressed.
570  */
571 int lcd_display_bitmap(ulong bmp_image, int x, int y)
572 {
573 	ushort *cmap;
574 	ushort i, j;
575 	uchar *fb;
576 	bmp_image_t *bmp=(bmp_image_t *)bmp_image;
577 	uchar *bmap;
578 	ushort padded_line;
579 	unsigned long width, height;
580 	unsigned colors,bpix;
581 	unsigned long compression;
582 #if defined(CONFIG_PXA250)
583 	struct pxafb_info *fbi = &panel_info.pxa;
584 #elif defined(CONFIG_MPC823)
585 	volatile immap_t *immr = (immap_t *) CFG_IMMR;
586 	volatile cpm8xx_t *cp = &(immr->im_cpm);
587 #endif
588 
589 	if (!((bmp->header.signature[0]=='B') &&
590 		(bmp->header.signature[1]=='M'))) {
591 		printf ("Error: no valid bmp image at %lx\n", bmp_image);
592 		return 1;
593 }
594 
595 	width = le32_to_cpu (bmp->header.width);
596 	height = le32_to_cpu (bmp->header.height);
597 	colors = 1<<le16_to_cpu (bmp->header.bit_count);
598 	compression = le32_to_cpu (bmp->header.compression);
599 
600 	bpix = NBITS(panel_info.vl_bpix);
601 
602 	if ((bpix != 1) && (bpix != 8)) {
603 		printf ("Error: %d bit/pixel mode not supported by U-Boot\n",
604 			bpix);
605 		return 1;
606 	}
607 
608 	if (bpix != le16_to_cpu(bmp->header.bit_count)) {
609 		printf ("Error: %d bit/pixel mode, but BMP has %d bit/pixel\n",
610 			bpix,
611 			le16_to_cpu(bmp->header.bit_count));
612 		return 1;
613 	}
614 
615 	debug ("Display-bmp: %d x %d  with %d colors\n",
616 		(int)width, (int)height, (int)colors);
617 
618 	if (bpix==8) {
619 #if defined(CONFIG_PXA250)
620 		cmap = (ushort *)fbi->palette;
621 #elif defined(CONFIG_MPC823)
622 		cmap = (ushort *)&(cp->lcd_cmap[255*sizeof(ushort)]);
623 #else
624 # error "Don't know location of color map"
625 #endif
626 
627 		/* Set color map */
628 		for (i=0; i<colors; ++i) {
629 			bmp_color_table_entry_t cte = bmp->color_table[i];
630 			ushort colreg =
631 				( ((cte.red)   << 8) & 0xf800) |
632 				( ((cte.green) << 4) & 0x07e0) |
633 				( (cte.blue) & 0x001f) ;
634 
635 #ifdef CFG_INVERT_COLORS
636 			*cmap = 0xffff - colreg;
637 #else
638 			*cmap = colreg;
639 #endif
640 #if defined(CONFIG_PXA250)
641 			cmap++;
642 #elif defined(CONFIG_MPC823)
643 			cmap--;
644 #endif
645 		}
646 	}
647 
648 	padded_line = (width&0x3) ? ((width&~0x3)+4) : (width);
649 	if ((x + width)>panel_info.vl_col)
650 		width = panel_info.vl_col - x;
651 	if ((y + height)>panel_info.vl_row)
652 		height = panel_info.vl_row - y;
653 
654 	bmap = (uchar *)bmp + le32_to_cpu (bmp->header.data_offset);
655 	fb   = (uchar *) (lcd_base +
656 		(y + height - 1) * lcd_line_length + x);
657 	for (i = 0; i < height; ++i) {
658 		for (j = 0; j < width ; j++)
659 #if defined(CONFIG_PXA250)
660 			*(fb++)=*(bmap++);
661 #elif defined(CONFIG_MPC823)
662 			*(fb++)=255-*(bmap++);
663 #endif
664 		bmap += (width - padded_line);
665 		fb   -= (width + lcd_line_length);
666 	}
667 
668 	return (0);
669 }
670 #endif /* (CONFIG_COMMANDS & CFG_CMD_BMP) || CONFIG_SPLASH_SCREEN */
671 
672 
673 static void *lcd_logo (void)
674 {
675 #ifdef LCD_INFO
676 	DECLARE_GLOBAL_DATA_PTR;
677 
678 	char info[80];
679 	char temp[32];
680 #endif /* LCD_INFO */
681 
682 #ifdef CONFIG_SPLASH_SCREEN
683 	char *s;
684 	ulong addr;
685 	static int do_splash = 1;
686 
687 	if (do_splash && (s = getenv("splashimage")) != NULL) {
688 		addr = simple_strtoul(s, NULL, 16);
689 		do_splash = 0;
690 
691 		if (lcd_display_bitmap (addr, 0, 0) == 0) {
692 			return ((void *)lcd_base);
693 		}
694 	}
695 #endif /* CONFIG_SPLASH_SCREEN */
696 
697 #ifdef CONFIG_LCD_LOGO
698 	bitmap_plot (0, 0);
699 #endif /* CONFIG_LCD_LOGO */
700 
701 #ifdef CONFIG_MPC823
702 #ifdef LCD_INFO
703 	sprintf (info, "%s (%s - %s) ", U_BOOT_VERSION, __DATE__, __TIME__);
704 	lcd_drawchars (LCD_INFO_X, LCD_INFO_Y, info, strlen(info));
705 
706 	sprintf (info, "(C) 2004 DENX Software Engineering");
707 	lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT,
708 					info, strlen(info));
709 
710 	sprintf (info, "    Wolfgang DENK, wd@denx.de");
711 	lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT * 2,
712 					info, strlen(info));
713 #ifdef LCD_INFO_BELOW_LOGO
714 	sprintf (info, "MPC823 CPU at %s MHz",
715 		strmhz(temp, gd->cpu_clk));
716 	lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT * 3,
717 					info, strlen(info));
718 	sprintf (info, "  %ld MB RAM, %ld MB Flash",
719 		gd->ram_size >> 20,
720 		gd->bd->bi_flashsize >> 20 );
721 	lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT * 4,
722 					info, strlen(info));
723 #else
724 	/* leave one blank line */
725 
726 	sprintf (info, "MPC823 CPU at %s MHz, %ld MB RAM, %ld MB Flash",
727 		strmhz(temp, gd->cpu_clk),
728 		gd->ram_size >> 20,
729 		gd->bd->bi_flashsize >> 20 );
730 	lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT * 4,
731 					info, strlen(info));
732 
733 #endif /* CONFIG_MPC823 */
734 #endif /* LCD_INFO_BELOW_LOGO */
735 #endif /* LCD_INFO */
736 
737 #if defined(CONFIG_LCD_LOGO) && !defined(LCD_INFO_BELOW_LOGO)
738 	return ((void *)((ulong)lcd_base + BMP_LOGO_HEIGHT * lcd_line_length));
739 #else
740 	return ((void *)lcd_base);
741 #endif /* CONFIG_LCD_LOGO */
742 }
743 
744 /************************************************************************/
745 /************************************************************************/
746 
747 #endif /* CONFIG_LCD */
748