Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sandpoint New device nhpow(4) to support the onboar...



details:   https://anonhg.NetBSD.org/src/rev/aaa15f9056e7
branches:  trunk
changeset: 772730:aaa15f9056e7
user:      phx <phx%NetBSD.org@localhost>
date:      Sat Jan 14 19:39:25 2012 +0000

description:
New device nhpow(4) to support the onboard GPIO pins on a NH230/231 board for
buttons, powerdown, reset, LEDs and fan control. It attaches gpio(4) for
its 8 pins on demand.

diffstat:

 sys/arch/sandpoint/conf/GENERIC         |    9 +-
 sys/arch/sandpoint/conf/KUROBOX         |    5 +-
 sys/arch/sandpoint/conf/files.sandpoint |   18 +-
 sys/arch/sandpoint/include/bus_funcs.h  |    3 +-
 sys/arch/sandpoint/sandpoint/machdep.c  |   19 +-
 sys/arch/sandpoint/sandpoint/mainbus.c  |   14 +-
 sys/arch/sandpoint/sandpoint/nhpow.c    |  324 ++++++++++++++++++++++++++++++++
 7 files changed, 375 insertions(+), 17 deletions(-)

diffs (truncated from 562 to 300 lines):

diff -r 8de7bcb20e9b -r aaa15f9056e7 sys/arch/sandpoint/conf/GENERIC
--- a/sys/arch/sandpoint/conf/GENERIC   Sat Jan 14 19:35:58 2012 +0000
+++ b/sys/arch/sandpoint/conf/GENERIC   Sat Jan 14 19:39:25 2012 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.65 2012/01/07 20:51:23 phx Exp $
+# $NetBSD: GENERIC,v 1.66 2012/01/14 19:39:25 phx Exp $
 #
 # machine description file for GENERIC NAS
 # 
@@ -22,7 +22,7 @@
 
 options        INCLUDE_CONFIG_FILE     # embed config file in kernel binary
 
-#ident                 "GENERIC-$Revision: 1.65 $"
+#ident                 "GENERIC-$Revision: 1.66 $"
 
 maxusers       32
 
@@ -179,6 +179,8 @@
 #nor*          at cfi?
 #flash*                at nor?
 
+nhpow0         at mainbus0                     # NH230/231 power,LED,buttons
+
 pci*           at mainbus0 bus ?
 pchb*          at pci? dev ? function ?        # PCI host bridge
 
@@ -225,6 +227,9 @@
 makphy* at mii? phy ?                  # Marvell Semiconductor 88E1000 PHYs
 ukphy* at mii? phy ?                   # generic unknown PHYs
 
+# GPIO devices
+gpio*  at gpiobus?
+
 # USB Controller and Devices
 ehci*  at pci? dev ? function ?        # Enhanced Host Controller
 ohci*  at pci? dev ? function ?        # Open Host Controller
diff -r 8de7bcb20e9b -r aaa15f9056e7 sys/arch/sandpoint/conf/KUROBOX
--- a/sys/arch/sandpoint/conf/KUROBOX   Sat Jan 14 19:35:58 2012 +0000
+++ b/sys/arch/sandpoint/conf/KUROBOX   Sat Jan 14 19:39:25 2012 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: KUROBOX,v 1.3 2010/06/09 17:34:32 phx Exp $
+#      $NetBSD: KUROBOX,v 1.4 2012/01/14 19:39:25 phx Exp $
 #
 # KuroBox/LinkStation support
 #
@@ -10,3 +10,6 @@
 com0   at eumb? unit 1                 # console at 0x4600
 #com1  at eumb? unit 0
 satmgr0 at eumb? unit 0                        # satmgr at 0x4500
+
+no nhpow0
+no gpio*
diff -r 8de7bcb20e9b -r aaa15f9056e7 sys/arch/sandpoint/conf/files.sandpoint
--- a/sys/arch/sandpoint/conf/files.sandpoint   Sat Jan 14 19:35:58 2012 +0000
+++ b/sys/arch/sandpoint/conf/files.sandpoint   Sat Jan 14 19:39:25 2012 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.sandpoint,v 1.30 2011/12/17 20:20:37 phx Exp $
+#      $NetBSD: files.sandpoint,v 1.31 2012/01/14 19:39:25 phx Exp $
 #
 # Motorola's "SandPoint" evaluation board and multiplied descendents.
 #
@@ -31,12 +31,12 @@
 #
 # Memory Disk for install floppy
 #
-file dev/md_root.c     memory_disk_hooks
+file   dev/md_root.c   memory_disk_hooks
 
 #
 # System bus types
 #
