cfi_cmdset_001.c problem

Aleksander Sanochkin asanochkin at Lnxw.COM
Fri Nov 30 06:13:23 EST 2001


Hi!

I see that after write and erase operations,
the current version of cfi_cmdset_0001.c driver
can left a Flash device not in the READY state.
If soft reboot is performed in such a situation,
applications that use flash will behave erroneously
since they expect that the flash is in the READY state.
For instance, if the system is supposed to boot from flash,
it will hang.

I've made a patch that fixes the problem for me - it is attached.
I was hoping it might be helpful for other people too.

Best regards.
-------------- next part --------------
diff -ur cvs/drivers/mtd/chips/cfi_cmdset_0001.c ready_state/drivers/mtd/chips/cfi_cmdset_0001.c
--- cvs/drivers/mtd/chips/cfi_cmdset_0001.c	Tue Oct  2 19:05:11 2001
+++ ready_state/drivers/mtd/chips/cfi_cmdset_0001.c	Wed Nov 21 12:57:27 2001
@@ -170,8 +170,10 @@
 	map->fldrv = &cfi_intelext_chipdrv;
 	MOD_INC_USE_COUNT;
 	
+	/* Clear Status Register. */
+	cfi_send_gen_cmd(0x50, 0x55, base, map, cfi, cfi->device_type, NULL);
+
 	/* Make sure it's in read mode */
-	cfi_send_gen_cmd(0xff, 0x55, base, map, cfi, cfi->device_type, NULL);
 	return cfi_intelext_setup(map);
 }
 
@@ -551,12 +553,16 @@
 	if (status & CMD(0x02)) {
 		/* clear status */
 		cfi_write(map, CMD(0x50), adr);
-		/* put back into read status register mode */
-		cfi_write(map, CMD(0x70), adr);
+		/* Return to the read array mode. */
+		cfi_write(map, CMD(0xff), adr);
+		chip->state = FL_READY;
 		wake_up(&chip->wq);
 		spin_unlock_bh(chip->mutex);
 		return -EROFS;
 	}
+	/* Return to the read array mode. */
+	cfi_write(map, CMD(0xff), adr);
+	chip->state = FL_READY;
 	wake_up(&chip->wq);
 	spin_unlock_bh(chip->mutex);
 	return 0;
@@ -839,12 +845,16 @@
 	if (status & CMD(0x02)) {
 		/* clear status */
 		cfi_write(map, CMD(0x50), cmd_adr);
-		/* put back into read status register mode */
-		cfi_write(map, CMD(0x70), adr);
+		/* Return to the read array mode. */
+		cfi_write(map, CMD(0xff), adr);
+		chip->state = FL_READY;
 		wake_up(&chip->wq);
 		spin_unlock_bh(chip->mutex);
 		return -EROFS;
 	}
+	/* Return to the read array mode. */
+	cfi_write(map, CMD(0xff), adr);
+	chip->state = FL_READY;
 	wake_up(&chip->wq);
 	spin_unlock_bh(chip->mutex);
 	return 0;
@@ -1077,6 +1087,10 @@
 		}
 	}
 
+	/* Return to the read array mode. */
+	cfi_write(map, CMD(0xff), adr);
+	chip->state = FL_READY;
+
 	wake_up(&chip->wq);
 	spin_unlock_bh(chip->mutex);
 	return ret;
@@ -1319,7 +1333,9 @@
 	}
 	
 	/* Done and happy. */
-	chip->state = FL_STATUS;
+	/* Return to the read array mode. */
+	cfi_write(map, CMD(0xff), adr);
+	chip->state = FL_READY;
 	DISABLE_VPP(map);
 	wake_up(&chip->wq);
 	spin_unlock_bh(chip->mutex);
@@ -1468,7 +1484,9 @@
 	}
 	
 	/* Done and happy. */
-	chip->state = FL_STATUS;
+	/* Return to the read array mode. */
+	cfi_write(map, CMD(0xff), adr);
+	chip->state = FL_READY;
 	DISABLE_VPP(map);
 	wake_up(&chip->wq);
 	spin_unlock_bh(chip->mutex);


More information about the linux-mtd mailing list