Skip to content

Commit 7228982

Browse files
mhennerichDavid Woodhouse
authored andcommitted
[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@analog.com: remove duplicate code] Signed-off-by: Michael Hennerich <michael.hennerich@analog.com> Signed-off-by: Bryan Wu <cooloney@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
1 parent a8931ef commit 7228982

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

drivers/mtd/devices/m25p80.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
/* Flash opcodes. */
3434
#define OPCODE_WREN 0x06 /* Write enable */
3535
#define OPCODE_RDSR 0x05 /* Read status register */
36+
#define OPCODE_WRSR 0x01 /* Write status register 1 byte */
3637
#define OPCODE_NORM_READ 0x03 /* Read data bytes (low frequency) */
3738
#define OPCODE_FAST_READ 0x0b /* Read data bytes (high frequency) */
3839
#define OPCODE_PP 0x02 /* Page program (up to 256 bytes) */
@@ -112,6 +113,17 @@ static int read_sr(struct m25p *flash)
112113
return val;
113114
}
114115

116+
/*
117+
* Write status register 1 byte
118+
* Returns negative if error occurred.
119+
*/
120+
static int write_sr(struct m25p *flash, u8 val)
121+
{
122+
flash->command[0] = OPCODE_WRSR;
123+
flash->command[1] = val;
124+
125+
return spi_write(flash->spi, flash->command, 2);
126+
}
115127

116128
/*
117129
* Set write enable latch with Write Enable command.
@@ -589,6 +601,16 @@ static int __devinit m25p_probe(struct spi_device *spi)
589601
mutex_init(&flash->lock);
590602
dev_set_drvdata(&spi->dev, flash);
591603

604+
/*
605+
* Atmel serial flash tend to power up
606+
* with the software protection bits set
607+
*/
608+
609+
if (info->jedec_id >> 16 == 0x1f) {
610+
write_enable(flash);
611+
write_sr(flash, 0);
612+
}
613+
592614
if (data && data->name)
593615
flash->mtd.name = data->name;
594616
else

0 commit comments

Comments
 (0)