| 1 |  |  | /*************************************************************************** | 
    
    | 2 |  |  |  * Copyright (c) 2024 Microsoft Corporation | 
    
    | 3 |  |  |  * | 
    
    | 4 |  |  |  * This program and the accompanying materials are made available under the | 
    
    | 5 |  |  |  * terms of the MIT License which is available at | 
    
    | 6 |  |  |  * https://opensource.org/licenses/MIT. | 
    
    | 7 |  |  |  * | 
    
    | 8 |  |  |  * SPDX-License-Identifier: MIT | 
    
    | 9 |  |  |  **************************************************************************/ | 
    
    | 10 |  |  |  | 
    
    | 11 |  |  |  | 
    
    | 12 |  |  | /**************************************************************************/ | 
    
    | 13 |  |  | /**************************************************************************/ | 
    
    | 14 |  |  | /**                                                                       */ | 
    
    | 15 |  |  | /** LevelX Component                                                      */ | 
    
    | 16 |  |  | /**                                                                       */ | 
    
    | 17 |  |  | /**   NAND Flash                                                          */ | 
    
    | 18 |  |  | /**                                                                       */ | 
    
    | 19 |  |  | /**************************************************************************/ | 
    
    | 20 |  |  | /**************************************************************************/ | 
    
    | 21 |  |  |  | 
    
    | 22 |  |  | #define LX_SOURCE_CODE | 
    
    | 23 |  |  |  | 
    
    | 24 |  |  |  | 
    
    | 25 |  |  | /* Disable ThreadX error checking.  */ | 
    
    | 26 |  |  |  | 
    
    | 27 |  |  | #ifndef LX_DISABLE_ERROR_CHECKING | 
    
    | 28 |  |  | #define LX_DISABLE_ERROR_CHECKING | 
    
    | 29 |  |  | #endif | 
    
    | 30 |  |  |  | 
    
    | 31 |  |  |  | 
    
    | 32 |  |  | /* Include necessary system files.  */ | 
    
    | 33 |  |  |  | 
    
    | 34 |  |  | #include "lx_api.h" | 
    
    | 35 |  |  |  | 
    
    | 36 |  |  |  | 
    
    | 37 |  |  | /**************************************************************************/ | 
    
    | 38 |  |  | /*                                                                        */ | 
    
    | 39 |  |  | /*  FUNCTION                                               RELEASE        */ | 
    
    | 40 |  |  | /*                                                                        */ | 
    
    | 41 |  |  | /*    _lx_nand_flash_driver_block_erase                   PORTABLE C      */ | 
    
    | 42 |  |  | /*                                                           6.2.1       */ | 
    
    | 43 |  |  | /*  AUTHOR                                                                */ | 
    
    | 44 |  |  | /*                                                                        */ | 
    
    | 45 |  |  | /*    William E. Lamie, Microsoft Corporation                             */ | 
    
    | 46 |  |  | /*                                                                        */ | 
    
    | 47 |  |  | /*  DESCRIPTION                                                           */ | 
    
    | 48 |  |  | /*                                                                        */ | 
    
    | 49 |  |  | /*    This function calls the driver to erase a block.                    */ | 
    
    | 50 |  |  | /*                                                                        */ | 
    
    | 51 |  |  | /*  INPUT                                                                 */ | 
    
    | 52 |  |  | /*                                                                        */ | 
    
    | 53 |  |  | /*    nand_flash                            NAND flash instance           */ | 
    
    | 54 |  |  | /*    block                                 Block number                  */ | 
    
    | 55 |  |  | /*    erase_count                           Erase count for this block    */ | 
    
    | 56 |  |  | /*                                                                        */ | 
    
    | 57 |  |  | /*  OUTPUT                                                                */ | 
    
    | 58 |  |  | /*                                                                        */ | 
    
    | 59 |  |  | /*    Completion Status                                                   */ | 
    
    | 60 |  |  | /*                                                                        */ | 
    
    | 61 |  |  | /*  CALLS                                                                 */ | 
    
    | 62 |  |  | /*                                                                        */ | 
    
    | 63 |  |  | /*    (lx_nand_flash_driver_block_erase)    Driver erase block            */ | 
    
    | 64 |  |  | /*                                                                        */ | 
    
    | 65 |  |  | /*  CALLED BY                                                             */ | 
    
    | 66 |  |  | /*                                                                        */ | 
    
    | 67 |  |  | /*    Internal LevelX                                                     */ | 
    
    | 68 |  |  | /*                                                                        */ | 
    
    | 69 |  |  | /*  RELEASE HISTORY                                                       */ | 
    
    | 70 |  |  | /*                                                                        */ | 
    
    | 71 |  |  | /*    DATE              NAME                      DESCRIPTION             */ | 
    
    | 72 |  |  | /*                                                                        */ | 
    
    | 73 |  |  | /*  05-19-2020     William E. Lamie         Initial Version 6.0           */ | 
    
    | 74 |  |  | /*  09-30-2020     William E. Lamie         Modified comment(s),          */ | 
    
    | 75 |  |  | /*                                            resulting in version 6.1    */ | 
    
    | 76 |  |  | /*  06-02-2021     Bhupendra Naphade        Modified comment(s),          */ | 
    
    | 77 |  |  | /*                                            resulting in version 6.1.7  */ | 
    
    | 78 |  |  | /*  03-08-2023     Xiuwen Cai               Modified comment(s),          */ | 
    
    | 79 |  |  | /*                                            removed cache support,      */ | 
    
    | 80 |  |  | /*                                            added new driver interface, */ | 
    
    | 81 |  |  | /*                                            resulting in version 6.2.1 */ | 
    
    | 82 |  |  | /*                                                                        */ | 
    
    | 83 |  |  | /**************************************************************************/ | 
    
    | 84 |  | 5514 | UINT  _lx_nand_flash_driver_block_erase(LX_NAND_FLASH *nand_flash, ULONG block, ULONG erase_count) | 
    
    | 85 |  |  | { | 
    
    | 86 |  |  |  | 
    
    | 87 |  |  | UINT    status; | 
    
    | 88 |  |  |  | 
    
    | 89 |  |  |  | 
    
    | 90 |  |  |     /* Increment the block erases count.  */ | 
    
    | 91 |  | 5514 |     nand_flash -> lx_nand_flash_diagnostic_block_erases++; | 
    
    | 92 |  |  |  | 
    
    | 93 |  |  |     /* Call driver erase block function.  */ | 
    
    | 94 |  |  | #ifdef LX_NAND_ENABLE_CONTROL_BLOCK_FOR_DRIVER_INTERFACE | 
    
    | 95 |  |  |     status =  (nand_flash -> lx_nand_flash_driver_block_erase)(nand_flash, block, erase_count); | 
    
    | 96 |  |  | #else | 
    
    | 97 |  | 5514 |     status =  (nand_flash -> lx_nand_flash_driver_block_erase)(block, erase_count); | 
    
    | 98 |  |  | #endif | 
    
    | 99 |  |  |  | 
    
    | 100 |  |  |     /* Return status.  */ | 
    
    | 101 |  | 5514 |     return(status); | 
    
    | 102 |  |  | } | 
    
    | 103 |  |  |  | 
    
    | 104 |  |  |  |