Lines Matching +full:ambient +full:- +full:celsius

1 // SPDX-License-Identifier: GPL-2.0
2 /* bbc_envctrl.c: UltraSPARC-III environment control driver.
26 /* Two temperature sensors exist in the SunBLADE-1000 enclosure.
29 * for the ambient temperature.
31 * The max1617 is capable of being programmed with power-off
33 * can be controlled independently for the cpu or ambient temperature.
44 * disabled/enabled when entering/exiting the lowest power-saving
59 * before the hardware based power-off event is triggered.
62 /* These settings are in Celsius. We use these defaults only
63 * if we cannot interrogate the cpu-fru SEEPROM.
71 { 100, 85, 80, 5, -5, -10 },
72 { 100, 85, 80, 5, -5, -10 },
76 { 65, 55, 40, 5, -5, -10 },
77 { 65, 55, 40, 5, -5, -10 },
95 /* Put temperatures into range so we don't mis-program in set_fan_speeds()
98 if (fp->cpu_fan_speed < FAN_SPEED_MIN) in set_fan_speeds()
99 fp->cpu_fan_speed = FAN_SPEED_MIN; in set_fan_speeds()
100 if (fp->cpu_fan_speed > FAN_SPEED_MAX) in set_fan_speeds()
101 fp->cpu_fan_speed = FAN_SPEED_MAX; in set_fan_speeds()
102 if (fp->system_fan_speed < FAN_SPEED_MIN) in set_fan_speeds()
103 fp->system_fan_speed = FAN_SPEED_MIN; in set_fan_speeds()
104 if (fp->system_fan_speed > FAN_SPEED_MAX) in set_fan_speeds()
105 fp->system_fan_speed = FAN_SPEED_MAX; in set_fan_speeds()
108 fp->index, in set_fan_speeds()
109 fp->cpu_fan_speed, fp->system_fan_speed); in set_fan_speeds()
112 bbc_i2c_writeb(fp->client, fp->cpu_fan_speed, CPU_FAN_REG); in set_fan_speeds()
113 bbc_i2c_writeb(fp->client, fp->system_fan_speed, SYS_FAN_REG); in set_fan_speeds()
114 bbc_i2c_writeb(fp->client, in set_fan_speeds()
115 (fp->psupply_fan_on ? in set_fan_speeds()
122 tp->prev_amb_temp = tp->curr_amb_temp; in get_current_temps()
123 bbc_i2c_readb(tp->client, in get_current_temps()
124 (unsigned char *) &tp->curr_amb_temp, in get_current_temps()
126 tp->prev_cpu_temp = tp->curr_cpu_temp; in get_current_temps()
127 bbc_i2c_readb(tp->client, in get_current_temps()
128 (unsigned char *) &tp->curr_cpu_temp, in get_current_temps()
132 tp->index, in get_current_temps()
133 (int) tp->curr_cpu_temp, (int) tp->curr_amb_temp); in get_current_temps()
142 s8 val = -1; in do_envctrl_shutdown()
147 if (tp->curr_amb_temp >= amb_temp_limits[tp->index].high_shutdown || in do_envctrl_shutdown()
148 tp->curr_amb_temp < amb_temp_limits[tp->index].low_shutdown) { in do_envctrl_shutdown()
149 type = "ambient"; in do_envctrl_shutdown()
150 val = tp->curr_amb_temp; in do_envctrl_shutdown()
151 } else if (tp->curr_cpu_temp >= cpu_temp_limits[tp->index].high_shutdown || in do_envctrl_shutdown()
152 tp->curr_cpu_temp < cpu_temp_limits[tp->index].low_shutdown) { in do_envctrl_shutdown()
154 val = tp->curr_cpu_temp; in do_envctrl_shutdown()
159 tp->index, type, val); in do_envctrl_shutdown()
174 if (tp->curr_amb_temp >= in analyze_ambient_temp()
175 amb_temp_limits[tp->index].high_warn) { in analyze_ambient_temp()
177 "Above safe ambient operating temperature, %d C.\n", in analyze_ambient_temp()
178 tp->index, (int) tp->curr_amb_temp); in analyze_ambient_temp()
180 } else if (tp->curr_amb_temp < in analyze_ambient_temp()
181 amb_temp_limits[tp->index].low_warn) { in analyze_ambient_temp()
183 "Below safe ambient operating temperature, %d C.\n", in analyze_ambient_temp()
184 tp->index, (int) tp->curr_amb_temp); in analyze_ambient_temp()
189 } else if (tp->curr_amb_temp >= amb_temp_limits[tp->index].high_warn || in analyze_ambient_temp()
190 tp->curr_amb_temp < amb_temp_limits[tp->index].low_warn) in analyze_ambient_temp()
194 if (tp->curr_amb_temp >= amb_temp_limits[tp->index].high_shutdown || in analyze_ambient_temp()
195 tp->curr_amb_temp < amb_temp_limits[tp->index].low_shutdown) { in analyze_ambient_temp()
201 tp->fan_todo[FAN_AMBIENT] = FAN_FULLBLAST; in analyze_ambient_temp()
202 } else if ((tick & (8 - 1)) == 0) { in analyze_ambient_temp()
203 s8 amb_goal_hi = amb_temp_limits[tp->index].high_warn - 10; in analyze_ambient_temp()
206 amb_goal_lo = amb_goal_hi - 3; in analyze_ambient_temp()
209 * only try to deal with over-heating and fan noise reduction. in analyze_ambient_temp()
211 if (tp->avg_amb_temp < amb_goal_hi) { in analyze_ambient_temp()
212 if (tp->avg_amb_temp >= amb_goal_lo) in analyze_ambient_temp()
213 tp->fan_todo[FAN_AMBIENT] = FAN_SAME; in analyze_ambient_temp()
215 tp->fan_todo[FAN_AMBIENT] = FAN_SLOWER; in analyze_ambient_temp()
217 tp->fan_todo[FAN_AMBIENT] = FAN_FASTER; in analyze_ambient_temp()
220 tp->fan_todo[FAN_AMBIENT] = FAN_SAME; in analyze_ambient_temp()
229 if (tp->curr_cpu_temp >= in analyze_cpu_temp()
230 cpu_temp_limits[tp->index].high_warn) { in analyze_cpu_temp()
233 tp->index, (int) tp->curr_cpu_temp); in analyze_cpu_temp()
235 } else if (tp->curr_cpu_temp < in analyze_cpu_temp()
236 cpu_temp_limits[tp->index].low_warn) { in analyze_cpu_temp()
239 tp->index, (int) tp->curr_cpu_temp); in analyze_cpu_temp()
244 } else if (tp->curr_cpu_temp >= cpu_temp_limits[tp->index].high_warn || in analyze_cpu_temp()
245 tp->curr_cpu_temp < cpu_temp_limits[tp->index].low_warn) in analyze_cpu_temp()
249 if (tp->curr_cpu_temp >= cpu_temp_limits[tp->index].high_shutdown || in analyze_cpu_temp()
250 tp->curr_cpu_temp < cpu_temp_limits[tp->index].low_shutdown) { in analyze_cpu_temp()
256 tp->fan_todo[FAN_CPU] = FAN_FULLBLAST; in analyze_cpu_temp()
257 } else if ((tick & (8 - 1)) == 0) { in analyze_cpu_temp()
258 s8 cpu_goal_hi = cpu_temp_limits[tp->index].high_warn - 10; in analyze_cpu_temp()
261 cpu_goal_lo = cpu_goal_hi - 3; in analyze_cpu_temp()
264 * only try to deal with over-heating and fan noise reduction. in analyze_cpu_temp()
266 if (tp->avg_cpu_temp < cpu_goal_hi) { in analyze_cpu_temp()
267 if (tp->avg_cpu_temp >= cpu_goal_lo) in analyze_cpu_temp()
268 tp->fan_todo[FAN_CPU] = FAN_SAME; in analyze_cpu_temp()
270 tp->fan_todo[FAN_CPU] = FAN_SLOWER; in analyze_cpu_temp()
272 tp->fan_todo[FAN_CPU] = FAN_FASTER; in analyze_cpu_temp()
275 tp->fan_todo[FAN_CPU] = FAN_SAME; in analyze_cpu_temp()
281 tp->avg_amb_temp = (s8)((int)((int)tp->avg_amb_temp + (int)tp->curr_amb_temp) / 2); in analyze_temps()
282 tp->avg_cpu_temp = (s8)((int)((int)tp->avg_cpu_temp + (int)tp->curr_cpu_temp) / 2); in analyze_temps()
284 analyze_ambient_temp(tp, last_warn, tp->sample_tick); in analyze_temps()
285 analyze_cpu_temp(tp, last_warn, tp->sample_tick); in analyze_temps()
287 tp->sample_tick++; in analyze_temps()
300 if (tp->fan_todo[which_fan] == FAN_FULLBLAST) { in prioritize_fan_action()
304 if (tp->fan_todo[which_fan] == FAN_SAME && in prioritize_fan_action()
307 else if (tp->fan_todo[which_fan] == FAN_FASTER) in prioritize_fan_action()
311 tp->fan_todo[which_fan] == FAN_SLOWER) in prioritize_fan_action()
330 if (fp->system_fan_speed >= FAN_SPEED_MAX) in maybe_new_ambient_fan_speed()
333 fp->system_fan_speed = FAN_SPEED_MAX; in maybe_new_ambient_fan_speed()
336 if (fp->system_fan_speed >= FAN_SPEED_MAX) in maybe_new_ambient_fan_speed()
339 fp->system_fan_speed += 2; in maybe_new_ambient_fan_speed()
341 int orig_speed = fp->system_fan_speed; in maybe_new_ambient_fan_speed()
344 orig_speed <= (fp->cpu_fan_speed - 3)) in maybe_new_ambient_fan_speed()
347 fp->system_fan_speed -= 1; in maybe_new_ambient_fan_speed()
364 if (fp->cpu_fan_speed >= FAN_SPEED_MAX) in maybe_new_cpu_fan_speed()
367 fp->cpu_fan_speed = FAN_SPEED_MAX; in maybe_new_cpu_fan_speed()
370 if (fp->cpu_fan_speed >= FAN_SPEED_MAX) in maybe_new_cpu_fan_speed()
373 fp->cpu_fan_speed += 2; in maybe_new_cpu_fan_speed()
374 if (fp->system_fan_speed < in maybe_new_cpu_fan_speed()
375 (fp->cpu_fan_speed - 3)) in maybe_new_cpu_fan_speed()
376 fp->system_fan_speed = in maybe_new_cpu_fan_speed()
377 fp->cpu_fan_speed - 3; in maybe_new_cpu_fan_speed()
380 if (fp->cpu_fan_speed <= FAN_SPEED_MIN) in maybe_new_cpu_fan_speed()
383 fp->cpu_fan_speed -= 1; in maybe_new_cpu_fan_speed()
409 fp->cpu_fan_speed = FAN_SPEED_MAX; in fans_full_blast()
410 fp->system_fan_speed = FAN_SPEED_MAX; in fans_full_blast()
411 fp->psupply_fan_on = 1; in fans_full_blast()
423 last_warning_jiffies = jiffies - WARN_INTERVAL; in kenvctrld()
455 INIT_LIST_HEAD(&tp->bp_list); in attach_one_temp()
456 INIT_LIST_HEAD(&tp->glob_list); in attach_one_temp()
458 tp->client = bbc_i2c_attach(bp, op); in attach_one_temp()
459 if (!tp->client) { in attach_one_temp()
465 tp->index = temp_idx; in attach_one_temp()
467 list_add(&tp->glob_list, &all_temps); in attach_one_temp()
468 list_add(&tp->bp_list, &bp->temps); in attach_one_temp()
473 bbc_i2c_writeb(tp->client, 0x00, MAX1617_WR_CFG_BYTE); in attach_one_temp()
474 bbc_i2c_writeb(tp->client, 0x02, MAX1617_WR_CVRATE_BYTE); in attach_one_temp()
477 bbc_i2c_writeb(tp->client, amb_temp_limits[tp->index].high_pwroff, in attach_one_temp()
479 bbc_i2c_writeb(tp->client, amb_temp_limits[tp->index].low_pwroff, in attach_one_temp()
481 bbc_i2c_writeb(tp->client, cpu_temp_limits[tp->index].high_pwroff, in attach_one_temp()
483 bbc_i2c_writeb(tp->client, cpu_temp_limits[tp->index].low_pwroff, in attach_one_temp()
487 tp->prev_cpu_temp = tp->avg_cpu_temp = tp->curr_cpu_temp; in attach_one_temp()
488 tp->prev_amb_temp = tp->avg_amb_temp = tp->curr_amb_temp; in attach_one_temp()
490 tp->fan_todo[FAN_AMBIENT] = FAN_SAME; in attach_one_temp()
491 tp->fan_todo[FAN_CPU] = FAN_SAME; in attach_one_temp()
503 INIT_LIST_HEAD(&fp->bp_list); in attach_one_fan()
504 INIT_LIST_HEAD(&fp->glob_list); in attach_one_fan()
506 fp->client = bbc_i2c_attach(bp, op); in attach_one_fan()
507 if (!fp->client) { in attach_one_fan()
512 fp->index = fan_idx; in attach_one_fan()
514 list_add(&fp->glob_list, &all_fans); in attach_one_fan()
515 list_add(&fp->bp_list, &bp->fans); in attach_one_fan()
517 /* The i2c device controlling the fans is write-only. in attach_one_fan()
523 fp->psupply_fan_on = 1; in attach_one_fan()
524 fp->cpu_fan_speed = (FAN_SPEED_MAX - FAN_SPEED_MIN) / 2; in attach_one_fan()
525 fp->cpu_fan_speed += FAN_SPEED_MIN; in attach_one_fan()
526 fp->system_fan_speed = (FAN_SPEED_MAX - FAN_SPEED_MIN) / 2; in attach_one_fan()
527 fp->system_fan_speed += FAN_SPEED_MIN; in attach_one_fan()
534 bbc_i2c_detach(tp->client); in destroy_one_temp()
542 list_for_each_entry_safe(tp, tpos, &bp->temps, bp_list) { in destroy_all_temps()
543 list_del(&tp->bp_list); in destroy_all_temps()
544 list_del(&tp->glob_list); in destroy_all_temps()
551 bbc_i2c_detach(fp->client); in destroy_one_fan()
559 list_for_each_entry_safe(fp, fpos, &bp->fans, bp_list) { in destroy_all_fans()
560 list_del(&fp->bp_list); in destroy_all_fans()
561 list_del(&fp->glob_list); in destroy_all_fans()
574 if (of_node_name_eq(op->dev.of_node, "temperature")) in bbc_envctrl_init()
576 if (of_node_name_eq(op->dev.of_node, "fan-control")) in bbc_envctrl_init()