mirror of
				https://review.coreboot.org/flashrom.git
				synced 2025-11-04 15:10:39 +01:00 
			
		
		
		
	dummyflasher: Add emulation for Winbond W25Q128FV
Just needed a 16MiB chip. Change-Id: Ic01d45c1f709808404ad53bb31f8b998c6977a9d Signed-off-by: Nico Huber <nico.h@gmx.de> Reviewed-on: https://review.coreboot.org/c/flashrom/+/31011 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Thomas Heijligen <src@posteo.de>
This commit is contained in:
		@@ -43,6 +43,7 @@ enum emu_chip {
 | 
			
		||||
	EMULATE_SST_SST25VF040_REMS,
 | 
			
		||||
	EMULATE_SST_SST25VF032B,
 | 
			
		||||
	EMULATE_MACRONIX_MX25L6436,
 | 
			
		||||
	EMULATE_WINBOND_W25Q128FV,
 | 
			
		||||
};
 | 
			
		||||
static enum emu_chip emu_chip = EMULATE_NONE;
 | 
			
		||||
static char *emu_persistent_image = NULL;
 | 
			
		||||
@@ -331,6 +332,18 @@ int dummy_init(void)
 | 
			
		||||
		msg_pdbg("Emulating Macronix MX25L6436 SPI flash chip (RDID, "
 | 
			
		||||
			 "SFDP)\n");
 | 
			
		||||
	}
 | 
			
		||||
	if (!strcmp(tmp, "W25Q128FV")) {
 | 
			
		||||
		emu_chip = EMULATE_WINBOND_W25Q128FV;
 | 
			
		||||
		emu_chip_size = 16 * 1024 * 1024;
 | 
			
		||||
		emu_max_byteprogram_size = 256;
 | 
			
		||||
		emu_max_aai_size = 0;
 | 
			
		||||
		emu_jedec_se_size = 4 * 1024;
 | 
			
		||||
		emu_jedec_be_52_size = 32 * 1024;
 | 
			
		||||
		emu_jedec_be_d8_size = 64 * 1024;
 | 
			
		||||
		emu_jedec_ce_60_size = emu_chip_size;
 | 
			
		||||
		emu_jedec_ce_c7_size = emu_chip_size;
 | 
			
		||||
		msg_pdbg("Emulating Winbond W25Q128FV SPI flash chip (RDID)\n");
 | 
			
		||||
	}
 | 
			
		||||
#endif
 | 
			
		||||
	if (emu_chip == EMULATE_NONE) {
 | 
			
		||||
		msg_perr("Invalid chip specified for emulation: %s\n", tmp);
 | 
			
		||||
@@ -474,6 +487,7 @@ static int emulate_spi_chip_response(unsigned int writecnt,
 | 
			
		||||
	const unsigned char sst25vf040_rems_response[2] = {0xbf, 0x44};
 | 
			
		||||
	const unsigned char sst25vf032b_rems_response[2] = {0xbf, 0x4a};
 | 
			
		||||
	const unsigned char mx25l6436_rems_response[2] = {0xc2, 0x16};
 | 
			
		||||
	const unsigned char w25q128fv_rems_response[2] = {0xef, 0x17};
 | 
			
		||||
 | 
			
		||||
	if (writecnt == 0) {
 | 
			
		||||
		msg_perr("No command sent to the chip!\n");
 | 
			
		||||
@@ -532,6 +546,10 @@ static int emulate_spi_chip_response(unsigned int writecnt,
 | 
			
		||||
			if (readcnt > 0)
 | 
			
		||||
				memset(readarr, 0x16, readcnt);
 | 
			
		||||
			break;
 | 
			
		||||
		case EMULATE_WINBOND_W25Q128FV:
 | 
			
		||||
			if (readcnt > 0)
 | 
			
		||||
				memset(readarr, 0x17, readcnt);
 | 
			
		||||
			break;
 | 
			
		||||
		default: /* ignore */
 | 
			
		||||
			break;
 | 
			
		||||
		}
 | 
			
		||||
@@ -555,6 +573,10 @@ static int emulate_spi_chip_response(unsigned int writecnt,
 | 
			
		||||
			for (i = 0; i < readcnt; i++)
 | 
			
		||||
				readarr[i] = mx25l6436_rems_response[(offs + i) % 2];
 | 
			
		||||
			break;
 | 
			
		||||
		case EMULATE_WINBOND_W25Q128FV:
 | 
			
		||||
			for (i = 0; i < readcnt; i++)
 | 
			
		||||
				readarr[i] = w25q128fv_rems_response[(offs + i) % 2];
 | 
			
		||||
			break;
 | 
			
		||||
		default: /* ignore */
 | 
			
		||||
			break;
 | 
			
		||||
		}
 | 
			
		||||
@@ -577,6 +599,14 @@ static int emulate_spi_chip_response(unsigned int writecnt,
 | 
			
		||||
			if (readcnt > 2)
 | 
			
		||||
				readarr[2] = 0x17;
 | 
			
		||||
			break;
 | 
			
		||||
		case EMULATE_WINBOND_W25Q128FV:
 | 
			
		||||
			if (readcnt > 0)
 | 
			
		||||
				readarr[0] = 0xef;
 | 
			
		||||
			if (readcnt > 1)
 | 
			
		||||
				readarr[1] = 0x40;
 | 
			
		||||
			if (readcnt > 2)
 | 
			
		||||
				readarr[2] = 0x18;
 | 
			
		||||
			break;
 | 
			
		||||
		default: /* ignore */
 | 
			
		||||
			break;
 | 
			
		||||
		}
 | 
			
		||||
@@ -806,6 +836,7 @@ static int dummy_spi_send_command(struct flashctx *flash, unsigned int writecnt,
 | 
			
		||||
	case EMULATE_SST_SST25VF040_REMS:
 | 
			
		||||
	case EMULATE_SST_SST25VF032B:
 | 
			
		||||
	case EMULATE_MACRONIX_MX25L6436:
 | 
			
		||||
	case EMULATE_WINBOND_W25Q128FV:
 | 
			
		||||
		if (emulate_spi_chip_response(writecnt, readcnt, writearr,
 | 
			
		||||
					      readarr)) {
 | 
			
		||||
			msg_pdbg("Invalid command sent to flash chip!\n");
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user