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>
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 d56b33f..96a808d 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 @@
 
 /*
  * 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 @@
 	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 @@
 	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 @@
 
 	/* 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.
 	 *