Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/hpcmips New button handler and power controller wit...



details:   https://anonhg.NetBSD.org/src/rev/5986a2e7d751
branches:  trunk
changeset: 479839:5986a2e7d751
user:      takemura <takemura%NetBSD.org@localhost>
date:      Thu Dec 23 06:26:08 1999 +0000

description:
New button handler and power controller with configurable hooking mechanism.

diffstat:

 sys/arch/hpcmips/conf/GENERIC             |   30 +++-
 sys/arch/hpcmips/conf/files.hpcmips       |   26 +++-
 sys/arch/hpcmips/conf/ioconf.incl.hpcmips |    3 +
 sys/arch/hpcmips/dev/btnmgr.c             |  177 +++++++++++++++++++++++++++
 sys/arch/hpcmips/hpcmips/config_hook.c    |  193 ++++++++++++++++++++++++++++++
 sys/arch/hpcmips/hpcmips/platid.c         |   10 +-
 sys/arch/hpcmips/include/config_hook.h    |   99 +++++++++++++++
 sys/arch/hpcmips/vr/button_vrgiu.c        |  156 ++++++++++++++++++++++++
 sys/arch/hpcmips/vr/com_vrip.c            |   25 ++-
 sys/arch/hpcmips/vr/pwctl_vrgiu.c         |  133 ++++++++++++++++++++
 sys/arch/hpcmips/vr/vrgiu.c               |   69 ++++------
 sys/arch/hpcmips/vr/vrgiuvar.h            |   12 +-
 sys/arch/hpcmips/vr/vrip.c                |   34 +++-
 sys/arch/hpcmips/vr/vrpmu.c               |    8 +-
 14 files changed, 890 insertions(+), 85 deletions(-)

diffs (truncated from 1302 to 300 lines):

diff -r 47102d31b643 -r 5986a2e7d751 sys/arch/hpcmips/conf/GENERIC
--- a/sys/arch/hpcmips/conf/GENERIC     Thu Dec 23 02:10:07 1999 +0000
+++ b/sys/arch/hpcmips/conf/GENERIC     Thu Dec 23 06:26:08 1999 +0000
@@ -2,7 +2,7 @@
 # Distribution kernel (any  model) kernel config file
 
 #
-#      $NetBSD: GENERIC,v 1.17 1999/11/29 02:20:11 shin Exp $
+#      $NetBSD: GENERIC,v 1.18 1999/12/23 06:26:08 takemura Exp $
 #
 include                "arch/hpcmips/conf/std.hpcmips"
 
@@ -127,11 +127,14 @@
 #  + Open/Close button: 6
 # (PCIC-ISA : 9)
 # (COM power:14)
-gpbus0 at vrgiu? platform NEC_MCR_3XX comctrl 14 button1 4 button2 6
-gpbus0 at vrgiu? platform NEC_MCR_5XX comctrl 14 button1 4 button2 6
-gpbus0 at vrgiu? platform NEC_MCR_7XX comctrl 46
-gpbus0 at vrgiu? platform NEC_MCCS comctrl 14
-
+button0 at vrgiu? platform NEC_MCR_3XX id BTN_REC port 4
+button1 at vrgiu? platform NEC_MCR_3XX id BTN_COVER port 6
+button0 at vrgiu? platform NEC_MCR_500 id BTN_REC port 4
+button1 at vrgiu? platform NEC_MCR_500 id BTN_COVER port 6
+pwctl0 at vrgiu? platform NEC_MCR_3XX id PWCTL_COM0 port 14
+pwctl0 at vrgiu? platform NEC_MCR_5XX id PWCTL_COM0 port 14
+pwctl0 at vrgiu? platform NEC_MCR_7XX id PWCTL_COM0 port 46
+pwctl0 at vrgiu? platform NEC_MCCS id PWCTL_COM0 port 14
 vrisab0 at vrgiu? platform NEC_MCR
 vrisab0 at vrgiu? platform NEC_MCCS
 vrisab0 at vrgiu? platform IBM_WORKPAD isaportoffset 0x1000000
@@ -154,7 +157,17 @@
 #        +12 +10
 #          +11
 # (PCIC-ISA : 23)
-gpbus1 at vrgiu? platform EVEREX_FREESTYLE button1 9 button2 10 button3 11 button4 12 button5 7 button6 4  button7 6  button8 5 button9 1 button10 20 button11 8
+button0 at vrgiu? platform EVEREX_FREESTYLE id BTN_APP0 port 9
+button1 at vrgiu? platform EVEREX_FREESTYLE id BTN_APP1 port 10
+button2 at vrgiu? platform EVEREX_FREESTYLE id BTN_APP2 port 11
+button3 at vrgiu? platform EVEREX_FREESTYLE id BTN_APP3 port 12
+button4 at vrgiu? platform EVEREX_FREESTYLE id BTN_CANCEL port 7
+button5 at vrgiu? platform EVEREX_FREESTYLE id BTN_UP port 4
+button6 at vrgiu? platform EVEREX_FREESTYLE id BTN_OK port 6
+button7 at vrgiu? platform EVEREX_FREESTYLE id BTN_DOWN port 5
+button8 at vrgiu? platform EVEREX_FREESTYLE id BTN_REC port 1
+button9 at vrgiu? platform EVEREX_FREESTYLE id BTN_LIGHT port 20
+button10 at vrgiu? platform EVEREX_FREESTYLE id BTN_CONTRAST port 8
 vrisab1 at vrgiu? platform EVEREX_FREESTYLE isaportoffset 0x1000000
 isa1   at vrisab1
 pcic0  at isa1 port 0x3e0 iomem 0x70000 iosiz 0x4000 irq 0x00170003
