OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (c) 2008-2009 NVIDIA Corporation. |
| 3 * All rights reserved. |
| 4 * |
| 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are met: |
| 7 * |
| 8 * Redistributions of source code must retain the above copyright notice, |
| 9 * this list of conditions and the following disclaimer. |
| 10 * |
| 11 * Redistributions in binary form must reproduce the above copyright notice, |
| 12 * this list of conditions and the following disclaimer in the documentation |
| 13 * and/or other materials provided with the distribution. |
| 14 * |
| 15 * Neither the name of the NVIDIA Corporation nor the names of its contributors |
| 16 * may be used to endorse or promote products derived from this software |
| 17 * without specific prior written permission. |
| 18 * |
| 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
| 23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 29 * POSSIBILITY OF SUCH DAMAGE. |
| 30 * |
| 31 */ |
| 32 |
| 33 /** |
| 34 * @file |
| 35 * <b> NVIDIA Driver Development Kit: NAND Flash Controller Interface</b> |
| 36 * |
| 37 * @b Description: This file declares the interface for the NAND module. |
| 38 */ |
| 39 |
| 40 #ifndef INCLUDED_NVDDK_NAND_H |
| 41 #define INCLUDED_NVDDK_NAND_H |
| 42 |
| 43 /** |
| 44 * @defgroup nvddk_nand NAND Flash Controller Interface |
| 45 * |
| 46 * This driver provides the interface to access external NAND flash devices |
| 47 * that are interfaced to the SOC. |
| 48 * It provides the APIs to access the NAND flash physically (in raw block number |
| 49 * and page numbers) and logically (in logical block number through |
| 50 * block device interface). |
| 51 * It does not support any software ECC algorithms. It makes use of hardware ECC
|
| 52 * features supported by NAND Controller for validating the data. |
| 53 * It supports accessing NAND flash devices in interleave mode. |
| 54 * |
| 55 * @ingroup nvddk_modules |
| 56 * @{ |
| 57 */ |
| 58 |
| 59 #include "nvcommon.h" |
| 60 #include "nvos.h" |
| 61 #include "nvrm_init.h" |
| 62 #include "nvodm_query_nand.h" |
| 63 |
| 64 #ifdef __cplusplus |
| 65 extern "C" { |
| 66 #endif |
| 67 |
| 68 /** |
| 69 * NvDdkNandHandle is an opaque context to the NvDdkNandRec interface. |
| 70 */ |
| 71 typedef struct NvDdkNandRec *NvDdkNandHandle; |
| 72 |
| 73 |
| 74 enum{ MAX_NAND_SUPPORTED = 8}; |
| 75 |
| 76 |
| 77 /** |
| 78 * NAND flash device information. |
| 79 */ |
| 80 typedef struct |
| 81 { |
| 82 /// Vendor ID. |
| 83 NvU8 VendorId; |
| 84 /// Device ID. |
| 85 NvU8 DeviceId; |
| 86 /** |
| 87 * Redundant area size per page to write any tag information. This will |
| 88 * be calculated as: |
| 89 * <pre> TagSize = spareAreaSize - mainAreaEcc - SpareAreaEcc </pre> |
| 90 * Shim layer is always supposed to request in multiples |
| 91 * of this number when spare area operations are requested. |
| 92 */ |
| 93 NvU8 TagSize; |
| 94 /// Bus width of the chip: can be 8- or 16-bit. |
| 95 NvU8 BusWidth; |
| 96 /// Page size in bytes, includes only data area, no redundant area. |
| 97 NvU32 PageSize; |
| 98 /// Number of Pages per block. |
| 99 NvU32 PagesPerBlock; |
| 100 /// Total number of blocks that are present in the NAND flash device. |
| 101 NvU32 NoOfBlocks; |
| 102 /** |
| 103 * Holds the zones per flash device--minimum value possible is 1. |
| 104 * Zone is a group of contiguous blocks among which internal copy back can |
| 105 * be performed, if the chip supports copy-back operation. |
| 106 * Zone is also referred as plane or district by some flashes. |
| 107 */ |
| 108 NvU32 ZonesPerDevice; |
| 109 /** |
| 110 * Total device capacity in kilobytes. |
| 111 * Includes only data area, no redundant area. |
| 112 */ |
| 113 NvU32 DeviceCapacityInKBytes; |
| 114 /// Interleave capability of the flash. |
| 115 NvOdmNandInterleaveCapability InterleaveCapability; |
| 116 /// Device type: SLC or MLC. |
| 117 NvOdmNandFlashType NandType; |
| 118 /// Number of NAND flash devices present on the board. |
| 119 NvU8 NumberOfDevices; |
| 120 // Size of Spare area |
| 121 NvU32 NumSpareAreaBytes; |
| 122 // Offset of Tag data in the spare area. |
| 123 NvU32 TagOffset; |
| 124 }NvDdkNandDeviceInfo; |
| 125 |
| 126 /** |
| 127 * Information related to a physical block. |
| 128 */ |
| 129 typedef struct |
| 130 { |
| 131 /// Tag information of the block. |
| 132 NvU8* pTagBuffer; |
| 133 /// Number of bytes to copy in tag buffer. |
| 134 NvU32 TagBufferSize; |
| 135 /// Determines whether the block is factory good block or not. |
| 136 /// - NV_TRUE if factory good block. |
| 137 /// - NV_FALSE if factory bad block. |
| 138 NvBool IsFactoryGoodBlock; |
| 139 /// Gives the lock status of the block. |
| 140 NvBool IsBlockLocked; |
| 141 }NandBlockInfo; |
| 142 |
| 143 |
| 144 /** |
| 145 * NAND DDK capabilities. |
| 146 */ |
| 147 typedef struct |
| 148 { |
| 149 /** |
| 150 * Flag indicating whether or not ECC is supported by the driver. |
| 151 * NV_TRUE means it supports ECC, else not supported. |
| 152 */ |
| 153 NvBool IsEccSupported; |
| 154 /** |
| 155 * Flag indicating whether or not interleaving operation is |
| 156 * supported by the driver. |
| 157 * NV_TRUE means it supports interleaving, else not supported. |
| 158 */ |
| 159 NvBool IsInterleavingSupported; |
| 160 /// Whether the command queue mode is supported by the SOC. |
| 161 NvBool IsCommandQueueModeSupported; |
| 162 /// Whether EDO mode is suported by the SOC. |
| 163 NvBool IsEdoModeSupported; |
| 164 /// Number of ECC parity bytes per spare area. |
| 165 NvU8 TagEccParitySize; |
| 166 /// Total number of NAND devices supported by SOC. |
| 167 NvU32 NumberOfDevicesSupported; |
| 168 /// Maximum data size that DMA can transfer. |
| 169 NvU32 MaxDataTransferSize; |
| 170 /// NAND controller default timing register value. |
| 171 NvU32 ControllerDefaultTiming; |
| 172 NvBool IsBCHEccSupported; |
| 173 }NvDdkNandDriverCapabilities; |
| 174 |
| 175 /** |
| 176 * The structure for locking of required NAND flash pages. |
| 177 */ |
| 178 typedef struct |
| 179 { |
| 180 /// Device number of the flash being protected by lock feature. |
| 181 NvU8 DeviceNumber; |
| 182 /// Starting page number, from where NAND lock feature should protect data. |
| 183 NvU32 StartPageNumber; |
| 184 /// Ending page number, up to where NAND lock feature should protect data. |
| 185 NvU32 EndPageNumber; |
| 186 }LockParams; |
| 187 |
| 188 /* |
| 189 * Macro to get expression for modulo value that is power of 2 |
| 190 * Expression: DIVIDEND % (pow(2, Log2X)) |
| 191 */ |
| 192 #define MACRO_MOD_LOG2NUM(DIVIDEND, Log2X) \ |
| 193 ((DIVIDEND) & ((1 << (Log2X)) - 1)) |
| 194 |
| 195 /* |
| 196 * Macro to get expression for multiply by number which is power of 2 |
| 197 * Expression: VAL * (1 << Log2Num) |
| 198 */ |
| 199 #define MACRO_POW2_LOG2NUM(Log2Num) \ |
| 200 (1 << (Log2Num)) |
| 201 |
| 202 /* |
| 203 * Macro to get expression for multiply by number which is power of 2 |
| 204 * Expression: VAL * (1 << Log2Num) |
| 205 */ |
| 206 #define MACRO_MULT_POW2_LOG2NUM(VAL, Log2Num) \ |
| 207 ((VAL) << (Log2Num)) |
| 208 |
| 209 /* |
| 210 * Macro to get expression for div by number that is power of 2 |
| 211 * Expression: VAL / (1 << Log2Num) |
| 212 */ |
| 213 #define MACRO_DIV_POW2_LOG2NUM(VAL, Log2Num) \ |
| 214 ((VAL) >> (Log2Num)) |
| 215 |
| 216 /** |
| 217 * Initializes the NAND Controller and returns a created handle to the client. |
| 218 * Only one instance of the handle can be created. |
| 219 * |
| 220 * @pre NAND client must call this API first before calling any further NAND API
s. |
| 221 * |
| 222 * @param hRmDevice Handle to RM device. |
| 223 * @param phNand Returns the created handle. |
| 224 * |
| 225 * @retval NvSuccess Initialization is successful. |
| 226 * @retval NvError_AlreadyAllocated The NAND device is already in use. |
| 227 */ |
| 228 NvError NvDdkNandOpen(NvRmDeviceHandle hRmDevice, NvDdkNandHandle *phNand); |
| 229 |
| 230 /** |
| 231 * Closes the NAND controller and frees the handle. |
| 232 * |
| 233 * @param hNand Handle to the NAND, which is returned by NvDdkNandOpen(). |
| 234 * |
| 235 */ |
| 236 void NvDdkNandClose(NvDdkNandHandle hNand); |
| 237 |
| 238 /** |
| 239 * Reads the data from the selected NAND device(s) synchronously. |
| 240 * |
| 241 * @param hNand Handle to the NAND, which is returned by NvDdkNandOpen(). |
| 242 * @param StartDeviceNum The Device number, which read operation has to be |
| 243 * started from. It starts from value '0'. |
| 244 * @param pPageNumbers A pointer to an array containing page numbers for |
| 245 * each NAND Device. If there are (n + 1) NAND Devices, then |
| 246 * array size should be (n + 1). |
| 247 * - pPageNumbers[0] gives page number to access in NAND Device 0. |
| 248 * - pPageNumbers[1] gives page number to access in NAND Device 1. |
| 249 * - .................................... |
| 250 * - pPageNumbers[n] gives page number to access in NAND Device n. |
| 251 * |
| 252 * If NAND Device 'n' should not be accessed, fill pPageNumbers[n] as |
| 253 * 0xFFFFFFFF. |
| 254 * If the read starts from NAND Device 'n', all the page numbers |
| 255 * in the array should correspond to the same row, even though we don't |
| 256 * access the same row pages for '0' to 'n-1' Devices. |
| 257 * @param pDataBuffer A pointer to read the page data into. The size of buffer |
| 258 * should be (*pNoOfPages * PageSize). |
| 259 * @param pTagBuffer Pointer to read the tag data into. The size of buffer |
| 260 * should be (*pNoOfPages * TagSize). |
| 261 * @param pNoOfPages The number of pages to read. This count should include |
| 262 * only valid page count. Consder that total NAND devices present is 4, |
| 263 * Need to read 1 page from Device1 and 1 page from Device3. In this case, |
| 264 * \a StartDeviceNum should be 1 and Number of pages should be 2. |
| 265 * \a pPageNumbers[0] and \a pPageNumbers[2] should have 0xFFFFFFFF. |
| 266 * \a pPageNumbers[1] and \a pPageNumbers[3] should have valid page numbers
. |
| 267 * The same pointer returns the number of pages read successfully. |
| 268 * @param IgnoreEccError If set to NV_TRUE, it ignores the ECC error and |
| 269 * continues to read the subsequent pages with out aborting read operation. |
| 270 * This is required during bad block replacements. |
| 271 * |
| 272 * @retval NvSuccess NAND read operation completed successfully. |
| 273 * @retval NvError_NandReadEccFailed Indicates NAND read encountered ECC |
| 274 * errors that cannot be corrected. |
| 275 * @retval NvError_NandErrorThresholdReached Indicates NAND read encountered |
| 276 * correctable ECC errors and they are equal to the threshold value set. |
| 277 * @retval NvError_NandOperationFailed NAND read operation failed. |
| 278 */ |
| 279 NvError |
| 280 NvDdkNandRead( |
| 281 NvDdkNandHandle hNand, |
| 282 NvU8 StartDeviceNum, |
| 283 NvU32* pPageNumbers, |
| 284 NvU8* const pDataBuffer, |
| 285 NvU8* const pTagBuffer, |
| 286 NvU32 *pNoOfPages, |
| 287 NvBool IgnoreEccError); |
| 288 |
| 289 /** |
| 290 * Writes the data to the selected NAND device(s) synchronously. |
| 291 * |
| 292 * @param hNand Handle to the NAND, which is returned by NvDdkNandOpen(). |
| 293 * @param StartDeviceNum The device number, which write operation has to be |
| 294 * started from. It starts from value '0'. |
| 295 * @param pPageNumbers A pointer to an array containing page numbers for |
| 296 * each NAND Device. If there are (n + 1) NAND Devices, then |
| 297 * array size should be (n + 1). |
| 298 * - pPageNumbers[0] gives page number to access in NAND Device 0. |
| 299 * - pPageNumbers[1] gives page number to access in NAND Device 1. |
| 300 * - .................................... |
| 301 * - pPageNumbers[n] gives page number to access in NAND Device n. |
| 302 * |
| 303 * If NAND Device 'n' should not be accessed, fill \a pPageNumbers[n] as |
| 304 * 0xFFFFFFFF. |
| 305 * If the read starts from NAND device 'n', all the page numbers |
| 306 * in the array should correspond to the same row, even though we don't |
| 307 * access the same row pages for '0' to 'n-1' Devices. |
| 308 * @param pDataBuffer A pointer to read the page data into. The size of buffer |
| 309 * should be (*pNoOfPages * PageSize). |
| 310 * @param pTagBuffer Pointer to read the tag data into. The size of buffer |
| 311 * should be (*pNoOfPages * TagSize). |
| 312 * @param pNoOfPages The number of pages to write. This count should include |
| 313 * only valid page count. Consder that total NAND devices present is 4, |
| 314 * Need to write 1 page to Device1 and 1 page to Device3. In this case, |
| 315 * \a StartDeviceNum should be 1 and Number of pages should be 2. |
| 316 * \a pPageNumbers[0] and \a pPageNumbers[2] should have 0xFFFFFFFF. |
| 317 * \a pPageNumbers[1] and \a pPageNumbers[3] should have valid page numbers
. |
| 318 * The same pointer returns the number of pages written successfully. |
| 319 * |
| 320 * @retval NvSuccess Operation completed successfully. |
| 321 * @retval NvError_NandOperationFailed Operation failed. |
| 322 */ |
| 323 NvError |
| 324 NvDdkNandWrite( |
| 325 NvDdkNandHandle hNand, |
| 326 NvU8 StartDeviceNum, |
| 327 NvU32* pPageNumbers, |
| 328 const NvU8* pDataBuffer, |
| 329 const NvU8* pTagBuffer, |
| 330 NvU32 *pNoOfPages); |
| 331 |
| 332 /** |
| 333 * Erases the selected blocks from the NAND device(s) synchronously. |
| 334 * |
| 335 * @param hNand Handle to the NAND, which is returned by NvDdkNandOpen(). |
| 336 * @param StartDeviceNum The Device number, which erase operation has to be |
| 337 * started from. It starts from value '0'. |
| 338 * @param pPageNumbers A pointer to an array containing page numbers for |
| 339 * each NAND Device. If there are (n + 1) NAND Devices, then |
| 340 * array size should be (n + 1). |
| 341 * - pPageNumbers[0] gives page number to access in NAND Device 0. |
| 342 * - pPageNumbers[1] gives page number to access in NAND Device 1. |
| 343 * - .................................... |
| 344 * - pPageNumbers[n] gives page number to access in NAND Device n. |
| 345 * |
| 346 * If NAND Device 'n' should not be accessed, fill pPageNumbers[n] as |
| 347 * 0xFFFFFFFF. |
| 348 * If the read starts from NAND device 'n', all the page numbers |
| 349 * in the array should correspond to the same row, even though we don't |
| 350 * access the same row pages for '0' to 'n-1' Devices. |
| 351 * @param pNumberOfBlocks The number of blocks to erase. This count should inclu
de |
| 352 * only valid block count. Consder that total NAND devices present is 4, |
| 353 * Need to erase 1 block from Device1 and 1 block from Device3. In this cas
e, |
| 354 * \a StartDeviceNum should be 1 and Number of blocks should be 2. |
| 355 * \a pPageNumbers[0] and \a pPageNumbers[2] should have 0xFFFFFFFF. |
| 356 * \a pPageNumbers[1] and \a pPageNumbers[3] should have valid page numbers |
| 357 * corresponding to blocks. |
| 358 * The same pointer returns the number of blocks erased successfully. |
| 359 * |
| 360 * @retval NvSuccess Operation completed successfully. |
| 361 * @retval NvError_NandOperationFailed Operation failed. |
| 362 */ |
| 363 NvError |
| 364 NvDdkNandErase( |
| 365 NvDdkNandHandle hNand, |
| 366 NvU8 StartDeviceNum, |
| 367 NvU32* pPageNumbers, |
| 368 NvU32* pNumberOfBlocks); |
| 369 |
| 370 /** |
| 371 * Copies the data in the source page(s) to the destination page(s) |
| 372 * synchronously. |
| 373 * |
| 374 * @param hNand Handle to the NAND, which is returned by NvDdkNandOpen(). |
| 375 * @param SrcStartDeviceNum The device number, from which data has to be read |
| 376 * for the copy back operation. It starts from value '0'. |
| 377 * @param DstStartDeviceNum The device number, to which data has to be copied |
| 378 * for the copy back operation. It starts from value '0'. |
| 379 * @param pSrcPageNumbers A pointer to an array containing page numbers for |
| 380 * each NAND Device. If there are (n + 1) NAND Devices, then |
| 381 * array size should be (n + 1). |
| 382 * - pSrcPageNumbers[0] gives page number to access in NAND Device 0. |
| 383 * - pSrcPageNumbers[1] gives page number to access in NAND Device 1. |
| 384 * - .................................... |
| 385 * - pSrcPageNumbers[n] gives page number to access in NAND Device n. |
| 386 * |
| 387 * If NAND Device 'n' should not be accessed, fill \a pSrcPageNumbers[n] as
|
| 388 * 0xFFFFFFFF. |
| 389 * If the copy-back starts from NAND devices 'n', all the page numbers |
| 390 * in the array should correspond to the same row, even though we don't |
| 391 * access the same row pages for '0' to 'n-1' Devices. |
| 392 * @param pDestPageNumbers A pointer to an array containing page numbers for |
| 393 * each NAND Device. If there are (n + 1) NAND Devices, then |
| 394 * array size should be (n + 1). |
| 395 * - pDestPageNumbers[0] gives page number to access in NAND Device 0. |
| 396 * - pDestPageNumbers[1] gives page number to access in NAND Device 1. |
| 397 * - .................................... |
| 398 * - pDestPageNumbers[n] gives page number to access in NAND Device n. |
| 399 * |
| 400 * If NAND Device 'n' should not be accessed, fill \a pDestPageNumbers[n] a
s |
| 401 * 0xFFFFFFFF. |
| 402 * If the Copy-back starts from Interleave column 'n', all the page numbers
|
| 403 * in the array should correspond to the same row, even though we don't |
| 404 * access the same row pages for '0' to 'n-1' Devices. |
| 405 * @param pNoOfPages The number of pages to copy-back. This count should include
|
| 406 * only valid page count. Consider that total NAND devices present is 4, |
| 407 * Need to Copy-back 1 page from Device1 and 1 page from Device3. In this |
| 408 * case, \a StartDeviceNum should be 1 and Number of pages should be 2. |
| 409 * \a pSrcPageNumbers[0], \a pSrcPageNumbers[2], \a pDestPageNumbers[0] and
|
| 410 * \a pDestPageNumbers[2] should have 0xFFFFFFFF. \a pSrcPageNumbers[1], |
| 411 * \a pSrcPageNumbers[3], \a pDestPageNumbers[1] and \a pDestPageNumbers[3] |
| 412 * should have valid page numbers. |
| 413 * The same pointer returns the number of pages copied-back successfully. |
| 414 * @param IgnoreEccError NV_TRUE to ingnore ECC errors, NV_FALSE otherwise. |
| 415 * |
| 416 * @retval NvSuccess Operation completed successfully |
| 417 * @retval NvError_NandOperationFailed Operation failed. |
| 418 */ |
| 419 NvError |
| 420 NvDdkNandCopybackPages( |
| 421 NvDdkNandHandle hNand, |
| 422 NvU8 SrcStartDeviceNum, |
| 423 NvU8 DstStartDeviceNum, |
| 424 NvU32* pSrcPageNumbers, |
| 425 NvU32* pDestPageNumbers, |
| 426 NvU32 *pNoOfPages, |
| 427 NvBool IgnoreEccError); |
| 428 |
| 429 /** |
| 430 * Gets the NAND flash device information. |
| 431 * |
| 432 * @param hNand Handle to the NAND, which is returned by NvDdkNandOpen(). |
| 433 * @param DeviceNumber NAND flash device number. |
| 434 * @param pDeviceInfo Returns the device information. |
| 435 * |
| 436 * @retval NvSuccess Operation completed successfully. |
| 437 * @retval NvError_NandOperationFailed NAND copy back operation failed. |
| 438 */ |
| 439 NvError |
| 440 NvDdkNandGetDeviceInfo( |
| 441 NvDdkNandHandle hNand, |
| 442 NvU8 DeviceNumber, |
| 443 NvDdkNandDeviceInfo* pDeviceInfo); |
| 444 |
| 445 /** |
| 446 * Locks the specified NAND flash pages. |
| 447 * |
| 448 * @param hNand Handle to the NAND, which is returned by NvDdkNandOpen(). |
| 449 * @param pFlashLockParams A pointer to the range of pages to be locked. |
| 450 */ |
| 451 void |
| 452 NvDdkNandSetFlashLock( |
| 453 NvDdkNandHandle hNand, |
| 454 LockParams* pFlashLockParams); |
| 455 |
| 456 /** |
| 457 * Returns the details of the locked apertures, like device number, starting |
| 458 * page number, ending page number of the region locked. |
| 459 * |
| 460 * @param hNand Handle to the NAND, which is returned by NvDdkNandOpen(). |
| 461 * @param pFlashLockParams A pointer to first array element of \a LockParams typ
e |
| 462 * with eight elements in the array. |
| 463 * Check if \a pFlashLockParams[i].DeviceNumber == 0xFF, then that aperture is |
| 464 * free to use for locking. |
| 465 */ |
| 466 void |
| 467 NvDdkNandGetLockedRegions( |
| 468 NvDdkNandHandle hNand, |
| 469 LockParams* pFlashLockParams); |
| 470 /** |
| 471 * Releases all regions that were locked using NvDdkNandSetFlashLock API. |
| 472 * |
| 473 * @param hNand Handle to the NAND, which is returned by NvDdkNandOpen(). |
| 474 */ |
| 475 void NvDdkNandReleaseFlashLock(NvDdkNandHandle hNand); |
| 476 |
| 477 /** |
| 478 * Gets the NAND driver capabilities. |
| 479 * |
| 480 * @param hNand Handle to the NAND, which is returned by NvDdkNandOpen(). |
| 481 * @param pNandDriverCapabilities Returns the capabilities. |
| 482 * |
| 483 */ |
| 484 void |
| 485 NvDdkNandGetCapabilities( |
| 486 NvDdkNandHandle hNand, |
| 487 NvDdkNandDriverCapabilities* pNandDriverCapabilities); |
| 488 |
| 489 /** |
| 490 * Gives the block specific information such as tag information, lock status, bl
ock good/bad. |
| 491 * @param hNand Handle to the NAND, which is returned by NvDdkNandOpen(). |
| 492 * @param DeviceNumber Device number in which the requested block exists. |
| 493 * @param BlockNumber Requested physical block number. |
| 494 * @param pBlockInfo Return the block information. |
| 495 * @param SkippedBytesReadEnable NV_TRUE enables reading skipped bytes. |
| 496 * |
| 497 * @retval NvSuccess Success |
| 498 */ |
| 499 NvError |
| 500 NvDdkNandGetBlockInfo( |
| 501 NvDdkNandHandle hNand, |
| 502 NvU32 DeviceNumber, |
| 503 NvU32 BlockNumber, |
| 504 NandBlockInfo* pBlockInfo, |
| 505 NvBool SkippedBytesReadEnable); |
| 506 |
| 507 /** |
| 508 * Part of static power management, call this API to put the NAND controller |
| 509 * into suspend state. This API is a mechanism for client to augment OS |
| 510 * power management policy. |
| 511 * |
| 512 * The h/w context of the NAND controller is saved. Clock is disabled and power |
| 513 * is also disabled to the controller. |
| 514 * |
| 515 * @param hNand Handle to the NAND, which is returned by NvDdkNandOpen(). |
| 516 * |
| 517 * @retval NvSuccess Success |
| 518 * @retval NvError_BadParameter Invalid input parameter value |
| 519 */ |
| 520 NvError NvDdkNandSuspend(NvDdkNandHandle hNand); |
| 521 |
| 522 /** |
| 523 * Part of static power management, call this API to wake the NAND controller |
| 524 * from suspend state. This API is a mechanism for client to augment OS power |
| 525 * management policy. |
| 526 * |
| 527 * The h/w context of the NAND controller is restored. Clock is enabled and powe
r |
| 528 * is also enabled to the controller |
| 529 * |
| 530 * @param hNand Handle to the NAND, which is returned by NvDdkNandOpen(). |
| 531 * |
| 532 * @retval NvSuccess Success |
| 533 * @retval NvError_BadParameter Invalid input parameter value |
| 534 */ |
| 535 NvError NvDdkNandResume(NvDdkNandHandle hNand); |
| 536 |
| 537 /** |
| 538 * Part of local power management of the driver. Call this API to turn off the |
| 539 * clocks required for NAND controller operation. |
| 540 * |
| 541 * @param hNand Handle to the NAND, which is returned by NvDdkNandOpen(). |
| 542 * |
| 543 * @retval NvSuccess Success |
| 544 * @retval NvError_BadParameter Invalid input parameter value |
| 545 */ |
| 546 NvError NvDdkNandSuspendClocks(NvDdkNandHandle hNand); |
| 547 |
| 548 /** |
| 549 * Part of local power management of the driver. Call this API to turn on the |
| 550 * clocks required for NAND controller operation. |
| 551 * |
| 552 * @param hNand Handle to the NAND, which is returned by NvDdkNandOpen(). |
| 553 * |
| 554 * @retval NvSuccess Success |
| 555 * @retval NvError_BadParameter Invalid input parameter value |
| 556 */ |
| 557 NvError NvDdkNandResumeClocks(NvDdkNandHandle hNand); |
| 558 |
| 559 /** |
| 560 * API to read to the spare area. |
| 561 */ |
| 562 NvError |
| 563 NvDdkNandReadSpare( |
| 564 NvDdkNandHandle hNand, |
| 565 NvU8 StartDeviceNum, |
| 566 NvU32* pPageNumbers, |
| 567 NvU8* const pSpareBuffer, |
| 568 NvU8 OffsetInSpareAreaInBytes, |
| 569 NvU8 NumSpareAreaBytes); |
| 570 |
| 571 /** |
| 572 * API to write to the spare area. Use this API with caution, as there is a |
| 573 * risk of overriding the factory bad block data. |
| 574 */ |
| 575 NvError |
| 576 NvDdkNandWriteSpare( |
| 577 NvDdkNandHandle hNand, |
| 578 NvU8 StartDeviceNum, |
| 579 NvU32* pPageNumbers, |
| 580 NvU8* const pSpareBuffer, |
| 581 NvU8 OffsetInSpareAreaInBytes, |
| 582 NvU8 NumSpareAreaBytes); |
| 583 |
| 584 /* |
| 585 * Functions shared between Ddk Nand, block driver and FTL code |
| 586 */ |
| 587 // Function to compare buffer contents |
| 588 NvU32 NandUtilMemcmp(const void *pSrc, const void *pDst, NvU32 Size); |
| 589 |
| 590 // Simple function to get log2, assumed value power of 2, else return |
| 591 // log2 for immediately smaller number |
| 592 NvU8 NandUtilGetLog2(NvU32 Val); |
| 593 |
| 594 #ifdef __cplusplus |
| 595 } |
| 596 #endif |
| 597 |
| 598 /** @} */ |
| 599 #endif // INCLUDED_NVDDK_NAND_H |
OLD | NEW |