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 | /*----------------------------------------------------------------------*/ |
| 58 | #ifdef CONFIG_KYOCERA_KCS057QV1AJ |
| 59 | /* |
| 60 | * Kyocera KCS057QV1AJ-G23. Passive, color, single scan. |
| 61 | */ |
| 62 | #define LCD_BPP LCD_COLOR4 |
| 63 | |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame^] | 64 | vidinfo_t panel_info = { |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 65 | 640, 480, 132, 99, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH, |
| 66 | LCD_BPP, 1, 0, 1, 0, 5, 0, 0, 0 |
| 67 | /* wbl, vpw, lcdac, wbf */ |
| 68 | }; |
| 69 | #endif /* CONFIG_KYOCERA_KCS057QV1AJ */ |
| 70 | /*----------------------------------------------------------------------*/ |
| 71 | |
| 72 | /*----------------------------------------------------------------------*/ |
wdenk | 682011f | 2003-06-03 23:54:09 +0000 | [diff] [blame] | 73 | #ifdef CONFIG_HITACHI_SP19X001_Z1A |
| 74 | /* |
| 75 | * Hitachi SP19X001-. Active, color, single scan. |
| 76 | */ |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame^] | 77 | vidinfo_t panel_info = { |
wdenk | 682011f | 2003-06-03 23:54:09 +0000 | [diff] [blame] | 78 | 640, 480, 154, 116, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH, |
| 79 | LCD_COLOR8, 1, 0, 1, 0, 0, 0, 0, 0 |
| 80 | /* wbl, vpw, lcdac, wbf */ |
| 81 | }; |
| 82 | #endif /* CONFIG_HITACHI_SP19X001_Z1A */ |
| 83 | /*----------------------------------------------------------------------*/ |
| 84 | |
| 85 | /*----------------------------------------------------------------------*/ |
wdenk | fd3103b | 2003-11-25 16:55:19 +0000 | [diff] [blame] | 86 | #ifdef CONFIG_NEC_NL6448AC33 |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 87 | /* |
wdenk | fd3103b | 2003-11-25 16:55:19 +0000 | [diff] [blame] | 88 | * NEC NL6448AC33-18. Active, color, single scan. |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 89 | */ |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame^] | 90 | vidinfo_t panel_info = { |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 91 | 640, 480, 132, 99, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_HIGH, |
| 92 | 3, 0, 0, 1, 1, 144, 2, 0, 33 |
| 93 | /* wbl, vpw, lcdac, wbf */ |
| 94 | }; |
wdenk | fd3103b | 2003-11-25 16:55:19 +0000 | [diff] [blame] | 95 | #endif /* CONFIG_NEC_NL6448AC33 */ |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 96 | /*----------------------------------------------------------------------*/ |
| 97 | |
wdenk | fd3103b | 2003-11-25 16:55:19 +0000 | [diff] [blame] | 98 | #ifdef CONFIG_NEC_NL6448BC20 |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 99 | /* |
wdenk | fd3103b | 2003-11-25 16:55:19 +0000 | [diff] [blame] | 100 | * NEC NL6448BC20-08. 6.5", 640x480. Active, color, single scan. |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 101 | */ |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame^] | 102 | vidinfo_t panel_info = { |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 103 | 640, 480, 132, 99, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_HIGH, |
| 104 | 3, 0, 0, 1, 1, 144, 2, 0, 33 |
| 105 | /* wbl, vpw, lcdac, wbf */ |
| 106 | }; |
wdenk | fd3103b | 2003-11-25 16:55:19 +0000 | [diff] [blame] | 107 | #endif /* CONFIG_NEC_NL6448BC20 */ |
| 108 | /*----------------------------------------------------------------------*/ |
| 109 | |
| 110 | #ifdef CONFIG_NEC_NL6448BC33_54 |
| 111 | /* |
| 112 | * NEC NL6448BC33-54. 10.4", 640x480. Active, color, single scan. |
| 113 | */ |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame^] | 114 | vidinfo_t panel_info = { |
wdenk | fd3103b | 2003-11-25 16:55:19 +0000 | [diff] [blame] | 115 | 640, 480, 212, 158, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_HIGH, |
| 116 | 3, 0, 0, 1, 1, 144, 2, 0, 33 |
| 117 | /* wbl, vpw, lcdac, wbf */ |
| 118 | }; |
| 119 | #endif /* CONFIG_NEC_NL6448BC33_54 */ |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 120 | /*----------------------------------------------------------------------*/ |
| 121 | |
| 122 | #ifdef CONFIG_SHARP_LQ104V7DS01 |
| 123 | /* |
| 124 | * SHARP LQ104V7DS01. 6.5", 640x480. Active, color, single scan. |
| 125 | */ |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame^] | 126 | vidinfo_t panel_info = { |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 127 | 640, 480, 132, 99, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_LOW, |
| 128 | 3, 0, 0, 1, 1, 25, 1, 0, 33 |
| 129 | /* wbl, vpw, lcdac, wbf */ |
| 130 | }; |
| 131 | #endif /* CONFIG_SHARP_LQ104V7DS01 */ |
| 132 | /*----------------------------------------------------------------------*/ |
| 133 | |
| 134 | #ifdef CONFIG_SHARP_16x9 |
| 135 | /* |
| 136 | * Sharp 320x240. Active, color, single scan. It isn't 16x9, and I am |
| 137 | * not sure what it is....... |
| 138 | */ |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame^] | 139 | vidinfo_t panel_info = { |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 140 | 320, 240, 0, 0, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH, |
| 141 | 3, 0, 0, 1, 1, 15, 4, 0, 3 |
| 142 | }; |
| 143 | #endif /* CONFIG_SHARP_16x9 */ |
| 144 | /*----------------------------------------------------------------------*/ |
| 145 | |
| 146 | #ifdef CONFIG_SHARP_LQ057Q3DC02 |
| 147 | /* |
| 148 | * Sharp LQ057Q3DC02 display. Active, color, single scan. |
| 149 | */ |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame^] | 150 | #undef LCD_DF |
wdenk | 4a6fd34 | 2003-04-12 23:38:12 +0000 | [diff] [blame] | 151 | #define LCD_DF 12 |
| 152 | |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame^] | 153 | vidinfo_t panel_info = { |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 154 | 320, 240, 0, 0, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_HIGH, |
| 155 | 3, 0, 0, 1, 1, 15, 4, 0, 3 |
| 156 | /* wbl, vpw, lcdac, wbf */ |
| 157 | }; |
| 158 | #define LCD_INFO_BELOW_LOGO |
| 159 | #endif /* CONFIG_SHARP_LQ057Q3DC02 */ |
| 160 | /*----------------------------------------------------------------------*/ |
| 161 | |
| 162 | #ifdef CONFIG_SHARP_LQ64D341 |
| 163 | /* |
| 164 | * Sharp LQ64D341 display, 640x480. Active, color, single scan. |
| 165 | */ |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame^] | 166 | vidinfo_t panel_info = { |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 167 | 640, 480, 0, 0, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_HIGH, |
| 168 | 3, 0, 0, 1, 1, 128, 16, 0, 32 |
| 169 | /* wbl, vpw, lcdac, wbf */ |
| 170 | }; |
| 171 | #endif /* CONFIG_SHARP_LQ64D341 */ |
wdenk | 608c914 | 2003-01-13 23:54:46 +0000 | [diff] [blame] | 172 | |
dzu | 29127b6 | 2003-09-25 22:30:12 +0000 | [diff] [blame] | 173 | #ifdef CONFIG_SHARP_LQ065T9DR51U |
| 174 | /* |
| 175 | * Sharp LQ065T9DR51U display, 400x240. Active, color, single scan. |
| 176 | */ |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame^] | 177 | vidinfo_t panel_info = { |
dzu | 29127b6 | 2003-09-25 22:30:12 +0000 | [diff] [blame] | 178 | 400, 240, 143, 79, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH, |
| 179 | 3, 0, 0, 1, 1, 248, 4, 0, 35 |
| 180 | /* wbl, vpw, lcdac, wbf */ |
| 181 | }; |
| 182 | #define LCD_INFO_BELOW_LOGO |
| 183 | #endif /* CONFIG_SHARP_LQ065T9DR51U */ |
| 184 | |
wdenk | 608c914 | 2003-01-13 23:54:46 +0000 | [diff] [blame] | 185 | #ifdef CONFIG_SHARP_LQ084V1DG21 |
| 186 | /* |
| 187 | * Sharp LQ084V1DG21 display, 640x480. Active, color, single scan. |
| 188 | */ |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame^] | 189 | vidinfo_t panel_info = { |
wdenk | 608c914 | 2003-01-13 23:54:46 +0000 | [diff] [blame] | 190 | 640, 480, 171, 129, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_LOW, |
| 191 | 3, 0, 0, 1, 1, 160, 3, 0, 48 |
| 192 | /* wbl, vpw, lcdac, wbf */ |
| 193 | }; |
| 194 | #endif /* CONFIG_SHARP_LQ084V1DG21 */ |
| 195 | |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 196 | /*----------------------------------------------------------------------*/ |
| 197 | |
| 198 | #ifdef CONFIG_HLD1045 |
| 199 | /* |
| 200 | * HLD1045 display, 640x480. Active, color, single scan. |
| 201 | */ |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame^] | 202 | vidinfo_t panel_info = { |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 203 | 640, 480, 0, 0, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_HIGH, |
| 204 | 3, 0, 0, 1, 1, 160, 3, 0, 48 |
| 205 | /* wbl, vpw, lcdac, wbf */ |
| 206 | }; |
| 207 | #endif /* CONFIG_HLD1045 */ |
| 208 | /*----------------------------------------------------------------------*/ |
| 209 | |
| 210 | #ifdef CONFIG_PRIMEVIEW_V16C6448AC |
| 211 | /* |
| 212 | * Prime View V16C6448AC |
| 213 | */ |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame^] | 214 | vidinfo_t panel_info = { |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 215 | 640, 480, 130, 98, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_HIGH, |
| 216 | 3, 0, 0, 1, 1, 144, 2, 0, 35 |
| 217 | /* wbl, vpw, lcdac, wbf */ |
| 218 | }; |
| 219 | #endif /* CONFIG_PRIMEVIEW_V16C6448AC */ |
| 220 | |
| 221 | /*----------------------------------------------------------------------*/ |
| 222 | |
| 223 | #ifdef CONFIG_OPTREX_BW |
| 224 | /* |
| 225 | * Optrex CBL50840-2 NF-FW 99 22 M5 |
| 226 | * or |
| 227 | * Hitachi LMG6912RPFC-00T |
| 228 | * or |
| 229 | * Hitachi SP14Q002 |
| 230 | * |
| 231 | * 320x240. Black & white. |
| 232 | */ |
| 233 | #define OPTREX_BPP 0 /* 0 - monochrome, 1 bpp */ |
| 234 | /* 1 - 4 grey levels, 2 bpp */ |
| 235 | /* 2 - 16 grey levels, 4 bpp */ |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame^] | 236 | vidinfo_t panel_info = { |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 237 | 320, 240, 0, 0, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_LOW, |
| 238 | OPTREX_BPP, 0, 0, 0, 0, 0, 0, 0, 0, 4 |
| 239 | }; |
| 240 | #endif /* CONFIG_OPTREX_BW */ |
| 241 | |
| 242 | /*-----------------------------------------------------------------*/ |
| 243 | #ifdef CONFIG_EDT32F10 |
| 244 | /* |
| 245 | * Emerging Display Technologies 320x240. Passive, monochrome, single scan. |
| 246 | */ |
| 247 | #define LCD_BPP LCD_MONOCHROME |
wdenk | 4a6fd34 | 2003-04-12 23:38:12 +0000 | [diff] [blame] | 248 | #define LCD_DF 10 |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 249 | |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame^] | 250 | vidinfo_t panel_info = { |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 251 | 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] | 252 | LCD_BPP, 0, 0, 0, 0, 33, 0, 0, 0 |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 253 | }; |
| 254 | #endif |
| 255 | /*----------------------------------------------------------------------*/ |
| 256 | |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 257 | |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame^] | 258 | int lcd_line_length; |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 259 | |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame^] | 260 | int lcd_color_fg; |
| 261 | int lcd_color_bg; |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 262 | |
| 263 | /* |
| 264 | * Frame buffer memory information |
| 265 | */ |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame^] | 266 | void *lcd_base; /* Start of framebuffer memory */ |
| 267 | void *lcd_console_address; /* Start of console buffer */ |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 268 | |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame^] | 269 | short console_col; |
| 270 | short console_row; |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 271 | |
| 272 | /************************************************************************/ |
| 273 | |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame^] | 274 | void lcd_ctrl_init (void *lcdbase); |
| 275 | void lcd_enable (void); |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 276 | #if LCD_BPP == LCD_COLOR8 |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame^] | 277 | void lcd_setcolreg (ushort regno, |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 278 | ushort red, ushort green, ushort blue); |
| 279 | #endif |
| 280 | #if LCD_BPP == LCD_MONOCHROME |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame^] | 281 | void lcd_initcolregs (void); |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 282 | #endif |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 283 | |
wdenk | 682011f | 2003-06-03 23:54:09 +0000 | [diff] [blame] | 284 | #if defined(CONFIG_RBC823) |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame^] | 285 | void lcd_disable (void); |
wdenk | 682011f | 2003-06-03 23:54:09 +0000 | [diff] [blame] | 286 | #endif |
| 287 | |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 288 | /************************************************************************/ |
| 289 | |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 290 | /************************************************************************/ |
| 291 | /* ----------------- chipset specific functions ----------------------- */ |
| 292 | /************************************************************************/ |
| 293 | |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame^] | 294 | /* |
| 295 | * Calculate fb size for VIDEOLFB_ATAG. |
| 296 | */ |
| 297 | ulong calc_fbsize (void) |
| 298 | { |
| 299 | ulong size; |
| 300 | int line_length = (panel_info.vl_col * NBITS (panel_info.vl_bpix)) / 8; |
| 301 | |
| 302 | size = line_length * panel_info.vl_row; |
| 303 | |
| 304 | return size; |
| 305 | } |
| 306 | |
| 307 | void lcd_ctrl_init (void *lcdbase) |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 308 | { |
| 309 | volatile immap_t *immr = (immap_t *) CFG_IMMR; |
| 310 | volatile lcd823_t *lcdp = &immr->im_lcd; |
| 311 | |
| 312 | uint lccrtmp; |
wdenk | 682011f | 2003-06-03 23:54:09 +0000 | [diff] [blame] | 313 | uint lchcr_hpc_tmp; |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 314 | |
| 315 | /* Initialize the LCD control register according to the LCD |
| 316 | * parameters defined. We do everything here but enable |
| 317 | * the controller. |
| 318 | */ |
| 319 | |
wdenk | e63c8ee | 2004-06-09 21:04:48 +0000 | [diff] [blame] | 320 | #ifdef CONFIG_RPXLITE |
| 321 | /* This is special for RPXlite_DW Software Development Platform **[Sam]** */ |
| 322 | panel_info.vl_dp = CFG_LOW; |
| 323 | #endif |
| 324 | |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 325 | lccrtmp = LCDBIT (LCCR_BNUM_BIT, |
| 326 | (((panel_info.vl_row * panel_info.vl_col) * (1 << LCD_BPP)) / 128)); |
| 327 | |
| 328 | lccrtmp |= LCDBIT (LCCR_CLKP_BIT, panel_info.vl_clkp) | |
| 329 | LCDBIT (LCCR_OEP_BIT, panel_info.vl_oep) | |
| 330 | LCDBIT (LCCR_HSP_BIT, panel_info.vl_hsp) | |
| 331 | LCDBIT (LCCR_VSP_BIT, panel_info.vl_vsp) | |
| 332 | LCDBIT (LCCR_DP_BIT, panel_info.vl_dp) | |
| 333 | LCDBIT (LCCR_BPIX_BIT, panel_info.vl_bpix) | |
| 334 | LCDBIT (LCCR_LBW_BIT, panel_info.vl_lbw) | |
| 335 | LCDBIT (LCCR_SPLT_BIT, panel_info.vl_splt) | |
| 336 | LCDBIT (LCCR_CLOR_BIT, panel_info.vl_clor) | |
| 337 | LCDBIT (LCCR_TFT_BIT, panel_info.vl_tft); |
| 338 | |
| 339 | #if 0 |
| 340 | lccrtmp |= ((SIU_LEVEL5 / 2) << 12); |
| 341 | lccrtmp |= LCCR_EIEN; |
| 342 | #endif |
| 343 | |
| 344 | lcdp->lcd_lccr = lccrtmp; |
| 345 | lcdp->lcd_lcsr = 0xFF; /* Clear pending interrupts */ |
| 346 | |
| 347 | /* Initialize LCD controller bus priorities. |
| 348 | */ |
wdenk | 682011f | 2003-06-03 23:54:09 +0000 | [diff] [blame] | 349 | #ifdef CONFIG_RBC823 |
| 350 | immr->im_siu_conf.sc_sdcr = (immr->im_siu_conf.sc_sdcr & ~0x0f) | 1; /* RAID = 01, LAID = 00 */ |
| 351 | #else |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 352 | immr->im_siu_conf.sc_sdcr &= ~0x0f; /* RAID = LAID = 0 */ |
| 353 | |
| 354 | /* set SHFT/CLOCK division factor 4 |
| 355 | * This needs to be set based upon display type and processor |
| 356 | * speed. The TFT displays run about 20 to 30 MHz. |
| 357 | * I was running 64 MHz processor speed. |
| 358 | * The value for this divider must be chosen so the result is |
| 359 | * an integer of the processor speed (i.e., divide by 3 with |
| 360 | * 64 MHz would be bad). |
| 361 | */ |
| 362 | immr->im_clkrst.car_sccr &= ~0x1F; |
| 363 | immr->im_clkrst.car_sccr |= LCD_DF; /* was 8 */ |
| 364 | |
wdenk | 682011f | 2003-06-03 23:54:09 +0000 | [diff] [blame] | 365 | #endif /* CONFIG_RBC823 */ |
| 366 | |
| 367 | #if defined(CONFIG_RBC823) |
| 368 | /* Enable LCD on port D. |
| 369 | */ |
| 370 | immr->im_ioport.iop_pddat &= 0x0300; |
| 371 | immr->im_ioport.iop_pdpar |= 0x1CFF; |
| 372 | immr->im_ioport.iop_pddir |= 0x1CFF; |
| 373 | |
| 374 | /* Configure LCD_ON, VEE_ON, CCFL_ON on port B. |
| 375 | */ |
| 376 | immr->im_cpm.cp_pbdat &= ~0x00005001; |
| 377 | immr->im_cpm.cp_pbpar &= ~0x00005001; |
| 378 | immr->im_cpm.cp_pbdir |= 0x00005001; |
| 379 | #elif !defined(CONFIG_EDT32F10) |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 380 | /* Enable LCD on port D. |
| 381 | */ |
| 382 | immr->im_ioport.iop_pdpar |= 0x1FFF; |
| 383 | immr->im_ioport.iop_pddir |= 0x1FFF; |
| 384 | |
| 385 | /* Enable LCD_A/B/C on port B. |
| 386 | */ |
| 387 | immr->im_cpm.cp_pbpar |= 0x00005001; |
| 388 | immr->im_cpm.cp_pbdir |= 0x00005001; |
| 389 | #else |
| 390 | /* Enable LCD on port D. |
| 391 | */ |
| 392 | immr->im_ioport.iop_pdpar |= 0x1DFF; |
| 393 | immr->im_ioport.iop_pdpar &= ~0x0200; |
| 394 | immr->im_ioport.iop_pddir |= 0x1FFF; |
| 395 | immr->im_ioport.iop_pddat |= 0x0200; |
| 396 | #endif |
| 397 | |
| 398 | /* Load the physical address of the linear frame buffer |
| 399 | * into the LCD controller. |
| 400 | * BIG NOTE: This has to be modified to load A and B depending |
| 401 | * upon the split mode of the LCD. |
| 402 | */ |
| 403 | lcdp->lcd_lcfaa = (ulong)lcd_base; |
| 404 | lcdp->lcd_lcfba = (ulong)lcd_base; |
| 405 | |
| 406 | /* MORE HACKS...This must be updated according to 823 manual |
| 407 | * for different panels. |
wdenk | 682011f | 2003-06-03 23:54:09 +0000 | [diff] [blame] | 408 | * Udi Finkelstein - done - see below: |
| 409 | * Note: You better not try unsupported combinations such as |
| 410 | * 4-bit wide passive dual scan LCD at 4/8 Bit color. |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 411 | */ |
wdenk | 682011f | 2003-06-03 23:54:09 +0000 | [diff] [blame] | 412 | lchcr_hpc_tmp = |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 413 | (panel_info.vl_col * |
wdenk | 682011f | 2003-06-03 23:54:09 +0000 | [diff] [blame] | 414 | (panel_info.vl_tft ? 8 : |
| 415 | (((2 - panel_info.vl_lbw) << /* 4 bit=2, 8-bit = 1 */ |
| 416 | /* use << to mult by: single scan = 1, dual scan = 2 */ |
| 417 | panel_info.vl_splt) * |
| 418 | (panel_info.vl_bpix | 1)))) >> 3; /* 2/4 BPP = 1, 8/16 BPP = 3 */ |
| 419 | |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 420 | lcdp->lcd_lchcr = LCHCR_BO | |
| 421 | LCDBIT (LCHCR_AT_BIT, 4) | |
wdenk | 682011f | 2003-06-03 23:54:09 +0000 | [diff] [blame] | 422 | LCDBIT (LCHCR_HPC_BIT, lchcr_hpc_tmp) | |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 423 | panel_info.vl_wbl; |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 424 | |
| 425 | lcdp->lcd_lcvcr = LCDBIT (LCVCR_VPW_BIT, panel_info.vl_vpw) | |
| 426 | LCDBIT (LCVCR_LCD_AC_BIT, panel_info.vl_lcdac) | |
| 427 | LCDBIT (LCVCR_VPC_BIT, panel_info.vl_row) | |
| 428 | panel_info.vl_wbf; |
| 429 | |
| 430 | } |
| 431 | |
| 432 | /*----------------------------------------------------------------------*/ |
| 433 | |
| 434 | #ifdef NOT_USED_SO_FAR |
| 435 | static void |
| 436 | lcd_getcolreg (ushort regno, ushort *red, ushort *green, ushort *blue) |
| 437 | { |
| 438 | volatile immap_t *immr = (immap_t *) CFG_IMMR; |
| 439 | volatile cpm8xx_t *cp = &(immr->im_cpm); |
| 440 | unsigned short colreg, *cmap_ptr; |
| 441 | |
| 442 | cmap_ptr = (unsigned short *)&cp->lcd_cmap[regno * 2]; |
| 443 | |
| 444 | colreg = *cmap_ptr; |
| 445 | #ifdef CFG_INVERT_COLORS |
| 446 | colreg ^= 0x0FFF; |
| 447 | #endif |
| 448 | |
| 449 | *red = (colreg >> 8) & 0x0F; |
| 450 | *green = (colreg >> 4) & 0x0F; |
| 451 | *blue = colreg & 0x0F; |
| 452 | } |
| 453 | #endif /* NOT_USED_SO_FAR */ |
| 454 | |
| 455 | /*----------------------------------------------------------------------*/ |
| 456 | |
| 457 | #if LCD_BPP == LCD_COLOR8 |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame^] | 458 | void |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 459 | lcd_setcolreg (ushort regno, ushort red, ushort green, ushort blue) |
| 460 | { |
| 461 | volatile immap_t *immr = (immap_t *) CFG_IMMR; |
| 462 | volatile cpm8xx_t *cp = &(immr->im_cpm); |
| 463 | unsigned short colreg, *cmap_ptr; |
| 464 | |
| 465 | cmap_ptr = (unsigned short *)&cp->lcd_cmap[regno * 2]; |
| 466 | |
| 467 | colreg = ((red & 0x0F) << 8) | |
| 468 | ((green & 0x0F) << 4) | |
| 469 | (blue & 0x0F) ; |
| 470 | #ifdef CFG_INVERT_COLORS |
| 471 | colreg ^= 0x0FFF; |
| 472 | #endif |
| 473 | *cmap_ptr = colreg; |
| 474 | |
| 475 | debug ("setcolreg: reg %2d @ %p: R=%02X G=%02X B=%02X => %02X%02X\n", |
| 476 | regno, &(cp->lcd_cmap[regno * 2]), |
| 477 | red, green, blue, |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 478 | cp->lcd_cmap[ regno * 2 ], cp->lcd_cmap[(regno * 2) + 1]); |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 479 | } |
| 480 | #endif /* LCD_COLOR8 */ |
| 481 | |
| 482 | /*----------------------------------------------------------------------*/ |
| 483 | |
| 484 | #if LCD_BPP == LCD_MONOCHROME |
| 485 | static |
| 486 | void lcd_initcolregs (void) |
| 487 | { |
| 488 | volatile immap_t *immr = (immap_t *) CFG_IMMR; |
| 489 | volatile cpm8xx_t *cp = &(immr->im_cpm); |
| 490 | ushort regno; |
| 491 | |
| 492 | for (regno = 0; regno < 16; regno++) { |
| 493 | cp->lcd_cmap[regno * 2] = 0; |
| 494 | cp->lcd_cmap[(regno * 2) + 1] = regno & 0x0f; |
| 495 | } |
| 496 | } |
| 497 | #endif |
| 498 | |
| 499 | /*----------------------------------------------------------------------*/ |
| 500 | |
wdenk | 8655b6f | 2004-10-09 23:25:58 +0000 | [diff] [blame^] | 501 | void lcd_enable (void) |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 502 | { |
| 503 | volatile immap_t *immr = (immap_t *) CFG_IMMR; |
| 504 | volatile lcd823_t *lcdp = &immr->im_lcd; |
| 505 | |
| 506 | /* Enable the LCD panel */ |
wdenk | 682011f | 2003-06-03 23:54:09 +0000 | [diff] [blame] | 507 | #ifndef CONFIG_RBC823 |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 508 | immr->im_siu_conf.sc_sdcr |= (1 << (31 - 25)); /* LAM = 1 */ |
wdenk | 682011f | 2003-06-03 23:54:09 +0000 | [diff] [blame] | 509 | #endif |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 510 | lcdp->lcd_lccr |= LCCR_PON; |
wdenk | 608c914 | 2003-01-13 23:54:46 +0000 | [diff] [blame] | 511 | |
| 512 | #ifdef CONFIG_V37 |
| 513 | /* Turn on display backlight */ |
| 514 | immr->im_cpm.cp_pbpar |= 0x00008000; |
| 515 | immr->im_cpm.cp_pbdir |= 0x00008000; |
wdenk | 682011f | 2003-06-03 23:54:09 +0000 | [diff] [blame] | 516 | #elif defined(CONFIG_RBC823) |
| 517 | /* Turn on display backlight */ |
| 518 | immr->im_cpm.cp_pbdat |= 0x00004000; |
wdenk | 608c914 | 2003-01-13 23:54:46 +0000 | [diff] [blame] | 519 | #endif |
| 520 | |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 521 | #if defined(CONFIG_LWMON) |
| 522 | { uchar c = pic_read (0x60); |
wdenk | 4532cb6 | 2003-04-27 22:52:51 +0000 | [diff] [blame] | 523 | #if defined(CONFIG_LCD) && defined(CONFIG_LWMON) && (CONFIG_POST & CFG_POST_SYSMON) |
wdenk | 7d7ce41 | 2004-03-17 01:13:07 +0000 | [diff] [blame] | 524 | /* Enable LCD later in sysmon test, only if temperature is OK */ |
wdenk | 4532cb6 | 2003-04-27 22:52:51 +0000 | [diff] [blame] | 525 | #else |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 526 | c |= 0x07; /* Power on CCFL, Enable CCFL, Chip Enable LCD */ |
wdenk | 4532cb6 | 2003-04-27 22:52:51 +0000 | [diff] [blame] | 527 | #endif |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 528 | pic_write (0x60, c); |
| 529 | } |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 530 | #endif /* CONFIG_LWMON */ |
wdenk | 4a6fd34 | 2003-04-12 23:38:12 +0000 | [diff] [blame] | 531 | |
| 532 | #if defined(CONFIG_R360MPI) |
| 533 | { |
| 534 | extern void r360_i2c_lcd_write (uchar data0, uchar data1); |
wdenk | cb4dbb7 | 2003-07-16 16:40:22 +0000 | [diff] [blame] | 535 | unsigned long bgi, ctr; |
| 536 | char *p; |
| 537 | |
| 538 | if ((p = getenv("lcdbgi")) != NULL) { |
| 539 | bgi = simple_strtoul (p, 0, 10) & 0xFFF; |
| 540 | } else { |
| 541 | bgi = 0xFFF; |
| 542 | } |
| 543 | |
| 544 | if ((p = getenv("lcdctr")) != NULL) { |
| 545 | ctr = simple_strtoul (p, 0, 10) & 0xFFF; |
| 546 | } else { |
| 547 | ctr=0x7FF; |
| 548 | } |
wdenk | 4a6fd34 | 2003-04-12 23:38:12 +0000 | [diff] [blame] | 549 | |
| 550 | r360_i2c_lcd_write(0x10, 0x01); |
| 551 | r360_i2c_lcd_write(0x20, 0x01); |
wdenk | cb4dbb7 | 2003-07-16 16:40:22 +0000 | [diff] [blame] | 552 | r360_i2c_lcd_write(0x30 | ((bgi>>8) & 0xF), bgi & 0xFF); |
| 553 | r360_i2c_lcd_write(0x40 | ((ctr>>8) & 0xF), ctr & 0xFF); |
wdenk | 4a6fd34 | 2003-04-12 23:38:12 +0000 | [diff] [blame] | 554 | } |
| 555 | #endif /* CONFIG_R360MPI */ |
wdenk | 682011f | 2003-06-03 23:54:09 +0000 | [diff] [blame] | 556 | #ifdef CONFIG_RBC823 |
| 557 | udelay(200000); /* wait 200ms */ |
| 558 | /* Turn VEE_ON first */ |
| 559 | immr->im_cpm.cp_pbdat |= 0x00000001; |
| 560 | udelay(200000); /* wait 200ms */ |
| 561 | /* Now turn on LCD_ON */ |
| 562 | immr->im_cpm.cp_pbdat |= 0x00001000; |
| 563 | #endif |
wdenk | 8564acf | 2003-07-14 22:13:32 +0000 | [diff] [blame] | 564 | #ifdef CONFIG_RRVISION |
| 565 | debug ("PC4->Output(1): enable LVDS\n"); |
| 566 | debug ("PC5->Output(0): disable PAL clock\n"); |
| 567 | immr->im_ioport.iop_pddir |= 0x1000; |
| 568 | immr->im_ioport.iop_pcpar &= ~(0x0C00); |
| 569 | immr->im_ioport.iop_pcdir |= 0x0C00 ; |
| 570 | immr->im_ioport.iop_pcdat |= 0x0800 ; |
| 571 | immr->im_ioport.iop_pcdat &= ~(0x0400); |
| 572 | debug ("PDPAR=0x%04X PDDIR=0x%04X PDDAT=0x%04X\n", |
| 573 | immr->im_ioport.iop_pdpar, |
| 574 | immr->im_ioport.iop_pddir, |
| 575 | immr->im_ioport.iop_pddat); |
| 576 | debug ("PCPAR=0x%04X PCDIR=0x%04X PCDAT=0x%04X\n", |
| 577 | immr->im_ioport.iop_pcpar, |
| 578 | immr->im_ioport.iop_pcdir, |
| 579 | immr->im_ioport.iop_pcdat); |
| 580 | #endif |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 581 | } |
| 582 | |
| 583 | /*----------------------------------------------------------------------*/ |
| 584 | |
wdenk | 682011f | 2003-06-03 23:54:09 +0000 | [diff] [blame] | 585 | #if defined (CONFIG_RBC823) |
| 586 | void lcd_disable (void) |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 587 | { |
| 588 | volatile immap_t *immr = (immap_t *) CFG_IMMR; |
| 589 | volatile lcd823_t *lcdp = &immr->im_lcd; |
| 590 | |
| 591 | #if defined(CONFIG_LWMON) |
| 592 | { uchar c = pic_read (0x60); |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 593 | c &= ~0x07; /* Power off CCFL, Disable CCFL, Chip Disable LCD */ |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 594 | pic_write (0x60, c); |
| 595 | } |
| 596 | #elif defined(CONFIG_R360MPI) |
| 597 | { |
wdenk | 4a6fd34 | 2003-04-12 23:38:12 +0000 | [diff] [blame] | 598 | extern void r360_i2c_lcd_write (uchar data0, uchar data1); |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 599 | |
wdenk | 4a6fd34 | 2003-04-12 23:38:12 +0000 | [diff] [blame] | 600 | r360_i2c_lcd_write(0x10, 0x00); |
| 601 | r360_i2c_lcd_write(0x20, 0x00); |
| 602 | r360_i2c_lcd_write(0x30, 0x00); |
| 603 | r360_i2c_lcd_write(0x40, 0x00); |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 604 | } |
| 605 | #endif /* CONFIG_LWMON */ |
| 606 | /* Disable the LCD panel */ |
| 607 | lcdp->lcd_lccr &= ~LCCR_PON; |
wdenk | 682011f | 2003-06-03 23:54:09 +0000 | [diff] [blame] | 608 | #ifdef CONFIG_RBC823 |
| 609 | /* Turn off display backlight, VEE and LCD_ON */ |
| 610 | immr->im_cpm.cp_pbdat &= ~0x00005001; |
| 611 | #else |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 612 | immr->im_siu_conf.sc_sdcr &= ~(1 << (31 - 25)); /* LAM = 0 */ |
wdenk | 682011f | 2003-06-03 23:54:09 +0000 | [diff] [blame] | 613 | #endif /* CONFIG_RBC823 */ |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 614 | } |
wdenk | 682011f | 2003-06-03 23:54:09 +0000 | [diff] [blame] | 615 | #endif /* NOT_USED_SO_FAR || CONFIG_RBC823 */ |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 616 | |
| 617 | |
| 618 | /************************************************************************/ |
wdenk | 5b1d713 | 2002-11-03 00:07:02 +0000 | [diff] [blame] | 619 | |
| 620 | #endif /* CONFIG_LCD */ |