Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp1824190lqz; Mon, 1 Apr 2024 20:27:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUH02sZwFGYvxlJiDsQIMJnzgrSi7fUESOTgubnTb2Ggssg569vxdVz8aliKGCh/tDXb2CGFNd5GTuxtGJJdUGLxsd3MpPh9iBLDoDLRQ== X-Google-Smtp-Source: AGHT+IH19iBPYsIgPhz4mK5fLo6pVVTFWxz1ZRuxxZOXCWaaExI2QAh3HUOnUKAlFVp+O5SpLGKC X-Received: by 2002:a17:902:dac8:b0:1e0:b5d4:9f60 with SMTP id q8-20020a170902dac800b001e0b5d49f60mr12582996plx.28.1712028442433; Mon, 01 Apr 2024 20:27:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712028442; cv=pass; d=google.com; s=arc-20160816; b=J5YUK7wZ8NO10qpMjjcqzh4xkH2aFhDaXv1m79gmF0XPtART3/eI55O0oQYm+DgPbp 41Rw5WLIzXtPaFlbKDB5Nsl+jBQXzWqYQFbM0zZKJ2pEb0kN3Lz3j4NqSpTZhf/MbCqA KrvelqhyQSP2ZyuEBfF0FmT7R/YYcHeeMYQbE30AHBe54V87d7BxC0PWvgYDIUE+eU+j 6b3nN3lfVN3clh+/go1QUOyKSiqxRRsUQiJouZFgs5Gggc+SmWAqJHLJL97ZT3JytcTb OP0t82Bgogp+GpVve2s/FdEBknESirKUGVhD5Hw4snrAbNiujAoW98OpiwsJbBDyrAk7 w6IQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:feedback-id:dkim-signature:dkim-signature; bh=7QfXQgaY7xZyYxNLvLcve7hd/L3NfO6jXnYr5RR0nC0=; fh=wDrqx0f+299Z9E/ydfQE0sLKgm4EkrYz7I1GVgXm5co=; b=L/zfWt2mXvgrI0Vi1sVKu9atOM67ZlGL8Azg/sh3KeW6+5wdklCJmPB2nDS1lDqNE9 3FnL8Bw204wCgKfLMGKJrAK0Q3/YKDzXTK4sknUTS3//yBao4FDRdtOpI88CsDa8iwmZ fBOFfVqB4tL23tJWAIeiaBZCdbwxJY3vjtZ/3Zhhx8Q3fELIUHBl33pe/6VcsOsy/FgC pA/P/zG8HJVYlkkpT6pffMJ7k6plVFUY/AoM5UF1ClPxVSZQtNsETeHpsSwcWWYjQdjJ 5ZW9R0WC4M1Aw/S3KK2miX51uqMdyIfUIbk4pBCjRI00pq+5ofAuaDBEDSGlI0dZhJrQ 7iRQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ljones.dev header.s=fm3 header.b=a6dNI14p; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=XS+AZFRp; arc=pass (i=1 dkim=pass dkdomain=ljones.dev dkim=pass dkdomain=messagingengine.com); spf=pass (google.com: domain of linux-kernel+bounces-127303-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-127303-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id u14-20020a170903124e00b001dd96e5febesi10670731plh.190.2024.04.01.20.27.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Apr 2024 20:27:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-127303-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@ljones.dev header.s=fm3 header.b=a6dNI14p; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=XS+AZFRp; arc=pass (i=1 dkim=pass dkdomain=ljones.dev dkim=pass dkdomain=messagingengine.com); spf=pass (google.com: domain of linux-kernel+bounces-127303-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-127303-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 67EA6B23D82 for ; Tue, 2 Apr 2024 02:28:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B29F818EAF; Tue, 2 Apr 2024 02:26:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ljones.dev header.i=@ljones.dev header.b="a6dNI14p"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="XS+AZFRp" Received: from wfhigh3-smtp.messagingengine.com (wfhigh3-smtp.messagingengine.com [64.147.123.154]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 121AF18633; Tue, 2 Apr 2024 02:26:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.123.154 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712024815; cv=none; b=YvkjyrlfqLRQ/1kpWEgXfBrQkPyIUq2bYE3y3MRF2kBveBP1XRD4KZWPEzPkj62GDHLgHERB6qnVBceSYbBwlWh8RAJvrKVhovX3iixsZCwL41mFI0d3c13fhzn+9BZxiFYgw/Q2MFuiQ6qySEweVkR+jCS3CddILCF3EAXfuxs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712024815; c=relaxed/simple; bh=n99dCLRp8ISXkNDLjTLaMp+/5Ar652WbbI/D0ElRLqw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z2SNIpPsfPAL32TBl9195JNnLP9bObW3Qm1b1ssu1OTFzvWVza6Q9vypIK4OW0f4ibVyjHLngXldmQ3WnsdV9F9v2y+B44xyJ3lbHaFDAdVAuLi1+e4nXzZ/M/LIfNhJ6n6XsO3cYCrhUYLcKyzmaJ7FHVOggX+MqtLqrsqRQL8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ljones.dev; spf=none smtp.mailfrom=ljones.dev; dkim=pass (2048-bit key) header.d=ljones.dev header.i=@ljones.dev header.b=a6dNI14p; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=XS+AZFRp; arc=none smtp.client-ip=64.147.123.154 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ljones.dev Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ljones.dev Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailfhigh.west.internal (Postfix) with ESMTP id D152218000D8; Mon, 1 Apr 2024 22:26:52 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Mon, 01 Apr 2024 22:26:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ljones.dev; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm3; t=1712024812; x= 1712111212; bh=7QfXQgaY7xZyYxNLvLcve7hd/L3NfO6jXnYr5RR0nC0=; b=a 6dNI14piOmudojHpxfnMeKbl8gJBDouXT77cYUD+/+yBaT4LWYxDYJUj83sHJJhu XINoVBkG5OHCvIplnZyE1FCYoOaW13bJdBtrmsx1hI/2kJrOkBVKyEmK6C9Mdjvi nVxFu5xKUHRFFNVdh8rerHkhR6hB4RrRQVufyjeVKMuI4lFHPmXoQH4tlMXuK7RQ xxawiPsH3Xv1b8+nsrySeUvxIWgC2d9+2E/7lzaRp9rj5fhyFckrTjgEp3JqY5H2 c0Exaob0PHozH5aDd5Mu5eZ6s1yje6wMSdosEAnWkQExV1Ye/cpPuiaTVkX29QII QXBGP9WTL1TveOtAMM5TA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1712024812; x= 1712111212; bh=7QfXQgaY7xZyYxNLvLcve7hd/L3NfO6jXnYr5RR0nC0=; b=X S+AZFRpfs5esCT+MCC9ZbEUCith2eUbdNZ2FY4Zdvf/FA0f9lIfs3jVl+rQhgV4N //E2Ln1R38vkr8QQrCGPxSz3KNjuJkZ3GjYeL5qGG71uKojp0SLZurslebmbe87C bJd5xLOEUEg0G12NzIruExNaKjTaemp4uJ+TQLjggVPqn11rWE6er4xPAz88teyy nTIZ23bKit9dvtOGKlybRnhYppukoYOgViN5zqB/rHoJlMBliy4kIoN41RmVgCnA oiOWow5cxaFH7Iy35Lw8QaV6f5MF8IcUetzJp2gcNcJO44N3LQxGotrhVThyYNmD R162EGRD2oFUL/nF5q9Gw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudefuddgheekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpedfnfhukhgvucffrdculfhonhgvshdfuceolhhukhgvsehl jhhonhgvshdruggvvheqnecuggftrfgrthhtvghrnhepgfetfedugfetudeuheetjefhue fggfelleetvdevtefhueeujeefvdegleevhefgnecuvehluhhsthgvrhfuihiivgepuden ucfrrghrrghmpehmrghilhhfrhhomheplhhukhgvsehljhhonhgvshdruggvvh X-ME-Proxy: Feedback-ID: i5ec1447f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 1 Apr 2024 22:26:49 -0400 (EDT) From: "Luke D. Jones" To: hdegoede@redhat.com Cc: corentin.chary@gmail.com, ilpo.jarvinen@linux.intel.com, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, "Luke D. Jones" Subject: [PATCH v2 8/9] platform/x86: asus-wmi: Add support for MCU powersave Date: Tue, 2 Apr 2024 15:26:06 +1300 Message-ID: <20240402022607.34625-9-luke@ljones.dev> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240402022607.34625-1-luke@ljones.dev> References: <20240402022607.34625-1-luke@ljones.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add support for an MCU powersave WMI call. This is intended to set the MCU in to a low-power mode when sleeping. This mode can cut sleep power use by around half. Signed-off-by: Luke D. Jones --- .../ABI/testing/sysfs-platform-asus-wmi | 11 +++- drivers/platform/x86/asus-wmi.c | 50 +++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/Documentation/ABI/testing/sysfs-platform-asus-wmi b/Documentation/ABI/testing/sysfs-platform-asus-wmi index 41b92e53e88a..28144371a0f1 100644 --- a/Documentation/ABI/testing/sysfs-platform-asus-wmi +++ b/Documentation/ABI/testing/sysfs-platform-asus-wmi @@ -202,4 +202,13 @@ Contact: "Luke Jones" Description: Set if the BIOS POST sound is played on boot. * 0 - False, - * 1 - True \ No newline at end of file + * 1 - True + +What: /sys/devices/platform//mcu_powersave +Date: Apr 2024 +KernelVersion: 6.10 +Contact: "Luke Jones" +Description: + Set if the MCU can go in to low-power mode on system sleep + * 0 - False, + * 1 - True diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index ddf568ef8c5e..cf872eed0986 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -1292,6 +1292,53 @@ static ssize_t nv_temp_target_show(struct device *dev, } static DEVICE_ATTR_RW(nv_temp_target); +/* Ally MCU Powersave ********************************************************/ +static ssize_t mcu_powersave_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct asus_wmi *asus = dev_get_drvdata(dev); + int result; + + result = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_MCU_POWERSAVE); + if (result < 0) + return result; + + return sysfs_emit(buf, "%d\n", result); +} + +static ssize_t mcu_powersave_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + int result, err; + u32 enable; + + struct asus_wmi *asus = dev_get_drvdata(dev); + + result = kstrtou32(buf, 10, &enable); + if (result) + return result; + + if (enable > 1) + return -EINVAL; + + err = asus_wmi_set_devstate(ASUS_WMI_DEVID_MCU_POWERSAVE, enable, &result); + if (err) { + pr_warn("Failed to set MCU powersave: %d\n", err); + return err; + } + + if (result > 1) { + pr_warn("Failed to set MCU powersave (result): 0x%x\n", result); + return -EIO; + } + + sysfs_notify(&asus->platform_device->dev.kobj, NULL, "mcu_powersave"); + + return count; +} +static DEVICE_ATTR_RW(mcu_powersave); + /* Battery ********************************************************************/ /* The battery maximum charging percentage */ @@ -4299,6 +4346,7 @@ static struct attribute *platform_attributes[] = { &dev_attr_ppt_platform_sppt.attr, &dev_attr_nv_dynamic_boost.attr, &dev_attr_nv_temp_target.attr, + &dev_attr_mcu_powersave.attr, &dev_attr_boot_sound.attr, &dev_attr_panel_od.attr, &dev_attr_mini_led_mode.attr, @@ -4352,6 +4400,8 @@ static umode_t asus_sysfs_is_visible(struct kobject *kobj, devid = ASUS_WMI_DEVID_NV_DYN_BOOST; else if (attr == &dev_attr_nv_temp_target.attr) devid = ASUS_WMI_DEVID_NV_THERM_TARGET; + else if (attr == &dev_attr_mcu_powersave.attr) + devid = ASUS_WMI_DEVID_MCU_POWERSAVE; else if (attr == &dev_attr_boot_sound.attr) devid = ASUS_WMI_DEVID_BOOT_SOUND; else if (attr == &dev_attr_panel_od.attr) -- 2.44.0