Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sandpoint 'satmgr' device for communicating with th...



details:   https://anonhg.NetBSD.org/src/rev/96006428905c
branches:  trunk
changeset: 755246:96006428905c
user:      phx <phx%NetBSD.org@localhost>
date:      Sat May 29 22:47:02 2010 +0000

description:
'satmgr' device for communicating with the satellite processor found on many
MPC824x-based systems. It registers the power button to sysmon and sets
a reboot/shutdown callback for cpu_reboot(). Other functions can be controlled
through /dev/satmgr.
Currently there is support for KuroBox and Synology, which will be extended
as soon more platforms have been reasearched.
This patch was submitted by Toru Nishimura.

diffstat:

 sys/arch/sandpoint/conf/GENERIC.NAS     |    7 +-
 sys/arch/sandpoint/conf/KUROBOX         |    7 +-
 sys/arch/sandpoint/conf/files.sandpoint |   12 +-
 sys/arch/sandpoint/sandpoint/machdep.c  |   31 +-
 sys/arch/sandpoint/sandpoint/satmgr.c   |  635 ++++++++++++++++++++++++++++++++
 5 files changed, 667 insertions(+), 25 deletions(-)

diffs (truncated from 807 to 300 lines):

diff -r 02434539e7d5 -r 96006428905c sys/arch/sandpoint/conf/GENERIC.NAS
--- a/sys/arch/sandpoint/conf/GENERIC.NAS       Sat May 29 22:45:41 2010 +0000
+++ b/sys/arch/sandpoint/conf/GENERIC.NAS       Sat May 29 22:47:02 2010 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC.NAS,v 1.13 2010/05/17 22:52:17 phx Exp $
+# $NetBSD: GENERIC.NAS,v 1.14 2010/05/29 22:47:02 phx Exp $
 #
 # machine description file for GENERIC.NAS
 # 
@@ -22,7 +22,7 @@
 
 options        INCLUDE_CONFIG_FILE     # embed config file in kernel binary
 
-#ident                 "GENERIC.NAS-$Revision: 1.13 $"
+#ident                 "GENERIC.NAS-$Revision: 1.14 $"
 
 maxusers       32
 
@@ -160,7 +160,8 @@
 
 eumb*  at mainbus0
 com0   at eumb? unit 0                 # console at 0x4500
-com1   at eumb? unit 1
+#com1  at eumb? unit 1
+satmgr0 at eumb? unit 1                        # satmgr at 0x4600
 ociic* at eumb?
 iic*   at ociic?
 rs5c372rtc* at iic? addr 0x32
diff -r 02434539e7d5 -r 96006428905c sys/arch/sandpoint/conf/KUROBOX
--- a/sys/arch/sandpoint/conf/KUROBOX   Sat May 29 22:45:41 2010 +0000
+++ b/sys/arch/sandpoint/conf/KUROBOX   Sat May 29 22:47:02 2010 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: KUROBOX,v 1.1 2010/05/17 22:52:17 phx Exp $
+#      $NetBSD: KUROBOX,v 1.2 2010/05/29 22:47:02 phx Exp $
 #
 # KuroBox/LinkStation support
 #
@@ -6,6 +6,7 @@
 include "arch/sandpoint/conf/GENERIC.NAS"
 
 no com0
-no com1
+no satmgr0
 com0   at eumb? unit 1                 # console at 0x4600
-com1   at eumb? unit 0
+#com1  at eumb? unit 0
+satmgr0 at eumb? unit 0                        # satmgr at 0x4500
diff -r 02434539e7d5 -r 96006428905c sys/arch/sandpoint/conf/files.sandpoint
--- a/sys/arch/sandpoint/conf/files.sandpoint   Sat May 29 22:45:41 2010 +0000
+++ b/sys/arch/sandpoint/conf/files.sandpoint   Sat May 29 22:47:02 2010 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.sandpoint,v 1.25 2008/04/09 01:56:19 nisimura Exp $
+#      $NetBSD: files.sandpoint,v 1.26 2010/05/29 22:47:02 phx Exp $
 #
 # Motorola's "SandPoint" evaluation board and multiplied descendents.
 #
@@ -94,14 +94,20 @@
 
 # Floppy disk controller
 device fdc {drive = -1}: isadma
-file   dev/isa/fd.c                    fdc needs-flag
+file   dev/isa/fd.c                            fdc needs-flag
 
 attach fdc at isa with fdc_isa
-file   dev/isa/fdc_isa.c               fdc_isa
+file   dev/isa/fdc_isa.c                       fdc_isa
 
 device fd: disk
 attach fd at fdc
 
 include        "dev/usb/files.usb"
 
+device satmgr: sysmon_power, sysmon_taskq
+attach satmgr at eumb
+file   arch/sandpoint/sandpoint/satmgr.c       satmgr
+
 include "arch/powerpc/conf/majors.powerpc"
+
+device-major   satmgr          char 100        satmgr
diff -r 02434539e7d5 -r 96006428905c sys/arch/sandpoint/sandpoint/machdep.c
--- a/sys/arch/sandpoint/sandpoint/machdep.c    Sat May 29 22:45:41 2010 +0000
+++ b/sys/arch/sandpoint/sandpoint/machdep.c    Sat May 29 22:47:02 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.50 2010/05/20 19:27:25 phx Exp $ */
+/*     $NetBSD: machdep.c,v 1.51 2010/05/29 22:47:02 phx Exp $ */
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.50 2010/05/20 19:27:25 phx Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.51 2010/05/29 22:47:02 phx Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_ddb.h"
@@ -98,14 +98,15 @@
 #include "ksyms.h"
 
 char bootinfo[BOOTINFO_MAXSIZE];
+void (*md_reboot)(int);
 
 void initppc(u_int, u_int, u_int, void *);
 void consinit(void);
 void sandpoint_bus_space_init(void);
 size_t mpc107memsize(void);
 
-#define        OFMEMREGIONS    32
-struct mem_region physmemr[OFMEMREGIONS], availmemr[OFMEMREGIONS];
+/* we support single chunk of memory */
+struct mem_region physmemr[2], availmemr[2];
 
 paddr_t avail_end;
 struct pic_ops *isa_pic = NULL;
@@ -142,8 +143,10 @@
                memsize = mpc107memsize();
        physmemr[0].start = 0;
        physmemr[0].size = memsize;
+       physmemr[1].size = 0;
        availmemr[0].start = (endkernel + PGOFSET) & ~PGOFSET;
        availmemr[0].size = memsize - availmemr[0].start;
+       availmemr[1].size = 0;
        avail_end = physmemr[0].start + physmemr[0].size; /* XXX */
 
        clockinfo = lookup_bootinfo(BTINFO_CLOCK);
@@ -360,7 +363,7 @@
        }           
        
        /* Disable intr */
-       splhigh();      
+       /* splhigh(); */
        
        /* Do dump if requested */
        if ((howto & (RB_DUMP | RB_HALT)) == RB_DUMP)
@@ -370,25 +373,21 @@
 
        pmf_system_shutdown(boothowto);
         
