summaryrefslogtreecommitdiff
path: root/src/drivers/spi/eon.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/drivers/spi/eon.c')
-rw-r--r--src/drivers/spi/eon.c68
1 files changed, 8 insertions, 60 deletions
diff --git a/src/drivers/spi/eon.c b/src/drivers/spi/eon.c
index 3270c39ab5..6d4833ce22 100644
--- a/src/drivers/spi/eon.c
+++ b/src/drivers/spi/eon.c
@@ -60,167 +60,115 @@ static const struct spi_flash_part_id flash_table[] = {
.id = EON_ID_EN25B80,
.name = "EN25B80",
.nr_sectors_shift = 8,
- .sector_size_kib_shift = 2,
},
{
.id = EON_ID_EN25B16,
.name = "EN25B16",
.nr_sectors_shift = 9,
- .sector_size_kib_shift = 2,
},
{
.id = EON_ID_EN25B32,
.name = "EN25B32",
.nr_sectors_shift = 10,
- .sector_size_kib_shift = 2,
},
{
.id = EON_ID_EN25B64,
.name = "EN25B64",
.nr_sectors_shift = 11,
- .sector_size_kib_shift = 2,
},
{
.id = EON_ID_EN25F80,
.name = "EN25F80",
.nr_sectors_shift = 8,
- .sector_size_kib_shift = 2,
},
{
.id = EON_ID_EN25F16,
.name = "EN25F16",
.nr_sectors_shift = 9,
- .sector_size_kib_shift = 2,
},
{
.id = EON_ID_EN25F32,
.name = "EN25F32",
.nr_sectors_shift = 10,
- .sector_size_kib_shift = 2,
},
{
.id = EON_ID_EN25F64,
.name = "EN25F64",
.nr_sectors_shift = 11,
- .sector_size_kib_shift = 2,
},
{
.id = EON_ID_EN25Q80,
.name = "EN25Q80(A)",
.nr_sectors_shift = 8,
- .sector_size_kib_shift = 2,
},
{
.id = EON_ID_EN25Q16,
.name = "EN25Q16(D16)",
.nr_sectors_shift = 9,
- .sector_size_kib_shift = 2,
},
{
.id = EON_ID_EN25Q32,
.name = "EN25Q32(A/B)",
.nr_sectors_shift = 10,
- .sector_size_kib_shift = 2,
},
{
.id = EON_ID_EN25Q64,
.name = "EN25Q64",
.nr_sectors_shift = 11,
- .sector_size_kib_shift = 2,
},
{
.id = EON_ID_EN25Q128,
.name = "EN25Q128",
.nr_sectors_shift = 12,
- .sector_size_kib_shift = 2,
},
{
.id = EON_ID_EN25QH16,
.name = "EN25QH16",
.nr_sectors_shift = 9,
- .sector_size_kib_shift = 2,
},
{
.id = EON_ID_EN25QH32,
.name = "EN25QH32",
.nr_sectors_shift = 10,
- .sector_size_kib_shift = 2,
},
{
.id = EON_ID_EN25QH64,
.name = "EN25QH64",
.nr_sectors_shift = 11,
- .sector_size_kib_shift = 2,
},
{
.id = EON_ID_EN25QH128,
.name = "EN25QH128",
.nr_sectors_shift = 12,
- .sector_size_kib_shift = 2,
},
{
.id = EON_ID_EN25S80,
.name = "EN25S80",
.nr_sectors_shift = 8,
- .sector_size_kib_shift = 2,
},
{
.id = EON_ID_EN25S16,
.name = "EN25S16",
.nr_sectors_shift = 9,
- .sector_size_kib_shift = 2,
},
{
.id = EON_ID_EN25S32,
.name = "EN25S32",
.nr_sectors_shift = 10,
- .sector_size_kib_shift = 2,
},
{
.id = EON_ID_EN25S64,
.name = "EN25S64",
.nr_sectors_shift = 11,
- .sector_size_kib_shift = 2,
},
};
-static const struct spi_flash_ops spi_flash_ops = {
- .read = spi_flash_cmd_read,
- .write = spi_flash_cmd_write_page_program,
- .erase = spi_flash_cmd_erase,
- .status = spi_flash_cmd_status,
+const struct spi_flash_vendor_info spi_flash_eon_vi = {
+ .id = VENDOR_ID_EON,
+ .page_size_shift = 8,
+ .sector_size_kib_shift = 2,
+ .match_id_mask = 0xffff,
+ .ids = flash_table,
+ .nr_part_ids = ARRAY_SIZE(flash_table),
+ .desc = &spi_flash_pp_0x20_sector_desc,
};
-
-int spi_flash_probe_eon(const struct spi_slave *spi, u8 *idcode,
- struct spi_flash *flash)
-{
- const struct spi_flash_part_id *params;
- unsigned int i;
-
- for (i = 0; i < ARRAY_SIZE(flash_table); ++i) {
- params = &flash_table[i];
- if (params->id == ((idcode[1] << 8) | idcode[2]))
- break;
- }
-
- if (i == ARRAY_SIZE(flash_table)) {
- printk(BIOS_WARNING, "SF: Unsupported EON ID %#02x%02x\n",
- idcode[1], idcode[2]);
- return -1;
- }
-
- memcpy(&flash->spi, spi, sizeof(*spi));
-
- flash->name = params->name;
- flash->page_size = 256;
- flash->sector_size = (1U << params->sector_size_kib_shift) * KiB;
- flash->size = flash->sector_size * (1U << params->nr_sectors_shift);
- flash->erase_cmd = CMD_EN25_SE;
- flash->status_cmd = CMD_EN25_RDSR;
- flash->pp_cmd = CMD_EN25_PP;
- flash->wren_cmd = CMD_EN25_WREN;
-
- flash->ops = &spi_flash_ops;
-
- return 0;
-}