1
2
3
4
5
6 struct powernow_k8_data {
7 unsigned int cpu;
8
9 u32 numps;
10 u32 batps;
11
12
13
14
15 u32 rvo;
16 u32 irt;
17 u32 vidmvs;
18 u32 vstable;
19 u32 plllock;
20 u32 exttype;
21
22
23 u32 currvid;
24 u32 currfid;
25
26
27
28
29 struct cpufreq_frequency_table *powernow_table;
30
31
32
33 struct acpi_processor_performance acpi_data;
34
35
36
37
38 struct cpumask *available_cores;
39 };
40
41
42 #define CPUID_PROCESSOR_SIGNATURE 1
43 #define CPUID_XFAM 0x0ff00000
44 #define CPUID_XFAM_K8 0
45 #define CPUID_XMOD 0x000f0000
46 #define CPUID_XMOD_REV_MASK 0x000c0000
47 #define CPUID_XFAM_10H 0x00100000
48 #define CPUID_USE_XFAM_XMOD 0x00000f00
49 #define CPUID_GET_MAX_CAPABILITIES 0x80000000
50 #define CPUID_FREQ_VOLT_CAPABILITIES 0x80000007
51 #define P_STATE_TRANSITION_CAPABLE 6
52
53
54
55
56
57
58 #define MSR_FIDVID_CTL 0xc0010041
59 #define MSR_FIDVID_STATUS 0xc0010042
60
61
62 #define MSR_C_LO_INIT_FID_VID 0x00010000
63 #define MSR_C_LO_NEW_VID 0x00003f00
64 #define MSR_C_LO_NEW_FID 0x0000003f
65 #define MSR_C_LO_VID_SHIFT 8
66
67
68 #define MSR_C_HI_STP_GNT_TO 0x000fffff
69
70
71 #define MSR_S_LO_CHANGE_PENDING 0x80000000
72 #define MSR_S_LO_MAX_RAMP_VID 0x3f000000
73 #define MSR_S_LO_MAX_FID 0x003f0000
74 #define MSR_S_LO_START_FID 0x00003f00
75 #define MSR_S_LO_CURRENT_FID 0x0000003f
76
77
78 #define MSR_S_HI_MIN_WORKING_VID 0x3f000000
79 #define MSR_S_HI_MAX_WORKING_VID 0x003f0000
80 #define MSR_S_HI_START_VID 0x00003f00
81 #define MSR_S_HI_CURRENT_VID 0x0000003f
82 #define MSR_C_HI_STP_GNT_BENIGN 0x00000001
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98 #define LO_FID_TABLE_TOP 7
99 #define HI_FID_TABLE_BOTTOM 8
100
101 #define LO_VCOFREQ_TABLE_TOP 1400
102 #define HI_VCOFREQ_TABLE_BOTTOM 1600
103
104 #define MIN_FREQ_RESOLUTION 200
105
106 #define MAX_FID 0x2a
107 #define LEAST_VID 0x3e
108
109 #define MIN_FREQ 800
110 #define MAX_FREQ 5000
111
112 #define INVALID_FID_MASK 0xffffffc0
113 #define INVALID_VID_MASK 0xffffffc0
114
115 #define VID_OFF 0x3f
116
117 #define STOP_GRANT_5NS 1
118
119 #define PLL_LOCK_CONVERSION (1000/5)
120
121 #define MAXIMUM_VID_STEPS 1
122 #define VST_UNITS_20US 20
123
124
125
126
127
128
129 #define IRT_SHIFT 30
130 #define RVO_SHIFT 28
131 #define EXT_TYPE_SHIFT 27
132 #define PLL_L_SHIFT 20
133 #define MVS_SHIFT 18
134 #define VST_SHIFT 11
135 #define VID_SHIFT 6
136 #define IRT_MASK 3
137 #define RVO_MASK 3
138 #define EXT_TYPE_MASK 1
139 #define PLL_L_MASK 0x7f
140 #define MVS_MASK 3
141 #define VST_MASK 0x7f
142 #define VID_MASK 0x1f
143 #define FID_MASK 0x1f
144 #define EXT_VID_MASK 0x3f
145 #define EXT_FID_MASK 0x3f
146
147
148
149
150
151
152
153
154
155
156 #define PSB_ID_STRING "AMDK7PNOW!"
157 #define PSB_ID_STRING_LEN 10
158
159 #define PSB_VERSION_1_4 0x14
160
161 struct psb_s {
162 u8 signature[10];
163 u8 tableversion;
164 u8 flags1;
165 u16 vstable;
166 u8 flags2;
167 u8 num_tables;
168 u32 cpuid;
169 u8 plllocktime;
170 u8 maxfid;
171 u8 maxvid;
172 u8 numps;
173 };
174
175
176 struct pst_s {
177 u8 fid;
178 u8 vid;
179 };
180
181 static int core_voltage_pre_transition(struct powernow_k8_data *data,
182 u32 reqvid, u32 regfid);
183 static int core_voltage_post_transition(struct powernow_k8_data *data, u32 reqvid);
184 static int core_frequency_transition(struct powernow_k8_data *data, u32 reqfid);
185
186 static void powernow_k8_acpi_pst_values(struct powernow_k8_data *data, unsigned int index);
187
188 static int fill_powernow_table_fidvid(struct powernow_k8_data *data, struct cpufreq_frequency_table *powernow_table);