Functions
NAND Functions
NAND

Functions

CSL_Status NAND_init (CSL_NandObj *nandObj, Uint16 nandInstId)
CSL_Status NAND_setup (CSL_NandHandle hNand, CSL_NandConfig *nandConfig)
CSL_Status NAND_getBankInfo (CSL_NandHandle hNand, CSL_NandAsyncBank *bank, Uint16 bankNum)
CSL_Status NAND_setLatchEnableOffset (CSL_NandHandle hNand, Uint32 addrOffset, Uint32 cmdOffset)
CSL_Status NAND_isStatusWriteProtected (CSL_NandHandle hNand, Uint16 *WPstatus)
CSL_Status NAND_sendCommand (CSL_NandHandle hNand, CSL_VUint16 cmd)
CSL_Status NAND_checkCommandStatus (CSL_NandHandle hNand)
CSL_Status NAND_setAddress (CSL_NandHandle hNand, Uint16 addr)
CSL_Status NAND_enableHwECC (CSL_NandHandle hNand, CSL_NandChipSelect csInput)
CSL_Status NAND_disableHwECC (CSL_NandHandle hNand, CSL_NandChipSelect csInput)
CSL_Status NAND_readECC (CSL_NandHandle hNand, Uint16 *eccBuffer, CSL_NandChipSelect csInput)
CSL_Status NAND_readNBytes (CSL_NandHandle hNand, Uint16 readRequest, Uint16 *pReadBuffer, Uint16 pack, Bool spare)
CSL_Status NAND_writeNBytes (CSL_NandHandle hNand, Uint16 writeRequest, Uint16 *pWriteBuffer, Uint16 val, Bool spare)
void NAND_hasRandomRead (Uint32 nandOptions, Uint16 *RRstatus)
void NAND_hasRandomWrite (Uint32 nandOptions, Uint16 *RWstatus)
void NAND_hasCacheProg (Uint32 nandOptions, Uint16 *CPstatus)
void NAND_hasCopyBack (Uint32 nandOptions, Uint16 *CBstatus)
CSL_Status NAND_intrEnable (CSL_NandHandle hNand)
CSL_Status NAND_intrDisable (CSL_NandHandle hNand)
Int16 NAND_getIntrNum (Uint16 nandInstId)
CSL_Status NAND_intrReadAT (CSL_NandHandle hNand, Uint16 *ATstatus)
CSL_Status NAND_intrReadLT (CSL_NandHandle hNand, Uint16 *LTstatus)
CSL_Status NAND_intrReadWR (CSL_NandHandle hNand, Uint16 *WRstatus)
CSL_Status NAND_intrClear (CSL_NandHandle hNand)
static CSL_Status NAND_getSetup (CSL_NandHandle hNand, CSL_NandConfig *getNandConfig)

Function Documentation

CSL_Status NAND_checkCommandStatus ( CSL_NandHandle  hNand)

============================================================================
NAND_checkCommandStatus

Description
This API checks the status of any command to the nand device. This API must be called after sending any command to the nand device.

Arguments

            hNand    Handle to the nand object
     

Return Value CSL_Status

  • CSL_SOK - Nand status check is successful
  • CSL_ESYS_BADHANDLE - Invalid handle
  • CSL_NAND_E_TIMEOUT - Time-out has occured

Pre Condition
NAND_sendCommand API should be called successfully

Post Condition
Returns time-out condition(If occurs)

Modifies
None

Example

            CSL_NandHandle    hNand;
            CSL_Status        status;

            status = NAND_sendCommand(hNand, CSL_NAND_CMD_READ_START);

            if(status == CSL_SOK)
            {
                status = NAND_checkCommandStatus(hNand);
            }
     

============================================================================

References CSL_NAND_E_TIMEOUT, CSL_NAND_MAX_TIMEOUT, CSL_NandObj::regs, and CSL_NandObj::waitPin.

CSL_Status NAND_disableHwECC ( CSL_NandHandle  hNand,
CSL_NandChipSelect  csInput 
)

============================================================================
NAND_disableHwECC

Description
This API disables hardware ECC of the nand device.

Arguments

            hNand      Handle to the nand object
            csInput    Nand chip selection input
     

Return Value CSL_Status

  • CSL_SOK - Nand disable HW ECC is successful
  • CSL_ESYS_BADHANDLE - Invalid handle
  • CSL_ESYS_INVPARAMS - Invalid parameter

Pre Condition
NAND_enableHwECC API should be called successfully

Post Condition
Disables nand hardware error check and correction

Modifies
Nand ECC registers

Example

            CSL_Status          status;
            CSL_NandHandle      hNand;
            CSL_NandChipSelect  csInput;

            csInput = CSL_NAND_CE0;

            status = NAND_enableHwECC(hNand, csInput);
            ...
            ...
            status = NAND_disableHwECC(hNand, csInput);
     

============================================================================

References CSL_EMIF_NCS2ECC1_LSB, CSL_EMIF_NCS2ECC1_MSB, CSL_EMIF_NCS3ECC1_LSB, CSL_EMIF_NCS3ECC1_MSB, CSL_EMIF_NCS4ECC1_LSB, CSL_EMIF_NCS4ECC1_MSB, CSL_EMIF_NCS5ECC1_LSB, CSL_EMIF_NCS5ECC1_MSB, CSL_NAND_8_BIT, CSL_NAND_CS2, CSL_NAND_CS3, CSL_NAND_CS4, CSL_NAND_CS5, CSL_NandObj::nandWidth, CSL_NandObj::regs, and CSL_NandObj::sysCtrlRegs.

CSL_Status NAND_enableHwECC ( CSL_NandHandle  hNand,
CSL_NandChipSelect  csInput 
)

============================================================================
NAND_enableHwECC

Description
This API enables hardware ECC(Error Check and Correction) of the nand device. ECC is used to check and correct errors occurred during nand data transfer.

Arguments

            hNand      Handle to the nand object
            csInput    Nand chip selection input
     

Return Value CSL_Status

  • CSL_SOK - Nand enable HW ECC is successful
  • CSL_ESYS_BADHANDLE - Invalid handle
  • CSL_ESYS_INVPARAMS - Invalid parameter

Pre Condition
Nand init should be called successfully

Post Condition
Enables nand hardware error check and correction

Modifies
Nand ECC registers

Example

            CSL_NandObj         nandObj;
            Uint16              instId;
            CSL_Status          status;
            CSL_NandHandle      hNand;
            CSL_NandChipSelect  csInput;

            instId = 0;
            status = NAND_init(&nandObj, instId);
            hNand  = &nandObj;
            ....
            ....
        	csInput = CSL_NAND_CE0;
            status = NAND_enableHwECC(hNand,csInput);
     

============================================================================

References CSL_NAND_8_BIT, CSL_NAND_CS2, CSL_NAND_CS3, CSL_NAND_CS4, CSL_NAND_CS5, CSL_NandObj::nandWidth, CSL_NandObj::regs, and CSL_NandObj::sysCtrlRegs.

CSL_Status NAND_getBankInfo ( CSL_NandHandle  hNand,
CSL_NandAsyncBank bank,
Uint16  bankNum 
)

============================================================================
NAND_getBankInfo

Description
This API gives the bank details of the nand device. This API populates the base and offset address locations for the NAND flash based on the bank number passed as the parameter. Bank number should be decide based on the EMIF chip select connected to NAND flash as shown below. CSL_NAND_BANK_0 - EMIF_CS2 CSL_NAND_BANK_1 - EMIF_CS3 CSL_NAND_BANK_2 - EMIF_CS4 CSL_NAND_BANK_3 - EMIF_CS5

NOTE: This API sets ALE and CLE address offset to default values assuming A11 address bit is connected to ALE signal of NAND flash and A12 address bit is connected to CLE signal of NAND flash. Use NAND_setLatchEnableOffset() to change the default offset values.

Arguments

            hNand      Handle to the nand object
            bank       Pointer to nand bank info structure
            bankNum    Nand bank number
     

Return Value CSL_Status

  • CSL_SOK - Nand get bank info is successful
  • CSL_ESYS_BADHANDLE - Invalid handle
  • CSL_ESYS_INVPARAMS - Invalid parameter

Pre Condition
Nand init should be called successfully

Post Condition
Populates nand bank info structure

Modifies
Nand bank info structure

Example

            CSL_NandObj    nandObj;
			Uint16         instId;
			Uint16         bankNum;
			CSL_Status     status;
			CSL_NandHandle hNand;

			instId  = 0;
			bankNum = 0;
			status = NAND_init(&nandObj, instId);
			hNand  = &nandObj;
			....
			....
            status = NAND_getBankInfo(hNand, (CSL_NandAsyncBank*)&hNand->bank, bankNum);
     

============================================================================

References CSL_NandAsyncBank::CExALE, CSL_NandAsyncBank::CExCLE, CSL_NandAsyncBank::CExDATA, CSL_NandAsyncBank::CExNUM, CSL_EMIF_CS2_DATA_BASE_ADDR, CSL_EMIF_CS3_DATA_BASE_ADDR, CSL_EMIF_CS4_DATA_BASE_ADDR, CSL_EMIF_CS5_DATA_BASE_ADDR, CSL_EMIF_CSx_ADDR_OFFSET, CSL_EMIF_CSx_CMD_OFFSET, CSL_NAND_BANK_0, CSL_NAND_BANK_1, CSL_NAND_BANK_2, and CSL_NAND_BANK_3.

Int16 NAND_getIntrNum ( Uint16  nandInstId)

============================================================================
NAND_getIntrNum

Description
This API returns the interrupt number of a particular nand hardware instance.

Arguments

            nandInstId    Nand Hardware instance number
     

Return Value Int16

  • Interrupt number of the nand device.

Pre Condition
None

Post Condition
Returns the interrupt number of nand instance

Modifies
None

Example

            int16    intrNum;
            Uint16   instId;

            instId = 0;
            intrNum = NAND_getIntrNum(instId);
     

============================================================================

References CSL_NAND_INST_0, and CSL_NAND_INV_INTR_NUM.

static CSL_Status NAND_getSetup ( CSL_NandHandle  hNand,
CSL_NandConfig getNandConfig 
) [inline, static]

NAND query function ============================================================================
NAND_getSetup

Description
This API returns configuration of the nand hardware registers.

Arguments

            hNand            Handle to the nand object
            getNandConfig    Nand configuration structure
     

Return Value CSL_Status

  • CSL_SOK - Returned for success
  • CSL_ESYS_INVPARAMS - Invalid handle

Pre Condition
NAND_setup should be called successfully

Post Condition
Returns the nand configuration

Modifies
nand get config structure

Example

            CSL_NandObj            nandObj;
            Uint16                 instId;
            CSL_Status             status;
            CSL_NandConfig         nandCfg;
            CSL_NandConfig         getNandConfig;
            CSL_NandHandle         hNand;
            CSL_NandAsyncWaitCfg   asyncWaitConfig;
            CSL_NandAsyncCfg       asyncConfig;
            CSL_NandAsyncWaitCfg   getAsyncWaitConfig;
            CSL_NandAsyncCfg       getAsyncConfig;

            instId = 0;
            status = NAND_init(&nandObj, instId);
            hNand  = &nandObj;
            ...
            nandCfg.nandWidth = CSL_NAND_8_BIT;
            ...
            ...
            nandCfg.asyncWaitCfg = &asyncWaitConfig;
            nandCfg.asyncCfg     = &asyncConfig;
            status = NAND_setup(hNand, &nandCfg);
            nandGetCfg.asyncWaitCfg = &getAsyncWaitConfig;
            nandGetCfg.asyncCfg     = &getAsyncConfig;
            status = NAND_getSetup(hNand, &nandGetCfg);
     

============================================================================

References CSL_NandAsyncCfg::aSize, CSL_NandConfig::asyncCfg, CSL_NandConfig::asyncWaitCfg, CSL_NandConfig::chipSelect, CSL_NAND_CS2, CSL_NAND_CS3, CSL_NAND_CS4, CSL_NAND_CS5, CSL_NandConfig::emifAccess, CSL_NandAsyncCfg::ewMode, CSL_NandObj::nandOpMode, CSL_NandConfig::nandOpMode, CSL_NandObj::nandPageSize, CSL_NandConfig::nandPageSize, CSL_NandAsyncWaitCfg::nandPort, CSL_NandObj::nandType, CSL_NandConfig::nandType, CSL_NandObj::nandWidth, CSL_NandConfig::nandWidth, CSL_NandAsyncCfg::r_hold, CSL_NandAsyncCfg::r_setup, CSL_NandAsyncCfg::r_strobe, CSL_NandObj::regs, CSL_NandAsyncCfg::selectStrobe, CSL_NandObj::sysCtrlRegs, CSL_NandAsyncCfg::turnAround, CSL_NandAsyncCfg::w_hold, CSL_NandAsyncCfg::w_setup, CSL_NandAsyncCfg::w_strobe, CSL_NandAsyncWaitCfg::waitCycles, and CSL_NandAsyncWaitCfg::waitPol.

void NAND_hasCacheProg ( Uint32  nandOptions,
Uint16 *  CPstatus 
)

============================================================================
NAND_hasCacheProg

Description
This API checks whether a nand device supports cache programming feature or not.

Arguments

            nandOptions    Extra commands for big block nand
            CPstatus       Cache program status pointer
     

Return Value None

Pre Condition
nandOptions information needs to be computed from nand device Id

Post Condition
Cache program status is returned in status variable

  • TRUE - NAND device is having cache programming
  • FALSE - NAND device is not having cache programming

Modifies
Cache program status variable

Example

             Uint32    nandOptions;
             Uint16    CPstatus;

             //get the nandOptions information from nand device Id
             NAND_hasCacheProg(nandOptions, &CPstatus);
     

============================================================================

References CSL_NAND_BB_CACHE_PROG.

void NAND_hasCopyBack ( Uint32  nandOptions,
Uint16 *  CBstatus 
)

============================================================================
NAND_hasCopyBack

Description
This API checks whether a nand device supports copy back feature or not.

Arguments

            nandOptions    Extra commands for big block nand
            CBstatus       Copy back status pointer
     

Return Value None

Pre Condition
nandOptions information needs to be computed from nand device Id

Post Condition
Copy back status is returned in status variable

  • TRUE - NAND device support copy back feature
  • FALSE - NAND device does not support copy back feature

Modifies
Copy back status variable

Example

            Uint32    nandOptions;
            Uint16    CBstatus;

            //get the nandOptions information from nand device Id
            NAND_hasCopyBack(nandOptions, &CBstatus);
     

============================================================================

References CSL_NAND_BB_COPY_BACK.

void NAND_hasRandomRead ( Uint32  nandOptions,
Uint16 *  RRstatus 
)

============================================================================
NAND_hasRandomRead

Description
This API is used to check whether a nand device is having random page read or not. If nand is having random read we can set pointer to any address in the page and retrieve the data from there.

Arguments

            nandOptions    Extra commands for big block nand
            RRstatus       Random read status pointer
     

Return Value None

Pre Condition
nandOptions information needs to be computed from nand device Id

Post Condition
Random read status is returned in status variable

  • TRUE - NAND device is having random read
  • FALSE - NAND device is not having random read

Modifies
Random read status variable

Example

             Uint32    nandOptions;
             Uint16    RRstatus;

             //get the nandOptions information from nand device Id
             NAND_hasRandomRead(nandOptions, &RRstatus);
     

============================================================================

References CSL_NAND_BB_RANDOM_PAGE_READ.

void NAND_hasRandomWrite ( Uint32  nandOptions,
Uint16 *  RWstatus 
)

============================================================================
NAND_hasRandomWrite

Description
This API is used to check whether a nand device is having random page write or not. If nand is having random write we can set pointer to any address in the page and write the data from there.

