From patchwork Tue Mar 11 16:53:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antheas Kapenekakis X-Patchwork-Id: 873007 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 CCCDA26039F; Tue, 11 Mar 2025 16:54:14 +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=1741712058; cv=none; b=nXO+/ykO3x9ksqz9kiUYpjGKVrSTKjtSb9XeWAC+3zZezshFFI80YetCWiH7s177e2Cqv+1N+1dFRUU1MgXOmv84zeTFw3u4NlNozVJaXWTW+lSx3IO8tSWczIrtKG2HDauLtBrg2Jg3QphQN1Ye6lRY9/QkP87KEyef0H0A/6Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741712058; c=relaxed/simple; bh=kILRVZMBdQIYoMJhfz1MBVu0woYBudSdv/e/sEtrRP0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dUv2muqe5MS5VLsGFvPjz6iE/TrTKzlyieuAmQ1j58NgPu3cR5UtXRMmSKfbqwzyIJwzFCM8MLwn/a8Q98es02HsQsN+P0tqt2BKIOJk2FvjMlhgr5HZZWqD2/0EFkaPUZivjuXoEgJQr8sSpEKMp6VQ9MTr3KmiG1wvHQKv6SE= 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=jRgM/I5D; 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="jRgM/I5D" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:cbc0:999f:73ad:33bd]) by linux1587.grserver.gr (Postfix) with ESMTPSA id A70CA2E0922E; Tue, 11 Mar 2025 18:54:10 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1741712052; bh=FKuGDlWLqAliU+VChCsFC7BlVYYSBUr2A+nRmwDGnlc=; h=From:To:Subject; b=jRgM/I5DV84WiaKAkA3Z6zDKzyt2lh7f+Jp/Isnnby9PxFSWpjI/G+crm1pozjWaj LOcusOE4Zdv1Zjw0z5mkf9ixoio/kBE+01+4vHaej2ckRATgGJLNJXPtyCnFuKoLov vdA1kMOGLgCC1iG+LGHKMBLDuP/lf6/6oOSilXvs= 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 , Antheas Kapenekakis Subject: [PATCH v4 01/13] hwmon: (oxp-sensors) Distinguish the X1 variants Date: Tue, 11 Mar 2025 17:53:53 +0100 Message-ID: <20250311165406.331046-2-lkml@antheas.dev> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250311165406.331046-1-lkml@antheas.dev> References: <20250311165406.331046-1-lkml@antheas.dev> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-PPP-Message-ID: <174171205194.19058.9442469946778927089@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 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 83730d931824..5a4230ad3757 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[] = { { .matches = { 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 = (void *)oxp_x1, + }, + { + .matches = { + DMI_MATCH(DMI_BOARD_VENDOR, "ONE-NETBOOK"), + DMI_EXACT_MATCH(DMI_BOARD_NAME, "ONEXPLAYER X1 i"), + }, + .driver_data = (void *)oxp_x1, + }, + { + .matches = { + DMI_MATCH(DMI_BOARD_VENDOR, "ONE-NETBOOK"), + DMI_EXACT_MATCH(DMI_BOARD_NAME, "ONEXPLAYER X1 mini"), + }, + .driver_data = (void *)oxp_x1, + }, + { + .matches = { + DMI_MATCH(DMI_BOARD_VENDOR, "ONE-NETBOOK"), + DMI_EXACT_MATCH(DMI_BOARD_NAME, "ONEXPLAYER X1Pro"), }, .driver_data = (void *)oxp_x1, }, From patchwork Tue Mar 11 16:53:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antheas Kapenekakis X-Patchwork-Id: 872733 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 1C460260A2A; Tue, 11 Mar 2025 16:54:15 +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=1741712059; cv=none; b=oQLCEZj8aL5VRZ2dTlnhnsQhFCx4ds+Msif+/4FYbL764R+dTLaiZuUsYT99Gnrwmi7aT8JZ0txKD+TpujbxRUo4gRBhSkNTa6yqbvSbQrVVLwdNw6r4typ8EKql4OzlXy1I26vHwXdmDaKnu22Y3jzOdFVET/NB2sYZOqHMwOE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741712059; c=relaxed/simple; bh=kmv3XjQR3LxCUV12vUqlHURIuf90Pq99ScjhPq4M/Hs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fC3ycDoF7aWCII+zIZqiwHARFxrmrK3+YeKv6aAhHcdLCCTuojNvXZTd18p8ZvU4cRQHunBN/agn8R0Yq85omyDaU6w5wVrM5T2clOBynwa7du4LNJTeILVFbPVeQwzhP1UUW6/rw4vzGHbQcQwLR8KvQTA8DB352ipMzzHIhtw= 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=fXX8kXO8; 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="fXX8kXO8" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:cbc0:999f:73ad:33bd]) by linux1587.grserver.gr (Postfix) with ESMTPSA id 656BF2E0922F; Tue, 11 Mar 2025 18:54:12 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1741712053; bh=YtLt9XdehsGGA86qaXpSdbFKUYdPorwNx5IDHL9oMvc=; h=From:To:Subject; b=fXX8kXO8aqeIL443OSWAI6gC7wYERTMT2Wq8zivYS0rxz1UawzihQqjVAFKm6cn7Y d41V/r4Nw9egQ15bpsCh2YgvVvk3Q/mvOAvI5MtumcdSMUH3i/ebFEbvnpFcGdodUY eK9msW2C1pzzTlUHdSkob5TTenHe1cj5oyGH+hKU= 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 , Antheas Kapenekakis Subject: [PATCH v4 02/13] hwmon: (oxp-sensors) Add all OneXFly variants Date: Tue, 11 Mar 2025 17:53:54 +0100 Message-ID: <20250311165406.331046-3-lkml@antheas.dev> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250311165406.331046-1-lkml@antheas.dev> References: <20250311165406.331046-1-lkml@antheas.dev> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-PPP-Message-ID: <174171205366.19167.17638543065004868049@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 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 5a4230ad3757..f7a64fbc8f33 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[] = { }, .driver_data = (void *)oxp_fly, }, + { + .matches = { + DMI_MATCH(DMI_BOARD_VENDOR, "ONE-NETBOOK"), + DMI_EXACT_MATCH(DMI_BOARD_NAME, "ONEXPLAYER F1 EVA-01"), + }, + .driver_data = (void *)oxp_fly, + }, + { + .matches = { + DMI_MATCH(DMI_BOARD_VENDOR, "ONE-NETBOOK"), + DMI_EXACT_MATCH(DMI_BOARD_NAME, "ONEXPLAYER F1 OLED"), + }, + .driver_data = (void *)oxp_fly, + }, + { + .matches = { + DMI_MATCH(DMI_BOARD_VENDOR, "ONE-NETBOOK"), + DMI_EXACT_MATCH(DMI_BOARD_NAME, "ONEXPLAYER F1L"), + }, + .driver_data = (void *)oxp_fly, + }, + { + .matches = { + DMI_MATCH(DMI_BOARD_VENDOR, "ONE-NETBOOK"), + DMI_EXACT_MATCH(DMI_BOARD_NAME, "ONEXPLAYER F1Pro"), + }, + .driver_data = (void *)oxp_fly, + }, + { + .matches = { + DMI_MATCH(DMI_BOARD_VENDOR, "ONE-NETBOOK"), + DMI_EXACT_MATCH(DMI_BOARD_NAME, "ONEXPLAYER F1 EVA-02"), + }, + .driver_data = (void *)oxp_fly, + }, { .matches = { DMI_MATCH(DMI_BOARD_VENDOR, "ONE-NETBOOK"), From patchwork Tue Mar 11 16:53:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Antheas Kapenekakis X-Patchwork-Id: 872732 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 A715F260A5E; Tue, 11 Mar 2025 16:54:17 +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=1741712061; cv=none; b=FYyrw5nKTTHKFwrA7dKe7ccvAq3sP9DHQknhhpi/k1PVRAdJq5zY6TlUYBQMfDL5duZIJvEpr0lVhd3/+9hqyVtbCencmbVZR/yZMy4KcK831LgB/k44ssTvWUkvPlKwVw1oxDFujMCQacmrFJicB4VAo4hmaCIWopSDAS0EO88= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741712061; c=relaxed/simple; bh=x6S/0nxkBHrs430nCf8NPtiIHScu8I4kRD5uWTXqEGM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Mllme10x2XNR1GuBN4XEW487nDMigeUngsRl8Gjr+CxBMOtE9EGGoOj6M9GusJUexY7k1N8e290j3HjX2MaQza+eB6JvjjGG5ueJ90nQLyNZQ3zSR3AAaMgZ1pREPVrjwnKEKH1A0j2lXc1TvErJ25vAJ8/r0bU/TJ5hbdwrnV4= 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=ll0JOTRR; 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="ll0JOTRR" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:cbc0:999f:73ad:33bd]) by linux1587.grserver.gr (Postfix) with ESMTPSA id 1CE0E2E0922D; Tue, 11 Mar 2025 18:54:14 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1741712055; bh=3zVtOkiK1iok/JHh0SuX4h1oaKggyuUfA/bd9q6T6JA=; h=From:To:Subject; b=ll0JOTRRqPAGgllmYFbehq+i+flWWpSQg8h217c6QdFK2bYEnsYgnZ+f7pKwj6M2d KUlrmMrpa9VDTlCRVSRb28gbT5HkES4D0WlO9kffUqJk/pWfwlmkKZNhcUAnJkMazm 1erK8GiVt4a41THXvMX2ZVKkTHWxAusfG+USHgzY= 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 , Antheas Kapenekakis Subject: [PATCH v4 03/13] platform/x86: oxpec: Move hwmon/oxp-sensors to platform/x86 Date: Tue, 11 Mar 2025 17:53:55 +0100 Message-ID: <20250311165406.331046-4-lkml@antheas.dev> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250311165406.331046-1-lkml@antheas.dev> References: <20250311165406.331046-1-lkml@antheas.dev> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-PPP-Message-ID: <174171205536.19229.14468028363760380874@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 avoid it becoming stale. While at it, add myself to the maintainer's file. Acked-by: Guenter Roeck 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 => 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 => platform/x86/oxpec.c} (98%) diff --git a/Documentation/hwmon/index.rst b/Documentation/hwmon/index.rst index 874f8fd26325..dd7a54d5f281 100644 --- a/Documentation/hwmon/index.rst +++ b/Documentation/hwmon/index.rst @@ -186,7 +186,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 581c4dafbfa1..000000000000 --- a/Documentation/hwmon/oxp-sensors.rst +++ /dev/null @@ -1,89 +0,0 @@ -.. SPDX-License-Identifier: GPL-2.0-or-later - -Kernel driver oxp-sensors -========================= - -Authors: - - Derek John Clark - - Joaquín Ignacio Aramendía - -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 status. - -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 device - both with this function on and off. This attribute is attached to the platform - driver and not to the hwmon driver (/sys/devices/platform/oxp-platform/tt_toggle) diff --git a/MAINTAINERS b/MAINTAINERS index ed7aa6867674..e78df39a10a3 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -17638,12 +17638,13 @@ S: Maintained F: drivers/mtd/nand/onenand/ F: include/linux/mtd/onenand*.h -ONEXPLAYER FAN DRIVER +ONEXPLAYER PLATFORM EC DRIVER +M: Antheas Kapenekakis M: Derek John Clark M: Joaquín Ignacio Aramendía -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 ONIE TLV NVMEM LAYOUT DRIVER M: Miquel Raynal diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 4cbaba15d86e..09f7aed96d15 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -1774,17 +1774,6 @@ config SENSORS_NZXT_SMART2 source "drivers/hwmon/occ/Kconfig" -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-sensors. - config SENSORS_PCF8591 tristate "Philips PCF8591 ADC/DAC" depends on I2C diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index b7ef0f0562d3..0edb08824b17 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile @@ -181,7 +181,6 @@ obj-$(CONFIG_SENSORS_NTC_THERMISTOR) += ntc_thermistor.o obj-$(CONFIG_SENSORS_NZXT_KRAKEN2) += nzxt-kraken2.o obj-$(CONFIG_SENSORS_NZXT_KRAKEN3) += nzxt-kraken3.o obj-$(CONFIG_SENSORS_NZXT_SMART2) += nzxt-smart2.o -obj-$(CONFIG_SENSORS_OXP) += oxp-sensors.o obj-$(CONFIG_SENSORS_PC87360) += pc87360.o obj-$(CONFIG_SENSORS_PC87427) += pc87427.o obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig index 0258dd879d64..82cfc76bc5c9 100644 --- a/drivers/platform/x86/Kconfig +++ b/drivers/platform/x86/Kconfig @@ -1186,6 +1186,18 @@ config SEL3350_PLATFORM To compile this driver as a module, choose M here: the module will be called sel3350-platform. +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 config P2SB diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile index e1b142947067..f64a191c1162 100644 --- a/drivers/platform/x86/Makefile +++ b/drivers/platform/x86/Makefile @@ -153,3 +153,6 @@ obj-$(CONFIG_WINMATE_FM07_KEYS) += winmate-fm07-keys.o # SEL obj-$(CONFIG_SEL3350_PLATFORM) += sel3350-platform.o + +# OneXPlayer +obj-$(CONFIG_OXP_EC) += oxpec.o \ No newline at end of file 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 f7a64fbc8f33..dc3a0871809c 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ín I. Aramendía * Copyright (C) 2024 Derek J. Clark + * Copyright (C) 2025 Antheas Kapenekakis */ #include From patchwork Tue Mar 11 16:53:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antheas Kapenekakis X-Patchwork-Id: 873006 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 495FC26039F; Tue, 11 Mar 2025 16:54:19 +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=1741712061; cv=none; b=Qfqd7GWMtVfcJqJZW33dm56thApNQV6WRwAQVTfo6G7BJzK6NMiYBCBbRc8ewhlAEViJjiH3TCoq5lFKicgClIkVEwM72iGTOn7COxzWN510+tPDTQRW0z4E35C6XFyWZJexC4kta18YDVyo5REQUsNcgKKh4uN3J5FgN4bG3rI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741712061; c=relaxed/simple; bh=WMwNdIpLsAWFA9L4KUa1ulOONEYrVIP4ZGl5gjwXjtA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HNTOkXYIsx7pho1n5V4OoKtNjFwFty/pkWnaWxy91MgUt2tfaTWQtO1Pt0guYzbiJ0HrYmQXsefE3KH3cd/96ILmkw56ion62DmHwUYzussw8ZsRdoC4ikICEgsSMvEFQtSnaf9TR8KkAOGuv1GKbTfmP82fFmCxixt/4kDnlu8= 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=Tl7WSR3U; 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="Tl7WSR3U" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:cbc0:999f:73ad:33bd]) by linux1587.grserver.gr (Postfix) with ESMTPSA id 02C992E09225; Tue, 11 Mar 2025 18:54:15 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1741712057; bh=dsIyCcmCpyH7Jdi7anj6i2jjWYqNwmJcYp3Nnc+rvtQ=; h=From:To:Subject; b=Tl7WSR3UIVP+gfoTKmkk7ZD2rCut6QF/gfCgRFGSoyHE6oSiOgJJHLSu0nz7Fp/pZ e4NT8YOyRWBIqgmyCbnXBTgiTPHYS057y36Ke9oJNsEstVe6jBBpORnplYr+AsdTzn UhOat0r7BkLeHMMDBsqDtK8BQEuFF8glMGxCGit0= 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 , Antheas Kapenekakis Subject: [PATCH v4 04/13] ABI: testing: add tt_toggle and tt_led entries Date: Tue, 11 Mar 2025 17:53:56 +0100 Message-ID: <20250311165406.331046-5-lkml@antheas.dev> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250311165406.331046-1-lkml@antheas.dev> References: <20250311165406.331046-1-lkml@antheas.dev> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-PPP-Message-ID: <174171205722.19380.4946563684217661100@linux1587.grserver.gr> X-PPP-Vhost: antheas.dev X-Virus-Scanned: clamav-milter 0.103.11 at linux1587.grserver.gr X-Virus-Status: Clean When tt_toggle was introduced, it was not added to the platform sysfs. Add it, then add documentation for tt_led. Signed-off-by: Antheas Kapenekakis --- Documentation/ABI/testing/sysfs-platform-oxp | 26 ++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-platform-oxp diff --git a/Documentation/ABI/testing/sysfs-platform-oxp b/Documentation/ABI/testing/sysfs-platform-oxp new file mode 100644 index 000000000000..776b7dee3d59 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-platform-oxp @@ -0,0 +1,26 @@ +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). + +What: /sys/devices/platform//tt_led +Date: Feb 2025 +KernelVersion: 6.15 +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. + From patchwork Tue Mar 11 16:53:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antheas Kapenekakis X-Patchwork-Id: 873005 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 9834F26158B; Tue, 11 Mar 2025 16:54:21 +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=1741712063; cv=none; b=sK5IrEvJZtC7o1Z5Fkn6457AlwVN4CFdmvgH4xpku+K0xH35ELN4U4UI4uCom1KzbE9hRyS2eqOY1BUJ9zjVjeVMV37e6ZMT0CKssws7HX7SSEP1xp7Ae3fGqq3SdlgUyYYBYMPLGRhjluEbEqooYCEK9Hb0dMGwuNnfIYyDIKw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741712063; c=relaxed/simple; bh=VA9Va1aH4PoY1eNSG8INff3Mq5jJh5TF4Zi9YOIweZU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SBOKC/KE+xN4A0oQv5AddHEohEaA+CWGMAZSHWN42YFLjMpGQgho5PUcjHoQfUU7a4gLd3Gm4ESAsiADRb2VXHAqM5cGPBL1wKS9fzX3IrDkLn01di9rgmujJ67HyaV/CQM0Nycypd30ozPo29tvbrIyuCywgDF533EtveBhXsg= 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=pAzeCWng; 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="pAzeCWng" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:cbc0:999f:73ad:33bd]) by linux1587.grserver.gr (Postfix) with ESMTPSA id A3A662E09230; Tue, 11 Mar 2025 18:54:17 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1741712059; bh=CuVXlBKRWwdRl9byCGuZ1p5t2CBME0ef2XNXSt73sdk=; h=From:To:Subject; b=pAzeCWngbzo+MAN7L7F351UW8oqNDsUMsvdtX0mIbKbsJ76mqPzGYcL/OkS2xGmzd UXLUQ6Ht9BK53o9ttJgNLgLjpcnwprxRsNyH2yRncyU3kMV+5ZBQIpNTh2IR8pW70z FeLKuf2OiA7XUo46W7oIxbgAByuHwRlycF+JWaDA= 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 , Antheas Kapenekakis Subject: [PATCH v4 05/13] power: supply: add inhibit-charge-s0 to charge_behaviour Date: Tue, 11 Mar 2025 17:53:57 +0100 Message-ID: <20250311165406.331046-6-lkml@antheas.dev> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250311165406.331046-1-lkml@antheas.dev> References: <20250311165406.331046-1-lkml@antheas.dev> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-PPP-Message-ID: <174171205924.19468.17545941463036318746@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 bypass feature that allows the user to select between it being active always or only when the device is on. Therefore, add attribute inhibit-charge-s0 to charge_behaviour to allow the user to select that bypass should only be on when the device is in the s0 state. Reviewed-by: Derek J. Clark Signed-off-by: Antheas Kapenekakis --- Documentation/ABI/testing/sysfs-class-power | 11 ++++++----- drivers/power/supply/power_supply_sysfs.c | 1 + drivers/power/supply/test_power.c | 1 + include/linux/power_supply.h | 1 + 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-class-power b/Documentation/ABI/testing/sysfs-class-power index 2a5c1a09a28f..4a187ca11f92 100644 --- a/Documentation/ABI/testing/sysfs-class-power +++ b/Documentation/ABI/testing/sysfs-class-power @@ -508,11 +508,12 @@ Description: Access: Read, Write Valid values: - ================ ==================================== - auto: Charge normally, respect thresholds - inhibit-charge: Do not charge while AC is attached - force-discharge: Force discharge while AC is attached - ================ ==================================== + ================== ===================================== + auto: Charge normally, respect thresholds + inhibit-charge: Do not charge while AC is attached + inhibit-charge-s0: same as inhibit-charge but only in S0 + force-discharge: Force discharge while AC is attached + ================== ===================================== What: /sys/class/power_supply//technology Date: May 2007 diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c index edb058c19c9c..1a98fc26ce96 100644 --- a/drivers/power/supply/power_supply_sysfs.c +++ b/drivers/power/supply/power_supply_sysfs.c @@ -140,6 +140,7 @@ static const char * const POWER_SUPPLY_SCOPE_TEXT[] = { static const char * const POWER_SUPPLY_CHARGE_BEHAVIOUR_TEXT[] = { [POWER_SUPPLY_CHARGE_BEHAVIOUR_AUTO] = "auto", [POWER_SUPPLY_CHARGE_BEHAVIOUR_INHIBIT_CHARGE] = "inhibit-charge", + [POWER_SUPPLY_CHARGE_BEHAVIOUR_INHIBIT_CHARGE_S0] = "inhibit-charge-s0", [POWER_SUPPLY_CHARGE_BEHAVIOUR_FORCE_DISCHARGE] = "force-discharge", }; diff --git a/drivers/power/supply/test_power.c b/drivers/power/supply/test_power.c index 2a975a110f48..4bc5ab84a9d6 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[] = { .property_is_writeable = test_power_battery_property_is_writeable, .charge_behaviours = BIT(POWER_SUPPLY_CHARGE_BEHAVIOUR_AUTO) | BIT(POWER_SUPPLY_CHARGE_BEHAVIOUR_INHIBIT_CHARGE) + | BIT(POWER_SUPPLY_CHARGE_BEHAVIOUR_INHIBIT_CHARGE_S0) | BIT(POWER_SUPPLY_CHARGE_BEHAVIOUR_FORCE_DISCHARGE), }, [TEST_USB] = { diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index 6ed53b292162..b1ca5e148759 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 = 0, POWER_SUPPLY_CHARGE_BEHAVIOUR_INHIBIT_CHARGE, + POWER_SUPPLY_CHARGE_BEHAVIOUR_INHIBIT_CHARGE_S0, POWER_SUPPLY_CHARGE_BEHAVIOUR_FORCE_DISCHARGE, }; From patchwork Tue Mar 11 16:53:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antheas Kapenekakis X-Patchwork-Id: 872731 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 6972B260A2A; Tue, 11 Mar 2025 16:54:23 +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=1741712065; cv=none; b=rlCCYKovKq1gFcns9ONLklKjUJ8BsjMSmxwEAxsj+CQFUg7974avgUXDf7ngyJv940KvvqB0pcarU+5M5CP2Iid+3VjotNVWhZU/3+efVHa5IKGnuK4/3dz53X0yKT2pL2hTYGWqgw9yG2XLLsRVEj5u1+S0Ax+ojvoiTOlDITM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741712065; c=relaxed/simple; bh=ZK2HpsbmFShU2nGbLiIOCea32AqrBAJovHE8yN48dIY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JbYF7wgBmLxGLu7JiU+N3hGwCQwozHtKmJ3QlpvtBSa904fEW6GHg98pOeizrWbW8ZQUk+nwaGyFkk6c7sO3yLIagnCjM9ho8mCWZbtdFAKaUlZZcnPr9kqM2TpEEesmPLIH8T3dp2Y9pZJXJjWuYfLHab9AHaoXG2ai6q0Opgs= 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=BnOThUWP; 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="BnOThUWP" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:cbc0:999f:73ad:33bd]) by linux1587.grserver.gr (Postfix) with ESMTPSA id B28622E09231; Tue, 11 Mar 2025 18:54:19 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1741712061; bh=wc0qaUpzAbsHBiAfZpuSOeNyD+N9aLV5rkQuKVNRAcA=; h=From:To:Subject; b=BnOThUWP1SVHGPsAKSfEGVUuL0zPN4e4jYcseOW8UkmyeLUsmSm8XrtdNrUSPg9md 281GOAA26vplqtGNnqWniGS8axr2KJ0bOCfPYYDU1lFOUu5DlIFQ1vnElNxViDegh/ 7cXNwmuwRB+jS5Y21jUlfN1CXke0sth9KNFVMnDM= 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 , Antheas Kapenekakis Subject: [PATCH v4 06/13] platform/x86: oxpec: Add charge threshold and behaviour to OneXPlayer Date: Tue, 11 Mar 2025 17:53:58 +0100 Message-ID: <20250311165406.331046-7-lkml@antheas.dev> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250311165406.331046-1-lkml@antheas.dev> References: <20250311165406.331046-1-lkml@antheas.dev> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-PPP-Message-ID: <174171206097.19543.13894957518655427827@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 bypass to their devices. Charge limit allows for choosing an arbitrary battery charge setpoint in percentages. Charge bypass allows to instruct the device to stop charging either when it is in s0 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. Add both of these under the standard sysfs battery endpoints for them, by looking for the battery. OneXPlayer devices have a single battery. Signed-off-by: Antheas Kapenekakis --- drivers/platform/x86/Kconfig | 1 + drivers/platform/x86/oxpec.c | 217 +++++++++++++++++++++++++++++++++++ 2 files changed, 218 insertions(+) diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig index 82cfc76bc5c9..f4d993658c01 100644 --- a/drivers/platform/x86/Kconfig +++ b/drivers/platform/x86/Kconfig @@ -1189,6 +1189,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 dc3a0871809c..d73a10598d8f 100644 --- a/drivers/platform/x86/oxpec.c +++ b/drivers/platform/x86/oxpec.c @@ -24,6 +24,7 @@ #include #include #include +#include /* Handle ACPI lock mechanism */ static u32 oxp_mutex; @@ -87,6 +88,24 @@ static enum oxp_board board; #define OXP_TURBO_RETURN_VAL 0x00 /* Common return val */ +/* Battery bypass settings */ +#define EC_CHARGE_CONTROL_BEHAVIOURS_X1 (BIT(POWER_SUPPLY_CHARGE_BEHAVIOUR_AUTO) | \ + BIT(POWER_SUPPLY_CHARGE_BEHAVIOUR_INHIBIT_CHARGE) | \ + BIT(POWER_SUPPLY_CHARGE_BEHAVIOUR_INHIBIT_CHARGE_S0)) + +#define OXP_X1_CHARGE_LIMIT_REG 0xA3 /* X1 charge limit (%) */ +#define OXP_X1_CHARGE_BYPASS_REG 0xA4 /* X1 bypass charging */ + +#define OXP_X1_CHARGE_BYPASS_MASK_S0 0x01 +/* + * Cannot control S3, S5 individually. + * X1 Mask is 0x0A, OneXFly F1Pro is just 0x02 + * but the extra bit on the X1 does nothing. + */ +#define OXP_X1_CHARGE_BYPASS_MASK_S3S5 0x02 +#define OXP_X1_CHARGE_BYPASS_MASK_ALWAYS (OXP_X1_CHARGE_BYPASS_MASK_S0 | \ + OXP_X1_CHARGE_BYPASS_MASK_S3S5) + static const struct dmi_system_id dmi_table[] = { { .matches = { @@ -434,6 +453,194 @@ static ssize_t tt_toggle_show(struct device *dev, static DEVICE_ATTR_RW(tt_toggle); +/* Callbacks for charge behaviour attributes */ +static bool charge_behaviour_supported(void) +{ + switch (board) { + case oxp_x1: + case oxp_fly: + return 1; + default: + break; + } + return 0; +} + +static ssize_t charge_behaviour_store(struct device *dev, + struct device_attribute *attr, const char *buf, + size_t count) +{ + unsigned int available; + long val, s0, always; + int ret; + u8 reg; + + switch (board) { + case oxp_x1: + case oxp_fly: + s0 = OXP_X1_CHARGE_BYPASS_MASK_S0; + always = OXP_X1_CHARGE_BYPASS_MASK_ALWAYS; + reg = OXP_X1_CHARGE_BYPASS_REG; + available = EC_CHARGE_CONTROL_BEHAVIOURS_X1; + break; + default: + return -EINVAL; + } + + ret = power_supply_charge_behaviour_parse(available, buf); + if (ret < 0) + return ret; + + switch (ret) { + case POWER_SUPPLY_CHARGE_BEHAVIOUR_AUTO: + val = 0; + break; + case POWER_SUPPLY_CHARGE_BEHAVIOUR_INHIBIT_CHARGE_S0: + val = s0; + break; + case POWER_SUPPLY_CHARGE_BEHAVIOUR_INHIBIT_CHARGE: + val = always; + break; + default: + return -EINVAL; + } + + ret = write_to_ec(reg, val); + if (ret) + return ret; + + return count; +} + +static ssize_t charge_behaviour_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + long val, s0, always, sel; + unsigned int available; + int ret; + u8 reg; + + switch (board) { + case oxp_x1: + case oxp_fly: + s0 = OXP_X1_CHARGE_BYPASS_MASK_S0; + always = OXP_X1_CHARGE_BYPASS_MASK_ALWAYS; + reg = OXP_X1_CHARGE_BYPASS_REG; + available = EC_CHARGE_CONTROL_BEHAVIOURS_X1; + break; + default: + return -EINVAL; + } + + ret = read_from_ec(reg, 1, &val); + if (ret) + return ret; + + if ((val & always) == always) + sel = POWER_SUPPLY_CHARGE_BEHAVIOUR_INHIBIT_CHARGE; + else if ((val & s0) == s0) + sel = POWER_SUPPLY_CHARGE_BEHAVIOUR_INHIBIT_CHARGE_S0; + else + sel = POWER_SUPPLY_CHARGE_BEHAVIOUR_AUTO; + + return power_supply_charge_behaviour_show(dev, available, sel, buf); +} + +static DEVICE_ATTR_RW(charge_behaviour); + +static ssize_t charge_control_end_threshold_store(struct device *dev, + struct device_attribute *attr, const char *buf, + size_t count) +{ + u64 val, reg; + int ret; + + ret = kstrtou64(buf, 10, &val); + if (ret) + return ret; + + if (val > 100) + return -EINVAL; + + switch (board) { + case oxp_x1: + case oxp_fly: + reg = OXP_X1_CHARGE_LIMIT_REG; + break; + default: + return -EINVAL; + } + + ret = write_to_ec(reg, val); + if (ret) + return ret; + + return count; +} + +static ssize_t charge_control_end_threshold_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + long val; + int ret; + u8 reg; + + switch (board) { + case oxp_x1: + case oxp_fly: + reg = OXP_X1_CHARGE_LIMIT_REG; + break; + default: + return -EINVAL; + } + + ret = read_from_ec(reg, 1, &val); + if (ret) + return ret; + + return sysfs_emit(buf, "%ld\n", val); +} + +static DEVICE_ATTR_RW(charge_control_end_threshold); + +static int oxp_battery_add(struct power_supply *battery, struct acpi_battery_hook *hook) +{ + /* OneXPlayer devices only have one battery. */ + if (strcmp(battery->desc->name, "BAT0") != 0 && + strcmp(battery->desc->name, "BAT1") != 0 && + strcmp(battery->desc->name, "BATC") != 0 && + strcmp(battery->desc->name, "BATT") != 0) + return -ENODEV; + + if (device_create_file(&battery->dev, + &dev_attr_charge_control_end_threshold)) + return -ENODEV; + + if (device_create_file(&battery->dev, + &dev_attr_charge_behaviour)) { + device_remove_file(&battery->dev, + &dev_attr_charge_control_end_threshold); + return -ENODEV; + } + + return 0; +} + +static int oxp_battery_remove(struct power_supply *battery, struct acpi_battery_hook *hook) +{ + device_remove_file(&battery->dev, + &dev_attr_charge_control_end_threshold); + device_remove_file(&battery->dev, + &dev_attr_charge_behaviour); + return 0; +} + +static struct acpi_battery_hook battery_hook = { + .add_battery = oxp_battery_add, + .remove_battery = oxp_battery_remove, + .name = "OneXPlayer Battery", +}; + /* PWM enable/disable functions */ static int oxp_pwm_enable(void) { @@ -716,15 +923,25 @@ static int oxp_platform_probe(struct platform_device *pdev) hwdev = devm_hwmon_device_register_with_info(dev, "oxpec", NULL, &oxp_ec_chip_info, NULL); + if (charge_behaviour_supported()) + battery_hook_register(&battery_hook); + return PTR_ERR_OR_ZERO(hwdev); } +static void oxp_platform_remove(struct platform_device *device) +{ + if (charge_behaviour_supported()) + battery_hook_unregister(&battery_hook); +} + static struct platform_driver oxp_platform_driver = { .driver = { .name = "oxp-platform", .dev_groups = oxp_ec_groups, }, .probe = oxp_platform_probe, + .remove = oxp_platform_remove, }; static struct platform_device *oxp_platform_device; From patchwork Tue Mar 11 16:53:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antheas Kapenekakis X-Patchwork-Id: 873004 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 5E0DC260A45; Tue, 11 Mar 2025 16:54:25 +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=1741712067; cv=none; b=Zjh1O8tgGk6eqjRMc2s1q1Fn7uMOWsInHzWblnjRJp70GVfZCMagCSgI8GYhr5orywSVsrEF0qXjY8h45xTUktJ9ld0n4uQPztuA76sMByQPuN1j7Irm73sDJJZbPABYxZ4rf4Qef82cuPea4nWDdtOT1aZk+uSJp3dEXZUIweI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741712067; c=relaxed/simple; bh=W6DCFV/7cyyDQqfrce1WsbKCLCwHNmUxgRovegC27i4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nzeEsM8r7OMKBKPQey5yq8Fd8qjINt2ByraNV0sQ4tzvV8cvmdWQIX4ZYYtyk+mZRDsh1fz6yAgAdLRNrgYs3k2uCduLIL7NM0npWtuLlaw2zGneAdB0VhwtzuIoIfujR121AYHFAC1f7FIZEoQsAphegierCp192CzgGgJWoHg= 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=XrhWm8Ul; 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="XrhWm8Ul" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:cbc0:999f:73ad:33bd]) by linux1587.grserver.gr (Postfix) with ESMTPSA id AC6C32E09233; Tue, 11 Mar 2025 18:54:21 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1741712063; bh=vvg+5jC9/r8WcHGcCmL9qbK6LB250lvlSwX700aQD4c=; h=From:To:Subject; b=XrhWm8UldJv2FgLe8lUIhNZNgThlk/G8FrX4gvLajKJ3SD+YHPLm6+Q47r9VpgfUF 5PJa6e972PjN+hbXYp/HzRc8sdXVs8bksZyHfy29z6CD2lF5N+vHeFSqDa0VYmOvKI hfqrnThg8/brqGDu+g1OQRy81e3AWxp9+esC9VCw= 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 , Antheas Kapenekakis Subject: [PATCH v4 07/13] platform/x86: oxpec: Rename ec group to tt_toggle Date: Tue, 11 Mar 2025 17:53:59 +0100 Message-ID: <20250311165406.331046-8-lkml@antheas.dev> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250311165406.331046-1-lkml@antheas.dev> References: <20250311165406.331046-1-lkml@antheas.dev> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-PPP-Message-ID: <174171206297.19632.3908566327497460833@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. Reviewed-by: Derek J. Clark 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 d73a10598d8f..95b0c946b7f8 100644 --- a/drivers/platform/x86/oxpec.c +++ b/drivers/platform/x86/oxpec.c @@ -888,18 +888,18 @@ static const struct hwmon_channel_info * const oxp_platform_sensors[] = { NULL, }; -static struct attribute *oxp_ec_attrs[] = { +static struct attribute *oxp_tt_toggle_attrs[] = { &dev_attr_tt_toggle.attr, NULL }; -static struct attribute_group oxp_ec_attribute_group = { +static struct attribute_group oxp_tt_toggle_attribute_group = { .is_visible = tt_toggle_is_visible, - .attrs = oxp_ec_attrs, + .attrs = oxp_tt_toggle_attrs, }; static const struct attribute_group *oxp_ec_groups[] = { - &oxp_ec_attribute_group, + &oxp_tt_toggle_attribute_group, NULL }; From patchwork Tue Mar 11 16:54:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antheas Kapenekakis X-Patchwork-Id: 872730 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 A4B822620C2; Tue, 11 Mar 2025 16:54:27 +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=1741712069; cv=none; b=KfA6KpKJs8AkxsYq81zyEcdusTnuHz4hq3Qwm5X54sqGA65gkz+8KPLtOO/oLhcmi4zZPZUy5kDi6041EjeEHtsCY98UaMrU/gWZIGpdonmXdbaAHhBdIUWF16s5NxYEIJoHaGFZCrEeU39M8s3reXX4P8tGZtjRmEpVKaKHGzU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741712069; c=relaxed/simple; bh=Uqkr4wOpRhSH/PEel77E1JX2r4IEKhn590qZZ91+r6w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ifC70YzDTz0ohKYocgadQrFl0PlPiooesEkrKXODUEVUzvh3+CKG3XWtCPV5jrLTc+MHSVdExiMInTPceUj34DBcc/JYNyNKfXeh9x8ftjGpG8rOxksMqMNqiZh/j9K3yghi4RNJyUGIbiSSD4cXuVfGIFYztLE0MRiBc/TeirU= 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=tkVBLn2G; 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="tkVBLn2G" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:cbc0:999f:73ad:33bd]) by linux1587.grserver.gr (Postfix) with ESMTPSA id 82E7F2E09237; Tue, 11 Mar 2025 18:54:23 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1741712065; bh=T9Q2y4b4EMW7PFfW1wTr0++fzbg0MG13G22QQuo9yO4=; h=From:To:Subject; b=tkVBLn2GrS4KpGZg1jSVC1lqXZ/b613OpI2P1dN04lV2TWYnKlH2r5ryzd3/Lwsst a2c2ltYLGWkUIFxIFJUSMC94I9gapeQpuQD6KsVrPJW0RwRQfqxaz2Rc7v2iX3BUEM G0tv5vsQ/gb/8B2hFcCCcjP6R6Tos4N1zbOhmFhE= 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 , Antheas Kapenekakis Subject: [PATCH v4 08/13] platform/x86: oxpec: Add turbo led support to X1 devices Date: Tue, 11 Mar 2025 17:54:00 +0100 Message-ID: <20250311165406.331046-9-lkml@antheas.dev> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250311165406.331046-1-lkml@antheas.dev> References: <20250311165406.331046-1-lkml@antheas.dev> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-PPP-Message-ID: <174171206482.19789.3305303352850930991@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. 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 95b0c946b7f8..58a1919aec15 100644 --- a/drivers/platform/x86/oxpec.c +++ b/drivers/platform/x86/oxpec.c @@ -106,6 +106,12 @@ static enum oxp_board board; #define OXP_X1_CHARGE_BYPASS_MASK_ALWAYS (OXP_X1_CHARGE_BYPASS_MASK_S0 | \ OXP_X1_CHARGE_BYPASS_MASK_S3S5) +/* 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[] = { { .matches = { @@ -453,6 +459,73 @@ static ssize_t tt_toggle_show(struct device *dev, static DEVICE_ATTR_RW(tt_toggle); +/* 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 rval; + + rval = kstrtobool(buf, &value); + if (rval) + return rval; + + switch (board) { + case oxp_x1: + reg = OXP_X1_TURBO_LED_REG; + val = value ? OXP_X1_TURBO_LED_ON : OXP_X1_TURBO_LED_OFF; + break; + default: + return -EINVAL; + } + rval = write_to_ec(reg, val); + + if (rval) + return rval; + + return count; +} + +static ssize_t tt_led_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + int retval; + long enval; + long val; + u8 reg; + + switch (board) { + case oxp_x1: + reg = OXP_X1_TURBO_LED_REG; + enval = OXP_X1_TURBO_LED_ON; + break; + default: + return -EINVAL; + } + + retval = read_from_ec(reg, 1, &val); + if (retval) + return retval; + + return sysfs_emit(buf, "%d\n", val == enval); +} + +static DEVICE_ATTR_RW(tt_led); + /* Callbacks for charge behaviour attributes */ static bool charge_behaviour_supported(void) { @@ -898,8 +971,19 @@ static struct attribute_group oxp_tt_toggle_attribute_group = { .attrs = oxp_tt_toggle_attrs, }; +static struct attribute *oxp_tt_led_attrs[] = { + &dev_attr_tt_led.attr, + NULL +}; + +static struct attribute_group oxp_tt_led_attribute_group = { + .is_visible = tt_led_is_visible, + .attrs = oxp_tt_led_attrs, +}; + static const struct attribute_group *oxp_ec_groups[] = { &oxp_tt_toggle_attribute_group, + &oxp_tt_led_attribute_group, NULL }; From patchwork Tue Mar 11 16:54:01 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antheas Kapenekakis X-Patchwork-Id: 873003 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 DD3FD260A45; Tue, 11 Mar 2025 16:54: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=1741712070; cv=none; b=H2EjbSTN1C0c28ifL8hO/+hBXL65USWzijATMi914iRPgW35uvSOERTzi/euqPWKxXTiqAjKIvhPpHqwwPxLZOx7pxUCvDp6/itGBs/fri+hAyg9L9bfOK1QD3QqpdIHxpMnB41KO5dTYpN6Q+san4bNWGVy/aAvRJuSQJCeJGA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741712070; c=relaxed/simple; bh=nRT6LA48v69J6tvLRneftqa1ArXK92XsnxLhaEYh6w0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OOKDS4C6HqY66Z5Exxpopjw6/L7RUPdo1MtI7msikGOC0y6KGojoO6NStZDusP5RWPQFBmA3halMk8m/3bkKCm3IozA7Q1YVQIp8vhNnfL806XARNbjiZlkKMb/Gu6kBpaCYg6w0fdHmiTr1ivC0rjU5AGlaXUr8etoDAEUaZ2M= 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=v+6k7CJl; 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="v+6k7CJl" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:cbc0:999f:73ad:33bd]) by linux1587.grserver.gr (Postfix) with ESMTPSA id 4E17D2E09238; Tue, 11 Mar 2025 18:54:25 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1741712066; bh=JVXzCrqbCnINLvVCrt28a4xe/Qg2XgidWiEOkLh/3nk=; h=From:To:Subject; b=v+6k7CJlDe8g76qV/J8n8sIdrNjJO6mhtOmwPuGTZvS3uy7gvwAoxtC2NAir7jmAi hETAbVaZdQel/a6TMISseLAR6S+bOOISkXQczZHwwxIG/uKNAsN9p1gjilBcC96Etw czSieNgI6eGl4VA652YsYqiceZ2wx1BejqUmazWw= 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 , Antheas Kapenekakis Subject: [PATCH v4 09/13] platform/x86: oxpec: Move pwm_enable read to its own function Date: Tue, 11 Mar 2025 17:54:01 +0100 Message-ID: <20250311165406.331046-10-lkml@antheas.dev> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250311165406.331046-1-lkml@antheas.dev> References: <20250311165406.331046-1-lkml@antheas.dev> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-PPP-Message-ID: <174171206656.19866.6107637543377574654@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 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 58a1919aec15..31c7d0041492 100644 --- a/drivers/platform/x86/oxpec.c +++ b/drivers/platform/x86/oxpec.c @@ -766,6 +766,32 @@ static int oxp_pwm_disable(void) } } +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) @@ -863,29 +889,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; } From patchwork Tue Mar 11 16:54:02 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antheas Kapenekakis X-Patchwork-Id: 872729 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 30141260A45; Tue, 11 Mar 2025 16:54: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=1741712073; cv=none; b=WvMGrZBeXgImzC7j1CQlGCHNaeFUf5Zct+2bCKcnNvP2tIASFcG2/nhrIdQHFuYh9gVgsA87/dgbS9cYxMx5/IY82g8rUamm4ezXs8kwUAm/10pW41A5prFExVhSDSUXci3aq8sJbFyHejScO3Ldv1u91wo8uZ1+JnM49kQSv9I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741712073; c=relaxed/simple; bh=WDazQlhRfZp95eow+bDfqAHhnY6otoyeSChs+O5/12c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uGYpPrmmjUMsIgVEdvemZP4M2S5Laea0hEpPNeu/eE8cGTZIM6s2UGfkpbt0tDQJ8j2V7h5lT0YBhdOH5GqsTBNC6PpYQNWsmpBHH3wijPtoyh79h/d6O9KFJJcGtGhJMl04LnwVHnGe8U/X1YHeO7P/+nX/8f89VgeFaAqTv8c= 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=kYmnKcSZ; 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="kYmnKcSZ" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:cbc0:999f:73ad:33bd]) by linux1587.grserver.gr (Postfix) with ESMTPSA id 0A1662E0922E; Tue, 11 Mar 2025 18:54:26 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1741712069; bh=OvoYtbYG7ah1UxSadas98AIe7sBqNDpSmQ4J+d+MHew=; h=From:To:Subject; b=kYmnKcSZkWB8157g2itVhGKzEJXr6BFJp7bQk5EZ3lli2mn9xR41KqVD60pGAiAjT 0mgNjYC0BWlAF1FzUm3LGUQMqY5OvqVI4C04wwsU9O0bW75dFOMFNfl5f2mjodhB1D jORQvrJLwUKszSMw7/t8CwN8ZOJbDVv+Cpdy4fP4= 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 , Antheas Kapenekakis Subject: [PATCH v4 10/13] platform/x86: oxpec: Move pwm value read/write to separate functions Date: Tue, 11 Mar 2025 17:54:02 +0100 Message-ID: <20250311165406.331046-11-lkml@antheas.dev> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250311165406.331046-1-lkml@antheas.dev> References: <20250311165406.331046-1-lkml@antheas.dev> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-PPP-Message-ID: <174171206825.19961.6580630023410387442@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 Signed-off-by: Antheas Kapenekakis --- drivers/platform/x86/oxpec.c | 162 +++++++++++++++++++---------------- 1 file changed, 87 insertions(+), 75 deletions(-) diff --git a/drivers/platform/x86/oxpec.c b/drivers/platform/x86/oxpec.c index 31c7d0041492..f0e70205ad19 100644 --- a/drivers/platform/x86/oxpec.c +++ b/drivers/platform/x86/oxpec.c @@ -806,6 +806,91 @@ static umode_t oxp_ec_hwmon_is_visible(const void *drvdata, } } +/* 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 = ((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 = (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 = (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 = read_from_ec(ORANGEPI_SENSOR_PWM_REG, 1, val); + if (ret) + return ret; + /* scale from range [1-244] */ + *val = ((*val - 1) * 254 / 243) + 1; + break; + case oxp_2: + case oxp_x1: + ret = read_from_ec(OXP_SENSOR_PWM_REG, 1, val); + if (ret) + return ret; + /* scale from range [0-184] */ + *val = (*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 = read_from_ec(OXP_SENSOR_PWM_REG, 1, val); + if (ret) + return ret; + /* scale from range [0-100] */ + *val = (*val * 255) / 100; + break; + case aok_zoe_a1: + case oxp_fly: + case oxp_mini_amd_pro: + default: + ret = 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 type, u32 attr, int channel, long *val) { @@ -846,48 +931,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 = read_from_ec(ORANGEPI_SENSOR_PWM_REG, 1, val); - if (ret) - return ret; - /* scale from range [1-244] */ - *val = ((*val - 1) * 254 / 243) + 1; - break; - case oxp_2: - case oxp_x1: - ret = read_from_ec(OXP_SENSOR_PWM_REG, 1, val); - if (ret) - return ret; - /* scale from range [0-184] */ - *val = (*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 = read_from_ec(OXP_SENSOR_PWM_REG, 1, val); - if (ret) - return ret; - /* scale from range [0-100] */ - *val = (*val * 255) / 100; - break; - case aok_zoe_a1: - case oxp_fly: - case oxp_mini_amd_pro: - default: - ret = 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: @@ -913,39 +957,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 = ((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 = (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 = (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; } From patchwork Tue Mar 11 16:54:03 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antheas Kapenekakis X-Patchwork-Id: 873002 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 A7416261382; Tue, 11 Mar 2025 16:54: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=1741712074; cv=none; b=EiV1/qr9zyKdi/pffQN62BhmEsHprp8McrIRXEkEIBnSCdMItNbOPGJrGACsvmJ7kLB0TX5pnfE8uqGLyfLWB1UiX/5p33oGha8KmmetXnAWI1MYWLW0m0WDTUdUjqIL8JbZUTBJ59wpZcee+ou4zADJZDJR64MiFuN77w7twGY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741712074; c=relaxed/simple; bh=3uDPeJnQqqJ9HXbAXZ01/ixO7b/9xhEVcyIzmMOb97k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dUziJnj0WCfmHvzFd+W5BmGUc7FA2z2WkYp4vGKJJ47AKN3N28Xj7Bmf87vN026rJAEK/BwHPKYG6UcKi19wdKhNfLeIjfy5IythOVfH5gPIEK548S3iaqD7qSmnDjZXdatBoSqARyRaMRcjvz1hLWhdfsJr0YHxZLsd4+xppGg= 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=eqwiAHBu; 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="eqwiAHBu" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:cbc0:999f:73ad:33bd]) by linux1587.grserver.gr (Postfix) with ESMTPSA id 57F782E0922F; Tue, 11 Mar 2025 18:54:29 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1741712070; bh=fz+QEXDgijsnzqKqvNoT4AdRG/0cAXDvNN6kXuH9sIs=; h=From:To:Subject; b=eqwiAHBugGi9O8LJrtteTaswt6N29CjvBJ2wd3w7ALsRigUBD5V5gXsypu0FaMWaO gQFv935yK2ec7jf4xeBQxEgXABGsj9CxN0eKdMdyWSnRD6n5VJJb5S67+0oetwRLHo HSld3C6BrZlwTQ7VRGzRci+8ZsHlIejilL0C5Qr8= 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 , Antheas Kapenekakis Subject: [PATCH v4 11/13] platform/x86: oxpec: Move fan speed read to separate function Date: Tue, 11 Mar 2025 17:54:03 +0100 Message-ID: <20250311165406.331046-12-lkml@antheas.dev> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250311165406.331046-1-lkml@antheas.dev> References: <20250311165406.331046-1-lkml@antheas.dev> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-PPP-Message-ID: <174171207063.20090.10686112370112123463@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 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 f0e70205ad19..97dc7b7c70c7 100644 --- a/drivers/platform/x86/oxpec.c +++ b/drivers/platform/x86/oxpec.c @@ -806,6 +806,34 @@ static umode_t oxp_ec_hwmon_is_visible(const void *drvdata, } } +/* 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) { @@ -900,30 +928,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; } From patchwork Tue Mar 11 16:54:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antheas Kapenekakis X-Patchwork-Id: 872728 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 AC5C82620E3; Tue, 11 Mar 2025 16:54:34 +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=1741712076; cv=none; b=R4rpumISECZTb96aajtT8mFj4h/83jEEBamGP/9Q2TJMIViE8HNPQa624VtOFcM1JgBDCQfiI03IfHWLQ3zpYqPmSCMixTlfieguXhoaTp6O140xA5p869HxbJsQbDYcU+ROEuU7xpJ1HiZWeC8axP61AKU/BH8flxhyla1tqHQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741712076; c=relaxed/simple; bh=VLFa8EV8zFRjutFhpZFmFK/wykFjdgD0m4TeWDJEUe0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Djid+/UUz+99zNbzmJrCS0sGQbRuMLe4O/vwTTgsEYuQEs8zisOZVp0gwryevHf+yHiJCWY2NjUWIsA+ajYGKGA/wDD1HENTgdzPtnNNbIB26aDKHMFIyYGM98OOpTOYaOnTmUVGNOv8TtoDQoT2uOdQ14jzXxss8H0s6anYoqQ= 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=4+vzOnkN; 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="4+vzOnkN" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:cbc0:999f:73ad:33bd]) by linux1587.grserver.gr (Postfix) with ESMTPSA id 1DF622E0922D; Tue, 11 Mar 2025 18:54:31 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1741712072; bh=aKRcxZJKN4w8n1EXAOzcnTCprELfbGXy5KJlVyjiz1I=; h=From:To:Subject; b=4+vzOnkN/4M2oCKThN3RntDrTg2hiC7I0nIkpF1M+oRV+2puozEncodn307bKPmKU QyIjY39BsM+ytSzvZlLRw+s1iluEBlVxFxhFbJ+zUHebpiso1XmpNY0cD3PxiWZAgG QVVhWLmiPRonHWpUUIqTjWNQ3tolxP1Wh0lImHUI= 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 , Antheas Kapenekakis Subject: [PATCH v4 12/13] platform/x86: oxpec: Adhere to sysfs-class-hwmon and enable pwm on 2 Date: Tue, 11 Mar 2025 17:54:04 +0100 Message-ID: <20250311165406.331046-13-lkml@antheas.dev> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250311165406.331046-1-lkml@antheas.dev> References: <20250311165406.331046-1-lkml@antheas.dev> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-PPP-Message-ID: <174171207237.20184.7101578828806063175@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 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 97dc7b7c70c7..273589f8b2fa 100644 --- a/drivers/platform/x86/oxpec.c +++ b/drivers/platform/x86/oxpec.c @@ -938,7 +938,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 = oxp_pwm_read(val); + if (ret) + return ret; + + /* Check for auto and return 2 */ + if (!*val) { + *val = 2; + return 0; + } + + /* Return 0 if at full fan speed, 1 otherwise */ + ret = oxp_pwm_fan_speed(val); + if (ret) + return ret; + + if (*val == 255) + *val = 0; + else + *val = 1; + + return 0; default: break; } @@ -952,15 +972,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 == 1) return oxp_pwm_enable(); - else if (val == 0) + else if (val == 2) return oxp_pwm_disable(); - return -EINVAL; + else if (val != 0) + return -EINVAL; + + /* Enable PWM and set to max speed */ + ret = oxp_pwm_enable(); + if (ret) + return ret; + return oxp_pwm_input_write(255); case hwmon_pwm_input: return oxp_pwm_input_write(val); default: @@ -1025,7 +1054,7 @@ static int oxp_platform_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct device *hwdev; - hwdev = devm_hwmon_device_register_with_info(dev, "oxpec", NULL, + hwdev = devm_hwmon_device_register_with_info(dev, "oxp_ec", NULL, &oxp_ec_chip_info, NULL); if (charge_behaviour_supported()) From patchwork Tue Mar 11 16:54:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antheas Kapenekakis X-Patchwork-Id: 873001 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 1B1CC261581; Tue, 11 Mar 2025 16:54:36 +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=1741712077; cv=none; b=Pz/qnHB4Sw/4UJ/REKYj3tULdKCtx60Fg7tPCz266r+x9izY8L/Lj/2YRntkkk61yCYllXj/YmlDVAbY7QBrI7mjFw9sqnZ6wCXvjk/eMaKgR1L84q4nHMIQkUmoMuEviDQaFTjm0BMZp43DtNhqafqz1xNoGzawUEE1zE9a7XM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741712077; c=relaxed/simple; bh=57bUtWkumIaNfzhU8UUldSsAdJwVHq1f+/iMLy2KNiA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lhJZpOwLA2+hrQ7tTgtH2hk6tCUDGYKbaFJ4a3KDye+MqF+mAKD1nppZ82UfiGImvud+yGw8dtJWuKR4KYUfv4syT4yJxe9R4aSXD6AXKpPdikQP5aya7/mpcU0xLo6zfPiT82OKpvr2QTTx1LLe8/+XqWHpKuW2QMaMT0tIvpo= 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=3ND2VWxW; 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="3ND2VWxW" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:cbc0:999f:73ad:33bd]) by linux1587.grserver.gr (Postfix) with ESMTPSA id D9C562E0923D; Tue, 11 Mar 2025 18:54:32 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1741712074; bh=EFhNmT7kyNtjQ1/AmOBtMWJ+TLTwebWeSRNPwES43Z8=; h=From:To:Subject; b=3ND2VWxW1Hc5edx/qW56OxHoaLIh301FXEqlTrzbEPBOCf4faflZeiu6XGvvdjEA4 1rTU5FOxDTGCYtdjy1/Xx0pMyGC2rtpAMDtiIVFcIH4bxKcRMRw9iFxorZVD/8BtmE w3IG7r83hN7/lO2kspTBz2uVqzksgcUpAfl32RjM= 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 , Antheas Kapenekakis Subject: [PATCH v4 13/13] platform/x86: oxpec: Follow reverse xmas convention for tt_toggle Date: Tue, 11 Mar 2025 17:54:05 +0100 Message-ID: <20250311165406.331046-14-lkml@antheas.dev> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250311165406.331046-1-lkml@antheas.dev> References: <20250311165406.331046-1-lkml@antheas.dev> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-PPP-Message-ID: <174171207410.20431.1423246787523265302@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 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 273589f8b2fa..a3c945c73fc5 100644 --- a/drivers/platform/x86/oxpec.c +++ b/drivers/platform/x86/oxpec.c @@ -294,9 +294,9 @@ static const struct dmi_system_id dmi_table[] = { /* 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; if (!lock_global_acpi_lock()) return -EBUSY; @@ -408,8 +408,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; rval = kstrtobool(buf, &value); if (rval) @@ -430,8 +430,8 @@ static ssize_t tt_toggle_show(struct device *dev, struct device_attribute *attr, char *buf) { int retval; - u8 reg; long val; + u8 reg; switch (board) { case oxp_mini_amd_a07: