__s32 NF_close( void ) { if( NAND_PhyExit( ) == FAIL ) return NF_ERROR; else return NF_OK; }
int nand_download_boot0(uint length, void *buffer) { int ret; if(!NAND_PhyInit()) { ret = NAND_BurnBoot0(length, buffer); } else { ret = -1; } NAND_PhyExit(); return ret; }
int nand_download_uboot(uint length, void *buffer) { int ret; debug("nand_download_uboot\n"); if(!NAND_PhyInit()) { ret = NAND_BurnUboot(length, buffer); debug("nand burn uboot error ret = %d\n", ret); } else { debug("nand phyinit error\n"); ret = -1; } NAND_PhyExit(); return ret; }
/* ************************************************************************************************************************ * EXIT NAND DRIVER * *Description: ; * *Arguments : void *Return : = SUCESS exit ok; * = FAIL exit fail. ************************************************************************************************************************ */ __s32 NAND_Exit(void) { __s32 result; #ifdef BOOT_CACHE_OPEN NAND_CacheClose(); #endif //exit nand flahs logic module result = LML_Exit(); if(result < 0) { return -1; } //exit nand flash physical module result = NAND_PhyExit(); if(result < 0) { return -2; } return result; }
/* ************************************************************************************************************ * * function * * 函数名称: * * 参数列表: * * 返回值 : * * 说明 : * * ************************************************************************************************************ */ __s32 NF_open( void ) { __u32 blk_for_boot1; struct boot_flash_info info; if( NAND_PhyInit( ) == FAIL ) return NF_ERROR; if( NAND_GetFlashInfo( &info ) == FAIL ) { goto error; } page_with_bad_block = info.pagewithbadflag; NF_BLOCK_SIZE = info.blocksize * NF_SECTOR_SIZE; switch( NF_BLOCK_SIZE ) { case SZ_16K : NF_BLK_SZ_WIDTH = 14; blk_for_boot1 = BLKS_FOR_BOOT1_IN_16K_BLK_NF; break; case SZ_32K : NF_BLK_SZ_WIDTH = 15; blk_for_boot1 = BLKS_FOR_BOOT1_IN_32K_BLK_NF; break; case SZ_128K : NF_BLK_SZ_WIDTH = 17; blk_for_boot1 = BLKS_FOR_BOOT1_IN_128K_BLK_NF; break; case SZ_256K : NF_BLK_SZ_WIDTH = 18; blk_for_boot1 = BLKS_FOR_BOOT1_IN_256K_BLK_NF; break; case SZ_512K : NF_BLK_SZ_WIDTH = 19; blk_for_boot1 = BLKS_FOR_BOOT1_IN_512K_BLK_NF; break; case SZ_1M : NF_BLK_SZ_WIDTH = 20; blk_for_boot1 = BLKS_FOR_BOOT1_IN_1M_BLK_NF; break; case SZ_2M : NF_BLK_SZ_WIDTH = 21; blk_for_boot1 = BLKS_FOR_BOOT1_IN_2M_BLK_NF; break; case SZ_4M : NF_BLK_SZ_WIDTH = 22; blk_for_boot1 = BLKS_FOR_BOOT1_IN_4M_BLK_NF; break; default : goto error; } BOOT1_LAST_BLK_NUM = BOOT1_START_BLK_NUM + blk_for_boot1 - 1; NF_PAGE_SIZE = info.pagesize * NF_SECTOR_SIZE; switch( NF_PAGE_SIZE ) { case SZ_512 : NF_PG_SZ_WIDTH = 9; break; case SZ_2K : NF_PG_SZ_WIDTH = 11; break; case SZ_4K : NF_PG_SZ_WIDTH = 12; break; case SZ_8K : NF_PG_SZ_WIDTH = 13; break; case SZ_16K : NF_PG_SZ_WIDTH = 14; break; default : goto error; } return NF_OK; error: NAND_PhyExit( ); return NF_ERROR; }