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
141 /* Set to kick the control loop into life */
155 * ****** System Fans Control Loop ******
159 /* Parameters for the System Fans control loop. Parameters
177 /* State data used by the system fans control loop
191 * Configs for SMU System Fan control loop
236 * ****** CPU Fans Control Loop ******
246 /* State data used by the cpu fans control loop
280 printk(KERN_WARNING "windfarm: System fan config not found " in wf_smu_create_sys_fans()
293 wf_smu_sys_fans->ticks = 1; in wf_smu_create_sys_fans()
294 wf_smu_sys_fans->scale0 = param->scale0; in wf_smu_create_sys_fans()
295 wf_smu_sys_fans->offset0 = param->offset0; in wf_smu_create_sys_fans()
296 wf_smu_sys_fans->scale1 = param->scale1; in wf_smu_create_sys_fans()
297 wf_smu_sys_fans->offset1 = param->offset1; in wf_smu_create_sys_fans()
300 pid_param.gd = param->gd; in wf_smu_create_sys_fans()
301 pid_param.gp = param->gp; in wf_smu_create_sys_fans()
302 pid_param.gr = param->gr; in wf_smu_create_sys_fans()
305 pid_param.itarget = param->itarget; in wf_smu_create_sys_fans()
314 wf_pid_init(&wf_smu_sys_fans->pid, &pid_param); in wf_smu_create_sys_fans()
316 DBG("wf: System Fan control initialized.\n"); in wf_smu_create_sys_fans()
334 if (--st->ticks != 0) { in wf_smu_sys_fans_tick()
339 st->ticks = WF_SMU_SYS_FANS_INTERVAL; in wf_smu_sys_fans_tick()
349 DBG("wf_smu: System Fans tick ! HD temp: %d.%03d\n", in wf_smu_sys_fans_tick()
352 if (temp > (st->pid.param.itarget + 0x50000)) in wf_smu_sys_fans_tick()
355 new_setpoint = wf_pid_run(&st->pid, temp); in wf_smu_sys_fans_tick()
359 scaled = ((((s64)new_setpoint) * (s64)st->scale0) >> 12) + st->offset0; in wf_smu_sys_fans_tick()
363 cputarget = wf_smu_cpu_fans ? wf_smu_cpu_fans->pid.target : 0; in wf_smu_sys_fans_tick()
364 cputarget = ((((s64)cputarget) * (s64)st->scale1) >> 12) + st->offset1; in wf_smu_sys_fans_tick()
366 scaled = max(scaled, st->pid.param.min); in wf_smu_sys_fans_tick()
367 scaled = min(scaled, st->pid.param.max); in wf_smu_sys_fans_tick()
371 if (st->sys_setpoint == scaled && new_setpoint == st->hd_setpoint) in wf_smu_sys_fans_tick()
373 st->sys_setpoint = scaled; in wf_smu_sys_fans_tick()
374 st->hd_setpoint = new_setpoint; in wf_smu_sys_fans_tick()
377 rc = wf_control_set(fan_system, st->sys_setpoint); in wf_smu_sys_fans_tick()
385 rc = wf_control_set(fan_hd, st->hd_setpoint); in wf_smu_sys_fans_tick()
417 tmax = ((s32)fvt->maxtemp) << 16; in wf_smu_create_cpu_fans()
426 wf_smu_cpu_fans->ticks = 1; in wf_smu_create_cpu_fans()
428 wf_smu_cpu_fans->scale = WF_SMU_CPU_FANS_SIBLING_SCALE; in wf_smu_create_cpu_fans()
429 wf_smu_cpu_fans->offset = WF_SMU_CPU_FANS_SIBLING_OFFSET; in wf_smu_create_cpu_fans()
433 pid_param.history_len = piddata->history_len; in wf_smu_create_cpu_fans()
436 "CPU control loop (%d)\n", piddata->history_len); in wf_smu_create_cpu_fans()
439 pid_param.gd = piddata->gd; in wf_smu_create_cpu_fans()
440 pid_param.gp = piddata->gp; in wf_smu_create_cpu_fans()
441 pid_param.gr = piddata->gr / pid_param.history_len; in wf_smu_create_cpu_fans()
443 tdelta = ((s32)piddata->target_temp_delta) << 16; in wf_smu_create_cpu_fans()
444 maxpow = ((s32)piddata->max_power) << 16; in wf_smu_create_cpu_fans()
445 powadj = ((s32)piddata->power_adj) << 16; in wf_smu_create_cpu_fans()
448 pid_param.ttarget = tmax - tdelta; in wf_smu_create_cpu_fans()
449 pid_param.pmaxadj = maxpow - powadj; in wf_smu_create_cpu_fans()
454 wf_cpu_pid_init(&wf_smu_cpu_fans->pid, &pid_param); in wf_smu_create_cpu_fans()
456 DBG("wf: CPU Fan control initialized.\n"); in wf_smu_create_cpu_fans()
478 if (--st->ticks != 0) { in wf_smu_cpu_fans_tick()
483 st->ticks = WF_SMU_CPU_FANS_INTERVAL; in wf_smu_cpu_fans_tick()
508 if (temp > st->pid.param.tmax) in wf_smu_cpu_fans_tick()
511 new_setpoint = wf_cpu_pid_run(&st->pid, power, temp); in wf_smu_cpu_fans_tick()
515 systarget = wf_smu_sys_fans ? wf_smu_sys_fans->pid.target : 0; in wf_smu_cpu_fans_tick()
516 systarget = ((((s64)systarget) * (s64)st->scale) >> 12) in wf_smu_cpu_fans_tick()
517 + st->offset; in wf_smu_cpu_fans_tick()
519 new_setpoint = max(new_setpoint, st->pid.param.min); in wf_smu_cpu_fans_tick()
520 new_setpoint = min(new_setpoint, st->pid.param.max); in wf_smu_cpu_fans_tick()
524 if (st->cpu_setpoint == new_setpoint) in wf_smu_cpu_fans_tick()
526 st->cpu_setpoint = new_setpoint; in wf_smu_cpu_fans_tick()
529 rc = wf_control_set(fan_cpu_main, st->cpu_setpoint); in wf_smu_cpu_fans_tick()
549 DBG("wf: creating control loops !\n"); in wf_smu_tick()
556 if (wf_smu_skipping && --wf_smu_skipping) in wf_smu_tick()
603 * the control loop levels, but we don't want to keep it clear in wf_smu_tick()
617 if (fan_cpu_main == NULL && !strcmp(ct->name, "cpu-fan")) { in wf_smu_new_control()
622 if (fan_system == NULL && !strcmp(ct->name, "system-fan")) { in wf_smu_new_control()
627 if (cpufreq_clamp == NULL && !strcmp(ct->name, "cpufreq-clamp")) { in wf_smu_new_control()
642 if (fan_hd == NULL && !strcmp(ct->name, "drive-bay-fan")) { in wf_smu_new_control()
656 if (sensor_cpu_power == NULL && !strcmp(sr->name, "cpu-power")) { in wf_smu_new_sensor()
661 if (sensor_cpu_temp == NULL && !strcmp(sr->name, "cpu-temp")) { in wf_smu_new_sensor()
666 if (sensor_hd_temp == NULL && !strcmp(sr->name, "hd-temp")) { in wf_smu_new_sensor()
681 DBG("wf: new control %s detected\n", in wf_smu_notify()
682 ((struct wf_control *)data)->name); in wf_smu_notify()
688 ((struct wf_sensor *)data)->name); in wf_smu_notify()
711 wf_smu_mach_model = st->model_id; in wf_init_pm()
761 /* Destroy control loops state structures */ in wf_smu_remove()
777 int rc = -ENODEV; in wf_smu_init()
808 MODULE_DESCRIPTION("Thermal control logic for iMac G5");