@@ -163,7 +176,7 @@
 #
 # Fujitsu INTERTOP CX300
 #
-gpbus2 at vrgiu? platform FUJITSU_INTERTOP comctrl 15
+pwctl0 at vrgiu? platform FUJITSU_INTERTOP id PWCTL_COM0 port 15
 vrisab2 at vrgiu? platform FUJITSU_INTERTOP isaportoffset 0x1000000
 isa2    at vrisab2
 pcic0   at isa2 port 0x3e0 iomem 0x70000 iosiz 0x4000 irq 0x00060003
@@ -205,6 +218,7 @@
 pseudo-device  ccd             4       # concatenated disks
 
 pseudo-device  biconsdev       1       # build-in console device
+pseudo-device  btnmgr          1       # button event handler
 
 # for IPv6
 pseudo-device  gif             4       # IPv[46] over IPv[46] tunnel (RFC1933)
diff -r 47102d31b643 -r 5986a2e7d751 sys/arch/hpcmips/conf/files.hpcmips
--- a/sys/arch/hpcmips/conf/files.hpcmips       Thu Dec 23 02:10:07 1999 +0000
+++ b/sys/arch/hpcmips/conf/files.hpcmips       Thu Dec 23 06:26:08 1999 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.hpcmips,v 1.11 1999/12/12 17:11:20 uch Exp $
+#      $NetBSD: files.hpcmips,v 1.12 1999/12/23 06:26:08 takemura Exp $
 
 # maxpartitions must be first item in files.${ARCH}.
 maxpartitions 8
@@ -50,13 +50,12 @@
 file   arch/hpcmips/hpcmips/bus_space.c
 #file  arch/hpcmips/hpcmips/bus_dma.c
 file   arch/hpcmips/hpcmips/disksubr.c disk
+file   arch/hpcmips/hpcmips/config_hook.c
 
 # Console autoconfiguration code: selects between a framebuffers
 file   dev/cons.c
 file   arch/hpcmips/dev/bicons.c
 file   arch/hpcmips/dev/bifont.c
-defpseudo      biconsdev
-file   arch/hpcmips/dev/biconsdev.c    biconsdev       needs-count
 
 # Raster operations
 include "dev/rasops/files.rasops"
@@ -77,9 +76,17 @@
 include "dev/isa/files.isa"
 
 #
+# pseudo devices
+#
+defpseudo      biconsdev
+file   arch/hpcmips/dev/biconsdev.c    biconsdev       needs-count
+defpseudo      btnmgr
+file   arch/hpcmips/dev/btnmgr.c       btnmgr
+
+#
 #  Vr41x1 integrated peripherals
 #
-device vrip { [addr=-1], [size=-1], [addr2=-1], [size2=-1], [intr=-1] }
+device vrip { [addr=-1], [size=-1], [addr2=-1], [size2=-1], [intr=-1], [pwctl=-1] }
 attach vrip at mainbus
 file arch/hpcmips/vr/vrip.c            vrip needs-flag
 
@@ -93,8 +100,9 @@
 
 device vrisabif {[platform = -1], [isaportoffset=0], [isamemoffset=0]}         # GIU attachment
 device  gpbusif {[platform = -1], [comctrl = -1], [button0 = -1], [button1 = -1], [button2 = -1], [button3 = -1], [button4 = -1], [button5 = -1], [button6 = -1], [button7 = -1], [button8 = -1], 
[button9 = -1], [button10 = -1], [button11 = -1]} 
+device  newgpbusif { [platform = -1], [id = -1], [port = -1], [active = 1], [level = -1] }
 
-device vrgiu: vrisabif, gpbusif
+device vrgiu: vrisabif, gpbusif, newgpbusif
 attach vrgiu at vrip
 file arch/hpcmips/vr/vrgiu.c                   vrgiu
 
@@ -106,6 +114,14 @@
 attach vrisab at vrisabif
 file arch/hpcmips/isa/isa_machdep.c            vrisab
 
+device pwctl
+attach pwctl at newgpbusif with pwctl_vrgiu
+file arch/hpcmips/vr/pwctl_vrgiu.c             pwctl_vrgiu
+
+device button
+attach button at newgpbusif with button_vrgiu
+file arch/hpcmips/vr/button_vrgiu.c            button_vrgiu
+
 device vrbcu
 attach vrbcu at vrip
 file arch/hpcmips/vr/bcu_vrip.c                        vrbcu needs-flag
