diff options
Diffstat (limited to 'board/esd/common')
-rw-r--r-- | board/esd/common/auto_update.c | 16 | ||||
-rw-r--r-- | board/esd/common/cmd_loadpci.c | 123 | ||||
-rw-r--r-- | board/esd/common/lcd.c | 270 | ||||
-rw-r--r-- | board/esd/common/misc.c | 4 |
4 files changed, 320 insertions, 93 deletions
diff --git a/board/esd/common/auto_update.c b/board/esd/common/auto_update.c index 0604a4e6fe..1decc0ec0c 100644 --- a/board/esd/common/auto_update.c +++ b/board/esd/common/auto_update.c @@ -65,7 +65,7 @@ extern int transfer_pic(unsigned char, unsigned char *, int, int); #endif extern int flash_sect_erase(ulong, ulong); extern int flash_sect_protect (int, ulong, ulong); -extern int flash_write (uchar *, ulong, ulong); +extern int flash_write (char *, ulong, ulong); /* change char* to void* to shutup the compiler */ extern block_dev_desc_t *get_dev (char*, int); @@ -103,7 +103,7 @@ int au_check_cksum_valid(int i, long nbytes) /* check the data CRC */ checksum = ntohl(hdr->ih_dcrc); - if (crc32 (0, (char *)(LOAD_ADDR + sizeof(*hdr)), ntohl(hdr->ih_size)) + if (crc32 (0, (uchar *)(LOAD_ADDR + sizeof(*hdr)), ntohl(hdr->ih_size)) != checksum) { printf ("Image %s bad data checksum\n", au_image[i].name); return -1; @@ -140,7 +140,7 @@ int au_check_header_valid(int i, long nbytes) checksum = ntohl(hdr->ih_hcrc); hdr->ih_hcrc = 0; - if (crc32 (0, (char *)hdr, sizeof(*hdr)) != checksum) { + if (crc32 (0, (uchar *)hdr, sizeof(*hdr)) != checksum) { printf ("Image %s bad header checksum\n", au_image[i].name); return -1; } @@ -283,12 +283,12 @@ int au_do_update(int i, long sz) */ if (au_image[i].type != AU_NAND) { debug ("flash_write(%p, %lx %x)\n", addr, start, nbytes); - rc = flash_write(addr, start, nbytes); + rc = flash_write((char *)addr, start, nbytes); } else { #if (CONFIG_COMMANDS & CFG_CMD_NAND) debug ("nand_rw(%p, %lx %x)\n", addr, start, nbytes); rc = nand_rw(nand_dev_desc, NANDRW_WRITE | NANDRW_JFFS2, - start, nbytes, &total, addr); + start, nbytes, (size_t *)&total, (uchar *)addr); debug ("nand_rw: ret=%x total=%d nbytes=%d\n", rc, total, nbytes); #endif } @@ -301,12 +301,12 @@ int au_do_update(int i, long sz) * check the dcrc of the copy */ if (au_image[i].type != AU_NAND) { - rc = crc32 (0, (char *)(start + off), ntohl(hdr->ih_size)); + rc = crc32 (0, (uchar *)(start + off), ntohl(hdr->ih_size)); } else { #if (CONFIG_COMMANDS & CFG_CMD_NAND) rc = nand_rw(nand_dev_desc, NANDRW_READ | NANDRW_JFFS2 | NANDRW_JFFS2_SKIP, - start, nbytes, &total, addr); - rc = crc32 (0, (char *)(addr + off), ntohl(hdr->ih_size)); + start, nbytes, (size_t *)&total, (uchar *)addr); + rc = crc32 (0, (uchar *)(addr + off), ntohl(hdr->ih_size)); #endif } if (rc != ntohl(hdr->ih_dcrc)) { diff --git a/board/esd/common/cmd_loadpci.c b/board/esd/common/cmd_loadpci.c new file mode 100644 index 0000000000..3478f825c5 --- /dev/null +++ b/board/esd/common/cmd_loadpci.c @@ -0,0 +1,123 @@ +/* + * (C) Copyright 2005 + * 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 + */ + +#include <common.h> +#include <command.h> + +#if (CONFIG_COMMANDS & CFG_CMD_BSP) + +extern int do_bootm (cmd_tbl_t *, int, int, char *[]); +extern int do_autoscript (cmd_tbl_t *, int, int, char *[]); + +#define ADDRMASK 0xfffff000 + +/* + * Command loadpci: wait for signal from host and boot image. + */ +int do_loadpci(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) +{ + unsigned int *ptr = 0; + int count = 0; + int count2 = 0; + char addr[16]; + char str[] = "\\|/-"; + char *local_args[2]; + + while(1) { + /* + * Mark sync address + */ + ptr = 0; + memset(ptr, 0, 0x20); + + *ptr = 0xffffffff; + puts("\nWaiting for action from pci host -"); + + /* + * Wait for host to write the start address + */ + while (*ptr == 0xffffffff) { + count++; + if (!(count % 100)) { + count2++; + putc(0x08); /* backspace */ + putc(str[count2 % 4]); + } + + /* Abort if ctrl-c was pressed */ + if (ctrlc()) { + puts("\nAbort\n"); + return 0; + } + + udelay(1000); + } + + printf("\nGot bootcode %08x: ", *ptr); + sprintf(addr, "%08x", *ptr & ADDRMASK); + + switch (*ptr & ~ADDRMASK) { + case 0: + /* + * Boot image via bootm + */ + printf("booting image at addr 0x%s ...\n", addr); + setenv("loadaddr", addr); + + do_bootm (cmdtp, 0, 0, NULL); + break; + + case 1: + /* + * Boot image via autoscr + */ + printf("executing script at addr 0x%s ...\n", addr); + + local_args[0] = addr; + local_args[1] = NULL; + do_autoscript(cmdtp, 0, 1, local_args); + break; + + case 2: + /* + * Call run_cmd + */ + printf("running command at addr 0x%s ...\n", addr); + run_command ((char*)(*ptr & ADDRMASK), 0); + break; + + default: + printf("unhandled boot method\n"); + break; + } + } +} + +U_BOOT_CMD( + loadpci, 1, 1, do_loadpci, + "loadpci - Wait for pci bootcmd and boot it\n", + NULL + ); + +#endif + diff --git a/board/esd/common/lcd.c b/board/esd/common/lcd.c index d2d642a1a7..0edc08308a 100644 --- a/board/esd/common/lcd.c +++ b/board/esd/common/lcd.c @@ -2,6 +2,9 @@ * (C) Copyright 2003-2004 * Stefan Roese, esd gmbh germany, stefan.roese@esd-electronics.com * + * (C) Copyright 2005 + * Stefan Roese, DENX Software Engineering, sr@denx.de. + * * See file CREDITS for list of people who contributed to this * project. * @@ -24,9 +27,14 @@ #include "lcd.h" +extern int video_display_bitmap (ulong, int, int); + + int palette_index; int palette_value; - +int lcd_depth; +unsigned char *glob_lcd_reg; +unsigned char *glob_lcd_mem; #ifdef CFG_LCD_ENDIAN void lcd_setup(int lcd, int config) @@ -67,92 +75,55 @@ void lcd_setup(int lcd, int config) #endif /* #ifdef CFG_LCD_ENDIAN */ -void lcd_init(uchar *lcd_reg, uchar *lcd_mem, S1D_REGS *regs, int reg_count, - uchar *logo_bmp, ulong len) +void lcd_bmp(uchar *logo_bmp) { int i; - ushort s1dReg; - uchar s1dValue; uchar *ptr; ushort *ptr2; ushort val; - unsigned char *dst; + unsigned char *dst = NULL; int x, y; int width, height, bpp, colors, line_size; int header_size; unsigned char *bmp; unsigned char r, g, b; BITMAPINFOHEADER *bm_info; - int reg_byte_swap; + ulong len; /* - * Detect epson + * Check for bmp mark 'BM' */ - if (lcd_reg[0] == 0x1c) { + if (*(ushort *)logo_bmp != 0x424d) { + /* - * Big epson detected + * Decompress bmp image */ - reg_byte_swap = FALSE; - palette_index = 0x1e2; - palette_value = 0x1e4; - puts("LCD: S1D13806"); - } else if (lcd_reg[1] == 0x1c) { - /* - * Big epson detected (with register swap bug) - */ - reg_byte_swap = TRUE; - palette_index = 0x1e3; - palette_value = 0x1e5; - puts("LCD: S1D13806S"); - } else if (lcd_reg[0] == 0x18) { + len = CFG_VIDEO_LOGO_MAX_SIZE; + dst = malloc(CFG_VIDEO_LOGO_MAX_SIZE); + if (dst == NULL) { + printf("Error: malloc in gunzip failed!\n"); + return; + } + 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"); + } + /* - * Small epson detected (704) + * Check for bmp mark 'BM' */ - reg_byte_swap = FALSE; - palette_index = 0x15; - palette_value = 0x17; - puts("LCD: S1D13704"); - } else if (lcd_reg[0x10000] == 0x24) { + if (*(ushort *)dst != 0x424d) { + printf("LCD: Unknown image format!\n"); + free(dst); + return; + } + } else { /* - * Small epson detected (705) + * Uncompressed BMP image, just use this pointer */ - reg_byte_swap = FALSE; - palette_index = 0x15; - palette_value = 0x17; - lcd_reg += 0x10000; /* add offset for 705 regs */ - puts("LCD: S1D13705"); - } else { - puts("LCD: No controller detected!\n"); - return; - } - - for (i = 0; i<reg_count; i++) { - s1dReg = regs[i].Index; - if (reg_byte_swap) { - if ((s1dReg & 0x0001) == 0) - s1dReg |= 0x0001; - else - s1dReg &= ~0x0001; - } - s1dValue = regs[i].Value; - lcd_reg[s1dReg] = s1dValue; - } - - /* - * Decompress bmp image - */ - dst = malloc(CFG_LCD_LOGO_MAX_SIZE); - if (gunzip(dst, CFG_LCD_LOGO_MAX_SIZE, (uchar *)logo_bmp, &len) != 0) { - return; - } - - /* - * Check for bmp mark 'BM' - */ - if (*(ushort *)dst != 0x424d) { - printf("LCD: Unknown image format!\n"); - free(dst); - return; + dst = (uchar *)logo_bmp; } /* @@ -181,7 +152,9 @@ void lcd_init(uchar *lcd_reg, uchar *lcd_mem, S1D_REGS *regs, int reg_count, break; default: printf("LCD: Unknown bpp (%d) im image!\n", bpp); - free(dst); + if ((dst != NULL) && (dst != (uchar *)logo_bmp)) { + free(dst); + } return; } printf(" (%d*%d, %dbpp)\n", width, height, bpp); @@ -189,35 +162,48 @@ void lcd_init(uchar *lcd_reg, uchar *lcd_mem, S1D_REGS *regs, int reg_count, /* * Write color palette */ - if (colors <= 256) { + if ((colors <= 256) && (lcd_depth <= 8)) { ptr = (unsigned char *)(dst + 14 + 40); for (i=0; i<colors; i++) { b = *ptr++; g = *ptr++; r = *ptr++; ptr++; - S1D_WRITE_PALETTE(lcd_reg, i, r, g, b); + S1D_WRITE_PALETTE(glob_lcd_reg, i, r, g, b); } } /* * Write bitmap data into framebuffer */ - ptr = lcd_mem; - ptr2 = (ushort *)lcd_mem; + ptr = glob_lcd_mem; + ptr2 = (ushort *)glob_lcd_mem; header_size = 14 + 40 + 4*colors; /* skip bmp header */ for (y=0; y<height; y++) { bmp = &dst[(height-1-y)*line_size + header_size]; - if (bpp == 24) { - for (x=0; x<width; x++) { - /* - * 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); - *ptr2++ = val; + if (lcd_depth == 16) { + if (bpp == 24) { + for (x=0; x<width; x++) { + /* + * 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); + *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 += (*bmp++) << 2; + b = *ptr++ >> 3; + g = *ptr++ >> 2; + r = *ptr++ >> 3; + val = ((r & 0x1f) << 11) | ((g & 0x3f) << 5) | (b & 0x1f); + *ptr2++ = val; + } } } else { for (x=0; x<line_size; x++) { @@ -226,5 +212,123 @@ void lcd_init(uchar *lcd_reg, uchar *lcd_mem, S1D_REGS *regs, int reg_count, } } - free(dst); + if ((dst != NULL) && (dst != (uchar *)logo_bmp)) { + free(dst); + } } + + +void lcd_init(uchar *lcd_reg, uchar *lcd_mem, S1D_REGS *regs, int reg_count, + uchar *logo_bmp, ulong len) +{ + int i; + ushort s1dReg; + uchar s1dValue; + int reg_byte_swap; + + /* + * Detect epson + */ + if (lcd_reg[0] == 0x1c) { + /* + * Big epson detected + */ + reg_byte_swap = FALSE; + palette_index = 0x1e2; + palette_value = 0x1e4; + lcd_depth = 16; + puts("LCD: S1D13806"); + } else if (lcd_reg[1] == 0x1c) { + /* + * Big epson detected (with register swap bug) + */ + reg_byte_swap = TRUE; + palette_index = 0x1e3; + palette_value = 0x1e5; + lcd_depth = 16; + puts("LCD: S1D13806S"); + } else if (lcd_reg[0] == 0x18) { + /* + * Small epson detected (704) + */ + reg_byte_swap = FALSE; + palette_index = 0x15; + palette_value = 0x17; + lcd_depth = 8; + puts("LCD: S1D13704"); + } else if (lcd_reg[0x10000] == 0x24) { + /* + * Small epson detected (705) + */ + reg_byte_swap = FALSE; + palette_index = 0x15; + palette_value = 0x17; + lcd_depth = 8; + lcd_reg += 0x10000; /* add offset for 705 regs */ + puts("LCD: S1D13705"); + } else { + puts("LCD: No controller detected!\n"); + return; + } + + /* + * Setup lcd controller regs + */ + for (i = 0; i<reg_count; i++) { + s1dReg = regs[i].Index; + if (reg_byte_swap) { + if ((s1dReg & 0x0001) == 0) + s1dReg |= 0x0001; + else + s1dReg &= ~0x0001; + } + s1dValue = regs[i].Value; + lcd_reg[s1dReg] = s1dValue; + } + + /* + * Save reg & mem pointer for later usage (e.g. bmp command) + */ + glob_lcd_reg = lcd_reg; + glob_lcd_mem = lcd_mem; + + /* + * Display bmp image + */ + lcd_bmp(logo_bmp); +} + +#ifdef CONFIG_VIDEO_SM501 +int do_esdbmp(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) +{ + ulong addr; + char *str; + + if (argc != 2) { + printf ("Usage:\n%s\n", cmdtp->usage); + return 1; + } + + addr = simple_strtoul(argv[1], NULL, 16); + + 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)); + } else { + /* + * No SM501 available, use esd epson bmp command + */ + lcd_bmp((uchar *)addr); + return 0; + } +} + +U_BOOT_CMD( + esdbmp, 2, 1, do_esdbmp, + "esdbmp - display BMP image\n", + "<imageAddr> - display image\n" +); +#endif diff --git a/board/esd/common/misc.c b/board/esd/common/misc.c index cba8c92f2e..48b4b7c7b9 100644 --- a/board/esd/common/misc.c +++ b/board/esd/common/misc.c @@ -33,8 +33,8 @@ void lxt971_no_sleep(void) { unsigned short reg; - miiphy_read(CONFIG_PHY_ADDR, 0x10, ®); + miiphy_read("ppc_4xx_eth0", CONFIG_PHY_ADDR, 0x10, ®); reg &= ~0x0040; /* disable sleep mode */ - miiphy_write(CONFIG_PHY_ADDR, 0x10, reg); + miiphy_write("ppc_4xx_eth0", CONFIG_PHY_ADDR, 0x10, reg); } #endif /* CONFIG_LXT971_NO_SLEEP */ |