summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/drivers/ata.c29
1 files changed, 10 insertions, 19 deletions
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c
index 173dab9be3..f49040a794 100644
--- a/firmware/drivers/ata.c
+++ b/firmware/drivers/ata.c
@@ -102,6 +102,7 @@ static unsigned short identify_info[SECTOR_SIZE];
102 102
103static int ata_power_on(void); 103static int ata_power_on(void);
104static int perform_soft_reset(void); 104static int perform_soft_reset(void);
105static int set_multiple_mode(int sectors);
105 106
106static int wait_for_bsy(void) __attribute__ ((section (".icode"))); 107static int wait_for_bsy(void) __attribute__ ((section (".icode")));
107static int wait_for_bsy(void) 108static int wait_for_bsy(void)
@@ -524,21 +525,18 @@ int ata_hard_reset(void)
524{ 525{
525 int ret; 526 int ret;
526 527
527 mutex_lock(&ata_mtx);
528
529 PADR &= ~0x0200; 528 PADR &= ~0x0200;
530 529
531 sleep(2); 530 sleep(2);
532 531
533 PADR |= 0x0200; 532 PADR |= 0x0200;
534 533
535 ret = wait_for_rdy(); 534 ret = wait_for_bsy();
536 535
537 /* Massage the return code so it is 0 on success and -1 on failure */ 536 /* Massage the return code so it is 0 on success and -1 on failure */
538 ret = ret?0:-1; 537 ret = ret?0:-1;
539 538
540 sleeping = false; 539 sleeping = false;
541 mutex_unlock(&ata_mtx);
542 return ret; 540 return ret;
543} 541}
544 542
@@ -582,26 +580,19 @@ int ata_soft_reset(void)
582 580
583static int ata_power_on(void) 581static int ata_power_on(void)
584{ 582{
585 int ret;
586 int retry_count;
587
588 ide_power_enable(true); 583 ide_power_enable(true);
589 sleep(HZ/2); 584 if( ata_hard_reset() )
585 return -1;
590 586
587 ATA_SELECT = SELECT_LBA;
591 ATA_CONTROL = CONTROL_nIEN; 588 ATA_CONTROL = CONTROL_nIEN;
592 589
593 /* This little sucker can take up to 30 seconds */ 590 if (set_multiple_mode(multisectors))
594 retry_count = 8; 591 return -2;
595 do
596 {
597 ret = wait_for_rdy();
598 } while(!ret && retry_count--);
599
600 /* Massage the return code so it is 0 on success and -1 on failure */
601 ret = ret?0:-1;
602 592
603 sleeping = false; 593 sleeping = false;
604 return ret; 594 poweroff = false;
595 return 0;
605} 596}
606 597
607static int master_slave_detect(void) 598static int master_slave_detect(void)
@@ -752,7 +743,7 @@ int ata_init(void)
752 initialized = true; 743 initialized = true;
753 } 744 }
754 if (set_multiple_mode(multisectors)) 745 if (set_multiple_mode(multisectors))
755 return -6; 746 return -6;
756 747
757 ATA_SELECT = SELECT_LBA; 748 ATA_SELECT = SELECT_LBA;
758 ATA_CONTROL = CONTROL_nIEN; 749 ATA_CONTROL = CONTROL_nIEN;