48
48
#define SST49LF040B 0x0050
49
49
#define SST49LF008A 0x005a
50
50
#define AT49BV6416 0x00d6
51
+ #define S29GL064N_MN12 0x0c01
51
52
52
53
/*
53
54
* Status Register bit description. Used by flash devices that don't
@@ -109,6 +110,8 @@ static struct mtd_chip_driver cfi_amdstd_chipdrv = {
109
110
.module = THIS_MODULE
110
111
};
111
112
113
+ static bool use_chip_good_for_write ;
114
+
112
115
/*
113
116
* Use status register to poll for Erase/write completion when DQ is not
114
117
* 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)
283
286
}
284
287
#endif /* !FORCE_WORD_WRITE */
285
288
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
+
286
300
/* Atmel chips don't use the same PRI format as AMD chips */
287
301
static void fixup_convert_atmel_pri (struct mtd_info * mtd )
288
302
{
@@ -462,7 +476,7 @@ static struct cfi_fixup cfi_fixup_table[] = {
462
476
{ CFI_MFR_AMD , 0x0056 , fixup_use_secsi },
463
477
{ CFI_MFR_AMD , 0x005C , fixup_use_secsi },
464
478
{ CFI_MFR_AMD , 0x005F , fixup_use_secsi },
465
- { CFI_MFR_AMD , 0x0c01 , fixup_s29gl064n_sectors },
479
+ { CFI_MFR_AMD , S29GL064N_MN12 , fixup_s29gl064n_sectors },
466
480
{ CFI_MFR_AMD , 0x1301 , fixup_s29gl064n_sectors },
467
481
{ CFI_MFR_AMD , 0x1a00 , fixup_s29gl032n_sectors },
468
482
{ CFI_MFR_AMD , 0x1a01 , fixup_s29gl032n_sectors },
@@ -474,6 +488,7 @@ static struct cfi_fixup cfi_fixup_table[] = {
474
488
#if !FORCE_WORD_WRITE
475
489
{ CFI_MFR_ANY , CFI_ID_ANY , fixup_use_write_buffers },
476
490
#endif
491
+ { CFI_MFR_ANY , CFI_ID_ANY , fixup_use_chip_good_for_write },
477
492
{ 0 , 0 , NULL }
478
493
};
479
494
static struct cfi_fixup jedec_fixup_table [] = {
@@ -801,42 +816,61 @@ static struct mtd_info *cfi_amdstd_setup(struct mtd_info *mtd)
801
816
return NULL ;
802
817
}
803
818
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 )
817
821
{
818
822
struct cfi_private * cfi = map -> fldrv_priv ;
819
- map_word d , t ;
823
+ map_word oldd , curd ;
824
+ int ret ;
820
825
821
826
if (cfi_use_status_reg (cfi )) {
822
827
map_word ready = CMD (CFI_SR_DRB );
828
+
823
829
/*
824
830
* For chips that support status register, check device
825
831
* ready bit
826
832
*/
827
833
cfi_send_gen_cmd (0x70 , cfi -> addr_unlock1 , chip -> start , map , cfi ,
828
834
cfi -> device_type , NULL );
829
- d = map_read (map , addr );
835
+ curd = map_read (map , addr );
830
836
831
- return map_word_andequal (map , d , ready , ready );
837
+ return map_word_andequal (map , curd , ready , ready );
832
838
}
833
839
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 );
836
857
837
- return map_word_equal (map , d , t );
858
+ return chip_check (map , chip , addr , NULL );
838
859
}
839
860
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
+
840
874
/*
841
875
* Return true if the chip is ready and has the correct value.
842
876
*
@@ -855,28 +889,7 @@ static int __xipram chip_ready(struct map_info *map, struct flchip *chip,
855
889
static int __xipram chip_good (struct map_info * map , struct flchip * chip ,
856
890
unsigned long addr , map_word expected )
857
891
{
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 );
880
893
}
881
894
882
895
static 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,
1699
1712
* "chip_good" to avoid the failure due to scheduling.
1700
1713
*/
1701
1714
if (time_after (jiffies , timeo ) &&
1702
- !chip_good (map , chip , adr , datum )) {
1715
+ !chip_good_for_write (map , chip , adr , datum )) {
1703
1716
xip_enable (map , chip , adr );
1704
1717
printk (KERN_WARNING "MTD %s(): software timeout\n" , __func__ );
1705
1718
xip_disable (map , chip , adr );
1706
1719
ret = - EIO ;
1707
1720
break ;
1708
1721
}
1709
1722
1710
- if (chip_good (map , chip , adr , datum )) {
1723
+ if (chip_good_for_write (map , chip , adr , datum )) {
1711
1724
if (cfi_check_err_status (map , chip , adr ))
1712
1725
ret = - EIO ;
1713
1726
break ;
@@ -1979,14 +1992,14 @@ static int __xipram do_write_buffer_wait(struct map_info *map,
1979
1992
* "chip_good" to avoid the failure due to scheduling.
1980
1993
*/
1981
1994
if (time_after (jiffies , timeo ) &&
1982
- !chip_good (map , chip , adr , datum )) {
1995
+ !chip_good_for_write (map , chip , adr , datum )) {
1983
1996
pr_err ("MTD %s(): software timeout, address:0x%.8lx.\n" ,
1984
1997
__func__ , adr );
1985
1998
ret = - EIO ;
1986
1999
break ;
1987
2000
}
1988
2001
1989
- if (chip_good (map , chip , adr , datum )) {
2002
+ if (chip_good_for_write (map , chip , adr , datum )) {
1990
2003
if (cfi_check_err_status (map , chip , adr ))
1991
2004
ret = - EIO ;
1992
2005
break ;
0 commit comments