From nobody Mon Jun 8 06:36:40 2026 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 13779239E80 for ; Fri, 5 Jun 2026 23:19:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780701557; cv=none; b=sot9pDQWO7MO8cv8yRM3u983ETd4k8rQNVOPAMOB9I72Fp5OZ6mfUk28jDd7V1lWzO7FnY6YDvcQ/eMJJw0uHq9ZtTf6nK9t76ZqXTJ3c073tyVPT8WeAYwV4XqGlfitg/6oKR3d7BFB6N6gIJwa4mt0E0VmuIcKjbH6bNqQ9kM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780701557; c=relaxed/simple; bh=fkFsuzlcMW31KHviKljL3GrnqaRn2DUKOPOYu/Z3/i4=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=BuRPhGKfMRF6Ecv/hJfiCVxEvTPOWYNQ0AzoDlHt5O0FJzKaH5WzDwEyzyr5VUKmvGejOJ/D4xZMRHqLvdIf/qdtAUg73BhVtW9r0lATIU3/6uVHO9IYYYj1zKcoQ+hfnepuytBIVMiMx1M5fckF1AFuOSAhEd0X79cDXsFdzV4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=CBJt0ogC; arc=none smtp.client-ip=209.85.128.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CBJt0ogC" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-490ac357c55so29243665e9.1 for ; Fri, 05 Jun 2026 16:19:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780701554; x=1781306354; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=pfCjHL7Z8sFsegg2MRdElxUNf+mctf7ZhTGeufyquJ0=; b=CBJt0ogCGdqo/1mWq2t0nIIyo61OXaHEIGIlVXwlBZQ0BQTa88h5EJSpdZGAZI0ms3 GpxNgLDB20oMJuziKIsr16nGkHOLq65atqyArk77v5gHgkT2bj0zLgXvxtjCCPnXF8Ts nTAniUW2JigoySiwleFjwHZMMGbrf4McdHog0ZmuCyjSdyijK0S4fTLZ6raESy8sxESR pxzuz8Q7sjUghwcgJcZeQb8F6rSggTxDcpeSUxu80YD+yVPQobmlqRcAw4BqdlIRu2Wx qwmEHVxezK2r7ER6l30MR8o190fsfZtISXzhjJAFKYyWRJ2dgeyIVNRWw+Z1pjI6IUOq SUng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780701554; x=1781306354; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=pfCjHL7Z8sFsegg2MRdElxUNf+mctf7ZhTGeufyquJ0=; b=n5j+A2sgK385b+Bm0jA06jAcZdu36TmvKMwJJ+VCBT5kKEykoyC0hiXjlK+9PThZyf ttOf8tfWzKEREVNJErkRINMtYt8PH0mN8GhIABSeApxJfxZS/I+V4fjMHJsi9G7xsJYk uqSKz9eAgNiBmjYYWK7+otF/HwO+bMJCoPHoEC62qWFkQvGh1xuMdizyUL9QQM25GPD1 6cbpibdz6YrU0+BT+VnAUdAMNLTzAiOwH1OOQd5fGa1DM62U53nfxZ2BL3Zdhg60VBM3 YO9H/Mk8w/G/nJa5RhH44QCqG5s4OAZyklDbdYflsUMRKqn7hmiUo3mRy45QGaluipt7 OScQ== X-Forwarded-Encrypted: i=1; AFNElJ+4dDxS+n5QlMV/+QNM/w/avWyL1qBO60dxy3z8hJboPo3kUyqbYumXp3bs7j01jwENDVWjtdou8+0WSds=@vger.kernel.org X-Gm-Message-State: AOJu0YwBrSRfDCJl3XMekX2ypt8MV5hjsuu3ExdC9SGK3Uf/VLI+sCK6 7cPaESWhJ3DsbHJ8ZubJHTLs0C3DbnfCO+IN+NIOpW+xn9OVY2FX5ctU X-Gm-Gg: Acq92OG2gbuuFum9IFjtI2FsmNl3xVQRdkR9smIrn8yoPXX1D6S6ZSdojOjqzxK+2RV JUq8PNrjtshAhhZlv0AF/tvNK2bZ4x1ORCUXoW90btODYMl/pvUNa49m/GAQssJpqTPVXEcXklZ fHIeA/1Dpegn4xpttpZy28B4vRB9OOUz0bw8pj91ImP5VLi+Zl8jJ8KcInkUJpBod/LZGchrWR8 vxta2BcLQbu8BnYwnv19jw0l5K96VXZR3ftENdm14exl2/s87hqFqwI8dgdzFH5Nbbbvt7c/Iyd vlGMqeVC3Yft+0/u9tQ1LMI5IvSLol+LEzHZ1RqMubs1HyA/L3HpNJIMWid2fNpFLsgFxn90GFB jhY6Qvz12GuJQp9BJw3N0VyhawgLiLKE4DdvqF1Yovr3zpeK+j7lb1S/9Aa/YWX6VTYowlR8LKO +KfuU30T/lw8qA05kzjqZ65fd0GVyCM1g5 X-Received: by 2002:a05:600c:608e:b0:490:b355:9c8c with SMTP id 5b1f17b1804b1-490c25f3f00mr87597665e9.23.1780701554352; Fri, 05 Jun 2026 16:19:14 -0700 (PDT) Received: from user ([104.28.165.221]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4601f35eae5sm29455627f8f.33.2026.06.05.16.19.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jun 2026 16:19:13 -0700 (PDT) From: yahia To: hansg@kernel.org, ilpo.jarvinen@linux.intel.com Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, yahia Subject: [PATCH] [PATCH] platform/x86: Add Battery Threshold support Date: Sat, 6 Jun 2026 02:19:09 +0300 Message-ID: <20260605231909.17028-1-yahia.a.abdrabou@gmail.com> X-Mailer: git-send-email 2.54.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Hello, I aim in this patch to add support to Battery threshold via SBCT and GBCT acpi methods from the acpi table Signed-off-by: yahia --- drivers/platform/x86/hp/hp-wmi.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-= wmi.c index f63bc00d9a9b..3d035ad9f03d 100644 --- a/drivers/platform/x86/hp/hp-wmi.c +++ b/drivers/platform/x86/hp/hp-wmi.c @@ -59,6 +59,8 @@ enum hp_ec_offsets { #define HP_POWER_LIMIT_DEFAULT 0x00 #define HP_POWER_LIMIT_NO_CHANGE 0xFF =20 +#define HP_BATTERY_THRESHOLD_CAP 0x37 + #define zero_if_sup(tmp) (zero_insize_support?0:sizeof(tmp)) // use when z= ero insize is required =20 enum hp_thermal_profile_omen_v0 { @@ -448,6 +450,7 @@ static struct notifier_block platform_power_source_nb; static enum platform_profile_option active_platform_profile; static bool platform_profile_support; static bool zero_insize_support; +static bool battery_threshold_support; =20 static struct rfkill *wifi_rfkill; static struct rfkill *bluetooth_rfkill; @@ -1130,6 +1133,22 @@ static struct attribute *hp_wmi_attrs[] =3D { }; ATTRIBUTE_GROUPS(hp_wmi); =20 +static int hp_battery_threshold_check(void) +{ + u8 buffer[128] =3D {0}; + int ret; + ret =3D hp_wmi_perform_query(HP_BATTERY_THRESHOLD_CAP, HPWMI_READ, buffer= , 128, 128); + if (ret !=3D 0) { + battery_threshold_support =3D false; + return -1; + } + if (buffer[28] =3D=3D 0xAA) { + battery_threshold_support =3D true; + return 0; + } + return false; +} + static void hp_wmi_notify(union acpi_object *obj, void *context) { u32 event_id, event_data; @@ -2287,6 +2306,12 @@ static int __init hp_wmi_bios_setup(struct platform_= device *device) hp_wmi_rfkill2_setup(device); } =20 + err =3D hp_battery_threshold_check(); + + if (err =3D=3D 0) { + pr_info("Battery Threshold is supported"); + } + err =3D hp_wmi_hwmon_init(); =20 if (err < 0) --=20 2.54.0