Lines Matching refs:tp

120 static void get_current_temps(struct bbc_cpu_temperature *tp)  in get_current_temps()  argument
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()
138 static void do_envctrl_shutdown(struct bbc_cpu_temperature *tp) in do_envctrl_shutdown() argument
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()
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()
169 static void analyze_ambient_temp(struct bbc_cpu_temperature *tp, unsigned long *last_warn, int tick) in analyze_ambient_temp() argument
174 if (tp->curr_amb_temp >= in analyze_ambient_temp()
175 amb_temp_limits[tp->index].high_warn) { 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()
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()
196 do_envctrl_shutdown(tp); in analyze_ambient_temp()
201 tp->fan_todo[FAN_AMBIENT] = FAN_FULLBLAST; in analyze_ambient_temp()
203 s8 amb_goal_hi = amb_temp_limits[tp->index].high_warn - 10; 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()
224 static void analyze_cpu_temp(struct bbc_cpu_temperature *tp, unsigned long *last_warn, int tick) in analyze_cpu_temp() argument
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()
251 do_envctrl_shutdown(tp); in analyze_cpu_temp()
256 tp->fan_todo[FAN_CPU] = FAN_FULLBLAST; in analyze_cpu_temp()
258 s8 cpu_goal_hi = cpu_temp_limits[tp->index].high_warn - 10; 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()
279 static void analyze_temps(struct bbc_cpu_temperature *tp, unsigned long *last_warn) in analyze_temps() argument
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()
292 struct bbc_cpu_temperature *tp; in prioritize_fan_action() local
299 list_for_each_entry(tp, &all_temps, glob_list) { in prioritize_fan_action()
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()
425 struct bbc_cpu_temperature *tp; in kenvctrld() local
432 list_for_each_entry(tp, &all_temps, glob_list) { in kenvctrld()
433 get_current_temps(tp); in kenvctrld()
434 analyze_temps(tp, &last_warning_jiffies); in kenvctrld()
449 struct bbc_cpu_temperature *tp; in attach_one_temp() local
451 tp = kzalloc(sizeof(*tp), GFP_KERNEL); in attach_one_temp()
452 if (!tp) in attach_one_temp()
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()
460 kfree(tp); 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()
486 get_current_temps(tp); 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()
532 static void destroy_one_temp(struct bbc_cpu_temperature *tp) in destroy_one_temp() argument
534 bbc_i2c_detach(tp->client); in destroy_one_temp()
535 kfree(tp); in destroy_one_temp()
540 struct bbc_cpu_temperature *tp, *tpos; in destroy_all_temps() local
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()
545 destroy_one_temp(tp); in destroy_all_temps()