mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-15 16:24:13 +08:00
2c162f9b41
Based on 1 normalized pattern(s): released under the term of the gnu gpl v2 extracted by the scancode license scanner the SPDX license identifier GPL-2.0-only has been chosen to replace the boilerplate/reference in 16 file(s). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Allison Randal <allison@lohutok.net> Reviewed-by: Enrico Weigelt <info@metux.net> Reviewed-by: Alexios Zavras <alexios.zavras@intel.com> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190602204654.922331175@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
85 lines
2.7 KiB
C
85 lines
2.7 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* Windfarm PowerMac thermal control. Generic PID helpers
|
|
*
|
|
* (c) Copyright 2005 Benjamin Herrenschmidt, IBM Corp.
|
|
* <benh@kernel.crashing.org>
|
|
*
|
|
* This is a pair of generic PID helpers that can be used by
|
|
* control loops. One is the basic PID implementation, the
|
|
* other one is more specifically tailored to the loops used
|
|
* for CPU control with 2 input sample types (temp and power)
|
|
*/
|
|
|
|
/*
|
|
* *** Simple PID ***
|
|
*/
|
|
|
|
#define WF_PID_MAX_HISTORY 32
|
|
|
|
/* This parameter array is passed to the PID algorithm. Currently,
|
|
* we don't support changing parameters on the fly as it's not needed
|
|
* but could be implemented (with necessary adjustment of the history
|
|
* buffer
|
|
*/
|
|
struct wf_pid_param {
|
|
int interval; /* Interval between samples in seconds */
|
|
int history_len; /* Size of history buffer */
|
|
int additive; /* 1: target relative to previous value */
|
|
s32 gd, gp, gr; /* PID gains */
|
|
s32 itarget; /* PID input target */
|
|
s32 min,max; /* min and max target values */
|
|
};
|
|
|
|
struct wf_pid_state {
|
|
int first; /* first run of the loop */
|
|
int index; /* index of current sample */
|
|
s32 target; /* current target value */
|
|
s32 samples[WF_PID_MAX_HISTORY]; /* samples history buffer */
|
|
s32 errors[WF_PID_MAX_HISTORY]; /* error history buffer */
|
|
|
|
struct wf_pid_param param;
|
|
};
|
|
|
|
extern void wf_pid_init(struct wf_pid_state *st, struct wf_pid_param *param);
|
|
extern s32 wf_pid_run(struct wf_pid_state *st, s32 sample);
|
|
|
|
|
|
/*
|
|
* *** CPU PID ***
|
|
*/
|
|
|
|
#define WF_CPU_PID_MAX_HISTORY 32
|
|
|
|
/* This parameter array is passed to the CPU PID algorithm. Currently,
|
|
* we don't support changing parameters on the fly as it's not needed
|
|
* but could be implemented (with necessary adjustment of the history
|
|
* buffer
|
|
*/
|
|
struct wf_cpu_pid_param {
|
|
int interval; /* Interval between samples in seconds */
|
|
int history_len; /* Size of history buffer */
|
|
s32 gd, gp, gr; /* PID gains */
|
|
s32 pmaxadj; /* PID max power adjust */
|
|
s32 ttarget; /* PID input target */
|
|
s32 tmax; /* PID input max */
|
|
s32 min,max; /* min and max target values */
|
|
};
|
|
|
|
struct wf_cpu_pid_state {
|
|
int first; /* first run of the loop */
|
|
int index; /* index of current power */
|
|
int tindex; /* index of current temp */
|
|
s32 target; /* current target value */
|
|
s32 last_delta; /* last Tactual - Ttarget */
|
|
s32 powers[WF_PID_MAX_HISTORY]; /* power history buffer */
|
|
s32 errors[WF_PID_MAX_HISTORY]; /* error history buffer */
|
|
s32 temps[2]; /* temp. history buffer */
|
|
|
|
struct wf_cpu_pid_param param;
|
|
};
|
|
|
|
extern void wf_cpu_pid_init(struct wf_cpu_pid_state *st,
|
|
struct wf_cpu_pid_param *param);
|
|
extern s32 wf_cpu_pid_run(struct wf_cpu_pid_state *st, s32 power, s32 temp);
|