Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 106430
b: refs/heads/master
c: 7228982
h: refs/heads/master
v: v3
  • Loading branch information
Michael Hennerich authored and David Woodhouse committed Jul 11, 2008
1 parent b284e2a commit 7ab7b28
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a8931ef380c92d121ae74ecfb03b2d63f72eea6f
refs/heads/master: 72289824423655e67993c25c91a7a86a34917209
22 changes: 22 additions & 0 deletions trunk/drivers/mtd/devices/m25p80.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) */
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7ab7b28

Please sign in to comment.