Module Name:    src
Committed By:   sborrill
Date:           Wed Jan 27 21:17:55 UTC 2010

Modified Files:
        src/sys/arch/sparc/conf [netbsd-5]: GENERIC files.sparc
        src/sys/dev [netbsd-5]: DEVNAMES
Added Files:
        src/sys/arch/sparc/dev [netbsd-5]: apc.c apcreg.h

Log Message:
Pull up the following revisions(s) (requested by bouyer in ticket #1248):
        sys/arch/sparc/conf/GENERIC:    revision 1.219
        sys/arch/sparc/conf/files.sparc:        revision 1.149
        sys/arch/sparc/dev/apc.c:       revision 1.1
        sys/arch/sparc/dev/apcreg.h:    revision 1.1
        sys/dev/DEVNAMES:       revision 1.255

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.


To generate a diff of this commit:
cvs rdiff -u -r1.205.4.3 -r1.205.4.4 src/sys/arch/sparc/conf/GENERIC
cvs rdiff -u -r1.146 -r1.146.20.1 src/sys/arch/sparc/conf/files.sparc
cvs rdiff -u -r0 -r1.1.2.2 src/sys/arch/sparc/dev/apc.c \
    src/sys/arch/sparc/dev/apcreg.h
cvs rdiff -u -r1.242.4.2 -r1.242.4.3 src/sys/dev/DEVNAMES

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc/conf/GENERIC
diff -u src/sys/arch/sparc/conf/GENERIC:1.205.4.3 src/sys/arch/sparc/conf/GENERIC:1.205.4.4
--- src/sys/arch/sparc/conf/GENERIC:1.205.4.3	Sun Oct 18 14:45:54 2009
+++ src/sys/arch/sparc/conf/GENERIC	Wed Jan 27 21:17:55 2010
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.205.4.3 2009/10/18 14:45:54 bouyer Exp $
+# $NetBSD: GENERIC,v 1.205.4.4 2010/01/27 21:17:55 sborrill Exp $
 #
 # GENERIC machine description file
 # 
@@ -22,7 +22,7 @@
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident 		"GENERIC-$Revision: 1.205.4.3 $"
+#ident 		"GENERIC-$Revision: 1.205.4.4 $"
 
 maxusers	32
 
@@ -677,6 +677,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

Index: src/sys/arch/sparc/conf/files.sparc
diff -u src/sys/arch/sparc/conf/files.sparc:1.146 src/sys/arch/sparc/conf/files.sparc:1.146.20.1
--- src/sys/arch/sparc/conf/files.sparc:1.146	Wed Feb 20 21:43:35 2008
+++ src/sys/arch/sparc/conf/files.sparc	Wed Jan 27 21:17:55 2010
@@ -1,4 +1,4 @@
-#	$NetBSD: files.sparc,v 1.146 2008/02/20 21:43:35 drochner Exp $
+#	$NetBSD: files.sparc,v 1.146.20.1 2010/01/27 21:17:55 sborrill 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
 

Index: src/sys/dev/DEVNAMES
diff -u src/sys/dev/DEVNAMES:1.242.4.2 src/sys/dev/DEVNAMES:1.242.4.3
--- src/sys/dev/DEVNAMES:1.242.4.2	Fri Oct 16 11:56:11 2009
+++ src/sys/dev/DEVNAMES	Wed Jan 27 21:17:55 2010
@@ -1,4 +1,4 @@
-#	$NetBSD: DEVNAMES,v 1.242.4.2 2009/10/16 11:56:11 sborrill Exp $
+#	$NetBSD: DEVNAMES,v 1.242.4.3 2010/01/27 21:17:55 sborrill 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

Added files:

Index: src/sys/arch/sparc/dev/apc.c
diff -u /dev/null src/sys/arch/sparc/dev/apc.c:1.1.2.2
--- /dev/null	Wed Jan 27 21:17:55 2010
+++ src/sys/arch/sparc/dev/apc.c	Wed Jan 27 21:17:55 2010
@@ -0,0 +1,97 @@
+/*	$NetBSD: apc.c,v 1.1.2.2 2010/01/27 21:17:55 sborrill 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.2.2 2010/01/27 21:17:55 sborrill 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);
+}
Index: src/sys/arch/sparc/dev/apcreg.h
diff -u /dev/null src/sys/arch/sparc/dev/apcreg.h:1.1.2.2
--- /dev/null	Wed Jan 27 21:17:55 2010
+++ src/sys/arch/sparc/dev/apcreg.h	Wed Jan 27 21:17:55 2010
@@ -0,0 +1,37 @@
+/*	$NetBSD: apcreg.h,v 1.1.2.2 2010/01/27 21:17:55 sborrill 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

Reply via email to