new I/O modules framework for TX based system.

This commit is contained in:
uch 2000-10-22 10:42:31 +00:00
parent c3ceefe48c
commit fc9212e594
27 changed files with 1783 additions and 1488 deletions

View File

@ -2,7 +2,7 @@
# Distribution kernel (TOSHIBA TX3912 based model) kernel config file
#
# $NetBSD: TX3912,v 1.27 2000/10/04 13:53:54 uch Exp $
# $NetBSD: TX3912,v 1.28 2000/10/22 10:42:31 uch Exp $
#
include "arch/hpcmips/conf/std.hpcmips"
@ -23,7 +23,6 @@ options TX39_WATCHDOGTIMER
#options TX39ICUDEBUG
#options TX39CLKDEBUG
#options TX39BIUDEBUG
#options TX39IODEBUG
#options TX39POWERDEBUG
#options TX39UARTDEBUG
@ -37,6 +36,7 @@ options DEBUG # extra kernel debugging support
options KTRACE # system call tracing support
#options SYSCALL_DEBUG # for debug
#options MINIROOTSIZE=10000
options MSGBUFSIZE=65534 # for dmesg
#options MEMORY_DISK_HOOKS
#options MEMORY_DISK_IS_ROOT # force root on memory disk
@ -120,11 +120,39 @@ tx39ir* at txcom1
#
options USE_POLL # keyboard / touchpanel device requires this
# IO module manager (Don't delete)
txioman3 at tx39io? platform COMPAQ_C
txioman4 at tx39io? platform PHILIPS_NINO
txioman5 at tx39io? platform SHARP_MOBILON
txioman* at tx39io? # misc unknown.
# unified IO module manager
# group 0 MFIO
# 1 IO
# 2 BETTY IO
# (3 ITE IO notyet)
# edge 0 no interrupt.
# edge 1 positive edge
# edge 2 negative edge
# edge 3 both edge
# initial ... set initial state (on/off)
txioman3 at txsim? platform COMPAQ_C
txout* at txioman3 id PWCTL_LED evtype POWER group 0 port 3 initial 0
txin* at txioman3 id BTN_REC evtype BUTTON group 1 port 6 edge 1
txin* at txioman3 id BTN_APP0 evtype BUTTON group 1 port 5 edge 1
txin* at txioman3 id PME_AC evtype EVENT group 0 port 28 edge 1
txin* at txioman3 id COM0_DCD evtype EVENT group 0 port 30 edge 3
txin* at txioman3 id COM0_CTS evtype EVENT group 0 port 5 edge 3
txout* at txioman3 id COM0_DTR evtype OUT group 0 port 31
txout* at txioman3 id COM0_RTS evtype OUT group 0 port 6
txioman30 at txsim? platform COMPAQ_C_810
txout* at txioman30 id BTN_LIGHT evtype BUTTON group 2 port 5
txioman4 at txsim? platform PHILIPS_NINO
txioman5 at txsim? platform SHARP_MOBILON
txout* at txioman5 id PWCTL_LCDLIGHT evtype POWER group 0 port 14
txin* at txioman5 id BTN_REC evtype BUTTON group 1 port 0 edge 1
txin* at txioman5 id BTN_APP0 evtype BUTTON group 0 port 31 edge 1
txin* at txioman5 id BTN_COVER evtype BUTTON group 0 port 29 edge 1
#txin* at txioman5 id COM0_CTS evtype EVENT group 1 port 4 edge 3 # DANGER
#txin* at txioman5 id COM0_DCD evtype EVENT group 1 port 6 edge 3 # DANGER
txout* at txioman5 id COM0_RTS evtype OUT group 1 port 5
txout* at txioman5 id COM0_DTR evtype OUT group 0 port 15
# Chip select manager
txcsbus3 at tx39biu? platform COMPAQ_C
@ -148,7 +176,6 @@ 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
hpcfb* at tx3912video?

View File

@ -1,7 +1,7 @@
#
# Distribution kernel (TOSHIBA TX3922 based model) kernel config file
#
# $NetBSD: TX3922,v 1.27 2000/10/04 13:53:54 uch Exp $
# $NetBSD: TX3922,v 1.28 2000/10/22 10:42:31 uch Exp $
#
include "arch/hpcmips/conf/std.hpcmips"
@ -22,7 +22,6 @@ options TX39_DEBUG
#options WINCE_DEFAULT_SETTING # Debugging use
#options TX39ICUDEBUG
#options TX39BIUDEBUG
#options TX39IODEBUG
#options TX39POWERDEBUG
#options TX39UARTDEBUG
@ -30,6 +29,7 @@ options DDB # in-kernel debugger
#options DIAGNOSTIC # extra kernel debugging checks
options DEBUG # extra kernel debugging support
options KTRACE # system call tracing support
options MSGBUFSIZE=65534
options __NO_SOFT_SERIAL_INTERRUPT
options SERIALCONSSLOT=0 # UARTA 0, UARTB 1
@ -107,21 +107,52 @@ tx39uart* at txsim?
txcom0 at tx39uart? slot 0
txcom1 at tx39uart? slot 1
# IO module manager (Don't delete)
txioman* at tx39io? # misc unknown.
txcsbus1 at tx39biu? platform SHARP_TELIOS
txcsbus2 at tx39biu? platform VICTOR_INTERLINK
options USE_POLL # m38813,tc5165 requires this
# unified IO module manager
# group 0 MFIO
# 1 IO
# 2 BETTY IO (
# (3) ITE IO notyet
# (4) Plum2 IO (EXTPW[0:2]) notyet
txioman1 at txsim? platform SHARP_TELIOS_HCAJ1
txin* at txioman1 id BTN_APP0 group 1 port 7 edge 1 # IE button
txin* at txioman1 id BTN_APP1 group 1 port 8 edge 1 # Mail button
txin* at txioman1 id PME_AC group 1 port 6 edge 1 # AC-power
txin* at txioman1 id COM0_CTS group 0 port 27 edge 3
txin* at txioman1 id COM0_DCD group 0 port 29 edge 3
txout* at txioman1 id PWCTL_LED group 1 port 4 flags 3 #(blink)
txioman2 at txsim? platform SHARP_TELIOS_HCVJ1C_JP
txin* at txioman2 id BTN_APP0 evtype BUTTON group 1 port 7 edge 1 # IE button
txin* at txioman2 id BTN_APP1 evtype BUTTON group 1 port 8 edge 1 # Mail button
txin* at txioman2 id BTN_APP2 evtype BUTTON group 1 port 11 edge 1 # Video button
txin* at txioman2 id BTN_APP3 evtype BUTTON group 1 port 12 edge 1 # Head phone button
txin* at txioman2 id PME_AC evtype PMEVENT group 1 port 6
txin* at txioman2 id COM0_CTS evtype EVENT group 0 port 27 edge 3
txin* at txioman2 id COM0_DCD evtype EVENT group 1 port 13 edge 3
txout* at txioman2 id PWCTL_COM0 evtype POWER group 1 port 15
txout* at txioman2 id PWCTL_LED evtype POWER group 1 port 4 flags 3 #(blink)
txioman3 at txsim? platform VICTOR_INTERLINK_MPC101
txin* at txioman3 id BTN_COVER evtype BUTTON group 1 port 4
txin* at txioman3 id BTN_REC evtype BUTTON group 1 port 7
txin* at txioman3 id COM0_DCD evtype EVENT group 0 port 29
txin* at txioman3 id COM0_CTS evtype EVENT group 0 port 30
# kbd MFIO:7 ?
options USE_POLL
# PHILIPS UCB1200 / TOSHIBA TC35413F modem/audio analog front-end
ucb* at tx39sib? slot 0
#ucbtp* at ucb?
ucbtp* at ucb?
ucbsnd* at ucb?
ucbio* at ucb?
# PHILIPS 74ALVC*1624? / TOSHIBA TC5165BFTS buffer chip (keyboard)
# chip select: CS1, IRQ: 3:12/4:12
# chip select: CS1, IRQ: 3:12/4:12 (irq1 108)
# interrupt-mode don't work. use polling mode.
tc5165buf* at txcsbus1 iocs 1 iocsbase 0 iocssize 0x100 iocswidth 16
hpckbd* at tc5165buf?
#wsmouse* at ucbtp? mux 0

View File

@ -1,4 +1,4 @@
# $NetBSD: files.hpcmips,v 1.41 2000/10/17 11:37:23 sato Exp $
# $NetBSD: files.hpcmips,v 1.42 2000/10/22 10:42:31 uch Exp $
# maxpartitions must be first item in files.${ARCH}.
maxpartitions 8
@ -203,18 +203,17 @@ defopt TX39_WATCHDOGTIMER
defopt TX39ICUDEBUG
defopt TX39CLKDEBUG
defopt TX39BIUDEBUG
defopt TX39IODEBUG
defopt TX39POWERDEBUG
defopt TX39UARTDEBUG
defopt USE_POLL
device txsim { }
device txsim {[platform = -1]}
device txcsbusif {[platform = -1]}
device txcomif {[slot = -1]}
device txsibif {[slot = -1]}
device ucbif { }
device irif { }
device txiomanif {[platform = -1]}
device txiomanif {[evtype = -1], [id = -1], [group = -1], [port = -1], [edge = -1], [initial = -1]}
attach txsim at mainbus
file arch/hpcmips/tx/txsim.c txsim
@ -244,14 +243,22 @@ device tx3912video: hpcfbif
attach tx3912video at txsim
file arch/hpcmips/tx/tx3912video.c tx3912video
device tx39io: txiomanif
device tx39io
attach tx39io at txsim
file arch/hpcmips/tx/tx39io.c tx39io
device txioman
attach txioman at txiomanif
device txioman: txiomanif
attach txioman at txsim
file arch/hpcmips/tx/txioman.c txioman
device txin
attach txin at txiomanif
file arch/hpcmips/tx/txioman_in.c txin
device txout
attach txout at txiomanif
file arch/hpcmips/tx/txioman_out.c txout
device tx39sib: txsibif
attach tx39sib at txsim
file arch/hpcmips/tx/tx39sib.c tx39sib
@ -269,14 +276,10 @@ device ucbsnd
attach ucbsnd at ucbif
file arch/hpcmips/dev/ucbsnd.c ucbsnd needs-flag
device ucbio: newgpbusif
device ucbio
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
@ -292,7 +295,7 @@ file arch/hpcmips/tx/tx39ir.c tx39ir
# ITE IT8368E PCMCIA / TOSHIBA TC6345AF buffer chip (PCMCIA)
device it8368e: pcmciabus
attach it8368e at txcsbus
file arch/hpcmips/dev/it8368.c it8368e
file arch/hpcmips/dev/it8368.c it8368e
# MITUBISHI M38813 keryboard controller
device m38813c: hpckbdif

View File

@ -1,4 +1,4 @@
/* $NetBSD: hpckbd.c,v 1.3 2000/10/21 07:27:42 takemura Exp $ */
/* $NetBSD: hpckbd.c,v 1.4 2000/10/22 10:42:31 uch Exp $ */
/*-
* Copyright (c) 1999, 2000 UCHIYAMA Yasushi. All rights reserved.
@ -369,11 +369,12 @@ __hpckbd_input(arg, flag, scancode)
if (scancode == hc->hc_special[KEY_SPECIAL_OFF])
printf("off button\n");
else if (scancode == hc->hc_special[KEY_SPECIAL_LIGHT])
else if (scancode == hc->hc_special[KEY_SPECIAL_LIGHT]) {
static int onoff; /* XXX -uch */
config_hook_call(CONFIG_HOOK_BUTTONEVENT,
CONFIG_HOOK_BUTTONEVENT_LIGHT,
0);
else
(void *)(onoff ^= 1));
} else
printf("unknown special key %d\n", scancode);
return (0);

View File

@ -1,4 +1,4 @@
/* $NetBSD: ucb1200.c,v 1.4 2000/03/12 15:36:11 uch Exp $ */
/* $NetBSD: ucb1200.c,v 1.5 2000/10/22 10:42:31 uch Exp $ */
/*
* Copyright (c) 2000, by UCHIYAMA Yasushi
@ -47,7 +47,7 @@
#include <hpcmips/dev/ucb1200reg.h>
#ifdef UCB1200DEBUG
int ucb1200debug = 0;
int ucb1200debug = 1;
#define DPRINTF(arg) if (ucb1200debug) printf arg;
#define DPRINTFN(n, arg) if (ucb1200debug > (n)) printf arg;
#else
@ -56,7 +56,7 @@ int ucb1200debug = 0;
#endif
struct ucbchild_state {
int (*cs_busy) __P((void*));
int (*cs_busy)(void *);
void *cs_arg;
};
@ -72,14 +72,14 @@ struct ucb1200_softc {
struct ucbchild_state sc_child[UCB1200_MODULE_MAX];
};
int ucb1200_match __P((struct device*, struct cfdata*, void*));
void ucb1200_attach __P((struct device*, struct device*, void*));
int ucb1200_print __P((void*, const char*));
int ucb1200_search __P((struct device*, struct cfdata*, void*));
int ucb1200_check_id __P((u_int16_t, int));
int ucb1200_match(struct device *, struct cfdata *, void *);
void ucb1200_attach(struct device *, struct device *, void *);
int ucb1200_print(void *, const char *);
int ucb1200_search(struct device *, struct cfdata *, void *);
int ucb1200_check_id(u_int16_t, int);
#ifdef UCB1200DEBUG
void ucb1200_dump __P((struct ucb1200_softc*));
void ucb1200_dump(struct ucb1200_softc *);
#endif
struct cfattach ucb_ca = {
@ -98,10 +98,7 @@ const struct ucb_id {
};
int
ucb1200_match(parent, cf, aux)
struct device *parent;
struct cfdata *cf;
void *aux;
ucb1200_match(struct device *parent, struct cfdata *cf, void *aux)
{
struct txsib_attach_args *sa = aux;
u_int16_t reg;
@ -114,10 +111,7 @@ ucb1200_match(parent, cf, aux)
}
void
ucb1200_attach(parent, self, aux)
struct device *parent;
struct device *self;
void *aux;
ucb1200_attach(struct device *parent, struct device *self, void *aux)
{
struct txsib_attach_args *sa = aux;
struct ucb1200_softc *sc = (void*)self;
@ -144,10 +138,7 @@ ucb1200_attach(parent, self, aux)
}
int
ucb1200_search(parent, cf, aux)
struct device *parent;
struct cfdata *cf;
void *aux;
ucb1200_search(struct device *parent, struct cfdata *cf, void *aux)
{
struct ucb1200_softc *sc = (void*)parent;
struct ucb1200_attach_args ucba;
@ -165,17 +156,13 @@ ucb1200_search(parent, cf, aux)
}
int
ucb1200_print(aux, pnp)
void *aux;
const char *pnp;
ucb1200_print(void *aux, const char *pnp)
{
return pnp ? QUIET : UNCONF;
}
int
ucb1200_check_id(idreg, print)
u_int16_t idreg;
int print;
ucb1200_check_id(u_int16_t idreg, int print)
{
int i;
@ -193,11 +180,8 @@ ucb1200_check_id(idreg, print)
}
void
ucb1200_state_install(dev, sfun, sarg, sid)
struct device *dev;
int (*sfun) __P((void*));
void *sarg;
int sid;
ucb1200_state_install(struct device *dev, int (*sfun)(void *), void *sarg,
int sid)
{
struct ucb1200_softc *sc = (void*)dev;
@ -224,8 +208,7 @@ ucb1200_state_idle(dev)
#ifdef UCB1200DEBUG
void
ucb1200_dump(sc)
struct ucb1200_softc *sc;
ucb1200_dump(struct ucb1200_softc *sc)
{
const char *regname[] = {
"IO_DATA ",
@ -245,10 +228,12 @@ ucb1200_dump(sc)
"RESERVED ",
"NULL "
};
tx_chipset_tag_t tc = sc->sc_tc;
tx_chipset_tag_t tc;
u_int16_t reg;
int i;
tc = sc->sc_tc;
printf("\n\t[UCB1200 register]\n");
for (i = 0; i < 16; i++) {
reg = txsibsf0_reg_read(tc, i);

View File

@ -1,29 +1,39 @@
/* $NetBSD: ucb1200var.h,v 1.3 2000/02/27 16:37:51 uch Exp $ */
/* $NetBSD: ucb1200var.h,v 1.4 2000/10/22 10:42:32 uch Exp $ */
/*
* Copyright (c) 2000, by UCHIYAMA Yasushi
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by UCHIYAMA Yasushi.
*
* 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.
* 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 NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation 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 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.
*/
struct ucb1200_attach_args {
@ -39,11 +49,6 @@ struct ucb1200_attach_args {
#define UCB1200_TEL_MODULE 2
#define UCB1200_MODULE_MAX 3
void ucb1200_state_install __P((struct device*, int (*)__P((void*)), void*, int));
int ucb1200_state_idle __P((struct device*));
void ucb1200_state_install(struct device *, int (*)(void *), void *, int);
int ucb1200_state_idle(struct device *);
struct ucbio_attach_args {
tx_chipset_tag_t uia_tc;
int uia_port;
int uia_id;
};

View File

@ -1,29 +1,39 @@
/* $NetBSD: ucbio.c,v 1.1 2000/02/27 16:34:13 uch Exp $ */
/* $NetBSD: ucbio.c,v 1.2 2000/10/22 10:42:32 uch Exp $ */
/*
* Copyright (c) 2000, by UCHIYAMA Yasushi
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by UCHIYAMA Yasushi.
*
* 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.
* 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 NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation 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 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.
*/
/*
@ -38,8 +48,6 @@
#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>
@ -48,82 +56,149 @@
#include <hpcmips/dev/ucb1200var.h>
#include <hpcmips/dev/ucb1200reg.h>
#include "locators.h"
int ucbio_match(struct device*, struct cfdata *, void *);
void ucbio_attach(struct device*, struct device *, void *);
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 betty_port_status {
u_int16_t dir;
u_int16_t in, out;
};
struct ucbio_softc {
struct device sc_dev;
struct device sc_dev;
tx_chipset_tag_t sc_tc;
struct betty_port_status sc_stat, sc_ostat;
struct txio_ops sc_betty_ops;
};
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*));
/* I/O */
static int betty_in(void *, int);
static void betty_out(void *, int, int);
/* interrupt */
static void betty_intr_map(void *, int, int *, int *);
static void *betty_intr_establish(void *, int, int (*)(void *), void *);
static void betty_intr_disestablish(void *, void *);
/* debug */
static void betty_update(void *);
static void betty_dump(void *);
int
ucbio_match(parent, cf, aux)
struct device *parent;
struct cfdata *cf;
void *aux;
ucbio_match(struct device *parent, struct cfdata *cf, void *aux)
{
return (1);
return 1;
}
void
ucbio_attach(parent, self, aux)
struct device *parent;
struct device *self;
void *aux;
ucbio_attach(struct device *parent, struct device *self, void *aux)
{
struct ucb1200_attach_args *ucba = aux;
struct ucbio_attach_args uia;
int port;
struct ucbio_softc *sc = (void *)self;
struct txio_ops *ops = &sc->sc_betty_ops;
sc->sc_tc = ucba->ucba_tc;
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);
}
ops->_v = sc;
ops->_group = BETTY;
ops->_in = betty_in;
ops->_out = betty_out;
ops->_intr_map = betty_intr_map;
ops->_intr_establish = betty_intr_establish;
ops->_intr_disestablish = betty_intr_disestablish;
ops->_update = betty_update;
ops->_dump = betty_dump;
tx_conf_register_ioman(sc->sc_tc, ops);
tx_ioman_update(BETTY);
tx_ioman_dump(BETTY);
}
int
ucbio_submatch(parent, cf, aux)
struct device *parent;
struct cfdata *cf;
void *aux;
/* basic I/O */
static void
betty_out(void *arg, int port, int onoff)
{
struct ucbio_attach_args *uia = aux;
platid_mask_t mask;
if (cf->cf_loc[NEWGPBUSIFCF_PORT] != uia->uia_port)
return (0);
struct ucbio_softc *sc = arg;
tx_chipset_tag_t tc = sc->sc_tc;
txreg_t reg, pos;
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));
pos = 1 << port;
reg = txsibsf0_reg_read(tc, UCB1200_IO_DATA_REG);
if (onoff)
reg |= pos;
else
reg &= ~pos;
txsibsf0_reg_write(tc, UCB1200_IO_DATA_REG, reg);
}
int
ucbio_print(aux, pnp)
void *aux;
const char *pnp;
static int
betty_in(void *arg, int port)
{
struct ucbio_attach_args *uia = aux;
if (!pnp)
printf(" port %d \"%s\"", uia->uia_port,
btnmgr_name(uia->uia_id));
return (QUIET);
struct ucbio_softc *sc = arg;
tx_chipset_tag_t tc = sc->sc_tc;
txreg_t reg = txsibsf0_reg_read(tc, UCB1200_IO_DATA_REG);
return reg & (1 << port);
}
/* interrupt method not implemented */
static void
betty_intr_map(void *arg, int port, int *pedge, int *nedge)
{
}
static void *
betty_intr_establish(void *arg, int edge, int (*func)(void *), void *func_arg)
{
struct ucbio_softc *sc = arg;
printf("%s: %s not implemented.\n", sc->sc_dev.dv_xname,
__FUNCTION__);
return 0;
}
static void
betty_intr_disestablish(void *arg, void *ih)
{
struct ucbio_softc *sc = arg;
printf("%s: %s not implemented.\n", sc->sc_dev.dv_xname,
__FUNCTION__);
}
/* debug */
static void
betty_update(void *arg)
{
struct ucbio_softc *sc = arg;
tx_chipset_tag_t tc = sc->sc_tc;
struct betty_port_status *stat = &sc->sc_stat;
u_int16_t dir, data;
sc->sc_ostat = *stat; /* save old status */
dir = stat->dir = txsibsf0_reg_read(tc, UCB1200_IO_DIR_REG);
data = txsibsf0_reg_read(tc, UCB1200_IO_DATA_REG);
stat->out = data & dir;
stat->in = data & ~dir;
}
static void
betty_dump(void *arg)
{
struct ucbio_softc *sc = arg;
struct betty_port_status *stat = &sc->sc_stat;
printf("[BETTY I/O]\n");
printf("IN ");
bitdisp(stat->in);
printf("OUT ");
bitdisp(stat->out);
printf("DIR ");
bitdisp(stat->dir);
}

View File

@ -1,115 +0,0 @@
/* $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);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: config_hook.h,v 1.7 2000/10/03 03:08:33 sato Exp $ */
/* $NetBSD: config_hook.h,v 1.8 2000/10/22 10:42:32 uch Exp $ */
/*-
* Copyright (c) 1999
@ -93,12 +93,40 @@ int config_hook_call __P((int type, long id, void *msg));
#define CONFIG_HOOK_PMEVENT_BATTERY 3
#define CONFIG_HOOK_PMEVENT_AC 4
#define CONFIG_HOOK_NTYPES 3
/* misc event */
#define CONFIG_HOOK_EVENT 3
#define CONFIG_HOOK_EVENT_COM0_CTS 0
#define CONFIG_HOOK_EVENT_COM1_CTS 1
#define CONFIG_HOOK_EVENT_COM2_CTS 2
#define CONFIG_HOOK_EVENT_COM3_CTS 3
#define CONFIG_HOOK_EVENT_COM0_DCD 4
#define CONFIG_HOOK_EVENT_COM1_DCD 5
#define CONFIG_HOOK_EVENT_COM2_DCD 6
#define CONFIG_HOOK_EVENT_COM3_DCD 7
/* misc output port */
#define CONFIG_HOOK_OUT 4
#define CONFIG_HOOK_OUT_COM0_RTS 0
#define CONFIG_HOOK_OUT_COM1_RTS 1
#define CONFIG_HOOK_OUT_COM2_RTS 2
#define CONFIG_HOOK_OUT_COM3_RTS 3
#define CONFIG_HOOK_OUT_COM0_DTR 4
#define CONFIG_HOOK_OUT_COM1_DTR 5
#define CONFIG_HOOK_OUT_COM2_DTR 6
#define CONFIG_HOOK_OUT_COM3_DTR 7
#define CONFIG_HOOK_NTYPES 5
/*
* nicknames for including from configration file.
*/
#ifdef CONFIG_HOOK_DEFINE_NICKNAME
#define POWER CONFIG_HOOK_POWERCONTROL
#define BUTTON CONFIG_HOOK_BUTTONEVENT
#define PMEVENT CONFIG_HOOK_PMEVENT
#define EVENT CONFIG_HOOK_EVENT
#define OUT CONFIG_HOOK_OUT
#define PWCTL_COM0 CONFIG_HOOK_POWERCONTROL_COM0
#define PWCTL_COM1 CONFIG_HOOK_POWERCONTROL_COM1
#define PWCTL_COM2 CONFIG_HOOK_POWERCONTROL_COM2
@ -126,6 +154,29 @@ int config_hook_call __P((int type, long id, void *msg));
#define BTN_CONTRAST_DN CONFIG_HOOK_BUTTONEVENT_CONTRAST_DOWN
#define BTN_LIGHT_UP CONFIG_HOOK_BUTTONEVENT_LIGHT_UP
#define BTN_LIGHT_DN CONFIG_HOOK_BUTTONEVENT_LIGHT_DOWN
#define PME_STANBY CONFIG_HOOK_PMEVENT_STANDBYREQ
#define PME_SUSPEND CONFIG_HOOK_PMEVENT_SUSPENDREQ
#define PME_HARDPOWER CONFIG_HOOK_PMEVENT_HARDPOWER
#define PME_BATTERY CONFIG_HOOK_PMEVENT_BATTERY
#define PME_AC CONFIG_HOOK_PMEVENT_AC
#define COM0_CTS CONFIG_HOOK_EVENT_COM0_CTS
#define COM1_CTS CONFIG_HOOK_EVENT_COM1_CTS
#define COM2_CTS CONFIG_HOOK_EVENT_COM2_CTS
#define COM3_CTS CONFIG_HOOK_EVENT_COM3_CTS
#define COM0_DCD CONFIG_HOOK_EVENT_COM0_DCD
#define COM1_DCD CONFIG_HOOK_EVENT_COM1_DCD
#define COM2_DCD CONFIG_HOOK_EVENT_COM2_DCD
#define COM3_DCD CONFIG_HOOK_EVENT_COM3_DCD
#define COM0_RTS CONFIG_HOOK_OUT_COM0_RTS
#define COM1_RTS CONFIG_HOOK_OUT_COM1_RTS
#define COM2_RTS CONFIG_HOOK_OUT_COM2_RTS
#define COM3_RTS CONFIG_HOOK_OUT_COM3_RTS
#define COM0_DTR CONFIG_HOOK_OUT_COM0_DTR
#define COM1_DTR CONFIG_HOOK_OUT_COM1_DTR
#define COM2_DTR CONFIG_HOOK_OUT_COM2_DTR
#define COM3_DTR CONFIG_HOOK_OUT_COM3_DTR
#endif /* CONFIG_HOOK_DEFINE_NICKNAME */
/*

View File

@ -1,7 +1,11 @@
/* $NetBSD: tx39.c,v 1.19 2000/07/27 17:29:05 cgd Exp $ */
/* $NetBSD: tx39.c,v 1.20 2000/10/22 10:42:32 uch Exp $ */
/*-
* Copyright (c) 1999, 2000 UCHIYAMA Yasushi. All rights reserved.
* Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by UCHIYAMA Yasushi.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -11,19 +15,25 @@
* 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. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation 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 AUTHOR ``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 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.
* 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 "opt_tx39_debug.h"
@ -69,8 +79,8 @@
#include <hpcmips/dev/tc5165bufvar.h>
#endif
extern unsigned nullclkread __P((void));
extern unsigned (*clkread) __P((void));
extern unsigned nullclkread(void);
extern unsigned (*clkread)(void);
struct tx_chipset_tag tx_chipset;
@ -78,21 +88,20 @@ struct tx_chipset_tag tx_chipset;
u_int32_t tx39debugflag;
#endif
void tx_init __P((void));
int tx39icu_intr __P((u_int32_t, u_int32_t, u_int32_t, u_int32_t));
void tx39clock_cpuspeed __P((int*, int*));
void tx_init(void);
int tx39icu_intr(u_int32_t, u_int32_t, u_int32_t, u_int32_t);
void tx39clock_cpuspeed(int*, int*);
/* TX39-specific initialization vector */
void tx_os_init __P((void));
void tx_bus_reset __P((void));
void tx_cons_init __P((void));
void tx_device_register __P((struct device *, void *));
void tx_fb_init __P((caddr_t*));
void tx_mem_init __P((paddr_t));
void tx_find_dram __P((paddr_t, paddr_t));
void tx_reboot __P((int howto, char *bootstr));
int tx_intr __P((u_int32_t mask, u_int32_t pc, u_int32_t statusReg,
u_int32_t causeReg));
void tx_os_init(void);
void tx_bus_reset(void);
void tx_cons_init(void);
void tx_device_register(struct device *, void *);
void tx_fb_init(caddr_t*);
void tx_mem_init(paddr_t);
void tx_find_dram(paddr_t, paddr_t);
void tx_reboot(int, char *);
int tx_intr(u_int32_t, u_int32_t, u_int32_t, u_int32_t);
extern phys_ram_seg_t mem_clusters[];
extern int mem_cluster_cnt;
@ -129,6 +138,7 @@ tx_init()
sprintf(cpu_name, "TOSHIBA TMPR3912 %d.%02d MHz",
cpuclock / 1000000, (cpuclock % 1000000) / 10000);
tc->tc_chipset = __TX391X;
break;
case TMPR3922:
tx39clock_cpuspeed(&cpuclock, &cpuspeed);
@ -137,6 +147,7 @@ tx_init()
sprintf(cpu_name, "TOSHIBA TMPR3922 rev. %x.%x "
"%d.%02d MHz", (rev >> 4) & 0xf, rev & 0xf,
cpuclock / 1000000, (cpuclock % 1000000) / 10000);
tc->tc_chipset = __TX392X;
break;
}
}
@ -275,7 +286,7 @@ void
tx_cons_init()
{
int slot;
#define CONSPLATIDMATCH(p) \
#define CONSPLATIDMATCH(p) \
platid_match(&platid, &platid_mask_MACH_##p)
#ifdef SERIALCONSSLOT
@ -333,13 +344,7 @@ tx_conf_register_intr(t, intrt)
tx_chipset_tag_t t;
void *intrt;
{
if (tx_chipset.tc_intrt) {
panic("duplicate intrt");
}
if (t != &tx_chipset) {
panic("bogus tx_chipset_tag");
}
KASSERT(t == &tx_chipset);
tx_chipset.tc_intrt = intrt;
}
@ -349,13 +354,7 @@ tx_conf_register_power(t, powert)
tx_chipset_tag_t t;
void *powert;
{
if (tx_chipset.tc_powert) {
panic("duplicate powert");
}
if (t != &tx_chipset) {
panic("bogus tx_chipset_tag");
}
KASSERT(t == &tx_chipset);
tx_chipset.tc_powert = powert;
}
@ -365,13 +364,7 @@ tx_conf_register_clock(t, clockt)
tx_chipset_tag_t t;
void *clockt;
{
if (tx_chipset.tc_clockt) {
panic("duplicate clockt");
}
if (t != &tx_chipset) {
panic("bogus tx_chipset_tag");
}
KASSERT(t == &tx_chipset);
tx_chipset.tc_clockt = clockt;
}
@ -381,27 +374,18 @@ tx_conf_register_sound(t, soundt)
tx_chipset_tag_t t;
void *soundt;
{
if (t != &tx_chipset) {
panic("bogus tx_chipset_tag");
}
KASSERT(t == &tx_chipset);
tx_chipset.tc_soundt = soundt;
}
void
tx_conf_register_ioman(t, iomant)
tx_chipset_tag_t t;
void *iomant;
tx_conf_register_ioman(tx_chipset_tag_t t, struct txio_ops *ops)
{
if (tx_chipset.tc_iomant) {
panic("duplicate iomant");
}
KASSERT(t == &tx_chipset);
KASSERT(ops);
if (t != &tx_chipset) {
panic("bogus tx_chipset_tag");
}
tx_chipset.tc_iomant = iomant;
tx_chipset.tc_ioops[ops->_group] = ops;
}
void
@ -409,38 +393,11 @@ tx_conf_register_video(t, videot)
tx_chipset_tag_t t;
void *videot;
{
if (t != &tx_chipset) {
panic("bogus tx_chipset_tag");
}
KASSERT(t == &tx_chipset);
tx_chipset.tc_videot = videot;
}
#ifdef TX39_PREFER_FUNCTION
tx_chipset_tag_t
tx_conf_get_tag()
{
return (tx_chipset_tag_t)&tx_chipset;
}
txreg_t
tx_conf_read(t, reg)
tx_chipset_tag_t t;
int reg;
{
return *((volatile txreg_t*)(TX39_SYSADDR_CONFIG_REG_KSEG1 + reg));
}
void
tx_conf_write(t, reg, val)
tx_chipset_tag_t t;
int reg;
txreg_t val;
{
*((volatile txreg_t*)(TX39_SYSADDR_CONFIG_REG_KSEG1 + reg)) = val;
}
#endif /* TX39_PREFER_FUNCTION */
int
__is_set_print(reg, mask, name)
u_int32_t reg;

View File

@ -1,4 +1,4 @@
/* $NetBSD: tx39biu.c,v 1.3 1999/12/26 17:06:02 uch Exp $ */
/* $NetBSD: tx39biu.c,v 1.4 2000/10/22 10:42:32 uch Exp $ */
/*
* Copyright (c) 1999, by UCHIYAMA Yasushi
@ -69,7 +69,7 @@ tx39biu_match(parent, cf, aux)
struct cfdata *cf;
void *aux;
{
return 1;
return ATTACH_NORMAL;
}
void

View File

@ -1,4 +1,4 @@
/* $NetBSD: tx39clock.c,v 1.7 2000/10/01 18:12:04 uch Exp $ */
/* $NetBSD: tx39clock.c,v 1.8 2000/10/22 10:42:32 uch Exp $ */
/*-
* Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@ -106,7 +106,7 @@ struct cfattach tx39clock_ca = {
int
tx39clock_match(struct device *parent, struct cfdata *cf, void *aux)
{
return 2; /* 1st attach group of txsim */
return ATTACH_FIRST;
}
void

View File

@ -1,4 +1,4 @@
/* $NetBSD: tx39icu.c,v 1.9 2000/10/04 13:53:55 uch Exp $ */
/* $NetBSD: tx39icu.c,v 1.10 2000/10/22 10:42:32 uch Exp $ */
/*-
* Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@ -190,7 +190,7 @@ tx39icu_match(parent, cf, aux)
struct cfdata *cf;
void *aux;
{
return 2; /* 1st attach group of txsim */
return ATTACH_FIRST;
}
void

View File

