[MTD] m25p80: fix bug - ATmel spi flash fails to be copied to
Linux-MTD Mailing List
linux-mtd at lists.infradead.org
Fri Jul 11 13:59:01 EDT 2008
Gitweb: http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=72289824423655e67993c25c91a7a86a34917209
Commit: 72289824423655e67993c25c91a7a86a34917209
Parent: a8931ef380c92d121ae74ecfb03b2d63f72eea6f
Author: Michael Hennerich <michael.hennerich at analog.com>
AuthorDate: Thu Jul 3 23:54:42 2008 -0700
Committer: David Woodhouse <David.Woodhouse at intel.com>
CommitDate: Fri Jul 11 14:44:32 2008 +0100
[MTD] m25p80: fix bug - ATmel spi flash fails to be copied to
Atmel serial flash tends to power up with the protection status bits set.
http://blackfin.uclinux.org/gf/project/uclinux-dist/tracker/?action=TrackerItemEdit&tracker_item_id=4089
[michael.hennerich at analog.com: remove duplicate code]
Signed-off-by: Michael Hennerich <michael.hennerich at analog.com>
Signed-off-by: Bryan Wu <cooloney at kernel.org>
Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
Signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
---
drivers/mtd/devices/m25p80.c | 22 ++++++++++++++++++++++
1 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index b402269..b35c333 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -33,6 +33,7 @@
/* Flash opcodes. */
#define OPCODE_WREN 0x06 /* Write enable */
#define OPCODE_RDSR 0x05 /* Read status register */
+#define OPCODE_WRSR 0x01 /* Write status register 1 byte */
#define OPCODE_NORM_READ 0x03 /* Read data bytes (low frequency) */
#define OPCODE_FAST_READ 0x0b /* Read data bytes (high frequency) */
#define OPCODE_PP 0x02 /* Page program (up to 256 bytes) */
@@ -112,6 +113,17 @@ static int read_sr(struct m25p *flash)
return val;
}
+/*
+ * Write status register 1 byte
+ * Returns negative if error occurred.
+ */
+static int write_sr(struct m25p *flash, u8 val)
+{
+ flash->command[0] = OPCODE_WRSR;
+ flash->command[1] = val;
+
+ return spi_write(flash->spi, flash->command, 2);
+}
/*
* Set write enable latch with Write Enable command.
@@ -589,6 +601,16 @@ static int __devinit m25p_probe(struct spi_device *spi)
mutex_init(&flash->lock);
dev_set_drvdata(&spi->dev, flash);
+ /*
+ * Atmel serial flash tend to power up
+ * with the software protection bits set
+ */
+
+ if (info->jedec_id >> 16 == 0x1f) {
+ write_enable(flash);
+ write_sr(flash, 0);
+ }
+
if (data && data->name)
flash->mtd.name = data->name;
else
More information about the linux-mtd-cvs
mailing list