thermal: int340x: New notifications for INT340X thermal
This series contains notifications to user space using currently used mechanism in these drivers.
Srinivas Pandruvada (3):
thermal: int340x: Provide notification for OEM variable change
thermal: core: Add new event for sending keep alive notifications
thermal: int340x: Add keep alive response method
.../intel/int340x_thermal/int3400_thermal.c | 51 +++++++++++++++---- include/linux/thermal.h | 1 + 2 files changed, 41 insertions(+), 11 deletions(-)
Signature · 1 line
2.25.4
PATCH 1/3 thermal: int340x: Provide notification for OEM variable change
When we receive ACPI notification for OEM variable change pass the notification to user space handler. This will avoid polling for OEM variable change from user space.
--- .../intel/int340x_thermal/int3400_thermal.c | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-)
drivers/thermal/intel/int340x_thermal/int3400_thermal.c +11 -11
@@ -349,30 +349,30 @@ static void int3400_notify(acpi_handle handle, {struct int3400_thermal_priv *priv = data;char *thermal_prop[5 ]; +int therm_event;if (!priv)return ;switch (event) {case INT3400_THERMAL_TABLE_CHANGED : - thermal_prop[0 ] =kasprintf (GFP_KERNEL ,"NAME=%s" , - priv->thermal->type); - thermal_prop[1 ] =kasprintf (GFP_KERNEL ,"TEMP=%d" , - priv->thermal->temperature); - thermal_prop[2 ] =kasprintf (GFP_KERNEL ,"TRIP=" ); - thermal_prop[3 ] =kasprintf (GFP_KERNEL ,"EVENT=%d" , -THERMAL_TABLE_CHANGED ); - thermal_prop[4 ] =NULL ; -kobject_uevent_env (&priv->thermal->device.kobj,KOBJ_CHANGE , - thermal_prop); + therm_event =THERMAL_TABLE_CHANGED ;break ;case INT3400_ODVP_CHANGED :evaluate_odvp (priv); + therm_event =THERMAL_DEVICE_POWER_CAPABILITY_CHANGED ;break ;default :/* Ignore unknown notification codes sent to INT3400 device */ -break ; +return ; } + + thermal_prop[0 ] =kasprintf (GFP_KERNEL ,"NAME=%s" , priv->thermal->type); + thermal_prop[1 ] =kasprintf (GFP_KERNEL ,"TEMP=%d" , priv->thermal->temperature); + thermal_prop[2 ] =kasprintf (GFP_KERNEL ,"TRIP=" ); + thermal_prop[3 ] =kasprintf (GFP_KERNEL ,"EVENT=%d" , therm_event); + thermal_prop[4 ] =NULL ; +kobject_uevent_env (&priv->thermal->device.kobj,KOBJ_CHANGE , thermal_prop); } static int int3400_thermal_get_temp(struct thermal_zone_device *thermal,
Signature · 1 line
2.25.4
PATCH 2/3 thermal: core: Add new event for sending keep alive notifications
In reply to Srinivas PandruvadaThis event is sent by the platform firmware to confirm that user space thermal solution is alive. The response to this event from the user space thermal solution is platform specific.
--- include/linux/thermal.h | 1 + 1 file changed, 1 insertion(+)
include/linux/thermal.h +1 -0
@@ -55,6 +55,7 @@ enum thermal_notify_event {THERMAL_DEVICE_UP ,/* Thermal device is up after a down event */ THERMAL_DEVICE_POWER_CAPABILITY_CHANGED ,/* power capability changed */ THERMAL_TABLE_CHANGED ,/* Thermal table(s) changed */ + THERMAL_EVENT_KEEP_ALIVE, /* Request for user space handler to respond */ }; struct thermal_zone_device_ops {
Signature · 1 line
2.25.4
PATCH 3/3 thermal: int340x: Add keep alive response method
In reply to Srinivas PandruvadaWhen firmware requests keep alive response, send an event to user space to confirm by using imok sysfs entry.
Create a new sysf entry called "imok". User space can write an integer, which results in execution of IMOK ACPI method of INT3400 thermal zone device. This results in sending response to firmware request for keep alive.
--- .../intel/int340x_thermal/int3400_thermal.c | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+)
drivers/thermal/intel/int340x_thermal/int3400_thermal.c +29 -0
@@ -14,6 +14,7 @@#define INT3400_THERMAL_TABLE_CHANGED 0x83#define INT3400_ODVP_CHANGED 0x88 +#define INT3400_KEEP_ALIVE 0xA0enum int3400_thermal_uuid {INT3400_THERMAL_PASSIVE_1 ,
@@ -83,8 +84,33 @@ static struct bin_attribute *data_attributes[] = { NULL, }; +static ssize_t imok_store (struct device *dev,struct device_attribute *attr, +const char *buf,size_t count) +{ +struct int3400_thermal_priv *priv =dev_get_drvdata (dev); +acpi_status status; +int input, ret; + + ret =kstrtouint (buf,10 , &input); +if (ret) +return ret; + status =acpi_execute_simple_method (priv->adev->handle,"IMOK" , input); +if (ACPI_FAILURE (status)) +return -EIO ; + +return count; +} + +static DEVICE_ATTR_WO (imok); + +static struct attribute *imok_attr[] = { + &dev_attr_imok.attr, +NULL +}; +static const struct attribute_group data_attribute_group = { .bin_attrs = data_attributes, + .attrs = imok_attr, }; static ssize_t available_uuids_show(struct device *dev,
@@ -358,6 +384,9 @@ static void int3400_notify(acpi_handle handle,case INT3400_THERMAL_TABLE_CHANGED : therm_event =THERMAL_TABLE_CHANGED ;break ; +case INT3400_KEEP_ALIVE : + therm_event =THERMAL_EVENT_KEEP_ALIVE ; +break ;case INT3400_ODVP_CHANGED :evaluate_odvp (priv); therm_event =THERMAL_DEVICE_POWER_CAPABILITY_CHANGED ;
Signature · 1 line
2.25.4