diff options
author | Rocky Hao <rocky.hao@rock-chips.com> | 2018-05-28 17:47:28 +0800 |
---|---|---|
committer | Rocky Hao <rocky.hao@rock-chips.com> | 2018-06-01 14:36:32 +0800 |
commit | 24d10acefcd8b9a911862a51164fbc973dba2f88 (patch) | |
tree | 7d69d8edd221f315b4948b505528f9746070a268 /drivers/thermal | |
parent | f113aefebc63513f4f90810a6ee0f5e9f1a34846 (diff) |
thermal: rockchip: tune tsadc parameter of temperature prediction
init temp_last with a more suitable value. also we eliminate
the steady state error by ajusting the temp calc fomular.
extra useful log is added to mark tsadc is probed successfully.
Change-Id: If88031c10646437fa7b5152c70aeaebf93e4df05
Signed-off-by: Rocky Hao <rocky.hao@rock-chips.com>
Diffstat (limited to 'drivers/thermal')
-rw-r--r-- | drivers/thermal/rockchip_thermal.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c index d21c92963761..3b6dd43dc3fb 100644 --- a/drivers/thermal/rockchip_thermal.c +++ b/drivers/thermal/rockchip_thermal.c @@ -232,13 +232,15 @@ struct rockchip_thermal_data { #define GRF_CON_TSADC_CH_INV (0x10001 << 1) #define MIN_TEMP (-40000) +#define LOWEST_TEMP (-273000) #define MAX_TEMP (125000) +#define MAX_ENV_TEMP (85000) #define BASE (1024) #define BASE_SHIFT (10) #define START_DEBOUNCE_COUNT (100) -#define HIGHER_DEBOUNCE_TEMP (30) -#define LOWER_DEBOUNCE_TEMP (15) +#define HIGHER_DEBOUNCE_TEMP (30000) +#define LOWER_DEBOUNCE_TEMP (15000) /** * struct tsadc_table - code to temperature conversion table @@ -724,11 +726,20 @@ static int predict_temp(int temp) int temp_now; int prob_mid; int prob_now; - static int temp_last = 25; - static int prob_last = 20; + static int temp_last = LOWEST_TEMP; + static int prob_last = 160; static int bounding_cnt; /* + * init temp_last with a more suitable value, which mostly equals to + * temp reading from tsadc, but not higher than MAX_ENV_TEMP. If the + * temp is higher than MAX_ENV_TEMP, it is assumed to be abnormal + * value and temp_last is adjusted to MAX_ENV_TEMP. + */ + if (temp_last == LOWEST_TEMP) + temp_last = min(temp, MAX_ENV_TEMP); + + /* * Before START_DEBOUNCE_COUNT's samples of temperature, we consider * tsadc is stable, i.e. after that, the temperature may be not stable * and may have abnormal reading, so we set a bounding temperature. If @@ -753,7 +764,7 @@ static int predict_temp(int temp) gain = (prob_mid * BASE) / (prob_mid + cov_r); /* calculate the prediction of temperature */ - temp_now = temp_mid + (gain * (temp - temp_mid) >> BASE_SHIFT); + temp_now = (temp_mid * BASE + gain * (temp - temp_mid)) >> BASE_SHIFT; /* * Base on this time's Kalman Gain, ajust our probability of prediction @@ -1384,6 +1395,8 @@ static int rockchip_thermal_probe(struct platform_device *pdev) atomic_notifier_chain_register(&panic_notifier_list, &rockchip_thermal_panic_block); + dev_info(&pdev->dev, "tsadc is probed successfully!\n"); + return 0; err_disable_pclk: |