Lines Matching refs:pid
109 struct _pid pid; member
192 static inline void pid_reset(struct _pid *pid, int setpoint, int busy, in pid_reset() argument
194 pid->setpoint = setpoint; in pid_reset()
195 pid->deadband = deadband; in pid_reset()
196 pid->integral = int_tofp(integral); in pid_reset()
197 pid->last_err = int_tofp(setpoint) - int_tofp(busy); in pid_reset()
200 static inline void pid_p_gain_set(struct _pid *pid, int percent) in pid_p_gain_set() argument
202 pid->p_gain = div_fp(int_tofp(percent), int_tofp(100)); in pid_p_gain_set()
205 static inline void pid_i_gain_set(struct _pid *pid, int percent) in pid_i_gain_set() argument
207 pid->i_gain = div_fp(int_tofp(percent), int_tofp(100)); in pid_i_gain_set()
210 static inline void pid_d_gain_set(struct _pid *pid, int percent) in pid_d_gain_set() argument
212 pid->d_gain = div_fp(int_tofp(percent), int_tofp(100)); in pid_d_gain_set()
215 static signed int pid_calc(struct _pid *pid, int32_t busy) in pid_calc() argument
221 fp_error = int_tofp(pid->setpoint) - busy; in pid_calc()
223 if (abs(fp_error) <= int_tofp(pid->deadband)) in pid_calc()
226 pterm = mul_fp(pid->p_gain, fp_error); in pid_calc()
228 pid->integral += fp_error; in pid_calc()
239 if (pid->integral > integral_limit) in pid_calc()
240 pid->integral = integral_limit; in pid_calc()
241 if (pid->integral < -integral_limit) in pid_calc()
242 pid->integral = -integral_limit; in pid_calc()
244 dterm = mul_fp(pid->d_gain, fp_error - pid->last_err); in pid_calc()
245 pid->last_err = fp_error; in pid_calc()
247 result = pterm + mul_fp(pid->integral, pid->i_gain) + dterm; in pid_calc()
254 pid_p_gain_set(&cpu->pid, pid_params.p_gain_pct); in intel_pstate_busy_pid_reset()
255 pid_d_gain_set(&cpu->pid, pid_params.d_gain_pct); in intel_pstate_busy_pid_reset()
256 pid_i_gain_set(&cpu->pid, pid_params.i_gain_pct); in intel_pstate_busy_pid_reset()
258 pid_reset(&cpu->pid, pid_params.setpoint, 100, pid_params.deadband, 0); in intel_pstate_busy_pid_reset()
974 struct _pid *pid; in intel_pstate_adjust_busy_pstate() local
981 pid = &cpu->pid; in intel_pstate_adjust_busy_pstate()
984 ctl = pid_calc(pid, busy_scaled); in intel_pstate_adjust_busy_pstate()