diff options
Diffstat (limited to 'firmware/drivers/ata_mmc.c')
-rw-r--r-- | firmware/drivers/ata_mmc.c | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/firmware/drivers/ata_mmc.c b/firmware/drivers/ata_mmc.c index 02ec72a1f2..5afb6ca8a1 100644 --- a/firmware/drivers/ata_mmc.c +++ b/firmware/drivers/ata_mmc.c | |||
@@ -178,6 +178,8 @@ void mmc_select_clock(int card_no) | |||
178 | 178 | ||
179 | static int select_card(int card_no) | 179 | static int select_card(int card_no) |
180 | { | 180 | { |
181 | mutex_lock(&mmc_mutex); | ||
182 | led(true); | ||
181 | mmc_select_clock(card_no); | 183 | mmc_select_clock(card_no); |
182 | last_disk_activity = current_tick; | 184 | last_disk_activity = current_tick; |
183 | 185 | ||
@@ -209,6 +211,8 @@ static void deselect_card(void) | |||
209 | while (!(SSR1 & SCI_TEND)); /* wait for end of transfer */ | 211 | while (!(SSR1 & SCI_TEND)); /* wait for end of transfer */ |
210 | or_b(0x06, &PADRH); /* deassert CS (both cards) */ | 212 | or_b(0x06, &PADRH); /* deassert CS (both cards) */ |
211 | 213 | ||
214 | led(false); | ||
215 | mutex_unlock(&mmc_mutex); | ||
212 | last_disk_activity = current_tick; | 216 | last_disk_activity = current_tick; |
213 | } | 217 | } |
214 | 218 | ||
@@ -527,10 +531,8 @@ tCardInfo *mmc_card_info(int card_no) | |||
527 | 531 | ||
528 | if (!card->initialized && ((card_no == 0) || mmc_detect())) | 532 | if (!card->initialized && ((card_no == 0) || mmc_detect())) |
529 | { | 533 | { |
530 | mutex_lock(&mmc_mutex); | ||
531 | select_card(card_no); | 534 | select_card(card_no); |
532 | deselect_card(); | 535 | deselect_card(); |
533 | mutex_unlock(&mmc_mutex); | ||
534 | } | 536 | } |
535 | return card; | 537 | return card; |
536 | } | 538 | } |
@@ -692,19 +694,15 @@ int ata_read_sectors(IF_MV2(int drive,) | |||
692 | unsigned long c_block, c_end_block; | 694 | unsigned long c_block, c_end_block; |
693 | unsigned char response; | 695 | unsigned char response; |
694 | tCardInfo *card; | 696 | tCardInfo *card; |
697 | #ifndef HAVE_MULTIVOLUME | ||
698 | int drive = current_card; | ||
699 | #endif | ||
695 | 700 | ||
696 | c_addr = start * SECTOR_SIZE; | 701 | c_addr = start * SECTOR_SIZE; |
697 | c_end_addr = c_addr + incount * SECTOR_SIZE; | 702 | c_end_addr = c_addr + incount * SECTOR_SIZE; |
698 | 703 | ||
699 | mutex_lock(&mmc_mutex); | ||
700 | led(true); | ||
701 | #ifdef HAVE_MULTIVOLUME | ||
702 | card = &card_info[drive]; | 704 | card = &card_info[drive]; |
703 | rc = select_card(drive); | 705 | rc = select_card(drive); |
704 | #else | ||
705 | card = &card_info[current_card]; | ||
706 | rc = select_card(current_card); | ||
707 | #endif | ||
708 | if (rc) | 706 | if (rc) |
709 | { | 707 | { |
710 | rc = rc * 10 - 1; | 708 | rc = rc * 10 - 1; |
@@ -798,8 +796,6 @@ int ata_read_sectors(IF_MV2(int drive,) | |||
798 | error: | 796 | error: |
799 | 797 | ||
800 | deselect_card(); | 798 | deselect_card(); |
801 | led(false); | ||
802 | mutex_unlock(&mmc_mutex); | ||
803 | 799 | ||
804 | /* only flush if reading went ok */ | 800 | /* only flush if reading went ok */ |
805 | if ( (rc == 0) && delayed_write ) | 801 | if ( (rc == 0) && delayed_write ) |
@@ -819,6 +815,9 @@ int ata_write_sectors(IF_MV2(int drive,) | |||
819 | unsigned long c_block, c_end_block; | 815 | unsigned long c_block, c_end_block; |
820 | unsigned char response; | 816 | unsigned char response; |
821 | tCardInfo *card; | 817 | tCardInfo *card; |
818 | #ifndef HAVE_MULTIVOLUME | ||
819 | int drive = current_card; | ||
820 | #endif | ||
822 | 821 | ||
823 | if (start == 0) | 822 | if (start == 0) |
824 | panicf("Writing on sector 0\n"); | 823 | panicf("Writing on sector 0\n"); |
@@ -826,15 +825,8 @@ int ata_write_sectors(IF_MV2(int drive,) | |||
826 | c_addr = start * SECTOR_SIZE; | 825 | c_addr = start * SECTOR_SIZE; |
827 | c_end_addr = c_addr + count * SECTOR_SIZE; | 826 | c_end_addr = c_addr + count * SECTOR_SIZE; |
828 | 827 | ||
829 | mutex_lock(&mmc_mutex); | ||
830 | led(true); | ||
831 | #ifdef HAVE_MULTIVOLUME | ||
832 | card = &card_info[drive]; | 828 | card = &card_info[drive]; |
833 | rc = select_card(drive); | 829 | rc = select_card(drive); |
834 | #else | ||
835 | card = &card_info[current_card]; | ||
836 | rc = select_card(current_card); | ||
837 | #endif | ||
838 | if (rc) | 830 | if (rc) |
839 | { | 831 | { |
840 | rc = rc * 10 - 1; | 832 | rc = rc * 10 - 1; |
@@ -959,8 +951,6 @@ int ata_write_sectors(IF_MV2(int drive,) | |||
959 | error: | 951 | error: |
960 | 952 | ||
961 | deselect_card(); | 953 | deselect_card(); |
962 | led(false); | ||
963 | mutex_unlock(&mmc_mutex); | ||
964 | 954 | ||
965 | /* only flush if writing went ok */ | 955 | /* only flush if writing went ok */ |
966 | if ( (rc == 0) && delayed_write ) | 956 | if ( (rc == 0) && delayed_write ) |