Add suspend/resume to DBDMA and ATA on PowerMacs.

This, and several subsequent commits, are suspend/resume for various PowerMac
drivers, which will include a change to the global suspend/resume code
eventually.
This commit is contained in:
Justin Hibbits 2013-12-21 00:07:56 +00:00
parent 5c35eb22d4
commit cab8300efb
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=259671
3 changed files with 61 additions and 0 deletions

View File

@ -114,11 +114,15 @@ static int ata_macio_probe(device_t dev);
static int ata_macio_setmode(device_t dev, int target, int mode);
static int ata_macio_attach(device_t dev);
static int ata_macio_begin_transaction(struct ata_request *request);
static int ata_macio_suspend(device_t dev);
static int ata_macio_resume(device_t dev);
static device_method_t ata_macio_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, ata_macio_probe),
DEVMETHOD(device_attach, ata_macio_attach),
DEVMETHOD(device_suspend, ata_macio_suspend),
DEVMETHOD(device_resume, ata_macio_resume),
/* ATA interface */
DEVMETHOD(ata_setmode, ata_macio_setmode),
@ -336,3 +340,34 @@ ata_macio_begin_transaction(struct ata_request *request)
return ata_begin_transaction(request);
}
static int
ata_macio_suspend(device_t dev)
{
struct ata_dbdma_channel *ch = device_get_softc(dev);
int error;
if (!ch->sc_ch.attached)
return (0);
error = ata_suspend(dev);
dbdma_save_state(ch->dbdma);
return (error);
}
static int
ata_macio_resume(device_t dev)
{
struct ata_dbdma_channel *ch = device_get_softc(dev);
int error;
if (!ch->sc_ch.attached)
return (0);
dbdma_restore_state(ch->dbdma);
error = ata_resume(dev);
return (error);
}

View File

@ -343,6 +343,31 @@ dbdma_sync_commands(dbdma_channel_t *chan, bus_dmasync_op_t op)
bus_dmamap_sync(chan->sc_dmatag, chan->sc_dmamap, op);
}
void
dbdma_save_state(dbdma_channel_t *chan)
{
chan->sc_saved_regs[0] = dbdma_read_reg(chan, CHAN_CMDPTR);
chan->sc_saved_regs[1] = dbdma_read_reg(chan, CHAN_CMDPTR_HI);
chan->sc_saved_regs[2] = dbdma_read_reg(chan, CHAN_INTR_SELECT);
chan->sc_saved_regs[3] = dbdma_read_reg(chan, CHAN_BRANCH_SELECT);
chan->sc_saved_regs[4] = dbdma_read_reg(chan, CHAN_WAIT_SELECT);
dbdma_stop(chan);
}
void
dbdma_restore_state(dbdma_channel_t *chan)
{
dbdma_wake(chan);
dbdma_write_reg(chan, CHAN_CMDPTR, chan->sc_saved_regs[0]);
dbdma_write_reg(chan, CHAN_CMDPTR_HI, chan->sc_saved_regs[1]);
dbdma_write_reg(chan, CHAN_INTR_SELECT, chan->sc_saved_regs[2]);
dbdma_write_reg(chan, CHAN_BRANCH_SELECT, chan->sc_saved_regs[3]);
dbdma_write_reg(chan, CHAN_WAIT_SELECT, chan->sc_saved_regs[4]);
}
static uint32_t
dbdma_read_reg(dbdma_channel_t *chan, u_int offset)
{

View File

@ -60,6 +60,7 @@ struct dbdma_channel {
bus_dma_tag_t sc_dmatag;
bus_dmamap_t sc_dmamap;
uint32_t sc_saved_regs[5];
};