New button handler and power controller with configurable hooking mechanism.
This commit is contained in:
parent
8515b446a0
commit
98a2a24647
@ -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 @@ vrdsu* at vrip? addr 0x0b0000e0 size 0x08
|
||||
# + 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 @@ pcic0 at isa0 port 0x3e0 iomem 0x70000 iosiz 0x4000 irq 0x00090003
|
||||
# +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 @@ options PCIC_ISA_INTR_ALLOC_MASK=0x0008 # IRQ 3 only (MCR/Freestyle)
|
||||
#
|
||||
# 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 vnd 4 # virtual disk ick
|
||||
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)
|
||||
|
@ -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/mainbus.c
|
||||
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"
|
||||
@ -76,10 +75,18 @@ file arch/hpcmips/dev/fb.c fb needs-flag
|
||||
#
|
||||
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 @@ file arch/hpcmips/vr/cmu.c vrcmu
|
||||
|
||||
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 @@ device vrisab: isabus
|
||||
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
|
||||
|
@ -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
|
||||
|
177
sys/arch/hpcmips/dev/btnmgr.c
Normal file
177
sys/arch/hpcmips/dev/btnmgr.c
Normal file
@ -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
|
||||
btnmgrread(dev, uio, flag)
|
||||
dev_t dev;
|
||||
struct uio *uio;
|
||||
int flag;
|
||||
{
|
||||
return (EINVAL);
|
||||
}
|
||||
|
||||
int
|
||||
btnmgrwrite(dev, uio, flag)
|
||||
dev_t dev;
|
||||
struct uio *uio;
|
||||
int flag;
|
||||
{
|
||||
return (EINVAL);
|
||||
}
|
||||
|
||||
int
|
||||
btnmgrioctl(dev, cmd, data, flag, p)
|
||||
dev_t dev;
|
||||
u_long cmd;
|
||||
caddr_t data;
|
||||
int flag;
|
||||
struct proc *p;
|
||||
{
|
||||
return (EINVAL);
|
||||
}
|
||||
#endif /* notyet */
|
193
sys/arch/hpcmips/hpcmips/config_hook.c
Normal file
193
sys/arch/hpcmips/hpcmips/config_hook.c
Normal file
@ -0,0 +1,193 @@
|
||||
/* $NetBSD: config_hook.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.
|
||||
*
|
||||
*/
|
||||
|
||||
#define XXX_AUTO_INIT /* XXX, Where would we call config_hook_init() from? */
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/device.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
|
||||
#include <machine/config_hook.h>
|
||||
|
||||
struct hook_rec {
|
||||
LIST_ENTRY(hook_rec) hr_link;
|
||||
void *hr_ctx;
|
||||
int hr_type;
|
||||
long hr_id;
|
||||
enum config_hook_mode hr_mode;
|
||||
int (*hr_func) __P((void *, int, long, void *));
|
||||
};
|
||||
|
||||
LIST_HEAD(hook_list, hook_rec);
|
||||
struct hook_list hook_lists[CONFIG_HOOK_NTYPES];
|
||||
|
||||
void
|
||||
config_hook_init()
|
||||
{
|
||||
int i;
|
||||
#ifdef XXX_AUTO_INIT
|
||||
static int initialized = 0;
|
||||
|
||||
if (initialized) {
|
||||
return;
|
||||
}
|
||||
initialized = 1;
|
||||
#endif
|
||||
|
||||
for (i = 0; i < CONFIG_HOOK_NTYPES; i++) {
|
||||
LIST_INIT(&hook_lists[i]);
|
||||
}
|
||||
}
|
||||
|
||||
config_hook_tag
|
||||
config_hook(type, id, mode, func, ctx)
|
||||
int type;
|
||||
long id;
|
||||
enum config_hook_mode mode;
|
||||
int (*func) __P((void*, int, long, void*));
|
||||
void *ctx;
|
||||
{
|
||||
struct hook_rec *hr, *prev_hr;
|
||||
int s;
|
||||
|
||||
#ifdef XXX_AUTO_INIT
|
||||
config_hook_init();
|
||||
#endif
|
||||
/* Check type value. */
|
||||
if (type < 0 || CONFIG_HOOK_NTYPES <= type) {
|
||||
panic("config_hook: invalid hook type");
|
||||
}
|
||||
|
||||
/*
|
||||
* Check mode compatibility.
|
||||
*/
|
||||
prev_hr = NULL;
|
||||
for (hr = LIST_FIRST(&hook_lists[type]); hr != NULL;
|
||||
hr = LIST_NEXT(hr, hr_link)) {
|
||||
if (hr->hr_id == id) {
|
||||
if (hr->hr_mode != mode) {
|
||||
panic("config_hook: incompatible mode on type=%d/id=%d",
|
||||
type, id);
|
||||
}
|
||||
prev_hr = hr;
|
||||
}
|
||||
}
|
||||
switch (mode) {
|
||||
case CONFIG_HOOK_SHARE:
|
||||
/* nothing to do */
|
||||
break;
|
||||
case CONFIG_HOOK_REPLACE:
|
||||
if (prev_hr != NULL) {
|
||||
printf("config_hook: type=%d/id=%ld is replaced",
|
||||
type, id);
|
||||
s = splhigh();
|
||||
LIST_REMOVE(prev_hr, hr_link);
|
||||
prev_hr->hr_link.le_next = NULL;
|
||||
splx(s);
|
||||
}
|
||||
break;
|
||||
case CONFIG_HOOK_EXCLUSIVE:
|
||||
if (prev_hr != NULL) {
|
||||
panic("config_hook: type=%d/id=%ld is already hooked",
|
||||
type, id);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
hr = malloc(sizeof(*hr), M_DEVBUF, cold ? M_NOWAIT : M_WAITOK);
|
||||
if (hr == NULL)
|
||||
panic("config_hook: malloc failed");
|
||||
|
||||
hr->hr_ctx = ctx;
|
||||
hr->hr_type = type;
|
||||
hr->hr_id = id;
|
||||
hr->hr_func = func;
|
||||
s = splhigh();
|
||||
LIST_INSERT_HEAD(&hook_lists[type], hr, hr_link);
|
||||
splx(s);
|
||||
|
||||
return (hr);
|
||||
}
|
||||
|
||||
void
|
||||
config_unhook(hrx)
|
||||
config_hook_tag hrx;
|
||||
{
|
||||
int s;
|
||||
struct hook_rec *hr = (struct hook_rec*)hrx;
|
||||
|
||||
#ifdef XXX_AUTO_INIT
|
||||
config_hook_init();
|
||||
#endif
|
||||
if (hr->hr_link.le_next != NULL) {
|
||||
s = splhigh();
|
||||
LIST_REMOVE(hr, hr_link);
|
||||
hr->hr_link.le_next = NULL;
|
||||
splx(s);
|
||||
}
|
||||
free(hr, M_DEVBUF);
|
||||
}
|
||||
|
||||
int
|
||||
config_hook_call(type, id, msg)
|
||||
int type;
|
||||
long id;
|
||||
void *msg;
|
||||
{
|
||||
int res;
|
||||
struct hook_rec *hr;
|
||||
|
||||
#ifdef XXX_AUTO_INIT
|
||||
config_hook_init();
|
||||
#endif
|
||||
/* Check type value. */
|
||||
if (type < 0 || CONFIG_HOOK_NTYPES <= type) {
|
||||
panic("config_hook: invalid hook type");
|
||||
}
|
||||
|
||||
res = -1;
|
||||
for (hr = LIST_FIRST(&hook_lists[type]); hr != NULL;
|
||||
hr = LIST_NEXT(hr, hr_link)) {
|
||||
if (hr->hr_id == id) {
|
||||
res = (*hr->hr_func)(hr->hr_ctx, type, id, msg);
|
||||
}
|
||||
}
|
||||
return (res);
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: platid.c,v 1.1.1.1 1999/09/16 12:23:21 takemura Exp $ */
|
||||
/* $NetBSD: platid.c,v 1.2 1999/12/23 06:26:09 takemura Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999
|
||||
@ -82,13 +82,17 @@ platid_match(platid_t *platid, platid_mask_t *mask)
|
||||
int
|
||||
platid_match_sub(platid_t *platid, platid_mask_t *mask, int unknown_is_match)
|
||||
{
|
||||
int match_count;
|
||||
|
||||
#define PLATID_MATCH(mbr) \
|
||||
if (platid->s.mbr != mask->s.mbr && \
|
||||
mask->s.mbr != platid_wild.s.mbr && \
|
||||
!(platid->s.mbr == platid_unknown.s.mbr && unknown_is_match)) { \
|
||||
return (0); \
|
||||
}
|
||||
} else if (platid->s.mbr == mask->s.mbr) \
|
||||
match_count++;
|
||||
|
||||
match_count = 1;
|
||||
PLATID_MATCH(cpu_submodel);
|
||||
PLATID_MATCH(cpu_model);
|
||||
PLATID_MATCH(cpu_series);
|
||||
@ -99,7 +103,7 @@ platid_match_sub(platid_t *platid, platid_mask_t *mask, int unknown_is_match)
|
||||
PLATID_MATCH(series);
|
||||
PLATID_MATCH(vendor);
|
||||
|
||||
return (1);
|
||||
return (match_count);
|
||||
|
||||
#undef PLATID_MATCH
|
||||
}
|
||||
|
99
sys/arch/hpcmips/include/config_hook.h
Normal file
99
sys/arch/hpcmips/include/config_hook.h
Normal file
@ -0,0 +1,99 @@
|
||||
/* $NetBSD: config_hook.h,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.
|
||||
*
|
||||
*/
|
||||
|
||||
enum config_hook_mode {
|
||||
CONFIG_HOOK_SHARE,
|
||||
CONFIG_HOOK_REPLACE,
|
||||
CONFIG_HOOK_EXCLUSIVE,
|
||||
};
|
||||
|
||||
typedef void *config_hook_tag;
|
||||
|
||||
void config_hook_init __P((void));
|
||||
config_hook_tag config_hook __P((int type, long id, enum config_hook_mode mode,
|
||||
int (*func) __P((void*, int, long, void*)),
|
||||
void *ctx));
|
||||
void config_unhook __P((config_hook_tag));
|
||||
int config_hook_call __P((int type, long id, void *msg));
|
||||
|
||||
/*
|
||||
* hook types and IDs
|
||||
*/
|
||||
#define CONFIG_HOOK_POWERCONTROL 0
|
||||
#define CONFIG_HOOK_POWERCONTROL_COM0 0
|
||||
#define CONFIG_HOOK_POWERCONTROL_COM1 1
|
||||
#define CONFIG_HOOK_POWERCONTROL_COM2 2
|
||||
#define CONFIG_HOOK_POWERCONTROL_COM3 3
|
||||
|
||||
#define CONFIG_HOOK_BUTTONEVENT 1
|
||||
#define CONFIG_HOOK_BUTTONEVENT_POWER 0
|
||||
#define CONFIG_HOOK_BUTTONEVENT_OK 1
|
||||
#define CONFIG_HOOK_BUTTONEVENT_CANCEL 2
|
||||
#define CONFIG_HOOK_BUTTONEVENT_UP 3
|
||||
#define CONFIG_HOOK_BUTTONEVENT_DOWN 4
|
||||
#define CONFIG_HOOK_BUTTONEVENT_REC 5
|
||||
#define CONFIG_HOOK_BUTTONEVENT_COVER 6
|
||||
#define CONFIG_HOOK_BUTTONEVENT_LIGHT 7
|
||||
#define CONFIG_HOOK_BUTTONEVENT_CONTRAST 8
|
||||
#define CONFIG_HOOK_BUTTONEVENT_APP0 9
|
||||
#define CONFIG_HOOK_BUTTONEVENT_APP1 10
|
||||
#define CONFIG_HOOK_BUTTONEVENT_APP2 11
|
||||
#define CONFIG_HOOK_BUTTONEVENT_APP3 12
|
||||
|
||||
#define CONFIG_HOOK_NTYPES 2
|
||||
|
||||
/*
|
||||
* nicknames for including from configration file.
|
||||
*/
|
||||
#ifdef CONFIG_HOOK_DEFINE_NICKNAME
|
||||
#define PWCTL_COM0 CONFIG_HOOK_POWERCONTROL_COM0
|
||||
#define PWCTL_COM1 CONFIG_HOOK_POWERCONTROL_COM1
|
||||
#define PWCTL_COM2 CONFIG_HOOK_POWERCONTROL_COM2
|
||||
#define PWCTL_COM3 CONFIG_HOOK_POWERCONTROL_COM3
|
||||
#define BTN_POWER CONFIG_HOOK_BUTTONEVENT_POWER
|
||||
#define BTN_OK CONFIG_HOOK_BUTTONEVENT_OK
|
||||
#define BTN_CANCEL CONFIG_HOOK_BUTTONEVENT_CANCEL
|
||||
#define BTN_UP CONFIG_HOOK_BUTTONEVENT_UP
|
||||
#define BTN_DOWN CONFIG_HOOK_BUTTONEVENT_DOWN
|
||||
#define BTN_REC CONFIG_HOOK_BUTTONEVENT_REC
|
||||
#define BTN_COVER CONFIG_HOOK_BUTTONEVENT_COVER
|
||||
#define BTN_LIGHT CONFIG_HOOK_BUTTONEVENT_LIGHT
|
||||
#define BTN_CONTRAST CONFIG_HOOK_BUTTONEVENT_CONTRAST
|
||||
#define BTN_APP0 CONFIG_HOOK_BUTTONEVENT_APP0
|
||||
#define BTN_APP1 CONFIG_HOOK_BUTTONEVENT_APP1
|
||||
#define BTN_APP2 CONFIG_HOOK_BUTTONEVENT_APP2
|
||||
#define BTN_APP3 CONFIG_HOOK_BUTTONEVENT_APP3
|
||||
#endif /* CONFIG_HOOK_DEFINE_NICKNAME */
|
156
sys/arch/hpcmips/vr/button_vrgiu.c
Normal file
156
sys/arch/hpcmips/vr/button_vrgiu.c
Normal file
@ -0,0 +1,156 @@
|
||||
/* $NetBSD: button_vrgiu.c,v 1.1 1999/12/23 06:26:10 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/device.h>
|
||||
|
||||
#include <machine/bus.h>
|
||||
|
||||
#include <machine/config_hook.h>
|
||||
#include <machine/platid.h>
|
||||
#include <machine/platid_mask.h>
|
||||
|
||||
#include <hpcmips/vr/vripreg.h>
|
||||
#include <hpcmips/vr/vripvar.h>
|
||||
#include <hpcmips/vr/vrgiureg.h>
|
||||
|
||||
#include "locators.h"
|
||||
|
||||
struct button_vrgiu_softc {
|
||||
struct device sc_dev;
|
||||
vrgiu_chipset_tag_t sc_gc;
|
||||
vrgiu_function_tag_t sc_gf;
|
||||
int sc_port;
|
||||
long sc_id;
|
||||
int sc_active;
|
||||
config_hook_tag sc_hook_tag;
|
||||
};
|
||||
|
||||
static int button_vrgiu_match __P((struct device *, struct cfdata *,
|
||||
void *));
|
||||
static void button_vrgiu_attach __P((struct device *, struct device *,
|
||||
void *));
|
||||
static int button_vrgiu_intr __P((void*));
|
||||
|
||||
struct cfattach button_vrgiu_ca = {
|
||||
sizeof(struct button_vrgiu_softc), button_vrgiu_match, button_vrgiu_attach
|
||||
};
|
||||
|
||||
int
|
||||
button_vrgiu_match(parent, match, aux)
|
||||
struct device *parent;
|
||||
struct cfdata *match;
|
||||
void *aux;
|
||||
{
|
||||
platid_mask_t mask;
|
||||
struct gpbus_attach_args *gpa = aux;
|
||||
|
||||
if (strcmp(gpa->gpa_busname, "gpbus"))
|
||||
return 0;
|
||||
if (match->cf_loc[NEWGPBUSIFCF_PLATFORM] == 0)
|
||||
return 0;
|
||||
mask = PLATID_DEREF(match->cf_loc[NEWGPBUSIFCF_PLATFORM]);
|
||||
return platid_match(&platid, &mask);
|
||||
}
|
||||
|
||||
void
|
||||
button_vrgiu_attach(parent, self, aux)
|
||||
struct device *parent;
|
||||
struct device *self;
|
||||
void *aux;
|
||||
{
|
||||
struct gpbus_attach_args *gpa = aux;
|
||||
int *loc;
|
||||
struct button_vrgiu_softc *sc = (void*)self;
|
||||
int mode;
|
||||
|
||||
sc->sc_gc = gpa->gpa_gc;
|
||||
sc->sc_gf = gpa->gpa_gf;
|
||||
|
||||
loc = sc->sc_dev.dv_cfdata->cf_loc;
|
||||
sc->sc_port = loc[NEWGPBUSIFCF_PORT];
|
||||
sc->sc_id = loc[NEWGPBUSIFCF_ID];
|
||||
sc->sc_active = loc[NEWGPBUSIFCF_ACTIVE];
|
||||
printf(" port=%d id=%ld active=%s",
|
||||
sc->sc_port, sc->sc_id, sc->sc_active ? "high" : "low");
|
||||
|
||||
#if 0
|
||||
#if 1 /* Windows CE default */
|
||||
mode = VRGIU_INTR_EDGE_HOLD;
|
||||
#else /* XXX Don't challenge! Freestyle Only */
|
||||
mode = VRGIU_INTR_LEVEL_LOW_HOLD;
|
||||
#endif
|
||||
#endif
|
||||
mode = VRGIU_INTR_HOLD;
|
||||
if (loc[NEWGPBUSIFCF_LEVEL] != NEWGPBUSIFCF_LEVEL_DEFAULT) {
|
||||
mode |= VRGIU_INTR_LEVEL;
|
||||
if (loc[NEWGPBUSIFCF_LEVEL] == 0)
|
||||
mode |= VRGIU_INTR_LOW;
|
||||
else
|
||||
mode |= VRGIU_INTR_HIGH;
|
||||
} else
|
||||
mode |= VRGIU_INTR_EDGE;
|
||||
|
||||
if (sc->sc_port == NEWGPBUSIFCF_PORT_DEFAULT ||
|
||||
sc->sc_id == NEWGPBUSIFCF_ID_DEFAULT)
|
||||
printf(" (ignored)");
|
||||
else
|
||||
sc->sc_gf->gf_intr_establish(sc->sc_gc, sc->sc_port,
|
||||
mode, IPL_TTY,
|
||||
button_vrgiu_intr, sc);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
int
|
||||
button_vrgiu_intr(ctx)
|
||||
void *ctx;
|
||||
{
|
||||
struct button_vrgiu_softc *sc = ctx;
|
||||
u_int32_t reg;
|
||||
int on;
|
||||
|
||||
on = (sc->sc_gf->gf_portread(sc->sc_gc, sc->sc_port) == sc->sc_active);
|
||||
|
||||
/* Clear interrupt */
|
||||
reg = sc->sc_gf->gf_regread_4(sc->sc_gc, GIUINTSTAT_REG);
|
||||
sc->sc_gf->gf_regwrite_4(sc->sc_gc, GIUINTSTAT_REG,
|
||||
reg & ~(1 << sc->sc_port));
|
||||
|
||||
config_hook_call(CONFIG_HOOK_BUTTONEVENT, sc->sc_id, (void*)on);
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: com_vrip.c,v 1.1.1.1 1999/09/16 12:23:31 takemura Exp $ */
|
||||
/* $NetBSD: com_vrip.c,v 1.2 1999/12/23 06:26:10 takemura Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999 SASAKI Takesi. All rights reserved.
|
||||
@ -56,6 +56,7 @@
|
||||
/* For serial console */
|
||||
#include <machine/platid.h>
|
||||
#include <machine/platid_mask.h>
|
||||
#include <machine/config_hook.h>
|
||||
|
||||
#include <hpcmips/vr/vr.h>
|
||||
#include <hpcmips/vr/vripvar.h>
|
||||
@ -78,6 +79,7 @@ int com_vrip_debug = 0;
|
||||
|
||||
struct com_vrip_softc {
|
||||
struct com_softc sc_com;
|
||||
int sc_pwctl;
|
||||
};
|
||||
|
||||
static int com_vrip_probe __P((struct device *, struct cfdata *, void *));
|
||||
@ -100,19 +102,23 @@ find_comenableport_from_cfdata(int *port)
|
||||
{
|
||||
platid_mask_t mask;
|
||||
struct cfdata *cf;
|
||||
int id;
|
||||
|
||||
printf ("COM enable port: ");
|
||||
for (cf = cfdata; cf->cf_driver; cf++) {
|
||||
if (strcmp(cf->cf_driver->cd_name, "gpbus"))
|
||||
if (strcmp(cf->cf_driver->cd_name, "pwctl"))
|
||||
continue;
|
||||
mask = PLATID_DEREF(cf->cf_loc[GPBUSIFCF_PLATFORM]);
|
||||
if (platid_match(&platid, &mask))
|
||||
mask = PLATID_DEREF(cf->cf_loc[NEWGPBUSIFCF_PLATFORM]);
|
||||
id = cf->cf_loc[NEWGPBUSIFCF_ID];
|
||||
if (platid_match(&platid, &mask) &&
|
||||
id == CONFIG_HOOK_POWERCONTROL_COM0)
|
||||
goto found;
|
||||
}
|
||||
*port = -1;
|
||||
printf ("not found\n");
|
||||
return 1;
|
||||
found:
|
||||
*port = cf->cf_loc[GPBUSIFCF_COMCTRL];
|
||||
*port = cf->cf_loc[NEWGPBUSIFCF_PORT];
|
||||
printf ("#%d\n", *port);
|
||||
|
||||
return *port == GPBUSIFCF_COMCTRL_DEFAULT;
|
||||
@ -206,6 +212,8 @@ com_vrip_attach(parent, self, aux)
|
||||
bus_space_tag_t iot = va->va_iot;
|
||||
bus_space_handle_t ioh;
|
||||
|
||||
vsc->sc_pwctl = sc->sc_dev.dv_cfdata->cf_loc[VRIPCF_PWCTL];
|
||||
|
||||
DPRINTF(("==com_vrip_attach"));
|
||||
|
||||
if (bus_space_map(iot, va->va_addr, 1, 0, &ioh)) {
|
||||
@ -222,7 +230,12 @@ com_vrip_attach(parent, self, aux)
|
||||
sc->sc_frequency = VRCOM_FREQ;
|
||||
/* Power management */
|
||||
va->va_cf->cf_clock(va->va_cc, CMUMSKSSIU | CMUMSKSIU, 1);
|
||||
va->va_gf->gf_portwrite_8(va->va_gc, GIUPORT_COM, 1);
|
||||
/*
|
||||
va->va_gf->gf_portwrite(va->va_gc, GIUPORT_COM, 1);
|
||||
*/
|
||||
/* XXX, locale 'ID' must be need */
|
||||
config_hook_call(CONFIG_HOOK_POWERCONTROL, vsc->sc_pwctl, (void*)1);
|
||||
|
||||
|
||||
DPRINTF(("Try to attach com.\n"));
|
||||
com_attach_subr(sc);
|
||||
|
133
sys/arch/hpcmips/vr/pwctl_vrgiu.c
Normal file
133
sys/arch/hpcmips/vr/pwctl_vrgiu.c
Normal file
@ -0,0 +1,133 @@
|
||||
/* $NetBSD: pwctl_vrgiu.c,v 1.1 1999/12/23 06:26:10 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/device.h>
|
||||
|
||||
#include <machine/bus.h>
|
||||
|
||||
#include <machine/config_hook.h>
|
||||
#include <machine/platid.h>
|
||||
#include <machine/platid_mask.h>
|
||||
|
||||
#include <hpcmips/vr/vripreg.h>
|
||||
#include <hpcmips/vr/vripvar.h>
|
||||
#include <hpcmips/vr/vrgiureg.h>
|
||||
|
||||
#include "locators.h"
|
||||
|
||||
struct pwctl_vrgiu_softc {
|
||||
struct device sc_dev;
|
||||
vrgiu_chipset_tag_t sc_gc;
|
||||
vrgiu_function_tag_t sc_gf;
|
||||
int sc_port;
|
||||
long sc_id;
|
||||
config_hook_tag sc_hook_tag;
|
||||
};
|
||||
|
||||
static int pwctl_vrgiu_match __P((struct device *, struct cfdata *,
|
||||
void *));
|
||||
static void pwctl_vrgiu_attach __P((struct device *, struct device *,
|
||||
void *));
|
||||
static int pwctl_vrgiu_hook __P((void *ctx, int type, long id,
|
||||
void *msg));
|
||||
|
||||
struct cfattach pwctl_vrgiu_ca = {
|
||||
sizeof(struct pwctl_vrgiu_softc), pwctl_vrgiu_match, pwctl_vrgiu_attach
|
||||
};
|
||||
|
||||
int
|
||||
pwctl_vrgiu_match(parent, match, aux)
|
||||
struct device *parent;
|
||||
struct cfdata *match;
|
||||
void *aux;
|
||||
{
|
||||
platid_mask_t mask;
|
||||
struct gpbus_attach_args *gpa = aux;
|
||||
|
||||
if (strcmp(gpa->gpa_busname, "gpbus"))
|
||||
return 0;
|
||||
if (match->cf_loc[NEWGPBUSIFCF_PLATFORM] == 0)
|
||||
return 0;
|
||||
mask = PLATID_DEREF(match->cf_loc[NEWGPBUSIFCF_PLATFORM]);
|
||||
if (!platid_match(&platid, &mask))
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
pwctl_vrgiu_attach(parent, self, aux)
|
||||
struct device *parent;
|
||||
struct device *self;
|
||||
void *aux;
|
||||
{
|
||||
struct gpbus_attach_args *gpa = aux;
|
||||
int *loc;
|
||||
struct pwctl_vrgiu_softc *sc = (void*)self;
|
||||
|
||||
sc->sc_gc = gpa->gpa_gc;
|
||||
sc->sc_gf = gpa->gpa_gf;
|
||||
|
||||
loc = sc->sc_dev.dv_cfdata->cf_loc;
|
||||
sc->sc_port = loc[NEWGPBUSIFCF_PORT];
|
||||
sc->sc_id = loc[NEWGPBUSIFCF_ID];
|
||||
printf(" port=%d id=%ld", sc->sc_port, sc->sc_id);
|
||||
|
||||
if (sc->sc_port == NEWGPBUSIFCF_PORT_DEFAULT ||
|
||||
sc->sc_id == NEWGPBUSIFCF_ID_DEFAULT) {
|
||||
printf(" (ignored)");
|
||||
} else {
|
||||
sc->sc_hook_tag = config_hook(CONFIG_HOOK_POWERCONTROL,
|
||||
sc->sc_id, CONFIG_HOOK_SHARE,
|
||||
pwctl_vrgiu_hook, sc);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
int
|
||||
pwctl_vrgiu_hook(ctx, type, id, msg)
|
||||
void *ctx;
|
||||
int type;
|
||||
long id;
|
||||
void *msg;
|
||||
{
|
||||
struct pwctl_vrgiu_softc *sc = ctx;
|
||||
|
||||
printf("pwctl hook: port %d %s", sc->sc_port, msg ? "ON" : "OFF");
|
||||
sc->sc_gf->gf_portwrite(sc->sc_gc, sc->sc_port, msg ? 1 : 0);
|
||||
return (0);
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: vrgiu.c,v 1.3 1999/12/04 10:15:34 takemura Exp $ */
|
||||
/* $NetBSD: vrgiu.c,v 1.4 1999/12/23 06:26:10 takemura Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999
|
||||
@ -78,15 +78,13 @@ u_int16_t vrgiu_regread __P((vrgiu_chipset_tag_t, bus_addr_t));
|
||||
void vrgiu_regwrite_4 __P((vrgiu_chipset_tag_t, bus_addr_t, u_int32_t));
|
||||
void vrgiu_regwrite __P((vrgiu_chipset_tag_t, bus_addr_t, u_int16_t));
|
||||
|
||||
int vrgiu_port_register __P((vrgiu_chipset_tag_t, enum gpio_name, int));
|
||||
int vrgiu_port_read __P((vrgiu_chipset_tag_t, vrgiu_gpioreg_t*));
|
||||
int vrgiu_port_write __P((vrgiu_chipset_tag_t, enum gpio_name, int));
|
||||
int vrgiu_port_read __P((vrgiu_chipset_tag_t, int));
|
||||
int vrgiu_port_write __P((vrgiu_chipset_tag_t, int, int));
|
||||
|
||||
void *vrgiu_intr_establish __P((vrgiu_chipset_tag_t, int, int, int, int (*)(void *), void*));
|
||||
void vrgiu_intr_disestablish __P((vrgiu_chipset_tag_t, void*));
|
||||
|
||||
struct vrgiu_function_tag vrgiu_functions = {
|
||||
vrgiu_port_register,
|
||||
vrgiu_port_read,
|
||||
vrgiu_port_write,
|
||||
vrgiu_regread_4,
|
||||
@ -156,11 +154,11 @@ vrgiu_attach(parent, self, aux)
|
||||
#ifdef VRGIUDEBUG
|
||||
/* Display port status (Input/Output) for debugging */
|
||||
if (vrgiu_debug & DEBUG_IO) {
|
||||
vrgiu_gpioreg_t preg;
|
||||
u_int32_t preg[2];
|
||||
printf("I/O setting: ");
|
||||
vrgiu_dump_iosetting(sc);
|
||||
printf("\n");
|
||||
vrgiu_port_read(sc, &preg);
|
||||
|
||||
printf(" data:");
|
||||
bitdisp64(preg);
|
||||
}
|
||||
@ -168,12 +166,10 @@ vrgiu_attach(parent, self, aux)
|
||||
/*
|
||||
* General purpose bus
|
||||
*/
|
||||
for (i = 0; i< MAX_GPIO_INOUT; i++)
|
||||
sc->sc_gpio_map[i] = GIUPORT_NOTDEF;
|
||||
gpa.gpa_busname = "gpbus";
|
||||
gpa.gpa_gc = sc;
|
||||
gpa.gpa_gf = &vrgiu_functions;
|
||||
config_found(self, &gpa, vrgiu_print);
|
||||
while (config_found(self, &gpa, vrgiu_print)) ;
|
||||
/*
|
||||
* GIU-ISA bridge
|
||||
*/
|
||||
@ -286,54 +282,43 @@ vrgiu_regwrite(vc, off, data)
|
||||
struct vrgiu_softc *sc = (void*)vc;
|
||||
bus_space_write_2(sc->sc_iot, sc->sc_ioh, off, data);
|
||||
}
|
||||
/*
|
||||
* Assign Platform independent port name to GPIO # map.
|
||||
*/
|
||||
int
|
||||
vrgiu_port_register(ic, gpio, port)
|
||||
vrgiu_chipset_tag_t ic;
|
||||
enum gpio_name gpio;
|
||||
int port;
|
||||
{
|
||||
struct vrgiu_softc *sc = (void*)ic;
|
||||
if (sc->sc_gpio_map[gpio] != GIUPORT_NOTDEF)
|
||||
panic("vrgiu_port_register: already defined port.");
|
||||
sc->sc_gpio_map[gpio] = port;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* PORT
|
||||
*/
|
||||
int
|
||||
vrgiu_port_read(vc, reg)
|
||||
vrgiu_port_read(vc, port)
|
||||
vrgiu_chipset_tag_t vc;
|
||||
vrgiu_gpioreg_t *reg;
|
||||
int port;
|
||||
{
|
||||
(*reg)[0] = vrgiu_regread_4(vc, GIUPIOD_REG);
|
||||
(*reg)[1] = vrgiu_regread_4(vc, GIUPODAT_REG);
|
||||
return 0;
|
||||
struct vrgiu_softc *sc = (void*)vc;
|
||||
int on;
|
||||
|
||||
if (!LEGAL_OUT_PORT(port))
|
||||
panic("vrgiu_port_read: illegal gpio port");
|
||||
|
||||
if (port < 32)
|
||||
on = (vrgiu_regread_4(vc, GIUPIOD_REG) & (1 << port));
|
||||
else
|
||||
on = (vrgiu_regread_4(vc, GIUPODAT_REG) & (1 << (port - 32)));
|
||||
|
||||
return (on ? 1 : 0);
|
||||
}
|
||||
|
||||
int
|
||||
vrgiu_port_write(vc, gpio, onoff)
|
||||
vrgiu_port_write(vc, port, onoff)
|
||||
vrgiu_chipset_tag_t vc;
|
||||
enum gpio_name gpio;
|
||||
int port;
|
||||
int onoff;
|
||||
{
|
||||
struct vrgiu_softc *sc = (void*)vc;
|
||||
vrgiu_gpioreg_t reg;
|
||||
int port, bank;
|
||||
u_int32_t reg[2];
|
||||
int bank;
|
||||
|
||||
if (!LEGAL_OUT_PORT(gpio))
|
||||
panic("vrgiu_port_write: illegal gpio name");
|
||||
if ((port = sc->sc_gpio_map[gpio]) == GIUPORT_NOTDEF) {
|
||||
printf ("vrgiu_port_write: not defined port name%d\n", gpio);
|
||||
return 0;
|
||||
}
|
||||
if (!LEGAL_OUT_PORT(port))
|
||||
panic("vrgiu_port_write: illegal gpio port");
|
||||
|
||||
vrgiu_port_read(vc, ®);
|
||||
reg[0] = vrgiu_regread_4(vc, GIUPIOD_REG);
|
||||
reg[1] = vrgiu_regread_4(vc, GIUPODAT_REG);
|
||||
bank = port < 32 ? 0 : 1;
|
||||
if (bank == 1)
|
||||
port -= 32;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: vrgiuvar.h,v 1.1.1.1 1999/09/16 12:23:32 takemura Exp $ */
|
||||
/* $NetBSD: vrgiuvar.h,v 1.2 1999/12/23 06:26:10 takemura Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999
|
||||
@ -34,16 +34,10 @@
|
||||
*
|
||||
*/
|
||||
typedef void *vrgiu_chipset_tag_t;
|
||||
typedef u_int32_t vrgiu_gpioreg_t[2];
|
||||
|
||||
#define GIUPORT_NOTDEF -1
|
||||
enum gpio_name {
|
||||
GIUPORT_COM
|
||||
};
|
||||
struct vrgiu_function_tag {
|
||||
int (*gf_map) __P((vrgiu_chipset_tag_t, enum gpio_name, int));
|
||||
int (*gf_portread_8) __P((vrgiu_chipset_tag_t, vrgiu_gpioreg_t*));
|
||||
int (*gf_portwrite_8) __P((vrgiu_chipset_tag_t, enum gpio_name, int));
|
||||
int (*gf_portread) __P((vrgiu_chipset_tag_t, int));
|
||||
int (*gf_portwrite) __P((vrgiu_chipset_tag_t, int, int));
|
||||
u_int32_t (*gf_regread_4) __P((vrgiu_chipset_tag_t, bus_addr_t));
|
||||
void (*gf_regwrite_4) __P((vrgiu_chipset_tag_t, bus_addr_t, u_int32_t));
|
||||
void *(*gf_intr_establish) __P((vrgiu_chipset_tag_t, int, int, int, int (*)(void *), void*));
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: vrip.c,v 1.2 1999/12/04 14:23:36 takemura Exp $ */
|
||||
/* $NetBSD: vrip.c,v 1.3 1999/12/23 06:26:10 takemura Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999
|
||||
@ -48,6 +48,14 @@
|
||||
#include <hpcmips/vr/icureg.h>
|
||||
#include "locators.h"
|
||||
|
||||
#define VRIPDEBUG
|
||||
#ifdef VRIPDEBUG
|
||||
int vrip_debug = 0;
|
||||
#define DPRINTF(arg) if (vrip_debug) printf arg;
|
||||
#else
|
||||
#define DPRINTF(arg)
|
||||
#endif
|
||||
|
||||
int vripmatch __P((struct device*, struct cfdata*, void*));
|
||||
void vripattach __P((struct device*, struct device*, void*));
|
||||
int vrip_print __P((void*, const char*));
|
||||
@ -296,7 +304,10 @@ vrip_intr_setmask1(vc, arg, enable)
|
||||
sc->sc_intrmask = reg;
|
||||
bus_space_write_2 (iot, ioh, MSYSINT1_REG_W, reg & 0xffff);
|
||||
bus_space_write_2 (iot, ioh, MSYSINT2_REG_W, (reg >> 16) & 0xffff);
|
||||
/* bitdisp32(reg); */
|
||||
#ifdef VRIPDEBUG
|
||||
if (vrip_debug)
|
||||
bitdisp32(reg);
|
||||
#endif /* VRIPDEBUG */
|
||||
|
||||
return;
|
||||
}
|
||||
@ -349,10 +360,13 @@ vrip_intr_setmask2(vc, arg, mask, onoff)
|
||||
struct vrip_softc *sc = (void*)vc;
|
||||
struct intrhand *ih = arg;
|
||||
u_int16_t reg;
|
||||
#if 1
|
||||
printf("vrip_intr_setmask2:\n");
|
||||
vrip_dump_level2mask (vc, arg);
|
||||
#endif
|
||||
|
||||
#ifdef VRIPDEBUG
|
||||
if (vrip_debug) {
|
||||
printf("vrip_intr_setmask2:\n");
|
||||
vrip_dump_level2mask (vc, arg);
|
||||
}
|
||||
#endif /* VRIPDEBUG */
|
||||
#ifdef WINCE_DEFAULT_SETTING
|
||||
#warning WINCE_DEFAULT_SETTING
|
||||
#else
|
||||
@ -374,9 +388,11 @@ vrip_intr_setmask2(vc, arg, mask, onoff)
|
||||
}
|
||||
}
|
||||
#endif /* WINCE_DEFAULT_SETTING */
|
||||
#if 0
|
||||
vrip_dump_level2mask (vc, arg);
|
||||
#endif
|
||||
#ifdef VRIPDEBUG
|
||||
if (vrip_debug)
|
||||
vrip_dump_level2mask (vc, arg);
|
||||
#endif /* VRIPDEBUG */
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: vrpmu.c,v 1.3 1999/12/16 09:37:33 sato Exp $ */
|
||||
/* $NetBSD: vrpmu.c,v 1.4 1999/12/23 06:26:10 takemura Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1999 M. Warner Losh. All rights reserved.
|
||||
@ -31,6 +31,7 @@
|
||||
#include <sys/device.h>
|
||||
|
||||
#include <machine/bus.h>
|
||||
#include <machine/config_hook.h>
|
||||
|
||||
#include <hpcmips/vr/vripvar.h>
|
||||
#include <hpcmips/vr/vrpmuvar.h>
|
||||
@ -115,7 +116,6 @@ vrpmuattach(parent, self, aux)
|
||||
/* clear interrupt status */
|
||||
vrpmu_write(sc, PMUINT_REG_W, PMUINT_ALL);
|
||||
vrpmu_write(sc, PMUINT2_REG_W, PMUINT2_ALL);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@ -254,7 +254,9 @@ vrpmu_intr(arg)
|
||||
if (intstat1 & PMUINT_BATTINTR)
|
||||
;
|
||||
if (intstat1 & PMUINT_POWERSW)
|
||||
;
|
||||
config_hook_call(CONFIG_HOOK_BUTTONEVENT,
|
||||
CONFIG_HOOK_BUTTONEVENT_POWER,
|
||||
(void*)1);
|
||||
|
||||
if (intstat2 & PMUINT_GPIO12)
|
||||
;
|
||||
|
Loading…
Reference in New Issue
Block a user