@ -1,4 +1,4 @@
/* $NetBSD: tx39io.c,v 1.6 2000/10/04 13:53:56 uch Exp $ */
/* $NetBSD: tx39io.c,v 1.7 2000/10/22 10:42:32 uch Exp $ */
/*-
* Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@ -35,9 +35,8 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#undef TX39IODEBUG
#include "opt_tx39_debug.h"
#include "opt_tx39iodebug.h"
#include <sys/param.h>
#include <sys/systm.h>
@ -46,374 +45,394 @@
#include <machine/bus.h>
#include <hpcmips/tx/tx39var.h>
#include <hpcmips/tx/tx39icureg.h>
#define __TX39IO_PRIVATE
#include <hpcmips/tx/tx39iovar.h>
#include <hpcmips/tx/tx39ioreg.h>
#include <hpcmips/tx/tx39icureg.h>
#include <hpcmips/tx/txiomanvar.h>
#ifdef TX39IODEBUG
#define DPRINTF(arg) printf arg
#else
#define DPRINTF(arg)
#endif
#undef TX39IODEBUG
#define TX39IO_ATTACH_DUMMYHANDLER 0
#undef TX39IO_MFIOOUTPORT_ON
#undef TX39IO_MFIOOUTPORT_OFF
#define ISSET(x, s) ((x) & (1 << (s)))
int tx39io_match(struct device *, struct cfdata *, void *);
void tx39io_attach(struct device *, struct device *, void *);
int tx39io_print(void *, const char *);
struct tx39io_softc {
struct device sc_dev;
tx_chipset_tag_t sc_tc;
};
struct cfattach tx39io_ca = {
sizeof(struct tx39io_softc), tx39io_match, tx39io_attach
};
#ifdef TX39IODEBUG
int tx39io_intr(void *);
int tx39mfio_intr(void *);
void tx39io_dump(struct tx39io_softc *);
void tx39io_dump_and_attach_handler(struct tx39io_softc *, int);
void __dump_and_attach_handler(tx_chipset_tag_t, u_int32_t,
u_int32_t, u_int32_t, u_int32_t,
int, int, int (*)(void *), void *, int);
#endif /* TX39IODEBUG */
#define ISSET(x, s) ((x) & (1 << (s)))
#define STD_IN 1
#define STD_OUT 2
#define STD_INOUT 3
const struct {
char *std_pin_name;
int std_type;
} mfio_map[TX39_IO_MFIO_MAX] = {
[31] = {"CHIFS", STD_INOUT},
[30] = {"CHICLK", STD_INOUT},
[29] = {"CHIDOUT", STD_OUT},
[28] = {"CHIDIN", STD_IN},
[27] = {"DREQ", STD_IN},
[26] = {"DGRINT", STD_OUT},
[25] = {"BC32K", STD_OUT},
[24] = {"TXD", STD_OUT},
[23] = {"RXD", STD_IN},
[22] = {"CS1", STD_OUT},
[21] = {"CS2", STD_OUT},
[20] = {"CS3", STD_OUT},
[19] = {"MCS0", STD_OUT},
[18] = {"MCS1", STD_OUT},
/* IO/MFIO common */
static void *port_intr_establish(void *, int, int (*)(void *), void *);
static void port_intr_disestablish(void *, void *);
/* MFIO */
static int mfio_in(void *, int);
static void mfio_out(void *, int, int);
static void mfio_intr_map(void *, int, int *, int *);
static void mfio_dump(void *);
static void mfio_update(void *);
/* IO */
#ifdef TX391X
[17] = {"MCS2", STD_OUT},
[16] = {"MCS3", STD_OUT},
#endif /* TX391X */
static int tx391x_io_in(void *, int);
static void tx391x_io_out(void *, int, int);
static void tx391x_io_update(void *);
static void tx391x_io_intr_map(void *, int, int *, int *);
#endif
#ifdef TX392X
[17] = {"RXPWR", STD_OUT},
[16] = {"IROUT", STD_OUT},
#endif /* TX392X */
[15] = {"SPICLK", STD_OUT},
[14] = {"SPIOUT", STD_OUT},
[13] = {"SPIN", STD_IN},
[12] = {"SIBMCLK", STD_INOUT},
[11] = {"CARDREG", STD_OUT},
[10] = {"CARDIOWR", STD_OUT},
[9] = {"CARDIORD", STD_OUT},
[8] = {"CARD1CSL", STD_OUT},
[7] = {"CARD1CSH", STD_OUT},
[6] = {"CARD2CSL", STD_OUT},
[5] = {"CARD2CSH", STD_OUT},
[4] = {"CARD1WAIT", STD_IN},
[3] = {"CARD2WAIT", STD_IN},
[2] = {"CARDDIR", STD_OUT},
#ifdef TX391X
[1] = {"MFIO[1]", 0},
[0] = {"MFIO[0]", 0}
#endif /* TX391X */
#ifdef TX392X
[1] = {"MCS1WAIT", 0},
[0] = {"MCS0WAIT", 0}
#endif /* TX392X */
};
static int tx392x_io_in(void *, int);
static void tx392x_io_out(void *, int, int);
static void tx392x_io_update(void *);
static void tx392x_io_intr_map(void *, int, int *, int *);
#endif
static void io_dump(void *);
static void __print_port_status(struct tx39io_port_status *, int);
int
tx39io_match(struct device *parent, struct cfdata *cf, void *aux)
{
return 2; /* 1st attach group of txsim */
return ATTACH_FIRST; /* 1st attach group of txsim */
}
void
tx39io_attach(struct device *parent, struct device *self, void *aux)
{
struct txsim_attach_args *ta = aux;
struct tx39io_softc *sc = (void*)self;
struct txioman_attach_args tia;
struct tx39io_softc *sc = (void *)self;
tx_chipset_tag_t tc;
struct txio_ops *ops_io = &sc->sc_io_ops;
struct txio_ops *ops_mfio = &sc->sc_mfio_ops;
sc->sc_tc = ta->ta_tc;
tc = sc->sc_tc = ta->ta_tc;
printf("\n");
#ifdef TX39IODEBUG
tx39io_dump(sc);
#endif /* TX39IODEBUG */
/*
* attach platform dependent io manager
*/
tia.tia_tc = sc->sc_tc;
config_found(self, &tia, tx39io_print);
}
sc->sc_stat_io_mask = ~(1 << 5); /* exclude Plum2 INT */
sc->sc_stat_mfio_mask = ~(0x3|(0x3 << 23));
int
tx39io_print(void *aux, const char *pnp)
{
return pnp ? QUIET : UNCONF;
}
void
tx39io_portout(tx_chipset_tag_t tc, int port, int onoff)
{
txreg_t reg;
/* XXX check port is output or not */
if (port >= TXIO) { /* XXX TX3922 case */
#ifdef TX391X
txreg_t iostat;
/* IO */
reg = tx_conf_read(tc, TX39_IOCTRL_REG);
iostat = TX39_IOCTRL_IODOUT(reg);
if (onoff)
iostat |= (1 << (port - TXIO));
else
iostat &= ~(1 << (port - TXIO));
TX39_IOCTRL_IODOUT_CLR(reg);
reg = TX39_IOCTRL_IODOUT_SET(reg, iostat);
tx_conf_write(tc, TX39_IOCTRL_REG, reg);
#endif /* TX391X */
} else {
/* MFIO */
reg = tx_conf_read(tc, TX39_IOMFIODATAOUT_REG);
if (onoff)
reg |= (1 << port);
else
reg &= ~(1 << port);
tx_conf_write(tc, TX39_IOMFIODATAOUT_REG, reg);
}
}
#ifdef TX39IODEBUG
int
tx39io_intr(void *arg)
{
printf("io (%d:%d)\n", (tx39intrvec >> 16) & 0xffff,
tx39intrvec & 0xfff);
return 0;
}
int
tx39mfio_intr(void *arg)
{
printf("mfio (%d:%d)\n", (tx39intrvec >> 16) & 0xffff,
tx39intrvec & 0xfff);
return 0;
}
void
tx39io_dump(struct tx39io_softc *sc)
{
#ifdef COMPAQ_LOCAL_INTR /* for debug */
/* 2010c Rec button */
tx_intr_establish(tc, MAKEINTR(5, (1<<6)), IST_EDGE, IPL_CLOCK, tx39io_intr, sc);
/* Play button */
tx_intr_establish(tc, MAKEINTR(5, (1<<5)), IST_EDGE, IPL_CLOCK, tx39io_intr, sc);
/* Power connector */
tx_intr_establish(tc, MAKEINTR(3, (1<<28)), IST_EDGE, IPL_CLOCK, tx39mfio_intr, sc);
tx_intr_establish(tc, MAKEINTR(4, (1<<28)), IST_EDGE, IPL_CLOCK, tx39mfio_intr, sc);
/* UARTA carrier */
tx_intr_establish(tc, MAKEINTR(3, (1<<30)), IST_EDGE, IPL_CLOCK, tx39mfio_intr, sc);
tx_intr_establish(tc, MAKEINTR(4, (1<<30)), IST_EDGE, IPL_CLOCK, tx39mfio_intr, sc);
/* --> then turn off MFIO 31 */
tx_intr_establish(tc, MAKEINTR(3, (1<<5)), IST_EDGE, IPL_CLOCK, tx39mfio_intr, sc);
tx_intr_establish(tc, MAKEINTR(4, (1<<5)), IST_EDGE, IPL_CLOCK, tx39mfio_intr, sc);
/* --> then turn off MFIO 6 */
/* green LED: MFIO 3 off */
/* orange LED: not connected to TX39IO ??? */
/* Backlight: UCB1200 GPIO port ??? */
#endif
#ifdef MOBILON_LOCAL_INTR /* for debug */
/* Rec button */
tx_intr_establish(tc, MAKEINTR(5, (1<<0)), IST_EDGE, IPL_CLOCK, tx39io_intr, sc);
/* Play button */
tx_intr_establish(tc, MAKEINTR(3, (1<<31)), IST_EDGE, IPL_CLOCK, tx39mfio_intr, sc);
/* Battery cover open */
tx_intr_establish(tc, MAKEINTR(3, (1<<29)), IST_EDGE, IPL_CLOCK, tx39mfio_intr, sc);
/* Serial DCD */
tx_intr_establish(tc, MAKEINTR(5, (1<<4)), IST_EDGE, IPL_CLOCK, tx39io_intr, sc);
/* --> then turn off IO 3 ??? */
tx_intr_establish(tc, MAKEINTR(5, (1<<6)), IST_EDGE, IPL_CLOCK, tx39io_intr, sc);
/* --> then turn off IO 5 ??? */
/* keyboard */
tx_intr_establish(tc, MAKEINTR(5, (1<<13)), IST_EDGE, IPL_CLOCK, tx39io_intr, sc);
/* Back light: MFIO 14 on */
#endif
#ifdef VICTOR_INTERLINK_INTR /* for debug */
/* open panel */
tx_intr_establish(tc, MAKEINTR(8, (1<<20)), IST_EDGE, IPL_CLOCK, tx39io_intr, sc);
/* close panel */
tx_intr_establish(tc, MAKEINTR(8, (1<<4)), IST_EDGE, IPL_CLOCK, tx39io_intr, sc);
/* serial session */
tx_intr_establish(tc, MAKEINTR(4, (1<<29)), IST_EDGE, IPL_CLOCK, tx39mfio_intr, sc);
tx_intr_establish(tc, MAKEINTR(4, (1<<30)), IST_EDGE, IPL_CLOCK, tx39mfio_intr, sc);
/* REC button */
tx_intr_establish(tc, MAKEINTR(8, (1<<7)), IST_EDGE, IPL_CLOCK, tx39io_intr, sc);
/* kbd */
tx_intr_establish(tc, MAKEINTR(3, (1<<7)), IST_EDGE, IPL_CLOCK, tx39mfio_intr, sc);
#endif
tx39io_dump_and_attach_handler(sc, TX39IO_ATTACH_DUMMYHANDLER);
}
void
tx39io_dump_and_attach_handler(struct tx39io_softc *sc, int dummy)
{
tx_chipset_tag_t tc;
u_int32_t reg, reg_out, reg_dir, reg_in, reg_sel, reg_pwr, reg_deb;
int i;
int (*iointr)(void*);
int (*mfiointr)(void*);
tc = sc->sc_tc;
if (dummy) {
iointr = tx39io_intr;
mfiointr = tx39mfio_intr;
} else {
iointr = mfiointr = 0;
}
printf("--------------------------------------------------------------\n");
printf(" Debounce Direction DataOut DataIn PowerDown Select\n");
printf("--------------------------------------------------------------\n");
/* IO */
reg = tx_conf_read(tc, TX39_IOCTRL_REG);
reg_deb = TX39_IOCTRL_IODEBSEL(reg);
reg_dir = TX39_IOCTRL_IODIREC(reg);
ops_io->_v = sc;
ops_io->_group = IO;
ops_io->_intr_establish = port_intr_establish;
ops_io->_intr_disestablish = port_intr_disestablish;
ops_io->_dump = io_dump;
if (IS_TX391X(tc)) {
#ifdef TX391X
reg_out = TX39_IOCTRL_IODOUT(reg);
reg_in = TX39_IOCTRL_IODIN(reg);
#endif /* TX391X */
ops_io->_in = tx391x_io_in;
ops_io->_out = tx391x_io_out;
ops_io->_intr_map = tx391x_io_intr_map;
ops_io->_update = tx391x_io_update;
#endif
} else if (IS_TX392X(tc)) {
#ifdef TX392X
reg = tx_conf_read(tc, TX39_IODATAINOUT_REG);
reg_out = TX39_IODATAINOUT_DOUT(reg);
reg_in = TX39_IODATAINOUT_DIN(reg);
#endif /* TX392X */
reg = tx_conf_read(tc, TX39_IOIOPOWERDWN_REG);
reg_pwr = TX39_IOIOPOWERDWN_IOPD(reg);
for (i = TX39_IO_IO_MAX - 1; i >= 0 ; i--) {
printf("IO %2d: ", i);
printf("%s", ISSET(reg_dir, i) ? "On " : "Off");
printf(" ");
__dump_and_attach_handler(tc, reg_dir, reg_out, reg_in,
reg_pwr, i, 1, iointr, sc, 1);
printf(" -");
printf("\n");
ops_io->_in = tx392x_io_in;
ops_io->_out = tx392x_io_out;
ops_io->_intr_map = tx392x_io_intr_map;
ops_io->_update = tx392x_io_update;
#endif
}
tx_conf_register_ioman(tc, ops_io);
/* MFIO */
printf("--------------------------------------------------------------\n");
reg_out = tx_conf_read(tc, TX39_IOMFIODATAOUT_REG);
reg_dir = tx_conf_read(tc, TX39_IOMFIODATADIR_REG);
reg_in = tx_conf_read(tc, TX39_IOMFIODATAIN_REG);
reg_sel = tx_conf_read(tc, TX39_IOMFIODATASEL_REG);
reg_pwr = tx_conf_read(tc, TX39_IOMFIOPOWERDWN_REG);
for (i = TX39_IO_MFIO_MAX - 1; i >= 0 ; i--) {
printf("MFIO %2d: - ", i);
__dump_and_attach_handler(tc, reg_dir, reg_out, reg_in,
reg_pwr, i, 0, mfiointr, sc,
ISSET(reg_sel, i));
printf(" ");
printf(ISSET(reg_sel, i) ? "MFIO(%s)" : "%s",
mfio_map[i].std_pin_name);
printf("\n");
}
printf("--------------------------------------------------------------\n");
ops_mfio->_v = sc;
ops_mfio->_group = MFIO;
ops_mfio->_in = mfio_in;
ops_mfio->_out = mfio_out;
ops_mfio->_intr_map = mfio_intr_map;
ops_mfio->_intr_establish = port_intr_establish;
ops_mfio->_intr_disestablish = port_intr_disestablish;
ops_mfio->_update = mfio_update;
ops_mfio->_dump = mfio_dump;
tx_conf_register_ioman(tc, ops_mfio);
tx_ioman_update(IO);
tx_ioman_update(MFIO);
#ifdef TX39IODEBUG
tx_ioman_dump(IO);
tx_ioman_dump(MFIO);
#else
printf("IO i0x%08x o0x%08x MFIO i0x%08x o0x%08x\n",
sc->sc_stat_io.in, sc->sc_stat_io.out,
sc->sc_stat_mfio.in, sc->sc_stat_mfio.out);
#endif
}
void
__dump_and_attach_handler(tx_chipset_tag_t tc, u_int32_t reg_dir,
u_int32_t reg_out, u_int32_t reg_in,
u_int32_t reg_pwr, int i, int io,
int (*func)(void*), void *arg, int mf)
/*
* TX391X, TX392X common
*/
static void *
port_intr_establish(void *arg, int edge, int (*func)(void *), void *func_arg)
{
int pset, nset, pofs, nofs;
struct tx39io_softc *sc = arg;
return tx_intr_establish(sc->sc_tc, edge, IST_EDGE, IPL_CLOCK, func,
func_arg);
}
static void
port_intr_disestablish(void *arg, void *ih)
{
struct tx39io_softc *sc = arg;
tx_intr_disestablish(sc->sc_tc, ih);
}
static void
mfio_out(void *arg, int port, int onoff)
{
struct tx39io_softc *sc = arg;
tx_chipset_tag_t tc;
txreg_t reg, pos;
DPRINTF(("%s: port #%d\n", __FUNCTION__, port));
tc = sc->sc_tc;
/* MFIO */
pos = 1 << port;
#ifdef DIAGNOSTIC
if (!(sc->sc_stat_mfio.dir & pos)) {
panic("%s: MFIO%d is not output port.\n",
sc->sc_dev.dv_xname, port);
}
#endif
reg = tx_conf_read(tc, TX39_IOMFIODATAOUT_REG);
if (onoff)
reg |= pos;
else
reg &= ~pos;
tx_conf_write(tc, TX39_IOMFIODATAOUT_REG, reg);
}
static int
mfio_in(void *arg, int port)
{
struct tx39io_softc *sc __attribute__((__unused__)) = arg ;
DPRINTF(("%s: port #%d\n", __FUNCTION__, port));
return tx_conf_read(sc->sc_tc, TX39_IOMFIODATAIN_REG) & (1 << port);
}
static void
mfio_intr_map(void *arg, int port, int *pedge, int *nedge)
{
if (pedge)
*pedge = MAKEINTR(3, (1 << port));
if (nedge)
*nedge = MAKEINTR(4, (1 << port));
}
static void
mfio_update(void *arg)
{
struct tx39io_softc *sc = arg;
tx_chipset_tag_t tc = sc->sc_tc;
struct tx39io_port_status *stat_mfio = &sc->sc_stat_mfio;
sc->sc_ostat_mfio = *stat_mfio; /* save old status */
stat_mfio->dir = tx_conf_read(tc, TX39_IOMFIODATADIR_REG);
stat_mfio->in = tx_conf_read(tc, TX39_IOMFIODATAIN_REG);
stat_mfio->out = tx_conf_read(tc, TX39_IOMFIODATAOUT_REG);
stat_mfio->power = tx_conf_read(tc, TX39_IOMFIOPOWERDWN_REG);
stat_mfio->u.select = tx_conf_read(tc, TX39_IOMFIODATASEL_REG);
}
if (io) {
#ifdef TX391X
pset = nset = 5;
pofs = i + 7;
nofs = i;
#endif
#ifdef TX392X
pset = nset = 8;
pofs = i + 16;
nofs = i;
#endif
} else {
pset = 3;
nset = 4;
pofs = nofs = i;
}
/*
* TMPR3912 specific
*/
int
tx391x_io_in(void *arg, int port)
{
struct tx39io_softc *sc __attribute__((__unused__)) = arg;
txreg_t reg = tx_conf_read(sc->sc_tc, TX39_IOCTRL_REG);
if (ISSET(reg_dir, i)) {
#if defined TX39IO_MFIOOUTPORT_ON || defined TX39IO_MFIOOUTPORT_OFF
txreg_t reg;
#ifdef TX392X
if (io) {
reg = tx_conf_read(tc, TX39_IODATAINOUT_REG);
#ifdef TX39IO_MFIOOUTPORT_ON
reg |= (1 << (i + 16));
printf("on.");
#else
reg &= ~(1 << (i + 16));
printf("off.");
DPRINTF(("%s: port #%d\n", __FUNCTION__, port));
return TX391X_IOCTRL_IODIN(reg) & (1 << port);
}
void
tx391x_io_out(void *arg, int port, int onoff)
{
#ifdef DIAGNOSTIC
const char *devname;
#endif
tx_conf_write(tc, TX39_IODATAINOUT_REG, reg);
} else
struct tx39io_softc *sc = arg;
tx_chipset_tag_t tc;
txreg_t reg, pos, iostat;
KASSERT(sc);
DPRINTF(("%s: port #%d\n", __FUNCTION__, port));
devname = sc->sc_dev.dv_xname;
tc = sc->sc_tc;
/* IO [0:6] */
pos = 1 << port;
#ifdef DIAGNOSTIC
if (!(sc->sc_stat_io.dir & pos))
panic("%s: IO%d is not output port.\n", devname, port);
#endif
reg = tx_conf_read(tc, TX39_IOCTRL_REG);
iostat = TX391X_IOCTRL_IODOUT(reg);
if (onoff)
iostat |= pos;
else
iostat &= ~pos;
TX391X_IOCTRL_IODOUT_CLR(reg);
reg = TX391X_IOCTRL_IODOUT_SET(reg, iostat);
tx_conf_write(tc, TX39_IOCTRL_REG, reg);
}
void
tx391x_io_intr_map(void *arg, int port, int *pedge, int *nedge)
{
if (pedge)
*pedge = MAKEINTR(5, (1 << (port + 7)));
if (nedge)
*nedge = MAKEINTR(5, (1 << port));
}
void
tx391x_io_update(void *arg)
{
struct tx39io_softc *sc = arg;
struct tx39io_port_status *stat_io = &sc->sc_stat_io;
tx_chipset_tag_t tc = sc->sc_tc;
txreg_t reg;
/* IO [0:6] */
sc->sc_ostat_io = *stat_io; /* save old status */
reg = tx_conf_read(tc, TX39_IOCTRL_REG);
stat_io->dir = TX391X_IOCTRL_IODIREC(reg);
stat_io->in = TX391X_IOCTRL_IODIN(reg);
stat_io->out = TX391X_IOCTRL_IODOUT(reg);
stat_io->u.debounce = TX391X_IOCTRL_IODEBSEL(reg);
reg = tx_conf_read(tc, TX39_IOIOPOWERDWN_REG);
stat_io->power = TX391X_IOIOPOWERDWN_IOPD(reg);
}
#endif /* TX391X */
#ifdef TX392X
/*
* TMPR3922 specific
*/
int
tx392x_io_in(void *arg, int port)
{
struct tx39io_softc *sc __attribute__((__unused__)) = arg;
txreg_t reg = tx_conf_read(sc->sc_tc, TX392X_IODATAINOUT_REG);
DPRINTF(("%s: port #%d\n", __FUNCTION__, port));
return TX392X_IODATAINOUT_DIN(reg) & (1 << port);
}
void
tx392x_io_out(void *arg, int port, int onoff)
{
struct tx39io_softc *sc = arg;
#ifdef DIAGNOSTIC
const char *devname = sc->sc_dev.dv_xname;
#endif
tx_chipset_tag_t tc = sc->sc_tc;
txreg_t reg, pos, iostat;
DPRINTF(("%s: port #%d\n", __FUNCTION__, port));
/* IO [0:15] */
pos = 1 << port;
#ifdef DIAGNOSTIC
if (!(sc->sc_status.dir_io & pos))
panic("%s: IO%d is not output port.\n", devname, port);
#endif
reg = tx_conf_read(tc, TX392X_IODATAINOUT_REG);
iostat = TX392X_IODATAINOUT_DOUT(reg);
if (onoff)
iostat |= pos;
else
iostat &= ~pos;
TX392X_IODATAINOUT_DOUT_CLR(reg);
reg = TX392X_IODATAINOUT_DOUT_SET(reg, iostat);
tx_conf_write(tc, TX392X_IODATAINOUT_REG, reg);
}
void
tx392x_io_intr_map(void *arg, int port, int *pedge, int *nedge)
{
if (pedge)
*pedge = MAKEINTR(8, (1 << (port + 16)));
if (nedge)
*nedge = MAKEINTR(8, (1 << port));
}
void
tx392x_io_update(void *arg)
{
struct tx39io_softc *sc = arg;
struct tx39io_port_status *stat_io = &sc->sc_stat_io;
tx_chipset_tag_t tc = sc->sc_tc;
txreg_t reg;
sc->sc_ostat_io = *stat_io; /* save old status */
/* IO [0:15] */
reg = tx_conf_read(tc, TX39_IOCTRL_REG);
stat_io->dir = TX392X_IOCTRL_IODIREC(reg);
stat_io->u.debounce = TX392X_IOCTRL_IODEBSEL(reg);
reg = tx_conf_read(tc, TX392X_IODATAINOUT_REG);
stat_io->in = TX392X_IODATAINOUT_DIN(reg);
stat_io->out = TX392X_IODATAINOUT_DOUT(reg);
reg = tx_conf_read(tc, TX39_IOIOPOWERDWN_REG);
stat_io->power = TX392X_IOIOPOWERDWN_IOPD(reg);
}
#endif /* TX392X */
{
reg = tx_conf_read(tc, TX39_IOMFIODATAOUT_REG);
#ifdef TX39IO_MFIOOUTPORT_ON
reg |= (1 << i);
printf("on.");
#else
reg &= ~(1 << i);
printf("off.");
#endif
tx_conf_write(tc, TX39_IOMFIODATAOUT_REG, reg);
}
#endif /* TX39IO_MFIOOUTPORT_ON */
printf("Out");
} else {
printf("In ");
if (mf && func) {
/* Positive Edge */
tx_intr_establish(
tc, MAKEINTR(pset, (1 << pofs)),
IST_EDGE, IPL_TTY, func, arg);
/* Negative Edge */
tx_intr_establish(
tc, MAKEINTR(nset, (1 << nofs)),
IST_EDGE, IPL_TTY, func, arg);
}
}
printf(" ");
printf("%d", ISSET(reg_out, i) ? 1 : 0);
printf(" ");
printf("%d", ISSET(reg_in, i) ? 1 : 0);
printf(" ");
printf("%s", ISSET(reg_pwr, i) ? "Down ": "Active");
};
#endif /* TX39IODEBUG */
static const char *line = "--------------------------------------------------"
"------------\n";
static void
mfio_dump(void *arg)
{
struct tx39io_softc *sc = arg;
const struct tx39io_mfio_map *map = tx39io_get_mfio_map(tc);
struct tx39io_port_status *stat;
int i;
printf("%s", line);
stat = &sc->sc_stat_mfio;
for (i = TX39_IO_MFIO_MAX - 1; i >= 0 ; i--) {
/* MFIO port has power down state */
printf("MFIO %2d: - ", i);
__print_port_status(stat, i);
printf(ISSET(stat->u.select, i) ? " MFIO(%s)\n" : " %s\n",
map[i].std_pin_name);
}
printf("%s", line);
}
static void
io_dump(void *arg)
{
struct tx39io_softc *sc = arg;
struct tx39io_port_status *stat;
int i;
printf("%s Debounce Direction DataOut DataIn PowerDown Select"
"\n%s", line, line);
stat = &sc->sc_stat_io;
for (i = tx39io_get_io_max(tc) - 1; i >= 0 ; i--) {
/* IO port has debouncer */
printf("IO %2d: %s ", i,
ISSET(stat->u.debounce, i) ? "On " : "Off");
__print_port_status(stat, i);
printf(" -\n");
}
}
static void
__print_port_status(struct tx39io_port_status *stat, int i)
{
printf("%s %d %d %s",
ISSET(stat->dir, i) ? "Out" : "In ",
ISSET(stat->out, i) ? 1 : 0,
ISSET(stat->in, i) ? 1 : 0,
ISSET(stat->power, i) ? "Down ": "Active");
}