Arguments

            nandOptions    Extra commands for big block nand
            RWstatus       Random write status pointer
     

Return Value None

Pre Condition
nandOptions information needs to be computed from nand device Id

Post Condition
Random write status is returned in status variable

  • TRUE - NAND device is having random write
  • FALSE - NAND device is not having random write

Modifies
Random write status variable

Example

             Uint32    nandOptions;
             Uint16    RWstatus;

             //get the nandOptions information from nand device Id
             NAND_hasRandomWrite(nandOptions, &RWstatus);
     

============================================================================

References CSL_NAND_BB_RANDOM_PAGE_WRITE.

CSL_Status NAND_init ( CSL_NandObj nandObj,
Uint16  nandInstId 
)

============================================================================
NAND_init

Description
This is the initialization function for the nand CSL. It populates nand object structure information. This API should be called before calling any other nand CSL APIs.

Arguments

            nandObj       Pointer to nand object structure
            nandInstId    Nand Hardware instance number
     

Return Value CSL_Status

  • CSL_SOK - Nand init is successful
  • CSL_ESYS_INVPARAMS - Invalid parameter

Pre Condition
None

Post Condition
Nand object structure is populated

Modifies
Nand object structure

Example

            CSL_NandObj    nandObj;
            Uint16         instId;
            CSL_Status     status;

            instId = 0;
            status = NAND_init(&nandObj, instId);
     

============================================================================

References CSL_NAND_DELAY, CSL_NAND_INST_0, CSL_NAND_RESET_COUNT_VAL, CSL_NandObj::instId, CSL_NandObj::regs, and CSL_NandObj::sysCtrlRegs.

CSL_Status NAND_intrClear ( CSL_NandHandle  hNand)

============================================================================
NAND_intrClear

Description
Clears a nand interrupt

Arguments

            hNand        Handle to the nand object
     

Return Value CSL_Status

  • CSL_SOK - Returned for success
  • CSL_ESYS_BADHANDLE - Invalid handle

Pre Condition
NAND_intrEnable should be called successfully

Post Condition
Clears nand interrupt

Modifies
Nand interrupt mask register

Example

            CSL_NandObj    nandObj;
            Uint16         instId;
            CSL_Status     status;
            CSL_NandHandle hNand;
            Uint16         WRstatus;

            instId  = 0;
            status = NAND_init(&nandObj, instId);
            hNand  = &nandObj;
            ....
            ....
            status = NAND_intrEnable(hNand);
            ...
            ...
            status = NAND_intrClear(hNand);
     

============================================================================

Clear Wait rise interrupt

Clear line trap interrupt

Clear asyncronous time-out interrupt

References CSL_NandObj::regs.

CSL_Status NAND_intrDisable ( CSL_NandHandle  hNand)

============================================================================
NAND_intrDisable

Description
This API is used to disable nand interrupts.

Arguments

            hNand        Handle to the nand object
     

Return Value CSL_Status

  • CSL_SOK - Nand interrupt disable is successful
  • CSL_ESYS_BADHANDLE - Invalid handle

Pre Condition
NAND_intrEnable should be called successfully

Post Condition
Disables nand interrupts

Modifies
Nand interrupt registers

Example

            CSL_NandObj    nandObj;
            Uint16         instId;
            CSL_Status     status;
            CSL_NandHandle hNand;

            instId  = 0;
            status = NAND_init(&nandObj, instId);
            hNand  = &nandObj;
            ....
            ....
            status = NAND_intrEnable(hNand);
            ...
            ...
            status = NAND_intrDisable(hNand);
     

============================================================================

Disable Wait rise interrupt

Disable line trap interrupt

Disable asyncronous time-out interrupt

References CSL_NandObj::regs.

CSL_Status NAND_intrEnable ( CSL_NandHandle  hNand)

============================================================================
NAND_intrEnable

Description
This API enables nand interrupts. This API is used in interrupt mode of operation of the device.

Arguments

            hNand        Handle to the nand object
     

Return Value CSL_Status

  • CSL_SOK - Nand interrupt enable is successful
  • CSL_ESYS_BADHANDLE - Invalid handle

Pre Condition
NAND_init should be called successfully

Post Condition
Enables nand interrupts

Modifies
Nand interrupt registers

Example

            CSL_NandObj    nandObj;
            Uint16         instId;
            CSL_Status     status;
            CSL_NandHandle hNand;

            instId  = 0;
            status = NAND_init(&nandObj, instId);
            hNand  = &nandObj;
            ....
            ....
            status = NAND_intrEnable(hNand);
     

============================================================================

Enable Wait rise interrupt

Enable line trap interrupt

Enable asyncronous time-out interrupt

References CSL_NandObj::regs.

CSL_Status NAND_intrReadAT ( CSL_NandHandle  hNand,
Uint16 *  ATstatus 
)

============================================================================
NAND_intrReadAT

Description
Reads Asynchronous time-out bit of nand interrupt raw register

Arguments

            hNand        Handle to the nand object
            ATstatus     Asynchronous time-out status variable
     

Return Value CSL_Status

  • CSL_SOK - Returned for success
  • CSL_ESYS_BADHANDLE - Invalid handle

Pre Condition
NAND_intrEnable should be called successfully

Post Condition
Nand asynchronous time-out bit status is returned in status variable

Modifies
Asynchronous time-out status variable

Example

            CSL_NandObj    nandObj;
            Uint16         instId;
            CSL_Status     status;
            CSL_NandHandle hNand;
            Uint16         ATstatus;

            instId  = 0;
            status = NAND_init(&nandObj, instId);
            hNand  = &nandObj;
            ....
            ....
            status = NAND_intrEnable(hNand);
            ...
            ...
            status = NAND_intrReadAT(hNand,&ATstatus);
     

============================================================================

============================================================================
NAND_intrReadAT

Description
Reads Asynchronous time-out bit of nand interrupt raw register

Arguments

            hNand        Handle to the nand object
            ATstatus     Asynchronous time-out status variable
     

Return Value CSL_Status

  • CSL_SOK - Returned for success
  • CSL_ESYS_BADHANDLE - Invalid handle
  • CSL_ESYS_INVPARAMS - Invalid parameter

Pre Condition
NAND_intrEnable should be called successfully

Post Condition
Nand asynchronous time-out bit status is returned in status variable

Modifies
Asynchronous time-out status variable

Example

            CSL_NandObj    nandObj;
 			Uint16         instId;
 			CSL_Status     status;
 			CSL_NandHandle hNand;
 			Uint16         ATstatus;

 			instId  = 0;
 			status = NAND_init(&nandObj, instId);
 			hNand  = &nandObj;
 			....
 			....
            status = NAND_intrEnable(hNand);
            ...
            ...
            status = NAND_intrReadAT(hNand,&ATstatus);
     

============================================================================

References CSL_NandObj::regs.

CSL_Status NAND_intrReadLT ( CSL_NandHandle  hNand,
Uint16 *  LTstatus 
)

============================================================================
NAND_intrReadLT

Description
Reads Line-trap bit of nand interrupt raw register

Arguments

            hNand        Handle to the nand object
            LTstatus     Line trap status variable
     

Return Value CSL_Status

  • CSL_SOK - Returned for success
  • CSL_ESYS_BADHANDLE - Invalid handle

Pre Condition
NAND_intrEnable should be called successfully

Post Condition
Nand line trap bit status is returned in status variable

Modifies
Line trap status variable

Example

            CSL_NandObj    nandObj;
            Uint16         instId;
            CSL_Status     status;
            CSL_NandHandle hNand;
            Uint16         LTstatus;

            instId  = 0;
            status = NAND_init(&nandObj, instId);
            hNand  = &nandObj;
            ....
            ....
            status = NAND_intrEnable(hNand);
            ...
            ...
            status = NAND_intrReadLT(hNand,&LTstatus);
     

============================================================================

============================================================================
NAND_intrReadLT

Description
Reads Line-trap bit of nand interrupt raw register

Arguments

            hNand        Handle to the nand object
            LTstatus     Line trap status variable
     

Return Value CSL_Status

  • CSL_SOK - Returned for success
  • CSL_ESYS_BADHANDLE - Invalid handle
  • CSL_ESYS_INVPARAMS - Invalid parameter

Pre Condition
NAND_intrEnable should be called successfully

Post Condition
Nand line trap bit status is returned in status variable

Modifies
Line trap status variable

Example

            CSL_NandObj    nandObj;
 			Uint16         instId;
 			CSL_Status     status;
 			CSL_NandHandle hNand;
 			Uint16         LTstatus;

 			instId  = 0;
 			status = NAND_init(&nandObj, instId);
 			hNand  = &nandObj;
 			....
 			....
            status = NAND_intrEnable(hNand);
            ...
            ...
            status = NAND_intrReadLT(hNand,&LTstatus);
     

============================================================================

References CSL_NandObj::regs.

CSL_Status NAND_intrReadWR ( CSL_NandHandle  hNand,
Uint16 *  WRstatus 
)

============================================================================
NAND_intrReadWR

Description
Reads wait-rise bit of nand interrupt raw register

Arguments

            hNand        Handle to the nand object
            WRstatus     Wait-raise status variable
     

Return Value CSL_Status

  • CSL_SOK - Returned for success
  • CSL_ESYS_BADHANDLE - Invalid handle
  • CSL_ESYS_INVPARAMS - Invalid parameter

Pre Condition
NAND_intrEnable should be called successfully

Post Condition
Nand wait-rise bit status is returned in status variable

Modifies
Wait-rise status variable

Example

            CSL_NandObj    nandObj;
 			Uint16         instId;
 			CSL_Status     status;
 			CSL_NandHandle hNand;
 			Uint16         WRstatus;

 			instId  = 0;
 			status = NAND_init(&nandObj, instId);
 			hNand  = &nandObj;
 			....
 			....
            status = NAND_intrEnable(hNand);
            ...
            ...
            status = NAND_intrReadWR(hNand,&WRstatus);
     

============================================================================

References CSL_NandObj::regs.

CSL_Status NAND_isStatusWriteProtected ( CSL_NandHandle  hNand,
Uint16 *  WPstatus 
)

============================================================================
NAND_isStatusWriteProtected

Description
This is the API used to check if the nand device is write protected. It is not possible write any data to nand if it is write-protected. So this API must be called before calling the write API to check the nand status.

Arguments

            hNand         Handle to the nand object
            WPstatus      Write protect status pointer
     

Return Value CSL_Status

  • CSL_SOK - Returned for success
  • CSL_ESYS_BADHANDLE - Invalid handle

