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