Change tx_poll_establish implementation and interface.
This commit is contained in:
parent
9ffbadc055
commit
c6376f2e26
|
@ -1,7 +1,7 @@
|
|||
/* $NetBSD: m38813c.c,v 1.1 1999/12/08 15:51:07 uch Exp $ */
|
||||
/* $NetBSD: m38813c.c,v 1.2 2000/01/03 18:24:03 uch Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1999, by UCHIYAMA Yasushi
|
||||
* Copyright (c) 1999, 2000, by UCHIYAMA Yasushi
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -110,7 +110,7 @@ m38813c_attach(parent, self, aux)
|
|||
#ifndef USE_POLL
|
||||
#error options USE_POLL requied.
|
||||
#endif
|
||||
if (!(sc->sc_ih = tx39_poll_establish(sc->sc_tc, 5, IST_EDGE,
|
||||
if (!(sc->sc_ih = tx39_poll_establish(sc->sc_tc, 1,
|
||||
IPL_TTY, m38813c_intr,
|
||||
sc))) {
|
||||
printf(": can't establish interrupt\n");
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: p7416buf.c,v 1.2 1999/12/08 16:22:10 uch Exp $ */
|
||||
/* $NetBSD: p7416buf.c,v 1.3 2000/01/03 18:24:03 uch Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1999, by UCHIYAMA Yasushi
|
||||
|
@ -120,7 +120,7 @@ p7416buf_attach(parent, self, aux)
|
|||
#ifndef USE_POLL
|
||||
#error options USE_POLL requied.
|
||||
#endif
|
||||
if (!(sc->sc_ih = tx39_poll_establish(sc->sc_tc, 1, IST_EDGE,
|
||||
if (!(sc->sc_ih = tx39_poll_establish(sc->sc_tc, 1,
|
||||
IPL_TTY, p7416buf_intr,
|
||||
sc))) {
|
||||
printf(": can't establish interrupt\n");
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $NetBSD: tc5165buf.c,v 1.1 1999/12/12 17:10:01 uch Exp $ */
|
||||
/* $NetBSD: tc5165buf.c,v 1.2 2000/01/03 18:24:03 uch Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1999, by UCHIYAMA Yasushi
|
||||
* Copyright (c) 1999, 2000, by UCHIYAMA Yasushi
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -126,7 +126,7 @@ tc5165buf_attach(parent, self, aux)
|
|||
return;
|
||||
}
|
||||
#endif
|
||||
if (!(sc->sc_ih = tx39_poll_establish(sc->sc_tc, 1, IST_EDGE,
|
||||
if (!(sc->sc_ih = tx39_poll_establish(sc->sc_tc, 1,
|
||||
IPL_TTY, tc5165buf_poll,
|
||||
sc->sc_chip))) {
|
||||
printf(": can't establish interrupt\n");
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $NetBSD: tx39.c,v 1.8 1999/12/22 15:35:35 uch Exp $ */
|
||||
/* $NetBSD: tx39.c,v 1.9 2000/01/03 18:24:04 uch Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1999, by UCHIYAMA Yasushi
|
||||
* Copyright (c) 1999, 2000, by UCHIYAMA Yasushi
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -337,6 +337,38 @@ tx_conf_register_intr(t, intrt)
|
|||
tx_chipset.tc_intrt = intrt;
|
||||
}
|
||||
|
||||
void
|
||||
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");
|
||||
}
|
||||
|
||||
tx_chipset.tc_powert = powert;
|
||||
}
|
||||
|
||||
void
|
||||
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");
|
||||
}
|
||||
|
||||
tx_chipset.tc_clockt = clockt;
|
||||
}
|
||||
|
||||
#ifdef TX39_PREFER_FUNCTION
|
||||
tx_chipset_tag_t
|
||||
tx_conf_get_tag()
|
||||
|
@ -368,9 +400,10 @@ __is_set_print(reg, mask, name)
|
|||
int mask;
|
||||
char *name;
|
||||
{
|
||||
if (reg & mask) {
|
||||
printf("%s ", name);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
const char onoff[2] = "_x";
|
||||
int ret = reg & mask ? 1 : 0;
|
||||
|
||||
printf("%s[%c] ", name, onoff[ret]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $NetBSD: tx39clock.c,v 1.4 1999/12/23 16:58:48 uch Exp $ */
|
||||
/* $NetBSD: tx39clock.c,v 1.5 2000/01/03 18:24:04 uch Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1999, by UCHIYAMA Yasushi
|
||||
* Copyright (c) 1999, 2000 by UCHIYAMA Yasushi
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -40,6 +40,7 @@
|
|||
|
||||
#include <hpcmips/tx/tx39var.h>
|
||||
#include <hpcmips/tx/tx39icureg.h>
|
||||
#include <hpcmips/tx/tx39clockvar.h>
|
||||
#include <hpcmips/tx/tx39clockreg.h>
|
||||
#include <hpcmips/tx/tx39timerreg.h>
|
||||
|
||||
|
@ -70,6 +71,8 @@ struct tx39clock_softc {
|
|||
struct device sc_dev;
|
||||
tx_chipset_tag_t sc_tc;
|
||||
|
||||
int sc_alarm;
|
||||
|
||||
int sc_enabled;
|
||||
int sc_year;
|
||||
struct clocktime sc_epoch;
|
||||
|
@ -111,6 +114,7 @@ tx39clock_attach(parent, self, aux)
|
|||
txreg_t reg;
|
||||
|
||||
tc = sc->sc_tc = ta->ta_tc;
|
||||
tx_conf_register_clock(tc, self);
|
||||
|
||||
/* Reset timer module */
|
||||
tx_conf_write(tc, TX39_TIMERCONTROL_REG, 0);
|
||||
|
@ -243,16 +247,16 @@ __tx39timer_rtcreset(tc)
|
|||
tx_conf_write(tc, TX39_TIMERCONTROL_REG, reg);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
tx39clock_init(dev)
|
||||
struct device *dev;
|
||||
{
|
||||
tx_chipset_tag_t tc;
|
||||
struct tx39clock_softc *sc = (void*)dev;
|
||||
tx_chipset_tag_t tc = sc->sc_tc;
|
||||
txreg_t reg;
|
||||
int pcnt;
|
||||
|
||||
tc = tx_conf_get_tag();
|
||||
|
||||
/*
|
||||
* Setup periodic timer (interrupting hz times per second.)
|
||||
*/
|
||||
|
@ -333,6 +337,33 @@ tx39clock_set(dev, ct)
|
|||
}
|
||||
}
|
||||
|
||||
int
|
||||
tx39clock_alarm_set(tc, msec)
|
||||
tx_chipset_tag_t tc;
|
||||
int msec;
|
||||
{
|
||||
struct tx39clock_softc *sc = tc->tc_clockt;
|
||||
|
||||
sc->sc_alarm = TX39_MSEC2RTC(msec);
|
||||
tx39clock_alarm_refill(tc);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
tx39clock_alarm_refill(tc)
|
||||
tx_chipset_tag_t tc;
|
||||
{
|
||||
struct tx39clock_softc *sc = tc->tc_clockt;
|
||||
struct txtime t;
|
||||
|
||||
__tx39timer_rtcget(&t);
|
||||
|
||||
tx_conf_write(tc, TX39_TIMERALARMHI_REG, t.t_hi); /* XXX */
|
||||
tx_conf_write(tc, TX39_TIMERALARMLO_REG, t.t_lo + sc->sc_alarm);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
tx39clock_dump(tc)
|
||||
tx_chipset_tag_t tc;
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
/* $NetBSD: tx39clockvar.h,v 1.1 2000/01/03 18:24:05 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.
|
||||
*
|
||||
*/
|
||||
|
||||
int tx39clock_alarm_set __P((tx_chipset_tag_t, int));
|
||||
void tx39clock_alarm_refill __P((tx_chipset_tag_t));
|
|
@ -1,7 +1,7 @@
|
|||
/* $NetBSD: tx39icu.c,v 1.4 1999/12/23 17:24:30 uch Exp $ */
|
||||
/* $NetBSD: tx39icu.c,v 1.5 2000/01/03 18:24:04 uch Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1999, by UCHIYAMA Yasushi
|
||||
* Copyright (c) 1999, 2000 by UCHIYAMA Yasushi
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -44,6 +44,7 @@
|
|||
|
||||
#include <hpcmips/tx/tx39var.h>
|
||||
#include <hpcmips/tx/tx39icureg.h>
|
||||
#include <hpcmips/tx/tx39clockvar.h>
|
||||
|
||||
#include <machine/clock_machdep.h>
|
||||
#include <machine/cpu.h>
|
||||
|
@ -619,17 +620,19 @@ tx39_intr_dump(sc)
|
|||
|
||||
#ifdef USE_POLL
|
||||
void*
|
||||
tx39_poll_establish(tc, interval, mode, level, ih_fun, ih_arg)
|
||||
tx39_poll_establish(tc, interval, level, ih_fun, ih_arg)
|
||||
tx_chipset_tag_t tc;
|
||||
int interval;
|
||||
int mode; /* Trigger setting. but TX39 handles edge only. */
|
||||
int level; /* XXX not yet */
|
||||
int (*ih_fun) __P((void*));
|
||||
void *ih_arg;
|
||||
{
|
||||
struct tx39icu_softc *sc;
|
||||
struct txpoll_entry *p;
|
||||
int s;
|
||||
void *ret;
|
||||
|
||||
s = splhigh();
|
||||
sc = tc->tc_intrt;
|
||||
|
||||
if (!(p = malloc(sizeof(struct txpoll_entry),
|
||||
|
@ -641,26 +644,28 @@ tx39_poll_establish(tc, interval, mode, level, ih_fun, ih_arg)
|
|||
p->p_fun = ih_fun;
|
||||
p->p_arg = ih_arg;
|
||||
p->p_cnt = interval;
|
||||
|
||||
if (!sc->sc_polling) {
|
||||
/* Hook VSync : TX39_INTRSTATUS1_LCDINT*/
|
||||
tx39clock_alarm_set(tc, 33); /* 33 msec */
|
||||
|
||||
if (!(sc->sc_poll_ih =
|
||||
tx_intr_establish(
|
||||
#ifdef TX391X
|
||||
tc, MAKEINTR(1, TX39_INTRSTATUS1_LCDINT),
|
||||
#endif
|
||||
#ifdef TX392X
|
||||
tc, MAKEINTR(5, TX39_INTRSTATUS5_STPTIMERINT),
|
||||
#endif
|
||||
mode, level, tx39_poll_intr, sc))) {
|
||||
tc, MAKEINTR(5, TX39_INTRSTATUS5_ALARMINT),
|
||||
IST_EDGE, level, tx39_poll_intr, sc))) {
|
||||
printf("tx39_poll_establish: can't hook\n");
|
||||
|
||||
splx(s);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
sc->sc_polling++;
|
||||
p->p_desc = sc->sc_polling;
|
||||
TAILQ_INSERT_TAIL(&sc->sc_p_head, p, p_link);
|
||||
ret = (void*)p->p_desc;
|
||||
|
||||
return (void*)p->p_desc;
|
||||
splx(s);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -670,7 +675,9 @@ tx39_poll_disestablish(tc, arg)
|
|||
{
|
||||
struct tx39icu_softc *sc;
|
||||
struct txpoll_entry *p;
|
||||
int desc;
|
||||
int s, desc;
|
||||
|
||||
s = splhigh();
|
||||
sc = tc->tc_intrt;
|
||||
|
||||
desc = (int)arg;
|
||||
|
@ -681,10 +688,14 @@ tx39_poll_disestablish(tc, arg)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (TAILQ_EMPTY(&sc->sc_p_head)) {
|
||||
sc->sc_polling = 0;
|
||||
tx_intr_disestablish(tc, sc->sc_poll_ih);
|
||||
}
|
||||
|
||||
splx(s);
|
||||
return;
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -694,15 +705,29 @@ tx39_poll_intr(arg)
|
|||
struct tx39icu_softc *sc = arg;
|
||||
struct txpoll_entry *p;
|
||||
|
||||
tx39clock_alarm_refill(sc->sc_tc);
|
||||
|
||||
if (!sc->sc_polling) {
|
||||
return 0;
|
||||
}
|
||||
sc->sc_pollcnt++;
|
||||
TAILQ_FOREACH(p, &sc->sc_p_head, p_link) {
|
||||
if (sc->sc_pollcnt % p->p_cnt == 0) {
|
||||
(*p->p_fun)(p->p_arg);
|
||||
if ((*p->p_fun)(p->p_arg) == POLL_END)
|
||||
goto disestablish;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
disestablish:
|
||||
TAILQ_REMOVE(&sc->sc_p_head, p, p_link);
|
||||
free(p, M_DEVBUF);
|
||||
if (TAILQ_EMPTY(&sc->sc_p_head)) {
|
||||
sc->sc_polling = 0;
|
||||
tx_intr_disestablish(sc->sc_tc, sc->sc_poll_ih);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /* USE_POLL */
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $NetBSD: tx39power.c,v 1.3 1999/12/12 17:06:22 uch Exp $ */
|
||||
/* $NetBSD: tx39power.c,v 1.4 2000/01/03 18:24:04 uch Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1999, by UCHIYAMA Yasushi
|
||||
* Copyright (c) 1999, 2000 by UCHIYAMA Yasushi
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -80,6 +80,8 @@ tx39power_attach(parent, self, aux)
|
|||
txreg_t reg;
|
||||
|
||||
tc = sc->sc_tc = ta->ta_tc;
|
||||
tx_conf_register_power(tc, self);
|
||||
|
||||
printf("\n");
|
||||
#ifdef TX39POWERDEBUG
|
||||
reg = tx_conf_read(tc, TX39_POWERCTRL_REG);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $NetBSD: tx39timerreg.h,v 1.2 1999/12/22 15:35:35 uch Exp $ */
|
||||
/* $NetBSD: tx39timerreg.h,v 1.3 2000/01/03 18:24:04 uch Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1999, by UCHIYAMA Yasushi
|
||||
* Copyright (c) 1999, 2000 by UCHIYAMA Yasushi
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -52,6 +52,7 @@
|
|||
|
||||
/* Real timer clock (32.768kHz) */
|
||||
#define TX39_RTCLOCK 32768
|
||||
#define TX39_MSEC2RTC(m) ((TX39_RTCLOCK * m) / 1000)
|
||||
|
||||
/*
|
||||
* RTC Register High/Low
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $NetBSD: tx39var.h,v 1.2 1999/12/22 15:35:35 uch Exp $ */
|
||||
/* $NetBSD: tx39var.h,v 1.3 2000/01/03 18:24:05 uch Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1999, by UCHIYAMA Yasushi
|
||||
* Copyright (c) 1999, 2000 by UCHIYAMA Yasushi
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -28,12 +28,17 @@
|
|||
|
||||
struct tx_chipset_tag {
|
||||
void *tc_intrt; /* interrupt tag */
|
||||
void *tc_powert; /* power/clock tag */
|
||||
void *tc_powert; /* power tag */
|
||||
void *tc_clockt; /* clock/timer tag */
|
||||
};
|
||||
|
||||
typedef struct tx_chipset_tag* tx_chipset_tag_t;
|
||||
typedef u_int32_t txreg_t;
|
||||
|
||||
void tx_conf_register_intr __P((tx_chipset_tag_t, void*));
|
||||
void tx_conf_register_power __P((tx_chipset_tag_t, void*));
|
||||
void tx_conf_register_clock __P((tx_chipset_tag_t, void*));
|
||||
|
||||
/*
|
||||
* TX39 Internal Function Register access
|
||||
*/
|
||||
|
@ -77,11 +82,13 @@ struct txsim_attach_args {
|
|||
#define MAKEINTR(s, b) ((s) * 32 + (ffs(b) - 1))
|
||||
void* tx_intr_establish __P((tx_chipset_tag_t, int, int, int, int (*) __P((void*)), void*));
|
||||
void tx_intr_disestablish __P((tx_chipset_tag_t, void*));
|
||||
|
||||
#ifdef USE_POLL
|
||||
void* tx39_poll_establish __P((tx_chipset_tag_t, int, int, int, int (*) __P((void*)), void*));
|
||||
void* tx39_poll_establish __P((tx_chipset_tag_t, int, int, int (*) __P((void*)), void*));
|
||||
void tx39_poll_disestablish __P((tx_chipset_tag_t, void*));
|
||||
#define POLL_CONT 0
|
||||
#define POLL_END 1
|
||||
#endif /* USE_POLL */
|
||||
void tx_conf_register_intr __P((tx_chipset_tag_t, void*));
|
||||
|
||||
#ifdef TX39_DEBUG
|
||||
extern u_int32_t tx39debugflag, tx39intrvec;
|
||||
|
|
Loading…
Reference in New Issue