Commit 955fb871 authored by Zhang Rui's avatar Zhang Rui Committed by Rafael J. Wysocki

thermal/intel/intel_soc_dts_iosf: Use Intel TCC library

Cleanup the code by using Intel TCC library for TCC (Thermal Control
Circuitry) MSR access.
Signed-off-by: default avatarZhang Rui <rui.zhang@intel.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent d91a4714
...@@ -32,6 +32,7 @@ config INTEL_SOC_DTS_IOSF_CORE ...@@ -32,6 +32,7 @@ config INTEL_SOC_DTS_IOSF_CORE
tristate tristate
depends on X86 && PCI depends on X86 && PCI
select IOSF_MBI select IOSF_MBI
select INTEL_TCC
help help
This is becoming a common feature for Intel SoCs to expose the additional This is becoming a common feature for Intel SoCs to expose the additional
digital temperature sensors (DTSs) using side band interface (IOSF). This digital temperature sensors (DTSs) using side band interface (IOSF). This
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/intel_tcc.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
...@@ -45,32 +46,6 @@ ...@@ -45,32 +46,6 @@
/* DTS0 and DTS 1 */ /* DTS0 and DTS 1 */
#define SOC_MAX_DTS_SENSORS 2 #define SOC_MAX_DTS_SENSORS 2
static int get_tj_max(u32 *tj_max)
{
u32 eax, edx;
u32 val;
int err;
err = rdmsr_safe(MSR_IA32_TEMPERATURE_TARGET, &eax, &edx);
if (err)
goto err_ret;
else {
val = (eax >> 16) & 0xff;
if (val)
*tj_max = val * 1000;
else {
err = -EINVAL;
goto err_ret;
}
}
return 0;
err_ret:
*tj_max = 0;
return err;
}
static int sys_get_trip_temp(struct thermal_zone_device *tzd, int trip, static int sys_get_trip_temp(struct thermal_zone_device *tzd, int trip,
int *temp) int *temp)
{ {
...@@ -415,8 +390,9 @@ struct intel_soc_dts_sensors *intel_soc_dts_iosf_init( ...@@ -415,8 +390,9 @@ struct intel_soc_dts_sensors *intel_soc_dts_iosf_init(
if (!trip_count || read_only_trip_count > trip_count) if (!trip_count || read_only_trip_count > trip_count)
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
if (get_tj_max(&tj_max)) tj_max = intel_tcc_get_tjmax(-1);
return ERR_PTR(-EINVAL); if (tj_max < 0)
return ERR_PTR(tj_max);
sensors = kzalloc(sizeof(*sensors), GFP_KERNEL); sensors = kzalloc(sizeof(*sensors), GFP_KERNEL);
if (!sensors) if (!sensors)
...@@ -475,4 +451,5 @@ void intel_soc_dts_iosf_exit(struct intel_soc_dts_sensors *sensors) ...@@ -475,4 +451,5 @@ void intel_soc_dts_iosf_exit(struct intel_soc_dts_sensors *sensors)
} }
EXPORT_SYMBOL_GPL(intel_soc_dts_iosf_exit); EXPORT_SYMBOL_GPL(intel_soc_dts_iosf_exit);
MODULE_IMPORT_NS(INTEL_TCC);
MODULE_LICENSE("GPL v2"); MODULE_LICENSE("GPL v2");
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment