Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/amiga/pci Add support for power management on Media...
details: https://anonhg.NetBSD.org/src/rev/48e05a039b82
branches: trunk
changeset: 784431:48e05a039b82
user: rkujawa <rkujawa%NetBSD.org@localhost>
date: Mon Jan 28 14:44:37 2013 +0000
description:
Add support for power management on Mediator 1200 SX and TX models. Allows
software power-off. Feels so modern.
diffstat:
sys/arch/amiga/pci/empb.c | 38 ++++++++++++++++++-
sys/arch/amiga/pci/empbreg.h | 16 ++++++-
sys/arch/amiga/pci/empbvar.h | 4 +-
sys/arch/amiga/pci/empm.c | 85 ++++++++++++++++++++++++++++++++++++++++++++
sys/arch/amiga/pci/empmvar.h | 47 ++++++++++++++++++++++++
5 files changed, 183 insertions(+), 7 deletions(-)
diffs (274 lines):
diff -r edde0d68d4c3 -r 48e05a039b82 sys/arch/amiga/pci/empb.c
--- a/sys/arch/amiga/pci/empb.c Mon Jan 28 14:25:18 2013 +0000
+++ b/sys/arch/amiga/pci/empb.c Mon Jan 28 14:44:37 2013 +0000
@@ -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,8 +66,10 @@
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_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);
@@ -125,7 +128,9 @@
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 @@
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)
{
diff -r edde0d68d4c3 -r 48e05a039b82 sys/arch/amiga/pci/empbreg.h
--- a/sys/arch/amiga/pci/empbreg.h Mon Jan 28 14:25:18 2013 +0000
+++ b/sys/arch/amiga/pci/empbreg.h Mon Jan 28 14:44:37 2013 +0000
@@ -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_ */
diff -r edde0d68d4c3 -r 48e05a039b82 sys/arch/amiga/pci/empbvar.h
--- a/sys/arch/amiga/pci/empbvar.h Mon Jan 28 14:25:18 2013 +0000
+++ b/sys/arch/amiga/pci/empbvar.h Mon Jan 28 14:44:37 2013 +0000
@@ -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_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;
diff -r edde0d68d4c3 -r 48e05a039b82 sys/arch/amiga/pci/empm.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/amiga/pci/empm.c Mon Jan 28 14:44:37 2013 +0000
@@ -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);
+}
+
diff -r edde0d68d4c3 -r 48e05a039b82 sys/arch/amiga/pci/empmvar.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/amiga/pci/empmvar.h Mon Jan 28 14:44:37 2013 +0000
@@ -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 *);
Home |
Main Index |
Thread Index |
Old Index