]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - drivers/mtd/chips/cfi_cmdset_0002.c
mtd: fix recovery after failed write-buffer operation in cfi_cmdset_0002.c
[karo-tx-linux.git] / drivers / mtd / chips / cfi_cmdset_0002.c
index 5ff5c4a16943c16dfefca20def28300b398ad6b6..b86197286f2406d4c419736a4252ab59e0403c11 100644 (file)
@@ -1536,8 +1536,20 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
                UDELAY(map, chip, adr, 1);
        }
 
-       /* reset on all failures. */
-       map_write( map, CMD(0xF0), chip->start );
+       /*
+        * Recovery from write-buffer programming failures requires
+        * the write-to-buffer-reset sequence.  Since the last part
+        * of the sequence also works as a normal reset, we can run
+        * the same commands regardless of why we are here.
+        * See e.g.
+        * http://www.spansion.com/Support/Application%20Notes/MirrorBit_Write_Buffer_Prog_Page_Buffer_Read_AN.pdf
+        */
+       cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi,
+                        cfi->device_type, NULL);
+       cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi,
+                        cfi->device_type, NULL);
+       cfi_send_gen_cmd(0xF0, cfi->addr_unlock1, chip->start, map, cfi,
+                        cfi->device_type, NULL);
        xip_enable(map, chip, adr);
        /* FIXME - should have reset delay before continuing */