summaryrefslogtreecommitdiff
path: root/firmware/target/arm/sandisk/sansa-e200/ata-e200.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/sandisk/sansa-e200/ata-e200.c')
-rw-r--r--firmware/target/arm/sandisk/sansa-e200/ata-e200.c23
1 files changed, 18 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 3d6cb23d9c..b66984bec4 100644
--- a/firmware/target/arm/sandisk/sansa-e200/ata-e200.c
+++ b/firmware/target/arm/sandisk/sansa-e200/ata-e200.c
@@ -22,6 +22,7 @@
22#include "system.h" 22#include "system.h"
23#include <string.h> 23#include <string.h>
24#include "thread.h" 24#include "thread.h"
25#include "pp5024.h"
25 26
26#define NOINLINE_ATTR __attribute__((noinline)) /* don't inline the loops */ 27#define NOINLINE_ATTR __attribute__((noinline)) /* don't inline the loops */
27 28
@@ -359,9 +360,9 @@ void sd_init_device(void)
359 GPIOD_ENABLE |= (0x1f); 360 GPIOD_ENABLE |= (0x1f);
360 GPIOD_OUTPUT_EN |= (0x1f); 361 GPIOD_OUTPUT_EN |= (0x1f);
361 GPIOD_OUTPUT_VAL |= (0x1f); 362 GPIOD_OUTPUT_VAL |= (0x1f);
362 DEV_EN |= (1 << 14); /* Enable controller */ 363 DEV_EN |= DEV_ATA; /* Enable controller */
363 DEV_RS |= (1 << 14); /* Reset controller */ 364 DEV_RS |= DEV_ATA; /* Reset controller */
364 DEV_RS &=~(1 << 14); /* Clear Reset */ 365 DEV_RS &=~DEV_ATA; /* Clear Reset */
365 outl(0, 0x6000b000); 366 outl(0, 0x6000b000);
366 outl(0, 0x6000a000); /* Init DMA controller? */ 367 outl(0, 0x6000a000); /* Init DMA controller? */
367 368
@@ -478,6 +479,7 @@ int ata_read_sectors(IF_MV2(int drive,)
478 last_disk_activity = current_tick; 479 last_disk_activity = current_tick;
479 spinup_start = current_tick; 480 spinup_start = current_tick;
480 481
482 ata_enable(true);
481 ata_led(true); 483 ata_led(true);
482 484
483 timeout = current_tick + READ_TIMEOUT; 485 timeout = current_tick + READ_TIMEOUT;
@@ -528,6 +530,7 @@ int ata_read_sectors(IF_MV2(int drive,)
528 break; 530 break;
529 } 531 }
530 ata_led(false); 532 ata_led(false);
533 ata_enable(false);
531 534
532 mutex_unlock(&sd_mtx); 535 mutex_unlock(&sd_mtx);
533 536
@@ -551,6 +554,7 @@ int ata_write_sectors(IF_MV2(int drive,)
551 tSDCardInfo *card = &card_info[current_card]; 554 tSDCardInfo *card = &card_info[current_card];
552 555
553 mutex_lock(&sd_mtx); 556 mutex_lock(&sd_mtx);
557 ata_enable(true);
554 ata_led(true); 558 ata_led(true);
555 if(current_card == 0) 559 if(current_card == 0)
556 { 560 {
@@ -603,8 +607,10 @@ retry:
603 sd_read_response(&response, 1); 607 sd_read_response(&response, 1);
604 608
605 sd_wait_for_state(card, TRAN); 609 sd_wait_for_state(card, TRAN);
606 mutex_unlock(&sd_mtx);
607 ata_led(false); 610 ata_led(false);
611 ata_enable(false);
612 mutex_unlock(&sd_mtx);
613
608 return ret; 614 return ret;
609} 615}
610 616
@@ -667,7 +673,14 @@ int ata_soft_reset(void)
667 673
668void ata_enable(bool on) 674void ata_enable(bool on)
669{ 675{
670 (void)on; 676 if(on)
677 {
678 DEV_EN |= DEV_ATA; /* Enable controller */
679 }
680 else
681 {
682 DEV_EN &= ~DEV_ATA; /* Disable controller */
683 }
671} 684}
672 685
673unsigned short* ata_get_identify(void) 686unsigned short* ata_get_identify(void)