Lines Matching refs:pid
107 struct _pid pid; member
169 static inline void pid_reset(struct _pid *pid, int setpoint, int busy, in pid_reset() argument
171 pid->setpoint = setpoint; in pid_reset()
172 pid->deadband = deadband; in pid_reset()
173 pid->integral = int_tofp(integral); in pid_reset()
174 pid->last_err = int_tofp(setpoint) - int_tofp(busy); in pid_reset()
177 static inline void pid_p_gain_set(struct _pid *pid, int percent) in pid_p_gain_set() argument
179 pid->p_gain = div_fp(int_tofp(percent), int_tofp(100)); in pid_p_gain_set()
182 static inline void pid_i_gain_set(struct _pid *pid, int percent) in pid_i_gain_set() argument
184 pid->i_gain = div_fp(int_tofp(percent), int_tofp(100)); in pid_i_gain_set()
187 static inline void pid_d_gain_set(struct _pid *pid, int percent) in pid_d_gain_set() argument
189 pid->d_gain = div_fp(int_tofp(percent), int_tofp(100)); in pid_d_gain_set()
192 static signed int pid_calc(struct _pid *pid, int32_t busy) in pid_calc() argument
198 fp_error = int_tofp(pid->setpoint) - busy; in pid_calc()
200 if (abs(fp_error) <= int_tofp(pid->deadband)) in pid_calc()
203 pterm = mul_fp(pid->p_gain, fp_error); in pid_calc()
205 pid->integral += fp_error; in pid_calc()
216 if (pid->integral > integral_limit) in pid_calc()
217 pid->integral = integral_limit; in pid_calc()
218 if (pid->integral < -integral_limit) in pid_calc()
219 pid->integral = -integral_limit; in pid_calc()
221 dterm = mul_fp(pid->d_gain, fp_error - pid->last_err); in pid_calc()
222 pid->last_err = fp_error; in pid_calc()
224 result = pterm + mul_fp(pid->integral, pid->i_gain) + dterm; in pid_calc()
231 pid_p_gain_set(&cpu->pid, pid_params.p_gain_pct); in intel_pstate_busy_pid_reset()
232 pid_d_gain_set(&cpu->pid, pid_params.d_gain_pct); in intel_pstate_busy_pid_reset()
233 pid_i_gain_set(&cpu->pid, pid_params.i_gain_pct); in intel_pstate_busy_pid_reset()
235 pid_reset(&cpu->pid, pid_params.setpoint, 100, pid_params.deadband, 0); in intel_pstate_busy_pid_reset()
844 struct _pid *pid; in intel_pstate_adjust_busy_pstate() local
847 pid = &cpu->pid; in intel_pstate_adjust_busy_pstate()
850 ctl = pid_calc(pid, busy_scaled); in intel_pstate_adjust_busy_pstate()