sf: inline data constants

I imagine much of these constants are due to copy & pasting previous
drivers rather than an actual reflection of the hardware layout.  At
any rate, inline the info that we don't care about externally as it
shrinks things nicely.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
master
Mike Frysinger 13 years ago
parent b98b611502
commit a4ed3b6531
  1. 19
      drivers/mtd/spi/eon.c
  2. 29
      drivers/mtd/spi/macronix.c
  3. 13
      drivers/mtd/spi/spansion.c
  4. 13
      drivers/mtd/spi/stmicro.c
  5. 43
      drivers/mtd/spi/winbond.c

@ -16,9 +16,6 @@
struct eon_spi_flash_params { struct eon_spi_flash_params {
u8 idcode1; u8 idcode1;
u16 page_size;
u16 pages_per_sector;
u16 sectors_per_block;
u16 nr_sectors; u16 nr_sectors;
const char *name; const char *name;
}; };
@ -26,25 +23,16 @@ struct eon_spi_flash_params {
static const struct eon_spi_flash_params eon_spi_flash_table[] = { static const struct eon_spi_flash_params eon_spi_flash_table[] = {
{ {
.idcode1 = 0x16, .idcode1 = 0x16,
.page_size = 256,
.pages_per_sector = 16,
.sectors_per_block = 16,
.nr_sectors = 1024, .nr_sectors = 1024,
.name = "EN25Q32B", .name = "EN25Q32B",
}, },
{ {
.idcode1 = 0x18, .idcode1 = 0x18,
.page_size = 256,
.pages_per_sector = 16,
.sectors_per_block = 16,
.nr_sectors = 4096, .nr_sectors = 4096,
.name = "EN25Q128", .name = "EN25Q128",
}, },
{ {
.idcode1 = 0x16, .idcode1 = 0x16,
.page_size = 256,
.pages_per_sector = 16,
.sectors_per_block = 16,
.nr_sectors = 1024, .nr_sectors = 1024,
.name = "EN25Q32B", .name = "EN25Q32B",
}, },
@ -84,10 +72,9 @@ struct spi_flash *spi_flash_probe_eon(struct spi_slave *spi, u8 *idcode)
flash->write = spi_flash_cmd_write_multi; flash->write = spi_flash_cmd_write_multi;
flash->erase = eon_erase; flash->erase = eon_erase;
flash->read = spi_flash_cmd_read_fast; flash->read = spi_flash_cmd_read_fast;
flash->page_size = params->page_size; flash->page_size = 256;
flash->sector_size = params->page_size * params->pages_per_sector flash->sector_size = 256 * 16 * 16;
* params->sectors_per_block; flash->size = 256 * 16
flash->size = params->page_size * params->pages_per_sector
* params->nr_sectors; * params->nr_sectors;
return flash; return flash;

@ -42,9 +42,6 @@
struct macronix_spi_flash_params { struct macronix_spi_flash_params {
u16 idcode; u16 idcode;
u16 page_size;
u16 pages_per_sector;
u16 sectors_per_block;
u16 nr_blocks; u16 nr_blocks;
const char *name; const char *name;
}; };
@ -52,57 +49,36 @@ struct macronix_spi_flash_params {
static const struct macronix_spi_flash_params macronix_spi_flash_table[] = { static const struct macronix_spi_flash_params macronix_spi_flash_table[] = {
{ {
.idcode = 0x2013, .idcode = 0x2013,
.page_size = 256,
.pages_per_sector = 16,
.sectors_per_block = 16,
.nr_blocks = 8, .nr_blocks = 8,
.name = "MX25L4005", .name = "MX25L4005",
}, },
{ {
.idcode = 0x2014, .idcode = 0x2014,
.page_size = 256,
.pages_per_sector = 16,
.sectors_per_block = 16,
.nr_blocks = 16, .nr_blocks = 16,
.name = "MX25L8005", .name = "MX25L8005",
}, },
{ {
.idcode = 0x2015, .idcode = 0x2015,
.page_size = 256,
.pages_per_sector = 16,
.sectors_per_block = 16,
.nr_blocks = 32, .nr_blocks = 32,
.name = "MX25L1605D", .name = "MX25L1605D",
}, },
{ {
.idcode = 0x2016, .idcode = 0x2016,
.page_size = 256,
.pages_per_sector = 16,
.sectors_per_block = 16,
.nr_blocks = 64, .nr_blocks = 64,
.name = "MX25L3205D", .name = "MX25L3205D",
}, },
{ {
.idcode = 0x2017, .idcode = 0x2017,
.page_size = 256,
.pages_per_sector = 16,
.sectors_per_block = 16,
.nr_blocks = 128, .nr_blocks = 128,
.name = "MX25L6405D", .name = "MX25L6405D",
}, },
{ {
.idcode = 0x2018, .idcode = 0x2018,
.page_size = 256,
.pages_per_sector = 16,
.sectors_per_block = 16,
.nr_blocks = 256, .nr_blocks = 256,
.name = "MX25L12805D", .name = "MX25L12805D",
}, },
{ {
.idcode = 0x2618, .idcode = 0x2618,
.page_size = 256,
.pages_per_sector = 16,
.sectors_per_block = 16,
.nr_blocks = 256, .nr_blocks = 256,
.name = "MX25L12855E", .name = "MX25L12855E",
}, },
@ -182,9 +158,8 @@ struct spi_flash *spi_flash_probe_macronix(struct spi_slave *spi, u8 *idcode)
flash->write = spi_flash_cmd_write_multi; flash->write = spi_flash_cmd_write_multi;
flash->erase = macronix_erase; flash->erase = macronix_erase;
flash->read = spi_flash_cmd_read_fast; flash->read = spi_flash_cmd_read_fast;
flash->page_size = params->page_size; flash->page_size = 256;
flash->sector_size = params->page_size * params->pages_per_sector flash->sector_size = 256 * 16 * 16;
* params->sectors_per_block;
flash->size = flash->sector_size * params->nr_blocks; flash->size = flash->sector_size * params->nr_blocks;
/* Clear BP# bits for read-only flash */ /* Clear BP# bits for read-only flash */

@ -38,7 +38,6 @@
struct spansion_spi_flash_params { struct spansion_spi_flash_params {
u16 idcode1; u16 idcode1;
u16 idcode2; u16 idcode2;
u16 page_size;
u16 pages_per_sector; u16 pages_per_sector;
u16 nr_sectors; u16 nr_sectors;
const char *name; const char *name;
@ -48,7 +47,6 @@ static const struct spansion_spi_flash_params spansion_spi_flash_table[] = {
{ {
.idcode1 = 0x0213, .idcode1 = 0x0213,
.idcode2 = 0, .idcode2 = 0,
.page_size = 256,
.pages_per_sector = 256, .pages_per_sector = 256,
.nr_sectors = 16, .nr_sectors = 16,
.name = "S25FL008A", .name = "S25FL008A",
@ -56,7 +54,6 @@ static const struct spansion_spi_flash_params spansion_spi_flash_table[] = {
{ {
.idcode1 = 0x0214, .idcode1 = 0x0214,
.idcode2 = 0, .idcode2 = 0,
.page_size = 256,
.pages_per_sector = 256, .pages_per_sector = 256,
.nr_sectors = 32, .nr_sectors = 32,
.name = "S25FL016A", .name = "S25FL016A",
@ -64,7 +61,6 @@ static const struct spansion_spi_flash_params spansion_spi_flash_table[] = {
{ {
.idcode1 = 0x0215, .idcode1 = 0x0215,
.idcode2 = 0, .idcode2 = 0,
.page_size = 256,
.pages_per_sector = 256, .pages_per_sector = 256,
.nr_sectors = 64, .nr_sectors = 64,
.name = "S25FL032A", .name = "S25FL032A",
@ -72,7 +68,6 @@ static const struct spansion_spi_flash_params spansion_spi_flash_table[] = {
{ {
.idcode1 = 0x0216, .idcode1 = 0x0216,
.idcode2 = 0, .idcode2 = 0,
.page_size = 256,
.pages_per_sector = 256, .pages_per_sector = 256,
.nr_sectors = 128, .nr_sectors = 128,
.name = "S25FL064A", .name = "S25FL064A",
@ -80,7 +75,6 @@ static const struct spansion_spi_flash_params spansion_spi_flash_table[] = {
{ {
.idcode1 = 0x2018, .idcode1 = 0x2018,
.idcode2 = 0x0301, .idcode2 = 0x0301,
.page_size = 256,
.pages_per_sector = 256, .pages_per_sector = 256,
.nr_sectors = 256, .nr_sectors = 256,
.name = "S25FL128P_64K", .name = "S25FL128P_64K",
@ -88,7 +82,6 @@ static const struct spansion_spi_flash_params spansion_spi_flash_table[] = {
{ {
.idcode1 = 0x2018, .idcode1 = 0x2018,
.idcode2 = 0x0300, .idcode2 = 0x0300,
.page_size = 256,
.pages_per_sector = 1024, .pages_per_sector = 1024,
.nr_sectors = 64, .nr_sectors = 64,
.name = "S25FL128P_256K", .name = "S25FL128P_256K",
@ -96,7 +89,6 @@ static const struct spansion_spi_flash_params spansion_spi_flash_table[] = {
{ {
.idcode1 = 0x0215, .idcode1 = 0x0215,
.idcode2 = 0x4d00, .idcode2 = 0x4d00,
.page_size = 256,
.pages_per_sector = 256, .pages_per_sector = 256,
.nr_sectors = 64, .nr_sectors = 64,
.name = "S25FL032P", .name = "S25FL032P",
@ -104,7 +96,6 @@ static const struct spansion_spi_flash_params spansion_spi_flash_table[] = {
{ {
.idcode1 = 0x2018, .idcode1 = 0x2018,
.idcode2 = 0x4d01, .idcode2 = 0x4d01,
.page_size = 256,
.pages_per_sector = 256, .pages_per_sector = 256,
.nr_sectors = 256, .nr_sectors = 256,
.name = "S25FL129P_64K", .name = "S25FL129P_64K",
@ -151,8 +142,8 @@ struct spi_flash *spi_flash_probe_spansion(struct spi_slave *spi, u8 *idcode)
flash->write = spi_flash_cmd_write_multi; flash->write = spi_flash_cmd_write_multi;
flash->erase = spansion_erase; flash->erase = spansion_erase;
flash->read = spi_flash_cmd_read_fast; flash->read = spi_flash_cmd_read_fast;
flash->page_size = params->page_size; flash->page_size = 256;
flash->sector_size = params->page_size * params->pages_per_sector; flash->sector_size = 256 * params->pages_per_sector;
flash->size = flash->sector_size * params->nr_sectors; flash->size = flash->sector_size * params->nr_sectors;
return flash; return flash;

@ -40,7 +40,6 @@
struct stmicro_spi_flash_params { struct stmicro_spi_flash_params {
u8 idcode1; u8 idcode1;
u16 page_size;
u16 pages_per_sector; u16 pages_per_sector;
u16 nr_sectors; u16 nr_sectors;
const char *name; const char *name;
@ -49,56 +48,48 @@ struct stmicro_spi_flash_params {
static const struct stmicro_spi_flash_params stmicro_spi_flash_table[] = { static const struct stmicro_spi_flash_params stmicro_spi_flash_table[] = {
{ {
.idcode1 = 0x11, .idcode1 = 0x11,
.page_size = 256,
.pages_per_sector = 128, .pages_per_sector = 128,
.nr_sectors = 4, .nr_sectors = 4,
.name = "M25P10", .name = "M25P10",
}, },
{ {
.idcode1 = 0x15, .idcode1 = 0x15,
.page_size = 256,
.pages_per_sector = 256, .pages_per_sector = 256,
.nr_sectors = 32, .nr_sectors = 32,
.name = "M25P16", .name = "M25P16",
}, },
{ {
.idcode1 = 0x12, .idcode1 = 0x12,
.page_size = 256,
.pages_per_sector = 256, .pages_per_sector = 256,
.nr_sectors = 4, .nr_sectors = 4,
.name = "M25P20", .name = "M25P20",
}, },
{ {
.idcode1 = 0x16, .idcode1 = 0x16,
.page_size = 256,
.pages_per_sector = 256, .pages_per_sector = 256,
.nr_sectors = 64, .nr_sectors = 64,
.name = "M25P32", .name = "M25P32",
}, },
{ {
.idcode1 = 0x13, .idcode1 = 0x13,
.page_size = 256,
.pages_per_sector = 256, .pages_per_sector = 256,
.nr_sectors = 8, .nr_sectors = 8,
.name = "M25P40", .name = "M25P40",
}, },
{ {
.idcode1 = 0x17, .idcode1 = 0x17,
.page_size = 256,
.pages_per_sector = 256, .pages_per_sector = 256,
.nr_sectors = 128, .nr_sectors = 128,
.name = "M25P64", .name = "M25P64",
}, },
{ {
.idcode1 = 0x14, .idcode1 = 0x14,
.page_size = 256,
.pages_per_sector = 256, .pages_per_sector = 256,
.nr_sectors = 16, .nr_sectors = 16,
.name = "M25P80", .name = "M25P80",
}, },
{ {
.idcode1 = 0x18, .idcode1 = 0x18,
.page_size = 256,
.pages_per_sector = 1024, .pages_per_sector = 1024,
.nr_sectors = 64, .nr_sectors = 64,
.name = "M25P128", .name = "M25P128",
@ -153,8 +144,8 @@ struct spi_flash *spi_flash_probe_stmicro(struct spi_slave *spi, u8 * idcode)
flash->write = spi_flash_cmd_write_multi; flash->write = spi_flash_cmd_write_multi;
flash->erase = stmicro_erase; flash->erase = stmicro_erase;
flash->read = spi_flash_cmd_read_fast; flash->read = spi_flash_cmd_read_fast;
flash->page_size = params->page_size; flash->page_size = 256;
flash->sector_size = params->page_size * params->pages_per_sector; flash->sector_size = 256 * params->pages_per_sector;
flash->size = flash->sector_size * params->nr_sectors; flash->size = flash->sector_size * params->nr_sectors;
return flash; return flash;

@ -17,10 +17,6 @@
struct winbond_spi_flash_params { struct winbond_spi_flash_params {
uint16_t id; uint16_t id;
/* Log2 of page size in power-of-two mode */
uint8_t l2_page_size;
uint16_t pages_per_sector;
uint16_t sectors_per_block;
uint16_t nr_blocks; uint16_t nr_blocks;
const char *name; const char *name;
}; };
@ -28,73 +24,46 @@ struct winbond_spi_flash_params {
static const struct winbond_spi_flash_params winbond_spi_flash_table[] = { static const struct winbond_spi_flash_params winbond_spi_flash_table[] = {
{ {
.id = 0x3013, .id = 0x3013,
.l2_page_size = 8,
.pages_per_sector = 16,
.sectors_per_block = 16,
.nr_blocks = 8, .nr_blocks = 8,
.name = "W25X40", .name = "W25X40",
}, },
{ {
.id = 0x3015, .id = 0x3015,
.l2_page_size = 8,
.pages_per_sector = 16,
.sectors_per_block = 16,
.nr_blocks = 32, .nr_blocks = 32,
.name = "W25X16", .name = "W25X16",
}, },
{ {
.id = 0x3016, .id = 0x3016,
.l2_page_size = 8,
.pages_per_sector = 16,
.sectors_per_block = 16,
.nr_blocks = 64, .nr_blocks = 64,
.name = "W25X32", .name = "W25X32",
}, },
{ {
.id = 0x3017, .id = 0x3017,
.l2_page_size = 8,
.pages_per_sector = 16,
.sectors_per_block = 16,
.nr_blocks = 128, .nr_blocks = 128,
.name = "W25X64", .name = "W25X64",
}, },
{ {
.id = 0x4014, .id = 0x4014,
.l2_page_size = 8,
.pages_per_sector = 16,
.sectors_per_block = 16,
.nr_blocks = 16, .nr_blocks = 16,
.name = "W25Q80BL", .name = "W25Q80BL",
}, },
{ {
.id = 0x4015, .id = 0x4015,
.l2_page_size = 8,
.pages_per_sector = 16,
.sectors_per_block = 16,
.nr_blocks = 32, .nr_blocks = 32,
.name = "W25Q16", .name = "W25Q16",
}, },
{ {
.id = 0x4016, .id = 0x4016,
.l2_page_size = 8,
.pages_per_sector = 16,
.sectors_per_block = 16,
.nr_blocks = 64, .nr_blocks = 64,
.name = "W25Q32", .name = "W25Q32",
}, },
{ {
.id = 0x4017, .id = 0x4017,
.l2_page_size = 8,
.pages_per_sector = 16,
.sectors_per_block = 16,
.nr_blocks = 128, .nr_blocks = 128,
.name = "W25Q64", .name = "W25Q64",
}, },
{ {
.id = 0x4018, .id = 0x4018,
.l2_page_size = 8,
.pages_per_sector = 16,
.sectors_per_block = 16,
.nr_blocks = 256, .nr_blocks = 256,
.name = "W25Q128", .name = "W25Q128",
}, },
@ -110,7 +79,6 @@ struct spi_flash *spi_flash_probe_winbond(struct spi_slave *spi, u8 *idcode)
const struct winbond_spi_flash_params *params; const struct winbond_spi_flash_params *params;
struct spi_flash *flash; struct spi_flash *flash;
unsigned int i; unsigned int i;
unsigned page_size;
for (i = 0; i < ARRAY_SIZE(winbond_spi_flash_table); i++) { for (i = 0; i < ARRAY_SIZE(winbond_spi_flash_table); i++) {
params = &winbond_spi_flash_table[i]; params = &winbond_spi_flash_table[i];
@ -133,17 +101,12 @@ struct spi_flash *spi_flash_probe_winbond(struct spi_slave *spi, u8 *idcode)
flash->spi = spi; flash->spi = spi;
flash->name = params->name; flash->name = params->name;
/* Assuming power-of-two page size initially. */
page_size = 1 << params->l2_page_size;
flash->write = spi_flash_cmd_write_multi; flash->write = spi_flash_cmd_write_multi;
flash->erase = winbond_erase; flash->erase = winbond_erase;
flash->read = spi_flash_cmd_read_fast; flash->read = spi_flash_cmd_read_fast;
flash->page_size = page_size; flash->page_size = 4096;
flash->sector_size = page_size * params->pages_per_sector; flash->sector_size = 4096;
flash->size = page_size * params->pages_per_sector flash->size = 4096 * 16 * params->nr_blocks;
* params->sectors_per_block
* params->nr_blocks;
return flash; return flash;
} }

Loading…
Cancel
Save