1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * 4 * HDF is dual licensed: you can use it either under the terms of 5 * the GPL, or the BSD license, at your option. 6 * See the LICENSE file in the root of this repository for complete details. 7 */ 8 9 #ifndef MTD_SPI_NAND_H 10 #define MTD_SPI_NAND_H 11 12 #include "mtd_core.h" 13 #include "mtd_nand.h" 14 #include "mtd_spi_common.h" 15 16 #ifdef __cplusplus 17 #if __cplusplus 18 extern "C" { 19 #endif 20 #endif /* __cplusplus */ 21 22 #define MTD_SPI_NAND_RDID_ADDR 0x00 23 #define MTD_SPI_NAND_PROTECT_ADDR 0xa0 24 #define SPI_NAND_PROTECT_BP0_MASK (1 << 3) 25 #define SPI_NAND_PROTECT_BP1_MASK (1 << 4) 26 #define SPI_NAND_PROTECT_BP2_MASK (1 << 5) 27 #define SPI_NAND_PROTECT_BP3_MASK (1 << 6) 28 #define SPI_NAND_ALL_BP_MASK (SPI_NAND_PROTECT_BP0_MASK | \ 29 SPI_NAND_PROTECT_BP1_MASK | \ 30 SPI_NAND_PROTECT_BP2_MASK | \ 31 SPI_NAND_PROTECT_BP3_MASK) 32 33 #define SPI_NAND_ANY_BP_ENABLE(x) ((SPI_NAND_PROTECT_BP0_MASK & (x)) || \ 34 (SPI_NAND_PROTECT_BP1_MASK & (x)) || \ 35 (SPI_NAND_PROTECT_BP2_MASK & (x)) || \ 36 (SPI_NAND_PROTECT_BP3_MASK & (x))) 37 38 #define MTD_SPI_NAND_FEATURE_ADDR 0xb0 39 40 #define MTD_SPI_NAND_STATUS_ADDR 0xc0 41 #define MTD_SPI_NAND_ERASE_FAIL 0x04 42 #define MTD_SPI_NAND_PROG_FAIL 0x08 43 44 struct SpinandInfo { 45 const char *name; 46 uint8_t id[MTD_FLASH_ID_LEN_MAX]; 47 uint8_t idLen; 48 uint32_t chipSize; 49 uint32_t blockSize; 50 uint32_t pageSize; 51 uint32_t oobSize; 52 struct MtdSpiConfig eraseCfg; 53 struct MtdSpiConfig writeCfg; 54 struct MtdSpiConfig readCfg; 55 }; 56 57 #ifdef __cplusplus 58 #if __cplusplus 59 } 60 #endif 61 #endif /* __cplusplus */ 62 63 #endif /* MTD_SPI_NAND_H */ 64