wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2001-2002 |
| 3 | * Wolfgang Denk, DENX Software Engineering -- wd@denx.de |
| 4 | * |
| 5 | * See file CREDITS for list of people who contributed to this |
| 6 | * project. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License as |
| 10 | * published by the Free Software Foundation; either version 2 of |
| 11 | * the License, or (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 21 | * MA 02111-1307 USA |
| 22 | */ |
| 23 | |
| 24 | /************************************************************************/ |
| 25 | /* ** HEADER FILES */ |
| 26 | /************************************************************************/ |
| 27 | |
wdenk | 8564acf | 2003-07-14 22:13:32 +0000 | [diff] [blame] | 28 | /* #define DEBUG */ |
| 29 | |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 30 | #include <config.h> |
| 31 | #include <common.h> |
wdenk | c3f4d17 | 2004-06-25 23:35:58 +0000 | [diff] [blame] | 32 | #include <command.h> |
wdenk | 7aa7861 | 2003-05-03 15:50:43 +0000 | [diff] [blame] | 33 | #include <watchdog.h> |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 34 | #include <version.h> |
| 35 | #include <stdarg.h> |
| 36 | #include <lcdvideo.h> |
| 37 | #include <linux/types.h> |
| 38 | #include <devices.h> |
wdenk | 4532cb6 | 2003-04-27 22:52:51 +0000 | [diff] [blame] | 39 | #if defined(CONFIG_POST) |
| 40 | #include <post.h> |
| 41 | #endif |
wdenk | 682011f | 2003-06-03 23:54:09 +0000 | [diff] [blame] | 42 | #include <lcd.h> |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 43 | |
| 44 | #ifdef CONFIG_LCD |
| 45 | |
| 46 | /************************************************************************/ |
| 47 | /* ** CONFIG STUFF -- should be moved to board config file */ |
| 48 | /************************************************************************/ |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 49 | #define CONFIG_LCD_LOGO |
| 50 | #define LCD_INFO /* Display Logo, (C) and system info */ |
wdenk | 608c914 | 2003-01-13 23:54:46 +0000 | [diff] [blame] | 51 | |
wdenk | d791b1d | 2003-04-20 14:04:18 +0000 | [diff] [blame] | 52 | #if defined(CONFIG_V37) || defined(CONFIG_EDT32F10) |
wdenk | 608c914 | 2003-01-13 23:54:46 +0000 | [diff] [blame] | 53 | #undef CONFIG_LCD_LOGO |
| 54 | #undef LCD_INFO |
| 55 | #endif |
| 56 | |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 57 | /* #define LCD_TEST_PATTERN */ /* color backgnd for frame/color adjust */ |
| 58 | /* #define CFG_INVERT_COLORS */ /* Not needed - adjust vl_dp instead */ |
| 59 | /************************************************************************/ |
| 60 | |
| 61 | /************************************************************************/ |
wdenk | d791b1d | 2003-04-20 14:04:18 +0000 | [diff] [blame] | 62 | /* ** BITMAP DISPLAY SUPPORT -- should probably be moved elsewhere */ |
| 63 | /************************************************************************/ |
| 64 | |
wdenk | 27b207f | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 65 | #if (CONFIG_COMMANDS & CFG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN) |
wdenk | d791b1d | 2003-04-20 14:04:18 +0000 | [diff] [blame] | 66 | #include <bmp_layout.h> |
wdenk | 27b207f | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 67 | #endif /* (CONFIG_COMMANDS & CFG_CMD_BMP) || CONFIG_SPLASH_SCREEN */ |
wdenk | d791b1d | 2003-04-20 14:04:18 +0000 | [diff] [blame] | 68 | |
| 69 | /************************************************************************/ |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 70 | /* ** FONT AND LOGO DATA */ |
| 71 | /************************************************************************/ |
| 72 | |
| 73 | #include <video_font.h> /* Get font data, width and height */ |
| 74 | |
| 75 | #ifdef CONFIG_LCD_LOGO |
| 76 | # include <bmp_logo.h> /* Get logo data, width and height */ |
| 77 | #endif |
| 78 | |
| 79 | /************************************************************************/ |
| 80 | /************************************************************************/ |
| 81 | |
| 82 | /* |
| 83 | * Information about displays we are using. This is for configuring |
| 84 | * the LCD controller and memory allocation. Someone has to know what |
| 85 | * is connected, as we can't autodetect anything. |
| 86 | */ |
| 87 | #define CFG_HIGH 0 /* Pins are active high */ |
| 88 | #define CFG_LOW 1 /* Pins are active low */ |
| 89 | |
| 90 | typedef struct vidinfo { |
| 91 | ushort vl_col; /* Number of columns (i.e. 640) */ |
| 92 | ushort vl_row; /* Number of rows (i.e. 480) */ |
| 93 | ushort vl_width; /* Width of display area in millimeters */ |
| 94 | ushort vl_height; /* Height of display area in millimeters */ |
| 95 | |
| 96 | /* LCD configuration register. |
| 97 | */ |
| 98 | u_char vl_clkp; /* Clock polarity */ |
| 99 | u_char vl_oep; /* Output Enable polarity */ |
| 100 | u_char vl_hsp; /* Horizontal Sync polarity */ |
| 101 | u_char vl_vsp; /* Vertical Sync polarity */ |
| 102 | u_char vl_dp; /* Data polarity */ |
| 103 | u_char vl_bpix; /* Bits per pixel, 0 = 1, 1 = 2, 2 = 4, 3 = 8 */ |
| 104 | u_char vl_lbw; /* LCD Bus width, 0 = 4, 1 = 8 */ |
| 105 | u_char vl_splt; /* Split display, 0 = single-scan, 1 = dual-scan */ |
| 106 | u_char vl_clor; /* Color, 0 = mono, 1 = color */ |
| 107 | u_char vl_tft; /* 0 = passive, 1 = TFT */ |
| 108 | |
| 109 | /* Horizontal control register. Timing from data sheet. |
| 110 | */ |
| 111 | ushort vl_wbl; /* Wait between lines */ |
| 112 | |
| 113 | /* Vertical control register. |
| 114 | */ |
| 115 | u_char vl_vpw; /* Vertical sync pulse width */ |
| 116 | u_char vl_lcdac; /* LCD AC timing */ |
| 117 | u_char vl_wbf; /* Wait between frames */ |
| 118 | } vidinfo_t; |
| 119 | |
| 120 | #define LCD_MONOCHROME 0 |
| 121 | #define LCD_COLOR2 1 |
| 122 | #define LCD_COLOR4 2 |
| 123 | #define LCD_COLOR8 3 |
| 124 | |
| 125 | /*----------------------------------------------------------------------*/ |
| 126 | #ifdef CONFIG_KYOCERA_KCS057QV1AJ |
| 127 | /* |
| 128 | * Kyocera KCS057QV1AJ-G23. Passive, color, single scan. |
| 129 | */ |
| 130 | #define LCD_BPP LCD_COLOR4 |
| 131 | |
| 132 | static vidinfo_t panel_info = { |
| 133 | 640, 480, 132, 99, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH, |
| 134 | LCD_BPP, 1, 0, 1, 0, 5, 0, 0, 0 |
| 135 | /* wbl, vpw, lcdac, wbf */ |
| 136 | }; |
| 137 | #endif /* CONFIG_KYOCERA_KCS057QV1AJ */ |
| 138 | /*----------------------------------------------------------------------*/ |
| 139 | |
| 140 | /*----------------------------------------------------------------------*/ |
wdenk | 682011f | 2003-06-03 23:54:09 +0000 | [diff] [blame] | 141 | #ifdef CONFIG_HITACHI_SP19X001_Z1A |
| 142 | /* |
| 143 | * Hitachi SP19X001-. Active, color, single scan. |
| 144 | */ |
| 145 | static vidinfo_t panel_info = { |
| 146 | 640, 480, 154, 116, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH, |
| 147 | LCD_COLOR8, 1, 0, 1, 0, 0, 0, 0, 0 |
| 148 | /* wbl, vpw, lcdac, wbf */ |
| 149 | }; |
| 150 | #endif /* CONFIG_HITACHI_SP19X001_Z1A */ |
| 151 | /*----------------------------------------------------------------------*/ |
| 152 | |
| 153 | /*----------------------------------------------------------------------*/ |
wdenk | fd3103b | 2003-11-25 16:55:19 +0000 | [diff] [blame] | 154 | #ifdef CONFIG_NEC_NL6448AC33 |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 155 | /* |
wdenk | fd3103b | 2003-11-25 16:55:19 +0000 | [diff] [blame] | 156 | * NEC NL6448AC33-18. Active, color, single scan. |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 157 | */ |
| 158 | static vidinfo_t panel_info = { |
| 159 | 640, 480, 132, 99, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_HIGH, |
| 160 | 3, 0, 0, 1, 1, 144, 2, 0, 33 |
| 161 | /* wbl, vpw, lcdac, wbf */ |
| 162 | }; |
wdenk | fd3103b | 2003-11-25 16:55:19 +0000 | [diff] [blame] | 163 | #endif /* CONFIG_NEC_NL6448AC33 */ |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 164 | /*----------------------------------------------------------------------*/ |
| 165 | |
wdenk | fd3103b | 2003-11-25 16:55:19 +0000 | [diff] [blame] | 166 | #ifdef CONFIG_NEC_NL6448BC20 |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 167 | /* |
wdenk | fd3103b | 2003-11-25 16:55:19 +0000 | [diff] [blame] | 168 | * NEC NL6448BC20-08. 6.5", 640x480. Active, color, single scan. |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 169 | */ |
| 170 | static vidinfo_t panel_info = { |
| 171 | 640, 480, 132, 99, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_HIGH, |
| 172 | 3, 0, 0, 1, 1, 144, 2, 0, 33 |
| 173 | /* wbl, vpw, lcdac, wbf */ |
| 174 | }; |
wdenk | fd3103b | 2003-11-25 16:55:19 +0000 | [diff] [blame] | 175 | #endif /* CONFIG_NEC_NL6448BC20 */ |
| 176 | /*----------------------------------------------------------------------*/ |
| 177 | |
| 178 | #ifdef CONFIG_NEC_NL6448BC33_54 |
| 179 | /* |
| 180 | * NEC NL6448BC33-54. 10.4", 640x480. Active, color, single scan. |
| 181 | */ |
| 182 | static vidinfo_t panel_info = { |
| 183 | 640, 480, 212, 158, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_HIGH, |
| 184 | 3, 0, 0, 1, 1, 144, 2, 0, 33 |
| 185 | /* wbl, vpw, lcdac, wbf */ |
| 186 | }; |
| 187 | #endif /* CONFIG_NEC_NL6448BC33_54 */ |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 188 | /*----------------------------------------------------------------------*/ |
| 189 | |
| 190 | #ifdef CONFIG_SHARP_LQ104V7DS01 |
| 191 | /* |
| 192 | * SHARP LQ104V7DS01. 6.5", 640x480. Active, color, single scan. |
| 193 | */ |
| 194 | static vidinfo_t panel_info = { |
| 195 | 640, 480, 132, 99, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_LOW, |
| 196 | 3, 0, 0, 1, 1, 25, 1, 0, 33 |
| 197 | /* wbl, vpw, lcdac, wbf */ |
| 198 | }; |
| 199 | #endif /* CONFIG_SHARP_LQ104V7DS01 */ |
| 200 | /*----------------------------------------------------------------------*/ |
| 201 | |
| 202 | #ifdef CONFIG_SHARP_16x9 |
| 203 | /* |
| 204 | * Sharp 320x240. Active, color, single scan. It isn't 16x9, and I am |
| 205 | * not sure what it is....... |
| 206 | */ |
| 207 | static vidinfo_t panel_info = { |
| 208 | 320, 240, 0, 0, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH, |
| 209 | 3, 0, 0, 1, 1, 15, 4, 0, 3 |
| 210 | }; |
| 211 | #endif /* CONFIG_SHARP_16x9 */ |
| 212 | /*----------------------------------------------------------------------*/ |
| 213 | |
| 214 | #ifdef CONFIG_SHARP_LQ057Q3DC02 |
| 215 | /* |
| 216 | * Sharp LQ057Q3DC02 display. Active, color, single scan. |
| 217 | */ |
wdenk | 4a6fd34 | 2003-04-12 23:38:12 +0000 | [diff] [blame] | 218 | #define LCD_DF 12 |
| 219 | |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 220 | static vidinfo_t panel_info = { |
| 221 | 320, 240, 0, 0, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_HIGH, |
| 222 | 3, 0, 0, 1, 1, 15, 4, 0, 3 |
| 223 | /* wbl, vpw, lcdac, wbf */ |
| 224 | }; |
| 225 | #define LCD_INFO_BELOW_LOGO |
| 226 | #endif /* CONFIG_SHARP_LQ057Q3DC02 */ |
| 227 | /*----------------------------------------------------------------------*/ |
| 228 | |
| 229 | #ifdef CONFIG_SHARP_LQ64D341 |
| 230 | /* |
| 231 | * Sharp LQ64D341 display, 640x480. Active, color, single scan. |
| 232 | */ |
| 233 | static vidinfo_t panel_info = { |
| 234 | 640, 480, 0, 0, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_HIGH, |
| 235 | 3, 0, 0, 1, 1, 128, 16, 0, 32 |
| 236 | /* wbl, vpw, lcdac, wbf */ |
| 237 | }; |
| 238 | #endif /* CONFIG_SHARP_LQ64D341 */ |
wdenk | 608c914 | 2003-01-13 23:54:46 +0000 | [diff] [blame] | 239 | |
dzu | 29127b6 | 2003-09-25 22:30:12 +0000 | [diff] [blame] | 240 | #ifdef CONFIG_SHARP_LQ065T9DR51U |
| 241 | /* |
| 242 | * Sharp LQ065T9DR51U display, 400x240. Active, color, single scan. |
| 243 | */ |
| 244 | static vidinfo_t panel_info = { |
| 245 | 400, 240, 143, 79, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH, |
| 246 | 3, 0, 0, 1, 1, 248, 4, 0, 35 |
| 247 | /* wbl, vpw, lcdac, wbf */ |
| 248 | }; |
| 249 | #define LCD_INFO_BELOW_LOGO |
| 250 | #endif /* CONFIG_SHARP_LQ065T9DR51U */ |
| 251 | |
wdenk | 608c914 | 2003-01-13 23:54:46 +0000 | [diff] [blame] | 252 | #ifdef CONFIG_SHARP_LQ084V1DG21 |
| 253 | /* |
| 254 | * Sharp LQ084V1DG21 display, 640x480. Active, color, single scan. |
| 255 | */ |
| 256 | static vidinfo_t panel_info = { |
| 257 | 640, 480, 171, 129, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_LOW, |
| 258 | 3, 0, 0, 1, 1, 160, 3, 0, 48 |
| 259 | /* wbl, vpw, lcdac, wbf */ |
| 260 | }; |
| 261 | #endif /* CONFIG_SHARP_LQ084V1DG21 */ |
| 262 | |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 263 | /*----------------------------------------------------------------------*/ |
| 264 | |
| 265 | #ifdef CONFIG_HLD1045 |
| 266 | /* |
| 267 | * HLD1045 display, 640x480. Active, color, single scan. |
| 268 | */ |
| 269 | static vidinfo_t panel_info = { |
| 270 | 640, 480, 0, 0, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_HIGH, |
| 271 | 3, 0, 0, 1, 1, 160, 3, 0, 48 |
| 272 | /* wbl, vpw, lcdac, wbf */ |
| 273 | }; |
| 274 | #endif /* CONFIG_HLD1045 */ |
| 275 | /*----------------------------------------------------------------------*/ |
| 276 | |
| 277 | #ifdef CONFIG_PRIMEVIEW_V16C6448AC |
| 278 | /* |
| 279 | * Prime View V16C6448AC |
| 280 | */ |
| 281 | static vidinfo_t panel_info = { |
| 282 | 640, 480, 130, 98, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_HIGH, |
| 283 | 3, 0, 0, 1, 1, 144, 2, 0, 35 |
| 284 | /* wbl, vpw, lcdac, wbf */ |
| 285 | }; |
| 286 | #endif /* CONFIG_PRIMEVIEW_V16C6448AC */ |
| 287 | |
| 288 | /*----------------------------------------------------------------------*/ |
| 289 | |
| 290 | #ifdef CONFIG_OPTREX_BW |
| 291 | /* |
| 292 | * Optrex CBL50840-2 NF-FW 99 22 M5 |
| 293 | * or |
| 294 | * Hitachi LMG6912RPFC-00T |
| 295 | * or |
| 296 | * Hitachi SP14Q002 |
| 297 | * |
| 298 | * 320x240. Black & white. |
| 299 | */ |
| 300 | #define OPTREX_BPP 0 /* 0 - monochrome, 1 bpp */ |
| 301 | /* 1 - 4 grey levels, 2 bpp */ |
| 302 | /* 2 - 16 grey levels, 4 bpp */ |
| 303 | static vidinfo_t panel_info = { |
| 304 | 320, 240, 0, 0, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_LOW, |
| 305 | OPTREX_BPP, 0, 0, 0, 0, 0, 0, 0, 0, 4 |
| 306 | }; |
| 307 | #endif /* CONFIG_OPTREX_BW */ |
| 308 | |
| 309 | /*-----------------------------------------------------------------*/ |
| 310 | #ifdef CONFIG_EDT32F10 |
| 311 | /* |
| 312 | * Emerging Display Technologies 320x240. Passive, monochrome, single scan. |
| 313 | */ |
| 314 | #define LCD_BPP LCD_MONOCHROME |
wdenk | 4a6fd34 | 2003-04-12 23:38:12 +0000 | [diff] [blame] | 315 | #define LCD_DF 10 |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 316 | |
| 317 | static vidinfo_t panel_info = { |
| 318 | 320, 240, 0, 0, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_LOW, |
wdenk | 4a6fd34 | 2003-04-12 23:38:12 +0000 | [diff] [blame] | 319 | LCD_BPP, 0, 0, 0, 0, 33, 0, 0, 0 |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 320 | }; |
| 321 | #endif |
| 322 | /*----------------------------------------------------------------------*/ |
| 323 | |
| 324 | #if defined(LCD_INFO_BELOW_LOGO) |
| 325 | # define LCD_INFO_X 0 |
| 326 | # define LCD_INFO_Y (BMP_LOGO_HEIGHT + VIDEO_FONT_HEIGHT) |
| 327 | #elif defined(CONFIG_LCD_LOGO) |
| 328 | # define LCD_INFO_X (BMP_LOGO_WIDTH + 4 * VIDEO_FONT_WIDTH) |
| 329 | # define LCD_INFO_Y (VIDEO_FONT_HEIGHT) |
| 330 | #else |
| 331 | # define LCD_INFO_X (VIDEO_FONT_WIDTH) |
| 332 | # define LCD_INFO_Y (VIDEO_FONT_HEIGHT) |
| 333 | #endif |
| 334 | |
| 335 | #ifndef LCD_BPP |
| 336 | #define LCD_BPP LCD_COLOR8 |
| 337 | #endif |
| 338 | #ifndef LCD_DF |
| 339 | #define LCD_DF 1 |
| 340 | #endif |
| 341 | |
| 342 | #define NBITS(bit_code) (1 << (bit_code)) |
| 343 | #define NCOLORS(bit_code) (1 << NBITS(bit_code)) |
| 344 | |
| 345 | static int lcd_line_length; |
| 346 | |
| 347 | static int lcd_color_fg; |
| 348 | static int lcd_color_bg; |
| 349 | |
wdenk | 682011f | 2003-06-03 23:54:09 +0000 | [diff] [blame] | 350 | char lcd_is_enabled = 0; /* Indicate that LCD is enabled */ |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 351 | |
| 352 | /* |
| 353 | * Frame buffer memory information |
| 354 | */ |
| 355 | static void *lcd_base; /* Start of framebuffer memory */ |
| 356 | static void *lcd_console_address; /* Start of console buffer */ |
| 357 | |
| 358 | |
| 359 | /************************************************************************/ |
| 360 | /* ** CONSOLE CONSTANTS */ |
| 361 | /************************************************************************/ |
| 362 | |
| 363 | #if LCD_BPP == LCD_MONOCHROME |
| 364 | |
| 365 | /* |
| 366 | * Simple color definitions |
| 367 | */ |
| 368 | #define CONSOLE_COLOR_BLACK 0 |
| 369 | #define CONSOLE_COLOR_WHITE 1 /* Must remain last / highest */ |
| 370 | |
| 371 | #else |
| 372 | |
| 373 | /* |
| 374 | * Simple color definitions |
| 375 | */ |
| 376 | #define CONSOLE_COLOR_BLACK 0 |
| 377 | #define CONSOLE_COLOR_RED 1 |
| 378 | #define CONSOLE_COLOR_GREEN 2 |
| 379 | #define CONSOLE_COLOR_YELLOW 3 |
| 380 | #define CONSOLE_COLOR_BLUE 4 |
| 381 | #define CONSOLE_COLOR_MAGENTA 5 |
| 382 | #define CONSOLE_COLOR_CYAN 6 |
| 383 | #define CONSOLE_COLOR_GREY 14 |
| 384 | #define CONSOLE_COLOR_WHITE 15 /* Must remain last / highest */ |
| 385 | |
| 386 | #endif |
| 387 | |
| 388 | #if defined(CONFIG_LCD_LOGO) && (CONSOLE_COLOR_WHITE >= BMP_LOGO_OFFSET) |
| 389 | #error Default Color Map overlaps with Logo Color Map |
| 390 | #endif |
| 391 | |
| 392 | /************************************************************************/ |
| 393 | |
| 394 | #ifndef PAGE_SIZE |
| 395 | #define PAGE_SIZE 4096 |
| 396 | #endif |
| 397 | |
| 398 | |
| 399 | /************************************************************************/ |
| 400 | /* ** CONSOLE DEFINITIONS & FUNCTIONS */ |
| 401 | /************************************************************************/ |
| 402 | |
| 403 | #if defined(CONFIG_LCD_LOGO) && !defined(LCD_INFO_BELOW_LOGO) |
| 404 | #define CONSOLE_ROWS ((panel_info.vl_row-BMP_LOGO_HEIGHT) \ |
| 405 | / VIDEO_FONT_HEIGHT) |
| 406 | #else |
| 407 | #define CONSOLE_ROWS (panel_info.vl_row / VIDEO_FONT_HEIGHT) |
| 408 | #endif |
| 409 | #define CONSOLE_COLS (panel_info.vl_col / VIDEO_FONT_WIDTH) |
| 410 | #define CONSOLE_ROW_SIZE (VIDEO_FONT_HEIGHT * lcd_line_length) |
| 411 | #define CONSOLE_ROW_FIRST (lcd_console_address) |
| 412 | #define CONSOLE_ROW_SECOND (lcd_console_address + CONSOLE_ROW_SIZE) |
| 413 | #define CONSOLE_ROW_LAST (lcd_console_address + CONSOLE_SIZE \ |
| 414 | - CONSOLE_ROW_SIZE) |
| 415 | #define CONSOLE_SIZE (CONSOLE_ROW_SIZE * CONSOLE_ROWS) |
| 416 | #define CONSOLE_SCROLL_SIZE (CONSOLE_SIZE - CONSOLE_ROW_SIZE) |
| 417 | |
| 418 | #if LCD_BPP == LCD_MONOCHROME |
| 419 | #define COLOR_MASK(c) ((c) | (c) << 1 | (c) << 2 | (c) << 3 | \ |
| 420 | (c) << 4 | (c) << 5 | (c) << 6 | (c) << 7) |
| 421 | #elif LCD_BPP == LCD_COLOR8 |
| 422 | #define COLOR_MASK(c) (c) |
| 423 | #else |
| 424 | #error Unsupported LCD BPP. |
| 425 | #endif |
| 426 | |
| 427 | static short console_col; |
| 428 | static short console_row; |
| 429 | |
| 430 | /************************************************************************/ |
| 431 | |
| 432 | ulong lcd_setmem (ulong addr); |
| 433 | |
| 434 | static void lcd_drawchars (ushort x, ushort y, uchar *str, int count); |
| 435 | static inline void lcd_puts_xy (ushort x, ushort y, uchar *s); |
| 436 | static inline void lcd_putc_xy (ushort x, ushort y, uchar c); |
| 437 | |
wdenk | c3f4d17 | 2004-06-25 23:35:58 +0000 | [diff] [blame] | 438 | static int lcd_init (void *lcdbase); |
wdenk | 682011f | 2003-06-03 23:54:09 +0000 | [diff] [blame] | 439 | |
wdenk | c3f4d17 | 2004-06-25 23:35:58 +0000 | [diff] [blame] | 440 | static int lcd_clear (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]); |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 441 | static void lcd_ctrl_init (void *lcdbase); |
| 442 | static void lcd_enable (void); |
| 443 | static void *lcd_logo (void); |
| 444 | #if LCD_BPP == LCD_COLOR8 |
| 445 | static void lcd_setcolreg (ushort regno, |
| 446 | ushort red, ushort green, ushort blue); |
| 447 | #endif |
| 448 | #if LCD_BPP == LCD_MONOCHROME |
| 449 | static void lcd_initcolregs (void); |
| 450 | #endif |
| 451 | static int lcd_getbgcolor (void); |
| 452 | static void lcd_setfgcolor (int color); |
| 453 | static void lcd_setbgcolor (int color); |
| 454 | |
wdenk | 682011f | 2003-06-03 23:54:09 +0000 | [diff] [blame] | 455 | #if defined(CONFIG_RBC823) |
| 456 | void lcd_disable (void); |
| 457 | #endif |
| 458 | |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 459 | #ifdef NOT_USED_SO_FAR |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 460 | static void lcd_getcolreg (ushort regno, |
| 461 | ushort *red, ushort *green, ushort *blue); |
| 462 | static int lcd_getfgcolor (void); |
| 463 | #endif /* NOT_USED_SO_FAR */ |
| 464 | |
| 465 | /************************************************************************/ |
| 466 | |
| 467 | /*----------------------------------------------------------------------*/ |
| 468 | |
| 469 | static void console_scrollup (void) |
| 470 | { |
| 471 | #if 1 |
| 472 | /* Copy up rows ignoring the first one */ |
| 473 | memcpy (CONSOLE_ROW_FIRST, CONSOLE_ROW_SECOND, CONSOLE_SCROLL_SIZE); |
| 474 | |
| 475 | /* Clear the last one */ |
| 476 | memset (CONSOLE_ROW_LAST, COLOR_MASK(lcd_color_bg), CONSOLE_ROW_SIZE); |
| 477 | #else |
| 478 | /* |
| 479 | * Poor attempt to optimize speed by moving "long"s. |
| 480 | * But the code is ugly, and not a bit faster :-( |
| 481 | */ |
| 482 | ulong *t = (ulong *)CONSOLE_ROW_FIRST; |
| 483 | ulong *s = (ulong *)CONSOLE_ROW_SECOND; |
| 484 | ulong l = CONSOLE_SCROLL_SIZE / sizeof(ulong); |
| 485 | uchar c = lcd_color_bg & 0xFF; |
| 486 | ulong val= (c<<24) | (c<<16) | (c<<8) | c; |
| 487 | |
| 488 | while (l--) |
| 489 | *t++ = *s++; |
| 490 | |
| 491 | t = (ulong *)CONSOLE_ROW_LAST; |
| 492 | l = CONSOLE_ROW_SIZE / sizeof(ulong); |
| 493 | |
| 494 | while (l-- > 0) |
| 495 | *t++ = val; |
| 496 | #endif |
| 497 | } |
| 498 | |
| 499 | /*----------------------------------------------------------------------*/ |
| 500 | |
| 501 | static inline void console_back (void) |
| 502 | { |
| 503 | if (--console_col < 0) { |
| 504 | console_col = CONSOLE_COLS-1 ; |
| 505 | if (--console_row < 0) { |
| 506 | console_row = 0; |
| 507 | } |
| 508 | } |
| 509 | |
| 510 | lcd_putc_xy (console_col * VIDEO_FONT_WIDTH, |
| 511 | console_row * VIDEO_FONT_HEIGHT, |
| 512 | ' '); |
| 513 | } |
| 514 | |
| 515 | /*----------------------------------------------------------------------*/ |
| 516 | |
| 517 | static inline void console_newline (void) |
| 518 | { |
| 519 | ++console_row; |
| 520 | console_col = 0; |
| 521 | |
| 522 | /* Check if we need to scroll the terminal */ |
| 523 | if (console_row >= CONSOLE_ROWS) { |
| 524 | /* Scroll everything up */ |
| 525 | console_scrollup () ; |
| 526 | --console_row; |
| 527 | } |
| 528 | } |
| 529 | |
| 530 | /*----------------------------------------------------------------------*/ |
| 531 | |
| 532 | void lcd_putc (const char c) |
| 533 | { |
| 534 | if (!lcd_is_enabled) { |
| 535 | serial_putc(c); |
| 536 | return; |
| 537 | } |
| 538 | |
| 539 | switch (c) { |
| 540 | case '\r': console_col = 0; |
| 541 | return; |
| 542 | |
| 543 | case '\n': console_newline(); |
| 544 | return; |
| 545 | |
| 546 | case '\t': /* Tab (8 chars alignment) */ |
| 547 | console_col |= 8; |
| 548 | console_col &= ~7; |
| 549 | |
| 550 | if (console_col >= CONSOLE_COLS) { |
| 551 | console_newline(); |
| 552 | } |
| 553 | return; |
| 554 | |
| 555 | case '\b': console_back(); |
| 556 | return; |
| 557 | |
| 558 | default: lcd_putc_xy (console_col * VIDEO_FONT_WIDTH, |
| 559 | console_row * VIDEO_FONT_HEIGHT, |
| 560 | c); |
| 561 | if (++console_col >= CONSOLE_COLS) { |
| 562 | console_newline(); |
| 563 | } |
| 564 | return; |
| 565 | } |
| 566 | /* NOTREACHED */ |
| 567 | } |
| 568 | |
| 569 | /*----------------------------------------------------------------------*/ |
| 570 | |
| 571 | void lcd_puts (const char *s) |
| 572 | { |
| 573 | if (!lcd_is_enabled) { |
| 574 | serial_puts (s); |
| 575 | return; |
| 576 | } |
| 577 | |
| 578 | while (*s) { |
| 579 | lcd_putc (*s++); |
| 580 | } |
| 581 | } |
| 582 | |
| 583 | /************************************************************************/ |
| 584 | /* ** Low-Level Graphics Routines */ |
| 585 | /************************************************************************/ |
| 586 | |
| 587 | static void lcd_drawchars (ushort x, ushort y, uchar *str, int count) |
| 588 | { |
| 589 | uchar *dest; |
| 590 | ushort off, row; |
| 591 | |
| 592 | dest = (uchar *)(lcd_base + y * lcd_line_length + x * (1 << LCD_BPP) / 8); |
| 593 | off = x * (1 << LCD_BPP) % 8; |
| 594 | |
| 595 | for (row=0; row < VIDEO_FONT_HEIGHT; ++row, dest += lcd_line_length) { |
| 596 | uchar *s = str; |
| 597 | uchar *d = dest; |
| 598 | int i; |
| 599 | |
| 600 | #if LCD_BPP == LCD_MONOCHROME |
| 601 | uchar rest = *d & -(1 << (8-off)); |
| 602 | uchar sym; |
| 603 | #endif |
| 604 | for (i=0; i<count; ++i) { |
| 605 | uchar c, bits; |
| 606 | |
| 607 | c = *s++; |
| 608 | bits = video_fontdata[c * VIDEO_FONT_HEIGHT + row]; |
| 609 | |
| 610 | #if LCD_BPP == LCD_MONOCHROME |
| 611 | sym = (COLOR_MASK(lcd_color_fg) & bits) | |
| 612 | (COLOR_MASK(lcd_color_bg) & ~bits); |
| 613 | |
| 614 | *d++ = rest | (sym >> off); |
| 615 | rest = sym << (8-off); |
| 616 | #elif LCD_BPP == LCD_COLOR8 |
| 617 | for (c=0; c<8; ++c) { |
| 618 | *d++ = (bits & 0x80) ? |
| 619 | lcd_color_fg : lcd_color_bg; |
| 620 | bits <<= 1; |
| 621 | } |
| 622 | #endif |
| 623 | } |
| 624 | |
| 625 | #if LCD_BPP == LCD_MONOCHROME |
| 626 | *d = rest | (*d & ((1 << (8-off)) - 1)); |
| 627 | #endif |
| 628 | } |
| 629 | } |
| 630 | |
| 631 | /*----------------------------------------------------------------------*/ |
| 632 | |
| 633 | static inline void lcd_puts_xy (ushort x, ushort y, uchar *s) |
| 634 | { |
| 635 | #if defined(CONFIG_LCD_LOGO) && !defined(LCD_INFO_BELOW_LOGO) |
| 636 | lcd_drawchars (x, y+BMP_LOGO_HEIGHT, s, strlen (s)); |
| 637 | #else |
| 638 | lcd_drawchars (x, y, s, strlen (s)); |
| 639 | #endif |
| 640 | } |
| 641 | |
| 642 | /*----------------------------------------------------------------------*/ |
| 643 | |
| 644 | static inline void lcd_putc_xy (ushort x, ushort y, uchar c) |
| 645 | { |
| 646 | #if defined(CONFIG_LCD_LOGO) && !defined(LCD_INFO_BELOW_LOGO) |
| 647 | lcd_drawchars (x, y+BMP_LOGO_HEIGHT, &c, 1); |
| 648 | #else |
| 649 | lcd_drawchars (x, y, &c, 1); |
| 650 | #endif |
| 651 | } |
| 652 | |
| 653 | /************************************************************************/ |
| 654 | /** Small utility to check that you got the colours right */ |
| 655 | /************************************************************************/ |
| 656 | #ifdef LCD_TEST_PATTERN |
| 657 | |
| 658 | #define N_BLK_VERT 2 |
| 659 | #define N_BLK_HOR 3 |
| 660 | |
| 661 | static int test_colors[N_BLK_HOR*N_BLK_VERT] = { |
| 662 | CONSOLE_COLOR_RED, CONSOLE_COLOR_GREEN, CONSOLE_COLOR_YELLOW, |
| 663 | CONSOLE_COLOR_BLUE, CONSOLE_COLOR_MAGENTA, CONSOLE_COLOR_CYAN, |
| 664 | }; |
| 665 | |
| 666 | static void test_pattern (void) |
| 667 | { |
| 668 | ushort v_max = panel_info.vl_row; |
| 669 | ushort h_max = panel_info.vl_col; |
| 670 | ushort v_step = (v_max + N_BLK_VERT - 1) / N_BLK_VERT; |
| 671 | ushort h_step = (h_max + N_BLK_HOR - 1) / N_BLK_HOR; |
| 672 | ushort v, h; |
| 673 | uchar *pix = (uchar *)lcd_base; |
| 674 | |
| 675 | printf ("[LCD] Test Pattern: %d x %d [%d x %d]\n", |
| 676 | h_max, v_max, h_step, v_step); |
| 677 | |
| 678 | /* WARNING: Code silently assumes 8bit/pixel */ |
| 679 | for (v=0; v<v_max; ++v) { |
| 680 | uchar iy = v / v_step; |
| 681 | for (h=0; h<h_max; ++h) { |
| 682 | uchar ix = N_BLK_HOR * iy + (h/h_step); |
| 683 | *pix++ = test_colors[ix]; |
| 684 | } |
| 685 | } |
| 686 | } |
| 687 | #endif /* LCD_TEST_PATTERN */ |
| 688 | |
| 689 | |
| 690 | /************************************************************************/ |
| 691 | /* ** GENERIC Initialization Routines */ |
| 692 | /************************************************************************/ |
| 693 | |
| 694 | int drv_lcd_init (void) |
| 695 | { |
| 696 | DECLARE_GLOBAL_DATA_PTR; |
| 697 | |
| 698 | device_t lcddev; |
| 699 | int rc; |
| 700 | |
| 701 | lcd_base = (void *)(gd->fb_base); |
| 702 | |
| 703 | lcd_line_length = (panel_info.vl_col * NBITS (panel_info.vl_bpix)) / 8; |
| 704 | |
| 705 | lcd_init (lcd_base); /* LCD initialization */ |
| 706 | |
| 707 | /* Device initialization */ |
| 708 | memset (&lcddev, 0, sizeof (lcddev)); |
| 709 | |
| 710 | strcpy (lcddev.name, "lcd"); |
| 711 | lcddev.ext = 0; /* No extensions */ |
| 712 | lcddev.flags = DEV_FLAGS_OUTPUT; /* Output only */ |
| 713 | lcddev.putc = lcd_putc; /* 'putc' function */ |
| 714 | lcddev.puts = lcd_puts; /* 'puts' function */ |
| 715 | |
| 716 | rc = device_register (&lcddev); |
| 717 | |
| 718 | return (rc == 0) ? 1 : rc; |
| 719 | } |
| 720 | |
| 721 | /*----------------------------------------------------------------------*/ |
| 722 | |
wdenk | c3f4d17 | 2004-06-25 23:35:58 +0000 | [diff] [blame] | 723 | static int lcd_clear (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 724 | { |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 725 | #if LCD_BPP == LCD_MONOCHROME |
| 726 | /* Setting the palette */ |
| 727 | lcd_initcolregs(); |
| 728 | |
| 729 | #elif LCD_BPP == LCD_COLOR8 |
| 730 | /* Setting the palette */ |
| 731 | lcd_setcolreg (CONSOLE_COLOR_BLACK, 0, 0, 0); |
| 732 | lcd_setcolreg (CONSOLE_COLOR_RED, 0xFF, 0, 0); |
| 733 | lcd_setcolreg (CONSOLE_COLOR_GREEN, 0, 0xFF, 0); |
| 734 | lcd_setcolreg (CONSOLE_COLOR_YELLOW, 0xFF, 0xFF, 0); |
| 735 | lcd_setcolreg (CONSOLE_COLOR_BLUE, 0, 0, 0xFF); |
| 736 | lcd_setcolreg (CONSOLE_COLOR_MAGENTA, 0xFF, 0, 0xFF); |
| 737 | lcd_setcolreg (CONSOLE_COLOR_CYAN, 0, 0xFF, 0xFF); |
| 738 | lcd_setcolreg (CONSOLE_COLOR_GREY, 0xAA, 0xAA, 0xAA); |
| 739 | lcd_setcolreg (CONSOLE_COLOR_WHITE, 0xFF, 0xFF, 0xFF); |
| 740 | #endif |
| 741 | |
| 742 | #ifndef CFG_WHITE_ON_BLACK |
| 743 | lcd_setfgcolor (CONSOLE_COLOR_BLACK); |
| 744 | lcd_setbgcolor (CONSOLE_COLOR_WHITE); |
| 745 | #else |
| 746 | lcd_setfgcolor (CONSOLE_COLOR_WHITE); |
| 747 | lcd_setbgcolor (CONSOLE_COLOR_BLACK); |
| 748 | #endif /* CFG_WHITE_ON_BLACK */ |
| 749 | |
| 750 | #ifdef LCD_TEST_PATTERN |
| 751 | test_pattern(); |
| 752 | #else |
| 753 | /* set framebuffer to background color */ |
| 754 | memset ((char *)lcd_base, |
| 755 | COLOR_MASK(lcd_getbgcolor()), |
| 756 | lcd_line_length*panel_info.vl_row); |
| 757 | #endif |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 758 | /* Paint the logo and retrieve LCD base address */ |
| 759 | debug ("[LCD] Drawing the logo...\n"); |
| 760 | lcd_console_address = lcd_logo (); |
| 761 | |
wdenk | c3f4d17 | 2004-06-25 23:35:58 +0000 | [diff] [blame] | 762 | console_col = 0; |
| 763 | console_row = 0; |
| 764 | |
| 765 | return (0); |
| 766 | } |
| 767 | |
| 768 | U_BOOT_CMD( |
| 769 | cls, 1, 1, lcd_clear, |
| 770 | "cls - clear screen\n", |
| 771 | NULL |
| 772 | ); |
| 773 | |
| 774 | /*----------------------------------------------------------------------*/ |
| 775 | |
| 776 | static int lcd_init (void *lcdbase) |
| 777 | { |
| 778 | /* Initialize the lcd controller */ |
| 779 | debug ("[LCD] Initializing LCD frambuffer at %p\n", lcdbase); |
| 780 | |
| 781 | lcd_ctrl_init (lcdbase); |
| 782 | lcd_clear (NULL, 1, 1, NULL); /* dummy args */ |
| 783 | lcd_enable (); |
| 784 | |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 785 | /* Initialize the console */ |
| 786 | console_col = 0; |
| 787 | #ifdef LCD_INFO_BELOW_LOGO |
| 788 | console_row = 7 + BMP_LOGO_HEIGHT / VIDEO_FONT_HEIGHT; |
| 789 | #else |
| 790 | console_row = 1; /* leave 1 blank line below logo */ |
| 791 | #endif |
| 792 | lcd_is_enabled = 1; |
| 793 | |
| 794 | return 0; |
| 795 | } |
| 796 | |
| 797 | |
| 798 | /************************************************************************/ |
| 799 | /* ** ROM capable initialization part - needed to reserve FB memory */ |
| 800 | /************************************************************************/ |
| 801 | |
| 802 | /* |
| 803 | * This is called early in the system initialization to grab memory |
| 804 | * for the LCD controller. |
| 805 | * Returns new address for monitor, after reserving LCD buffer memory |
| 806 | * |
| 807 | * Note that this is running from ROM, so no write access to global data. |
| 808 | */ |
| 809 | ulong lcd_setmem (ulong addr) |
| 810 | { |
| 811 | ulong size; |
| 812 | int line_length = (panel_info.vl_col * NBITS (panel_info.vl_bpix)) / 8; |
| 813 | |
| 814 | debug ("LCD panel info: %d x %d, %d bit/pix\n", |
| 815 | panel_info.vl_col, panel_info.vl_row, NBITS (panel_info.vl_bpix) ); |
| 816 | |
| 817 | size = line_length * panel_info.vl_row; |
| 818 | |
| 819 | /* Round up to nearest full page */ |
| 820 | size = (size + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1); |
| 821 | |
| 822 | /* Allocate pages for the frame buffer. */ |
| 823 | addr -= size; |
| 824 | |
| 825 | debug ("Reserving %ldk for LCD Framebuffer at: %08lx\n", size>>10, addr); |
| 826 | |
| 827 | return (addr); |
| 828 | } |
| 829 | |
| 830 | |
| 831 | /************************************************************************/ |
| 832 | /* ----------------- chipset specific functions ----------------------- */ |
| 833 | /************************************************************************/ |
| 834 | |
| 835 | static void lcd_ctrl_init (void *lcdbase) |
| 836 | { |
| 837 | volatile immap_t *immr = (immap_t *) CFG_IMMR; |
| 838 | volatile lcd823_t *lcdp = &immr->im_lcd; |
| 839 | |
| 840 | uint lccrtmp; |
wdenk | 682011f | 2003-06-03 23:54:09 +0000 | [diff] [blame] | 841 | uint lchcr_hpc_tmp; |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 842 | |
| 843 | /* Initialize the LCD control register according to the LCD |
| 844 | * parameters defined. We do everything here but enable |
| 845 | * the controller. |
| 846 | */ |
| 847 | |
wdenk | e63c8ee | 2004-06-09 21:04:48 +0000 | [diff] [blame] | 848 | #ifdef CONFIG_RPXLITE |
| 849 | /* This is special for RPXlite_DW Software Development Platform **[Sam]** */ |
| 850 | panel_info.vl_dp = CFG_LOW; |
| 851 | #endif |
| 852 | |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 853 | lccrtmp = LCDBIT (LCCR_BNUM_BIT, |
| 854 | (((panel_info.vl_row * panel_info.vl_col) * (1 << LCD_BPP)) / 128)); |
| 855 | |
| 856 | lccrtmp |= LCDBIT (LCCR_CLKP_BIT, panel_info.vl_clkp) | |
| 857 | LCDBIT (LCCR_OEP_BIT, panel_info.vl_oep) | |
| 858 | LCDBIT (LCCR_HSP_BIT, panel_info.vl_hsp) | |
| 859 | LCDBIT (LCCR_VSP_BIT, panel_info.vl_vsp) | |
| 860 | LCDBIT (LCCR_DP_BIT, panel_info.vl_dp) | |
| 861 | LCDBIT (LCCR_BPIX_BIT, panel_info.vl_bpix) | |
| 862 | LCDBIT (LCCR_LBW_BIT, panel_info.vl_lbw) | |
| 863 | LCDBIT (LCCR_SPLT_BIT, panel_info.vl_splt) | |
| 864 | LCDBIT (LCCR_CLOR_BIT, panel_info.vl_clor) | |
| 865 | LCDBIT (LCCR_TFT_BIT, panel_info.vl_tft); |
| 866 | |
| 867 | #if 0 |
| 868 | lccrtmp |= ((SIU_LEVEL5 / 2) << 12); |
| 869 | lccrtmp |= LCCR_EIEN; |
| 870 | #endif |
| 871 | |
| 872 | lcdp->lcd_lccr = lccrtmp; |
| 873 | lcdp->lcd_lcsr = 0xFF; /* Clear pending interrupts */ |
| 874 | |
| 875 | /* Initialize LCD controller bus priorities. |
| 876 | */ |
wdenk | 682011f | 2003-06-03 23:54:09 +0000 | [diff] [blame] | 877 | #ifdef CONFIG_RBC823 |
| 878 | immr->im_siu_conf.sc_sdcr = (immr->im_siu_conf.sc_sdcr & ~0x0f) | 1; /* RAID = 01, LAID = 00 */ |
| 879 | #else |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 880 | immr->im_siu_conf.sc_sdcr &= ~0x0f; /* RAID = LAID = 0 */ |
| 881 | |
| 882 | /* set SHFT/CLOCK division factor 4 |
| 883 | * This needs to be set based upon display type and processor |
| 884 | * speed. The TFT displays run about 20 to 30 MHz. |
| 885 | * I was running 64 MHz processor speed. |
| 886 | * The value for this divider must be chosen so the result is |
| 887 | * an integer of the processor speed (i.e., divide by 3 with |
| 888 | * 64 MHz would be bad). |
| 889 | */ |
| 890 | immr->im_clkrst.car_sccr &= ~0x1F; |
| 891 | immr->im_clkrst.car_sccr |= LCD_DF; /* was 8 */ |
| 892 | |
wdenk | 682011f | 2003-06-03 23:54:09 +0000 | [diff] [blame] | 893 | #endif /* CONFIG_RBC823 */ |
| 894 | |
| 895 | #if defined(CONFIG_RBC823) |
| 896 | /* Enable LCD on port D. |
| 897 | */ |
| 898 | immr->im_ioport.iop_pddat &= 0x0300; |
| 899 | immr->im_ioport.iop_pdpar |= 0x1CFF; |
| 900 | immr->im_ioport.iop_pddir |= 0x1CFF; |
| 901 | |
| 902 | /* Configure LCD_ON, VEE_ON, CCFL_ON on port B. |
| 903 | */ |
| 904 | immr->im_cpm.cp_pbdat &= ~0x00005001; |
| 905 | immr->im_cpm.cp_pbpar &= ~0x00005001; |
| 906 | immr->im_cpm.cp_pbdir |= 0x00005001; |
| 907 | #elif !defined(CONFIG_EDT32F10) |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 908 | /* Enable LCD on port D. |
| 909 | */ |
| 910 | immr->im_ioport.iop_pdpar |= 0x1FFF; |
| 911 | immr->im_ioport.iop_pddir |= 0x1FFF; |
| 912 | |
| 913 | /* Enable LCD_A/B/C on port B. |
| 914 | */ |
| 915 | immr->im_cpm.cp_pbpar |= 0x00005001; |
| 916 | immr->im_cpm.cp_pbdir |= 0x00005001; |
| 917 | #else |
| 918 | /* Enable LCD on port D. |
| 919 | */ |
| 920 | immr->im_ioport.iop_pdpar |= 0x1DFF; |
| 921 | immr->im_ioport.iop_pdpar &= ~0x0200; |
| 922 | immr->im_ioport.iop_pddir |= 0x1FFF; |
| 923 | immr->im_ioport.iop_pddat |= 0x0200; |
| 924 | #endif |
| 925 | |
| 926 | /* Load the physical address of the linear frame buffer |
| 927 | * into the LCD controller. |
| 928 | * BIG NOTE: This has to be modified to load A and B depending |
| 929 | * upon the split mode of the LCD. |
| 930 | */ |
| 931 | lcdp->lcd_lcfaa = (ulong)lcd_base; |
| 932 | lcdp->lcd_lcfba = (ulong)lcd_base; |
| 933 | |
| 934 | /* MORE HACKS...This must be updated according to 823 manual |
| 935 | * for different panels. |
wdenk | 682011f | 2003-06-03 23:54:09 +0000 | [diff] [blame] | 936 | * Udi Finkelstein - done - see below: |
| 937 | * Note: You better not try unsupported combinations such as |
| 938 | * 4-bit wide passive dual scan LCD at 4/8 Bit color. |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 939 | */ |
wdenk | 682011f | 2003-06-03 23:54:09 +0000 | [diff] [blame] | 940 | lchcr_hpc_tmp = |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 941 | (panel_info.vl_col * |
wdenk | 682011f | 2003-06-03 23:54:09 +0000 | [diff] [blame] | 942 | (panel_info.vl_tft ? 8 : |
| 943 | (((2 - panel_info.vl_lbw) << /* 4 bit=2, 8-bit = 1 */ |
| 944 | /* use << to mult by: single scan = 1, dual scan = 2 */ |
| 945 | panel_info.vl_splt) * |
| 946 | (panel_info.vl_bpix | 1)))) >> 3; /* 2/4 BPP = 1, 8/16 BPP = 3 */ |
| 947 | |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 948 | lcdp->lcd_lchcr = LCHCR_BO | |
| 949 | LCDBIT (LCHCR_AT_BIT, 4) | |
wdenk | 682011f | 2003-06-03 23:54:09 +0000 | [diff] [blame] | 950 | LCDBIT (LCHCR_HPC_BIT, lchcr_hpc_tmp) | |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 951 | panel_info.vl_wbl; |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 952 | |
| 953 | lcdp->lcd_lcvcr = LCDBIT (LCVCR_VPW_BIT, panel_info.vl_vpw) | |
| 954 | LCDBIT (LCVCR_LCD_AC_BIT, panel_info.vl_lcdac) | |
| 955 | LCDBIT (LCVCR_VPC_BIT, panel_info.vl_row) | |
| 956 | panel_info.vl_wbf; |
| 957 | |
| 958 | } |
| 959 | |
| 960 | /*----------------------------------------------------------------------*/ |
| 961 | |
| 962 | #ifdef NOT_USED_SO_FAR |
| 963 | static void |
| 964 | lcd_getcolreg (ushort regno, ushort *red, ushort *green, ushort *blue) |
| 965 | { |
| 966 | volatile immap_t *immr = (immap_t *) CFG_IMMR; |
| 967 | volatile cpm8xx_t *cp = &(immr->im_cpm); |
| 968 | unsigned short colreg, *cmap_ptr; |
| 969 | |
| 970 | cmap_ptr = (unsigned short *)&cp->lcd_cmap[regno * 2]; |
| 971 | |
| 972 | colreg = *cmap_ptr; |
| 973 | #ifdef CFG_INVERT_COLORS |
| 974 | colreg ^= 0x0FFF; |
| 975 | #endif |
| 976 | |
| 977 | *red = (colreg >> 8) & 0x0F; |
| 978 | *green = (colreg >> 4) & 0x0F; |
| 979 | *blue = colreg & 0x0F; |
| 980 | } |
| 981 | #endif /* NOT_USED_SO_FAR */ |
| 982 | |
| 983 | /*----------------------------------------------------------------------*/ |
| 984 | |
| 985 | #if LCD_BPP == LCD_COLOR8 |
| 986 | static void |
| 987 | lcd_setcolreg (ushort regno, ushort red, ushort green, ushort blue) |
| 988 | { |
| 989 | volatile immap_t *immr = (immap_t *) CFG_IMMR; |
| 990 | volatile cpm8xx_t *cp = &(immr->im_cpm); |
| 991 | unsigned short colreg, *cmap_ptr; |
| 992 | |
| 993 | cmap_ptr = (unsigned short *)&cp->lcd_cmap[regno * 2]; |
| 994 | |
| 995 | colreg = ((red & 0x0F) << 8) | |
| 996 | ((green & 0x0F) << 4) | |
| 997 | (blue & 0x0F) ; |
| 998 | #ifdef CFG_INVERT_COLORS |
| 999 | colreg ^= 0x0FFF; |
| 1000 | #endif |
| 1001 | *cmap_ptr = colreg; |
| 1002 | |
| 1003 | debug ("setcolreg: reg %2d @ %p: R=%02X G=%02X B=%02X => %02X%02X\n", |
| 1004 | regno, &(cp->lcd_cmap[regno * 2]), |
| 1005 | red, green, blue, |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1006 | cp->lcd_cmap[ regno * 2 ], cp->lcd_cmap[(regno * 2) + 1]); |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 1007 | } |
| 1008 | #endif /* LCD_COLOR8 */ |
| 1009 | |
| 1010 | /*----------------------------------------------------------------------*/ |
| 1011 | |
| 1012 | #if LCD_BPP == LCD_MONOCHROME |
| 1013 | static |
| 1014 | void lcd_initcolregs (void) |
| 1015 | { |
| 1016 | volatile immap_t *immr = (immap_t *) CFG_IMMR; |
| 1017 | volatile cpm8xx_t *cp = &(immr->im_cpm); |
| 1018 | ushort regno; |
| 1019 | |
| 1020 | for (regno = 0; regno < 16; regno++) { |
| 1021 | cp->lcd_cmap[regno * 2] = 0; |
| 1022 | cp->lcd_cmap[(regno * 2) + 1] = regno & 0x0f; |
| 1023 | } |
| 1024 | } |
| 1025 | #endif |
| 1026 | |
| 1027 | /*----------------------------------------------------------------------*/ |
| 1028 | |
| 1029 | static void lcd_setfgcolor (int color) |
| 1030 | { |
| 1031 | lcd_color_fg = color & 0x0F; |
| 1032 | } |
| 1033 | |
| 1034 | /*----------------------------------------------------------------------*/ |
| 1035 | |
| 1036 | static void lcd_setbgcolor (int color) |
| 1037 | { |
| 1038 | lcd_color_bg = color & 0x0F; |
| 1039 | } |
| 1040 | |
| 1041 | /*----------------------------------------------------------------------*/ |
| 1042 | |
| 1043 | #ifdef NOT_USED_SO_FAR |
| 1044 | static int lcd_getfgcolor (void) |
| 1045 | { |
| 1046 | return lcd_color_fg; |
| 1047 | } |
| 1048 | #endif /* NOT_USED_SO_FAR */ |
| 1049 | |
| 1050 | /*----------------------------------------------------------------------*/ |
| 1051 | |
| 1052 | static int lcd_getbgcolor (void) |
| 1053 | { |
| 1054 | return lcd_color_bg; |
| 1055 | } |
| 1056 | |
| 1057 | /*----------------------------------------------------------------------*/ |
| 1058 | |
| 1059 | static void lcd_enable (void) |
| 1060 | { |
| 1061 | volatile immap_t *immr = (immap_t *) CFG_IMMR; |
| 1062 | volatile lcd823_t *lcdp = &immr->im_lcd; |
| 1063 | |
| 1064 | /* Enable the LCD panel */ |
wdenk | 682011f | 2003-06-03 23:54:09 +0000 | [diff] [blame] | 1065 | #ifndef CONFIG_RBC823 |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 1066 | immr->im_siu_conf.sc_sdcr |= (1 << (31 - 25)); /* LAM = 1 */ |
wdenk | 682011f | 2003-06-03 23:54:09 +0000 | [diff] [blame] | 1067 | #endif |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 1068 | lcdp->lcd_lccr |= LCCR_PON; |
wdenk | 608c914 | 2003-01-13 23:54:46 +0000 | [diff] [blame] | 1069 | |
| 1070 | #ifdef CONFIG_V37 |
| 1071 | /* Turn on display backlight */ |
| 1072 | immr->im_cpm.cp_pbpar |= 0x00008000; |
| 1073 | immr->im_cpm.cp_pbdir |= 0x00008000; |
wdenk | 682011f | 2003-06-03 23:54:09 +0000 | [diff] [blame] | 1074 | #elif defined(CONFIG_RBC823) |
| 1075 | /* Turn on display backlight */ |
| 1076 | immr->im_cpm.cp_pbdat |= 0x00004000; |
wdenk | 608c914 | 2003-01-13 23:54:46 +0000 | [diff] [blame] | 1077 | #endif |
| 1078 | |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 1079 | #if defined(CONFIG_LWMON) |
| 1080 | { uchar c = pic_read (0x60); |
wdenk | 4532cb6 | 2003-04-27 22:52:51 +0000 | [diff] [blame] | 1081 | #if defined(CONFIG_LCD) && defined(CONFIG_LWMON) && (CONFIG_POST & CFG_POST_SYSMON) |
wdenk | 7d7ce41 | 2004-03-17 01:13:07 +0000 | [diff] [blame] | 1082 | /* Enable LCD later in sysmon test, only if temperature is OK */ |
wdenk | 4532cb6 | 2003-04-27 22:52:51 +0000 | [diff] [blame] | 1083 | #else |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1084 | c |= 0x07; /* Power on CCFL, Enable CCFL, Chip Enable LCD */ |
wdenk | 4532cb6 | 2003-04-27 22:52:51 +0000 | [diff] [blame] | 1085 | #endif |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 1086 | pic_write (0x60, c); |
| 1087 | } |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 1088 | #endif /* CONFIG_LWMON */ |
wdenk | 4a6fd34 | 2003-04-12 23:38:12 +0000 | [diff] [blame] | 1089 | |
| 1090 | #if defined(CONFIG_R360MPI) |
| 1091 | { |
| 1092 | extern void r360_i2c_lcd_write (uchar data0, uchar data1); |
wdenk | cb4dbb7 | 2003-07-16 16:40:22 +0000 | [diff] [blame] | 1093 | unsigned long bgi, ctr; |
| 1094 | char *p; |
| 1095 | |
| 1096 | if ((p = getenv("lcdbgi")) != NULL) { |
| 1097 | bgi = simple_strtoul (p, 0, 10) & 0xFFF; |
| 1098 | } else { |
| 1099 | bgi = 0xFFF; |
| 1100 | } |
| 1101 | |
| 1102 | if ((p = getenv("lcdctr")) != NULL) { |
| 1103 | ctr = simple_strtoul (p, 0, 10) & 0xFFF; |
| 1104 | } else { |
| 1105 | ctr=0x7FF; |
| 1106 | } |
wdenk | 4a6fd34 | 2003-04-12 23:38:12 +0000 | [diff] [blame] | 1107 | |
| 1108 | r360_i2c_lcd_write(0x10, 0x01); |
| 1109 | r360_i2c_lcd_write(0x20, 0x01); |
wdenk | cb4dbb7 | 2003-07-16 16:40:22 +0000 | [diff] [blame] | 1110 | r360_i2c_lcd_write(0x30 | ((bgi>>8) & 0xF), bgi & 0xFF); |
| 1111 | r360_i2c_lcd_write(0x40 | ((ctr>>8) & 0xF), ctr & 0xFF); |
wdenk | 4a6fd34 | 2003-04-12 23:38:12 +0000 | [diff] [blame] | 1112 | } |
| 1113 | #endif /* CONFIG_R360MPI */ |
wdenk | 682011f | 2003-06-03 23:54:09 +0000 | [diff] [blame] | 1114 | #ifdef CONFIG_RBC823 |
| 1115 | udelay(200000); /* wait 200ms */ |
| 1116 | /* Turn VEE_ON first */ |
| 1117 | immr->im_cpm.cp_pbdat |= 0x00000001; |
| 1118 | udelay(200000); /* wait 200ms */ |
| 1119 | /* Now turn on LCD_ON */ |
| 1120 | immr->im_cpm.cp_pbdat |= 0x00001000; |
| 1121 | #endif |
wdenk | 8564acf | 2003-07-14 22:13:32 +0000 | [diff] [blame] | 1122 | #ifdef CONFIG_RRVISION |
| 1123 | debug ("PC4->Output(1): enable LVDS\n"); |
| 1124 | debug ("PC5->Output(0): disable PAL clock\n"); |
| 1125 | immr->im_ioport.iop_pddir |= 0x1000; |
| 1126 | immr->im_ioport.iop_pcpar &= ~(0x0C00); |
| 1127 | immr->im_ioport.iop_pcdir |= 0x0C00 ; |
| 1128 | immr->im_ioport.iop_pcdat |= 0x0800 ; |
| 1129 | immr->im_ioport.iop_pcdat &= ~(0x0400); |
| 1130 | debug ("PDPAR=0x%04X PDDIR=0x%04X PDDAT=0x%04X\n", |
| 1131 | immr->im_ioport.iop_pdpar, |
| 1132 | immr->im_ioport.iop_pddir, |
| 1133 | immr->im_ioport.iop_pddat); |
| 1134 | debug ("PCPAR=0x%04X PCDIR=0x%04X PCDAT=0x%04X\n", |
| 1135 | immr->im_ioport.iop_pcpar, |
| 1136 | immr->im_ioport.iop_pcdir, |
| 1137 | immr->im_ioport.iop_pcdat); |
| 1138 | #endif |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 1139 | } |
| 1140 | |
| 1141 | /*----------------------------------------------------------------------*/ |
| 1142 | |
wdenk | 682011f | 2003-06-03 23:54:09 +0000 | [diff] [blame] | 1143 | #if defined (CONFIG_RBC823) |
| 1144 | void lcd_disable (void) |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 1145 | { |
| 1146 | volatile immap_t *immr = (immap_t *) CFG_IMMR; |
| 1147 | volatile lcd823_t *lcdp = &immr->im_lcd; |
| 1148 | |
| 1149 | #if defined(CONFIG_LWMON) |
| 1150 | { uchar c = pic_read (0x60); |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 1151 | c &= ~0x07; /* Power off CCFL, Disable CCFL, Chip Disable LCD */ |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 1152 | pic_write (0x60, c); |
| 1153 | } |
| 1154 | #elif defined(CONFIG_R360MPI) |
| 1155 | { |
wdenk | 4a6fd34 | 2003-04-12 23:38:12 +0000 | [diff] [blame] | 1156 | extern void r360_i2c_lcd_write (uchar data0, uchar data1); |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 1157 | |
wdenk | 4a6fd34 | 2003-04-12 23:38:12 +0000 | [diff] [blame] | 1158 | r360_i2c_lcd_write(0x10, 0x00); |
| 1159 | r360_i2c_lcd_write(0x20, 0x00); |
| 1160 | r360_i2c_lcd_write(0x30, 0x00); |
| 1161 | r360_i2c_lcd_write(0x40, 0x00); |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 1162 | } |
| 1163 | #endif /* CONFIG_LWMON */ |
| 1164 | /* Disable the LCD panel */ |
| 1165 | lcdp->lcd_lccr &= ~LCCR_PON; |
wdenk | 682011f | 2003-06-03 23:54:09 +0000 | [diff] [blame] | 1166 | #ifdef CONFIG_RBC823 |
| 1167 | /* Turn off display backlight, VEE and LCD_ON */ |
| 1168 | immr->im_cpm.cp_pbdat &= ~0x00005001; |
| 1169 | #else |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 1170 | immr->im_siu_conf.sc_sdcr &= ~(1 << (31 - 25)); /* LAM = 0 */ |
wdenk | 682011f | 2003-06-03 23:54:09 +0000 | [diff] [blame] | 1171 | #endif /* CONFIG_RBC823 */ |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 1172 | } |
wdenk | 682011f | 2003-06-03 23:54:09 +0000 | [diff] [blame] | 1173 | #endif /* NOT_USED_SO_FAR || CONFIG_RBC823 */ |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 1174 | |
| 1175 | |
| 1176 | /************************************************************************/ |
| 1177 | /* ** Chipset depending Bitmap / Logo stuff... */ |
| 1178 | /************************************************************************/ |
| 1179 | |
| 1180 | |
| 1181 | #ifdef CONFIG_LCD_LOGO |
| 1182 | static void bitmap_plot (int x, int y) |
| 1183 | { |
| 1184 | volatile immap_t *immr = (immap_t *) CFG_IMMR; |
| 1185 | volatile cpm8xx_t *cp = &(immr->im_cpm); |
| 1186 | ushort *cmap; |
| 1187 | ushort i; |
| 1188 | uchar *bmap; |
| 1189 | uchar *fb; |
| 1190 | |
| 1191 | debug ("Logo: width %d height %d colors %d cmap %d\n", |
| 1192 | BMP_LOGO_WIDTH, BMP_LOGO_HEIGHT, BMP_LOGO_COLORS, |
| 1193 | sizeof(bmp_logo_palette)/(sizeof(ushort)) |
| 1194 | ); |
| 1195 | |
| 1196 | /* Leave room for default color map */ |
| 1197 | cmap = (ushort *)&(cp->lcd_cmap[BMP_LOGO_OFFSET*sizeof(ushort)]); |
| 1198 | |
wdenk | 7aa7861 | 2003-05-03 15:50:43 +0000 | [diff] [blame] | 1199 | WATCHDOG_RESET(); |
| 1200 | |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 1201 | /* Set color map */ |
| 1202 | for (i=0; i<(sizeof(bmp_logo_palette)/(sizeof(ushort))); ++i) { |
| 1203 | ushort colreg = bmp_logo_palette[i]; |
| 1204 | #ifdef CFG_INVERT_COLORS |
| 1205 | colreg ^= 0xFFF; |
| 1206 | #endif |
| 1207 | *cmap++ = colreg; |
| 1208 | } |
| 1209 | |
| 1210 | bmap = &bmp_logo_bitmap[0]; |
| 1211 | fb = (char *)(lcd_base + y * lcd_line_length + x); |
| 1212 | |
wdenk | 7aa7861 | 2003-05-03 15:50:43 +0000 | [diff] [blame] | 1213 | WATCHDOG_RESET(); |
| 1214 | |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 1215 | for (i=0; i<BMP_LOGO_HEIGHT; ++i) { |
| 1216 | memcpy (fb, bmap, BMP_LOGO_WIDTH); |
| 1217 | bmap += BMP_LOGO_WIDTH; |
| 1218 | fb += panel_info.vl_col; |
| 1219 | } |
wdenk | 7aa7861 | 2003-05-03 15:50:43 +0000 | [diff] [blame] | 1220 | |
| 1221 | WATCHDOG_RESET(); |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 1222 | } |
| 1223 | #endif /* CONFIG_LCD_LOGO */ |
| 1224 | |
wdenk | 27b207f | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 1225 | #if (CONFIG_COMMANDS & CFG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN) |
wdenk | d791b1d | 2003-04-20 14:04:18 +0000 | [diff] [blame] | 1226 | /* |
wdenk | 824a1eb | 2003-04-20 16:49:37 +0000 | [diff] [blame] | 1227 | * Display the BMP file located at address bmp_image. |
| 1228 | * Only uncompressed |
| 1229 | */ |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1230 | int lcd_display_bitmap(ulong bmp_image, int x, int y) |
wdenk | d791b1d | 2003-04-20 14:04:18 +0000 | [diff] [blame] | 1231 | { |
| 1232 | volatile immap_t *immr = (immap_t *) CFG_IMMR; |
| 1233 | volatile cpm8xx_t *cp = &(immr->im_cpm); |
| 1234 | ushort *cmap; |
| 1235 | ushort i, j; |
| 1236 | uchar *fb; |
| 1237 | bmp_image_t *bmp=(bmp_image_t *)bmp_image; |
| 1238 | uchar *bmap; |
| 1239 | ushort padded_line; |
| 1240 | unsigned long width, height; |
| 1241 | unsigned colors,bpix; |
| 1242 | unsigned long compression; |
| 1243 | |
wdenk | 7aa7861 | 2003-05-03 15:50:43 +0000 | [diff] [blame] | 1244 | WATCHDOG_RESET(); |
| 1245 | |
wdenk | d791b1d | 2003-04-20 14:04:18 +0000 | [diff] [blame] | 1246 | if (!((bmp->header.signature[0]=='B') && |
| 1247 | (bmp->header.signature[1]=='M'))) { |
| 1248 | printf ("Error: no valid bmp image at %lx\n", bmp_image); |
| 1249 | return 1; |
| 1250 | } |
| 1251 | |
| 1252 | width = le32_to_cpu (bmp->header.width); |
| 1253 | height = le32_to_cpu (bmp->header.height); |
| 1254 | colors = 1<<le16_to_cpu (bmp->header.bit_count); |
| 1255 | compression = le32_to_cpu (bmp->header.compression); |
| 1256 | |
| 1257 | bpix = NBITS(panel_info.vl_bpix); |
| 1258 | |
| 1259 | if ((bpix != 1) && (bpix != 8)) { |
| 1260 | printf ("Error: %d bit/pixel mode not supported by U-Boot\n", |
| 1261 | bpix); |
| 1262 | return 1; |
| 1263 | } |
| 1264 | |
| 1265 | if (bpix != le16_to_cpu(bmp->header.bit_count)) { |
| 1266 | printf ("Error: %d bit/pixel mode, but BMP has %d bit/pixel\n", |
| 1267 | bpix, |
| 1268 | le16_to_cpu(bmp->header.bit_count)); |
| 1269 | return 1; |
| 1270 | } |
| 1271 | |
| 1272 | if (compression!=BMP_BI_RGB) { |
| 1273 | printf ("Error: compression type %ld not supported\n", |
| 1274 | compression); |
| 1275 | return 1; |
| 1276 | } |
| 1277 | |
| 1278 | debug ("Display-bmp: %d x %d with %d colors\n", |
| 1279 | width, height, colors); |
| 1280 | |
| 1281 | if (bpix==8) { |
| 1282 | /* Fill the entire color map */ |
| 1283 | cmap = (ushort *)&(cp->lcd_cmap[255*sizeof(ushort)]); |
| 1284 | |
| 1285 | /* Set color map */ |
| 1286 | for (i = 0; i < colors; ++i) { |
| 1287 | bmp_color_table_entry_t cte = bmp->color_table[i]; |
| 1288 | ushort colreg = |
| 1289 | ((cte.red>>4) << 8) | |
| 1290 | ((cte.green>>4) << 4) | |
| 1291 | (cte.blue>>4) ; |
| 1292 | #ifdef CFG_INVERT_COLORS |
| 1293 | colreg ^= 0xFFF; |
| 1294 | #endif |
| 1295 | *cmap-- = colreg; |
| 1296 | } |
wdenk | 7aa7861 | 2003-05-03 15:50:43 +0000 | [diff] [blame] | 1297 | |
| 1298 | WATCHDOG_RESET(); |
wdenk | d791b1d | 2003-04-20 14:04:18 +0000 | [diff] [blame] | 1299 | } |
| 1300 | |
| 1301 | padded_line = (width&0x3) ? ((width&~0x3)+4) : (width); |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1302 | if ((x + width)>panel_info.vl_col) |
| 1303 | width = panel_info.vl_col - x; |
| 1304 | if ((y + height)>panel_info.vl_row) |
| 1305 | height = panel_info.vl_row - y; |
wdenk | d791b1d | 2003-04-20 14:04:18 +0000 | [diff] [blame] | 1306 | |
| 1307 | bmap = (uchar *)bmp + le32_to_cpu (bmp->header.data_offset); |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1308 | fb = (uchar *) (lcd_base + |
| 1309 | (y + height - 1) * lcd_line_length + x); |
wdenk | d791b1d | 2003-04-20 14:04:18 +0000 | [diff] [blame] | 1310 | for (i = 0; i < height; ++i) { |
wdenk | 7aa7861 | 2003-05-03 15:50:43 +0000 | [diff] [blame] | 1311 | WATCHDOG_RESET(); |
wdenk | d791b1d | 2003-04-20 14:04:18 +0000 | [diff] [blame] | 1312 | for (j = 0; j < width ; j++) |
| 1313 | *(fb++)=255-*(bmap++); |
| 1314 | bmap += (width - padded_line); |
| 1315 | fb -= (width + lcd_line_length); |
| 1316 | } |
| 1317 | |
| 1318 | return (0); |
| 1319 | } |
wdenk | 27b207f | 2003-07-24 23:38:38 +0000 | [diff] [blame] | 1320 | #endif /* (CONFIG_COMMANDS & CFG_CMD_BMP) || CONFIG_SPLASH_SCREEN */ |
wdenk | d791b1d | 2003-04-20 14:04:18 +0000 | [diff] [blame] | 1321 | |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 1322 | /*----------------------------------------------------------------------*/ |
| 1323 | |
| 1324 | static void *lcd_logo (void) |
| 1325 | { |
| 1326 | #ifdef LCD_INFO |
| 1327 | DECLARE_GLOBAL_DATA_PTR; |
| 1328 | |
| 1329 | char info[80]; |
| 1330 | char temp[32]; |
| 1331 | #endif /* LCD_INFO */ |
| 1332 | |
wdenk | d791b1d | 2003-04-20 14:04:18 +0000 | [diff] [blame] | 1333 | #ifdef CONFIG_SPLASH_SCREEN |
| 1334 | char *s; |
| 1335 | ulong addr; |
wdenk | e94d2cd | 2004-06-30 22:59:18 +0000 | [diff] [blame] | 1336 | static int do_splash = 1; |
wdenk | d791b1d | 2003-04-20 14:04:18 +0000 | [diff] [blame] | 1337 | |
wdenk | e94d2cd | 2004-06-30 22:59:18 +0000 | [diff] [blame] | 1338 | if (do_splash && (s = getenv("splashimage")) != NULL) { |
wdenk | d791b1d | 2003-04-20 14:04:18 +0000 | [diff] [blame] | 1339 | addr = simple_strtoul(s, NULL, 16); |
wdenk | e94d2cd | 2004-06-30 22:59:18 +0000 | [diff] [blame] | 1340 | do_splash = 0; |
wdenk | d791b1d | 2003-04-20 14:04:18 +0000 | [diff] [blame] | 1341 | |
wdenk | 4b248f3 | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 1342 | if (lcd_display_bitmap (addr, 0, 0) == 0) { |
wdenk | d791b1d | 2003-04-20 14:04:18 +0000 | [diff] [blame] | 1343 | return ((void *)lcd_base); |
| 1344 | } |
| 1345 | } |
| 1346 | #endif /* CONFIG_SPLASH_SCREEN */ |
| 1347 | |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 1348 | #ifdef CONFIG_LCD_LOGO |
| 1349 | bitmap_plot (0, 0); |
| 1350 | #endif /* CONFIG_LCD_LOGO */ |
| 1351 | |
| 1352 | |
| 1353 | #ifdef LCD_INFO |
| 1354 | sprintf (info, "%s (%s - %s) ", U_BOOT_VERSION, __DATE__, __TIME__); |
| 1355 | lcd_drawchars (LCD_INFO_X, LCD_INFO_Y, info, strlen(info)); |
| 1356 | |
wdenk | 07cba35 | 2004-07-12 14:37:59 +0000 | [diff] [blame] | 1357 | sprintf (info, "(C) 2004 DENX Software Engineering"); |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 1358 | lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT, |
| 1359 | info, strlen(info)); |
| 1360 | |
| 1361 | sprintf (info, " Wolfgang DENK, wd@denx.de"); |
| 1362 | lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT * 2, |
| 1363 | info, strlen(info)); |
| 1364 | #ifdef LCD_INFO_BELOW_LOGO |
| 1365 | sprintf (info, "MPC823 CPU at %s MHz", |
| 1366 | strmhz(temp, gd->cpu_clk)); |
| 1367 | lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT * 3, |
| 1368 | info, strlen(info)); |
| 1369 | sprintf (info, " %ld MB RAM, %ld MB Flash", |
| 1370 | gd->ram_size >> 20, |
| 1371 | gd->bd->bi_flashsize >> 20 ); |
| 1372 | lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT * 4, |
| 1373 | info, strlen(info)); |
| 1374 | #else |
| 1375 | /* leave one blank line */ |
| 1376 | |
| 1377 | sprintf (info, "MPC823 CPU at %s MHz, %ld MB RAM, %ld MB Flash", |
| 1378 | strmhz(temp, gd->cpu_clk), |
| 1379 | gd->ram_size >> 20, |
| 1380 | gd->bd->bi_flashsize >> 20 ); |
| 1381 | lcd_drawchars (LCD_INFO_X, LCD_INFO_Y + VIDEO_FONT_HEIGHT * 4, |
| 1382 | info, strlen(info)); |
| 1383 | #endif /* LCD_INFO_BELOW_LOGO */ |
| 1384 | #endif /* LCD_INFO */ |
| 1385 | |
| 1386 | #if defined(CONFIG_LCD_LOGO) && !defined(LCD_INFO_BELOW_LOGO) |
| 1387 | return ((void *)((ulong)lcd_base + BMP_LOGO_HEIGHT * lcd_line_length)); |
| 1388 | #else |
| 1389 | return ((void *)lcd_base); |
| 1390 | #endif /* CONFIG_LCD_LOGO */ |
| 1391 | } |
| 1392 | |
| 1393 | /************************************************************************/ |
| 1394 | /************************************************************************/ |
| 1395 | |
| 1396 | #endif /* CONFIG_LCD */ |