9 #include <linux/reboot.h>
11 #include <linux/slab.h>
13 #include <asm/oplib.h>
70 { 100, 85, 80, 5, -5, -10 },
71 { 100, 85, 80, 5, -5, -10 },
75 { 65, 55, 40, 5, -5, -10 },
76 { 65, 55, 40, 5, -5, -10 },
82 #define CPU_FAN_REG 0xf0
83 #define SYS_FAN_REG 0xf2
84 #define PSUPPLY_FAN_REG 0xf4
86 #define FAN_SPEED_MIN 0x0c
87 #define FAN_SPEED_MAX 0x3f
89 #define PSUPPLY_FAN_ON 0x1f
90 #define PSUPPLY_FAN_OFF 0x00
106 printk(
"fan%d: Changed fan speed to cpu(%02x) sys(%02x)\n",
130 printk(
"temp%d: cpu(%d C) amb(%d C)\n",
139 static int shutting_down = 0;
143 if (shutting_down != 0)
157 "operating temperature, %d C.\n",
158 tp->
index, type, val);
167 #define WARN_INTERVAL (30 * HZ)
177 "Above safe ambient operating temperature, %d C.\n",
183 "Below safe ambient operating temperature, %d C.\n",
196 do_envctrl_shutdown(tp);
202 }
else if ((tick & (8 - 1)) == 0) {
206 amb_goal_lo = amb_goal_hi - 3;
232 "Above safe CPU operating temperature, %d C.\n",
238 "Below safe CPU operating temperature, %d C.\n",
251 do_envctrl_shutdown(tp);
257 }
else if ((tick & (8 - 1)) == 0) {
261 cpu_goal_lo = cpu_goal_hi - 3;
284 analyze_ambient_temp(tp, last_warn, tp->
sample_tick);
290 static enum fan_action prioritize_fan_action(
int which_fan)
394 new = maybe_new_ambient_fan_speed(fp);
395 new |= maybe_new_cpu_fan_speed(fp);
401 static void fans_full_blast(
void)
416 #define POLL_INTERVAL (5 * 1000)
417 static unsigned long last_warning_jiffies;
420 static int kenvctrld(
void *
__unused)
433 get_current_temps(tp);
434 analyze_temps(tp, &last_warning_jiffies);
437 maybe_new_fan_speeds(fp);
462 tp->
index = temp_idx;
483 get_current_temps(tp);
532 static void destroy_all_temps(
struct bbc_i2c_bus *bp)
539 destroy_one_temp(tp);
549 static void destroy_all_fans(
struct bbc_i2c_bus *bp)
568 if (!
strcmp(op->
dev.of_node->name,
"temperature"))
569 attach_one_temp(bp, op, temp_index++);
570 if (!
strcmp(op->
dev.of_node->name,
"fan-control"))
571 attach_one_fan(bp, op, fan_index++);
573 if (temp_index != 0 && fan_index != 0) {
575 if (IS_ERR(kenvctrld_task)) {
576 int err = PTR_ERR(kenvctrld_task);
578 kenvctrld_task =
NULL;
579 destroy_all_temps(bp);
580 destroy_all_fans(bp);
593 destroy_all_temps(bp);
594 destroy_all_fans(bp);