From: hackbard Date: Sat, 1 Sep 2007 23:37:44 +0000 (+0200) Subject: stupid mistake!!! + reorg of functions X-Git-Url: https://hackdaworld.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d9929818aa52c56daa1d89d1753e171b45c8608a;p=my-code%2Farm.git stupid mistake!!! + reorg of functions --- diff --git a/betty/fwflash.c b/betty/fwflash.c index 2704fd5..f138dc1 100644 --- a/betty/fwflash.c +++ b/betty/fwflash.c @@ -68,6 +68,8 @@ unsigned long sector_address[19]={ * functions */ +void uart0_send_byte(u8 send); + void mmap_init(u8 memtype) { MEMMAP=memtype; @@ -86,105 +88,6 @@ void pll_init(void) { continue; } -int flash_sector_erase(u8 flash,u8 sector) { - - u32 a18_12; - u32 base; - - if(sector>18) - return -1; - a18_12=sector_address[sector]<<1; - - if((flash!='0')|(flash!='2')) - return -1; - - switch(flash) { - case '0': - base=0x80000000; - B0F555=0xaa; - B0F2AA=0x55; - B0F555=0x80; - B0F555=0xaa; - B0F2AA=0x55; - *((volatile u16 *)(base|a18_12))=0x30; - break; - case '2': - base=0x82000000; - B2F555=0xaa; - B2F2AA=0x55; - B2F555=0x80; - B2F555=0xaa; - B2F2AA=0x55; - *((volatile u16 *)(base|a18_12))=0x30; - break; - default: - return -1; - } - - return 0; -} - -int flash_chip_erase(u8 bank) { - - if((bank!='0')|(bank!='2')) - return -1; - - if(bank=='0') { - B0F555=0xaa; - B0F2AA=0x55; - B0F555=0x80; - B0F555=0xaa; - B0F2AA=0x55; - B0F555=0x10; - } - else { - B2F555=0xaa; - B2F2AA=0x55; - B2F555=0x80; - B2F555=0xaa; - B2F2AA=0x55; - B2F555=0x10; - } -} - -void unlock_bypass(u8 bank) { - - if((bank!='0')|(bank!='2')) - return; - - if(bank=='0') { - B0F555=0xaa; - B0F2AA=0x55; - B0F555=0x20; - } - else { - B2F555=0xaa; - B2F2AA=0x55; - B2F555=0x20; - } -} - -void unlock_bypass_reset(u8 bank) { - - if((bank!='0')|(bank!='2')) - return; - - if(bank=='0') { - B0F=0x90; - B0F=0x00; - } - else { - B2F=0x90; - B2F=0x00; - } -} - -void flash_write(u32 addr,u16 data) { - - *((volatile unsigned short *)addr)=0xa0; - *((volatile unsigned short *)addr)=data; -} - void ext_mem_bank_init(void) { BCFG0=0x10000420; // flash 1 @@ -290,6 +193,105 @@ u8 uart0_get_byte(void) { return rx; } +void flash_sector_erase(u8 flash,u8 sector) { + + u32 a18_12; + u32 base; + + if(sector>18) + return; + a18_12=sector_address[sector]<<1; + + if((flash!='0')&(flash!='2')) + return; + + switch(flash) { + case '0': + base=0x80000000; + B0F555=0xaa; + B0F2AA=0x55; + B0F555=0x80; + B0F555=0xaa; + B0F2AA=0x55; + *((volatile u16 *)(base|a18_12))=0x30; + break; + case '2': + base=0x82000000; + B2F555=0xaa; + B2F2AA=0x55; + B2F555=0x80; + B2F555=0xaa; + B2F2AA=0x55; + *((volatile u16 *)(base|a18_12))=0x30; + break; + default: + return; + } + + return; +} + +void flash_chip_erase(u8 bank) { + + if((bank!='0')&(bank!='2')) + return; + + if(bank=='0') { + B0F555=0xaa; + B0F2AA=0x55; + B0F555=0x80; + B0F555=0xaa; + B0F2AA=0x55; + B0F555=0x10; + } + else { + B2F555=0xaa; + B2F2AA=0x55; + B2F555=0x80; + B2F555=0xaa; + B2F2AA=0x55; + B2F555=0x10; + } +} + +void unlock_bypass(u8 bank) { + + if((bank!='0')&(bank!='2')) + return; + + if(bank=='0') { + B0F555=0xaa; + B0F2AA=0x55; + B0F555=0x20; + } + else { + B2F555=0xaa; + B2F2AA=0x55; + B2F555=0x20; + } +} + +void unlock_bypass_reset(u8 bank) { + + if((bank!='0')&(bank!='2')) + return; + + if(bank=='0') { + B0F=0x90; + B0F=0x00; + } + else { + B2F=0x90; + B2F=0x00; + } +} + +void flash_write(u32 addr,u16 data) { + + *((volatile unsigned short *)addr)=0xa0; + *((volatile unsigned short *)addr)=data; +} + void receive_data_and_write_to_flash(u32 addr,u32 datalen) { u8 bank;