MTD DataFlash: fix bug - ATMEL AT45DF321D spi flash card fails to be copied to
PATCH 1/1 MTD DataFlash: fix bug - ATMEL AT45DF321D spi flash card fails to be copied to
From: Michael Hennerich <[email protected]>
- Add support for binary page size DataFlashes.
- The driver now prints out pagesize and erasesize. Printout valuable information for creating flash filesystems.
--- drivers/mtd/devices/mtd_dataflash.c | 38 ++++++++++++++++++++++++++-------- 1 files changed, 29 insertions(+), 9 deletions(-)
drivers/mtd/devices/mtd_dataflash.c +29 -9
@@ -487,7 +487,9 @@ add_dataflash(struct spi_device *spi, char *name, device->write = dataflash_write; device->priv = priv; -dev_info (&spi->dev,"%s (%d KBytes)\n" , name, device->size/1024 ); +dev_info (&spi->dev,"%s (%d KBytes) pagesize %d bytes, " +"erasesize %d bytes\n" , name, device->size/1024 , + pagesize, pagesize *8 );/* 8 pages = 1 block */ dev_set_drvdata (&spi->dev, priv);if (mtd_has_partitions ()) {
@@ -524,10 +526,13 @@ add_dataflash(struct spi_device *spi, char *name,* AT45DB021B 2Mbit (256K) xx0101xx (0x14) 1025 264 9 * AT45DB041B 4Mbit (512K) xx0111xx (0x1c) 2048 264 9 * AT45DB081B 8Mbit (1M) xx1001xx (0x24) 4096 264 9 -* AT45DB0161B 16Mbit (2M) xx1011xx (0x2c) 4096 528 10 -* AT45DB0321B 32Mbit (4M) xx1101xx (0x34) 8192 528 10 -* AT45DB0642 64Mbit (8M) xx111xxx (0x3c) 8192 1056 11 -* AT45DB1282 128Mbit (16M) xx0100xx (0x10) 16384 1056 11 +* AT45DB0161B 16Mbit (2M) xx1011x0 (0x2c) 4096 528 10 +* AT45DB0161B 16Mbit (2M) xx1011x1 (0x2d) 4096 512 9 +* AT45DB0321B 32Mbit (4M) xx1101x0 (0x34) 8192 528 10 +* AT45DB0321B 32Mbit (4M) xx1101x1 (0x35) 8192 512 9 +* AT45DB0642 64Mbit (8M) xx111xx0 (0x3c) 8192 1056 11 +* AT45DB0642 64Mbit (8M) xx111xx1 (0x3d) 8192 1024 10 +* AT45DB1282 128Mbit (16M) xx0100x0 (0x10) 16384 1056 11 */ static int __devinit dataflash_probe (struct spi_device *spi) {
@@ -546,29 +551,44 @@ static int __devinit dataflash_probe(struct spi_device *spi)* board setup should have set spi->max_speed_max to * match f(car) for continuous reads, mode 0 or 3. */ -switch (status &0x3c ) { +switch (status &0x3d ) {case 0x0c :/* 0 0 1 1 x x */ +case 0x0d : status =add_dataflash (spi,"AT45DB011B" ,512 ,264 ,9 );break ;case 0x14 :/* 0 1 0 1 x x */ +case 0x15 : status =add_dataflash (spi,"AT45DB021B" ,1025 ,264 ,9 );break ;case 0x1c :/* 0 1 1 1 x x */ +case 0x1d : status =add_dataflash (spi,"AT45DB041x" ,2048 ,264 ,9 );break ;case 0x24 :/* 1 0 0 1 x x */ +case 0x25 : status =add_dataflash (spi,"AT45DB081B" ,4096 ,264 ,9 );break ; -case 0x2c :/* 1 0 1 1 x x */ +case 0x2c :/* 1 0 1 1 x 0 */ status =add_dataflash (spi,"AT45DB161x" ,4096 ,528 ,10 );break ; -case 0x34 :/* 1 1 0 1 x x */ +case 0x34 :/* 1 1 0 1 x 0 */ status =add_dataflash (spi,"AT45DB321x" ,8192 ,528 ,10 );break ; -case 0x38 :/* 1 1 1 x x x */ +case 0x38 :/* 1 1 1 x x 0 */ case 0x3c : status =add_dataflash (spi,"AT45DB642x" ,8192 ,1056 ,11 );break ; +/* Binary page size factory preset / user set */ +case 0x2d :/* 1 0 1 1 x 1 */ + status =add_dataflash (spi,"AT45DB161x" ,4096 ,512 ,9 ); +break ; +case 0x35 :/* 1 1 0 1 x 1 */ + status =add_dataflash (spi,"AT45DB321x" ,8192 ,512 ,9 ); +break ; +case 0x39 :/* 1 1 1 x x 1 */ +case 0x3d : + status =add_dataflash (spi,"AT45DB642x" ,8192 ,1024 ,10 ); +break ;/* obsolete AT45DB1282 not (yet?) supported */ default : DEBUG(MTD_DEBUG_LEVEL1, "%s: unsupported device (%x)\n",
Signature · 1 line
1.5.5
Quoted 5 lines · Bryan Wu
From: Michael Hennerich <[email protected]>
- Add support for binary page size DataFlashes.
- The driver now prints out pagesize and erasesize. Printout valuable information for creating flash filesystems.
I like the idea, but I'm afraid this approach isn't sufficient.
Thing is, the LSB of the status register is explicitly undefined for earlier chip revisions (e.g. see datasheets for AT45DB321B and AT45DB321C vs AT45DB321D), so you should use a different chip discovery algorithm. Perhaps:
* Try the original scheme (read status register);
* If it indicates a chip that has new versions with binary page size options, use the 0x9F command to read the JEDEC id (and chip revision);
* If it's a sufficently new revision, *then* you can interpret that LSB as indicating the page size
Example, on the AT45DB321x chips, that JEDEC instruction was added for the 'C' revision (according to my copies of the datasheets) and wasn't there for the 'B' revision ... while it was the 'D' revision which introduced the binary page size.
Maybe the JEDEC code from the m25p80 driver can be reused.
Also, I'd like to see a pre-existing typo fixed (in case anyone uses a flash that small) ... see below.
- Dave
drivers/mtd/devices/mtd_dataflash.c static int __devinit dataflash_probe(struct spi_device *spi) · line 561
Quoted 13 lines
drivers/mtd/devices/mtd_dataflash.c +3
-1@@ -546,29 +551,44 @@ static int __devinit dataflash_probe(struct spi_device *spi)* board setup should have set spi->max_speed_max to * match f(car) for continuous reads, mode 0 or 3. */ -switch (status &0x3c ) { +switch (status &0x3d ) {case 0x0c :/* 0 0 1 1 x x */ +case 0x0d : status =add_dataflash (spi,"AT45DB011B" ,512 ,264 ,9 );break ;case 0x14 :/* 0 1 0 1 x x */ +case 0x15 : status =add_dataflash (spi,"AT45DB021B" ,1025 ,264 ,9 );
1024 pages (of 264 bytes), not 1025. :)
Quoted 4 lines
drivers/mtd/devices/mtd_dataflash.c +1
-0break ;case 0x1c :/* 0 1 1 1 x x */ +case 0x1d :
David,
Please disregard this patch.
According to the ATMEL DataFlash datasheets, it's not a 100% correct.
I contacted ATMEL to get some commitment that BIT 0 of the DataFlash Status Register reads always 0 for all DataFlash Devices NOT in binary page size.
This was not acknowledged.
For the AT45DBXXXB devices bit 0 of the status register is a don't care (0 or 1). The '"B" version of the part does not support the binary page size.
For the AT45DBXXXD devices bit 0 of the status register is a 0 in the non-binary page mode.
We need use the Manufacturer and Device ID read command (opcode 9Fh) to distinguish between the "B" (parts which do not support the binary page size) and the "D" (parts which support the binary page size) version parts.
On the "B" version parts the Manufacturer and Device ID read command is ignored and output is tristated. Using this same opcode on the "D" version parts outputs 1Fh as the first byte and device ID (value depends on the density) as the second byte.
Bryan is going to send an updated path soon.
Best regards,
Michael
Quoted 5 lines
-----Original Message-----
From: Bryan Wu [mailto:[email protected]] On Behalf Of Bryan Wu
Sent: Samstag, 31. Mai 2008 12:39
To: [email protected]; [email protected]
Cc: [email protected]; [email protected];
Michael
Quoted 2 lines
Hennerich; Bryan Wu
Subject: [PATCH 1/1] MTD DataFlash: fix bug - ATMEL AT45DF321D spi
flash
Quoted 4 lines
card fails to be copied to
From: Michael Hennerich <[email protected]>
Quoted 8 lines
- Add support for binary page size DataFlashes.
- The driver now prints out pagesize and erasesize. Printout valuable information for creating flash filesystems.Signed-off-by Michael Hennerich <[email protected]>Signed-off-by Bryan Wu <[email protected]>---
drivers/mtd/devices/mtd_dataflash.c| 38
++++++++++++++++++++++++++-----
drivers/mtd/devices/mtd_dataflash.c add_dataflash(struct spi_device *spi, char *name, · line 490
Quoted 13 lines
---
1 files changed, 29 insertions(+), 9 deletions(-)drivers/mtd/devices/mtd_dataflash.c +0
-1@@ -487,7 +487,9 @@ add_dataflash(struct spi_device *spi, char *name, device->write = dataflash_write; device->priv = priv; - dev_info(&spi->dev, "%s (%d KBytes)\n", name,
device->size/1024);
Quoted 40 lines
drivers/mtd/devices/mtd_dataflash.c +13
-5+dev_info (&spi->dev,"%s (%d KBytes) pagesize %d bytes, " +"erasesize %d bytes\n" , name, device->size/1024 , + pagesize, pagesize *8 );/* 8 pages = 1 block */ dev_set_drvdata (&spi->dev, priv);if (mtd_has_partitions ()) {@@ -524,10 +526,13 @@ add_dataflash(struct spi_device *spi, char *name,* AT45DB021B 2Mbit (256K) xx0101xx (0x14) 1025 264 9 * AT45DB041B 4Mbit (512K) xx0111xx (0x1c) 2048 264 9 * AT45DB081B 8Mbit (1M) xx1001xx (0x24) 4096 264 9 -* AT45DB0161B 16Mbit (2M) xx1011xx (0x2c) 4096 528 10 -* AT45DB0321B 32Mbit (4M) xx1101xx (0x34) 8192 528 10 -* AT45DB0642 64Mbit (8M) xx111xxx (0x3c) 8192 1056 11 -* AT45DB1282 128Mbit (16M) xx0100xx (0x10) 16384 1056 11 +* AT45DB0161B 16Mbit (2M) xx1011x0 (0x2c) 4096 528 10 +* AT45DB0161B 16Mbit (2M) xx1011x1 (0x2d) 4096 512 9 +* AT45DB0321B 32Mbit (4M) xx1101x0 (0x34) 8192 528 10 +* AT45DB0321B 32Mbit (4M) xx1101x1 (0x35) 8192 512 9 +* AT45DB0642 64Mbit (8M) xx111xx0 (0x3c) 8192 1056 11 +* AT45DB0642 64Mbit (8M) xx111xx1 (0x3d) 8192 1024 10 +* AT45DB1282 128Mbit (16M) xx0100x0 (0x10) 16384 1056 11 */ static int __devinit dataflash_probe (struct spi_device *spi) {@@ -546,29 +551,44 @@ static int __devinit dataflash_probe(structspi_device *spi) * board setup should have set spi->max_speed_max to * match f(car) for continuous reads, mode 0 or 3. */ -switch (status &0x3c ) { +switch (status &0x3d ) {case 0x0c :/* 0 0 1 1 x x */ +case 0x0d : status =add_dataflash (spi,"AT45DB011B" ,512 ,264 ,9 );break ;case 0x14 :/* 0 1 0 1 x x */ +case 0x15 : status =add_dataflash (spi,"AT45DB021B" ,1025 ,264 ,9 );break ;case 0x1c :/* 0 1 1 1 x x */
drivers/mtd/devices/mtd_dataflash.c static int __devinit dataflash_probe(struct · line 573
Quoted 10 lines
drivers/mtd/devices/mtd_dataflash.c +3
-1+case 0x1d : status =add_dataflash (spi,"AT45DB041x" ,2048 ,264 ,9 );break ;case 0x24 :/* 1 0 0 1 x x */ +case 0x25 : status =add_dataflash (spi,"AT45DB081B" ,4096 ,264 ,9 );break ; -case 0x2c :/* 1 0 1 1 x x */ +case 0x2c :/* 1 0 1 1 x 0 */ status = add_dataflash(spi, "AT45DB161x", 4096, 528,
10);
drivers/mtd/devices/mtd_dataflash.c static int __devinit dataflash_probe(struct spi_device *spi)
Quoted 4 lines
drivers/mtd/devices/mtd_dataflash.c +1
-1break ; -case 0x34 :/* 1 1 0 1 x x */ +case 0x34 :/* 1 1 0 1 x 0 */ status = add_dataflash(spi, "AT45DB321x", 8192, 528,
10);
drivers/mtd/devices/mtd_dataflash.c static int __devinit dataflash_probe(struct spi_device *spi)
Quoted 5 lines
drivers/mtd/devices/mtd_dataflash.c +1
-1break ; -case 0x38 :/* 1 1 1 x x x */ +case 0x38 :/* 1 1 1 x x 0 */ case 0x3c : status = add_dataflash(spi, "AT45DB642x", 8192, 1056,
11);
drivers/mtd/devices/mtd_dataflash.c static int __devinit dataflash_probe(struct spi_device *spi)
Quoted 11 lines
drivers/mtd/devices/mtd_dataflash.c +10
-0break ; +/* Binary page size factory preset / user set */ +case 0x2d :/* 1 0 1 1 x 1 */ + status =add_dataflash (spi,"AT45DB161x" ,4096 ,512 ,9 ); +break ; +case 0x35 :/* 1 1 0 1 x 1 */ + status =add_dataflash (spi,"AT45DB321x" ,8192 ,512 ,9 ); +break ; +case 0x39 :/* 1 1 1 x x 1 */ +case 0x3d : + status = add_dataflash(spi, "AT45DB642x", 8192, 1024,
10);
Quoted 6 lines
drivers/mtd/devices/mtd_dataflash.c +1
-0+break ;/* obsolete AT45DB1282 not (yet?) supported */ default :DEBUG(MTD_DEBUG_LEVEL1, "%s: unsupported device (%x)\n",
--
1.5.5