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
@@ -462,7 +463,7 @@ static struct cfi_fixup cfi_fixup_table[] = {
462
463
{ CFI_MFR_AMD , 0x0056 , fixup_use_secsi },
463
464
{ CFI_MFR_AMD , 0x005C , fixup_use_secsi },
464
465
{ CFI_MFR_AMD , 0x005F , fixup_use_secsi },
465
- { CFI_MFR_AMD , 0x0c01 , fixup_s29gl064n_sectors },
466
+ { CFI_MFR_AMD , S29GL064N_MN12 , fixup_s29gl064n_sectors },
466
467
{ CFI_MFR_AMD , 0x1301 , fixup_s29gl064n_sectors },
467
468
{ CFI_MFR_AMD , 0x1a00 , fixup_s29gl032n_sectors },
468
469
{ CFI_MFR_AMD , 0x1a01 , fixup_s29gl032n_sectors },
@@ -801,22 +802,12 @@ static struct mtd_info *cfi_amdstd_setup(struct mtd_info *mtd)
801
802
return NULL ;
802
803
}
803
804
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 )
805
+ static int __xipram chip_check (struct map_info * map , struct flchip * chip ,
806
+ unsigned long addr , map_word * expected )
817
807
{
818
808
struct cfi_private * cfi = map -> fldrv_priv ;
819
- map_word d , t ;
809
+ map_word oldd , curd ;
810
+ int ret ;
820
811
821
812
if (cfi_use_status_reg (cfi )) {
822
813
map_word ready = CMD (CFI_SR_DRB );
@@ -826,17 +817,35 @@ static int __xipram chip_ready(struct map_info *map, struct flchip *chip,
826
817
*/
827
818
cfi_send_gen_cmd (0x70 , cfi -> addr_unlock1 , chip -> start , map , cfi ,
828
819
cfi -> device_type , NULL );
829
- d = map_read (map , addr );
820
+ curd = map_read (map , addr );
830
821
831
- return map_word_andequal (map , d , ready , ready );
822
+ return map_word_andequal (map , curd , ready , ready );
832
823
}
833
824
834
- d = map_read (map , addr );
835
- t = map_read (map , addr );
825
+ oldd = map_read (map , addr );
826
+ curd = map_read (map , addr );
827
+
828
+ ret = map_word_equal (map , oldd , curd );
836
829
837
- return map_word_equal (map , d , t );
830
+ if (!ret || !expected )
831
+ return ret ;
832
+
833
+ return map_word_equal (map , curd , * expected );
838
834
}
839
835
836
+ /*
837
+ * Return true if the chip is ready.
838
+ *
839
+ * Ready is one of: read mode, query mode, erase-suspend-read mode (in any
840
+ * non-suspended sector) and is indicated by no toggle bits toggling.
841
+ *
842
+ * Note that anything more complicated than checking if no bits are toggling
843
+ * (including checking DQ5 for an error status) is tricky to get working
844
+ * correctly and is therefore not done (particularly with interleaved chips
845
+ * as each chip must be checked independently of the others).
846
+ */
847
+ #define chip_ready (map , chip , addr ) chip_check(map, chip, addr, NULL)
848
+
840
849
/*
841
850
* Return true if the chip is ready and has the correct value.
842
851
*
@@ -855,28 +864,24 @@ static int __xipram chip_ready(struct map_info *map, struct flchip *chip,
855
864
static int __xipram chip_good (struct map_info * map , struct flchip * chip ,
856
865
unsigned long addr , map_word expected )
857
866
{
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 );
867
+ return chip_check (map , chip , addr , & expected );
868
+ }
863
869
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 );
870
+ static bool cfi_use_chip_ready_for_write (struct map_info * map )
871
+ {
872
+ struct cfi_private * cfi = map -> fldrv_priv ;
871
873
872
- return map_word_andequal ( map , curd , ready , ready ) ;
873
- }
874
+ return cfi -> mfr == CFI_MFR_AMD && cfi -> id == S29GL064N_MN12 ;
875
+ }
874
876
875
- oldd = map_read (map , addr );
876
- curd = map_read (map , addr );
877
+ static int __xipram chip_good_for_write (struct map_info * map ,
878
+ struct flchip * chip , unsigned long addr ,
879
+ map_word expected )
880
+ {
881
+ if (cfi_use_chip_ready_for_write (map ))
882
+ return chip_ready (map , chip , addr );
877
883
878
- return map_word_equal (map , oldd , curd ) &&
879
- map_word_equal (map , curd , expected );
884
+ return chip_good (map , chip , addr , expected );
880
885
}
881
886
882
887
static int get_chip (struct map_info * map , struct flchip * chip , unsigned long adr , int mode )
@@ -1699,15 +1704,15 @@ static int __xipram do_write_oneword_once(struct map_info *map,
1699
1704
* "chip_good" to avoid the failure due to scheduling.
1700
1705
*/
1701
1706
if (time_after (jiffies , timeo ) &&
1702
- !chip_good (map , chip , adr , datum )) {
1707
+ !chip_good_for_write (map , chip , adr , datum )) {
1703
1708
xip_enable (map , chip , adr );
1704
1709
printk (KERN_WARNING "MTD %s(): software timeout\n" , __func__ );
1705
1710
xip_disable (map , chip , adr );
1706
1711
ret = - EIO ;
1707
1712
break ;
1708
1713
}
1709
1714
1710
- if (chip_good (map , chip , adr , datum )) {
1715
+ if (chip_good_for_write (map , chip , adr , datum )) {
1711
1716
if (cfi_check_err_status (map , chip , adr ))
1712
1717
ret = - EIO ;
1713
1718
break ;
@@ -1979,14 +1984,14 @@ static int __xipram do_write_buffer_wait(struct map_info *map,
1979
1984
* "chip_good" to avoid the failure due to scheduling.
1980
1985
*/
1981
1986
if (time_after (jiffies , timeo ) &&
1982
- !chip_good (map , chip , adr , datum )) {
1987
+ !chip_good_for_write (map , chip , adr , datum )) {
1983
1988
pr_err ("MTD %s(): software timeout, address:0x%.8lx.\n" ,
1984
1989
__func__ , adr );
1985
1990
ret = - EIO ;
1986
1991
break ;
1987
1992
}
1988
1993
1989
- if (chip_good (map , chip , adr , datum )) {
1994
+ if (chip_good_for_write (map , chip , adr , datum )) {
1990
1995
if (cfi_check_err_status (map , chip , adr ))
1991
1996
ret = - EIO ;
1992
1997
break ;
0 commit comments