44 *
55 * (C) 2000 Red Hat. GPL'd
66 *
7- * $Id: cfi_cmdset_0001.c,v 1.181 2005/08/06 04:16:48 nico Exp $
7+ * $Id: cfi_cmdset_0001.c,v 1.182 2005/08/06 04:40:41 nico Exp $
88 *
99 *
1010 * 10/10/2000 Nicolas Pitre <nico@cam.org>
@@ -105,6 +105,7 @@ static struct mtd_chip_driver cfi_intelext_chipdrv = {
105105static void cfi_tell_features (struct cfi_pri_intelext * extp )
106106{
107107 int i ;
108+ printk (" Extended Query version %c.%c\n" , extp -> MajorVersion , extp -> MinorVersion );
108109 printk (" Feature/Command Support: %4.4X\n" , extp -> FeatureSupport );
109110 printk (" - Chip Erase: %s\n" , extp -> FeatureSupport & 1 ?"supported" :"unsupported" );
110111 printk (" - Suspend Erase: %s\n" , extp -> FeatureSupport & 2 ?"supported" :"unsupported" );
@@ -116,7 +117,8 @@ static void cfi_tell_features(struct cfi_pri_intelext *extp)
116117 printk (" - Page-mode read: %s\n" , extp -> FeatureSupport & 128 ?"supported" :"unsupported" );
117118 printk (" - Synchronous read: %s\n" , extp -> FeatureSupport & 256 ?"supported" :"unsupported" );
118119 printk (" - Simultaneous operations: %s\n" , extp -> FeatureSupport & 512 ?"supported" :"unsupported" );
119- for (i = 10 ; i < 32 ; i ++ ) {
120+ printk (" - Extended Flash Array: %s\n" , extp -> FeatureSupport & 1024 ?"supported" :"unsupported" );
121+ for (i = 11 ; i < 32 ; i ++ ) {
120122 if (extp -> FeatureSupport & (1 <<i ))
121123 printk (" - Unknown Bit %X: supported\n" , i );
122124 }
@@ -130,12 +132,18 @@ static void cfi_tell_features(struct cfi_pri_intelext *extp)
130132
131133 printk (" Block Status Register Mask: %4.4X\n" , extp -> BlkStatusRegMask );
132134 printk (" - Lock Bit Active: %s\n" , extp -> BlkStatusRegMask & 1 ?"yes" :"no" );
133- printk (" - Valid Bit Active: %s\n" , extp -> BlkStatusRegMask & 2 ?"yes" :"no" );
134- for (i = 2 ; i < 16 ; i ++ ) {
135+ printk (" - Lock-Down Bit Active: %s\n" , extp -> BlkStatusRegMask & 2 ?"yes" :"no" );
136+ for (i = 2 ; i < 3 ; i ++ ) {
135137 if (extp -> BlkStatusRegMask & (1 <<i ))
136138 printk (" - Unknown Bit %X Active: yes\n" ,i );
137139 }
138-
140+ printk (" - EFA Lock Bit: %s\n" , extp -> BlkStatusRegMask & 16 ?"yes" :"no" );
141+ printk (" - EFA Lock-Down Bit: %s\n" , extp -> BlkStatusRegMask & 32 ?"yes" :"no" );
142+ for (i = 6 ; i < 16 ; i ++ ) {
143+ if (extp -> BlkStatusRegMask & (1 <<i ))
144+ printk (" - Unknown Bit %X Active: yes\n" ,i );
145+ }
146+
139147 printk (" Vcc Logic Supply Optimum Program/Erase Voltage: %d.%d V\n" ,
140148 extp -> VccOptimal >> 4 , extp -> VccOptimal & 0xf );
141149 if (extp -> VppOptimal )
@@ -253,7 +261,7 @@ read_pri_intelext(struct map_info *map, __u16 adr)
253261 return NULL ;
254262
255263 if (extp -> MajorVersion != '1' ||
256- (extp -> MinorVersion < '0' || extp -> MinorVersion > '3 ' )) {
264+ (extp -> MinorVersion < '0' || extp -> MinorVersion > '4 ' )) {
257265 printk (KERN_ERR " Unknown Intel/Sharp Extended Query "
258266 "version %c.%c.\n" , extp -> MajorVersion ,
259267 extp -> MinorVersion );
@@ -266,7 +274,7 @@ read_pri_intelext(struct map_info *map, __u16 adr)
266274 extp -> BlkStatusRegMask = le16_to_cpu (extp -> BlkStatusRegMask );
267275 extp -> ProtRegAddr = le16_to_cpu (extp -> ProtRegAddr );
268276
269- if (extp -> MajorVersion == '1' && extp -> MinorVersion = = '3' ) {
277+ if (extp -> MajorVersion == '1' && extp -> MinorVersion > = '3' ) {
270278 unsigned int extra_size = 0 ;
271279 int nb_parts , i ;
272280
@@ -275,14 +283,18 @@ read_pri_intelext(struct map_info *map, __u16 adr)
275283 sizeof (struct cfi_intelext_otpinfo );
276284
277285 /* Burst Read info */
278- extra_size += 6 ;
286+ extra_size += ( extp -> MinorVersion < '4' ) ? 6 : 5 ;
279287
280288 /* Number of hardware-partitions */
281289 extra_size += 1 ;
282290 if (extp_size < sizeof (* extp ) + extra_size )
283291 goto need_more ;
284292 nb_parts = extp -> extra [extra_size - 1 ];
285293
294+ /* skip the sizeof(partregion) field in CFI 1.4 */
295+ if (extp -> MinorVersion >= '4' )
296+ extra_size += 2 ;
297+
286298 for (i = 0 ; i < nb_parts ; i ++ ) {
287299 struct cfi_intelext_regioninfo * rinfo ;
288300 rinfo = (struct cfi_intelext_regioninfo * )& extp -> extra [extra_size ];
@@ -294,6 +306,9 @@ read_pri_intelext(struct map_info *map, __u16 adr)
294306 * sizeof (struct cfi_intelext_blockinfo );
295307 }
296308
309+ if (extp -> MinorVersion >= '4' )
310+ extra_size += sizeof (struct cfi_intelext_programming_regioninfo );
311+
297312 if (extp_size < sizeof (* extp ) + extra_size ) {
298313 need_more :
299314 extp_size = sizeof (* extp ) + extra_size ;
@@ -490,7 +505,7 @@ static int cfi_intelext_partition_fixup(struct mtd_info *mtd,
490505 * arrangement at this point. This can be rearranged in the future
491506 * if someone feels motivated enough. --nico
492507 */
493- if (extp && extp -> MajorVersion == '1' && extp -> MinorVersion = = '3'
508+ if (extp && extp -> MajorVersion == '1' && extp -> MinorVersion > = '3'
494509 && extp -> FeatureSupport & (1 << 9 )) {
495510 struct cfi_private * newcfi ;
496511 struct flchip * chip ;
@@ -502,12 +517,16 @@ static int cfi_intelext_partition_fixup(struct mtd_info *mtd,
502517 sizeof (struct cfi_intelext_otpinfo );
503518
504519 /* Burst Read info */
505- offs += 6 ;
520+ offs += ( extp -> MinorVersion < '4' ) ? 6 : 5 ;
506521
507522 /* Number of partition regions */
508523 numregions = extp -> extra [offs ];
509524 offs += 1 ;
510525
526+ /* skip the sizeof(partregion) field in CFI 1.4 */
527+ if (extp -> MinorVersion >= '4' )
528+ offs += 2 ;
529+
511530 /* Number of hardware partitions */
512531 numparts = 0 ;
513532 for (i = 0 ; i < numregions ; i ++ ) {
@@ -519,6 +538,20 @@ static int cfi_intelext_partition_fixup(struct mtd_info *mtd,
519538 sizeof (struct cfi_intelext_blockinfo );
520539 }
521540
541+ /* Programming Region info */
542+ if (extp -> MinorVersion >= '4' ) {
543+ struct cfi_intelext_programming_regioninfo * prinfo ;
544+ prinfo = (struct cfi_intelext_programming_regioninfo * )& extp -> extra [offs ];
545+ MTD_PROGREGION_SIZE (mtd ) = cfi -> interleave << prinfo -> ProgRegShift ;
546+ MTD_PROGREGION_CTRLMODE_VALID (mtd ) = cfi -> interleave * prinfo -> ControlValid ;
547+ MTD_PROGREGION_CTRLMODE_INVALID (mtd ) = cfi -> interleave * prinfo -> ControlInvalid ;
548+ mtd -> flags |= MTD_PROGRAM_REGIONS ;
549+ printk (KERN_DEBUG "%s: program region size/ctrl_valid/ctrl_inval = %d/%d/%d\n" ,
550+ map -> name , MTD_PROGREGION_SIZE (mtd ),
551+ MTD_PROGREGION_CTRLMODE_VALID (mtd ),
552+ MTD_PROGREGION_CTRLMODE_INVALID (mtd ));
553+ }
554+
522555 /*
523556 * All functions below currently rely on all chips having
524557 * the same geometry so we'll just assume that all hardware
@@ -1222,12 +1255,17 @@ static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip,
12221255
12231256 adr += chip -> start ;
12241257
1225- /* Let's determine this according to the interleave only once */
1258+ /* Let's determine those according to the interleave only once */
12261259 status_OK = CMD (0x80 );
12271260 switch (mode ) {
1228- case FL_WRITING : write_cmd = CMD (0x40 ); break ;
1229- case FL_OTP_WRITE : write_cmd = CMD (0xc0 ); break ;
1230- default : return - EINVAL ;
1261+ case FL_WRITING :
1262+ write_cmd = (cfi -> cfiq -> P_ID != 0x0200 ) ? CMD (0x40 ) : CMD (0x41 );
1263+ break ;
1264+ case FL_OTP_WRITE :
1265+ write_cmd = CMD (0xc0 );
1266+ break ;
1267+ default :
1268+ return - EINVAL ;
12311269 }
12321270
12331271 spin_lock (chip -> mutex );
@@ -1410,16 +1448,17 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
14101448 unsigned long adr , const u_char * buf , int len )
14111449{
14121450 struct cfi_private * cfi = map -> fldrv_priv ;
1413- map_word status , status_OK ;
1451+ map_word status , status_OK , write_cmd ;
14141452 unsigned long cmd_adr , timeo ;
14151453 int wbufsize , z , ret = 0 , bytes , words ;
14161454
14171455 wbufsize = cfi_interleave (cfi ) << cfi -> cfiq -> MaxBufWriteSize ;
14181456 adr += chip -> start ;
14191457 cmd_adr = adr & ~(wbufsize - 1 );
1420-
1458+
14211459 /* Let's determine this according to the interleave only once */
14221460 status_OK = CMD (0x80 );
1461+ write_cmd = (cfi -> cfiq -> P_ID != 0x0200 ) ? CMD (0xe8 ) : CMD (0xe9 );
14231462
14241463 spin_lock (chip -> mutex );
14251464 ret = get_chip (map , chip , cmd_adr , FL_WRITING );
@@ -1451,7 +1490,7 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
14511490
14521491 z = 0 ;
14531492 for (;;) {
1454- map_write (map , CMD ( 0xe8 ) , cmd_adr );
1493+ map_write (map , write_cmd , cmd_adr );
14551494
14561495 status = map_read (map , cmd_adr );
14571496 if (map_word_andequal (map , status , status_OK , status_OK ))
@@ -2380,20 +2419,23 @@ static void cfi_intelext_destroy(struct mtd_info *mtd)
23802419 kfree (mtd -> eraseregions );
23812420}
23822421
2383- static char im_name_1 []= "cfi_cmdset_0001" ;
2384- static char im_name_3 []= "cfi_cmdset_0003" ;
2422+ static char im_name_0001 [] = "cfi_cmdset_0001" ;
2423+ static char im_name_0003 [] = "cfi_cmdset_0003" ;
2424+ static char im_name_0200 [] = "cfi_cmdset_0200" ;
23852425
23862426static int __init cfi_intelext_init (void )
23872427{
2388- inter_module_register (im_name_1 , THIS_MODULE , & cfi_cmdset_0001 );
2389- inter_module_register (im_name_3 , THIS_MODULE , & cfi_cmdset_0001 );
2428+ inter_module_register (im_name_0001 , THIS_MODULE , & cfi_cmdset_0001 );
2429+ inter_module_register (im_name_0003 , THIS_MODULE , & cfi_cmdset_0001 );
2430+ inter_module_register (im_name_0200 , THIS_MODULE , & cfi_cmdset_0001 );
23902431 return 0 ;
23912432}
23922433
23932434static void __exit cfi_intelext_exit (void )
23942435{
2395- inter_module_unregister (im_name_1 );
2396- inter_module_unregister (im_name_3 );
2436+ inter_module_unregister (im_name_0001 );
2437+ inter_module_unregister (im_name_0003 );
2438+ inter_module_unregister (im_name_0200 );
23972439}
23982440
23992441module_init (cfi_intelext_init );
0 commit comments