diff options
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/spi/atmel.c | 40 | ||||
-rw-r--r-- | drivers/mtd/spi/eon.c | 13 | ||||
-rw-r--r-- | drivers/mtd/spi/macronix.c | 17 | ||||
-rw-r--r-- | drivers/mtd/spi/ramtron.c | 5 | ||||
-rw-r--r-- | drivers/mtd/spi/spansion.c | 15 | ||||
-rw-r--r-- | drivers/mtd/spi/spi_flash.c | 9 | ||||
-rw-r--r-- | drivers/mtd/spi/spi_flash_internal.h | 2 | ||||
-rw-r--r-- | drivers/mtd/spi/sst.c | 17 | ||||
-rw-r--r-- | drivers/mtd/spi/stmicro.c | 15 | ||||
-rw-r--r-- | drivers/mtd/spi/winbond.c | 13 |
10 files changed, 71 insertions, 75 deletions
diff --git a/drivers/mtd/spi/atmel.c b/drivers/mtd/spi/atmel.c index a9910b1..1ecece0 100644 --- a/drivers/mtd/spi/atmel.c +++ b/drivers/mtd/spi/atmel.c @@ -113,8 +113,35 @@ static const struct atmel_spi_flash_params atmel_spi_flash_table[] = { static int at45_wait_ready(struct spi_flash *flash, unsigned long timeout) { - return spi_flash_cmd_poll_bit(flash, timeout, - CMD_AT45_READ_STATUS, AT45_STATUS_READY); + struct spi_slave *spi = flash->spi; + unsigned long timebase; + int ret; + u8 cmd = CMD_AT45_READ_STATUS; + u8 status; + + timebase = get_timer(0); + + ret = spi_xfer(spi, 8, &cmd, NULL, SPI_XFER_BEGIN); + if (ret) + return -1; + + do { + ret = spi_xfer(spi, 8, NULL, &status, 0); + if (ret) + return -1; + + if (status & AT45_STATUS_READY) + break; + } while (get_timer(timebase) < timeout); + + /* Deactivate CS */ + spi_xfer(spi, 0, NULL, NULL, SPI_XFER_END); + + if (status & AT45_STATUS_READY) + return 0; + + /* Timed out */ + return -1; } /* @@ -301,7 +328,7 @@ out: /* * TODO: the two erase funcs (_p2/_at45) should get unified ... */ -int dataflash_erase_p2(struct spi_flash *flash, u32 offset, size_t len) +static int dataflash_erase_p2(struct spi_flash *flash, u32 offset, size_t len) { struct atmel_spi_flash *asf = to_atmel_spi_flash(flash); unsigned long page_size; @@ -360,7 +387,7 @@ out: return ret; } -int dataflash_erase_at45(struct spi_flash *flash, u32 offset, size_t len) +static int dataflash_erase_at45(struct spi_flash *flash, u32 offset, size_t len) { struct atmel_spi_flash *asf = to_atmel_spi_flash(flash); unsigned long page_addr; @@ -495,14 +522,11 @@ struct spi_flash *spi_flash_probe_atmel(struct spi_slave *spi, u8 *idcode) goto err; } + asf->flash.sector_size = page_size; asf->flash.size = page_size * params->pages_per_block * params->blocks_per_sector * params->nr_sectors; - printf("SF: Detected %s with page size %u, total ", - params->name, page_size); - print_size(asf->flash.size, "\n"); - return &asf->flash; err: diff --git a/drivers/mtd/spi/eon.c b/drivers/mtd/spi/eon.c index 01caed5..e3de3aa 100644 --- a/drivers/mtd/spi/eon.c +++ b/drivers/mtd/spi/eon.c @@ -119,13 +119,9 @@ static int eon_write(struct spi_flash *flash, return ret; } -int eon_erase(struct spi_flash *flash, u32 offset, size_t len) +static int eon_erase(struct spi_flash *flash, u32 offset, size_t len) { - struct eon_spi_flash *eon = to_eon_spi_flash(flash); - return spi_flash_cmd_erase(flash, CMD_EN25Q128_BE, - eon->params->page_size * eon->params->pages_per_sector * - eon->params->sectors_per_block; - offset, len); + return spi_flash_cmd_erase(flash, CMD_EN25Q128_BE, offset, len); } struct spi_flash *spi_flash_probe_eon(struct spi_slave *spi, u8 *idcode) @@ -158,11 +154,10 @@ struct spi_flash *spi_flash_probe_eon(struct spi_slave *spi, u8 *idcode) eon->flash.write = eon_write; eon->flash.erase = eon_erase; eon->flash.read = spi_flash_cmd_read_fast; + eon->flash.sector_size = params->page_size * params->pages_per_sector + * params->sectors_per_block; eon->flash.size = params->page_size * params->pages_per_sector * params->nr_sectors; - debug("SF: Detected %s with page size %u, total %u bytes\n", - params->name, params->page_size, eon->flash.size); - return &eon->flash; } diff --git a/drivers/mtd/spi/macronix.c b/drivers/mtd/spi/macronix.c index 4155d4d..ff66f2a 100644 --- a/drivers/mtd/spi/macronix.c +++ b/drivers/mtd/spi/macronix.c @@ -175,13 +175,9 @@ static int macronix_write(struct spi_flash *flash, return ret; } -int macronix_erase(struct spi_flash *flash, u32 offset, size_t len) +static int macronix_erase(struct spi_flash *flash, u32 offset, size_t len) { - struct macronix_spi_flash *mcx = to_macronix_spi_flash(flash); - return spi_flash_cmd_erase(flash, CMD_MX25XX_BE, - mcx->params->page_size * mcx->params->pages_per_sector * - mcx->params->sectors_per_block, - offset, len); + return spi_flash_cmd_erase(flash, CMD_MX25XX_BE, offset, len); } struct spi_flash *spi_flash_probe_macronix(struct spi_slave *spi, u8 *idcode) @@ -215,12 +211,9 @@ struct spi_flash *spi_flash_probe_macronix(struct spi_slave *spi, u8 *idcode) mcx->flash.write = macronix_write; mcx->flash.erase = macronix_erase; mcx->flash.read = spi_flash_cmd_read_fast; - mcx->flash.size = params->page_size * params->pages_per_sector - * params->sectors_per_block * params->nr_blocks; - - printf("SF: Detected %s with page size %u, total ", - params->name, params->page_size); - print_size(mcx->flash.size, "\n"); + mcx->flash.sector_size = params->page_size * params->pages_per_sector + * params->sectors_per_block; + mcx->flash.size = mcx->flash.sector_size * params->nr_blocks; return &mcx->flash; } diff --git a/drivers/mtd/spi/ramtron.c b/drivers/mtd/spi/ramtron.c index 171390d..078d16c 100644 --- a/drivers/mtd/spi/ramtron.c +++ b/drivers/mtd/spi/ramtron.c @@ -233,7 +233,7 @@ static int ramtron_write(struct spi_flash *flash, CMD_RAMTRON_WRITE); } -int ramtron_erase(struct spi_flash *flash, u32 offset, size_t len) +static int ramtron_erase(struct spi_flash *flash, u32 offset, size_t len) { debug("SF: Erase of RAMTRON FRAMs is pointless\n"); return -1; @@ -312,8 +312,5 @@ found: sn->flash.erase = ramtron_erase; sn->flash.size = params->size; - printf("SF: Detected %s with size ", params->name); - print_size(sn->flash.size, "\n"); - return &sn->flash; } diff --git a/drivers/mtd/spi/spansion.c b/drivers/mtd/spi/spansion.c index d54a5fa..a3401b3 100644 --- a/drivers/mtd/spi/spansion.c +++ b/drivers/mtd/spi/spansion.c @@ -196,12 +196,9 @@ static int spansion_write(struct spi_flash *flash, return ret; } -int spansion_erase(struct spi_flash *flash, u32 offset, size_t len) +static int spansion_erase(struct spi_flash *flash, u32 offset, size_t len) { - struct spansion_spi_flash *spsn = to_spansion_spi_flash(flash); - return spi_flash_cmd_erase(flash, CMD_S25FLXX_SE, - spsn->params->page_size * spsn->params->pages_per_sector, - offset, len); + return spi_flash_cmd_erase(flash, CMD_S25FLXX_SE, offset, len); } struct spi_flash *spi_flash_probe_spansion(struct spi_slave *spi, u8 *idcode) @@ -240,12 +237,8 @@ struct spi_flash *spi_flash_probe_spansion(struct spi_slave *spi, u8 *idcode) spsn->flash.write = spansion_write; spsn->flash.erase = spansion_erase; spsn->flash.read = spi_flash_cmd_read_fast; - spsn->flash.size = params->page_size * params->pages_per_sector - * params->nr_sectors; - - printf("SF: Detected %s with page size %u, total ", - params->name, params->page_size); - print_size(spsn->flash.size, "\n"); + spsn->flash.sector_size = params->page_size * params->pages_per_sector; + spsn->flash.size = spsn->flash.sector_size * params->nr_sectors; return &spsn->flash; } diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c index 5c261f1..c75b716 100644 --- a/drivers/mtd/spi/spi_flash.c +++ b/drivers/mtd/spi/spi_flash.c @@ -131,12 +131,13 @@ int spi_flash_cmd_wait_ready(struct spi_flash *flash, unsigned long timeout) } int spi_flash_cmd_erase(struct spi_flash *flash, u8 erase_cmd, - u32 erase_size, u32 offset, size_t len) + u32 offset, size_t len) { - u32 start, end; + u32 start, end, erase_size; int ret; u8 cmd[4]; + erase_size = flash->sector_size; if (offset % erase_size || len % erase_size) { debug("SF: Erase offset/length not multiple of erase size\n"); return -1; @@ -296,6 +297,10 @@ struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs, goto err_manufacturer_probe; } + printf("SF: Detected %s with page size ", flash->name); + print_size(flash->sector_size, ", total "); + print_size(flash->size, "\n"); + spi_release_bus(spi); return flash; diff --git a/drivers/mtd/spi/spi_flash_internal.h b/drivers/mtd/spi/spi_flash_internal.h index d7bcd6d..fc109ce 100644 --- a/drivers/mtd/spi/spi_flash_internal.h +++ b/drivers/mtd/spi/spi_flash_internal.h @@ -64,7 +64,7 @@ int spi_flash_cmd_wait_ready(struct spi_flash *flash, unsigned long timeout); /* Erase sectors. */ int spi_flash_cmd_erase(struct spi_flash *flash, u8 erase_cmd, - u32 erase_size, u32 offset, size_t len); + u32 offset, size_t len); /* Manufacturer-specific probe functions */ struct spi_flash *spi_flash_probe_spansion(struct spi_slave *spi, u8 *idcode); diff --git a/drivers/mtd/spi/sst.c b/drivers/mtd/spi/sst.c index 792d04d..4dc2db2 100644 --- a/drivers/mtd/spi/sst.c +++ b/drivers/mtd/spi/sst.c @@ -71,6 +71,10 @@ static const struct sst_spi_flash_params sst_spi_flash_table[] = { .nr_sectors = 1024, .name = "SST25VF032B", },{ + .idcode1 = 0x4b, + .nr_sectors = 2048, + .name = "SST25VF064C", + },{ .idcode1 = 0x01, .nr_sectors = 16, .name = "SST25WF512", @@ -199,10 +203,9 @@ sst_write(struct spi_flash *flash, u32 offset, size_t len, const void *buf) return ret; } -int sst_erase(struct spi_flash *flash, u32 offset, size_t len) +static int sst_erase(struct spi_flash *flash, u32 offset, size_t len) { - return spi_flash_cmd_erase(flash, CMD_SST_SE, SST_SECTOR_SIZE, - offset, len); + return spi_flash_cmd_erase(flash, CMD_SST_SE, offset, len); } static int @@ -256,11 +259,9 @@ spi_flash_probe_sst(struct spi_slave *spi, u8 *idcode) stm->flash.write = sst_write; stm->flash.erase = sst_erase; - stm->flash.size = SST_SECTOR_SIZE * params->nr_sectors; - - printf("SF: Detected %s with page size %u, total ", - params->name, SST_SECTOR_SIZE); - print_size(stm->flash.size, "\n"); + stm->flash.read = spi_flash_cmd_read_fast; + stm->flash.sector_size = SST_SECTOR_SIZE; + stm->flash.size = stm->flash.sector_size * params->nr_sectors; /* Flash powers up read-only, so clear BP# bits */ sst_unlock(&stm->flash); diff --git a/drivers/mtd/spi/stmicro.c b/drivers/mtd/spi/stmicro.c index 7ef690d..a1959ca 100644 --- a/drivers/mtd/spi/stmicro.c +++ b/drivers/mtd/spi/stmicro.c @@ -197,12 +197,9 @@ static int stmicro_write(struct spi_flash *flash, return ret; } -int stmicro_erase(struct spi_flash *flash, u32 offset, size_t len) +static int stmicro_erase(struct spi_flash *flash, u32 offset, size_t len) { - struct stmicro_spi_flash *stm = to_stmicro_spi_flash(flash); - return spi_flash_cmd_erase(flash, CMD_M25PXX_SE, - stm->params->page_size * stm->params->pages_per_sector, - offset, len); + return spi_flash_cmd_erase(flash, CMD_M25PXX_SE, offset, len); } struct spi_flash *spi_flash_probe_stmicro(struct spi_slave *spi, u8 * idcode) @@ -249,12 +246,8 @@ struct spi_flash *spi_flash_probe_stmicro(struct spi_slave *spi, u8 * idcode) stm->flash.write = stmicro_write; stm->flash.erase = stmicro_erase; stm->flash.read = spi_flash_cmd_read_fast; - stm->flash.size = params->page_size * params->pages_per_sector - * params->nr_sectors; - - printf("SF: Detected %s with page size %u, total ", - params->name, params->page_size); - print_size(stm->flash.size, "\n"); + stm->flash.sector_size = params->page_size * params->pages_per_sector; + stm->flash.size = stm->flash.sector_size * params->nr_sectors; return &stm->flash; } diff --git a/drivers/mtd/spi/winbond.c b/drivers/mtd/spi/winbond.c index e88802f..e8d30ae 100644 --- a/drivers/mtd/spi/winbond.c +++ b/drivers/mtd/spi/winbond.c @@ -170,12 +170,9 @@ out: return ret; } -int winbond_erase(struct spi_flash *flash, u32 offset, size_t len) +static int winbond_erase(struct spi_flash *flash, u32 offset, size_t len) { - struct winbond_spi_flash *stm = to_winbond_spi_flash(flash); - return spi_flash_cmd_erase(flash, CMD_W25_SE, - (1 << stm->params->l2_page_size) * stm->params->pages_per_sector, - offset, len); + return spi_flash_cmd_erase(flash, CMD_W25_SE, offset, len); } struct spi_flash *spi_flash_probe_winbond(struct spi_slave *spi, u8 *idcode) @@ -213,13 +210,11 @@ struct spi_flash *spi_flash_probe_winbond(struct spi_slave *spi, u8 *idcode) stm->flash.write = winbond_write; stm->flash.erase = winbond_erase; stm->flash.read = spi_flash_cmd_read_fast; + stm->flash.sector_size = (1 << stm->params->l2_page_size) * + stm->params->pages_per_sector; stm->flash.size = page_size * params->pages_per_sector * params->sectors_per_block * params->nr_blocks; - printf("SF: Detected %s with page size %u, total ", - params->name, page_size); - print_size(stm->flash.size, "\n"); - return &stm->flash; } |