svn commit: r277234 - head/sys/dev/pccbb
Warner Losh
imp at FreeBSD.org
Fri Jan 16 06:19:41 UTC 2015
Author: imp
Date: Fri Jan 16 06:19:39 2015
New Revision: 277234
URL: https://svnweb.freebsd.org/changeset/base/277234
Log:
Move the suspsned and resume functions to the bus attachment. They
were accessing PCI config registers, which won't work for the ISA
version.
Modified:
head/sys/dev/pccbb/pccbb.c
head/sys/dev/pccbb/pccbb_isa.c
head/sys/dev/pccbb/pccbb_pci.c
head/sys/dev/pccbb/pccbbvar.h
Modified: head/sys/dev/pccbb/pccbb.c
==============================================================================
--- head/sys/dev/pccbb/pccbb.c Fri Jan 16 06:19:24 2015 (r277233)
+++ head/sys/dev/pccbb/pccbb.c Fri Jan 16 06:19:39 2015 (r277234)
@@ -1563,61 +1563,6 @@ cbb_write_ivar(device_t brdev, device_t
}
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);
Modified: head/sys/dev/pccbb/pccbb_isa.c
==============================================================================
--- head/sys/dev/pccbb/pccbb_isa.c Fri Jan 16 06:19:24 2015 (r277233)
+++ head/sys/dev/pccbb/pccbb_isa.c Fri Jan 16 06:19:39 2015 (r277234)
@@ -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),
Modified: head/sys/dev/pccbb/pccbb_pci.c
==============================================================================
--- head/sys/dev/pccbb/pccbb_pci.c Fri Jan 16 06:19:24 2015 (r277233)
+++ head/sys/dev/pccbb/pccbb_pci.c Fri Jan 16 06:19:39 2015 (r277234)
@@ -877,14 +877,69 @@ cbb_write_config(device_t brdev, u_int b
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),
Modified: head/sys/dev/pccbb/pccbbvar.h
==============================================================================
--- head/sys/dev/pccbb/pccbbvar.h Fri Jan 16 06:19:24 2015 (r277233)
+++ head/sys/dev/pccbb/pccbbvar.h Fri Jan 16 06:19:39 2015 (r277234)
@@ -134,11 +134,9 @@ int cbb_read_ivar(device_t brdev, device
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,
More information about the svn-src-all
mailing list