freemyipod r224 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r223‎ | r224 | r225 >
Date:02:19, 24 October 2010
Author:theseven
Status:new
Tags:
Comment:
iPod Nano 2G NAND driver: Add debugging output if NAND_TRACE is defined
Modified paths:
  • /embios/trunk/target/ipodnano2g/nand.c (modified) (history)

Diff [purge]

Index: embios/trunk/target/ipodnano2g/nand.c
@@ -375,6 +375,9 @@
376376 void* sparebuffer, uint32_t doecc,
377377 uint32_t checkempty)
378378 {
 379+#ifdef NAND_TRACE
 380+ DEBUGF("NAND: Read bank %d, page %d", bank, page);
 381+#endif
379382 uint8_t* data = (uint8_t*)databuffer;
380383 uint8_t* spare = nand_spare;
381384 if (sparebuffer) spare = (uint8_t*)sparebuffer;
@@ -430,7 +433,26 @@
431434 else memcpy(sparebuffer, nand_ctrl, 0xC);
432435 }
433436 if (checkempty) rc |= nand_check_empty(spare) << 1;
 437+#ifdef NAND_DEBUG
 438+ if ((rc & 2) == 0)
 439+ {
 440+ if ((rc & 0x10) != 0)
 441+ DEBUGF("NAND: ECC failed to correct bank %d page %d user data!", bank, page);
 442+ if ((rc & 0xE0) != 0)
 443+ DEBUGF("NAND: ECC corrected %d errors in bank %d page %d user data!", rc >> 5, bank, page);
 444+ if ((rc & 0x100) != 0)
 445+ DEBUGF("NAND: ECC failed to correct bank %d page %d control data!", bank, page);
 446+ if ((rc & 0xE00) != 0)
 447+ DEBUGF("NAND: ECC corrected %d errors in bank %d page %d control data!", (rc >> 9) & 7, bank, page);
 448+ }
 449+#ifdef NAND_TRACE
 450+ else DEBUGF("NAND: Bank %d page %d: Erased page!", bank, page);
 451+#endif
 452+#endif
434453
 454+#ifdef NAND_TRACE
 455+ DEBUGF("NAND: Read success, RC=%X", rc);
 456+#endif
435457 return nand_unlock(rc);
436458 }
437459
@@ -438,6 +460,9 @@
439461 void* databuffer, void* sparebuffer,
440462 uint32_t doecc, uint32_t wait)
441463 {
 464+#ifdef NAND_TRACE
 465+ DEBUGF("NAND: Write bank %d, page %d", bank, page);
 466+#endif
442467 uint8_t* data = (uint8_t*)databuffer;
443468 uint8_t* spare = nand_spare;
444469 if (sparebuffer) spare = (uint8_t*)sparebuffer;
@@ -480,6 +505,9 @@
481506
482507 uint32_t nand_block_erase(uint32_t bank, uint32_t page)
483508 {
 509+#ifdef NAND_TRACE
 510+ DEBUGF("NAND: Block erase starting at bank %d, page %d", bank, page);
 511+#endif
484512 mutex_lock(&nand_mtx, TIMEOUT_BLOCK);
485513 nand_last_activity_value = USEC_TIMER;
486514 if (!nand_powered) nand_power_up();
@@ -498,6 +526,9 @@
499527 void* sparebuffer, uint32_t doecc,
500528 uint32_t checkempty)
501529 {
 530+#ifdef NAND_TRACE
 531+ DEBUGF("NAND: Read all banks, page %d", page);
 532+#endif
502533 uint32_t i, rc = 0;
503534 if (((uint32_t)databuffer & 0xf) || ((uint32_t)sparebuffer & 0xf)
504535 || !databuffer || !sparebuffer || !doecc)
@@ -629,6 +660,9 @@
630661 uint32_t nand_write_page_start(uint32_t bank, uint32_t page, void* databuffer,
631662 void* sparebuffer, uint32_t doecc)
632663 {
 664+#ifdef NAND_TRACE
 665+ DEBUGF("NAND: Write all banks, page %d", page);
 666+#endif
633667 if (((uint32_t)databuffer & 0xf) || ((uint32_t)sparebuffer & 0xf)
634668 || !databuffer || !sparebuffer || !doecc || !nand_interleaved)
635669 return nand_write_page_int(bank, page, databuffer, sparebuffer, doecc, !nand_interleaved);