From: Caesar Wang <hidden> Date: 2015-01-21 17:30:05
This patch is merged on chromiumos/third_party/kernel.
https://chromium-review.googlesource.com/#/c/239190/
Tested on veyron boards.
Changes in v3:
Suggested-by Daniel Kurtz,
the check doesn't reject "code == 0xfff"
Fixed in rk_tsadcv2_code_to_temp(u32 code)
Changes in v2:
Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Caesar Wang (1):
thermal: rockchip: make temperature reporting much more accurate
drivers/thermal/rockchip_thermal.c | 32 ++++++++++++++++++++++----------
1 file changed, 22 insertions(+), 10 deletions(-)
--
1.9.1
From: Caesar Wang <hidden> Date: 2015-01-21 17:30:11
In general, the kernel should report temperature readings exactly as
reported by the hardware. The cpu / gpu thermal driver works in 5 degree
increments,but we ought to do more accurate. The temperature will do
linear interpolation between the entries in the table.
Test= $md5sum /dev/zero &
$while true; do grep "" /sys/class/thermal/thermal_zone[1-2]/temp;
sleep .5; done
e.g. We can get the result as follows:
/sys/class/thermal/thermal_zone1/temp:39994
/sys/class/thermal/thermal_zone2/temp:39086
/sys/class/thermal/thermal_zone1/temp:39994
/sys/class/thermal/thermal_zone2/temp:39540
/sys/class/thermal/thermal_zone1/temp:39540
/sys/class/thermal/thermal_zone2/temp:39540
/sys/class/thermal/thermal_zone1/temp:39540
/sys/class/thermal/thermal_zone2/temp:39994
Signed-off-by: Caesar Wang <redacted>
Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
Changes in v3:
Suggested-by Daniel Kurtz,
the check doesn't reject "code == 0xfff"
Fixed in rk_tsadcv2_code_to_temp(u32 code)
Changes in v2:
Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/thermal/rockchip_thermal.c | 32 ++++++++++++++++++++++----------
1 file changed, 22 insertions(+), 10 deletions(-)
From: Daniel Kurtz <hidden> Date: 2015-01-22 04:02:13
On Thu, Jan 22, 2015 at 1:29 AM, Caesar Wang [off-list ref] wrote:
quoted hunk
In general, the kernel should report temperature readings exactly as
reported by the hardware. The cpu / gpu thermal driver works in 5 degree
increments,but we ought to do more accurate. The temperature will do
linear interpolation between the entries in the table.
Test= $md5sum /dev/zero &
$while true; do grep "" /sys/class/thermal/thermal_zone[1-2]/temp;
sleep .5; done
e.g. We can get the result as follows:
/sys/class/thermal/thermal_zone1/temp:39994
/sys/class/thermal/thermal_zone2/temp:39086
/sys/class/thermal/thermal_zone1/temp:39994
/sys/class/thermal/thermal_zone2/temp:39540
/sys/class/thermal/thermal_zone1/temp:39540
/sys/class/thermal/thermal_zone2/temp:39540
/sys/class/thermal/thermal_zone1/temp:39540
/sys/class/thermal/thermal_zone2/temp:39994
Signed-off-by: Caesar Wang <redacted>
Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
Changes in v3:
Suggested-by Daniel Kurtz,
the check doesn't reject "code == 0xfff"
Fixed in rk_tsadcv2_code_to_temp(u32 code)
Changes in v2:
Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/thermal/rockchip_thermal.c | 32 ++++++++++++++++++++++----------
1 file changed, 22 insertions(+), 10 deletions(-)
@@ -213,7 +216,16 @@ static long rk_tsadcv2_code_to_temp(u32 code) mid = (low + high) / 2; }- return 125000;+ /*+ * The 5C granularity provided by the table is too much. Let's+ * assume that the relationship between sensor readings and+ * temperature between 2 table entries is linear and interpolate+ * to produce less granular result.+ */+ num = v2_code_table[mid].temp - v2_code_table[mid - 1].temp;+ num *= v2_code_table[mid - 1].code - code;+ denom = v2_code_table[mid - 1].code - v2_code_table[mid].code;+ return v2_code_table[mid - 1].temp + (num / denom); } /**--
From: Caesar Wang <hidden> Date: 2015-01-22 04:22:14
? 2015?01?22? 12:01, Daniel Kurtz ??:
On Thu, Jan 22, 2015 at 1:29 AM, Caesar Wang [off-list ref] wrote:
quoted
In general, the kernel should report temperature readings exactly as
reported by the hardware. The cpu / gpu thermal driver works in 5 degree
increments,but we ought to do more accurate. The temperature will do
linear interpolation between the entries in the table.
Test= $md5sum /dev/zero &
$while true; do grep "" /sys/class/thermal/thermal_zone[1-2]/temp;
sleep .5; done
e.g. We can get the result as follows:
/sys/class/thermal/thermal_zone1/temp:39994
/sys/class/thermal/thermal_zone2/temp:39086
/sys/class/thermal/thermal_zone1/temp:39994
/sys/class/thermal/thermal_zone2/temp:39540
/sys/class/thermal/thermal_zone1/temp:39540
/sys/class/thermal/thermal_zone2/temp:39540
/sys/class/thermal/thermal_zone1/temp:39540
/sys/class/thermal/thermal_zone2/temp:39994
Signed-off-by: Caesar Wang <redacted>
Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
Changes in v3:
Suggested-by Daniel Kurtz,
the check doesn't reject "code == 0xfff"
Fixed in rk_tsadcv2_code_to_temp(u32 code)
Changes in v2:
Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/thermal/rockchip_thermal.c | 32 ++++++++++++++++++++++----------
1 file changed, 22 insertions(+), 10 deletions(-)
@@ -213,7 +216,16 @@ static long rk_tsadcv2_code_to_temp(u32 code) mid = (low + high) / 2; }- return 125000;+ /*+ * The 5C granularity provided by the table is too much. Let's+ * assume that the relationship between sensor readings and+ * temperature between 2 table entries is linear and interpolate+ * to produce less granular result.+ */+ num = v2_code_table[mid].temp - v2_code_table[mid - 1].temp;+ num *= v2_code_table[mid - 1].code - code;+ denom = v2_code_table[mid - 1].code - v2_code_table[mid].code;+ return v2_code_table[mid - 1].temp + (num / denom); } /**--
1.9.1
--
Best regards
Caesar Wang (???)
???????????
Fuzhou Rockchip Electronics Co.Ltd
?????????????89????A?18??(350003)
Addr:No.18 Building, A District, No.89, software Boulevard Fuzhou, Fujian,PRC
Email:wxt at rock-chips.com
Tel:+86-591-83991906/07->8221
From: Daniel Kurtz <hidden> Date: 2015-01-22 04:25:28
On Thu, Jan 22, 2015 at 12:21 PM, Caesar Wang
[off-list ref] wrote:
? 2015?01?22? 12:01, Daniel Kurtz ??:
quoted
On Thu, Jan 22, 2015 at 1:29 AM, Caesar Wang [off-list ref] wrote:
quoted
In general, the kernel should report temperature readings exactly as
reported by the hardware. The cpu / gpu thermal driver works in 5 degree
increments,but we ought to do more accurate. The temperature will do
linear interpolation between the entries in the table.
Test= $md5sum /dev/zero &
$while true; do grep "" /sys/class/thermal/thermal_zone[1-2]/temp;
sleep .5; done
e.g. We can get the result as follows:
/sys/class/thermal/thermal_zone1/temp:39994
/sys/class/thermal/thermal_zone2/temp:39086
/sys/class/thermal/thermal_zone1/temp:39994
/sys/class/thermal/thermal_zone2/temp:39540
/sys/class/thermal/thermal_zone1/temp:39540
/sys/class/thermal/thermal_zone2/temp:39540
/sys/class/thermal/thermal_zone1/temp:39540
/sys/class/thermal/thermal_zone2/temp:39994
Signed-off-by: Caesar Wang <redacted>
Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
Changes in v3:
Suggested-by Daniel Kurtz,
the check doesn't reject "code == 0xfff"
Fixed in rk_tsadcv2_code_to_temp(u32 code)
Changes in v2:
Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/thermal/rockchip_thermal.c | 32
++++++++++++++++++++++----------
1 file changed, 22 insertions(+), 10 deletions(-)
diff --git a/drivers/thermal/rockchip_thermal.c
b/drivers/thermal/rockchip_thermal.c
index 1bcddfc..ce18007 100644
v2_code_table[high].code)
- return 125000; /* No code available, return max
temperature */
+ return rk_tsadcv2_code_to_temp(code);
Isn't this an infinite recursion?
No, I think we can try check if it is happened.
Maybe we can return a warning/error for it.
I mean, if the 'if' condition is true, then this will just call the
same function again with the same code, and again, and again...
Just return an error code here, -ENOENT maybe?
I am not sure what error code is appropriate.
@@ -213,7 +216,16 @@ static long rk_tsadcv2_code_to_temp(u32 code) mid = (low + high) / 2; }- return 125000;+ /*+ * The 5C granularity provided by the table is too much. Let's+ * assume that the relationship between sensor readings and+ * temperature between 2 table entries is linear and interpolate+ * to produce less granular result.+ */+ num = v2_code_table[mid].temp - v2_code_table[mid - 1].temp;+ num *= v2_code_table[mid - 1].code - code;+ denom = v2_code_table[mid - 1].code - v2_code_table[mid].code;+ return v2_code_table[mid - 1].temp + (num / denom); } /**--
1.9.1
--
Best regards
Caesar Wang (???)
???????????
Fuzhou Rockchip Electronics Co.Ltd
?????????????89????A?18??(350003)
Addr:No.18 Building, A District, No.89, software Boulevard Fuzhou,
Fujian,PRC
Email:wxt at rock-chips.com
Tel:+86-591-83991906/07->8221
From: Caesar Wang <hidden> Date: 2015-01-22 04:59:00
? 2015?01?22? 12:25, Daniel Kurtz ??:
On Thu, Jan 22, 2015 at 12:21 PM, Caesar Wang
[off-list ref] wrote:
quoted
? 2015?01?22? 12:01, Daniel Kurtz ??:
quoted
On Thu, Jan 22, 2015 at 1:29 AM, Caesar Wang [off-list ref] wrote:
quoted
In general, the kernel should report temperature readings exactly as
reported by the hardware. The cpu / gpu thermal driver works in 5 degree
increments,but we ought to do more accurate. The temperature will do
linear interpolation between the entries in the table.
Test= $md5sum /dev/zero &
$while true; do grep "" /sys/class/thermal/thermal_zone[1-2]/temp;
sleep .5; done
e.g. We can get the result as follows:
/sys/class/thermal/thermal_zone1/temp:39994
/sys/class/thermal/thermal_zone2/temp:39086
/sys/class/thermal/thermal_zone1/temp:39994
/sys/class/thermal/thermal_zone2/temp:39540
/sys/class/thermal/thermal_zone1/temp:39540
/sys/class/thermal/thermal_zone2/temp:39540
/sys/class/thermal/thermal_zone1/temp:39540
/sys/class/thermal/thermal_zone2/temp:39994
Signed-off-by: Caesar Wang <redacted>
Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
Changes in v3:
Suggested-by Daniel Kurtz,
the check doesn't reject "code == 0xfff"
Fixed in rk_tsadcv2_code_to_temp(u32 code)
Changes in v2:
Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/thermal/rockchip_thermal.c | 32
++++++++++++++++++++++----------
1 file changed, 22 insertions(+), 10 deletions(-)
diff --git a/drivers/thermal/rockchip_thermal.c
b/drivers/thermal/rockchip_thermal.c
index 1bcddfc..ce18007 100644
v2_code_table[high].code)
- return 125000; /* No code available, return max
temperature */
+ return rk_tsadcv2_code_to_temp(code);
Isn't this an infinite recursion?
No, I think we can try check if it is happened.
Maybe we can return a warning/error for it.
I mean, if the 'if' condition is true, then this will just call the
same function again with the same code, and again, and again...
Just return an error code here, -ENOENT maybe?
I am not sure what error code is appropriate.
@@ -213,7 +216,16 @@ static long rk_tsadcv2_code_to_temp(u32 code) mid = (low + high) / 2; }- return 125000;+ /*+ * The 5C granularity provided by the table is too much. Let's+ * assume that the relationship between sensor readings and+ * temperature between 2 table entries is linear and interpolate+ * to produce less granular result.+ */+ num = v2_code_table[mid].temp - v2_code_table[mid - 1].temp;+ num *= v2_code_table[mid - 1].code - code;+ denom = v2_code_table[mid - 1].code - v2_code_table[mid].code;+ return v2_code_table[mid - 1].temp + (num / denom); } /**--
1.9.1
--
Best regards
Caesar Wang (???)
???????????
Fuzhou Rockchip Electronics Co.Ltd
?????????????89????A?18??(350003)
Addr:No.18 Building, A District, No.89, software Boulevard Fuzhou,
Fujian,PRC
Email:wxt at rock-chips.com
Tel:+86-591-83991906/07->8221