diff -r 47102d31b643 -r 5986a2e7d751 sys/arch/hpcmips/conf/ioconf.incl.hpcmips
--- a/sys/arch/hpcmips/conf/ioconf.incl.hpcmips Thu Dec 23 02:10:07 1999 +0000
+++ b/sys/arch/hpcmips/conf/ioconf.incl.hpcmips Thu Dec 23 06:26:08 1999 +0000
@@ -6,3 +6,6 @@
 #define PLATID_DEFINE_MASK_NICKNAME
 #include <machine/platid_mask.h>
 #undef PLATID_DEFINE_MASK_NICKNAME
+#define CONFIG_HOOK_DEFINE_NICKNAME
+#include <machine/config_hook.h>
+#undef CONFIG_HOOK_DEFINE_NICKNAME
diff -r 47102d31b643 -r 5986a2e7d751 sys/arch/hpcmips/dev/btnmgr.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/hpcmips/dev/btnmgr.c     Thu Dec 23 06:26:08 1999 +0000
@@ -0,0 +1,177 @@
+/*     $NetBSD: btnmgr.c,v 1.1 1999/12/23 06:26:09 takemura Exp $      */
+
+/*-
+ * Copyright (c) 1999
+ *         Shin Takemura and PocketBSD Project. All rights reserved.
+ *
+ * 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.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the PocketBSD project
+ *     and its contributors.
+ * 4. Neither the name of the project nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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/ioctl.h>
+#include <sys/conf.h>
+#include <sys/device.h>
+#include <sys/malloc.h>
+#include <sys/kernel.h>
+
+#include <machine/config_hook.h>
+
+cdev_decl(btnmgr);
+
+struct btnmgr_softc {
+       config_hook_tag sc_hook_tag;
+};
+
+static struct btnmgr_softc *the_btnmgr_sc;
+
+void           btnmgrattach  __P((int n));
+static int     btnmgr_hook __P((void *ctx, int type, long id,
+                                void *msg));
+static char*   btnmgr_name __P((long id));
+
+static struct {
+       long id;
+       char *name;
+} button_names[] = {
+       { CONFIG_HOOK_BUTTONEVENT_POWER,        "Power"         },
+       { CONFIG_HOOK_BUTTONEVENT_OK,           "OK"            },
+       { CONFIG_HOOK_BUTTONEVENT_CANCEL,       "Cancel"        },
+       { CONFIG_HOOK_BUTTONEVENT_UP,           "Up"            },
+       { CONFIG_HOOK_BUTTONEVENT_DOWN,         "Down"          },
+       { CONFIG_HOOK_BUTTONEVENT_REC,          "Rec"           },
+       { CONFIG_HOOK_BUTTONEVENT_COVER,        "Cover"         },
+       { CONFIG_HOOK_BUTTONEVENT_LIGHT,        "Light"         },
+       { CONFIG_HOOK_BUTTONEVENT_CONTRAST,     "Contrast"      },
+       { CONFIG_HOOK_BUTTONEVENT_APP0,         "Application 0" },
+       { CONFIG_HOOK_BUTTONEVENT_APP1,         "Application 1" },
+       { CONFIG_HOOK_BUTTONEVENT_APP2,         "Application 2" },
+       { CONFIG_HOOK_BUTTONEVENT_APP3,         "Application 3" },
+};
+static int n_button_names = sizeof(button_names)/sizeof(*button_names);
+
+void
+btnmgrattach (n)
+       int n;
+{
+       int id;
+
+       printf("button manager\n");
+
+       the_btnmgr_sc = malloc(sizeof(struct btnmgr_softc), M_DEVBUF,
+                              cold ? M_NOWAIT : M_WAITOK);
+       if (the_btnmgr_sc == NULL)
+               panic("button manager: malloc failed");
+       bzero(the_btnmgr_sc, sizeof(struct btnmgr_softc));
+
+       for (id = 0; id < 16; id++)
+               the_btnmgr_sc->sc_hook_tag =
+                       config_hook(CONFIG_HOOK_BUTTONEVENT,
+                                   id, CONFIG_HOOK_SHARE,
+                                   btnmgr_hook,
+                                   the_btnmgr_sc);
+}
+
+int
+btnmgr_hook(ctx, type, id, msg)
+       void *ctx;
+       int type;
+       long id;
+       void *msg;
+{
+#ifdef notyet
+       struct btnmgr_softc *sc = ctx;
+#endif /* not yet */
+
+       printf("%s button: %s\n", btnmgr_name(id), msg ? "ON" : "OFF");
+
+       return (0);
+}
+
+char*
+btnmgr_name(id)
+       long id;
+{
+       int i;
+
+       for (i = 0; i < n_button_names; i++)
+               if (button_names[i].id == id)
+                       return (button_names[i].name);
+       return ("unknown");
+}
+
+#ifdef notyet
+int
+btnmgropen(dev, flag, mode, p)
+       dev_t dev;
+       int flag, mode;
+       struct proc *p;
+{
+       return (EINVAL);
+}
+
+int
+btnmgrclose(dev, flag, mode, p)
+       dev_t dev;
+       int flag, mode;
+       struct proc *p;
+{
+       return (EINVAL);
+}
+
+int



Home | Main Index | Thread Index | Old Index