-define mainbus { }
+define mainbus { }
 device mainbus: isabus, pcibus, mainbus
 attach mainbus at root
 
@@ -48,15 +48,19 @@
 attach cfi at mainbus with sandpointcfi
 file   arch/sandpoint/sandpoint/flash_cfi.c    sandpointcfi
 
-device eumb { [ unit = -1 ] }: mainbus
-attach eumb at mainbus
+device nhpow: sysmon_power, sysmon_taskq, gpiobus
+attach nhpow at mainbus
+file   arch/sandpoint/sandpoint/nhpow.c        nhpow
+
+device eumb { [ unit = -1 ] }: mainbus
+attach eumb at mainbus
 file   arch/sandpoint/sandpoint/eumb.c         eumb
 
-attach com at eumb with com_eumb
+attach com at eumb with com_eumb
 file   arch/sandpoint/sandpoint/com_eumb.c     com_eumb needs-flag
 
 device ociic: motoi2c, i2cbus
-attach ociic at eumb with iic_eumb
+attach ociic at eumb with iic_eumb
 file   arch/sandpoint/sandpoint/iic_eumb.c     iic_eumb
 
 device satmgr: sysmon_power, sysmon_taskq
diff -r 8de7bcb20e9b -r aaa15f9056e7 sys/arch/sandpoint/include/bus_funcs.h
--- a/sys/arch/sandpoint/include/bus_funcs.h    Sat Jan 14 19:35:58 2012 +0000
+++ b/sys/arch/sandpoint/include/bus_funcs.h    Sat Jan 14 19:39:25 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bus_funcs.h,v 1.2 2011/12/17 20:20:37 phx Exp $        */
+/*     $NetBSD: bus_funcs.h,v 1.3 2012/01/14 19:39:25 phx Exp $        */
 /*     $OpenBSD: bus.h,v 1.1 1997/10/13 10:53:42 pefo Exp $    */
 
 #ifndef _SANDPOINT_BUS_FUNCS_H_
@@ -11,6 +11,7 @@
 extern struct powerpc_bus_space genppc_isa_mem_space_tag;
 extern struct powerpc_bus_space sandpoint_eumb_space_tag;
 extern struct powerpc_bus_space sandpoint_flash_space_tag;
+extern struct powerpc_bus_space sandpoint_nhgpio_space_tag;
 #endif
 
 #include <powerpc/bus_funcs.h>
diff -r 8de7bcb20e9b -r aaa15f9056e7 sys/arch/sandpoint/sandpoint/machdep.c
--- a/sys/arch/sandpoint/sandpoint/machdep.c    Sat Jan 14 19:35:58 2012 +0000
+++ b/sys/arch/sandpoint/sandpoint/machdep.c    Sat Jan 14 19:39:25 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.60 2011/12/17 20:20:38 phx Exp $ */
+/*     $NetBSD: machdep.c,v 1.61 2012/01/14 19:39:25 phx Exp $ */
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.60 2011/12/17 20:20:38 phx Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.61 2012/01/14 19:39:25 phx Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_ddb.h"
@@ -122,12 +122,12 @@
 void
 initppc(u_int startkernel, u_int endkernel, u_int args, void *btinfo)
 {
+       extern u_long ticks_per_sec, ns_per_tick;
        struct btinfo_magic *bi_magic = btinfo;
        struct btinfo_memory *meminfo;
        struct btinfo_clock *clockinfo;
        size_t memsize;
        u_long ticks;
-       extern u_long ticks_per_sec, ns_per_tick;
 
        if ((unsigned)btinfo != 0 && (unsigned)btinfo < startkernel
            && bi_magic->magic == BOOTINFO_MAGIC)
@@ -173,6 +173,7 @@
        oea_batinit(
            0x80000000, BAT_BL_256M,    /* SANDPOINT_BUS_SPACE_MEM */
            0xfc000000, BAT_BL_64M,     /* _EUMB|_IO */
+           0x70000000, BAT_BL_128K,    /* only for NH230 board control */
            0);
 
        /* Install vectors and interrupt handler */
@@ -452,8 +453,12 @@
        _BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_MEM_TYPE,
        0x00000000, 0xff000000, 0x00000000,
 };
+struct powerpc_bus_space sandpoint_nhgpio_space_tag = {
+       _BUS_SPACE_BIG_ENDIAN|_BUS_SPACE_MEM_TYPE,
+       0x70000000, 0x00000000, 0x00001000,
+};
 
