diff options
Diffstat (limited to 'firmware/target/arm')
-rw-r--r-- | firmware/target/arm/as3525/ata_sd_as3525.c | 81 | ||||
-rw-r--r-- | firmware/target/arm/ata-sd-pp.c | 44 | ||||
-rw-r--r-- | firmware/target/arm/sd-pp-target.h (renamed from firmware/target/arm/ata-sd-target.h) | 26 | ||||
-rw-r--r-- | firmware/target/arm/system-pp502x.c | 4 |
4 files changed, 67 insertions, 88 deletions
diff --git a/firmware/target/arm/as3525/ata_sd_as3525.c b/firmware/target/arm/as3525/ata_sd_as3525.c index a184e9fead..c0fad722b6 100644 --- a/firmware/target/arm/as3525/ata_sd_as3525.c +++ b/firmware/target/arm/as3525/ata_sd_as3525.c | |||
@@ -99,7 +99,7 @@ static void init_pl180_controller(const int drive); | |||
99 | #define SECTOR_SIZE 512 | 99 | #define SECTOR_SIZE 512 |
100 | #define BLOCKS_PER_BANK 0x7a7800 | 100 | #define BLOCKS_PER_BANK 0x7a7800 |
101 | 101 | ||
102 | static tSDCardInfo card_info[NUM_VOLUMES]; | 102 | static tCardInfo card_info[NUM_VOLUMES]; |
103 | 103 | ||
104 | /* maximum timeouts recommanded in the SD Specification v2.00 */ | 104 | /* maximum timeouts recommanded in the SD Specification v2.00 */ |
105 | #define SD_MAX_READ_TIMEOUT ((AS3525_PCLK_FREQ) / 1000 * 100) /* 100 ms */ | 105 | #define SD_MAX_READ_TIMEOUT ((AS3525_PCLK_FREQ) / 1000 * 100) /* 100 ms */ |
@@ -181,7 +181,7 @@ void INT_MCI0(void) | |||
181 | #endif | 181 | #endif |
182 | 182 | ||
183 | static bool send_cmd(const int drive, const int cmd, const int arg, | 183 | static bool send_cmd(const int drive, const int cmd, const int arg, |
184 | const int flags, int *response) | 184 | const int flags, long *response) |
185 | { | 185 | { |
186 | int val, status; | 186 | int val, status; |
187 | 187 | ||
@@ -243,9 +243,10 @@ static int sd_init_card(const int drive) | |||
243 | { | 243 | { |
244 | unsigned int c_size; | 244 | unsigned int c_size; |
245 | unsigned long c_mult; | 245 | unsigned long c_mult; |
246 | int response; | 246 | unsigned long response; |
247 | int max_tries = 100; /* max acmd41 attemps */ | 247 | int max_tries = 100; /* max acmd41 attemps */ |
248 | bool sdhc; | 248 | bool sdhc; |
249 | unsigned char temp; | ||
249 | 250 | ||
250 | if(!send_cmd(drive, SD_GO_IDLE_STATE, 0, MCI_NO_FLAGS, NULL)) | 251 | if(!send_cmd(drive, SD_GO_IDLE_STATE, 0, MCI_NO_FLAGS, NULL)) |
251 | return -1; | 252 | return -1; |
@@ -286,6 +287,15 @@ static int sd_init_card(const int drive) | |||
286 | card_info[drive].cid)) | 287 | card_info[drive].cid)) |
287 | return -5; | 288 | return -5; |
288 | 289 | ||
290 | /* ascii chars here */ | ||
291 | card_info[drive].cid[0] = htobe32(card_info[drive].cid[0]); | ||
292 | card_info[drive].cid[1] = htobe32(card_info[drive].cid[1]); | ||
293 | |||
294 | /* adjust year<=>month, 1997 <=> 2000 */ | ||
295 | temp = *((char*)card_info[drive].cid+13); | ||
296 | *((char*)card_info[drive].cid+13) = | ||
297 | (unsigned char)((temp >> 4) | (temp << 4)) + 3; | ||
298 | |||
289 | /* send RCA */ | 299 | /* send RCA */ |
290 | if(!send_cmd(drive, SD_SEND_RELATIVE_ADDR, 0, MCI_RESP|MCI_ARG, | 300 | if(!send_cmd(drive, SD_SEND_RELATIVE_ADDR, 0, MCI_RESP|MCI_ARG, |
291 | &card_info[drive].rca)) | 301 | &card_info[drive].rca)) |
@@ -299,23 +309,21 @@ static int sd_init_card(const int drive) | |||
299 | /* These calculations come from the Sandisk SD card product manual */ | 309 | /* These calculations come from the Sandisk SD card product manual */ |
300 | if( (card_info[drive].csd[3]>>30) == 0) | 310 | if( (card_info[drive].csd[3]>>30) == 0) |
301 | { | 311 | { |
312 | int max_read_bl_len; | ||
302 | /* CSD version 1.0 */ | 313 | /* CSD version 1.0 */ |
303 | c_size = ((card_info[drive].csd[2] & 0x3ff) << 2) + (card_info[drive].csd[1]>>30) + 1; | 314 | c_size = ((card_info[drive].csd[2] & 0x3ff) << 2) + (card_info[drive].csd[1]>>30) + 1; |
304 | c_mult = 4 << ((card_info[drive].csd[1] >> 15) & 7); | 315 | c_mult = 4 << ((card_info[drive].csd[1] >> 15) & 7); |
305 | card_info[drive].max_read_bl_len = 1 << ((card_info[drive].csd[2] >> 16) & 15); | 316 | max_read_bl_len = 1 << ((card_info[drive].csd[2] >> 16) & 15); |
306 | card_info[drive].block_size = BLOCK_SIZE; /* Always use 512 byte blocks */ | 317 | card_info[drive].blocksize = BLOCK_SIZE; /* Always use 512 byte blocks */ |
307 | card_info[drive].numblocks = c_size * c_mult * (card_info[drive].max_read_bl_len/512); | 318 | card_info[drive].numblocks = c_size * c_mult * (max_read_bl_len/512); |
308 | card_info[drive].capacity = card_info[drive].numblocks * card_info[drive].block_size; | ||
309 | } | 319 | } |
310 | #ifdef HAVE_MULTIVOLUME | 320 | #ifdef HAVE_MULTIVOLUME |
311 | else if( (card_info[drive].csd[3]>>30) == 1) | 321 | else if( (card_info[drive].csd[3]>>30) == 1) |
312 | { | 322 | { |
313 | /* CSD version 2.0 */ | 323 | /* CSD version 2.0 */ |
314 | c_size = ((card_info[drive].csd[2] & 0x3f) << 16) + (card_info[drive].csd[1]>>16) + 1; | 324 | c_size = ((card_info[drive].csd[2] & 0x3f) << 16) + (card_info[drive].csd[1]>>16) + 1; |
315 | card_info[drive].max_read_bl_len = 1 << ((card_info[drive].csd[2] >> 16) & 0xf); | 325 | card_info[drive].blocksize = BLOCK_SIZE; /* Always use 512 byte blocks */ |
316 | card_info[drive].block_size = BLOCK_SIZE; /* Always use 512 byte blocks */ | ||
317 | card_info[drive].numblocks = c_size << 10; | 326 | card_info[drive].numblocks = c_size << 10; |
318 | card_info[drive].capacity = card_info[drive].numblocks * card_info[drive].block_size; | ||
319 | } | 327 | } |
320 | #endif | 328 | #endif |
321 | 329 | ||
@@ -328,7 +336,7 @@ static int sd_init_card(const int drive) | |||
328 | if(!send_cmd(drive, SD_SET_BUS_WIDTH, card_info[drive].rca | 2, MCI_ARG, NULL)) | 336 | if(!send_cmd(drive, SD_SET_BUS_WIDTH, card_info[drive].rca | 2, MCI_ARG, NULL)) |
329 | return -11; | 337 | return -11; |
330 | 338 | ||
331 | if(!send_cmd(drive, SD_SET_BLOCKLEN, card_info[drive].block_size, MCI_ARG, | 339 | if(!send_cmd(drive, SD_SET_BLOCKLEN, card_info[drive].blocksize, MCI_ARG, |
332 | NULL)) | 340 | NULL)) |
333 | return -12; | 341 | return -12; |
334 | 342 | ||
@@ -518,7 +526,7 @@ void sd_get_info(IF_MV2(int drive,) struct storage_info *info) | |||
518 | #ifndef HAVE_MULTIVOLUME | 526 | #ifndef HAVE_MULTIVOLUME |
519 | const int drive=0; | 527 | const int drive=0; |
520 | #endif | 528 | #endif |
521 | info->sector_size=card_info[drive].block_size; | 529 | info->sector_size=card_info[drive].blocksize; |
522 | info->num_sectors=card_info[drive].numblocks; | 530 | info->num_sectors=card_info[drive].numblocks; |
523 | info->vendor="Rockbox"; | 531 | info->vendor="Rockbox"; |
524 | info->product = (drive == 0) ? "Internal Storage" : "SD Card Slot"; | 532 | info->product = (drive == 0) ? "Internal Storage" : "SD Card Slot"; |
@@ -546,7 +554,7 @@ bool sd_present(IF_MV_NONVOID(int drive)) | |||
546 | 554 | ||
547 | static int sd_wait_for_state(const int drive, unsigned int state) | 555 | static int sd_wait_for_state(const int drive, unsigned int state) |
548 | { | 556 | { |
549 | unsigned int response = 0; | 557 | unsigned long response = 0; |
550 | unsigned int timeout = 100; /* ticks */ | 558 | unsigned int timeout = 100; /* ticks */ |
551 | long t = current_tick; | 559 | long t = current_tick; |
552 | 560 | ||
@@ -686,7 +694,7 @@ static int sd_transfer_sectors(IF_MV2(int drive,) unsigned long start, | |||
686 | /* Only switch banks for internal storage */ | 694 | /* Only switch banks for internal storage */ |
687 | if(drive == INTERNAL_AS3525) | 695 | if(drive == INTERNAL_AS3525) |
688 | { | 696 | { |
689 | int bank = start / BLOCKS_PER_BANK; /* Current bank */ | 697 | unsigned int bank = start / BLOCKS_PER_BANK; /* Current bank */ |
690 | 698 | ||
691 | /* Switch bank if needed */ | 699 | /* Switch bank if needed */ |
692 | if(card_info[INTERNAL_AS3525].current_bank != bank) | 700 | if(card_info[INTERNAL_AS3525].current_bank != bank) |
@@ -737,7 +745,7 @@ static int sd_transfer_sectors(IF_MV2(int drive,) unsigned long start, | |||
737 | * Note : the OF doesn't seem to use them anyway */ | 745 | * Note : the OF doesn't seem to use them anyway */ |
738 | MCI_DATA_TIMER(drive) = write ? | 746 | MCI_DATA_TIMER(drive) = write ? |
739 | SD_MAX_WRITE_TIMEOUT : SD_MAX_READ_TIMEOUT; | 747 | SD_MAX_WRITE_TIMEOUT : SD_MAX_READ_TIMEOUT; |
740 | MCI_DATA_LENGTH(drive) = transfer * card_info[drive].block_size; | 748 | MCI_DATA_LENGTH(drive) = transfer * card_info[drive].blocksize; |
741 | MCI_DATA_CTRL(drive) = (1<<0) /* enable */ | | 749 | MCI_DATA_CTRL(drive) = (1<<0) /* enable */ | |
742 | (!write<<1) /* transfer direction */ | | 750 | (!write<<1) /* transfer direction */ | |
743 | (1<<3) /* DMA */ | | 751 | (1<<3) /* DMA */ | |
@@ -867,35 +875,24 @@ void sd_enable(bool on) | |||
867 | } | 875 | } |
868 | } | 876 | } |
869 | 877 | ||
870 | /* move the sd-card info to mmc struct */ | ||
871 | tCardInfo *card_get_info_target(int card_no) | 878 | tCardInfo *card_get_info_target(int card_no) |
872 | { | 879 | { |
873 | int i, temp; | 880 | unsigned char temp; |
874 | static tCardInfo card; | 881 | tCardInfo *card = &card_info[card_no]; |
875 | static const char mantissa[] = { /* *10 */ | 882 | |
876 | 0, 10, 12, 13, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 70, 80 }; | 883 | temp = card->csd[3]; |
877 | static const int exponent[] = { /* use varies */ | 884 | card->speed = sd_mantissa[temp & 7] * sd_exponent[(temp >> 3) & 0xf]; |
878 | 1,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000 }; | 885 | |
879 | 886 | temp = card->csd[3] >> 8; | |
880 | card.initialized = card_info[card_no].initialized; | 887 | card->nsac = 100 * temp; |
881 | card.ocr = card_info[card_no].ocr; | 888 | |
882 | for(i=0; i<4; i++) card.csd[i] = card_info[card_no].csd[i]; | 889 | temp = (card->csd[3] >> 16) & 0x7f; /* bit 7 reserved */ |
883 | for(i=0; i<4; i++) card.cid[i] = card_info[card_no].cid[i]; | 890 | card->taac = sd_mantissa[temp >> 3] * sd_exponent[temp & 7]; |
884 | card.numblocks = card_info[card_no].numblocks; | 891 | |
885 | card.blocksize = card_info[card_no].block_size; | 892 | temp = (card->csd[0] >> 26) & 7; |
886 | temp = card_extract_bits(card.csd, 29, 3); | 893 | card->r2w_factor = temp; |
887 | card.speed = mantissa[card_extract_bits(card.csd, 25, 4)] | 894 | |
888 | * exponent[temp > 2 ? 7 : temp + 4]; | 895 | return card; |
889 | card.nsac = 100 * card_extract_bits(card.csd, 16, 8); | ||
890 | temp = card_extract_bits(card.csd, 13, 3); | ||
891 | card.tsac = mantissa[card_extract_bits(card.csd, 9, 4)] | ||
892 | * exponent[temp] / 10; | ||
893 | card.cid[0] = htobe32(card.cid[0]); /* ascii chars here */ | ||
894 | card.cid[1] = htobe32(card.cid[1]); /* ascii chars here */ | ||
895 | temp = *((char*)card.cid+13); /* adjust year<=>month, 1997 <=> 2000 */ | ||
896 | *((char*)card.cid+13) = (unsigned char)((temp >> 4) | (temp << 4)) + 3; | ||
897 | |||
898 | return &card; | ||
899 | } | 896 | } |
900 | 897 | ||
901 | bool card_detect_target(void) | 898 | bool card_detect_target(void) |
diff --git a/firmware/target/arm/ata-sd-pp.c b/firmware/target/arm/ata-sd-pp.c index cd3b5ca3f9..ade5b8090b 100644 --- a/firmware/target/arm/ata-sd-pp.c +++ b/firmware/target/arm/ata-sd-pp.c | |||
@@ -21,7 +21,9 @@ | |||
21 | #include "config.h" /* for HAVE_MULTIVOLUME */ | 21 | #include "config.h" /* for HAVE_MULTIVOLUME */ |
22 | #include "fat.h" | 22 | #include "fat.h" |
23 | #include "hotswap.h" | 23 | #include "hotswap.h" |
24 | #include "ata-sd-target.h" | 24 | #ifdef HAVE_HOTSWAP |
25 | #include "sd-pp-target.h" | ||
26 | #endif | ||
25 | #include "ata_idle_notify.h" | 27 | #include "ata_idle_notify.h" |
26 | #include "system.h" | 28 | #include "system.h" |
27 | #include <string.h> | 29 | #include <string.h> |
@@ -156,8 +158,8 @@ static bool initialized = false; | |||
156 | static long next_yield = 0; | 158 | static long next_yield = 0; |
157 | #define MIN_YIELD_PERIOD 1000 | 159 | #define MIN_YIELD_PERIOD 1000 |
158 | 160 | ||
159 | static tSDCardInfo card_info[2]; | 161 | static tCardInfo card_info[2]; |
160 | static tSDCardInfo *currcard = NULL; /* current active card */ | 162 | static tCardInfo *currcard = NULL; /* current active card */ |
161 | 163 | ||
162 | struct sd_card_status | 164 | struct sd_card_status |
163 | { | 165 | { |
@@ -222,7 +224,7 @@ static bool sd_poll_status(unsigned int trigger, long timeout) | |||
222 | } | 224 | } |
223 | 225 | ||
224 | static int sd_command(unsigned int cmd, unsigned long arg1, | 226 | static int sd_command(unsigned int cmd, unsigned long arg1, |
225 | unsigned int *response, unsigned int cmdat) | 227 | unsigned long *response, unsigned int cmdat) |
226 | { | 228 | { |
227 | int i, words; /* Number of 16 bit words to read from MMC_RES */ | 229 | int i, words; /* Number of 16 bit words to read from MMC_RES */ |
228 | unsigned int data[9]; | 230 | unsigned int data[9]; |
@@ -303,7 +305,7 @@ static int sd_command(unsigned int cmd, unsigned long arg1, | |||
303 | 305 | ||
304 | static int sd_wait_for_state(unsigned int state, int id) | 306 | static int sd_wait_for_state(unsigned int state, int id) |
305 | { | 307 | { |
306 | unsigned int response = 0; | 308 | unsigned long response = 0; |
307 | unsigned int timeout = 0x80000; | 309 | unsigned int timeout = 0x80000; |
308 | 310 | ||
309 | check_time[id] = USEC_TIMER; | 311 | check_time[id] = USEC_TIMER; |
@@ -647,7 +649,7 @@ static void sd_init_device(int card_no) | |||
647 | { | 649 | { |
648 | /* SD Protocol registers */ | 650 | /* SD Protocol registers */ |
649 | #ifdef HAVE_HOTSWAP | 651 | #ifdef HAVE_HOTSWAP |
650 | unsigned int response = 0; | 652 | unsigned long response = 0; |
651 | #endif | 653 | #endif |
652 | unsigned int i; | 654 | unsigned int i; |
653 | unsigned int c_size; | 655 | unsigned int c_size; |
@@ -746,23 +748,21 @@ static void sd_init_device(int card_no) | |||
746 | /* These calculations come from the Sandisk SD card product manual */ | 748 | /* These calculations come from the Sandisk SD card product manual */ |
747 | if( (currcard->csd[3]>>30) == 0) | 749 | if( (currcard->csd[3]>>30) == 0) |
748 | { | 750 | { |
751 | int max_read_bl_len; | ||
749 | /* CSD version 1.0 */ | 752 | /* CSD version 1.0 */ |
750 | c_size = ((currcard->csd[2] & 0x3ff) << 2) + (currcard->csd[1]>>30) + 1; | 753 | c_size = ((currcard->csd[2] & 0x3ff) << 2) + (currcard->csd[1]>>30) + 1; |
751 | c_mult = 4 << ((currcard->csd[1] >> 15) & 7); | 754 | c_mult = 4 << ((currcard->csd[1] >> 15) & 7); |
752 | currcard->max_read_bl_len = 1 << ((currcard->csd[2] >> 16) & 15); | 755 | max_read_bl_len = 1 << ((currcard->csd[2] >> 16) & 15); |
753 | currcard->block_size = BLOCK_SIZE; /* Always use 512 byte blocks */ | 756 | currcard->blocksize = BLOCK_SIZE; /* Always use 512 byte blocks */ |
754 | currcard->numblocks = c_size * c_mult * (currcard->max_read_bl_len/512); | 757 | currcard->numblocks = c_size * c_mult * (max_read_bl_len/512); |
755 | currcard->capacity = currcard->numblocks * currcard->block_size; | ||
756 | } | 758 | } |
757 | #ifdef HAVE_HOTSWAP | 759 | #ifdef HAVE_HOTSWAP |
758 | else if( (currcard->csd[3]>>30) == 1) | 760 | else if( (currcard->csd[3]>>30) == 1) |
759 | { | 761 | { |
760 | /* CSD version 2.0 */ | 762 | /* CSD version 2.0 */ |
761 | c_size = ((currcard->csd[2] & 0x3f) << 16) + (currcard->csd[1]>>16) + 1; | 763 | c_size = ((currcard->csd[2] & 0x3f) << 16) + (currcard->csd[1]>>16) + 1; |
762 | currcard->max_read_bl_len = 1 << ((currcard->csd[2] >> 16) & 0xf); | 764 | currcard->blocksize = BLOCK_SIZE; /* Always use 512 byte blocks */ |
763 | currcard->block_size = BLOCK_SIZE; /* Always use 512 byte blocks */ | ||
764 | currcard->numblocks = c_size << 10; | 765 | currcard->numblocks = c_size << 10; |
765 | currcard->capacity = currcard->numblocks * currcard->block_size; | ||
766 | } | 766 | } |
767 | #endif /* HAVE_HOTSWAP */ | 767 | #endif /* HAVE_HOTSWAP */ |
768 | 768 | ||
@@ -782,12 +782,12 @@ static void sd_init_device(int card_no) | |||
782 | if (ret < 0) | 782 | if (ret < 0) |
783 | goto card_init_error; | 783 | goto card_init_error; |
784 | 784 | ||
785 | ret = sd_command(SD_SET_BLOCKLEN, currcard->block_size, NULL, | 785 | ret = sd_command(SD_SET_BLOCKLEN, currcard->blocksize, NULL, |
786 | CMDAT_RES_TYPE1); | 786 | CMDAT_RES_TYPE1); |
787 | if (ret < 0) | 787 | if (ret < 0) |
788 | goto card_init_error; | 788 | goto card_init_error; |
789 | 789 | ||
790 | MMC_BLKLEN = currcard->block_size; | 790 | MMC_BLKLEN = currcard->blocksize; |
791 | 791 | ||
792 | /* If this card is >4GB & not SDHC, then we need to enable bank switching */ | 792 | /* If this card is >4GB & not SDHC, then we need to enable bank switching */ |
793 | if( (currcard->numblocks >= BLOCKS_PER_BANK) && | 793 | if( (currcard->numblocks >= BLOCKS_PER_BANK) && |
@@ -867,7 +867,7 @@ int sd_read_sectors(IF_MV2(int drive,) unsigned long start, int incount, | |||
867 | #endif | 867 | #endif |
868 | int ret; | 868 | int ret; |
869 | unsigned char *buf, *buf_end; | 869 | unsigned char *buf, *buf_end; |
870 | int bank; | 870 | unsigned int bank; |
871 | 871 | ||
872 | /* TODO: Add DMA support. */ | 872 | /* TODO: Add DMA support. */ |
873 | 873 | ||
@@ -932,7 +932,7 @@ sd_read_retry: | |||
932 | 932 | ||
933 | /* TODO: Don't assume BLOCK_SIZE == SECTOR_SIZE */ | 933 | /* TODO: Don't assume BLOCK_SIZE == SECTOR_SIZE */ |
934 | 934 | ||
935 | buf_end = (unsigned char *)inbuf + incount * currcard->block_size; | 935 | buf_end = (unsigned char *)inbuf + incount * currcard->blocksize; |
936 | for (buf = inbuf; buf < buf_end;) | 936 | for (buf = inbuf; buf < buf_end;) |
937 | { | 937 | { |
938 | /* Wait for the FIFO to be full */ | 938 | /* Wait for the FIFO to be full */ |
@@ -987,7 +987,7 @@ int sd_write_sectors(IF_MV2(int drive,) unsigned long start, int count, | |||
987 | #endif | 987 | #endif |
988 | int ret; | 988 | int ret; |
989 | const unsigned char *buf, *buf_end; | 989 | const unsigned char *buf, *buf_end; |
990 | int bank; | 990 | unsigned int bank; |
991 | 991 | ||
992 | mutex_lock(&sd_mtx); | 992 | mutex_lock(&sd_mtx); |
993 | sd_enable(true); | 993 | sd_enable(true); |
@@ -1048,7 +1048,7 @@ sd_write_retry: | |||
1048 | if (ret < 0) | 1048 | if (ret < 0) |
1049 | goto sd_write_error; | 1049 | goto sd_write_error; |
1050 | 1050 | ||
1051 | buf_end = outbuf + count * currcard->block_size - 2*FIFO_LEN; | 1051 | buf_end = outbuf + count * currcard->blocksize - 2*FIFO_LEN; |
1052 | 1052 | ||
1053 | for (buf = outbuf; buf <= buf_end;) | 1053 | for (buf = outbuf; buf <= buf_end;) |
1054 | { | 1054 | { |
@@ -1305,13 +1305,13 @@ tCardInfo *card_get_info_target(int card_no) | |||
1305 | for(i=0; i<4; i++) card.csd[i] = card_info[card_no].csd[3-i]; | 1305 | for(i=0; i<4; i++) card.csd[i] = card_info[card_no].csd[3-i]; |
1306 | for(i=0; i<4; i++) card.cid[i] = card_info[card_no].cid[3-i]; | 1306 | for(i=0; i<4; i++) card.cid[i] = card_info[card_no].cid[3-i]; |
1307 | card.numblocks = card_info[card_no].numblocks; | 1307 | card.numblocks = card_info[card_no].numblocks; |
1308 | card.blocksize = card_info[card_no].block_size; | 1308 | card.blocksize = card_info[card_no].blocksize; |
1309 | temp = card_extract_bits(card.csd, 29, 3); | 1309 | temp = card_extract_bits(card.csd, 29, 3); |
1310 | card.speed = mantissa[card_extract_bits(card.csd, 25, 4)] | 1310 | card.speed = mantissa[card_extract_bits(card.csd, 25, 4)] |
1311 | * exponent[temp > 2 ? 7 : temp + 4]; | 1311 | * exponent[temp > 2 ? 7 : temp + 4]; |
1312 | card.nsac = 100 * card_extract_bits(card.csd, 16, 8); | 1312 | card.nsac = 100 * card_extract_bits(card.csd, 16, 8); |
1313 | temp = card_extract_bits(card.csd, 13, 3); | 1313 | temp = card_extract_bits(card.csd, 13, 3); |
1314 | card.tsac = mantissa[card_extract_bits(card.csd, 9, 4)] | 1314 | card.taac = mantissa[card_extract_bits(card.csd, 9, 4)] |
1315 | * exponent[temp] / 10; | 1315 | * exponent[temp] / 10; |
1316 | card.cid[0] = htobe32(card.cid[0]); /* ascii chars here */ | 1316 | card.cid[0] = htobe32(card.cid[0]); /* ascii chars here */ |
1317 | card.cid[1] = htobe32(card.cid[1]); /* ascii chars here */ | 1317 | card.cid[1] = htobe32(card.cid[1]); /* ascii chars here */ |
@@ -1381,7 +1381,7 @@ void sd_get_info(IF_MV2(int drive,) struct storage_info *info) | |||
1381 | #ifndef HAVE_MULTIVOLUME | 1381 | #ifndef HAVE_MULTIVOLUME |
1382 | const int drive=0; | 1382 | const int drive=0; |
1383 | #endif | 1383 | #endif |
1384 | info->sector_size=card_info[drive].block_size; | 1384 | info->sector_size=card_info[drive].blocksize; |
1385 | info->num_sectors=card_info[drive].numblocks; | 1385 | info->num_sectors=card_info[drive].numblocks; |
1386 | info->vendor="Rockbox"; | 1386 | info->vendor="Rockbox"; |
1387 | if(drive==0) | 1387 | if(drive==0) |
diff --git a/firmware/target/arm/ata-sd-target.h b/firmware/target/arm/sd-pp-target.h index b2ac6e2a57..222daa1a52 100644 --- a/firmware/target/arm/ata-sd-target.h +++ b/firmware/target/arm/sd-pp-target.h | |||
@@ -21,32 +21,12 @@ | |||
21 | #ifndef ATA_SD_TARGET_H | 21 | #ifndef ATA_SD_TARGET_H |
22 | #define ATA_SD_TARGET_H | 22 | #define ATA_SD_TARGET_H |
23 | 23 | ||
24 | #include "inttypes.h" | 24 | #ifdef CPU_PP /* PortalPlayer specific functions */ |
25 | #include "hotswap.h" | ||
26 | |||
27 | typedef struct | ||
28 | { | ||
29 | int initialized; | ||
30 | |||
31 | unsigned int ocr; /* OCR register */ | ||
32 | unsigned int csd[4]; /* CSD register */ | ||
33 | unsigned int cid[4]; /* CID register */ | ||
34 | unsigned int rca; | ||
35 | |||
36 | uint64_t capacity; /* size in bytes */ | ||
37 | unsigned long numblocks; /* size in flash blocks */ | ||
38 | unsigned int block_size; /* block size in bytes */ | ||
39 | unsigned int max_read_bl_len;/* max read data block length */ | ||
40 | unsigned int block_exp; /* block size exponent */ | ||
41 | unsigned char current_bank; /* The bank that we are working with */ | ||
42 | } tSDCardInfo; | ||
43 | |||
44 | tCardInfo *card_get_info_target(int card_no); | ||
45 | bool card_detect_target(void); | ||
46 | 25 | ||
47 | #ifdef HAVE_HOTSWAP | 26 | #ifdef HAVE_HOTSWAP |
48 | void card_enable_monitoring_target(bool on); | ||
49 | void microsd_int(void); | 27 | void microsd_int(void); |
50 | #endif | 28 | #endif |
51 | 29 | ||
52 | #endif | 30 | #endif |
31 | |||
32 | #endif | ||
diff --git a/firmware/target/arm/system-pp502x.c b/firmware/target/arm/system-pp502x.c index 4735cd8d83..967144ad0b 100644 --- a/firmware/target/arm/system-pp502x.c +++ b/firmware/target/arm/system-pp502x.c | |||
@@ -23,7 +23,9 @@ | |||
23 | #include "i2s.h" | 23 | #include "i2s.h" |
24 | #include "i2c-pp.h" | 24 | #include "i2c-pp.h" |
25 | #include "as3514.h" | 25 | #include "as3514.h" |
26 | #include "ata-sd-target.h" | 26 | #ifdef HAVE_HOTSWAP |
27 | #include "sd-pp-target.h" | ||
28 | #endif | ||
27 | #include "button-target.h" | 29 | #include "button-target.h" |
28 | #include "usb-target.h" | 30 | #include "usb-target.h" |
29 | #include "usb_drv.h" | 31 | #include "usb_drv.h" |