From d489e9eab5e854ca996753f7fe314f1337e1308c Mon Sep 17 00:00:00 2001 From: mkarthik Date: Wed, 1 Jul 2020 18:56:10 +0530 Subject: thermal: pwm-fan: Add tach feedback support Why? The current implementation of the pwm-fan driver only writes a pwm value to the HW when requested. There is no tachometer rpm read back to check if the thermal performance is as expected. This change aims to add the rpm offsets necessary to maintain the desired fan rpm. How? A new work queue is added which gets the pwm fan rpm and checks the same for a rpm diff tolerance value. In case the tolerance value is exceeded, the next pwm corresponding to the next rpm ramp index is written to the pwm controller. Bug 200646929 Change-Id: Iff780a7edf98ca457ace10079149925adf06189d Signed-off-by: Mantravadi Karthik Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2369412 Tested-by: Rajkumar Kasirajan Tested-by: mobile promotions Reviewed-by: Rajkumar Kasirajan Reviewed-by: Bibek Basu Reviewed-by: Sandipan Patra Reviewed-by: mobile promotions GVS: Gerrit_Virtual_Submit --- include/linux/therm_est.h | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'include/linux') diff --git a/include/linux/therm_est.h b/include/linux/therm_est.h index 6cca50946..fa1ea7ffc 100644 --- a/include/linux/therm_est.h +++ b/include/linux/therm_est.h @@ -1,7 +1,7 @@ /* * include/linux/therm_est.h * - * Copyright (c) 2010-2019, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2010-2020, NVIDIA CORPORATION. All rights reserved. * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and @@ -177,6 +177,22 @@ struct fan_dev_data { u64 last_irq; u64 old_irq; + struct device_node *of_node_tach; + bool use_tach_feedback; + int rpm_diff_tolerance; + int fan_rpm_target_hit_count; + int fan_rpm_ramp_index; + int next_target_rpm; + int fan_ramp_time_ms; + struct delayed_work fan_ramp_pwm_work; + struct delayed_work fan_ramp_rpm_work; + struct device *pwm_tach_dev; + struct mutex pwm_set; + bool fan_rpm_in_limits; + int rpm_valid_retry_delay; + int rpm_invalid_retry_delay; + int rpm_valid_retry_count; + bool continuous_gov; }; @@ -222,4 +238,20 @@ struct therm_fan_estimator { bool is_continuous_gov; }; + +#if IS_ENABLED(CONFIG_GENERIC_PWM_TACHOMETER) +int pwm_tach_capture_rpm(struct device *dev); +struct device *pwm_get_tach_dev(void); +#else +static inline int pwm_tach_capture_rpm(struct device *dev) +{ + return 0; +} + +static inline struct device *pwm_get_tach_dev(void) +{ + return NULL; +} +#endif + #endif /* _LINUX_THERM_EST_H */ -- cgit v1.2.2