![]() |
|
|||
File indexing completed on 2025-05-11 08:23:42
0001 /****************************************************************************** 0002 * Copyright (C) 2015 - 2022 Xilinx, Inc. All rights reserved. 0003 * SPDX-License-Identifier: MIT 0004 ******************************************************************************/ 0005 0006 /*****************************************************************************/ 0007 /** 0008 * 0009 * @file xnandpsu.h 0010 * @addtogroup Overview 0011 * @{ 0012 * @details 0013 * 0014 * This file implements a driver to support Arasan NAND controller 0015 * present in Zynq Ultrascale Mp. 0016 * 0017 * <b>Driver Initialization</b> 0018 * 0019 * The function call XNandPsu_CfgInitialize() should be called by the application 0020 * before any other function in the driver. The initialization function takes 0021 * device specific data (like device id, instance id, and base address) and 0022 * initializes the XNandPsu instance with the device specific data. 0023 * 0024 * <b>Device Geometry</b> 0025 * 0026 * NAND flash device is memory device and it is segmented into areas called 0027 * Logical Unit(s) (LUN) and further in to blocks and pages. A NAND flash device 0028 * can have multiple LUN. LUN is sequential raw of multiple blocks of the same 0029 * size. A block is the smallest erasable unit of data within the Flash array of 0030 * a LUN. The size of each block is based on a power of 2. There is no 0031 * restriction on the number of blocks within the LUN. A block contains a number 0032 * of pages. A page is the smallest addressable unit for read and program 0033 * operations. The arrangement of LUN, blocks, and pages is referred to by this 0034 * module as the part's geometry. 0035 * 0036 * The cells within the part can be programmed from a logic 1 to a logic 0 0037 * and not the other way around. To change a cell back to a logic 1, the 0038 * entire block containing that cell must be erased. When a block is erased 0039 * all bytes contain the value 0xFF. The number of times a block can be 0040 * erased is finite. Eventually the block will wear out and will no longer 0041 * be capable of erasure. As of this writing, the typical flash block can 0042 * be erased 100,000 or more times. 0043 * 0044 * The jobs done by this driver typically are: 0045 * - 8-bit operational mode 0046 * - Read, Write, and Erase operation 0047 * 0048 * <b>Write Operation</b> 0049 * 0050 * The write call can be used to write a minimum of one byte and a maximum 0051 * entire flash. If the address offset specified to write is out of flash or if 0052 * the number of bytes specified from the offset exceed flash boundaries 0053 * an error is reported back to the user. The write is blocking in nature in that 0054 * the control is returned back to user only after the write operation is 0055 * completed successfully or an error is reported. 0056 * 0057 * <b>Read Operation</b> 0058 * 0059 * The read call can be used to read a minimum of one byte and maximum of 0060 * entire flash. If the address offset specified to read is out of flash or if 0061 * the number of bytes specified from the offset exceed flash boundaries 0062 * an error is reported back to the user. The read is blocking in nature in that 0063 * the control is returned back to user only after the read operation is 0064 * completed successfully or an error is reported. 0065 * 0066 * <b>Erase Operation</b> 0067 * 0068 * The erase operations are provided to erase a Block in the Flash memory. The 0069 * erase call is blocking in nature in that the control is returned back to user 0070 * only after the erase operation is completed successfully or an error is 0071 * reported. 0072 * 0073 * @note Driver has been renamed to nandpsu after change in 0074 * naming convention. 0075 * 0076 * This driver is intended to be RTOS and processor independent. It works with 0077 * physical addresses only. Any needs for dynamic memory management, threads, 0078 * mutual exclusion, virtual memory, cache control, or HW write protection 0079 * management must be satisfied by the layer above this driver. 0080 * 0081 * <pre> 0082 * MODIFICATION HISTORY: 0083 * 0084 * Ver Who Date Changes 0085 * ----- ---- ---------- ----------------------------------------------- 0086 * 1.0 nm 05/06/2014 First release 0087 * 2.0 sb 01/12/2015 Removed Null checks for Buffer passed 0088 * as parameter to Read API's 0089 * - XNandPsu_Read() 0090 * - XNandPsu_ReadPage 0091 * Modified 0092 * - XNandPsu_SetFeature() 0093 * - XNandPsu_GetFeature() 0094 * and made them public. 0095 * Removed Failure Return for BCF Error check in 0096 * XNandPsu_ReadPage() and added BCH_Error counter 0097 * in the instance pointer structure. 0098 * Added XNandPsu_Prepare_Cmd API 0099 * Replaced 0100 * - XNandPsu_IntrStsEnable 0101 * - XNandPsu_IntrStsClear 0102 * - XNandPsu_IntrClear 0103 * - XNandPsu_SetProgramReg 0104 * with XNandPsu_WriteReg call 0105 * Modified xnandpsu.c file API's with above changes. 0106 * Corrected the program command for Set Feature API. 0107 * Modified 0108 * - XNandPsu_OnfiReadStatus 0109 * - XNandPsu_GetFeature 0110 * - XNandPsu_SetFeature 0111 * to add support for DDR mode. 0112 * Changed Convention for SLC/MLC 0113 * SLC --> HAMMING 0114 * MLC --> BCH 0115 * SlcMlc --> IsBCH 0116 * Added support for writing BBT signature and version 0117 * in page section by enabling XNANDPSU_BBT_NO_OOB. 0118 * Removed extra DMA mode initialization from 0119 * the XNandPsu_CfgInitialize API. 0120 * Modified 0121 * - XNandPsu_SetEccAddrSize 0122 * ECC address now is calculated based upon the 0123 * size of spare area 0124 * Modified Block Erase API, removed clearing of 0125 * packet register before erase. 0126 * Clearing Data Interface Register before 0127 * XNandPsu_OnfiReset call. 0128 * Modified XNandPsu_ChangeTimingMode API supporting 0129 * SDR and NVDDR interface for timing modes 0 to 5. 0130 * Modified Bbt Signature and Version Offset value for 0131 * Oob and No-Oob region. 0132 * 1.0 kpc 17/06/2015 Increased the timeout for complete event to avoid 0133 * timeout errors for erase operation on slower devices. 0134 * 1.1 mi 09/16/16 Removed compilation warnings with extra compiler flags. 0135 * 1.1 nsk 11/07/16 Change memcpy to Xil_MemCpy, CR#960462 0136 * 1.2 nsk 01/19/17 Fix for the failure of reading nand first redundant 0137 * parameter page. CR#966603 0138 * ms 02/12/17 Fix for the compilation warning in _g.c file. 0139 * ms 03/17/17 Added readme.txt file in examples folder for doxygen 0140 * generation. 0141 * ms 04/10/17 Modified Comment lines in nandpsu_example.c to 0142 * follow doxygen rules. 0143 * 1.2 nsk 08/08/17 Added support to import example in SDK 0144 * 1.4 nsk 04/10/18 Added ICCARM compiler support. CR#997552. 0145 * 1.5 mus 11/08/18 Updated BBT signature array size in 0146 * XNandPsu_BbtDesc structure to fix the compilation 0147 * warnings. 0148 # 1.6 sd 06/02/20 Added Clock support 0149 * 1.6 sd 20/03/20 Added compilation flag 0150 * 1.8 sg 03/18/21 Added validation check for parameter page. 0151 * 1.9 akm 07/15/21 Initialize NandInstPtr with Data Interface & Timing mode info. 0152 * 1.10 akm 10/20/21 Fix gcc warnings. 0153 * 1.10 akm 12/21/21 Validate input parameters before use. 0154 * 1.10 akm 01/05/22 Remove assert checks form static and internal APIs. 0155 * 1.11 akm 03/31/22 Fix unused parameter warning. 0156 * 1.11 akm 03/31/22 Fix misleading-indentation warning. 0157 * 0158 * </pre> 0159 * 0160 ******************************************************************************/ 0161 0162 #ifndef XNANDPSU_H /* prevent circular inclusions */ 0163 #define XNANDPSU_H /* by using protection macros */ 0164 0165 #ifdef __cplusplus 0166 extern "C" { 0167 #endif 0168 0169 /***************************** Include Files *********************************/ 0170 #ifndef __rtems__ 0171 #include "xil_types.h" 0172 #include <string.h> 0173 #include "xstatus.h" 0174 #include "xil_assert.h" 0175 #include "xnandpsu_hw.h" 0176 #include "xnandpsu_onfi.h" 0177 #include "xil_cache.h" 0178 #if defined (XCLOCKING) 0179 #include "xil_clocking.h" 0180 #endif 0181 #else 0182 #include <bsp/xil-compat.h> 0183 #include <string.h> 0184 #include "xnandpsu_hw.h" 0185 #include "xnandpsu_onfi.h" 0186 #endif 0187 /************************** Constant Definitions *****************************/ 0188 0189 #define XNANDPSU_DEBUG 0190 0191 #ifdef __rtems__ 0192 #define XNANDPSU_MAX_TARGETS 2U /**< ce_n0, ce_n1 */ 0193 #else 0194 #define XNANDPSU_MAX_TARGETS 1U /**< ce_n0, ce_n1 */ 0195 #endif 0196 #define XNANDPSU_MAX_PKT_SIZE 0x7FFU /**< Max packet size */ 0197 #define XNANDPSU_MAX_PKT_COUNT 0xFFFU /**< Max packet count */ 0198 0199 #define XNANDPSU_PAGE_SIZE_512 512U /**< 512 bytes page */ 0200 #define XNANDPSU_PAGE_SIZE_2K 2048U /**< 2K bytes page */ 0201 #define XNANDPSU_PAGE_SIZE_4K 4096U /**< 4K bytes page */ 0202 #define XNANDPSU_PAGE_SIZE_8K 8192U /**< 8K bytes page */ 0203 #define XNANDPSU_PAGE_SIZE_16K 16384U /**< 16K bytes page */ 0204 #define XNANDPSU_PAGE_SIZE_1K_16BIT 1024U /**< 16-bit 2K bytes page */ 0205 #define XNANDPSU_MAX_PAGE_SIZE 16384U /**< Max page size supported */ 0206 0207 #define XNANDPSU_HAMMING 0x1U /**< Hamming Flash */ 0208 #define XNANDPSU_BCH 0x2U /**< BCH Flash */ 0209 0210 #define XNANDPSU_MAX_BLOCKS 16384U /**< Max number of Blocks */ 0211 #define XNANDPSU_MAX_SPARE_SIZE 0x800U /**< Max spare bytes of a NAND 0212 flash page of 16K */ 0213 #define XNANDPSU_MAX_LUNS 8U /**< Max number of LUNs */ 0214 #define XNANDPSU_MAX_PAGES_PER_BLOCK 512U /**< Max number pages per block */ 0215 0216 #define XNANDPSU_INTR_POLL_TIMEOUT 0xF000000U 0217 0218 #define XNANDPSU_SDR_CLK ((u16)100U * (u16)1000U * (u16)1000U) 0219 #define XNANDPSU_NVDDR_CLK_0 ((u16)20U * (u16)1000U * (u16)1000U) 0220 #define XNANDPSU_NVDDR_CLK_1 ((u16)33U * (u16)1000U * (u16)1000U) 0221 #define XNANDPSU_NVDDR_CLK_2 ((u16)50U * (u16)1000U * (u16)1000U) 0222 #define XNANDPSU_NVDDR_CLK_3 ((u16)66U * (u16)1000U * (u16)1000U) 0223 #define XNANDPSU_NVDDR_CLK_4 ((u16)83U * (u16)1000U * (u16)1000U) 0224 #define XNANDPSU_NVDDR_CLK_5 ((u16)100U * (u16)1000U * (u16)1000U) 0225 0226 #define XNANDPSU_MAX_TIMING_MODE 5 0227 0228 #ifdef __rtems__ 0229 #define XNANDPSU_PAGE_CACHE_UNAVAILABLE -2 0230 #define XNANDPSU_PAGE_CACHE_NONE -1 0231 #endif 0232 0233 /** 0234 * The XNandPsu_Config structure contains configuration information for NAND 0235 * controller. 0236 */ 0237 typedef struct { 0238 u16 DeviceId; /**< Instance ID of NAND flash controller */ 0239 u32 BaseAddress; /**< Base address of NAND flash controller */ 0240 u8 IsCacheCoherent; /**< Describes whether Cache Coherent or not */ 0241 #if defined (XCLOCKING) 0242 u32 RefClk; /**< Input clocks */ 0243 #endif 0244 } XNandPsu_Config; 0245 0246 /** 0247 * The XNandPsu_DataInterface enum contains flash operating mode. 0248 */ 0249 typedef enum { 0250 XNANDPSU_SDR = 0U, /**< Single Data Rate */ 0251 XNANDPSU_NVDDR /**< Double Data Rate */ 0252 } XNandPsu_DataInterface; 0253 0254 /** 0255 * XNandPsu_TimingMode enum contains timing modes. 0256 */ 0257 typedef enum { 0258 XNANDPSU_SDR0 = 0U, 0259 XNANDPSU_SDR1, 0260 XNANDPSU_SDR2, 0261 XNANDPSU_SDR3, 0262 XNANDPSU_SDR4, 0263 XNANDPSU_SDR5, 0264 XNANDPSU_NVDDR0, 0265 XNANDPSU_NVDDR1, 0266 XNANDPSU_NVDDR2, 0267 XNANDPSU_NVDDR3, 0268 XNANDPSU_NVDDR4, 0269 XNANDPSU_NVDDR5 0270 } XNandPsu_TimingMode; 0271 0272 /** 0273 * The XNandPsu_SWMode enum contains the driver operating mode. 0274 */ 0275 typedef enum { 0276 XNANDPSU_POLLING = 0, /**< Polling */ 0277 XNANDPSU_INTERRUPT /**< Interrupt */ 0278 } XNandPsu_SWMode; 0279 0280 /** 0281 * The XNandPsu_DmaMode enum contains the controller MDMA mode. 0282 */ 0283 typedef enum { 0284 XNANDPSU_PIO = 0, /**< PIO Mode */ 0285 XNANDPSU_SDMA, /**< SDMA Mode */ 0286 XNANDPSU_MDMA /**< MDMA Mode */ 0287 } XNandPsu_DmaMode; 0288 0289 /** 0290 * The XNandPsu_EccMode enum contains ECC functionality. 0291 */ 0292 typedef enum { 0293 XNANDPSU_NONE = 0, 0294 XNANDPSU_HWECC, 0295 XNANDPSU_EZNAND, 0296 XNANDPSU_ONDIE 0297 } XNandPsu_EccMode; 0298 0299 /** 0300 * Bad block table descriptor 0301 */ 0302 typedef struct { 0303 u32 PageOffset[XNANDPSU_MAX_TARGETS]; 0304 /**< Page offset where BBT resides */ 0305 u32 SigOffset; /**< Signature offset in Spare area */ 0306 u32 VerOffset; /**< Offset of BBT version */ 0307 u32 SigLength; /**< Length of the signature */ 0308 u32 MaxBlocks; /**< Max blocks to search for BBT */ 0309 char Signature[5]; /**< BBT signature */ 0310 u8 Version[XNANDPSU_MAX_TARGETS]; 0311 /**< BBT version */ 0312 u32 Valid; /**< BBT descriptor is valid or not */ 0313 } XNandPsu_BbtDesc; 0314 0315 /** 0316 * Bad block pattern 0317 */ 0318 typedef struct { 0319 u32 Options; /**< Options to search the bad block pattern */ 0320 u32 Offset; /**< Offset to search for specified pattern */ 0321 u32 Length; /**< Number of bytes to check the pattern */ 0322 u8 Pattern[2]; /**< Pattern format to search for */ 0323 } XNandPsu_BadBlockPattern; 0324 0325 /** 0326 * The XNandPsu_Geometry structure contains the ONFI geometry information. 0327 */ 0328 typedef struct { 0329 /* Parameter page information */ 0330 u32 BytesPerPage; /**< Number of bytes per page */ 0331 u16 SpareBytesPerPage; /**< Number of spare bytes per page */ 0332 u32 PagesPerBlock; /**< Number of pages per block */ 0333 u32 BlocksPerLun; /**< Number of blocks per LUN */ 0334 u8 NumLuns; /**< Number of LUN's */ 0335 u8 RowAddrCycles; /**< Row address cycles */ 0336 u8 ColAddrCycles; /**< Column address cycles */ 0337 u8 NumBitsPerCell; /**< Number of bits per cell (Hamming/BCH) */ 0338 u8 NumBitsECC; /**< Number of bits ECC correctability */ 0339 u32 EccCodeWordSize; /**< ECC codeword size */ 0340 /* Driver specific information */ 0341 u32 BlockSize; /**< Block size */ 0342 u32 NumTargetPages; /**< Total number of pages in a Target */ 0343 u32 NumTargetBlocks; /**< Total number of blocks in a Target */ 0344 u64 TargetSize; /**< Target size in bytes */ 0345 u8 NumTargets; /**< Number of targets present */ 0346 u32 NumPages; /**< Total number of pages */ 0347 u32 NumBlocks; /**< Total number of blocks */ 0348 u64 DeviceSize; /**< Total flash size in bytes */ 0349 } XNandPsu_Geometry; 0350 0351 /** 0352 * The XNandPsu_Features structure contains the ONFI features information. 0353 */ 0354 typedef struct { 0355 u32 NvDdr; 0356 u32 EzNand; 0357 u32 OnDie; 0358 u32 ExtPrmPage; 0359 } XNandPsu_Features; 0360 0361 /** 0362 * The XNandPsu_EccMatrix structure contains ECC features information. 0363 */ 0364 typedef struct { 0365 u16 PageSize; 0366 u16 CodeWordSize; 0367 u8 NumEccBits; 0368 u8 IsBCH; 0369 u16 EccAddr; 0370 u16 EccSize; 0371 } XNandPsu_EccMatrix; 0372 0373 /** 0374 * The XNandPsu_EccCfg structure contains ECC configuration. 0375 */ 0376 typedef struct { 0377 u16 EccAddr; 0378 u16 EccSize; 0379 u16 CodeWordSize; 0380 u8 NumEccBits; 0381 u8 IsBCH; 0382 } XNandPsu_EccCfg; 0383 0384 /** 0385 * The XNandPsu structure contains the driver instance data. The user is 0386 * required to allocate a variable of this type for the NAND controller. 0387 * A pointer to a variable of this type is then passed to the driver API 0388 * functions. 0389 */ 0390 #ifdef __ICCARM__ 0391 #pragma pack(push, 1) 0392 #endif 0393 typedef struct { 0394 u32 IsReady; /**< Device is initialized and ready */ 0395 XNandPsu_Config Config; 0396 u32 Ecc_Stat_PerPage_flips; /**< Ecc Correctable Error Counter for Current Page */ 0397 u32 Ecc_Stats_total_flips; /**< Total Ecc Errors Corrected */ 0398 XNandPsu_DataInterface DataInterface; 0399 XNandPsu_TimingMode TimingMode; 0400 XNandPsu_SWMode Mode; /**< Driver operating mode */ 0401 XNandPsu_DmaMode DmaMode; /**< MDMA mode enabled/disabled */ 0402 XNandPsu_EccMode EccMode; /**< ECC Mode */ 0403 XNandPsu_EccCfg EccCfg; /**< ECC configuration */ 0404 XNandPsu_Geometry Geometry; /**< Flash geometry */ 0405 XNandPsu_Features Features; /**< ONFI features */ 0406 #ifdef __rtems__ 0407 int32_t PartialDataPageIndex; /**< Cached page index */ 0408 #endif 0409 #ifdef __ICCARM__ 0410 u8 PartialDataBuf[XNANDPSU_MAX_PAGE_SIZE]; /**< Partial read/write buffer */ 0411 #pragma pack(pop) 0412 #else 0413 u8 PartialDataBuf[XNANDPSU_MAX_PAGE_SIZE] __attribute__ ((aligned(64))); 0414 #endif 0415 /* Bad block table definitions */ 0416 XNandPsu_BbtDesc BbtDesc; /**< Bad block table descriptor */ 0417 XNandPsu_BbtDesc BbtMirrorDesc; /**< Mirror BBT descriptor */ 0418 XNandPsu_BadBlockPattern BbPattern; /**< Bad block pattern to 0419 search */ 0420 u8 Bbt[XNANDPSU_MAX_BLOCKS >> 2]; /**< Bad block table array */ 0421 } XNandPsu; 0422 0423 /******************* Macro Definitions (Inline Functions) *******************/ 0424 0425 /*****************************************************************************/ 0426 /** 0427 * This macro sets the bitmask in the register. 0428 * 0429 * @param InstancePtr is a pointer to the XNandPsu instance of the 0430 * controller. 0431 * @param RegOffset is the register offset. 0432 * @param BitMask is the bitmask. 0433 * 0434 * @note C-style signature: 0435 * void XNandPsu_SetBits(XNandPsu *InstancePtr, u32 RegOffset, 0436 * u32 BitMask) 0437 * 0438 *****************************************************************************/ 0439 #define XNandPsu_SetBits(InstancePtr, RegOffset, BitMask) \ 0440 XNandPsu_WriteReg((InstancePtr)->Config.BaseAddress, \ 0441 (RegOffset), \ 0442 ((u32)(XNandPsu_ReadReg((InstancePtr)->Config.BaseAddress, \ 0443 (RegOffset)) | (BitMask)))) 0444 0445 /*****************************************************************************/ 0446 /** 0447 * This macro clears the bitmask in the register. 0448 * 0449 * @param InstancePtr is a pointer to the XNandPsu instance of the 0450 * controller. 0451 * @param RegOffset is the register offset. 0452 * @param BitMask is the bitmask. 0453 * 0454 * @note C-style signature: 0455 * void XNandPsu_ClrBits(XNandPsu *InstancePtr, u32 RegOffset, 0456 * u32 BitMask) 0457 * 0458 *****************************************************************************/ 0459 #define XNandPsu_ClrBits(InstancePtr, RegOffset, BitMask) \ 0460 XNandPsu_WriteReg((InstancePtr)->Config.BaseAddress, \ 0461 (RegOffset), \ 0462 ((u32)(XNandPsu_ReadReg((InstancePtr)->Config.BaseAddress, \ 0463 (RegOffset)) & ~(BitMask)))) 0464 0465 /*****************************************************************************/ 0466 /** 0467 * This macro clears and updates the bitmask in the register. 0468 * 0469 * @param InstancePtr is a pointer to the XNandPsu instance of the 0470 * controller. 0471 * @param RegOffset is the register offset. 0472 * @param Mask is the bitmask. 0473 * @param Value is the register value to write. 0474 * 0475 * @note C-style signature: 0476 * void XNandPsu_ReadModifyWrite(XNandPsu *InstancePtr, 0477 * u32 RegOffset, u32 Mask, u32 Val) 0478 * 0479 *****************************************************************************/ 0480 #define XNandPsu_ReadModifyWrite(InstancePtr, RegOffset, Mask, Value) \ 0481 XNandPsu_WriteReg((InstancePtr)->Config.BaseAddress, \ 0482 (RegOffset), \ 0483 ((u32)((u32)(XNandPsu_ReadReg((InstancePtr)->Config.BaseAddress,\ 0484 (u32)(RegOffset)) & (u32)(~(Mask))) | (u32)(Value)))) 0485 0486 /*****************************************************************************/ 0487 /** 0488 * This macro enables bitmask in Interrupt Signal Enable register. 0489 * 0490 * @param InstancePtr is a pointer to the XNandPsu instance of the 0491 * controller. 0492 * @param Mask is the bitmask. 0493 * 0494 * @note C-style signature: 0495 * void XNandPsu_IntrSigEnable(XNandPsu *InstancePtr, u32 Mask) 0496 * 0497 *****************************************************************************/ 0498 #define XNandPsu_IntrSigEnable(InstancePtr, Mask) \ 0499 XNandPsu_SetBits((InstancePtr), \ 0500 XNANDPSU_INTR_SIG_EN_OFFSET, \ 0501 (Mask)) 0502 0503 /*****************************************************************************/ 0504 /** 0505 * This macro clears bitmask in Interrupt Signal Enable register. 0506 * 0507 * @param InstancePtr is a pointer to the XNandPsu instance of the 0508 * controller. 0509 * @param Mask is the bitmask. 0510 * 0511 * @note C-style signature: 0512 * void XNandPsu_IntrSigClear(XNandPsu *InstancePtr, u32 Mask) 0513 * 0514 *****************************************************************************/ 0515 #define XNandPsu_IntrSigClear(InstancePtr, Mask) \ 0516 XNandPsu_ClrBits((InstancePtr), \ 0517 XNANDPSU_INTR_SIG_EN_OFFSET, \ 0518 (Mask)) 0519 0520 /*****************************************************************************/ 0521 /** 0522 * This macro enables bitmask in Interrupt Status Enable register. 0523 * 0524 * @param InstancePtr is a pointer to the XNandPsu instance of the 0525 * controller. 0526 * @param Mask is the bitmask. 0527 * 0528 * @note C-style signature: 0529 * void XNandPsu_IntrStsEnable(XNandPsu *InstancePtr, u32 Mask) 0530 * 0531 *****************************************************************************/ 0532 #define XNandPsu_IntrStsEnable(InstancePtr, Mask) \ 0533 XNandPsu_SetBits((InstancePtr), \ 0534 XNANDPSU_INTR_STS_EN_OFFSET, \ 0535 (Mask)) 0536 0537 /*****************************************************************************/ 0538 /** 0539 * This macro checks for the ONFI ID. 0540 * 0541 * @param Buff is the buffer holding ONFI ID 0542 * 0543 * @note none. 0544 * 0545 *****************************************************************************/ 0546 #define IS_ONFI(Buff) \ 0547 ((Buff)[0] == (u8)'O') && ((Buff)[1] == (u8)'N') && \ 0548 ((Buff)[2] == (u8)'F') && ((Buff)[3] == (u8)'I') 0549 0550 /************************** Function Prototypes *****************************/ 0551 0552 s32 XNandPsu_CfgInitialize(XNandPsu *InstancePtr, XNandPsu_Config *ConfigPtr, 0553 u32 EffectiveAddr); 0554 0555 s32 XNandPsu_Erase(XNandPsu *InstancePtr, u64 Offset, u64 Length); 0556 0557 s32 XNandPsu_Write(XNandPsu *InstancePtr, u64 Offset, u64 Length, 0558 u8 *SrcBuf); 0559 0560 s32 XNandPsu_Read(XNandPsu *InstancePtr, u64 Offset, u64 Length, 0561 u8 *DestBuf); 0562 0563 s32 XNandPsu_EraseBlock(XNandPsu *InstancePtr, u32 Target, u32 Block); 0564 0565 s32 XNandPsu_WriteSpareBytes(XNandPsu *InstancePtr, u32 Page, u8 *Buf); 0566 0567 s32 XNandPsu_ReadSpareBytes(XNandPsu *InstancePtr, u32 Page, u8 *Buf); 0568 0569 s32 XNandPsu_ChangeTimingMode(XNandPsu *InstancePtr, 0570 XNandPsu_DataInterface NewIntf, 0571 XNandPsu_TimingMode NewMode); 0572 0573 s32 XNandPsu_GetFeature(XNandPsu *InstancePtr, u32 Target, u8 Feature, 0574 u8 *Buf); 0575 0576 s32 XNandPsu_SetFeature(XNandPsu *InstancePtr, u32 Target, u8 Feature, 0577 u8 *Buf); 0578 0579 s32 XNandPsu_ScanBbt(XNandPsu *InstancePtr); 0580 0581 s32 XNandPsu_MarkBlockBad(XNandPsu *InstancePtr, u32 Block); 0582 0583 #ifdef __rtems__ 0584 #include <stdbool.h> 0585 /*****************************************************************************/ 0586 /** 0587 * This function changes the marking of a block in the RAM based Bad Block Table(BBT). It 0588 * also updates the Bad Block Table(BBT) in the flash if necessary. 0589 * 0590 * @param InstancePtr is the pointer to the XNandPsu instance. 0591 * @param Block is the block number. 0592 * 0593 * @return 0594 * - XST_SUCCESS if successful. 0595 * - XST_FAILURE if fail. 0596 * 0597 ******************************************************************************/ 0598 s32 XNandPsu_MarkBlock(XNandPsu *InstancePtr, u32 Block, u8 BlockMark); 0599 0600 /*****************************************************************************/ 0601 /** 0602 * This function changes the marking of a block in the RAM based Bad Block Table(BBT). It 0603 * does not update the Bad Block Table(BBT) in the flash. 0604 * 0605 * @param InstancePtr is the pointer to the XNandPsu instance. 0606 * @param Block is the block number. 0607 * 0608 * @return 0609 * - true if the BBT needs updating. 0610 * - false if the BBT does not need updating. 0611 * 0612 ******************************************************************************/ 0613 bool XNandPsu_StageBlockMark(XNandPsu *InstancePtr, u32 Block, u8 BlockMark); 0614 0615 /*****************************************************************************/ 0616 /** 0617 * This function updates the primary and mirror Bad Block Table(BBT) in the 0618 * flash. 0619 * 0620 * @param InstancePtr is the pointer to the XNandPsu instance. 0621 * @return 0622 * - XST_SUCCESS if successful. 0623 * - XST_FAILURE if fail. 0624 * 0625 ******************************************************************************/ 0626 s32 XNandPsu_UpdateBbt(XNandPsu *InstancePtr, u32 Target); 0627 #endif 0628 0629 void XNandPsu_EnableDmaMode(XNandPsu *InstancePtr); 0630 0631 void XNandPsu_DisableDmaMode(XNandPsu *InstancePtr); 0632 0633 void XNandPsu_EnableEccMode(XNandPsu *InstancePtr); 0634 0635 void XNandPsu_DisableEccMode(XNandPsu *InstancePtr); 0636 0637 void XNandPsu_Prepare_Cmd(XNandPsu *InstancePtr, u8 Cmd1, u8 Cmd2, u8 EccState, 0638 u8 DmaMode, u8 AddrCycles); 0639 0640 /* XNandPsu_LookupConfig in xnandpsu_sinit.c */ 0641 XNandPsu_Config *XNandPsu_LookupConfig(u16 DevID); 0642 0643 0644 #ifdef __cplusplus 0645 } 0646 #endif 0647 0648 #endif /* XNANDPSU_H end of protection macro */ 0649 /** @} */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |