forked from len0rd/rockbox
ipod6g: Issue a FLUSH_CACHE[_EXT] command if device can't sleep.
Additionally, synchronize with the standard ATA driver's feature table * Acoustic management set to quietest * Set power mode to lowest w/o standby Change-Id: I12e64354d4c946228e9a55fc8da2114127d08d28
This commit is contained in:
parent
9a17185e63
commit
aa7357861a
1 changed files with 45 additions and 4 deletions
|
@ -48,6 +48,8 @@
|
||||||
#define CMD_READ_DMA 0xC8
|
#define CMD_READ_DMA 0xC8
|
||||||
#define CMD_WRITE_DMA 0xCA
|
#define CMD_WRITE_DMA 0xCA
|
||||||
#define CMD_STANDBY_IMMEDIATE 0xE0
|
#define CMD_STANDBY_IMMEDIATE 0xE0
|
||||||
|
#define CMD_FLUSH_CACHE 0xE7
|
||||||
|
#define CMD_FLUSH_CACHE_EXT 0xEA
|
||||||
#define CMD_IDENTIFY 0xEC
|
#define CMD_IDENTIFY 0xEC
|
||||||
#define CMD_SET_FEATURES 0xEF
|
#define CMD_SET_FEATURES 0xEF
|
||||||
|
|
||||||
|
@ -678,10 +680,15 @@ static int ata_power_up(void)
|
||||||
}
|
}
|
||||||
ata_dma = param ? true : false;
|
ata_dma = param ? true : false;
|
||||||
dma_mode = param;
|
dma_mode = param;
|
||||||
PASS_RC(ata_set_feature(0x03, param), 3, 4);
|
PASS_RC(ata_set_feature(0x03, param), 3, 4); /* Transfer mode */
|
||||||
if (ata_identify_data[82] & BIT(5))
|
if (ata_identify_data[82] & BIT(5))
|
||||||
PASS_RC(ata_set_feature(0x02, 0), 3, 5);
|
PASS_RC(ata_set_feature(0x02, 0), 3, 5); /* Enable volatile write cache */
|
||||||
if (ata_identify_data[82] & BIT(6)) PASS_RC(ata_set_feature(0xaa, 0), 3, 6);
|
if (ata_identify_data[82] & BIT(6))
|
||||||
|
PASS_RC(ata_set_feature(0xaa, 0), 3, 6); /* Enable read lookahead */
|
||||||
|
if (ata_identify_data[83] & BIT(3))
|
||||||
|
PASS_RC(ata_set_feature(0x05, 0x80), 3, 7); /* Enable lowest power mode w/o standby */
|
||||||
|
if (ata_identify_data[83] & BIT(9))
|
||||||
|
PASS_RC(ata_set_feature(0x42, 0x80), 3, 8); /* Enable lowest noise mode */
|
||||||
ATA_PIO_TIME = piotime;
|
ATA_PIO_TIME = piotime;
|
||||||
ATA_MDMA_TIME = mdmatime;
|
ATA_MDMA_TIME = mdmatime;
|
||||||
ATA_UDMA_TIME = udmatime;
|
ATA_UDMA_TIME = udmatime;
|
||||||
|
@ -692,7 +699,8 @@ static int ata_power_up(void)
|
||||||
| (((uint64_t)ata_identify_data[101]) << 16)
|
| (((uint64_t)ata_identify_data[101]) << 16)
|
||||||
| (((uint64_t)ata_identify_data[102]) << 32)
|
| (((uint64_t)ata_identify_data[102]) << 32)
|
||||||
| (((uint64_t)ata_identify_data[103]) << 48);
|
| (((uint64_t)ata_identify_data[103]) << 48);
|
||||||
else ata_total_sectors = ata_identify_data[60] | (((uint32_t)ata_identify_data[61]) << 16);
|
else
|
||||||
|
ata_total_sectors = ata_identify_data[60] | (((uint32_t)ata_identify_data[61]) << 16);
|
||||||
ata_total_sectors >>= 3;
|
ata_total_sectors >>= 3;
|
||||||
ata_powered = true;
|
ata_powered = true;
|
||||||
ata_set_active();
|
ata_set_active();
|
||||||
|
@ -981,12 +989,45 @@ void ata_spindown(int seconds)
|
||||||
ata_sleep_timeout = seconds * HZ;
|
ata_sleep_timeout = seconds * HZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ata_flush_cache(void)
|
||||||
|
{
|
||||||
|
uint8_t cmd;
|
||||||
|
|
||||||
|
if (ata_identify_data[83] & BIT(13)) {
|
||||||
|
cmd = CMD_FLUSH_CACHE_EXT;
|
||||||
|
} else if (ata_identify_data[83] & BIT(12)) {
|
||||||
|
cmd = CMD_FLUSH_CACHE;
|
||||||
|
} else {
|
||||||
|
/* If neither (mandatory!) command is supported
|
||||||
|
then don't issue it. */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ceata)
|
||||||
|
{
|
||||||
|
memset(ceata_taskfile, 0, 16);
|
||||||
|
ceata_taskfile[0xf] = cmd;
|
||||||
|
ceata_wait_idle();
|
||||||
|
ceata_write_multiple_register(0, ceata_taskfile, 16);
|
||||||
|
ceata_wait_idle();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ata_wait_for_rdy(1000000);
|
||||||
|
ata_write_cbr(&ATA_PIO_DVR, 0);
|
||||||
|
ata_write_cbr(&ATA_PIO_CSD, cmd);
|
||||||
|
ata_wait_for_rdy(1000000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ata_sleepnow(void)
|
void ata_sleepnow(void)
|
||||||
{
|
{
|
||||||
mutex_lock(&ata_mutex);
|
mutex_lock(&ata_mutex);
|
||||||
|
|
||||||
if (ata_disk_can_poweroff())
|
if (ata_disk_can_poweroff())
|
||||||
ata_power_down();
|
ata_power_down();
|
||||||
|
else
|
||||||
|
ata_flush_cache();
|
||||||
|
|
||||||
mutex_unlock(&ata_mutex);
|
mutex_unlock(&ata_mutex);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue