📄 oren_mtd.c
字号:
FLStatus OREN_deepPowerDownMode (FLFlash *flashPtr,FLWord wState) ;
#ifndef FL_READ_ONLY
static void OREN_completeOperationErase (FLFlash *flashPtr,
LastOperationResults *completeOpStruct,
completeOpVarsStruct *completeOpVars) ;
static void OREN_completeOperationWrite (FLFlash *flashPtr,
LastOperationResults *completeOpStruct,
completeOpVarsStruct *completeOpVars) ;
#endif /* FL_READ_ONLY */
FLStatus OREN_completeOperation (FLFlash *flashPtr) ;
void OREN_restoreRegistersCurrentState (FLFlash *flashPtr) ;
void OREN_executeReadSequence (FLFlash *flashPtr,FLWord wNoOfPhySectors) ;
void OREN_executePageProgramSequence (FLFlash *flashPtr,FLWord wNoOfPhySectors,
FLWord wSectorsWritten,FLByte bSectorsInPageToWrite) ;
#ifdef VERIFY_WRITE
FLStatus OREN_verifyWrite (FLFlash *flashPtr,OREN_OperationArgsStructPtr writeArgsPtr) ;
#endif
#ifdef FL_PLANT_BBT_FOR_TESTING
extern FLStatus plantedIsGoodBlock(FLFlash * flashPtr, FLWord wBlockNo,FLBoolean * bCurBlockStatus);
#endif /* FL_PLANT_BBT_FOR_TESTING */
#ifdef STORE_DPS_BEFORE_DOWNLOAD
extern FLStatus QA_DPS_BeforeDownload(FLFlash *callingFlashPtr);
#endif /* STORE_DPS_BEFORE_DOWNLOAD */
#ifdef FL_PLANT_BBT_FOR_TESTING
extern FLStatus informOfOperation(FLFlash * flash, FLDword start, FLDword length , FLByte bType);
#endif /* FL_PLANT_BBT_FOR_TESTING */
/***************************** Macros **************************/
/***********************************************************************
* Name: OREN_NOP
* Performs one NOP.
*
* Parameters:
* flashPtr : Pointer identifying drive
*
* Returns: Byte of data that was read
***********************************************************************/
#define OREN_NOP(flashPtr) \
OREN_Write8BitReg(flashPtr,OREN_NOP_REG,0x00) ;
/***********************************************************************
* Name: OREN_IsFlashErased
*
* Check if flash is erased .
*
* Parameters:
* volume : Pointer identifying drive
*
* Returns: TRUE -> Flash erased
* FALSE -> Flash is not erased
***********************************************************************/
#define OREN_IsFlashErased(volume) (((OREN_Read8BitReg(volume,OREN_HW_PROTECTION_CONTROL_REG) & \
(Reg8bitType)OREN_FLASH_EMPTY) == OREN_FLASH_EMPTY) ? \
TRUE:FALSE)
/***********************************************************************
* Name: OREN_Read16BitReg
* Read 16 bit register
*
* Parameters:
* flashPtr : Pointer identifying drive
* wOffset : The Offset of register from base address
* Returns: Value of the 16 bit register
***********************************************************************/
FLWord OREN_Read16BitReg(FLFlash *flashPtr,FLWord wOffset)
{
FLWord tmp;
tmp = OREN_DirectRead16BitReg(flashPtr,wOffset);
return LE2(*(LEushort *)&tmp);
}
/***********************************************************************
* Name: OREN_Read8BitFromDataReg
* Read 8 bit from Data register.
*
* Parameters:
* flashPtr : Pointer identifying drive
*
* Returns: Byte of data that was read
***********************************************************************/
#define OREN_Read8BitFromDataReg(flashPtr) \
OREN_Read8BitReg(flashPtr,OREN_FLASH_DATA_REG_LB_BYTE);
/***********************************************************************
* Name: OREN_Write8BitToDataReg
* Write 8 bit from Data register.
*
* Parameters:
* flashPtr : Pointer identifying drive
* bValue : Value that would be written
* Returns:
***********************************************************************/
#define OREN_Write8BitToDataReg(flashPtr,bValue) \
OREN_Write8BitReg(flashPtr,OREN_FLASH_DATA_REG_LB_BYTE,bValue);
/***********************************************************************
* Name: OREN_IsFlashReady
* Poll the selected flash busy signal.
*
* Parameters:
* flashPtr : Pointer identifying drive
*
* Returns: 0 -> Flash Busy
* None 0 -> Flash Ready
***********************************************************************/
#define OREN_IsFlashReady(flashPtr) \
(OREN_Read8BitReg(flashPtr,OREN_FLASH_STATUS_REG) & \
(Reg8bitType)OREN_FLASH_READY)
/***********************************************************************
* Name : OREN_ReadChipID
* Returns the controller (ASIC) chipID
*
***********************************************************************/
#define OREN_ReadChipID(flashPtr) \
OREN_Read8BitReg(flashPtr,OREN_CHIP_ID_REG)
/***********************************************************************
* Name : OREN_ReadChipID_Confirm
* Returns the controller (ASIC) confirmation chipID
*
***********************************************************************/
#define OREN_ReadChipID_Confirm(flashPtr) \
OREN_Read8BitReg(flashPtr,OREN_CHIP_ID_CONFIRM_REG)
/***********************************************************************
* Name : OREN_AsicChkMode
*
* Check the controller (ASIC) mode.
*
* Parameters:
* flashPtr : Pointer identifying drive
*
* Returns:ASIC_MODE_ENUM
* mode : One of the modes below:
* RESET_MODE = 0
* NORMAL_MODE = 1
* POWER_DOWN_MODE = 2
*
************************************************************************/
#define OREN_AsicChkMode(flashPtr) \
(FL_AsicModeE)(OREN_Read8BitReg(flashPtr,OREN_DOC_CONTROL_REG) & OREN_MODE_BITS)
/***********************************************************************
* Name : OREN_Find_IF_CFG
* Return the IF_CFG
*
* 8 : IF_CFG = 8
* 16: IF_CFG = 16
***********************************************************************/
#define OREN_Find_IF_CFG(flashPtr) \
((OREN_Read8BitReg(flashPtr,OREN_CONFIGURATION_REG) & \
(Reg8bitType)OREN_IF_CFG_STATUS) ? 16:8)
/***********************************************************************
* Name : OREN_IsSequenceOrProtectionError
*
* None 0 - Sequence ERROR
* 0 - SEQUENCE OK
***********************************************************************/
#define OREN_IsSequenceOrProtectionError(flashPtr) \
(OREN_Read8BitReg(flashPtr,OREN_FLASH_STATUS_REG) & (Reg8bitType)\
(OREN_SEQUENCE_ERROR_DETECTED | OREN_PROTECTION_ERROR_DETECTED))
/***********************************************************************
* Name : OREN_FindSystemInterleave
* Return the SYS_INTLV bit
*
* 1: Interleave 1
* 2: Interleave 2
***********************************************************************/
#define OREN_FindSystemInterleave(flashPtr) \
((OREN_Read8BitReg(flashPtr,OREN_FLASH_STATUS_REG) & \
(Reg8bitType)OREN_SYSTEM_INTERLEAVE_2) ? 2:1)
/***********************************************************************
* Name : OREN_Is16BitsFlash
* check if single 16 bits flash is connected.
* None 0 - 16 bits single flash is connected.
* 0 - 8 bits single flash is connected.
***********************************************************************/
#define OREN_Is16BitsFlash(flashPtr) \
(OREN_Read8BitReg(flashPtr,OREN_FLASH_STATUS_REG) & \
(Reg8bitType)OREN_SINGLE_16BIT_FLASH_CONNECT)
/***********************************************************************
* Name : OREN_IsECCBusy
* Check if the controller (ASIC) is busy calculating the ECC
* (BCH OR HAMMING) syndrom bytes
* None 0 - ECC is busy.
* 0 - ECC is not busy.
***********************************************************************/
#define OREN_IsECCBusy(flashPtr) \
(OREN_Read8BitReg(flashPtr,OREN_ECC_CONTROL_REG_1) & \
(Reg8bitType)OREN_ECC_BUSY)
/***********************************************************************
* Name : OREN_ExecuteSequenceID
*
* Auxiliary routine for reading from flash I\O registers.
*
* Parameters:
* flashPtr : Pointer identifying drive
* SEQ_ID : One of the following sequences :
***********************************************************************/
#define OREN_ExecuteSequenceID(flashPtr,SEQ_ID) \
(OREN_Write8BitReg (flashPtr,OREN_FLASH_SEQUENCE_REG,(FLByte)(SEQ_ID)))
/***********************************************************************
* Name : OREN_OREN_FlashCommandRegWrite
*
* This Routine writes a command to the Flash Command Register
*
* Parameters:
* flashPtr : Pointer identifying drive
* FLASH_CMD : One of the flash Commands :
* RESET_COMMAND = 0xFF
* READ_ID_CMD = 0x90
* READ_ID_2_CMD = 0x91
* READ_STATUS_CMD = 0x70
* READ_STATUS_MULTI_CMD = 0x71
* READ_AREA_A_CMD = 0x00
* READ_AREA_B_CMD = 0x01
* READ_AREA_C_CMD = 0x50
* PAGE_PROG_CYCLE_1_CMD = 0x80
* PAGE_PROG_CYCLE_2_CMD = 0x10
* PAGE_PROG_DUMMY_CMD = 0x11
* PAGE_ERASE_CYCLE_1_CMD = 0x60
* PAGE_ERASE_CYCLE_2_CMD = 0xD0
************************************************************************/
#define OREN_FlashCommandRegWrite(flashPtr,FLASH_CMD) \
(OREN_Write8BitReg (flashPtr,OREN_FLASH_COMMAND_REG,(FLByte)(FLASH_CMD)))
/***********************************************************************
* Name : OREN_BankInterface
* check if only 8 bits flash is used simultaniously.
* 1 : The interface is one 8 bit
* 2 : The interface is one 16 bit
***********************************************************************/
#define OREN_BankInterface(flashPtr) \
(MTD_VARS->bInterleaveFlag & \
(OREN_INTLV_1_8_BIT | OREN_INTLV_2_SEPERATED) ? 1:2)
/***********************************************************************
* Name : OREN_IsBCHError
* check if BCH syndrom occurred.
* None 0 - BCH ECC ERROR
* 0 - NO ECC ERROR.
***********************************************************************/
#define OREN_IsBCHError(flashPtr) \
(OREN_Read8BitReg(flashPtr,OREN_ECC_CONTROL_REG_1) & \
(Reg8bitType)OREN_BCH_SYNDROM_ERROR)
/***********************************************************************
* Name : OREN_IsHMError
* Check if Humming syndrom occurred.
* None 0 - HM ECC ERROR
* 0 - NO ECC ERROR.
***********************************************************************/
#define OREN_IsHMError(flashPtr) \
(OREN_Read8BitReg(flashPtr,OREN_HAMMING_PARITY_REG))
/***********************************************************************
* Name : OREN_IsPageInUse
* Check if the page is in use - was written.
* at least 3 zero bits in the humming area.
* None 0 - Page in use.
* 0 - Page not in use.
***********************************************************************/
#define OREN_IsPageInUse(flashPtr) \
(OREN_Read8BitReg(flashPtr,OREN_ECC_CONTROL_REG_1) & \
(Reg8bitType)OREN_PAGE_READ_IS_USED)
/***********************************************************************
* Name : OREN_IsClockAvailable
* Check if the ICMU clock is available
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -