summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJörg Hohensohn <hohensoh@rockbox.org>2003-07-03 00:02:15 +0000
committerJörg Hohensohn <hohensoh@rockbox.org>2003-07-03 00:02:15 +0000
commitd1a3a3e148cf54569fbf0df4dca5a8db6e0e4793 (patch)
treef8dc616e39bf52225e3bcb0862e139d7aac6f8a6
parent973d7a9440c27d3a25e411bb87b18d906b46a478 (diff)
downloadrockbox-d1a3a3e148cf54569fbf0df4dca5a8db6e0e4793.tar.gz
rockbox-d1a3a3e148cf54569fbf0df4dca5a8db6e0e4793.zip
When starting from flash, we have to wait for the disk to get ready. (Quite a new situation ;-)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3803 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/drivers/ata.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c
index 46c2bc8645..f4e1da48c4 100644
--- a/firmware/drivers/ata.c
+++ b/firmware/drivers/ata.c
@@ -424,8 +424,18 @@ extern void ata_flush(void)
424 424
425static int check_registers(void) 425static int check_registers(void)
426{ 426{
427 if ( ATA_STATUS & STATUS_BSY ) 427 /* When starting from Flash, the disk is not yet ready when we get here. */
428 return -1; 428 /* Crude first fix is to block and poll here for a while,
429 can we do better? */
430 int time = 0;
431 while ((ATA_STATUS & STATUS_BSY))
432 {
433 if (time >= HZ*10) /* timeout, disk is not coming up */
434 return -1;
435
436 sleep(HZ/10);
437 time += HZ/10;
438 };
429 439
430 ATA_NSECTOR = 0xa5; 440 ATA_NSECTOR = 0xa5;
431 ATA_SECTOR = 0x5a; 441 ATA_SECTOR = 0x5a;
@@ -797,14 +807,14 @@ unsigned short* ata_get_identify(void)
797 807
798int ata_init(void) 808int ata_init(void)
799{ 809{
800 mutex_init(&ata_mtx); 810 mutex_init(&ata_mtx);
801 811
802 led(false); 812 led(false);
803 813
804 /* Port A setup */ 814 /* Port A setup */
805 PAIOR |= 0x0200; /* output for ATA reset */ 815 PAIOR |= 0x0200; /* output for ATA reset */
806 PADR |= 0x0200; /* release ATA reset */ 816 PADR |= 0x0200; /* release ATA reset */
807 PACR2 &= 0xBFFF; /* GPIO function for PA7 (IDE enable) */ 817 PACR2 &= 0xBFFF; /* GPIO function for PA7 (IDE enable) */
808 818
809 ata_enable(true); 819 ata_enable(true);
810 820