Thread (3 messages) 3 messages, 2 authors, 2015-10-08

[PATCH v2 2/9] thermal: qcom: tsens-8916: Add support for 8916 family of SoCs

From: Rajendra Nayak <hidden>
Date: 2015-10-08 05:05:39
Also in: linux-arm-msm, linux-pm

On 09/21/2015 09:58 AM, Rajendra Nayak wrote:
[]..
quoted
quoted
+static inline int code_to_degc(u32 adc_code, const struct tsens_sensor *s)
+{
+    int degc, num, den;
+
+    num = (adc_code * SLOPE_FACTOR) - s->offset;
+    den = s->slope;
+
+    if (num > 0)
+        degc = num + (den / 2);
+    else if (num < 0)
+        degc = num - (den / 2);
+    else
+        degc = num;
+
+    degc /= den;
+
+    return degc;
+}
+
+int get_temp_common(struct tsens_device *tmdev, int id, int *temp)
+{
+    struct tsens_sensor *s = &tmdev->sensor[id];
+    u32 code;
+    unsigned int sensor_addr;
+    int last_temp = 0, ret;
+
+    sensor_addr = S0_ST_ADDR + s->hw_id * SN_ADDR_OFFSET;
+    ret = regmap_read(tmdev->map, sensor_addr, &code);
+    if (ret)
+        return ret;
+    last_temp = code & SN_ST_TEMP_MASK;
+
+    *temp = code_to_degc(last_temp, s) * 1000;
+
+    return 0;
+}
The way this function is coded the temperature will only ever change by
1C (i.e., 1000mC). Is there a chance that you're losing precision in the
code_to_degc conversion that could be preserved perhaps?

This is useful in scenarios where you use the power allocator governor
and the greater precision allows better power budget estimation.
I'll take a look to see if we can get better precision. Thanks.
I checked, and it does not look like these devices can support better precision
than degC.

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help