📄 oren_mtd.c
字号:
* None 0 : Clock is available
* 0 : Clock is not available
***********************************************************************/
#define OREN_IsClockAvailable(flashPtr) \
((flashPtr->bBusType == FL_LPC_MODE) | \
(OREN_Read8BitReg(flashPtr,OREN_ICMU_CONTROL_REG) & \
(Reg8bitType)OREN_CLOCK_AVAILABLE))
/***********************************************************************
* Name : OREN_IsCustomerOTPLocked
* Checks if the customer OTP is OREN_LOCKED
* None 0 - Customer OTP is locked
* 0 - Customer OTP is not locked
***********************************************************************/
#define OREN_IsCustomerOTPLocked(flashPtr) \
(OREN_Read8BitReg(flashPtr,OREN_PROTECTION_STATUS_REG) & \
(Reg8bitType)OREN_CUSTOMER_OTP_LOCKED)
/***********************************************************************
* Name : OREN_BusConfiguration
* Returns the bus configuration
* the options are: FL_SRAM_MODE , OREN_MUXED_MODE , FL_LPC_MODE
***********************************************************************/
#define OREN_BusConfiguration(flashPtr) \
(OREN_Read8BitReg(flashPtr,OREN_CONFIGURATION_REG) & \
(Reg8bitType)OREN_BUS_CONFIGURATION_BITS)
/************************************************************************
************************** Download functions **************************
************************************************************************/
/************************************************************************
* Name : OREN_downloadStatus ()
*
* Returns the download status of the current floor
*
* Parameters:
* flashPtr: The flash struct.
*
* Returns :
* flOK : On success
* flBadDownload : Download failed
************************************************************************/
static FLStatus OREN_downloadStatus (FLFlash *flashPtr)
{
FLByte bTemp = OREN_Read8BitReg(flashPtr,OREN_DOWNLOAD_STATUS_REGISTER0);
#ifndef DEBUG_MTD
if(bTemp & OREN_CLEAN_DOWNLOAD)
{
DBG_PRINT_ERR(FLZONE_MTD,"ERROR in downloadStatus:Failed downloading.\r\n");
/* Note that IPL download error is considered an error */
return flBadDownload;
}
DBG_PRINT_FLOW(FLZONE_MTD,"Download status O.K ! \r\n");
return flOK;
#else
FLBoolean fDownloadSuccessFlag = TRUE ;
if (bTemp & OREN_DPS0_DOWNLOAD_ERROR_BITS)
{
DBG_PRINT_ERR(FLZONE_MTD,"ERROR in downloadStatus:DPS_0 Download Error.\r\n");
fDownloadSuccessFlag=FALSE ;
}
if (bTemp & OREN_DPS1_DOWNLOAD_ERROR_BITS)
{
DBG_PRINT_ERR(FLZONE_MTD,"ERROR in downloadStatus:DPS_1 Download Error.\r\n");
fDownloadSuccessFlag=FALSE ;
}
if (bTemp & OREN_IPL_DOWNLOAD_ERROR_BITS)
{
DBG_PRINT_ERR(FLZONE_MTD,"ERROR in downloadStatus:IPL Download Error.\r\n");
fDownloadSuccessFlag=FALSE ;
}
if (bTemp & OREN_SEQUENCE_DOWNLOAD_ERROR)
{
DBG_PRINT_ERR(FLZONE_MTD,"ERROR in downloadStatus:SEQUENCE Download Error.\r\n");
fDownloadSuccessFlag=FALSE ;
}
if (bTemp & OREN_OTP_DOWNLOAD_ERROR)
{
DBG_PRINT_ERR(FLZONE_MTD,"ERROR in downloadStatus:OTP Download Error.\r\n");
fDownloadSuccessFlag=FALSE ;
}
return ((fDownloadSuccessFlag==TRUE) ? flOK : flBadDownload) ;
#endif /* DEBUG_MTD */
}
/************************************************************************
* Name : OREN_waitUntilDownloadFinished ()
*
* Wait until download is finished (or timeout)
*
* Parameters:
* flashPtr: The flash struct.
*
* Returns :
* flOK : Download is finished
* flTimedOut: Download TimeOut
*
************************************************************************/
static FLStatus OREN_waitUntilDownloadFinished (FLFlash *flashPtr,FLByte bLastFloor)
{
FLDword i;
DBG_PRINT_FLOW(FLZONE_MTD,"Flow: waitUntilDownloadFinished Entered.\r\n");
for(i=0;i<OREN_BUSY_DELAY;i++)
{
if (i%200==0) /* Delay before polling */
{
OREN_AsicSetFloor (flashPtr,bLastFloor) ;
/* set controller (ASIC) to NORMAL MODE */
OREN_asicSetMode (flashPtr,NORMAL_MODE);
/* Check if the Controller responds (Check CHIP_ID & CHIP_ID_CONFIRM */
if ((OREN_ReadChipID(flashPtr) == OREN_CHIP_ID_OREN )&&
(OREN_ReadChipID_Confirm(flashPtr) == OREN_CHIP_ID_COMPLEMENT) )
{
DBG_PRINT_FLOW(FLZONE_MTD,"Flow: waitUntilDownloadFinished (controller was found) exit.\r\n");
return flOK;
}
}
}
DBG_PRINT_FLOW(FLZONE_MTD,"Flow: waitUntilDownloadFinished exit.\r\n");
return flTimedOut;
}
/************************************************************************
************************ Registration functions ************************
************************************************************************/
/************************************************************************
* Name : OREN_docWindowBaseAddress *
* *
* Return the host base address of the window. *
* If the window base address is programmable, this routine selects *
* where the base address will be programmed to. *
* *
* Parameters: *
* bSocketNo : Socket No (0..SOCKETS-1) *
* dwLowAddress : host memory range to search - low address *
* dwHighAddress: host memory range to search - high address *
* fResetAll : TRUE - Send reset command before identifing *
* FALSE - Do not send the reset command, in order *
* not clear the alias resolution register *
* *
* Returns: *
* Host physical address of window divided by 4 KB *
* dwNextAddressPtr : The address of the next DiskOnChip. *
************************************************************************/
static FLStatus OREN_docWindowBaseAddress(FLByte bSocketNo,
FLDword dwLowAddress,
FLDword dwHighAddress,
FLDword *dwNextAddressPtr,
unsigned *dwDOC_PhyAddress,
FLBoolean fResetAll)
{
FLFlash *flash;
FLDword dwWinSize = 0; /* Initialized to remove */
volatile FLByte bChipId;
volatile FLByte bChipIdConfirm;
FLByte bIF_CFG ;
DBG_PRINT_FLOW(FLZONE_MTD,"Flow: docWindowBaseAddress Entered.\r\n");
/* if memory range to search for DiskOnChip window is not specified */
/* assume the standard x86 PC architecture where DiskOnChip Plus appears */
/* in a memory range reserved for BIOS expansions */
#ifndef FL_ADD_ADDRESS_0_SUPPORT
if (dwLowAddress == 0x0L)
{
dwLowAddress = OREN_DEFAULT_START_ADR;
dwHighAddress = OREN_DEFAULT_STOP_ADR;
}
else if (dwHighAddress == 0x0L)
{
dwHighAddress = OREN_DEFAULT_STOP_ADR;
}
#endif
/* Initialize socket memory access routine */
flash = flFlashOf(bSocketNo);
/*** Step 1 : Set all possible controllers (ASIC) to RESET MODE ***/
for (bIF_CFG=8;bIF_CFG<=16;bIF_CFG +=8)
{
#ifndef FL_NO_USE_FUNC
if(OREN_setBusType(flash,flBusConfig[bSocketNo],1,bIF_CFG)==FALSE)
{
continue ;
}
#endif /* FL_NO_USE_FUNC */
dwWinSize = OREN_DocWindow(flash) ;
if(fResetAll == TRUE)
{
for(*dwNextAddressPtr=dwLowAddress;*dwNextAddressPtr<=dwHighAddress;
*dwNextAddressPtr+=dwWinSize)
{
flash->win = (NDOC2window)physicalToPointer(*dwNextAddressPtr,dwWinSize,bSocketNo);
/* Make sure we are in reset mode in order not to suffer time out in LPC */
OREN_asicSetMode (flash,RESET_MODE) ;
OREN_NOP (flash); /* Nop between r/w of same register */
/* Make sure we are not in DPD and the device is in normal mode */
OREN_asicSetInNormalMode (flash);
OREN_NOP (flash); /* Nop between r/w of same register */
/* Make sure the aliase resolution register is zeroed, because */
/* the first reset command might have been ignored due to DPD */
OREN_asicSetMode (flash,RESET_MODE) ;
OREN_NOP (flash); /* Nop between r/w of same register */
/* Make sure we are in NORMAL mode */
OREN_asicSetMode (flash,NORMAL_MODE) ;
}
}
}
/*** Step 2 : Read chip ID while skipping alias addresses ***/
for(*dwNextAddressPtr=dwLowAddress;*dwNextAddressPtr<=dwHighAddress;*dwNextAddressPtr+=dwWinSize)
{
DBG_PRINT_WRN_PRM(FLZONE_MTD,(FLTXT("Looking for OREN DOC at address 0x%lx \r\n"),*dwNextAddressPtr));
for (bIF_CFG=8;bIF_CFG<=16;bIF_CFG +=8)
{
#ifndef FL_NO_USE_FUNC
if(OREN_setBusType(flash,flBusConfig[bSocketNo],1,bIF_CFG)==FALSE)
{
continue ;
}
#endif /* FL_NO_USE_FUNC */
flash->win = (NDOC2window)physicalToPointer(*dwNextAddressPtr,dwWinSize,bSocketNo);
OREN_NOP (flash);
bChipId = OREN_ReadChipID(flash);
bChipIdConfirm = OREN_ReadChipID_Confirm(flash) ;
if ((bChipId != OREN_CHIP_ID_OREN ) ||
(bChipIdConfirm != OREN_CHIP_ID_COMPLEMENT) ||
(OREN_Read8BitReg(flash,OREN_ALIAS_RESOLUTION_REG) == OREN_ALIAS_RESOLUTION))
continue;
#ifndef FL_NO_USE_FUNC
/* Now that we found the controller use the correct if_cfg and interleave */
if(OREN_setBusType(flash,flBusConfig[bSocketNo],1,(FLByte)(OREN_Find_IF_CFG(flash)))==FALSE)
{
continue;
}
#endif /* FL_NO_USE_FUNC */
/* DiskOnChip found, mark alias resolution register */
OREN_Write8BitReg(flash,OREN_ALIAS_RESOLUTION_REG,OREN_ALIAS_RESOLUTION);
dwLowAddress = *dwNextAddressPtr ; /* save DiskOnChip address */
*dwNextAddressPtr += dwWinSize;
DBG_PRINT_WRN(FLZONE_MTD,"OREN DiskOnChip was FOUND ");
DBG_PRINT_WRN_PRM(FLZONE_MTD,(FLTXT("On address 0x%lx.\r\n"),dwLowAddress));
*dwDOC_PhyAddress = (dwLowAddress >> 12) ;
flash->mediaType = DOC_OREN_TYPE; /* Prevent identification of other devices */
return flOK;
} /* Loop over IF_CFG */
} /* Loop over addresses */
DBG_PRINT_FLOW(FLZONE_MTD,"Flow: docWindowBaseAddress Exit (NOT FOUND).\r\n");
/* DiskOnChip memory window not found */
*dwDOC_PhyAddress = 0 ;
return flAdapterNotFound ;
}
/************************************************************************
* flRegisterDOCORENSOC *
* *
* The routine searches for DOC and if found it updates the noOfSockets *
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -