aboutsummaryrefslogtreecommitdiffstats
path: root/dummyflasher.c
diff options
context:
space:
mode:
Diffstat (limited to 'dummyflasher.c')
-rw-r--r--dummyflasher.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/dummyflasher.c b/dummyflasher.c
index 29296865..22b28c45 100644
--- a/dummyflasher.c
+++ b/dummyflasher.c
@@ -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");
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325