summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/target/arm/sandisk/sansa-e200/ata-e200.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/firmware/target/arm/sandisk/sansa-e200/ata-e200.c b/firmware/target/arm/sandisk/sansa-e200/ata-e200.c
index 8323574d69..87a70a5d32 100644
--- a/firmware/target/arm/sandisk/sansa-e200/ata-e200.c
+++ b/firmware/target/arm/sandisk/sansa-e200/ata-e200.c
@@ -32,6 +32,7 @@
32 32
33#define BLOCK_SIZE (512) 33#define BLOCK_SIZE (512)
34#define SECTOR_SIZE (512) 34#define SECTOR_SIZE (512)
35#define BLOCKS_PER_BANK 0x7a7800
35 36
36#define STATUS_REG (*(volatile unsigned int *)(0x70008204)) 37#define STATUS_REG (*(volatile unsigned int *)(0x70008204))
37#define REG_1 (*(volatile unsigned int *)(0x70008208)) 38#define REG_1 (*(volatile unsigned int *)(0x70008208))
@@ -440,7 +441,7 @@ void sd_init_device(void)
440 BLOCK_SIZE_REG = card->block_size; 441 BLOCK_SIZE_REG = card->block_size;
441 442
442 /* If this card is > 4Gb, then we need to enable bank switching */ 443 /* If this card is > 4Gb, then we need to enable bank switching */
443 if(card->numblocks > 0x7a77ff) 444 if(card->numblocks >= BLOCKS_PER_BANK)
444 { 445 {
445 SD_STATE_REG = TRAN; 446 SD_STATE_REG = TRAN;
446 BLOCK_COUNT_REG = 1; 447 BLOCK_COUNT_REG = 1;
@@ -502,10 +503,10 @@ int ata_read_sectors(IF_MV2(int drive,)
502 /* TODO: Select device */ 503 /* TODO: Select device */
503 if(current_card == 0) 504 if(current_card == 0)
504 { 505 {
505 if(start > 0x7a77ff) 506 if(start >= BLOCKS_PER_BANK)
506 { 507 {
507 sd_select_bank(1); 508 sd_select_bank(1);
508 start-=0x7a77ff; 509 start -= BLOCKS_PER_BANK;
509 } else { 510 } else {
510 sd_select_bank(0); 511 sd_select_bank(0);
511 } 512 }
@@ -571,12 +572,12 @@ int ata_write_sectors(IF_MV2(int drive,)
571 ata_led(true); 572 ata_led(true);
572 if(current_card == 0) 573 if(current_card == 0)
573 { 574 {
574 if(start <= 0x7a77ff) 575 if(start < BLOCKS_PER_BANK)
575 { 576 {
576 sd_select_bank(0); 577 sd_select_bank(0);
577 } else { 578 } else {
578 sd_select_bank(1); 579 sd_select_bank(1);
579 start -= 0x7a77ff; 580 start -= BLOCKS_PER_BANK;
580 } 581 }
581 } 582 }
582 583