svn commit: r249826 - head/sys/powerpc/wii
Rui Paulo
rpaulo at FreeBSD.org
Wed Apr 24 01:36:36 UTC 2013
Author: rpaulo
Date: Wed Apr 24 01:36:35 2013
New Revision: 249826
URL: http://svnweb.freebsd.org/changeset/base/249826
Log:
Handle the IRQ for the reset button.
Modified:
head/sys/powerpc/wii/wii_bus.c
head/sys/powerpc/wii/wii_pic.c
head/sys/powerpc/wii/wii_picreg.h
Modified: head/sys/powerpc/wii/wii_bus.c
==============================================================================
--- head/sys/powerpc/wii/wii_bus.c Wed Apr 24 01:20:10 2013 (r249825)
+++ head/sys/powerpc/wii/wii_bus.c Wed Apr 24 01:36:35 2013 (r249826)
@@ -157,7 +157,7 @@ wiibus_attach(device_t self)
/* Nintendo PIC */
dinfo = malloc(sizeof(*dinfo), M_WIIBUS, M_WAITOK | M_ZERO);
wiibus_init_device_resources(&sc->sc_rman, dinfo, 0, WIIPIC_REG_ADDR,
- WIIPIC_REG_LEN, 0);
+ WIIPIC_REG_LEN, 1);
cdev = BUS_ADD_CHILD(self, 0, "wiipic", 0);
device_set_ivars(cdev, dinfo);
Modified: head/sys/powerpc/wii/wii_pic.c
==============================================================================
--- head/sys/powerpc/wii/wii_pic.c Wed Apr 24 01:20:10 2013 (r249825)
+++ head/sys/powerpc/wii/wii_pic.c Wed Apr 24 01:36:35 2013 (r249826)
@@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$");
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/rman.h>
+#include <sys/reboot.h>
#include <machine/bus.h>
#include <machine/platform.h>
@@ -51,6 +52,7 @@ static void wiipic_enable(device_t, unsi
static void wiipic_eoi(device_t, unsigned int);
static void wiipic_mask(device_t, unsigned int);
static void wiipic_unmask(device_t, unsigned int);
+static void wiipic_intr(void *);
struct wiipic_softc {
device_t sc_dev;
@@ -58,6 +60,9 @@ struct wiipic_softc {
bus_space_tag_t sc_bt;
bus_space_handle_t sc_bh;
int sc_rrid;
+ int sc_irqid;
+ struct resource *sc_irq;
+ void *sc_irqctx;
int sc_vector[WIIPIC_NIRQ];
};
@@ -146,6 +151,19 @@ wiipic_attach(device_t dev)
powerpc_register_pic(dev, 0, WIIPIC_NIRQ, 0, FALSE);
+ /*
+ * Setup the interrupt handler.
+ */
+ sc->sc_irqid = 0;
+ sc->sc_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &sc->sc_irqid,
+ RF_ACTIVE);
+ if (sc->sc_irq == NULL) {
+ device_printf(dev, "could not alloc IRQ resource\n");
+ return (ENXIO);
+ }
+ bus_setup_intr(dev, sc->sc_irq, INTR_TYPE_MISC | INTR_MPSAFE,
+ NULL, wiipic_intr, sc, &sc->sc_irqctx);
+
return (0);
}
@@ -210,3 +228,17 @@ wiipic_unmask(device_t dev, unsigned int
imr |= (1 << irq);
wiipic_imr_write(sc, imr);
}
+
+/*
+ * Reset button interrupt.
+ */
+static void
+wiipic_intr(void *xsc)
+{
+ struct wiipic_softc *sc;
+
+ sc = (struct wiipic_softc *)xsc;
+ if (wiipic_icr_read(sc) & WIIPIC_RBS)
+ shutdown_nice(RB_AUTOBOOT);
+}
+
Modified: head/sys/powerpc/wii/wii_picreg.h
==============================================================================
--- head/sys/powerpc/wii/wii_picreg.h Wed Apr 24 01:20:10 2013 (r249825)
+++ head/sys/powerpc/wii/wii_picreg.h Wed Apr 24 01:36:35 2013 (r249826)
@@ -30,9 +30,10 @@
#define _POWERPC_WII_WII_PICREG_H
#define WIIPIC_REG_ADDR 0x0c003000
-#define WIIPIC_REG_LEN 0x08
+#define WIIPIC_REG_LEN 0x28
#define WIIPIC_ICR 0x00
+#define WIIPIC_RBS 0x10000
#define WIIPIC_IMR 0x04
#define WIIPIC_RESET 0x24
More information about the svn-src-all
mailing list