drivers/spi: fix flash writes at page boundaries
There was an assumption that all SPI controllers could consume a full page of data to write. However, that assumption doesn't hold when spi_crop_chunk() indicates sizes smaller than page size. If the requested offset isn't page aligned from the start then writes will fail corrupting data since a page boundary isn't honored. The spansion driver needed quite a bit more work to honor the spi_crop_chunk() result. It now mimics the other driver's code. Also, needed to add spi_crop_chunk() to marvell/bg4cd SoC to make google/cosmos build. SPI obviously doesn't work on that platform, but it fixes the build error. Change-Id: I93e24a5a717adcee45a017c164bd960f4592ad50 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: https://review.coreboot.org/17910 Tested-by: build bot (Jenkins) Reviewed-by: Matt DeVillier <matt.devillier@gmail.com> Reviewed-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
This commit is contained in:
		| @@ -91,9 +91,9 @@ static int eon_write(const struct spi_flash *flash, | ||||
| 	u8 cmd[4]; | ||||
|  | ||||
| 	page_size = 1 << eon->params->page_size; | ||||
| 	byte_addr = offset % page_size; | ||||
|  | ||||
| 	for (actual = 0; actual < len; actual += chunk_len) { | ||||
| 		byte_addr = offset % page_size; | ||||
| 		chunk_len = min(len - actual, page_size - byte_addr); | ||||
| 		chunk_len = spi_crop_chunk(sizeof(cmd), chunk_len); | ||||
|  | ||||
| @@ -128,7 +128,6 @@ static int eon_write(const struct spi_flash *flash, | ||||
| 		} | ||||
|  | ||||
| 		offset += chunk_len; | ||||
| 		byte_addr = 0; | ||||
| 	} | ||||
|  | ||||
| #if CONFIG_DEBUG_SPI_FLASH | ||||
|   | ||||
		Reference in New Issue
	
	Block a user