drivers/spi/spi_flash: remove continuation byte support

There was code to handle the case of continuation bytes for identifying
the manufacturer id to a jedec rdid command. However, all the parts that
currently supported have this defined to be 0. Remove the unused
continuation byte support.

Change-Id: Ia7c63162e4ef9dc46ef916ca8c31ebd721cbeca7
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/38361
Reviewed-by: Julius Werner <jwerner@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Aaron Durbin 2020-01-11 09:59:32 -07:00
parent 1bfa2c79f8
commit ae43f32458
1 changed files with 24 additions and 40 deletions

View File

@ -312,73 +312,61 @@ out:
/* /*
* The following table holds all device probe functions * The following table holds all device probe functions
* *
* shift: number of continuation bytes before the ID * idcode: the expected IDCODE
* idcode: the expected IDCODE or 0xff for non JEDEC devices
* probe: the function to call * probe: the function to call
* *
* Non JEDEC devices should be ordered in the table such that
* the probe functions with best detection algorithms come first.
*
* Several matching entries are permitted, they will be tried * Several matching entries are permitted, they will be tried
* in sequence until a probe function returns non NULL. * in sequence until a probe function returns non NULL.
* *
* IDCODE_CONT_LEN may be redefined if a device needs to declare a
* larger "shift" value. IDCODE_PART_LEN generally shouldn't be
* changed. This is the max number of bytes probe functions may
* examine when looking up part-specific identification info.
*
* Probe functions will be given the idcode buffer starting at their * Probe functions will be given the idcode buffer starting at their
* manu id byte (the "idcode" in the table below). In other words, * manu id byte (the "idcode" in the table below).
* all of the continuation bytes will be skipped (the "shift" below).
*/ */
#define IDCODE_CONT_LEN 0
#define IDCODE_PART_LEN 5
static struct { static struct {
const u8 shift;
const u8 idcode; const u8 idcode;
int (*probe) (const struct spi_slave *spi, u8 *idcode, int (*probe) (const struct spi_slave *spi, u8 *idcode,
struct spi_flash *flash); struct spi_flash *flash);
} flashes[] = { } flashes[] = {
/* Keep it sorted by define name */ /* Keep it sorted by define name */
#if CONFIG(SPI_FLASH_AMIC) #if CONFIG(SPI_FLASH_AMIC)
{ 0, VENDOR_ID_AMIC, spi_flash_probe_amic, }, { VENDOR_ID_AMIC, spi_flash_probe_amic, },
#endif #endif
#if CONFIG(SPI_FLASH_ATMEL) #if CONFIG(SPI_FLASH_ATMEL)
{ 0, VENDOR_ID_ATMEL, spi_flash_probe_atmel, }, { VENDOR_ID_ATMEL, spi_flash_probe_atmel, },
#endif #endif
#if CONFIG(SPI_FLASH_EON) #if CONFIG(SPI_FLASH_EON)
{ 0, VENDOR_ID_EON, spi_flash_probe_eon, }, { VENDOR_ID_EON, spi_flash_probe_eon, },
#endif #endif
#if CONFIG(SPI_FLASH_GIGADEVICE) #if CONFIG(SPI_FLASH_GIGADEVICE)
{ 0, VENDOR_ID_GIGADEVICE, spi_flash_probe_gigadevice, }, { VENDOR_ID_GIGADEVICE, spi_flash_probe_gigadevice, },
#endif #endif
#if CONFIG(SPI_FLASH_MACRONIX) #if CONFIG(SPI_FLASH_MACRONIX)
{ 0, VENDOR_ID_MACRONIX, spi_flash_probe_macronix, }, { VENDOR_ID_MACRONIX, spi_flash_probe_macronix, },
#endif #endif
#if CONFIG(SPI_FLASH_SPANSION) #if CONFIG(SPI_FLASH_SPANSION)
{ 0, VENDOR_ID_SPANSION, spi_flash_probe_spansion, }, { VENDOR_ID_SPANSION, spi_flash_probe_spansion, },
#endif #endif
#if CONFIG(SPI_FLASH_SST) #if CONFIG(SPI_FLASH_SST)
{ 0, VENDOR_ID_SST, spi_flash_probe_sst, }, { VENDOR_ID_SST, spi_flash_probe_sst, },
#endif #endif
#if CONFIG(SPI_FLASH_STMICRO) #if CONFIG(SPI_FLASH_STMICRO)
{ 0, VENDOR_ID_STMICRO, spi_flash_probe_stmicro, }, { VENDOR_ID_STMICRO, spi_flash_probe_stmicro, },
#endif #endif
#if CONFIG(SPI_FLASH_WINBOND) #if CONFIG(SPI_FLASH_WINBOND)
{ 0, VENDOR_ID_WINBOND, spi_flash_probe_winbond, }, { VENDOR_ID_WINBOND, spi_flash_probe_winbond, },
#endif #endif
/* Keep it sorted by best detection */ /* Keep it sorted by best detection */
#if CONFIG(SPI_FLASH_ADESTO) #if CONFIG(SPI_FLASH_ADESTO)
{ 0, VENDOR_ID_ADESTO, spi_flash_probe_adesto, }, { VENDOR_ID_ADESTO, spi_flash_probe_adesto, },
#endif #endif
}; };
#define IDCODE_LEN (IDCODE_CONT_LEN + IDCODE_PART_LEN) #define IDCODE_LEN 5
int spi_flash_generic_probe(const struct spi_slave *spi, int spi_flash_generic_probe(const struct spi_slave *spi,
struct spi_flash *flash) struct spi_flash *flash)
{ {
int ret, i, shift; int ret, i;
u8 idcode[IDCODE_LEN], *idp; u8 idcode[IDCODE_LEN];
u8 manuf_id;
/* Read the ID codes */ /* Read the ID codes */
ret = spi_flash_cmd(spi, CMD_READ_ID, idcode, sizeof(idcode)); ret = spi_flash_cmd(spi, CMD_READ_ID, idcode, sizeof(idcode));
@ -392,29 +380,25 @@ int spi_flash_generic_probe(const struct spi_slave *spi,
printk(BIOS_SPEW, "\n"); printk(BIOS_SPEW, "\n");
} }
/* count the number of continuation bytes */ manuf_id = idcode[0];
for (shift = 0, idp = idcode; shift < IDCODE_CONT_LEN && *idp == 0x7f;
++shift, ++idp)
continue;
printk(BIOS_INFO, "Manufacturer: %02x\n", *idp); printk(BIOS_INFO, "Manufacturer: %02x\n", manuf_id);
/* If no result from RDID command and STMicro parts are enabled attempt /* If no result from RDID command and STMicro parts are enabled attempt
to wake the part from deep sleep and obtain alternative id info. */ to wake the part from deep sleep and obtain alternative id info. */
if (CONFIG(SPI_FLASH_STMICRO) && *idp == 0xff) { if (CONFIG(SPI_FLASH_STMICRO) && manuf_id == 0xff) {
if (stmicro_release_deep_sleep_identify(spi, idcode)) if (stmicro_release_deep_sleep_identify(spi, idcode))
return -1; return -1;
idp = idcode; manuf_id = idcode[0];
shift = 0;
} }
/* search the table for matches in shift and id */ /* search the table for matches in shift and id */
for (i = 0; i < (int)ARRAY_SIZE(flashes); ++i) for (i = 0; i < (int)ARRAY_SIZE(flashes); ++i)
if (flashes[i].shift == shift && flashes[i].idcode == *idp) { if (flashes[i].idcode == manuf_id) {
/* we have a match, call probe */ /* we have a match, call probe */
if (flashes[i].probe(spi, idp, flash) == 0) { if (flashes[i].probe(spi, idcode, flash) == 0) {
flash->vendor = idp[0]; flash->vendor = idcode[0];
flash->model = (idp[1] << 8) | idp[2]; flash->model = (idcode[1] << 8) | idcode[2];
return 0; return 0;
} }
} }