mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-24 11:16:51 +00:00
projects/Cuboxi/patches/linux: add patch to make CPU temp output to work
Signed-off-by: Stephan Raue <stephan@openelec.tv>
This commit is contained in:
parent
6d3f2f3d8d
commit
53127541e4
85
projects/Cuboxi/patches/linux/linux-imx6-thermal.patch
Normal file
85
projects/Cuboxi/patches/linux/linux-imx6-thermal.patch
Normal file
@ -0,0 +1,85 @@
|
||||
diff --git a/drivers/mxc/thermal/thermal.c b/drivers/mxc/thermal/thermal.c
|
||||
index cbe771d..8c08838 100644
|
||||
--- a/drivers/mxc/thermal/thermal.c
|
||||
+++ b/drivers/mxc/thermal/thermal.c
|
||||
@@ -22,7 +22,7 @@
|
||||
*
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
*/
|
||||
-
|
||||
+#define DEBUG
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/dmi.h>
|
||||
@@ -123,17 +123,17 @@
|
||||
ANATOP_TRIPS_HOT | ANATOP_TRIPS_ACTIVE)
|
||||
|
||||
#define _COMPONENT ANATOP_THERMAL_COMPONENT
|
||||
-#define KELVIN_OFFSET 273
|
||||
+#define MKELVIN_OFFSET 273000
|
||||
#define POLLING_FREQ 2000 /* 2s */
|
||||
-#define TEMP_CRITICAL 373 /* 100 C*/
|
||||
-#define TEMP_HOT 363 /* 90 C*/
|
||||
-#define TEMP_ACTIVE 353 /* 80 C*/
|
||||
+#define TEMP_CRITICAL 373000 /* 100000 mC*/
|
||||
+#define TEMP_HOT 363000 /* 90000 mC*/
|
||||
+#define TEMP_ACTIVE 353000 /* 80000 mC*/
|
||||
#define MEASURE_FREQ 3276 /* 3276 RTC clocks delay, 100ms */
|
||||
#define KELVIN_TO_CEL(t, off) (((t) - (off)))
|
||||
#define CEL_TO_KELVIN(t, off) (((t) + (off)))
|
||||
#define DEFAULT_RATIO 145
|
||||
#define DEFAULT_N40C 1563
|
||||
-#define REG_VALUE_TO_CEL(ratio, raw) ((raw_n40c - raw) * 100 / ratio - 40)
|
||||
+#define REG_VALUE_TO_MCEL(ratio, raw) (((raw_n40c - raw) * 100 / ratio - 40) * 1000)
|
||||
#define ANATOP_DEBUG false
|
||||
#define THERMAL_FUSE_NAME "/sys/fsl_otp/HW_OCOTP_ANA1"
|
||||
|
||||
@@ -282,7 +282,7 @@ static int anatop_thermal_get_temp(struct thermal_zone_device *thermal,
|
||||
return -EINVAL;
|
||||
|
||||
if (!ratio || suspend_flag) {
|
||||
- *temp = KELVIN_TO_CEL(TEMP_ACTIVE, KELVIN_OFFSET);
|
||||
+ *temp = KELVIN_TO_CEL(TEMP_ACTIVE, MKELVIN_OFFSET);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -332,17 +332,17 @@ static int anatop_thermal_get_temp(struct thermal_zone_device *thermal,
|
||||
/* only the temp between -40C and 125C is valid, this
|
||||
is for save */
|
||||
if (tmp <= raw_n40c && tmp >= raw_125c)
|
||||
- tz->temperature = REG_VALUE_TO_CEL(ratio, tmp);
|
||||
+ tz->temperature = REG_VALUE_TO_MCEL(ratio, tmp);
|
||||
else {
|
||||
printk(KERN_WARNING "Invalid temperature, force it to 25C\n");
|
||||
- tz->temperature = 25;
|
||||
+ tz->temperature = 25000;
|
||||
}
|
||||
|
||||
if (debug_mask & DEBUG_VERBOSE)
|
||||
pr_info("Cooling device Temperature is %lu C\n", tz->temperature);
|
||||
|
||||
- *temp = (cooling_device_disable && tz->temperature >= KELVIN_TO_CEL(TEMP_CRITICAL, KELVIN_OFFSET)) ?
|
||||
- KELVIN_TO_CEL(TEMP_CRITICAL - 1, KELVIN_OFFSET) : tz->temperature;
|
||||
+ *temp = (cooling_device_disable && tz->temperature >= KELVIN_TO_CEL(TEMP_CRITICAL, MKELVIN_OFFSET)) ?
|
||||
+ KELVIN_TO_CEL(TEMP_CRITICAL - 1, MKELVIN_OFFSET) : tz->temperature;
|
||||
|
||||
/* Set alarm threshold if necessary */
|
||||
if ((__raw_readl(anatop_base + HW_ANADIG_TEMPSENSE0) &
|
||||
@@ -822,7 +822,7 @@ static int anatop_thermal_add(struct anatop_device *device)
|
||||
if (result)
|
||||
goto free_memory;
|
||||
|
||||
- tz->kelvin_offset = KELVIN_OFFSET;
|
||||
+ tz->kelvin_offset = MKELVIN_OFFSET;
|
||||
|
||||
result = anatop_thermal_register_thermal_zone(tz);
|
||||
if (result)
|
||||
@@ -909,7 +909,7 @@ static int anatop_thermal_counting_ratio(unsigned int fuse_data)
|
||||
raw_n40c = raw_25c + (13 * ratio) / 20;
|
||||
raw_125c = raw_25c - ratio;
|
||||
/* Init default critical temp to set alarm */
|
||||
- raw_critical = raw_25c - ratio * (KELVIN_TO_CEL(TEMP_CRITICAL, KELVIN_OFFSET) - 25) / 100;
|
||||
+ raw_critical = raw_25c - ratio * (KELVIN_TO_CEL(TEMP_CRITICAL, MKELVIN_OFFSET) - 25) / 100000;
|
||||
clk_enable(pll3_clk);
|
||||
|
||||
return ret;
|
Loading…
x
Reference in New Issue
Block a user