Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sandpoint/sandpoint Add QNAP reboot, reset and butt...



details:   https://anonhg.NetBSD.org/src/rev/5177a7cecb90
branches:  trunk
changeset: 763590:5177a7cecb90
user:      phx <phx%NetBSD.org@localhost>
date:      Sat Mar 26 22:36:34 2011 +0000

description:
Add QNAP reboot, reset and button handling functions.
Introduced an optional init function per board, which can set LEDs and other
special hardware to an initial state using the satellite processor.

diffstat:

 sys/arch/sandpoint/sandpoint/satmgr.c |  45 ++++++++++++++++++++++++++++-------
 1 files changed, 36 insertions(+), 9 deletions(-)

diffs (108 lines):

diff -r 51d4ef537ac1 -r 5177a7cecb90 sys/arch/sandpoint/sandpoint/satmgr.c
--- a/sys/arch/sandpoint/sandpoint/satmgr.c     Sat Mar 26 22:20:04 2011 +0000
+++ b/sys/arch/sandpoint/sandpoint/satmgr.c     Sat Mar 26 22:36:34 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: satmgr.c,v 1.6 2011/03/12 16:49:16 phx Exp $ */
+/* $NetBSD: satmgr.c,v 1.7 2011/03/26 22:36:34 phx Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -112,6 +112,8 @@
 static void txintr(struct satmgr_softc *);
 static void startoutput(struct satmgr_softc *);
 static void swintr(void *);
+static void sinit(struct satmgr_softc *);
+static void qinit(struct satmgr_softc *);
 static void kreboot(struct satmgr_softc *);
 static void sreboot(struct satmgr_softc *);
 static void qreboot(struct satmgr_softc *);
@@ -127,16 +129,17 @@
 
 struct satops {
        const char *family;
+       void (*init)(struct satmgr_softc *);
        void (*reboot)(struct satmgr_softc *);
        void (*pwroff)(struct satmgr_softc *);
        void (*dispatch)(struct satmgr_softc *, int);
 };
 
 static struct satops satmodel[] = {
-    { "kurobox",  kreboot, kpwroff, kbutton },
-    { "synology", sreboot, spwroff, sbutton },
-    { "qnap",     qreboot, qpwroff, qbutton },
-    { "dlink",    NULL, NULL, dbutton }
+    { "kurobox",  NULL, kreboot, kpwroff, kbutton },
+    { "synology", sinit, sreboot, spwroff, sbutton },
+    { "qnap",     qinit, qreboot, qpwroff, qbutton },
+    { "dlink",    NULL, NULL, NULL, dbutton }
 };
 
 /* single byte stride register layout */
@@ -253,7 +256,9 @@
                        CTL_CREATE, CTL_EOL);
        }
 
-       md_reboot = satmgr_reboot; /* cpu_reboot() hook */
+       md_reboot = satmgr_reboot;      /* cpu_reboot() hook */
+       if (ops->init != NULL)
+               (*ops->init)(sc);       /* init sat.cpu, LEDs, etc. */
        return;
 
   notavail:
@@ -652,6 +657,13 @@
 }
 
 static void
+sinit(struct satmgr_softc *sc)
+{
+
+       send_sat(sc, "8");      /* status LED green */
+}
+
+static void
 sreboot(struct satmgr_softc *sc)
 {
 
@@ -681,24 +693,39 @@
 }
 
 static void
+qinit(struct satmgr_softc *sc)
+{
+
+       send_sat(sc, "V");      /* status LED green */
+}
+
+static void
 qreboot(struct satmgr_softc *sc)
 {
 
-       send_sat(sc, "f");
+       send_sat(sc, "Pf");
 }
 
 static void
 qpwroff(struct satmgr_softc *sc)
 {
 
-       send_sat(sc, "A");
+       send_sat(sc, "PA");
 }
 
 static void
 qbutton(struct satmgr_softc *sc, int ch)
 {
 
-       /* research in progress */
+       switch (ch) {
+       case '@':
+               /* power button, notified after 5 seconds guard time */
+               sysmon_task_queue_sched(0, sched_sysmon_pbutton, sc);
+               break;
+       case 'j':       /* reset to default button */
+       case 'h':       /* USB copy button */
+               break;
+       }
 }
 
 static void



Home | Main Index | Thread Index | Old Index