diff options
author | Björn Stenberg <bjorn@haxx.se> | 2002-12-02 10:30:40 +0000 |
---|---|---|
committer | Björn Stenberg <bjorn@haxx.se> | 2002-12-02 10:30:40 +0000 |
commit | 7249c8807c6e8f9d083d3909863097e8a44cc4fe (patch) | |
tree | 7448b697a12f9bbe01de6d9d571f4832f21be785 /firmware | |
parent | 657a2f3d1cae6fe436cd7eb5b3ef962f50d4c8c6 (diff) | |
download | rockbox-7249c8807c6e8f9d083d3909863097e8a44cc4fe.tar.gz rockbox-7249c8807c6e8f9d083d3909863097e8a44cc4fe.zip |
Updated power-on procedure
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2896 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/drivers/ata.c | 29 |
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 | ||
103 | static int ata_power_on(void); | 103 | static int ata_power_on(void); |
104 | static int perform_soft_reset(void); | 104 | static int perform_soft_reset(void); |
105 | static int set_multiple_mode(int sectors); | ||
105 | 106 | ||
106 | static int wait_for_bsy(void) __attribute__ ((section (".icode"))); | 107 | static int wait_for_bsy(void) __attribute__ ((section (".icode"))); |
107 | static int wait_for_bsy(void) | 108 | static 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 | ||
583 | static int ata_power_on(void) | 581 | static 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 | ||
607 | static int master_slave_detect(void) | 598 | static 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; |