summaryrefslogtreecommitdiff
path: root/src/drivers/spi/spi_flash.c
diff options
context:
space:
mode:
authorAaron Durbin <adurbin@chromium.org>2020-01-23 11:45:30 -0700
committerAaron Durbin <adurbin@chromium.org>2020-01-28 14:44:37 +0000
commitfc7b953366b776aa3eaaf0539af06086facda14e (patch)
tree52ae47be248bed559c27128e97a51d24b8d3d3c6 /src/drivers/spi/spi_flash.c
parent98eeb961353d187a26085a07889bd0414cdaa910 (diff)
downloadcoreboot-fc7b953366b776aa3eaaf0539af06086facda14e.tar.xz
drivers/spi/spi_flash: remove spi flash names
The names of each spi flash cause quite a bit of bloat in the text size of each stage/program. Remove the name entirely from spi flash in order to reduce overhead. In order to pack space as closely as possible the previous 32-bit id and mask were split into 2 16-bit ids and masks. On Chrome OS build of Aleena there's a savings of >2.21KiB in each of verstage, romstage, and ramstage. Change-Id: Ie98f7e1c7d116c5d7b4bf78605f62fee89dee0a5 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/38380 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
Diffstat (limited to 'src/drivers/spi/spi_flash.c')
-rw-r--r--src/drivers/spi/spi_flash.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/drivers/spi/spi_flash.c b/src/drivers/spi/spi_flash.c
index 90dd5877ff..51498296d6 100644
--- a/src/drivers/spi/spi_flash.c
+++ b/src/drivers/spi/spi_flash.c
@@ -355,8 +355,7 @@ static int fill_spi_flash(const struct spi_slave *spi, struct spi_flash *flash,
{
memcpy(&flash->spi, spi, sizeof(*spi));
flash->vendor = vi->id;
- flash->model = part->id;
- flash->name = part->name;
+ flash->model = part->id[0];
flash->page_size = 1U << vi->page_size_shift;
flash->sector_size = (1U << vi->sector_size_kib_shift) * KiB;
@@ -379,14 +378,19 @@ static int fill_spi_flash(const struct spi_slave *spi, struct spi_flash *flash,
}
static const struct spi_flash_part_id *find_part(const struct spi_flash_vendor_info *vi,
- uint32_t id)
+ uint16_t id[2])
{
size_t i;
+ const uint16_t lid[2] = {
+ [0] = id[0] & vi->match_id_mask[0],
+ [1] = id[1] & vi->match_id_mask[1],
+ };
+
for (i = 0; i < vi->nr_part_ids; i++) {
const struct spi_flash_part_id *part = &vi->ids[i];
- if (part->id == id)
+ if (part->id[0] == lid[0] && part->id[1] == lid[1])
return part;
}
@@ -394,7 +398,7 @@ static const struct spi_flash_part_id *find_part(const struct spi_flash_vendor_i
}
static int find_match(const struct spi_slave *spi, struct spi_flash *flash,
- uint8_t manuf_id, uint32_t id)
+ uint8_t manuf_id, uint16_t id[2])
{
int i;
@@ -407,7 +411,7 @@ static int find_match(const struct spi_slave *spi, struct spi_flash *flash,
if (manuf_id != vi->id)
continue;
- part = find_part(vi, id & vi->match_id_mask);
+ part = find_part(vi, id);
if (part == NULL)
continue;
@@ -424,7 +428,7 @@ int spi_flash_generic_probe(const struct spi_slave *spi,
int ret, i;
u8 idcode[IDCODE_LEN];
u8 manuf_id;
- u32 id;
+ u16 id[2];
/* Read the ID codes */
ret = spi_flash_cmd(spi, CMD_READ_ID, idcode, sizeof(idcode));
@@ -450,7 +454,8 @@ int spi_flash_generic_probe(const struct spi_slave *spi,
manuf_id = idcode[0];
}
- id = (idcode[3] << 24) | (idcode[4] << 16) | (idcode[1] << 8) | idcode[2];
+ id[0] = (idcode[1] << 8) | idcode[2];
+ id[1] = (idcode[3] << 8) | idcode[4];
return find_match(spi, flash, manuf_id, id);
}
@@ -483,8 +488,8 @@ int spi_flash_probe(unsigned int bus, unsigned int cs, struct spi_flash *flash)
if (flash->flags.dual_spi && spi.ctrlr->xfer_dual)
mode_string = " (Dual SPI mode)";
printk(BIOS_INFO,
- "SF: Detected %s with sector size 0x%x, total 0x%x%s\n",
- flash->name, flash->sector_size, flash->size, mode_string);
+ "SF: Detected %02x %04x with sector size 0x%x, total 0x%x%s\n",
+ flash->vendor, flash->model, flash->sector_size, flash->size, mode_string);
if (bus == CONFIG_BOOT_DEVICE_SPI_FLASH_BUS
&& flash->size != CONFIG_ROM_SIZE) {
printk(BIOS_ERR, "SF size 0x%x does not correspond to"