View File

@ -1,34 +1,47 @@
/* $NetBSD: tx39ioreg.h,v 1.2 2000/01/16 21:47:00 uch Exp $ */
/* $NetBSD: tx39ioreg.h,v 1.3 2000/10/22 10:42:32 uch Exp $ */
/*
* Copyright (c) 1999, by UCHIYAMA Yasushi
/*-
* Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by UCHIYAMA Yasushi.
*
* 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.
* 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 NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation 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 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.
*/
/*
* TOSHIBA TX3912/TX3922 IO module
*/
#ifndef __TX39IO_PRIVATE
#error "don't include this file"
#else /* !__TX39IO_PRIVATE */
#define TX39_IOCTRL_REG 0x180
#define TX39_IOMFIODATAOUT_REG 0x184
#define TX39_IOMFIODATADIR_REG 0x188
@ -37,93 +50,96 @@
#define TX39_IOIOPOWERDWN_REG 0x194
#define TX39_IOMFIOPOWERDWN_REG 0x198
#ifdef TX392X
#define TX39_IODATAINOUT_REG 0x19c
#define TX392X_IODATAINOUT_REG 0x19c
#endif /* TX392X */
#define TX39_IO_MFIO_MAX 32
#ifdef TX391X
#define TX39_IO_IO_MAX 7
#define TX391X_IO_IO_MAX 7
#endif /* TX391X */
#ifdef TX392X
#define TX39_IO_IO_MAX 16
#define TX392X_IO_IO_MAX 16
#endif /* TX392X */
/*
* IO Control Register
*/
#ifdef TX391X
#define TX39_IOCTRL_IODEBSEL_SHIFT 24
#define TX39_IOCTRL_IODEBSEL_MASK 0x7f
#define TX39_IOCTRL_IODEBSEL(cr) \
(((cr) >> TX39_IOCTRL_IODEBSEL_SHIFT) & \
TX39_IOCTRL_IODEBSEL_MASK)
#define TX39_IOCTRL_IODEBSEL_SET(cr, val) \
((cr) | (((val) << TX39_IOCTRL_IODEBSEL_SHIFT) & \
(TX39_IOCTRL_IODEBSEL_MASK << TX39_IOCTRL_IODEBSEL_SHIFT)))
#define TX391X_IOCTRL_IODEBSEL_SHIFT 24
#define TX391X_IOCTRL_IODEBSEL_MASK 0x7f
#define TX391X_IOCTRL_IODEBSEL(cr) \
(((cr) >> TX391X_IOCTRL_IODEBSEL_SHIFT) & \
TX391X_IOCTRL_IODEBSEL_MASK)
#define TX391X_IOCTRL_IODEBSEL_SET(cr, val) \
((cr) | (((val) << TX391X_IOCTRL_IODEBSEL_SHIFT) & \
(TX391X_IOCTRL_IODEBSEL_MASK << TX391X_IOCTRL_IODEBSEL_SHIFT)))
#define TX39_IOCTRL_IODIREC_SHIFT 16
#define TX39_IOCTRL_IODIREC_MASK 0x7f
#define TX39_IOCTRL_IODIREC(cr) \
(((cr) >> TX39_IOCTRL_IODIREC_SHIFT) & \
TX39_IOCTRL_IODIREC_MASK)
#define TX39_IOCTRL_IODIREC_SET(cr, val) \
((cr) | (((val) << TX39_IOCTRL_IODIREC_SHIFT) & \
(TX39_IOCTRL_IODIREC_MASK << TX39_IOCTRL_IODIREC_SHIFT)))
#define TX391X_IOCTRL_IODIREC_SHIFT 16
#define TX391X_IOCTRL_IODIREC_MASK 0x7f
#define TX391X_IOCTRL_IODIREC(cr) \
(((cr) >> TX391X_IOCTRL_IODIREC_SHIFT) & \
TX391X_IOCTRL_IODIREC_MASK)
#define TX391X_IOCTRL_IODIREC_SET(cr, val) \
((cr) | (((val) << TX391X_IOCTRL_IODIREC_SHIFT) & \
(TX391X_IOCTRL_IODIREC_MASK << TX391X_IOCTRL_IODIREC_SHIFT)))
#define TX39_IOCTRL_IODOUT_SHIFT 8
#define TX39_IOCTRL_IODOUT_MASK 0x7f
#define TX39_IOCTRL_IODOUT(cr) \
(((cr) >> TX39_IOCTRL_IODOUT_SHIFT) & \
TX39_IOCTRL_IODOUT_MASK)
#define TX39_IOCTRL_IODOUT_CLR(cr) \
((cr) &= ~(TX39_IOCTRL_IODOUT_MASK << TX39_IOCTRL_IODOUT_SHIFT))
#define TX39_IOCTRL_IODOUT_SET(cr, val) \
((cr) | (((val) << TX39_IOCTRL_IODOUT_SHIFT) & \
(TX39_IOCTRL_IODOUT_MASK << TX39_IOCTRL_IODOUT_SHIFT)))
#define TX391X_IOCTRL_IODOUT_SHIFT 8
#define TX391X_IOCTRL_IODOUT_MASK 0x7f
#define TX391X_IOCTRL_IODOUT(cr) \
(((cr) >> TX391X_IOCTRL_IODOUT_SHIFT) & \
TX391X_IOCTRL_IODOUT_MASK)
#define TX391X_IOCTRL_IODOUT_CLR(cr) \
((cr) &= ~(TX391X_IOCTRL_IODOUT_MASK << TX391X_IOCTRL_IODOUT_SHIFT))
#define TX391X_IOCTRL_IODOUT_SET(cr, val) \
((cr) | (((val) << TX391X_IOCTRL_IODOUT_SHIFT) & \
(TX391X_IOCTRL_IODOUT_MASK << TX391X_IOCTRL_IODOUT_SHIFT)))
#define TX39_IOCTRL_IODIN_SHIFT 0
#define TX39_IOCTRL_IODIN_MASK 0x7f
#define TX39_IOCTRL_IODIN(cr) \
(((cr) >> TX39_IOCTRL_IODIN_SHIFT) & \
TX39_IOCTRL_IODIN_MASK)
#define TX391X_IOCTRL_IODIN_SHIFT 0
#define TX391X_IOCTRL_IODIN_MASK 0x7f
#define TX391X_IOCTRL_IODIN(cr) \
(((cr) >> TX391X_IOCTRL_IODIN_SHIFT) & \
TX391X_IOCTRL_IODIN_MASK)
#endif /* TX391X */
#ifdef TX392X
#define TX39_IOCTRL_IODEBSEL_SHIFT 16
#define TX39_IOCTRL_IODEBSEL_MASK 0xffff
#define TX39_IOCTRL_IODEBSEL(cr) \
(((cr) >> TX39_IOCTRL_IODEBSEL_SHIFT) & \
TX39_IOCTRL_IODEBSEL_MASK)
#define TX39_IOCTRL_IODEBSEL_SET(cr, val) \
((cr) | (((val) << TX39_IOCTRL_IODEBSEL_SHIFT) & \
(TX39_IOCTRL_IODEBSEL_MASK << TX39_IOCTRL_IODEBSEL_SHIFT)))
#define TX392X_IOCTRL_IODEBSEL_SHIFT 16
#define TX392X_IOCTRL_IODEBSEL_MASK 0xffff
#define TX392X_IOCTRL_IODEBSEL(cr) \
(((cr) >> TX392X_IOCTRL_IODEBSEL_SHIFT) & \
TX392X_IOCTRL_IODEBSEL_MASK)
#define TX392X_IOCTRL_IODEBSEL_SET(cr, val) \
((cr) | (((val) << TX392X_IOCTRL_IODEBSEL_SHIFT) & \
(TX392X_IOCTRL_IODEBSEL_MASK << TX392X_IOCTRL_IODEBSEL_SHIFT)))
#define TX39_IOCTRL_IODIREC_SHIFT 0
#define TX39_IOCTRL_IODIREC_MASK 0xffff
#define TX39_IOCTRL_IODIREC(cr) \
(((cr) >> TX39_IOCTRL_IODIREC_SHIFT) & \
TX39_IOCTRL_IODIREC_MASK)
#define TX39_IOCTRL_IODIREC_SET(cr, val) \
((cr) | (((val) << TX39_IOCTRL_IODIREC_SHIFT) & \
(TX39_IOCTRL_IODIREC_MASK << TX39_IOCTRL_IODIREC_SHIFT)))
#define TX392X_IOCTRL_IODIREC_SHIFT 0
#define TX392X_IOCTRL_IODIREC_MASK 0xffff
#define TX392X_IOCTRL_IODIREC(cr) \
(((cr) >> TX392X_IOCTRL_IODIREC_SHIFT) & \
TX392X_IOCTRL_IODIREC_MASK)
#define TX392X_IOCTRL_IODIREC_SET(cr, val) \
((cr) | (((val) << TX392X_IOCTRL_IODIREC_SHIFT) & \
(TX392X_IOCTRL_IODIREC_MASK << TX392X_IOCTRL_IODIREC_SHIFT)))
#define TX39_IODATAINOUT_DOUT_SHIFT 16
#define TX39_IODATAINOUT_DOUT_MASK 0xffff
#define TX39_IODATAINOUT_DOUT(cr) \
(((cr) >> TX39_IODATAINOUT_DOUT_SHIFT) & \
TX39_IODATAINOUT_DOUT_MASK)
#define TX39_IODATAINOUT_DOUT_SET(cr, val) \
((cr) | (((val) << TX39_IODATAINOUT_DOUT_SHIFT) & \
(TX39_IODATAINOUT_DOUT_MASK << TX39_IODATAINOUT_DOUT_SHIFT)))
#define TX392X_IODATAINOUT_DOUT_SHIFT 16
#define TX392X_IODATAINOUT_DOUT_MASK 0xffff
#define TX392X_IODATAINOUT_DOUT(cr) \
(((cr) >> TX392X_IODATAINOUT_DOUT_SHIFT) & \
TX392X_IODATAINOUT_DOUT_MASK)
#define TX392X_IODATAINOUT_DOUT_SET(cr, val) \
((cr) | (((val) << TX392X_IODATAINOUT_DOUT_SHIFT) & \
(TX392X_IODATAINOUT_DOUT_MASK << TX392X_IODATAINOUT_DOUT_SHIFT)))
#define TX392X_IODATAINOUT_DOUT_CLR(cr) \
((cr) &= ~(TX392X_IODATAINOUT_DOUT_MASK << \
TX392X_IODATAINOUT_DOUT_SHIFT))
#define TX39_IODATAINOUT_DIN_SHIFT 0
#define TX39_IODATAINOUT_DIN_MASK 0xffff
#define TX39_IODATAINOUT_DIN(cr) \
(((cr) >> TX39_IODATAINOUT_DIN_SHIFT) & \
TX39_IODATAINOUT_DIN_MASK)
#define TX39_IODATAINOUT_DIN_SET(cr, val) \
((cr) | (((val) << TX39_IODATAINOUT_DIN_SHIFT) & \
(TX39_IODATAINOUT_DIN_MASK << TX39_IODATAINOUT_DIN_SHIFT)))
#define TX392X_IODATAINOUT_DIN_SHIFT 0
#define TX392X_IODATAINOUT_DIN_MASK 0xffff
#define TX392X_IODATAINOUT_DIN(cr) \
(((cr) >> TX392X_IODATAINOUT_DIN_SHIFT) & \
TX392X_IODATAINOUT_DIN_MASK)
#define TX392X_IODATAINOUT_DIN_SET(cr, val) \
((cr) | (((val) << TX392X_IODATAINOUT_DIN_SHIFT) & \
(TX392X_IODATAINOUT_DIN_MASK << TX392X_IODATAINOUT_DIN_SHIFT)))
#endif /* TX392X */
/*
* MFIO Data Output Register
@ -149,21 +165,28 @@
/*
* IO Power Down Register
*/
#define TX39_IOIOPOWERDWN_IOPD_SHIFT 0
#ifdef TX391X
#define TX39_IOIOPOWERDWN_IOPD_MASK 0x7f
#define TX39_IOIOPOWERDWN_IOPD_RESET 0x7f
#define TX391X_IOIOPOWERDWN_IOPD_SHIFT 0
#define TX391X_IOIOPOWERDWN_IOPD_MASK 0x7f
#define TX391X_IOIOPOWERDWN_IOPD_RESET 0x7f
#define TX391X_IOIOPOWERDWN_IOPD(cr) \
(((cr) >> TX391X_IOIOPOWERDWN_IOPD_SHIFT) & \
TX391X_IOIOPOWERDWN_IOPD_MASK)
#define TX391X_IOIOPOWERDWN_IOPD_SET(cr, val) \
((cr) | (((val) << TX391X_IOIOPOWERDWN_IOPD_SHIFT) & \
(TX391X_IOIOPOWERDWN_IOPD_MASK << TX391X_IOIOPOWERDOWN_IOPD_SHIFT)))
#endif /* TX391X */
#ifdef TX392X
#define TX39_IOIOPOWERDWN_IOPD_MASK 0xffff
#define TX39_IOIOPOWERDWN_IOPD_RESET 0x0fff
#define TX392X_IOIOPOWERDWN_IOPD_SHIFT 0
#define TX392X_IOIOPOWERDWN_IOPD_MASK 0xffff
#define TX392X_IOIOPOWERDWN_IOPD_RESET 0x0fff
#define TX392X_IOIOPOWERDWN_IOPD(cr) \
(((cr) >> TX392X_IOIOPOWERDWN_IOPD_SHIFT) & \
TX392X_IOIOPOWERDWN_IOPD_MASK)
#define TX392X_IOIOPOWERDWN_IOPD_SET(cr, val) \
((cr) | (((val) << TX392X_IOIOPOWERDWN_IOPD_SHIFT) & \
(TX392X_IOIOPOWERDWN_IOPD_MASK << TX392X_IOIOPOWERDOWN_IOPD_SHIFT)))
#endif /* TX392X */
#define TX39_IOIOPOWERDWN_IOPD(cr) \
(((cr) >> TX39_IOIOPOWERDWN_IOPD_SHIFT) & \
TX39_IOIOPOWERDWN_IOPD_MASK)
#define TX39_IOIOPOWERDWN_IOPD_SET(cr, val) \
((cr) | (((val) << TX39_IOIOPOWERDWN_IOPD_SHIFT) & \
(TX39_IOIOPOWERDWN_IOPD_MASK << TX39_IOIOPOWERDOWN_IOPD_SHIFT)))
/*
@ -172,3 +195,105 @@
#define TX39_IOMFIOPOWERDWN_MFIOPD 0
#define TX39_IOMFIOPOWERDWN_MFIOPD_RESET 0xfaf03ffc
/*
* MFIO mapping
*/
struct tx39io_mfio_map {
char *std_pin_name;
int std_type;
#define STD_IN 1
#define STD_OUT 2
#define STD_INOUT 3
};
#ifdef TX391X
static const struct tx39io_mfio_map
tx391x_mfio_map[TX39_IO_MFIO_MAX] = {
[31] = {"CHIFS", STD_INOUT},
[30] = {"CHICLK", STD_INOUT},
[29] = {"CHIDOUT", STD_OUT},
[28] = {"CHIDIN", STD_IN},
[27] = {"DREQ", STD_IN},
[26] = {"DGRINT", STD_OUT},
[25] = {"BC32K", STD_OUT},
[24] = {"TXD", STD_OUT},
[23] = {"RXD", STD_IN},
[22] = {"CS1", STD_OUT},
[21] = {"CS2", STD_OUT},
[20] = {"CS3", STD_OUT},
[19] = {"MCS0", STD_OUT},
[18] = {"MCS1", STD_OUT},
[17] = {"MCS2", STD_OUT},
[16] = {"MCS3", STD_OUT},
[15] = {"SPICLK", STD_OUT},
[14] = {"SPIOUT", STD_OUT},
[13] = {"SPIN", STD_IN},
[12] = {"SIBMCLK", STD_INOUT},
[11] = {"CARDREG", STD_OUT},
[10] = {"CARDIOWR", STD_OUT},
[9] = {"CARDIORD", STD_OUT},
[8] = {"CARD1CSL", STD_OUT},
[7] = {"CARD1CSH", STD_OUT},
[6] = {"CARD2CSL", STD_OUT},
[5] = {"CARD2CSH", STD_OUT},
[4] = {"CARD1WAIT", STD_IN},
[3] = {"CARD2WAIT", STD_IN},
[2] = {"CARDDIR", STD_OUT},
[1] = {"MFIO[1]", 0},
[0] = {"MFIO[0]", 0}
};
#endif /* TX391X */
#ifdef TX392X
static const struct tx39io_mfio_map
tx392x_mfio_map[TX39_IO_MFIO_MAX] = {
[31] = {"CHIFS", STD_INOUT},
[30] = {"CHICLK", STD_INOUT},
[29] = {"CHIDOUT", STD_OUT},
[28] = {"CHIDIN", STD_IN},
[27] = {"DREQ", STD_IN},
[26] = {"DGRINT", STD_OUT},
[25] = {"BC32K", STD_OUT},
[24] = {"TXD", STD_OUT},
[23] = {"RXD", STD_IN},
[22] = {"CS1", STD_OUT},
[21] = {"CS2", STD_OUT},
[20] = {"CS3", STD_OUT},
[19] = {"MCS0", STD_OUT},
[18] = {"MCS1", STD_OUT},
[17] = {"RXPWR", STD_OUT},
[16] = {"IROUT", STD_OUT},
[15] = {"SPICLK", STD_OUT},
[14] = {"SPIOUT", STD_OUT},
[13] = {"SPIN", STD_IN},
[12] = {"SIBMCLK", STD_INOUT},
[11] = {"CARDREG", STD_OUT},
[10] = {"CARDIOWR", STD_OUT},
[9] = {"CARDIORD", STD_OUT},
[8] = {"CARD1CSL", STD_OUT},
[7] = {"CARD1CSH", STD_OUT},
[6] = {"CARD2CSL", STD_OUT},
[5] = {"CARD2CSH", STD_OUT},
[4] = {"CARD1WAIT", STD_IN},
[3] = {"CARD2WAIT", STD_IN},
[2] = {"CARDDIR", STD_OUT},
[1] = {"MCS1WAIT", 0},
[0] = {"MCS0WAIT", 0}
};
#endif /* TX392X */
#if defined TX391X && defined TX392X
#define tx39io_get_mfio_map(c) \
(IS_TX391X(c) ? tx391x_mfio_map : tx392x_mfio_map)
#define tx39io_get_io_max(c) \
(IS_TX391X(c) ? TX391X_IO_IO_MAX : TX392X_IO_IO_MAX)
#elif defined TX391X
#define tx39io_get_mfio_map(c) tx391x_mfio_map
#define tx39io_get_io_max(c) TX391X_IO_IO_MAX
#elif defined TX392X
#define tx39io_get_mfio_map(c) tx392x_mfio_map
#define tx39io_get_io_max(c) TX392X_IO_IO_MAX
#endif
#endif /* !__TX39IO_PRIVATE */

View File

@ -1,37 +1,61 @@
/* $NetBSD: tx39iovar.h,v 1.1 2000/01/16 21:47:00 uch Exp $ */
/* $NetBSD: tx39iovar.h,v 1.2 2000/10/22 10:42:32 uch Exp $ */
/*
* Copyright (c) 2000, by UCHIYAMA Yasushi
/*-
* Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by UCHIYAMA Yasushi.
*
* 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.
* 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 NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation 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 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.
*/
#define TXMFIO 0
#define TXIO 32
struct tx39io_port_status {
txreg_t dir, in, out, power;
union {
txreg_t debounce; /* IO */
txreg_t select; /* MFIO */
} u;
};
#define TXON 1
#define TXOFF 0
struct tx39io_softc {
struct device sc_dev;
tx_chipset_tag_t sc_tc;
u_int32_t sc_stat_io_mask, sc_stat_mfio_mask;
struct tx39io_port_status sc_stat_io;
struct tx39io_port_status sc_ostat_io;
struct tx39io_port_status sc_stat_mfio;
struct tx39io_port_status sc_ostat_mfio;
#define TXPORT(type, num) ((type) + (num))
/* unified IO manager ops */
struct txio_ops sc_io_ops;
struct txio_ops sc_mfio_ops;
};
void tx39io_portout __P((tx_chipset_tag_t, int, int));

View File

