--- zzzz-none-000/linux-4.4.271/include/linux/mtd/nand.h 2021-06-03 06:22:09.000000000 +0000 +++ hawkeye-5590-750/linux-4.4.271/include/linux/mtd/nand.h 2023-04-19 10:22:30.000000000 +0000 @@ -23,7 +23,6 @@ #include #include #include - struct mtd_info; struct nand_flash_dev; struct device_node; @@ -89,6 +88,14 @@ #define NAND_CMD_SET_FEATURES 0xef #define NAND_CMD_RESET 0xff +/* + * Serial NAND flash commands + */ +#define NAND_CMD_READID_SERIAL 0x9F +#define NAND_CMD_ERASE_SERIAL 0xd8 +#define NAND_CMD_SET_FEATURE_SERIAL 0x1F +#define NAND_CMD_GET_FEATURE_SERIAL 0x0F + #define NAND_CMD_LOCK 0x2a #define NAND_CMD_UNLOCK1 0x23 #define NAND_CMD_UNLOCK2 0x24 @@ -98,15 +105,22 @@ #define NAND_CMD_RNDOUTSTART 0xE0 #define NAND_CMD_CACHEDPROG 0x15 +#define NAND_CMD_ECCSTATUS 0x7A + #define NAND_CMD_NONE -1 /* Status bits */ #define NAND_STATUS_FAIL 0x01 #define NAND_STATUS_FAIL_N1 0x02 +#define NAND_STATUS_CRITICAL_BLOCK 0x08 #define NAND_STATUS_TRUE_READY 0x20 #define NAND_STATUS_READY 0x40 #define NAND_STATUS_WP 0x80 +#if IS_ENABLED(CONFIG_PAGE_SCOPE_MULTI_PAGE_READ) +#define MAX_MULTI_PAGE 64 +#endif + /* * Constants for ECC_MODES */ @@ -507,6 +521,10 @@ const uint8_t *buf, int oob_required, int page); int (*read_page)(struct mtd_info *mtd, struct nand_chip *chip, uint8_t *buf, int oob_required, int page); +#if IS_ENABLED(CONFIG_PAGE_SCOPE_MULTI_PAGE_READ) + int (*read_multi_page)(struct mtd_info *mtd, struct nand_chip *chip, + uint8_t *buf, int oob_required, int page, int no_pages); +#endif int (*read_subpage)(struct mtd_info *mtd, struct nand_chip *chip, uint32_t offs, uint32_t len, uint8_t *buf, int page); int (*write_subpage)(struct mtd_info *mtd, struct nand_chip *chip, @@ -521,6 +539,10 @@ int (*read_oob)(struct mtd_info *mtd, struct nand_chip *chip, int page); int (*write_oob)(struct mtd_info *mtd, struct nand_chip *chip, int page); + /* AVM */ +#ifdef CONFIG_TFFS_PANIC_LOG + bool (*get_tffs_panic_state)(struct mtd_info *mtd); +#endif }; /** @@ -540,6 +562,7 @@ /** * struct nand_chip - NAND Private Flash Chip Data + * @mtd: MTD device registered to the MTD framework * @IO_ADDR_R: [BOARDSPECIFIC] address to read the 8 I/O lines of the * flash device * @IO_ADDR_W: [BOARDSPECIFIC] address to write the 8 I/O lines of the @@ -640,6 +663,7 @@ */ struct nand_chip { + struct mtd_info mtd; void __iomem *IO_ADDR_R; void __iomem *IO_ADDR_W; @@ -651,7 +675,7 @@ void (*write_buf)(struct mtd_info *mtd, const uint8_t *buf, int len); void (*read_buf)(struct mtd_info *mtd, uint8_t *buf, int len); void (*select_chip)(struct mtd_info *mtd, int chip); - int (*block_bad)(struct mtd_info *mtd, loff_t ofs, int getchip); + int (*block_bad)(struct mtd_info *mtd, loff_t ofs); int (*block_markbad)(struct mtd_info *mtd, loff_t ofs); void (*cmd_ctrl)(struct mtd_info *mtd, int dat, unsigned int ctrl); int (*dev_ready)(struct mtd_info *mtd); @@ -719,6 +743,27 @@ void *priv; }; +static inline void nand_set_flash_node(struct nand_chip *chip, + struct device_node *np) +{ + chip->flash_node = np; +} + +static inline struct device_node *nand_get_flash_node(struct nand_chip *chip) +{ + return chip->flash_node; +} + +static inline struct nand_chip *mtd_to_nand(struct mtd_info *mtd) +{ + return container_of(mtd, struct nand_chip, mtd); +} + +static inline struct mtd_info *nand_to_mtd(struct nand_chip *chip) +{ + return &chip->mtd; +} + /* * NAND Flash Manufacturer ID Codes */ @@ -736,6 +781,10 @@ #define NAND_MFR_SANDISK 0x45 #define NAND_MFR_INTEL 0x89 #define NAND_MFR_ATO 0x9b +#define NAND_MFR_GIGA 0xc8 +#define NAND_MFR_ATO 0x9b +#define NAND_MFR_WINBOND 0xef +#define NAND_MFR_FIDELIX 0xe5 /* The maximum expected count of bytes in the NAND ID sequence */ #define NAND_MAX_ID_LEN 8 @@ -863,6 +912,7 @@ unsigned int options; unsigned int bbt_options; const char **part_probe_types; + int (*chip_fixup)(struct mtd_info *mtd); }; /* Keep gcc happy */