Pre Condition
NAND_init and NAND_getBankInfo should be called successfully

Post Condition
Write protect status is returned in status variable

  • TRUE - NAND device is write protected
  • FALSE - NAND device is not write protected

Modifies
Write protect status variable

Example

            CSL_NandObj    nandObj;
            Uint16         instId;
            Uint16         bankNum;
            CSL_Status     status;
            CSL_NandHandle hNand;
            Uint16         wpstatus;

            instId  = 0;
            bankNum = 0;
            status = NAND_init(&nandObj, instId);
            hNand  = &nandObj;
            ....
            ....
            status = NAND_getBankInfo(hNand, (CSL_NandAsyncBank*)&hNand->bank, bankNum);
             ....
             ....
            status = NAND_isStatusWriteProtected(hNand,&wpstatus);
     

============================================================================

============================================================================
NAND_isStatusWriteProtected

Description
This is the API used to check if the nand device is write protected. It is not possible write any data to nand if it is write-protected. So this API must be called before calling the write API to check the nand status.

Arguments

            hNand         Handle to the nand object
            WPstatus      Write protect status pointer
     

Return Value CSL_Status

  • CSL_SOK - Retutned for success
  • CSL_ESYS_BADHANDLE - Invalid handle
  • CSL_ESYS_INVPARAMS - Invalid parameter

Pre Condition
NAND_init and NAND_getBankInfo should be called successfully

Post Condition
Write protect status is returned in status variable

  • TRUE - NAND device is write protected
  • FALSE - NAND device is not write protected

Modifies
Write protect status variable

Example

            CSL_NandObj    nandObj;
			Uint16         instId;
			Uint16         bankNum;
			CSL_Status     status;
			CSL_NandHandle hNand;
            		Uint16         wpstatus;

			instId  = 0;
			bankNum = 0;
			status = NAND_init(&nandObj, instId);
			hNand  = &nandObj;
			....
			....
            status = NAND_getBankInfo(hNand, (CSL_NandAsyncBank*)&hNand->bank, bankNum);
 			....
 			....
            status = NAND_isStatusWriteProtected(hNand,&wpstatus);
     

============================================================================

References CSL_NandObj::bank, CSL_NandAsyncBank::CExCLE, CSL_NAND_BB_CMD_STATUS_SUCCESS, CSL_NAND_BB_CMD_WP_STATUS_OPEN, CSL_NAND_CMD_STATUS, CSL_NAND_DELAY, CSL_NAND_READ_STATUS_TIMEOUT, CSL_NAND_READWORD, CSL_NAND_SB_CMD_STATUS_SUCCESS, CSL_NAND_SMALL_BLOCK, and CSL_NandObj::nandType.

CSL_Status NAND_readECC ( CSL_NandHandle  hNand,
Uint16 *  eccBuffer,
CSL_NandChipSelect  csInput 
)

============================================================================
NAND_readECC

Description
This API is used to read the information generated by ECC hardware. Hardware ECC must be enabled before calling this API.

Arguments

            hNand        Handle to the nand object
            eccBuffer    ECC Buffer pointer
            csInput      Chip select used for calculating Ecc
     

Return Value CSL_Status

  • CSL_SOK - Nand read is successful
  • CSL_ESYS_BADHANDLE - Invalid handle
  • CSL_ESYS_INVPARAMS - Invalid parameter

Pre Condition
NAND_enableHwECC API should be called successfully

Post Condition
Populates ECC data into eccBuffer

Modifies
eccBuffer

Example

            CSL_Status           status;
            CSL_NandHandle       hNand;
            Uint16               eccBuffer[8];
            CSL_NandChipSelect   csInput;

            csInput = CSL_NAND_CE0;

            status = NAND_enableHwECC(hNand, csInput);
            ...
            ...
            status = NAND_readECC(hNand, eccBuffer, csInput);
     

============================================================================

References CSL_EMIF_NCS2ECC1_LSB, CSL_EMIF_NCS2ECC1_MSB, CSL_EMIF_NCS2ECC2_LSB, CSL_EMIF_NCS2ECC2_MSB, CSL_EMIF_NCS3ECC1_LSB, CSL_EMIF_NCS3ECC1_MSB, CSL_EMIF_NCS3ECC2_LSB, CSL_EMIF_NCS3ECC2_MSB, CSL_EMIF_NCS4ECC1_LSB, CSL_EMIF_NCS4ECC1_MSB, CSL_EMIF_NCS4ECC2_LSB, CSL_EMIF_NCS4ECC2_MSB, CSL_EMIF_NCS5ECC1_LSB, CSL_EMIF_NCS5ECC1_MSB, CSL_EMIF_NCS5ECC2_LSB, CSL_EMIF_NCS5ECC2_MSB, CSL_NAND_8_BIT, CSL_NAND_CS2, CSL_NAND_CS3, CSL_NAND_CS4, CSL_NAND_CS5, CSL_NandObj::nandWidth, and CSL_NandObj::regs.

CSL_Status NAND_readNBytes ( CSL_NandHandle  hNand,
Uint16  readRequest,
Uint16 *  pReadBuffer,
Uint16  pack,
Bool  spare 
)

============================================================================
NAND_readNBytes

Description
This API reads N number of bytes from a nand physical page. Number of bytes to be read is sent as an argument to this API. A read command should be sent and nand page address should be set before calling this API.

