Lines Matching +full:cpu +full:- +full:thermal
1 // SPDX-License-Identifier: GPL-2.0
3 * temp.c Thermal management for cpu's with Thermal Assist Units
8 * dynamic power management to limit peak CPU temp (using ICTC)
11 * Silly, crazy ideas: use cpu load (from scheduler) and ICTC to extend battery
55 static void set_thresholds(unsigned long cpu) in set_thresholds() argument
60 mtspr(SPRN_THRM1, THRM1_THRES(tau[cpu].low) | THRM1_V | maybe_tie | THRM1_TID); in set_thresholds()
63 mtspr(SPRN_THRM2, THRM1_THRES(tau[cpu].high) | THRM1_V | maybe_tie); in set_thresholds()
66 static void TAUupdate(int cpu) in TAUupdate() argument
77 if (tau[cpu].low >= step_size) { in TAUupdate()
78 tau[cpu].low -= step_size; in TAUupdate()
79 tau[cpu].high -= (step_size - window_expand); in TAUupdate()
81 tau[cpu].grew = 1; in TAUupdate()
88 if (tau[cpu].high <= 127 - step_size) { in TAUupdate()
89 tau[cpu].low += (step_size - window_expand); in TAUupdate()
90 tau[cpu].high += step_size; in TAUupdate()
92 tau[cpu].grew = 1; in TAUupdate()
99 * TAU interrupts - called when we have a thermal assist unit interrupt
105 int cpu = smp_processor_id(); in DEFINE_INTERRUPT_HANDLER_ASYNC() local
107 tau[cpu].interrupts++; in DEFINE_INTERRUPT_HANDLER_ASYNC()
109 TAUupdate(cpu); in DEFINE_INTERRUPT_HANDLER_ASYNC()
115 int cpu; in tau_timeout() local
119 cpu = smp_processor_id(); in tau_timeout()
122 TAUupdate(cpu); in tau_timeout()
124 /* Stop thermal sensor comparisons and interrupts */ in tau_timeout()
127 size = tau[cpu].high - tau[cpu].low; in tau_timeout()
128 if (size > min_window && ! tau[cpu].grew) { in tau_timeout()
130 shrink = (2 + size - min_window) / 4; in tau_timeout()
132 tau[cpu].low += shrink; in tau_timeout()
133 tau[cpu].high -= shrink; in tau_timeout()
135 tau[cpu].low += 1; in tau_timeout()
137 if ((tau[cpu].high - tau[cpu].low) != min_window){ in tau_timeout()
144 tau[cpu].grew = 0; in tau_timeout()
146 set_thresholds(cpu); in tau_timeout()
148 /* Restart thermal sensor comparisons and interrupts. in tau_timeout()
179 unsigned long cpu = smp_processor_id(); in TAU_init_smp() local
183 tau[cpu].low = 5; in TAU_init_smp()
184 tau[cpu].high = 120; in TAU_init_smp()
186 set_thresholds(cpu); in TAU_init_smp()
191 /* We assume in SMP that if one CPU has TAU support, they in TAU_init()
192 * all have it --BenH in TAU_init()
195 printk("Thermal assist unit not available\n"); in TAU_init()
201 !strcmp(cur_cpu_spec->platform, "ppc750"); in TAU_init()
205 return -ENOMEM; in TAU_init()
211 pr_info("Thermal assist unit using %s, shrink_timer: %d ms\n", in TAU_init()
224 u32 cpu_temp_both(unsigned long cpu) in cpu_temp_both() argument
226 return ((tau[cpu].high << 16) | tau[cpu].low); in cpu_temp_both()
229 u32 cpu_temp(unsigned long cpu) in cpu_temp() argument
231 return ((tau[cpu].high + tau[cpu].low) / 2); in cpu_temp()
234 u32 tau_interrupts(unsigned long cpu) in tau_interrupts() argument
236 return (tau[cpu].interrupts); in tau_interrupts()