From nobody Mon Feb 9 08:54:31 2026 Received: from linux1587.grserver.gr (linux1587.grserver.gr [185.138.42.100]) (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 9E8982561DF; Thu, 17 Apr 2025 17:53:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.138.42.100 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744912412; cv=none; b=o9rSKdDBhBtI7Xo/Rc16PNP+JrjJ3pLv7UjiMu3MrkvCCc8BY+EqkVSUgmU3vHh0J2JXQnt10DSyg9QZQHGmCz0aYSOiMjRkYlwn2eA+BqTlgZpDlABUOcxah4DdibN3ucqK7hwBu4Y2G+S1XZvfiVvJ6g7OVh6Z3TbcHDEr9es= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744912412; c=relaxed/simple; bh=azP9R//yUd3y5xSiHZSqZVFVUGg1StaFMpCzpZ10L/A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=DWHAQPmzjxfwCPg2GyCW0fISf5Pd7AEBWW4leVWKRvWY4nZ49drtNOH2uf5RCtcFUozfbGEjgrpTEQKVUVnTAvRYc8GoOlN8ZJ++vf2qAbEIuClw+PBEh4TZDSSUHL8ISLMNJOCdAOq3SeGoni+lXU9FB9w5RqfA7LpXBCHfRpQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=antheas.dev; spf=pass smtp.mailfrom=antheas.dev; dkim=pass (1024-bit key) header.d=antheas.dev header.i=@antheas.dev header.b=nQZDLXkC; arc=none smtp.client-ip=185.138.42.100 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=antheas.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=antheas.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=antheas.dev header.i=@antheas.dev header.b="nQZDLXkC" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:cbc0:999f:73ad:33bd]) by linux1587.grserver.gr (Postfix) with ESMTPSA id 84C632E0873F; Thu, 17 Apr 2025 20:53:18 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1744912400; bh=B46fOP7F4O5Q9kYipJf9WysyVm2OwQxbttBN2mgY+e8=; h=From:To:Subject; b=nQZDLXkCo6y8D5mobePHaSkXW4MLoaPxvk3fI3MsohATLkY9TstJm4XuIJkHodPlO pVNtrm11jdtFkSFWRddtEcyEEvAfwDExqTXzFP79wanp8j0MlkA2LKLXlGZjaDSKeI kavbkg5H5x5hWrHPdXyDSY1/xBXRLdv5ejJkqbuA= Authentication-Results: linux1587.grserver.gr; spf=pass (sender IP is 2a05:f6c2:511b:0:cbc0:999f:73ad:33bd) smtp.mailfrom=lkml@antheas.dev smtp.helo=localhost.localdomain Received-SPF: pass (linux1587.grserver.gr: connection is authenticated) From: Antheas Kapenekakis To: platform-driver-x86@vger.kernel.org Cc: linux-hwmon@vger.kernel.org, linux-doc@vger.kernel.org, linux-pm@vger.kernel.org, Guenter Roeck , Jean Delvare , Jonathan Corbet , Joaquin Ignacio Aramendia , Derek J Clark , Kevin Greenberg , Joshua Tam , Parth Menon , Eileen , linux-kernel@vger.kernel.org, sre@kernel.org, linux@weissschuh.net, ilpo.jarvinen@linux.intel.com, hdegoede@redhat.com, mario.limonciello@amd.com, Antheas Kapenekakis Subject: [PATCH v9 01/15] hwmon: (oxp-sensors) Distinguish the X1 variants Date: Thu, 17 Apr 2025 19:52:56 +0200 Message-ID: <20250417175310.3552671-2-lkml@antheas.dev> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250417175310.3552671-1-lkml@antheas.dev> References: <20250417175310.3552671-1-lkml@antheas.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-PPP-Message-ID: <174491240014.24615.16762837287985019775@linux1587.grserver.gr> X-PPP-Vhost: antheas.dev X-Virus-Scanned: clamav-milter 0.103.11 at linux1587.grserver.gr X-Virus-Status: Clean Currently, the oxp-sensors driver fuzzy matches the X1 variants. Luckily, X1 and X1 mini share most hardware features so this works. However, they are completely different product lines, and there is an expectation that OneXPlayer will release more devices in the X1 line that may have differences. Therefore, distinguish the 3 devices that currently exist in the market. These are the OneXPlayer X1 AMD and Intel variants, and the X1 mini which only has an AMD variant. As far as registers go, all three support the current driver functionality. Reviewed-by: Derek J. Clark Acked-by: Guenter Roeck Reviewed-by: Thomas Wei=C3=9Fschuh Reviewed-by: Ilpo J=C3=A4rvinen Signed-off-by: Antheas Kapenekakis --- drivers/hwmon/oxp-sensors.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/drivers/hwmon/oxp-sensors.c b/drivers/hwmon/oxp-sensors.c index 83730d9318240..5a4230ad3757e 100644 --- a/drivers/hwmon/oxp-sensors.c +++ b/drivers/hwmon/oxp-sensors.c @@ -205,7 +205,28 @@ static const struct dmi_system_id dmi_table[] =3D { { .matches =3D { DMI_MATCH(DMI_BOARD_VENDOR, "ONE-NETBOOK"), - DMI_MATCH(DMI_BOARD_NAME, "ONEXPLAYER X1"), + DMI_EXACT_MATCH(DMI_BOARD_NAME, "ONEXPLAYER X1 A"), + }, + .driver_data =3D (void *)oxp_x1, + }, + { + .matches =3D { + DMI_MATCH(DMI_BOARD_VENDOR, "ONE-NETBOOK"), + DMI_EXACT_MATCH(DMI_BOARD_NAME, "ONEXPLAYER X1 i"), + }, + .driver_data =3D (void *)oxp_x1, + }, + { + .matches =3D { + DMI_MATCH(DMI_BOARD_VENDOR, "ONE-NETBOOK"), + DMI_EXACT_MATCH(DMI_BOARD_NAME, "ONEXPLAYER X1 mini"), + }, + .driver_data =3D (void *)oxp_x1, + }, + { + .matches =3D { + DMI_MATCH(DMI_BOARD_VENDOR, "ONE-NETBOOK"), + DMI_EXACT_MATCH(DMI_BOARD_NAME, "ONEXPLAYER X1Pro"), }, .driver_data =3D (void *)oxp_x1, }, --=20 2.49.0 From nobody Mon Feb 9 08:54:31 2026 Received: from linux1587.grserver.gr (linux1587.grserver.gr [185.138.42.100]) (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 CDA242566EB; Thu, 17 Apr 2025 17:53:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.138.42.100 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744912412; cv=none; b=XsUsmjnbC77wHoxr+mgp4Cc7gT/jVQrbMUoFqOi+EI+FnQGKxRQrkFa56FCD+1nEoNoQ2/VHTA6dXelO+FQCbvfZnVahB8NSW0M6p/v73SFXIRXE8HTSb6F3VxY9i1wo3R4TfB6XcZqSdTcEA8+lFkFvg1F1wCFE/gI5s7I3wnA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744912412; c=relaxed/simple; bh=DQuiCF1SN/NjnZzhOowdWV/B0vWkundVtE6TjRFYqqk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Bvs/Q3hkSr8Bj6RcCy35se+46BDTglX/ecRfXYj5162nHkVzAs8hEb1vvtqV/qvYdXUsM9WDwGAJkZaoJTW6hdsm8PFKPmasWrDWOjPUKOr9oquqg1629UyXR2tAK973ml2mQVYL3KB6vakP3/0nKvHD343rvJDZwKhPJqq1u1A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=antheas.dev; spf=pass smtp.mailfrom=antheas.dev; dkim=pass (1024-bit key) header.d=antheas.dev header.i=@antheas.dev header.b=taOevH1f; arc=none smtp.client-ip=185.138.42.100 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=antheas.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=antheas.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=antheas.dev header.i=@antheas.dev header.b="taOevH1f" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:cbc0:999f:73ad:33bd]) by linux1587.grserver.gr (Postfix) with ESMTPSA id 9CA1B2E08886; Thu, 17 Apr 2025 20:53:20 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1744912402; bh=/7DXyuv2rJHvdhAG9cuHuiAEipooyujiZO2C2+5uEdU=; h=From:To:Subject; b=taOevH1fjcTEoo+wGQy0Whmr8mEfocQh7JTgKGkEFvhMkyC7F59E4t9qQVztiCo5B ufRbjURd7oTbZI94YfDbDJKZISCM+MufrHb2wsDHZib2jkukx82gXKIyUb8hY3tiHU zITt04rePdS3uTODy8WVaMVSa7zZNrg2J9z/iQRM= Authentication-Results: linux1587.grserver.gr; spf=pass (sender IP is 2a05:f6c2:511b:0:cbc0:999f:73ad:33bd) smtp.mailfrom=lkml@antheas.dev smtp.helo=localhost.localdomain Received-SPF: pass (linux1587.grserver.gr: connection is authenticated) From: Antheas Kapenekakis To: platform-driver-x86@vger.kernel.org Cc: linux-hwmon@vger.kernel.org, linux-doc@vger.kernel.org, linux-pm@vger.kernel.org, Guenter Roeck , Jean Delvare , Jonathan Corbet , Joaquin Ignacio Aramendia , Derek J Clark , Kevin Greenberg , Joshua Tam , Parth Menon , Eileen , linux-kernel@vger.kernel.org, sre@kernel.org, linux@weissschuh.net, ilpo.jarvinen@linux.intel.com, hdegoede@redhat.com, mario.limonciello@amd.com, Antheas Kapenekakis Subject: [PATCH v9 02/15] hwmon: (oxp-sensors) Add all OneXFly variants Date: Thu, 17 Apr 2025 19:52:57 +0200 Message-ID: <20250417175310.3552671-3-lkml@antheas.dev> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250417175310.3552671-1-lkml@antheas.dev> References: <20250417175310.3552671-1-lkml@antheas.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-PPP-Message-ID: <174491240228.24731.16826431214339898659@linux1587.grserver.gr> X-PPP-Vhost: antheas.dev X-Virus-Scanned: clamav-milter 0.103.11 at linux1587.grserver.gr X-Virus-Status: Clean Currently, the driver only has the F1 OneXFly variant, which was based on the 7000 AMD platform. Add its special editions: F1 EVA-01, F1 OLED. F1 OLED might have been a dev unit, but it is supported by OneXConsole with the same features so add it. Then add the F1L variant which is based on the 8000 AMD platform and the F1Pro and its special edition EVA-02. One might ask why not just fuzzy match. Well, EVA-02 is a variant of F1Pro which is a Strix Point handheld, but does not have F1Pro in its name. This makes it risky to fuzzy match, as special variants in the future from different platforms might not have the same feature set or registers. By happenstance, all current devices use the same registers. For the charge limitting feature on this series, only F1Pro/X1 (AMD) were released with it, but OneXPlayer is providing bios updates for F1, F1L, X1 Mini units that use the same register, so treat all of them the same. Acked-by: Guenter Roeck Reviewed-by: Thomas Wei=C3=9Fschuh Reviewed-by: Derek J. Clark Reviewed-by: Ilpo J=C3=A4rvinen Signed-off-by: Antheas Kapenekakis --- drivers/hwmon/oxp-sensors.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/drivers/hwmon/oxp-sensors.c b/drivers/hwmon/oxp-sensors.c index 5a4230ad3757e..f7a64fbc8f33e 100644 --- a/drivers/hwmon/oxp-sensors.c +++ b/drivers/hwmon/oxp-sensors.c @@ -188,6 +188,41 @@ static const struct dmi_system_id dmi_table[] =3D { }, .driver_data =3D (void *)oxp_fly, }, + { + .matches =3D { + DMI_MATCH(DMI_BOARD_VENDOR, "ONE-NETBOOK"), + DMI_EXACT_MATCH(DMI_BOARD_NAME, "ONEXPLAYER F1 EVA-01"), + }, + .driver_data =3D (void *)oxp_fly, + }, + { + .matches =3D { + DMI_MATCH(DMI_BOARD_VENDOR, "ONE-NETBOOK"), + DMI_EXACT_MATCH(DMI_BOARD_NAME, "ONEXPLAYER F1 OLED"), + }, + .driver_data =3D (void *)oxp_fly, + }, + { + .matches =3D { + DMI_MATCH(DMI_BOARD_VENDOR, "ONE-NETBOOK"), + DMI_EXACT_MATCH(DMI_BOARD_NAME, "ONEXPLAYER F1L"), + }, + .driver_data =3D (void *)oxp_fly, + }, + { + .matches =3D { + DMI_MATCH(DMI_BOARD_VENDOR, "ONE-NETBOOK"), + DMI_EXACT_MATCH(DMI_BOARD_NAME, "ONEXPLAYER F1Pro"), + }, + .driver_data =3D (void *)oxp_fly, + }, + { + .matches =3D { + DMI_MATCH(DMI_BOARD_VENDOR, "ONE-NETBOOK"), + DMI_EXACT_MATCH(DMI_BOARD_NAME, "ONEXPLAYER F1 EVA-02"), + }, + .driver_data =3D (void *)oxp_fly, + }, { .matches =3D { DMI_MATCH(DMI_BOARD_VENDOR, "ONE-NETBOOK"), --=20 2.49.0 From nobody Mon Feb 9 08:54:31 2026 Received: from linux1587.grserver.gr (linux1587.grserver.gr [185.138.42.100]) (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 382CC255E23; Thu, 17 Apr 2025 17:53:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.138.42.100 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744912410; cv=none; b=VdMGzyCwWH3QPl3u3clXncUFZdxNmO2VMZSEWOzuQ4aJ4nsEhPtvTsCrRvumV6d2w9UF+cMnmweJpBbj9nM8xbAJ+NeTTmkDTk/INrc5BlFM4DMHdL15hexQObE0DtPClTi04J4RtB1mUuwNw5Nkk6SJ7H56t/Xjv6kQTiFzTZQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744912410; c=relaxed/simple; bh=zpPGTn9jBq6dlXLi2aKAfFOf1S875AgtFgpT+dNjwe8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=OKxGUYHD/UgEaKgHgj6esaVwhRtZ9sLCFry4i+7r5iKuPEjGi/KQraj8ADdufVS0xIT+w8lF/6iBMjqa5fuxSuAPxiTF8gvdVDsPlQoB9a5CK7MF/tytbRwmBruKKuzfYqqs791gnqLGBuaQU8PQ+c6z4DXk6IgMcKuc+hnyS0k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=antheas.dev; spf=pass smtp.mailfrom=antheas.dev; dkim=pass (1024-bit key) header.d=antheas.dev header.i=@antheas.dev header.b=bSaSMj3n; arc=none smtp.client-ip=185.138.42.100 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=antheas.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=antheas.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=antheas.dev header.i=@antheas.dev header.b="bSaSMj3n" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:cbc0:999f:73ad:33bd]) by linux1587.grserver.gr (Postfix) with ESMTPSA id D4E7B2E0895C; Thu, 17 Apr 2025 20:53:22 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1744912404; bh=5krtJAQ2Hs3Msl2turSRVjSkxAaMpQ5x31o5h0mc8ag=; h=From:To:Subject; b=bSaSMj3nl7wrP1gi03SdKUxIuOVWEGwnJEnh7MEoGhY5KOwYYa8VSsD1WnnHVK4dE RIPuiKHbhGErUclgatM5JTbdeQcsTkKiGPgj+cMHzFHJlr2wLZ+uYiwFs2E7kyteCt 59/utkRZuS3KRUiiZG+7AoNmzPv/OjgYnUdY3wLA= Authentication-Results: linux1587.grserver.gr; spf=pass (sender IP is 2a05:f6c2:511b:0:cbc0:999f:73ad:33bd) smtp.mailfrom=lkml@antheas.dev smtp.helo=localhost.localdomain Received-SPF: pass (linux1587.grserver.gr: connection is authenticated) From: Antheas Kapenekakis To: platform-driver-x86@vger.kernel.org Cc: linux-hwmon@vger.kernel.org, linux-doc@vger.kernel.org, linux-pm@vger.kernel.org, Guenter Roeck , Jean Delvare , Jonathan Corbet , Joaquin Ignacio Aramendia , Derek J Clark , Kevin Greenberg , Joshua Tam , Parth Menon , Eileen , linux-kernel@vger.kernel.org, sre@kernel.org, linux@weissschuh.net, ilpo.jarvinen@linux.intel.com, hdegoede@redhat.com, mario.limonciello@amd.com, Antheas Kapenekakis Subject: [PATCH v9 03/15] platform/x86: oxpec: Move hwmon/oxp-sensors to platform/x86 Date: Thu, 17 Apr 2025 19:52:58 +0200 Message-ID: <20250417175310.3552671-4-lkml@antheas.dev> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250417175310.3552671-1-lkml@antheas.dev> References: <20250417175310.3552671-1-lkml@antheas.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-PPP-Message-ID: <174491240451.24806.15948022686644251336@linux1587.grserver.gr> X-PPP-Vhost: antheas.dev X-Virus-Scanned: clamav-milter 0.103.11 at linux1587.grserver.gr X-Virus-Status: Clean The EC of OneXPlayer devices used to only control the fan. This is no longer the case, with the EC of OneXPlayer gaining additional functionality (turbo button, turbo led, battery controls). As it will be beneficial from a complexity perspective to retain this driver as a single unit, move it out of hwmon, and into platform/x86. Also, remove the hwmon documentation to prepare moving it to Documentation/ABI/. While at it, add myself to the maintainer's file. Acked-by: Guenter Roeck Reviewed-by: Thomas Wei=C3=9Fschuh Reviewed-by: Derek J. Clark Signed-off-by: Antheas Kapenekakis --- Documentation/hwmon/index.rst | 2 +- Documentation/hwmon/oxp-sensors.rst | 89 ------------------- MAINTAINERS | 7 +- drivers/hwmon/Kconfig | 11 --- drivers/hwmon/Makefile | 1 - drivers/platform/x86/Kconfig | 12 +++ drivers/platform/x86/Makefile | 3 + .../oxp-sensors.c =3D> platform/x86/oxpec.c} | 10 +-- 8 files changed, 24 insertions(+), 111 deletions(-) delete mode 100644 Documentation/hwmon/oxp-sensors.rst rename drivers/{hwmon/oxp-sensors.c =3D> platform/x86/oxpec.c} (98%) diff --git a/Documentation/hwmon/index.rst b/Documentation/hwmon/index.rst index f0ddf6222c44d..a86f7aa9006e6 100644 --- a/Documentation/hwmon/index.rst +++ b/Documentation/hwmon/index.rst @@ -189,7 +189,7 @@ Hardware Monitoring Kernel Drivers nzxt-kraken3 nzxt-smart2 occ - oxp-sensors + oxpec pc87360 pc87427 pcf8591 diff --git a/Documentation/hwmon/oxp-sensors.rst b/Documentation/hwmon/oxp-= sensors.rst deleted file mode 100644 index 581c4dafbfa13..0000000000000 --- a/Documentation/hwmon/oxp-sensors.rst +++ /dev/null @@ -1,89 +0,0 @@ -.. SPDX-License-Identifier: GPL-2.0-or-later - -Kernel driver oxp-sensors -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D - -Authors: - - Derek John Clark - - Joaqu=C3=ADn Ignacio Aramend=C3=ADa - -Description: ------------- - -Handheld devices from OneNetbook, AOKZOE, AYANEO, And OrangePi provide fan -readings and fan control through their embedded controllers. - -Currently supports OneXPlayer devices, AOKZOE, AYANEO, and OrangePi -handheld devices. AYANEO devices preceding the AIR and OneXPlayer devices -preceding the Mini A07 are not supportable as the EC model is different -and do not have manual control capabilities. - -Some OneXPlayer and AOKZOE models have a toggle for changing the behaviour -of the "Turbo/Silent" button of the device. It will change the key event -that it triggers with a flip of the `tt_toggle` attribute. See below for -boards that support this function. - -Supported devices ------------------ - -Currently the driver supports the following handhelds: - - - AOKZOE A1 - - AOKZOE A1 PRO - - AYANEO 2 - - AYANEO 2S - - AYANEO AIR - - AYANEO AIR 1S - - AYANEO AIR Plus (Mendocino) - - AYANEO AIR Pro - - AYANEO Flip DS - - AYANEO Flip KB - - AYANEO Geek - - AYANEO Geek 1S - - AYANEO KUN - - OneXPlayer 2 - - OneXPlayer 2 Pro - - OneXPlayer AMD - - OneXPlayer mini AMD - - OneXPlayer mini AMD PRO - - OneXPlayer OneXFly - - OneXPlayer X1 A - - OneXPlayer X1 i - - OneXPlayer X1 mini - - OrangePi NEO-01 - -"Turbo/Silent" button behaviour toggle is only supported on: - - AOK ZOE A1 - - AOK ZOE A1 PRO - - OneXPlayer 2 - - OneXPlayer 2 Pro - - OneXPlayer mini AMD (only with updated alpha BIOS) - - OneXPlayer mini AMD PRO - - OneXPlayer OneXFly - - OneXPlayer X1 A - - OneXPlayer X1 i - - OneXPlayer X1 mini - -Sysfs entries -------------- - -The following attributes are supported: - -fan1_input - Read Only. Reads current fan RPM. - -pwm1_enable - Read Write. Enable manual fan control. Write "1" to set to manual, write= "0" - to let the EC control de fan speed. Read this attribute to see current s= tatus. - -pwm1 - Read Write. Read this attribute to see current duty cycle in the range [= 0-255]. - When pwm1_enable is set to "1" (manual) write any value in the range [0-= 255] - to set fan speed. - -tt_toggle - Read Write. Read this attribute to check the status of the turbo/silent - button behaviour function. Write "1" to activate the switch and "0" to - deactivate it. The specific keycodes and behaviour is specific to the de= vice - both with this function on and off. This attribute is attached to the pl= atform - driver and not to the hwmon driver (/sys/devices/platform/oxp-platform/t= t_toggle) diff --git a/MAINTAINERS b/MAINTAINERS index c59316109e3f8..e584c1a25449a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -18013,12 +18013,13 @@ S: Maintained F: drivers/mtd/nand/onenand/ F: include/linux/mtd/onenand*.h =20 -ONEXPLAYER FAN DRIVER +ONEXPLAYER PLATFORM EC DRIVER +M: Antheas Kapenekakis M: Derek John Clark M: Joaqu=C3=ADn Ignacio Aramend=C3=ADa -L: linux-hwmon@vger.kernel.org +L: platform-driver-x86@vger.kernel.org S: Maintained -F: drivers/hwmon/oxp-sensors.c +F: drivers/platform/x86/oxpec.c =20 ONIE TLV NVMEM LAYOUT DRIVER M: Miquel Raynal diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index f91f713b0105d..5fd93aad2d6df 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -1795,17 +1795,6 @@ config SENSORS_NZXT_SMART2 =20 source "drivers/hwmon/occ/Kconfig" =20 -config SENSORS_OXP - tristate "OneXPlayer EC fan control" - depends on ACPI_EC - depends on X86 - help - If you say yes here you get support for fan readings and control over - OneXPlayer handheld devices. Only OneXPlayer mini AMD handheld variant - boards are supported. - - Can also be built as a module. In that case it will be called oxp-sensor= s. - config SENSORS_PCF8591 tristate "Philips PCF8591 ADC/DAC" depends on I2C diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index 766c652ef22be..e3468d024ff39 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile @@ -183,7 +183,6 @@ obj-$(CONFIG_SENSORS_NTC_THERMISTOR) +=3D ntc_thermisto= r.o obj-$(CONFIG_SENSORS_NZXT_KRAKEN2) +=3D nzxt-kraken2.o obj-$(CONFIG_SENSORS_NZXT_KRAKEN3) +=3D nzxt-kraken3.o obj-$(CONFIG_SENSORS_NZXT_SMART2) +=3D nzxt-smart2.o -obj-$(CONFIG_SENSORS_OXP) +=3D oxp-sensors.o obj-$(CONFIG_SENSORS_PC87360) +=3D pc87360.o obj-$(CONFIG_SENSORS_PC87427) +=3D pc87427.o obj-$(CONFIG_SENSORS_PCF8591) +=3D pcf8591.o diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig index 43407e76476b5..739740c4bb535 100644 --- a/drivers/platform/x86/Kconfig +++ b/drivers/platform/x86/Kconfig @@ -1201,6 +1201,18 @@ config SEL3350_PLATFORM To compile this driver as a module, choose M here: the module will be called sel3350-platform. =20 +config OXP_EC + tristate "OneXPlayer EC platform control" + depends on ACPI_EC + depends on HWMON + depends on X86 + help + Enables support for the platform EC of OneXPlayer and AOKZOE + handheld devices. This includes fan speed, fan controls, and + disabling the default TDP behavior of the device. Due to legacy + reasons, this driver also provides hwmon functionality to Ayaneo + devices and the OrangePi Neo. + endif # X86_PLATFORM_DEVICES =20 config P2SB diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile index 650dfbebb6c8c..38ffc4c98e786 100644 --- a/drivers/platform/x86/Makefile +++ b/drivers/platform/x86/Makefile @@ -154,3 +154,6 @@ obj-$(CONFIG_WINMATE_FM07_KEYS) +=3D winmate-fm07-keys= .o =20 # SEL obj-$(CONFIG_SEL3350_PLATFORM) +=3D sel3350-platform.o + +# OneXPlayer +obj-$(CONFIG_OXP_EC) +=3D oxpec.o diff --git a/drivers/hwmon/oxp-sensors.c b/drivers/platform/x86/oxpec.c similarity index 98% rename from drivers/hwmon/oxp-sensors.c rename to drivers/platform/x86/oxpec.c index f7a64fbc8f33e..dc3a0871809cd 100644 --- a/drivers/hwmon/oxp-sensors.c +++ b/drivers/platform/x86/oxpec.c @@ -1,11 +1,8 @@ // SPDX-License-Identifier: GPL-2.0+ /* - * Platform driver for OneXPlayer, AOKZOE, AYANEO, and OrangePi Handhelds - * that expose fan reading and control via hwmon sysfs. - * - * Old OXP boards have the same DMI strings and they are told apart by - * the boot cpu vendor (Intel/AMD). Of these older models only AMD is - * supported. + * Platform driver for OneXPlayer and AOKZOE devices. For the time being, + * it also exposes fan controls for AYANEO, and OrangePi Handhelds via + * hwmon sysfs. * * Fan control is provided via pwm interface in the range [0-255]. * Old AMD boards use [0-100] as range in the EC, the written value is @@ -16,6 +13,7 @@ * * Copyright (C) 2022 Joaqu=C3=ADn I. Aramend=C3=ADa * Copyright (C) 2024 Derek J. Clark + * Copyright (C) 2025 Antheas Kapenekakis */ =20 #include --=20 2.49.0 From nobody Mon Feb 9 08:54:31 2026 Received: from linux1587.grserver.gr (linux1587.grserver.gr [185.138.42.100]) (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 501072566C4; Thu, 17 Apr 2025 17:53:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.138.42.100 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744912410; cv=none; b=dUx9xcstTSRo2w2f8Sj1iRY3NMQ3vmUcm2Ouv3c2cZBQuE+4p8U8vDHnBSgI/IWJB1fMuxMJucVcOlXr8B8dKQLC+glBYcgnQJZhu4xCB1G3KSqCy/KB0WGvV3mTrF3MJ62nq4Y/fRV8S+FhzqDDEvKGTsZh/OUvkmma2I9a4OE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744912410; c=relaxed/simple; bh=32EjIPtZXp/rf4ttCzgCwCUDL15K7aMZ0/DvvRvlLKg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=opZefkMZOoAtw8d9x3gu5j0QK9IpK8iQcKlatrphiay1eRcsaijsyOuibK6iWVtt6mz3IZk4o08G9pS7wLVukoc3IVpX5BzRbPboG+IelCna0lj51asAguFq5bB6L+jIEG0w3oYDWD3CHEW88b0jOyWClYRCkTIxVeEwPprLMLY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=antheas.dev; spf=pass smtp.mailfrom=antheas.dev; dkim=pass (1024-bit key) header.d=antheas.dev header.i=@antheas.dev header.b=s6qexdTj; arc=none smtp.client-ip=185.138.42.100 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=antheas.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=antheas.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=antheas.dev header.i=@antheas.dev header.b="s6qexdTj" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:cbc0:999f:73ad:33bd]) by linux1587.grserver.gr (Postfix) with ESMTPSA id 162552E08699; Thu, 17 Apr 2025 20:53:25 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1744912406; bh=qE5ChC30UpmwauKSNSAaNybCBbXeDCOAvfXA41bKRPY=; h=From:To:Subject; b=s6qexdTjhCKatgbEpPNcZt+QKfvuGAIjJ6e6HmWLMoEtwwSLDwG367iqWqxcSxhOh 8sHW/svc3ouS8x0aQPztmJE69KtXz4fSZLsci/01vBzrvWLqFSuzWh5pirwuJz5zUW f4ey/CwU/qg71zUe3bC44T1jwfkAp73qtoSgg8lI= Authentication-Results: linux1587.grserver.gr; spf=pass (sender IP is 2a05:f6c2:511b:0:cbc0:999f:73ad:33bd) smtp.mailfrom=lkml@antheas.dev smtp.helo=localhost.localdomain Received-SPF: pass (linux1587.grserver.gr: connection is authenticated) From: Antheas Kapenekakis To: platform-driver-x86@vger.kernel.org Cc: linux-hwmon@vger.kernel.org, linux-doc@vger.kernel.org, linux-pm@vger.kernel.org, Guenter Roeck , Jean Delvare , Jonathan Corbet , Joaquin Ignacio Aramendia , Derek J Clark , Kevin Greenberg , Joshua Tam , Parth Menon , Eileen , linux-kernel@vger.kernel.org, sre@kernel.org, linux@weissschuh.net, ilpo.jarvinen@linux.intel.com, hdegoede@redhat.com, mario.limonciello@amd.com, Antheas Kapenekakis Subject: [PATCH v9 04/15] ABI: testing: sysfs-class-oxp: add missing documentation Date: Thu, 17 Apr 2025 19:52:59 +0200 Message-ID: <20250417175310.3552671-5-lkml@antheas.dev> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250417175310.3552671-1-lkml@antheas.dev> References: <20250417175310.3552671-1-lkml@antheas.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-PPP-Message-ID: <174491240664.24883.8188525224180457173@linux1587.grserver.gr> X-PPP-Vhost: antheas.dev X-Virus-Scanned: clamav-milter 0.103.11 at linux1587.grserver.gr X-Virus-Status: Clean Add missing documentation about the tt_toggle attribute that was added in kernel 6.5. Fixes: be144ee491272 ("hwmon: (oxp-sensors) Add tt_toggle attribute on supp= orted boards") Reviewed-by: Thomas Wei=C3=9Fschuh Reviewed-by: Derek J. Clark Signed-off-by: Antheas Kapenekakis --- Documentation/ABI/testing/sysfs-platform-oxp | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-platform-oxp diff --git a/Documentation/ABI/testing/sysfs-platform-oxp b/Documentation/A= BI/testing/sysfs-platform-oxp new file mode 100644 index 0000000000000..091269ab2c8c4 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-platform-oxp @@ -0,0 +1,13 @@ +What: /sys/devices/platform//tt_toggle +Date: Jun 2023 +KernelVersion: 6.5 +Contact: "Antheas Kapenekakis" +Description: + Takeover TDP controls from the device. OneXPlayer devices have a + turbo button that can be used to switch between two TDP modes + (usually 15W and 25W). By setting this attribute to 1, this + functionality is disabled, handing TDP control over to (Windows) + userspace software and the Turbo button turns into a keyboard + shortcut over the AT keyboard of the device. In addition, + using this setting is a prerequisite for PWM control for most + newer models (otherwise it NOOPs). --=20 2.49.0 From nobody Mon Feb 9 08:54:31 2026 Received: from linux1587.grserver.gr (linux1587.grserver.gr [185.138.42.100]) (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 B2FDD2571CA; Thu, 17 Apr 2025 17:53:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.138.42.100 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744912414; cv=none; b=Dp3rf9+wQcNoeLpT0ZFlRBVNPLoCfyGbu0RhiXCc2cB8HcJ3QG6s/wEZ1r14ycTg+K3O+WSPv2iukeKiJbRVFCVSaPuP/C+yY4WiDmkd11DxsZl/iwwRPPoUgcpeuR/pmkkpusgydwo+FJwkeRGNm0GQZwtf0lWru88M0M8olkY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744912414; c=relaxed/simple; bh=7z9+NBdXvgZs8VMPVVMsPGq7ziNHtwhTTOGs0r+Jai0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Lpr8n7VmJnZk99NLqDcqaLW0wRo9C14Eiy5wEkDevGEX5/EsbDQfvVS7wbWmeYUtilPV5+QIjBzrdCvtEEGFwH7IOv2KPDyfhratZV5bRlgs4GNWeamwzx3GZkJMG1jfEuDZy+PcO0fHHiKLdgWrgINqsqNwQZmQROk8dGoWefM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=antheas.dev; spf=pass smtp.mailfrom=antheas.dev; dkim=pass (1024-bit key) header.d=antheas.dev header.i=@antheas.dev header.b=eI5bkfiC; arc=none smtp.client-ip=185.138.42.100 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=antheas.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=antheas.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=antheas.dev header.i=@antheas.dev header.b="eI5bkfiC" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:cbc0:999f:73ad:33bd]) by linux1587.grserver.gr (Postfix) with ESMTPSA id 29EA92E088D8; Thu, 17 Apr 2025 20:53:27 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1744912409; bh=2oyeEHL5RGXZ13onh6k9JhX2IrdUxRPNzwIc6bpWggA=; h=From:To:Subject; b=eI5bkfiCjE39Na+a+PLeO9hw96UbRO+03N4O8OnmGFoj8RpnUC7uXzPpCbYj/OPOY GHXmDrAgnCBcOy6QmarNJvHMe6Ntya4ykULOBclqayGGVwZKRBiU3EA25aufGbgiY9 pOJdJ6HU1JWnY/MZf9jAHUpyZyqOjQ6ftzMmqIKQ= Authentication-Results: linux1587.grserver.gr; spf=pass (sender IP is 2a05:f6c2:511b:0:cbc0:999f:73ad:33bd) smtp.mailfrom=lkml@antheas.dev smtp.helo=localhost.localdomain Received-SPF: pass (linux1587.grserver.gr: connection is authenticated) From: Antheas Kapenekakis To: platform-driver-x86@vger.kernel.org Cc: linux-hwmon@vger.kernel.org, linux-doc@vger.kernel.org, linux-pm@vger.kernel.org, Guenter Roeck , Jean Delvare , Jonathan Corbet , Joaquin Ignacio Aramendia , Derek J Clark , Kevin Greenberg , Joshua Tam , Parth Menon , Eileen , linux-kernel@vger.kernel.org, sre@kernel.org, linux@weissschuh.net, ilpo.jarvinen@linux.intel.com, hdegoede@redhat.com, mario.limonciello@amd.com, Antheas Kapenekakis Subject: [PATCH v9 05/15] ABI: testing: sysfs-class-oxp: add tt_led attribute documentation Date: Thu, 17 Apr 2025 19:53:00 +0200 Message-ID: <20250417175310.3552671-6-lkml@antheas.dev> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250417175310.3552671-1-lkml@antheas.dev> References: <20250417175310.3552671-1-lkml@antheas.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-PPP-Message-ID: <174491240878.24952.11919427039514044173@linux1587.grserver.gr> X-PPP-Vhost: antheas.dev X-Virus-Scanned: clamav-milter 0.103.11 at linux1587.grserver.gr X-Virus-Status: Clean Adds documentation about the tt_led attribute of OneXPlayer devices to the sysfs-class-oxp ABI documentation. Reviewed-by: Thomas Wei=C3=9Fschuh Reviewed-by: Derek J. Clark Signed-off-by: Antheas Kapenekakis --- Documentation/ABI/testing/sysfs-platform-oxp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-platform-oxp b/Documentation/A= BI/testing/sysfs-platform-oxp index 091269ab2c8c4..b3f39fc21dfa8 100644 --- a/Documentation/ABI/testing/sysfs-platform-oxp +++ b/Documentation/ABI/testing/sysfs-platform-oxp @@ -11,3 +11,15 @@ Description: shortcut over the AT keyboard of the device. In addition, using this setting is a prerequisite for PWM control for most newer models (otherwise it NOOPs). + +What: /sys/devices/platform//tt_led +Date: April 2025 +KernelVersion: 6.16 +Contact: "Antheas Kapenekakis" +Description: + Some OneXPlayer devices (e.g., X1 series) feature a little LED + nested in the Turbo button. This LED is illuminated when the + device is in the higher TDP mode (e.g., 25W). Once tt_toggle + is engaged, this LED is left dangling to its last state. This + attribute allows userspace to control the LED state manually + (either with 1 or 0). Only a subset of devices contain this LED. --=20 2.49.0 From nobody Mon Feb 9 08:54:31 2026 Received: from linux1587.grserver.gr (linux1587.grserver.gr [185.138.42.100]) (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 EA78B257424; Thu, 17 Apr 2025 17:53:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.138.42.100 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744912414; cv=none; b=ewhhu45TpTpfcg/ujXHnCyToWmWJCz0W+C1tMg+rsFeBOdKjLyVyzXKzn8gXEZHQ1QWDDiu8IFsV3zyH06HR2pavyuinPwkr93cEuR+u+26Ly8AVZDm8GVlkksn4IXxwqxFyG8cillStsS790UigDh6ply2anHGQbpOkAHPsr8A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744912414; c=relaxed/simple; bh=yYF43Unru39rskLB6o15FW18gb2pC1rZY8MRgF53hIU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=sVS0BmvUFFqascKtBjRJ0oSW9NxgoPSSlpyXGiICMp52GVOaeBxO9IoV67rj/ibVYeP6hx7izCjCNYntZe9qLDLLu1cUnRysccIcaQu/F5wtm7Atja4N0B3jOBhLYeaTz7cPK58eIN7G7ChBJkzZhUyKZ4sHBihZV6Y9cIdnug0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=antheas.dev; spf=pass smtp.mailfrom=antheas.dev; dkim=pass (1024-bit key) header.d=antheas.dev header.i=@antheas.dev header.b=nUCn0eye; arc=none smtp.client-ip=185.138.42.100 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=antheas.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=antheas.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=antheas.dev header.i=@antheas.dev header.b="nUCn0eye" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:cbc0:999f:73ad:33bd]) by linux1587.grserver.gr (Postfix) with ESMTPSA id 43D182E08A29; Thu, 17 Apr 2025 20:53:29 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1744912411; bh=rPiuh34oF+Te4yOv2w+rVAfjfi+m0fUEXD7gGDgXtCU=; h=From:To:Subject; b=nUCn0eye67J9FNVs+biACED7f313IDwmXp2xJqVyEIdWrATWohEkGkXuJ4kS797ei 72WmY0vXlkQent9eFpwK6lBHilmy4elfDnGMN+OUp4P+N16qJoSvnHul1B0xT/tJ1M GiPOMwVzlCALE9FH5uAP2dlqxNl/qHFzAu+9QPbU= Authentication-Results: linux1587.grserver.gr; spf=pass (sender IP is 2a05:f6c2:511b:0:cbc0:999f:73ad:33bd) smtp.mailfrom=lkml@antheas.dev smtp.helo=localhost.localdomain Received-SPF: pass (linux1587.grserver.gr: connection is authenticated) From: Antheas Kapenekakis To: platform-driver-x86@vger.kernel.org Cc: linux-hwmon@vger.kernel.org, linux-doc@vger.kernel.org, linux-pm@vger.kernel.org, Guenter Roeck , Jean Delvare , Jonathan Corbet , Joaquin Ignacio Aramendia , Derek J Clark , Kevin Greenberg , Joshua Tam , Parth Menon , Eileen , linux-kernel@vger.kernel.org, sre@kernel.org, linux@weissschuh.net, ilpo.jarvinen@linux.intel.com, hdegoede@redhat.com, mario.limonciello@amd.com, Antheas Kapenekakis Subject: [PATCH v9 06/15] platform/x86: oxpec: Rename ec group to tt_toggle Date: Thu, 17 Apr 2025 19:53:01 +0200 Message-ID: <20250417175310.3552671-7-lkml@antheas.dev> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250417175310.3552671-1-lkml@antheas.dev> References: <20250417175310.3552671-1-lkml@antheas.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-PPP-Message-ID: <174491241084.25014.303836050158476415@linux1587.grserver.gr> X-PPP-Vhost: antheas.dev X-Virus-Scanned: clamav-milter 0.103.11 at linux1587.grserver.gr X-Virus-Status: Clean Currently, the EC group is used for the turbo button. However, the next patch in the series adds support for the LED button in X1 devices, which is only applicable for X1 devices. Therefore, rename it to prepare for adding the second group. And make it const while at it. Reviewed-by: Derek J. Clark Reviewed-by: Thomas Wei=C3=9Fschuh Reviewed-by: Ilpo J=C3=A4rvinen Signed-off-by: Antheas Kapenekakis --- drivers/platform/x86/oxpec.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/platform/x86/oxpec.c b/drivers/platform/x86/oxpec.c index dc3a0871809cd..ee37070ec54fc 100644 --- a/drivers/platform/x86/oxpec.c +++ b/drivers/platform/x86/oxpec.c @@ -681,18 +681,18 @@ static const struct hwmon_channel_info * const oxp_pl= atform_sensors[] =3D { NULL, }; =20 -static struct attribute *oxp_ec_attrs[] =3D { +static struct attribute *oxp_tt_toggle_attrs[] =3D { &dev_attr_tt_toggle.attr, NULL }; =20 -static struct attribute_group oxp_ec_attribute_group =3D { +static const struct attribute_group oxp_tt_toggle_attribute_group =3D { .is_visible =3D tt_toggle_is_visible, - .attrs =3D oxp_ec_attrs, + .attrs =3D oxp_tt_toggle_attrs, }; =20 static const struct attribute_group *oxp_ec_groups[] =3D { - &oxp_ec_attribute_group, + &oxp_tt_toggle_attribute_group, NULL }; =20 --=20 2.49.0 From nobody Mon Feb 9 08:54:31 2026 Received: from linux1587.grserver.gr (linux1587.grserver.gr [185.138.42.100]) (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 A84E3259CAD; Thu, 17 Apr 2025 17:53:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.138.42.100 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744912417; cv=none; b=O2M6voxqJu+ioSr5J8kG9HFNo9AVcByCP+LbeezP8CIB6CV7dIGiQU/pTRjR2PW2pjqmnGNP9roySjF/pPW4LbG42mPTl6GK6kCzBH0XSWZ+YxZcqnaDY+2pITgJoeNGwJp9vlCf10gV65GxAUiSKnI3ZwVMKnaaX58sOsVS3vA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744912417; c=relaxed/simple; bh=e9Hbc8ubwQ4WKqHswBn8INFYzOeYPNNIUDcFdGAEhr4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SGjLgEjraLDkDY6jHfBwW/5aZF/OdlQ+oa2afxE+kTxads7LP6793fXnVyrVo0o8YgS/SEU5ZGa7+yfFu2wICMZyvTN1Aju5TXFSN1Gby+aPxQowlXB1iyejcvM7zUDIfw39u4q711T5ddq6dv4a6YaCtvTGB6D9UqnSK4Z+MVk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=antheas.dev; spf=pass smtp.mailfrom=antheas.dev; dkim=pass (1024-bit key) header.d=antheas.dev header.i=@antheas.dev header.b=ET4fQz6f; arc=none smtp.client-ip=185.138.42.100 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=antheas.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=antheas.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=antheas.dev header.i=@antheas.dev header.b="ET4fQz6f" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:cbc0:999f:73ad:33bd]) by linux1587.grserver.gr (Postfix) with ESMTPSA id 5EEA52E08A2B; Thu, 17 Apr 2025 20:53:31 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1744912413; bh=6+NxRo4VNOh/wyitaaHROZSWCiVZG4W+kTfXNty+Of0=; h=From:To:Subject; b=ET4fQz6f2WFDrHTiVg1PLS4yBjAJBAOw5xj83U3MeeBwoNcnFZfLGkB3vzhxeNnqx mvaAj4bxgOWD8lw0XOOHiE5u7n/0rhsRmzoe/4JQzT1KnhFpyHlbSgVNLmRL5geqtH R40T5QPoyYu8MqOzLzj1iPIrF00rtR/K9pxoCoZA= Authentication-Results: linux1587.grserver.gr; spf=pass (sender IP is 2a05:f6c2:511b:0:cbc0:999f:73ad:33bd) smtp.mailfrom=lkml@antheas.dev smtp.helo=localhost.localdomain Received-SPF: pass (linux1587.grserver.gr: connection is authenticated) From: Antheas Kapenekakis To: platform-driver-x86@vger.kernel.org Cc: linux-hwmon@vger.kernel.org, linux-doc@vger.kernel.org, linux-pm@vger.kernel.org, Guenter Roeck , Jean Delvare , Jonathan Corbet , Joaquin Ignacio Aramendia , Derek J Clark , Kevin Greenberg , Joshua Tam , Parth Menon , Eileen , linux-kernel@vger.kernel.org, sre@kernel.org, linux@weissschuh.net, ilpo.jarvinen@linux.intel.com, hdegoede@redhat.com, mario.limonciello@amd.com, Antheas Kapenekakis Subject: [PATCH v9 07/15] platform/x86: oxpec: Add turbo led support to X1 devices Date: Thu, 17 Apr 2025 19:53:02 +0200 Message-ID: <20250417175310.3552671-8-lkml@antheas.dev> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250417175310.3552671-1-lkml@antheas.dev> References: <20250417175310.3552671-1-lkml@antheas.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-PPP-Message-ID: <174491241307.25075.2973299611837331159@linux1587.grserver.gr> X-PPP-Vhost: antheas.dev X-Virus-Scanned: clamav-milter 0.103.11 at linux1587.grserver.gr X-Virus-Status: Clean The X1 and X1 mini lineups feature an LED nested within their turbo button. When turbo takeover is not enabled, the turbo button allows the device to switch from 18W to 25W TDP. When the device is in the 25W TDP mode, the LED is turned on. However, when we engage turbo takeover, the turbo led remains on its last state, which might be illuminated and cannot be currently controlled. Therefore, add the register that controls it under sysfs, to allow userspace to turn it off once engaging turbo takeover and then control it as they wish. 2024 OneXPlayer devices, other than the X1s, do not have a turbo LED. However, earlier models do, so this can be extended to them as well when the register for it is found. Reviewed-by: Thomas Wei=C3=9Fschuh Reviewed-by: Derek J. Clark Signed-off-by: Antheas Kapenekakis --- drivers/platform/x86/oxpec.c | 84 ++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/drivers/platform/x86/oxpec.c b/drivers/platform/x86/oxpec.c index ee37070ec54fc..e8f27441fa31f 100644 --- a/drivers/platform/x86/oxpec.c +++ b/drivers/platform/x86/oxpec.c @@ -87,6 +87,12 @@ static enum oxp_board board; =20 #define OXP_TURBO_RETURN_VAL 0x00 /* Common return val */ =20 +/* X1 Turbo LED */ +#define OXP_X1_TURBO_LED_REG 0x57 + +#define OXP_X1_TURBO_LED_OFF 0x01 +#define OXP_X1_TURBO_LED_ON 0x02 + static const struct dmi_system_id dmi_table[] =3D { { .matches =3D { @@ -434,6 +440,73 @@ static ssize_t tt_toggle_show(struct device *dev, =20 static DEVICE_ATTR_RW(tt_toggle); =20 +/* Callbacks for turbo LED attribute */ +static umode_t tt_led_is_visible(struct kobject *kobj, + struct attribute *attr, int n) +{ + switch (board) { + case oxp_x1: + return attr->mode; + default: + break; + } + return 0; +} + +static ssize_t tt_led_store(struct device *dev, + struct device_attribute *attr, const char *buf, + size_t count) +{ + u8 reg, val; + bool value; + int ret; + + ret =3D kstrtobool(buf, &value); + if (ret) + return ret; + + switch (board) { + case oxp_x1: + reg =3D OXP_X1_TURBO_LED_REG; + val =3D value ? OXP_X1_TURBO_LED_ON : OXP_X1_TURBO_LED_OFF; + break; + default: + return -EINVAL; + } + + ret =3D write_to_ec(reg, val); + if (ret) + return ret; + + return count; +} + +static ssize_t tt_led_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + long enval; + long val; + int ret; + u8 reg; + + switch (board) { + case oxp_x1: + reg =3D OXP_X1_TURBO_LED_REG; + enval =3D OXP_X1_TURBO_LED_ON; + break; + default: + return -EINVAL; + } + + ret =3D read_from_ec(reg, 1, &val); + if (ret) + return ret; + + return sysfs_emit(buf, "%d\n", val =3D=3D enval); +} + +static DEVICE_ATTR_RW(tt_led); + /* PWM enable/disable functions */ static int oxp_pwm_enable(void) { @@ -691,8 +764,19 @@ static const struct attribute_group oxp_tt_toggle_attr= ibute_group =3D { .attrs =3D oxp_tt_toggle_attrs, }; =20 +static struct attribute *oxp_tt_led_attrs[] =3D { + &dev_attr_tt_led.attr, + NULL +}; + +static const struct attribute_group oxp_tt_led_attribute_group =3D { + .is_visible =3D tt_led_is_visible, + .attrs =3D oxp_tt_led_attrs, +}; + static const struct attribute_group *oxp_ec_groups[] =3D { &oxp_tt_toggle_attribute_group, + &oxp_tt_led_attribute_group, NULL }; =20 --=20 2.49.0 From nobody Mon Feb 9 08:54:31 2026 Received: from linux1587.grserver.gr (linux1587.grserver.gr [185.138.42.100]) (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 B7FCF25D1EA; Thu, 17 Apr 2025 17:53:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.138.42.100 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744912419; cv=none; b=Sh8KSY7S+Bu0IBS7v932RswRXbX4AQZM1XUxV47ZhK87ZPCmULbxAmhXKUqaJdYqu6G90INzm6w0+ndt/bLKXyV7W/YHY2F85tmLpBZYER8iAkKJLx15GMyYPZ+nGdnrwvelSFfMc43mit0BmR93MEc6POjEi5eu8+MRbaF1hYc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744912419; c=relaxed/simple; bh=DeOuTeA3Wt2x605puUmi+rabUHcjBIXnWo4T24iT+7U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=l82Qsm2H+o/6CdIXFaUCnj7Wb19P8wbCeTJuG0TJ2xvdj9VgrDnNcn4GE0NbHShjTrYSQVgvIR1bU3s54uGwh3PRWBqAY1U4kyVSO9xTWpsxZ1lTshxrgy6hK3kJYwbZv8mciAw9uC1TKjRYegzJFDFRXmrj+bfQRkvgV0a957s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=antheas.dev; spf=pass smtp.mailfrom=antheas.dev; dkim=pass (1024-bit key) header.d=antheas.dev header.i=@antheas.dev header.b=Z3B0A6/w; arc=none smtp.client-ip=185.138.42.100 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=antheas.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=antheas.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=antheas.dev header.i=@antheas.dev header.b="Z3B0A6/w" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:cbc0:999f:73ad:33bd]) by linux1587.grserver.gr (Postfix) with ESMTPSA id C57A02E081B2; Thu, 17 Apr 2025 20:53:33 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1744912415; bh=JFaOX+/EyUeZ6M2rSWhHqRcRyfpLP02I7m4jgGc7Wu0=; h=From:To:Subject; b=Z3B0A6/wcus3uEv9Rh/B5gC1eNpjsVMXFgigFfzeVronekzsRu1OUhA2JJkyF5En8 eYdDoBQBZVbU+kh0IUdoZeK0CB6vz4+WrYAOdGe+5OZLkctDnO1W9dGfJoGRmanzdT YSSZJQ2rIJ7CRoQWFRQzJHWERn4EiyYw9jUU1gTg= Authentication-Results: linux1587.grserver.gr; spf=pass (sender IP is 2a05:f6c2:511b:0:cbc0:999f:73ad:33bd) smtp.mailfrom=lkml@antheas.dev smtp.helo=localhost.localdomain Received-SPF: pass (linux1587.grserver.gr: connection is authenticated) From: Antheas Kapenekakis To: platform-driver-x86@vger.kernel.org Cc: linux-hwmon@vger.kernel.org, linux-doc@vger.kernel.org, linux-pm@vger.kernel.org, Guenter Roeck , Jean Delvare , Jonathan Corbet , Joaquin Ignacio Aramendia , Derek J Clark , Kevin Greenberg , Joshua Tam , Parth Menon , Eileen , linux-kernel@vger.kernel.org, sre@kernel.org, linux@weissschuh.net, ilpo.jarvinen@linux.intel.com, hdegoede@redhat.com, mario.limonciello@amd.com, Antheas Kapenekakis Subject: [PATCH v9 08/15] platform/x86: oxpec: Move pwm_enable read to its own function Date: Thu, 17 Apr 2025 19:53:03 +0200 Message-ID: <20250417175310.3552671-9-lkml@antheas.dev> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250417175310.3552671-1-lkml@antheas.dev> References: <20250417175310.3552671-1-lkml@antheas.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-PPP-Message-ID: <174491241536.25153.7474410264922812240@linux1587.grserver.gr> X-PPP-Vhost: antheas.dev X-Virus-Scanned: clamav-milter 0.103.11 at linux1587.grserver.gr X-Virus-Status: Clean Currently, this driver breaks ABI by using auto as 0 and manual as 1. However, for pwm_enable, 0 is full speed, 1 is manual, and 2 is auto. For the correction to be possible, this means that the pwm_enable endpoint will need access to both pwm enable and value (as for the 0th value, the fan needs to be set to full power). Therefore, begin by moving the current pwm_enable read to its own function, oxp_pwm_enable. Reviewed-by: Derek J. Clark Reviewed-by: Thomas Wei=C3=9Fschuh Reviewed-by: Ilpo J=C3=A4rvinen Signed-off-by: Antheas Kapenekakis --- drivers/platform/x86/oxpec.c | 50 +++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/drivers/platform/x86/oxpec.c b/drivers/platform/x86/oxpec.c index e8f27441fa31f..2f9624323c4b1 100644 --- a/drivers/platform/x86/oxpec.c +++ b/drivers/platform/x86/oxpec.c @@ -559,6 +559,32 @@ static int oxp_pwm_disable(void) } } =20 +static int oxp_pwm_read(long *val) +{ + switch (board) { + case orange_pi_neo: + return read_from_ec(ORANGEPI_SENSOR_PWM_ENABLE_REG, 1, val); + case aok_zoe_a1: + case aya_neo_2: + case aya_neo_air: + case aya_neo_air_1s: + case aya_neo_air_plus_mendo: + case aya_neo_air_pro: + case aya_neo_flip: + case aya_neo_geek: + case aya_neo_kun: + case oxp_2: + case oxp_fly: + case oxp_mini_amd: + case oxp_mini_amd_a07: + case oxp_mini_amd_pro: + case oxp_x1: + return read_from_ec(OXP_SENSOR_PWM_ENABLE_REG, 1, val); + default: + return -EOPNOTSUPP; + } +} + /* Callbacks for hwmon interface */ static umode_t oxp_ec_hwmon_is_visible(const void *drvdata, enum hwmon_sensor_types type, u32 attr, int channel) @@ -656,29 +682,7 @@ static int oxp_platform_read(struct device *dev, enum = hwmon_sensor_types type, } return 0; case hwmon_pwm_enable: - switch (board) { - case orange_pi_neo: - return read_from_ec(ORANGEPI_SENSOR_PWM_ENABLE_REG, 1, val); - case aok_zoe_a1: - case aya_neo_2: - case aya_neo_air: - case aya_neo_air_1s: - case aya_neo_air_plus_mendo: - case aya_neo_air_pro: - case aya_neo_flip: - case aya_neo_geek: - case aya_neo_kun: - case oxp_2: - case oxp_fly: - case oxp_mini_amd: - case oxp_mini_amd_a07: - case oxp_mini_amd_pro: - case oxp_x1: - return read_from_ec(OXP_SENSOR_PWM_ENABLE_REG, 1, val); - default: - break; - } - break; + return oxp_pwm_read(val); default: break; } --=20 2.49.0 From nobody Mon Feb 9 08:54:31 2026 Received: from linux1587.grserver.gr (linux1587.grserver.gr [185.138.42.100]) (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 EB95725E832; Thu, 17 Apr 2025 17:53:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.138.42.100 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744912421; cv=none; b=Znw2VWK/mq1tcC2zTOddarx4GfmCKhrkrQ4G6qG7fuUUa6M3AdO67/Y4C7BZiXx4z7HOeVxJaaE7arM+lNy1SEhwFfFYugNFV9afJUWfgvKZHiOk99yBrbAo3te//9jUixI0lTDKMY4yMFOloxnjWCisNy+Ns/5Po/ZebA6PBIg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744912421; c=relaxed/simple; bh=K+yOCdrjpc9WsuBt9Sg5Ex5cwXhmT4L8EQg+kmNln3s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uDiiA5jTPyu+7LReKRTqx21gsZc1g11S/LKJRDNGBPZkmEusIc9fVUuX4IULB31u+smXjQYBavGEJNR3sPnp03qHdGxto16Ti/GKGz9tyoQl1WM+GVVaoI81WygHoEQFz382B61mr0K4A0nP6FrqCUS0wQQwZYxu6ma6Eb4u+Lk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=antheas.dev; spf=pass smtp.mailfrom=antheas.dev; dkim=pass (1024-bit key) header.d=antheas.dev header.i=@antheas.dev header.b=iktyPzRI; arc=none smtp.client-ip=185.138.42.100 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=antheas.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=antheas.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=antheas.dev header.i=@antheas.dev header.b="iktyPzRI" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:cbc0:999f:73ad:33bd]) by linux1587.grserver.gr (Postfix) with ESMTPSA id 39C052E0873F; Thu, 17 Apr 2025 20:53:36 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1744912418; bh=41PpekqZpIsYf6wfYqsQVIKMGlIXkxMJLVN73gCVBX4=; h=From:To:Subject; b=iktyPzRIkN/tDkaSEZahGHz343jAXxXdJCZ5bGiLKBiIJ8SJasu4rSJOoSzPprFbj XqYaOX1PfNxqbw0roqYatGJdwOKJv/1V4PW7Asyyb8hkSOkaKo2OS59VxFtVxv1AJa NSVsmKxFnKFIsykcTd8MvP5fAPQL/BmNjEzW/9J8= Authentication-Results: linux1587.grserver.gr; spf=pass (sender IP is 2a05:f6c2:511b:0:cbc0:999f:73ad:33bd) smtp.mailfrom=lkml@antheas.dev smtp.helo=localhost.localdomain Received-SPF: pass (linux1587.grserver.gr: connection is authenticated) From: Antheas Kapenekakis To: platform-driver-x86@vger.kernel.org Cc: linux-hwmon@vger.kernel.org, linux-doc@vger.kernel.org, linux-pm@vger.kernel.org, Guenter Roeck , Jean Delvare , Jonathan Corbet , Joaquin Ignacio Aramendia , Derek J Clark , Kevin Greenberg , Joshua Tam , Parth Menon , Eileen , linux-kernel@vger.kernel.org, sre@kernel.org, linux@weissschuh.net, ilpo.jarvinen@linux.intel.com, hdegoede@redhat.com, mario.limonciello@amd.com, Antheas Kapenekakis Subject: [PATCH v9 09/15] platform/x86: oxpec: Move pwm value read/write to separate functions Date: Thu, 17 Apr 2025 19:53:04 +0200 Message-ID: <20250417175310.3552671-10-lkml@antheas.dev> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250417175310.3552671-1-lkml@antheas.dev> References: <20250417175310.3552671-1-lkml@antheas.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-PPP-Message-ID: <174491241782.25239.15144120348941442798@linux1587.grserver.gr> X-PPP-Vhost: antheas.dev X-Virus-Scanned: clamav-milter 0.103.11 at linux1587.grserver.gr X-Virus-Status: Clean Currently, this driver breaks hwmon ABI by using auto as 0 and manual as 1. However, for pwm_enable, 0 is full speed, 1 is manual, and 2 is auto. For the correction to be possible, this means that the pwm_enable endpoint will need access to both pwm enable and value (as for the 0th value, the fan needs to be set to full power). Therefore, move the pwm value read/write to separate functions. Reviewed-by: Derek J. Clark Reviewed-by: Thomas Wei=C3=9Fschuh Reviewed-by: Ilpo J=C3=A4rvinen Signed-off-by: Antheas Kapenekakis --- drivers/platform/x86/oxpec.c | 163 +++++++++++++++++++---------------- 1 file changed, 88 insertions(+), 75 deletions(-) diff --git a/drivers/platform/x86/oxpec.c b/drivers/platform/x86/oxpec.c index 2f9624323c4b1..e670f7d6682a3 100644 --- a/drivers/platform/x86/oxpec.c +++ b/drivers/platform/x86/oxpec.c @@ -599,6 +599,92 @@ static umode_t oxp_ec_hwmon_is_visible(const void *drv= data, } } =20 +/* PWM input read/write functions */ +static int oxp_pwm_input_write(long val) +{ + if (val < 0 || val > 255) + return -EINVAL; + + switch (board) { + case orange_pi_neo: + /* scale to range [1-244] */ + val =3D ((val - 1) * 243 / 254) + 1; + return write_to_ec(ORANGEPI_SENSOR_PWM_REG, val); + case oxp_2: + case oxp_x1: + /* scale to range [0-184] */ + val =3D (val * 184) / 255; + return write_to_ec(OXP_SENSOR_PWM_REG, val); + case aya_neo_2: + case aya_neo_air: + case aya_neo_air_1s: + case aya_neo_air_plus_mendo: + case aya_neo_air_pro: + case aya_neo_flip: + case aya_neo_geek: + case aya_neo_kun: + case oxp_mini_amd: + case oxp_mini_amd_a07: + /* scale to range [0-100] */ + val =3D (val * 100) / 255; + return write_to_ec(OXP_SENSOR_PWM_REG, val); + case aok_zoe_a1: + case oxp_fly: + case oxp_mini_amd_pro: + return write_to_ec(OXP_SENSOR_PWM_REG, val); + default: + return -EOPNOTSUPP; + } +} + +static int oxp_pwm_input_read(long *val) +{ + int ret; + + switch (board) { + case orange_pi_neo: + ret =3D read_from_ec(ORANGEPI_SENSOR_PWM_REG, 1, val); + if (ret) + return ret; + /* scale from range [1-244] */ + *val =3D ((*val - 1) * 254 / 243) + 1; + break; + case oxp_2: + case oxp_x1: + ret =3D read_from_ec(OXP_SENSOR_PWM_REG, 1, val); + if (ret) + return ret; + /* scale from range [0-184] */ + *val =3D (*val * 255) / 184; + break; + case aya_neo_2: + case aya_neo_air: + case aya_neo_air_1s: + case aya_neo_air_plus_mendo: + case aya_neo_air_pro: + case aya_neo_flip: + case aya_neo_geek: + case aya_neo_kun: + case oxp_mini_amd: + case oxp_mini_amd_a07: + ret =3D read_from_ec(OXP_SENSOR_PWM_REG, 1, val); + if (ret) + return ret; + /* scale from range [0-100] */ + *val =3D (*val * 255) / 100; + break; + case aok_zoe_a1: + case oxp_fly: + case oxp_mini_amd_pro: + default: + ret =3D read_from_ec(OXP_SENSOR_PWM_REG, 1, val); + if (ret) + return ret; + break; + } + return 0; +} + static int oxp_platform_read(struct device *dev, enum hwmon_sensor_types t= ype, u32 attr, int channel, long *val) { @@ -639,48 +725,7 @@ static int oxp_platform_read(struct device *dev, enum = hwmon_sensor_types type, case hwmon_pwm: switch (attr) { case hwmon_pwm_input: - switch (board) { - case orange_pi_neo: - ret =3D read_from_ec(ORANGEPI_SENSOR_PWM_REG, 1, val); - if (ret) - return ret; - /* scale from range [1-244] */ - *val =3D ((*val - 1) * 254 / 243) + 1; - break; - case oxp_2: - case oxp_x1: - ret =3D read_from_ec(OXP_SENSOR_PWM_REG, 1, val); - if (ret) - return ret; - /* scale from range [0-184] */ - *val =3D (*val * 255) / 184; - break; - case aya_neo_2: - case aya_neo_air: - case aya_neo_air_1s: - case aya_neo_air_plus_mendo: - case aya_neo_air_pro: - case aya_neo_flip: - case aya_neo_geek: - case aya_neo_kun: - case oxp_mini_amd: - case oxp_mini_amd_a07: - ret =3D read_from_ec(OXP_SENSOR_PWM_REG, 1, val); - if (ret) - return ret; - /* scale from range [0-100] */ - *val =3D (*val * 255) / 100; - break; - case aok_zoe_a1: - case oxp_fly: - case oxp_mini_amd_pro: - default: - ret =3D read_from_ec(OXP_SENSOR_PWM_REG, 1, val); - if (ret) - return ret; - break; - } - return 0; + return oxp_pwm_input_read(val); case hwmon_pwm_enable: return oxp_pwm_read(val); default: @@ -706,39 +751,7 @@ static int oxp_platform_write(struct device *dev, enum= hwmon_sensor_types type, return oxp_pwm_disable(); return -EINVAL; case hwmon_pwm_input: - if (val < 0 || val > 255) - return -EINVAL; - switch (board) { - case orange_pi_neo: - /* scale to range [1-244] */ - val =3D ((val - 1) * 243 / 254) + 1; - return write_to_ec(ORANGEPI_SENSOR_PWM_REG, val); - case oxp_2: - case oxp_x1: - /* scale to range [0-184] */ - val =3D (val * 184) / 255; - return write_to_ec(OXP_SENSOR_PWM_REG, val); - case aya_neo_2: - case aya_neo_air: - case aya_neo_air_1s: - case aya_neo_air_plus_mendo: - case aya_neo_air_pro: - case aya_neo_flip: - case aya_neo_geek: - case aya_neo_kun: - case oxp_mini_amd: - case oxp_mini_amd_a07: - /* scale to range [0-100] */ - val =3D (val * 100) / 255; - return write_to_ec(OXP_SENSOR_PWM_REG, val); - case aok_zoe_a1: - case oxp_fly: - case oxp_mini_amd_pro: - return write_to_ec(OXP_SENSOR_PWM_REG, val); - default: - break; - } - break; + return oxp_pwm_input_write(val); default: break; } --=20 2.49.0 From nobody Mon Feb 9 08:54:31 2026 Received: from linux1587.grserver.gr (linux1587.grserver.gr [185.138.42.100]) (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 5F47B25F7A1; Thu, 17 Apr 2025 17:53:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.138.42.100 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744912424; cv=none; b=kQJwhTvekCEUJd6Iww5S/Pw39Bb/5LQUjYpYE2UfNxL4o3njLwsvnviaE/L1YisA+gdOBQ82qip9socgPOVTtOzSQ/kgEhfGuEp/50pPhiXLcobu4bdE/tQTK52kfhurzgOviDfKdoU4dQCrieT/5MrrhaIPRhoG132GoK7E8hE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744912424; c=relaxed/simple; bh=38ShhrSrNGKh7k7/IHHz53bSwsS8kRtrwr1hDJdaPOI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=gvak4GdloQvmnd9MXa2sns606fwBJl9TgE+dN6J/M3xVWBrdYZCu8HaOb1NqqwMBnwGFn+pEdpk3vD8/jme2UuO8RaTMe4HCZ7Q4K4T46f+O+D0pg5V4a+fs9OtM17NmEGUhAPnTgoBHYsogQphn5IDPb1g+9IhEYcgSoEDd3UA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=antheas.dev; spf=pass smtp.mailfrom=antheas.dev; dkim=pass (1024-bit key) header.d=antheas.dev header.i=@antheas.dev header.b=v1K18Og6; arc=none smtp.client-ip=185.138.42.100 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=antheas.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=antheas.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=antheas.dev header.i=@antheas.dev header.b="v1K18Og6" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:cbc0:999f:73ad:33bd]) by linux1587.grserver.gr (Postfix) with ESMTPSA id 645C52E08886; Thu, 17 Apr 2025 20:53:38 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1744912420; bh=8W/U9wN57KtC9m5oXOAzSL0bGHr6zkPOnN65SFdPg8M=; h=From:To:Subject; b=v1K18Og69plvtuR5ZApS/9LKVQ95q5bUIdj6j8EAj8XECw1K2BSuBxm36uvvBjRRg gc9OPCgxy6CijLGVA3NnATGUbjR631jcmjprK69R9vZDYdylALoDiShMkJU/mDAz+8 4bfOG6OEC7AUtdzq8yYAwLxDz8R49wLieajf6RYo= Authentication-Results: linux1587.grserver.gr; spf=pass (sender IP is 2a05:f6c2:511b:0:cbc0:999f:73ad:33bd) smtp.mailfrom=lkml@antheas.dev smtp.helo=localhost.localdomain Received-SPF: pass (linux1587.grserver.gr: connection is authenticated) From: Antheas Kapenekakis To: platform-driver-x86@vger.kernel.org Cc: linux-hwmon@vger.kernel.org, linux-doc@vger.kernel.org, linux-pm@vger.kernel.org, Guenter Roeck , Jean Delvare , Jonathan Corbet , Joaquin Ignacio Aramendia , Derek J Clark , Kevin Greenberg , Joshua Tam , Parth Menon , Eileen , linux-kernel@vger.kernel.org, sre@kernel.org, linux@weissschuh.net, ilpo.jarvinen@linux.intel.com, hdegoede@redhat.com, mario.limonciello@amd.com, Antheas Kapenekakis Subject: [PATCH v9 10/15] platform/x86: oxpec: Move fan speed read to separate function Date: Thu, 17 Apr 2025 19:53:05 +0200 Message-ID: <20250417175310.3552671-11-lkml@antheas.dev> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250417175310.3552671-1-lkml@antheas.dev> References: <20250417175310.3552671-1-lkml@antheas.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-PPP-Message-ID: <174491242000.25306.3703614940855849095@linux1587.grserver.gr> X-PPP-Vhost: antheas.dev X-Virus-Scanned: clamav-milter 0.103.11 at linux1587.grserver.gr X-Virus-Status: Clean While not necessary for fixing the ABI hwmon issue, fan speed will be the only remaining value without a function. Therefore, finish the refactor by moving it to a separate function. Reviewed-by: Derek J. Clark Reviewed-by: Thomas Wei=C3=9Fschuh Reviewed-by: Ilpo J=C3=A4rvinen Signed-off-by: Antheas Kapenekakis --- drivers/platform/x86/oxpec.c | 53 ++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/drivers/platform/x86/oxpec.c b/drivers/platform/x86/oxpec.c index e670f7d6682a3..34d03525302bb 100644 --- a/drivers/platform/x86/oxpec.c +++ b/drivers/platform/x86/oxpec.c @@ -599,6 +599,34 @@ static umode_t oxp_ec_hwmon_is_visible(const void *drv= data, } } =20 +/* Fan speed read function */ +static int oxp_pwm_fan_speed(long *val) +{ + switch (board) { + case orange_pi_neo: + return read_from_ec(ORANGEPI_SENSOR_FAN_REG, 2, val); + case oxp_2: + case oxp_x1: + return read_from_ec(OXP_2_SENSOR_FAN_REG, 2, val); + case aok_zoe_a1: + case aya_neo_2: + case aya_neo_air: + case aya_neo_air_1s: + case aya_neo_air_plus_mendo: + case aya_neo_air_pro: + case aya_neo_flip: + case aya_neo_geek: + case aya_neo_kun: + case oxp_fly: + case oxp_mini_amd: + case oxp_mini_amd_a07: + case oxp_mini_amd_pro: + return read_from_ec(OXP_SENSOR_FAN_REG, 2, val); + default: + return -EOPNOTSUPP; + } +} + /* PWM input read/write functions */ static int oxp_pwm_input_write(long val) { @@ -694,30 +722,7 @@ static int oxp_platform_read(struct device *dev, enum = hwmon_sensor_types type, case hwmon_fan: switch (attr) { case hwmon_fan_input: - switch (board) { - case orange_pi_neo: - return read_from_ec(ORANGEPI_SENSOR_FAN_REG, 2, val); - case oxp_2: - case oxp_x1: - return read_from_ec(OXP_2_SENSOR_FAN_REG, 2, val); - case aok_zoe_a1: - case aya_neo_2: - case aya_neo_air: - case aya_neo_air_1s: - case aya_neo_air_plus_mendo: - case aya_neo_air_pro: - case aya_neo_flip: - case aya_neo_geek: - case aya_neo_kun: - case oxp_fly: - case oxp_mini_amd: - case oxp_mini_amd_a07: - case oxp_mini_amd_pro: - return read_from_ec(OXP_SENSOR_FAN_REG, 2, val); - default: - break; - } - break; + return oxp_pwm_fan_speed(val); default: break; } --=20 2.49.0 From nobody Mon Feb 9 08:54:31 2026 Received: from linux1587.grserver.gr (linux1587.grserver.gr [185.138.42.100]) (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 6CAEC25F976; Thu, 17 Apr 2025 17:53:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.138.42.100 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744912426; cv=none; b=EL4iNBJNIrZOiKcDoPAIh8lJA4us5reIJZVXxI/vxWOmwgbMibAr/DXMr2Q+e3OuxY5aABuXSPk4CR6MtCEnCsAc/9RcoB1wnYf3iIl6NCXfiMr4WOJZi1ug2QvUctzypPtzvJekhE6E7gkV7aHZiItKFM+HWV5YTXT6zcmivmI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744912426; c=relaxed/simple; bh=W1x5pJjA9EdH/lFvdzSyanXB2Y+JhoFnDL8qI9tULMs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bl2CrkiGK+0206gipPjTnLIzZDhhLSNrX/lncifch3in+Ud3JOX1GfCE5RUZG7GoBeuvMS+BZKy9A8SqBmgAvXBdqlYoaCNve04OI6sf9c7a61tPKGDTp9AFPNQJ6HRP17CBl0qpdvOjz5ezefEqwNlIwlvImdO12mgTC2wmvLk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=antheas.dev; spf=pass smtp.mailfrom=antheas.dev; dkim=pass (1024-bit key) header.d=antheas.dev header.i=@antheas.dev header.b=FVp/JD+Q; arc=none smtp.client-ip=185.138.42.100 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=antheas.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=antheas.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=antheas.dev header.i=@antheas.dev header.b="FVp/JD+Q" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:cbc0:999f:73ad:33bd]) by linux1587.grserver.gr (Postfix) with ESMTPSA id 85EFC2E08A45; Thu, 17 Apr 2025 20:53:40 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1744912422; bh=XhHSSS3yH/u0IeInccMOpfgv+K5OyWpd/7A7EUyh9l8=; h=From:To:Subject; b=FVp/JD+QyvEqbGgBtoqQHLTng0zlqYEcvxnVBRhtegrQy1o2bx7jLIiIkV5pEwJKz 6C4DlQme93t8eGzR6V6WsLoq2bRFx67la3QVkyFlF8b77EgS3WYVvOF/tMFS5ttsvB GnlOWY4XiYfcHFJhGgnEd0aOk/W4H5aK6odiJ2HA= Authentication-Results: linux1587.grserver.gr; spf=pass (sender IP is 2a05:f6c2:511b:0:cbc0:999f:73ad:33bd) smtp.mailfrom=lkml@antheas.dev smtp.helo=localhost.localdomain Received-SPF: pass (linux1587.grserver.gr: connection is authenticated) From: Antheas Kapenekakis To: platform-driver-x86@vger.kernel.org Cc: linux-hwmon@vger.kernel.org, linux-doc@vger.kernel.org, linux-pm@vger.kernel.org, Guenter Roeck , Jean Delvare , Jonathan Corbet , Joaquin Ignacio Aramendia , Derek J Clark , Kevin Greenberg , Joshua Tam , Parth Menon , Eileen , linux-kernel@vger.kernel.org, sre@kernel.org, linux@weissschuh.net, ilpo.jarvinen@linux.intel.com, hdegoede@redhat.com, mario.limonciello@amd.com, Antheas Kapenekakis Subject: [PATCH v9 11/15] platform/x86: oxpec: Adhere to sysfs-class-hwmon and enable pwm on 2 Date: Thu, 17 Apr 2025 19:53:06 +0200 Message-ID: <20250417175310.3552671-12-lkml@antheas.dev> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250417175310.3552671-1-lkml@antheas.dev> References: <20250417175310.3552671-1-lkml@antheas.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-PPP-Message-ID: <174491242209.25384.9562712213909073386@linux1587.grserver.gr> X-PPP-Vhost: antheas.dev X-Virus-Scanned: clamav-milter 0.103.11 at linux1587.grserver.gr X-Virus-Status: Clean Currently, the driver does not adhere to the sysfs-class-hwmon specification: 0 is used for auto fan control and 1 is used for manual control. However, it is expected that 0 sets the fan to full speed, 1 sets the fan to manual, and then 2 is used for automatic control. Therefore, change the sysfs API to reflect this and enable pwm on 2. As we are breaking the ABI for this driver, rename oxpec to oxp_ec, reflecting the naming convention used by other drivers, to allow for a smooth migration in current userspace programs. Closes: https://lore.kernel.org/linux-hwmon/20241027174836.8588-1-derekjohn= .clark@gmail.com/ Reviewed-by: Derek J. Clark Reviewed-by: Thomas Wei=C3=9Fschuh Signed-off-by: Antheas Kapenekakis --- drivers/platform/x86/oxpec.c | 37 ++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/drivers/platform/x86/oxpec.c b/drivers/platform/x86/oxpec.c index 34d03525302bb..52da8eae1f6ab 100644 --- a/drivers/platform/x86/oxpec.c +++ b/drivers/platform/x86/oxpec.c @@ -732,7 +732,27 @@ static int oxp_platform_read(struct device *dev, enum = hwmon_sensor_types type, case hwmon_pwm_input: return oxp_pwm_input_read(val); case hwmon_pwm_enable: - return oxp_pwm_read(val); + ret =3D oxp_pwm_read(val); + if (ret) + return ret; + + /* Check for auto and return 2 */ + if (!*val) { + *val =3D 2; + return 0; + } + + /* Return 0 if at full fan speed, 1 otherwise */ + ret =3D oxp_pwm_fan_speed(val); + if (ret) + return ret; + + if (*val =3D=3D 255) + *val =3D 0; + else + *val =3D 1; + + return 0; default: break; } @@ -746,15 +766,24 @@ static int oxp_platform_read(struct device *dev, enum= hwmon_sensor_types type, static int oxp_platform_write(struct device *dev, enum hwmon_sensor_types = type, u32 attr, int channel, long val) { + int ret; + switch (type) { case hwmon_pwm: switch (attr) { case hwmon_pwm_enable: if (val =3D=3D 1) return oxp_pwm_enable(); - else if (val =3D=3D 0) + else if (val =3D=3D 2) return oxp_pwm_disable(); - return -EINVAL; + else if (val !=3D 0) + return -EINVAL; + + /* Enable PWM and set to max speed */ + ret =3D oxp_pwm_enable(); + if (ret) + return ret; + return oxp_pwm_input_write(255); case hwmon_pwm_input: return oxp_pwm_input_write(val); default: @@ -819,7 +848,7 @@ static int oxp_platform_probe(struct platform_device *p= dev) struct device *dev =3D &pdev->dev; struct device *hwdev; =20 - hwdev =3D devm_hwmon_device_register_with_info(dev, "oxpec", NULL, + hwdev =3D devm_hwmon_device_register_with_info(dev, "oxp_ec", NULL, &oxp_ec_chip_info, NULL); =20 return PTR_ERR_OR_ZERO(hwdev); --=20 2.49.0 From nobody Mon Feb 9 08:54:31 2026 Received: from linux1587.grserver.gr (linux1587.grserver.gr [185.138.42.100]) (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 8E4EC25FA02; Thu, 17 Apr 2025 17:53:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.138.42.100 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744912428; cv=none; b=keuSNbLAPM7T5OZASh8is3fp+BxEebGTFuzDF4ZKGsFav7MWi0oZ11ZtOC85S+OEfgZ/pn7RX9gBB+zYjki+ehB6KAPDzgEXYm+lNCSRhhYRo2CjOkeb7GZ7CZJ4etsx9mxFU6yvrqg0vAD9yo3AL+99cxjxWoigx/j7JfTLonk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744912428; c=relaxed/simple; bh=yhEC6EeCpLHcZHJ9zjuVKtqzb6sByX/NcvDaQXwglx0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QbUYGu0hSBNOHjFHWNl6gqyX0ELbbJs0bAzIogy6s1W5FBnPfzkDlzluuXFsMxf1JO2TLkNVU7rtCtQfyPs+nbEX1dYkI9TM8EsVypJsuyjKBykhobIUMT4JWhEMIowkOv1f+2u3RuHFWbBYizM1+rTyAkkPKT7pANtQ3Uthh7w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=antheas.dev; spf=pass smtp.mailfrom=antheas.dev; dkim=pass (1024-bit key) header.d=antheas.dev header.i=@antheas.dev header.b=BkSqAX8D; arc=none smtp.client-ip=185.138.42.100 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=antheas.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=antheas.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=antheas.dev header.i=@antheas.dev header.b="BkSqAX8D" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:cbc0:999f:73ad:33bd]) by linux1587.grserver.gr (Postfix) with ESMTPSA id 9B2B22E0895C; Thu, 17 Apr 2025 20:53:42 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1744912424; bh=HggYufjt3XZkNQt7t5KK5n04IGuQ6SJ0N3o6KdXnpCk=; h=From:To:Subject; b=BkSqAX8DndrbHnvOuOpzKnE2N7ofieFtzPuARqD173Dt1/e1L4sOLODAHovl0Wt7D nY5JXqcYvTtriqJpuXKgjjl6ecaeLHIP91qKZX4jjJ6k/+RR52u5xmMmq0+/DWr3hP sKb93wymoleqVD6KHD42zUKb0FNOhXiJjnSWRYgk= Authentication-Results: linux1587.grserver.gr; spf=pass (sender IP is 2a05:f6c2:511b:0:cbc0:999f:73ad:33bd) smtp.mailfrom=lkml@antheas.dev smtp.helo=localhost.localdomain Received-SPF: pass (linux1587.grserver.gr: connection is authenticated) From: Antheas Kapenekakis To: platform-driver-x86@vger.kernel.org Cc: linux-hwmon@vger.kernel.org, linux-doc@vger.kernel.org, linux-pm@vger.kernel.org, Guenter Roeck , Jean Delvare , Jonathan Corbet , Joaquin Ignacio Aramendia , Derek J Clark , Kevin Greenberg , Joshua Tam , Parth Menon , Eileen , linux-kernel@vger.kernel.org, sre@kernel.org, linux@weissschuh.net, ilpo.jarvinen@linux.intel.com, hdegoede@redhat.com, mario.limonciello@amd.com, Antheas Kapenekakis Subject: [PATCH v9 12/15] platform/x86: oxpec: Follow reverse xmas convention for tt_toggle Date: Thu, 17 Apr 2025 19:53:07 +0200 Message-ID: <20250417175310.3552671-13-lkml@antheas.dev> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250417175310.3552671-1-lkml@antheas.dev> References: <20250417175310.3552671-1-lkml@antheas.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-PPP-Message-ID: <174491242423.25446.11537593235259946639@linux1587.grserver.gr> X-PPP-Vhost: antheas.dev X-Virus-Scanned: clamav-milter 0.103.11 at linux1587.grserver.gr X-Virus-Status: Clean Since the rest of the driver follows this convention, apply it to the tt_toggle attribute as well. Suggested-by: Derek J. Clark Reviewed-by: Thomas Wei=C3=9Fschuh Reviewed-by: Derek J. Clark Reviewed-by: Ilpo J=C3=A4rvinen Signed-off-by: Antheas Kapenekakis --- drivers/platform/x86/oxpec.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/platform/x86/oxpec.c b/drivers/platform/x86/oxpec.c index 52da8eae1f6ab..f0b9fff704de2 100644 --- a/drivers/platform/x86/oxpec.c +++ b/drivers/platform/x86/oxpec.c @@ -275,9 +275,9 @@ static const struct dmi_system_id dmi_table[] =3D { /* Helper functions to handle EC read/write */ static int read_from_ec(u8 reg, int size, long *val) { - int i; - int ret; u8 buffer; + int ret; + int i; =20 if (!lock_global_acpi_lock()) return -EBUSY; @@ -389,8 +389,8 @@ static ssize_t tt_toggle_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - int rval; bool value; + int rval; =20 rval =3D kstrtobool(buf, &value); if (rval) @@ -411,8 +411,8 @@ static ssize_t tt_toggle_show(struct device *dev, struct device_attribute *attr, char *buf) { int retval; - u8 reg; long val; + u8 reg; =20 switch (board) { case oxp_mini_amd_a07: --=20 2.49.0 From nobody Mon Feb 9 08:54:31 2026 Received: from linux1587.grserver.gr (linux1587.grserver.gr [185.138.42.100]) (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 DA752256C7C; Thu, 17 Apr 2025 17:53:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.138.42.100 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744912430; cv=none; b=NubkXkXO9jMS6LnvR0xmG6JfSr+XJ1jl33p4jbcgX8CdRgtR25AyO39tEjADZFaBzQ4wC+8bGdukDXkk8UhNTiK4vLgCtn2vV7DfEtqlcG2dzdSxePepfvWdZdoOsAIzwLZfEbcTt3pOSBqZxyQNYZsEY2JTqH8H4ThW3XCPDQA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744912430; c=relaxed/simple; bh=KHGeqRdR5/i8bbgxfw+CwTe2YU3ouOcLdfQneRVejQU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YaO6oe4ia8yHIhnGDap6A6D9L1ReWaarNDCCmVZ2I6O1mNCPTQL1owNa0qpb1qXlPF67X+DG7eY4KXum0hb1fWEMlcKI5k6lziTbzrteCj9/AgwC132sR8OPjNZvFX4CcinmsHtt3KBXBHlnK6aRhLLvLQeRgl9Ip2MLUPSkvUE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=antheas.dev; spf=pass smtp.mailfrom=antheas.dev; dkim=pass (1024-bit key) header.d=antheas.dev header.i=@antheas.dev header.b=J1svjDUO; arc=none smtp.client-ip=185.138.42.100 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=antheas.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=antheas.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=antheas.dev header.i=@antheas.dev header.b="J1svjDUO" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:cbc0:999f:73ad:33bd]) by linux1587.grserver.gr (Postfix) with ESMTPSA id C56C12E08ABD; Thu, 17 Apr 2025 20:53:44 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1744912426; bh=wppNQ2GNLFtVHAZHYjXQGDauhSnmxaDr95bquKr3Evc=; h=From:To:Subject; b=J1svjDUO/g4mVDriZP1Hhf4tQ0y8Xy7T9341DYqgq9ptHVG4RWmRmIYGs4asHWAxd MOKTO7AuAvBKXD1WPTMrLKtsQ15fWurpt2gIiunZZTdchx4S6uq2kNwspRsdSgbUT7 +htb33e7VahFCUSpNmEHVPR4/M0+BQ8JJ3fcagUE= Authentication-Results: linux1587.grserver.gr; spf=pass (sender IP is 2a05:f6c2:511b:0:cbc0:999f:73ad:33bd) smtp.mailfrom=lkml@antheas.dev smtp.helo=localhost.localdomain Received-SPF: pass (linux1587.grserver.gr: connection is authenticated) From: Antheas Kapenekakis To: platform-driver-x86@vger.kernel.org Cc: linux-hwmon@vger.kernel.org, linux-doc@vger.kernel.org, linux-pm@vger.kernel.org, Guenter Roeck , Jean Delvare , Jonathan Corbet , Joaquin Ignacio Aramendia , Derek J Clark , Kevin Greenberg , Joshua Tam , Parth Menon , Eileen , linux-kernel@vger.kernel.org, sre@kernel.org, linux@weissschuh.net, ilpo.jarvinen@linux.intel.com, hdegoede@redhat.com, mario.limonciello@amd.com, Antheas Kapenekakis Subject: [PATCH v9 13/15] power: supply: add inhibit-charge-awake to charge_behaviour Date: Thu, 17 Apr 2025 19:53:08 +0200 Message-ID: <20250417175310.3552671-14-lkml@antheas.dev> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250417175310.3552671-1-lkml@antheas.dev> References: <20250417175310.3552671-1-lkml@antheas.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-PPP-Message-ID: <174491242635.25552.2163975697188219251@linux1587.grserver.gr> X-PPP-Vhost: antheas.dev X-Virus-Scanned: clamav-milter 0.103.11 at linux1587.grserver.gr X-Virus-Status: Clean OneXPlayer devices have a charge inhibit feature that allows the user to select between it being active always or only when the device is on. Therefore, add attribute inhibit-charge-awake to charge_behaviour to allow the user to select that charge should be paused only when the device is awake. Reviewed-by: Hans de Goede Reviewed-by: Thomas Wei=C3=9Fschuh Reviewed-by: Derek J. Clark Signed-off-by: Antheas Kapenekakis --- Documentation/ABI/testing/sysfs-class-power | 11 ++++++----- drivers/power/supply/power_supply_sysfs.c | 7 ++++--- drivers/power/supply/test_power.c | 1 + include/linux/power_supply.h | 1 + 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-class-power b/Documentation/AB= I/testing/sysfs-class-power index 2a5c1a09a28f9..78afb2422fc5a 100644 --- a/Documentation/ABI/testing/sysfs-class-power +++ b/Documentation/ABI/testing/sysfs-class-power @@ -508,11 +508,12 @@ Description: Access: Read, Write =20 Valid values: - =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D - auto: Charge normally, respect thresholds - inhibit-charge: Do not charge while AC is attached - force-discharge: Force discharge while AC is attached - =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D + =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + auto: Charge normally, respect thresholds + inhibit-charge: Do not charge while AC is attached + inhibit-charge-awake: inhibit-charge only when device is awake + force-discharge: Force discharge while AC is attached + =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 What: /sys/class/power_supply//technology Date: May 2007 diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supp= ly/power_supply_sysfs.c index edb058c19c9c4..f769d5941d0d3 100644 --- a/drivers/power/supply/power_supply_sysfs.c +++ b/drivers/power/supply/power_supply_sysfs.c @@ -138,9 +138,10 @@ static const char * const POWER_SUPPLY_SCOPE_TEXT[] = =3D { }; =20 static const char * const POWER_SUPPLY_CHARGE_BEHAVIOUR_TEXT[] =3D { - [POWER_SUPPLY_CHARGE_BEHAVIOUR_AUTO] =3D "auto", - [POWER_SUPPLY_CHARGE_BEHAVIOUR_INHIBIT_CHARGE] =3D "inhibit-charge", - [POWER_SUPPLY_CHARGE_BEHAVIOUR_FORCE_DISCHARGE] =3D "force-discharge", + [POWER_SUPPLY_CHARGE_BEHAVIOUR_AUTO] =3D "auto", + [POWER_SUPPLY_CHARGE_BEHAVIOUR_INHIBIT_CHARGE] =3D "inhibit-charge", + [POWER_SUPPLY_CHARGE_BEHAVIOUR_INHIBIT_CHARGE_AWAKE] =3D "inhibit-charge-= awake", + [POWER_SUPPLY_CHARGE_BEHAVIOUR_FORCE_DISCHARGE] =3D "force-discharge", }; =20 static struct power_supply_attr power_supply_attrs[] __ro_after_init =3D { diff --git a/drivers/power/supply/test_power.c b/drivers/power/supply/test_= power.c index 2a975a110f485..958e0c0cf2876 100644 --- a/drivers/power/supply/test_power.c +++ b/drivers/power/supply/test_power.c @@ -214,6 +214,7 @@ static const struct power_supply_desc test_power_desc[]= =3D { .property_is_writeable =3D test_power_battery_property_is_writeable, .charge_behaviours =3D BIT(POWER_SUPPLY_CHARGE_BEHAVIOUR_AUTO) | BIT(POWER_SUPPLY_CHARGE_BEHAVIOUR_INHIBIT_CHARGE) + | BIT(POWER_SUPPLY_CHARGE_BEHAVIOUR_INHIBIT_CHARGE_AWAKE) | BIT(POWER_SUPPLY_CHARGE_BEHAVIOUR_FORCE_DISCHARGE), }, [TEST_USB] =3D { diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index 888824592953d..cbec930430a79 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -212,6 +212,7 @@ enum power_supply_usb_type { enum power_supply_charge_behaviour { POWER_SUPPLY_CHARGE_BEHAVIOUR_AUTO =3D 0, POWER_SUPPLY_CHARGE_BEHAVIOUR_INHIBIT_CHARGE, + POWER_SUPPLY_CHARGE_BEHAVIOUR_INHIBIT_CHARGE_AWAKE, POWER_SUPPLY_CHARGE_BEHAVIOUR_FORCE_DISCHARGE, }; =20 --=20 2.49.0 From nobody Mon Feb 9 08:54:31 2026 Received: from linux1587.grserver.gr (linux1587.grserver.gr [185.138.42.100]) (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 CD487261596; Thu, 17 Apr 2025 17:53:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.138.42.100 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744912432; cv=none; b=SZkV0dOlXqB9e6bvxyTHtXkmqF/6Vto1H3354E/lmuCRFmFlUOXTQxiWAQHnfZYvRkhkBbS0tdqhPDWBchdTQmPuf/vFN4f57TMvTCcLwl3g6qpAxuc4haBjsVg9JvuFYrODKym+5XJG+JQNH4jBoPYuQ5ZkGg8PnhX90bBW10o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744912432; c=relaxed/simple; bh=ZbJK7WSW9vrJAq1geMxJC0zIrQYeRPzUlmkFL/ZUGMI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LBHiMeFg/eTv618Vk9B0Bq+Z+hB9qX0QRe8ocvMzgcBZEuhND8rgqnp4p4CWys0FZl+DL4De/egnRJ3gmGP68YBMhhJZOGzHqAmS0sicBoOE+DDFDjsWQJ8bB2JJCvh5xRjv0rLduUOBO2olYrlIp/4EUg0yWXq81sc/tRCe5BQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=antheas.dev; spf=pass smtp.mailfrom=antheas.dev; dkim=pass (1024-bit key) header.d=antheas.dev header.i=@antheas.dev header.b=z3hEd+NB; arc=none smtp.client-ip=185.138.42.100 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=antheas.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=antheas.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=antheas.dev header.i=@antheas.dev header.b="z3hEd+NB" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:cbc0:999f:73ad:33bd]) by linux1587.grserver.gr (Postfix) with ESMTPSA id D7F882E08699; Thu, 17 Apr 2025 20:53:46 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1744912428; bh=8h6yzCqYcnoeJQQzxUS2gzrRRMIzjsAjfJRkwAvEXEw=; h=From:To:Subject; b=z3hEd+NBGVktNXufOshglVsuByfCiEx8u8v4yteQmBRklB3GFFnuYEDFKGOC6cVQT kKmgG6JH/La1xhheQoeP6tE1YMY4Twa66kRd2RWtepPWZXEl7ayNJrZLrGdzDrQx4s +ue9NVtdUD2AispImcJRh/PTWJoFbA4VSWEGgmD4= Authentication-Results: linux1587.grserver.gr; spf=pass (sender IP is 2a05:f6c2:511b:0:cbc0:999f:73ad:33bd) smtp.mailfrom=lkml@antheas.dev smtp.helo=localhost.localdomain Received-SPF: pass (linux1587.grserver.gr: connection is authenticated) From: Antheas Kapenekakis To: platform-driver-x86@vger.kernel.org Cc: linux-hwmon@vger.kernel.org, linux-doc@vger.kernel.org, linux-pm@vger.kernel.org, Guenter Roeck , Jean Delvare , Jonathan Corbet , Joaquin Ignacio Aramendia , Derek J Clark , Kevin Greenberg , Joshua Tam , Parth Menon , Eileen , linux-kernel@vger.kernel.org, sre@kernel.org, linux@weissschuh.net, ilpo.jarvinen@linux.intel.com, hdegoede@redhat.com, mario.limonciello@amd.com, Antheas Kapenekakis Subject: [PATCH v9 14/15] platform/x86: oxpec: Add charge threshold and behaviour to OneXPlayer Date: Thu, 17 Apr 2025 19:53:09 +0200 Message-ID: <20250417175310.3552671-15-lkml@antheas.dev> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250417175310.3552671-1-lkml@antheas.dev> References: <20250417175310.3552671-1-lkml@antheas.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-PPP-Message-ID: <174491242847.25623.9412430074795185223@linux1587.grserver.gr> X-PPP-Vhost: antheas.dev X-Virus-Scanned: clamav-milter 0.103.11 at linux1587.grserver.gr X-Virus-Status: Clean With the X1 (AMD), OneXPlayer added a charge limit and charge inhibit feature to their devices. Charge limit allows for choosing an arbitrary battery charge setpoint in percentages. Charge ihibit allows to instruct the device to stop charging either when it is awake or always. This feature was then extended for the F1Pro as well. OneXPlayer also released BIOS updates for the X1 Mini, X1 (Intel), and F1 devices that add support for this feature. Therefore, enable it for all F1 and X1 devices. Reviewed-by: Thomas Wei=C3=9Fschuh Reviewed-by: Derek J. Clark Signed-off-by: Antheas Kapenekakis --- drivers/platform/x86/Kconfig | 1 + drivers/platform/x86/oxpec.c | 155 ++++++++++++++++++++++++++++++++++- 2 files changed, 155 insertions(+), 1 deletion(-) diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig index 739740c4bb535..6c9e64a03aaef 100644 --- a/drivers/platform/x86/Kconfig +++ b/drivers/platform/x86/Kconfig @@ -1204,6 +1204,7 @@ config SEL3350_PLATFORM config OXP_EC tristate "OneXPlayer EC platform control" depends on ACPI_EC + depends on ACPI_BATTERY depends on HWMON depends on X86 help diff --git a/drivers/platform/x86/oxpec.c b/drivers/platform/x86/oxpec.c index f0b9fff704de2..ce20bf70027df 100644 --- a/drivers/platform/x86/oxpec.c +++ b/drivers/platform/x86/oxpec.c @@ -24,6 +24,7 @@ #include #include #include +#include =20 /* Handle ACPI lock mechanism */ static u32 oxp_mutex; @@ -60,6 +61,7 @@ enum oxp_board { }; =20 static enum oxp_board board; +static struct device *oxp_dev; =20 /* Fan reading and PWM */ #define OXP_SENSOR_FAN_REG 0x76 /* Fan reading is 2 registers = long */ @@ -93,6 +95,23 @@ static enum oxp_board board; #define OXP_X1_TURBO_LED_OFF 0x01 #define OXP_X1_TURBO_LED_ON 0x02 =20 +/* Battery extension settings */ +#define EC_CHARGE_CONTROL_BEHAVIOURS (BIT(POWER_SUPPLY_CHARGE_BEHAVIOUR_AU= TO) | \ + BIT(POWER_SUPPLY_CHARGE_BEHAVIOUR_INHIBIT_CHARGE) | \ + BIT(POWER_SUPPLY_CHARGE_BEHAVIOUR_INHIBIT_CHARGE_AWAKE)) + +#define OXP_X1_CHARGE_LIMIT_REG 0xA3 /* X1 charge limit (%) */ +#define OXP_X1_CHARGE_INHIBIT_REG 0xA4 /* X1 bypass charging */ + +#define OXP_X1_CHARGE_INHIBIT_MASK_AWAKE 0x01 +/* + * X1 Mask is 0x0A, OneXFly F1Pro is just 0x02 + * but the extra bit on the X1 does nothing. + */ +#define OXP_X1_CHARGE_INHIBIT_MASK_OFF 0x02 +#define OXP_X1_CHARGE_INHIBIT_MASK_ALWAYS (OXP_X1_CHARGE_INHIBIT_MASK_AWAK= E | \ + OXP_X1_CHARGE_INHIBIT_MASK_OFF) + static const struct dmi_system_id dmi_table[] =3D { { .matches =3D { @@ -507,6 +526,129 @@ static ssize_t tt_led_show(struct device *dev, =20 static DEVICE_ATTR_RW(tt_led); =20 +/* Callbacks for charge behaviour attributes */ +static bool oxp_psy_ext_supported(void) +{ + switch (board) { + case oxp_x1: + case oxp_fly: + return true; + default: + break; + } + return false; +} + +static int oxp_psy_ext_get_prop(struct power_supply *psy, + const struct power_supply_ext *ext, + void *data, + enum power_supply_property psp, + union power_supply_propval *val) +{ + long raw_val; + int ret; + + switch (psp) { + case POWER_SUPPLY_PROP_CHARGE_CONTROL_END_THRESHOLD: + ret =3D read_from_ec(OXP_X1_CHARGE_LIMIT_REG, 1, &raw_val); + if (ret) + return ret; + if (raw_val < 0 || raw_val > 100) + return -EINVAL; + val->intval =3D raw_val; + return 0; + case POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR: + ret =3D read_from_ec(OXP_X1_CHARGE_INHIBIT_REG, 1, &raw_val); + if (ret) + return ret; + if ((raw_val & OXP_X1_CHARGE_INHIBIT_MASK_ALWAYS) =3D=3D + OXP_X1_CHARGE_INHIBIT_MASK_ALWAYS) + val->intval =3D POWER_SUPPLY_CHARGE_BEHAVIOUR_INHIBIT_CHARGE; + else if ((raw_val & OXP_X1_CHARGE_INHIBIT_MASK_AWAKE) =3D=3D + OXP_X1_CHARGE_INHIBIT_MASK_AWAKE) + val->intval =3D POWER_SUPPLY_CHARGE_BEHAVIOUR_INHIBIT_CHARGE_AWAKE; + else + val->intval =3D POWER_SUPPLY_CHARGE_BEHAVIOUR_AUTO; + return 0; + default: + return -EINVAL; + } +} + +static int oxp_psy_ext_set_prop(struct power_supply *psy, + const struct power_supply_ext *ext, + void *data, + enum power_supply_property psp, + const union power_supply_propval *val) +{ + long raw_val; + + switch (psp) { + case POWER_SUPPLY_PROP_CHARGE_CONTROL_END_THRESHOLD: + if (val->intval > 100) + return -EINVAL; + return write_to_ec(OXP_X1_CHARGE_LIMIT_REG, val->intval); + case POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR: + switch (val->intval) { + case POWER_SUPPLY_CHARGE_BEHAVIOUR_AUTO: + raw_val =3D 0; + break; + case POWER_SUPPLY_CHARGE_BEHAVIOUR_INHIBIT_CHARGE_AWAKE: + raw_val =3D OXP_X1_CHARGE_INHIBIT_MASK_AWAKE; + break; + case POWER_SUPPLY_CHARGE_BEHAVIOUR_INHIBIT_CHARGE: + raw_val =3D OXP_X1_CHARGE_INHIBIT_MASK_ALWAYS; + break; + default: + return -EINVAL; + } + + return write_to_ec(OXP_X1_CHARGE_INHIBIT_REG, raw_val); + default: + return -EINVAL; + } +} + +static int oxp_psy_prop_is_writeable(struct power_supply *psy, + const struct power_supply_ext *ext, + void *data, + enum power_supply_property psp) +{ + return true; +} + +static const enum power_supply_property oxp_psy_ext_props[] =3D { + POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR, + POWER_SUPPLY_PROP_CHARGE_CONTROL_END_THRESHOLD, +}; + +static const struct power_supply_ext oxp_psy_ext =3D { + .name =3D "oxp-charge-control", + .properties =3D oxp_psy_ext_props, + .num_properties =3D ARRAY_SIZE(oxp_psy_ext_props), + .charge_behaviours =3D EC_CHARGE_CONTROL_BEHAVIOURS, + .get_property =3D oxp_psy_ext_get_prop, + .set_property =3D oxp_psy_ext_set_prop, + .property_is_writeable =3D oxp_psy_prop_is_writeable, +}; + +static int oxp_add_battery(struct power_supply *battery, struct acpi_batte= ry_hook *hook) +{ + return power_supply_register_extension(battery, &oxp_psy_ext, oxp_dev, NU= LL); +} + +static int oxp_remove_battery(struct power_supply *battery, struct acpi_ba= ttery_hook *hook) +{ + power_supply_unregister_extension(battery, &oxp_psy_ext); + return 0; +} + +static struct acpi_battery_hook battery_hook =3D { + .add_battery =3D oxp_add_battery, + .remove_battery =3D oxp_remove_battery, + .name =3D "OneXPlayer Battery", +}; + /* PWM enable/disable functions */ static int oxp_pwm_enable(void) { @@ -847,11 +989,22 @@ static int oxp_platform_probe(struct platform_device = *pdev) { struct device *dev =3D &pdev->dev; struct device *hwdev; + int ret; =20 + oxp_dev =3D dev; hwdev =3D devm_hwmon_device_register_with_info(dev, "oxp_ec", NULL, &oxp_ec_chip_info, NULL); =20 - return PTR_ERR_OR_ZERO(hwdev); + if (IS_ERR(hwdev)) + return PTR_ERR(hwdev); + + if (oxp_psy_ext_supported()) { + ret =3D devm_battery_hook_register(dev, &battery_hook); + if (ret) + return ret; + } + + return 0; } =20 static struct platform_driver oxp_platform_driver =3D { --=20 2.49.0 From nobody Mon Feb 9 08:54:31 2026 Received: from linux1587.grserver.gr (linux1587.grserver.gr [185.138.42.100]) (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 9A881262802; Thu, 17 Apr 2025 17:53:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.138.42.100 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744912434; cv=none; b=s6aN0h4NGsNBfKmf744wwcvF/FRxb9VJcKUbqIxWvlzwV35hAdB3llIqnrNFZTwtN84gIQJ9KH8LsSVCXpoPg/5Q58De3UlbsGx8G+6o05xr6vHzxwd5fMDYHI0V8Pj32iSJJuZhUupdAHUdwX6IV9ynN0FbRQOIj/hj8+iG6Z8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744912434; c=relaxed/simple; bh=A3MMV+vmZjIoXu0GmJWHKWsCrLocFJbNSS2ruwYfoRs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=n9U/gWRcmYXu1q6UFINR4fZqPeSCMMtM8lVH2k7aAAi3ttd78aAG1Bm0LcUl3Qgk7wFFwY53ox9wDIxoFtMrRp76YS4gLhkLOOCdA04VLYzy9whDbc2zPBa0wRDggQlxFjvyJUIz/vrO5yzqMY9RH72QJLza75nEdbkglufvZ2c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=antheas.dev; spf=pass smtp.mailfrom=antheas.dev; dkim=pass (1024-bit key) header.d=antheas.dev header.i=@antheas.dev header.b=PiT8k22B; arc=none smtp.client-ip=185.138.42.100 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=antheas.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=antheas.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=antheas.dev header.i=@antheas.dev header.b="PiT8k22B" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:cbc0:999f:73ad:33bd]) by linux1587.grserver.gr (Postfix) with ESMTPSA id 0026D2E08A29; Thu, 17 Apr 2025 20:53:48 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1744912430; bh=iATCUyRrvR0Ub0BIamsKc+GUsMtporebMAuhSglaFuM=; h=From:To:Subject; b=PiT8k22B3W8LIwSYgQk/E3Z89kgwiMcntTebJg05hNPL+Rv7XXsuwMQeBEFMQAqrq 5m2HIm0ZlcWNUOK2rHelMr29nlH8EGAVOh+yZHckye5umEpjbLn3DzNOtBPvzFk88c CHK9MgADOKAvA6WpnvkSlRfhnvqRZZWk80S4GEgU= Authentication-Results: linux1587.grserver.gr; spf=pass (sender IP is 2a05:f6c2:511b:0:cbc0:999f:73ad:33bd) smtp.mailfrom=lkml@antheas.dev smtp.helo=localhost.localdomain Received-SPF: pass (linux1587.grserver.gr: connection is authenticated) From: Antheas Kapenekakis To: platform-driver-x86@vger.kernel.org Cc: linux-hwmon@vger.kernel.org, linux-doc@vger.kernel.org, linux-pm@vger.kernel.org, Guenter Roeck , Jean Delvare , Jonathan Corbet , Joaquin Ignacio Aramendia , Derek J Clark , Kevin Greenberg , Joshua Tam , Parth Menon , Eileen , linux-kernel@vger.kernel.org, sre@kernel.org, linux@weissschuh.net, ilpo.jarvinen@linux.intel.com, hdegoede@redhat.com, mario.limonciello@amd.com, Antheas Kapenekakis Subject: [PATCH v9 15/15] platform/x86: oxpec: Rename rval to ret in tt_toggle Date: Thu, 17 Apr 2025 19:53:10 +0200 Message-ID: <20250417175310.3552671-16-lkml@antheas.dev> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250417175310.3552671-1-lkml@antheas.dev> References: <20250417175310.3552671-1-lkml@antheas.dev> 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 X-PPP-Message-ID: <174491243058.25694.1911444091932643740@linux1587.grserver.gr> X-PPP-Vhost: antheas.dev X-Virus-Scanned: clamav-milter 0.103.11 at linux1587.grserver.gr X-Virus-Status: Clean Content-Type: text/plain; charset="utf-8" Rename the variable `rval` to `ret` in the function to follow conventions. Signed-off-by: Antheas Kapenekakis --- drivers/platform/x86/oxpec.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/platform/x86/oxpec.c b/drivers/platform/x86/oxpec.c index ce20bf70027df..93d4abf8c3b8a 100644 --- a/drivers/platform/x86/oxpec.c +++ b/drivers/platform/x86/oxpec.c @@ -409,19 +409,19 @@ static ssize_t tt_toggle_store(struct device *dev, size_t count) { bool value; - int rval; + int ret; =20 - rval =3D kstrtobool(buf, &value); - if (rval) - return rval; + ret =3D kstrtobool(buf, &value); + if (ret) + return ret; =20 if (value) { - rval =3D tt_toggle_enable(); + ret =3D tt_toggle_enable(); } else { - rval =3D tt_toggle_disable(); + ret =3D tt_toggle_disable(); } - if (rval) - return rval; + if (ret) + return ret; =20 return count; } --=20 2.49.0