Remove building with NOCRYPTO option
[minix.git] / sys / arch / x86 / include / powernow.h
blob8282789b63b738faf820735d6e6b62f704a1d5ed
1 /* $NetBSD: powernow.h,v 1.13 2011/02/24 10:56:02 jruoho Exp $ */
3 /*-
4 * Copyright (c) 2004 Martin VĂ©giard.
5 * All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 /*-
31 * Copyright (c) 2004-2005 Bruno Ducrot
32 * Copyright (c) 2004 FUKUDA Nobuhiko <nfukuda@spa.is.uec.ac.jp>
34 * Redistribution and use in source and binary forms, with or without
35 * modification, are permitted provided that the following conditions
36 * are met:
37 * 1. Redistributions of source code must retain the above copyright
38 * notice, this list of conditions and the following disclaimer.
39 * 2. Redistributions in binary form must reproduce the above copyright
40 * notice, this list of conditions and the following disclaimer in the
41 * documentation and/or other materials provided with the distribution.
43 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
44 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
45 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
46 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
47 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
48 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
49 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
50 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
51 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
52 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
55 #ifndef _X86_POWERNOW_H
56 #define _X86_POWERNOW_H
58 #ifdef POWERNOW_DEBUG
59 #define DPRINTF(x) do { printf x; } while (0)
60 #else
61 #define DPRINTF(x)
62 #endif
64 #define BIOS_START 0xe0000
65 #define BIOS_LEN 0x20000
66 #define BIOS_STEP 16
69 * MSRs and bits used by Powernow technology
71 #define MSR_AMDK7_FIDVID_CTL 0xc0010041
72 #define MSR_AMDK7_FIDVID_STATUS 0xc0010042
73 #define AMD_PN_FID_VID 0x06
74 #define AMD_ERRATA_A0_CPUSIG 0x660
76 #define PN7_FLAG_ERRATA_A0 0x01
77 #define PN7_FLAG_DESKTOP_VRM 0x02
79 /* Bitfields used by K7 */
80 #define PN7_PSB_VERSION 0x12
81 #define PN7_CTR_FID(x) ((x) & 0x1f)
82 #define PN7_CTR_VID(x) (((x) & 0x1f) << 8)
83 #define PN7_CTR_FIDC 0x00010000
84 #define PN7_CTR_VIDC 0x00020000
85 #define PN7_CTR_FIDCHRATIO 0x00100000
86 #define PN7_CTR_SGTC(x) (((uint64_t)(x) & 0x000fffff) << 32)
88 #define PN7_STA_CFID(x) ((x) & 0x1f)
89 #define PN7_STA_SFID(x) (((x) >> 8) & 0x1f)
90 #define PN7_STA_MFID(x) (((x) >> 16) & 0x1f)
91 #define PN7_STA_CVID(x) (((x) >> 32) & 0x1f)
92 #define PN7_STA_SVID(x) (((x) >> 40) & 0x1f)
93 #define PN7_STA_MVID(x) (((x) >> 48) & 0x1f)
95 /* Bitfields used by K8 */
96 #define PN8_CTR_FID(x) ((x) & 0x3f)
97 #define PN8_CTR_VID(x) (((x) & 0x1f) << 8)
98 #define PN8_CTR_PENDING(x) (((x) & 1) << 32)
100 #define PN8_STA_CFID(x) ((x) & 0x3f)
101 #define PN8_STA_SFID(x) (((x) >> 8) & 0x3f)
102 #define PN8_STA_MFID(x) (((x) >> 16) & 0x3f)
103 #define PN8_STA_PENDING(x) (((x) >> 31) & 0x01)
104 #define PN8_STA_CVID(x) (((x) >> 32) & 0x1f)
105 #define PN8_STA_SVID(x) (((x) >> 40) & 0x1f)
106 #define PN8_STA_MVID(x) (((x) >> 48) & 0x1f)
108 #define COUNT_OFF_IRT(irt) DELAY(10 * (1 << (irt)))
109 #define COUNT_OFF_VST(vst) DELAY(20 * (vst))
111 #define FID_TO_VCO_FID(fid) \
112 (((fid) < 8) ? (8 + ((fid) << 1)) : (fid))
114 /* Reserved1 to powernow k8 configuration */
115 #define PN8_PSB_TO_RVO(x) ((x) & 0x03)
116 #define PN8_PSB_TO_IRT(x) (((x) >> 2) & 0x03)
117 #define PN8_PSB_TO_MVS(x) (((x) >> 4) & 0x03)
118 #define PN8_PSB_TO_BATT(x) (((x) >> 6) & 0x03)
120 #define POWERNOW_MAX_STATES 16
122 struct powernow_state {
123 int freq;
124 uint8_t fid;
125 uint8_t vid;
128 struct powernow_cpu_state {
129 struct powernow_state state_table[POWERNOW_MAX_STATES];
130 unsigned int fsb;
131 unsigned int n_states;
132 unsigned int sgtc;
133 unsigned int vst;
134 unsigned int mvs;
135 unsigned int pll;
136 unsigned int rvo;
137 unsigned int irt;
138 int low;
141 struct powernow_psb_s {
142 char signature[10]; /* AMDK7PNOW! */
143 uint8_t version;
144 uint8_t flags;
145 uint16_t ttime; /* Min settling time */
146 uint8_t reserved;
147 uint8_t n_pst;
150 struct powernow_pst_s {
151 uint32_t signature;
152 uint8_t pll;
153 uint8_t fid;
154 uint8_t vid;
155 uint8_t n_states;
158 #endif /* !_X86_POWERNOW_H */