summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/target/arm/s5l8700/ipodnano2g/ftl-nano2g.c134
-rw-r--r--firmware/target/arm/s5l8700/ipodnano2g/lcd-nano2g.c9
-rw-r--r--firmware/target/arm/s5l8700/ipodnano2g/nand-nano2g.c72
-rw-r--r--firmware/target/arm/s5l8700/ipodnano2g/pmu-nano2g.c1
-rw-r--r--firmware/target/arm/s5l8700/ipodnano2g/power-nano2g.c5
-rw-r--r--firmware/target/arm/s5l8700/pcm-s5l8700.c8
-rw-r--r--firmware/target/arm/usb-s3c6400x.c8
7 files changed, 116 insertions, 121 deletions
diff --git a/firmware/target/arm/s5l8700/ipodnano2g/ftl-nano2g.c b/firmware/target/arm/s5l8700/ipodnano2g/ftl-nano2g.c
index 65a282fe37..69fac62289 100644
--- a/firmware/target/arm/s5l8700/ipodnano2g/ftl-nano2g.c
+++ b/firmware/target/arm/s5l8700/ipodnano2g/ftl-nano2g.c
@@ -178,7 +178,7 @@ struct ftl_cxt_type
178 /* Seems to be unused, but gets loaded from flash by Whimory. */ 178 /* Seems to be unused, but gets loaded from flash by Whimory. */
179 uint8_t field_130[0x15C]; 179 uint8_t field_130[0x15C];
180 180
181} __attribute__((packed)) FTLCxtType; 181} __attribute__((packed));
182 182
183 183
184/* Keeps the state of the bank's VFL, both on flash and in memory. 184/* Keeps the state of the bank's VFL, both on flash and in memory.
@@ -363,54 +363,54 @@ const struct nand_device_info_type* ftl_nand_type;
363uint32_t ftl_banks; 363uint32_t ftl_banks;
364 364
365/* Block map, used vor pBlock to vBlock mapping */ 365/* Block map, used vor pBlock to vBlock mapping */
366uint16_t ftl_map[0x2000]; 366static uint16_t ftl_map[0x2000];
367 367
368/* VFL context for each bank */ 368/* VFL context for each bank */
369struct ftl_vfl_cxt_type ftl_vfl_cxt[4]; 369static struct ftl_vfl_cxt_type ftl_vfl_cxt[4];
370 370
371/* FTL context */ 371/* FTL context */
372struct ftl_cxt_type ftl_cxt; 372static struct ftl_cxt_type ftl_cxt;
373 373
374/* Temporary data buffers for internal use by the FTL */ 374/* Temporary data buffers for internal use by the FTL */
375uint8_t ftl_buffer[0x800] STORAGE_ALIGN_ATTR; 375static uint8_t ftl_buffer[0x800] STORAGE_ALIGN_ATTR;
376 376
377/* Temporary spare byte buffer for internal use by the FTL */ 377/* Temporary spare byte buffer for internal use by the FTL */
378union ftl_spare_data_type ftl_sparebuffer[FTL_WRITESPARE_SIZE] STORAGE_ALIGN_ATTR; 378static union ftl_spare_data_type ftl_sparebuffer[FTL_WRITESPARE_SIZE] STORAGE_ALIGN_ATTR;
379 379
380 380
381#ifndef FTL_READONLY 381#ifndef FTL_READONLY
382 382
383/* Lowlevel BBT for each bank */ 383/* Lowlevel BBT for each bank */
384uint8_t ftl_bbt[4][0x410]; 384static uint8_t ftl_bbt[4][0x410];
385 385
386/* Erase counters for the vBlocks */ 386/* Erase counters for the vBlocks */
387uint16_t ftl_erasectr[0x2000]; 387static uint16_t ftl_erasectr[0x2000];
388 388
389/* Used by ftl_log */ 389/* Used by ftl_log */
390uint16_t ftl_offsets[0x11][0x200]; 390static uint16_t ftl_offsets[0x11][0x200];
391 391
392/* Structs keeping record of scattered page blocks */ 392/* Structs keeping record of scattered page blocks */
393struct ftl_log_type ftl_log[0x11]; 393static struct ftl_log_type ftl_log[0x11];
394 394
395/* Global cross-bank update sequence number of the VFL context */ 395/* Global cross-bank update sequence number of the VFL context */
396uint32_t ftl_vfl_usn; 396static uint32_t ftl_vfl_usn;
397 397
398/* Keeps track (temporarily) of troublesome blocks */ 398/* Keeps track (temporarily) of troublesome blocks */
399struct ftl_trouble_type ftl_troublelog[5]; 399static struct ftl_trouble_type ftl_troublelog[5];
400 400
401/* Counts erase counter page changes, after 100 of them the affected 401/* Counts erase counter page changes, after 100 of them the affected
402 page will be committed to the flash. */ 402 page will be committed to the flash. */
403uint8_t ftl_erasectr_dirt[8]; 403static uint8_t ftl_erasectr_dirt[8];
404 404
405/* Buffer needed for copying pages around while moving or committing blocks. 405/* Buffer needed for copying pages around while moving or committing blocks.
406 This can't be shared with ftl_buffer, because this one could be overwritten 406 This can't be shared with ftl_buffer, because this one could be overwritten
407 during the copying operation in order to e.g. commit a CXT. */ 407 during the copying operation in order to e.g. commit a CXT. */
408uint8_t ftl_copybuffer[FTL_COPYBUF_SIZE][0x800] STORAGE_ALIGN_ATTR; 408static uint8_t ftl_copybuffer[FTL_COPYBUF_SIZE][0x800] STORAGE_ALIGN_ATTR;
409union ftl_spare_data_type ftl_copyspare[FTL_COPYBUF_SIZE] STORAGE_ALIGN_ATTR; 409static union ftl_spare_data_type ftl_copyspare[FTL_COPYBUF_SIZE] STORAGE_ALIGN_ATTR;
410 410
411/* Needed to store the old scattered page offsets in order to be able to roll 411/* Needed to store the old scattered page offsets in order to be able to roll
412 back if something fails while compacting a scattered page block. */ 412 back if something fails while compacting a scattered page block. */
413uint16_t ftl_offsets_backup[0x200] STORAGE_ALIGN_ATTR; 413static uint16_t ftl_offsets_backup[0x200] STORAGE_ALIGN_ATTR;
414 414
415#endif 415#endif
416 416
@@ -421,7 +421,7 @@ static struct mutex ftl_mtx;
421 421
422/* Finds a device info page for the specified bank and returns its number. 422/* Finds a device info page for the specified bank and returns its number.
423 Used to check if one is present, and to read the lowlevel BBT. */ 423 Used to check if one is present, and to read the lowlevel BBT. */
424uint32_t ftl_find_devinfo(uint32_t bank) 424static uint32_t ftl_find_devinfo(uint32_t bank)
425{ 425{
426 /* Scan the last 10% of the flash for device info pages */ 426 /* Scan the last 10% of the flash for device info pages */
427 uint32_t lowestBlock = ftl_nand_type->blocks 427 uint32_t lowestBlock = ftl_nand_type->blocks
@@ -445,7 +445,7 @@ uint32_t ftl_find_devinfo(uint32_t bank)
445 445
446 446
447/* Checks if all banks have proper device info pages */ 447/* Checks if all banks have proper device info pages */
448uint32_t ftl_has_devinfo(void) 448static uint32_t ftl_has_devinfo(void)
449{ 449{
450 uint32_t i; 450 uint32_t i;
451 for (i = 0; i < ftl_banks; i++) if (ftl_find_devinfo(i) == 0) return 0; 451 for (i = 0; i < ftl_banks; i++) if (ftl_find_devinfo(i) == 0) return 0;
@@ -455,7 +455,7 @@ uint32_t ftl_has_devinfo(void)
455 455
456/* Loads the lowlevel BBT for a bank to the specified buffer. 456/* Loads the lowlevel BBT for a bank to the specified buffer.
457 This is based on some cryptic disassembly and not fully understood yet. */ 457 This is based on some cryptic disassembly and not fully understood yet. */
458uint32_t ftl_load_bbt(uint32_t bank, uint8_t* bbt) 458static uint32_t ftl_load_bbt(uint32_t bank, uint8_t* bbt)
459{ 459{
460 uint32_t i, j; 460 uint32_t i, j;
461 uint32_t pagebase, page = ftl_find_devinfo(bank), page2; 461 uint32_t pagebase, page = ftl_find_devinfo(bank), page2;
@@ -489,8 +489,8 @@ uint32_t ftl_load_bbt(uint32_t bank, uint8_t* bbt)
489 489
490 490
491/* Calculates the checksums for the VFL context page of the specified bank */ 491/* Calculates the checksums for the VFL context page of the specified bank */
492void ftl_vfl_calculate_checksum(uint32_t bank, 492static void ftl_vfl_calculate_checksum(uint32_t bank,
493 uint32_t* checksum1, uint32_t* checksum2) 493 uint32_t* checksum1, uint32_t* checksum2)
494{ 494{
495 uint32_t i; 495 uint32_t i;
496 *checksum1 = 0xAABBCCDD; 496 *checksum1 = 0xAABBCCDD;
@@ -505,7 +505,7 @@ void ftl_vfl_calculate_checksum(uint32_t bank,
505 505
506/* Checks if the checksums of the VFL context 506/* Checks if the checksums of the VFL context
507 of the specified bank are correct */ 507 of the specified bank are correct */
508uint32_t ftl_vfl_verify_checksum(uint32_t bank) 508static uint32_t ftl_vfl_verify_checksum(uint32_t bank)
509{ 509{
510 uint32_t checksum1, checksum2; 510 uint32_t checksum1, checksum2;
511 ftl_vfl_calculate_checksum(bank, &checksum1, &checksum2); 511 ftl_vfl_calculate_checksum(bank, &checksum1, &checksum2);
@@ -520,7 +520,7 @@ uint32_t ftl_vfl_verify_checksum(uint32_t bank)
520 520
521#ifndef FTL_READONLY 521#ifndef FTL_READONLY
522/* Updates the checksums of the VFL context of the specified bank */ 522/* Updates the checksums of the VFL context of the specified bank */
523void ftl_vfl_update_checksum(uint32_t bank) 523static void ftl_vfl_update_checksum(uint32_t bank)
524{ 524{
525 ftl_vfl_calculate_checksum(bank, &ftl_vfl_cxt[bank].checksum1, 525 ftl_vfl_calculate_checksum(bank, &ftl_vfl_cxt[bank].checksum1,
526 &ftl_vfl_cxt[bank].checksum2); 526 &ftl_vfl_cxt[bank].checksum2);
@@ -531,7 +531,7 @@ void ftl_vfl_update_checksum(uint32_t bank)
531#ifndef FTL_READONLY 531#ifndef FTL_READONLY
532/* Writes 8 copies of the VFL context of the specified bank to flash, 532/* Writes 8 copies of the VFL context of the specified bank to flash,
533 and succeeds if at least 4 can be read back properly. */ 533 and succeeds if at least 4 can be read back properly. */
534uint32_t ftl_vfl_store_cxt(uint32_t bank) 534static uint32_t ftl_vfl_store_cxt(uint32_t bank)
535{ 535{
536 uint32_t i; 536 uint32_t i;
537 ftl_vfl_cxt[bank].updatecount--; 537 ftl_vfl_cxt[bank].updatecount--;
@@ -575,7 +575,7 @@ uint32_t ftl_vfl_store_cxt(uint32_t bank)
575#ifndef FTL_READONLY 575#ifndef FTL_READONLY
576/* Commits the VFL context of the specified bank to flash, 576/* Commits the VFL context of the specified bank to flash,
577 retries until it works or all available pages have been tried */ 577 retries until it works or all available pages have been tried */
578uint32_t ftl_vfl_commit_cxt(uint32_t bank) 578static uint32_t ftl_vfl_commit_cxt(uint32_t bank)
579{ 579{
580 if (ftl_vfl_cxt[bank].nextcxtpage + 8 <= ftl_nand_type->pagesperblock) 580 if (ftl_vfl_cxt[bank].nextcxtpage + 8 <= ftl_nand_type->pagesperblock)
581 if (ftl_vfl_store_cxt(bank) == 0) return 0; 581 if (ftl_vfl_store_cxt(bank) == 0) return 0;
@@ -604,7 +604,7 @@ uint32_t ftl_vfl_commit_cxt(uint32_t bank)
604/* Returns a pointer to the most recently updated VFL context, 604/* Returns a pointer to the most recently updated VFL context,
605 used to find out the current FTL context vBlock numbers 605 used to find out the current FTL context vBlock numbers
606 (planetbeing's "maxthing") */ 606 (planetbeing's "maxthing") */
607struct ftl_vfl_cxt_type* ftl_vfl_get_newest_cxt(void) 607static struct ftl_vfl_cxt_type* ftl_vfl_get_newest_cxt(void)
608{ 608{
609 uint32_t i, maxusn; 609 uint32_t i, maxusn;
610 struct ftl_vfl_cxt_type* cxt = (struct ftl_vfl_cxt_type*)0; 610 struct ftl_vfl_cxt_type* cxt = (struct ftl_vfl_cxt_type*)0;
@@ -621,7 +621,7 @@ struct ftl_vfl_cxt_type* ftl_vfl_get_newest_cxt(void)
621 621
622/* Checks if the specified pBlock is marked bad in the supplied lowlevel BBT. 622/* Checks if the specified pBlock is marked bad in the supplied lowlevel BBT.
623 Only used while mounting the VFL. */ 623 Only used while mounting the VFL. */
624uint32_t ftl_is_good_block(uint8_t* bbt, uint32_t block) 624static uint32_t ftl_is_good_block(uint8_t* bbt, uint32_t block)
625{ 625{
626 if ((bbt[block >> 3] & (1 << (block & 7))) == 0) return 0; 626 if ((bbt[block >> 3] & (1 << (block & 7))) == 0) return 0;
627 else return 1; 627 else return 1;
@@ -629,7 +629,7 @@ uint32_t ftl_is_good_block(uint8_t* bbt, uint32_t block)
629 629
630 630
631/* Checks if the specified vBlock could be remapped */ 631/* Checks if the specified vBlock could be remapped */
632uint32_t ftl_vfl_is_good_block(uint32_t bank, uint32_t block) 632static uint32_t ftl_vfl_is_good_block(uint32_t bank, uint32_t block)
633{ 633{
634 uint8_t bbtentry = ftl_vfl_cxt[bank].bbt[block >> 6]; 634 uint8_t bbtentry = ftl_vfl_cxt[bank].bbt[block >> 6];
635 if ((bbtentry & (1 << ((7 - (block >> 3)) & 7))) == 0) return 0; 635 if ((bbtentry & (1 << ((7 - (block >> 3)) & 7))) == 0) return 0;
@@ -640,7 +640,7 @@ uint32_t ftl_vfl_is_good_block(uint32_t bank, uint32_t block)
640#ifndef FTL_READONLY 640#ifndef FTL_READONLY
641/* Sets or unsets the bad bit of the specified vBlock 641/* Sets or unsets the bad bit of the specified vBlock
642 in the specified bank's VFL context */ 642 in the specified bank's VFL context */
643void ftl_vfl_set_good_block(uint32_t bank, uint32_t block, uint32_t isgood) 643static void ftl_vfl_set_good_block(uint32_t bank, uint32_t block, uint32_t isgood)
644{ 644{
645 uint8_t bit = (1 << ((7 - (block >> 3)) & 7)); 645 uint8_t bit = (1 << ((7 - (block >> 3)) & 7));
646 if (isgood == 1) ftl_vfl_cxt[bank].bbt[block >> 6] |= bit; 646 if (isgood == 1) ftl_vfl_cxt[bank].bbt[block >> 6] |= bit;
@@ -650,9 +650,9 @@ void ftl_vfl_set_good_block(uint32_t bank, uint32_t block, uint32_t isgood)
650 650
651 651
652/* Tries to read a VFL context from the specified bank, pBlock and page */ 652/* Tries to read a VFL context from the specified bank, pBlock and page */
653uint32_t ftl_vfl_read_page(uint32_t bank, uint32_t block, 653static uint32_t ftl_vfl_read_page(uint32_t bank, uint32_t block,
654 uint32_t startpage, void* databuffer, 654 uint32_t startpage, void* databuffer,
655 union ftl_spare_data_type* sparebuffer) 655 union ftl_spare_data_type* sparebuffer)
656{ 656{
657 uint32_t i; 657 uint32_t i;
658 for (i = 0; i < 8; i++) 658 for (i = 0; i < 8; i++)
@@ -670,7 +670,7 @@ uint32_t ftl_vfl_read_page(uint32_t bank, uint32_t block,
670 670
671 671
672/* Translates a bank and vBlock to a pBlock, following remaps */ 672/* Translates a bank and vBlock to a pBlock, following remaps */
673uint32_t ftl_vfl_get_physical_block(uint32_t bank, uint32_t block) 673static uint32_t ftl_vfl_get_physical_block(uint32_t bank, uint32_t block)
674{ 674{
675 if (ftl_vfl_is_good_block(bank, block) == 1) return block; 675 if (ftl_vfl_is_good_block(bank, block) == 1) return block;
676 676
@@ -685,7 +685,7 @@ uint32_t ftl_vfl_get_physical_block(uint32_t bank, uint32_t block)
685 685
686#ifndef FTL_READONLY 686#ifndef FTL_READONLY
687/* Checks if remapping is scheduled for the specified bank and vBlock */ 687/* Checks if remapping is scheduled for the specified bank and vBlock */
688uint32_t ftl_vfl_check_remap_scheduled(uint32_t bank, uint32_t block) 688static uint32_t ftl_vfl_check_remap_scheduled(uint32_t bank, uint32_t block)
689{ 689{
690 uint32_t i; 690 uint32_t i;
691 for (i = 0x333; i > 0 && i > ftl_vfl_cxt[bank].scheduledstart; i--) 691 for (i = 0x333; i > 0 && i > ftl_vfl_cxt[bank].scheduledstart; i--)
@@ -697,7 +697,7 @@ uint32_t ftl_vfl_check_remap_scheduled(uint32_t bank, uint32_t block)
697 697
698#ifndef FTL_READONLY 698#ifndef FTL_READONLY
699/* Schedules remapping for the specified bank and vBlock */ 699/* Schedules remapping for the specified bank and vBlock */
700void ftl_vfl_schedule_block_for_remap(uint32_t bank, uint32_t block) 700static void ftl_vfl_schedule_block_for_remap(uint32_t bank, uint32_t block)
701{ 701{
702 if (ftl_vfl_check_remap_scheduled(bank, block) == 1) 702 if (ftl_vfl_check_remap_scheduled(bank, block) == 1)
703 return; 703 return;
@@ -713,7 +713,7 @@ void ftl_vfl_schedule_block_for_remap(uint32_t bank, uint32_t block)
713#ifndef FTL_READONLY 713#ifndef FTL_READONLY
714/* Removes the specified bank and vBlock combination 714/* Removes the specified bank and vBlock combination
715 from the remap scheduled list */ 715 from the remap scheduled list */
716void ftl_vfl_mark_remap_done(uint32_t bank, uint32_t block) 716static void ftl_vfl_mark_remap_done(uint32_t bank, uint32_t block)
717{ 717{
718 uint32_t i; 718 uint32_t i;
719 uint32_t start = ftl_vfl_cxt[bank].scheduledstart; 719 uint32_t start = ftl_vfl_cxt[bank].scheduledstart;
@@ -734,7 +734,7 @@ void ftl_vfl_mark_remap_done(uint32_t bank, uint32_t block)
734/* Logs that there is trouble for the specified vBlock on the specified bank. 734/* Logs that there is trouble for the specified vBlock on the specified bank.
735 The vBlock will be scheduled for remap 735 The vBlock will be scheduled for remap
736 if there is too much trouble with it. */ 736 if there is too much trouble with it. */
737void ftl_vfl_log_trouble(uint32_t bank, uint32_t vblock) 737static void ftl_vfl_log_trouble(uint32_t bank, uint32_t vblock)
738{ 738{
739 uint32_t i; 739 uint32_t i;
740 for (i = 0; i < 5; i++) 740 for (i = 0; i < 5; i++)
@@ -763,7 +763,7 @@ void ftl_vfl_log_trouble(uint32_t bank, uint32_t vblock)
763 763
764#ifndef FTL_READONLY 764#ifndef FTL_READONLY
765/* Logs a successful erase for the specified vBlock on the specified bank */ 765/* Logs a successful erase for the specified vBlock on the specified bank */
766void ftl_vfl_log_success(uint32_t bank, uint32_t vblock) 766static void ftl_vfl_log_success(uint32_t bank, uint32_t vblock)
767{ 767{
768 uint32_t i; 768 uint32_t i;
769 for (i = 0; i < 5; i++) 769 for (i = 0; i < 5; i++)
@@ -783,7 +783,7 @@ void ftl_vfl_log_success(uint32_t bank, uint32_t vblock)
783 not caring about data in there. 783 not caring about data in there.
784 If it worked, it will return the new pBlock number, 784 If it worked, it will return the new pBlock number,
785 if not (no more spare blocks available), it will return zero. */ 785 if not (no more spare blocks available), it will return zero. */
786uint32_t ftl_vfl_remap_block(uint32_t bank, uint32_t block) 786static uint32_t ftl_vfl_remap_block(uint32_t bank, uint32_t block)
787{ 787{
788 uint32_t i; 788 uint32_t i;
789 uint32_t newblock = 0, newidx; 789 uint32_t newblock = 0, newidx;
@@ -813,8 +813,8 @@ uint32_t ftl_vfl_remap_block(uint32_t bank, uint32_t block)
813 813
814 814
815/* Reads the specified vPage, dealing with all kinds of trouble */ 815/* Reads the specified vPage, dealing with all kinds of trouble */
816uint32_t ftl_vfl_read(uint32_t vpage, void* buffer, void* sparebuffer, 816static uint32_t ftl_vfl_read(uint32_t vpage, void* buffer, void* sparebuffer,
817 uint32_t checkempty, uint32_t remaponfail) 817 uint32_t checkempty, uint32_t remaponfail)
818{ 818{
819 uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks; 819 uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks;
820 uint32_t syshyperblocks = ftl_nand_type->blocks 820 uint32_t syshyperblocks = ftl_nand_type->blocks
@@ -852,8 +852,8 @@ uint32_t ftl_vfl_read(uint32_t vpage, void* buffer, void* sparebuffer,
852 852
853 853
854/* Multi-bank version of ftl_vfl_read, will read ftl_banks pages in parallel */ 854/* Multi-bank version of ftl_vfl_read, will read ftl_banks pages in parallel */
855uint32_t ftl_vfl_read_fast(uint32_t vpage, void* buffer, void* sparebuffer, 855static uint32_t ftl_vfl_read_fast(uint32_t vpage, void* buffer, void* sparebuffer,
856 uint32_t checkempty, uint32_t remaponfail) 856 uint32_t checkempty, uint32_t remaponfail)
857{ 857{
858 uint32_t i, rc = 0; 858 uint32_t i, rc = 0;
859 uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks; 859 uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks;
@@ -922,8 +922,8 @@ uint32_t ftl_vfl_read_fast(uint32_t vpage, void* buffer, void* sparebuffer,
922 922
923#ifndef FTL_READONLY 923#ifndef FTL_READONLY
924/* Writes the specified vPage, dealing with all kinds of trouble */ 924/* Writes the specified vPage, dealing with all kinds of trouble */
925uint32_t ftl_vfl_write(uint32_t vpage, uint32_t count, 925static uint32_t ftl_vfl_write(uint32_t vpage, uint32_t count,
926 void* buffer, void* sparebuffer) 926 void* buffer, void* sparebuffer)
927{ 927{
928 uint32_t i, j; 928 uint32_t i, j;
929 uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks; 929 uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks;
@@ -993,7 +993,7 @@ uint32_t ftl_vfl_write(uint32_t vpage, uint32_t count,
993 993
994 994
995/* Mounts the VFL on all banks */ 995/* Mounts the VFL on all banks */
996uint32_t ftl_vfl_open(void) 996static uint32_t ftl_vfl_open(void)
997{ 997{
998 uint32_t i, j, k; 998 uint32_t i, j, k;
999 uint32_t minusn, vflcxtidx, last; 999 uint32_t minusn, vflcxtidx, last;
@@ -1080,7 +1080,7 @@ uint32_t ftl_vfl_open(void)
1080 1080
1081 1081
1082/* Mounts the actual FTL */ 1082/* Mounts the actual FTL */
1083uint32_t ftl_open(void) 1083static uint32_t ftl_open(void)
1084{ 1084{
1085 uint32_t i; 1085 uint32_t i;
1086 uint32_t ret; 1086 uint32_t ret;
@@ -1182,7 +1182,7 @@ uint32_t ftl_open(void)
1182#ifndef FTL_READONLY 1182#ifndef FTL_READONLY
1183/* Returns a pointer to the ftl_log entry for the specified vBlock, 1183/* Returns a pointer to the ftl_log entry for the specified vBlock,
1184 or null, if there is none */ 1184 or null, if there is none */
1185struct ftl_log_type* ftl_get_log_entry(uint32_t block) 1185static struct ftl_log_type* ftl_get_log_entry(uint32_t block)
1186{ 1186{
1187 uint32_t i; 1187 uint32_t i;
1188 for (i = 0; i < 0x11; i++) 1188 for (i = 0; i < 0x11; i++)
@@ -1264,7 +1264,7 @@ uint32_t ftl_read(uint32_t sector, uint32_t count, void* buffer)
1264#ifndef FTL_READONLY 1264#ifndef FTL_READONLY
1265/* Performs a vBlock erase, dealing with hardware, 1265/* Performs a vBlock erase, dealing with hardware,
1266 remapping and all kinds of trouble */ 1266 remapping and all kinds of trouble */
1267uint32_t ftl_erase_block_internal(uint32_t block) 1267static uint32_t ftl_erase_block_internal(uint32_t block)
1268{ 1268{
1269 uint32_t i, j; 1269 uint32_t i, j;
1270 block = block + ftl_nand_type->blocks 1270 block = block + ftl_nand_type->blocks
@@ -1308,7 +1308,7 @@ uint32_t ftl_erase_block_internal(uint32_t block)
1308 1308
1309#ifndef FTL_READONLY 1309#ifndef FTL_READONLY
1310/* Highlevel vBlock erase, that increments the erase counter for the block */ 1310/* Highlevel vBlock erase, that increments the erase counter for the block */
1311uint32_t ftl_erase_block(uint32_t block) 1311static uint32_t ftl_erase_block(uint32_t block)
1312{ 1312{
1313 ftl_erasectr[block]++; 1313 ftl_erasectr[block]++;
1314 if (ftl_erasectr_dirt[block >> 10] == 100) ftl_cxt.erasedirty = 1; 1314 if (ftl_erasectr_dirt[block >> 10] == 100) ftl_cxt.erasedirty = 1;
@@ -1321,7 +1321,7 @@ uint32_t ftl_erase_block(uint32_t block)
1321#ifndef FTL_READONLY 1321#ifndef FTL_READONLY
1322/* Allocates a block from the pool, 1322/* Allocates a block from the pool,
1323 returning its vBlock number, or 0xFFFFFFFF on error */ 1323 returning its vBlock number, or 0xFFFFFFFF on error */
1324uint32_t ftl_allocate_pool_block(void) 1324static uint32_t ftl_allocate_pool_block(void)
1325{ 1325{
1326 uint32_t i; 1326 uint32_t i;
1327 uint32_t erasectr = 0xFFFFFFFF, bestidx = 0xFFFFFFFF, block; 1327 uint32_t erasectr = 0xFFFFFFFF, bestidx = 0xFFFFFFFF, block;
@@ -1355,7 +1355,7 @@ uint32_t ftl_allocate_pool_block(void)
1355 1355
1356#ifndef FTL_READONLY 1356#ifndef FTL_READONLY
1357/* Releases a vBlock back into the pool */ 1357/* Releases a vBlock back into the pool */
1358void ftl_release_pool_block(uint32_t block) 1358static void ftl_release_pool_block(uint32_t block)
1359{ 1359{
1360 if (block >= (uint32_t)ftl_nand_type->userblocks + 0x17) 1360 if (block >= (uint32_t)ftl_nand_type->userblocks + 0x17)
1361 panicf("FTL: Tried to release block %u", (unsigned)block); 1361 panicf("FTL: Tried to release block %u", (unsigned)block);
@@ -1369,7 +1369,7 @@ void ftl_release_pool_block(uint32_t block)
1369#ifndef FTL_READONLY 1369#ifndef FTL_READONLY
1370/* Commits the location of the FTL context blocks 1370/* Commits the location of the FTL context blocks
1371 to a semi-randomly chosen VFL context */ 1371 to a semi-randomly chosen VFL context */
1372uint32_t ftl_store_ctrl_block_list(void) 1372static uint32_t ftl_store_ctrl_block_list(void)
1373{ 1373{
1374 uint32_t i; 1374 uint32_t i;
1375 for (i = 0; i < ftl_banks; i++) 1375 for (i = 0; i < ftl_banks; i++)
@@ -1382,7 +1382,7 @@ uint32_t ftl_store_ctrl_block_list(void)
1382#ifndef FTL_READONLY 1382#ifndef FTL_READONLY
1383/* Saves the n-th erase counter page to the flash, 1383/* Saves the n-th erase counter page to the flash,
1384 because it is too dirty or needs to be moved. */ 1384 because it is too dirty or needs to be moved. */
1385uint32_t ftl_save_erasectr_page(uint32_t index) 1385static uint32_t ftl_save_erasectr_page(uint32_t index)
1386{ 1386{
1387 memset(&ftl_sparebuffer[0], 0xFF, 0x40); 1387 memset(&ftl_sparebuffer[0], 0xFF, 0x40);
1388 ftl_sparebuffer[0].meta.usn = ftl_cxt.usn; 1388 ftl_sparebuffer[0].meta.usn = ftl_cxt.usn;
@@ -1408,7 +1408,7 @@ uint32_t ftl_save_erasectr_page(uint32_t index)
1408#ifndef FTL_READONLY 1408#ifndef FTL_READONLY
1409/* Increments ftl_cxt.ftlctrlpage to the next available FTL context page, 1409/* Increments ftl_cxt.ftlctrlpage to the next available FTL context page,
1410 allocating a new context block if neccessary. */ 1410 allocating a new context block if neccessary. */
1411uint32_t ftl_next_ctrl_pool_page(void) 1411static uint32_t ftl_next_ctrl_pool_page(void)
1412{ 1412{
1413 uint32_t i; 1413 uint32_t i;
1414 uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks; 1414 uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks;
@@ -1446,8 +1446,8 @@ uint32_t ftl_next_ctrl_pool_page(void)
1446 1446
1447#ifndef FTL_READONLY 1447#ifndef FTL_READONLY
1448/* Copies a vPage from one location to another */ 1448/* Copies a vPage from one location to another */
1449uint32_t ftl_copy_page(uint32_t source, uint32_t destination, 1449static uint32_t ftl_copy_page(uint32_t source, uint32_t destination,
1450 uint32_t lpn, uint32_t type) 1450 uint32_t lpn, uint32_t type)
1451{ 1451{
1452 uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks; 1452 uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks;
1453 uint32_t rc = ftl_vfl_read(source, ftl_copybuffer[0], 1453 uint32_t rc = ftl_vfl_read(source, ftl_copybuffer[0],
@@ -1467,7 +1467,7 @@ uint32_t ftl_copy_page(uint32_t source, uint32_t destination,
1467 1467
1468#ifndef FTL_READONLY 1468#ifndef FTL_READONLY
1469/* Copies a pBlock to a vBlock */ 1469/* Copies a pBlock to a vBlock */
1470uint32_t ftl_copy_block(uint32_t source, uint32_t destination) 1470static uint32_t ftl_copy_block(uint32_t source, uint32_t destination)
1471{ 1471{
1472 uint32_t i, j; 1472 uint32_t i, j;
1473 uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks; 1473 uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks;
@@ -1509,7 +1509,7 @@ uint32_t ftl_copy_block(uint32_t source, uint32_t destination)
1509 1509
1510#ifndef FTL_READONLY 1510#ifndef FTL_READONLY
1511/* Clears ftl_log.issequential, if something violating that is written. */ 1511/* Clears ftl_log.issequential, if something violating that is written. */
1512void ftl_check_still_sequential(struct ftl_log_type* entry, uint32_t page) 1512static void ftl_check_still_sequential(struct ftl_log_type* entry, uint32_t page)
1513{ 1513{
1514 if (entry->pagesused != entry->pagescurrent 1514 if (entry->pagesused != entry->pagescurrent
1515 || entry->pageoffsets[page] != page) 1515 || entry->pageoffsets[page] != page)
@@ -1526,7 +1526,7 @@ void ftl_check_still_sequential(struct ftl_log_type* entry, uint32_t page)
1526 space again. This is usually done when a scattered page block is being 1526 space again. This is usually done when a scattered page block is being
1527 removed because it is full, but less than half of the pages in there are 1527 removed because it is full, but less than half of the pages in there are
1528 still in use and rest is just filled with old crap. */ 1528 still in use and rest is just filled with old crap. */
1529uint32_t ftl_compact_scattered(struct ftl_log_type* entry) 1529static uint32_t ftl_compact_scattered(struct ftl_log_type* entry)
1530{ 1530{
1531 uint32_t i, j; 1531 uint32_t i, j;
1532 uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks; 1532 uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks;
@@ -1582,7 +1582,7 @@ uint32_t ftl_compact_scattered(struct ftl_log_type* entry)
1582 1582
1583#ifndef FTL_READONLY 1583#ifndef FTL_READONLY
1584/* Commits an ftl_log entry to proper blocks, no matter what's in there. */ 1584/* Commits an ftl_log entry to proper blocks, no matter what's in there. */
1585uint32_t ftl_commit_scattered(struct ftl_log_type* entry) 1585static uint32_t ftl_commit_scattered(struct ftl_log_type* entry)
1586{ 1586{
1587 uint32_t i; 1587 uint32_t i;
1588 uint32_t error; 1588 uint32_t error;
@@ -1610,7 +1610,7 @@ uint32_t ftl_commit_scattered(struct ftl_log_type* entry)
1610 sequentially until now, in order to be able to save a block erase by 1610 sequentially until now, in order to be able to save a block erase by
1611 committing it without needing to copy it again. 1611 committing it without needing to copy it again.
1612 If this fails for whichever reason, it will be committed the usual way. */ 1612 If this fails for whichever reason, it will be committed the usual way. */
1613uint32_t ftl_commit_sequential(struct ftl_log_type* entry) 1613static uint32_t ftl_commit_sequential(struct ftl_log_type* entry)
1614{ 1614{
1615 uint32_t i; 1615 uint32_t i;
1616 uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks; 1616 uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks;
@@ -1656,7 +1656,7 @@ uint32_t ftl_commit_sequential(struct ftl_log_type* entry)
1656/* If a log entry is supplied, its scattered page block will be removed in 1656/* If a log entry is supplied, its scattered page block will be removed in
1657 whatever way seems most appropriate. Else, the oldest scattered page block 1657 whatever way seems most appropriate. Else, the oldest scattered page block
1658 will be freed by committing it. */ 1658 will be freed by committing it. */
1659uint32_t ftl_remove_scattered_block(struct ftl_log_type* entry) 1659static uint32_t ftl_remove_scattered_block(struct ftl_log_type* entry)
1660{ 1660{
1661 uint32_t i; 1661 uint32_t i;
1662 uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks; 1662 uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks;
@@ -1692,7 +1692,7 @@ uint32_t ftl_remove_scattered_block(struct ftl_log_type* entry)
1692 1692
1693#ifndef FTL_READONLY 1693#ifndef FTL_READONLY
1694/* Initialize a log entry to the values for an empty scattered page block */ 1694/* Initialize a log entry to the values for an empty scattered page block */
1695void ftl_init_log_entry(struct ftl_log_type* entry) 1695static void ftl_init_log_entry(struct ftl_log_type* entry)
1696{ 1696{
1697 entry->issequential = 1; 1697 entry->issequential = 1;
1698 entry->pagescurrent = 0; 1698 entry->pagescurrent = 0;
@@ -1705,7 +1705,7 @@ void ftl_init_log_entry(struct ftl_log_type* entry)
1705#ifndef FTL_READONLY 1705#ifndef FTL_READONLY
1706/* Allocates a log entry for the specified vBlock, 1706/* Allocates a log entry for the specified vBlock,
1707 first making space, if neccessary. */ 1707 first making space, if neccessary. */
1708struct ftl_log_type* ftl_allocate_log_entry(uint32_t block) 1708static struct ftl_log_type* ftl_allocate_log_entry(uint32_t block)
1709{ 1709{
1710 uint32_t i; 1710 uint32_t i;
1711 struct ftl_log_type* entry = ftl_get_log_entry(block); 1711 struct ftl_log_type* entry = ftl_get_log_entry(block);
@@ -1746,7 +1746,7 @@ struct ftl_log_type* ftl_allocate_log_entry(uint32_t block)
1746 1746
1747#ifndef FTL_READONLY 1747#ifndef FTL_READONLY
1748/* Commits the FTL block map, erase counters, and context to flash */ 1748/* Commits the FTL block map, erase counters, and context to flash */
1749uint32_t ftl_commit_cxt(void) 1749static uint32_t ftl_commit_cxt(void)
1750{ 1750{
1751 uint32_t i; 1751 uint32_t i;
1752 uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks; 1752 uint32_t ppb = ftl_nand_type->pagesperblock * ftl_banks;
@@ -1788,7 +1788,7 @@ uint32_t ftl_commit_cxt(void)
1788/* Swaps the most and least worn block on the flash, 1788/* Swaps the most and least worn block on the flash,
1789 to better distribute wear. It will refuse to do anything 1789 to better distribute wear. It will refuse to do anything
1790 if the wear spread is lower than 5 erases. */ 1790 if the wear spread is lower than 5 erases. */
1791uint32_t ftl_swap_blocks(void) 1791static uint32_t ftl_swap_blocks(void)
1792{ 1792{
1793 uint32_t i; 1793 uint32_t i;
1794 uint32_t min = 0xFFFFFFFF, max = 0, maxidx = 0x14; 1794 uint32_t min = 0xFFFFFFFF, max = 0, maxidx = 0x14;
diff --git a/firmware/target/arm/s5l8700/ipodnano2g/lcd-nano2g.c b/firmware/target/arm/s5l8700/ipodnano2g/lcd-nano2g.c
index e29708f40c..0600c77b62 100644
--- a/firmware/target/arm/s5l8700/ipodnano2g/lcd-nano2g.c
+++ b/firmware/target/arm/s5l8700/ipodnano2g/lcd-nano2g.c
@@ -153,15 +153,6 @@ void lcd_shutdown(void)
153 } 153 }
154} 154}
155 155
156
157void lcd_off(void)
158{
159}
160
161void lcd_on(void)
162{
163}
164
165/* LCD init */ 156/* LCD init */
166void lcd_init_device(void) 157void lcd_init_device(void)
167{ 158{
diff --git a/firmware/target/arm/s5l8700/ipodnano2g/nand-nano2g.c b/firmware/target/arm/s5l8700/ipodnano2g/nand-nano2g.c
index 86eda75768..fc7d20febc 100644
--- a/firmware/target/arm/s5l8700/ipodnano2g/nand-nano2g.c
+++ b/firmware/target/arm/s5l8700/ipodnano2g/nand-nano2g.c
@@ -84,15 +84,15 @@ static const struct nand_device_info_type nand_deviceinfotable[] =
84 {0xA555D520, 8192, 3872, 0x80, 7, 2, 1, 2, 1} 84 {0xA555D520, 8192, 3872, 0x80, 7, 2, 1, 2, 1}
85}; 85};
86 86
87uint8_t nand_tunk1[4]; 87static uint8_t nand_tunk1[4];
88uint8_t nand_twp[4]; 88static uint8_t nand_twp[4];
89uint8_t nand_tunk2[4]; 89static uint8_t nand_tunk2[4];
90uint8_t nand_tunk3[4]; 90static uint8_t nand_tunk3[4];
91uint32_t nand_type[4]; 91static uint32_t nand_type[4];
92int nand_powered = 0; 92static int nand_powered = 0;
93int nand_interleaved = 0; 93static int nand_interleaved = 0;
94int nand_cached = 0; 94static int nand_cached = 0;
95long nand_last_activity_value = -1; 95static long nand_last_activity_value = -1;
96static long nand_stack[DEFAULT_STACK_SIZE]; 96static long nand_stack[DEFAULT_STACK_SIZE];
97 97
98static struct mutex nand_mtx; 98static struct mutex nand_mtx;
@@ -106,7 +106,7 @@ static uint8_t nand_spare[0x40] STORAGE_ALIGN_ATTR;
106static uint8_t nand_ecc[0x30] STORAGE_ALIGN_ATTR; 106static uint8_t nand_ecc[0x30] STORAGE_ALIGN_ATTR;
107 107
108 108
109uint32_t nand_unlock(uint32_t rc) 109static uint32_t nand_unlock(uint32_t rc)
110{ 110{
111 led(false); 111 led(false);
112 nand_last_activity_value = current_tick; 112 nand_last_activity_value = current_tick;
@@ -114,13 +114,13 @@ uint32_t nand_unlock(uint32_t rc)
114 return rc; 114 return rc;
115} 115}
116 116
117uint32_t ecc_unlock(uint32_t rc) 117static uint32_t ecc_unlock(uint32_t rc)
118{ 118{
119 mutex_unlock(&ecc_mtx); 119 mutex_unlock(&ecc_mtx);
120 return rc; 120 return rc;
121} 121}
122 122
123uint32_t nand_timeout(long timeout) 123static uint32_t nand_timeout(long timeout)
124{ 124{
125 if (TIME_AFTER(current_tick, timeout)) return 1; 125 if (TIME_AFTER(current_tick, timeout)) return 1;
126 else 126 else
@@ -130,7 +130,7 @@ uint32_t nand_timeout(long timeout)
130 } 130 }
131} 131}
132 132
133uint32_t nand_wait_rbbdone(void) 133static uint32_t nand_wait_rbbdone(void)
134{ 134{
135 long timeout = current_tick + HZ / 50; 135 long timeout = current_tick + HZ / 50;
136 while (!(FMCSTAT & FMCSTAT_RBBDONE)) 136 while (!(FMCSTAT & FMCSTAT_RBBDONE))
@@ -139,7 +139,7 @@ uint32_t nand_wait_rbbdone(void)
139 return 0; 139 return 0;
140} 140}
141 141
142uint32_t nand_wait_cmddone(void) 142static uint32_t nand_wait_cmddone(void)
143{ 143{
144 long timeout = current_tick + HZ / 50; 144 long timeout = current_tick + HZ / 50;
145 while (!(FMCSTAT & FMCSTAT_CMDDONE)) 145 while (!(FMCSTAT & FMCSTAT_CMDDONE))
@@ -148,7 +148,7 @@ uint32_t nand_wait_cmddone(void)
148 return 0; 148 return 0;
149} 149}
150 150
151uint32_t nand_wait_addrdone(void) 151static uint32_t nand_wait_addrdone(void)
152{ 152{
153 long timeout = current_tick + HZ / 50; 153 long timeout = current_tick + HZ / 50;
154 while (!(FMCSTAT & FMCSTAT_ADDRDONE)) 154 while (!(FMCSTAT & FMCSTAT_ADDRDONE))
@@ -157,7 +157,7 @@ uint32_t nand_wait_addrdone(void)
157 return 0; 157 return 0;
158} 158}
159 159
160uint32_t nand_wait_chip_ready(uint32_t bank) 160static uint32_t nand_wait_chip_ready(uint32_t bank)
161{ 161{
162 long timeout = current_tick + HZ / 50; 162 long timeout = current_tick + HZ / 50;
163 while (!(FMCSTAT & (FMCSTAT_BANK0READY << bank))) 163 while (!(FMCSTAT & (FMCSTAT_BANK0READY << bank)))
@@ -166,19 +166,19 @@ uint32_t nand_wait_chip_ready(uint32_t bank)
166 return 0; 166 return 0;
167} 167}
168 168
169void nand_set_fmctrl0(uint32_t bank, uint32_t flags) 169static void nand_set_fmctrl0(uint32_t bank, uint32_t flags)
170{ 170{
171 FMCTRL0 = (nand_tunk1[bank] << 16) | (nand_twp[bank] << 12) 171 FMCTRL0 = (nand_tunk1[bank] << 16) | (nand_twp[bank] << 12)
172 | (1 << 11) | 1 | (1 << (bank + 1)) | flags; 172 | (1 << 11) | 1 | (1 << (bank + 1)) | flags;
173} 173}
174 174
175uint32_t nand_send_cmd(uint32_t cmd) 175static uint32_t nand_send_cmd(uint32_t cmd)
176{ 176{
177 FMCMD = cmd; 177 FMCMD = cmd;
178 return nand_wait_rbbdone(); 178 return nand_wait_rbbdone();
179} 179}
180 180
181uint32_t nand_send_address(uint32_t page, uint32_t offset) 181static uint32_t nand_send_address(uint32_t page, uint32_t offset)
182{ 182{
183 FMANUM = 4; 183 FMANUM = 4;
184 FMADDR0 = (page << 16) | offset; 184 FMADDR0 = (page << 16) | offset;
@@ -197,7 +197,7 @@ uint32_t nand_reset(uint32_t bank)
197 return 0; 197 return 0;
198} 198}
199 199
200uint32_t nand_wait_status_ready(uint32_t bank) 200static uint32_t nand_wait_status_ready(uint32_t bank)
201{ 201{
202 long timeout = current_tick + HZ / 50; 202 long timeout = current_tick + HZ / 50;
203 nand_set_fmctrl0(bank, 0); 203 nand_set_fmctrl0(bank, 0);
@@ -218,8 +218,8 @@ uint32_t nand_wait_status_ready(uint32_t bank)
218 return nand_send_cmd(NAND_CMD_READ); 218 return nand_send_cmd(NAND_CMD_READ);
219} 219}
220 220
221void nand_transfer_data_start(uint32_t bank, uint32_t direction, 221static void nand_transfer_data_start(uint32_t bank, uint32_t direction,
222 void* buffer, uint32_t size) 222 void* buffer, uint32_t size)
223{ 223{
224 nand_set_fmctrl0(bank, FMCTRL0_ENABLEDMA); 224 nand_set_fmctrl0(bank, FMCTRL0_ENABLEDMA);
225 FMDNUM = size - 1; 225 FMDNUM = size - 1;
@@ -236,7 +236,7 @@ void nand_transfer_data_start(uint32_t bank, uint32_t direction,
236 DMACOM3 = 4; 236 DMACOM3 = 4;
237} 237}
238 238
239uint32_t nand_transfer_data_collect(uint32_t direction) 239static uint32_t nand_transfer_data_collect(uint32_t direction)
240{ 240{
241 long timeout = current_tick + HZ / 50; 241 long timeout = current_tick + HZ / 50;
242 while ((DMAALLST & DMAALLST_DMABUSY3)) 242 while ((DMAALLST & DMAALLST_DMABUSY3))
@@ -248,15 +248,16 @@ uint32_t nand_transfer_data_collect(uint32_t direction)
248 return 0; 248 return 0;
249} 249}
250 250
251uint32_t nand_transfer_data(uint32_t bank, uint32_t direction, 251static uint32_t nand_transfer_data(uint32_t bank, uint32_t direction,
252 void* buffer, uint32_t size) 252 void* buffer, uint32_t size)
253{ 253{
254 nand_transfer_data_start(bank, direction, buffer, size); 254 nand_transfer_data_start(bank, direction, buffer, size);
255 uint32_t rc = nand_transfer_data_collect(direction); 255 uint32_t rc = nand_transfer_data_collect(direction);
256 return rc; 256 return rc;
257} 257}
258 258
259void ecc_start(uint32_t size, void* databuffer, void* sparebuffer, uint32_t type) 259static void ecc_start(uint32_t size, void* databuffer, void* sparebuffer,
260 uint32_t type)
260{ 261{
261 mutex_lock(&ecc_mtx); 262 mutex_lock(&ecc_mtx);
262 ECC_INT_CLR = 1; 263 ECC_INT_CLR = 1;
@@ -268,7 +269,7 @@ void ecc_start(uint32_t size, void* databuffer, void* sparebuffer, uint32_t type
268 ECC_CTRL = type; 269 ECC_CTRL = type;
269} 270}
270 271
271uint32_t ecc_collect(void) 272static uint32_t ecc_collect(void)
272{ 273{
273 long timeout = current_tick + HZ / 50; 274 long timeout = current_tick + HZ / 50;
274 while (!(SRCPND & INTMSK_ECC)) 275 while (!(SRCPND & INTMSK_ECC))
@@ -279,21 +280,21 @@ uint32_t ecc_collect(void)
279 return ecc_unlock(ECC_RESULT); 280 return ecc_unlock(ECC_RESULT);
280} 281}
281 282
282uint32_t ecc_decode(uint32_t size, void* databuffer, void* sparebuffer) 283static uint32_t ecc_decode(uint32_t size, void* databuffer, void* sparebuffer)
283{ 284{
284 ecc_start(size, databuffer, sparebuffer, ECCCTRL_STARTDECODING); 285 ecc_start(size, databuffer, sparebuffer, ECCCTRL_STARTDECODING);
285 uint32_t rc = ecc_collect(); 286 uint32_t rc = ecc_collect();
286 return rc; 287 return rc;
287} 288}
288 289
289uint32_t ecc_encode(uint32_t size, void* databuffer, void* sparebuffer) 290static uint32_t ecc_encode(uint32_t size, void* databuffer, void* sparebuffer)
290{ 291{
291 ecc_start(size, databuffer, sparebuffer, ECCCTRL_STARTENCODING); 292 ecc_start(size, databuffer, sparebuffer, ECCCTRL_STARTENCODING);
292 ecc_collect(); 293 ecc_collect();
293 return 0; 294 return 0;
294} 295}
295 296
296uint32_t nand_check_empty(uint8_t* buffer) 297static uint32_t nand_check_empty(uint8_t* buffer)
297{ 298{
298 uint32_t i, count; 299 uint32_t i, count;
299 count = 0; 300 count = 0;
@@ -302,7 +303,7 @@ uint32_t nand_check_empty(uint8_t* buffer)
302 return 0; 303 return 0;
303} 304}
304 305
305uint32_t nand_get_chip_type(uint32_t bank) 306static uint32_t nand_get_chip_type(uint32_t bank)
306{ 307{
307 mutex_lock(&nand_mtx); 308 mutex_lock(&nand_mtx);
308 uint32_t result; 309 uint32_t result;
@@ -443,8 +444,9 @@ uint32_t nand_read_page(uint32_t bank, uint32_t page, void* databuffer,
443 return nand_unlock(rc); 444 return nand_unlock(rc);
444} 445}
445 446
446uint32_t nand_write_page_int(uint32_t bank, uint32_t page, void* databuffer, 447static uint32_t nand_write_page_int(uint32_t bank, uint32_t page,
447 void* sparebuffer, uint32_t doecc, uint32_t wait) 448 void* databuffer, void* sparebuffer,
449 uint32_t doecc, uint32_t wait)
448{ 450{
449 uint8_t* data = nand_data; 451 uint8_t* data = nand_data;
450 uint8_t* spare = nand_spare; 452 uint8_t* spare = nand_spare;
@@ -674,7 +676,8 @@ uint32_t nand_write_page_collect(uint32_t bank)
674 return nand_wait_status_ready(bank); 676 return nand_wait_status_ready(bank);
675} 677}
676 678
677uint32_t nand_block_erase_fast(uint32_t page) 679#if 0 /* currently unused */
680static uint32_t nand_block_erase_fast(uint32_t page)
678{ 681{
679 uint32_t i, rc = 0; 682 uint32_t i, rc = 0;
680 mutex_lock(&nand_mtx); 683 mutex_lock(&nand_mtx);
@@ -708,6 +711,7 @@ uint32_t nand_block_erase_fast(uint32_t page)
708 } 711 }
709 return nand_unlock(rc); 712 return nand_unlock(rc);
710} 713}
714#endif
711 715
712const struct nand_device_info_type* nand_get_device_type(uint32_t bank) 716const struct nand_device_info_type* nand_get_device_type(uint32_t bank)
713{ 717{
diff --git a/firmware/target/arm/s5l8700/ipodnano2g/pmu-nano2g.c b/firmware/target/arm/s5l8700/ipodnano2g/pmu-nano2g.c
index aea9b79b55..37cc1dcced 100644
--- a/firmware/target/arm/s5l8700/ipodnano2g/pmu-nano2g.c
+++ b/firmware/target/arm/s5l8700/ipodnano2g/pmu-nano2g.c
@@ -22,6 +22,7 @@
22#include "config.h" 22#include "config.h"
23#include "kernel.h" 23#include "kernel.h"
24#include "i2c-s5l8700.h" 24#include "i2c-s5l8700.h"
25#include "pmu-target.h"
25 26
26static struct mutex pmu_adc_mutex; 27static struct mutex pmu_adc_mutex;
27 28
diff --git a/firmware/target/arm/s5l8700/ipodnano2g/power-nano2g.c b/firmware/target/arm/s5l8700/ipodnano2g/power-nano2g.c
index a75cb39729..06876be3f5 100644
--- a/firmware/target/arm/s5l8700/ipodnano2g/power-nano2g.c
+++ b/firmware/target/arm/s5l8700/ipodnano2g/power-nano2g.c
@@ -23,12 +23,9 @@
23#include "inttypes.h" 23#include "inttypes.h"
24#include "s5l8700.h" 24#include "s5l8700.h"
25#include "power.h" 25#include "power.h"
26#include "ftl-target.h"
27#include <string.h>
28#include "panic.h" 26#include "panic.h"
29#include "pmu-target.h" 27#include "pmu-target.h"
30#include "lcd.h" 28#include "usb_core.h" /* for usb_charging_maxcurrent_change */
31
32 29
33void power_off(void) 30void power_off(void)
34{ 31{
diff --git a/firmware/target/arm/s5l8700/pcm-s5l8700.c b/firmware/target/arm/s5l8700/pcm-s5l8700.c
index e593039f64..0819088c02 100644
--- a/firmware/target/arm/s5l8700/pcm-s5l8700.c
+++ b/firmware/target/arm/s5l8700/pcm-s5l8700.c
@@ -41,10 +41,10 @@
41*/ 41*/
42 42
43static volatile int locked = 0; 43static volatile int locked = 0;
44size_t nextsize; 44static size_t nextsize;
45size_t dblbufsize; 45static size_t dblbufsize;
46int dmamode; 46static int dmamode;
47const unsigned char* dblbuf; 47static const unsigned char* dblbuf;
48 48
49/* table of recommended PLL/MCLK dividers for mode 256Fs from the datasheet */ 49/* table of recommended PLL/MCLK dividers for mode 256Fs from the datasheet */
50static const struct div_entry { 50static const struct div_entry {
diff --git a/firmware/target/arm/usb-s3c6400x.c b/firmware/target/arm/usb-s3c6400x.c
index 3f28e7f379..6fbf453cd1 100644
--- a/firmware/target/arm/usb-s3c6400x.c
+++ b/firmware/target/arm/usb-s3c6400x.c
@@ -21,6 +21,8 @@
21 21
22#include "config.h" 22#include "config.h"
23#include "usb.h" 23#include "usb.h"
24#include "usb-target.h"
25#include "usb_drv.h"
24 26
25#define OTGBASE 0x38800000 27#define OTGBASE 0x38800000
26#define PHYBASE 0x3C400000 28#define PHYBASE 0x3C400000
@@ -55,7 +57,7 @@ int usb_drv_port_speed(void)
55 return (DSTS & 2) == 0 ? 1 : 0; 57 return (DSTS & 2) == 0 ? 1 : 0;
56} 58}
57 59
58void reset_endpoints(int reinit) 60static void reset_endpoints(int reinit)
59{ 61{
60 unsigned int i; 62 unsigned int i;
61 for (i = 0; i < sizeof(endpoints)/sizeof(struct ep_type); i++) 63 for (i = 0; i < sizeof(endpoints)/sizeof(struct ep_type); i++)
@@ -268,7 +270,7 @@ void usb_drv_set_address(int address)
268 into the USB core, which will then call this dummy function. */ 270 into the USB core, which will then call this dummy function. */
269} 271}
270 272
271void ep_send(int ep, void *ptr, int length) 273static void ep_send(int ep, void *ptr, int length)
272{ 274{
273 endpoints[ep].busy = true; 275 endpoints[ep].busy = true;
274 endpoints[ep].size = length; 276 endpoints[ep].size = length;
@@ -289,7 +291,7 @@ void ep_send(int ep, void *ptr, int length)
289 DIEPCTL(ep) |= 0x84000000; /* EPx OUT ENABLE CLEARNAK */ 291 DIEPCTL(ep) |= 0x84000000; /* EPx OUT ENABLE CLEARNAK */
290} 292}
291 293
292void ep_recv(int ep, void *ptr, int length) 294static void ep_recv(int ep, void *ptr, int length)
293{ 295{
294 endpoints[ep].busy = true; 296 endpoints[ep].busy = true;
295 endpoints[ep].size = length; 297 endpoints[ep].size = length;