summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>2015-01-16 06:19:39 +0000
committerimp <imp@FreeBSD.org>2015-01-16 06:19:39 +0000
commit6af83bc2fb27b71b3341700707011946cae39527 (patch)
treee5577227bf03c21ab32800d9d834f62401251836
parent7ab8c7eece0a392636d3ccd0ddeb2bd58eb2e222 (diff)
downloadFreeBSD-src-6af83bc2fb27b71b3341700707011946cae39527.zip
FreeBSD-src-6af83bc2fb27b71b3341700707011946cae39527.tar.gz
Move the suspsned and resume functions to the bus attachment. They
were accessing PCI config registers, which won't work for the ISA version.
-rw-r--r--sys/dev/pccbb/pccbb.c55
-rw-r--r--sys/dev/pccbb/pccbb_isa.c16
-rw-r--r--sys/dev/pccbb/pccbb_pci.c59
-rw-r--r--sys/dev/pccbb/pccbbvar.h2
4 files changed, 71 insertions, 61 deletions
diff --git a/sys/dev/pccbb/pccbb.c b/sys/dev/pccbb/pccbb.c
index 1302f35..d3ebe52 100644
--- a/sys/dev/pccbb/pccbb.c
+++ b/sys/dev/pccbb/pccbb.c
@@ -1563,61 +1563,6 @@ cbb_write_ivar(device_t brdev, device_t child, int which, uintptr_t value)
}
int
-cbb_suspend(device_t brdev)
-{
- int error = 0;
- struct cbb_softc *sc = device_get_softc(brdev);
-
- error = bus_generic_suspend(brdev);
- if (error != 0)
- return (error);
- cbb_set(sc, CBB_SOCKET_MASK, 0); /* Quiet hardware */
- sc->cardok = 0; /* Card is bogus now */
- return (0);
-}
-
-int
-cbb_resume(device_t brdev)
-{
- int error = 0;
- struct cbb_softc *sc = (struct cbb_softc *)device_get_softc(brdev);
- uint32_t tmp;
-
- /*
- * In the APM and early ACPI era, BIOSes saved the PCI config
- * registers. As chips became more complicated, that functionality moved
- * into the ACPI code / tables. We must therefore, restore the settings
- * we made here to make sure the device come back. Transitions to Dx
- * from D0 and back to D0 cause the bridge to lose its config space, so
- * all the bus mappings and such are preserved.
- *
- * For most drivers, the PCI layer handles this saving. However, since
- * there's much black magic and arcane art hidden in these few lines of
- * code that would be difficult to transition into the PCI
- * layer. chipinit was several years of trial and error to write.
- */
- pci_write_config(brdev, CBBR_SOCKBASE, rman_get_start(sc->base_res), 4);
- DEVPRINTF((brdev, "PCI Memory allocated: %08lx\n",
- rman_get_start(sc->base_res)));
-
- sc->chipinit(sc);
-
- /* reset interrupt -- Do we really need to do this? */
- tmp = cbb_get(sc, CBB_SOCKET_EVENT);
- cbb_set(sc, CBB_SOCKET_EVENT, tmp);
-
- /* CSC Interrupt: Card detect interrupt on */
- cbb_setb(sc, CBB_SOCKET_MASK, CBB_SOCKET_MASK_CD);
-
- /* Signal the thread to wakeup. */
- wakeup(&sc->intrhand);
-
- error = bus_generic_resume(brdev);
-
- return (error);
-}
-
-int
cbb_child_present(device_t parent, device_t child)
{
struct cbb_softc *sc = (struct cbb_softc *)device_get_softc(parent);
diff --git a/sys/dev/pccbb/pccbb_isa.c b/sys/dev/pccbb/pccbb_isa.c
index c511062..6ef441f 100644
--- a/sys/dev/pccbb/pccbb_isa.c
+++ b/sys/dev/pccbb/pccbb_isa.c
@@ -203,13 +203,25 @@ cbb_isa_attach(device_t dev)
return (ENOMEM);
}
+static int
+cbb_isa_suspend(device_t dev)
+{
+ return (0);
+}
+
+static int
+cbb_isa_resume(device_t dev)
+{
+ return (0);
+}
+
static device_method_t cbb_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, cbb_isa_probe),
DEVMETHOD(device_attach, cbb_isa_attach),
DEVMETHOD(device_detach, cbb_detach),
- DEVMETHOD(device_suspend, cbb_suspend),
- DEVMETHOD(device_resume, cbb_resume),
+ DEVMETHOD(device_suspend, cbb_isa_suspend),
+ DEVMETHOD(device_resume, cbb_isa_resume),
/* bus methods */
DEVMETHOD(bus_read_ivar, cbb_read_ivar),
diff --git a/sys/dev/pccbb/pccbb_pci.c b/sys/dev/pccbb/pccbb_pci.c
index 7b4727c..328a504 100644
--- a/sys/dev/pccbb/pccbb_pci.c
+++ b/sys/dev/pccbb/pccbb_pci.c
@@ -877,14 +877,69 @@ cbb_write_config(device_t brdev, u_int b, u_int s, u_int f, u_int reg, uint32_t
b, s, f, reg, val, width);
}
+static int
+cbb_pci_suspend(device_t brdev)
+{
+ int error = 0;
+ struct cbb_softc *sc = device_get_softc(brdev);
+
+ error = bus_generic_suspend(brdev);
+ if (error != 0)
+ return (error);
+ cbb_set(sc, CBB_SOCKET_MASK, 0); /* Quiet hardware */
+ sc->cardok = 0; /* Card is bogus now */
+ return (0);
+}
+
+static int
+cbb_pci_resume(device_t brdev)
+{
+ int error = 0;
+ struct cbb_softc *sc = (struct cbb_softc *)device_get_softc(brdev);
+ uint32_t tmp;
+
+ /*
+ * In the APM and early ACPI era, BIOSes saved the PCI config
+ * registers. As chips became more complicated, that functionality moved
+ * into the ACPI code / tables. We must therefore, restore the settings
+ * we made here to make sure the device come back. Transitions to Dx
+ * from D0 and back to D0 cause the bridge to lose its config space, so
+ * all the bus mappings and such are preserved.
+ *
+ * For most drivers, the PCI layer handles this saving. However, since
+ * there's much black magic and arcane art hidden in these few lines of
+ * code that would be difficult to transition into the PCI
+ * layer. chipinit was several years of trial and error to write.
+ */
+ pci_write_config(brdev, CBBR_SOCKBASE, rman_get_start(sc->base_res), 4);
+ DEVPRINTF((brdev, "PCI Memory allocated: %08lx\n",
+ rman_get_start(sc->base_res)));
+
+ sc->chipinit(sc);
+
+ /* reset interrupt -- Do we really need to do this? */
+ tmp = cbb_get(sc, CBB_SOCKET_EVENT);
+ cbb_set(sc, CBB_SOCKET_EVENT, tmp);
+
+ /* CSC Interrupt: Card detect interrupt on */
+ cbb_setb(sc, CBB_SOCKET_MASK, CBB_SOCKET_MASK_CD);
+
+ /* Signal the thread to wakeup. */
+ wakeup(&sc->intrhand);
+
+ error = bus_generic_resume(brdev);
+
+ return (error);
+}
+
static device_method_t cbb_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, cbb_pci_probe),
DEVMETHOD(device_attach, cbb_pci_attach),
DEVMETHOD(device_detach, cbb_detach),
DEVMETHOD(device_shutdown, cbb_pci_shutdown),
- DEVMETHOD(device_suspend, cbb_suspend),
- DEVMETHOD(device_resume, cbb_resume),
+ DEVMETHOD(device_suspend, cbb_pci_suspend),
+ DEVMETHOD(device_resume, cbb_pci_resume),
/* bus methods */
DEVMETHOD(bus_read_ivar, cbb_read_ivar),
diff --git a/sys/dev/pccbb/pccbbvar.h b/sys/dev/pccbb/pccbbvar.h
index c3e2d24..f19b933 100644
--- a/sys/dev/pccbb/pccbbvar.h
+++ b/sys/dev/pccbb/pccbbvar.h
@@ -134,11 +134,9 @@ int cbb_read_ivar(device_t brdev, device_t child, int which,
uintptr_t *result);
int cbb_release_resource(device_t brdev, device_t child,
int type, int rid, struct resource *r);
-int cbb_resume(device_t self);
int cbb_setup_intr(device_t dev, device_t child, struct resource *irq,
int flags, driver_filter_t *filt, driver_intr_t *intr, void *arg,
void **cookiep);
-int cbb_suspend(device_t self);
int cbb_teardown_intr(device_t dev, device_t child, struct resource *irq,
void *cookie);
int cbb_write_ivar(device_t brdev, device_t child, int which,
OpenPOWER on IntegriCloud