From bf9e3b38f77c2eac620263dd60437c6ec47a27bf Mon Sep 17 00:00:00 2001 From: wdenk Date: Thu, 12 Feb 2004 00:47:09 +0000 Subject: * Some code cleanup * Patch by Josef Baumgartner, 10 Feb 2004: Fixes for Coldfire port * Patch by Brad Kemp, 11 Feb 2004: Fix CFI flash driver problems --- board/eltec/bab7xx/bab7xx.c | 195 ++++++------ board/eltec/elppc/misc.c | 393 ++++++++++++------------ board/eltec/mhpc/mhpc.c | 720 ++++++++++++++++++++++---------------------- 3 files changed, 660 insertions(+), 648 deletions(-) (limited to 'board/eltec') diff --git a/board/eltec/bab7xx/bab7xx.c b/board/eltec/bab7xx/bab7xx.c index c75137ab3e4..fc48ed547e7 100644 --- a/board/eltec/bab7xx/bab7xx.c +++ b/board/eltec/bab7xx/bab7xx.c @@ -37,17 +37,18 @@ */ ulong bab7xx_get_bus_freq (void) { - /* - * The GPIO Port 1 on BAB7xx reflects the bus speed. - */ - volatile struct GPIO *gpio = (struct GPIO *)(CFG_ISA_IO + CFG_NS87308_GPIO_BASE); + /* + * The GPIO Port 1 on BAB7xx reflects the bus speed. + */ + volatile struct GPIO *gpio = + (struct GPIO *) (CFG_ISA_IO + CFG_NS87308_GPIO_BASE); - unsigned char data = gpio->dta1; + unsigned char data = gpio->dta1; - if (data & 0x02) - return 66666666; + if (data & 0x02) + return 66666666; - return 83333333; + return 83333333; } /*---------------------------------------------------------------------------*/ @@ -57,24 +58,26 @@ ulong bab7xx_get_bus_freq (void) */ ulong bab7xx_get_gclk_freq (void) { - static const int pllratio_to_factor[] = { - 00, 75, 70, 00, 20, 65, 100, 45, 30, 55, 40, 50, 80, 60, 35, 00, - }; + static const int pllratio_to_factor[] = { + 00, 75, 70, 00, 20, 65, 100, 45, 30, 55, 40, 50, 80, 60, 35, + 00, + }; - return pllratio_to_factor[get_hid1 () >> 28] * (bab7xx_get_bus_freq() / 10); + return pllratio_to_factor[get_hid1 () >> 28] * + (bab7xx_get_bus_freq () / 10); } /*----------------------------------------------------------------------------*/ int checkcpu (void) { - uint pvr = get_pvr(); + uint pvr = get_pvr (); - printf ("MPC7xx V%d.%d",(pvr >> 8) & 0xFF, pvr & 0xFF); - printf (" at %ld / %ld MHz\n", bab7xx_get_gclk_freq()/1000000, - bab7xx_get_bus_freq()/1000000); + printf ("MPC7xx V%d.%d", (pvr >> 8) & 0xFF, pvr & 0xFF); + printf (" at %ld / %ld MHz\n", bab7xx_get_gclk_freq () / 1000000, + bab7xx_get_bus_freq () / 1000000); - return (0); + return (0); } /* ------------------------------------------------------------------------- */ @@ -82,20 +85,20 @@ int checkcpu (void) int checkboard (void) { #ifdef CFG_ADDRESS_MAP_A - puts ("Board: ELTEC BAB7xx PReP\n"); + puts ("Board: ELTEC BAB7xx PReP\n"); #else - puts ("Board: ELTEC BAB7xx CHRP\n"); + puts ("Board: ELTEC BAB7xx CHRP\n"); #endif - return (0); + return (0); } /* ------------------------------------------------------------------------- */ int checkflash (void) { - /* TODO: XXX XXX XXX */ - printf ("2 MB ## Test not implemented yet ##\n"); - return (0); + /* TODO: XXX XXX XXX */ + printf ("2 MB ## Test not implemented yet ##\n"); + return (0); } /* ------------------------------------------------------------------------- */ @@ -103,77 +106,75 @@ int checkflash (void) static unsigned int mpc106_read_cfg_dword (unsigned int reg) { - unsigned int reg_addr = MPC106_REG | (reg & 0xFFFFFFFC); + unsigned int reg_addr = MPC106_REG | (reg & 0xFFFFFFFC); - out32r(MPC106_REG_ADDR, reg_addr); + out32r (MPC106_REG_ADDR, reg_addr); - return (in32r(MPC106_REG_DATA | (reg & 0x3))); + return (in32r (MPC106_REG_DATA | (reg & 0x3))); } /* ------------------------------------------------------------------------- */ long int dram_size (int board_type) { - /* No actual initialisation to do - done when setting up - * PICRs MCCRs ME/SARs etc in ram_init.S. - */ + /* No actual initialisation to do - done when setting up + * PICRs MCCRs ME/SARs etc in ram_init.S. + */ - register unsigned long i, msar1, mear1, memSize; + register unsigned long i, msar1, mear1, memSize; #if defined(CFG_MEMTEST) - register unsigned long reg; + register unsigned long reg; - printf("Testing DRAM\n"); + printf ("Testing DRAM\n"); - /* write each mem addr with it's address */ - for (reg = CFG_MEMTEST_START; reg < CFG_MEMTEST_END; reg+=4) - *reg = reg; + /* write each mem addr with it's address */ + for (reg = CFG_MEMTEST_START; reg < CFG_MEMTEST_END; reg += 4) + *reg = reg; - for (reg = CFG_MEMTEST_START; reg < CFG_MEMTEST_END; reg+=4) - { - if (*reg != reg) - return -1; - } + for (reg = CFG_MEMTEST_START; reg < CFG_MEMTEST_END; reg += 4) { + if (*reg != reg) + return -1; + } #endif - /* - * Since MPC106 memory controller chip has already been set to - * control all memory, just read and interpret its memory boundery register. - */ - memSize = 0; - msar1 = mpc106_read_cfg_dword(MPC106_MSAR1); - mear1 = mpc106_read_cfg_dword(MPC106_MEAR1); - i = mpc106_read_cfg_dword(MPC106_MBER) & 0xf; - - do - { - if (i & 0x01) /* is bank enabled ? */ - memSize += (mear1 & 0xff) - (msar1 & 0xff) + 1; - msar1 >>= 8; - mear1 >>= 8; - i >>= 1; - } while (i); - - return (memSize * 0x100000); + /* + * Since MPC106 memory controller chip has already been set to + * control all memory, just read and interpret its memory boundery register. + */ + memSize = 0; + msar1 = mpc106_read_cfg_dword (MPC106_MSAR1); + mear1 = mpc106_read_cfg_dword (MPC106_MEAR1); + i = mpc106_read_cfg_dword (MPC106_MBER) & 0xf; + + do { + if (i & 0x01) /* is bank enabled ? */ + memSize += (mear1 & 0xff) - (msar1 & 0xff) + 1; + msar1 >>= 8; + mear1 >>= 8; + i >>= 1; + } while (i); + + return (memSize * 0x100000); } /* ------------------------------------------------------------------------- */ -long int initdram(int board_type) +long int initdram (int board_type) { - return dram_size(board_type); + return dram_size (board_type); } /* ------------------------------------------------------------------------- */ void after_reloc (ulong dest_addr) { - DECLARE_GLOBAL_DATA_PTR; + DECLARE_GLOBAL_DATA_PTR; - /* - * Jump to the main U-Boot board init code - */ - board_init_r((gd_t *)gd, dest_addr); + /* + * Jump to the main U-Boot board init code + */ + board_init_r ((gd_t *) gd, dest_addr); } /* ------------------------------------------------------------------------- */ @@ -182,14 +183,13 @@ void after_reloc (ulong dest_addr) * do_reset is done here because in this case it is board specific, since the * 7xx CPUs can only be reset by external HW (the RTC in this case). */ -void -do_reset (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) +void do_reset (cmd_tbl_t * cmdtp, bd_t * bd, int flag, int argc, char *argv[]) { #if defined(CONFIG_RTC_MK48T59) - /* trigger watchdog immediately */ - rtc_set_watchdog(1, RTC_WD_RB_16TH); + /* trigger watchdog immediately */ + rtc_set_watchdog (1, RTC_WD_RB_16TH); #else - #error "You must define the macro CONFIG_RTC_MK48T59." +#error "You must define the macro CONFIG_RTC_MK48T59." #endif } @@ -200,16 +200,16 @@ do_reset (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) * Since the 7xx CPUs don't have an internal watchdog, this function is * board specific. We use the RTC here. */ -void watchdog_reset(void) +void watchdog_reset (void) { #if defined(CONFIG_RTC_MK48T59) - /* we use a 32 sec watchdog timer */ - rtc_set_watchdog(8, RTC_WD_RB_4); + /* we use a 32 sec watchdog timer */ + rtc_set_watchdog (8, RTC_WD_RB_4); #else - #error "You must define the macro CONFIG_RTC_MK48T59." +#error "You must define the macro CONFIG_RTC_MK48T59." #endif } -#endif /* CONFIG_WATCHDOG */ +#endif /* CONFIG_WATCHDOG */ /* ------------------------------------------------------------------------- */ @@ -218,29 +218,28 @@ extern GraphicDevice smi; void video_get_info_str (int line_number, char *info) { - /* init video info strings for graphic console */ - switch (line_number) - { - case 1: - sprintf (info," MPC7xx V%d.%d at %ld / %ld MHz", - (get_pvr() >> 8) & 0xFF, - get_pvr() & 0xFF, - bab7xx_get_gclk_freq()/1000000, - bab7xx_get_bus_freq()/1000000); + /* init video info strings for graphic console */ + switch (line_number) { + case 1: + sprintf (info, " MPC7xx V%d.%d at %ld / %ld MHz", + (get_pvr () >> 8) & 0xFF, + get_pvr () & 0xFF, + bab7xx_get_gclk_freq () / 1000000, + bab7xx_get_bus_freq () / 1000000); + return; + case 2: + sprintf (info, + " ELTEC BAB7xx with %ld MB DRAM and %ld MB FLASH", + dram_size (0) / 0x100000, flash_init () / 0x100000); + return; + case 3: + sprintf (info, " %s", smi.modeIdent); + return; + } + + /* no more info lines */ + *info = 0; return; - case 2: - sprintf (info, " ELTEC BAB7xx with %ld MB DRAM and %ld MB FLASH", - dram_size(0)/0x100000, - flash_init()/0x100000); - return; - case 3: - sprintf (info, " %s", smi.modeIdent); - return; - } - - /* no more info lines */ - *info = 0; - return; } #endif diff --git a/board/eltec/elppc/misc.c b/board/eltec/elppc/misc.c index f33aef71bc3..15056606cb9 100644 --- a/board/eltec/elppc/misc.c +++ b/board/eltec/elppc/misc.c @@ -31,32 +31,32 @@ /* imports */ extern char console_buffer[CFG_CBSIZE]; extern int l2_cache_enable (int l2control); -extern int eepro100_write_eeprom (struct eth_device* dev, int location, - int addr_len, unsigned short data); -extern int read_eeprom (struct eth_device* dev, int location, int addr_len); +extern int eepro100_write_eeprom (struct eth_device *dev, int location, + int addr_len, unsigned short data); +extern int read_eeprom (struct eth_device *dev, int location, int addr_len); /*----------------------------------------------------------------------------*/ /* * read/write to nvram is only byte access */ -void *nvram_read(void *dest, const long src, size_t count) +void *nvram_read (void *dest, const long src, size_t count) { - uchar *d = (uchar *) dest; - uchar *s = (uchar *) (CFG_ENV_MAP_ADRS + src); + uchar *d = (uchar *) dest; + uchar *s = (uchar *) (CFG_ENV_MAP_ADRS + src); - while (count--) - *d++ = *s++; + while (count--) + *d++ = *s++; - return dest; + return dest; } -void nvram_write(long dest, const void *src, size_t count) +void nvram_write (long dest, const void *src, size_t count) { - uchar *d = (uchar *) (CFG_ENV_MAP_ADRS + dest); - uchar *s = (uchar *) src; + uchar *d = (uchar *) (CFG_ENV_MAP_ADRS + dest); + uchar *s = (uchar *) src; - while (count--) - *d++ = *s++; + while (count--) + *d++ = *s++; } /*----------------------------------------------------------------------------*/ @@ -67,192 +67,199 @@ void nvram_write(long dest, const void *src, size_t count) */ int misc_init_r (void) { - revinfo eerev; - u_char *ptr; - u_int i, l, initSrom, copyNv; - char buf[256]; - char hex[23] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, - 0, 0, 0, 0, 10, 11, 12, 13, 14, 15 }; - - /* Clock setting for MPC107 i2c */ - mpc107_i2c_init (MPC107_EUMB_ADDR, 0x2b); - - /* Reset the EPIC */ - out32r (MPC107_EUMB_GCR, 0xa0000000); - while (in32r (MPC107_EUMB_GCR) & 0x80000000); /* Wait for reset to complete */ - out32r (MPC107_EUMB_GCR, 0x20000000); /* Put into into mixed mode */ - while (in32r (MPC107_EUMB_IACKR) != 0xff); /* Clear all pending interrupts */ - - /* - * Check/Remake revision info - */ - initSrom = 0; - copyNv = 0; - - /* read out current revision srom contens */ - mpc107_srom_load (0x0000, (u_char*)&eerev, sizeof(revinfo), - SECOND_DEVICE, FIRST_BLOCK); - - /* read out current nvram shadow image */ - nvram_read (buf, CFG_NV_SROM_COPY_ADDR, CFG_SROM_SIZE); - - if (strcmp (eerev.magic, "ELTEC") != 0) - { - /* srom is not initialized -> create a default revision info */ - for (i = 0, ptr = (u_char *)&eerev; i < sizeof(revinfo); i++) - *ptr++ = 0x00; - strcpy(eerev.magic, "ELTEC"); - eerev.revrev[0] = 1; - eerev.revrev[1] = 0; - eerev.size = 0x00E0; - eerev.category[0] = 0x01; - - /* node id from dead e128 as default */ - eerev.etheraddr[0] = 0x00; - eerev.etheraddr[1] = 0x00; - eerev.etheraddr[2] = 0x5B; - eerev.etheraddr[3] = 0x00; - eerev.etheraddr[4] = 0x2E; - eerev.etheraddr[5] = 0x4D; - - /* cache config word for ELPPC */ - *(int*)&eerev.res[0] = 0; - - initSrom = 1; /* force dialog */ - copyNv = 1; /* copy to nvram */ - } - - if ((copyNv == 0) && (el_srom_checksum((u_char*)&eerev, CFG_SROM_SIZE) != - el_srom_checksum((u_char*)buf, CFG_SROM_SIZE))) - { - printf ("Invalid revision info copy in nvram !\n"); - printf ("Press key:\n to copy current revision info to nvram.\n"); - printf (" to reenter revision info.\n"); - printf ("=> "); - if (0 != readline (NULL)) - { - switch ((char)toupper(console_buffer[0])) - { - case 'C': - copyNv = 1; - break; - case 'R': - copyNv = 1; - initSrom = 1; - break; - } - } - } - - if (initSrom) - { - memcpy (buf, &eerev.revision[0][0], 14); /* save all revision info */ - printf ("Enter revision number (0-9): %c ", eerev.revision[0][0]); - if (0 != readline (NULL)) - { - eerev.revision[0][0] = (char)toupper(console_buffer[0]); - memcpy (&eerev.revision[1][0], buf, 12); /* shift rest of rev info */ - } - - printf ("Enter revision character (A-Z): %c ", eerev.revision[0][1]); - if (1 == readline (NULL)) - { - eerev.revision[0][1] = (char)toupper(console_buffer[0]); + revinfo eerev; + u_char *ptr; + u_int i, l, initSrom, copyNv; + char buf[256]; + char hex[23] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, + 0, 0, 0, 0, 10, 11, 12, 13, 14, 15 + }; + + /* Clock setting for MPC107 i2c */ + mpc107_i2c_init (MPC107_EUMB_ADDR, 0x2b); + + /* Reset the EPIC */ + out32r (MPC107_EUMB_GCR, 0xa0000000); + while (in32r (MPC107_EUMB_GCR) & 0x80000000); /* Wait for reset to complete */ + out32r (MPC107_EUMB_GCR, 0x20000000); /* Put into into mixed mode */ + while (in32r (MPC107_EUMB_IACKR) != 0xff); /* Clear all pending interrupts */ + + /* + * Check/Remake revision info + */ + initSrom = 0; + copyNv = 0; + + /* read out current revision srom contens */ + mpc107_srom_load (0x0000, (u_char *) & eerev, sizeof (revinfo), + SECOND_DEVICE, FIRST_BLOCK); + + /* read out current nvram shadow image */ + nvram_read (buf, CFG_NV_SROM_COPY_ADDR, CFG_SROM_SIZE); + + if (strcmp (eerev.magic, "ELTEC") != 0) { + /* srom is not initialized -> create a default revision info */ + for (i = 0, ptr = (u_char *) & eerev; i < sizeof (revinfo); + i++) + *ptr++ = 0x00; + strcpy (eerev.magic, "ELTEC"); + eerev.revrev[0] = 1; + eerev.revrev[1] = 0; + eerev.size = 0x00E0; + eerev.category[0] = 0x01; + + /* node id from dead e128 as default */ + eerev.etheraddr[0] = 0x00; + eerev.etheraddr[1] = 0x00; + eerev.etheraddr[2] = 0x5B; + eerev.etheraddr[3] = 0x00; + eerev.etheraddr[4] = 0x2E; + eerev.etheraddr[5] = 0x4D; + + /* cache config word for ELPPC */ + *(int *) &eerev.res[0] = 0; + + initSrom = 1; /* force dialog */ + copyNv = 1; /* copy to nvram */ } - printf ("Enter board name (V-XXXX-XXXX): %s ", (char *)&eerev.board); - if (11 == readline (NULL)) - { - for (i=0; i<11; i++) - eerev.board[i] = (char)toupper(console_buffer[i]); - eerev.board[11] = '\0'; + if ((copyNv == 0) + && (el_srom_checksum ((u_char *) & eerev, CFG_SROM_SIZE) != + el_srom_checksum ((u_char *) buf, CFG_SROM_SIZE))) { + printf ("Invalid revision info copy in nvram !\n"); + printf ("Press key:\n to copy current revision info to nvram.\n"); + printf (" to reenter revision info.\n"); + printf ("=> "); + if (0 != readline (NULL)) { + switch ((char) toupper (console_buffer[0])) { + case 'C': + copyNv = 1; + break; + case 'R': + copyNv = 1; + initSrom = 1; + break; + } + } } - printf ("Enter serial number: %s ", (char *)&eerev.serial ); - if (6 == readline (NULL)) - { - for (i=0; i<6; i++) - eerev.serial[i] = console_buffer[i]; - eerev.serial[6] = '\0'; - } - - printf ("Enter ether node ID with leading zero (HEX): %02x%02x%02x%02x%02x%02x ", - eerev.etheraddr[0], eerev.etheraddr[1], - eerev.etheraddr[2], eerev.etheraddr[3], - eerev.etheraddr[4], eerev.etheraddr[5]); - if (12 == readline (NULL)) - { - for (i=0; i<12; i+=2) - eerev.etheraddr[i>>1] = (char)(16*hex[toupper(console_buffer[i])-'0'] + - hex[toupper(console_buffer[i+1])-'0']); - } + if (initSrom) { + memcpy (buf, &eerev.revision[0][0], 14); /* save all revision info */ + printf ("Enter revision number (0-9): %c ", + eerev.revision[0][0]); + if (0 != readline (NULL)) { + eerev.revision[0][0] = + (char) toupper (console_buffer[0]); + memcpy (&eerev.revision[1][0], buf, 12); /* shift rest of rev info */ + } + + printf ("Enter revision character (A-Z): %c ", + eerev.revision[0][1]); + if (1 == readline (NULL)) { + eerev.revision[0][1] = + (char) toupper (console_buffer[0]); + } + + printf ("Enter board name (V-XXXX-XXXX): %s ", + (char *) &eerev.board); + if (11 == readline (NULL)) { + for (i = 0; i < 11; i++) + eerev.board[i] = + (char) toupper (console_buffer[i]); + eerev.board[11] = '\0'; + } + + printf ("Enter serial number: %s ", (char *) &eerev.serial); + if (6 == readline (NULL)) { + for (i = 0; i < 6; i++) + eerev.serial[i] = console_buffer[i]; + eerev.serial[6] = '\0'; + } + + printf ("Enter ether node ID with leading zero (HEX): %02x%02x%02x%02x%02x%02x ", eerev.etheraddr[0], eerev.etheraddr[1], eerev.etheraddr[2], eerev.etheraddr[3], eerev.etheraddr[4], eerev.etheraddr[5]); + if (12 == readline (NULL)) { + for (i = 0; i < 12; i += 2) + eerev.etheraddr[i >> 1] = + (char) (16 * + hex[toupper + (console_buffer[i]) - + '0'] + + hex[toupper + (console_buffer[i + 1]) - + '0']); + } + + l = strlen ((char *) &eerev.text); + printf ("Add to text section (max 64 chr): %s ", + (char *) &eerev.text); + if (0 != readline (NULL)) { + for (i = l; i < 63; i++) + eerev.text[i] = console_buffer[i - l]; + eerev.text[63] = '\0'; + } + + /* prepare network eeprom */ + memset (buf, 0, 128); + + buf[0] = eerev.etheraddr[1]; + buf[1] = eerev.etheraddr[0]; + buf[2] = eerev.etheraddr[3]; + buf[3] = eerev.etheraddr[2]; + buf[4] = eerev.etheraddr[5]; + buf[5] = eerev.etheraddr[4]; + + *(unsigned short *) &buf[20] = 0x48B2; + *(unsigned short *) &buf[22] = 0x0004; + *(unsigned short *) &buf[24] = 0x1433; + + printf ("\nSRom: Writing i82559 info ........ "); + if (eepro100_srom_store ((unsigned short *) buf) == -1) + printf ("FAILED\n"); + else + printf ("OK\n"); + + /* update CRC */ + eerev.crc = + el_srom_checksum ((u_char *) eerev.board, eerev.size); + + /* write new values */ + printf ("\nSRom: Writing revision info ...... "); + if (mpc107_srom_store + ((BLOCK_SIZE - sizeof (revinfo)), (u_char *) & eerev, + sizeof (revinfo), SECOND_DEVICE, FIRST_BLOCK) == -1) + printf ("FAILED\n\n"); + else + printf ("OK\n\n"); + + /* write new values as shadow image to nvram */ + nvram_write (CFG_NV_SROM_COPY_ADDR, (void *) &eerev, + CFG_SROM_SIZE); - l = strlen ((char *)&eerev.text); - printf("Add to text section (max 64 chr): %s ", (char *)&eerev.text ); - if (0 != readline (NULL)) - { - for (i = l; i<63; i++) - eerev.text[i] = console_buffer[i-l]; - eerev.text[63] = '\0'; } - /* prepare network eeprom */ - memset (buf, 0, 128); - - buf[0] = eerev.etheraddr[1]; - buf[1] = eerev.etheraddr[0]; - buf[2] = eerev.etheraddr[3]; - buf[3] = eerev.etheraddr[2]; - buf[4] = eerev.etheraddr[5]; - buf[5] = eerev.etheraddr[4]; - - *(unsigned short *)&buf[20] = 0x48B2; - *(unsigned short *)&buf[22] = 0x0004; - *(unsigned short *)&buf[24] = 0x1433; - - printf("\nSRom: Writing i82559 info ........ "); - if (eepro100_srom_store ((unsigned short *)buf) == -1) - printf("FAILED\n"); - else - printf("OK\n"); - - /* update CRC */ - eerev.crc = el_srom_checksum((u_char *)eerev.board, eerev.size); - - /* write new values */ - printf("\nSRom: Writing revision info ...... "); - if (mpc107_srom_store((BLOCK_SIZE-sizeof(revinfo)), (u_char *)&eerev, - sizeof(revinfo), SECOND_DEVICE, FIRST_BLOCK) == -1) - printf("FAILED\n\n"); - else - printf("OK\n\n"); - - /* write new values as shadow image to nvram */ - nvram_write (CFG_NV_SROM_COPY_ADDR, (void *)&eerev, CFG_SROM_SIZE); - - } /*if (initSrom) */ - - /* copy current values as shadow image to nvram */ - if (initSrom == 0 && copyNv == 1) - nvram_write (CFG_NV_SROM_COPY_ADDR, (void *)&eerev, CFG_SROM_SIZE); - - /* update environment */ - sprintf (buf, "%02x:%02x:%02x:%02x:%02x:%02x", - eerev.etheraddr[0], eerev.etheraddr[1], - eerev.etheraddr[2], eerev.etheraddr[3], - eerev.etheraddr[4], eerev.etheraddr[5]); - setenv ("ethaddr", buf); - - /* set serial console as default */ - if ((ptr = getenv ("console")) == NULL) - setenv ("console", "serial"); - - /* print actual board identification */ - printf("Ident: %s Ser %s Rev %c%c\n", - eerev.board, (char *)&eerev.serial, - eerev.revision[0][0], eerev.revision[0][1]); - - return (0); + /*if (initSrom) */ + /* copy current values as shadow image to nvram */ + if (initSrom == 0 && copyNv == 1) + nvram_write (CFG_NV_SROM_COPY_ADDR, (void *) &eerev, + CFG_SROM_SIZE); + + /* update environment */ + sprintf (buf, "%02x:%02x:%02x:%02x:%02x:%02x", + eerev.etheraddr[0], eerev.etheraddr[1], + eerev.etheraddr[2], eerev.etheraddr[3], + eerev.etheraddr[4], eerev.etheraddr[5]); + setenv ("ethaddr", buf); + + /* set serial console as default */ + if ((ptr = getenv ("console")) == NULL) + setenv ("console", "serial"); + + /* print actual board identification */ + printf ("Ident: %s Ser %s Rev %c%c\n", + eerev.board, (char *) &eerev.serial, + eerev.revision[0][0], eerev.revision[0][1]); + + return (0); } /*----------------------------------------------------------------------------*/ diff --git a/board/eltec/mhpc/mhpc.c b/board/eltec/mhpc/mhpc.c index 76f9f372b1c..bc3d9f4c628 100644 --- a/board/eltec/mhpc/mhpc.c +++ b/board/eltec/mhpc/mhpc.c @@ -38,19 +38,19 @@ /* imports from common/main.c */ extern char console_buffer[CFG_CBSIZE]; -extern void eeprom_init (void); -extern int eeprom_read (unsigned dev_addr, unsigned offset, - unsigned char *buffer, unsigned cnt); -extern int eeprom_write (unsigned dev_addr, unsigned offset, - unsigned char *buffer, unsigned cnt); +extern void eeprom_init (void); +extern int eeprom_read (unsigned dev_addr, unsigned offset, + unsigned char *buffer, unsigned cnt); +extern int eeprom_write (unsigned dev_addr, unsigned offset, + unsigned char *buffer, unsigned cnt); /* globals */ -void *video_hw_init(void); -void video_set_lut (unsigned int index, /* color number */ - unsigned char r, /* red */ - unsigned char g, /* green */ - unsigned char b /* blue */ - ); +void *video_hw_init (void); +void video_set_lut (unsigned int index, /* color number */ + unsigned char r, /* red */ + unsigned char g, /* green */ + unsigned char b /* blue */ + ); GraphicDevice gdev; @@ -60,79 +60,78 @@ static void video_test_image (void); static void video_default_lut (unsigned int clut_type); /* revision info foer MHPC EEPROM offset 480 */ -typedef struct { - char board[12]; /* 000 - Board Revision information */ - char sensor; /* 012 - Sensor Type information */ - char serial[8]; /* 013 - Board serial number */ - char etheraddr[6]; /* 021 - Ethernet node addresse */ - char revision[2]; /* 027 - Revision code */ - char option[3]; /* 029 - resevered for options */ +typedef struct { + char board[12]; /* 000 - Board Revision information */ + char sensor; /* 012 - Sensor Type information */ + char serial[8]; /* 013 - Board serial number */ + char etheraddr[6]; /* 021 - Ethernet node addresse */ + char revision[2]; /* 027 - Revision code */ + char option[3]; /* 029 - resevered for options */ } revinfo; /* ------------------------------------------------------------------------- */ -static const unsigned int sdram_table[] = -{ - /* read single beat cycle */ - 0xef0efc04, 0x0e2dac04, 0x01ba5c04, 0x1ff5fc00, - 0xfffffc05, 0xeffafc34, 0x0ff0bc34, 0x1ff57c35, - - /* read burst cycle */ - 0xef0efc04, 0x0e3dac04, 0x10ff5c04, 0xf0fffc00, - 0xf0fffc00, 0xf1fffc00, 0xfffffc00, 0xfffffc05, - 0xfffffc04, 0xfffffc04, 0xfffffc04, 0xfffffc04, - 0xfffffc04, 0xfffffc04, 0xfffffc04, 0xfffffc04, - - /* write single beat cycle */ - 0xef0efc04, 0x0e29ac00, 0x01b25c04, 0x1ff5fc05, - 0xfffffc04, 0xfffffc04, 0xfffffc04, 0xfffffc04, - - /* write burst cycle */ - 0xef0ef804, 0x0e39a000, 0x10f75000, 0xf0fff440, - 0xf0fffc40, 0xf1fffc04, 0xfffffc05, 0xfffffc04, - 0xfffffc04, 0xfffffc04, 0xfffffc04, 0xfffffc04, - 0xfffffc04, 0xfffffc04, 0xfffffc04, 0xfffffc04, - - /* periodic timer expired */ - 0xeffebc84, 0x1ffd7c04, 0xfffffc04, 0xfffffc84, - 0xeffebc04, 0x1ffd7c04, 0xfffffc04, 0xfffffc05, - 0xfffffc04, 0xfffffc04, 0xfffffc04, 0xfffffc04, - - /* exception */ - 0xfffffc04, 0xfffffc05, 0xfffffc04, 0xfffffc04 +static const unsigned int sdram_table[] = { + /* read single beat cycle */ + 0xef0efc04, 0x0e2dac04, 0x01ba5c04, 0x1ff5fc00, + 0xfffffc05, 0xeffafc34, 0x0ff0bc34, 0x1ff57c35, + + /* read burst cycle */ + 0xef0efc04, 0x0e3dac04, 0x10ff5c04, 0xf0fffc00, + 0xf0fffc00, 0xf1fffc00, 0xfffffc00, 0xfffffc05, + 0xfffffc04, 0xfffffc04, 0xfffffc04, 0xfffffc04, + 0xfffffc04, 0xfffffc04, 0xfffffc04, 0xfffffc04, + + /* write single beat cycle */ + 0xef0efc04, 0x0e29ac00, 0x01b25c04, 0x1ff5fc05, + 0xfffffc04, 0xfffffc04, 0xfffffc04, 0xfffffc04, + + /* write burst cycle */ + 0xef0ef804, 0x0e39a000, 0x10f75000, 0xf0fff440, + 0xf0fffc40, 0xf1fffc04, 0xfffffc05, 0xfffffc04, + 0xfffffc04, 0xfffffc04, 0xfffffc04, 0xfffffc04, + 0xfffffc04, 0xfffffc04, 0xfffffc04, 0xfffffc04, + + /* periodic timer expired */ + 0xeffebc84, 0x1ffd7c04, 0xfffffc04, 0xfffffc84, + 0xeffebc04, 0x1ffd7c04, 0xfffffc04, 0xfffffc05, + 0xfffffc04, 0xfffffc04, 0xfffffc04, 0xfffffc04, + + /* exception */ + 0xfffffc04, 0xfffffc05, 0xfffffc04, 0xfffffc04 }; /* ------------------------------------------------------------------------- */ int board_early_init_f (void) { - volatile immap_t *im = (immap_t *)CFG_IMMR; - volatile cpm8xx_t *cp = &(im->im_cpm); - volatile iop8xx_t *ip = (iop8xx_t *)&(im->im_ioport); - - /* reset the port A s.a. cpm-routines */ - ip->iop_padat = 0x0000; - ip->iop_papar = 0x0000; - ip->iop_padir = 0x0800; - ip->iop_paodr = 0x0000; - - /* reset the port B for digital and LCD output */ - cp->cp_pbdat = 0x0300; - cp->cp_pbpar = 0x5001; - cp->cp_pbdir = 0x5301; - cp->cp_pbodr = 0x0000; - - /* reset the port C configured for SMC1 serial port and aqc. control */ - ip->iop_pcdat = 0x0800; - ip->iop_pcpar = 0x0000; - ip->iop_pcdir = 0x0e30; - ip->iop_pcso = 0x0000; - - /* Config port D for LCD output */ - ip->iop_pdpar = 0x1fff; - ip->iop_pddir = 0x1fff; - - return (0); + volatile immap_t *im = (immap_t *) CFG_IMMR; + volatile cpm8xx_t *cp = &(im->im_cpm); + volatile iop8xx_t *ip = (iop8xx_t *) & (im->im_ioport); + + /* reset the port A s.a. cpm-routines */ + ip->iop_padat = 0x0000; + ip->iop_papar = 0x0000; + ip->iop_padir = 0x0800; + ip->iop_paodr = 0x0000; + + /* reset the port B for digital and LCD output */ + cp->cp_pbdat = 0x0300; + cp->cp_pbpar = 0x5001; + cp->cp_pbdir = 0x5301; + cp->cp_pbodr = 0x0000; + + /* reset the port C configured for SMC1 serial port and aqc. control */ + ip->iop_pcdat = 0x0800; + ip->iop_pcpar = 0x0000; + ip->iop_pcdir = 0x0e30; + ip->iop_pcso = 0x0000; + + /* Config port D for LCD output */ + ip->iop_pdpar = 0x1fff; + ip->iop_pddir = 0x1fff; + + return (0); } /* ------------------------------------------------------------------------- */ @@ -142,322 +141,327 @@ int board_early_init_f (void) */ int checkboard (void) { - puts ("Board: ELTEC miniHiperCam\n"); - return(0); + puts ("Board: ELTEC miniHiperCam\n"); + return (0); } /* ------------------------------------------------------------------------- */ -int misc_init_r(void) +int misc_init_r (void) { - revinfo mhpcRevInfo; - char nid[32]; - char *mhpcSensorTypes[] = { "OMNIVISON OV7610/7620 color", - "OMNIVISON OV7110 b&w", NULL }; - char hex[23] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, - 0, 0, 0, 0, 10, 11, 12, 13, 14, 15 }; - int i; - - /* check revision data */ - eeprom_read (CFG_I2C_EEPROM_ADDR, 480, (char*)&mhpcRevInfo, 32); - - if (strncmp((char *)&mhpcRevInfo.board[2], "MHPC", 4) != 0) - { - printf ("Enter revision number (0-9): %c ", mhpcRevInfo.revision[0]); - if (0 != readline (NULL)) - { - mhpcRevInfo.revision[0] = (char)toupper(console_buffer[0]); - } - - printf ("Enter revision character (A-Z): %c ", mhpcRevInfo.revision[1]); - if (1 == readline (NULL)) - { - mhpcRevInfo.revision[1] = (char)toupper(console_buffer[0]); - } - - printf("Enter board name (V-XXXX-XXXX): %s ", (char *)&mhpcRevInfo.board); - if (11 == readline (NULL)) - { - for (i=0; i<11; i++) - { - mhpcRevInfo.board[i] = (char)toupper(console_buffer[i]); - mhpcRevInfo.board[11] = '\0'; - } - } - - printf("Supported sensor types:\n"); - i=0; - do - { - printf("\n \'%d\' : %s\n", i, mhpcSensorTypes[i]); - } while ( mhpcSensorTypes[++i] != NULL ); - - do - { - printf("\nEnter sensor number (0-255): %d ", (int)mhpcRevInfo.sensor ); - if (0 != readline (NULL)) - { - mhpcRevInfo.sensor = (unsigned char)simple_strtoul(console_buffer, NULL, 10); - } - } while ( mhpcRevInfo.sensor >= i ); - - printf("Enter serial number: %s ", (char *)&mhpcRevInfo.serial ); - if (6 == readline (NULL)) - { - for (i=0; i<6; i++) - { - mhpcRevInfo.serial[i] = console_buffer[i]; - } - mhpcRevInfo.serial[6] = '\0'; - } - - printf("Enter ether node ID with leading zero (HEX): %02x%02x%02x%02x%02x%02x ", - mhpcRevInfo.etheraddr[0], mhpcRevInfo.etheraddr[1], - mhpcRevInfo.etheraddr[2], mhpcRevInfo.etheraddr[3], - mhpcRevInfo.etheraddr[4], mhpcRevInfo.etheraddr[5] ); - if (12 == readline (NULL)) - { - for (i=0; i<12; i+=2) - { - mhpcRevInfo.etheraddr[i>>1] = (char)(16*hex[toupper(console_buffer[i])-'0'] + - hex[toupper(console_buffer[i+1])-'0']); + revinfo mhpcRevInfo; + char nid[32]; + char *mhpcSensorTypes[] = { "OMNIVISON OV7610/7620 color", + "OMNIVISON OV7110 b&w", NULL + }; + char hex[23] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, + 0, 0, 0, 0, 10, 11, 12, 13, 14, 15 + }; + int i; + + /* check revision data */ + eeprom_read (CFG_I2C_EEPROM_ADDR, 480, (char *) &mhpcRevInfo, 32); + + if (strncmp ((char *) &mhpcRevInfo.board[2], "MHPC", 4) != 0) { + printf ("Enter revision number (0-9): %c ", + mhpcRevInfo.revision[0]); + if (0 != readline (NULL)) { + mhpcRevInfo.revision[0] = + (char) toupper (console_buffer[0]); + } + + printf ("Enter revision character (A-Z): %c ", + mhpcRevInfo.revision[1]); + if (1 == readline (NULL)) { + mhpcRevInfo.revision[1] = + (char) toupper (console_buffer[0]); + } + + printf ("Enter board name (V-XXXX-XXXX): %s ", + (char *) &mhpcRevInfo.board); + if (11 == readline (NULL)) { + for (i = 0; i < 11; i++) { + mhpcRevInfo.board[i] = + (char) toupper (console_buffer[i]); + mhpcRevInfo.board[11] = '\0'; + } + } + + printf ("Supported sensor types:\n"); + i = 0; + do { + printf ("\n \'%d\' : %s\n", i, mhpcSensorTypes[i]); + } while (mhpcSensorTypes[++i] != NULL); + + do { + printf ("\nEnter sensor number (0-255): %d ", + (int) mhpcRevInfo.sensor); + if (0 != readline (NULL)) { + mhpcRevInfo.sensor = + (unsigned char) + simple_strtoul (console_buffer, NULL, + 10); + } + } while (mhpcRevInfo.sensor >= i); + + printf ("Enter serial number: %s ", + (char *) &mhpcRevInfo.serial); + if (6 == readline (NULL)) { + for (i = 0; i < 6; i++) { + mhpcRevInfo.serial[i] = console_buffer[i]; + } + mhpcRevInfo.serial[6] = '\0'; + } + + printf ("Enter ether node ID with leading zero (HEX): %02x%02x%02x%02x%02x%02x ", mhpcRevInfo.etheraddr[0], mhpcRevInfo.etheraddr[1], mhpcRevInfo.etheraddr[2], mhpcRevInfo.etheraddr[3], mhpcRevInfo.etheraddr[4], mhpcRevInfo.etheraddr[5]); + if (12 == readline (NULL)) { + for (i = 0; i < 12; i += 2) { + mhpcRevInfo.etheraddr[i >> 1] = + (char) (16 * + hex[toupper + (console_buffer[i]) - + '0'] + + hex[toupper + (console_buffer[i + 1]) - + '0']); + } + } + + /* setup new revision data */ + eeprom_write (CFG_I2C_EEPROM_ADDR, 480, (char *) &mhpcRevInfo, + 32); } - } - - /* setup new revision data */ - eeprom_write (CFG_I2C_EEPROM_ADDR, 480, (char*)&mhpcRevInfo, 32); - } - - /* set environment */ - sprintf( nid, "%02x:%02x:%02x:%02x:%02x:%02x", - mhpcRevInfo.etheraddr[0], mhpcRevInfo.etheraddr[1], - mhpcRevInfo.etheraddr[2], mhpcRevInfo.etheraddr[3], - mhpcRevInfo.etheraddr[4], mhpcRevInfo.etheraddr[5]); - setenv("ethaddr", nid); - - /* print actual board identification */ - printf("Ident: %s %s Ser %s Rev %c%c\n", - mhpcRevInfo.board, (mhpcRevInfo.sensor==0?"color":"b&w"), - (char *)&mhpcRevInfo.serial, - mhpcRevInfo.revision[0], mhpcRevInfo.revision[1]); - - return (0); + + /* set environment */ + sprintf (nid, "%02x:%02x:%02x:%02x:%02x:%02x", + mhpcRevInfo.etheraddr[0], mhpcRevInfo.etheraddr[1], + mhpcRevInfo.etheraddr[2], mhpcRevInfo.etheraddr[3], + mhpcRevInfo.etheraddr[4], mhpcRevInfo.etheraddr[5]); + setenv ("ethaddr", nid); + + /* print actual board identification */ + printf ("Ident: %s %s Ser %s Rev %c%c\n", + mhpcRevInfo.board, + (mhpcRevInfo.sensor == 0 ? "color" : "b&w"), + (char *) &mhpcRevInfo.serial, mhpcRevInfo.revision[0], + mhpcRevInfo.revision[1]); + + return (0); } /* ------------------------------------------------------------------------- */ long int initdram (int board_type) { - volatile immap_t *immap = (immap_t *)CFG_IMMR; - volatile memctl8xx_t *memctl = &immap->im_memctl; - - upmconfig(UPMA, (uint *)sdram_table, sizeof(sdram_table)/sizeof(uint)); - - memctl->memc_mamr = CFG_MAMR & (~(MAMR_PTAE)); /* no refresh yet */ - memctl->memc_mbmr = MBMR_GPL_B4DIS; /* should this be mamr? - NTL */ - memctl->memc_mptpr = MPTPR_PTP_DIV64; - memctl->memc_mar = 0x00008800; - - /* - * Map controller SDRAM bank 0 - */ - memctl->memc_or1 = CFG_OR1_PRELIM; - memctl->memc_br1 = CFG_BR1_PRELIM; - udelay(200); - - /* - * Map controller SDRAM bank 1 - */ - memctl->memc_or2 = CFG_OR2; - memctl->memc_br2 = CFG_BR2; - - /* - * Perform SDRAM initializsation sequence - */ - memctl->memc_mcr = 0x80002105; /* SDRAM bank 0 */ - udelay(1); - memctl->memc_mcr = 0x80002730; /* SDRAM bank 0 - execute twice */ - udelay(1); - memctl->memc_mamr |= MAMR_PTAE; /* enable refresh */ - - udelay(10000); - - /* leave place for framebuffers */ - return (SDRAM_MAX_SIZE-SDRAM_RES_SIZE); + volatile immap_t *immap = (immap_t *) CFG_IMMR; + volatile memctl8xx_t *memctl = &immap->im_memctl; + + upmconfig (UPMA, (uint *) sdram_table, + sizeof (sdram_table) / sizeof (uint)); + + memctl->memc_mamr = CFG_MAMR & (~(MAMR_PTAE)); /* no refresh yet */ + memctl->memc_mbmr = MBMR_GPL_B4DIS; /* should this be mamr? - NTL */ + memctl->memc_mptpr = MPTPR_PTP_DIV64; + memctl->memc_mar = 0x00008800; + + /* + * Map controller SDRAM bank 0 + */ + memctl->memc_or1 = CFG_OR1_PRELIM; + memctl->memc_br1 = CFG_BR1_PRELIM; + udelay (200); + + /* + * Map controller SDRAM bank 1 + */ + memctl->memc_or2 = CFG_OR2; + memctl->memc_br2 = CFG_BR2; + + /* + * Perform SDRAM initializsation sequence + */ + memctl->memc_mcr = 0x80002105; /* SDRAM bank 0 */ + udelay (1); + memctl->memc_mcr = 0x80002730; /* SDRAM bank 0 - execute twice */ + udelay (1); + memctl->memc_mamr |= MAMR_PTAE; /* enable refresh */ + + udelay (10000); + + /* leave place for framebuffers */ + return (SDRAM_MAX_SIZE - SDRAM_RES_SIZE); } /* ------------------------------------------------------------------------- */ static void video_circle (char *center, int radius, int color, int pitch) { - int x,y,d,dE,dSE; - - x = 0; - y = radius; - d = 1-radius; - dE = 3; - dSE = -2*radius+5; - - *(center+x+y*pitch) = color; - *(center+y+x*pitch) = color; - *(center+y-x*pitch) = color; - *(center+x-y*pitch) = color; - *(center-x-y*pitch) = color; - *(center-y-x*pitch) = color; - *(center-y+x*pitch) = color; - *(center-x+y*pitch) = color; - while(y>x) - { - if (d<0) - { - d += dE; - dE += 2; - dSE += 2; - x++; + int x, y, d, dE, dSE; + + x = 0; + y = radius; + d = 1 - radius; + dE = 3; + dSE = -2 * radius + 5; + + *(center + x + y * pitch) = color; + *(center + y + x * pitch) = color; + *(center + y - x * pitch) = color; + *(center + x - y * pitch) = color; + *(center - x - y * pitch) = color; + *(center - y - x * pitch) = color; + *(center - y + x * pitch) = color; + *(center - x + y * pitch) = color; + while (y > x) { + if (d < 0) { + d += dE; + dE += 2; + dSE += 2; + x++; + } else { + d += dSE; + dE += 2; + dSE += 4; + x++; + y--; + } + *(center + x + y * pitch) = color; + *(center + y + x * pitch) = color; + *(center + y - x * pitch) = color; + *(center + x - y * pitch) = color; + *(center - x - y * pitch) = color; + *(center - y - x * pitch) = color; + *(center - y + x * pitch) = color; + *(center - x + y * pitch) = color; } - else - { - d += dSE; - dE += 2; - dSE += 4; - x++; - y--; - } - *(center+x+y*pitch) = color; - *(center+y+x*pitch) = color; - *(center+y-x*pitch) = color; - *(center+x-y*pitch) = color; - *(center-x-y*pitch) = color; - *(center-y-x*pitch) = color; - *(center-y+x*pitch) = color; - *(center-x+y*pitch) = color; - } } /* ------------------------------------------------------------------------- */ -static void video_test_image(void) +static void video_test_image (void) { - char *di; - int i, n; - - /* draw raster */ - for (i=0; iim_lcd.lcd_lccr = 0x96000866; - - /* config LCD regs. */ - immr->im_lcd.lcd_lcfaa = LCD_VIDEO_ADDR; - immr->im_lcd.lcd_lchcr = 0x010a0093; - immr->im_lcd.lcd_lcvcr = 0x900f0024; - - printf ("Video: 640x480 8Bit Index Lut %s\n", - (clut==1?"240/16 (gray/vga)":"256(gray)")); - - video_default_lut (clut); - - /* clear framebuffer */ - memset ( (char*)(LCD_VIDEO_ADDR), LCD_VIDEO_BG, LCD_VIDEO_ROWS*LCD_VIDEO_COLS ); - - /* enable graphic */ - immr->im_lcd.lcd_lccr = 0x96000867; - - /* fill in Graphic Device */ - gdev.frameAdrs = LCD_VIDEO_ADDR; - gdev.winSizeX = LCD_VIDEO_COLS; - gdev.winSizeY = LCD_VIDEO_ROWS; - gdev.gdfBytesPP = 1; - gdev.gdfIndex = GDF__8BIT_INDEX; - - if (clut > 1) - /* return Graphic Device for console */ - return (void *)&gdev; - else - /* just graphic enabled - draw something beautiful */ - video_test_image(); - - return NULL; /* this disabels cfb - console */ + unsigned int clut = 0; + unsigned char *penv; + immap_t *immr = (immap_t *) CFG_IMMR; + + /* enable video only on CLUT value */ + if ((penv = getenv ("clut")) != NULL) + clut = (u_int) simple_strtoul (penv, NULL, 10); + else + return NULL; + + /* disable graphic before write LCD regs. */ + immr->im_lcd.lcd_lccr = 0x96000866; + + /* config LCD regs. */ + immr->im_lcd.lcd_lcfaa = LCD_VIDEO_ADDR; + immr->im_lcd.lcd_lchcr = 0x010a0093; + immr->im_lcd.lcd_lcvcr = 0x900f0024; + + printf ("Video: 640x480 8Bit Index Lut %s\n", + (clut == 1 ? "240/16 (gray/vga)" : "256(gray)")); + + video_default_lut (clut); + + /* clear framebuffer */ + memset ((char *) (LCD_VIDEO_ADDR), LCD_VIDEO_BG, + LCD_VIDEO_ROWS * LCD_VIDEO_COLS); + + /* enable graphic */ + immr->im_lcd.lcd_lccr = 0x96000867; + + /* fill in Graphic Device */ + gdev.frameAdrs = LCD_VIDEO_ADDR; + gdev.winSizeX = LCD_VIDEO_COLS; + gdev.winSizeY = LCD_VIDEO_ROWS; + gdev.gdfBytesPP = 1; + gdev.gdfIndex = GDF__8BIT_INDEX; + + if (clut > 1) + /* return Graphic Device for console */ + return (void *) &gdev; + else + /* just graphic enabled - draw something beautiful */ + video_test_image (); + + return NULL; /* this disabels cfb - console */ } /* ------------------------------------------------------------------------- */ @@ -465,13 +469,15 @@ void *video_hw_init (void) void video_set_lut (unsigned int index, unsigned char r, unsigned char g, unsigned char b) { - unsigned int lum; - unsigned short *pLut = (unsigned short *)(CFG_IMMR + 0x0e00); - - /* 16 bit lut values, 12 bit used, xxxx BBGG RRii iiii */ - /* y = 0.299*R + 0.587*G + 0.114*B */ - lum = (2990*r + 5870*g + 1140*b)/10000; - pLut[index] = ((b & 0xc0)<<4) | ((g & 0xc0)<<2) | (r & 0xc0) | (lum & 0x3f); + unsigned int lum; + unsigned short *pLut = (unsigned short *) (CFG_IMMR + 0x0e00); + + /* 16 bit lut values, 12 bit used, xxxx BBGG RRii iiii */ + /* y = 0.299*R + 0.587*G + 0.114*B */ + lum = (2990 * r + 5870 * g + 1140 * b) / 10000; + pLut[index] = + ((b & 0xc0) << 4) | ((g & 0xc0) << 2) | (r & 0xc0) | (lum & + 0x3f); } /* ------------------------------------------------------------------------- */ -- cgit v1.2.3