Skip to content

Commit 38e44da

Browse files
Brian Bianzhang-rui
authored andcommitted
thermal: int3400_thermal: process "thermal table changed" event
Some BIOS implement ACPI notification code 0x83 to indicate active relationship table(ART) and/or thermal relationship table(TRT) changes to INT3400 device. This event needs to be propagated to user space so that it can be handled by the user space thermal daemon. Signed-off-by: Brian Bian <brian.bian@linux.intel.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
1 parent 1820142 commit 38e44da

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

drivers/thermal/int340x_thermal/int3400_thermal.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#include <linux/thermal.h>
1717
#include "acpi_thermal_rel.h"
1818

19+
#define INT3400_THERMAL_TABLE_CHANGED 0x83
20+
1921
enum int3400_thermal_uuid {
2022
INT3400_THERMAL_PASSIVE_1,
2123
INT3400_THERMAL_ACTIVE,
@@ -185,6 +187,35 @@ static int int3400_thermal_run_osc(acpi_handle handle,
185187
return result;
186188
}
187189

190+
static void int3400_notify(acpi_handle handle,
191+
u32 event,
192+
void *data)
193+
{
194+
struct int3400_thermal_priv *priv = data;
195+
char *thermal_prop[5];
196+
197+
if (!priv)
198+
return;
199+
200+
switch (event) {
201+
case INT3400_THERMAL_TABLE_CHANGED:
202+
thermal_prop[0] = kasprintf(GFP_KERNEL, "NAME=%s",
203+
priv->thermal->type);
204+
thermal_prop[1] = kasprintf(GFP_KERNEL, "TEMP=%d",
205+
priv->thermal->temperature);
206+
thermal_prop[2] = kasprintf(GFP_KERNEL, "TRIP=");
207+
thermal_prop[3] = kasprintf(GFP_KERNEL, "EVENT=%d",
208+
THERMAL_TABLE_CHANGED);
209+
thermal_prop[4] = NULL;
210+
kobject_uevent_env(&priv->thermal->device.kobj, KOBJ_CHANGE,
211+
thermal_prop);
212+
break;
213+
default:
214+
dev_err(&priv->adev->dev, "Unsupported event [0x%x]\n", event);
215+
break;
216+
}
217+
}
218+
188219
static int int3400_thermal_get_temp(struct thermal_zone_device *thermal,
189220
int *temp)
190221
{
@@ -290,6 +321,12 @@ static int int3400_thermal_probe(struct platform_device *pdev)
290321
if (result)
291322
goto free_zone;
292323

324+
result = acpi_install_notify_handler(
325+
priv->adev->handle, ACPI_DEVICE_NOTIFY, int3400_notify,
326+
(void *)priv);
327+
if (result)
328+
goto free_zone;
329+
293330
return 0;
294331

295332
free_zone:
@@ -306,6 +343,10 @@ static int int3400_thermal_remove(struct platform_device *pdev)
306343
{
307344
struct int3400_thermal_priv *priv = platform_get_drvdata(pdev);
308345

346+
acpi_remove_notify_handler(
347+
priv->adev->handle, ACPI_DEVICE_NOTIFY,
348+
int3400_notify);
349+
309350
if (!priv->rel_misc_dev_res)
310351
acpi_thermal_rel_misc_device_remove(priv->adev->handle);
311352

include/linux/thermal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ enum thermal_notify_event {
102102
THERMAL_DEVICE_DOWN, /* Thermal device is down */
103103
THERMAL_DEVICE_UP, /* Thermal device is up after a down event */
104104
THERMAL_DEVICE_POWER_CAPABILITY_CHANGED, /* power capability changed */
105+
THERMAL_TABLE_CHANGED, /* Thermal table(s) changed */
105106
};
106107

107108
struct thermal_zone_device_ops {

0 commit comments

Comments
 (0)