From patchwork Tue Sep 15 22:36:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Pandruvada X-Patchwork-Id: 256766 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 79F29C433E2 for ; Tue, 15 Sep 2020 22:37:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4DF18206BE for ; Tue, 15 Sep 2020 22:37:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727678AbgIOWhX (ORCPT ); Tue, 15 Sep 2020 18:37:23 -0400 Received: from mga18.intel.com ([134.134.136.126]:55540 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727673AbgIOWhQ (ORCPT ); Tue, 15 Sep 2020 18:37:16 -0400 IronPort-SDR: 4vUcubuTWcJIkP6aYAZY2JK1nDaKvsKzUZGtTw+TO7SF21mh4L7YgxASK9D/LziAqKmIgQSCR8 QUyFRYQ2srfQ== X-IronPort-AV: E=McAfee;i="6000,8403,9745"; a="147112837" X-IronPort-AV: E=Sophos;i="5.76,430,1592895600"; d="scan'208";a="147112837" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2020 15:37:07 -0700 IronPort-SDR: iq7oEeUhRErSHEFmoS1mtG6v8k484Mll85A5XWUdvLJoIQ/d0XYK5KKviH54zEvA6lzW29tjFP 7UW+SNchzZXg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,430,1592895600"; d="scan'208";a="306813339" Received: from spandruv-desk.jf.intel.com ([10.54.75.21]) by orsmga006.jf.intel.com with ESMTP; 15 Sep 2020 15:37:07 -0700 From: Srinivas Pandruvada To: rui.zhang@intel.com, daniel.lezcano@linaro.org, amitk@kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Pandruvada Subject: [PATCH 2/3] thermal: core: Add new event for sending keep alive notifications Date: Tue, 15 Sep 2020 15:36:49 -0700 Message-Id: <20200915223650.406046-3-srinivas.pandruvada@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200915223650.406046-1-srinivas.pandruvada@linux.intel.com> References: <20200915223650.406046-1-srinivas.pandruvada@linux.intel.com> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org This 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. Signed-off-by: Srinivas Pandruvada --- include/linux/thermal.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 42ef807e5d84..42b69d4072a4 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -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 { From patchwork Tue Sep 15 22:36:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Pandruvada X-Patchwork-Id: 256765 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 07286C433E2 for ; Tue, 15 Sep 2020 22:37:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B991320872 for ; Tue, 15 Sep 2020 22:37:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727556AbgIOWhu (ORCPT ); Tue, 15 Sep 2020 18:37:50 -0400 Received: from mga18.intel.com ([134.134.136.126]:55545 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727665AbgIOWhN (ORCPT ); Tue, 15 Sep 2020 18:37:13 -0400 IronPort-SDR: whCXvDBSxHR95KUy3HOBjxgS1whIOcfbzD10l9iHezUG9tIbrR12ByDHcQYVnv0hD5v2neXAd8 jyT1LSGvKMqA== X-IronPort-AV: E=McAfee;i="6000,8403,9745"; a="147112838" X-IronPort-AV: E=Sophos;i="5.76,430,1592895600"; d="scan'208";a="147112838" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Sep 2020 15:37:07 -0700 IronPort-SDR: PwmIcDhQFwZqgW2LPuXodt5U9r1JMME4azuk8p7k2G/slEZW0dq8f0pK6Ad6FeaJPiBvYdZgbi 8VQ53j7ERqZw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,430,1592895600"; d="scan'208";a="306813341" Received: from spandruv-desk.jf.intel.com ([10.54.75.21]) by orsmga006.jf.intel.com with ESMTP; 15 Sep 2020 15:37:07 -0700 From: Srinivas Pandruvada To: rui.zhang@intel.com, daniel.lezcano@linaro.org, amitk@kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Pandruvada Subject: [PATCH 3/3] thermal: int340x: Add keep alive response method Date: Tue, 15 Sep 2020 15:36:50 -0700 Message-Id: <20200915223650.406046-4-srinivas.pandruvada@linux.intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200915223650.406046-1-srinivas.pandruvada@linux.intel.com> References: <20200915223650.406046-1-srinivas.pandruvada@linux.intel.com> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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 --- .../intel/int340x_thermal/int3400_thermal.c | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c index 2ca295e6e64d..0966551cbaaa 100644 --- a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c +++ b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c @@ -14,6 +14,7 @@ #define INT3400_THERMAL_TABLE_CHANGED 0x83 #define INT3400_ODVP_CHANGED 0x88 +#define INT3400_KEEP_ALIVE 0xA0 enum 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;