4848#define SST49LF040B 0x0050
4949#define SST49LF008A 0x005a
5050#define AT49BV6416 0x00d6
51+ #define S29GL064N_MN12 0x0c01
5152
5253/*
5354 * Status Register bit description. Used by flash devices that don't
@@ -109,6 +110,8 @@ static struct mtd_chip_driver cfi_amdstd_chipdrv = {
109110 .module = THIS_MODULE
110111};
111112
113+ static bool use_chip_good_for_write ;
114+
112115/*
113116 * Use status register to poll for Erase/write completion when DQ is not
114117 * supported. This is indicated by Bit[1:0] of SoftwareFeatures field in
@@ -283,6 +286,17 @@ static void fixup_use_write_buffers(struct mtd_info *mtd)
283286}
284287#endif /* !FORCE_WORD_WRITE */
285288
289+ static void fixup_use_chip_good_for_write (struct mtd_info * mtd )
290+ {
291+ struct map_info * map = mtd -> priv ;
292+ struct cfi_private * cfi = map -> fldrv_priv ;
293+
294+ if (cfi -> mfr == CFI_MFR_AMD && cfi -> id == S29GL064N_MN12 )
295+ return ;
296+
297+ use_chip_good_for_write = true;
298+ }
299+
286300/* Atmel chips don't use the same PRI format as AMD chips */
287301static void fixup_convert_atmel_pri (struct mtd_info * mtd )
288302{
@@ -462,7 +476,7 @@ static struct cfi_fixup cfi_fixup_table[] = {
462476 { CFI_MFR_AMD , 0x0056 , fixup_use_secsi },
463477 { CFI_MFR_AMD , 0x005C , fixup_use_secsi },
464478 { CFI_MFR_AMD , 0x005F , fixup_use_secsi },
465- { CFI_MFR_AMD , 0x0c01 , fixup_s29gl064n_sectors },
479+ { CFI_MFR_AMD , S29GL064N_MN12 , fixup_s29gl064n_sectors },
466480 { CFI_MFR_AMD , 0x1301 , fixup_s29gl064n_sectors },
467481 { CFI_MFR_AMD , 0x1a00 , fixup_s29gl032n_sectors },
468482 { CFI_MFR_AMD , 0x1a01 , fixup_s29gl032n_sectors },
@@ -474,6 +488,7 @@ static struct cfi_fixup cfi_fixup_table[] = {
474488#if !FORCE_WORD_WRITE
475489 { CFI_MFR_ANY , CFI_ID_ANY , fixup_use_write_buffers },
476490#endif
491+ { CFI_MFR_ANY , CFI_ID_ANY , fixup_use_chip_good_for_write },
477492 { 0 , 0 , NULL }
478493};
479494static struct cfi_fixup jedec_fixup_table [] = {
@@ -801,42 +816,61 @@ static struct mtd_info *cfi_amdstd_setup(struct mtd_info *mtd)
801816 return NULL ;
802817}
803818
804- /*
805- * Return true if the chip is ready.
806- *
807- * Ready is one of: read mode, query mode, erase-suspend-read mode (in any
808- * non-suspended sector) and is indicated by no toggle bits toggling.
809- *
810- * Note that anything more complicated than checking if no bits are toggling
811- * (including checking DQ5 for an error status) is tricky to get working
812- * correctly and is therefore not done (particularly with interleaved chips
813- * as each chip must be checked independently of the others).
814- */
815- static int __xipram chip_ready (struct map_info * map , struct flchip * chip ,
816- unsigned long addr )
819+ static int __xipram chip_check (struct map_info * map , struct flchip * chip ,
820+ unsigned long addr , map_word * expected )
817821{
818822 struct cfi_private * cfi = map -> fldrv_priv ;
819- map_word d , t ;
823+ map_word oldd , curd ;
824+ int ret ;
820825
821826 if (cfi_use_status_reg (cfi )) {
822827 map_word ready = CMD (CFI_SR_DRB );
828+
823829 /*
824830 * For chips that support status register, check device
825831 * ready bit
826832 */
827833 cfi_send_gen_cmd (0x70 , cfi -> addr_unlock1 , chip -> start , map , cfi ,
828834 cfi -> device_type , NULL );
829- d = map_read (map , addr );
835+ curd = map_read (map , addr );
830836
831- return map_word_andequal (map , d , ready , ready );
837+ return map_word_andequal (map , curd , ready , ready );
832838 }
833839
834- d = map_read (map , addr );
835- t = map_read (map , addr );
840+ oldd = map_read (map , addr );
841+ curd = map_read (map , addr );
842+
843+ ret = map_word_equal (map , oldd , curd );
844+
845+ if (!ret || !expected )
846+ return ret ;
847+
848+ return map_word_equal (map , curd , * expected );
849+ }
850+
851+ static int __xipram chip_good_for_write (struct map_info * map ,
852+ struct flchip * chip , unsigned long addr ,
853+ map_word expected )
854+ {
855+ if (use_chip_good_for_write )
856+ return chip_check (map , chip , addr , & expected );
836857
837- return map_word_equal (map , d , t );
858+ return chip_check (map , chip , addr , NULL );
838859}
839860
861+ /*
862+ * Return true if the chip is ready.
863+ *
864+ * Ready is one of: read mode, query mode, erase-suspend-read mode (in any
865+ * non-suspended sector) and is indicated by no toggle bits toggling.
866+ *
867+ * Note that anything more complicated than checking if no bits are toggling
868+ * (including checking DQ5 for an error status) is tricky to get working
869+ * correctly and is therefore not done (particularly with interleaved chips
870+ * as each chip must be checked independently of the others).
871+ */
872+ #define chip_ready (map , chip , addr ) chip_check(map, chip, addr, NULL)
873+
840874/*
841875 * Return true if the chip is ready and has the correct value.
842876 *
@@ -855,28 +889,7 @@ static int __xipram chip_ready(struct map_info *map, struct flchip *chip,
855889static int __xipram chip_good (struct map_info * map , struct flchip * chip ,
856890 unsigned long addr , map_word expected )
857891{
858- struct cfi_private * cfi = map -> fldrv_priv ;
859- map_word oldd , curd ;
860-
861- if (cfi_use_status_reg (cfi )) {
862- map_word ready = CMD (CFI_SR_DRB );
863-
864- /*
865- * For chips that support status register, check device
866- * ready bit
867- */
868- cfi_send_gen_cmd (0x70 , cfi -> addr_unlock1 , chip -> start , map , cfi ,
869- cfi -> device_type , NULL );
870- curd = map_read (map , addr );
871-
872- return map_word_andequal (map , curd , ready , ready );
873- }
874-
875- oldd = map_read (map , addr );
876- curd = map_read (map , addr );
877-
878- return map_word_equal (map , oldd , curd ) &&
879- map_word_equal (map , curd , expected );
892+ return chip_check (map , chip , addr , & expected );
880893}
881894
882895static int get_chip (struct map_info * map , struct flchip * chip , unsigned long adr , int mode )
@@ -1699,15 +1712,15 @@ static int __xipram do_write_oneword_once(struct map_info *map,
16991712 * "chip_good" to avoid the failure due to scheduling.
17001713 */
17011714 if (time_after (jiffies , timeo ) &&
1702- !chip_good (map , chip , adr , datum )) {
1715+ !chip_good_for_write (map , chip , adr , datum )) {
17031716 xip_enable (map , chip , adr );
17041717 printk (KERN_WARNING "MTD %s(): software timeout\n" , __func__ );
17051718 xip_disable (map , chip , adr );
17061719 ret = - EIO ;
17071720 break ;
17081721 }
17091722
1710- if (chip_good (map , chip , adr , datum )) {
1723+ if (chip_good_for_write (map , chip , adr , datum )) {
17111724 if (cfi_check_err_status (map , chip , adr ))
17121725 ret = - EIO ;
17131726 break ;
@@ -1979,14 +1992,14 @@ static int __xipram do_write_buffer_wait(struct map_info *map,
19791992 * "chip_good" to avoid the failure due to scheduling.
19801993 */
19811994 if (time_after (jiffies , timeo ) &&
1982- !chip_good (map , chip , adr , datum )) {
1995+ !chip_good_for_write (map , chip , adr , datum )) {
19831996 pr_err ("MTD %s(): software timeout, address:0x%.8lx.\n" ,
19841997 __func__ , adr );
19851998 ret = - EIO ;
19861999 break ;
19872000 }
19882001
1989- if (chip_good (map , chip , adr , datum )) {
2002+ if (chip_good_for_write (map , chip , adr , datum )) {
19902003 if (cfi_check_err_status (map , chip , adr ))
19912004 ret = - EIO ;
19922005 break ;
0 commit comments