Lines Matching refs:tp

120 static void get_current_temps(struct bbc_cpu_temperature *tp)
122 tp->prev_amb_temp = tp->curr_amb_temp;
123 bbc_i2c_readb(tp->client,
124 (unsigned char *) &tp->curr_amb_temp,
126 tp->prev_cpu_temp = tp->curr_cpu_temp;
127 bbc_i2c_readb(tp->client,
128 (unsigned char *) &tp->curr_cpu_temp,
132 tp->index,
133 (int) tp->curr_cpu_temp, (int) tp->curr_amb_temp);
138 static void do_envctrl_shutdown(struct bbc_cpu_temperature *tp)
147 if (tp->curr_amb_temp >= amb_temp_limits[tp->index].high_shutdown ||
148 tp->curr_amb_temp < amb_temp_limits[tp->index].low_shutdown) {
150 val = tp->curr_amb_temp;
151 } else if (tp->curr_cpu_temp >= cpu_temp_limits[tp->index].high_shutdown ||
152 tp->curr_cpu_temp < cpu_temp_limits[tp->index].low_shutdown) {
154 val = tp->curr_cpu_temp;
159 tp->index, type, val);
169 static void analyze_ambient_temp(struct bbc_cpu_temperature *tp, unsigned long *last_warn, int tick)
174 if (tp->curr_amb_temp >=
175 amb_temp_limits[tp->index].high_warn) {
178 tp->index, (int) tp->curr_amb_temp);
180 } else if (tp->curr_amb_temp <
181 amb_temp_limits[tp->index].low_warn) {
184 tp->index, (int) tp->curr_amb_temp);
189 } else if (tp->curr_amb_temp >= amb_temp_limits[tp->index].high_warn ||
190 tp->curr_amb_temp < amb_temp_limits[tp->index].low_warn)
194 if (tp->curr_amb_temp >= amb_temp_limits[tp->index].high_shutdown ||
195 tp->curr_amb_temp < amb_temp_limits[tp->index].low_shutdown) {
196 do_envctrl_shutdown(tp);
201 tp->fan_todo[FAN_AMBIENT] = FAN_FULLBLAST;
203 s8 amb_goal_hi = amb_temp_limits[tp->index].high_warn - 10;
211 if (tp->avg_amb_temp < amb_goal_hi) {
212 if (tp->avg_amb_temp >= amb_goal_lo)
213 tp->fan_todo[FAN_AMBIENT] = FAN_SAME;
215 tp->fan_todo[FAN_AMBIENT] = FAN_SLOWER;
217 tp->fan_todo[FAN_AMBIENT] = FAN_FASTER;
220 tp->fan_todo[FAN_AMBIENT] = FAN_SAME;
224 static void analyze_cpu_temp(struct bbc_cpu_temperature *tp, unsigned long *last_warn, int tick)
229 if (tp->curr_cpu_temp >=
230 cpu_temp_limits[tp->index].high_warn) {
233 tp->index, (int) tp->curr_cpu_temp);
235 } else if (tp->curr_cpu_temp <
236 cpu_temp_limits[tp->index].low_warn) {
239 tp->index, (int) tp->curr_cpu_temp);
244 } else if (tp->curr_cpu_temp >= cpu_temp_limits[tp->index].high_warn ||
245 tp->curr_cpu_temp < cpu_temp_limits[tp->index].low_warn)
249 if (tp->curr_cpu_temp >= cpu_temp_limits[tp->index].high_shutdown ||
250 tp->curr_cpu_temp < cpu_temp_limits[tp->index].low_shutdown) {
251 do_envctrl_shutdown(tp);
256 tp->fan_todo[FAN_CPU] = FAN_FULLBLAST;
258 s8 cpu_goal_hi = cpu_temp_limits[tp->index].high_warn - 10;
266 if (tp->avg_cpu_temp < cpu_goal_hi) {
267 if (tp->avg_cpu_temp >= cpu_goal_lo)
268 tp->fan_todo[FAN_CPU] = FAN_SAME;
270 tp->fan_todo[FAN_CPU] = FAN_SLOWER;
272 tp->fan_todo[FAN_CPU] = FAN_FASTER;
275 tp->fan_todo[FAN_CPU] = FAN_SAME;
279 static void analyze_temps(struct bbc_cpu_temperature *tp, unsigned long *last_warn)
281 tp->avg_amb_temp = (s8)((int)((int)tp->avg_amb_temp + (int)tp->curr_amb_temp) / 2);
282 tp->avg_cpu_temp = (s8)((int)((int)tp->avg_cpu_temp + (int)tp->curr_cpu_temp) / 2);
284 analyze_ambient_temp(tp, last_warn, tp->sample_tick);
285 analyze_cpu_temp(tp, last_warn, tp->sample_tick);
287 tp->sample_tick++;
292 struct bbc_cpu_temperature *tp;
299 list_for_each_entry(tp, &all_temps, glob_list) {
300 if (tp->fan_todo[which_fan] == FAN_FULLBLAST) {
304 if (tp->fan_todo[which_fan] == FAN_SAME &&
307 else if (tp->fan_todo[which_fan] == FAN_FASTER)
311 tp->fan_todo[which_fan] == FAN_SLOWER)
425 struct bbc_cpu_temperature *tp;
432 list_for_each_entry(tp, &all_temps, glob_list) {
433 get_current_temps(tp);
434 analyze_temps(tp, &last_warning_jiffies);
449 struct bbc_cpu_temperature *tp;
451 tp = kzalloc(sizeof(*tp), GFP_KERNEL);
452 if (!tp)
455 INIT_LIST_HEAD(&tp->bp_list);
456 INIT_LIST_HEAD(&tp->glob_list);
458 tp->client = bbc_i2c_attach(bp, op);
459 if (!tp->client) {
460 kfree(tp);
465 tp->index = temp_idx;
467 list_add(&tp->glob_list, &all_temps);
468 list_add(&tp->bp_list, &bp->temps);
473 bbc_i2c_writeb(tp->client, 0x00, MAX1617_WR_CFG_BYTE);
474 bbc_i2c_writeb(tp->client, 0x02, MAX1617_WR_CVRATE_BYTE);
477 bbc_i2c_writeb(tp->client, amb_temp_limits[tp->index].high_pwroff,
479 bbc_i2c_writeb(tp->client, amb_temp_limits[tp->index].low_pwroff,
481 bbc_i2c_writeb(tp->client, cpu_temp_limits[tp->index].high_pwroff,
483 bbc_i2c_writeb(tp->client, cpu_temp_limits[tp->index].low_pwroff,
486 get_current_temps(tp);
487 tp->prev_cpu_temp = tp->avg_cpu_temp = tp->curr_cpu_temp;
488 tp->prev_amb_temp = tp->avg_amb_temp = tp->curr_amb_temp;
490 tp->fan_todo[FAN_AMBIENT] = FAN_SAME;
491 tp->fan_todo[FAN_CPU] = FAN_SAME;
532 static void destroy_one_temp(struct bbc_cpu_temperature *tp)
534 bbc_i2c_detach(tp->client);
535 kfree(tp);
540 struct bbc_cpu_temperature *tp, *tpos;
542 list_for_each_entry_safe(tp, tpos, &bp->temps, bp_list) {
543 list_del(&tp->bp_list);
544 list_del(&tp->glob_list);
545 destroy_one_temp(tp);