Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Add apc(4), a driver for the Aurora Personality Chip (AP...



details:   https://anonhg.NetBSD.org/src/rev/785980b3d810
branches:  trunk
changeset: 750824:785980b3d810
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Fri Jan 15 20:57:12 2010 +0000

description:
Add apc(4), a driver for the Aurora Personality Chip (APC) found
on SPARCstation-4/5, and emulated by qemu to idle the simulator
when the CPU is idle. Infos about the registers from the linux driver.
Not enabled by default because it can cause some Sparc systems to
hang (so says the linux driver).
Only the CPU idle part implemented at this time; fan speed and
Convenience power outlet management to be added.
Tested on qemu.

diffstat:

 sys/arch/sparc/conf/GENERIC     |   8 ++-
 sys/arch/sparc/conf/files.sparc |   6 ++-
 sys/arch/sparc/dev/apc.c        |  97 +++++++++++++++++++++++++++++++++++++++++
 sys/arch/sparc/dev/apcreg.h     |  37 +++++++++++++++
 sys/dev/DEVNAMES                |   3 +-
 5 files changed, 147 insertions(+), 4 deletions(-)

diffs (208 lines):

diff -r de49c3333bdf -r 785980b3d810 sys/arch/sparc/conf/GENERIC
--- a/sys/arch/sparc/conf/GENERIC       Fri Jan 15 20:39:46 2010 +0000
+++ b/sys/arch/sparc/conf/GENERIC       Fri Jan 15 20:57:12 2010 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.218 2009/12/05 20:11:17 pooka Exp $
+# $NetBSD: GENERIC,v 1.219 2010/01/15 20:57:12 bouyer Exp $
 #
 # GENERIC machine description file
 # 
@@ -22,7 +22,7 @@
 
 options        INCLUDE_CONFIG_FILE     # embed config file in kernel binary
 
-#ident                 "GENERIC-$Revision: 1.218 $"
+#ident                 "GENERIC-$Revision: 1.219 $"
 
 maxusers       32
 
@@ -712,6 +712,10 @@
 # Tadpole microcontroller
 tctrl0 at obio0
 
+# Aurora Personality Chip (APC) on SPARCstation-4/5
+# Not enabled by default as it may hang some systems
+#apc*          at sbus? slot ? offset ?
+
 ## Pseudo ttys, required for network logins and programs like screen.
 
 pseudo-device  pty                     # pseudo-terminals
diff -r de49c3333bdf -r 785980b3d810 sys/arch/sparc/conf/files.sparc
--- a/sys/arch/sparc/conf/files.sparc   Fri Jan 15 20:39:46 2010 +0000
+++ b/sys/arch/sparc/conf/files.sparc   Fri Jan 15 20:57:12 2010 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.sparc,v 1.148 2009/09/27 13:27:44 tsutsui Exp $
+#      $NetBSD: files.sparc,v 1.149 2010/01/15 20:57:12 bouyer Exp $
 
 # @(#)files.sparc      8.1 (Berkeley) 7/19/93
 # sparc-specific configuration info
@@ -224,6 +224,10 @@
 file   arch/sparc/dev/audioamd.c               audioamd
 file   arch/sparc/sparc/amd7930intr.s          audioamd
 
+device apc
+attach apc at sbus
+file   arch/sparc/dev/apc.c                    apc
+
 attach bwtwo at obio with bwtwo_obio
 file   arch/sparc/dev/bwtwo_obio.c     bwtwo_obio & obio
 
diff -r de49c3333bdf -r 785980b3d810 sys/arch/sparc/dev/apc.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/sparc/dev/apc.c  Fri Jan 15 20:57:12 2010 +0000
@@ -0,0 +1,97 @@
+/*     $NetBSD: apc.c,v 1.1 2010/01/15 20:57:12 bouyer Exp $   */
+
+/*
+ * Copyright (c) 2010 Manuel Bouyer.
+ *
+ * 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 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 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/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: apc.c,v 1.1 2010/01/15 20:57:12 bouyer Exp $");
+
+
+/*
+ * driver for the power management functions of the Aurora Personality Chip
+ * on SPARCstation-4/5 and derivatives
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/errno.h>
+#include <sys/device.h>
+#include <sys/bus.h>
+
+#include <machine/autoconf.h>
+
+#include <sparc/dev/apcreg.h>
+
+static int apcmatch(device_t, struct cfdata *, void *);
+static void apcattach(device_t, device_t, void *);
+static void apc_cpu_sleep(struct cpu_info *);
+
+struct apc_softc {
+       device_t        sc_dev;
+       bus_space_tag_t sc_bt;
+       bus_space_handle_t sc_bh;
+};
+
+struct apc_softc *apc = NULL;
+
+CFATTACH_DECL_NEW(apc, sizeof(struct apc_softc),
+    apcmatch, apcattach, NULL, NULL);
+
+
+static int
+apcmatch(device_t parent, struct cfdata *cf, void *aux)
+{
+       struct sbus_attach_args *sa = aux;
+       if (apc != NULL) /* only one instance */
+               return 0;
+       return strcmp("power-management", sa->sa_name) == 0;
+}
+
+static void
+apcattach(device_t parent, device_t self, void *aux)
+{
+       struct sbus_attach_args *sa = aux;
+       struct apc_softc *sc = device_private(self);
+
+       sc->sc_bt = sa->sa_bustag;
+       if (sbus_bus_map(sa->sa_bustag,
+           sa->sa_slot, sa->sa_offset, APC_REG_SIZE, 0, &sc->sc_bh) != 0) {
+               aprint_error(": cannot map registers\n");
+               return;
+       }
+       aprint_normal("\n");
+       apc = sc;
+       curcpu()->idlespin = apc_cpu_sleep;
+}
+
+static void
+apc_cpu_sleep(struct cpu_info *ci)
+{
+       uint8_t val;
+       if (apc == NULL)
+               return;
+       val = bus_space_read_1(apc->sc_bt, apc->sc_bh, APC_IDLE_REG);
+       bus_space_write_1(apc->sc_bt, apc->sc_bh, APC_IDLE_REG,
+           val | APC_IDLE_REG_IDLE);
+}
diff -r de49c3333bdf -r 785980b3d810 sys/arch/sparc/dev/apcreg.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/sparc/dev/apcreg.h       Fri Jan 15 20:57:12 2010 +0000
@@ -0,0 +1,37 @@
+/*     $NetBSD: apcreg.h,v 1.1 2010/01/15 20:57:12 bouyer Exp $        */
+
+/*
+ * Copyright (c) 2010 Manuel Bouyer.
+ *
+ * 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 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 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.
+ */
+
+#define APC_IDLE_REG   0x00
+#define APC_IDLE_REG_IDLE      0x01    /* suspend CPU */
+#define APC_FANCTL_REG 0x20
+#define APC_FANCTL_REG_HI      0x00    /* full speed */
+#define APC_FANCTL_REG_LOW     0x01    /* low speed */
+#define APC_CPOWER_REG 0x24
+#define APC_CPOWER_REG_ON      0x00    /* Convenience power outlet on */
+#define APC_CPOWER_REG_OFF     0x01    /* Convenience power outlet off */
+#define APC_BPORT_REG  0x30
+
+#define APC_REG_SIZE   0x34
diff -r de49c3333bdf -r 785980b3d810 sys/dev/DEVNAMES
--- a/sys/dev/DEVNAMES  Fri Jan 15 20:39:46 2010 +0000
+++ b/sys/dev/DEVNAMES  Fri Jan 15 20:57:12 2010 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: DEVNAMES,v 1.254 2010/01/07 09:24:45 jdc Exp $
+#      $NetBSD: DEVNAMES,v 1.255 2010/01/15 20:57:13 bouyer Exp $
 #
 # This file contains all used device names and defined attributes in
 # alphabetical order. New devices added to the system somewhere should first
@@ -81,6 +81,7 @@
 ams                    macppc
 an                     MI
 ap                     newsmips
+apc                    sparc
 apecs                  alpha
 apm                    i386
 aps                    MI



Home | Main Index | Thread Index | Old Index