Home | History | Annotate | Line # | Download | only in vr
rtc.c revision 1.30
      1  1.30   tsutsui /*	$NetBSD: rtc.c,v 1.30 2011/03/16 14:43:37 tsutsui Exp $	*/
      2   1.1  takemura 
      3   1.1  takemura /*-
      4   1.1  takemura  * Copyright (c) 1999 Shin Takemura. All rights reserved.
      5   1.1  takemura  * Copyright (c) 1999 SATO Kazumi. All rights reserved.
      6   1.1  takemura  * Copyright (c) 1999 PocketBSD Project. All rights reserved.
      7   1.1  takemura  *
      8   1.1  takemura  * Redistribution and use in source and binary forms, with or without
      9   1.1  takemura  * modification, are permitted provided that the following conditions
     10   1.1  takemura  * are met:
     11   1.1  takemura  * 1. Redistributions of source code must retain the above copyright
     12   1.1  takemura  *    notice, this list of conditions and the following disclaimer.
     13   1.1  takemura  * 2. Redistributions in binary form must reproduce the above copyright
     14   1.1  takemura  *    notice, this list of conditions and the following disclaimer in the
     15   1.1  takemura  *    documentation and/or other materials provided with the distribution.
     16   1.1  takemura  * 3. All advertising materials mentioning features or use of this software
     17   1.1  takemura  *    must display the following acknowledgement:
     18   1.1  takemura  *	This product includes software developed by the PocketBSD project
     19   1.1  takemura  *	and its contributors.
     20   1.1  takemura  * 4. Neither the name of the project nor the names of its contributors
     21   1.1  takemura  *    may be used to endorse or promote products derived from this software
     22   1.1  takemura  *    without specific prior written permission.
     23   1.1  takemura  *
     24   1.1  takemura  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     25   1.1  takemura  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     26   1.1  takemura  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     27   1.1  takemura  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     28   1.1  takemura  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     29   1.1  takemura  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     30   1.1  takemura  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     31   1.1  takemura  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     32   1.1  takemura  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     33   1.1  takemura  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     34   1.1  takemura  * SUCH DAMAGE.
     35   1.1  takemura  *
     36   1.1  takemura  */
     37  1.20     lukem 
     38  1.20     lukem #include <sys/cdefs.h>
     39  1.30   tsutsui __KERNEL_RCSID(0, "$NetBSD: rtc.c,v 1.30 2011/03/16 14:43:37 tsutsui Exp $");
     40   1.1  takemura 
     41   1.5     enami #include "opt_vr41xx.h"
     42   1.5     enami 
     43   1.1  takemura #include <sys/param.h>
     44   1.1  takemura #include <sys/systm.h>
     45  1.24   gdamore #include <sys/timetc.h>
     46  1.25        ad #include <sys/device.h>
     47  1.27   tsutsui #include <sys/cpu.h>
     48   1.1  takemura 
     49   1.8       uch #include <machine/sysconf.h>
     50   1.1  takemura #include <machine/bus.h>
     51   1.8       uch 
     52   1.8       uch #include <dev/clock_subr.h>
     53   1.1  takemura 
     54   1.1  takemura #include <hpcmips/vr/vr.h>
     55   1.5     enami #include <hpcmips/vr/vrcpudef.h>
     56  1.12  takemura #include <hpcmips/vr/vripif.h>
     57  1.14  takemura #include <hpcmips/vr/vripreg.h>
     58   1.1  takemura #include <hpcmips/vr/rtcreg.h>
     59   1.1  takemura 
     60   1.3      sato /*
     61   1.3      sato  * for debugging definitions
     62   1.6    toshii  * 	VRRTCDEBUG	print rtc debugging information
     63   1.3      sato  */
     64   1.4      sato #ifdef VRRTCDEBUG
     65   1.4      sato #ifndef VRRTCDEBUG_CONF
     66   1.4      sato #define VRRTCDEBUG_CONF 0
     67   1.4      sato #endif
     68   1.4      sato int vrrtc_debug = VRRTCDEBUG_CONF;
     69   1.4      sato #define DPRINTF(arg) if (vrrtc_debug) printf arg;
     70   1.4      sato #define DDUMP_REGS(arg) if (vrrtc_debug) vrrtc_dump_regs(arg);
     71   1.4      sato #else /* VRRTCDEBUG */
     72   1.4      sato #define DPRINTF(arg)
     73   1.4      sato #define DDUMP_REGS(arg)
     74   1.4      sato #endif /* VRRTCDEBUG */
     75   1.1  takemura 
     76   1.1  takemura struct vrrtc_softc {
     77   1.1  takemura 	struct device sc_dev;
     78   1.1  takemura 	bus_space_tag_t sc_iot;
     79   1.1  takemura 	bus_space_handle_t sc_ioh;
     80   1.1  takemura 	void *sc_ih;
     81  1.14  takemura #ifndef SINGLE_VRIP_BASE
     82  1.14  takemura 	int sc_rtcint_reg;
     83  1.14  takemura 	int sc_tclk_h_reg, sc_tclk_l_reg;
     84  1.14  takemura 	int sc_tclk_cnt_h_reg, sc_tclk_cnt_l_reg;
     85  1.14  takemura #endif /* SINGLE_VRIP_BASE */
     86  1.24   gdamore 	int64_t sc_epoch;
     87  1.24   gdamore 	struct todr_chip_handle sc_todr;
     88  1.24   gdamore 	struct timecounter sc_tc;
     89   1.1  takemura };
     90   1.1  takemura 
     91  1.30   tsutsui void	vrrtc_init(device_t);
     92  1.26   tsutsui int	vrrtc_get(todr_chip_handle_t, struct timeval *);
     93  1.26   tsutsui int	vrrtc_set(todr_chip_handle_t, struct timeval *);
     94  1.24   gdamore uint32_t vrrtc_get_timecount(struct timecounter *);
     95   1.1  takemura 
     96   1.8       uch struct platform_clock vr_clock = {
     97   1.8       uch #define CLOCK_RATE	128
     98  1.24   gdamore 	CLOCK_RATE, vrrtc_init,
     99   1.1  takemura };
    100   1.1  takemura 
    101   1.7       uch int	vrrtc_match(struct device *, struct cfdata *, void *);
    102   1.7       uch void	vrrtc_attach(struct device *, struct device *, void *);
    103  1.29   tsutsui int	vrrtc_intr(void*, uint32_t, uint32_t);
    104   1.7       uch void	vrrtc_dump_regs(struct vrrtc_softc *);
    105   1.1  takemura 
    106  1.18   thorpej CFATTACH_DECL(vrrtc, sizeof(struct vrrtc_softc),
    107  1.18   thorpej     vrrtc_match, vrrtc_attach, NULL, NULL);
    108   1.1  takemura 
    109   1.8       uch int
    110   1.8       uch vrrtc_match(struct device *parent, struct cfdata *cf, void *aux)
    111   1.1  takemura {
    112   1.7       uch 
    113  1.29   tsutsui 	return 1;
    114   1.1  takemura }
    115   1.1  takemura 
    116  1.14  takemura #ifndef SINGLE_VRIP_BASE
    117  1.14  takemura #define RTCINT_REG_W		(sc->sc_rtcint_reg)
    118  1.14  takemura #define TCLK_H_REG_W		(sc->sc_tclk_h_reg)
    119  1.14  takemura #define TCLK_L_REG_W		(sc->sc_tclk_l_reg)
    120  1.14  takemura #define TCLK_CNT_H_REG_W	(sc->sc_tclk_cnt_h_reg)
    121  1.14  takemura #define TCLK_CNT_L_REG_W	(sc->sc_tclk_cnt_l_reg)
    122  1.14  takemura #endif /* SINGLE_VRIP_BASE */
    123  1.14  takemura 
    124   1.1  takemura void
    125   1.7       uch vrrtc_attach(struct device *parent, struct device *self, void *aux)
    126   1.1  takemura {
    127   1.1  takemura 	struct vrip_attach_args *va = aux;
    128  1.30   tsutsui 	struct vrrtc_softc *sc = device_private(self);
    129  1.24   gdamore 	int year;
    130  1.14  takemura 
    131  1.14  takemura #ifndef SINGLE_VRIP_BASE
    132  1.14  takemura 	if (va->va_addr == VR4102_RTC_ADDR) {
    133  1.14  takemura 		sc->sc_rtcint_reg = VR4102_RTCINT_REG_W;
    134  1.14  takemura 		sc->sc_tclk_h_reg = VR4102_TCLK_H_REG_W;
    135  1.14  takemura 		sc->sc_tclk_l_reg = VR4102_TCLK_L_REG_W;
    136  1.14  takemura 		sc->sc_tclk_cnt_h_reg = VR4102_TCLK_CNT_H_REG_W;
    137  1.14  takemura 		sc->sc_tclk_cnt_l_reg = VR4102_TCLK_CNT_L_REG_W;
    138  1.29   tsutsui 	} else if (va->va_addr == VR4122_RTC_ADDR) {
    139  1.14  takemura 		sc->sc_rtcint_reg = VR4122_RTCINT_REG_W;
    140  1.14  takemura 		sc->sc_tclk_h_reg = VR4122_TCLK_H_REG_W;
    141  1.14  takemura 		sc->sc_tclk_l_reg = VR4122_TCLK_L_REG_W;
    142  1.14  takemura 		sc->sc_tclk_cnt_h_reg = VR4122_TCLK_CNT_H_REG_W;
    143  1.14  takemura 		sc->sc_tclk_cnt_l_reg = VR4122_TCLK_CNT_L_REG_W;
    144  1.29   tsutsui 	} else if (va->va_addr == VR4181_RTC_ADDR) {
    145  1.14  takemura 		sc->sc_rtcint_reg = VR4181_RTCINT_REG_W;
    146  1.14  takemura 		sc->sc_tclk_h_reg = RTC_NO_REG_W;
    147  1.14  takemura 		sc->sc_tclk_l_reg = RTC_NO_REG_W;
    148  1.14  takemura 		sc->sc_tclk_cnt_h_reg = RTC_NO_REG_W;
    149  1.14  takemura 		sc->sc_tclk_cnt_l_reg = RTC_NO_REG_W;
    150  1.14  takemura 	} else {
    151  1.16    provos 		panic("%s: unknown base address 0x%lx",
    152  1.14  takemura 		    sc->sc_dev.dv_xname, va->va_addr);
    153  1.14  takemura 	}
    154  1.14  takemura #endif /* SINGLE_VRIP_BASE */
    155  1.14  takemura 
    156   1.1  takemura 	sc->sc_iot = va->va_iot;
    157   1.1  takemura 	if (bus_space_map(sc->sc_iot, va->va_addr, va->va_size,
    158   1.7       uch 	    0 /* no flags */, &sc->sc_ioh)) {
    159   1.1  takemura 		printf("vrrtc_attach: can't map i/o space\n");
    160   1.1  takemura 		return;
    161   1.1  takemura 	}
    162   1.1  takemura 	/* RTC interrupt handler is directly dispatched from CPU intr */
    163   1.1  takemura 	vr_intr_establish(VR_INTR1, vrrtc_intr, sc);
    164  1.19       wiz 	/* But need to set level 1 interrupt mask register,
    165   1.1  takemura 	 * so regsiter fake interrurpt handler
    166   1.1  takemura 	 */
    167  1.12  takemura 	if (!(sc->sc_ih = vrip_intr_establish(va->va_vc, va->va_unit, 0,
    168   1.7       uch 	    IPL_CLOCK, 0, 0))) {
    169   1.1  takemura 		printf (":can't map interrupt.\n");
    170   1.1  takemura 		return;
    171   1.1  takemura 	}
    172   1.1  takemura 	/*
    173   1.1  takemura 	 *  Rtc is attached to call this routine
    174   1.1  takemura 	 *  before cpu_initclock() calls clock_init().
    175   1.1  takemura 	 *  So we must disable all interrupt for now.
    176   1.1  takemura 	 */
    177   1.1  takemura 	/*
    178   1.1  takemura 	 * Disable all rtc interrupts
    179   1.1  takemura 	 */
    180   1.1  takemura 	/* Disable Elapse compare intr */
    181   1.1  takemura 	bus_space_write_2(sc->sc_iot, sc->sc_ioh, ECMP_H_REG_W, 0);
    182   1.1  takemura 	bus_space_write_2(sc->sc_iot, sc->sc_ioh, ECMP_M_REG_W, 0);
    183   1.1  takemura 	bus_space_write_2(sc->sc_iot, sc->sc_ioh, ECMP_L_REG_W, 0);
    184   1.1  takemura 	/* Disable RTC Long1 intr */
    185   1.1  takemura 	bus_space_write_2(sc->sc_iot, sc->sc_ioh, RTCL1_H_REG_W, 0);
    186   1.1  takemura 	bus_space_write_2(sc->sc_iot, sc->sc_ioh, RTCL1_L_REG_W, 0);
    187   1.1  takemura 	/* Disable RTC Long2 intr */
    188   1.1  takemura 	bus_space_write_2(sc->sc_iot, sc->sc_ioh, RTCL2_H_REG_W, 0);
    189   1.1  takemura 	bus_space_write_2(sc->sc_iot, sc->sc_ioh, RTCL2_L_REG_W, 0);
    190   1.1  takemura 	/* Disable RTC TCLK intr */
    191  1.13      sato 	if (TCLK_H_REG_W != RTC_NO_REG_W) {
    192  1.10      sato 		bus_space_write_2(sc->sc_iot, sc->sc_ioh, TCLK_H_REG_W, 0);
    193  1.10      sato 		bus_space_write_2(sc->sc_iot, sc->sc_ioh, TCLK_L_REG_W, 0);
    194  1.10      sato 	}
    195   1.1  takemura 	/*
    196   1.1  takemura 	 * Clear all rtc intrrupts.
    197   1.1  takemura 	 */
    198   1.1  takemura 	bus_space_write_2(sc->sc_iot, sc->sc_ioh, RTCINT_REG_W, RTCINT_ALL);
    199   1.1  takemura 
    200  1.24   gdamore 	/*
    201  1.24   gdamore 	 * Figure out the epoch, which could be either forward or
    202  1.24   gdamore 	 * backwards in time.  We assume that the start date will always
    203  1.24   gdamore 	 * be on Jan 1.
    204  1.24   gdamore 	 */
    205  1.24   gdamore 	for (year = EPOCHYEAR; year < POSIX_BASE_YEAR; year++) {
    206  1.24   gdamore 		sc->sc_epoch += LEAPYEAR4(year) ? SECYR + SECDAY : SECYR;
    207  1.24   gdamore 	}
    208  1.24   gdamore 	for (year = POSIX_BASE_YEAR; year < EPOCHYEAR; year++) {
    209  1.24   gdamore 		sc->sc_epoch -= LEAPYEAR4(year) ? SECYR + SECDAY : SECYR;
    210  1.24   gdamore 	}
    211  1.24   gdamore 
    212  1.24   gdamore 	/*
    213  1.24   gdamore 	 * Initialize MI todr(9)
    214  1.24   gdamore 	 */
    215  1.24   gdamore 	sc->sc_todr.todr_settime = vrrtc_set;
    216  1.24   gdamore 	sc->sc_todr.todr_gettime = vrrtc_get;
    217  1.24   gdamore 	sc->sc_todr.cookie = sc;
    218  1.24   gdamore 	todr_attach(&sc->sc_todr);
    219  1.24   gdamore 
    220  1.30   tsutsui 	platform_clock_attach(self, &vr_clock);
    221   1.1  takemura }
    222   1.1  takemura 
    223   1.1  takemura int
    224  1.29   tsutsui vrrtc_intr(void *arg, uint32_t pc, uint32_t status)
    225   1.1  takemura {
    226   1.1  takemura 	struct vrrtc_softc *sc = arg;
    227   1.1  takemura 	struct clockframe cf;
    228  1.14  takemura 
    229   1.1  takemura 	bus_space_write_2(sc->sc_iot, sc->sc_ioh, RTCINT_REG_W, RTCINT_ALL);
    230   1.1  takemura 	cf.pc = pc;
    231  1.29   tsutsui 	cf.sr = status;
    232  1.27   tsutsui 	cf.intr = (curcpu()->ci_idepth > 1);
    233   1.1  takemura 	hardclock(&cf);
    234   1.1  takemura 
    235   1.1  takemura 	return 0;
    236   1.1  takemura }
    237   1.1  takemura 
    238   1.1  takemura void
    239  1.30   tsutsui vrrtc_init(device_t self)
    240   1.1  takemura {
    241  1.30   tsutsui 	struct vrrtc_softc *sc = device_private(self);
    242   1.1  takemura 
    243   1.8       uch 	DDUMP_REGS(sc);
    244   1.8       uch 	/*
    245   1.8       uch 	 * Set tick (CLOCK_RATE)
    246   1.8       uch 	 */
    247   1.8       uch 	bus_space_write_2(sc->sc_iot, sc->sc_ioh, RTCL1_H_REG_W, 0);
    248  1.29   tsutsui 	bus_space_write_2(sc->sc_iot, sc->sc_ioh,
    249  1.29   tsutsui 	    RTCL1_L_REG_W, RTCL1_L_HZ / CLOCK_RATE);
    250  1.24   gdamore 
    251  1.24   gdamore 	/*
    252  1.24   gdamore 	 * Initialize timecounter.
    253  1.24   gdamore 	 */
    254  1.24   gdamore 	sc->sc_tc.tc_get_timecount = vrrtc_get_timecount;
    255  1.24   gdamore 	sc->sc_tc.tc_name = "vrrtc";
    256  1.24   gdamore 	sc->sc_tc.tc_counter_mask = 0xffff;
    257  1.24   gdamore 	sc->sc_tc.tc_frequency = ETIME_L_HZ;
    258  1.24   gdamore 	sc->sc_tc.tc_priv = sc;
    259  1.24   gdamore 	sc->sc_tc.tc_quality = 100;
    260  1.24   gdamore 	tc_init(&sc->sc_tc);
    261  1.24   gdamore }
    262  1.24   gdamore 
    263  1.24   gdamore uint32_t
    264  1.24   gdamore vrrtc_get_timecount(struct timecounter *tc)
    265  1.24   gdamore {
    266  1.24   gdamore 	struct vrrtc_softc *sc = (struct vrrtc_softc *)tc->tc_priv;
    267  1.24   gdamore 	bus_space_tag_t iot = sc->sc_iot;
    268  1.24   gdamore 	bus_space_handle_t ioh = sc->sc_ioh;
    269  1.24   gdamore 
    270  1.29   tsutsui 	return bus_space_read_2(iot, ioh, ETIME_L_REG_W);
    271   1.8       uch }
    272   1.1  takemura 
    273  1.24   gdamore int
    274  1.26   tsutsui vrrtc_get(todr_chip_handle_t tch, struct timeval *tvp)
    275   1.8       uch {
    276  1.24   gdamore 	struct vrrtc_softc *sc = (struct vrrtc_softc *)tch->cookie;
    277   1.8       uch 	bus_space_tag_t iot = sc->sc_iot;
    278   1.8       uch 	bus_space_handle_t ioh = sc->sc_ioh;
    279  1.29   tsutsui 	uint32_t timeh;		/* elapse time (2*timeh sec) */
    280  1.29   tsutsui 	uint32_t timel;		/* timel/32768 sec */
    281  1.29   tsutsui 	uint64_t sec, usec;
    282   1.8       uch 
    283   1.8       uch 	timeh = bus_space_read_2(iot, ioh, ETIME_H_REG_W);
    284   1.8       uch 	timeh = (timeh << 16) | bus_space_read_2(iot, ioh, ETIME_M_REG_W);
    285   1.8       uch 	timel = bus_space_read_2(iot, ioh, ETIME_L_REG_W);
    286   1.1  takemura 
    287  1.11      shin 	DPRINTF(("clock_get: timeh %08x timel %08x\n", timeh, timel));
    288   1.1  takemura 
    289  1.24   gdamore 	timeh -= EPOCHOFF;
    290  1.28   tsutsui 	sec = (uint64_t)timeh * 2;
    291  1.24   gdamore 	sec -= sc->sc_epoch;
    292  1.24   gdamore 	tvp->tv_sec = sec;
    293  1.24   gdamore 	tvp->tv_sec += timel / ETIME_L_HZ;
    294  1.24   gdamore 
    295  1.24   gdamore 	/* scale from 32kHz to 1MHz */
    296  1.24   gdamore 	usec = (timel % ETIME_L_HZ);
    297  1.24   gdamore 	usec *= 1000000;
    298  1.24   gdamore 	usec /= ETIME_L_HZ;
    299  1.28   tsutsui 	tvp->tv_usec = usec;
    300   1.1  takemura 
    301  1.24   gdamore 	return 0;
    302   1.4      sato }
    303   1.4      sato 
    304  1.24   gdamore int
    305  1.26   tsutsui vrrtc_set(todr_chip_handle_t tch, struct timeval *tvp)
    306   1.4      sato {
    307  1.24   gdamore 	struct vrrtc_softc *sc = (struct vrrtc_softc *)tch->cookie;
    308   1.8       uch 	bus_space_tag_t iot = sc->sc_iot;
    309   1.8       uch 	bus_space_handle_t ioh = sc->sc_ioh;
    310  1.29   tsutsui 	uint32_t timeh;		/* elapse time (2*timeh sec) */
    311  1.29   tsutsui 	uint32_t timel;		/* timel/32768 sec */
    312  1.24   gdamore 	int64_t sec, cnt;
    313   1.8       uch 
    314  1.24   gdamore 	sec = tvp->tv_sec + sc->sc_epoch;
    315  1.24   gdamore 	sec += sc->sc_epoch;
    316  1.24   gdamore 	timeh = EPOCHOFF + (sec / 2);
    317  1.24   gdamore 	timel = sec % 2;
    318  1.24   gdamore 
    319  1.24   gdamore 	cnt = tvp->tv_usec;
    320  1.24   gdamore 	/* scale from 1MHz to 32kHz */
    321  1.24   gdamore 	cnt *= ETIME_L_HZ;
    322  1.24   gdamore 	cnt /= 1000000;
    323  1.24   gdamore 	timel += (uint32_t)cnt;
    324   1.8       uch 
    325   1.8       uch 	bus_space_write_2(iot, ioh, ETIME_H_REG_W, (timeh >> 16) & 0xffff);
    326   1.8       uch 	bus_space_write_2(iot, ioh, ETIME_M_REG_W, timeh & 0xffff);
    327   1.8       uch 	bus_space_write_2(iot, ioh, ETIME_L_REG_W, timel);
    328   1.1  takemura 
    329  1.24   gdamore 	return 0;
    330   1.1  takemura }
    331   1.1  takemura 
    332   1.1  takemura void
    333   1.8       uch vrrtc_dump_regs(struct vrrtc_softc *sc)
    334   1.1  takemura {
    335   1.8       uch 	int timeh;
    336   1.8       uch 	int timel;
    337   1.1  takemura 
    338   1.1  takemura 	timeh = bus_space_read_2(sc->sc_iot, sc->sc_ioh, ETIME_H_REG_W);
    339   1.8       uch 	timel = bus_space_read_2(sc->sc_iot, sc->sc_ioh, ETIME_M_REG_W);
    340   1.8       uch 	timel = (timel << 16)
    341   1.8       uch 	    | bus_space_read_2(sc->sc_iot, sc->sc_ioh, ETIME_L_REG_W);
    342   1.8       uch 	printf("clock_init()  Elapse Time %04x%04x\n", timeh, timel);
    343   1.1  takemura 
    344   1.8       uch 	timeh = bus_space_read_2(sc->sc_iot, sc->sc_ioh, ECMP_H_REG_W);
    345   1.8       uch 	timel = bus_space_read_2(sc->sc_iot, sc->sc_ioh, ECMP_M_REG_W);
    346   1.8       uch 	timel = (timel << 16)
    347   1.8       uch 	    | bus_space_read_2(sc->sc_iot, sc->sc_ioh, ECMP_L_REG_W);
    348   1.8       uch 	printf("clock_init()  Elapse Compare %04x%04x\n", timeh, timel);
    349   1.1  takemura 
    350   1.8       uch 	timeh = bus_space_read_2(sc->sc_iot, sc->sc_ioh, RTCL1_H_REG_W);
    351   1.8       uch 	timel = bus_space_read_2(sc->sc_iot, sc->sc_ioh, RTCL1_L_REG_W);
    352   1.8       uch 	printf("clock_init()  LONG1 %04x%04x\n", timeh, timel);
    353   1.1  takemura 
    354   1.8       uch 	timeh = bus_space_read_2(sc->sc_iot, sc->sc_ioh, RTCL1_CNT_H_REG_W);
    355   1.8       uch 	timel = bus_space_read_2(sc->sc_iot, sc->sc_ioh, RTCL1_CNT_L_REG_W);
    356   1.8       uch 	printf("clock_init()  LONG1 CNTL %04x%04x\n", timeh, timel);
    357   1.1  takemura 
    358   1.8       uch 	timeh = bus_space_read_2(sc->sc_iot, sc->sc_ioh, RTCL2_H_REG_W);
    359   1.8       uch 	timel = bus_space_read_2(sc->sc_iot, sc->sc_ioh, RTCL2_L_REG_W);
    360   1.8       uch 	printf("clock_init()  LONG2 %04x%04x\n", timeh, timel);
    361   1.1  takemura 
    362   1.8       uch 	timeh = bus_space_read_2(sc->sc_iot, sc->sc_ioh, RTCL2_CNT_H_REG_W);
    363   1.8       uch 	timel = bus_space_read_2(sc->sc_iot, sc->sc_ioh, RTCL2_CNT_L_REG_W);
    364   1.8       uch 	printf("clock_init()  LONG2 CNTL %04x%04x\n", timeh, timel);
    365   1.1  takemura 
    366  1.13      sato 	if (TCLK_H_REG_W != RTC_NO_REG_W) {
    367  1.10      sato 		timeh = bus_space_read_2(sc->sc_iot, sc->sc_ioh, TCLK_H_REG_W);
    368  1.10      sato 		timel = bus_space_read_2(sc->sc_iot, sc->sc_ioh, TCLK_L_REG_W);
    369  1.10      sato 		printf("clock_init()  TCLK %04x%04x\n", timeh, timel);
    370  1.10      sato 
    371  1.29   tsutsui 		timeh = bus_space_read_2(sc->sc_iot, sc->sc_ioh,
    372  1.29   tsutsui 		    TCLK_CNT_H_REG_W);
    373  1.29   tsutsui 		timel = bus_space_read_2(sc->sc_iot, sc->sc_ioh,
    374  1.29   tsutsui 		    TCLK_CNT_L_REG_W);
    375  1.10      sato 		printf("clock_init()  TCLK CNTL %04x%04x\n", timeh, timel);
    376  1.10      sato 	}
    377   1.1  takemura }
    378