timerreg.h revision 1.1 1 1.1 uch /* $NetBSD: timerreg.h,v 1.1 2001/10/16 15:38:40 uch Exp $ */
2 1.1 uch
3 1.1 uch /*-
4 1.1 uch * Copyright (c) 2001 The NetBSD Foundation, Inc.
5 1.1 uch * All rights reserved.
6 1.1 uch *
7 1.1 uch * This code is derived from software contributed to The NetBSD Foundation
8 1.1 uch * by UCHIYAMA Yasushi.
9 1.1 uch *
10 1.1 uch * Redistribution and use in source and binary forms, with or without
11 1.1 uch * modification, are permitted provided that the following conditions
12 1.1 uch * are met:
13 1.1 uch * 1. Redistributions of source code must retain the above copyright
14 1.1 uch * notice, this list of conditions and the following disclaimer.
15 1.1 uch * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 uch * notice, this list of conditions and the following disclaimer in the
17 1.1 uch * documentation and/or other materials provided with the distribution.
18 1.1 uch * 3. All advertising materials mentioning features or use of this software
19 1.1 uch * must display the following acknowledgement:
20 1.1 uch * This product includes software developed by the NetBSD
21 1.1 uch * Foundation, Inc. and its contributors.
22 1.1 uch * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.1 uch * contributors may be used to endorse or promote products derived
24 1.1 uch * from this software without specific prior written permission.
25 1.1 uch *
26 1.1 uch * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.1 uch * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.1 uch * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.1 uch * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.1 uch * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.1 uch * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.1 uch * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.1 uch * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.1 uch * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.1 uch * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.1 uch * POSSIBILITY OF SUCH DAMAGE.
37 1.1 uch */
38 1.1 uch
39 1.1 uch /*
40 1.1 uch * 16bit timer 0:3
41 1.1 uch * source: BUSCLK, H-BLNK
42 1.1 uch */
43 1.1 uch
44 1.1 uch #define TIMER_MIN 0
45 1.1 uch #define TIMER_MAX 3
46 1.1 uch #define LEGAL_TIMER(x) \
47 1.1 uch (((x) >= TIMER_MIN) && ((x) <= TIMER_MAX))
48 1.1 uch
49 1.1 uch /* Register address. all registers are 32bit wide */
50 1.1 uch #define TIMER_REGBASE 0x10000000
51 1.1 uch #define TIMER_REGSIZE 0x2000
52 1.1 uch #define TIMER_OFS 0x800
53 1.1 uch
54 1.1 uch #define T_COUNT_REG(x) MIPS_PHYS_TO_KSEG1((TIMER_REGBASE + TIMER_OFS * (x)))
55 1.1 uch #define T_MODE_REG(x) MIPS_PHYS_TO_KSEG1((TIMER_REGBASE + \
56 1.1 uch TIMER_OFS * (x) + 0x10))
57 1.1 uch #define T_COMP_REG(x) MIPS_PHYS_TO_KSEG1((TIMER_REGBASE + \
58 1.1 uch TIMER_OFS * (x) + 0x20))
59 1.1 uch /*
60 1.1 uch * timer0, timer1 have `hold register'.
61 1.1 uch * (save T_COUNT when SBUS interrupt occured)
62 1.1 uch */
63 1.1 uch #define T_HOLD_REG(x) (TIMER_REGBASE + TIMER_OFS * (x) + 0x30)
64 1.1 uch
65 1.1 uch #define T0_COUNT_REG MIPS_PHYS_TO_KSEG1(0x10000000)
66 1.1 uch #define T0_MODE_REG MIPS_PHYS_TO_KSEG1(0x10000010)
67 1.1 uch #define T0_COMP_REG MIPS_PHYS_TO_KSEG1(0x10000020)
68 1.1 uch #define T0_HOLD_REG MIPS_PHYS_TO_KSEG1(0x10000030)
69 1.1 uch #define T1_COUNT_REG MIPS_PHYS_TO_KSEG1(0x10000800)
70 1.1 uch #define T1_MODE_REG MIPS_PHYS_TO_KSEG1(0x10000810)
71 1.1 uch #define T1_COMP_REG MIPS_PHYS_TO_KSEG1(0x10000820)
72 1.1 uch #define T1_HOLD_REG MIPS_PHYS_TO_KSEG1(0x10000830)
73 1.1 uch #define T2_COUNT_REG MIPS_PHYS_TO_KSEG1(0x10001000)
74 1.1 uch #define T2_MODE_REG MIPS_PHYS_TO_KSEG1(0x10001010)
75 1.1 uch #define T2_COMP_REG MIPS_PHYS_TO_KSEG1(0x10001020)
76 1.1 uch #define T3_COUNT_REG MIPS_PHYS_TO_KSEG1(0x10001800)
77 1.1 uch #define T3_MODE_REG MIPS_PHYS_TO_KSEG1(0x10001810)
78 1.1 uch #define T3_COMP_REG MIPS_PHYS_TO_KSEG1(0x10001820)
79 1.1 uch
80 1.1 uch /*
81 1.1 uch * Tn_MODE: mode, status register.
82 1.1 uch */
83 1.1 uch #define T_MODE_CLKS_MASK 0x3
84 1.1 uch #define T_MODE_CLKS(x) ((x) & T_MODE_CLKS_MASK)
85 1.1 uch #define T_MODE_CLKS_CLR(x) ((x) & ~T_MODE_CLKS_MASK)
86 1.1 uch
87 1.1 uch #define T_MODE_CLKS_BUSCLK1 0 /* 150Mhz */
88 1.1 uch #define T_MODE_CLKS_BUSCLK16 1 /* 150 / 16 */
89 1.1 uch #define T_MODE_CLKS_BUSCLK256 2 /* 150 / 256 */
90 1.1 uch #define T_MODE_CLKS_HBLNK 3 /* H-Blank */
91 1.1 uch
92 1.1 uch /* Gate Function Enabled */
93 1.1 uch #define T_MODE_GATE 0x00000004
94 1.1 uch /* Gate Selection */
95 1.1 uch #define T_MODE_GATS_VBLNK 0x00000008
96 1.1 uch /* Gate Mode */
97 1.1 uch #define T_MODE_GATM_MASK 0x3
98 1.1 uch #define T_MODE_GATM_SHIFT 4
99 1.1 uch #define T_MODE_GATM(x) (((x) >> T_MODE_GATM_SHIFT) & T_MODE_GATM_MASK)
100 1.1 uch #define T_MODE_GATM_CLR(x) \
101 1.1 uch ((x) & ~(T_MODE_GATM_MASK << T_MODE_GATM_SHIFT))
102 1.1 uch #define T_MODE_GATM_SET(x, val) \
103 1.1 uch ((x) | (((val) << T_MODE_GATM_SHIFT) & \
104 1.1 uch (T_MODE_GATM_MASK << T_MODE_GATM_SHIFT)))
105 1.1 uch #define T_MODE_GATM_LOW 0x0
106 1.1 uch #define T_MODE_GATM_POSEDGE 0x1
107 1.1 uch #define T_MODE_GATM_NEGEDGE 0x2
108 1.1 uch #define T_MODE_GATM_EDGE 0x3
109 1.1 uch
110 1.1 uch /* Zero Return */
111 1.1 uch #define T_MODE_ZRET 0x00000040
112 1.1 uch /* Count Up Enable */
113 1.1 uch #define T_MODE_CUE 0x00000080
114 1.1 uch /* Compare-Interrupt Enable */
115 1.1 uch #define T_MODE_CMPE 0x00000100
116 1.1 uch /* Overflow-Interrupt Enable */
117 1.1 uch #define T_MODE_OVFE 0x00000200
118 1.1 uch /* Equal Flag (write clear) */
119 1.1 uch #define T_MODE_EQUF 0x00000400
120 1.1 uch /* Overflow Flag (write clear) */
121 1.1 uch #define T_MODE_OVFF 0x00000800
122 1.1 uch
123 1.1 uch /*
124 1.1 uch * Tn_COUNT: counter register
125 1.1 uch */
126 1.1 uch #define T_COUNT_MASK 0x0000ffff
127 1.1 uch #define T_COUNT(x) ((x) & T_COUNT_MASK)
128 1.1 uch
129 1.1 uch /*
130 1.1 uch * Tn_COMP: compare register
131 1.1 uch */
132 1.1 uch #define T_COMP_MASK 0x0000ffff
133 1.1 uch #define T_COMP(x) ((x) & T_COMP_MASK)
134 1.1 uch
135 1.1 uch /*
136 1.1 uch * Tn_HOLD: hold register
137 1.1 uch */
138 1.1 uch #define T_HOLD_MASK 0x0000ffff
139 1.1 uch #define T_HOLD(x) ((x) & T_HOLD_MASK)
140