forked from len0rd/rockbox
Bug fix: Master/slave was not always properly selected after powerdown.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2910 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
4a931c6285
commit
c032e65034
1 changed files with 14 additions and 9 deletions
|
|
@ -188,6 +188,7 @@ int ata_read_sectors(unsigned long start,
|
||||||
poweroff = false;
|
poweroff = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ATA_SELECT = ata_device;
|
||||||
if (!wait_for_rdy())
|
if (!wait_for_rdy())
|
||||||
{
|
{
|
||||||
mutex_unlock(&ata_mtx);
|
mutex_unlock(&ata_mtx);
|
||||||
|
|
@ -308,6 +309,7 @@ int ata_write_sectors(unsigned long start,
|
||||||
poweroff = false;
|
poweroff = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ATA_SELECT = ata_device;
|
||||||
if (!wait_for_rdy())
|
if (!wait_for_rdy())
|
||||||
{
|
{
|
||||||
mutex_unlock(&ata_mtx);
|
mutex_unlock(&ata_mtx);
|
||||||
|
|
@ -398,6 +400,8 @@ static int check_registers(void)
|
||||||
|
|
||||||
static int freeze_lock(void)
|
static int freeze_lock(void)
|
||||||
{
|
{
|
||||||
|
ATA_SELECT = ata_device;
|
||||||
|
|
||||||
if (!wait_for_rdy())
|
if (!wait_for_rdy())
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
|
@ -435,13 +439,14 @@ static int ata_perform_sleep(void)
|
||||||
|
|
||||||
mutex_lock(&ata_mtx);
|
mutex_lock(&ata_mtx);
|
||||||
|
|
||||||
|
ATA_SELECT = ata_device;
|
||||||
|
|
||||||
if(!wait_for_rdy()) {
|
if(!wait_for_rdy()) {
|
||||||
DEBUGF("ata_perform_sleep() - not RDY\n");
|
DEBUGF("ata_perform_sleep() - not RDY\n");
|
||||||
mutex_unlock(&ata_mtx);
|
mutex_unlock(&ata_mtx);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ATA_SELECT = ata_device;
|
|
||||||
ATA_COMMAND = CMD_SLEEP;
|
ATA_COMMAND = CMD_SLEEP;
|
||||||
|
|
||||||
if (!wait_for_rdy())
|
if (!wait_for_rdy())
|
||||||
|
|
@ -537,6 +542,7 @@ int ata_hard_reset(void)
|
||||||
sleep(1); /* > 2ms */
|
sleep(1); /* > 2ms */
|
||||||
|
|
||||||
/* state HRR2 */
|
/* state HRR2 */
|
||||||
|
ATA_SELECT = ata_device; /* select the right device */
|
||||||
ret = wait_for_bsy();
|
ret = wait_for_bsy();
|
||||||
|
|
||||||
/* Massage the return code so it is 0 on success and -1 on failure */
|
/* Massage the return code so it is 0 on success and -1 on failure */
|
||||||
|
|
@ -590,12 +596,12 @@ static int ata_power_on(void)
|
||||||
if( ata_hard_reset() )
|
if( ata_hard_reset() )
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
ATA_SELECT = SELECT_LBA;
|
|
||||||
ATA_CONTROL = CONTROL_nIEN;
|
|
||||||
|
|
||||||
if (set_multiple_mode(multisectors))
|
if (set_multiple_mode(multisectors))
|
||||||
return -2;
|
return -2;
|
||||||
|
|
||||||
|
if (freeze_lock())
|
||||||
|
return -3;
|
||||||
|
|
||||||
sleeping = false;
|
sleeping = false;
|
||||||
poweroff = false;
|
poweroff = false;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -676,12 +682,13 @@ static int identify(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
ATA_SELECT = ata_device;
|
||||||
|
|
||||||
if(!wait_for_rdy()) {
|
if(!wait_for_rdy()) {
|
||||||
DEBUGF("identify() - not RDY\n");
|
DEBUGF("identify() - not RDY\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ATA_SELECT = ata_device;
|
|
||||||
ATA_COMMAND = CMD_IDENTIFY;
|
ATA_COMMAND = CMD_IDENTIFY;
|
||||||
|
|
||||||
if (!wait_for_start_of_transfer())
|
if (!wait_for_start_of_transfer())
|
||||||
|
|
@ -699,12 +706,13 @@ static int identify(void)
|
||||||
|
|
||||||
static int set_multiple_mode(int sectors)
|
static int set_multiple_mode(int sectors)
|
||||||
{
|
{
|
||||||
|
ATA_SELECT = ata_device;
|
||||||
|
|
||||||
if(!wait_for_rdy()) {
|
if(!wait_for_rdy()) {
|
||||||
DEBUGF("set_multiple_mode() - not RDY\n");
|
DEBUGF("set_multiple_mode() - not RDY\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ATA_SELECT = ata_device;
|
|
||||||
ATA_NSECTOR = sectors;
|
ATA_NSECTOR = sectors;
|
||||||
ATA_COMMAND = CMD_SET_MULTIPLE_MODE;
|
ATA_COMMAND = CMD_SET_MULTIPLE_MODE;
|
||||||
|
|
||||||
|
|
@ -756,8 +764,5 @@ int ata_init(void)
|
||||||
if (set_multiple_mode(multisectors))
|
if (set_multiple_mode(multisectors))
|
||||||
return -6;
|
return -6;
|
||||||
|
|
||||||
ATA_SELECT = SELECT_LBA;
|
|
||||||
ATA_CONTROL = CONTROL_nIEN;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue