From 9572c366af21a84c49693f63dd8e24f97155dbc4 Mon Sep 17 00:00:00 2001 From: Shakti Bhatnagar Date: Fri, 12 Dec 2014 14:51:49 +0530 Subject: [PATCH] nandps8_v2_0: nandps8_v2_0: Modified XNandPs8_FlashInit API Modified XNandPs8_FlashInit API present in xnanps8.c Added Macro for Onfi Read ID check. Signed-off-by: Shakti Bhatnagar --- .../drivers/nandps8_v2_0/src/xnandps8.c | 137 ++++++++---------- .../drivers/nandps8_v2_0/src/xnandps8.h | 12 ++ 2 files changed, 71 insertions(+), 78 deletions(-) diff --git a/XilinxProcessorIPLib/drivers/nandps8_v2_0/src/xnandps8.c b/XilinxProcessorIPLib/drivers/nandps8_v2_0/src/xnandps8.c index b18b7095..6fb7d4a8 100755 --- a/XilinxProcessorIPLib/drivers/nandps8_v2_0/src/xnandps8.c +++ b/XilinxProcessorIPLib/drivers/nandps8_v2_0/src/xnandps8.c @@ -397,75 +397,68 @@ static s32 XNandPs8_FlashInit(XNandPs8 *InstancePtr) goto Out; } - if ((Id[0] == (u8)'O') && (Id[1] == (u8)'N') && - (Id[2] == (u8)'F') && (Id[3] == (u8)'I')) { - /* - * Read Parameter Page - */ - for(Index = 0U; Index < ONFI_MND_PRM_PGS; Index++) { - if (Index == 0U) { - Status = XNandPs8_OnfiReadParamPage( - InstancePtr, Target, - (u8 *)&Param); - } else { - PrmPgOff = Index * ONFI_PRM_PG_LEN; - PrmPgLen = ONFI_PRM_PG_LEN; - - Status = XNandPs8_ChangeReadColumn( - InstancePtr, - Target, - PrmPgOff, - ONFI_PRM_PG_LEN, 1U, - (u8 *) &Param); - } - if (Status != XST_SUCCESS) { - goto Out; - } - /* - * Check CRC - */ - Crc = XNandPs8_OnfiParamPageCrc((u8*)&Param, - 0U, - ONFI_CRC_LEN); - if (Crc != Param.Crc) { + if (!IS_ONFI(Id)) { + if (Target == 0U) { #ifdef XNANDPS8_DEBUG - xil_printf("%s: ONFI parameter page (%d) crc check failed\r\n", - __func__, Index); + xil_printf("%s: ONFI ID doesn't match\r\n", + __func__); #endif - continue; - } else { - break; - } - } - if (Index >= ONFI_MND_PRM_PGS) { Status = XST_FAILURE; goto Out; } - /* - * Fill Geometry for the first target - */ - if (Target == 0U) { - XNandPs8_InitGeometry(InstancePtr, &Param); - XNandPs8_InitFeatures(InstancePtr, &Param); - if ((!InstancePtr->Features.EzNand) != 0U) { - Status =XNandPs8_CheckOnDie( - InstancePtr,&Param); - if (Status != XST_SUCCESS) { - InstancePtr->Features.OnDie = 0U; - } + } + + /* Read Parameter Page */ + for(Index = 0U; Index < ONFI_MND_PRM_PGS; Index++) { + if (Index == 0U) { + Status = XNandPs8_OnfiReadParamPage(InstancePtr, + Target, (u8 *)&Param); + } else { + PrmPgOff = Index * ONFI_PRM_PG_LEN; + PrmPgLen = ONFI_PRM_PG_LEN; + Status = XNandPs8_ChangeReadColumn(InstancePtr, + Target,PrmPgOff, + ONFI_PRM_PG_LEN, 1U, + (u8 *) &Param); + } + if (Status != XST_SUCCESS) { + goto Out; + } + /* Check CRC */ + Crc = XNandPs8_OnfiParamPageCrc((u8*)&Param, 0U, + ONFI_CRC_LEN); + if (Crc != Param.Crc) { +#ifdef XNANDPS8_DEBUG + xil_printf("%s: ONFI parameter page (%d) crc check failed\r\n", + __func__, Index); +#endif + continue; + } else { + break; + } + } + if (Index >= ONFI_MND_PRM_PGS) { + Status = XST_FAILURE; + goto Out; + } + /* Fill Geometry for the first target */ + if (Target == 0U) { + XNandPs8_InitGeometry(InstancePtr, &Param); + XNandPs8_InitFeatures(InstancePtr, &Param); + if ((!InstancePtr->Features.EzNand) != 0U) { + Status =XNandPs8_CheckOnDie(InstancePtr,&Param); + if (Status != XST_SUCCESS) { + InstancePtr->Features.OnDie = 0U; } - if (isQemuPlatform != 0U) { - InstancePtr->Geometry.NumTargets++; - break; - } - if ((InstancePtr->Geometry.NumBitsECC == 0xFFU) - && - (InstancePtr->Features.ExtPrmPage != 0U)) { - /* - * ONFI 3.1 section 5.7.1.6 & 5.7.1.7 - */ - PrmPgLen = (u32)Param.ExtParamPageLen - * 16U; + } + if (isQemuPlatform != 0U) { + InstancePtr->Geometry.NumTargets++; + break; + } + if ((InstancePtr->Geometry.NumBitsECC == 0xFFU) && + (InstancePtr->Features.ExtPrmPage != 0U)) { + /* ONFI 3.1 section 5.7.1.6 & 5.7.1.7 */ + PrmPgLen = (u32)Param.ExtParamPageLen * 16U; PrmPgOff = (u32)((u32)Param.NumOfParamPages * ONFI_PRM_PG_LEN) + (Index * (u32)PrmPgLen); @@ -504,24 +497,12 @@ static s32 XNandPs8_FlashInit(XNandPs8 *InstancePtr) xil_printf("%s: Init extended ecc failed\r\n",__func__); #endif goto Out; - } } - /* - * Configure ECC settings - */ - XNandPs8_SetEccAddrSize(InstancePtr); - } - InstancePtr->Geometry.NumTargets++; - } else { - if (Target == 0U) { -#ifdef XNANDPS8_DEBUG - xil_printf("%s: ONFI ID doesn't match\r\n", - __func__); -#endif - Status = XST_FAILURE; - goto Out; } + /* Configure ECC settings */ + XNandPs8_SetEccAddrSize(InstancePtr); } + InstancePtr->Geometry.NumTargets++; } /* * Calculate total number of blocks and total size of flash diff --git a/XilinxProcessorIPLib/drivers/nandps8_v2_0/src/xnandps8.h b/XilinxProcessorIPLib/drivers/nandps8_v2_0/src/xnandps8.h index 2473bccf..741818e0 100755 --- a/XilinxProcessorIPLib/drivers/nandps8_v2_0/src/xnandps8.h +++ b/XilinxProcessorIPLib/drivers/nandps8_v2_0/src/xnandps8.h @@ -515,6 +515,18 @@ typedef struct { XNANDPS8_INTR_STS_EN_OFFSET, \ (Mask)) +/*****************************************************************************/ +/** + * This macro checks for the ONFI ID. + * + * @param Buff is the buffer holding ONFI ID + * + * @note none. + * + *****************************************************************************/ +#define IS_ONFI(Buff) \ + (Buff[0] == (u8)'O') && (Buff[1] == (u8)'N') && \ + (Buff[2] == (u8)'F') && (Buff[3] == (u8)'I') /************************** Function Prototypes *****************************/