-       if (howto & RB_HALT) {
+       if ((howto & RB_POWERDOWN) == RB_HALT) {
                printf("\n");
                printf("The operating system has halted.\n");
                printf("Please press any key to reboot.\n\n");
                cnpollc(1);     /* for proper keyboard command handling */
                cngetc();  
                cnpollc(0);
+               howto = RB_AUTOBOOT;
        }
-    
-       printf("rebooting...\n\n");
 
-#if 1
-    {
-       /* XXX reboot scheme is target dependent XXX */
-       extern void jump_to_ppc_reset_entry(void);
-       jump_to_ppc_reset_entry();
-    }
-#endif
-       while (1);
+       if (md_reboot != NULL) {
+               (*md_reboot)(howto);
+               /* should not come here */
+       }
+       while (1) ; /* may practice PPC processor reset sequence here */
 }
 
 struct powerpc_bus_space sandpoint_io_space_tag = {
diff -r 02434539e7d5 -r 96006428905c sys/arch/sandpoint/sandpoint/satmgr.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/sandpoint/sandpoint/satmgr.c     Sat May 29 22:47:02 2010 +0000
@@ -0,0 +1,635 @@
+/* $NetBSD: satmgr.c,v 1.1 2010/05/29 22:47:02 phx Exp $ */
+
+/*-
+ * Copyright (c) 2010 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Tohru Nishimura.
+ *
+ * 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/param.h>
+#include <sys/systm.h> 
+#include <sys/kernel.h>
+#include <sys/device.h>
+#include <sys/conf.h>
+#include <sys/proc.h>
+#include <sys/vnode.h>
+#include <sys/select.h>
+#include <sys/poll.h>
+#include <sys/callout.h>
+#include <sys/sysctl.h>
+#include <sys/reboot.h>
+#include <sys/intr.h>
+
+#include <dev/sysmon/sysmonvar.h>
+#include <dev/sysmon/sysmon_taskq.h>
+
+#include <dev/ic/comreg.h>
+
+#include <machine/bus.h>
+#include <machine/intr.h>
+#include <machine/bootinfo.h>
+
+#include <sandpoint/sandpoint/eumbvar.h>
+#include "locators.h"
+
+struct satmgr_softc {
+       device_t                sc_dev;
+       bus_space_tag_t         sc_iot;
+       bus_space_handle_t      sc_ioh;
+       kmutex_t                sc_lock;
+       struct selinfo          sc_rsel;
+       callout_t               sc_ch_wdog;
+       callout_t               sc_ch_pbutton;
+       struct sysmon_pswitch   sc_sm_pbutton;
+       int                     sc_open;
+       void                    *sc_si;
+       uint32_t                sc_ierror, sc_overr;
+       char sc_rd_buf[16], *sc_rd_lim, *sc_rd_cur, *sc_rd_ptr;
+       char sc_wr_buf[16], *sc_wr_lim, *sc_wr_cur, *sc_wr_ptr;
+       int sc_rd_cnt, sc_wr_cnt;
+};
+
+static int  satmgr_match(device_t, cfdata_t, void *);
+static void satmgr_attach(device_t, device_t, void *);
+
+CFATTACH_DECL_NEW(satmgr, sizeof(struct satmgr_softc),
+    satmgr_match, satmgr_attach, NULL, NULL);
+extern struct cfdriver satmgr_cd;
+
+static int found = 0;
+extern void (*md_reboot)(int);
+
+static dev_type_open(satopen);
+static dev_type_close(satclose);
+static dev_type_read(satread);
+static dev_type_write(satwrite);
+static dev_type_poll(satpoll);
+static dev_type_kqfilter(satkqfilter);
+
+const struct cdevsw satmgr_cdevsw = {
+       satopen, satclose, satread, satwrite, noioctl,
+       nostop, notty, satpoll, nommap, satkqfilter, D_OTHER
+};
+
+static void satmgr_reboot(int);
+static int satmgr_sysctl_wdogenable(SYSCTLFN_PROTO);
+static void wdog_tickle(void *);
+static void send_sat(struct satmgr_softc *, const char *);
+static int hwintr(void *);
+static void rxintr(struct satmgr_softc *);
+static void startoutput(struct satmgr_softc *);
+static void swintr(void *);
+static void kbutton(struct satmgr_softc *, int);
+static void sbutton(struct satmgr_softc *, int);
+static void qbutton(struct satmgr_softc *, int);
+static void guarded_pbutton(void *);
+static void sched_sysmon_pbutton(void *);
+
+struct satmsg {
+       const char *family;
+       const char *reboot, *poweroff;
+       void (*dispatch)(struct satmgr_softc *, int);
+};
+
+const struct satmsg satmodel[] = {
+    { "kurobox",  "CCGG", "EEGG", kbutton },
+    { "synology", "C",    "1",    sbutton },
+    { "qnap",     "f",    "A",    qbutton }
+} *satmgr_msg;
+
+/* single byte stride register layout */
+#define RBR            0
+#define THR            0
+#define DLB            0
+#define IER            1
+#define DMB            1



Home | Main Index | Thread Index | Old Index