comparison loadtools/flamdsec.c @ 993:84c9869a3659

flash PPB erase: make internal API more consistent
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 03 Dec 2023 04:58:50 +0000
parents 0407d14fb854
children ad3041e19884
comparison
equal deleted inserted replaced
992:c4c400c1b10c 993:84c9869a3659
332 } 332 }
333 fprintf(stderr, "PPB erase cycle FAILED, tried %u pulses\n", pulsecnt); 333 fprintf(stderr, "PPB erase cycle FAILED, tried %u pulses\n", pulsecnt);
334 return(-1); 334 return(-1);
335 } 335 }
336 336
337 plj_ppb_erase_all_single(bank, raw_mode) 337 plj_ppb_erase_all_single(bi, raw_mode)
338 { 338 struct flash_bank_info *bi;
339 struct flash_bank_info *bi = flash_bank_info + bank; 339 {
340 unsigned pulsecnt; 340 unsigned pulsecnt;
341 uint16_t stat; 341 uint16_t stat;
342 int rc; 342 int rc;
343 343
344 if (raw_mode) 344 if (raw_mode)
374 } 374 }
375 printf("\nPPB erase complete, total pulses: %u\n", pulsecnt); 375 printf("\nPPB erase complete, total pulses: %u\n", pulsecnt);
376 return(0); 376 return(0);
377 } 377 }
378 378
379 plj_ppb_erase_all_dualbank(reqbank, raw_mode) 379 plj_ppb_erase_all_dualbank(dummy_bi, raw_mode)
380 { 380 void *dummy_bi;
381 int altbank = !reqbank; 381 {
382 unsigned pulsecnt; 382 unsigned pulsecnt;
383 uint16_t stat; 383 uint16_t stat;
384 int rc; 384 int rc;
385 385
386 if (flash_detect(altbank, 0) < 0) 386 if (flash_detect(0, 0) < 0)
387 return(-1);
388 if (flash_detect(1, 0) < 0)
387 return(-1); 389 return(-1);
388 if (flash_bank_info[0].device != flash_bank_info[1].device) { 390 if (flash_bank_info[0].device != flash_bank_info[1].device) {
389 fprintf(stderr, "error: mismatch between two flash banks\n"); 391 fprintf(stderr, "error: mismatch between two flash banks\n");
390 return(-1); 392 return(-1);
391 } 393 }
392 if (raw_mode) 394 if (raw_mode)
393 return plj_ppb_erase_cycle(flash_bank_info + reqbank); 395 return plj_ppb_erase_cycle(&flash_bank_info[0]);
394 printf("Programming all PPBs in flash bank 0\n"); 396 printf("Programming all PPBs in flash bank 0\n");
395 rc = plj_ppb_program_all(&flash_bank_info[0]); 397 rc = plj_ppb_program_all(&flash_bank_info[0]);
396 if (rc < 0) 398 if (rc < 0)
397 return(-1); 399 return(-1);
398 printf("Programming all PPBs in flash bank 1\n"); 400 printf("Programming all PPBs in flash bank 1\n");
532 if (!li || !li->ppb_erase_all) { 534 if (!li || !li->ppb_erase_all) {
533 fprintf(stderr, 535 fprintf(stderr,
534 "Operation not supported for this flash chip type\n"); 536 "Operation not supported for this flash chip type\n");
535 return(-1); 537 return(-1);
536 } 538 }
537 return li->ppb_erase_all(bank, raw_mode); 539 return li->ppb_erase_all(bi, raw_mode);
538 } 540 }