summaryrefslogtreecommitdiff
path: root/sys/arch/hppa
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch/hppa')
-rw-r--r--sys/arch/hppa/conf/GENERIC6
-rw-r--r--sys/arch/hppa/conf/RAMDISK6
-rw-r--r--sys/arch/hppa/conf/files.hppa6
-rw-r--r--sys/arch/hppa/dev/power.c130
-rw-r--r--sys/arch/hppa/hppa/mainbus.c8
5 files changed, 146 insertions, 10 deletions
diff --git a/sys/arch/hppa/conf/GENERIC b/sys/arch/hppa/conf/GENERIC
index c806d54033f..c0780fbc299 100644
--- a/sys/arch/hppa/conf/GENERIC
+++ b/sys/arch/hppa/conf/GENERIC
@@ -1,4 +1,4 @@
-# $OpenBSD: GENERIC,v 1.35 2003/08/14 19:55:57 mickey Exp $
+# $OpenBSD: GENERIC,v 1.36 2003/08/20 20:53:31 mickey Exp $
# Machine architecture; required by config(8)
machine hppa
@@ -26,11 +26,11 @@ mainbus0 at root # root "bus"
mem* at mainbus0 # /dev/*mem and memory controller
pdc0 at mainbus0 # PDC/IODC wrapper for boot console
+power0 at mainbus0 # power/fail manager (iv 2)
cpu* at mainbus0 irq 31 # HP PA-RISC cpu
-phantomas0 at mainbus0 # Phantom PseudoBC GSC+ Port
#fpu* at mainbus0 # HP PA-RISC fpu (iv N/A)
#pmu* at mainbus0 irq 29 # HP PA-RISC perfomance monitor unit
-#power* at mainbus0 # power/fail manager (iv 2)
+phantomas0 at mainbus0 # Phantom PseudoBC GSC+ Port
lasi0 at mainbus0 offset 0x100000 irq 28 # LASI host adapter
lasi0 at mainbus0 offset 0xfd00000 irq 28 # LASI on C1[01]0, J2[01]0
diff --git a/sys/arch/hppa/conf/RAMDISK b/sys/arch/hppa/conf/RAMDISK
index e52d14b2354..9e696535865 100644
--- a/sys/arch/hppa/conf/RAMDISK
+++ b/sys/arch/hppa/conf/RAMDISK
@@ -1,4 +1,4 @@
-# $OpenBSD: RAMDISK,v 1.18 2003/08/14 19:54:15 mickey Exp $
+# $OpenBSD: RAMDISK,v 1.19 2003/08/20 20:53:31 mickey Exp $
#
# Diskless kernel config
#
@@ -43,11 +43,11 @@ mainbus0 at root # root "bus"
mem* at mainbus0 # /dev/*mem and memory controller
pdc0 at mainbus0 # PDC/IODC wrapper for boot console
+power0 at mainbus0 # power/fail manager (iv 2)
cpu* at mainbus0 irq 31 # HP PA-RISC cpu
-phantomas0 at mainbus0 # Phantom PseudoBC GSC+ Port
#fpu* at mainbus0 # HP PA-RISC fpu (iv N/A)
#pmu* at mainbus0 irq 29 # HP PA-RISC perfomance monitor unit
-#power* at mainbus0 # power/fail manager (iv 2)
+phantomas0 at mainbus0 # Phantom PseudoBC GSC+ Port
lasi0 at mainbus0 offset 0x100000 irq 28 # LASI host adapter
lasi0 at mainbus0 offset 0xfd00000 irq 28 # LASI on C1[01]0, J2[01]0
diff --git a/sys/arch/hppa/conf/files.hppa b/sys/arch/hppa/conf/files.hppa
index fad66c0c665..feac7e5f228 100644
--- a/sys/arch/hppa/conf/files.hppa
+++ b/sys/arch/hppa/conf/files.hppa
@@ -1,4 +1,4 @@
-# $OpenBSD: files.hppa,v 1.45 2003/03/29 00:51:38 mickey Exp $
+# $OpenBSD: files.hppa,v 1.46 2003/08/20 20:53:31 mickey Exp $
#
# hppa-specific configuration info
@@ -75,6 +75,10 @@ device pdc
attach pdc at mainbus
file arch/hppa/dev/pdc.c pdc
+device power
+attach power at mainbus
+file arch/hppa/dev/power.c power
+
device mem
attach mem at mainbus
file arch/hppa/dev/mem.c mem
diff --git a/sys/arch/hppa/dev/power.c b/sys/arch/hppa/dev/power.c
new file mode 100644
index 00000000000..1f8412e0367
--- /dev/null
+++ b/sys/arch/hppa/dev/power.c
@@ -0,0 +1,130 @@
+/* $OpenBSD: power.c,v 1.1 2003/08/20 20:53:31 mickey Exp $ */
+
+/*
+ * Copyright (c) 2003 Michael Shalayeff
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/systm.h>
+#include <sys/reboot.h>
+#include <sys/device.h>
+#include <sys/kthread.h>
+
+#include <machine/reg.h>
+#include <machine/autoconf.h>
+
+#include <hppa/dev/cpudevs.h>
+
+struct power_softc {
+ struct device sc_dev;
+
+ struct proc *sc_thread;
+ void (*sc_kicker)(void *);
+
+ int sc_dr_cnt;
+};
+
+int powermatch(struct device *, void *, void *);
+void powerattach(struct device *, struct device *, void *);
+
+struct cfattach power_ca = {
+ sizeof(struct power_softc), powermatch, powerattach
+};
+
+struct cfdriver power_cd = {
+ NULL, "power", DV_DULL
+};
+
+void power_thread_create(void *v);
+void power_thread_dr(void *v);
+
+int
+powermatch(struct device *parent, void *cfdata, void *aux)
+{
+ struct cfdata *cf = cfdata;
+ struct confargs *ca = aux;
+
+ if (cf->cf_unit > 0 && !strcmp(ca->ca_name, "power"))
+ return (0);
+
+ return (1);
+}
+
+void
+powerattach(struct device *parent, struct device *self, void *aux)
+{
+ struct power_softc *sc = (struct power_softc *)self;
+
+ switch (cpu_hvers) {
+ case HPPA_BOARD_HP712_60:
+ case HPPA_BOARD_HP712_80:
+ case HPPA_BOARD_HP712_100:
+ case HPPA_BOARD_HP712_120:
+ sc->sc_kicker = power_thread_dr;
+ break;
+ default:
+ break;
+ }
+
+ printf("\n");
+
+ if (sc->sc_kicker)
+ kthread_create_deferred(power_thread_create, sc);
+}
+
+void
+power_thread_create(void *v)
+{
+ struct power_softc *sc = v;
+
+ if (kthread_create(sc->sc_kicker, sc, &sc->sc_thread,
+ "powerbutton", 0))
+ printf("WARNING: failed to create kernel power thread\n");
+}
+
+void
+power_thread_dr(void *v)
+{
+ struct power_softc *sc = v;
+ u_int32_t r;
+
+ for (;;) {
+ mfcpu(DR0_PCXL_SHINT_EN, r); /* XXX don't ask */
+ if (r & 0x80000000)
+ sc->sc_dr_cnt = 0;
+ else
+ sc->sc_dr_cnt++;
+
+ /*
+ * the bit is undampened straight wire from the power
+ * switch and thus we have do dampen it ourselves.
+ */
+ if (sc->sc_dr_cnt == hz / 10)
+ boot(RB_POWERDOWN | RB_HALT);
+
+ tsleep(v, PWAIT, "drpower", 10);
+ }
+}
diff --git a/sys/arch/hppa/hppa/mainbus.c b/sys/arch/hppa/hppa/mainbus.c
index 8da13e57954..f8c995ad96a 100644
--- a/sys/arch/hppa/hppa/mainbus.c
+++ b/sys/arch/hppa/hppa/mainbus.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mainbus.c,v 1.48 2003/08/20 20:28:40 mickey Exp $ */
+/* $OpenBSD: mainbus.c,v 1.49 2003/08/20 20:53:31 mickey Exp $ */
/*
* Copyright (c) 1998-2003 Michael Shalayeff
@@ -1006,12 +1006,14 @@ mbattach(parent, self, aux)
/* PDC first */
bzero (&nca, sizeof(nca));
nca.ca_name = "pdc";
- nca.ca_hpa = 0;
- nca.ca_hpamask = 0;
nca.ca_iot = &hppa_bustag;
nca.ca_dmatag = &hppa_dmatag;
config_found(self, &nca, mbprint);
+ /* get some power */
+ nca.ca_name = "power";
+ config_found(self, &nca, mbprint);
+
bzero (&nca, sizeof(nca));
nca.ca_name = "mainbus";
nca.ca_hpa = 0;