diff options
author | Daniel Fu <danifu@nvidia.com> | 2012-07-11 15:11:56 +0800 |
---|---|---|
committer | Simone Willett <swillett@nvidia.com> | 2012-07-12 13:03:43 -0700 |
commit | 127f5dd94b954298db3b205e6c5eeea946ff13cc (patch) | |
tree | 13c875846171308ce6e38d00ef615d50f2536f1f /drivers | |
parent | 43b9194b9f6dc2053ccfe2d61162cd3089c5ef9c (diff) |
hwmon: tegra: tsensor: improve counter accuracy
When set threshold of tsensor,convert the temp to counter.
The counter convert from temp is with ~1.8C average error.
Improved the accuracy, make it to be ~0.1C.
Bug 1015288
Change-Id: Icab03b559eaeb8846dd1191869afe39c9965f934
Signed-off-by: Daniel Fu <danifu@nvidia.com>
Reviewed-on: http://git-master/r/114904
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Bitan Biswas <bbiswas@nvidia.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/hwmon/tegra-tsensor.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/drivers/hwmon/tegra-tsensor.c b/drivers/hwmon/tegra-tsensor.c index 6cd43be93cf9..1c372a4bcce5 100644 --- a/drivers/hwmon/tegra-tsensor.c +++ b/drivers/hwmon/tegra-tsensor.c @@ -1056,7 +1056,7 @@ static void get_quadratic_roots(struct tegra_tsensor_data *data, int v_e_minus6_b2, v_e_minus6_4ac; int v_e_minus6_b2_minus4ac; int v_e_minus6_sqrt_b2_minus4ac; - int v_e_minus6_2mA; + s64 v_e_minus12_2mA; int root1, root2; int temp_rem; bool is_neg; @@ -1086,10 +1086,9 @@ static void get_quadratic_roots(struct tegra_tsensor_data *data, is_neg = true; } temp_rem = do_div(temp_64, 1000000); - temp_rem = do_div(temp_64, 1000000);/* divide by 10^6 again */ if (is_neg) temp_64 *= -1; - v_e_minus6_2mA = (s32)temp_64; + v_e_minus12_2mA = temp_64; /* computed 2mA */ /* m * B^2 calculation */ @@ -1144,18 +1143,16 @@ static void get_quadratic_roots(struct tegra_tsensor_data *data, "temp=%d\n", data->A_e_minus12, data->B_e_minus6, data->m_e_minus6, data->n_e_minus6, data->p_e_minus2, (int)temp); - dev_dbg(data->hwmon_dev, "2mB_n=%d, 2mA=%d, mB2_nB_p_minusTemp=%d," + dev_dbg(data->hwmon_dev, "2mB_n=%d, 2mA=%lld, mB2_nB_p_minusTemp=%d," "b2_minus4ac=%d\n", v_e_minus6_2mB_n, - v_e_minus6_2mA, v_e_minus4_mB2_nB_p_minusTemp, + v_e_minus12_2mA, v_e_minus4_mB2_nB_p_minusTemp, v_e_minus6_b2_minus4ac); - root1 = DIV_ROUND_CLOSEST(( - -v_e_minus6_2mB_n - v_e_minus6_sqrt_b2_minus4ac), - v_e_minus6_2mA); + temp_64=(s64)(-v_e_minus6_2mB_n - v_e_minus6_sqrt_b2_minus4ac) * 1000000; + root1=(s32)div64_s64(temp_64, v_e_minus12_2mA); - root2 = DIV_ROUND_CLOSEST(( - -v_e_minus6_2mB_n + v_e_minus6_sqrt_b2_minus4ac), - v_e_minus6_2mA); + temp_64=(s64)(-v_e_minus6_2mB_n + v_e_minus6_sqrt_b2_minus4ac) * 1000000; + root2=(s32)div64_s64(temp_64, v_e_minus12_2mA); dev_dbg(data->hwmon_dev, "new expr: temp=%d, root1=%d, root2=%d\n", temp, root1, root2); |