Home | History | Annotate | Line # | Download | only in tx
tx39clock.c revision 1.8.2.2
      1  1.8.2.2  bouyer /*	$NetBSD: tx39clock.c,v 1.8.2.2 2000/11/20 20:47:17 bouyer Exp $ */
      2  1.8.2.2  bouyer 
      3  1.8.2.2  bouyer /*-
      4  1.8.2.2  bouyer  * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
      5  1.8.2.2  bouyer  * All rights reserved.
      6  1.8.2.2  bouyer  *
      7  1.8.2.2  bouyer  * This code is derived from software contributed to The NetBSD Foundation
      8  1.8.2.2  bouyer  * by UCHIYAMA Yasushi.
      9  1.8.2.2  bouyer  *
     10  1.8.2.2  bouyer  * Redistribution and use in source and binary forms, with or without
     11  1.8.2.2  bouyer  * modification, are permitted provided that the following conditions
     12  1.8.2.2  bouyer  * are met:
     13  1.8.2.2  bouyer  * 1. Redistributions of source code must retain the above copyright
     14  1.8.2.2  bouyer  *    notice, this list of conditions and the following disclaimer.
     15  1.8.2.2  bouyer  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.8.2.2  bouyer  *    notice, this list of conditions and the following disclaimer in the
     17  1.8.2.2  bouyer  *    documentation and/or other materials provided with the distribution.
     18  1.8.2.2  bouyer  * 3. All advertising materials mentioning features or use of this software
     19  1.8.2.2  bouyer  *    must display the following acknowledgement:
     20  1.8.2.2  bouyer  *        This product includes software developed by the NetBSD
     21  1.8.2.2  bouyer  *        Foundation, Inc. and its contributors.
     22  1.8.2.2  bouyer  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  1.8.2.2  bouyer  *    contributors may be used to endorse or promote products derived
     24  1.8.2.2  bouyer  *    from this software without specific prior written permission.
     25  1.8.2.2  bouyer  *
     26  1.8.2.2  bouyer  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  1.8.2.2  bouyer  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  1.8.2.2  bouyer  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  1.8.2.2  bouyer  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  1.8.2.2  bouyer  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  1.8.2.2  bouyer  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  1.8.2.2  bouyer  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  1.8.2.2  bouyer  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  1.8.2.2  bouyer  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  1.8.2.2  bouyer  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  1.8.2.2  bouyer  * POSSIBILITY OF SUCH DAMAGE.
     37  1.8.2.2  bouyer  */
     38  1.8.2.2  bouyer 
     39  1.8.2.2  bouyer #include "opt_tx39_debug.h"
     40  1.8.2.2  bouyer 
     41  1.8.2.2  bouyer #include <sys/param.h>
     42  1.8.2.2  bouyer #include <sys/kernel.h>
     43  1.8.2.2  bouyer #include <sys/systm.h>
     44  1.8.2.2  bouyer #include <sys/device.h>
     45  1.8.2.2  bouyer 
     46  1.8.2.2  bouyer #include <dev/clock_subr.h>
     47  1.8.2.2  bouyer 
     48  1.8.2.2  bouyer #include <machine/bus.h>
     49  1.8.2.2  bouyer #include <machine/clock_machdep.h>
     50  1.8.2.2  bouyer #include <machine/cpu.h>
     51  1.8.2.2  bouyer 
     52  1.8.2.2  bouyer #include <hpcmips/tx/tx39var.h>
     53  1.8.2.2  bouyer #include <hpcmips/tx/tx39icureg.h>
     54  1.8.2.2  bouyer #include <hpcmips/tx/tx39clockvar.h>
     55  1.8.2.2  bouyer #include <hpcmips/tx/tx39clockreg.h>
     56  1.8.2.2  bouyer #include <hpcmips/tx/tx39timerreg.h>
     57  1.8.2.2  bouyer 
     58  1.8.2.2  bouyer #include <dev/dec/clockvar.h>
     59  1.8.2.2  bouyer 
     60  1.8.2.2  bouyer #ifdef TX39CLKDEBUG
     61  1.8.2.2  bouyer #define	DPRINTF(arg)	printf arg
     62  1.8.2.2  bouyer #else
     63  1.8.2.2  bouyer #define	DPRINTF(arg)	((void)0)
     64  1.8.2.2  bouyer #endif
     65  1.8.2.2  bouyer 
     66  1.8.2.2  bouyer #define ISSETPRINT(r, m) __is_set_print(r, TX39_CLOCK_EN##m##CLK, #m)
     67  1.8.2.2  bouyer 
     68  1.8.2.2  bouyer void	tx39clock_init(struct device *);
     69  1.8.2.2  bouyer void	tx39clock_get(struct device *, time_t, struct clocktime *);
     70  1.8.2.2  bouyer void	tx39clock_set(struct device *, struct clocktime *);
     71  1.8.2.2  bouyer 
     72  1.8.2.2  bouyer const struct clockfns tx39clockfns = {
     73  1.8.2.2  bouyer 	tx39clock_init, tx39clock_get, tx39clock_set,
     74  1.8.2.2  bouyer };
     75  1.8.2.2  bouyer 
     76  1.8.2.2  bouyer struct txtime {
     77  1.8.2.2  bouyer 	u_int32_t t_hi;
     78  1.8.2.2  bouyer 	u_int32_t t_lo;
     79  1.8.2.2  bouyer };
     80  1.8.2.2  bouyer 
     81  1.8.2.2  bouyer struct tx39clock_softc {
     82  1.8.2.2  bouyer 	struct	device sc_dev;
     83  1.8.2.2  bouyer 	tx_chipset_tag_t sc_tc;
     84  1.8.2.2  bouyer 
     85  1.8.2.2  bouyer 	int sc_alarm;
     86  1.8.2.2  bouyer 	int sc_enabled;
     87  1.8.2.2  bouyer 	int sc_year;
     88  1.8.2.2  bouyer 	struct clocktime sc_epoch;
     89  1.8.2.2  bouyer };
     90  1.8.2.2  bouyer 
     91  1.8.2.2  bouyer int	tx39clock_match(struct device *, struct cfdata *, void *);
     92  1.8.2.2  bouyer void	tx39clock_attach(struct device *, struct device *, void *);
     93  1.8.2.2  bouyer void	tx39clock_dump(tx_chipset_tag_t);
     94  1.8.2.2  bouyer 
     95  1.8.2.2  bouyer void	tx39clock_cpuspeed(int *, int *);
     96  1.8.2.2  bouyer 
     97  1.8.2.2  bouyer void	__tx39timer_rtcfreeze(tx_chipset_tag_t);
     98  1.8.2.2  bouyer void	__tx39timer_rtcreset(tx_chipset_tag_t);
     99  1.8.2.2  bouyer __inline__ void	__tx39timer_rtcget(struct txtime *);
    100  1.8.2.2  bouyer __inline__ time_t __tx39timer_rtc2sec(struct txtime *);
    101  1.8.2.2  bouyer 
    102  1.8.2.2  bouyer struct cfattach tx39clock_ca = {
    103  1.8.2.2  bouyer 	sizeof(struct tx39clock_softc), tx39clock_match, tx39clock_attach
    104  1.8.2.2  bouyer };
    105  1.8.2.2  bouyer 
    106  1.8.2.2  bouyer int
    107  1.8.2.2  bouyer tx39clock_match(struct device *parent, struct cfdata *cf, void *aux)
    108  1.8.2.2  bouyer {
    109  1.8.2.2  bouyer 	return ATTACH_FIRST;
    110  1.8.2.2  bouyer }
    111  1.8.2.2  bouyer 
    112  1.8.2.2  bouyer void
    113  1.8.2.2  bouyer tx39clock_attach(struct device *parent, struct device *self, void *aux)
    114  1.8.2.2  bouyer {
    115  1.8.2.2  bouyer 	struct txsim_attach_args *ta = aux;
    116  1.8.2.2  bouyer 	struct tx39clock_softc *sc = (void*)self;
    117  1.8.2.2  bouyer 	tx_chipset_tag_t tc;
    118  1.8.2.2  bouyer 	txreg_t reg;
    119  1.8.2.2  bouyer 
    120  1.8.2.2  bouyer 	tc = sc->sc_tc = ta->ta_tc;
    121  1.8.2.2  bouyer 	tx_conf_register_clock(tc, self);
    122  1.8.2.2  bouyer 
    123  1.8.2.2  bouyer 	/* Reset timer module */
    124  1.8.2.2  bouyer 	tx_conf_write(tc, TX39_TIMERCONTROL_REG, 0);
    125  1.8.2.2  bouyer 
    126  1.8.2.2  bouyer 	/* Enable periodic timer */
    127  1.8.2.2  bouyer 	reg = tx_conf_read(tc, TX39_TIMERCONTROL_REG);
    128  1.8.2.2  bouyer 	reg |= TX39_TIMERCONTROL_ENPERTIMER;
    129  1.8.2.2  bouyer 	tx_conf_write(tc, TX39_TIMERCONTROL_REG, reg);
    130  1.8.2.2  bouyer 
    131  1.8.2.2  bouyer 	sc->sc_enabled = 0;
    132  1.8.2.2  bouyer 	/*
    133  1.8.2.2  bouyer 	 * RTC and ALARM
    134  1.8.2.2  bouyer 	 *    RTCINT    ... INTR5 bit 31  (roll over)
    135  1.8.2.2  bouyer 	 *    ALARMINT  ... INTR5 bit 30
    136  1.8.2.2  bouyer 	 *    PERINT    ... INTR5 bit 29
    137  1.8.2.2  bouyer 	 */
    138  1.8.2.2  bouyer 
    139  1.8.2.2  bouyer 	clockattach(self, &tx39clockfns);
    140  1.8.2.2  bouyer 
    141  1.8.2.2  bouyer #ifdef TX39CLKDEBUG
    142  1.8.2.2  bouyer 	tx39clock_dump(tc);
    143  1.8.2.2  bouyer #endif /* TX39CLKDEBUG */
    144  1.8.2.2  bouyer }
    145  1.8.2.2  bouyer 
    146  1.8.2.2  bouyer /*
    147  1.8.2.2  bouyer  * cpuclock ... CPU clock (Hz)
    148  1.8.2.2  bouyer  * cpuspeed ... instructions-per-microsecond
    149  1.8.2.2  bouyer  */
    150  1.8.2.2  bouyer void
    151  1.8.2.2  bouyer tx39clock_cpuspeed(int *cpuclock, int *cpuspeed)
    152  1.8.2.2  bouyer {
    153  1.8.2.2  bouyer 	struct txtime t0, t1;
    154  1.8.2.2  bouyer 	int elapsed;
    155  1.8.2.2  bouyer 
    156  1.8.2.2  bouyer 	__tx39timer_rtcget(&t0);
    157  1.8.2.2  bouyer 	__asm__ __volatile__("
    158  1.8.2.2  bouyer 		.set	noreorder;
    159  1.8.2.2  bouyer 		li	$8, 10000000;
    160  1.8.2.2  bouyer 	1:	nop;
    161  1.8.2.2  bouyer 		nop;
    162  1.8.2.2  bouyer 		nop;
    163  1.8.2.2  bouyer 		nop;
    164  1.8.2.2  bouyer 		nop;
    165  1.8.2.2  bouyer 		nop;
    166  1.8.2.2  bouyer 		nop;
    167  1.8.2.2  bouyer 		add	$8, $8, -1;
    168  1.8.2.2  bouyer 		bnez	$8, 1b;
    169  1.8.2.2  bouyer 		nop;
    170  1.8.2.2  bouyer 		.set	reorder;
    171  1.8.2.2  bouyer 	");
    172  1.8.2.2  bouyer 	__tx39timer_rtcget(&t1);
    173  1.8.2.2  bouyer 
    174  1.8.2.2  bouyer 	elapsed = t1.t_lo - t0.t_lo;
    175  1.8.2.2  bouyer 
    176  1.8.2.2  bouyer 	*cpuclock = (100000000 / elapsed) * TX39_RTCLOCK;
    177  1.8.2.2  bouyer 	*cpuspeed = *cpuclock / 1000000;
    178  1.8.2.2  bouyer }
    179  1.8.2.2  bouyer 
    180  1.8.2.2  bouyer void
    181  1.8.2.2  bouyer __tx39timer_rtcfreeze(tx_chipset_tag_t tc)
    182  1.8.2.2  bouyer {
    183  1.8.2.2  bouyer 	txreg_t reg;
    184  1.8.2.2  bouyer 
    185  1.8.2.2  bouyer 	reg = tx_conf_read(tc, TX39_TIMERCONTROL_REG);
    186  1.8.2.2  bouyer 
    187  1.8.2.2  bouyer 	/* Freeze RTC */
    188  1.8.2.2  bouyer 	reg |= TX39_TIMERCONTROL_FREEZEPRE; /* Upper 8bit */
    189  1.8.2.2  bouyer 	reg |= TX39_TIMERCONTROL_FREEZERTC; /* Lower 32bit */
    190  1.8.2.2  bouyer 
    191  1.8.2.2  bouyer 	/* Freeze periodic timer */
    192  1.8.2.2  bouyer 	reg |= TX39_TIMERCONTROL_FREEZETIMER;
    193  1.8.2.2  bouyer 	reg &= ~TX39_TIMERCONTROL_ENPERTIMER;
    194  1.8.2.2  bouyer 	tx_conf_write(tc, TX39_TIMERCONTROL_REG, reg);
    195  1.8.2.2  bouyer }
    196  1.8.2.2  bouyer 
    197  1.8.2.2  bouyer __inline__ time_t
    198  1.8.2.2  bouyer __tx39timer_rtc2sec(struct txtime *t)
    199  1.8.2.2  bouyer {
    200  1.8.2.2  bouyer 	/* This rely on RTC is 32.768kHz */
    201  1.8.2.2  bouyer 	return (t->t_lo >> 15) | (t->t_hi << 17);
    202  1.8.2.2  bouyer }
    203  1.8.2.2  bouyer 
    204  1.8.2.2  bouyer __inline__ void
    205  1.8.2.2  bouyer __tx39timer_rtcget(struct txtime *t)
    206  1.8.2.2  bouyer {
    207  1.8.2.2  bouyer 	tx_chipset_tag_t tc;
    208  1.8.2.2  bouyer 	txreg_t reghi, reglo, oreghi, oreglo;
    209  1.8.2.2  bouyer 	int retry;
    210  1.8.2.2  bouyer 
    211  1.8.2.2  bouyer 	tc = tx_conf_get_tag();
    212  1.8.2.2  bouyer 
    213  1.8.2.2  bouyer 	retry = 10;
    214  1.8.2.2  bouyer 
    215  1.8.2.2  bouyer 	do {
    216  1.8.2.2  bouyer 		oreglo = tx_conf_read(tc, TX39_TIMERRTCLO_REG);
    217  1.8.2.2  bouyer 		reglo = tx_conf_read(tc, TX39_TIMERRTCLO_REG);
    218  1.8.2.2  bouyer 
    219  1.8.2.2  bouyer 		oreghi = tx_conf_read(tc, TX39_TIMERRTCHI_REG);
    220  1.8.2.2  bouyer 		reghi = tx_conf_read(tc, TX39_TIMERRTCHI_REG);
    221  1.8.2.2  bouyer 	} while ((reghi != oreghi || reglo != oreglo) && (--retry > 0));
    222  1.8.2.2  bouyer 
    223  1.8.2.2  bouyer 	if (retry < 0) {
    224  1.8.2.2  bouyer 		printf("RTC timer read error.\n");
    225  1.8.2.2  bouyer 	}
    226  1.8.2.2  bouyer 
    227  1.8.2.2  bouyer 	t->t_hi = TX39_TIMERRTCHI(reghi);
    228  1.8.2.2  bouyer 	t->t_lo = reglo;
    229  1.8.2.2  bouyer }
    230  1.8.2.2  bouyer 
    231  1.8.2.2  bouyer void
    232  1.8.2.2  bouyer __tx39timer_rtcreset(tx_chipset_tag_t tc)
    233  1.8.2.2  bouyer {
    234  1.8.2.2  bouyer 	txreg_t reg;
    235  1.8.2.2  bouyer 
    236  1.8.2.2  bouyer 	reg = tx_conf_read(tc, TX39_TIMERCONTROL_REG);
    237  1.8.2.2  bouyer 
    238  1.8.2.2  bouyer 	/* Reset counter and stop */
    239  1.8.2.2  bouyer 	reg |= TX39_TIMERCONTROL_RTCCLR;
    240  1.8.2.2  bouyer 	tx_conf_write(tc, TX39_TIMERCONTROL_REG, reg);
    241  1.8.2.2  bouyer 
    242  1.8.2.2  bouyer 	/* Count again */
    243  1.8.2.2  bouyer 	reg &= ~TX39_TIMERCONTROL_RTCCLR;
    244  1.8.2.2  bouyer 	tx_conf_write(tc, TX39_TIMERCONTROL_REG, reg);
    245  1.8.2.2  bouyer }
    246  1.8.2.2  bouyer 
    247  1.8.2.2  bouyer void
    248  1.8.2.2  bouyer tx39clock_init(struct device *dev)
    249  1.8.2.2  bouyer {
    250  1.8.2.2  bouyer 	struct tx39clock_softc *sc = (void*)dev;
    251  1.8.2.2  bouyer 	tx_chipset_tag_t tc = sc->sc_tc;
    252  1.8.2.2  bouyer 	txreg_t reg;
    253  1.8.2.2  bouyer 	int pcnt;
    254  1.8.2.2  bouyer 
    255  1.8.2.2  bouyer 	/*
    256  1.8.2.2  bouyer 	 * Setup periodic timer (interrupting hz times per second.)
    257  1.8.2.2  bouyer 	 */
    258  1.8.2.2  bouyer 	pcnt = TX39_TIMERCLK / hz - 1;
    259  1.8.2.2  bouyer 	reg = tx_conf_read(tc, TX39_TIMERPERIODIC_REG);
    260  1.8.2.2  bouyer 	TX39_TIMERPERIODIC_PERVAL_CLR(reg);
    261  1.8.2.2  bouyer 	reg = TX39_TIMERPERIODIC_PERVAL_SET(reg, pcnt);
    262  1.8.2.2  bouyer 	tx_conf_write(tc, TX39_TIMERPERIODIC_REG, reg);
    263  1.8.2.2  bouyer 
    264  1.8.2.2  bouyer 	/*
    265  1.8.2.2  bouyer 	 * Enable periodic timer
    266  1.8.2.2  bouyer 	 */
    267  1.8.2.2  bouyer 	reg = tx_conf_read(tc, TX39_INTRENABLE6_REG);
    268  1.8.2.2  bouyer 	reg |= TX39_INTRPRI13_TIMER_PERIODIC_BIT;
    269  1.8.2.2  bouyer 	tx_conf_write(tc, TX39_INTRENABLE6_REG, reg);
    270  1.8.2.2  bouyer 
    271  1.8.2.2  bouyer 	/*
    272  1.8.2.2  bouyer 	 * number of microseconds between interrupts
    273  1.8.2.2  bouyer 	 */
    274  1.8.2.2  bouyer 	tick = 1000000 / hz;
    275  1.8.2.2  bouyer }
    276  1.8.2.2  bouyer 
    277  1.8.2.2  bouyer void
    278  1.8.2.2  bouyer tx39clock_get(struct device *dev, time_t base, struct clocktime *ct)
    279  1.8.2.2  bouyer {
    280  1.8.2.2  bouyer 	struct clock_ymdhms dt;
    281  1.8.2.2  bouyer 	struct tx39clock_softc *sc = (void*)dev;
    282  1.8.2.2  bouyer 	struct txtime tt;
    283  1.8.2.2  bouyer 	time_t sec;
    284  1.8.2.2  bouyer 
    285  1.8.2.2  bouyer 	__tx39timer_rtcget(&tt);
    286  1.8.2.2  bouyer 	sec = __tx39timer_rtc2sec(&tt);
    287  1.8.2.2  bouyer 
    288  1.8.2.2  bouyer 	if (!sc->sc_enabled) {
    289  1.8.2.2  bouyer 		DPRINTF(("bootstrap: %d sec from previous reboot\n",
    290  1.8.2.2  bouyer 			 (int)sec));
    291  1.8.2.2  bouyer 
    292  1.8.2.2  bouyer 		sc->sc_enabled = 1;
    293  1.8.2.2  bouyer 		base += sec;
    294  1.8.2.2  bouyer 	} else {
    295  1.8.2.2  bouyer 		dt.dt_year = sc->sc_year;
    296  1.8.2.2  bouyer 		dt.dt_mon = sc->sc_epoch.mon;
    297  1.8.2.2  bouyer 		dt.dt_day = sc->sc_epoch.day;
    298  1.8.2.2  bouyer 		dt.dt_hour = sc->sc_epoch.hour;
    299  1.8.2.2  bouyer 		dt.dt_min = sc->sc_epoch.min;
    300  1.8.2.2  bouyer 		dt.dt_sec = sc->sc_epoch.sec;
    301  1.8.2.2  bouyer 		dt.dt_wday = sc->sc_epoch.dow;
    302  1.8.2.2  bouyer 		base = sec + clock_ymdhms_to_secs(&dt);
    303  1.8.2.2  bouyer 	}
    304  1.8.2.2  bouyer 
    305  1.8.2.2  bouyer 	clock_secs_to_ymdhms(base, &dt);
    306  1.8.2.2  bouyer 
    307  1.8.2.2  bouyer 	ct->year = dt.dt_year % 100;
    308  1.8.2.2  bouyer 	ct->mon = dt.dt_mon;
    309  1.8.2.2  bouyer 	ct->day = dt.dt_day;
    310  1.8.2.2  bouyer 	ct->hour = dt.dt_hour;
    311  1.8.2.2  bouyer 	ct->min = dt.dt_min;
    312  1.8.2.2  bouyer 	ct->sec = dt.dt_sec;
    313  1.8.2.2  bouyer 	ct->dow = dt.dt_wday;
    314  1.8.2.2  bouyer 
    315  1.8.2.2  bouyer 	sc->sc_year = dt.dt_year;
    316  1.8.2.2  bouyer }
    317  1.8.2.2  bouyer 
    318  1.8.2.2  bouyer void
    319  1.8.2.2  bouyer tx39clock_set(struct device *dev, struct clocktime *ct)
    320  1.8.2.2  bouyer {
    321  1.8.2.2  bouyer 	struct tx39clock_softc *sc = (void*)dev;
    322  1.8.2.2  bouyer 
    323  1.8.2.2  bouyer 	if (sc->sc_enabled) {
    324  1.8.2.2  bouyer 		sc->sc_epoch = *ct;
    325  1.8.2.2  bouyer 	}
    326  1.8.2.2  bouyer }
    327  1.8.2.2  bouyer 
    328  1.8.2.2  bouyer int
    329  1.8.2.2  bouyer tx39clock_alarm_set(tx_chipset_tag_t tc, int msec)
    330  1.8.2.2  bouyer {
    331  1.8.2.2  bouyer 	struct tx39clock_softc *sc = tc->tc_clockt;
    332  1.8.2.2  bouyer 
    333  1.8.2.2  bouyer 	sc->sc_alarm = TX39_MSEC2RTC(msec);
    334  1.8.2.2  bouyer 	tx39clock_alarm_refill(tc);
    335  1.8.2.2  bouyer 
    336  1.8.2.2  bouyer 	return 0;
    337  1.8.2.2  bouyer }
    338  1.8.2.2  bouyer 
    339  1.8.2.2  bouyer void
    340  1.8.2.2  bouyer tx39clock_alarm_refill(tx_chipset_tag_t tc)
    341  1.8.2.2  bouyer {
    342  1.8.2.2  bouyer 	struct tx39clock_softc *sc = tc->tc_clockt;
    343  1.8.2.2  bouyer 	struct txtime t;
    344  1.8.2.2  bouyer 	u_int64_t time;
    345  1.8.2.2  bouyer 
    346  1.8.2.2  bouyer 	__tx39timer_rtcget(&t);
    347  1.8.2.2  bouyer 
    348  1.8.2.2  bouyer 	time = ((u_int64_t)t.t_hi << 32) | (u_int64_t)t.t_lo;
    349  1.8.2.2  bouyer 	time += (u_int64_t)sc->sc_alarm;
    350  1.8.2.2  bouyer 
    351  1.8.2.2  bouyer 	t.t_hi = (u_int32_t)((time >> 32) & TX39_TIMERALARMHI_MASK);
    352  1.8.2.2  bouyer 	t.t_lo = (u_int32_t)(time & 0xffffffff);
    353  1.8.2.2  bouyer 
    354  1.8.2.2  bouyer 	tx_conf_write(tc, TX39_TIMERALARMHI_REG, t.t_hi);
    355  1.8.2.2  bouyer 	tx_conf_write(tc, TX39_TIMERALARMLO_REG, t.t_lo);
    356  1.8.2.2  bouyer }
    357  1.8.2.2  bouyer 
    358  1.8.2.2  bouyer void
    359  1.8.2.2  bouyer tx39clock_dump(tx_chipset_tag_t tc)
    360  1.8.2.2  bouyer {
    361  1.8.2.2  bouyer 	txreg_t reg;
    362  1.8.2.2  bouyer 
    363  1.8.2.2  bouyer 	reg = tx_conf_read(tc, TX39_CLOCKCTRL_REG);
    364  1.8.2.2  bouyer 
    365  1.8.2.2  bouyer 	printf(" ");
    366  1.8.2.2  bouyer 	ISSETPRINT(reg, CHIM);
    367  1.8.2.2  bouyer #ifdef TX391X
    368  1.8.2.2  bouyer 	ISSETPRINT(reg, VID);
    369  1.8.2.2  bouyer 	ISSETPRINT(reg, MBUS);
    370  1.8.2.2  bouyer #endif /* TX391X */
    371  1.8.2.2  bouyer #ifdef TX392X
    372  1.8.2.2  bouyer 	ISSETPRINT(reg, IRDA);
    373  1.8.2.2  bouyer #endif /* TX392X */
    374  1.8.2.2  bouyer 	ISSETPRINT(reg, SPI);
    375  1.8.2.2  bouyer 	ISSETPRINT(reg, TIMER);
    376  1.8.2.2  bouyer 	ISSETPRINT(reg, FASTTIMER);
    377  1.8.2.2  bouyer #ifdef TX392X
    378  1.8.2.2  bouyer 	ISSETPRINT(reg, C48MOUT);
    379  1.8.2.2  bouyer #endif /* TX392X */
    380  1.8.2.2  bouyer 	ISSETPRINT(reg, SIBM);
    381  1.8.2.2  bouyer 	ISSETPRINT(reg, CSER);
    382  1.8.2.2  bouyer 	ISSETPRINT(reg, IR);
    383  1.8.2.2  bouyer 	ISSETPRINT(reg, UARTA);
    384  1.8.2.2  bouyer 	ISSETPRINT(reg, UARTB);
    385  1.8.2.2  bouyer 	printf("\n");
    386  1.8.2.2  bouyer }
    387