diff options
Diffstat (limited to 'board/esd/common')
-rw-r--r-- | board/esd/common/auto_update.c | 274 | ||||
-rw-r--r-- | board/esd/common/auto_update.h | 15 | ||||
-rw-r--r-- | board/esd/common/lcd.c | 123 | ||||
-rw-r--r-- | board/esd/common/s1d13505_640_480_16bpp.h | 65 |
4 files changed, 295 insertions, 182 deletions
diff --git a/board/esd/common/auto_update.c b/board/esd/common/auto_update.c index a76b00fe49..7e6eea0f1c 100644 --- a/board/esd/common/auto_update.c +++ b/board/esd/common/auto_update.c @@ -44,29 +44,16 @@ extern au_image_t au_image[]; extern int N_AU_IMAGES; -#define AU_DEBUG -#undef AU_DEBUG - -#undef debug -#ifdef AU_DEBUG -#define debug(fmt,args...) printf (fmt ,##args) -#else -#define debug(fmt,args...) -#endif /* AU_DEBUG */ - - -#define LOAD_ADDR ((unsigned char *)0x100000) /* where to load files into memory */ -#define MAX_LOADSZ 0x1e00000 +/* where to load files into memory */ +#define LOAD_ADDR ((unsigned char *)0x100000) +#define MAX_LOADSZ 0x1c00000 /* externals */ extern int fat_register_device(block_dev_desc_t *, int); extern int file_fat_detectfs(void); extern long file_fat_read(const char *, void *, unsigned long); -long do_fat_read (const char *filename, void *buffer, unsigned long maxsize, int dols); -#ifdef CONFIG_VFD -extern int trab_vfd (ulong); -extern int transfer_pic(unsigned char, unsigned char *, int, int); -#endif +long do_fat_read (const char *filename, void *buffer, + unsigned long maxsize, int dols); extern int flash_sect_erase(ulong, ulong); extern int flash_sect_protect (int, ulong, ulong); extern int flash_write (char *, ulong, ulong); @@ -78,105 +65,91 @@ extern int flash_write (char *, ulong, ulong); #define NANDRW_JFFS2 0x02 #define NANDRW_JFFS2_SKIP 0x04 extern struct nand_chip nand_dev_desc[]; -extern int nand_legacy_rw(struct nand_chip* nand, int cmd, size_t start, size_t len, - size_t * retlen, u_char * buf); -extern int nand_legacy_erase(struct nand_chip* nand, size_t ofs, size_t len, int clean); +extern int nand_legacy_rw(struct nand_chip* nand, int cmd, + size_t start, size_t len, + size_t * retlen, u_char * buf); +extern int nand_legacy_erase(struct nand_chip* nand, size_t ofs, + size_t len, int clean); #endif extern block_dev_desc_t ide_dev_desc[CFG_IDE_MAXDEVICE]; - int au_check_cksum_valid(int i, long nbytes) { image_header_t *hdr; - unsigned long checksum; hdr = (image_header_t *)LOAD_ADDR; +#if defined(CONFIG_FIT) + if (genimg_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) { + puts ("Non legacy image format not supported\n"); + return -1; + } +#endif - if ((au_image[i].type == AU_FIRMWARE) && (au_image[i].size != ntohl(hdr->ih_size))) { + if ((au_image[i].type == AU_FIRMWARE) && + (au_image[i].size != image_get_data_size (hdr))) { printf ("Image %s has wrong size\n", au_image[i].name); return -1; } - if (nbytes != (sizeof(*hdr) + ntohl(hdr->ih_size))) { + if (nbytes != (image_get_image_size (hdr))) { printf ("Image %s bad total SIZE\n", au_image[i].name); return -1; } - /* check the data CRC */ - checksum = ntohl(hdr->ih_dcrc); - if (crc32 (0, (uchar *)(LOAD_ADDR + sizeof(*hdr)), ntohl(hdr->ih_size)) - != checksum) { + /* check the data CRC */ + if (!image_check_dcrc (hdr)) { printf ("Image %s bad data checksum\n", au_image[i].name); return -1; } return 0; } - int au_check_header_valid(int i, long nbytes) { image_header_t *hdr; unsigned long checksum; hdr = (image_header_t *)LOAD_ADDR; - /* check the easy ones first */ -#undef CHECK_VALID_DEBUG -#ifdef CHECK_VALID_DEBUG - printf("magic %#x %#x ", ntohl(hdr->ih_magic), IH_MAGIC); - printf("arch %#x %#x ", hdr->ih_arch, IH_CPU_PPC); - printf("size %#x %#lx ", ntohl(hdr->ih_size), nbytes); - printf("type %#x %#x ", hdr->ih_type, IH_TYPE_KERNEL); +#if defined(CONFIG_FIT) + if (genimg_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) { + puts ("Non legacy image format not supported\n"); + return -1; + } #endif - if (nbytes < sizeof(*hdr)) - { + + /* check the easy ones first */ + if (nbytes < image_get_header_size ()) { printf ("Image %s bad header SIZE\n", au_image[i].name); return -1; } - if (ntohl(hdr->ih_magic) != IH_MAGIC || hdr->ih_arch != IH_CPU_PPC) - { + if (!image_check_magic (hdr) || !image_check_arch (hdr, IH_ARCH_PPC)) { printf ("Image %s bad MAGIC or ARCH\n", au_image[i].name); return -1; } - /* check the hdr CRC */ - checksum = ntohl(hdr->ih_hcrc); - hdr->ih_hcrc = 0; - - if (crc32 (0, (uchar *)hdr, sizeof(*hdr)) != checksum) { + if (!image_check_hcrc (hdr)) { printf ("Image %s bad header checksum\n", au_image[i].name); return -1; } - hdr->ih_hcrc = htonl(checksum); /* check the type - could do this all in one gigantic if() */ - if ((au_image[i].type == AU_FIRMWARE) && (hdr->ih_type != IH_TYPE_FIRMWARE)) { + if (((au_image[i].type & AU_TYPEMASK) == AU_FIRMWARE) && + !image_check_type (hdr, IH_TYPE_FIRMWARE)) { printf ("Image %s wrong type\n", au_image[i].name); return -1; } - if ((au_image[i].type == AU_SCRIPT) && (hdr->ih_type != IH_TYPE_SCRIPT)) { + if (((au_image[i].type & AU_TYPEMASK) == AU_SCRIPT) && + !image_check_type (hdr, IH_TYPE_SCRIPT)) { printf ("Image %s wrong type\n", au_image[i].name); return -1; } /* recycle checksum */ - checksum = ntohl(hdr->ih_size); - -#if 0 /* test-only */ - /* for kernel and app the image header must also fit into flash */ - if (idx != IDX_DISK) - checksum += sizeof(*hdr); - /* check the size does not exceed space in flash. HUSH scripts */ - /* all have ausize[] set to 0 */ - if ((ausize[idx] != 0) && (ausize[idx] < checksum)) { - printf ("Image %s is bigger than FLASH\n", au_image[i].name); - return -1; - } -#endif + checksum = image_get_data_size (hdr); return 0; } - int au_do_update(int i, long sz) { image_header_t *hdr; @@ -190,17 +163,23 @@ int au_do_update(int i, long sz) #endif hdr = (image_header_t *)LOAD_ADDR; +#if defined(CONFIG_FIT) + if (genimg_get_format ((void *)hdr) != IMAGE_FORMAT_LEGACY) { + puts ("Non legacy image format not supported\n"); + return -1; + } +#endif - switch (au_image[i].type) { + switch (au_image[i].type & AU_TYPEMASK) { case AU_SCRIPT: printf("Executing script %s\n", au_image[i].name); /* execute a script */ - if (hdr->ih_type == IH_TYPE_SCRIPT) { - addr = (char *)((char *)hdr + sizeof(*hdr)); + if (image_check_type (hdr, IH_TYPE_SCRIPT)) { + addr = (char *)((char *)hdr + image_get_header_size ()); /* stick a NULL at the end of the script, otherwise */ /* parse_string_outer() runs off the end. */ - addr[ntohl(hdr->ih_size)] = 0; + addr[image_get_data_size (hdr)] = 0; addr += 8; /* @@ -231,38 +210,43 @@ int au_do_update(int i, long sz) */ if (au_image[i].type == AU_FIRMWARE) { char *orig = (char*)start; - char *new = (char *)((char *)hdr + sizeof(*hdr)); - nbytes = ntohl(hdr->ih_size); + char *new = (char *)((char *)hdr + + image_get_header_size ()); + nbytes = image_get_data_size (hdr); - while(--nbytes) { + while (--nbytes) { if (*orig++ != *new++) { break; } } if (!nbytes) { - printf("Skipping firmware update - images are identical\n"); + printf ("Skipping firmware update - " + "images are identical\n"); break; } } /* unprotect the address range */ - /* this assumes that ONLY the firmware is protected! */ - if (au_image[i].type == AU_FIRMWARE) { - flash_sect_protect(0, start, end); + if (((au_image[i].type & AU_FLAGMASK) == AU_PROTECT) || + (au_image[i].type == AU_FIRMWARE)) { + flash_sect_protect (0, start, end); } /* * erase the address range. */ if (au_image[i].type != AU_NAND) { - printf("Updating NOR FLASH with image %s\n", au_image[i].name); + printf ("Updating NOR FLASH with image %s\n", + au_image[i].name); debug ("flash_sect_erase(%lx, %lx);\n", start, end); - flash_sect_erase(start, end); + flash_sect_erase (start, end); } else { #if defined(CONFIG_CMD_NAND) && defined(CFG_NAND_LEGACY) - printf("Updating NAND FLASH with image %s\n", au_image[i].name); + printf ("Updating NAND FLASH with image %s\n", + au_image[i].name); debug ("nand_legacy_erase(%lx, %lx);\n", start, end); - rc = nand_legacy_erase (nand_dev_desc, start, end - start + 1, 0); + rc = nand_legacy_erase (nand_dev_desc, start, + end - start + 1, 0); debug ("nand_legacy_erase returned %x\n", rc); #endif } @@ -272,32 +256,38 @@ int au_do_update(int i, long sz) /* strip the header - except for the kernel and ramdisk */ if (au_image[i].type != AU_FIRMWARE) { addr = (char *)hdr; - off = sizeof(*hdr); - nbytes = sizeof(*hdr) + ntohl(hdr->ih_size); + off = image_get_header_size (); + nbytes = image_get_image_size (hdr); } else { - addr = (char *)((char *)hdr + sizeof(*hdr)); + addr = (char *)((char *)hdr + image_get_header_size ()); off = 0; - nbytes = ntohl(hdr->ih_size); + nbytes = image_get_data_size (hdr); } /* * copy the data from RAM to FLASH */ if (au_image[i].type != AU_NAND) { - debug ("flash_write(%p, %lx %x)\n", addr, start, nbytes); - rc = flash_write((char *)addr, start, nbytes); + debug ("flash_write(%p, %lx, %x)\n", + addr, start, nbytes); + rc = flash_write ((char *)addr, start, + (nbytes + 1) & ~1); } else { #if defined(CONFIG_CMD_NAND) && defined(CFG_NAND_LEGACY) - debug ("nand_legacy_rw(%p, %lx %x)\n", addr, start, nbytes); - rc = nand_legacy_rw(nand_dev_desc, NANDRW_WRITE | NANDRW_JFFS2, - start, nbytes, (size_t *)&total, (uchar *)addr); - debug ("nand_legacy_rw: ret=%x total=%d nbytes=%d\n", rc, total, nbytes); + debug ("nand_legacy_rw(%p, %lx, %x)\n", + addr, start, nbytes); + rc = nand_legacy_rw (nand_dev_desc, + NANDRW_WRITE | NANDRW_JFFS2, + start, nbytes, (size_t *)&total, + (uchar *)addr); + debug ("nand_legacy_rw: ret=%x total=%d nbytes=%d\n", + rc, total, nbytes); #else rc = -1; #endif } if (rc != 0) { - printf("Flashing failed due to error %d\n", rc); + printf ("Flashing failed due to error %d\n", rc); return -1; } @@ -305,23 +295,30 @@ int au_do_update(int i, long sz) * check the dcrc of the copy */ if (au_image[i].type != AU_NAND) { - rc = crc32 (0, (uchar *)(start + off), ntohl(hdr->ih_size)); + rc = crc32 (0, (uchar *)(start + off), + image_get_data_size (hdr)); } else { #if defined(CONFIG_CMD_NAND) && defined(CFG_NAND_LEGACY) - rc = nand_legacy_rw(nand_dev_desc, NANDRW_READ | NANDRW_JFFS2 | NANDRW_JFFS2_SKIP, - start, nbytes, (size_t *)&total, (uchar *)addr); - rc = crc32 (0, (uchar *)(addr + off), ntohl(hdr->ih_size)); + rc = nand_legacy_rw (nand_dev_desc, + NANDRW_READ | NANDRW_JFFS2 | + NANDRW_JFFS2_SKIP, + start, nbytes, (size_t *)&total, + (uchar *)addr); + rc = crc32 (0, (uchar *)(addr + off), + image_get_data_size (hdr)); #endif } - if (rc != ntohl(hdr->ih_dcrc)) { - printf ("Image %s Bad Data Checksum After COPY\n", au_image[i].name); + if (rc != image_get_dcrc (hdr)) { + printf ("Image %s Bad Data Checksum After COPY\n", + au_image[i].name); return -1; } /* protect the address range */ /* this assumes that ONLY the firmware is protected! */ - if (au_image[i].type == AU_FIRMWARE) { - flash_sect_protect(1, start, end); + if (((au_image[i].type & AU_FLAGMASK) == AU_PROTECT) || + (au_image[i].type == AU_FIRMWARE)) { + flash_sect_protect (1, start, end); } break; @@ -333,7 +330,6 @@ int au_do_update(int i, long sz) return 0; } - static void process_macros (const char *input, char *output) { char c, prev; @@ -347,16 +343,17 @@ static void process_macros (const char *input, char *output) #ifdef DEBUG_PARSER char *output_start = output; - printf ("[PROCESS_MACROS] INPUT len %d: \"%s\"\n", strlen(input), input); + printf ("[PROCESS_MACROS] INPUT len %d: \"%s\"\n", + strlen(input), input); #endif - prev = '\0'; /* previous character */ + prev = '\0'; /* previous character */ while (inputcnt && outputcnt) { c = *input++; inputcnt--; - if (state!=3) { + if (state != 3) { /* remove one level of escape characters */ if ((c == '\\') && (prev != '\\')) { if (inputcnt-- == 0) @@ -367,7 +364,7 @@ static void process_macros (const char *input, char *output) } switch (state) { - case 0: /* Waiting for (unescaped) $ */ + case 0: /* Waiting for (unescaped) $ */ if ((c == '\'') && (prev != '\\')) { state = 3; break; @@ -379,7 +376,7 @@ static void process_macros (const char *input, char *output) outputcnt--; } break; - case 1: /* Waiting for ( */ + case 1: /* Waiting for ( */ if (c == '(' || c == '{') { state++; varname_start = input; @@ -398,7 +395,8 @@ static void process_macros (const char *input, char *output) if (c == ')' || c == '}') { int i; char envname[CFG_CBSIZE], *envval; - int envcnt = input-varname_start-1; /* Varname # of chars */ + /* Varname # of chars */ + int envcnt = input - varname_start - 1; /* Get the varname */ for (i = 0; i < envcnt; i++) { @@ -436,11 +434,10 @@ static void process_macros (const char *input, char *output) #ifdef DEBUG_PARSER printf ("[PROCESS_MACROS] OUTPUT len %d: \"%s\"\n", - strlen(output_start), output_start); + strlen (output_start), output_start); #endif } - /* * this is called from board_init() after the hardware has been set up * and is usable. That seems like a good time to do this. @@ -448,84 +445,84 @@ static void process_macros (const char *input, char *output) */ int do_auto_update(void) { - block_dev_desc_t *stor_dev; + block_dev_desc_t *stor_dev = NULL; long sz; int i, res, cnt, old_ctrlc, got_ctrlc; char buffer[32]; char str[80]; + int n; - /* - * Check whether a CompactFlash is inserted - */ - if (ide_dev_desc[0].type == DEV_TYPE_UNKNOWN) { - return -1; /* no disk detected! */ + if (ide_dev_desc[0].type != DEV_TYPE_UNKNOWN) { + stor_dev = get_dev ("ide", 0); + if (stor_dev == NULL) { + debug ("ide: unknown device\n"); + return -1; + } } - /* check whether it has a partition table */ - stor_dev = get_dev("ide", 0); - if (stor_dev == NULL) { - debug ("Uknown device type\n"); - return -1; - } - if (fat_register_device(stor_dev, 1) != 0) { - debug ("Unable to register ide disk 0:1 for fatls\n"); + if (fat_register_device (stor_dev, 1) != 0) { + debug ("Unable to register ide disk 0:1\n"); return -1; } /* * Check if magic file is present */ - if (do_fat_read(AU_MAGIC_FILE, buffer, sizeof(buffer), LS_NO) <= 0) { + if ((n = do_fat_read (AU_MAGIC_FILE, buffer, + sizeof(buffer), LS_NO)) <= 0) { + debug ("No auto_update magic file (n=%d)\n", n); return -1; } #ifdef CONFIG_AUTO_UPDATE_SHOW - board_auto_update_show(1); + board_auto_update_show (1); #endif puts("\nAutoUpdate Disk detected! Trying to update system...\n"); /* make sure that we see CTRL-C and save the old state */ - old_ctrlc = disable_ctrlc(0); + old_ctrlc = disable_ctrlc (0); /* just loop thru all the possible files */ for (i = 0; i < N_AU_IMAGES; i++) { /* * Try to expand the environment var in the fname */ - process_macros(au_image[i].name, str); - strcpy(au_image[i].name, str); + process_macros (au_image[i].name, str); + strcpy (au_image[i].name, str); printf("Reading %s ...", au_image[i].name); /* just read the header */ - sz = do_fat_read(au_image[i].name, LOAD_ADDR, sizeof(image_header_t), LS_NO); + sz = do_fat_read (au_image[i].name, LOAD_ADDR, + image_get_header_size (), LS_NO); debug ("read %s sz %ld hdr %d\n", - au_image[i].name, sz, sizeof(image_header_t)); - if (sz <= 0 || sz < sizeof(image_header_t)) { + au_image[i].name, sz, image_get_header_size ()); + if (sz <= 0 || sz < image_get_header_size ()) { puts(" not found\n"); continue; } - if (au_check_header_valid(i, sz) < 0) { + if (au_check_header_valid (i, sz) < 0) { puts(" header not valid\n"); continue; } - sz = do_fat_read(au_image[i].name, LOAD_ADDR, MAX_LOADSZ, LS_NO); + sz = do_fat_read (au_image[i].name, LOAD_ADDR, + MAX_LOADSZ, LS_NO); debug ("read %s sz %ld hdr %d\n", - au_image[i].name, sz, sizeof(image_header_t)); - if (sz <= 0 || sz <= sizeof(image_header_t)) { + au_image[i].name, sz, image_get_header_size ()); + if (sz <= 0 || sz <= image_get_header_size ()) { puts(" not found\n"); continue; } - if (au_check_cksum_valid(i, sz) < 0) { + if (au_check_cksum_valid (i, sz) < 0) { puts(" checksum not valid\n"); continue; } puts(" done\n"); do { - res = au_do_update(i, sz); + res = au_do_update (i, sz); /* let the user break out of the loop */ - if (ctrlc() || had_ctrlc()) { - clear_ctrlc(); + if (ctrlc() || had_ctrlc ()) { + clear_ctrlc (); if (res < 0) got_ctrlc = 1; break; @@ -535,17 +532,16 @@ int do_auto_update(void) } /* restore the old state */ - disable_ctrlc(old_ctrlc); + disable_ctrlc (old_ctrlc); puts("AutoUpdate finished\n\n"); #ifdef CONFIG_AUTO_UPDATE_SHOW - board_auto_update_show(0); + board_auto_update_show (0); #endif return 0; } - int auto_update(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { do_auto_update(); diff --git a/board/esd/common/auto_update.h b/board/esd/common/auto_update.h index e2af3c7b15..3ed0e16372 100644 --- a/board/esd/common/auto_update.h +++ b/board/esd/common/auto_update.h @@ -29,16 +29,21 @@ #define AU_MAGIC_FILE "__auto_update" -#define AU_SCRIPT 1 -#define AU_FIRMWARE 2 -#define AU_NOR 3 -#define AU_NAND 4 +#define AU_TYPEMASK 0x000000ff +#define AU_FLAGMASK 0xffff0000 + +#define AU_PROTECT 0x80000000 + +#define AU_SCRIPT 0x01 +#define AU_FIRMWARE (0x02 | AU_PROTECT) +#define AU_NOR 0x03 +#define AU_NAND 0x04 struct au_image_s { char name[80]; ulong start; ulong size; - int type; + ulong type; }; typedef struct au_image_s au_image_t; diff --git a/board/esd/common/lcd.c b/board/esd/common/lcd.c index ed50def484..c23dc81a26 100644 --- a/board/esd/common/lcd.c +++ b/board/esd/common/lcd.c @@ -44,37 +44,57 @@ void lcd_setup(int lcd, int config) /* * Set endianess and reset lcd controller 0 (small) */ - out_be32((void*)GPIO0_OR, in_be32((void*)GPIO0_OR) & ~CFG_LCD0_RST); /* set reset to low */ + + /* set reset to low */ + out_be32((void*)GPIO0_OR, + in_be32((void*)GPIO0_OR) & ~CFG_LCD0_RST); udelay(10); /* wait 10us */ - if (config == 1) - out_be32((void*)GPIO0_OR, in_be32((void*)GPIO0_OR) | CFG_LCD_ENDIAN); /* big-endian */ - else - out_be32((void*)GPIO0_OR, in_be32((void*)GPIO0_OR) & ~CFG_LCD_ENDIAN); /* little-endian */ + if (config == 1) { + /* big-endian */ + out_be32((void*)GPIO0_OR, + in_be32((void*)GPIO0_OR) | CFG_LCD_ENDIAN); + } else { + /* little-endian */ + out_be32((void*)GPIO0_OR, + in_be32((void*)GPIO0_OR) & ~CFG_LCD_ENDIAN); + } udelay(10); /* wait 10us */ - out_be32((void*)GPIO0_OR, in_be32((void*)GPIO0_OR) | CFG_LCD0_RST); /* set reset to high */ + /* set reset to high */ + out_be32((void*)GPIO0_OR, + in_be32((void*)GPIO0_OR) | CFG_LCD0_RST); } else { /* * Set endianess and reset lcd controller 1 (big) */ - out_be32((void*)GPIO0_OR, in_be32((void*)GPIO0_OR) & ~CFG_LCD1_RST); /* set reset to low */ + + /* set reset to low */ + out_be32((void*)GPIO0_OR, + in_be32((void*)GPIO0_OR) & ~CFG_LCD1_RST); udelay(10); /* wait 10us */ - if (config == 1) - out_be32((void*)GPIO0_OR, in_be32((void*)GPIO0_OR) | CFG_LCD_ENDIAN); /* big-endian */ - else - out_be32((void*)GPIO0_OR, in_be32((void*)GPIO0_OR) & ~CFG_LCD_ENDIAN); /* little-endian */ + if (config == 1) { + /* big-endian */ + out_be32((void*)GPIO0_OR, + in_be32((void*)GPIO0_OR) | CFG_LCD_ENDIAN); + } else { + /* little-endian */ + out_be32((void*)GPIO0_OR, + in_be32((void*)GPIO0_OR) & ~CFG_LCD_ENDIAN); + } udelay(10); /* wait 10us */ - out_be32((void*)GPIO0_OR, in_be32((void*)GPIO0_OR) | CFG_LCD1_RST); /* set reset to high */ + /* set reset to high */ + out_be32((void*)GPIO0_OR, + in_be32((void*)GPIO0_OR) | CFG_LCD1_RST); } /* * CFG_LCD_ENDIAN may also be FPGA_RESET, so set inactive */ - out_be32((void*)GPIO0_OR, in_be32((void*)GPIO0_OR) | CFG_LCD_ENDIAN); /* set reset high again */ + out_be32((void*)GPIO0_OR, in_be32((void*)GPIO0_OR) | CFG_LCD_ENDIAN); } #endif /* CFG_LCD_ENDIAN */ -void lcd_bmp(uchar *logo_bmp) +int lcd_bmp(uchar *logo_bmp) { int i; uchar *ptr; @@ -99,13 +119,18 @@ void lcd_bmp(uchar *logo_bmp) len = CFG_VIDEO_LOGO_MAX_SIZE; dst = malloc(CFG_VIDEO_LOGO_MAX_SIZE); if (dst == NULL) { - printf("Error: malloc in gunzip failed!\n"); - return; + printf("Error: malloc for gunzip failed!\n"); + return 1; + } + if (gunzip(dst, CFG_VIDEO_LOGO_MAX_SIZE, + (uchar *)logo_bmp, &len) != 0) { + free(dst); + return 1; + } + if (len == CFG_VIDEO_LOGO_MAX_SIZE) { + printf("Image could be truncated" + " (increase CFG_VIDEO_LOGO_MAX_SIZE)!\n"); } - if (gunzip(dst, CFG_VIDEO_LOGO_MAX_SIZE, (uchar *)logo_bmp, &len) != 0) - return; - if (len == CFG_VIDEO_LOGO_MAX_SIZE) - printf("Image could be truncated (increase CFG_VIDEO_LOGO_MAX_SIZE)!\n"); /* * Check for bmp mark 'BM' @@ -113,7 +138,7 @@ void lcd_bmp(uchar *logo_bmp) if (*(ushort *)dst != 0x424d) { printf("LCD: Unknown image format!\n"); free(dst); - return; + return 1; } } else { /* @@ -150,7 +175,7 @@ void lcd_bmp(uchar *logo_bmp) printf("LCD: Unknown bpp (%d) im image!\n", bpp); if ((dst != NULL) && (dst != (uchar *)logo_bmp)) free(dst); - return; + return 1; } printf(" (%d*%d, %dbpp)\n", width, height, bpp); @@ -180,23 +205,28 @@ void lcd_bmp(uchar *logo_bmp) if (bpp == 24) { for (x = 0; x < width; x++) { /* - * Generate epson 16bpp fb-format from 24bpp image + * Generate epson 16bpp fb-format + * from 24bpp image */ b = *bmp++ >> 3; g = *bmp++ >> 2; r = *bmp++ >> 3; - val = ((r & 0x1f) << 11) | ((g & 0x3f) << 5) | (b & 0x1f); + val = ((r & 0x1f) << 11) | + ((g & 0x3f) << 5) | + (b & 0x1f); *ptr2++ = val; } } else if (bpp == 8) { for (x = 0; x < line_size; x++) { /* query rgb value from palette */ - ptr = (unsigned char *)(dst + 14 + 40) ; + ptr = (unsigned char *)(dst + 14 + 40); ptr += (*bmp++) << 2; b = *ptr++ >> 3; g = *ptr++ >> 2; r = *ptr++ >> 3; - val = ((r & 0x1f) << 11) | ((g & 0x3f) << 5) | (b & 0x1f); + val = ((r & 0x1f) << 11) | + ((g & 0x3f) << 5) | + (b & 0x1f); *ptr2++ = val; } } @@ -208,11 +238,12 @@ void lcd_bmp(uchar *logo_bmp) if ((dst != NULL) && (dst != (uchar *)logo_bmp)) free(dst); + return 0; } -void lcd_init(uchar *lcd_reg, uchar *lcd_mem, S1D_REGS *regs, int reg_count, - uchar *logo_bmp, ulong len) +int lcd_init(uchar *lcd_reg, uchar *lcd_mem, S1D_REGS *regs, int reg_count, + uchar *logo_bmp, ulong len) { int i; ushort s1dReg; @@ -263,8 +294,22 @@ void lcd_init(uchar *lcd_reg, uchar *lcd_mem, S1D_REGS *regs, int reg_count, lcd_reg += 0x10000; /* add offset for 705 regs */ puts("LCD: S1D13705"); } else { - puts("LCD: No controller detected!\n"); - return; + out_8(&lcd_reg[0x1a], 0x00); + udelay(1000); + if (in_8(&lcd_reg[1]) == 0x0c) { + /* + * S1D13505 detected + */ + reg_byte_swap = TRUE; + palette_index = 0x25; + palette_value = 0x27; + lcd_depth = 16; + + puts("LCD: S1D13505"); + } else { + puts("LCD: No controller detected!\n"); + return 1; + } } /* @@ -279,7 +324,7 @@ void lcd_init(uchar *lcd_reg, uchar *lcd_mem, S1D_REGS *regs, int reg_count, s1dReg &= ~0x0001; } s1dValue = regs[i].Value; - lcd_reg[s1dReg] = s1dValue; + out_8(&lcd_reg[s1dReg], s1dValue); } /* @@ -291,15 +336,15 @@ void lcd_init(uchar *lcd_reg, uchar *lcd_mem, S1D_REGS *regs, int reg_count, /* * Display bmp image */ - lcd_bmp(logo_bmp); + return lcd_bmp(logo_bmp); } -#if defined(CONFIG_VIDEO_SM501) int do_esdbmp(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { ulong addr; +#ifdef CONFIG_VIDEO_SM501 char *str; - +#endif if (argc != 2) { printf ("Usage:\n%s\n", cmdtp->usage); return 1; @@ -307,19 +352,22 @@ int do_esdbmp(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) addr = simple_strtoul(argv[1], NULL, 16); +#ifdef CONFIG_VIDEO_SM501 str = getenv("bd_type"); if ((strcmp(str, "ppc221") == 0) || (strcmp(str, "ppc231") == 0)) { /* * SM501 available, use standard bmp command */ - return (video_display_bitmap(addr, 0, 0)); + return video_display_bitmap(addr, 0, 0); } else { /* * No SM501 available, use esd epson bmp command */ - lcd_bmp((uchar *)addr); - return 0; + return lcd_bmp((uchar *)addr); } +#else + return lcd_bmp((uchar *)addr); +#endif } U_BOOT_CMD( @@ -327,4 +375,3 @@ U_BOOT_CMD( "esdbmp - display BMP image\n", "<imageAddr> - display image\n" ); -#endif diff --git a/board/esd/common/s1d13505_640_480_16bpp.h b/board/esd/common/s1d13505_640_480_16bpp.h new file mode 100644 index 0000000000..02b3b9291c --- /dev/null +++ b/board/esd/common/s1d13505_640_480_16bpp.h @@ -0,0 +1,65 @@ +/* + * (C) Copyright 2008 + * Matthias Fuchs, esd gmbh germany, matthias.fuchs@esd-electronics.com + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +/* + * Panel: 640x480 50Hz TFT Single 18-bit (PCLK=20.000 MHz) + * Memory: DRAM (MCLK=40.000 MHz) + */ +static S1D_REGS regs_13505_640_480_16bpp[] = +{ + {0x1B,0x00}, /* Miscellaneous Register */ + {0x23,0x20}, /* Performance Enhancement Register 1 */ + {0x01,0x30}, /* Memory Configuration Register */ + {0x22,0x24}, /* Performance Enhancement Register 0 */ + {0x02,0x25}, /* Panel Type Register */ + {0x03,0x00}, /* MOD Rate Register */ + {0x04,0x4F}, /* Horizontal Display Width Register */ + {0x05,0x0c}, /* Horizontal Non-Display Period Register */ + {0x06,0x00}, /* HRTC/FPLINE Start Position Register */ + {0x07,0x01}, /* HRTC/FPLINE Pulse Width Register */ + {0x08,0xDF}, /* Vertical Display Height Register 0 */ + {0x09,0x01}, /* Vertical Display Height Register 1 */ + {0x0A,0x3E}, /* Vertical Non-Display Period Register */ + {0x0B,0x00}, /* VRTC/FPFRAME Start Position Register */ + {0x0C,0x01}, /* VRTC/FPFRAME Pulse Width Register */ + {0x0E,0xFF}, /* Screen 1 Line Compare Register 0 */ + {0x0F,0x03}, /* Screen 1 Line Compare Register 1 */ + {0x10,0x00}, /* Screen 1 Display Start Address Register 0 */ + {0x11,0x00}, /* Screen 1 Display Start Address Register 1 */ + {0x12,0x00}, /* Screen 1 Display Start Address Register 2 */ + {0x13,0x00}, /* Screen 2 Display Start Address Register 0 */ + {0x14,0x00}, /* Screen 2 Display Start Address Register 1 */ + {0x15,0x00}, /* Screen 2 Display Start Address Register 2 */ + {0x16,0x80}, /* Memory Address Offset Register 0 */ + {0x17,0x02}, /* Memory Address Offset Register 1 */ + {0x18,0x00}, /* Pixel Panning Register */ + {0x19,0x01}, /* Clock Configuration Register */ + {0x1A,0x00}, /* Power Save Configuration Register */ + {0x1C,0x00}, /* MD Configuration Readback Register 0 */ + {0x1E,0x06}, /* General IO Pins Configuration Register 0 */ + {0x1F,0x00}, /* General IO Pins Configuration Register 1 */ + {0x20,0x00}, /* General IO Pins Control Register 0 */ + {0x21,0x00}, /* General IO Pins Control Register 1 */ + {0x23,0x20}, /* Performance Enhancement Register 1 */ + {0x0D,0x15}, /* Display Mode Register */ +}; |