drivers/spi/spi_flash: Add page_size to struct spi_flash
Add a new member page_size to spi_flash structure so that the various spi flash drivers can store this info in spi_flash along with the other sizes (sector size and total size) during flash probe. This removes the need to have {driver}_spi_flash structure in every spi flash driver. This is part of patch series to clean up the SPI flash and SPI driver interface. BUG=b:38330715 Change-Id: I0f83e52cb1041432b0b575a8ee3bd173cc038d1f Signed-off-by: Furquan Shaikh <furquan@chromium.org> Reviewed-on: https://review.coreboot.org/19704 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
committed by
Furquan Shaikh
parent
f422fd2c78
commit
fc1a123aa7
@ -47,11 +47,6 @@ struct sst_spi_flash_params {
|
||||
size_t len, const void *buf);
|
||||
};
|
||||
|
||||
struct sst_spi_flash {
|
||||
struct spi_flash flash;
|
||||
const struct sst_spi_flash_params *params;
|
||||
};
|
||||
|
||||
static int sst_write_ai(const struct spi_flash *flash, u32 offset, size_t len,
|
||||
const void *buf);
|
||||
static int sst_write_256(const struct spi_flash *flash, u32 offset, size_t len,
|
||||
@ -323,7 +318,7 @@ struct spi_flash *
|
||||
spi_flash_probe_sst(struct spi_slave *spi, u8 *idcode)
|
||||
{
|
||||
const struct sst_spi_flash_params *params;
|
||||
struct sst_spi_flash *stm;
|
||||
struct spi_flash *flash;
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(sst_spi_flash_table); ++i) {
|
||||
@ -337,27 +332,26 @@ spi_flash_probe_sst(struct spi_slave *spi, u8 *idcode)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
stm = malloc(sizeof(*stm));
|
||||
if (!stm) {
|
||||
flash = malloc(sizeof(*flash));
|
||||
if (!flash) {
|
||||
printk(BIOS_WARNING, "SF: Failed to allocate memory\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
stm->params = params;
|
||||
memcpy(&stm->flash.spi, spi, sizeof(*spi));
|
||||
stm->flash.name = params->name;
|
||||
memcpy(&flash->spi, spi, sizeof(*spi));
|
||||
flash->name = params->name;
|
||||
flash->sector_size = SST_SECTOR_SIZE;
|
||||
flash->size = flash->sector_size * params->nr_sectors;
|
||||
flash->erase_cmd = CMD_SST_SE;
|
||||
flash->status_cmd = CMD_SST_RDSR;
|
||||
|
||||
stm->flash.internal_write = params->write;
|
||||
stm->flash.internal_erase = spi_flash_cmd_erase;
|
||||
stm->flash.internal_status = spi_flash_cmd_status;
|
||||
stm->flash.internal_read = spi_flash_cmd_read_fast;
|
||||
stm->flash.sector_size = SST_SECTOR_SIZE;
|
||||
stm->flash.size = stm->flash.sector_size * params->nr_sectors;
|
||||
stm->flash.erase_cmd = CMD_SST_SE;
|
||||
stm->flash.status_cmd = CMD_SST_RDSR;
|
||||
flash->internal_write = params->write;
|
||||
flash->internal_erase = spi_flash_cmd_erase;
|
||||
flash->internal_status = spi_flash_cmd_status;
|
||||
flash->internal_read = spi_flash_cmd_read_fast;
|
||||
|
||||
/* Flash powers up read-only, so clear BP# bits */
|
||||
sst_unlock(&stm->flash);
|
||||
sst_unlock(flash);
|
||||
|
||||
return &stm->flash;
|
||||
return flash;
|
||||
}
|
||||
|
Reference in New Issue
Block a user