UCB1200 GPIO routines.

This commit is contained in:
uch 2000-02-27 16:34:13 +00:00
parent fc0a27a970
commit c26429fac5
5 changed files with 283 additions and 14 deletions

View File

@ -2,7 +2,7 @@
# Distribution kernel (TX3912 based model) kernel config file
#
# $NetBSD: TX3912,v 1.10 2000/02/12 03:21:07 shin Exp $
# $NetBSD: TX3912,v 1.11 2000/02/27 16:34:14 uch Exp $
#
include "arch/hpcmips/conf/std.hpcmips"
@ -38,6 +38,11 @@ options KTRACE # system call tracing support
#options SYSCALL_DEBUG # for debug
#options MINIROOTSIZE=10000
#options MEMORY_DISK_HOOKS
#options MEMORY_DISK_IS_ROOT # force root on memory disk
#options MEMORY_DISK_SERVER=0 # no userspace memory disk support
#options MINIROOTSIZE=12288 # size of memory disk, in blocks
options PPP_BSDCOMP # BSD-Compress compression support for PPP
options PPP_DEFLATE # Deflate compression support for PPP
options PPP_FILTER # Active filter support for PPP (requires bpf)
@ -98,15 +103,17 @@ tc5165buf* at txcsbus5 iocs 4 iocsbase 0 iocssize 0x100 iocswidth 16
skbd* at tc5165buf?
# ITE IT8368E PCMCIA / TOSHIBA TC6345AF buffer chip (PCMCIA)
# card ... 3:2 (98)
# insert/remove ... 5:1/8 (161/168)
# card/insert ... 3:2 (98)
# remove ... 5:8 (168)
options IT8368E_LEGACY_MODE # Mobilon HC-4100 requires this
it8368e* at txcsbus? regcs 2 regcsbase 0 regcssize 0x20 regcswidth 16 iocs 8 iocsbase 0 iocssize 0x4000000 iocswidth 16 irq1 161 irq2 168 irq3 98
it8368e* at txcsbus? regcs 2 regcsbase 0 regcssize 0x20 regcswidth 16 iocs 8 iocsbase 0 iocssize 0x4000000 iocswidth 16 irq1 98 irq2 168 irq3 98
# PHILIPS UCB1200 / TOSHIBA TC35413F (modem/audio analog front-end)
ucb* at tx39sib? slot 0
ucbtp* at ucb?
ucbsnd* at ucb?
ucbio* at ucb?
ucbioport* at ucbio? platform COMPAQ_C_810 id BTN_LIGHT port 5
# WS console uses SUN or VT100 terminal emulation
fb* at tx3912video?

View File

@ -1,4 +1,4 @@
# $NetBSD: files.hpcmips,v 1.21 2000/02/06 08:47:03 takemura Exp $
# $NetBSD: files.hpcmips,v 1.22 2000/02/27 16:34:14 uch Exp $
# maxpartitions must be first item in files.${ARCH}.
maxpartitions 8
@ -232,6 +232,14 @@ device ucbsnd
attach ucbsnd at ucbif
file arch/hpcmips/dev/ucbsnd.c ucbsnd
device ucbio: newgpbusif
attach ucbio at ucbif
file arch/hpcmips/dev/ucbio.c ucbio
device ucbioport
attach ucbioport at newgpbusif
file arch/hpcmips/dev/ucbioport.c ucbioport
device tx39uart: txcomif
attach tx39uart at txsim
file arch/hpcmips/tx/tx39uart.c tx39uart needs-flag

View File

@ -1,4 +1,4 @@
/* $NetBSD: btnmgr.c,v 1.1 1999/12/23 06:26:09 takemura Exp $ */
/* $NetBSD: btnmgr.c,v 1.2 2000/02/27 16:34:13 uch Exp $ */
/*-
* Copyright (c) 1999
@ -33,6 +33,7 @@
* SUCH DAMAGE.
*
*/
#define BTNMGRDEBUG
#include <sys/param.h>
#include <sys/systm.h>
@ -44,6 +45,15 @@
#include <machine/config_hook.h>
#ifdef BTNMGRDEBUG
int btnmgr_debug = 0;
#define DPRINTF(arg) if (btnmgr_debug) printf arg;
#define DPRINTFN(n, arg) if (btnmgr_debug > (n)) printf arg;
#else
#define DPRINTF(arg)
#define DPRINTFN(n, arg)
#endif
cdev_decl(btnmgr);
struct btnmgr_softc {
@ -52,12 +62,11 @@ struct btnmgr_softc {
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));
void btnmgrattach __P((int));
char* btnmgr_name __P((long));
static int btnmgr_hook __P((void *, int, long, void *));
static struct {
static const struct {
long id;
char *name;
} button_names[] = {
@ -75,7 +84,8 @@ static struct {
{ CONFIG_HOOK_BUTTONEVENT_APP2, "Application 2" },
{ CONFIG_HOOK_BUTTONEVENT_APP3, "Application 3" },
};
static int n_button_names = sizeof(button_names)/sizeof(*button_names);
static const int n_button_names =
sizeof(button_names) / sizeof(*button_names);
void
btnmgrattach (n)
@ -99,7 +109,7 @@ btnmgrattach (n)
the_btnmgr_sc);
}
int
static int
btnmgr_hook(ctx, type, id, msg)
void *ctx;
int type;
@ -110,7 +120,7 @@ btnmgr_hook(ctx, type, id, msg)
struct btnmgr_softc *sc = ctx;
#endif /* not yet */
printf("%s button: %s\n", btnmgr_name(id), msg ? "ON" : "OFF");
DPRINTF(("%s button: %s\n", btnmgr_name(id), msg ? "ON" : "OFF"));
return (0);
}

