stroese | 56b9e4f | 2004-12-16 18:43:13 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2003-2004 |
| 3 | * Stefan Roese, esd gmbh germany, stefan.roese@esd-electronics.com |
| 4 | * |
Stefan Roese | d9d9774 | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 5 | * (C) Copyright 2005 |
| 6 | * Stefan Roese, DENX Software Engineering, sr@denx.de. |
| 7 | * |
stroese | 56b9e4f | 2004-12-16 18:43:13 +0000 | [diff] [blame] | 8 | * See file CREDITS for list of people who contributed to this |
| 9 | * project. |
| 10 | * |
| 11 | * This program is free software; you can redistribute it and/or |
| 12 | * modify it under the terms of the GNU General Public License as |
| 13 | * published by the Free Software Foundation; either version 2 of |
| 14 | * the License, or (at your option) any later version. |
| 15 | * |
| 16 | * This program is distributed in the hope that it will be useful, |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | * GNU General Public License for more details. |
| 20 | * |
| 21 | * You should have received a copy of the GNU General Public License |
| 22 | * along with this program; if not, write to the Free Software |
| 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 24 | * MA 02111-1307 USA |
| 25 | */ |
| 26 | |
Matthias Fuchs | b99514d | 2007-12-28 17:10:44 +0100 | [diff] [blame] | 27 | #include "asm/io.h" |
stroese | 56b9e4f | 2004-12-16 18:43:13 +0000 | [diff] [blame] | 28 | #include "lcd.h" |
| 29 | |
Stefan Roese | d9d9774 | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 30 | |
| 31 | extern int video_display_bitmap (ulong, int, int); |
| 32 | |
stroese | 56b9e4f | 2004-12-16 18:43:13 +0000 | [diff] [blame] | 33 | |
| 34 | int palette_index; |
| 35 | int palette_value; |
Stefan Roese | d9d9774 | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 36 | int lcd_depth; |
| 37 | unsigned char *glob_lcd_reg; |
| 38 | unsigned char *glob_lcd_mem; |
stroese | 56b9e4f | 2004-12-16 18:43:13 +0000 | [diff] [blame] | 39 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 40 | #if defined(CONFIG_SYS_LCD_ENDIAN) |
stroese | 56b9e4f | 2004-12-16 18:43:13 +0000 | [diff] [blame] | 41 | void lcd_setup(int lcd, int config) |
| 42 | { |
| 43 | if (lcd == 0) { |
| 44 | /* |
| 45 | * Set endianess and reset lcd controller 0 (small) |
| 46 | */ |
Matthias Fuchs | d8b5223 | 2008-04-21 14:41:59 +0200 | [diff] [blame] | 47 | |
| 48 | /* set reset to low */ |
| 49 | out_be32((void*)GPIO0_OR, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 50 | in_be32((void*)GPIO0_OR) & ~CONFIG_SYS_LCD0_RST); |
stroese | 56b9e4f | 2004-12-16 18:43:13 +0000 | [diff] [blame] | 51 | udelay(10); /* wait 10us */ |
Matthias Fuchs | d8b5223 | 2008-04-21 14:41:59 +0200 | [diff] [blame] | 52 | if (config == 1) { |
| 53 | /* big-endian */ |
| 54 | out_be32((void*)GPIO0_OR, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 55 | in_be32((void*)GPIO0_OR) | CONFIG_SYS_LCD_ENDIAN); |
Matthias Fuchs | d8b5223 | 2008-04-21 14:41:59 +0200 | [diff] [blame] | 56 | } else { |
| 57 | /* little-endian */ |
| 58 | out_be32((void*)GPIO0_OR, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 59 | in_be32((void*)GPIO0_OR) & ~CONFIG_SYS_LCD_ENDIAN); |
Matthias Fuchs | d8b5223 | 2008-04-21 14:41:59 +0200 | [diff] [blame] | 60 | } |
stroese | 56b9e4f | 2004-12-16 18:43:13 +0000 | [diff] [blame] | 61 | udelay(10); /* wait 10us */ |
Matthias Fuchs | d8b5223 | 2008-04-21 14:41:59 +0200 | [diff] [blame] | 62 | /* set reset to high */ |
| 63 | out_be32((void*)GPIO0_OR, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 64 | in_be32((void*)GPIO0_OR) | CONFIG_SYS_LCD0_RST); |
stroese | 56b9e4f | 2004-12-16 18:43:13 +0000 | [diff] [blame] | 65 | } else { |
| 66 | /* |
| 67 | * Set endianess and reset lcd controller 1 (big) |
| 68 | */ |
Matthias Fuchs | d8b5223 | 2008-04-21 14:41:59 +0200 | [diff] [blame] | 69 | |
| 70 | /* set reset to low */ |
| 71 | out_be32((void*)GPIO0_OR, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 72 | in_be32((void*)GPIO0_OR) & ~CONFIG_SYS_LCD1_RST); |
stroese | 56b9e4f | 2004-12-16 18:43:13 +0000 | [diff] [blame] | 73 | udelay(10); /* wait 10us */ |
Matthias Fuchs | d8b5223 | 2008-04-21 14:41:59 +0200 | [diff] [blame] | 74 | if (config == 1) { |
| 75 | /* big-endian */ |
| 76 | out_be32((void*)GPIO0_OR, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 77 | in_be32((void*)GPIO0_OR) | CONFIG_SYS_LCD_ENDIAN); |
Matthias Fuchs | d8b5223 | 2008-04-21 14:41:59 +0200 | [diff] [blame] | 78 | } else { |
| 79 | /* little-endian */ |
| 80 | out_be32((void*)GPIO0_OR, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 81 | in_be32((void*)GPIO0_OR) & ~CONFIG_SYS_LCD_ENDIAN); |
Matthias Fuchs | d8b5223 | 2008-04-21 14:41:59 +0200 | [diff] [blame] | 82 | } |
stroese | 56b9e4f | 2004-12-16 18:43:13 +0000 | [diff] [blame] | 83 | udelay(10); /* wait 10us */ |
Matthias Fuchs | d8b5223 | 2008-04-21 14:41:59 +0200 | [diff] [blame] | 84 | /* set reset to high */ |
| 85 | out_be32((void*)GPIO0_OR, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 86 | in_be32((void*)GPIO0_OR) | CONFIG_SYS_LCD1_RST); |
stroese | 56b9e4f | 2004-12-16 18:43:13 +0000 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | /* |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 90 | * CONFIG_SYS_LCD_ENDIAN may also be FPGA_RESET, so set inactive |
stroese | 56b9e4f | 2004-12-16 18:43:13 +0000 | [diff] [blame] | 91 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 92 | out_be32((void*)GPIO0_OR, in_be32((void*)GPIO0_OR) | CONFIG_SYS_LCD_ENDIAN); |
stroese | 56b9e4f | 2004-12-16 18:43:13 +0000 | [diff] [blame] | 93 | } |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 94 | #endif /* CONFIG_SYS_LCD_ENDIAN */ |
stroese | 56b9e4f | 2004-12-16 18:43:13 +0000 | [diff] [blame] | 95 | |
| 96 | |
Matthias Fuchs | d8b5223 | 2008-04-21 14:41:59 +0200 | [diff] [blame] | 97 | int lcd_bmp(uchar *logo_bmp) |
stroese | 56b9e4f | 2004-12-16 18:43:13 +0000 | [diff] [blame] | 98 | { |
| 99 | int i; |
stroese | 56b9e4f | 2004-12-16 18:43:13 +0000 | [diff] [blame] | 100 | uchar *ptr; |
| 101 | ushort *ptr2; |
| 102 | ushort val; |
Stefan Roese | 13b9369 | 2005-10-08 10:19:07 +0200 | [diff] [blame] | 103 | unsigned char *dst = NULL; |
stroese | 56b9e4f | 2004-12-16 18:43:13 +0000 | [diff] [blame] | 104 | int x, y; |
| 105 | int width, height, bpp, colors, line_size; |
| 106 | int header_size; |
| 107 | unsigned char *bmp; |
| 108 | unsigned char r, g, b; |
| 109 | BITMAPINFOHEADER *bm_info; |
Stefan Roese | d9d9774 | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 110 | ulong len; |
stroese | 56b9e4f | 2004-12-16 18:43:13 +0000 | [diff] [blame] | 111 | |
| 112 | /* |
Stefan Roese | d9d9774 | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 113 | * Check for bmp mark 'BM' |
stroese | 56b9e4f | 2004-12-16 18:43:13 +0000 | [diff] [blame] | 114 | */ |
Stefan Roese | d9d9774 | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 115 | if (*(ushort *)logo_bmp != 0x424d) { |
stroese | 56b9e4f | 2004-12-16 18:43:13 +0000 | [diff] [blame] | 116 | /* |
Stefan Roese | d9d9774 | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 117 | * Decompress bmp image |
stroese | 56b9e4f | 2004-12-16 18:43:13 +0000 | [diff] [blame] | 118 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 119 | len = CONFIG_SYS_VIDEO_LOGO_MAX_SIZE; |
| 120 | dst = malloc(CONFIG_SYS_VIDEO_LOGO_MAX_SIZE); |
Stefan Roese | 13b9369 | 2005-10-08 10:19:07 +0200 | [diff] [blame] | 121 | if (dst == NULL) { |
Matthias Fuchs | d8b5223 | 2008-04-21 14:41:59 +0200 | [diff] [blame] | 122 | printf("Error: malloc for gunzip failed!\n"); |
| 123 | return 1; |
| 124 | } |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 125 | if (gunzip(dst, CONFIG_SYS_VIDEO_LOGO_MAX_SIZE, |
Matthias Fuchs | d8b5223 | 2008-04-21 14:41:59 +0200 | [diff] [blame] | 126 | (uchar *)logo_bmp, &len) != 0) { |
| 127 | free(dst); |
| 128 | return 1; |
| 129 | } |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 130 | if (len == CONFIG_SYS_VIDEO_LOGO_MAX_SIZE) { |
Matthias Fuchs | d8b5223 | 2008-04-21 14:41:59 +0200 | [diff] [blame] | 131 | printf("Image could be truncated" |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 132 | " (increase CONFIG_SYS_VIDEO_LOGO_MAX_SIZE)!\n"); |
Stefan Roese | d9d9774 | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 133 | } |
| 134 | |
stroese | 56b9e4f | 2004-12-16 18:43:13 +0000 | [diff] [blame] | 135 | /* |
Stefan Roese | d9d9774 | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 136 | * Check for bmp mark 'BM' |
stroese | 56b9e4f | 2004-12-16 18:43:13 +0000 | [diff] [blame] | 137 | */ |
Stefan Roese | d9d9774 | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 138 | if (*(ushort *)dst != 0x424d) { |
| 139 | printf("LCD: Unknown image format!\n"); |
| 140 | free(dst); |
Matthias Fuchs | d8b5223 | 2008-04-21 14:41:59 +0200 | [diff] [blame] | 141 | return 1; |
Stefan Roese | d9d9774 | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 142 | } |
| 143 | } else { |
stroese | 56b9e4f | 2004-12-16 18:43:13 +0000 | [diff] [blame] | 144 | /* |
Stefan Roese | d9d9774 | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 145 | * Uncompressed BMP image, just use this pointer |
stroese | 56b9e4f | 2004-12-16 18:43:13 +0000 | [diff] [blame] | 146 | */ |
Stefan Roese | d9d9774 | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 147 | dst = (uchar *)logo_bmp; |
wdenk | 07d7e6b | 2004-12-16 21:44:03 +0000 | [diff] [blame] | 148 | } |
stroese | 56b9e4f | 2004-12-16 18:43:13 +0000 | [diff] [blame] | 149 | |
| 150 | /* |
stroese | 56b9e4f | 2004-12-16 18:43:13 +0000 | [diff] [blame] | 151 | * Get image info from bmp-header |
| 152 | */ |
| 153 | bm_info = (BITMAPINFOHEADER *)(dst + 14); |
| 154 | bpp = LOAD_SHORT(bm_info->biBitCount); |
| 155 | width = LOAD_LONG(bm_info->biWidth); |
| 156 | height = LOAD_LONG(bm_info->biHeight); |
| 157 | switch (bpp) { |
| 158 | case 1: |
| 159 | colors = 1; |
| 160 | line_size = width >> 3; |
| 161 | break; |
| 162 | case 4: |
| 163 | colors = 16; |
| 164 | line_size = width >> 1; |
| 165 | break; |
| 166 | case 8: |
| 167 | colors = 256; |
| 168 | line_size = width; |
| 169 | break; |
| 170 | case 24: |
| 171 | colors = 0; |
| 172 | line_size = width * 3; |
| 173 | break; |
| 174 | default: |
| 175 | printf("LCD: Unknown bpp (%d) im image!\n", bpp); |
Stefan Roese | 2689862 | 2007-12-28 17:29:56 +0100 | [diff] [blame] | 176 | if ((dst != NULL) && (dst != (uchar *)logo_bmp)) |
Stefan Roese | 13b9369 | 2005-10-08 10:19:07 +0200 | [diff] [blame] | 177 | free(dst); |
Matthias Fuchs | d8b5223 | 2008-04-21 14:41:59 +0200 | [diff] [blame] | 178 | return 1; |
stroese | 56b9e4f | 2004-12-16 18:43:13 +0000 | [diff] [blame] | 179 | } |
| 180 | printf(" (%d*%d, %dbpp)\n", width, height, bpp); |
| 181 | |
| 182 | /* |
| 183 | * Write color palette |
| 184 | */ |
Stefan Roese | d9d9774 | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 185 | if ((colors <= 256) && (lcd_depth <= 8)) { |
stroese | 56b9e4f | 2004-12-16 18:43:13 +0000 | [diff] [blame] | 186 | ptr = (unsigned char *)(dst + 14 + 40); |
Matthias Fuchs | e83a391 | 2008-01-02 12:05:14 +0100 | [diff] [blame] | 187 | for (i = 0; i < colors; i++) { |
stroese | 56b9e4f | 2004-12-16 18:43:13 +0000 | [diff] [blame] | 188 | b = *ptr++; |
| 189 | g = *ptr++; |
| 190 | r = *ptr++; |
| 191 | ptr++; |
Stefan Roese | d9d9774 | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 192 | S1D_WRITE_PALETTE(glob_lcd_reg, i, r, g, b); |
stroese | 56b9e4f | 2004-12-16 18:43:13 +0000 | [diff] [blame] | 193 | } |
| 194 | } |
| 195 | |
| 196 | /* |
| 197 | * Write bitmap data into framebuffer |
| 198 | */ |
Stefan Roese | d9d9774 | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 199 | ptr = glob_lcd_mem; |
| 200 | ptr2 = (ushort *)glob_lcd_mem; |
stroese | 56b9e4f | 2004-12-16 18:43:13 +0000 | [diff] [blame] | 201 | header_size = 14 + 40 + 4*colors; /* skip bmp header */ |
Matthias Fuchs | e83a391 | 2008-01-02 12:05:14 +0100 | [diff] [blame] | 202 | for (y = 0; y < height; y++) { |
stroese | 56b9e4f | 2004-12-16 18:43:13 +0000 | [diff] [blame] | 203 | bmp = &dst[(height-1-y)*line_size + header_size]; |
Stefan Roese | d9d9774 | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 204 | if (lcd_depth == 16) { |
| 205 | if (bpp == 24) { |
Matthias Fuchs | e83a391 | 2008-01-02 12:05:14 +0100 | [diff] [blame] | 206 | for (x = 0; x < width; x++) { |
Stefan Roese | d9d9774 | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 207 | /* |
Matthias Fuchs | d8b5223 | 2008-04-21 14:41:59 +0200 | [diff] [blame] | 208 | * Generate epson 16bpp fb-format |
| 209 | * from 24bpp image |
Stefan Roese | d9d9774 | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 210 | */ |
| 211 | b = *bmp++ >> 3; |
| 212 | g = *bmp++ >> 2; |
| 213 | r = *bmp++ >> 3; |
Matthias Fuchs | d8b5223 | 2008-04-21 14:41:59 +0200 | [diff] [blame] | 214 | val = ((r & 0x1f) << 11) | |
| 215 | ((g & 0x3f) << 5) | |
| 216 | (b & 0x1f); |
Stefan Roese | d9d9774 | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 217 | *ptr2++ = val; |
| 218 | } |
| 219 | } else if (bpp == 8) { |
Matthias Fuchs | e83a391 | 2008-01-02 12:05:14 +0100 | [diff] [blame] | 220 | for (x = 0; x < line_size; x++) { |
Stefan Roese | d9d9774 | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 221 | /* query rgb value from palette */ |
Matthias Fuchs | d8b5223 | 2008-04-21 14:41:59 +0200 | [diff] [blame] | 222 | ptr = (unsigned char *)(dst + 14 + 40); |
Stefan Roese | d9d9774 | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 223 | ptr += (*bmp++) << 2; |
| 224 | b = *ptr++ >> 3; |
| 225 | g = *ptr++ >> 2; |
| 226 | r = *ptr++ >> 3; |
Matthias Fuchs | d8b5223 | 2008-04-21 14:41:59 +0200 | [diff] [blame] | 227 | val = ((r & 0x1f) << 11) | |
| 228 | ((g & 0x3f) << 5) | |
| 229 | (b & 0x1f); |
Stefan Roese | d9d9774 | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 230 | *ptr2++ = val; |
| 231 | } |
stroese | 56b9e4f | 2004-12-16 18:43:13 +0000 | [diff] [blame] | 232 | } |
| 233 | } else { |
Matthias Fuchs | e83a391 | 2008-01-02 12:05:14 +0100 | [diff] [blame] | 234 | for (x = 0; x < line_size; x++) |
stroese | 56b9e4f | 2004-12-16 18:43:13 +0000 | [diff] [blame] | 235 | *ptr++ = *bmp++; |
stroese | 56b9e4f | 2004-12-16 18:43:13 +0000 | [diff] [blame] | 236 | } |
Stefan Roese | d9d9774 | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 237 | } |
| 238 | |
Stefan Roese | 2689862 | 2007-12-28 17:29:56 +0100 | [diff] [blame] | 239 | if ((dst != NULL) && (dst != (uchar *)logo_bmp)) |
Stefan Roese | d9d9774 | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 240 | free(dst); |
Matthias Fuchs | d8b5223 | 2008-04-21 14:41:59 +0200 | [diff] [blame] | 241 | return 0; |
Stefan Roese | d9d9774 | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 242 | } |
| 243 | |
| 244 | |
Matthias Fuchs | d8b5223 | 2008-04-21 14:41:59 +0200 | [diff] [blame] | 245 | int lcd_init(uchar *lcd_reg, uchar *lcd_mem, S1D_REGS *regs, int reg_count, |
| 246 | uchar *logo_bmp, ulong len) |
Stefan Roese | d9d9774 | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 247 | { |
| 248 | int i; |
| 249 | ushort s1dReg; |
| 250 | uchar s1dValue; |
| 251 | int reg_byte_swap; |
| 252 | |
| 253 | /* |
| 254 | * Detect epson |
| 255 | */ |
Matthias Fuchs | b99514d | 2007-12-28 17:10:44 +0100 | [diff] [blame] | 256 | out_8(&lcd_reg[0], 0x00); |
| 257 | out_8(&lcd_reg[1], 0x00); |
Stefan Roese | e10e85e | 2006-02-07 16:51:04 +0100 | [diff] [blame] | 258 | |
Stefan Roese | 2689862 | 2007-12-28 17:29:56 +0100 | [diff] [blame] | 259 | if (in_8(&lcd_reg[0]) == 0x1c) { |
Stefan Roese | d9d9774 | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 260 | /* |
| 261 | * Big epson detected |
| 262 | */ |
York Sun | 4a59809 | 2013-04-01 11:29:11 -0700 | [diff] [blame] | 263 | reg_byte_swap = false; |
Stefan Roese | d9d9774 | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 264 | palette_index = 0x1e2; |
| 265 | palette_value = 0x1e4; |
| 266 | lcd_depth = 16; |
| 267 | puts("LCD: S1D13806"); |
Stefan Roese | 2689862 | 2007-12-28 17:29:56 +0100 | [diff] [blame] | 268 | } else if (in_8(&lcd_reg[1]) == 0x1c) { |
Stefan Roese | d9d9774 | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 269 | /* |
| 270 | * Big epson detected (with register swap bug) |
| 271 | */ |
York Sun | 4a59809 | 2013-04-01 11:29:11 -0700 | [diff] [blame] | 272 | reg_byte_swap = true; |
Stefan Roese | d9d9774 | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 273 | palette_index = 0x1e3; |
| 274 | palette_value = 0x1e5; |
| 275 | lcd_depth = 16; |
| 276 | puts("LCD: S1D13806S"); |
Stefan Roese | 2689862 | 2007-12-28 17:29:56 +0100 | [diff] [blame] | 277 | } else if (in_8(&lcd_reg[0]) == 0x18) { |
Stefan Roese | d9d9774 | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 278 | /* |
| 279 | * Small epson detected (704) |
| 280 | */ |
York Sun | 4a59809 | 2013-04-01 11:29:11 -0700 | [diff] [blame] | 281 | reg_byte_swap = false; |
Stefan Roese | d9d9774 | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 282 | palette_index = 0x15; |
| 283 | palette_value = 0x17; |
| 284 | lcd_depth = 8; |
| 285 | puts("LCD: S1D13704"); |
Matthias Fuchs | e83a391 | 2008-01-02 12:05:14 +0100 | [diff] [blame] | 286 | } else if (in_8(&lcd_reg[0x10000]) == 0x24) { |
Stefan Roese | d9d9774 | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 287 | /* |
| 288 | * Small epson detected (705) |
| 289 | */ |
York Sun | 4a59809 | 2013-04-01 11:29:11 -0700 | [diff] [blame] | 290 | reg_byte_swap = false; |
Stefan Roese | d9d9774 | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 291 | palette_index = 0x15; |
| 292 | palette_value = 0x17; |
| 293 | lcd_depth = 8; |
| 294 | lcd_reg += 0x10000; /* add offset for 705 regs */ |
| 295 | puts("LCD: S1D13705"); |
| 296 | } else { |
Matthias Fuchs | d8b5223 | 2008-04-21 14:41:59 +0200 | [diff] [blame] | 297 | out_8(&lcd_reg[0x1a], 0x00); |
| 298 | udelay(1000); |
| 299 | if (in_8(&lcd_reg[1]) == 0x0c) { |
| 300 | /* |
| 301 | * S1D13505 detected |
| 302 | */ |
York Sun | 4a59809 | 2013-04-01 11:29:11 -0700 | [diff] [blame] | 303 | reg_byte_swap = true; |
Matthias Fuchs | d8b5223 | 2008-04-21 14:41:59 +0200 | [diff] [blame] | 304 | palette_index = 0x25; |
| 305 | palette_value = 0x27; |
| 306 | lcd_depth = 16; |
| 307 | |
| 308 | puts("LCD: S1D13505"); |
| 309 | } else { |
| 310 | puts("LCD: No controller detected!\n"); |
| 311 | return 1; |
| 312 | } |
Stefan Roese | d9d9774 | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 313 | } |
| 314 | |
| 315 | /* |
| 316 | * Setup lcd controller regs |
| 317 | */ |
Matthias Fuchs | b99514d | 2007-12-28 17:10:44 +0100 | [diff] [blame] | 318 | for (i = 0; i < reg_count; i++) { |
Stefan Roese | d9d9774 | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 319 | s1dReg = regs[i].Index; |
| 320 | if (reg_byte_swap) { |
| 321 | if ((s1dReg & 0x0001) == 0) |
| 322 | s1dReg |= 0x0001; |
| 323 | else |
| 324 | s1dReg &= ~0x0001; |
| 325 | } |
| 326 | s1dValue = regs[i].Value; |
Matthias Fuchs | d8b5223 | 2008-04-21 14:41:59 +0200 | [diff] [blame] | 327 | out_8(&lcd_reg[s1dReg], s1dValue); |
stroese | 56b9e4f | 2004-12-16 18:43:13 +0000 | [diff] [blame] | 328 | } |
| 329 | |
Stefan Roese | d9d9774 | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 330 | /* |
| 331 | * Save reg & mem pointer for later usage (e.g. bmp command) |
| 332 | */ |
| 333 | glob_lcd_reg = lcd_reg; |
| 334 | glob_lcd_mem = lcd_mem; |
| 335 | |
| 336 | /* |
| 337 | * Display bmp image |
| 338 | */ |
Matthias Fuchs | d8b5223 | 2008-04-21 14:41:59 +0200 | [diff] [blame] | 339 | return lcd_bmp(logo_bmp); |
stroese | 56b9e4f | 2004-12-16 18:43:13 +0000 | [diff] [blame] | 340 | } |
Stefan Roese | d9d9774 | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 341 | |
Wolfgang Denk | 6262d021 | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 342 | int do_esdbmp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
Stefan Roese | d9d9774 | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 343 | { |
| 344 | ulong addr; |
Matthias Fuchs | d8b5223 | 2008-04-21 14:41:59 +0200 | [diff] [blame] | 345 | #ifdef CONFIG_VIDEO_SM501 |
Stefan Roese | d9d9774 | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 346 | char *str; |
Matthias Fuchs | d8b5223 | 2008-04-21 14:41:59 +0200 | [diff] [blame] | 347 | #endif |
Wolfgang Denk | 3b68311 | 2010-07-17 01:06:04 +0200 | [diff] [blame] | 348 | if (argc != 2) |
| 349 | return cmd_usage(cmdtp); |
Stefan Roese | d9d9774 | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 350 | |
| 351 | addr = simple_strtoul(argv[1], NULL, 16); |
| 352 | |
Matthias Fuchs | d8b5223 | 2008-04-21 14:41:59 +0200 | [diff] [blame] | 353 | #ifdef CONFIG_VIDEO_SM501 |
Stefan Roese | d9d9774 | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 354 | str = getenv("bd_type"); |
| 355 | if ((strcmp(str, "ppc221") == 0) || (strcmp(str, "ppc231") == 0)) { |
| 356 | /* |
| 357 | * SM501 available, use standard bmp command |
| 358 | */ |
Matthias Fuchs | d8b5223 | 2008-04-21 14:41:59 +0200 | [diff] [blame] | 359 | return video_display_bitmap(addr, 0, 0); |
Stefan Roese | d9d9774 | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 360 | } else { |
| 361 | /* |
| 362 | * No SM501 available, use esd epson bmp command |
| 363 | */ |
Matthias Fuchs | d8b5223 | 2008-04-21 14:41:59 +0200 | [diff] [blame] | 364 | return lcd_bmp((uchar *)addr); |
Stefan Roese | d9d9774 | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 365 | } |
Matthias Fuchs | d8b5223 | 2008-04-21 14:41:59 +0200 | [diff] [blame] | 366 | #else |
| 367 | return lcd_bmp((uchar *)addr); |
| 368 | #endif |
Stefan Roese | d9d9774 | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 369 | } |
| 370 | |
| 371 | U_BOOT_CMD( |
| 372 | esdbmp, 2, 1, do_esdbmp, |
Peter Tyser | dfb72b8 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 373 | "display BMP image", |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 374 | "<imageAddr> - display image" |
Stefan Roese | d9d9774 | 2005-09-22 09:04:17 +0200 | [diff] [blame] | 375 | ); |