diff options
| author | Björn Stenberg <bjorn@haxx.se> | 2002-07-16 12:18:17 +0000 |
|---|---|---|
| committer | Björn Stenberg <bjorn@haxx.se> | 2002-07-16 12:18:17 +0000 |
| commit | c4b285027bd4e07a2259db6d56792d00d1a37ede (patch) | |
| tree | def55cad50993d569149438a7879e1b01b73c5ba /firmware/drivers/ata.c | |
| parent | 42b764553281b7049cbcb9009e29cb6d2bc5a1e7 (diff) | |
| download | rockbox-c4b285027bd4e07a2259db6d56792d00d1a37ede.zip rockbox-c4b285027bd4e07a2259db6d56792d00d1a37ede.tar.gz rockbox-c4b285027bd4e07a2259db6d56792d00d1a37ede.tar.bz2 rockbox-c4b285027bd4e07a2259db6d56792d00d1a37ede.tar.xz | |
Faster, deeper disk sleep. Should save us some power.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1370 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers/ata.c')
| -rw-r--r-- | firmware/drivers/ata.c | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c index 63bfc92..963929d 100644 --- a/firmware/drivers/ata.c +++ b/firmware/drivers/ata.c @@ -64,10 +64,10 @@ static struct mutex ata_mtx; char ata_device; /* device 0 (master) or 1 (slave) */ int ata_io_address; /* 0x300 or 0x200, only valid on recorder */ - static volatile unsigned char* ata_control; bool old_recorder = false; +static bool sleeping = false; static int wait_for_bsy(void) { @@ -113,6 +113,13 @@ int ata_read_sectors(unsigned long start, int i; int ret = 0; + if ( sleeping ) { + if (ata_soft_reset()) { + mutex_unlock(&ata_mtx); + return -1; + } + } + mutex_lock(&ata_mtx); if (!wait_for_rdy()) @@ -164,6 +171,13 @@ int ata_write_sectors(unsigned long start, { int i; + if ( sleeping ) { + if (ata_soft_reset()) { + mutex_unlock(&ata_mtx); + return -1; + } + } + mutex_lock(&ata_mtx); if (!wait_for_rdy()) @@ -272,6 +286,28 @@ int ata_spindown(int time) return ret; } +int ata_sleep(void) +{ + int ret = 0; + + mutex_lock(&ata_mtx); + + if(!wait_for_rdy()) { + mutex_unlock(&ata_mtx); + return -1; + } + + ATA_SELECT = ata_device; + ATA_COMMAND = CMD_SLEEP; + + if (!wait_for_rdy()) + ret = -1; + + sleeping = true; + mutex_unlock(&ata_mtx); + return ret; +} + int ata_hard_reset(void) { int ret; @@ -289,6 +325,7 @@ int ata_hard_reset(void) /* Massage the return code so it is 0 on success and -1 on failure */ ret = ret?0:-1; + sleeping = false; mutex_unlock(&ata_mtx); return ret; } @@ -316,7 +353,8 @@ int ata_soft_reset(void) /* Massage the return code so it is 0 on success and -1 on failure */ ret = ret?0:-1; - + + sleeping = false; mutex_unlock(&ata_mtx); return ret; } |