Lines Matching refs:tp
119 static void get_current_temps(struct bbc_cpu_temperature *tp) in get_current_temps() argument
121 tp->prev_amb_temp = tp->curr_amb_temp; in get_current_temps()
122 bbc_i2c_readb(tp->client, in get_current_temps()
123 (unsigned char *) &tp->curr_amb_temp, in get_current_temps()
125 tp->prev_cpu_temp = tp->curr_cpu_temp; in get_current_temps()
126 bbc_i2c_readb(tp->client, in get_current_temps()
127 (unsigned char *) &tp->curr_cpu_temp, in get_current_temps()
131 tp->index, in get_current_temps()
132 (int) tp->curr_cpu_temp, (int) tp->curr_amb_temp); in get_current_temps()
137 static void do_envctrl_shutdown(struct bbc_cpu_temperature *tp) in do_envctrl_shutdown() argument
146 if (tp->curr_amb_temp >= amb_temp_limits[tp->index].high_shutdown || in do_envctrl_shutdown()
147 tp->curr_amb_temp < amb_temp_limits[tp->index].low_shutdown) { in do_envctrl_shutdown()
149 val = tp->curr_amb_temp; in do_envctrl_shutdown()
150 } else if (tp->curr_cpu_temp >= cpu_temp_limits[tp->index].high_shutdown || in do_envctrl_shutdown()
151 tp->curr_cpu_temp < cpu_temp_limits[tp->index].low_shutdown) { in do_envctrl_shutdown()
153 val = tp->curr_cpu_temp; in do_envctrl_shutdown()
158 tp->index, type, val); in do_envctrl_shutdown()
168 static void analyze_ambient_temp(struct bbc_cpu_temperature *tp, unsigned long *last_warn, int tick) in analyze_ambient_temp() argument
173 if (tp->curr_amb_temp >= in analyze_ambient_temp()
174 amb_temp_limits[tp->index].high_warn) { in analyze_ambient_temp()
177 tp->index, (int) tp->curr_amb_temp); in analyze_ambient_temp()
179 } else if (tp->curr_amb_temp < in analyze_ambient_temp()
180 amb_temp_limits[tp->index].low_warn) { in analyze_ambient_temp()
183 tp->index, (int) tp->curr_amb_temp); in analyze_ambient_temp()
188 } else if (tp->curr_amb_temp >= amb_temp_limits[tp->index].high_warn || in analyze_ambient_temp()
189 tp->curr_amb_temp < amb_temp_limits[tp->index].low_warn) in analyze_ambient_temp()
193 if (tp->curr_amb_temp >= amb_temp_limits[tp->index].high_shutdown || in analyze_ambient_temp()
194 tp->curr_amb_temp < amb_temp_limits[tp->index].low_shutdown) { in analyze_ambient_temp()
195 do_envctrl_shutdown(tp); in analyze_ambient_temp()
200 tp->fan_todo[FAN_AMBIENT] = FAN_FULLBLAST; in analyze_ambient_temp()
202 s8 amb_goal_hi = amb_temp_limits[tp->index].high_warn - 10; in analyze_ambient_temp()
210 if (tp->avg_amb_temp < amb_goal_hi) { in analyze_ambient_temp()
211 if (tp->avg_amb_temp >= amb_goal_lo) in analyze_ambient_temp()
212 tp->fan_todo[FAN_AMBIENT] = FAN_SAME; in analyze_ambient_temp()
214 tp->fan_todo[FAN_AMBIENT] = FAN_SLOWER; in analyze_ambient_temp()
216 tp->fan_todo[FAN_AMBIENT] = FAN_FASTER; in analyze_ambient_temp()
219 tp->fan_todo[FAN_AMBIENT] = FAN_SAME; in analyze_ambient_temp()
223 static void analyze_cpu_temp(struct bbc_cpu_temperature *tp, unsigned long *last_warn, int tick) in analyze_cpu_temp() argument
228 if (tp->curr_cpu_temp >= in analyze_cpu_temp()
229 cpu_temp_limits[tp->index].high_warn) { in analyze_cpu_temp()
232 tp->index, (int) tp->curr_cpu_temp); in analyze_cpu_temp()
234 } else if (tp->curr_cpu_temp < in analyze_cpu_temp()
235 cpu_temp_limits[tp->index].low_warn) { in analyze_cpu_temp()
238 tp->index, (int) tp->curr_cpu_temp); in analyze_cpu_temp()
243 } else if (tp->curr_cpu_temp >= cpu_temp_limits[tp->index].high_warn || in analyze_cpu_temp()
244 tp->curr_cpu_temp < cpu_temp_limits[tp->index].low_warn) in analyze_cpu_temp()
248 if (tp->curr_cpu_temp >= cpu_temp_limits[tp->index].high_shutdown || in analyze_cpu_temp()
249 tp->curr_cpu_temp < cpu_temp_limits[tp->index].low_shutdown) { in analyze_cpu_temp()
250 do_envctrl_shutdown(tp); in analyze_cpu_temp()
255 tp->fan_todo[FAN_CPU] = FAN_FULLBLAST; in analyze_cpu_temp()
257 s8 cpu_goal_hi = cpu_temp_limits[tp->index].high_warn - 10; in analyze_cpu_temp()
265 if (tp->avg_cpu_temp < cpu_goal_hi) { in analyze_cpu_temp()
266 if (tp->avg_cpu_temp >= cpu_goal_lo) in analyze_cpu_temp()
267 tp->fan_todo[FAN_CPU] = FAN_SAME; in analyze_cpu_temp()
269 tp->fan_todo[FAN_CPU] = FAN_SLOWER; in analyze_cpu_temp()
271 tp->fan_todo[FAN_CPU] = FAN_FASTER; in analyze_cpu_temp()
274 tp->fan_todo[FAN_CPU] = FAN_SAME; in analyze_cpu_temp()
278 static void analyze_temps(struct bbc_cpu_temperature *tp, unsigned long *last_warn) in analyze_temps() argument
280 tp->avg_amb_temp = (s8)((int)((int)tp->avg_amb_temp + (int)tp->curr_amb_temp) / 2); in analyze_temps()
281 tp->avg_cpu_temp = (s8)((int)((int)tp->avg_cpu_temp + (int)tp->curr_cpu_temp) / 2); in analyze_temps()
283 analyze_ambient_temp(tp, last_warn, tp->sample_tick); in analyze_temps()
284 analyze_cpu_temp(tp, last_warn, tp->sample_tick); in analyze_temps()
286 tp->sample_tick++; in analyze_temps()
291 struct bbc_cpu_temperature *tp; in prioritize_fan_action() local
298 list_for_each_entry(tp, &all_temps, glob_list) { in prioritize_fan_action()
299 if (tp->fan_todo[which_fan] == FAN_FULLBLAST) { in prioritize_fan_action()
303 if (tp->fan_todo[which_fan] == FAN_SAME && in prioritize_fan_action()
306 else if (tp->fan_todo[which_fan] == FAN_FASTER) in prioritize_fan_action()
310 tp->fan_todo[which_fan] == FAN_SLOWER) in prioritize_fan_action()
424 struct bbc_cpu_temperature *tp; in kenvctrld() local
431 list_for_each_entry(tp, &all_temps, glob_list) { in kenvctrld()
432 get_current_temps(tp); in kenvctrld()
433 analyze_temps(tp, &last_warning_jiffies); in kenvctrld()
448 struct bbc_cpu_temperature *tp; in attach_one_temp() local
450 tp = kzalloc(sizeof(*tp), GFP_KERNEL); in attach_one_temp()
451 if (!tp) in attach_one_temp()
454 INIT_LIST_HEAD(&tp->bp_list); in attach_one_temp()
455 INIT_LIST_HEAD(&tp->glob_list); in attach_one_temp()
457 tp->client = bbc_i2c_attach(bp, op); in attach_one_temp()
458 if (!tp->client) { in attach_one_temp()
459 kfree(tp); in attach_one_temp()
464 tp->index = temp_idx; in attach_one_temp()
466 list_add(&tp->glob_list, &all_temps); in attach_one_temp()
467 list_add(&tp->bp_list, &bp->temps); in attach_one_temp()
472 bbc_i2c_writeb(tp->client, 0x00, MAX1617_WR_CFG_BYTE); in attach_one_temp()
473 bbc_i2c_writeb(tp->client, 0x02, MAX1617_WR_CVRATE_BYTE); in attach_one_temp()
476 bbc_i2c_writeb(tp->client, amb_temp_limits[tp->index].high_pwroff, in attach_one_temp()
478 bbc_i2c_writeb(tp->client, amb_temp_limits[tp->index].low_pwroff, in attach_one_temp()
480 bbc_i2c_writeb(tp->client, cpu_temp_limits[tp->index].high_pwroff, in attach_one_temp()
482 bbc_i2c_writeb(tp->client, cpu_temp_limits[tp->index].low_pwroff, in attach_one_temp()
485 get_current_temps(tp); in attach_one_temp()
486 tp->prev_cpu_temp = tp->avg_cpu_temp = tp->curr_cpu_temp; in attach_one_temp()
487 tp->prev_amb_temp = tp->avg_amb_temp = tp->curr_amb_temp; in attach_one_temp()
489 tp->fan_todo[FAN_AMBIENT] = FAN_SAME; in attach_one_temp()
490 tp->fan_todo[FAN_CPU] = FAN_SAME; in attach_one_temp()
531 static void destroy_one_temp(struct bbc_cpu_temperature *tp) in destroy_one_temp() argument
533 bbc_i2c_detach(tp->client); in destroy_one_temp()
534 kfree(tp); in destroy_one_temp()
539 struct bbc_cpu_temperature *tp, *tpos; in destroy_all_temps() local
541 list_for_each_entry_safe(tp, tpos, &bp->temps, bp_list) { in destroy_all_temps()
542 list_del(&tp->bp_list); in destroy_all_temps()
543 list_del(&tp->glob_list); in destroy_all_temps()
544 destroy_one_temp(tp); in destroy_all_temps()