drivers/spi/winbond: Improve structure packing
Use bitfields to pack the struct more tightly. Change-Id: If1e7a5a3a9504327f987403ec0a7b79b2383792a Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com> Reviewed-on: https://review.coreboot.org/27815 Reviewed-by: Julius Werner <jwerner@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
parent
4cc0126188
commit
79ab843edf
|
@ -27,111 +27,110 @@
|
||||||
#define CMD_W25_RES 0xab /* Release from DP, and Read Signature */
|
#define CMD_W25_RES 0xab /* Release from DP, and Read Signature */
|
||||||
|
|
||||||
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_shift;
|
||||||
uint8_t l2_page_size;
|
uint8_t pages_per_sector_shift : 4;
|
||||||
uint16_t pages_per_sector;
|
uint8_t sectors_per_block_shift : 4;
|
||||||
uint16_t sectors_per_block;
|
uint8_t nr_blocks_shift;
|
||||||
uint16_t nr_blocks;
|
char name[10];
|
||||||
const char *name;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct winbond_spi_flash_params winbond_spi_flash_table[] = {
|
static const struct winbond_spi_flash_params winbond_spi_flash_table[] = {
|
||||||
{
|
{
|
||||||
.id = 0x3015,
|
.id = 0x3015,
|
||||||
.l2_page_size = 8,
|
.l2_page_size_shift = 8,
|
||||||
.pages_per_sector = 16,
|
.pages_per_sector_shift = 4,
|
||||||
.sectors_per_block = 16,
|
.sectors_per_block_shift = 4,
|
||||||
.nr_blocks = 32,
|
.nr_blocks_shift = 5,
|
||||||
.name = "W25X16",
|
.name = "W25X16",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.id = 0x3016,
|
.id = 0x3016,
|
||||||
.l2_page_size = 8,
|
.l2_page_size_shift = 8,
|
||||||
.pages_per_sector = 16,
|
.pages_per_sector_shift = 4,
|
||||||
.sectors_per_block = 16,
|
.sectors_per_block_shift = 4,
|
||||||
.nr_blocks = 64,
|
.nr_blocks_shift = 6,
|
||||||
.name = "W25X32",
|
.name = "W25X32",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.id = 0x3017,
|
.id = 0x3017,
|
||||||
.l2_page_size = 8,
|
.l2_page_size_shift = 8,
|
||||||
.pages_per_sector = 16,
|
.pages_per_sector_shift = 4,
|
||||||
.sectors_per_block = 16,
|
.sectors_per_block_shift = 4,
|
||||||
.nr_blocks = 128,
|
.nr_blocks_shift = 7,
|
||||||
.name = "W25X64",
|
.name = "W25X64",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.id = 0x4014,
|
.id = 0x4014,
|
||||||
.l2_page_size = 8,
|
.l2_page_size_shift = 8,
|
||||||
.pages_per_sector = 16,
|
.pages_per_sector_shift = 4,
|
||||||
.sectors_per_block = 16,
|
.sectors_per_block_shift = 4,
|
||||||
.nr_blocks = 16,
|
.nr_blocks_shift = 4,
|
||||||
.name = "W25Q80",
|
.name = "W25Q80",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.id = 0x4015,
|
.id = 0x4015,
|
||||||
.l2_page_size = 8,
|
.l2_page_size_shift = 8,
|
||||||
.pages_per_sector = 16,
|
.pages_per_sector_shift = 4,
|
||||||
.sectors_per_block = 16,
|
.sectors_per_block_shift = 4,
|
||||||
.nr_blocks = 32,
|
.nr_blocks_shift = 5,
|
||||||
.name = "W25Q16",
|
.name = "W25Q16",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.id = 0x4016,
|
.id = 0x4016,
|
||||||
.l2_page_size = 8,
|
.l2_page_size_shift = 8,
|
||||||
.pages_per_sector = 16,
|
.pages_per_sector_shift = 4,
|
||||||
.sectors_per_block = 16,
|
.sectors_per_block_shift = 4,
|
||||||
.nr_blocks = 64,
|
.nr_blocks_shift = 6,
|
||||||
.name = "W25Q32",
|
.name = "W25Q32",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.id = 0x6016,
|
.id = 0x6016,
|
||||||
.l2_page_size = 8,
|
.l2_page_size_shift = 8,
|
||||||
.pages_per_sector = 16,
|
.pages_per_sector_shift = 4,
|
||||||
.sectors_per_block = 16,
|
.sectors_per_block_shift = 4,
|
||||||
.nr_blocks = 64,
|
.nr_blocks_shift = 6,
|
||||||
.name = "W25Q32DW",
|
.name = "W25Q32DW",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.id = 0x4017,
|
.id = 0x4017,
|
||||||
.l2_page_size = 8,
|
.l2_page_size_shift = 8,
|
||||||
.pages_per_sector = 16,
|
.pages_per_sector_shift = 4,
|
||||||
.sectors_per_block = 16,
|
.sectors_per_block_shift = 4,
|
||||||
.nr_blocks = 128,
|
.nr_blocks_shift = 7,
|
||||||
.name = "W25Q64",
|
.name = "W25Q64",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.id = 0x6017,
|
.id = 0x6017,
|
||||||
.l2_page_size = 8,
|
.l2_page_size_shift = 8,
|
||||||
.pages_per_sector = 16,
|
.pages_per_sector_shift = 4,
|
||||||
.sectors_per_block = 16,
|
.sectors_per_block_shift = 4,
|
||||||
.nr_blocks = 128,
|
.nr_blocks_shift = 7,
|
||||||
.name = "W25Q64DW",
|
.name = "W25Q64DW",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.id = 0x4018,
|
.id = 0x4018,
|
||||||
.l2_page_size = 8,
|
.l2_page_size_shift = 8,
|
||||||
.pages_per_sector = 16,
|
.pages_per_sector_shift = 4,
|
||||||
.sectors_per_block = 16,
|
.sectors_per_block_shift = 4,
|
||||||
.nr_blocks = 256,
|
.nr_blocks_shift = 8,
|
||||||
.name = "W25Q128",
|
.name = "W25Q128",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.id = 0x6018,
|
.id = 0x6018,
|
||||||
.l2_page_size = 8,
|
.l2_page_size_shift = 8,
|
||||||
.pages_per_sector = 16,
|
.pages_per_sector_shift = 4,
|
||||||
.sectors_per_block = 16,
|
.sectors_per_block_shift = 4,
|
||||||
.nr_blocks = 256,
|
.nr_blocks_shift = 8,
|
||||||
.name = "W25Q128FW",
|
.name = "W25Q128FW",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.id = 0x4019,
|
.id = 0x4019,
|
||||||
.l2_page_size = 8,
|
.l2_page_size_shift = 8,
|
||||||
.pages_per_sector = 16,
|
.pages_per_sector_shift = 4,
|
||||||
.sectors_per_block = 16,
|
.sectors_per_block_shift = 4,
|
||||||
.nr_blocks = 512,
|
.nr_blocks_shift = 9,
|
||||||
.name = "W25Q256",
|
.name = "W25Q256",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -223,11 +222,14 @@ int spi_flash_probe_winbond(const struct spi_slave *spi, u8 *idcode,
|
||||||
|
|
||||||
memcpy(&flash->spi, spi, sizeof(*spi));
|
memcpy(&flash->spi, spi, sizeof(*spi));
|
||||||
flash->name = params->name;
|
flash->name = params->name;
|
||||||
/* Assuming power-of-two page size initially. */
|
|
||||||
flash->page_size = 1 << params->l2_page_size;
|
/* Params are in power-of-two. */
|
||||||
flash->sector_size = flash->page_size * params->pages_per_sector;
|
flash->page_size = 1 << params->l2_page_size_shift;
|
||||||
flash->size = flash->sector_size * params->sectors_per_block *
|
flash->sector_size = flash->page_size *
|
||||||
params->nr_blocks;
|
(1 << params->pages_per_sector_shift);
|
||||||
|
flash->size = flash->sector_size *
|
||||||
|
(1 << params->sectors_per_block_shift) *
|
||||||
|
(1 << params->nr_blocks_shift);
|
||||||
flash->erase_cmd = CMD_W25_SE;
|
flash->erase_cmd = CMD_W25_SE;
|
||||||
flash->status_cmd = CMD_W25_RDSR;
|
flash->status_cmd = CMD_W25_RDSR;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue