--- zzzz-none-000/linux-4.4.60/drivers/mtd/chips/cfi_cmdset_0002.c 2017-04-08 07:53:53.000000000 +0000 +++ scorpion-7490-727/linux-4.4.60/drivers/mtd/chips/cfi_cmdset_0002.c 2021-02-04 17:41:59.000000000 +0000 @@ -40,7 +40,7 @@ #include #define AMD_BOOTLOC_BUG -#define FORCE_WORD_WRITE 0 +#define FORCE_WORD_WRITE 1 #define MAX_WORD_RETRIES 3 @@ -51,7 +51,9 @@ static int cfi_amdstd_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *); static int cfi_amdstd_write_words(struct mtd_info *, loff_t, size_t, size_t *, const u_char *); +#if !FORCE_WORD_WRITE static int cfi_amdstd_write_buffers(struct mtd_info *, loff_t, size_t, size_t *, const u_char *); +#endif static int cfi_amdstd_erase_chip(struct mtd_info *, struct erase_info *); static int cfi_amdstd_erase_varsize(struct mtd_info *, struct erase_info *); static void cfi_amdstd_sync (struct mtd_info *); @@ -202,6 +204,7 @@ } #endif +#if !FORCE_WORD_WRITE static void fixup_use_write_buffers(struct mtd_info *mtd) { struct map_info *map = mtd->priv; @@ -211,6 +214,7 @@ mtd->_write = cfi_amdstd_write_buffers; } } +#endif /* !FORCE_WORD_WRITE */ /* Atmel chips don't use the same PRI format as AMD chips */ static void fixup_convert_atmel_pri(struct mtd_info *mtd) @@ -809,7 +813,7 @@ return 0; case FL_ERASING: - if (!cfip || !(cfip->EraseSuspend & (0x1|0x2)) || + if (1 /* no suspend */ || !cfip || !(cfip->EraseSuspend & (0x1|0x2)) || !(mode == FL_READY || mode == FL_POINT || (mode == FL_WRITING && (cfip->EraseSuspend & 0x2)))) goto sleep; @@ -1632,8 +1636,8 @@ break; } - if (chip_ready(map, adr)) - break; + if (chip_good(map, adr, datum)) + goto enable_xip; /* Latency issues. Drop the lock, wait a while and retry */ UDELAY(map, chip, adr, 1); @@ -1649,6 +1653,8 @@ ret = -EIO; } + + enable_xip: xip_enable(map, chip, adr); op_done: if (mode == FL_OTP_WRITE) @@ -1789,6 +1795,7 @@ /* * FIXME: interleaved mode not tested, and probably not supported! */ +#if !FORCE_WORD_WRITE static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip, unsigned long adr, const u_char *buf, int len) @@ -1830,6 +1837,7 @@ /* Write Buffer Load */ map_write(map, CMD(0x25), cmd_adr); + (void) map_read(map, cmd_adr); chip->state = FL_WRITING_TO_BUFFER; @@ -1916,7 +1924,6 @@ return ret; } - static int cfi_amdstd_write_buffers(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf) { @@ -1991,6 +1998,7 @@ return 0; } +#endif /* !FORCE_WORD_WRITE */ /* * Wait for the flash chip to become ready to write data @@ -2226,7 +2234,6 @@ return 0; } - /* * Handle devices with one erase region, that only implement * the chip erase command. @@ -2290,8 +2297,8 @@ chip->erase_suspended = 0; } - if (chip_ready(map, adr)) - break; + if (chip_good(map, adr, map_word_ff(map))) + goto op_done; if (time_after(jiffies, timeo)) { printk(KERN_WARNING "MTD %s(): software timeout\n", @@ -2311,6 +2318,7 @@ ret = -EIO; } + op_done: chip->state = FL_READY; xip_enable(map, chip, adr); DISABLE_VPP(map); @@ -2379,9 +2387,9 @@ chip->erase_suspended = 0; } - if (chip_ready(map, adr)) { + if (chip_good(map, adr, map_word_ff(map))) { xip_enable(map, chip, adr); - break; + goto op_done; } if (time_after(jiffies, timeo)) { @@ -2403,6 +2411,7 @@ ret = -EIO; } + op_done: chip->state = FL_READY; DISABLE_VPP(map); put_chip(map, chip, adr);