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