svn commit: r250780 - in projects/pmac_pmu/sys/powerpc: include powermac powerpc psim
Justin Hibbits
jhibbits at FreeBSD.org
Sat May 18 17:41:44 UTC 2013
Author: jhibbits
Date: Sat May 18 17:41:42 2013
New Revision: 250780
URL: http://svnweb.freebsd.org/changeset/base/250780
Log:
Save and restore openpic upon suspend/resume.
Modified:
projects/pmac_pmu/sys/powerpc/include/openpicreg.h
projects/pmac_pmu/sys/powerpc/include/openpicvar.h
projects/pmac_pmu/sys/powerpc/powermac/openpic_macio.c
projects/pmac_pmu/sys/powerpc/powerpc/openpic_fdt.c
projects/pmac_pmu/sys/powerpc/psim/openpic_iobus.c
Modified: projects/pmac_pmu/sys/powerpc/include/openpicreg.h
==============================================================================
--- projects/pmac_pmu/sys/powerpc/include/openpicreg.h Sat May 18 17:29:32 2013 (r250779)
+++ projects/pmac_pmu/sys/powerpc/include/openpicreg.h Sat May 18 17:41:42 2013 (r250780)
@@ -99,6 +99,7 @@
*/
/* interrupt vector/priority reg */
+#define OPENPIC_SRC_VECTOR_COUNT 64
#ifndef OPENPIC_SRC_VECTOR
#define OPENPIC_SRC_VECTOR(irq) (0x10000 + (irq) * 0x20)
#endif
Modified: projects/pmac_pmu/sys/powerpc/include/openpicvar.h
==============================================================================
--- projects/pmac_pmu/sys/powerpc/include/openpicvar.h Sat May 18 17:29:32 2013 (r250779)
+++ projects/pmac_pmu/sys/powerpc/include/openpicvar.h Sat May 18 17:41:42 2013 (r250780)
@@ -32,6 +32,14 @@
#define OPENPIC_IRQMAX 256 /* h/w allows more */
+/* Names match the macros in openpicreg.h. */
+struct openpic_timer {
+ uint32_t tcnt;
+ uint32_t tbase;
+ uint32_t tvec;
+ uint32_t tdst;
+};
+
struct openpic_softc {
device_t sc_dev;
struct resource *sc_memr;
@@ -45,6 +53,14 @@ struct openpic_softc {
u_int sc_ncpu;
u_int sc_nirq;
int sc_psim;
+
+ /* Saved states. */
+ uint32_t sc_saved_config;
+ uint32_t sc_saved_ipis[4];
+ uint32_t sc_saved_prios[4];
+ struct openpic_timer sc_saved_timers[OPENPIC_TIMERS];
+ uint32_t sc_saved_vectors[OPENPIC_SRC_VECTOR_COUNT];
+
};
extern devclass_t openpic_devclass;
Modified: projects/pmac_pmu/sys/powerpc/powermac/openpic_macio.c
==============================================================================
--- projects/pmac_pmu/sys/powerpc/powermac/openpic_macio.c Sat May 18 17:29:32 2013 (r250779)
+++ projects/pmac_pmu/sys/powerpc/powermac/openpic_macio.c Sat May 18 17:41:42 2013 (r250780)
@@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$");
#include <sys/rman.h>
+#include <machine/openpicreg.h>
#include <machine/openpicvar.h>
#include "pic_if.h"
@@ -59,11 +60,15 @@ __FBSDID("$FreeBSD$");
*/
static int openpic_macio_probe(device_t);
static int openpic_macio_attach(device_t);
+static int openpic_macio_suspend(device_t);
+static int openpic_macio_resume(device_t);
static device_method_t openpic_macio_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, openpic_macio_probe),
DEVMETHOD(device_attach, openpic_macio_attach),
+ DEVMETHOD(device_suspend, openpic_macio_suspend),
+ DEVMETHOD(device_resume, openpic_macio_resume),
/* PIC interface */
DEVMETHOD(pic_bind, openpic_bind),
@@ -108,3 +113,64 @@ openpic_macio_attach(device_t dev)
return (openpic_common_attach(dev, ofw_bus_get_node(dev)));
}
+
+static int
+openpic_macio_suspend(device_t dev)
+{
+ struct openpic_softc *sc;
+ int i;
+
+ sc = device_get_softc(dev);
+
+ sc->sc_saved_config = bus_read_4(sc->sc_memr, OPENPIC_CONFIG);
+ for (i = 0; i < 4; i++) {
+ sc->sc_saved_ipis[i] = bus_read_4(sc->sc_memr, OPENPIC_IPI_VECTOR(i));
+ }
+
+ for (i = 0; i < 4; i++) {
+ sc->sc_saved_prios[i] = bus_read_4(sc->sc_memr, OPENPIC_PCPU_TPR(i));
+ }
+
+ for (i = 0; i < OPENPIC_TIMERS; i++) {
+ sc->sc_saved_timers[i].tcnt = bus_read_4(sc->sc_memr, OPENPIC_TCNT(i));
+ sc->sc_saved_timers[i].tbase = bus_read_4(sc->sc_memr, OPENPIC_TBASE(i));
+ sc->sc_saved_timers[i].tvec = bus_read_4(sc->sc_memr, OPENPIC_TVEC(i));
+ sc->sc_saved_timers[i].tdst = bus_read_4(sc->sc_memr, OPENPIC_TDST(i));
+ }
+
+ for (i = 0; i < OPENPIC_SRC_VECTOR_COUNT; i++)
+ sc->sc_saved_vectors[i] =
+ bus_read_4(sc->sc_memr, OPENPIC_SRC_VECTOR(i)) & ~OPENPIC_ACTIVITY;
+
+ return (0);
+}
+
+static int
+openpic_macio_resume(device_t dev)
+{
+ struct openpic_softc *sc;
+ int i;
+
+ sc = device_get_softc(dev);
+
+ sc->sc_saved_config = bus_read_4(sc->sc_memr, OPENPIC_CONFIG);
+ for (i = 0; i < 4; i++) {
+ bus_write_4(sc->sc_memr, OPENPIC_IPI_VECTOR(i), sc->sc_saved_ipis[i]);
+ }
+
+ for (i = 0; i < 4; i++) {
+ bus_write_4(sc->sc_memr, OPENPIC_PCPU_TPR(i), sc->sc_saved_prios[i]);
+ }
+
+ for (i = 0; i < OPENPIC_TIMERS; i++) {
+ bus_write_4(sc->sc_memr, OPENPIC_TCNT(i), sc->sc_saved_timers[i].tcnt);
+ bus_write_4(sc->sc_memr, OPENPIC_TBASE(i), sc->sc_saved_timers[i].tbase);
+ bus_write_4(sc->sc_memr, OPENPIC_TVEC(i), sc->sc_saved_timers[i].tvec);
+ bus_write_4(sc->sc_memr, OPENPIC_TDST(i), sc->sc_saved_timers[i].tdst);
+ }
+
+ for (i = 0; i < OPENPIC_SRC_VECTOR_COUNT; i++)
+ bus_write_4(sc->sc_memr, OPENPIC_SRC_VECTOR(i), sc->sc_saved_vectors[i]);
+
+ return (0);
+}
Modified: projects/pmac_pmu/sys/powerpc/powerpc/openpic_fdt.c
==============================================================================
--- projects/pmac_pmu/sys/powerpc/powerpc/openpic_fdt.c Sat May 18 17:29:32 2013 (r250779)
+++ projects/pmac_pmu/sys/powerpc/powerpc/openpic_fdt.c Sat May 18 17:41:42 2013 (r250780)
@@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$");
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
+#include <machine/openpicreg.h>
#include <machine/openpicvar.h>
#include "pic_if.h"
Modified: projects/pmac_pmu/sys/powerpc/psim/openpic_iobus.c
==============================================================================
--- projects/pmac_pmu/sys/powerpc/psim/openpic_iobus.c Sat May 18 17:29:32 2013 (r250779)
+++ projects/pmac_pmu/sys/powerpc/psim/openpic_iobus.c Sat May 18 17:41:42 2013 (r250780)
@@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$");
#include <sys/rman.h>
+#include <machine/openpicreg.h>
#include <machine/openpicvar.h>
#include <powerpc/psim/iobusvar.h>
More information about the svn-src-projects
mailing list