-static char ex_storage[6][EXTENT_FIXED_STORAGE_SIZE(8)]
+static char ex_storage[7][EXTENT_FIXED_STORAGE_SIZE(8)]
     __attribute__((aligned(8)));
 
 void
@@ -496,6 +501,12 @@
            ex_storage[5], sizeof(ex_storage[5]));
        if (error)
                panic("sandpoint_bus_space_init: can't init flash tag");
+
+       /* NH230/231 only: extended ROM space at 0x70000000 for GPIO */
+       error = bus_space_init(&sandpoint_nhgpio_space_tag, "nh23x-gpio",
+           ex_storage[6], sizeof(ex_storage[6]));
+       if (error)
+               panic("sandpoint_bus_space_init: can't init nhgpio tag");
 }
 
 #define MPC107_EUMBBAR         0x78    /* Eumb base address */
diff -r 8de7bcb20e9b -r aaa15f9056e7 sys/arch/sandpoint/sandpoint/mainbus.c
--- a/sys/arch/sandpoint/sandpoint/mainbus.c    Sat Jan 14 19:35:58 2012 +0000
+++ b/sys/arch/sandpoint/sandpoint/mainbus.c    Sat Jan 14 19:39:25 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mainbus.c,v 1.26 2011/12/18 14:28:59 phx Exp $ */
+/*     $NetBSD: mainbus.c,v 1.27 2012/01/14 19:39:25 phx Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.26 2011/12/18 14:28:59 phx Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.27 2012/01/14 19:39:25 phx Exp $");
 
 #include "opt_pci.h"
 #include "pci.h"
@@ -43,6 +43,7 @@
 #include <sys/systm.h>
 
 #include <machine/autoconf.h>
+#include <machine/bootinfo.h>
 #include <machine/isa_machdep.h>
 
 #include <dev/pci/pcivar.h>
@@ -75,6 +76,7 @@
 {
        struct mainbus_attach_args mba;
        struct pcibus_attach_args pba;
+       struct btinfo_prodfamily *pfam;
 #if defined(PCI_NETBSD_CONFIGURE)
        struct extent *ioext, *memext;
 #endif
@@ -89,6 +91,14 @@
        mba.ma_bst = &sandpoint_eumb_space_tag;
        config_found_ia(self, "mainbus", &mba, mainbus_print);
 
+       pfam = lookup_bootinfo(BTINFO_PRODFAMILY);
+       if (pfam != NULL && strcmp(pfam->name, "nhnas") == 0) {
+               /* attach nhpow(4) for NH230/231 only */
+               mba.ma_name = "nhpow";
+               mba.ma_bst = &sandpoint_nhgpio_space_tag;
+               config_found_ia(self, "mainbus", &mba, mainbus_print);
+       }
+
        mba.ma_name = "cfi";
        mba.ma_bst = &sandpoint_flash_space_tag;
        mba.ma_addr = 0xffe00000; /* smallest flash is 2 MiB */
diff -r 8de7bcb20e9b -r aaa15f9056e7 sys/arch/sandpoint/sandpoint/nhpow.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/sandpoint/sandpoint/nhpow.c      Sat Jan 14 19:39:25 2012 +0000
@@ -0,0 +1,324 @@
+/* $NetBSD: nhpow.c,v 1.1 2012/01/14 19:39:25 phx Exp $ */
+
+/*-
+ * Copyright (c) 2012 Frank Wille.
+ * All rights reserved.
+ *
+ * Written by Frank Wille for The NetBSD Project.
+ *
+ * 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.
+ */
+
+/*
+ * NH230/231 power and LED control, button handling
+ */
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: nhpow.c,v 1.1 2012/01/14 19:39:25 phx Exp $");
+#include "gpio.h"
+
+#include <sys/param.h>
+#include <sys/device.h>
+#if NGPIO > 0
+#include <sys/gpio.h>
+#endif
+#include <sys/callout.h>
+#include <sys/kernel.h>
+#include <sys/proc.h>
+#include <sys/reboot.h>
+#include <sys/sysctl.h>
+
+#if NGPIO > 0
+#include <dev/gpio/gpiovar.h>
+#endif
+#include <dev/sysmon/sysmonvar.h>
+#include <dev/sysmon/sysmon_taskq.h>
+
+#include <machine/autoconf.h>
+
+static int  nhpow_match(device_t, cfdata_t, void *);
+static void nhpow_attach(device_t, device_t, void *);
+static void nhpow_reboot(int);
+static int nhpow_sysctl_fan(SYSCTLFN_PROTO);
+static int hwintr(void *);
+static void guarded_pbutton(void *);



Home | Main Index | Thread Index | Old Index