fix tx39clock_alarm_refill bug.

This commit is contained in:
uch 2000-09-28 16:18:26 +00:00
parent 6776b270ae
commit 154f1e86b1
4 changed files with 214 additions and 201 deletions

View File

@ -1,30 +1,41 @@
/* $NetBSD: tx39clock.c,v 1.5 2000/01/03 18:24:04 uch Exp $ */
/* $NetBSD: tx39clock.c,v 1.6 2000/09/28 16:18:26 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 <sys/param.h>
@ -47,16 +58,16 @@
#include <dev/dec/clockvar.h>
#ifdef TX39CLKDEBUG
#define DPRINTF(arg) printf arg
#define DPRINTF(arg) printf arg
#else
#define DPRINTF(arg)
#define DPRINTF(arg) ((void)0)
#endif
#define ISSETPRINT(r, m) __is_set_print(r, TX39_CLOCK_EN##m##CLK, #m)
void tx39clock_init __P((struct device*));
void tx39clock_get __P((struct device*, time_t, struct clocktime*));
void tx39clock_set __P((struct device*, struct clocktime*));
void tx39clock_init(struct device *);
void tx39clock_get(struct device *, time_t, struct clocktime *);
void tx39clock_set(struct device *, struct clocktime *);
const struct clockfns tx39clockfns = {
tx39clock_init, tx39clock_get, tx39clock_set,
@ -72,41 +83,34 @@ struct tx39clock_softc {
tx_chipset_tag_t sc_tc;
int sc_alarm;
int sc_enabled;
int sc_year;
struct clocktime sc_epoch;
};
int tx39clock_match __P((struct device*, struct cfdata*, void*));
void tx39clock_attach __P((struct device*, struct device*, void*));
void tx39clock_dump __P((tx_chipset_tag_t));
int tx39clock_match(struct device *, struct cfdata *, void *);
void tx39clock_attach(struct device *, struct device *, void *);
void tx39clock_dump(tx_chipset_tag_t);
void tx39clock_cpuspeed __P((int*, int*));
void tx39clock_cpuspeed(int *, int *);
void __tx39timer_rtcfreeze __P((tx_chipset_tag_t));
void __tx39timer_rtcreset __P((tx_chipset_tag_t));
__inline void __tx39timer_rtcget __P((struct txtime*));
__inline time_t __tx39timer_rtc2sec __P((struct txtime*));
void __tx39timer_rtcfreeze(tx_chipset_tag_t);
void __tx39timer_rtcreset(tx_chipset_tag_t);
__inline__ void __tx39timer_rtcget(struct txtime *);
__inline__ time_t __tx39timer_rtc2sec(struct txtime *);
struct cfattach tx39clock_ca = {
sizeof(struct tx39clock_softc), tx39clock_match, tx39clock_attach
};
int
tx39clock_match(parent, cf, aux)
struct device *parent;
struct cfdata *cf;
void *aux;
tx39clock_match(struct device *parent, struct cfdata *cf, void *aux)
{
return 2; /* 1st attach group of txsim */
}
void
tx39clock_attach(parent, self, aux)
struct device *parent;
struct device *self;
void *aux;
tx39clock_attach(struct device *parent, struct device *self, void *aux)
{
struct txsim_attach_args *ta = aux;
struct tx39clock_softc *sc = (void*)self;
@ -144,15 +148,13 @@ tx39clock_attach(parent, self, aux)
* cpuspeed ... instructions-per-microsecond
*/
void
tx39clock_cpuspeed(cpuclock, cpuspeed)
int *cpuclock;
int *cpuspeed;
tx39clock_cpuspeed(int *cpuclock, int *cpuspeed)
{
struct txtime t0, t1;
int elapsed;
__tx39timer_rtcget(&t0);
__asm __volatile("
__asm__ __volatile__("
.set noreorder;
li $8, 10000000;
1: nop;
@ -173,12 +175,10 @@ tx39clock_cpuspeed(cpuclock, cpuspeed)
*cpuclock = (100000000 / elapsed) * TX39_RTCLOCK;
*cpuspeed = *cpuclock / 1000000;
}
void
__tx39timer_rtcfreeze(tc)
tx_chipset_tag_t tc;
__tx39timer_rtcfreeze(tx_chipset_tag_t tc)
{
txreg_t reg;
@ -194,17 +194,15 @@ __tx39timer_rtcfreeze(tc)
tx_conf_write(tc, TX39_TIMERCONTROL_REG, reg);
}
__inline time_t
__tx39timer_rtc2sec(t)
struct txtime *t;
__inline__ time_t
__tx39timer_rtc2sec(struct txtime *t)
{
/* This rely on RTC is 32.768kHz */
return (t->t_lo >> 15) | (t->t_hi << 17);
}
__inline void
__tx39timer_rtcget(t)
struct txtime *t;
__inline__ void
__tx39timer_rtcget(struct txtime *t)
{
tx_chipset_tag_t tc;
txreg_t reghi, reglo, oreghi, oreglo;
@ -231,8 +229,7 @@ __tx39timer_rtcget(t)
}
void
__tx39timer_rtcreset(tc)
tx_chipset_tag_t tc;
__tx39timer_rtcreset(tx_chipset_tag_t tc)
{
txreg_t reg;
@ -247,10 +244,8 @@ __tx39timer_rtcreset(tc)
tx_conf_write(tc, TX39_TIMERCONTROL_REG, reg);
}
void
tx39clock_init(dev)
struct device *dev;
tx39clock_init(struct device *dev)
{
struct tx39clock_softc *sc = (void*)dev;
tx_chipset_tag_t tc = sc->sc_tc;
@ -280,10 +275,7 @@ tx39clock_init(dev)
}
void
tx39clock_get(dev, base, ct)
struct device *dev;
time_t base;
struct clocktime *ct;
tx39clock_get(struct device *dev, time_t base, struct clocktime *ct)
{
struct clock_ymdhms dt;
struct tx39clock_softc *sc = (void*)dev;
@ -324,9 +316,7 @@ tx39clock_get(dev, base, ct)
}
void
tx39clock_set(dev, ct)
struct device *dev;
struct clocktime *ct;
tx39clock_set(struct device *dev, struct clocktime *ct)
{
struct tx39clock_softc *sc = (void*)dev;
@ -338,9 +328,7 @@ tx39clock_set(dev, ct)
}
int
tx39clock_alarm_set(tc, msec)
tx_chipset_tag_t tc;
int msec;
tx39clock_alarm_set(tx_chipset_tag_t tc, int msec)
{
struct tx39clock_softc *sc = tc->tc_clockt;
@ -351,22 +339,26 @@ tx39clock_alarm_set(tc, msec)
}
void
tx39clock_alarm_refill(tc)
tx_chipset_tag_t tc;
tx39clock_alarm_refill(tx_chipset_tag_t tc)
{
struct tx39clock_softc *sc = tc->tc_clockt;
struct txtime t;
u_int64_t time;
__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);
time = ((u_int64_t)t.t_hi << 32) | (u_int64_t)t.t_lo;
time += (u_int64_t)sc->sc_alarm;
t.t_hi = (u_int32_t)((time >> 32) & TX39_TIMERALARMHI_MASK);
t.t_lo = (u_int32_t)(time & 0xffffffff);
tx_conf_write(tc, TX39_TIMERALARMHI_REG, t.t_hi);
tx_conf_write(tc, TX39_TIMERALARMLO_REG, t.t_lo);
}
void
tx39clock_dump(tc)
tx_chipset_tag_t tc;
tx39clock_dump(tx_chipset_tag_t tc)
{
txreg_t reg;

View File

@ -1,35 +1,46 @@
/* $NetBSD: tx39clockreg.h,v 1.1 1999/11/20 19:56:33 uch Exp $ */
/* $NetBSD: tx39clockreg.h,v 1.2 2000/09/28 16:18:26 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/3922 Clock module
*/
#define TX39_CLOCKCTRL_REG 0x1c0
#define TX39_CLOCKCTRL_REG 0x1c0
/*
* Clock Control Register
@ -37,56 +48,56 @@
/* R/W */
#define TX39_CLOCK_CHICLKDIV_SHIFT 24
#define TX39_CLOCK_CHICLKDIV_MASK 0xff
#define TX39_CLOCK_CHICLKDIV(cr) \
(((cr) >> TX39_CLOCK_CHICLKDIV_SHIFT) & \
#define TX39_CLOCK_CHICLKDIV(cr) \
(((cr) >> TX39_CLOCK_CHICLKDIV_SHIFT) & \
TX39_CLOCK_CHICLKDIV_MASK)
#define TX39_CLOCK_CHICLKDIV_SET(cr, val) \
((cr) | (((val) << TX39_CLOCK_CHICLKDIV_SHIFT) & \
#define TX39_CLOCK_CHICLKDIV_SET(cr, val) \
((cr) | (((val) << TX39_CLOCK_CHICLKDIV_SHIFT) & \
(TX39_CLOCK_CHICLKDIV_MASK << TX39_CLOCK_CHICLKDIV_SHIFT)))
#define TX39_CLOCK_ENCLKTEST 0x00800000
#define TX39_CLOCK_CCLKTESTSELSIB 0x00400000
#define TX39_CLOCK_CHIMCLKSEL 0x00200000
#define TX39_CLOCK_CHICLKDIR 0x00100000
#define TX39_CLOCK_ENCHIMCLK 0x00080000
#define TX39_CLOCK_ENCLKTEST 0x00800000
#define TX39_CLOCK_CCLKTESTSELSIB 0x00400000
#define TX39_CLOCK_CHIMCLKSEL 0x00200000
#define TX39_CLOCK_CHICLKDIR 0x00100000
#define TX39_CLOCK_ENCHIMCLK 0x00080000
#ifdef TX391X
#define TX39_CLOCK_ENVIDCLK 0x00040000
#define TX39_CLOCK_ENMBUSCLK 0x00020000
#define TX39_CLOCK_ENVIDCLK 0x00040000
#define TX39_CLOCK_ENMBUSCLK 0x00020000
#endif /* TX391X */
#ifdef TX392X
#define TX39_CLOCK_SPICLKDIR 0x00040000
#define TX39_CLOCK_ENIRDACLK 0x00020000
#define TX39_CLOCK_SPICLKDIR 0x00040000
#define TX39_CLOCK_ENIRDACLK 0x00020000
#endif /* TX392X */
#define TX39_CLOCK_ENSPICLK 0x00010000
#define TX39_CLOCK_ENTIMERCLK 0x00008000
#define TX39_CLOCK_ENFASTTIMERCLK 0x00004000
#define TX39_CLOCK_SIBCLKDIR 0x00002000
#define TX39_CLOCK_ENSPICLK 0x00010000
#define TX39_CLOCK_ENTIMERCLK 0x00008000
#define TX39_CLOCK_ENFASTTIMERCLK 0x00004000
#define TX39_CLOCK_SIBCLKDIR 0x00002000
#ifdef TX392X
#define TX39_CLOCK_ENC48MOUTCLK 0x00001000
#define TX39_CLOCK_ENC48MOUTCLK 0x00001000
#endif /* TX392X */
#define TX39_CLOCK_ENSIBMCLK 0x00000800
#define TX39_CLOCK_ENSIBMCLK 0x00000800
#define TX39_CLOCK_SIBMCLKDIV_SHIFT 8
#define TX39_CLOCK_SIBMCLKDIV_MASK 0x7
#define TX39_CLOCK_SIBMCLKDIV(cr) \
(((cr) >> TX39_CLOCK_SIBMCLKDIV_SHIFT) & \
#define TX39_CLOCK_SIBMCLKDIV(cr) \
(((cr) >> TX39_CLOCK_SIBMCLKDIV_SHIFT) & \
TX39_CLOCK_SIBMCLKDIV_MASK)
#define TX39_CLOCK_SIBMCLKDIV_SET(cr, val) \
((cr) | (((val) << TX39_CLOCK_SIBMCLKDIV_SHIFT) & \
#define TX39_CLOCK_SIBMCLKDIV_SET(cr, val) \
((cr) | (((val) << TX39_CLOCK_SIBMCLKDIV_SHIFT) & \
(TX39_CLOCK_SIBMCLKDIV_MASK << TX39_CLOCK_SIBMCLKDIV_SHIFT)))
#define TX39_CLOCK_CSERSEL 0x00000080
#define TX39_CLOCK_CSERDIV_SHIFT 4
#define TX39_CLOCK_CSERDIV_MASK 0x7
#define TX39_CLOCK_CSERDIV(cr) \
(((cr) >> TX39_CLOCK_CSERDIV_SHIFT) & \
#define TX39_CLOCK_CSERDIV(cr) \
(((cr) >> TX39_CLOCK_CSERDIV_SHIFT) & \
TX39_CLOCK_CSERDIV_MASK)
#define TX39_CLOCK_CSERDIV_SET(cr, val) \
((cr) | (((val) << TX39_CLOCK_CSERDIV_SHIFT) & \
#define TX39_CLOCK_CSERDIV_SET(cr, val) \
((cr) | (((val) << TX39_CLOCK_CSERDIV_SHIFT) & \
(TX39_CLOCK_CSERDIV_MASK << TX39_CLOCK_CSERDIV_SHIFT)))
#define TX39_CLOCK_ENCSERCLK 0x00000008
#define TX39_CLOCK_ENIRCLK 0x00000004
#define TX39_CLOCK_ENUARTACLK 0x00000002
#define TX39_CLOCK_ENUARTBCLK 0x00000001
#define TX39_CLOCK_ENCSERCLK 0x00000008
#define TX39_CLOCK_ENIRCLK 0x00000004
#define TX39_CLOCK_ENUARTACLK 0x00000002
#define TX39_CLOCK_ENUARTBCLK 0x00000001

View File

@ -1,30 +1,41 @@
/* $NetBSD: tx39clockvar.h,v 1.1 2000/01/03 18:24:05 uch Exp $ */
/* $NetBSD: tx39clockvar.h,v 1.2 2000/09/28 16:18:26 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.
*/
int tx39clock_alarm_set __P((tx_chipset_tag_t, int));
void tx39clock_alarm_refill __P((tx_chipset_tag_t));
int tx39clock_alarm_set(tx_chipset_tag_t, int);
void tx39clock_alarm_refill(tx_chipset_tag_t);

View File

@ -1,99 +1,98 @@
/* $NetBSD: tx39timerreg.h,v 1.3 2000/01/03 18:24:04 uch Exp $ */
/* $NetBSD: tx39timerreg.h,v 1.4 2000/09/28 16:18:26 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.
*/
/*
* Toshiba TX3912/3922 Timer module
*/
#define TX39_TIMERRTCHI_REG 0x140
#define TX39_TIMERRTCLO_REG 0x144
#define TX39_TIMERALARMHI_REG 0x148
#define TX39_TIMERALARMLO_REG 0x14C
#define TX39_TIMERCONTROL_REG 0x150
#define TX39_TIMERPERIODIC_REG 0x154
#define TX39_TIMERRTCHI_REG 0x140
#define TX39_TIMERRTCLO_REG 0x144
#define TX39_TIMERALARMHI_REG 0x148
#define TX39_TIMERALARMLO_REG 0x14C
#define TX39_TIMERCONTROL_REG 0x150
#define TX39_TIMERPERIODIC_REG 0x154
/* Periodic timer (1.15MHz) */
#ifdef TX391X
/*
* TX3912 base clock is 36.864MHz
*/
#define TX39_TIMERCLK 1152000
#define TX39_TIMERCLK 1152000
#endif
#ifdef TX392X
/*
* TX3922 base clock seems to be 32.25MHz (Telios)
*/
#define TX39_TIMERCLK 1007812
#define TX39_TIMERCLK 1007812
#endif
/* Real timer clock (32.768kHz) */
#define TX39_RTCLOCK 32768
#define TX39_MSEC2RTC(m) ((TX39_RTCLOCK * m) / 1000)
#define TX39_RTCLOCK 32768
#define TX39_MSEC2RTC(m) ((TX39_RTCLOCK * (m)) / 1000)
/*
* RTC Register High/Low
*/
/* R */
#define TX39_TIMERRTCHI_SHIFT 0
#define TX39_TIMERRTCHI_SHIFT 0
#ifdef TX391X
#define TX39_TIMERRTCHI_MASK 0xff
#define TX39_TIMERRTCHI_MASK 0xff
#endif /* TX391X */
#ifdef TX392X
#define TX39_TIMERRTCHI_MASK 0x7ff
#define TX39_TIMERRTCHI_MASK 0x7ff
#endif /* TX392X */
#define TX39_TIMERRTCHI(cr) \
(((cr) >> TX39_TIMERRTCHI_SHIFT) & \
TX39_TIMERRTCHI_MASK)
#define TX39_TIMERRTCHI(cr) ((cr) & TX39_TIMERRTCHI_MASK)
/*
* Alarm Register High/Low
*/
/* R/W */
#ifdef TX391X
#define TX39_TIMERALARMHI_SHIFT 0
#define TX39_TIMERALARMHI_MASK 0xff
#define TX39_TIMERALARMHI(cr) \
(((cr) >> TX39_TIMERALARMHI_SHIFT) & \
TX39_TIMERALARMHI_MASK)
#define TX39_TIMERALARMHI_SET(cr, val) \
((cr) | (((val) << TX39_TIMERALARMHI_SHIFT) & \
(TX39_TIMERALARMHI_MASK << TX39_TIMERALARMHI_SHIFT)))
#ifdef TX391X /* 40bit */
#define TX39_TIMERALARMHI_SHIFT 0
#define TX39_TIMERALARMHI_MASK 0xff
#endif /* TX391X */
#ifdef TX392X
#define TX39_TIMERALARMHI_SHIFT 0
#define TX39_TIMERALARMHI_MASK 0x7ff
#define TX39_TIMERALARMHI(cr) \
(((cr) >> TX39_TIMERALARMHI_SHIFT) & \
TX39_TIMERALARMHI_MASK)
#define TX39_TIMERALARMHI_SET(cr, val) \
((cr) | (((val) << TX39_TIMERALARMHI_SHIFT) & \
(TX39_TIMERALARMHI_MASK << TX39_TIMERALARMHI_SHIFT)))
#ifdef TX392X /* 43bit */
#define TX39_TIMERALARMHI_SHIFT 0
#define TX39_TIMERALARMHI_MASK 0x7ff
#endif /* TX392X */
#define TX39_TIMERALARMHI(cr) ((cr) & TX39_TIMERALARMHI_MASK)
/*
* Timer Control Register
*/
@ -112,20 +111,20 @@
/* R */
#define TX39_TIMERPERIODIC_PERCNT_SHIFT 15
#define TX39_TIMERPERIODIC_PERCNT_MASK 0xffff
#define TX39_TIMERPERIODIC_PERCNT(cr) \
(((cr) >> TX39_TIMERPERIODIC_PERCNT_SHIFT) & \
#define TX39_TIMERPERIODIC_PERCNT(cr) \
(((cr) >> TX39_TIMERPERIODIC_PERCNT_SHIFT) & \
TX39_TIMERPERIODIC_PERCNT_MASK)
/* R/W */
#define TX39_TIMERPERIODIC_PERVAL_SHIFT 0
#define TX39_TIMERPERIODIC_PERVAL_MASK 0xffff
#define TX39_TIMERPERIODIC_PERVAL(cr) \
(((cr) >> TX39_TIMERPERIODIC_PERVAL_SHIFT) & \
#define TX39_TIMERPERIODIC_PERVAL(cr) \
(((cr) >> TX39_TIMERPERIODIC_PERVAL_SHIFT) & \
TX39_TIMERPERIODIC_PERVAL_MASK)
#define TX39_TIMERPERIODIC_PERVAL_SET(cr, val) \
((cr) | (((val) << TX39_TIMERPERIODIC_PERVAL_SHIFT) & \
#define TX39_TIMERPERIODIC_PERVAL_SET(cr, val) \
((cr) | (((val) << TX39_TIMERPERIODIC_PERVAL_SHIFT) & \
(TX39_TIMERPERIODIC_PERVAL_MASK << TX39_TIMERPERIODIC_PERVAL_SHIFT)))
#define TX39_TIMERPERIODIC_PERVAL_CLR(cr) ((cr) &= \
#define TX39_TIMERPERIODIC_PERVAL_CLR(cr) ((cr) &= \
~(TX39_TIMERPERIODIC_PERVAL_MASK << TX39_TIMERPERIODIC_PERVAL_SHIFT))
#define TX39_TIMERPERIODIC_INTRRATE(val) \
#define TX39_TIMERPERIODIC_INTRRATE(val) \
((val) + 1)/TX39_TIMERCLK /* unit:Hz */