Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

thermal: int340x: Add keep alive response method

When 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.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20200915223650.406046-4-srinivas.pandruvada@linux.intel.com

authored by

Srinivas Pandruvada and committed by
Daniel Lezcano
94a3c35e 88052319

+29
+29
drivers/thermal/intel/int340x_thermal/int3400_thermal.c
··· 14 14 15 15 #define INT3400_THERMAL_TABLE_CHANGED 0x83 16 16 #define INT3400_ODVP_CHANGED 0x88 17 + #define INT3400_KEEP_ALIVE 0xA0 17 18 18 19 enum int3400_thermal_uuid { 19 20 INT3400_THERMAL_PASSIVE_1, ··· 84 83 NULL, 85 84 }; 86 85 86 + static ssize_t imok_store(struct device *dev, struct device_attribute *attr, 87 + const char *buf, size_t count) 88 + { 89 + struct int3400_thermal_priv *priv = dev_get_drvdata(dev); 90 + acpi_status status; 91 + int input, ret; 92 + 93 + ret = kstrtouint(buf, 10, &input); 94 + if (ret) 95 + return ret; 96 + status = acpi_execute_simple_method(priv->adev->handle, "IMOK", input); 97 + if (ACPI_FAILURE(status)) 98 + return -EIO; 99 + 100 + return count; 101 + } 102 + 103 + static DEVICE_ATTR_WO(imok); 104 + 105 + static struct attribute *imok_attr[] = { 106 + &dev_attr_imok.attr, 107 + NULL 108 + }; 109 + 87 110 static const struct attribute_group data_attribute_group = { 88 111 .bin_attrs = data_attributes, 112 + .attrs = imok_attr, 89 113 }; 90 114 91 115 static ssize_t available_uuids_show(struct device *dev, ··· 383 357 switch (event) { 384 358 case INT3400_THERMAL_TABLE_CHANGED: 385 359 therm_event = THERMAL_TABLE_CHANGED; 360 + break; 361 + case INT3400_KEEP_ALIVE: 362 + therm_event = THERMAL_EVENT_KEEP_ALIVE; 386 363 break; 387 364 case INT3400_ODVP_CHANGED: 388 365 evaluate_odvp(priv);