diff options
author | jhibbits <jhibbits@FreeBSD.org> | 2013-12-21 00:07:56 +0000 |
---|---|---|
committer | jhibbits <jhibbits@FreeBSD.org> | 2013-12-21 00:07:56 +0000 |
commit | 4186c2041d450d8a3fb1c6a0fb9a7d2888164fd7 (patch) | |
tree | e88aad79edb61fce0dd320422ac4dadd750431cc /sys/powerpc/powermac | |
parent | 7b38c6ff68ccec355955b39704a559e13af6fe48 (diff) | |
download | FreeBSD-src-4186c2041d450d8a3fb1c6a0fb9a7d2888164fd7.zip FreeBSD-src-4186c2041d450d8a3fb1c6a0fb9a7d2888164fd7.tar.gz |
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.
Diffstat (limited to 'sys/powerpc/powermac')
-rw-r--r-- | sys/powerpc/powermac/ata_macio.c | 35 | ||||
-rw-r--r-- | sys/powerpc/powermac/dbdma.c | 25 | ||||
-rw-r--r-- | sys/powerpc/powermac/dbdmavar.h | 1 |
3 files changed, 61 insertions, 0 deletions
diff --git a/sys/powerpc/powermac/ata_macio.c b/sys/powerpc/powermac/ata_macio.c index 8505664..78fa60d 100644 --- a/sys/powerpc/powermac/ata_macio.c +++ b/sys/powerpc/powermac/ata_macio.c @@ -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); +} + diff --git a/sys/powerpc/powermac/dbdma.c b/sys/powerpc/powermac/dbdma.c index 6712c1a..8e8c582 100644 --- a/sys/powerpc/powermac/dbdma.c +++ b/sys/powerpc/powermac/dbdma.c @@ -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) { diff --git a/sys/powerpc/powermac/dbdmavar.h b/sys/powerpc/powermac/dbdmavar.h index 2916b6a..0b89618 100644 --- a/sys/powerpc/powermac/dbdmavar.h +++ b/sys/powerpc/powermac/dbdmavar.h @@ -60,6 +60,7 @@ struct dbdma_channel { bus_dma_tag_t sc_dmatag; bus_dmamap_t sc_dmamap; + uint32_t sc_saved_regs[5]; }; |