Lines Matching +full:system +full:- +full:control
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Windfarm PowerMac thermal control. iMac G5
8 * The algorithm used is the PID control algorithm, used the same
11 * that none of the code has been re-used, it's a complete re-implementation
13 * The various control loops found in Darwin config file are:
18 * System Fans control loop. Different based on models. In addition to the
19 * usual PID algorithm, the control loop gets 2 additional pairs of linear
24 * - the linked control (second control) gets the target value as-is
26 * - the main control (first control) gets the target value scaled with
28 * - the value of the target of the CPU Fan control loop is retrieved,
30 * the scaled target is applied to the main control.
33 * controls : system-fan, drive-bay-fan
34 * sensors : hd-temp
41 * linear-factors : offset = 0xff38 scale = 0x0ccd
45 * controls : system-fan, drive-bay-fan
46 * sensors : hd-temp
53 * linear-factors : offset = 0xff38 scale = 0x0ccd
57 * controls : system-fan
58 * sensors : hd-temp
65 * linear-factors : offset = 0x0000 scale = 0x1000
68 * CPU Fan control loop. The loop is identical for all models. it
70 * systems fan control loop target result (the one before it gets scaled
71 * by the System Fans control loop itself). Then, the max value of the
72 * calculated target value and system fan value is sent to the fans
74 * controls : cpu-fan
75 * sensors : cpu-temp cpu-power
77 * linear-factors : offset = 0xfb50 scale = 0x1000
79 * CPU Slew control loop. Not implemented. The cpufreq driver in linux is
84 * WARNING ! The CPU control loop requires the CPU tmax for the current
89 * from the SDB partition. If we ever end up with actually slewing the system
140 /* Set to kick the control loop into life */
154 * ****** System Fans Control Loop ******
158 /* Parameters for the System Fans control loop. Parameters
176 /* State data used by the system fans control loop
190 * Configs for SMU System Fan control loop
235 * ****** CPU Fans Control Loop ******
245 /* State data used by the cpu fans control loop
279 printk(KERN_WARNING "windfarm: System fan config not found " in wf_smu_create_sys_fans()
292 wf_smu_sys_fans->ticks = 1; in wf_smu_create_sys_fans()
293 wf_smu_sys_fans->scale0 = param->scale0; in wf_smu_create_sys_fans()
294 wf_smu_sys_fans->offset0 = param->offset0; in wf_smu_create_sys_fans()
295 wf_smu_sys_fans->scale1 = param->scale1; in wf_smu_create_sys_fans()
296 wf_smu_sys_fans->offset1 = param->offset1; in wf_smu_create_sys_fans()
299 pid_param.gd = param->gd; in wf_smu_create_sys_fans()
300 pid_param.gp = param->gp; in wf_smu_create_sys_fans()
301 pid_param.gr = param->gr; in wf_smu_create_sys_fans()
304 pid_param.itarget = param->itarget; in wf_smu_create_sys_fans()
313 wf_pid_init(&wf_smu_sys_fans->pid, &pid_param); in wf_smu_create_sys_fans()
315 DBG("wf: System Fan control initialized.\n"); in wf_smu_create_sys_fans()
333 if (--st->ticks != 0) { in wf_smu_sys_fans_tick()
338 st->ticks = WF_SMU_SYS_FANS_INTERVAL; in wf_smu_sys_fans_tick()
348 DBG("wf_smu: System Fans tick ! HD temp: %d.%03d\n", in wf_smu_sys_fans_tick()
351 if (temp > (st->pid.param.itarget + 0x50000)) in wf_smu_sys_fans_tick()
354 new_setpoint = wf_pid_run(&st->pid, temp); in wf_smu_sys_fans_tick()
358 scaled = ((((s64)new_setpoint) * (s64)st->scale0) >> 12) + st->offset0; in wf_smu_sys_fans_tick()
362 cputarget = wf_smu_cpu_fans ? wf_smu_cpu_fans->pid.target : 0; in wf_smu_sys_fans_tick()
363 cputarget = ((((s64)cputarget) * (s64)st->scale1) >> 12) + st->offset1; in wf_smu_sys_fans_tick()
365 scaled = max(scaled, st->pid.param.min); in wf_smu_sys_fans_tick()
366 scaled = min(scaled, st->pid.param.max); in wf_smu_sys_fans_tick()
370 if (st->sys_setpoint == scaled && new_setpoint == st->hd_setpoint) in wf_smu_sys_fans_tick()
372 st->sys_setpoint = scaled; in wf_smu_sys_fans_tick()
373 st->hd_setpoint = new_setpoint; in wf_smu_sys_fans_tick()
376 rc = wf_control_set(fan_system, st->sys_setpoint); in wf_smu_sys_fans_tick()
384 rc = wf_control_set(fan_hd, st->hd_setpoint); in wf_smu_sys_fans_tick()
416 tmax = ((s32)fvt->maxtemp) << 16; in wf_smu_create_cpu_fans()
425 wf_smu_cpu_fans->ticks = 1; in wf_smu_create_cpu_fans()
427 wf_smu_cpu_fans->scale = WF_SMU_CPU_FANS_SIBLING_SCALE; in wf_smu_create_cpu_fans()
428 wf_smu_cpu_fans->offset = WF_SMU_CPU_FANS_SIBLING_OFFSET; in wf_smu_create_cpu_fans()
432 pid_param.history_len = piddata->history_len; in wf_smu_create_cpu_fans()
435 "CPU control loop (%d)\n", piddata->history_len); in wf_smu_create_cpu_fans()
438 pid_param.gd = piddata->gd; in wf_smu_create_cpu_fans()
439 pid_param.gp = piddata->gp; in wf_smu_create_cpu_fans()
440 pid_param.gr = piddata->gr / pid_param.history_len; in wf_smu_create_cpu_fans()
442 tdelta = ((s32)piddata->target_temp_delta) << 16; in wf_smu_create_cpu_fans()
443 maxpow = ((s32)piddata->max_power) << 16; in wf_smu_create_cpu_fans()
444 powadj = ((s32)piddata->power_adj) << 16; in wf_smu_create_cpu_fans()
447 pid_param.ttarget = tmax - tdelta; in wf_smu_create_cpu_fans()
448 pid_param.pmaxadj = maxpow - powadj; in wf_smu_create_cpu_fans()
453 wf_cpu_pid_init(&wf_smu_cpu_fans->pid, &pid_param); in wf_smu_create_cpu_fans()
455 DBG("wf: CPU Fan control initialized.\n"); in wf_smu_create_cpu_fans()
477 if (--st->ticks != 0) { in wf_smu_cpu_fans_tick()
482 st->ticks = WF_SMU_CPU_FANS_INTERVAL; in wf_smu_cpu_fans_tick()
507 if (temp > st->pid.param.tmax) in wf_smu_cpu_fans_tick()
510 new_setpoint = wf_cpu_pid_run(&st->pid, power, temp); in wf_smu_cpu_fans_tick()
514 systarget = wf_smu_sys_fans ? wf_smu_sys_fans->pid.target : 0; in wf_smu_cpu_fans_tick()
515 systarget = ((((s64)systarget) * (s64)st->scale) >> 12) in wf_smu_cpu_fans_tick()
516 + st->offset; in wf_smu_cpu_fans_tick()
518 new_setpoint = max(new_setpoint, st->pid.param.min); in wf_smu_cpu_fans_tick()
519 new_setpoint = min(new_setpoint, st->pid.param.max); in wf_smu_cpu_fans_tick()
523 if (st->cpu_setpoint == new_setpoint) in wf_smu_cpu_fans_tick()
525 st->cpu_setpoint = new_setpoint; in wf_smu_cpu_fans_tick()
528 rc = wf_control_set(fan_cpu_main, st->cpu_setpoint); in wf_smu_cpu_fans_tick()
548 DBG("wf: creating control loops !\n"); in wf_smu_tick()
555 if (wf_smu_skipping && --wf_smu_skipping) in wf_smu_tick()
602 * the control loop levels, but we don't want to keep it clear in wf_smu_tick()
616 if (fan_cpu_main == NULL && !strcmp(ct->name, "cpu-fan")) { in wf_smu_new_control()
621 if (fan_system == NULL && !strcmp(ct->name, "system-fan")) { in wf_smu_new_control()
626 if (cpufreq_clamp == NULL && !strcmp(ct->name, "cpufreq-clamp")) { in wf_smu_new_control()
641 if (fan_hd == NULL && !strcmp(ct->name, "drive-bay-fan")) { in wf_smu_new_control()
655 if (sensor_cpu_power == NULL && !strcmp(sr->name, "cpu-power")) { in wf_smu_new_sensor()
660 if (sensor_cpu_temp == NULL && !strcmp(sr->name, "cpu-temp")) { in wf_smu_new_sensor()
665 if (sensor_hd_temp == NULL && !strcmp(sr->name, "hd-temp")) { in wf_smu_new_sensor()
680 DBG("wf: new control %s detected\n", in wf_smu_notify()
681 ((struct wf_control *)data)->name); in wf_smu_notify()
687 ((struct wf_sensor *)data)->name); in wf_smu_notify()
710 wf_smu_mach_model = st->model_id; in wf_init_pm()
760 /* Destroy control loops state structures */ in wf_smu_remove()
778 int rc = -ENODEV; in wf_smu_init()
809 MODULE_DESCRIPTION("Thermal control logic for iMac G5");