@ -1,4 +1,4 @@
/* $NetBSD: tx39power.c,v 1.7 2000/10/04 13:53:56 uch Exp $ */
/* $NetBSD: tx39power.c,v 1.8 2000/10/22 10:42:32 uch Exp $ */
/*-
* Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@ -37,7 +37,8 @@
*/
#include "opt_tx39_debug.h"
#include "opt_tx39powerdebug.h"
//#include "opt_tx39powerdebug.h"
#define TX39POWERDEBUG
#include <sys/param.h>
#include <sys/systm.h>
@ -50,7 +51,17 @@
#include <hpcmips/tx/tx39var.h>
#include <hpcmips/tx/tx39icureg.h>
#include <hpcmips/tx/tx39powerreg.h>
#include <hpcmips/tx/tx39spireg.h>
#ifdef TX39POWERDEBUG
int tx39power_debug = 1;
#define DPRINTF(arg) if (tx39power_debug) printf arg;
#define DPRINTFN(n, arg) if (tx39power_debug > (n)) printf arg;
#define DUMP_REGS(x) __tx39power_dump(x)
#else
#define DPRINTF(arg) ((void)0)
#define DPRINTFN(n, arg) ((void)0)
#define DUMP_REGS(x) ((void)0)
#endif
#define ISSET(x, v) ((x) & (v))
#define ISSETPRINT(r, m) __is_set_print(r, TX39_POWERCTRL_##m, #m)
@ -79,13 +90,13 @@ static int tx39power_ok_intr_n(void *);
static int tx39power_button_intr_p(void *);
static int tx39power_button_intr_n(void *);
#ifdef TX39POWERDEBUG
static void tx39power_dump(struct tx39power_softc *);
static void __tx39power_dump(struct tx39power_softc *);
#endif
int
tx39power_match(struct device *parent, struct cfdata *cf, void *aux)
{
return 2; /* 1st attach group of txsim */
return ATTACH_FIRST;
}
void
@ -100,42 +111,38 @@ tx39power_attach(struct device *parent, struct device *self, void *aux)
tx_conf_register_power(tc, self);
printf("\n");
#ifdef TX39POWERDEBUG
__tx39power_dump (sc);
#endif
/*
* Disable SPI module
*/
reg = tx_conf_read(tc, TX39_SPICTRL_REG);
if (ISSET(reg, TX39_SPICTRL_ENSPI)) {
reg &= ~TX39_SPICTRL_ENSPI;
}
printf("SPI module disabled\n");
DUMP_REGS(sc);
/*
* enable stop timer
*/
/* power button setting */
reg = tx_conf_read(tc, TX39_POWERCTRL_REG);
reg |= TX39_POWERCTRL_DBNCONBUTN;
tx_conf_write(tc, TX39_POWERCTRL_REG, reg);
/* enable stop timer */
reg = tx_conf_read(tc, TX39_POWERCTRL_REG);
reg &= ~(TX39_POWERCTRL_STPTIMERVAL_MASK <<
TX39_POWERCTRL_STPTIMERVAL_SHIFT);
reg = TX39_POWERCTRL_STPTIMERVAL_SET(reg, 1);
reg = TX39_POWERCTRL_STPTIMERVAL_SET(reg,
TX39_POWERCTRL_STPTIMERVAL_MAX);
reg |= TX39_POWERCTRL_ENSTPTIMER;
tx_conf_write(tc, TX39_POWERCTRL_REG, reg);
/* install power event handler */
/* low priority */
tx_intr_establish(tc, MAKEINTR(5, TX39_INTRSTATUS5_POSPWRINT),
IST_EDGE, IPL_CLOCK,
tx39power_intr_p, sc);
tx_intr_establish(tc, MAKEINTR(5, TX39_INTRSTATUS5_NEGPWRINT),
IST_EDGE, IPL_CLOCK,
tx39power_intr_n, sc);
/* high priority */
tx_intr_establish(tc, MAKEINTR(5, TX39_INTRSTATUS5_POSPWROKINT),
IST_EDGE, IPL_CLOCK,
tx39power_ok_intr_p, sc);
tx_intr_establish(tc, MAKEINTR(5, TX39_INTRSTATUS5_NEGPWROKINT),
IST_EDGE, IPL_CLOCK,
tx39power_ok_intr_n, sc);
/* user driven event */
tx_intr_establish(tc, MAKEINTR(5, TX39_INTRSTATUS5_POSONBUTNINT),
IST_EDGE, IPL_CLOCK,
tx39power_button_intr_p, sc);
@ -155,9 +162,6 @@ tx39power_suspend_cpu() /* I assume already splhigh */
__asm__ __volatile__(".set noreorder");
reg = tx_conf_read(tc, TX39_POWERCTRL_REG);
reg |= TX39_POWERCTRL_STOPCPU;
#ifdef TX392X
reg |= TX39_POWERCTRL_WARMSTART;
#endif
/* save interrupt state */
iregs[0] = tx_conf_read(tc, TX39_INTRENABLE6_REG);
iregs[1] = tx_conf_read(tc, TX39_INTRENABLE1_REG);
@ -191,6 +195,12 @@ tx39power_suspend_cpu() /* I assume already splhigh */
/* wait until power button pressed */
/* clear interrupt */
tx_conf_write(tc, TX39_INTRCLEAR5_REG, TX39_INTRSTATUS5_NEGONBUTNINT);
#ifdef TX392X
/* Clear WARMSTART bit to reset vector(0xbfc00000) work correctly */
reg = tx_conf_read(tc, TX39_POWERCTRL_REG);
reg &= ~TX39_POWERCTRL_WARMSTART;
tx_conf_write(tc, TX39_POWERCTRL_REG, reg);
#endif
/* restore interrupt state */
tx_conf_write(tc, TX39_INTRENABLE6_REG, iregs[0]);
@ -223,27 +233,34 @@ tx39power_button_intr_n(void *arg)
config_hook_call(CONFIG_HOOK_BUTTONEVENT,
CONFIG_HOOK_BUTTONEVENT_POWER,
(void *)0 /* off */);
DUMP_REGS(arg);
return 0;
}
int
tx39power_intr_p(void *arg)
{
/* low priority event */
printf("power_p\n");
DUMP_REGS(arg);
return 0;
}
static int
tx39power_intr_n(void *arg)
{
/* low priority event */
printf("power_n\n");
DUMP_REGS(arg);
return 0;
}
static int
tx39power_ok_intr_p(void *arg)
{
/* high priority event */
printf("power NG\n");
DUMP_REGS(arg);
config_hook_call(CONFIG_HOOK_PMEVENT,
CONFIG_HOOK_PMEVENT_SUSPENDREQ, NULL);
return 0;
@ -252,7 +269,9 @@ tx39power_ok_intr_p(void *arg)
static int
tx39power_ok_intr_n(void *arg)
{
/* high priority event */
printf("power OK\n");
DUMP_REGS(arg);
return 0;
}
@ -261,6 +280,7 @@ static void
__tx39power_dump (struct tx39power_softc *sc)
{
tx_chipset_tag_t tc = sc->sc_tc;
txreg_t reg;
reg = tx_conf_read(tc, TX39_POWERCTRL_REG);
ISSETPRINT(reg, ONBUTN);

View File

@ -1,4 +1,4 @@
/* $NetBSD: tx39powerreg.h,v 1.2 2000/10/04 13:53:56 uch Exp $ */
/* $NetBSD: tx39powerreg.h,v 1.3 2000/10/22 10:42:32 uch Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@ -77,6 +77,8 @@
#define TX39_POWERCTRL_STPTIMERVAL_SET(cr, val) \
((cr) | (((val) << TX39_POWERCTRL_STPTIMERVAL_SHIFT) & \
(TX39_POWERCTRL_STPTIMERVAL_MASK << TX39_POWERCTRL_STPTIMERVAL_SHIFT)))
#define TX39_POWERCTRL_STPTIMERVAL_MIN 0x0
#define TX39_POWERCTRL_STPTIMERVAL_MAX 0xf
#define TX39_POWERCTRL_ENSTPTIMER 0x00000800
#define TX39_POWERCTRL_ENFORCESHUTDWN 0x00000400

View File

@ -1,4 +1,4 @@
/* $NetBSD: tx39sib.c,v 1.6 2000/03/12 15:42:43 uch Exp $ */
/* $NetBSD: tx39sib.c,v 1.7 2000/10/22 10:42:32 uch Exp $ */
/*
* Copyright (c) 2000, by UCHIYAMA Yasushi
@ -138,7 +138,7 @@ tx39sib_match(parent, cf, aux)
struct cfdata *cf;
void *aux;
{
return 1;
return ATTACH_FIRST;
}
void

View File

@ -1,29 +1,39 @@
/* $NetBSD: tx39uart.c,v 1.3 2000/01/16 21:47:01 uch Exp $ */
/* $NetBSD: tx39uart.c,v 1.4 2000/10/22 10:42:33 uch Exp $ */
/*
* Copyright (c) 1999, 2000, by UCHIYAMA Yasushi
/*-
* Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by UCHIYAMA Yasushi.
*
* 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.
* 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 NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation 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 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 "opt_tx39_debug.h"
#include "opt_tx39uartdebug.h"
@ -38,14 +48,12 @@
#include <hpcmips/tx/tx39var.h>
#include <hpcmips/tx/tx39uartvar.h>
#include <hpcmips/tx/txiomanvar.h>
#include "locators.h"
int tx39uart_match __P((struct device*, struct cfdata*, void*));
void tx39uart_attach __P((struct device*, struct device*, void*));
int tx39uart_print __P((void*, const char*));
int tx39uart_search __P((struct device*, struct cfdata*, void*));
int tx39uart_match(struct device *, struct cfdata *, void *);
void tx39uart_attach(struct device *, struct device *, void *);
int tx39uart_print(void *, const char *);
int tx39uart_search(struct device *, struct cfdata *, void *);
struct tx39uart_softc {
struct device sc_dev;
@ -58,39 +66,28 @@ struct cfattach tx39uart_ca = {
};
int
tx39uart_match(parent, cf, aux)
struct device *parent;
struct cfdata *cf;
void *aux;
tx39uart_match(struct device *parent, struct cfdata *cf, void *aux)
{
return 1;
return ATTACH_LAST;
}
void
tx39uart_attach(parent, self, aux)
struct device *parent;
struct device *self;
void *aux;
tx39uart_attach(struct device *parent, struct device *self, void *aux)
{
struct txsim_attach_args *ta = aux;
struct tx39uart_softc *sc = (void*)self;
struct tx39uart_softc *sc = (void *)self;
tx_chipset_tag_t tc;
printf("\n");
sc->sc_tc = tc = ta->ta_tc;
txioman_uart_init(tc);
config_search(tx39uart_search, self, tx39uart_print);
}
int
tx39uart_search(parent, cf, aux)
struct device *parent;
struct cfdata *cf;
void *aux;
tx39uart_search(struct device *parent, struct cfdata *cf, void *aux)
{
struct tx39uart_softc *sc = (void*)parent;
struct tx39uart_softc *sc = (void *)parent;
struct tx39uart_attach_args ua;
ua.ua_tc = sc->sc_tc;
@ -111,9 +108,7 @@ tx39uart_search(parent, cf, aux)
}
int
tx39uart_print(aux, pnp)
void *aux;
const char *pnp;
tx39uart_print(void *aux, const char *pnp)
{
struct tx39uart_attach_args *ua = aux;

View File

@ -1,4 +1,4 @@
/* $NetBSD: tx39var.h,v 1.7 2000/10/04 13:53:56 uch Exp $ */
/* $NetBSD: tx39var.h,v 1.8 2000/10/22 10:42:33 uch Exp $ */
/*-
* Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@ -36,43 +36,101 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
enum tx_chipset {
__TX391X,
__TX392X,
};
/* attach priority of TX-internal modules. */
enum tx_attach_order {
ATTACH_FIRST = 3,
ATTACH_NORMAL = 2,
ATTACH_LAST = 1,
};
/* unified I/O manager */
enum txio_group {
MFIO = 0,
IO,
BETTY,
SNOWBALL,
PLUM,
NTXIO_GROUP
};
struct txio_ops;
struct tx_chipset_tag {
enum tx_chipset tc_chipset;
void *tc_intrt; /* interrupt tag */
void *tc_powert; /* power tag */
void *tc_clockt; /* clock/timer tag */
void *tc_soundt; /* sound tag */
void *tc_iomant; /* io manager tag */
struct txio_ops *tc_ioops[NTXIO_GROUP];
void *tc_videot; /* video chip tag */
};
typedef struct tx_chipset_tag* tx_chipset_tag_t;
typedef struct tx_chipset_tag* tx_chipset_tag_t __attribute__((__unused__));
typedef u_int32_t txreg_t;
extern struct tx_chipset_tag tx_chipset;
#define tx_conf_get_tag() (&tx_chipset)
#if defined TX391X && defined TX392X
#define IS_TX391X(t) ((t)->tc_chipset == __TX391X)
#define IS_TX392X(t) ((t)->tc_chipset == __TX392X)
#elif defined TX391X
#define IS_TX391X(t) (1)
#define IS_TX392X(t) (0)
#elif defined TX392X
#define IS_TX391X(t) (0)
#define IS_TX392X(t) (1)
#endif
void tx_conf_register_intr(tx_chipset_tag_t, void *);
void tx_conf_register_power(tx_chipset_tag_t, void *);
void tx_conf_register_clock(tx_chipset_tag_t, void *);
void tx_conf_register_sound(tx_chipset_tag_t, void *);
void tx_conf_register_ioman(tx_chipset_tag_t, void *);
void tx_conf_register_ioman(tx_chipset_tag_t, struct txio_ops *);
void tx_conf_register_video(tx_chipset_tag_t, void *);
/* Unified IO manager */
struct txio_ops {
void *_v; /* context */
enum txio_group _group;
int (*_in)(void *, int);
void (*_out)(void *, int, int);
void (*_intr_map)(void *, int, int *, int *);
void *(*_intr_establish)(void *, int, int (*)(void *), void *);
void (*_intr_disestablish)(void *, void *);
void (*_update)(void *); /* debug */
void (*_dump)(void *); /* debug */
};
#define tx_ioman_T(g, ops, args...) \
({ \
struct txio_ops *__o = tx_chipset.tc_ioops[g]; \
KASSERT(__o); \
__o->_##ops(__o->_v , ##args); \
})
/* access ops */
#define tx_ioman_in(g, args...) tx_ioman_T(g, in, args)
#define tx_ioman_out(g, args...) tx_ioman_T(g, out, args)
#define tx_ioman_intr_map(g, args...) tx_ioman_T(g, intr_map, args)
#define tx_ioman_intr_establish(g, args...) \
tx_ioman_T(g, intr_establish, args)
#define tx_ioman_intr_disestablish(g, args...) \
tx_ioman_T(g, intr_disestablish, args)
#define tx_ioman_update(g) tx_ioman_T(g, update)
#define tx_ioman_dump(g) tx_ioman_T(g, dump)
/*
* TX39 Internal Function Register access
*/
#define TX39_SYSADDR_CONFIG_REG_KSEG1 0xb0c00000
#ifdef TX39_PREFER_FUNCTION
tx_chipset_tag_t tx_conf_get_tag(void);
u_int32_t tx_conf_read(tx_chipset_tag_t, int);
void tx_conf_write(tx_chipset_tag_t, int, txreg_t);
#else /* TX39_PREFER_FUNCTION */
extern struct tx_chipset_tag tx_chipset;
#define tx_conf_read(t, reg) ((void)(t), \
#define tx_conf_read(t, reg) ( \
(*((volatile txreg_t *)(TX39_SYSADDR_CONFIG_REG_KSEG1 + (reg)))))
#define tx_conf_write(t, reg, val) ((void)(t), \
#define tx_conf_write(t, reg, val) ( \
(*((volatile txreg_t *)(TX39_SYSADDR_CONFIG_REG_KSEG1 + (reg))) \
= (val)))
#define tx_conf_get_tag() (&tx_chipset)
#endif /* TX39_PREFER_FUNCTION */
/*
* txsim attach arguments. (txsim ... TX System Internal Module)
@ -144,7 +202,7 @@ extern u_int32_t tx39debugflag;
} \
printf("\n"); \
})
#define bitdisp(a) __bitdisp(a, 0, 0, 0, 1)
#define bitdisp(a) __bitdisp((a), 0, 0, 0, 1)
#else /* TX39_DEBUG */
#define __bitdisp(a, s, e, m, c)
#define bitdisp(a)

View File

