Rev 597 | Go to most recent revision | Details | 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 | |||
54 | static int cpu_installed = FALSE; |
||
55 | static int dvs_installed = DVS_NONE; |
||
56 | |||
57 | /* Init the Linux CPU Layer */ |
||
58 | int CPU26_installed(void) |
||
59 | { |
||
60 | return cpu_installed; |
||
61 | } |
||
62 | |||
63 | void CPU26_showinfo(void) |
||
64 | { |
||
65 | print_cpu_info_0(); |
||
66 | } |
||
67 | |||
68 | int CPU26_init(void) |
||
69 | { |
||
70 | int ret = 0; |
||
71 | |||
72 | if (cpu_installed == TRUE) return 0; |
||
73 | |||
74 | early_cpu_init(); |
||
75 | |||
76 | identify_cpu_0(); |
||
77 | |||
78 | printk(KERN_INFO); |
||
79 | print_cpu_info_0(); |
||
80 | |||
81 | cpu_installed = TRUE; |
||
82 | |||
83 | return ret; |
||
84 | } |
||
85 | |||
86 | int CPU26_close(void) |
||
87 | { |
||
88 | if (cpu_installed == TRUE) { |
||
89 | return 0; |
||
90 | } else |
||
91 | return -1; |
||
92 | } |
||
93 | |||
94 | int CPU26_initDVS(void) |
||
95 | { |
||
96 | int ret = 0; |
||
97 | |||
98 | if (cpu_installed == FALSE) |
||
99 | return -1; |
||
100 | |||
101 | if (dvs_installed != DVS_NONE) |
||
102 | return 0; |
||
103 | |||
104 | ret = powernow_k6_init(); |
||
105 | #ifdef __CPU26_DEBUG__ |
||
106 | printk(KERN_DEBUG "Check PowerNow! K6 - Returned: %d\n", ret); |
||
107 | #endif |
||
108 | if (!ret) { |
||
109 | dvs_installed = DVS_POWERNOW_K6; |
||
110 | return dvs_installed; |
||
111 | } |
||
112 | |||
113 | ret = powernow_init(); |
||
114 | #ifdef __CPU26_DEBUG__ |
||
115 | printk(KERN_DEBUG "Check PowerNow! K7 - Returned: %d\n", ret); |
||
116 | #endif |
||
117 | if (!ret) { |
||
118 | dvs_installed = DVS_POWERNOW_K7; |
||
119 | return dvs_installed; |
||
120 | } |
||
121 | |||
122 | ret = powernowk8_init(); |
||
123 | #ifdef __CPU26_DEBUG__ |
||
124 | printk(KERN_DEBUG "Check PowerNow! K8 - Returned: %d\n", ret); |
||
125 | #endif |
||
126 | if (!ret) { |
||
127 | dvs_installed = DVS_POWERNOW_K8; |
||
128 | return dvs_installed; |
||
129 | } |
||
130 | |||
131 | ret = cpufreq_gx_init(); |
||
132 | #ifdef __CPU26_DEBUG__ |
||
133 | printk(KERN_DEBUG "Check MediaGX/Geode (Returned: %d)\n", ret); |
||
134 | #endif |
||
135 | if (!ret) { |
||
136 | dvs_installed = DVS_MEDIAGX_GEODE; |
||
137 | return dvs_installed; |
||
138 | } |
||
139 | |||
140 | ret = cpufreq_p4_init(); |
||
141 | #ifdef __CPU26_DEBUG__ |
||
142 | printk(KERN_DEBUG "Check Pentium4 ClockModulation (Returned: %d)\n", ret); |
||
143 | #endif |
||
144 | if (!ret) { |
||
145 | dvs_installed = DVS_P4_CLOCK_MOD; |
||
146 | return dvs_installed; |
||
147 | } |
||
148 | |||
149 | ret = centrino_init(); |
||
150 | #ifdef __CPU26_DEBUG__ |
||
151 | printk(KERN_DEBUG "Check SpeedStep Centrino (Returned: %d)\n", ret); |
||
152 | #endif |
||
153 | if (!ret) { |
||
154 | dvs_installed = DVS_SS_CENTRINO; |
||
155 | return dvs_installed; |
||
156 | } |
||
157 | |||
158 | ret = speedstep_ich_init(); |
||
159 | #ifdef __CPU26_DEBUG__ |
||
160 | printk(KERN_DEBUG "Check SpeedStep ICH (Returned: %d)\n", ret); |
||
161 | #endif |
||
162 | if (!ret) { |
||
163 | dvs_installed = DVS_SS_ICH; |
||
164 | return dvs_installed; |
||
165 | } |
||
166 | |||
167 | /*ret = speedstep_smi_init(); |
||
168 | #ifdef __CPU26_DEBUG__ |
||
169 | printk(KERN_DEBUG "Check SpeedStep SMI (Returned: %d)\n", ret); |
||
170 | #endif |
||
171 | if (!ret) { |
||
172 | dvs_installed = DVS_SS_SMI; |
||
173 | return dvs_installed; |
||
174 | }*/ |
||
175 | |||
176 | return -1; |
||
177 | } |
||
178 | |||
179 | int CPU26_closeDVS(void) |
||
180 | { |
||
181 | switch(dvs_installed) { |
||
182 | case DVS_NONE: |
||
183 | return -1; |
||
184 | case DVS_POWERNOW_K6: |
||
185 | powernow_k6_exit(); |
||
186 | return 0; |
||
187 | case DVS_POWERNOW_K7: |
||
188 | powernow_exit(); |
||
189 | return 0; |
||
190 | case DVS_POWERNOW_K8: |
||
191 | powernowk8_exit(); |
||
192 | return 0; |
||
193 | case DVS_MEDIAGX_GEODE: |
||
194 | cpufreq_gx_exit(); |
||
195 | return 0; |
||
196 | case DVS_P4_CLOCK_MOD: |
||
197 | cpufreq_p4_exit(); |
||
198 | return 0; |
||
199 | case DVS_SS_CENTRINO: |
||
200 | centrino_exit(); |
||
201 | return 0; |
||
202 | case DVS_SS_ICH: |
||
203 | speedstep_ich_exit(); |
||
204 | return 0; |
||
205 | /*case DVS_SS_SMI: |
||
206 | speedstep_smi_exit(); |
||
207 | return 0;*/ |
||
208 | } |
||
209 | |||
210 | dvs_installed = DVS_NONE; |
||
211 | return 0; |
||
212 | } |