Module Name:    src
Committed By:   rkujawa
Date:           Mon Jan 28 14:44:37 UTC 2013

Modified Files:
        src/sys/arch/amiga/pci: empb.c empbreg.h empbvar.h
Added Files:
        src/sys/arch/amiga/pci: empm.c empmvar.h

Log Message:
Add support for power management on Mediator 1200 SX and TX models. Allows
software power-off. Feels so modern.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/amiga/pci/empb.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/amiga/pci/empbreg.h
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/amiga/pci/empbvar.h
cvs rdiff -u -r0 -r1.1 src/sys/arch/amiga/pci/empm.c \
    src/sys/arch/amiga/pci/empmvar.h

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/amiga/pci/empb.c
diff -u src/sys/arch/amiga/pci/empb.c:1.8 src/sys/arch/amiga/pci/empb.c:1.9
--- src/sys/arch/amiga/pci/empb.c:1.8	Sat Oct 27 17:17:34 2012
+++ src/sys/arch/amiga/pci/empb.c	Mon Jan 28 14:44:37 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: empb.c,v 1.8 2012/10/27 17:17:34 chs Exp $ */
+/*	$NetBSD: empb.c,v 1.9 2013/01/28 14:44:37 rkujawa Exp $ */
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -50,6 +50,7 @@
 #include <amiga/pci/empbreg.h>
 #include <amiga/pci/empbvar.h>
 #include <amiga/pci/emmemvar.h>
+#include <amiga/pci/empmvar.h>
 
 #include <dev/pci/pciconf.h>
 
@@ -65,9 +66,11 @@
 
 static int	empb_match(device_t, cfdata_t, void *);
 static void	empb_attach(device_t, device_t, void *);
-
 static void	empb_callback(device_t);
 
+static void	empb_empm_attach(struct empb_softc *sc);
+static int	empb_empm_print(void *aux, const char *pnp);
+
 static void	empb_find_mem(struct empb_softc *);
 static void	empb_switch_bridge(struct empb_softc *, uint8_t);
 static void	empb_intr_enable(struct empb_softc *);
