summaryrefslogtreecommitdiff
path: root/drivers/thermal/intel
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2023-04-14 18:14:02 +0300
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2023-04-14 18:14:02 +0300
commit065ca2a8c6ee601d990ea10efc71b861c5afc4fd (patch)
treeb158f7026bdf08cbc2fdd7675568e76342af4336 /drivers/thermal/intel
parent117e4e5bd9d47b89777dbf6b37a709dcfe59520f (diff)
parentd4d8516624e1042d33011cf93b6e9c220a22c9f0 (diff)
downloadlinux-065ca2a8c6ee601d990ea10efc71b861c5afc4fd.tar.xz
Merge back Intel thermal control material for 6.4-rc1.
Diffstat (limited to 'drivers/thermal/intel')
-rw-r--r--drivers/thermal/intel/int340x_thermal/int3400_thermal.c2
-rw-r--r--drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c4
-rw-r--r--drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c4
-rw-r--r--drivers/thermal/intel/intel_pch_thermal.c2
-rw-r--r--drivers/thermal/intel/intel_quark_dts_thermal.c6
-rw-r--r--drivers/thermal/intel/intel_soc_dts_iosf.c13
-rw-r--r--drivers/thermal/intel/x86_pkg_temp_thermal.c12
7 files changed, 21 insertions, 22 deletions
diff --git a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c
index d0295123cc3e..810231b59dcd 100644
--- a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c
+++ b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c
@@ -497,7 +497,7 @@ static int int3400_thermal_get_temp(struct thermal_zone_device *thermal,
static int int3400_thermal_change_mode(struct thermal_zone_device *thermal,
enum thermal_device_mode mode)
{
- struct int3400_thermal_priv *priv = thermal->devdata;
+ struct int3400_thermal_priv *priv = thermal_zone_device_priv(thermal);
int result = 0;
if (!priv)
diff --git a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c b/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c
index 00665967ca52..89cf007146ea 100644
--- a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c
+++ b/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c
@@ -14,7 +14,7 @@
static int int340x_thermal_get_zone_temp(struct thermal_zone_device *zone,
int *temp)
{
- struct int34x_thermal_zone *d = zone->devdata;
+ struct int34x_thermal_zone *d = thermal_zone_device_priv(zone);
unsigned long long tmp;
acpi_status status;
@@ -41,7 +41,7 @@ static int int340x_thermal_get_zone_temp(struct thermal_zone_device *zone,
static int int340x_thermal_set_trip_temp(struct thermal_zone_device *zone,
int trip, int temp)
{
- struct int34x_thermal_zone *d = zone->devdata;
+ struct int34x_thermal_zone *d = thermal_zone_device_priv(zone);
char name[] = {'P', 'A', 'T', '0' + trip, '\0'};
acpi_status status;
diff --git a/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c b/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c
index d71ee50e7878..5d4fe48366ad 100644
--- a/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c
+++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c
@@ -135,7 +135,7 @@ static irqreturn_t proc_thermal_irq_handler(int irq, void *devid)
static int sys_get_curr_temp(struct thermal_zone_device *tzd, int *temp)
{
- struct proc_thermal_pci *pci_info = tzd->devdata;
+ struct proc_thermal_pci *pci_info = thermal_zone_device_priv(tzd);
u32 _temp;
proc_thermal_mmio_read(pci_info, PROC_THERMAL_MMIO_PKG_TEMP, &_temp);
@@ -146,7 +146,7 @@ static int sys_get_curr_temp(struct thermal_zone_device *tzd, int *temp)
static int sys_set_trip_temp(struct thermal_zone_device *tzd, int trip, int temp)
{
- struct proc_thermal_pci *pci_info = tzd->devdata;
+ struct proc_thermal_pci *pci_info = thermal_zone_device_priv(tzd);
int tjmax, _temp;
if (temp <= 0) {
diff --git a/drivers/thermal/intel/intel_pch_thermal.c b/drivers/thermal/intel/intel_pch_thermal.c
index b855d031a855..dce50d239357 100644
--- a/drivers/thermal/intel/intel_pch_thermal.c
+++ b/drivers/thermal/intel/intel_pch_thermal.c
@@ -119,7 +119,7 @@ static int pch_wpt_add_acpi_psv_trip(struct pch_thermal_device *ptd, int trip)
static int pch_thermal_get_temp(struct thermal_zone_device *tzd, int *temp)
{
- struct pch_thermal_device *ptd = tzd->devdata;
+ struct pch_thermal_device *ptd = thermal_zone_device_priv(tzd);
*temp = GET_WPT_TEMP(WPT_TEMP_TSR & readw(ptd->hw_base + WPT_TEMP));
return 0;
diff --git a/drivers/thermal/intel/intel_quark_dts_thermal.c b/drivers/thermal/intel/intel_quark_dts_thermal.c
index ffdc95047838..646ca8bd40a9 100644
--- a/drivers/thermal/intel/intel_quark_dts_thermal.c
+++ b/drivers/thermal/intel/intel_quark_dts_thermal.c
@@ -120,7 +120,7 @@ static DEFINE_MUTEX(dts_update_mutex);
static int soc_dts_enable(struct thermal_zone_device *tzd)
{
u32 out;
- struct soc_sensor_entry *aux_entry = tzd->devdata;
+ struct soc_sensor_entry *aux_entry = thermal_zone_device_priv(tzd);
int ret;
ret = iosf_mbi_read(QRK_MBI_UNIT_RMU, MBI_REG_READ,
@@ -148,7 +148,7 @@ static int soc_dts_enable(struct thermal_zone_device *tzd)
static int soc_dts_disable(struct thermal_zone_device *tzd)
{
u32 out;
- struct soc_sensor_entry *aux_entry = tzd->devdata;
+ struct soc_sensor_entry *aux_entry = thermal_zone_device_priv(tzd);
int ret;
ret = iosf_mbi_read(QRK_MBI_UNIT_RMU, MBI_REG_READ,
@@ -250,7 +250,7 @@ failed:
static inline int sys_set_trip_temp(struct thermal_zone_device *tzd, int trip,
int temp)
{
- return update_trip_temp(tzd->devdata, trip, temp);
+ return update_trip_temp(thermal_zone_device_priv(tzd), trip, temp);
}
static int sys_get_curr_temp(struct thermal_zone_device *tzd,
diff --git a/drivers/thermal/intel/intel_soc_dts_iosf.c b/drivers/thermal/intel/intel_soc_dts_iosf.c
index 8c26f7b2316b..f99dc7e4ae89 100644
--- a/drivers/thermal/intel/intel_soc_dts_iosf.c
+++ b/drivers/thermal/intel/intel_soc_dts_iosf.c
@@ -54,7 +54,7 @@ static int sys_get_trip_temp(struct thermal_zone_device *tzd, int trip,
struct intel_soc_dts_sensor_entry *dts;
struct intel_soc_dts_sensors *sensors;
- dts = tzd->devdata;
+ dts = thermal_zone_device_priv(tzd);
sensors = dts->sensors;
mutex_lock(&sensors->dts_update_lock);
status = iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ,
@@ -168,7 +168,7 @@ err_restore_ptps:
static int sys_set_trip_temp(struct thermal_zone_device *tzd, int trip,
int temp)
{
- struct intel_soc_dts_sensor_entry *dts = tzd->devdata;
+ struct intel_soc_dts_sensor_entry *dts = thermal_zone_device_priv(tzd);
struct intel_soc_dts_sensors *sensors = dts->sensors;
int status;
@@ -176,7 +176,7 @@ static int sys_set_trip_temp(struct thermal_zone_device *tzd, int trip,
return -EINVAL;
mutex_lock(&sensors->dts_update_lock);
- status = update_trip_temp(tzd->devdata, trip, temp,
+ status = update_trip_temp(dts, trip, temp,
dts->trip_types[trip]);
mutex_unlock(&sensors->dts_update_lock);
@@ -186,9 +186,7 @@ static int sys_set_trip_temp(struct thermal_zone_device *tzd, int trip,
static int sys_get_trip_type(struct thermal_zone_device *tzd,
int trip, enum thermal_trip_type *type)
{
- struct intel_soc_dts_sensor_entry *dts;
-
- dts = tzd->devdata;
+ struct intel_soc_dts_sensor_entry *dts = thermal_zone_device_priv(tzd);
*type = dts->trip_types[trip];
@@ -200,11 +198,10 @@ static int sys_get_curr_temp(struct thermal_zone_device *tzd,
{
int status;
u32 out;
- struct intel_soc_dts_sensor_entry *dts;
+ struct intel_soc_dts_sensor_entry *dts = thermal_zone_device_priv(tzd);
struct intel_soc_dts_sensors *sensors;
unsigned long raw;
- dts = tzd->devdata;
sensors = dts->sensors;
status = iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ,
SOC_DTS_OFFSET_TEMP, &out);
diff --git a/drivers/thermal/intel/x86_pkg_temp_thermal.c b/drivers/thermal/intel/x86_pkg_temp_thermal.c
index 1c2de84742df..11a7f8108bbb 100644
--- a/drivers/thermal/intel/x86_pkg_temp_thermal.c
+++ b/drivers/thermal/intel/x86_pkg_temp_thermal.c
@@ -107,7 +107,7 @@ static struct zone_device *pkg_temp_thermal_get_dev(unsigned int cpu)
static int sys_get_curr_temp(struct thermal_zone_device *tzd, int *temp)
{
- struct zone_device *zonedev = tzd->devdata;
+ struct zone_device *zonedev = thermal_zone_device_priv(tzd);
int val;
val = intel_tcc_get_temp(zonedev->cpu, true);
@@ -122,16 +122,18 @@ static int sys_get_curr_temp(struct thermal_zone_device *tzd, int *temp)
static int
sys_set_trip_temp(struct thermal_zone_device *tzd, int trip, int temp)
{
- struct zone_device *zonedev = tzd->devdata;
+ struct zone_device *zonedev = thermal_zone_device_priv(tzd);
u32 l, h, mask, shift, intr;
- int tj_max, ret;
+ int tj_max, val, ret;
tj_max = intel_tcc_get_tjmax(zonedev->cpu);
if (tj_max < 0)
return tj_max;
tj_max *= 1000;
- if (trip >= MAX_NUMBER_OF_TRIPS || temp >= tj_max)
+ val = (tj_max - temp)/1000;
+
+ if (trip >= MAX_NUMBER_OF_TRIPS || val < 0 || val > 0x7f)
return -EINVAL;
ret = rdmsr_on_cpu(zonedev->cpu, MSR_IA32_PACKAGE_THERM_INTERRUPT,
@@ -156,7 +158,7 @@ sys_set_trip_temp(struct thermal_zone_device *tzd, int trip, int temp)
if (!temp) {
l &= ~intr;
} else {
- l |= (tj_max - temp)/1000 << shift;
+ l |= val << shift;
l |= intr;
}