1
0
Fork 0
forked from len0rd/rockbox

Experiment: enable ATA STANDBY when switching to USB mode

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3668 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Linus Nielsen Feltzing 2003-05-10 01:55:23 +00:00
parent f70a41cdc6
commit 159d04d3f9
3 changed files with 29 additions and 0 deletions

View file

@ -503,6 +503,33 @@ static int ata_perform_sleep(void)
return ret; return ret;
} }
int ata_standby(int time)
{
int ret = 0;
mutex_lock(&ata_mtx);
ATA_SELECT = ata_device;
if(!wait_for_rdy()) {
DEBUGF("ata_standby() - not RDY\n");
mutex_unlock(&ata_mtx);
return -1;
}
ATA_NSECTOR = ((time + 5) / 5) & 0xff; /* Round up to nearest 5 secs */
ATA_COMMAND = CMD_STANDBY;
if (!wait_for_rdy())
{
DEBUGF("ata_standby() - CMD failed\n");
ret = -2;
}
mutex_unlock(&ata_mtx);
return ret;
}
int ata_sleep(void) int ata_sleep(void)
{ {
queue_post(&ata_queue, Q_SLEEP, NULL); queue_post(&ata_queue, Q_SLEEP, NULL);

View file

@ -36,6 +36,7 @@ extern void ata_enable(bool on);
extern void ata_spindown(int seconds); extern void ata_spindown(int seconds);
extern void ata_poweroff(bool enable); extern void ata_poweroff(bool enable);
extern int ata_sleep(void); extern int ata_sleep(void);
extern int ata_standby(int time);
extern bool ata_disk_is_active(void); extern bool ata_disk_is_active(void);
extern int ata_hard_reset(void); extern int ata_hard_reset(void);
extern int ata_soft_reset(void); extern int ata_soft_reset(void);

View file

@ -86,6 +86,7 @@ static void usb_slave_mode(bool on)
DEBUGF("Entering USB slave mode\n"); DEBUGF("Entering USB slave mode\n");
ata_soft_reset(); ata_soft_reset();
ata_init(); ata_init();
ata_standby(15);
ata_enable(false); ata_enable(false);
usb_enable(true); usb_enable(true);
} }