Rev 582 | Rev 770 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
582 | mauro | 1 | /* |
2 | * Project: S.Ha.R.K. |
||
3 | * |
||
4 | * Coordinators: |
||
5 | * Giorgio Buttazzo <giorgio@sssup.it> |
||
6 | * Paolo Gai <pj@gandalf.sssup.it> |
||
7 | * |
||
8 | * Authors : |
||
9 | * Mauro Marinoni <mauro.marinoni@unipv.it> |
||
10 | * |
||
11 | * |
||
12 | * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
||
13 | * |
||
14 | * http://www.sssup.it |
||
15 | * http://retis.sssup.it |
||
16 | * http://shark.sssup.it |
||
17 | */ |
||
18 | |||
19 | #include <kernel/func.h> |
||
20 | #include "../include/drivers/shark_cpu26.h" |
||
21 | |||
22 | #define __CPU26_DEBUG__ |
||
23 | |||
24 | /* CPU Initialization */ |
||
25 | extern void early_cpu_init(void); |
||
26 | extern void identify_cpu_0(void); |
||
27 | extern void print_cpu_info_0(void); |
||
28 | |||
29 | /* AMD K6 PowerNow */ |
||
30 | extern int powernow_k6_init(void); |
||
31 | extern void powernow_k6_exit(void); |
||
32 | /* AMD K7 PowerNow */ |
||
33 | extern int powernow_init(void); |
||
34 | extern void powernow_exit(void); |
||
35 | /* AMD K8 PowerNow */ |
||
36 | extern int powernowk8_init(void); |
||
37 | extern void powernowk8_exit(void); |
||
38 | /* Cyrix MediaGX - NatSemi Geode */ |
||
39 | extern int cpufreq_gx_init(void); |
||
40 | extern void cpufreq_gx_exit(void); |
||
41 | /* Pentium4 clock modulation/speed scaling */ |
||
42 | extern int cpufreq_p4_init(void); |
||
43 | extern void cpufreq_p4_exit(void); |
||
44 | /* PentiumM/Centrino SpeedStep */ |
||
45 | extern int centrino_init(void); |
||
46 | extern void centrino_exit(void); |
||
47 | /* Pentium ICH SpeedStep */ |
||
48 | extern int speedstep_ich_init(void); |
||
49 | extern void speedstep_ich_exit(void); |
||
50 | /* Pentium SMI SpeedStep */ |
||
51 | /*extern int speedstep_smi_init(void); |
||
52 | extern void speedstep_smi_exit(void);*/ |
||
53 | |||
597 | mauro | 54 | /* DVS function */ |
55 | extern int cpufreq_target(unsigned int target_freq, unsigned int relation); |
||
56 | extern int cpufreq_get_cur_freq(void); |
||
57 | extern int cpufreq_get_min_freq(void); |
||
58 | extern int cpufreq_get_max_freq(void); |
||
59 | extern int cpufreq_get_latency(void); |
||
60 | |||
582 | mauro | 61 | static int cpu_installed = FALSE; |
62 | static int dvs_installed = DVS_NONE; |
||
63 | |||
597 | mauro | 64 | /* DVS user function */ |
65 | int CPU26_set_frequency(unsigned int target_freq, unsigned int relation) |
||
582 | mauro | 66 | { |
597 | mauro | 67 | return cpufreq_target(target_freq, relation); |
582 | mauro | 68 | } |
69 | |||
597 | mauro | 70 | int CPU26_get_cur_frequency() |
582 | mauro | 71 | { |
597 | mauro | 72 | return cpufreq_get_cur_freq(); |
582 | mauro | 73 | } |
74 | |||
597 | mauro | 75 | int CPU26_get_min_frequency() |
582 | mauro | 76 | { |
597 | mauro | 77 | return cpufreq_get_min_freq(); |
78 | } |
||
582 | mauro | 79 | |
597 | mauro | 80 | int CPU26_get_max_frequency() |
81 | { |
||
82 | return cpufreq_get_max_freq(); |
||
582 | mauro | 83 | } |
84 | |||
597 | mauro | 85 | int CPU26_get_latency() |
582 | mauro | 86 | { |
597 | mauro | 87 | return cpufreq_get_latency(); |
582 | mauro | 88 | } |
89 | |||
90 | int CPU26_initDVS(void) |
||
91 | { |
||
92 | int ret = 0; |
||
93 | |||
94 | if (cpu_installed == FALSE) |
||
95 | return -1; |
||
96 | |||
97 | if (dvs_installed != DVS_NONE) |
||
98 | return 0; |
||
99 | |||
100 | ret = powernow_k6_init(); |
||
101 | #ifdef __CPU26_DEBUG__ |
||
102 | printk(KERN_DEBUG "Check PowerNow! K6 - Returned: %d\n", ret); |
||
103 | #endif |
||
104 | if (!ret) { |
||
105 | dvs_installed = DVS_POWERNOW_K6; |
||
106 | return dvs_installed; |
||
107 | } |
||
108 | |||
109 | ret = powernow_init(); |
||
110 | #ifdef __CPU26_DEBUG__ |
||
111 | printk(KERN_DEBUG "Check PowerNow! K7 - Returned: %d\n", ret); |
||
112 | #endif |
||
113 | if (!ret) { |
||
114 | dvs_installed = DVS_POWERNOW_K7; |
||
115 | return dvs_installed; |
||
116 | } |
||
117 | |||
118 | ret = powernowk8_init(); |
||
119 | #ifdef __CPU26_DEBUG__ |
||
120 | printk(KERN_DEBUG "Check PowerNow! K8 - Returned: %d\n", ret); |
||
121 | #endif |
||
122 | if (!ret) { |
||
123 | dvs_installed = DVS_POWERNOW_K8; |
||
124 | return dvs_installed; |
||
125 | } |
||
126 | |||
127 | ret = cpufreq_gx_init(); |
||
128 | #ifdef __CPU26_DEBUG__ |
||
129 | printk(KERN_DEBUG "Check MediaGX/Geode (Returned: %d)\n", ret); |
||
130 | #endif |
||
131 | if (!ret) { |
||
132 | dvs_installed = DVS_MEDIAGX_GEODE; |
||
133 | return dvs_installed; |
||
134 | } |
||
135 | |||
136 | ret = cpufreq_p4_init(); |
||
137 | #ifdef __CPU26_DEBUG__ |
||
138 | printk(KERN_DEBUG "Check Pentium4 ClockModulation (Returned: %d)\n", ret); |
||
139 | #endif |
||
140 | if (!ret) { |
||
141 | dvs_installed = DVS_P4_CLOCK_MOD; |
||
142 | return dvs_installed; |
||
143 | } |
||
144 | |||
145 | ret = centrino_init(); |
||
146 | #ifdef __CPU26_DEBUG__ |
||
147 | printk(KERN_DEBUG "Check SpeedStep Centrino (Returned: %d)\n", ret); |
||
148 | #endif |
||
149 | if (!ret) { |
||
150 | dvs_installed = DVS_SS_CENTRINO; |
||
151 | return dvs_installed; |
||
152 | } |
||
153 | |||
154 | ret = speedstep_ich_init(); |
||
155 | #ifdef __CPU26_DEBUG__ |
||
156 | printk(KERN_DEBUG "Check SpeedStep ICH (Returned: %d)\n", ret); |
||
157 | #endif |
||
158 | if (!ret) { |
||
159 | dvs_installed = DVS_SS_ICH; |
||
160 | return dvs_installed; |
||
161 | } |
||
162 | |||
163 | /*ret = speedstep_smi_init(); |
||
164 | #ifdef __CPU26_DEBUG__ |
||
165 | printk(KERN_DEBUG "Check SpeedStep SMI (Returned: %d)\n", ret); |
||
166 | #endif |
||
167 | if (!ret) { |
||
168 | dvs_installed = DVS_SS_SMI; |
||
169 | return dvs_installed; |
||
170 | }*/ |
||
171 | |||
172 | return -1; |
||
173 | } |
||
174 | |||
175 | int CPU26_closeDVS(void) |
||
176 | { |
||
177 | switch(dvs_installed) { |
||
178 | case DVS_NONE: |
||
179 | return -1; |
||
180 | case DVS_POWERNOW_K6: |
||
181 | powernow_k6_exit(); |
||
182 | return 0; |
||
183 | case DVS_POWERNOW_K7: |
||
184 | powernow_exit(); |
||
185 | return 0; |
||
186 | case DVS_POWERNOW_K8: |
||
187 | powernowk8_exit(); |
||
188 | return 0; |
||
189 | case DVS_MEDIAGX_GEODE: |
||
190 | cpufreq_gx_exit(); |
||
191 | return 0; |
||
192 | case DVS_P4_CLOCK_MOD: |
||
193 | cpufreq_p4_exit(); |
||
194 | return 0; |
||
195 | case DVS_SS_CENTRINO: |
||
196 | centrino_exit(); |
||
197 | return 0; |
||
198 | case DVS_SS_ICH: |
||
199 | speedstep_ich_exit(); |
||
200 | return 0; |
||
201 | /*case DVS_SS_SMI: |
||
202 | speedstep_smi_exit(); |
||
203 | return 0;*/ |
||
204 | } |
||
205 | |||
206 | dvs_installed = DVS_NONE; |
||
207 | return 0; |
||
208 | } |
||
597 | mauro | 209 | |
210 | /* Init the Linux CPU Layer */ |
||
211 | int CPU26_installed(void) |
||
212 | { |
||
213 | return cpu_installed; |
||
214 | } |
||
215 | |||
216 | void CPU26_showinfo(void) |
||
217 | { |
||
218 | print_cpu_info_0(); |
||
219 | } |
||
220 | |||
221 | int CPU26_init(void) |
||
222 | { |
||
223 | int ret = 0; |
||
224 | |||
225 | if (cpu_installed == TRUE) return 0; |
||
226 | |||
227 | early_cpu_init(); |
||
228 | |||
229 | identify_cpu_0(); |
||
230 | |||
231 | printk(KERN_INFO); |
||
232 | print_cpu_info_0(); |
||
233 | |||
234 | cpu_installed = TRUE; |
||
235 | |||
236 | return ret; |
||
237 | } |
||
238 | |||
239 | int CPU26_close(void) |
||
240 | { |
||
241 | if (cpu_installed == TRUE) { |
||
242 | return 0; |
||
243 | } else |
||
244 | return -1; |
||
245 | } |