Example #1
0
static void ata_power_down(void)
{
    if (!ata_powered) return;
    ata_powered = false;
    if (ceata)
    {
        memset(ceata_taskfile, 0, 16);
        ceata_taskfile[0xf] = 0xe0;
        ceata_wait_idle();
        ceata_write_multiple_register(0, ceata_taskfile, 16);
        sleep(HZ);
        PWRCON(0) |= (1 << 9);
    }
    else
    {
        ata_wait_for_rdy(1000000);
        ata_write_cbr(&ATA_PIO_DVR, 0);
        ata_write_cbr(&ATA_PIO_CSD, 0xe0);
        ata_wait_for_rdy(1000000);
        sleep(HZ / 30);
        ATA_CONTROL = 0;
        while (!(ATA_CONTROL & BIT(1))) yield();
        PWRCON(0) |= (1 << 5);
    }
    ide_power_enable(false);
}
Example #2
0
static int ata_set_feature(uint32_t feature, uint32_t param)
{
    PASS_RC(ata_wait_for_rdy(500000), 1, 0);
    ata_write_cbr(&ATA_PIO_DVR, 0);
    ata_write_cbr(&ATA_PIO_FED, 3);
    ata_write_cbr(&ATA_PIO_SCR, param);
    ata_write_cbr(&ATA_PIO_CSD, feature);
    PASS_RC(ata_wait_for_rdy(500000), 1, 1);
    return 0;
}
static int ata_set_feature(uint32_t feature, uint32_t param)
{
    if (ceata)
    {
        memset(ceata_taskfile, 0, 16);
        ceata_taskfile[0x1] = feature;
        ceata_taskfile[0x2] = param;
        ceata_taskfile[0xf] = 0xef;
        PASS_RC(ceata_wait_idle(), 2, 0);
        PASS_RC(ceata_write_multiple_register(0, ceata_taskfile, 16), 2, 1);
        PASS_RC(ceata_wait_idle(), 2, 2);
    }
    else
    {
        PASS_RC(ata_wait_for_rdy(2000000), 2, 0);
        ata_write_cbr(&ATA_PIO_DVR, 0);
        ata_write_cbr(&ATA_PIO_FED, feature);
        ata_write_cbr(&ATA_PIO_SCR, param);
        ata_write_cbr(&ATA_PIO_CSD, 0xef);
        PASS_RC(ata_wait_for_rdy(2000000), 2, 1);
    }
    return 0;
}
Example #4
0
     ceata_taskfile[0x2] = cnt >> 5;
     ceata_taskfile[0x3] = sector >> 21;
     ceata_taskfile[0x4] = sector >> 29;
     ceata_taskfile[0x5] = sector >> 37;
     ceata_taskfile[0xa] = cnt << 3;
     ceata_taskfile[0xb] = sector << 3;
     ceata_taskfile[0xc] = sector >> 5;
     ceata_taskfile[0xd] = sector >> 13;
     ceata_taskfile[0xf] = write ? 0x35 : 0x25;
     PASS_RC(ceata_wait_idle(), 2, 0);
     PASS_RC(ceata_write_multiple_register(0, ceata_taskfile, 16), 2, 1);
     PASS_RC(ceata_rw_multiple_block(write, buffer, cnt << 3, CEATA_COMMAND_TIMEOUT * HZ / 1000000), 2, 2);
 }
 else
 {
     PASS_RC(ata_wait_for_rdy(100000), 2, 0);
     ata_write_cbr(&ATA_PIO_DVR, 0);
     if (ata_lba48)
     {
         ata_write_cbr(&ATA_PIO_SCR, cnt >> 5);
         ata_write_cbr(&ATA_PIO_SCR, (cnt << 3) & 0xff);
         ata_write_cbr(&ATA_PIO_LHR, (sector >> 37) & 0xff);
         ata_write_cbr(&ATA_PIO_LMR, (sector >> 29) & 0xff);
         ata_write_cbr(&ATA_PIO_LLR, (sector >> 21) & 0xff);
         ata_write_cbr(&ATA_PIO_LHR, (sector >> 13) & 0xff);
         ata_write_cbr(&ATA_PIO_LMR, (sector >> 5) & 0xff);
         ata_write_cbr(&ATA_PIO_LLR, (sector << 3) & 0xff);
         ata_write_cbr(&ATA_PIO_DVR, BIT(6));
         if (write) ata_write_cbr(&ATA_PIO_CSD, ata_dma ? 0x35 : 0x39);
         else ata_write_cbr(&ATA_PIO_CSD, ata_dma ? 0x25 : 0x29);
     }