summaryrefslogtreecommitdiff
path: root/src/soc/intel/common/block/fast_spi
diff options
context:
space:
mode:
authorFurquan Shaikh <furquan@chromium.org>2017-05-12 00:19:56 -0700
committerFurquan Shaikh <furquan@google.com>2017-05-19 21:21:30 +0200
commitfc1a123aa7392fe7900b466e6a6f089733fec1ee (patch)
tree9aeca66f20edb1d92aaa751d502134d401a15045 /src/soc/intel/common/block/fast_spi
parentf422fd2c78b8a7ab58e75ba7bd13b0c354a207b8 (diff)
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>
Diffstat (limited to 'src/soc/intel/common/block/fast_spi')
-rw-r--r--src/soc/intel/common/block/fast_spi/fast_spi_flash.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/soc/intel/common/block/fast_spi/fast_spi_flash.c b/src/soc/intel/common/block/fast_spi/fast_spi_flash.c
index d56b33fa15..96a808d423 100644
--- a/src/soc/intel/common/block/fast_spi/fast_spi_flash.c
+++ b/src/soc/intel/common/block/fast_spi/fast_spi_flash.c
@@ -154,12 +154,13 @@ static int exec_sync_hwseq_xfer(struct fast_spi_flash_ctx *ctx,
/*
* Ensure read/write xfer len is not greater than SPIBAR_FDATA_FIFO_SIZE and
- * that the operation does not cross 256-byte boundary.
+ * that the operation does not cross page boundary.
*/
-static size_t get_xfer_len(uint32_t addr, size_t len)
+static size_t get_xfer_len(const struct spi_flash *flash, uint32_t addr,
+ size_t len)
{
size_t xfer_len = min(len, SPIBAR_FDATA_FIFO_SIZE);
- size_t bytes_left = ALIGN_UP(addr, 256) - addr;
+ size_t bytes_left = ALIGN_UP(addr, flash->page_size) - addr;
if (bytes_left)
xfer_len = min(xfer_len, bytes_left);
@@ -217,7 +218,7 @@ static int fast_spi_flash_read(const struct spi_flash *flash,
BOILERPLATE_CREATE_CTX(ctx);
while (len) {
- xfer_len = get_xfer_len(addr, len);
+ xfer_len = get_xfer_len(flash, addr, len);
ret = exec_sync_hwseq_xfer(ctx, SPIBAR_HSFSTS_CYCLE_READ,
addr, xfer_len);
@@ -244,7 +245,7 @@ static int fast_spi_flash_write(const struct spi_flash *flash,
BOILERPLATE_CREATE_CTX(ctx);
while (len) {
- xfer_len = get_xfer_len(addr, len);
+ xfer_len = get_xfer_len(flash, addr, len);
fill_xfer_fifo(ctx, data, xfer_len);
ret = exec_sync_hwseq_xfer(ctx, SPIBAR_HSFSTS_CYCLE_WRITE,
@@ -303,6 +304,7 @@ struct spi_flash *spi_flash_programmer_probe(struct spi_slave *dev, int force)
/* Can erase both 4 KiB and 64 KiB chunks. Declare the smaller size. */
flash->sector_size = 4 * KiB;
+ flash->page_size = 256;
/*
* FIXME: Get erase+cmd, and status_cmd from SFDP.
*