Arguments

            hNand          Handle to the nand object
            readRequest    Number of bytes to read
            pReadBuffer    Read buffer pointer
            pack           Data pack flag
            spare          Spare area flag
     

Return Value CSL_Status

  • CSL_SOK - Nand read is successful
  • CSL_ESYS_BADHANDLE - Invalid handle
  • CSL_ESYS_INVPARAMS - Invalid parameter

Pre Condition
NAND_sendCommand and NAND_setAddress APIs should be called successfully

Post Condition
Reads the data from nand

Modifies
Copies data from nand to read buffer

Example

            #define  NAND_BUF_SIZE      (1024)

			CSL_Status     status;
			CSL_NandHandle hNand;
			Uint32         address;
			Uint16         nandReadBuf[NAND_BUF_SIZE];

			address = 0x40;
            status = NAND_sendCommand(hNand,CSL_NAND_CMD_READ_START);

            // Set column address
			status = NAND_setAddress(hNand,0x00);
	        status = NAND_setAddress(hNand,0x00);
            // Set row address
			status = NAND_setAddress(hNand,0x40);
			status = NAND_setAddress(hNand,0x00);
			status = NAND_setAddress(hNand,0x00);
            ....
            ....
            status = NAND_readNBytes(hNand,NAND_BUF_SIZE,nandreadBuf,0,0);
     

============================================================================

References CSL_NAND_READWORD.

CSL_Status NAND_sendCommand ( CSL_NandHandle  hNand,
CSL_VUint16  cmd 
)

============================================================================
NAND_sendCommand

Description
Any command to the nand device should be sent through this API. nand device is having specific commands for each operation.

Arguments

            hNand          Handle to the nand object
            cmd            Command to the nand device
     

Return Value CSL_Status

  • CSL_SOK - Nand send command is successful
  • CSL_ESYS_BADHANDLE - Invalid handle

Pre Condition
NAND_init and NAND_getBankInfo should be called successfully

Post Condition
Sends command to the nand device

Modifies
Writes command to the command latch address

Example

            CSL_NandObj    nandObj;
            Uint16         instId;
            Uint16         bankNum;
            CSL_Status     status;
            CSL_NandHandle hNand;

            instId  = 0;
            bankNum = 0;
            status = NAND_init(&nandObj, instId);
            hNand  = &nandObj;
            ....
            ....
            status = NAND_getBankInfo(hNand, (CSL_NandAsyncBank*)&hNand->bank, bankNum);
            ....
            ....
            status = NAND_sendCommand(hNand,CSL_NAND_CMD_READ_START);
     

============================================================================

References CSL_NandObj::bank, and CSL_NandAsyncBank::CExCLE.

CSL_Status NAND_setAddress ( CSL_NandHandle  hNand,
Uint16  addr 
)

============================================================================
NAND_setAddress

Description
This API used to set address of nand page to read/write data from/to nand device. Page address must be set to a valid nand page before calling read/write APIs.

Arguments

            hNand          Handle to the nand object
            addr           Addres value to set
     

Return Value CSL_Status

  • CSL_SOK - Nand set address is successful
  • CSL_ESYS_BADHANDLE - Invalid handle
  • CSL_ESYS_INVPARAMS - Invalid parameter

Pre Condition
NAND_init and NAND_getBankInfo should be called successfully

Post Condition
Sets nand address

Modifies
Writes address to the address latch

Example

            CSL_NandObj    nandObj;
            Uint16         instId;
            Uint16         bankNum;
            CSL_Status     status;
            CSL_NandHandle hNand;

            instId  = 0;
            bankNum = 0;
            status = NAND_init(&nandObj, instId);
            hNand  = &nandObj;
            ....
            ....
            status = NAND_getBankInfo(hNand, (CSL_NandAsyncBank*)&hNand->bank, bankNum);
            ....
            ....
            status = NAND_setAddress(hNand,0x01);
     

============================================================================

References CSL_NandObj::bank, CSL_NandAsyncBank::CExALE, CSL_NAND_16_BIT, CSL_NAND_8_BIT, and CSL_NandObj::nandWidth.

CSL_Status NAND_setLatchEnableOffset ( CSL_NandHandle  hNand,
Uint32  addrOffset,
Uint32  cmdOffset 
)

============================================================================
NAND_setLatchEnableOffset

Description
This API sets the CLE and ALE address offset. Any of the EMIF address lines can be used to drive ALE and CLE of the NAND flash. ALE and CLE address offset are decided based of the address lines used to drive ALE and CLE pins. This API should be called after calling NAND_getBankInfo() API to modify the ALE and CLE address from the default value.

NOTE: Addresses passed should be offset values from the base address. For example assume that EMIF A11 line is used to drive ALE pin and EMIF A12 line is used to driver CLE pin. Then the address offset for ALE will be 0x1000 and address offset for CLE will be 0x2000.

Calling this API is mandatory in case of NAND ALE and CLE connected to pins other than A11 and A12 respectively. Otherwise NAND CSL APIs will not function properly.

Arguments

            hNand         Handle to the nand object
            addrOffset    ALE offset location
            cmdOffset     CLE offset location
     

Return Value CSL_Status

  • CSL_SOK - Set address offset is successful
  • CSL_ESYS_BADHANDLE - Invalid handle

Pre Condition
Nand init should be called successfully
NAND_getBankInfo() should be called successfully

Post Condition
Sets the ALE and CLE address offset

