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

Punit Agrawal punit.agrawal at arm.com
Thu Oct 8 07:32:13 PDT 2015


Rajendra Nayak <rnayak at codeaurora.org> writes:

> On 09/21/2015 09:58 AM, Rajendra Nayak wrote:
>> []..
>> 
>>>> +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.

Ah well. Thanks for checking!



More information about the linux-arm-kernel mailing list