summaryrefslogtreecommitdiff
path: root/firmware/drivers/ata_mmc.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers/ata_mmc.c')
-rw-r--r--firmware/drivers/ata_mmc.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/firmware/drivers/ata_mmc.c b/firmware/drivers/ata_mmc.c
index ba79cc516a..a62f778cfd 100644
--- a/firmware/drivers/ata_mmc.c
+++ b/firmware/drivers/ata_mmc.c
@@ -110,7 +110,9 @@ static unsigned char sector_buffer[2][(SECTOR_SIZE+4)];
110static int current_buffer = 0; 110static int current_buffer = 0;
111 111
112static tCardInfo card_info[2]; 112static tCardInfo card_info[2];
113#ifndef HAVE_MULTIVOLUME
113static int current_card = 0; 114static int current_card = 0;
115#endif
114static bool last_mmc_status = false; 116static bool last_mmc_status = false;
115static int countdown; /* for mmc switch debouncing */ 117static int countdown; /* for mmc switch debouncing */
116 118
@@ -620,15 +622,17 @@ int ata_read_sectors(
620 unsigned char response; 622 unsigned char response;
621 void *inbuf_prev = NULL; 623 void *inbuf_prev = NULL;
622 tCardInfo *card; 624 tCardInfo *card;
623#ifdef HAVE_MULTIVOLUME 625
624 current_card = drive;
625#endif
626 card = &card_info[current_card];
627 addr = start * SECTOR_SIZE; 626 addr = start * SECTOR_SIZE;
628 627
629 mutex_lock(&mmc_mutex); 628 mutex_lock(&mmc_mutex);
629#ifdef HAVE_MULTIVOLUME
630 card = &card_info[drive];
631 ret = select_card(drive);
632#else
633 card = &card_info[current_card];
630 ret = select_card(current_card); 634 ret = select_card(current_card);
631 635#endif
632 if (ret == 0) 636 if (ret == 0)
633 { 637 {
634 if (incount == 1) 638 if (incount == 1)
@@ -678,10 +682,6 @@ int ata_write_sectors(IF_MV2(int drive,)
678 unsigned long addr; 682 unsigned long addr;
679 unsigned char response; 683 unsigned char response;
680 tCardInfo *card; 684 tCardInfo *card;
681#ifdef HAVE_MULTIVOLUME
682 current_card = drive;
683#endif
684 card = &card_info[current_card];
685 685
686 if (start == 0) 686 if (start == 0)
687 panicf("Writing on sector 0\n"); 687 panicf("Writing on sector 0\n");
@@ -689,7 +689,13 @@ int ata_write_sectors(IF_MV2(int drive,)
689 addr = start * SECTOR_SIZE; 689 addr = start * SECTOR_SIZE;
690 690
691 mutex_lock(&mmc_mutex); 691 mutex_lock(&mmc_mutex);
692#ifdef HAVE_MULTIVOLUME
693 card = &card_info[drive];
694 ret = select_card(drive);
695#else
696 card = &card_info[current_card];
692 ret = select_card(current_card); 697 ret = select_card(current_card);
698#endif
693 699
694 if (ret == 0) 700 if (ret == 0)
695 { 701 {
@@ -859,6 +865,7 @@ int ata_init(void)
859 PBIOR &= ~0x0C00; /* TxD1, RxD1 input */ 865 PBIOR &= ~0x0C00; /* TxD1, RxD1 input */
860 866
861 last_mmc_status = mmc_detect(); 867 last_mmc_status = mmc_detect();
868#ifndef HAVE_MULTIVOLUME
862 if (last_mmc_status) 869 if (last_mmc_status)
863 { /* MMC inserted */ 870 { /* MMC inserted */
864 current_card = 1; 871 current_card = 1;
@@ -867,6 +874,7 @@ int ata_init(void)
867 { /* no MMC, use internal memory */ 874 { /* no MMC, use internal memory */
868 current_card = 0; 875 current_card = 0;
869 } 876 }
877#endif
870 878
871 ata_enable(true); 879 ata_enable(true);
872 880