Modifies
NAND handle

Example

            CSL_NandObj    nandObj;
			Uint16         instId;
			Uint16         bankNum;
			CSL_Status     status;
			CSL_NandHandle hNand;

			instId  = 0;
			bankNum = 0;
			status = NAND_init(&nandObj, instId);
			hNand  = &nandObj;
			....
			....
            status = NAND_getBankInfo(hNand, (CSL_NandAsyncBank*)&hNand->bank, bankNum);
            status = NAND_setLatchEnableOffset(hNand, 0x2000, 0x4000);
     

============================================================================

References CSL_NandObj::bank, CSL_NandAsyncBank::CExALE, CSL_NandAsyncBank::CExCLE, and CSL_NandAsyncBank::CExDATA.

CSL_Status NAND_setup ( CSL_NandHandle  hNand,
CSL_NandConfig nandConfig 
)

============================================================================
NAND_setup

Description
This API configures the nand hardware registers.

Arguments

            hNand         Handle to the nand object
            nandConfig    Nand configuration structure
     

Return Value CSL_Status

  • CSL_SOK - Nand setup is successful
  • CSL_ESYS_BADHANDLE - Invalid handle
  • CSL_ESYS_INVPARAMS - Invalid config structure

Pre Condition
Nand init should be called successfully

Post Condition
Configures nand registers

Modifies
nand registers

Example

            CSL_NandObj            nandObj;
            Uint16                 instId;
            CSL_Status             status;
            CSL_NandConfig         nandCfg;
            CSL_NandHandle         hNand;
            CSL_NandAsyncWaitCfg   asyncWaitConfig;
            CSL_NandAsyncCfg       asyncConfig;

            instId = 0;
            status = NAND_init(&nandObj, instId);
            hNand  = &nandObj;
            ...
            nandCfg.nandWidth = CSL_NAND_8_BIT;
            ...
            ...
            nandCfg.asyncWaitCfg = &asyncWaitConfig;
        	nandCfg.asyncCfg     = &asyncConfig;
            status = NAND_setup(hNand, &nandCfg);
     

============================================================================

References CSL_NandAsyncCfg::aSize, CSL_NandConfig::asyncCfg, CSL_NandConfig::asyncWaitCfg, CSL_NandConfig::chipSelect, CSL_NandObj::chipSelect, CSL_NAND_CS2, CSL_NAND_CS3, CSL_NAND_CS4, CSL_NAND_CS5, CSL_NandConfig::emifAccess, CSL_NandAsyncCfg::ewMode, CSL_NandConfig::nandOpMode, CSL_NandObj::nandOpMode, CSL_NandConfig::nandPageSize, CSL_NandObj::nandPageSize, CSL_NandAsyncWaitCfg::nandPort, CSL_NandConfig::nandType, CSL_NandObj::nandType, CSL_NandConfig::nandWidth, CSL_NandObj::nandWidth, CSL_NandAsyncCfg::r_hold, CSL_NandAsyncCfg::r_setup, CSL_NandAsyncCfg::r_strobe, CSL_NandObj::regs, CSL_NandAsyncCfg::selectStrobe, CSL_NandObj::sysCtrlRegs, CSL_NandAsyncCfg::turnAround, CSL_NandAsyncCfg::w_hold, CSL_NandAsyncCfg::w_setup, CSL_NandAsyncCfg::w_strobe, CSL_NandAsyncWaitCfg::waitCycles, CSL_NandObj::waitPin, and CSL_NandAsyncWaitCfg::waitPol.

CSL_Status NAND_writeNBytes ( CSL_NandHandle  hNand,
Uint16  writeRequest,
Uint16 *  pWriteBuffer,
Uint16  val,
Bool  spare 
)

============================================================================
NAND_writeNBytes

Description
This API writes N number of bytes to a nand physical page. Number of bytes to be written is sent as an argument to this API. A page program command should be sent and nand page address should be set before calling this API. nand device should not be write-protected for proper functioning of this API.

Arguments

            hNand          Handle to the nand object
            writeRequest   Number of bytes to write
            pWriteBuffer   Write buffer pointer
            val            If a value needs to be wriiten directly without
                           using write buffer
            spare          Spare area flag
     

Return Value CSL_Status

  • CSL_SOK - Nand write is successful
  • CSL_ESYS_BADHANDLE - Invalid handle

Pre Condition
NAND_sendCommand and NAND_setAddress APIs should be called successfully

Post Condition
Writes the data to nand

Modifies
Nand write registers

Example

            #define  NAND_BUF_SIZE      (1024)

			CSL_Status     status;
			CSL_NandHandle hNand;
			Uint32         address;
			Uint16         nandWriteBuf[NAND_BUF_SIZE];

			address = 0x40;
            status = NAND_sendCommand(hNand,CSL_NAND_CMD_READ_START);
            // Set column address
			status = NAND_setAddress(hNand,0x00);
	        status = NAND_setAddress(hNand,0x00);

            // Set row address
			status = NAND_setAddress(hNand,0x40);
			status = NAND_setAddress(hNand,0x00);
			status = NAND_setAddress(hNand,0x00);
            ....
            ....
            status = NAND_writeNBytes(hNand,NAND_BUF_SIZE,nandWriteBuf,0,0);
     

============================================================================

References CSL_NAND_WRITEBYTE, and CSL_NAND_WRITEWORD.