svn commit: r259671 - head/sys/powerpc/powermac
Justin Hibbits
jhibbits at FreeBSD.org
Sat Dec 21 00:07:58 UTC 2013
Author: jhibbits
Date: Sat Dec 21 00:07:56 2013
New Revision: 259671
URL: http://svnweb.freebsd.org/changeset/base/259671
Log:
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.
Modified:
head/sys/powerpc/powermac/ata_macio.c
head/sys/powerpc/powermac/dbdma.c
head/sys/powerpc/powermac/dbdmavar.h
Modified: head/sys/powerpc/powermac/ata_macio.c
==============================================================================
--- head/sys/powerpc/powermac/ata_macio.c Fri Dec 20 23:57:05 2013 (r259670)
+++ head/sys/powerpc/powermac/ata_macio.c Sat Dec 21 00:07:56 2013 (r259671)
@@ -114,11 +114,15 @@ static int ata_macio_probe(device_t de
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_r
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);
+}
+
Modified: head/sys/powerpc/powermac/dbdma.c
==============================================================================
--- head/sys/powerpc/powermac/dbdma.c Fri Dec 20 23:57:05 2013 (r259670)
+++ head/sys/powerpc/powermac/dbdma.c Sat Dec 21 00:07:56 2013 (r259671)
@@ -343,6 +343,31 @@ dbdma_sync_commands(dbdma_channel_t *cha
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)
{
Modified: head/sys/powerpc/powermac/dbdmavar.h
==============================================================================
--- head/sys/powerpc/powermac/dbdmavar.h Fri Dec 20 23:57:05 2013 (r259670)
+++ head/sys/powerpc/powermac/dbdmavar.h Sat Dec 21 00:07:56 2013 (r259671)
@@ -60,6 +60,7 @@ struct dbdma_channel {
bus_dma_tag_t sc_dmatag;
bus_dmamap_t sc_dmamap;
+ uint32_t sc_saved_regs[5];
};
More information about the svn-src-all
mailing list