?? nand_drv_st.c
字號:
/*******************************************************************************
* Copyright Statement:
* --------------------
* This software is protected by Copyright and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2005
*
*******************************************************************************/
/*******************************************************************************
*
* Filename:
* ---------
* nand_drv_ST.c
*
* Project:
* --------
* FlashTool Download Agent
*
* Description:
* ------------
* STMicroelectronics compatible NAND flash driver
*
* Author:
* -------
* Amos Hsu
*
*==============================================================================
* HISTORY
* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* $Revision: 1.1 $
* $Modtime: Dec 19 2005 16:02:28 $
* $Log: //mtkvs01/vmdata/new_flash_tool/archives/DA/SRC/nand_drv_ST.c-arc $
*
* Rev 1.1 Dec 29 2005 10:53:18 mtk00539
* 1. [DA] Add pre-process callback function to unlock all the blocks to meet ST NAND flash requirement.
* Resolution for 156: [FlashTool v2.7.1013][BUG FIX] Fix BootROM start command failure while manually selecting NMT6226 or MT6227 baseband chip.
*
* Rev 1.0 Oct 19 2005 14:41:08 mtk00539
* Initial revision.
* Resolution for 140: [BROM_DLL v2.7.1008][New] Support NFB download and many new features.
*
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*==============================================================================
*******************************************************************************/
#include "nand_drv_ST.h"
#include "nand_drv_COMMON.h"
#include "nand_util_func.h"
#include "NFI.h"
//------------------------------------------------------------------------------
// STMicroelectronics Command Set
//------------------------------------------------------------------------------
const NAND_CommandSet_S g_NAND_ST_512_CMD_SET={
{ 1, 0x90 } // read id
,{ 1, 0x70 } // read status
,{ 1, 0xFF } // reset device
,{ 1, 0x00 } // read
,{ 1, 0x50 } // read spare area
,{ 0, 0 } // read confirm
,{ 1, 0x00 } // program 1st half page
,{ 1, 0x80 } // program
,{ 1, 0x10 } // program confirm
,{ 1, 0x60 } // erase
,{ 1, 0xD0 } // erase confirm
,{ 1, 0x00 } // copyback read
,{ 0, 0 } // copyback read confirm
,{ 1, 0x8A } // copyback program
,{ 1, 0x10 } // copyback program confirm
};
const NAND_CommandSet_S g_NAND_ST_2048_CMD_SET={
{ 1, 0x90 } // read id
,{ 1, 0x70 } // read status
,{ 1, 0xFF } // reset device
,{ 1, 0x00 } // read
,{ 0, 0 } // read spare area
,{ 1, 0x30 } // read confirm
,{ 0, 0 } // program 1st half page
,{ 1, 0x80 } // program
,{ 1, 0x10 } // program confirm
,{ 1, 0x60 } // erase
,{ 1, 0xD0 } // erase confirm
,{ 1, 0x00 } // copyback read
,{ 1, 0x35 } // copyback read confirm
,{ 1, 0x85 } // copyback program
,{ 1, 0x10 } // copyback program confirm
};
//------------------------------------------------------------------------------
// ST Callback Function Set
//------------------------------------------------------------------------------
const NAND_CMD_Callback_S g_NAND_ST_CB_FUNC_SET={
NAND_COMMON_ReadID
,NAND_COMMON_Reset
,NAND_ST_WholeChipUnlock
,NAND_COMMON_ReadStatus
,NAND_COMMON_BlockErase
,NAND_COMMON_BadBlockSymbol_Check
,NAND_COMMON_BadBlockSymbol_Set
,NAND_COMMON_PageRead
,NAND_COMMON_PageProgram
,NAND_COMMON_SpareRead
,NAND_COMMON_SpareProgram
,NAND_COMMON_CopyBack
};
//------------------------------------------------------------------------------
// ST Callback Function Set Without H/W CopyBack Function
//------------------------------------------------------------------------------
const NAND_CMD_Callback_S g_NAND_ST_CB_FUNC_SET_WITHOUT_COPYBACK={
NAND_COMMON_ReadID
,NAND_COMMON_Reset
,NAND_ST_WholeChipUnlock
,NAND_COMMON_ReadStatus
,NAND_COMMON_BlockErase
,NAND_COMMON_BadBlockSymbol_Check
,NAND_COMMON_BadBlockSymbol_Set
,NAND_COMMON_PageRead
,NAND_COMMON_PageProgram
,NAND_COMMON_SpareRead
,NAND_COMMON_SpareProgram
,NULL
};
//------------------------------------------------------------------------------
// Whole Chip Unlock
//------------------------------------------------------------------------------
STATUS_E NAND_ST_WholeChipUnlock(const NAND_DeviceInfo_S *nand_info, const uint32 c_timeout)
{
uint32 page_size;
uint32 spare_size;
uint32 addr_cycle;
uint32 ra_last_blockaddr;
page_size = NUTL_PAGE_SIZE(nand_info);
spare_size = NUTL_SPARE_SIZE(nand_info);
addr_cycle = NUTL_ADDR_CYCLE(nand_info);
ra_last_blockaddr = NUTL_AbsAddrToBlockAddr(nand_info, (NUTL_TOTAL_SIZE(nand_info)-1));
// reset the NFI core state machine, data FIFO and flushing FIFO
*NFI_OPCON = 0x0;
*NFI_CON = 0x0;
*NFI_FIFOCON = 0x30;
// block unlock command
*NFI_CMD = 0x23;
// wait til CMD is completely issued
while( *NFI_PSTA & STATUS_CMD );
// fill 1~4 cycle addr
*NFI_ADDRL = 0;
*NFI_ADDRM = 0;
// no. of addr cycle
if( 512 < page_size ) {
*NFI_ADDNOB = addr_cycle-2;
}
else {
*NFI_ADDNOB = addr_cycle-1;
}
// wait til ADDR is completely issued
while( *NFI_PSTA & STATUS_ADDR );
// block unlock confirm
*NFI_CMD = 0x24;
// wait til CMD is completely issued
while( *NFI_PSTA & STATUS_CMD );
// fill 1~4 cycle addr , block unlock command only fill row address, so column bits shift is unnecessary
*NFI_ADDRL = ra_last_blockaddr;
*NFI_ADDRM = 0;
// no. of addr cycle
if( 512 < page_size ) {
*NFI_ADDNOB = addr_cycle-2;
}
else {
*NFI_ADDNOB = addr_cycle-1;
}
// wait til ADDR is completely issued
while( *NFI_PSTA & STATUS_ADDR );
return S_DONE;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -