diff options
author | Frank Gevaerts <frank@gevaerts.be> | 2009-07-17 22:28:49 +0000 |
---|---|---|
committer | Frank Gevaerts <frank@gevaerts.be> | 2009-07-17 22:28:49 +0000 |
commit | c0a5a67387c4eec3db3bad4da77ba5126faf03c4 (patch) | |
tree | d7e61f6287c5fcdce903489b6b72d474225b98a7 /firmware/target/arm/as3525 | |
parent | bb3b57f64594ba517e06add4cfeff72b2b06e65b (diff) | |
download | rockbox-c0a5a67387c4eec3db3bad4da77ba5126faf03c4.tar.gz rockbox-c0a5a67387c4eec3db3bad4da77ba5126faf03c4.zip |
Commit FS#9545, storage cleanup and multi-driver support
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21933 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/as3525')
-rw-r--r-- | firmware/target/arm/as3525/ata_sd_as3525.c | 58 |
1 files changed, 36 insertions, 22 deletions
diff --git a/firmware/target/arm/as3525/ata_sd_as3525.c b/firmware/target/arm/as3525/ata_sd_as3525.c index 8a18a70826..bca52a09f1 100644 --- a/firmware/target/arm/as3525/ata_sd_as3525.c +++ b/firmware/target/arm/as3525/ata_sd_as3525.c | |||
@@ -24,7 +24,7 @@ | |||
24 | 24 | ||
25 | /* TODO: Find the real capacity of >2GB models (will be useful for USB) */ | 25 | /* TODO: Find the real capacity of >2GB models (will be useful for USB) */ |
26 | 26 | ||
27 | #include "config.h" /* for HAVE_MULTIVOLUME & AMS_OF_SIZE */ | 27 | #include "config.h" /* for HAVE_MULTIDRIVE & AMS_OF_SIZE */ |
28 | #include "fat.h" | 28 | #include "fat.h" |
29 | #include "thread.h" | 29 | #include "thread.h" |
30 | #include "led.h" | 30 | #include "led.h" |
@@ -88,9 +88,9 @@ | |||
88 | #define INTERNAL_AS3525 0 /* embedded SD card */ | 88 | #define INTERNAL_AS3525 0 /* embedded SD card */ |
89 | #define SD_SLOT_AS3525 1 /* SD slot if present */ | 89 | #define SD_SLOT_AS3525 1 /* SD slot if present */ |
90 | 90 | ||
91 | static const int pl180_base[NUM_VOLUMES] = { | 91 | static const int pl180_base[NUM_DRIVES] = { |
92 | NAND_FLASH_BASE | 92 | NAND_FLASH_BASE |
93 | #ifdef HAVE_MULTIVOLUME | 93 | #ifdef HAVE_MULTIDRIVE |
94 | , SD_MCI_BASE | 94 | , SD_MCI_BASE |
95 | #endif | 95 | #endif |
96 | }; | 96 | }; |
@@ -101,7 +101,7 @@ static void init_pl180_controller(const int drive); | |||
101 | #define SECTOR_SIZE 512 /* XXX: different sector sizes ? */ | 101 | #define SECTOR_SIZE 512 /* XXX: different sector sizes ? */ |
102 | #define BLOCKS_PER_BANK 0x7a7800 | 102 | #define BLOCKS_PER_BANK 0x7a7800 |
103 | 103 | ||
104 | static tCardInfo card_info[NUM_VOLUMES]; | 104 | static tCardInfo card_info[NUM_DRIVES]; |
105 | 105 | ||
106 | /* maximum timeouts recommanded in the SD Specification v2.00 */ | 106 | /* maximum timeouts recommanded in the SD Specification v2.00 */ |
107 | #define SD_MAX_READ_TIMEOUT ((AS3525_PCLK_FREQ) / 1000 * 100) /* 100 ms */ | 107 | #define SD_MAX_READ_TIMEOUT ((AS3525_PCLK_FREQ) / 1000 * 100) /* 100 ms */ |
@@ -169,7 +169,7 @@ void INT_NAND(void) | |||
169 | MCI_CLEAR(INTERNAL_AS3525) = status; | 169 | MCI_CLEAR(INTERNAL_AS3525) = status; |
170 | } | 170 | } |
171 | 171 | ||
172 | #ifdef HAVE_MULTIVOLUME | 172 | #ifdef HAVE_MULTIDRIVE |
173 | void INT_MCI0(void) | 173 | void INT_MCI0(void) |
174 | { | 174 | { |
175 | const int status = MCI_STATUS(SD_SLOT_AS3525); | 175 | const int status = MCI_STATUS(SD_SLOT_AS3525); |
@@ -436,7 +436,7 @@ static void init_pl180_controller(const int drive) | |||
436 | 436 | ||
437 | MCI_MASK0(drive) = MCI_MASK1(drive) = MCI_ERROR | MCI_DATA_END; | 437 | MCI_MASK0(drive) = MCI_MASK1(drive) = MCI_ERROR | MCI_DATA_END; |
438 | 438 | ||
439 | #ifdef HAVE_MULTIVOLUME | 439 | #ifdef HAVE_MULTIDRIVE |
440 | VIC_INT_ENABLE |= | 440 | VIC_INT_ENABLE |= |
441 | (drive == INTERNAL_AS3525) ? INTERRUPT_NAND : INTERRUPT_MCI0; | 441 | (drive == INTERNAL_AS3525) ? INTERRUPT_NAND : INTERRUPT_MCI0; |
442 | 442 | ||
@@ -478,7 +478,7 @@ int sd_init(void) | |||
478 | 478 | ||
479 | 479 | ||
480 | CGU_PERI |= CGU_NAF_CLOCK_ENABLE; | 480 | CGU_PERI |= CGU_NAF_CLOCK_ENABLE; |
481 | #ifdef HAVE_MULTIVOLUME | 481 | #ifdef HAVE_MULTIDRIVE |
482 | CGU_PERI |= CGU_MCI_CLOCK_ENABLE; | 482 | CGU_PERI |= CGU_MCI_CLOCK_ENABLE; |
483 | CCU_IO &= ~(1<<3); /* bits 3:2 = 01, xpd is SD interface */ | 483 | CCU_IO &= ~(1<<3); /* bits 3:2 = 01, xpd is SD interface */ |
484 | CCU_IO |= (1<<2); | 484 | CCU_IO |= (1<<2); |
@@ -490,7 +490,7 @@ int sd_init(void) | |||
490 | ret = sd_init_card(INTERNAL_AS3525); | 490 | ret = sd_init_card(INTERNAL_AS3525); |
491 | if(ret < 0) | 491 | if(ret < 0) |
492 | return ret; | 492 | return ret; |
493 | #ifdef HAVE_MULTIVOLUME | 493 | #ifdef HAVE_MULTIDRIVE |
494 | init_pl180_controller(SD_SLOT_AS3525); | 494 | init_pl180_controller(SD_SLOT_AS3525); |
495 | #endif | 495 | #endif |
496 | 496 | ||
@@ -509,17 +509,17 @@ int sd_init(void) | |||
509 | } | 509 | } |
510 | 510 | ||
511 | #ifdef HAVE_HOTSWAP | 511 | #ifdef HAVE_HOTSWAP |
512 | bool sd_removable(IF_MV_NONVOID(int drive)) | 512 | bool sd_removable(IF_MD_NONVOID(int drive)) |
513 | { | 513 | { |
514 | #ifndef HAVE_MULTIVOLUME | 514 | #ifndef HAVE_MULTIDRIVE |
515 | const int drive=0; | 515 | const int drive=0; |
516 | #endif | 516 | #endif |
517 | return (drive==1); | 517 | return (drive==1); |
518 | } | 518 | } |
519 | 519 | ||
520 | bool sd_present(IF_MV_NONVOID(int drive)) | 520 | bool sd_present(IF_MD_NONVOID(int drive)) |
521 | { | 521 | { |
522 | #ifndef HAVE_MULTIVOLUME | 522 | #ifndef HAVE_MULTIDRIVE |
523 | const int drive=0; | 523 | const int drive=0; |
524 | #endif | 524 | #endif |
525 | return (card_info[drive].initialized && card_info[drive].numblocks > 0); | 525 | return (card_info[drive].initialized && card_info[drive].numblocks > 0); |
@@ -619,10 +619,10 @@ static int sd_select_bank(signed char bank) | |||
619 | return 0; | 619 | return 0; |
620 | } | 620 | } |
621 | 621 | ||
622 | static int sd_transfer_sectors(IF_MV2(int drive,) unsigned long start, | 622 | static int sd_transfer_sectors(IF_MD2(int drive,) unsigned long start, |
623 | int count, void* buf, const bool write) | 623 | int count, void* buf, const bool write) |
624 | { | 624 | { |
625 | #ifndef HAVE_MULTIVOLUME | 625 | #ifndef HAVE_MULTIDRIVE |
626 | const int drive = 0; | 626 | const int drive = 0; |
627 | #endif | 627 | #endif |
628 | int ret = 0; | 628 | int ret = 0; |
@@ -774,18 +774,18 @@ sd_transfer_error: | |||
774 | return ret; | 774 | return ret; |
775 | } | 775 | } |
776 | 776 | ||
777 | int sd_read_sectors(IF_MV2(int drive,) unsigned long start, int count, | 777 | int sd_read_sectors(IF_MD2(int drive,) unsigned long start, int count, |
778 | void* buf) | 778 | void* buf) |
779 | { | 779 | { |
780 | return sd_transfer_sectors(IF_MV2(drive,) start, count, buf, false); | 780 | return sd_transfer_sectors(IF_MD2(drive,) start, count, buf, false); |
781 | } | 781 | } |
782 | 782 | ||
783 | int sd_write_sectors(IF_MV2(int drive,) unsigned long start, int count, | 783 | int sd_write_sectors(IF_MD2(int drive,) unsigned long start, int count, |
784 | const void* buf) | 784 | const void* buf) |
785 | { | 785 | { |
786 | 786 | ||
787 | #ifdef BOOTLOADER /* we don't need write support in bootloader */ | 787 | #ifdef BOOTLOADER /* we don't need write support in bootloader */ |
788 | #ifdef HAVE_MULTIVOLUME | 788 | #ifdef HAVE_MULTIDRIVE |
789 | (void) drive; | 789 | (void) drive; |
790 | #endif | 790 | #endif |
791 | (void) start; | 791 | (void) start; |
@@ -793,7 +793,7 @@ int sd_write_sectors(IF_MV2(int drive,) unsigned long start, int count, | |||
793 | (void) buf; | 793 | (void) buf; |
794 | return -1; | 794 | return -1; |
795 | #else | 795 | #else |
796 | return sd_transfer_sectors(IF_MV2(drive,) start, count, (void*)buf, true); | 796 | return sd_transfer_sectors(IF_MD2(drive,) start, count, (void*)buf, true); |
797 | #endif | 797 | #endif |
798 | } | 798 | } |
799 | 799 | ||
@@ -807,7 +807,7 @@ void sd_enable(bool on) | |||
807 | { | 807 | { |
808 | /* buttonlight AMSes need a bit of special handling for the buttonlight here, | 808 | /* buttonlight AMSes need a bit of special handling for the buttonlight here, |
809 | * due to the dual mapping of GPIOD and XPD */ | 809 | * due to the dual mapping of GPIOD and XPD */ |
810 | #if defined(HAVE_BUTTON_LIGHT) && defined(HAVE_MULTIVOLUME) | 810 | #if defined(HAVE_BUTTON_LIGHT) && defined(HAVE_MULTIDRIVE) |
811 | extern int buttonlight_is_on; | 811 | extern int buttonlight_is_on; |
812 | #endif | 812 | #endif |
813 | if (sd_enabled == on) | 813 | if (sd_enabled == on) |
@@ -815,7 +815,7 @@ void sd_enable(bool on) | |||
815 | if(on) | 815 | if(on) |
816 | { | 816 | { |
817 | CGU_PERI |= CGU_NAF_CLOCK_ENABLE; | 817 | CGU_PERI |= CGU_NAF_CLOCK_ENABLE; |
818 | #ifdef HAVE_MULTIVOLUME | 818 | #ifdef HAVE_MULTIDRIVE |
819 | CGU_PERI |= CGU_MCI_CLOCK_ENABLE; | 819 | CGU_PERI |= CGU_MCI_CLOCK_ENABLE; |
820 | #ifdef HAVE_BUTTON_LIGHT | 820 | #ifdef HAVE_BUTTON_LIGHT |
821 | CCU_IO |= (1<<2); | 821 | CCU_IO |= (1<<2); |
@@ -832,7 +832,7 @@ void sd_enable(bool on) | |||
832 | else | 832 | else |
833 | { | 833 | { |
834 | CGU_PERI &= ~CGU_NAF_CLOCK_ENABLE; | 834 | CGU_PERI &= ~CGU_NAF_CLOCK_ENABLE; |
835 | #ifdef HAVE_MULTIVOLUME | 835 | #ifdef HAVE_MULTIDRIVE |
836 | #ifdef HAVE_BUTTON_LIGHT | 836 | #ifdef HAVE_BUTTON_LIGHT |
837 | CCU_IO &= ~(1<<2); | 837 | CCU_IO &= ~(1<<2); |
838 | if (buttonlight_is_on) | 838 | if (buttonlight_is_on) |
@@ -882,3 +882,17 @@ void card_enable_monitoring_target(bool on) | |||
882 | #endif | 882 | #endif |
883 | 883 | ||
884 | #endif /* BOOTLOADER */ | 884 | #endif /* BOOTLOADER */ |
885 | |||
886 | #ifdef CONFIG_STORAGE_MULTI | ||
887 | int sd_num_drives(int first_drive) | ||
888 | { | ||
889 | /* We don't care which logical drive number(s) we have been assigned */ | ||
890 | (void)first_drive; | ||
891 | |||
892 | #ifdef HAVE_MULTIDRIVE | ||
893 | return 2; | ||
894 | #else | ||
895 | return 1; | ||
896 | #endif | ||
897 | } | ||
898 | #endif | ||