summaryrefslogtreecommitdiff
path: root/firmware/drivers/ata.c
diff options
context:
space:
mode:
authorJörg Hohensohn <hohensoh@rockbox.org>2003-07-08 06:33:30 +0000
committerJörg Hohensohn <hohensoh@rockbox.org>2003-07-08 06:33:30 +0000
commitadef8fb17e3990f9ee3d4d63374513108ec1a534 (patch)
treef255679922e298ca5bf9d91f987826fb98286d3a /firmware/drivers/ata.c
parentf937912b5c2a3d6030b78eacfe15d57d9b3483ae (diff)
downloadrockbox-adef8fb17e3990f9ee3d4d63374513108ec1a534.tar.gz
rockbox-adef8fb17e3990f9ee3d4d63374513108ec1a534.zip
better place and method for the spinup wait code, still I'd welcome comments on this
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3815 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers/ata.c')
-rw-r--r--firmware/drivers/ata.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c
index f4e1da48c4..b665dc09fd 100644
--- a/firmware/drivers/ata.c
+++ b/firmware/drivers/ata.c
@@ -424,19 +424,9 @@ extern void ata_flush(void)
424 424
425static int check_registers(void) 425static int check_registers(void)
426{ 426{
427 /* When starting from Flash, the disk is not yet ready when we get here. */ 427 if ( ATA_STATUS & STATUS_BSY )
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; 428 return -1;
435 429
436 sleep(HZ/10);
437 time += HZ/10;
438 };
439
440 ATA_NSECTOR = 0xa5; 430 ATA_NSECTOR = 0xa5;
441 ATA_SECTOR = 0x5a; 431 ATA_SECTOR = 0x5a;
442 ATA_LCYL = 0xaa; 432 ATA_LCYL = 0xaa;
@@ -819,6 +809,19 @@ int ata_init(void)
819 ata_enable(true); 809 ata_enable(true);
820 810
821 if ( !initialized ) { 811 if ( !initialized ) {
812 /* When starting from Flash, the disk is not yet ready when we get here. */
813 /* Crude first fix is to block and poll here for a while,
814 can we do better? */
815 int time = 0;
816 while ((ATA_STATUS & STATUS_BSY))
817 {
818 if (time >= HZ*10) /* timeout, disk is not coming up */
819 return -6;
820
821 sleep(HZ/10);
822 time += HZ/10;
823 };
824
822 if (master_slave_detect()) 825 if (master_slave_detect())
823 return -1; 826 return -1;
824 827