Jonathon Hall has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/68093 )
Change subject: serprog.c: Replace custom mapper with max_rom_decode ......................................................................
serprog.c: Replace custom mapper with max_rom_decode
serprog's custom mapper is actually a hack to check for a maximum chip size. It would not have actually failed a read/write/erase attempt since mappers are allowed to return NULL, it only printed a warning.
We can't remove custom mappers from SPI masters yet since some still use it, but many of those are not actually needed or could be reworked, so this is one step closer to removing SPI custom mappers.
Change-Id: If8b313708a52813b9354cbf45cb91cdd1fe36b13 Signed-off-by: Jonathon Hall jonathon.hall@puri.sm --- M serprog.c 1 file changed, 28 insertions(+), 17 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/93/68093/1
diff --git a/serprog.c b/serprog.c index a3a3db3..bdcf697 100644 --- a/serprog.c +++ b/serprog.c @@ -438,23 +438,7 @@ return 0; }
-static void *serprog_map(const char *descr, uintptr_t phys_addr, size_t len) -{ - /* Serprog transmits 24 bits only and assumes the underlying implementation handles any remaining bits - * correctly (usually setting them to one either in software (for FWH/LPC) or relying on the fact that - * the hardware observes a subset of the address bits only). Combined with the standard mapping of - * flashrom this creates a 16 MB-wide window just below the 4 GB boundary where serprog can operate (as - * needed for non-SPI chips). Below we make sure that the requested range is within this window. */ - if ((phys_addr & 0xFF000000) == 0xFF000000) { - return (void*)phys_addr; - } - msg_pwarn(MSGHEADER "requested mapping %s is incompatible: 0x%zx bytes at 0x%0*" PRIxPTR ".\n", - descr, len, PRIxPTR_WIDTH, phys_addr); - return NULL; -} - static struct spi_master spi_master_serprog = { - .map_flash_region = serprog_map, .features = SPI_MASTER_4BA, .max_data_read = MAX_DATA_READ_UNLIMITED, .max_data_write = MAX_DATA_WRITE_UNLIMITED, @@ -569,7 +553,6 @@ }
static const struct par_master par_master_serprog = { - .map_flash_region = serprog_map, .chip_readb = serprog_chip_readb, .chip_readw = fallback_chip_readw, .chip_readl = fallback_chip_readl, @@ -928,6 +911,16 @@ sp_streamed_transmit_bytes = 0; sp_opbuf_usage = 0;
+ /* Serprog transmits 24 bits only and assumes the underlying + * implementation handles any remaining bits correctly (usually setting + * them to one either in software (for FWH/LPC) or relying on the fact + * that the hardware observes a subset of the address bits only). Only + * 16MB or smaller chips can be used with serprog. */ + max_rom_decode.parallel = 16 * MiB; + max_rom_decode.lpc = 16 * MiB; + max_rom_decode.fwh = 16 * MiB; + max_rom_decode.spi = 16 * MiB; + if (register_shutdown(serprog_shutdown, NULL)) goto init_err_cleanup_exit; if (serprog_buses_supported & BUS_SPI)