From patchwork Sun Feb 21 21:02:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elia Devito X-Patchwork-Id: 12097669 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=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 75B05C433DB for ; Sun, 21 Feb 2021 21:04:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3483C64DA1 for ; Sun, 21 Feb 2021 21:04:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230152AbhBUVEW (ORCPT ); Sun, 21 Feb 2021 16:04:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229985AbhBUVEU (ORCPT ); Sun, 21 Feb 2021 16:04:20 -0500 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 291AEC061574; Sun, 21 Feb 2021 13:03:40 -0800 (PST) Received: by mail-wm1-x32a.google.com with SMTP id o10so6616406wmc.1; Sun, 21 Feb 2021 13:03:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=QpVogwZXK8MPIrBQ4cNdy6joZ0UgMTCKhaogvnww6HU=; b=gGGkA0RMlUyTXDedZpkL/fAgmAMdqkR3kTGqfCwoGsItK0Ie5iYwIRpD2EbWCpNcWm TLUMkVW+ywGSLfU7ldmNlIFOe35zU7/2l0wCeztJYR6im+HHJeQYjilMvlW8J2lgJHmu RcddwhQDnqqO1SiExnzrdk65D3VETWU+OuHw5ashv9vNnnFSgpbHkXtVWSrtxJ9cFIUS n1DhAK73ueHfCTQRr+WLvWowbmOyU3rtZKsvYs7CwDeXOa7yLb/3w9Q+5cdF3Ye1MBj5 tzII5Teu4On4LPpLmNk3Sjxj4zoKZf9Vpp01gMRrb5o2osjoAS7fT81b0AGyqYbmOgQc Hejw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=QpVogwZXK8MPIrBQ4cNdy6joZ0UgMTCKhaogvnww6HU=; b=Pa7Jc8vKuAzALxe4Ck5LfsEK96M4gQqYzZSj+pr/gweJJhJY7wXE8WvtbewF3u2KUd k6PAa/3cSetCl2ZPlCxQvPZfVFjY3IS+Ur4cngZPGcHxtKcjf2ugsBDWB/EuUlQ7BHtC VdznxDmNONmaKq9Az6/1IsTejhKrkqdzuGV+CHYZibWyt9b3hjn7U/A6I7QOOSk+Xq6e XeUQT+QhP8H9QJRnfVoVcPu+bgwbe+aLm5iO4AO1OlqVKzLH8G5QzmFa+wTSzKKHzEOz utvkQP40imQMYEhjWPIATuxof/d93caF1ub/VJs9j6xuGH52DyEJqU4y6CtKruo4WMR0 uOBA== X-Gm-Message-State: AOAM530wbWoWYJD0JbTeshCffC4feUwFYDPwocm9w5LHNZirb06X9bkt K4ivGg/nq8QKPcjvajJ3uhZ9IKVPFgI19Q== X-Google-Smtp-Source: ABdhPJzFBEco3abKziwfhUNSJSdjJQBC0vBKLxmcQMvYJhtHcebvNHiNQx0VTDowdpew8JJJwlHmBw== X-Received: by 2002:a1c:7f83:: with SMTP id a125mr17128442wmd.141.1613941418890; Sun, 21 Feb 2021 13:03:38 -0800 (PST) Received: from localhost.localdomain (host-79-22-224-43.retail.telecomitalia.it. [79.22.224.43]) by smtp.gmail.com with ESMTPSA id b10sm18277956wmh.36.2021.02.21.13.03.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Feb 2021 13:03:38 -0800 (PST) From: Elia Devito Cc: Elia Devito , Hans de Goede , Mark Gross , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] platform/x86: hp-wmi: rename "thermal policy" to "thermal profile" Date: Sun, 21 Feb 2021 22:02:57 +0100 Message-Id: <20210221210256.68198-1-eliadevito@gmail.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org rename "thermal policy" with the more appropriate term "thermal profile" Signed-off-by: Elia Devito Reviewed-by: Hans de Goede --- drivers/platform/x86/hp-wmi.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c index e94e59283ecb..6d7b91b8109b 100644 --- a/drivers/platform/x86/hp-wmi.c +++ b/drivers/platform/x86/hp-wmi.c @@ -85,7 +85,7 @@ enum hp_wmi_commandtype { HPWMI_FEATURE2_QUERY = 0x0d, HPWMI_WIRELESS2_QUERY = 0x1b, HPWMI_POSTCODEERROR_QUERY = 0x2a, - HPWMI_THERMAL_POLICY_QUERY = 0x4c, + HPWMI_THERMAL_PROFILE_QUERY = 0x4c, }; enum hp_wmi_command { @@ -869,19 +869,19 @@ static int __init hp_wmi_rfkill2_setup(struct platform_device *device) return err; } -static int thermal_policy_setup(struct platform_device *device) +static int thermal_profile_setup(struct platform_device *device) { int err, tp; - tp = hp_wmi_read_int(HPWMI_THERMAL_POLICY_QUERY); + tp = hp_wmi_read_int(HPWMI_THERMAL_PROFILE_QUERY); if (tp < 0) return tp; /* - * call thermal policy write command to ensure that the firmware correctly + * call thermal profile write command to ensure that the firmware correctly * sets the OEM variables for the DPTF */ - err = hp_wmi_perform_query(HPWMI_THERMAL_POLICY_QUERY, HPWMI_WRITE, &tp, + err = hp_wmi_perform_query(HPWMI_THERMAL_PROFILE_QUERY, HPWMI_WRITE, &tp, sizeof(tp), 0); if (err) return err; @@ -900,7 +900,7 @@ static int __init hp_wmi_bios_setup(struct platform_device *device) if (hp_wmi_rfkill_setup(device)) hp_wmi_rfkill2_setup(device); - thermal_policy_setup(device); + thermal_profile_setup(device); return 0; } From patchwork Sun Feb 21 21:04:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elia Devito X-Patchwork-Id: 12097671 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=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 62D6AC433DB for ; Sun, 21 Feb 2021 21:06:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1F00A64E4B for ; Sun, 21 Feb 2021 21:06:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230184AbhBUVGA (ORCPT ); Sun, 21 Feb 2021 16:06:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229985AbhBUVGA (ORCPT ); Sun, 21 Feb 2021 16:06:00 -0500 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 989DBC061574; Sun, 21 Feb 2021 13:05:19 -0800 (PST) Received: by mail-wm1-x333.google.com with SMTP id v62so12571762wmg.4; Sun, 21 Feb 2021 13:05:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=sK//K0s31poyiYG87+9PljlbveG+XzuTDDaliKRPm2Y=; b=GpqbLRth2mV+AU+vIyJjk3DcdKSUuAq+sFxJv2mywG05x/qd96F8dUkLcZed3fATOD a16w2ZfeIXiyrOE8rrBBvbKRd03oJm37O/ea1y/UQivXvD+zj2hYbZd3lRfw1sUgPWpF XaHDtSmO5BiA4J8fPB7gnyQWkYUBeYsMnRE3gY/i6M7lLPy8t+StiZ9EVF82rwytYuTv OMnUu9VMBiyIk5HgcWMKPtYGR/A0DO1nnSWRxJnwlBc7Q/1iVQmHGYoVumYld+asWvM+ ewwA5W2jrXoIN3WsKpQmog/TJX3zQsrWZQSN5AJarnpQNbs4k6ElQgM+GqxzmBisjlCA cuSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=sK//K0s31poyiYG87+9PljlbveG+XzuTDDaliKRPm2Y=; b=VsBG9jESr0u+kDKTe1oIceoby6dRGEnvq5eKWEPHhzrgoWOl4H8eqYvVvwwBuAsCo6 h53l8cZmtnOlTgR2857+XrC02WmfZDU4+qS6eeooYXCGnxK1kDHDhFmSXScEUwluV0Nn UPdCfpIz4WBfAZAcLv9xizwUsfIjqVgCxMp/DKHaazG/MAoP/T7+EcAwGAXtXejksLPf zVY8tFXAP6FstE4DaM7/zteyAozVuSsxaWkpcGfndsYsWjk4+rJZx2xDqBbMa+iaElIV 6uj21sBeWoB1T0jvvBDcxbmwDmM4wdSQczA5GxnZbXFrEUQrSa0IkSEOpfezrZGAJ3vm ppRw== X-Gm-Message-State: AOAM533C8Yt8e/O4LLg7Sk3m4h2IZm0KLdYDZ1rfZyMw5XL46SxeUEhi SHYToFxXJgeFuE0G+RqbG+E= X-Google-Smtp-Source: ABdhPJxf+ZxPxUBFPXP+XOa0zs8+8n6s/W9jIQqqpgdMNrD2vxbZDTYobjuH4f0iPO1sPSrixzL9Sg== X-Received: by 2002:a1c:2d47:: with SMTP id t68mr17798100wmt.189.1613941518339; Sun, 21 Feb 2021 13:05:18 -0800 (PST) Received: from localhost.localdomain (host-79-22-224-43.retail.telecomitalia.it. [79.22.224.43]) by smtp.gmail.com with ESMTPSA id g1sm23166595wmh.9.2021.02.21.13.05.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Feb 2021 13:05:18 -0800 (PST) From: Elia Devito Cc: Elia Devito , Hans de Goede , Mark Gross , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] platform/x86: hp-wmi: add platform profile support Date: Sun, 21 Feb 2021 22:04:39 +0100 Message-Id: <20210221210439.68590-1-eliadevito@gmail.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Implement support for cool, balanced and performance thermal profile Signed-off-by: Elia Devito --- the "quiet" profile will be implemented with a further patch drivers/platform/x86/hp-wmi.c | 96 +++++++++++++++++++++++++++++++++-- 1 file changed, 91 insertions(+), 5 deletions(-) diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c index 6d7b91b8109b..d983267b252b 100644 --- a/drivers/platform/x86/hp-wmi.c +++ b/drivers/platform/x86/hp-wmi.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -119,6 +120,12 @@ enum hp_wireless2_bits { HPWMI_POWER_FW_OR_HW = HPWMI_POWER_BIOS | HPWMI_POWER_HARD, }; +enum hp_thermal_profile { + HP_THERMAL_PROFILE_PERFORMANCE = 0x00, + HP_THERMAL_PROFILE_DEFAULT = 0x01, + HP_THERMAL_PROFILE_COOL = 0x02 +}; + #define IS_HWBLOCKED(x) ((x & HPWMI_POWER_FW_OR_HW) != HPWMI_POWER_FW_OR_HW) #define IS_SWBLOCKED(x) !(x & HPWMI_POWER_SOFT) @@ -159,6 +166,7 @@ static const struct key_entry hp_wmi_keymap[] = { static struct input_dev *hp_wmi_input_dev; static struct platform_device *hp_wmi_platform_dev; +static struct platform_profile_handler platform_profile_handler; static struct rfkill *wifi_rfkill; static struct rfkill *bluetooth_rfkill; @@ -869,23 +877,101 @@ static int __init hp_wmi_rfkill2_setup(struct platform_device *device) return err; } -static int thermal_profile_setup(struct platform_device *device) +static int thermal_profile_get(void) { - int err, tp; + int tp; tp = hp_wmi_read_int(HPWMI_THERMAL_PROFILE_QUERY); if (tp < 0) return tp; + return tp; +} + +static int thermal_profile_set(int thermal_profile) +{ + int err; + + err = hp_wmi_perform_query(HPWMI_THERMAL_PROFILE_QUERY, HPWMI_WRITE, &thermal_profile, + sizeof(thermal_profile), 0); + if (err) + return err; + + return 0; +} + +static int platform_profile_get(struct platform_profile_handler *pprof, + enum platform_profile_option *profile) +{ + int tp = thermal_profile_get(); + + switch (tp) { + case HP_THERMAL_PROFILE_PERFORMANCE: + *profile = PLATFORM_PROFILE_PERFORMANCE; + break; + case HP_THERMAL_PROFILE_DEFAULT: + *profile = PLATFORM_PROFILE_BALANCED; + break; + case HP_THERMAL_PROFILE_COOL: + *profile = PLATFORM_PROFILE_COOL; + break; + default: + return -EINVAL; + } + + return 0; +} + +static int platform_profile_set(struct platform_profile_handler *pprof, + enum platform_profile_option profile) +{ + int err, tp; + + switch (profile) { + case PLATFORM_PROFILE_PERFORMANCE: + tp = HP_THERMAL_PROFILE_PERFORMANCE; + break; + case PLATFORM_PROFILE_BALANCED: + tp = HP_THERMAL_PROFILE_DEFAULT; + break; + case PLATFORM_PROFILE_COOL: + tp = HP_THERMAL_PROFILE_COOL; + break; + default: + return -EOPNOTSUPP; + } + + err = thermal_profile_set(tp); + if (err) + return err; + + return 0; +} + +static int thermal_profile_setup(void) +{ + int err, tp; + + tp = thermal_profile_get(); + if (tp < 0) + return tp; + /* * call thermal profile write command to ensure that the firmware correctly * sets the OEM variables for the DPTF */ - err = hp_wmi_perform_query(HPWMI_THERMAL_PROFILE_QUERY, HPWMI_WRITE, &tp, - sizeof(tp), 0); + err = thermal_profile_set(tp); if (err) return err; + platform_profile_handler.profile_get = platform_profile_get, + platform_profile_handler.profile_set = platform_profile_set, + + set_bit(PLATFORM_PROFILE_COOL, platform_profile_handler.choices); + set_bit(PLATFORM_PROFILE_BALANCED, platform_profile_handler.choices); + set_bit(PLATFORM_PROFILE_PERFORMANCE, platform_profile_handler.choices); + + platform_profile_register(&platform_profile_handler); return 0; } @@ -900,7 +986,7 @@ static int __init hp_wmi_bios_setup(struct platform_device *device) if (hp_wmi_rfkill_setup(device)) hp_wmi_rfkill2_setup(device); - thermal_profile_setup(device); + thermal_profile_setup(); return 0; }