Module Name:    src
Committed By:   phx
Date:           Sat Mar 26 22:36:34 UTC 2011

Modified Files:
        src/sys/arch/sandpoint/sandpoint: satmgr.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sandpoint/sandpoint/satmgr.c

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/sandpoint/sandpoint/satmgr.c
diff -u src/sys/arch/sandpoint/sandpoint/satmgr.c:1.6 src/sys/arch/sandpoint/sandpoint/satmgr.c:1.7
--- src/sys/arch/sandpoint/sandpoint/satmgr.c:1.6	Sat Mar 12 16:49:16 2011
+++ src/sys/arch/sandpoint/sandpoint/satmgr.c	Sat Mar 26 22:36:34 2011
@@ -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

Reply via email to