10 #include <linux/types.h>
11 #include <linux/errno.h>
12 #include <linux/kernel.h>
14 #include <linux/slab.h>
16 #include <linux/wait.h>
19 #include <asm/machdep.h>
21 #include <asm/sections.h>
31 #define DBG(args...) printk(args)
33 #define DBG(args...) do { } while(0)
36 static int smu_supports_new_fans_ops = 1;
52 #define to_smu_fan(c) container_of(c, struct smu_fan_control, ctrl)
71 if (smu_supports_new_fans_ops) {
74 *((
u16 *)(&buffer[2])) = value;
81 buffer[0] = pwm ? 0x10 : 0x00;
82 buffer[1] = 0x01 <<
id;
83 *((
u16 *)&buffer[2 +
id * 2]) =
value;
88 cmd.data_buf = cmd.reply_buf =
buffer;
99 if (cmd.status != 0 && smu_supports_new_fans_ops) {
101 "falling back to old method\n");
102 smu_supports_new_fans_ops = 0;
120 if (value < fct->
min)
122 if (value > fct->
max)
126 return smu_set_fan(fct->
fan_type, fct->
reg, value);
149 .set_value = smu_fan_set,
150 .get_value = smu_fan_get,
151 .get_min = smu_fan_min,
152 .get_max = smu_fan_max,
153 .release = smu_fan_release,
168 fct->
ctrl.ops = &smu_fan_ops;
188 if (!
strcmp(l,
"Rear Fan 0") || !
strcmp(l,
"Rear Fan") ||
190 !
strcmp(l,
"CPU A EXHAUST"))
191 fct->
ctrl.name =
"cpu-rear-fan-0";
192 else if (!
strcmp(l,
"Rear Fan 1") || !
strcmp(l,
"Rear fan 1") ||
193 !
strcmp(l,
"CPU B EXHAUST"))
194 fct->
ctrl.name =
"cpu-rear-fan-1";
195 else if (!
strcmp(l,
"Front Fan 0") || !
strcmp(l,
"Front Fan") ||
197 !
strcmp(l,
"CPU A INTAKE"))
198 fct->
ctrl.name =
"cpu-front-fan-0";
199 else if (!
strcmp(l,
"Front Fan 1") || !
strcmp(l,
"Front fan 1") ||
200 !
strcmp(l,
"CPU B INTAKE"))
201 fct->
ctrl.name =
"cpu-front-fan-1";
202 else if (!
strcmp(l,
"CPU A PUMP"))
203 fct->
ctrl.name =
"cpu-pump-0";
204 else if (!
strcmp(l,
"CPU B PUMP"))
205 fct->
ctrl.name =
"cpu-pump-1";
206 else if (!
strcmp(l,
"Slots Fan") || !
strcmp(l,
"Slots fan") ||
207 !
strcmp(l,
"EXPANSION SLOTS INTAKE"))
208 fct->
ctrl.name =
"slots-fan";
209 else if (!
strcmp(l,
"Drive Bay") || !
strcmp(l,
"Drive bay") ||
210 !
strcmp(l,
"DRIVE BAY A INTAKE"))
211 fct->
ctrl.name =
"drive-bay-fan";
212 else if (!
strcmp(l,
"BACKSIDE"))
213 fct->
ctrl.name =
"backside-fan";
216 if (!
strcmp(l,
"System Fan") || !
strcmp(l,
"System fan"))
217 fct->
ctrl.name =
"system-fan";
218 else if (!
strcmp(l,
"CPU Fan") || !
strcmp(l,
"CPU fan"))
219 fct->
ctrl.name =
"cpu-fan";
220 else if (!
strcmp(l,
"Hard Drive") || !
strcmp(l,
"Hard drive"))
221 fct->
ctrl.name =
"drive-bay-fan";
222 else if (!
strcmp(l,
"HDD Fan"))
223 fct->
ctrl.name =
"hard-drive-fan";
224 else if (!
strcmp(l,
"ODD Fan"))
225 fct->
ctrl.name =
"optical-drive-fan";
257 static int __init smu_controls_init(
void)
277 fct = smu_fan_create(fan, 0);
280 "RPM fan %s\n", fan->name);
283 list_add(&fct->
link, &smu_fans);
296 fct = smu_fan_create(fan, 1);
299 "PWM fan %s\n", fan->name);
302 list_add(&fct->
link, &smu_fans);
310 static void __exit smu_controls_exit(
void)
314 while (!list_empty(&smu_fans)) {