diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-12-09 11:28:36 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-12-09 11:28:36 -0500 |
commit | 4d9c6a21befe6c73c35f2799c7e25a9eda82a95d (patch) | |
tree | d77a05b369b40bd48ce663f5206f3630fc942bbc /drivers/mtd/devices | |
parent | b749e3f8d7879c9c87e237d75b2256b4d1d04df2 (diff) | |
parent | e93f1be503efd0e44e46fc1fd4c13dbee72a6561 (diff) |
Merge git://git.infradead.org/mtd-2.6
* git://git.infradead.org/mtd-2.6:
[MTD] [NAND] fix OOPS accessing flash operations over STM flash on PXA
[MTD] [NAND] drivers/mtd/nand/pasemi_nand.c: Add missing pci_dev_put
[MTD] [NAND] fsl_upm: fix build problem with 2.6.28-rc2
[MTD] physmap: fix memory leak on physmap_flash_remove by using devres
[MTD] m25p80: chip erase != block erase != sector erase
[MTD] m25p80: fix detection of m25p16 flashes
[MTD] m25p80: fix detection of SPI parts
[MTD] [NAND] OMAP: OneNAND: header file relocation (part 2)
[MTD] [NAND] OMAP: OneNAND: header file relocation
Diffstat (limited to 'drivers/mtd/devices')
-rw-r--r-- | drivers/mtd/devices/m25p80.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c index 76a76751da36..6659b2275c0c 100644 --- a/drivers/mtd/devices/m25p80.c +++ b/drivers/mtd/devices/m25p80.c | |||
@@ -37,9 +37,9 @@ | |||
37 | #define OPCODE_NORM_READ 0x03 /* Read data bytes (low frequency) */ | 37 | #define OPCODE_NORM_READ 0x03 /* Read data bytes (low frequency) */ |
38 | #define OPCODE_FAST_READ 0x0b /* Read data bytes (high frequency) */ | 38 | #define OPCODE_FAST_READ 0x0b /* Read data bytes (high frequency) */ |
39 | #define OPCODE_PP 0x02 /* Page program (up to 256 bytes) */ | 39 | #define OPCODE_PP 0x02 /* Page program (up to 256 bytes) */ |
40 | #define OPCODE_BE_4K 0x20 /* Erase 4KiB block */ | 40 | #define OPCODE_BE_4K 0x20 /* Erase 4KiB block */ |
41 | #define OPCODE_BE_32K 0x52 /* Erase 32KiB block */ | 41 | #define OPCODE_BE_32K 0x52 /* Erase 32KiB block */ |
42 | #define OPCODE_BE 0xc7 /* Erase whole flash block */ | 42 | #define OPCODE_CHIP_ERASE 0xc7 /* Erase whole flash chip */ |
43 | #define OPCODE_SE 0xd8 /* Sector erase (usually 64KiB) */ | 43 | #define OPCODE_SE 0xd8 /* Sector erase (usually 64KiB) */ |
44 | #define OPCODE_RDID 0x9f /* Read JEDEC ID */ | 44 | #define OPCODE_RDID 0x9f /* Read JEDEC ID */ |
45 | 45 | ||
@@ -167,7 +167,7 @@ static int wait_till_ready(struct m25p *flash) | |||
167 | * | 167 | * |
168 | * Returns 0 if successful, non-zero otherwise. | 168 | * Returns 0 if successful, non-zero otherwise. |
169 | */ | 169 | */ |
170 | static int erase_block(struct m25p *flash) | 170 | static int erase_chip(struct m25p *flash) |
171 | { | 171 | { |
172 | DEBUG(MTD_DEBUG_LEVEL3, "%s: %s %dKiB\n", | 172 | DEBUG(MTD_DEBUG_LEVEL3, "%s: %s %dKiB\n", |
173 | flash->spi->dev.bus_id, __func__, | 173 | flash->spi->dev.bus_id, __func__, |
@@ -181,7 +181,7 @@ static int erase_block(struct m25p *flash) | |||
181 | write_enable(flash); | 181 | write_enable(flash); |
182 | 182 | ||
183 | /* Set up command buffer. */ | 183 | /* Set up command buffer. */ |
184 | flash->command[0] = OPCODE_BE; | 184 | flash->command[0] = OPCODE_CHIP_ERASE; |
185 | 185 | ||
186 | spi_write(flash->spi, flash->command, 1); | 186 | spi_write(flash->spi, flash->command, 1); |
187 | 187 | ||
@@ -250,15 +250,18 @@ static int m25p80_erase(struct mtd_info *mtd, struct erase_info *instr) | |||
250 | 250 | ||
251 | mutex_lock(&flash->lock); | 251 | mutex_lock(&flash->lock); |
252 | 252 | ||
253 | /* REVISIT in some cases we could speed up erasing large regions | 253 | /* whole-chip erase? */ |
254 | * by using OPCODE_SE instead of OPCODE_BE_4K | 254 | if (len == flash->mtd.size && erase_chip(flash)) { |
255 | */ | ||
256 | |||
257 | /* now erase those sectors */ | ||
258 | if (len == flash->mtd.size && erase_block(flash)) { | ||
259 | instr->state = MTD_ERASE_FAILED; | 255 | instr->state = MTD_ERASE_FAILED; |
260 | mutex_unlock(&flash->lock); | 256 | mutex_unlock(&flash->lock); |
261 | return -EIO; | 257 | return -EIO; |
258 | |||
259 | /* REVISIT in some cases we could speed up erasing large regions | ||
260 | * by using OPCODE_SE instead of OPCODE_BE_4K. We may have set up | ||
261 | * to use "small sector erase", but that's not always optimal. | ||
262 | */ | ||
263 | |||
264 | /* "sector"-at-a-time erase */ | ||
262 | } else { | 265 | } else { |
263 | while (len) { | 266 | while (len) { |
264 | if (erase_sector(flash, addr)) { | 267 | if (erase_sector(flash, addr)) { |
@@ -574,10 +577,11 @@ static struct flash_info *__devinit jedec_probe(struct spi_device *spi) | |||
574 | for (tmp = 0, info = m25p_data; | 577 | for (tmp = 0, info = m25p_data; |
575 | tmp < ARRAY_SIZE(m25p_data); | 578 | tmp < ARRAY_SIZE(m25p_data); |
576 | tmp++, info++) { | 579 | tmp++, info++) { |
577 | if (info->jedec_id == jedec) | 580 | if (info->jedec_id == jedec) { |
578 | if (ext_jedec != 0 && info->ext_id != ext_jedec) | 581 | if (info->ext_id != 0 && info->ext_id != ext_jedec) |
579 | continue; | 582 | continue; |
580 | return info; | 583 | return info; |
584 | } | ||
581 | } | 585 | } |
582 | dev_err(&spi->dev, "unrecognized JEDEC id %06x\n", jedec); | 586 | dev_err(&spi->dev, "unrecognized JEDEC id %06x\n", jedec); |
583 | return NULL; | 587 | return NULL; |