NetBSD/sys/arch/hpcmips/tx/tx39timerreg.h

131 lines
4.5 KiB
C
Raw Normal View History

2000-09-28 20:18:26 +04:00
/* $NetBSD: tx39timerreg.h,v 1.4 2000/09/28 16:18:26 uch Exp $ */
1999-11-20 22:56:31 +03:00
2000-09-28 20:18:26 +04:00
/*-
* Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
1999-11-20 22:56:31 +03:00
* All rights reserved.
*
2000-09-28 20:18:26 +04:00
* This code is derived from software contributed to The NetBSD Foundation
* by UCHIYAMA Yasushi.
*
1999-11-20 22:56:31 +03:00
* 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.
2000-09-28 20:18:26 +04:00
* 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.
1999-11-20 22:56:31 +03:00
*
2000-09-28 20:18:26 +04:00
* 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.
1999-11-20 22:56:31 +03:00
*/
2000-09-28 20:18:26 +04:00
1999-11-20 22:56:31 +03:00
/*
* Toshiba TX3912/3922 Timer module
*/
2000-09-28 20:18:26 +04:00
#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
1999-11-20 22:56:31 +03:00
/* Periodic timer (1.15MHz) */
#ifdef TX391X
/*
* TX3912 base clock is 36.864MHz
*/
2000-09-28 20:18:26 +04:00
#define TX39_TIMERCLK 1152000
#endif
#ifdef TX392X
/*
* TX3922 base clock seems to be 32.25MHz (Telios)
*/
2000-09-28 20:18:26 +04:00
#define TX39_TIMERCLK 1007812
#endif
/* Real timer clock (32.768kHz) */
2000-09-28 20:18:26 +04:00
#define TX39_RTCLOCK 32768
#define TX39_MSEC2RTC(m) ((TX39_RTCLOCK * (m)) / 1000)
1999-11-20 22:56:31 +03:00
/*
* RTC Register High/Low
*/
/* R */
2000-09-28 20:18:26 +04:00
#define TX39_TIMERRTCHI_SHIFT 0
1999-11-20 22:56:31 +03:00
#ifdef TX391X
2000-09-28 20:18:26 +04:00
#define TX39_TIMERRTCHI_MASK 0xff
1999-11-20 22:56:31 +03:00
#endif /* TX391X */
#ifdef TX392X
2000-09-28 20:18:26 +04:00
#define TX39_TIMERRTCHI_MASK 0x7ff
1999-11-20 22:56:31 +03:00
#endif /* TX392X */
2000-09-28 20:18:26 +04:00
#define TX39_TIMERRTCHI(cr) ((cr) & TX39_TIMERRTCHI_MASK)
1999-11-20 22:56:31 +03:00
/*
* Alarm Register High/Low
*/
/* R/W */
2000-09-28 20:18:26 +04:00
#ifdef TX391X /* 40bit */
#define TX39_TIMERALARMHI_SHIFT 0
#define TX39_TIMERALARMHI_MASK 0xff
1999-11-20 22:56:31 +03:00
#endif /* TX391X */
2000-09-28 20:18:26 +04:00
#ifdef TX392X /* 43bit */
#define TX39_TIMERALARMHI_SHIFT 0
#define TX39_TIMERALARMHI_MASK 0x7ff
1999-11-20 22:56:31 +03:00
#endif /* TX392X */
2000-09-28 20:18:26 +04:00
#define TX39_TIMERALARMHI(cr) ((cr) & TX39_TIMERALARMHI_MASK)
1999-11-20 22:56:31 +03:00
/*
* Timer Control Register
*/
#define TX39_TIMERCONTROL_FREEZEPRE 0x00000080
#define TX39_TIMERCONTROL_FREEZERTC 0x00000040
#define TX39_TIMERCONTROL_FREEZETIMER 0x00000020
#define TX39_TIMERCONTROL_ENPERTIMER 0x00000010
#define TX39_TIMERCONTROL_RTCCLR 0x00000008
1999-11-20 22:56:31 +03:00
#define TX39_TIMERCONTROL_TESTCMS 0x00000004 /* Don't set */
#define TX39_TIMERCONTROL_ENTESTCLK 0x00000002 /* Don't set */
1999-11-20 22:56:31 +03:00
#define TX39_TIMERCONTROL_ENRTCTST 0x00000001
/*
* Periodic Timer Register
*/
/* R */
#define TX39_TIMERPERIODIC_PERCNT_SHIFT 15
#define TX39_TIMERPERIODIC_PERCNT_MASK 0xffff
2000-09-28 20:18:26 +04:00
#define TX39_TIMERPERIODIC_PERCNT(cr) \
(((cr) >> TX39_TIMERPERIODIC_PERCNT_SHIFT) & \
1999-11-20 22:56:31 +03:00
TX39_TIMERPERIODIC_PERCNT_MASK)
/* R/W */
#define TX39_TIMERPERIODIC_PERVAL_SHIFT 0
#define TX39_TIMERPERIODIC_PERVAL_MASK 0xffff
2000-09-28 20:18:26 +04:00
#define TX39_TIMERPERIODIC_PERVAL(cr) \
(((cr) >> TX39_TIMERPERIODIC_PERVAL_SHIFT) & \
1999-11-20 22:56:31 +03:00
TX39_TIMERPERIODIC_PERVAL_MASK)
2000-09-28 20:18:26 +04:00
#define TX39_TIMERPERIODIC_PERVAL_SET(cr, val) \
((cr) | (((val) << TX39_TIMERPERIODIC_PERVAL_SHIFT) & \
1999-11-20 22:56:31 +03:00
(TX39_TIMERPERIODIC_PERVAL_MASK << TX39_TIMERPERIODIC_PERVAL_SHIFT)))
2000-09-28 20:18:26 +04:00
#define TX39_TIMERPERIODIC_PERVAL_CLR(cr) ((cr) &= \
~(TX39_TIMERPERIODIC_PERVAL_MASK << TX39_TIMERPERIODIC_PERVAL_SHIFT))
2000-09-28 20:18:26 +04:00
#define TX39_TIMERPERIODIC_INTRRATE(val) \
((val) + 1)/TX39_TIMERCLK /* unit:Hz */