geodereg.h revision 1.6.6.2 1 1.6.6.2 tron /* $NetBSD: geodereg.h,v 1.6.6.2 2006/05/20 12:25:40 tron Exp $ */
2 1.6.6.2 tron
3 1.6.6.2 tron /*-
4 1.6.6.2 tron * Copyright (c) 2005 David Young. All rights reserved.
5 1.6.6.2 tron *
6 1.6.6.2 tron * This code was written by David Young.
7 1.6.6.2 tron *
8 1.6.6.2 tron * Redistribution and use in source and binary forms, with or without
9 1.6.6.2 tron * modification, are permitted provided that the following conditions
10 1.6.6.2 tron * are met:
11 1.6.6.2 tron * 1. Redistributions of source code must retain the above copyright
12 1.6.6.2 tron * notice, this list of conditions and the following disclaimer.
13 1.6.6.2 tron * 2. Redistributions in binary form must reproduce the above copyright
14 1.6.6.2 tron * notice, this list of conditions and the following disclaimer in the
15 1.6.6.2 tron * documentation and/or other materials provided with the distribution.
16 1.6.6.2 tron * 3. All advertising materials mentioning features or use of this software
17 1.6.6.2 tron * must display the following acknowledgement:
18 1.6.6.2 tron * This product includes software developed by David Young.
19 1.6.6.2 tron * 4. The name of David Young may not be used to endorse or promote
20 1.6.6.2 tron * products derived from this software without specific prior
21 1.6.6.2 tron * written permission.
22 1.6.6.2 tron *
23 1.6.6.2 tron * THIS SOFTWARE IS PROVIDED BY DAVID YOUNG ``AS IS'' AND ANY
24 1.6.6.2 tron * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
25 1.6.6.2 tron * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
26 1.6.6.2 tron * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DAVID
27 1.6.6.2 tron * YOUNG BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28 1.6.6.2 tron * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
29 1.6.6.2 tron * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 1.6.6.2 tron * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31 1.6.6.2 tron * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32 1.6.6.2 tron * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 1.6.6.2 tron * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
34 1.6.6.2 tron * OF SUCH DAMAGE.
35 1.6.6.2 tron */
36 1.6.6.2 tron
37 1.6.6.2 tron /*
38 1.6.6.2 tron * Register definitions for the AMD Geode SC1100.
39 1.6.6.2 tron */
40 1.6.6.2 tron
41 1.6.6.2 tron #ifndef _I386_PCI_GEODEREG_H_
42 1.6.6.2 tron #define _I386_PCI_GEODEREG_H_
43 1.6.6.2 tron
44 1.6.6.2 tron /* Macros for bit twiddling. */
45 1.6.6.2 tron
46 1.6.6.2 tron #ifndef _BIT_TWIDDLE
47 1.6.6.2 tron #define _BIT_TWIDDLE
48 1.6.6.2 tron /* nth bit, BIT(0) == 0x1. */
49 1.6.6.2 tron #define BIT(n) (((n) == 32) ? 0 : ((u_int32_t) 1 << (n)))
50 1.6.6.2 tron
51 1.6.6.2 tron /* bits m through n, m < n. */
52 1.6.6.2 tron #define BITS(m, n) ((BIT(MAX((m), (n)) + 1) - 1) ^ (BIT(MIN((m), (n))) - 1))
53 1.6.6.2 tron
54 1.6.6.2 tron /* find least significant bit that is set */
55 1.6.6.2 tron #define LOWEST_SET_BIT(x) ((((x) - 1) & (x)) ^ (x))
56 1.6.6.2 tron
57 1.6.6.2 tron /* for x a power of two and p a non-negative integer, is x a greater power than 2**p? */
58 1.6.6.2 tron #define GTEQ_POWER(x, p) (((u_long)(x) >> (p)) != 0)
59 1.6.6.2 tron
60 1.6.6.2 tron #define MASK_TO_SHIFT2(m) (GTEQ_POWER(LOWEST_SET_BIT((m)), 1) ? 1 : 0)
61 1.6.6.2 tron
62 1.6.6.2 tron #define MASK_TO_SHIFT4(m) \
63 1.6.6.2 tron (GTEQ_POWER(LOWEST_SET_BIT((m)), 2) \
64 1.6.6.2 tron ? 2 + MASK_TO_SHIFT2((m) >> 2) \
65 1.6.6.2 tron : MASK_TO_SHIFT2((m)))
66 1.6.6.2 tron
67 1.6.6.2 tron #define MASK_TO_SHIFT8(m) \
68 1.6.6.2 tron (GTEQ_POWER(LOWEST_SET_BIT((m)), 4) \
69 1.6.6.2 tron ? 4 + MASK_TO_SHIFT4((m) >> 4) \
70 1.6.6.2 tron : MASK_TO_SHIFT4((m)))
71 1.6.6.2 tron
72 1.6.6.2 tron #define MASK_TO_SHIFT16(m) \
73 1.6.6.2 tron (GTEQ_POWER(LOWEST_SET_BIT((m)), 8) \
74 1.6.6.2 tron ? 8 + MASK_TO_SHIFT8((m) >> 8) \
75 1.6.6.2 tron : MASK_TO_SHIFT8((m)))
76 1.6.6.2 tron
77 1.6.6.2 tron #define MASK_TO_SHIFT(m) \
78 1.6.6.2 tron (GTEQ_POWER(LOWEST_SET_BIT((m)), 16) \
79 1.6.6.2 tron ? 16 + MASK_TO_SHIFT16((m) >> 16) \
80 1.6.6.2 tron : MASK_TO_SHIFT16((m)))
81 1.6.6.2 tron
82 1.6.6.2 tron #define MASK_AND_RSHIFT(x, mask) (((x) & (mask)) >> MASK_TO_SHIFT(mask))
83 1.6.6.2 tron #define LSHIFT(x, mask) ((x) << MASK_TO_SHIFT(mask))
84 1.6.6.2 tron #define MASK_AND_REPLACE(reg, val, mask) ((reg & ~mask) | LSHIFT(val, mask))
85 1.6.6.2 tron #define PRESHIFT(m) MASK_AND_RSHIFT((m), (m))
86 1.6.6.2 tron
87 1.6.6.2 tron #endif /* _BIT_TWIDDLE */
88 1.6.6.2 tron
89 1.6.6.2 tron /* AMD Geode SC1100 X-Bus PCI Configuration Register: General
90 1.6.6.2 tron * Configuration Block Scratchpad. Set to 0x00000000 after chip reset.
91 1.6.6.2 tron * The BIOS writes the base address of the General Configuration
92 1.6.6.2 tron * Block to this register.
93 1.6.6.2 tron */
94 1.6.6.2 tron #define SC1100_XBUS_CBA_SCRATCHPAD 0x64
95 1.6.6.2 tron
96 1.6.6.2 tron #define SC1100_GCB_SIZE 64
97 1.6.6.2 tron
98 1.6.6.2 tron /* watchdog timeout register, 16 bits. */
99 1.6.6.2 tron #define SC1100_GCB_WDTO 0x00
100 1.6.6.2 tron
101 1.6.6.2 tron /* Watchdog configuration register, 16 bits. */
102 1.6.6.2 tron #define SC1100_GCB_WDCNFG 0x02
103 1.6.6.2 tron #define SC1100_WDCNFG_RESERVED BITS(15,9) /* write as read */
104 1.6.6.2 tron
105 1.6.6.2 tron /* 32kHz clock power-down, 0: clock is enabled, 1: clock is disabled. */
106 1.6.6.2 tron #define SC1100_WDCNFG_WD32KPD BIT(8)
107 1.6.6.2 tron
108 1.6.6.2 tron /* Watchdog event type 1, and type 2
109 1.6.6.2 tron *
110 1.6.6.2 tron * 00: no action (default after POR# is asserted)
111 1.6.6.2 tron * 01: interrupt
112 1.6.6.2 tron * 10: SMI
113 1.6.6.2 tron * 11: system reset
114 1.6.6.2 tron */
115 1.6.6.2 tron #define SC1100_WDCNFG_WDTYPE2_MASK BITS(7,6)
116 1.6.6.2 tron #define SC1100_WDCNFG_WDTYPE1_MASK BITS(5,4)
117 1.6.6.2 tron
118 1.6.6.2 tron #define SC1100_WDCNFG_WDTYPE2_NOACTION LSHIFT(0, SC1100_WDCNFG_WDTYPE2_MASK)
119 1.6.6.2 tron #define SC1100_WDCNFG_WDTYPE2_INTERRUPT LSHIFT(1, SC1100_WDCNFG_WDTYPE2_MASK)
120 1.6.6.2 tron #define SC1100_WDCNFG_WDTYPE2_SMI LSHIFT(2, SC1100_WDCNFG_WDTYPE2_MASK)
121 1.6.6.2 tron #define SC1100_WDCNFG_WDTYPE2_RESET LSHIFT(3, SC1100_WDCNFG_WDTYPE2_MASK)
122 1.6.6.2 tron
123 1.6.6.2 tron #define SC1100_WDCNFG_WDTYPE1_NOACTION LSHIFT(0, SC1100_WDCNFG_WDTYPE1_MASK)
124 1.6.6.2 tron #define SC1100_WDCNFG_WDTYPE1_INTERRUPT LSHIFT(1, SC1100_WDCNFG_WDTYPE1_MASK)
125 1.6.6.2 tron #define SC1100_WDCNFG_WDTYPE1_SMI LSHIFT(2, SC1100_WDCNFG_WDTYPE1_MASK)
126 1.6.6.2 tron #define SC1100_WDCNFG_WDTYPE1_RESET LSHIFT(3, SC1100_WDCNFG_WDTYPE1_MASK)
127 1.6.6.2 tron
128 1.6.6.2 tron /* Watchdog timer prescaler
129 1.6.6.2 tron *
130 1.6.6.2 tron * The prescaler divisor is 2**WDPRES. 1110 (0xe) and 1111 (0xf) are
131 1.6.6.2 tron * reserved values.
132 1.6.6.2 tron */
133 1.6.6.2 tron #define SC1100_WDCNFG_WDPRES_MASK BITS(3,0)
134 1.6.6.2 tron #define SC1100_WDCNFG_WDPRES_MAX 0xd
135 1.6.6.2 tron
136 1.6.6.2 tron /* Watchdog status register, 8 bits. */
137 1.6.6.2 tron #define SC1100_GCB_WDSTS 0x04
138 1.6.6.2 tron #define SC1100_WDSTS_RESERVED BIT(7,4) /* write as read */
139 1.6.6.2 tron /* Set to 1 when watchdog reset is asserted. Read-only. Reset either by
140 1.6.6.2 tron * POR# (power-on reset) or by writing writing 0 to WDOVF.
141 1.6.6.2 tron */
142 1.6.6.2 tron #define SC1100_WDSTS_WDRST BIT(3)
143 1.6.6.2 tron /* Set to 1 when watchdog SMI is asserted. Read-only. Reset either by
144 1.6.6.2 tron * POR# (power-on reset) or by writing writing 0 to WDOVF.
145 1.6.6.2 tron */
146 1.6.6.2 tron #define SC1100_WDSTS_WDSMI BIT(2)
147 1.6.6.2 tron /* Set to 1 when watchdog interrupt is asserted. Read-only. Reset either by
148 1.6.6.2 tron * POR# (power-on reset) or by writing writing 0 to WDOVF.
149 1.6.6.2 tron */
150 1.6.6.2 tron #define SC1100_WDSTS_WDINT BIT(1)
151 1.6.6.2 tron /* Set to 1 when watchdog overflow is asserted. Reset either by
152 1.6.6.2 tron * POR# (power-on reset) or by writing writing 1 to this bit.
153 1.6.6.2 tron */
154 1.6.6.2 tron #define SC1100_WDSTS_WDOVF BIT(0)
155 1.6.6.2 tron
156 1.6.6.2 tron /*
157 1.6.6.2 tron * Helpful constants
158 1.6.6.2 tron */
159 1.6.6.2 tron
160 1.6.6.2 tron /* maximum watchdog interval in seconds */
161 1.6.6.2 tron #define SC1100_WDIVL_MAX ((1 << SC1100_WDCNFG_WDPRES_MAX) * \
162 1.6.6.2 tron UINT16_MAX / SC1100_WDCLK_HZ)
163 1.6.6.2 tron /* watchdog clock rate in Hertz */
164 1.6.6.2 tron #define SC1100_WDCLK_HZ 32000
165 1.6.6.2 tron
166 1.6.6.2 tron #endif /* _I386_PCI_GEODEREG_H_ */
167