From: kettenis Date: Thu, 5 Aug 2010 20:21:36 +0000 (+0000) Subject: Suspend/resume support for sili(4). Not perfect yet, but prevents us from X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=eea4c4024677a715c027e0ca94ceb35a915077c6;p=openbsd Suspend/resume support for sili(4). Not perfect yet, but prevents us from getting stuck. Based on an initial diff from deraadt@. --- diff --git a/sys/dev/ic/sili.c b/sys/dev/ic/sili.c index 59410879076..f8caf97ccf2 100644 --- a/sys/dev/ic/sili.c +++ b/sys/dev/ic/sili.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sili.c,v 1.45 2010/05/19 15:27:35 oga Exp $ */ +/* $OpenBSD: sili.c,v 1.46 2010/08/05 20:21:36 kettenis Exp $ */ /* * Copyright (c) 2007 David Gwynne @@ -223,6 +223,19 @@ sili_detach(struct sili_softc *sc, int flags) return (0); } +void +sili_resume(struct sili_softc *sc) +{ + int i; + + /* bounce the controller */ + sili_write(sc, SILI_REG_GC, SILI_REG_GC_GR); + sili_write(sc, SILI_REG_GC, 0x0); + + for (i = 0; i < sc->sc_nports; i++) + sili_ata_probe(sc, i); +} + u_int32_t sili_port_intr(struct sili_port *sp, int timeout_slot) { diff --git a/sys/dev/ic/silivar.h b/sys/dev/ic/silivar.h index dab11d6f338..be30842435a 100644 --- a/sys/dev/ic/silivar.h +++ b/sys/dev/ic/silivar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: silivar.h,v 1.6 2008/11/23 12:46:51 dlg Exp $ */ +/* $OpenBSD: silivar.h,v 1.7 2010/08/05 20:21:36 kettenis Exp $ */ /* * Copyright (c) 2007 David Gwynne @@ -41,4 +41,6 @@ struct sili_softc { int sili_attach(struct sili_softc *); int sili_detach(struct sili_softc *, int); +void sili_resume(struct sili_softc *); + int sili_intr(void *); diff --git a/sys/dev/pci/sili_pci.c b/sys/dev/pci/sili_pci.c index 05817ab7de0..199fb6c21be 100644 --- a/sys/dev/pci/sili_pci.c +++ b/sys/dev/pci/sili_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sili_pci.c,v 1.10 2009/05/13 08:35:29 jsg Exp $ */ +/* $OpenBSD: sili_pci.c,v 1.11 2010/08/05 20:21:36 kettenis Exp $ */ /* * Copyright (c) 2007 David Gwynne @@ -37,6 +37,7 @@ int sili_pci_match(struct device *, void *, void *); void sili_pci_attach(struct device *, struct device *, void *); int sili_pci_detach(struct device *, int); +int sili_pci_activate(struct device *, int); struct sili_pci_softc { struct sili_softc psc_sili; @@ -51,7 +52,8 @@ struct cfattach sili_pci_ca = { sizeof(struct sili_pci_softc), sili_pci_match, sili_pci_attach, - sili_pci_detach + sili_pci_detach, + sili_pci_activate }; struct sili_device { @@ -196,3 +198,22 @@ sili_pci_detach(struct device *self, int flags) return (0); } + +int +sili_pci_activate(struct device *self, int act) +{ + struct sili_softc *sc = (struct sili_softc *)self; + int rv = 0; + + switch (act) { + case DVACT_SUSPEND: + rv = config_activate_children(self, act); + break; + case DVACT_RESUME: + sili_resume(sc); + rv = config_activate_children(self, act); + break; + } + + return (rv); +}