@ -1,29 +1,39 @@
/* $NetBSD: txcom.c,v 1.8 2000/03/23 06:38:03 thorpej Exp $ */
/* $NetBSD: txcom.c,v 1.9 2000/10/22 10:42:33 uch Exp $ */
/*
* Copyright (c) 1999, 2000, by UCHIYAMA Yasushi
/*-
* Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by UCHIYAMA Yasushi.
*
* 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.
* 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 NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation 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 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 "opt_tx39_debug.h"
#include "opt_tx39uartdebug.h"
@ -45,6 +55,7 @@
#include <dev/cons.h> /* consdev */
#include <machine/bus.h>
#include <machine/config_hook.h>
#include <hpcmips/tx/tx39var.h>
#include <hpcmips/tx/tx39icureg.h>
@ -60,6 +71,13 @@
#define SET(t, f) (t) |= (f)
#define CLR(t, f) (t) &= ~(f)
#define ISSET(t, f) ((t) & (f))
/*
* UARTA channel has DTR, DSR, RTS, CTS lines. and they wired to MFIO/IO port.
*/
#define IS_COM0(s) ((s) == 0)
#define IS_COM1(s) ((s) == 1)
#define ON ((void *)1)
#define OFF ((void *)0)
#ifdef TX39UARTDEBUG
#define DPRINTF(arg) printf arg
@ -80,6 +98,8 @@ struct txcom_chip {
int sc_hwflags;
int sc_dcd;
int sc_msr_cts;
int sc_tx_stopped;
};
struct txcom_softc {
@ -100,44 +120,50 @@ struct txcom_softc {
extern struct cfdriver txcom_cd;
int txcom_match __P((struct device*, struct cfdata*, void*));
void txcom_attach __P((struct device*, struct device*, void*));
int txcom_print __P((void*, const char*));
int txcom_match(struct device *, struct cfdata *, void *);
void txcom_attach(struct device *, struct device *, void *);
int txcom_print(void*, const char *);
int txcom_txintr __P((void*));
int txcom_rxintr __P((void*));
int txcom_frameerr_intr __P((void*));
int txcom_parityerr_intr __P((void*));
int txcom_break_intr __P((void*));
int txcom_txintr(void *);
int txcom_rxintr(void *);
int txcom_frameerr_intr(void *);
int txcom_parityerr_intr(void *);
int txcom_break_intr(void *);
void txcom_rxsoft __P((void*));
void txcom_txsoft __P((void*));
void txcom_rxsoft(void *);
void txcom_txsoft(void *);
int txcom_stsoft __P((void*));
int txcom_stsoft2 __P((void*));
int txcom_stsoft3 __P((void*));
int txcom_stsoft4 __P((void*));
int txcom_stsoft(void *);
int txcom_stsoft2(void *);
int txcom_stsoft3(void *);
int txcom_stsoft4(void *);
void txcom_shutdown __P((struct txcom_softc*));
void txcom_break __P((struct txcom_softc*, int));
void txcom_modem __P((struct txcom_softc*, int));
void txcomstart __P((struct tty*));
int txcomparam __P((struct tty*, struct termios*));
void txcom_shutdown(struct txcom_softc *);
void txcom_break(struct txcom_softc *, int);
void txcom_modem(struct txcom_softc *, int);
void txcomstart(struct tty *);
int txcomparam(struct tty *, struct termios *);
void txcom_reset __P((struct txcom_chip*));
int txcom_enable __P((struct txcom_chip*));
void txcom_disable __P((struct txcom_chip*));
void txcom_setmode __P((struct txcom_chip*));
void txcom_setbaudrate __P((struct txcom_chip*));
int txcom_cngetc __P((dev_t));
void txcom_cnputc __P((dev_t, int));
void txcom_cnpollc __P((dev_t, int));
void txcom_reset (struct txcom_chip *);
int txcom_enable (struct txcom_chip *);
void txcom_disable (struct txcom_chip *);
void txcom_setmode (struct txcom_chip *);
void txcom_setbaudrate(struct txcom_chip *);
int txcom_cngetc (dev_t);
void txcom_cnputc (dev_t, int);
void txcom_cnpollc (dev_t, int);
__inline int __txcom_txbufready __P((struct txcom_chip*, int));
__inline const char *__txcom_slotname __P((int));
int txcom_dcd_hook(void *, int, long, void *);
int txcom_cts_hook(void *, int, long, void *);
void txcom_dump __P((struct txcom_chip*));
__inline__ int __txcom_txbufready(struct txcom_chip *, int);
const char *__txcom_slotname(int);
#ifdef TX39UARTDEBUG
void txcom_dump(struct txcom_chip *);
#endif
cdev_decl(txcom);
@ -164,10 +190,7 @@ txcom_match(parent, cf, aux)
}
void
txcom_attach(parent, self, aux)
struct device *parent;
struct device *self;
void *aux;
txcom_attach(struct device *parent, struct device *self, void *aux)
{
struct tx39uart_attach_args *ua = aux;
struct txcom_softc *sc = (void*)self;
@ -248,13 +271,21 @@ txcom_attach(parent, self, aux)
tx_intr_establish(tc, TXCOMINTR(BREAK, slot), IST_EDGE, IPL_TTY,
txcom_break_intr, sc);
if (ua->ua_slot == 0)
txioman_uarta_init(tc, self);
/*
* UARTA has external signal line. (its wiring is platform dependent)
*/
if (IS_COM0(slot)) {
/* install DCD, CTS hooks. */
config_hook(CONFIG_HOOK_EVENT, CONFIG_HOOK_EVENT_COM0_DCD,
CONFIG_HOOK_EXCLUSIVE, txcom_dcd_hook, sc);
config_hook(CONFIG_HOOK_EVENT, CONFIG_HOOK_EVENT_COM0_CTS,
CONFIG_HOOK_EXCLUSIVE, txcom_cts_hook, sc);
}
/*
* UARTB can connect IR module
*/
if (ua->ua_slot == 1) {
if (IS_COM1(slot)) {
struct txcom_attach_args tca;
tca.tca_tc = tc;
tca.tca_parent = self;
@ -263,16 +294,13 @@ txcom_attach(parent, self, aux)
}
int
txcom_print(aux, pnp)
void *aux;
const char *pnp;
txcom_print(void *aux, const char *pnp)
{
return pnp ? QUIET : UNCONF;
}
void
txcom_reset(chip)
struct txcom_chip *chip;
txcom_reset(struct txcom_chip *chip)
{
tx_chipset_tag_t tc;
int slot, ofs;
@ -292,8 +320,7 @@ txcom_reset(chip)
}
int
txcom_enable(chip)
struct txcom_chip *chip;
txcom_enable(struct txcom_chip *chip)
{
tx_chipset_tag_t tc;
txreg_t reg;
@ -303,6 +330,11 @@ txcom_enable(chip)
slot = chip->sc_slot;
ofs = TX39_UARTCTRL1_REG(slot);
/* External power supply (if any) */
config_hook_call(CONFIG_HOOK_POWERCONTROL,
CONFIG_HOOK_POWERCONTROL_COM0, PWCTL_ON);
delay(3);
/* Supply clock */
reg = tx_conf_read(tc, TX39_CLOCKCTRL_REG);
reg |= (slot ? TX39_CLOCK_ENUARTBCLK : TX39_CLOCK_ENUARTACLK);
@ -321,7 +353,7 @@ txcom_enable(chip)
reg &= ~TX39_UARTCTRL1_ENBREAHALT;
tx_conf_write(tc, ofs, reg);
timeout = 100;
timeout = 100000;
while(!(tx_conf_read(tc, ofs) & TX39_UARTCTRL1_UARTON) &&
--timeout > 0)
@ -336,8 +368,7 @@ txcom_enable(chip)
}
void
txcom_disable(chip)
struct txcom_chip *chip;
txcom_disable(struct txcom_chip *chip)
{
tx_chipset_tag_t tc;
txreg_t reg;
@ -361,10 +392,8 @@ txcom_disable(chip)
}
__inline int
__txcom_txbufready(chip, retry)
struct txcom_chip *chip;
int retry;
__inline__ int
__txcom_txbufready(struct txcom_chip *chip, int retry)
{
tx_chipset_tag_t tc = chip->sc_tc;
int ofs = TX39_UARTCTRL1_REG(chip->sc_slot);
@ -378,8 +407,7 @@ __txcom_txbufready(chip, retry)
}
void
txcom_pulse_mode(dev)
struct device *dev;
txcom_pulse_mode(struct device *dev)
{
struct txcom_softc *sc = (void*)dev;
struct txcom_chip *chip = sc->sc_chip;
@ -402,8 +430,7 @@ txcom_pulse_mode(dev)
* console
*/
int
txcom_cngetc(dev)
dev_t dev;
txcom_cngetc(dev_t dev)
{
tx_chipset_tag_t tc;
int ofs, c, s;
@ -428,9 +455,7 @@ txcom_cngetc(dev)
}
void
txcom_cnputc(dev, c)
dev_t dev;
int c;
txcom_cnputc(dev_t dev, int c)
{
struct txcom_chip *chip = &txcom_chip;
tx_chipset_tag_t tc = chip->sc_tc;
@ -450,15 +475,12 @@ txcom_cnputc(dev, c)
}
void
txcom_cnpollc(dev, on)
dev_t dev;
int on;
txcom_cnpollc(dev_t dev, int on)
{
}
void
txcom_setmode(chip)
struct txcom_chip *chip;
txcom_setmode(struct txcom_chip *chip)
{
tcflag_t cflag = chip->sc_cflag;
int ofs = TX39_UARTCTRL1_REG(chip->sc_slot);
@ -501,8 +523,7 @@ txcom_setmode(chip)
}
void
txcom_setbaudrate(chip)
struct txcom_chip *chip;
txcom_setbaudrate(struct txcom_chip *chip)
{
int baudrate;
int ofs = TX39_UARTCTRL1_REG(chip->sc_slot);
@ -528,8 +549,7 @@ txcom_setbaudrate(chip)
}
int
txcom_cnattach(slot, speed, cflag)
int slot, speed, cflag;
txcom_cnattach(int slot, int speed, int cflag)
{
cn_tab = &txcomcons;
@ -554,9 +574,7 @@ txcom_cnattach(slot, speed, cflag)
* tty
*/
void
txcom_break(sc, on)
struct txcom_softc *sc;
int on;
txcom_break(struct txcom_softc *sc, int on)
{
struct txcom_chip *chip = sc->sc_chip;
@ -565,15 +583,20 @@ txcom_break(sc, on)
}
void
txcom_modem(sc, on)
struct txcom_softc *sc;
int on;
txcom_modem(struct txcom_softc *sc, int on)
{
struct txcom_chip *chip = sc->sc_chip;
tx_chipset_tag_t tc = chip->sc_tc;
int slot = chip->sc_slot;
txreg_t reg;
/* assert DTR */
if (IS_COM0(slot)) {
config_hook_call(CONFIG_HOOK_OUT,
CONFIG_HOOK_OUT_COM0_DTR,
(void *)on);
}
reg = tx_conf_read(tc, TX39_UARTCTRL1_REG(slot));
reg &= ~TX39_UARTCTRL1_ENUART;
tx_conf_write(tc, TX39_UARTCTRL1_REG(slot), reg);
@ -589,8 +612,7 @@ txcom_modem(sc, on)
}
void
txcom_shutdown(sc)
struct txcom_softc *sc;
txcom_shutdown(struct txcom_softc *sc)
{
struct tty *tp = sc->sc_tty;
int s = spltty();
@ -616,21 +638,19 @@ txcom_shutdown(sc)
splx(s);
}
__inline const char *
__txcom_slotname(slot)
int slot;
const char *
__txcom_slotname(int slot)
{
static const char *slotname[] = {"UARTA", "UARTB"};
if (slot != 0 && slot != 1) {
return "bogus slot";
} else {
return slotname[slot];
}
static const char *slotname[] = {"UARTA", "UARTB", "unknown"};
if (slot != 0 && slot != 1)
return slotname[2];
return slotname[slot];
}
int
txcom_frameerr_intr(arg)
void *arg;
txcom_frameerr_intr(void *arg)
{
struct txcom_softc *sc = arg;
@ -640,8 +660,7 @@ txcom_frameerr_intr(arg)
}
int
txcom_parityerr_intr(arg)
void *arg;
txcom_parityerr_intr(void *arg)
{
struct txcom_softc *sc = arg;
@ -651,8 +670,7 @@ txcom_parityerr_intr(arg)
}
int
txcom_break_intr(arg)
void *arg;
txcom_break_intr(void *arg)
{
struct txcom_softc *sc = arg;
@ -662,8 +680,7 @@ txcom_break_intr(arg)
}
int
txcom_rxintr(arg)
void *arg;
txcom_rxintr(void *arg)
{
struct txcom_softc *sc = arg;
struct txcom_chip *chip = sc->sc_chip;
@ -682,8 +699,7 @@ txcom_rxintr(arg)
}
void
txcom_rxsoft(arg)
void *arg;
txcom_rxsoft(void *arg)
{
struct txcom_softc *sc = arg;
struct tty *tp = sc->sc_tty;
@ -713,8 +729,7 @@ txcom_rxsoft(arg)
}
int
txcom_txintr(arg)
void *arg;
txcom_txintr(void *arg)
{
struct txcom_softc *sc = arg;
struct txcom_chip *chip = sc->sc_chip;
@ -734,8 +749,7 @@ txcom_txintr(arg)
}
void
txcom_txsoft(arg)
void *arg;
txcom_txsoft(void *arg)
{
struct txcom_softc *sc = arg;
struct tty *tp = sc->sc_tty;
@ -754,10 +768,7 @@ txcom_txsoft(arg)
}
int
txcomopen(dev, flag, mode, p)
dev_t dev;
int flag, mode;
struct proc *p;
txcomopen(dev_t dev, int flag, int mode, struct proc *p)
{
struct txcom_softc *sc = txcom_cd.cd_devs[minor(dev)];
struct txcom_chip *chip;
@ -856,10 +867,7 @@ txcomopen(dev, flag, mode, p)
}
int
txcomclose(dev, flag, mode, p)
dev_t dev;
int flag, mode;
struct proc *p;
txcomclose(dev_t dev, int flag, int mode, struct proc *p)
{
struct txcom_softc *sc = txcom_cd.cd_devs[minor(dev)];
struct tty *tp = sc->sc_tty;
@ -884,10 +892,7 @@ txcomclose(dev, flag, mode, p)
}
int
txcomread(dev, uio, flag)
dev_t dev;
struct uio *uio;
int flag;
txcomread(dev_t dev, struct uio *uio, int flag)
{
struct txcom_softc *sc = txcom_cd.cd_devs[minor(dev)];
struct tty *tp = sc->sc_tty;
@ -896,10 +901,7 @@ txcomread(dev, uio, flag)
}
int
txcomwrite(dev, uio, flag)
dev_t dev;
struct uio *uio;
int flag;
txcomwrite(dev_t dev, struct uio *uio, int flag)
{
struct txcom_softc *sc = txcom_cd.cd_devs[minor(dev)];
struct tty *tp = sc->sc_tty;
@ -908,8 +910,7 @@ txcomwrite(dev, uio, flag)
}
struct tty *
txcomtty(dev)
dev_t dev;
txcomtty(dev_t dev)
{
struct txcom_softc *sc = txcom_cd.cd_devs[minor(dev)];
@ -917,12 +918,7 @@ txcomtty(dev)
}
int
txcomioctl(dev, cmd, data, flag, p)
dev_t dev;
u_long cmd;
caddr_t data;
int flag;
struct proc *p;
txcomioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
{
struct txcom_softc *sc = txcom_cd.cd_devs[minor(dev)];
struct tty *tp = sc->sc_tty;
@ -983,9 +979,7 @@ txcomioctl(dev, cmd, data, flag, p)
}
void
txcomstop(tp, flag)
struct tty *tp;
int flag;
txcomstop(struct tty *tp, int flag)
{
struct txcom_softc *sc = txcom_cd.cd_devs[minor(tp->t_dev)];
int s;
@ -1004,8 +998,7 @@ txcomstop(tp, flag)
}
void
txcomstart(tp)
struct tty *tp;
txcomstart(struct tty *tp)
{
struct txcom_softc *sc = txcom_cd.cd_devs[minor(tp->t_dev)];
struct txcom_chip *chip = sc->sc_chip;
@ -1048,9 +1041,7 @@ txcomstart(tp)
* Set TXcom tty parameters from termios.
*/
int
txcomparam(tp, t)
struct tty *tp;
struct termios *t;
txcomparam(struct tty *tp, struct termios *t)
{
struct txcom_softc *sc = txcom_cd.cd_devs[minor(tp->t_dev)];
struct txcom_chip *chip;
@ -1134,9 +1125,47 @@ txcomparam(tp, t)
return 0;
}
int
txcom_dcd_hook(void *arg, int type, long id, void *msg)
{
struct txcom_softc *sc = arg;
struct tty *tp = sc->sc_tty;
struct txcom_chip *chip = sc->sc_chip;
int modem = !(int)msg; /* p-edge 1, n-edge 0 */
DPRINTF(("%s: DCD %s\n", __FUNCTION__, modem ? "ON" : "OFF"));
if (modem && chip->sc_dcd)
(void) (*linesw[tp->t_line].l_modem)(tp, chip->sc_dcd);
return 0;
}
int
txcom_cts_hook(void *arg, int type, long id, void *msg)
{
struct txcom_softc *sc = arg;
struct tty *tp = sc->sc_tty;
struct txcom_chip *chip = sc->sc_chip;
int clear = !(int)msg; /* p-edge 1, n-edge 0 */
DPRINTF(("%s: CTS %s\n", __FUNCTION__, clear ? "ON" : "OFF"));
if (chip->sc_msr_cts) {
if (!clear) {
chip->sc_tx_stopped = 1;
} else {
chip->sc_tx_stopped = 0;
(*linesw[tp->t_line].l_start)(tp);
}
}
return 0;
}
#ifdef TX39UARTDEBUG
void
txcom_dump(chip)
struct txcom_chip *chip;
txcom_dump(struct txcom_chip *chip)
{
tx_chipset_tag_t tc = chip->sc_tc;
int slot = chip->sc_slot;
@ -1166,79 +1195,4 @@ txcom_dump(chip)
ISSETPRINT(reg, ENPARITY);
ISSETPRINT(reg, ENUART);
}
/*
* Compaq-C function.
*/
#include <hpcmips/tx/tx39iovar.h>
int __compaq_uart_dcd __P((void*));
int __mobilon_uart_dcd __P((void*));
int
__compaq_uart_dcd(arg)
void *arg;
{
struct txcom_softc *sc = arg;
struct tty *tp = sc->sc_tty;
struct txcom_chip *chip = sc->sc_chip;
int modem;
switch (tx39intrvec) {
default:
return 0;
case ((3 << 16) | 30): /* MFIO 30 positive edge */
tx39io_portout(chip->sc_tc, TXPORT(TXMFIO, 31), TXON);
modem = 1;
break;
case ((4 << 16) | 30): /* MFIO 30 negative edge */
tx39io_portout(chip->sc_tc, TXPORT(TXMFIO, 31), TXOFF);
modem = 1;
break;
case ((3 << 16) | 5): /* MFIO 5 positive edge */
tx39io_portout(chip->sc_tc, TXPORT(TXMFIO, 6), TXON);
modem = 0;
break;
case ((4 << 16) | 5): /* MFIO 5 negative edge */
tx39io_portout(chip->sc_tc, TXPORT(TXMFIO, 6), TXOFF);
modem = 0;
break;
}
if (modem && chip->sc_dcd)
(void) (*linesw[tp->t_line].l_modem)(tp, chip->sc_dcd);
return 0;
}
int
__mobilon_uart_dcd(arg)
void *arg;
{
struct txcom_softc *sc = arg;
struct tty *tp = sc->sc_tty;
struct txcom_chip *chip = sc->sc_chip;
int modem;
switch (tx39intrvec) {
default:
return 0;
case ((5 << 16) | 4): /* IO 4 positive edge */
modem = 1;
break;
case ((5 << 16) | 11): /* IO 4 negative edge */
modem = 1;
break;
case ((5 << 16) | 6): /* IO 6 positive edge */
modem = 0;
break;
case ((5 << 16) | 13): /* IO 6 negative edge */
modem = 0;
break;
}
if (modem && chip->sc_dcd)
(void) (*linesw[tp->t_line].l_modem)(tp, chip->sc_dcd);
return 0;
}
#endif /* TX39UARTDEBUG */

View File

@ -1,29 +1,39 @@
/* $NetBSD: txioman.c,v 1.1 2000/01/16 21:47:00 uch Exp $ */
/* $NetBSD: txioman.c,v 1.2 2000/10/22 10:42:33 uch Exp $ */
/*
* Copyright (c) 2000, by UCHIYAMA Yasushi
/*-
* Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by UCHIYAMA Yasushi.
*
* 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.
* 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 NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation 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 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 "opt_tx39_debug.h"
@ -39,280 +49,85 @@
#include <machine/platid_mask.h>
#include <hpcmips/tx/tx39var.h>
#include <hpcmips/tx/tx39iovar.h>
#include <hpcmips/tx/txiomanvar.h>
#include <hpcmips/tx/txsnd.h>
#include "locators.h"
int txioman_match __P((struct device*, struct cfdata*, void*));
void txioman_attach __P((struct device*, struct device*, void*));
int txioman_match(struct device *, struct cfdata *, void *);
void txioman_attach(struct device *, struct device *, void *);
int txioman_print(void *, const char *);
int txioman_search(struct device *, struct cfdata *, void *);
struct txioman_softc {
struct device sc_dev;
tx_chipset_tag_t sc_tc;
struct device sc_dev;
};
struct cfattach txioman_ca = {
sizeof(struct txioman_softc), txioman_match, txioman_attach
};
void __txioman_led __P((txioman_tag_t, int, int));
void __txioman_backlight __P((txioman_tag_t, int));
void __txioman_uart_init __P((txioman_tag_t));
void __txioman_uarta_init __P((txioman_tag_t, void*));
struct txioman_tag txioman_null_tag = {
NULL,
__txioman_led,
__txioman_backlight,
__txioman_uart_init,
__txioman_uarta_init,
};
void __mobilon_backlight __P((txioman_tag_t, int));
void __mobilon_uart_init __P((txioman_tag_t));
void __mobilon_uarta_init __P((txioman_tag_t, void*));
struct txioman_tag txioman_mobilon_tag = {
NULL,
__txioman_led,
__mobilon_backlight,
__mobilon_uart_init,
__mobilon_uarta_init,
};
void __compaq_led __P((txioman_tag_t, int, int));
void __compaq_uarta_init __P((txioman_tag_t, void*));
struct txioman_tag txioman_compaq_tag = {
NULL,
__compaq_led,
__txioman_backlight,
__txioman_uart_init,
__compaq_uarta_init,
};
const struct txioman_platform_table {
platid_t tp_platform;
char* tp_name;
txioman_tag_t tp_tag;
} txioman_platform_table[] = {
{{{PLATID_WILD, PLATID_MACH_COMPAQ_C}},
"Compaq-C",
&txioman_compaq_tag},
{{{PLATID_WILD, PLATID_MACH_SHARP_MOBILON}},
"Mobilon HC",
&txioman_mobilon_tag},
{{{0, 0}}, "", &txioman_null_tag}
};
txioman_tag_t txioman_tag_lookup __P((void));
int __config_hook_backlight __P((void*, int, long, void*));
int
txioman_match(parent, cf, aux)
struct device *parent;
struct cfdata *cf;
void *aux;
txioman_match(struct device *parent, struct cfdata *cf, void *aux)
{
platid_mask_t mask;
if (cf->cf_loc[TXIOMANIFCF_PLATFORM] ==
TXIOMANIFCF_PLATFORM_DEFAULT) {
return 1;
}
mask = PLATID_DEREF(cf->cf_loc[TXIOMANIFCF_PLATFORM]);
/* select platform */
mask = PLATID_DEREF(cf->cf_loc[TXSIMCF_PLATFORM]);
if (platid_match(&platid, &mask)) {
return 2;
return ATTACH_NORMAL;
}
return 0;
}
void
txioman_attach(parent, self, aux)
struct device *parent;
struct device *self;
void *aux;
txioman_attach(struct device *parent, struct device *self, void *aux)
{
struct txioman_attach_args *tia = aux;
struct txioman_softc *sc = (void*)self;
txioman_tag_t tag;
sc->sc_tc = tia->tia_tc;
tag = txioman_tag_lookup();
tag->ti_v = sc;
/*
* register myself to tx_chipset.
*/
tx_conf_register_ioman(sc->sc_tc, tag);
/*
* register backlight config_hook if any.
*/
config_hook(CONFIG_HOOK_BUTTONEVENT,
CONFIG_HOOK_BUTTONEVENT_LIGHT,
CONFIG_HOOK_SHARE, /* btnmgr */
__config_hook_backlight, sc->sc_tc);
}
txioman_tag_t
txioman_tag_lookup()
{
const struct txioman_platform_table *tab;
platid_mask_t mask;
struct txsim_attach_args *ta = aux;
struct txio_attach_args taa;
for (tab = txioman_platform_table;
tab->tp_tag != &txioman_null_tag; tab++) {
mask = PLATID_DEREF(&tab->tp_platform);
if (platid_match(&platid, &mask))
goto out;
}
out:
printf(": %s\n", tab->tp_name);
taa.taa_tc = ta->ta_tc;
printf("\n");
return tab->tp_tag;
config_search(txioman_search, self, &taa);
}
/*
* default functions.
*/
void
__txioman_led(ti, type, onoff)
txioman_tag_t ti;
int type, onoff;
{
}
void
__txioman_backlight(ti, onoff)
txioman_tag_t ti;
int onoff;
{
}
void
__txioman_uart_init(ti)
txioman_tag_t ti;
{
}
void
__txioman_uarta_init(ti, cookie)
txioman_tag_t ti;
void *cookie;
{
}
/*
* Compaq-C functions.
*/
void
__compaq_led(ti, type, onoff)
txioman_tag_t ti;
int type, onoff;
{
struct txioman_softc *sc = (void*)ti;
/* Green LED */
tx39io_portout(sc->sc_tc, TXPORT(TXMFIO, 3),
onoff ? TXOFF : TXON);
}
extern int __compaq_uart_dcd __P((void*));
extern int __mobilon_uart_dcd __P((void*));
void
__compaq_uarta_init(ti, cookie)
txioman_tag_t ti;
void *cookie;
{
struct txioman_softc *sc = (void*)ti;
tx_chipset_tag_t tc = sc->sc_tc;
tx_intr_establish(tc, MAKEINTR(3, (1<<30)), IST_EDGE, IPL_TTY,
__compaq_uart_dcd, cookie);
tx_intr_establish(tc, MAKEINTR(4, (1<<30)), IST_EDGE, IPL_TTY,
__compaq_uart_dcd, cookie);
tx_intr_establish(tc, MAKEINTR(3, (1<<5)), IST_EDGE, IPL_TTY,
__compaq_uart_dcd, cookie);
tx_intr_establish(tc, MAKEINTR(4, (1<<5)), IST_EDGE, IPL_TTY,
__compaq_uart_dcd, cookie);
}
/*
* Mobilon HC functions
*/
void
__mobilon_backlight(ti, onoff)
txioman_tag_t ti;
int onoff;
{
struct txioman_softc *sc = (void*)ti;
tx39io_portout(sc->sc_tc, TXPORT(TXMFIO, 14),
onoff ? TXON : TXOFF);
}
void
__mobilon_uart_init(ti)
txioman_tag_t ti;
{
struct txioman_softc *sc = (void*)ti;
tx39io_portout(sc->sc_tc, TXPORT(TXIO, 5), TXON);
tx39io_portout(sc->sc_tc, TXPORT(TXMFIO, 15), TXON);
}
void
__mobilon_uarta_init(ti, cookie)
txioman_tag_t ti;
void *cookie;
{
#if not_required /* ??? this is harmful... */
struct txioman_softc *sc = (void*)ti;
tx_chipset_tag_t tc = sc->sc_tc;
tx_intr_establish(tc, MAKEINTR(5, (1<<4)), IST_EDGE, IPL_TTY,
__mobilon_uart_dcd, cookie);
tx_intr_establish(tc, MAKEINTR(5, (1<<11)), IST_EDGE, IPL_TTY,
__mobilon_uart_dcd, cookie);
tx_intr_establish(tc, MAKEINTR(5, (1<<6)), IST_EDGE, IPL_TTY,
__mobilon_uart_dcd, cookie);
tx_intr_establish(tc, MAKEINTR(5, (1<<13)), IST_EDGE, IPL_TTY,
__mobilon_uart_dcd, cookie);
#endif
}
/*
* config_hook.
*/
int
__config_hook_backlight(arg, type, id, msg)
void* arg;
int type;
long id;
void* msg;
txioman_search(struct device *parent, struct cfdata *cf, void *aux)
{
static int onoff; /* XXX */
tx_chipset_tag_t tc = arg;
struct txio_attach_args *taa = aux;
taa->taa_group = cf->cf_group;
taa->taa_port = cf->cf_port;
taa->taa_type = cf->cf_type;
taa->taa_id = cf->cf_id;
taa->taa_edge = cf->cf_edge;
taa->taa_initial = cf->cf_initial;
onoff ^= 1;
txioman_backlight(tc, onoff);
txioman_led(tc, 0, onoff); /* test */
tx_sound_mute(tc, !onoff); /* test */
config_attach(parent, cf, taa, txioman_print);
return 0;
}
int
txioman_print(void *aux, const char *pnp)
{
struct txio_attach_args *taa = aux;
int edge = taa->taa_edge;
int type = taa->taa_type;
if (!pnp) {
printf(" group %d port %d type %d id %d", taa->taa_group,
taa->taa_port, type, taa->taa_id);
if (type == CONFIG_HOOK_BUTTONEVENT ||
type == CONFIG_HOOK_PMEVENT ||
type == CONFIG_HOOK_EVENT) {
printf (" interrupt edge [%s%s]",
edge & 0x1 ? "p" : "", edge & 0x2 ? "n" : "");
}
if (taa->taa_initial != -1)
printf(" initial %d", taa->taa_initial);
}
return QUIET;
}

View File

@ -0,0 +1,155 @@
/* $NetBSD: txioman_in.c,v 1.1 2000/10/22 10:42:33 uch Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by UCHIYAMA Yasushi.
*
* 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 NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation 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 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 "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/config_hook.h>
#include <hpcmips/tx/tx39var.h>
#include <hpcmips/tx/txiomanvar.h>
int txin_match(struct device *, struct cfdata *, void *);
void txin_attach(struct device *, struct device *, void *);
int txin_intr(void *);
int txin_intr_p(void *);
int txin_intr_n(void *);
struct txin_softc {
struct device sc_dev;
int sc_type; /* event type */
int sc_id; /* event id */
int sc_pedge;
int sc_state;
void *sc_ih_p;
void *sc_ih_n;
};
struct cfattach txin_ca = {
sizeof(struct txin_softc), txin_match, txin_attach
};
int
txin_match(struct device *parent, struct cfdata *cf, void *aux)
{
return 1;
}
void
txin_attach(struct device *parent, struct device *self, void *aux)
{
struct txio_attach_args *taa = aux;
struct txin_softc *sc = (void *)self;
struct txio_ops *ops;
int pe, ne;
ops = taa->taa_tc->tc_ioops[taa->taa_group];
if (ops == 0) {
printf(": I/O module not found.\n");
return;
}
printf("\n");
sc->sc_type = taa->taa_type;
sc->sc_id = taa->taa_id;
if (taa->taa_initial != -1) {
sc->sc_state = taa->taa_initial;
/* set initial state */
config_defer(self, (void (*)(struct device *))txin_intr);
}
/* install interrupt handler */
ops->_intr_map(ops->_v, taa->taa_port, &pe, &ne);
switch (taa->taa_edge) {
case TXIO_BOTHEDGE:
sc->sc_ih_p = ops->_intr_establish(ops->_v, pe,
txin_intr_p, sc);
sc->sc_ih_n = ops->_intr_establish(ops->_v, ne,
txin_intr_n, sc);
break;
case TXIO_POSEDGE:
sc->sc_ih_p = ops->_intr_establish(ops->_v, pe, txin_intr, sc);
break;
case TXIO_NEGEDGE:
sc->sc_ih_p = ops->_intr_establish(ops->_v, ne, txin_intr, sc);
break;
}
}
int
txin_intr(void *arg)
{
struct txin_softc *sc = arg;
printf("%s: type=%d, id=%d\n", __FUNCTION__, sc->sc_type, sc->sc_id);
config_hook_call(sc->sc_type, sc->sc_id, (void *)sc->sc_state);
sc->sc_state ^= 1;
printf("done.\n");
return 0;
}
int
txin_intr_p(void *arg)
{
struct txin_softc *sc = arg;
printf("%s(p): type=%d, id=%d\n", __FUNCTION__, sc->sc_type, sc->sc_id);
config_hook_call(sc->sc_type, sc->sc_id, (void *)1);
printf("done.\n");
return 0;
}
int
txin_intr_n(void *arg)
{
struct txin_softc *sc = arg;
printf("%s(n): type=%d, id=%d\n", __FUNCTION__, sc->sc_type, sc->sc_id);
config_hook_call(sc->sc_type, sc->sc_id, (void *)0);
printf("done.\n");
return 0;
}

View File

@ -0,0 +1,106 @@
/* $NetBSD: txioman_out.c,v 1.1 2000/10/22 10:42:33 uch Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by UCHIYAMA Yasushi.
*
* 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 NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation 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 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 "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/config_hook.h>
#include <hpcmips/tx/tx39var.h>
#include <hpcmips/tx/txiomanvar.h>
int txout_match(struct device *, struct cfdata *, void *);
void txout_attach(struct device *, struct device *, void *);
int txout_hook(void *, int, long, void *);
struct txout_softc {
struct device sc_dev;
struct txio_ops *sc_ops;
int sc_port;
};
struct cfattach txout_ca = {
sizeof(struct txout_softc), txout_match, txout_attach
};
int
txout_match(struct device *parent, struct cfdata *cf, void *aux)
{
return 1;
}
void
txout_attach(struct device *parent, struct device *self, void *aux)
{
struct txio_attach_args *taa = aux;
struct txout_softc *sc = (void *)self;
struct txio_ops *ops;
ops = sc->sc_ops = taa->taa_tc->tc_ioops[taa->taa_group];
if (ops == 0) {
printf(": I/O module not found.\n");
return;
}
printf("\n");
sc->sc_port = taa->taa_port;
if (taa->taa_initial != -1) {
ops->_out(ops->_v, sc->sc_port, taa->taa_initial);
}
config_hook(taa->taa_type, taa->taa_id, CONFIG_HOOK_SHARE,
txout_hook, sc);
}
int
txout_hook(void *arg, int type, long id, void *msg)
{
struct txout_softc *sc = arg;
struct txio_ops *ops = sc->sc_ops;
printf("%s: %d\n", __FUNCTION__, sc->sc_port);
ops->_out(ops->_v, sc->sc_port, (int)msg);
printf("done.\n");
return 0;
}

View File

@ -1,60 +1,57 @@
/* $NetBSD: txiomanvar.h,v 1.1 2000/01/16 21:47:00 uch Exp $ */
/* $NetBSD: txiomanvar.h,v 1.2 2000/10/22 10:42:33 uch Exp $ */
/*
* Copyright (c) 2000, by UCHIYAMA Yasushi
/*-
* Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by UCHIYAMA Yasushi.
*
* 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.
* 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 NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation 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 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.
*/
struct txioman_attach_args {
char *tia_busname;
tx_chipset_tag_t tia_tc;
struct txio_attach_args {
tx_chipset_tag_t taa_tc;
enum txio_group taa_group;
int taa_edge;
#define TXIO_POSEDGE 0x1
#define TXIO_NEGEDGE 0x2
#define TXIO_BOTHEDGE 0x3
int taa_type;
int taa_port;
int taa_id;
int taa_initial;
};
typedef struct txioman_tag *txioman_tag_t;
struct txioman_tag {
void *ti_v;
void (*ti_led) __P((txioman_tag_t, int, int));
void (*ti_backlight) __P((txioman_tag_t, int));
void (*ti_uart_init) __P((txioman_tag_t));
void (*ti_uarta_init) __P((txioman_tag_t, void*));
#if not_required_yet
void (*ti_uartb_init) __P((txioman_tag_t, void*));
#endif
};
#define txioman_led(t, type, onoff) \
(*((txioman_tag_t)(t->tc_iomant))->ti_led) \
(((txioman_tag_t)(t->tc_iomant))->ti_v, (type), (onoff))
#define txioman_backlight(t, onoff) \
(*((txioman_tag_t)(t->tc_iomant))->ti_backlight) \
(((txioman_tag_t)(t->tc_iomant))->ti_v, (onoff))
#define txioman_uart_init(t) \
(*((txioman_tag_t)(t->tc_iomant))->ti_uart_init) \
(((txioman_tag_t)(t->tc_iomant))->ti_v)
#define txioman_uarta_init(t, c) \
(*((txioman_tag_t)(t->tc_iomant))->ti_uarta_init) \
(((txioman_tag_t)(t->tc_iomant))->ti_v, (c))
#define cf_type cf_loc[TXIOMANIFCF_EVTYPE]
#define cf_group cf_loc[TXIOMANIFCF_GROUP]
#define cf_port cf_loc[TXIOMANIFCF_PORT]
#define cf_id cf_loc[TXIOMANIFCF_ID]
#define cf_edge cf_loc[TXIOMANIFCF_EDGE]
#define cf_initial cf_loc[TXIOMANIFCF_INITIAL]

View File

@ -1,29 +1,39 @@
/* $NetBSD: txsim.c,v 1.2 2000/01/12 14:56:20 uch Exp $ */
/* $NetBSD: txsim.c,v 1.3 2000/10/22 10:42:33 uch Exp $ */
/*
* Copyright (c) 1999, by UCHIYAMA Yasushi
/*-
* Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by UCHIYAMA Yasushi.
*
* 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.
* 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 NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation 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 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.
*/
/*
@ -41,10 +51,10 @@
#include <hpcmips/tx/tx39var.h>
#include <hpcmips/tx/txsnd.h>
int txsim_match __P((struct device*, struct cfdata*, void*));
void txsim_attach __P((struct device*, struct device*, void*));
int txsim_print __P((void*, const char*));
int txsim_search __P((struct device*, struct cfdata*, void*));
int txsim_match(struct device *, struct cfdata *, void *);
void txsim_attach(struct device *, struct device *, void *);
int txsim_print(void *, const char*);
int txsim_search(struct device *, struct cfdata *, void *);
struct txsim_softc {
struct device sc_dev;
@ -56,10 +66,7 @@ struct cfattach txsim_ca = {
};
int
txsim_match(parent, match, aux)
struct device *parent;
struct cfdata *match;
void *aux;
txsim_match(struct device *parent, struct cfdata *match, void *aux)
{
struct mainbus_attach_args *ma = aux;
@ -69,10 +76,7 @@ txsim_match(parent, match, aux)
}
void
txsim_attach(parent, self, aux)
struct device *parent;
struct device *self;
void *aux;
txsim_attach(struct device *parent, struct device *self, void *aux)
{
struct txsim_softc *sc = (void*)self;
@ -80,31 +84,32 @@ txsim_attach(parent, self, aux)
tx_sound_init(tx_conf_get_tag());
/*
* interrupt, clock module is used by other system module.
* so attach first.
* interrupt, clock module is used by other system module.
* so attach first.
*/
sc->sc_pri = 2;
sc->sc_pri = ATTACH_FIRST;
config_search(txsim_search, self, txsim_print);
/*
* unified I/O manager requires all I/O capable module already
* attached.
*/
sc->sc_pri = ATTACH_NORMAL;
config_search(txsim_search, self, txsim_print);
/*
* Other system module.
* UART module uses platform dependent config_hooks.
*/
sc->sc_pri = 1;
sc->sc_pri = ATTACH_LAST;
config_search(txsim_search, self, txsim_print);
}
int
txsim_print(aux, pnp)
void *aux;
const char *pnp;
txsim_print(void *aux, const char *pnp)
{
return pnp ? QUIET : UNCONF;
}
int
txsim_search(parent, cf, aux)
struct device *parent;
struct cfdata *cf;
void *aux;
txsim_search(struct device *parent, struct cfdata *cf, void *aux)
{
struct txsim_softc *sc = (void*)parent;
struct txsim_attach_args ta;