View File

@ -0,0 +1,129 @@
/* $NetBSD: ucbio.c,v 1.1 2000/02/27 16:34:13 uch Exp $ */
/*
* Copyright (c) 2000, by UCHIYAMA Yasushi
* 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. The name of the developer may NOT be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
*
*/
/*
* Device driver for PHILIPS UCB1200 Advanced modem/audio analog front-end
* General Purpose I/O part.
*/
#include "opt_tx39_debug.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <machine/bus.h>
#include <machine/intr.h>
#include <machine/platid.h>
#include <machine/platid_mask.h>
#include <hpcmips/tx/tx39var.h>
#include <hpcmips/tx/tx39sibvar.h>
#include <hpcmips/tx/tx39sibreg.h>
#include <hpcmips/dev/ucb1200var.h>
#include <hpcmips/dev/ucb1200reg.h>
#include "locators.h"
extern char* btnmgr_name __P((long));
int ucbio_match __P((struct device*, struct cfdata*, void*));
void ucbio_attach __P((struct device*, struct device*, void*));
struct ucbio_softc {
struct device sc_dev;
};
struct cfattach ucbio_ca = {
sizeof(struct ucbio_softc), ucbio_match, ucbio_attach
};
int ucbio_print __P((void*, const char*));
int ucbio_submatch __P((struct device*, struct cfdata*, void*));
int
ucbio_match(parent, cf, aux)
struct device *parent;
struct cfdata *cf;
void *aux;
{
return (1);
}
void
ucbio_attach(parent, self, aux)
struct device *parent;
struct device *self;
void *aux;
{
struct ucb1200_attach_args *ucba = aux;
struct ucbio_attach_args uia;
int port;
printf("\n");
uia.uia_tc = ucba->ucba_tc;
for (port = 0; port < UCB1200_IOPORT_MAX; port++) {
uia.uia_port = port;
config_found_sm(self, &uia, ucbio_print, ucbio_submatch);
}
}
int
ucbio_submatch(parent, cf, aux)
struct device *parent;
struct cfdata *cf;
void *aux;
{
struct ucbio_attach_args *uia = aux;
platid_mask_t mask;
if (cf->cf_loc[NEWGPBUSIFCF_PORT] != uia->uia_port)
return (0);
mask = PLATID_DEREF(cf->cf_loc[NEWGPBUSIFCF_PLATFORM]);
if (!platid_match(&platid, &mask))
return (0);
uia->uia_id = cf->cf_loc[NEWGPBUSIFCF_ID];
return ((*cf->cf_attach->ca_match)(parent, cf, aux));
}
int
ucbio_print(aux, pnp)
void *aux;
const char *pnp;
{
struct ucbio_attach_args *uia = aux;
if (!pnp)
printf(" port %d \"%s\"", uia->uia_port,
btnmgr_name(uia->uia_id));
return (QUIET);
}

View File

@ -0,0 +1,115 @@
/* $NetBSD: ucbioport.c,v 1.1 2000/02/27 16:34:13 uch Exp $ */
/*
* Copyright (c) 2000, by UCHIYAMA Yasushi
* 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. The name of the developer may NOT be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
*
*/
/*
* Device driver for PHILIPS UCB1200 Advanced modem/audio analog front-end
* General Purpose I/O part. platform dependent port hook.
*/
#define UCBIOPORTDEBUG
#include "opt_tx39_debug.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <machine/config_hook.h>
#include <machine/bus.h>
#include <machine/intr.h>
#include <hpcmips/tx/tx39var.h>
#include <hpcmips/tx/tx39sibvar.h>
#include <hpcmips/tx/tx39sibreg.h>
#include <hpcmips/dev/ucb1200var.h>
#include <hpcmips/dev/ucb1200reg.h>
int ucbioport_match __P((struct device*, struct cfdata*, void*));
void ucbioport_attach __P((struct device*, struct device*, void*));
struct ucbioport_softc {
struct device sc_dev;
tx_chipset_tag_t sc_tc;
int sc_port;
};
struct cfattach ucbioport_ca = {
sizeof(struct ucbioport_softc), ucbioport_match, ucbioport_attach
};
int ucbioport_hook __P((void*, int, long, void*));
int
ucbioport_match(parent, cf, aux)
struct device *parent;
struct cfdata *cf;
void *aux;
{
return (1);
}
void
ucbioport_attach(parent, self, aux)
struct device *parent;
struct device *self;
void *aux;
{
struct ucbioport_softc *sc = (void*)self;
struct ucbio_attach_args *uia = aux;
printf("\n");
sc->sc_tc = uia->uia_tc;
sc->sc_port = uia->uia_port;
config_hook(CONFIG_HOOK_BUTTONEVENT, uia->uia_id,
CONFIG_HOOK_SHARE, /* btnmgr */
ucbioport_hook, sc);
}
int
ucbioport_hook(arg, type, id, msg)
void* arg;
int type;
long id;
void* msg;
{
struct ucbioport_softc *sc = arg;
txreg_t reg, mask, port;
reg = txsibsf0_reg_read(sc->sc_tc, UCB1200_IO_DATA_REG);
port = 1 << sc->sc_port;
mask = reg & port;
mask ^= port;
reg &= ~port;
reg |= mask;
txsibsf0_reg_write(sc->sc_tc, UCB1200_IO_DATA_REG, reg);
return (0);
}