@@ -125,7 +128,9 @@ empb_attach(device_t parent, device_t se
 	sc->sc_dev = self;
 	ba = zap->va;
 
-	switch (zap->prodid) {
+	sc->model = zap->prodid;
+
+	switch (sc->model) {
 	case ZORRO_PRODID_MED1K2:
 		aprint_normal(": ELBOX Mediator PCI 1200\n"); 
 		break;
@@ -255,11 +260,38 @@ empb_callback(device_t self) {
 	pba.pba_bus = 0;
 	pba.pba_bridgetag = NULL;
 
+	/* Attach power management on SX and TX models. */
+	switch (sc->model) {
+	case ZORRO_PRODID_MED1K2SX:
+	case ZORRO_PRODID_MED1K2TX:
+		empb_empm_attach(sc);
+	default:
+		break;
+	}	
+
 	empb_intr_enable(sc);
 
 	config_found_ia(self, "pcibus", &pba, pcibusprint);
 }
 
+static void
+empb_empm_attach(struct empb_softc *sc)
+{
+	struct empm_attach_args aa;
+	aa.setup_area_t = sc->setup_area_t;
+
+	config_found_ia(sc->sc_dev, "empmdev", &aa, empb_empm_print);
+}
+
+static int 
+empb_empm_print(void *aux, const char *pnp)
+{
+	if (pnp)
+		aprint_normal("empm at %s", pnp);
+
+	return UNCONF;
+}
+
 static void 
 empb_intr_enable(struct empb_softc *sc) 
 {

Index: src/sys/arch/amiga/pci/empbreg.h
diff -u src/sys/arch/amiga/pci/empbreg.h:1.4 src/sys/arch/amiga/pci/empbreg.h:1.5
--- src/sys/arch/amiga/pci/empbreg.h:1.4	Mon Jun  4 12:56:49 2012
+++ src/sys/arch/amiga/pci/empbreg.h	Mon Jan 28 14:44:37 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: empbreg.h,v 1.4 2012/06/04 12:56:49 rkujawa Exp $ */
+/*	$NetBSD: empbreg.h,v 1.5 2013/01/28 14:44:37 rkujawa Exp $ */
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -64,7 +64,7 @@
  * RAM space (its size depends on a WINDOW jumper setting).
  */
 #define EMPB_SETUP_OFF		0x00000000
-#define EMPB_SETUP_SIZE		0xFFFF
+#define EMPB_SETUP_SIZE		0x30
 
 #define EMPB_SETUP_WINDOW_OFF	0x2	/* set memory window position */
 #define EMPB_SETUP_BRIDGE_OFF	0x7	/* select between conf or I/O */
@@ -88,7 +88,17 @@
 #define EMPB_MEM_BASE		0x80000000
 #define EMPB_MEM_END		0xA0000000
 
+#define EMPB_PM_OFF		0x40	/* power management register */
+#define EMPB_PM_PSU_SHUTDOWN	0x0
+
 /* All PCI interrupt lines are wired to INT2? */
-#define EMPB_INT		2	// XXX: wild guess
+#define EMPB_INT		2
+
+/*
+ * Elbox Mediator 4000.
+ */
+#define EM4K_CONF_OFF		0x00C00000
+#define EM4K_IO_OFF		0x00800000
+#define EM4K_SETUP_WINDOW_OFF	0x0
 
 #endif /* _AMIGA_EMPBREG_H_ */

Index: src/sys/arch/amiga/pci/empbvar.h
diff -u src/sys/arch/amiga/pci/empbvar.h:1.2 src/sys/arch/amiga/pci/empbvar.h:1.3
--- src/sys/arch/amiga/pci/empbvar.h:1.2	Mon Jun  4 12:56:49 2012
+++ src/sys/arch/amiga/pci/empbvar.h	Mon Jan 28 14:44:37 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: empbvar.h,v 1.2 2012/06/04 12:56:49 rkujawa Exp $ */
+/*	$NetBSD: empbvar.h,v 1.3 2013/01/28 14:44:37 rkujawa Exp $ */
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -57,6 +57,8 @@ struct empb_dmamemdev_entry {
 struct empb_softc {
 	device_t			sc_dev;
 
+	uint16_t			model;
+
 	struct bus_space_tag		setup_area;
 	bus_space_tag_t			setup_area_t;
 	bus_space_handle_t		setup_area_h;

Added files:

Index: src/sys/arch/amiga/pci/empm.c
diff -u /dev/null src/sys/arch/amiga/pci/empm.c:1.1
--- /dev/null	Mon Jan 28 14:44:37 2013
+++ src/sys/arch/amiga/pci/empm.c	Mon Jan 28 14:44:37 2013
@@ -0,0 +1,85 @@
+/*	$NetBSD: empm.c,v 1.1 2013/01/28 14:44:37 rkujawa Exp $ */
+
+/*-
+ * Copyright (c) 2013 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Radoslaw Kujawa.
+ *
+ * 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``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 FOUNDATION OR CONTRIBUTORS
+ * 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.
+ */
+
+/*
+ * Power management on Elbox Mediator 1200 SX and TX.
+ */
+
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/device.h>
+
+#include <machine/bus.h>
+
+#include <amiga/pci/empbreg.h>
+#include <amiga/pci/empmvar.h>
+
+static int	empm_match(device_t, cfdata_t, void *);
+static void	empm_attach(device_t, device_t, void *);
+
+CFATTACH_DECL_NEW(empm, sizeof(struct empm_softc),
+    empm_match, empm_attach, NULL, NULL);
+
+static int
+empm_match(device_t parent, cfdata_t cf, void *aux)
+{
+	return 1;
+}
+
+static void
+empm_attach(device_t parent, device_t self, void *aux)
+{
+	struct empm_softc *sc;
+	struct empm_attach_args *aa;
+
+	sc = device_private(self); 
+	aa = aux;
+
+	sc->sc_dev = self;
+
+	aprint_normal(": ELBOX Mediator 1200 SX/TX Power Manager\n");
+
+	sc->setup_area_t = aa->setup_area_t;
+	
+	if (bus_space_map(sc->setup_area_t, EMPB_PM_OFF, 1, 0,
+	    &sc->powermgr_h))
+		aprint_error_dev(self, "couldn't map power manager register\n");
+
+}
+
+void
+empm_power_off(struct empm_softc *sc)
+{
+	aprint_normal_dev(sc->sc_dev, "trying soft power-off...\n");
+
+	bus_space_write_1(sc->setup_area_t, sc->powermgr_h, 0, 0);
+}
+
Index: src/sys/arch/amiga/pci/empmvar.h
diff -u /dev/null src/sys/arch/amiga/pci/empmvar.h:1.1
--- /dev/null	Mon Jan 28 14:44:37 2013
+++ src/sys/arch/amiga/pci/empmvar.h	Mon Jan 28 14:44:37 2013
@@ -0,0 +1,47 @@
+/*	$NetBSD: empmvar.h,v 1.1 2013/01/28 14:44:37 rkujawa Exp $ */
+
+/*-
+ * Copyright (c) 2013 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Radoslaw Kujawa.
+ *
+ * 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``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 FOUNDATION OR CONTRIBUTORS
+ * 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/types.h>
+#include <sys/device.h>
+#include <sys/bus.h>
+
+struct empm_softc {
+	device_t	sc_dev;
+
+	bus_space_tag_t		setup_area_t;
+	bus_space_handle_t	powermgr_h;
+};
+
+struct empm_attach_args {
+	bus_space_tag_t		setup_area_t;
+};
+
+void empm_power_off(struct empm_softc *);

Reply via email to