forked from len0rd/rockbox
Some cleanup
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1260 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
392f3853b1
commit
2012e1ec28
2 changed files with 27 additions and 3 deletions
|
@ -285,6 +285,9 @@ int ata_hard_reset(void)
|
||||||
|
|
||||||
ret = wait_for_rdy();
|
ret = wait_for_rdy();
|
||||||
|
|
||||||
|
/* Massage the return code so it is 0 on success and -1 on failure */
|
||||||
|
ret = ret?0:-1;
|
||||||
|
|
||||||
mutex_unlock(&ata_mtx);
|
mutex_unlock(&ata_mtx);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -292,6 +295,7 @@ int ata_hard_reset(void)
|
||||||
int ata_soft_reset(void)
|
int ata_soft_reset(void)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
int retry_count;
|
||||||
|
|
||||||
mutex_lock(&ata_mtx);
|
mutex_lock(&ata_mtx);
|
||||||
|
|
||||||
|
@ -302,8 +306,16 @@ int ata_soft_reset(void)
|
||||||
ATA_CONTROL = CONTROL_nIEN;
|
ATA_CONTROL = CONTROL_nIEN;
|
||||||
sleep(HZ/400); /* >2ms */
|
sleep(HZ/400); /* >2ms */
|
||||||
|
|
||||||
ret = wait_for_rdy();
|
/* This little sucker can take up to 30 seconds */
|
||||||
|
retry_count = 8;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
ret = wait_for_rdy();
|
||||||
|
} while(!ret && retry_count--);
|
||||||
|
|
||||||
|
/* Massage the return code so it is 0 on success and -1 on failure */
|
||||||
|
ret = ret?0:-1;
|
||||||
|
|
||||||
mutex_unlock(&ata_mtx);
|
mutex_unlock(&ata_mtx);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -367,14 +379,23 @@ static int io_address_detect(void)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ata_enable(bool on)
|
||||||
|
{
|
||||||
|
if(on)
|
||||||
|
PADR &= ~0x80; /* enable ATA */
|
||||||
|
else
|
||||||
|
PADR |= 0x80; /* disable ATA */
|
||||||
|
|
||||||
|
PAIOR |= 0x80;
|
||||||
|
}
|
||||||
|
|
||||||
int ata_init(void)
|
int ata_init(void)
|
||||||
{
|
{
|
||||||
mutex_init(&ata_mtx);
|
mutex_init(&ata_mtx);
|
||||||
|
|
||||||
led(false);
|
led(false);
|
||||||
|
|
||||||
PADR |= 0x800; /* disable USB */
|
ata_enable(true);
|
||||||
PADR &= ~0x80; /* activate ATA */
|
|
||||||
|
|
||||||
if (master_slave_detect())
|
if (master_slave_detect())
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
#ifndef __ATA_H__
|
#ifndef __ATA_H__
|
||||||
#define __ATA_H__
|
#define __ATA_H__
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
ata_spindown() time values:
|
ata_spindown() time values:
|
||||||
-1 Immediate spindown
|
-1 Immediate spindown
|
||||||
|
@ -30,6 +32,7 @@
|
||||||
254 Reserved
|
254 Reserved
|
||||||
255 21 min 15 s
|
255 21 min 15 s
|
||||||
*/
|
*/
|
||||||
|
extern void ata_enable(bool on);
|
||||||
extern int ata_spindown(int time);
|
extern int ata_spindown(int time);
|
||||||
extern int ata_hard_reset(void);
|
extern int ata_hard_reset(void);
|
||||||
extern int ata_soft_reset(void);
|
extern int ata_soft_reset(void);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue