1 1.7 pooka /* $NetBSD: timerreg.h,v 1.8 2014/03/31 11:25:49 martin 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 * 19 1.1 uch * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 1.1 uch * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 1.1 uch * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 1.1 uch * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 1.1 uch * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 1.1 uch * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 1.1 uch * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 1.1 uch * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 1.1 uch * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 1.1 uch * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 1.1 uch * POSSIBILITY OF SUCH DAMAGE. 30 1.1 uch */ 31 1.1 uch 32 1.1 uch /* 33 1.1 uch * 16bit timer 0:3 34 1.1 uch * source: BUSCLK, H-BLNK 35 1.1 uch */ 36 1.1 uch 37 1.2 shin #define EE_TIMER_MIN 0 38 1.2 shin #define EE_TIMER_MAX 3 39 1.1 uch #define LEGAL_TIMER(x) \ 40 1.2 shin (((x) >= EE_TIMER_MIN) && ((x) <= EE_TIMER_MAX)) 41 1.1 uch 42 1.1 uch /* Register address. all registers are 32bit wide */ 43 1.1 uch #define TIMER_REGBASE 0x10000000 44 1.1 uch #define TIMER_REGSIZE 0x2000 45 1.1 uch #define TIMER_OFS 0x800 46 1.1 uch 47 1.1 uch #define T_COUNT_REG(x) MIPS_PHYS_TO_KSEG1((TIMER_REGBASE + TIMER_OFS * (x))) 48 1.1 uch #define T_MODE_REG(x) MIPS_PHYS_TO_KSEG1((TIMER_REGBASE + \ 49 1.1 uch TIMER_OFS * (x) + 0x10)) 50 1.1 uch #define T_COMP_REG(x) MIPS_PHYS_TO_KSEG1((TIMER_REGBASE + \ 51 1.1 uch TIMER_OFS * (x) + 0x20)) 52 1.1 uch /* 53 1.1 uch * timer0, timer1 have `hold register'. 54 1.3 wiz * (save T_COUNT when SBUS interrupt occurred) 55 1.1 uch */ 56 1.1 uch #define T_HOLD_REG(x) (TIMER_REGBASE + TIMER_OFS * (x) + 0x30) 57 1.1 uch 58 1.1 uch #define T0_COUNT_REG MIPS_PHYS_TO_KSEG1(0x10000000) 59 1.1 uch #define T0_MODE_REG MIPS_PHYS_TO_KSEG1(0x10000010) 60 1.1 uch #define T0_COMP_REG MIPS_PHYS_TO_KSEG1(0x10000020) 61 1.1 uch #define T0_HOLD_REG MIPS_PHYS_TO_KSEG1(0x10000030) 62 1.1 uch #define T1_COUNT_REG MIPS_PHYS_TO_KSEG1(0x10000800) 63 1.1 uch #define T1_MODE_REG MIPS_PHYS_TO_KSEG1(0x10000810) 64 1.1 uch #define T1_COMP_REG MIPS_PHYS_TO_KSEG1(0x10000820) 65 1.1 uch #define T1_HOLD_REG MIPS_PHYS_TO_KSEG1(0x10000830) 66 1.1 uch #define T2_COUNT_REG MIPS_PHYS_TO_KSEG1(0x10001000) 67 1.1 uch #define T2_MODE_REG MIPS_PHYS_TO_KSEG1(0x10001010) 68 1.1 uch #define T2_COMP_REG MIPS_PHYS_TO_KSEG1(0x10001020) 69 1.1 uch #define T3_COUNT_REG MIPS_PHYS_TO_KSEG1(0x10001800) 70 1.1 uch #define T3_MODE_REG MIPS_PHYS_TO_KSEG1(0x10001810) 71 1.1 uch #define T3_COMP_REG MIPS_PHYS_TO_KSEG1(0x10001820) 72 1.1 uch 73 1.1 uch /* 74 1.1 uch * Tn_MODE: mode, status register. 75 1.1 uch */ 76 1.1 uch #define T_MODE_CLKS_MASK 0x3 77 1.1 uch #define T_MODE_CLKS(x) ((x) & T_MODE_CLKS_MASK) 78 1.1 uch #define T_MODE_CLKS_CLR(x) ((x) & ~T_MODE_CLKS_MASK) 79 1.1 uch 80 1.5 lukem #define T_MODE_CLKS_BUSCLK1 0 /* 150 MHz */ 81 1.1 uch #define T_MODE_CLKS_BUSCLK16 1 /* 150 / 16 */ 82 1.1 uch #define T_MODE_CLKS_BUSCLK256 2 /* 150 / 256 */ 83 1.1 uch #define T_MODE_CLKS_HBLNK 3 /* H-Blank */ 84 1.1 uch 85 1.1 uch /* Gate Function Enabled */ 86 1.1 uch #define T_MODE_GATE 0x00000004 87 1.1 uch /* Gate Selection */ 88 1.1 uch #define T_MODE_GATS_VBLNK 0x00000008 89 1.1 uch /* Gate Mode */ 90 1.1 uch #define T_MODE_GATM_MASK 0x3 91 1.1 uch #define T_MODE_GATM_SHIFT 4 92 1.1 uch #define T_MODE_GATM(x) (((x) >> T_MODE_GATM_SHIFT) & T_MODE_GATM_MASK) 93 1.1 uch #define T_MODE_GATM_CLR(x) \ 94 1.1 uch ((x) & ~(T_MODE_GATM_MASK << T_MODE_GATM_SHIFT)) 95 1.1 uch #define T_MODE_GATM_SET(x, val) \ 96 1.1 uch ((x) | (((val) << T_MODE_GATM_SHIFT) & \ 97 1.1 uch (T_MODE_GATM_MASK << T_MODE_GATM_SHIFT))) 98 1.1 uch #define T_MODE_GATM_LOW 0x0 99 1.1 uch #define T_MODE_GATM_POSEDGE 0x1 100 1.1 uch #define T_MODE_GATM_NEGEDGE 0x2 101 1.1 uch #define T_MODE_GATM_EDGE 0x3 102 1.1 uch 103 1.1 uch /* Zero Return */ 104 1.1 uch #define T_MODE_ZRET 0x00000040 105 1.1 uch /* Count Up Enable */ 106 1.1 uch #define T_MODE_CUE 0x00000080 107 1.1 uch /* Compare-Interrupt Enable */ 108 1.1 uch #define T_MODE_CMPE 0x00000100 109 1.1 uch /* Overflow-Interrupt Enable */ 110 1.1 uch #define T_MODE_OVFE 0x00000200 111 1.1 uch /* Equal Flag (write clear) */ 112 1.1 uch #define T_MODE_EQUF 0x00000400 113 1.1 uch /* Overflow Flag (write clear) */ 114 1.1 uch #define T_MODE_OVFF 0x00000800 115 1.1 uch 116 1.1 uch /* 117 1.1 uch * Tn_COUNT: counter register 118 1.1 uch */ 119 1.1 uch #define T_COUNT_MASK 0x0000ffff 120 1.1 uch #define T_COUNT(x) ((x) & T_COUNT_MASK) 121 1.1 uch 122 1.1 uch /* 123 1.1 uch * Tn_COMP: compare register 124 1.1 uch */ 125 1.1 uch #define T_COMP_MASK 0x0000ffff 126 1.1 uch #define T_COMP(x) ((x) & T_COMP_MASK) 127 1.1 uch 128 1.1 uch /* 129 1.1 uch * Tn_HOLD: hold register 130 1.1 uch */ 131 1.1 uch #define T_HOLD_MASK 0x0000ffff 132 1.1 uch #define T_HOLD(x) ((x) & T_HOLD_MASK) 133