From nobody Wed Dec 17 13:54:10 2025 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 9B52E2940D; Mon, 17 Mar 2025 15:54:01 +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=1742226844; cv=none; b=fSx/C2nlSXp8XPnpeKzGmU4/uNdnEihuUbnCsXTQySN6zV289Wfhbel0qZMEr+Js5NzFOuzuZBnq+EU2E1lV0qbkqK3N7xE22o/6S+88TkaTHD3CRwyb3fcssZWHHJNa4LMttPIzjIgPKzCDolua/LCqR3HcHfvaVX5VMWiJLJY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742226844; c=relaxed/simple; bh=tdiUN/gA808UkpN6g6l5ag5+wM4qUAmQudO57SdnzHI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y4+VG2r6orsZTtHq5qK2H6ozzH0kDmyGhk5jLXd8rixP98h0mTBszz86EfUH2Dm0SjAwNhX9GeTsaKfccVUI5EUuhffgNvRE5tgl7ZqR3liWzvYBy5ABbwIWswXPAciw6rdODtITl3SeZWgMtQQG3lN/+VERKHuBOphtBEM5xBc= 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=xJ6y4qFR; 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="xJ6y4qFR" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:cbc0:999f:73ad:33bd]) by linux1587.grserver.gr (Postfix) with ESMTPSA id 64F882E0946E; Mon, 17 Mar 2025 17:53:57 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1742226839; bh=ZipG212NCF1KOV9rJuhRvhXErr3HGLMwbPUXCMDhaTs=; h=From:To:Subject; b=xJ6y4qFR0i+lKwedfexi54OFVQCaYnQ7ivrXPHSMUExBk2HiSHf5md0bakZWATA2m QJVtzIPxoxdN5kRCHkeW/6/9cUH7Ua/R6tgIxDg4Vz12FtrDxIEvZJv2oUCo/agr3B um7WyxWQOvGevQIqtyrW+RlAcq++BzgWgUra5YtE= 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, Antheas Kapenekakis Subject: [PATCH v5 01/13] hwmon: (oxp-sensors) Distinguish the X1 variants Date: Mon, 17 Mar 2025 16:53:37 +0100 Message-ID: <20250317155349.1236188-2-lkml@antheas.dev> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250317155349.1236188-1-lkml@antheas.dev> References: <20250317155349.1236188-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: <174222683886.22378.18442803234456392248@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" 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 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.48.1 From nobody Wed Dec 17 13:54:10 2025 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 7A2C4183CB0; Mon, 17 Mar 2025 15:54:04 +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=1742226846; cv=none; b=RQwcjzsXHTUvQQ4PZ1PXASdIj7akG7azCst+ZFJtpMcG/blqGa97iYQr3uPilvuWtkeWNdnCBwiuMBoQ6iwbHHrr+gSWPgO3ff+KtuwEPf9oNUyqeUEvPEkWmybJ8UCDn9Bfu8O6MHBMAKbhqhXPynOtG8eC5ZmTmQqUgNcjqgY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742226846; c=relaxed/simple; bh=Gss3XMvEr6F8jZFASLjg30cmvsp+TDCFV0lyB/oGlnU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tDoH4nntObjX6o3JoQBmypLwPXW0JdufCQATQQshHFwLTtEsTjzwPouShElEj+XLX/TISgg1MWp84HC+tJ+PkxPW1bvVSjJUdeuAe1Rd9QJZpa9KWc28FHxWSMzrstHvVclLsR6H/GLiFBdemftWWvUvuAg5c7sRzkbeq3zqwuA= 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=RaQPw6CM; 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="RaQPw6CM" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:cbc0:999f:73ad:33bd]) by linux1587.grserver.gr (Postfix) with ESMTPSA id 6E8A42E09474; Mon, 17 Mar 2025 17:53:59 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1742226841; bh=LSdJAQ0bA/H736JjZxupZ8TrXX+Ae+7knS+jEmuGyQg=; h=From:To:Subject; b=RaQPw6CM0+75cYkDSnK9MuaM4cXnj983ZVEt01qr/wt6Eoq4KD2k3YTYQSV2FbKaP bZ3yEue6AGlpukX2e2suMVJUp8UCTuppphZD98SWiQ4oy/2e6XbEY9EsNWHGBbqMzP dBn8YOZTEFOvkZUyadsgq9G1Y2bG8yGHmfIuUJF0= 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, Antheas Kapenekakis Subject: [PATCH v5 02/13] hwmon: (oxp-sensors) Add all OneXFly variants Date: Mon, 17 Mar 2025 16:53:38 +0100 Message-ID: <20250317155349.1236188-3-lkml@antheas.dev> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250317155349.1236188-1-lkml@antheas.dev> References: <20250317155349.1236188-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: <174222684095.22458.5968359271258115630@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" 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 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.48.1 From nobody Wed Dec 17 13:54:10 2025 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 765C9176FB0; Mon, 17 Mar 2025 15:54:06 +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=1742226848; cv=none; b=UFWN7lMdU+Hl3iokdUPaM5N5mQ0EcU5vVGkl5SKzXzUjbKMkmfty72PUx19m10meXap5zb4g4Rk9hv/R2ox6m/N7ktuvFk5MF0WTs8zwHUr6svY9b/NKrwnpwI47IUEzi7U+pbEWQIRWerfPeKfoMzYWC+4wSlDUGDXrCrA9tMM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742226848; c=relaxed/simple; bh=OhVEUcEzjbQVZ0w91N9nYEWsSxN9XG5JPoAdXtg3MfY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=i/EVTfvRcHVwsLOzcwJ+ILqa9IV+FavC4k9Rv2lV79R/BwxbaWvyfPKHCFl1mvQP77ntYK5h1grvpD8oqIpZJ/JWTohmN20LHYjMOkj3e4NJl052fu4wZnds4PEeyO/lTRz3gFOsUZnMjMKaf2ZijqCGHqZy7uFlSrwp9bNgI7o= 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=bxx0Yh4S; 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="bxx0Yh4S" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:cbc0:999f:73ad:33bd]) by linux1587.grserver.gr (Postfix) with ESMTPSA id 022552E09476; Mon, 17 Mar 2025 17:54:01 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1742226844; bh=UQJDxs1mtnDumBb2isG/FnxXPecbW6NXnOagBKtZQ44=; h=From:To:Subject; b=bxx0Yh4SXWNk/RxGJElGWVZEU0hLEmDm2garQYGJGpI/syd0LN8TVJPekhT9WvsGR Fon5jJNMsOe8o2ClaE6nhuxQL4tmcgc8400uuvmYicbdWZG319sYplF5PU2gWDLpMC yjkq2q/kKSRNiV3HPWN6xxDpvK1WbTRpuSh1lL5I= 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, Antheas Kapenekakis Subject: [PATCH v5 03/13] platform/x86: oxpec: Move hwmon/oxp-sensors to platform/x86 Date: Mon, 17 Mar 2025 16:53:39 +0100 Message-ID: <20250317155349.1236188-4-lkml@antheas.dev> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250317155349.1236188-1-lkml@antheas.dev> References: <20250317155349.1236188-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: <174222684393.23494.5809904754412602114@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 =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 874f8fd263252..dd7a54d5f2816 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 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 c9763412a5089..20720f92e4a63 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -17656,12 +17656,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 4cbaba15d86ef..09f7aed96d15e 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -1774,17 +1774,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 b7ef0f0562d37..0edb08824b178 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile @@ -181,7 +181,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 0258dd879d64b..82cfc76bc5c9f 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. =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 e1b1429470674..f64a191c1162e 100644 --- a/drivers/platform/x86/Makefile +++ b/drivers/platform/x86/Makefile @@ -153,3 +153,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 \ 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 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.48.1 From nobody Wed Dec 17 13:54:10 2025 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 148701A0BF3; Mon, 17 Mar 2025 15:54:08 +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=1742226850; cv=none; b=YEJ1WgOU+kwrW1nQzN6gYkGZFu9IszzZMTaTT3H/9ljrmeXzXpoL42+8WNERtZvFjCrahjRIrBtjxrBAe+AaAtFG5wBCrU6J0WB9W0GTcQtOMSZEF/yLhge5tIMV3Zrh7uu3+8XJ7SBcIw7rptZNf+J4VJHYJ6zoKG+WvkJto1Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742226850; c=relaxed/simple; bh=M7el599bwHdIOuoMBeltM/sc/3KUKxsvOSV7rbo54Fk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ax9tjyTM01Flva0vlQAZ8c78AqQKthU5npBaSSC11YowH9W90ItOftCusirgui7ahi6vX+sf/bxQXMp3lmOyd1PafXj4M8EUKyXW4WPxafTO68DQNdRueLjBSCqelrwfCnPLhs7TsQfxng3n8nuChuHsaRqraktTLOdSej7KKso= 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=ddAIDG8z; 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="ddAIDG8z" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:cbc0:999f:73ad:33bd]) by linux1587.grserver.gr (Postfix) with ESMTPSA id DA40C2E09479; Mon, 17 Mar 2025 17:54:04 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1742226846; bh=3T2Wdl7yX47LEWXmyKBnfKUb25WQD9gTzDHYYPXyFcI=; h=From:To:Subject; b=ddAIDG8zyMi48idAzq9EX9ZFl2817K7L6jaXP8Rit1g1YhHZUwE7p2JzdnInOxqML lZIPkX3JXxJ9vKVXlu0XkGUvHoIhaVzlkZk/QDRVpGb/DuET9L1TyKC550JVMFY0+B vDX42pNcZcaT7cC1XjLj4j4xb28FJRD0rYRxP+Ag= 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, Antheas Kapenekakis Subject: [PATCH v5 04/13] ABI: testing: add tt_toggle and tt_led entries Date: Mon, 17 Mar 2025 16:53:40 +0100 Message-ID: <20250317155349.1236188-5-lkml@antheas.dev> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250317155349.1236188-1-lkml@antheas.dev> References: <20250317155349.1236188-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: <174222684654.24760.16330231138895074200@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" 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/A= BI/testing/sysfs-platform-oxp new file mode 100644 index 0000000000000..776b7dee3d595 --- /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. + --=20 2.48.1 From nobody Wed Dec 17 13:54:10 2025 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 0B03D1A5BAF; Mon, 17 Mar 2025 15:54:10 +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=1742226852; cv=none; b=GEnC6koKcRzar8/ieHCL9dLLU/bRuZBe5/TCqDrv7r1wrEyxiDIwDGS83yJ4U8nfT3hWhvHyouEHKjrb5obHrb52iEITIhRHfljK552x+ZCudq8mxsXxnZj99fnxTrGrodaUeXliRJxdhjXBJRcSHCjrGeFPTmnWMg88a/vK+3c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742226852; c=relaxed/simple; bh=tB5IqVaCrQjweRLudiZFfy5G6/+e6PG/KQ09ygaDgAc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=f8wSoiV8kONMbAkLnjr4P3s6nIrhOJwxECo+9sw5BiW0OkNuoxZAGOXpRRGCQY4/ZXFz7+8UefiVlcccATPrhOy2E8Xu8VwAeXvqPQjnU1c9bm5bQW/WEip2/jXYZ8+nZF/vf4O7rN9WlAuYWzNhosRcvlU/oWbNbf4iVYgI/aI= 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=CFVwkXwk; 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="CFVwkXwk" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:cbc0:999f:73ad:33bd]) by linux1587.grserver.gr (Postfix) with ESMTPSA id 248F62E09478; Mon, 17 Mar 2025 17:54:07 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1742226848; bh=xOJBRmPb77Upc6malwv2xiNxBLox/UlI116EjsTj0x0=; h=From:To:Subject; b=CFVwkXwku8Yg0JUlIP+0nHaNQlYj3RJt7wm6LsRN1QAVYzDQ6FXMg1ehH3/u5KbxH ldYQjItWter2SUlhFDu44TL6U17U8GxkvcQcGj30JIPEFOxuW340tOmJJ3Xb/hiqr/ BbGNFH4HreT/0IiILYkXDZFi7OHoV19zZEwcAHjg= 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, Antheas Kapenekakis Subject: [PATCH v5 05/13] platform/x86: oxpec: Rename ec group to tt_toggle Date: Mon, 17 Mar 2025 16:53:41 +0100 Message-ID: <20250317155349.1236188-6-lkml@antheas.dev> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250317155349.1236188-1-lkml@antheas.dev> References: <20250317155349.1236188-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: <174222684857.25118.187880419746453389@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" 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 dc3a0871809cd..8836b3df0d57e 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 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.48.1 From nobody Wed Dec 17 13:54:10 2025 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 D32CD1B043E; Mon, 17 Mar 2025 15:54:12 +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=1742226854; cv=none; b=S5EFlRFr6WOA9xYdnVBxsrmqMvyo9DcoGrjkSngzATVUpXgIYTjIANfPmkrM0zEdMG3Kz3qQ5H3xUsM1nEHMr6G7CO19mh6kD/RDcX46amuAP5Fa27M29qewdYa2UFayX4YOmittS53PJ/bnAaSFJ/VzVrxSQ0AGcBICqlUlnvw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742226854; c=relaxed/simple; bh=yoqGJKnal9DYCnh0IwfKjc0tl6iG2sFiajTRj01DapU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BtI4NS7OvpU7QlfIWdcSLCBRbE04Xr+tKANHE5cqTQdTT2212vD0W/j27xg7kOCauH9Mq/5Tx6BEX6e7MOmD5YSeTN30Kw0Z9Z8hoEtpMBxiMAhf1mPBbmXilVdec32qQfpN8FNYlFCPVKnrrjGys4tiUqvcpST+d3mrak1BhEs= 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=Xp4OGN9h; 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="Xp4OGN9h" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:cbc0:999f:73ad:33bd]) by linux1587.grserver.gr (Postfix) with ESMTPSA id 0F48C2E0947A; Mon, 17 Mar 2025 17:54:09 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1742226850; bh=htkcy/R1mvK/qCMqFlwUbifyGY+8azwR8Yn4zr7kqo4=; h=From:To:Subject; b=Xp4OGN9hm3ltVNi6it6nZ9ddLc+Gwy60CWRfHXWxzoooCY8jbIAJYo7wisUhrKuLK c0uKPpM7Tr5HW8UVS5mvrurIHLlg5FkEFn98+92ySk/UDWUrpuBumcCKfWPIhQk62P i3bAu62yQrT8EaelUKBkje2zKvz3zUgl6j0m8azc= 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, Antheas Kapenekakis Subject: [PATCH v5 06/13] platform/x86: oxpec: Add turbo led support to X1 devices Date: Mon, 17 Mar 2025 16:53:42 +0100 Message-ID: <20250317155349.1236188-7-lkml@antheas.dev> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250317155349.1236188-1-lkml@antheas.dev> References: <20250317155349.1236188-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: <174222685049.25210.12028853202139099731@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" 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 8836b3df0d57e..d13704218d264 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 rval; + + rval =3D kstrtobool(buf, &value); + if (rval) + return rval; + + 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; + } + rval =3D 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 =3D OXP_X1_TURBO_LED_REG; + enval =3D OXP_X1_TURBO_LED_ON; + break; + default: + return -EINVAL; + } + + retval =3D read_from_ec(reg, 1, &val); + if (retval) + return retval; + + 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 struct attribute_group oxp_tt_toggle_attribute_= group =3D { .attrs =3D oxp_tt_toggle_attrs, }; =20 +static struct attribute *oxp_tt_led_attrs[] =3D { + &dev_attr_tt_led.attr, + NULL +}; + +static 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.48.1 From nobody Wed Dec 17 13:54:10 2025 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 31AD91B4F1F; Mon, 17 Mar 2025 15: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=1742226856; cv=none; b=ecaXclsFnR7sc3qGNwCQujjoa08VrwbDls2kyGTMIjqzkY6M03Nubl0QvcrzrrOz2xq9300BzK9+SSYI+S4a0iiQJFmln8KnBsmfO2qmmDIXniUHLD/fleZsfXYo/mDCMOhN3KBUJE1DWCQpbwKRy9TrjWmuoCVsGdPnIC/718g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742226856; c=relaxed/simple; bh=NOBglK2Qm0Q1On+BVinoSr1EVnEvw2Jp6/SN/q0rUnI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lqvd9k//X6ntZbyEVmTamf8PFJWdP3U8e2RqQZrOTsBTsmHN0wJDP9ySOzSLrQH3wDrH2sgZPmBD5YQN+QR7yU+bbfN8SINhLos4QHsqesYEuKPVLjm5pqn5IiXPpcavSBF9w5GtXGuyBJswxTSMoJidjD4msZsBwII8TaDU+H4= 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=J8/rvSIt; 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="J8/rvSIt" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:cbc0:999f:73ad:33bd]) by linux1587.grserver.gr (Postfix) with ESMTPSA id 048182E0946F; Mon, 17 Mar 2025 17:54:10 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1742226853; bh=ZKF6gDzYQyX19MF8K7/dBz3k5vZBjUkN2pdUColclfE=; h=From:To:Subject; b=J8/rvSItUtMGPryOVRAy00uwTMd5P9zTFYMGZ62NpxsGmvq3BmYLMEtj3h4+gDAUi YF+KKTcLLdJ3ySeqXdF4n5WgSxPfd11zqET18OImBZzh6ibXsOVsu9uIJf/KV/ExSk FDpu2x/PZASjmBJmK68LBUttWShWaEKIS3MkzryA= 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, Antheas Kapenekakis Subject: [PATCH v5 07/13] platform/x86: oxpec: Move pwm_enable read to its own function Date: Mon, 17 Mar 2025 16:53:43 +0100 Message-ID: <20250317155349.1236188-8-lkml@antheas.dev> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250317155349.1236188-1-lkml@antheas.dev> References: <20250317155349.1236188-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: <174222685242.25318.1845623697253863095@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" 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 d13704218d264..0ca965e224438 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.48.1 From nobody Wed Dec 17 13:54:10 2025 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 6772F1C6FF6; Mon, 17 Mar 2025 15: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=1742226859; cv=none; b=tbLCtX8GDMynoBfbkNm69FtXRmLRy1250Ajzzk1wQ4vtF1qPyEjvmGUTiexBZhd2T9uKsm6YtuVj1CKwlBI1bFligVlresrUmo1Sjf8uwHO0jKxKduX9PE9Ykb06YzpX9xS0pL0pLsw8eQmDdmVqTUO83nIFKCDIT6avJiG/uwQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742226859; c=relaxed/simple; bh=fOWQVgU2+W7s0Du4CSQjBqOhpL3GdLYu/Um6Se6n1h0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fL2oC5OJPZgifouGogCxHeNnLhP3gEGFAHHafPxQP9h1biwU2eAi5XfK14sS56Fzc/NLKTZvGo8VA0U/a38NXew2NW+jtjaoQL0VEJbWLLNVZlwHZdG0PrIJewYvgTDbWfDjQjulmmqkH2VceFC953BPe4VmQmWVsX/qhKcosJc= 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=Jsu2tMPq; 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="Jsu2tMPq" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:cbc0:999f:73ad:33bd]) by linux1587.grserver.gr (Postfix) with ESMTPSA id 44EE82E09477; Mon, 17 Mar 2025 17:54:13 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1742226855; bh=D6sDLIrDnjOeLutyw7TyQF+oRWXBDfhCyqTaBCb1E/E=; h=From:To:Subject; b=Jsu2tMPq3ioFoZkDFbTPRLmWYYf/OcmmTp//FpFLf4ZT9nPqq9fcMkQ+ENvXabDiE tio0jwQiWyJUNvOToAnEhdbm4v4tm8ny9RxyeIlOH9tr6LJALga2v6hf6lFaChg78d 4Yi+mMc/JCpn8TbagfpfEe2Nydw5HZtpipzKCNa4= 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, Antheas Kapenekakis Subject: [PATCH v5 08/13] platform/x86: oxpec: Move pwm value read/write to separate functions Date: Mon, 17 Mar 2025 16:53:44 +0100 Message-ID: <20250317155349.1236188-9-lkml@antheas.dev> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250317155349.1236188-1-lkml@antheas.dev> References: <20250317155349.1236188-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: <174222685487.25411.2620804120285440600@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" 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 0ca965e224438..67bc871462466 100644 --- a/drivers/platform/x86/oxpec.c +++ b/drivers/platform/x86/oxpec.c @@ -599,6 +599,91 @@ 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 +724,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 +750,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.48.1 From nobody Wed Dec 17 13:54:10 2025 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 CB58A1D7E54; Mon, 17 Mar 2025 15: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=1742226861; cv=none; b=bg5pLatvuEh/t4HgGT4Z1YhCziVQZHL+TLDSlUS/VW9VjTgNBr8EtEMNFCFw76nlwLpC/8OAdfEOnh64EcrghPcGpugAFvfZf8g7fNXc3TpCCyAl1jdRsxknYYJS1c+yQVd3zOfJWg4AeEPedpHq9A4Ug+ownXzxgwhDVENECDQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742226861; c=relaxed/simple; bh=L0yeIbgZofMJx+dLHOxsp3bZht7NWMtb4aZrjRI5ejs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rZKK8C2HDMNP+avx574C9I5x65MtI6/lHYGzYM2xOtiaD+WPicsVDJi51T92Z8lvJB7of3NovvV6vGcDEqrODJcP2pnMeN7JjRyGMcQX3NjPfspqTv7IdaOBZ3uppPzPTQ6FUGkHdaxe+VUyHD+YCG712EjFerpruQF53Pj9ZGE= 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=dSnrwSZY; 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="dSnrwSZY" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:cbc0:999f:73ad:33bd]) by linux1587.grserver.gr (Postfix) with ESMTPSA id 86AD92E0946E; Mon, 17 Mar 2025 17:54:15 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1742226857; bh=QR00oEXFkQqxdYbOVnD2go255guMIBYxIzYnhHBxSz0=; h=From:To:Subject; b=dSnrwSZYn6I5RdBz1giSsRzFfYWmVm0lsHNAJJ4e2mMqpQXUnSQO8muZamkm7QyOQ zcNBzOLyAcoAMD6xYBkgD5ffObPbPJmM/KfotowcwMkSx8L5XU3Ugg1WvI1RKN8z8N 1W2moIoDWJPGXrfFxkqi7ZXbSF77IUDzcgEFlsvo= 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, Antheas Kapenekakis Subject: [PATCH v5 09/13] platform/x86: oxpec: Move fan speed read to separate function Date: Mon, 17 Mar 2025 16:53:45 +0100 Message-ID: <20250317155349.1236188-10-lkml@antheas.dev> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250317155349.1236188-1-lkml@antheas.dev> References: <20250317155349.1236188-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: <174222685698.25504.12005777082839056085@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" 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 67bc871462466..61b070168249e 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) { @@ -693,30 +721,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.48.1 From nobody Wed Dec 17 13:54:10 2025 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 453F31DACB8; Mon, 17 Mar 2025 15: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=1742226862; cv=none; b=sLwDgTChlVxhPR0fRtLonWy04RXm3wKpMUuM3oEklAsj7ToOOjsQHFYIsHmFROPId/eb6c3cx4P4LKF1HmejXyu07R+8bKWz1B7DrHXvXLRpO+w5ZEWKuF/yAqwWqcOE5N1w/vBZwnzJ+tZwJbwJx6fQgz7jDT0Yf30Y97sDwHk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742226862; c=relaxed/simple; bh=AvzKmq9AxIImUXEa711RH6QDbR/FS5B//HOdynBwMO4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ul1Q6G1O9Gzvy5PD0zEOouVuJfWbwsWIL6MN2Hx9Z7dB1qM3LnXuw1OHJ267UiyOuUKAx/rmOfnCnooCMeAgslSKWJmj9feWflw5AC1qJLO16kVbFTy7FNoA1wQywWjAW2i9zSKy04TqiIW1WdTEh8mVGJkFMj1yJphLlkQe500= 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=FM6LwnTc; 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="FM6LwnTc" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:cbc0:999f:73ad:33bd]) by linux1587.grserver.gr (Postfix) with ESMTPSA id A22B22E0947B; Mon, 17 Mar 2025 17:54:17 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1742226859; bh=PIHxmjexBEnKKIekxNlK9X3mmUjFTEC9azVuFq4rxmA=; h=From:To:Subject; b=FM6LwnTcIJcrZQewzzQgIsho5oS/E1jaWWLsrqqN51Jas4+u3T6x8btP2smJJW23/ rvLREGHXxKr1BGd2xMOjTH54vHcHeR2jpsBD/nIhmjZtU8w11yA/kIaD96/eB2glqy sfog+HbuCWe2MwOPBOqN/Yc6PHB3IENrqkQ25uvs= 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, Antheas Kapenekakis Subject: [PATCH v5 10/13] platform/x86: oxpec: Adhere to sysfs-class-hwmon and enable pwm on 2 Date: Mon, 17 Mar 2025 16:53:46 +0100 Message-ID: <20250317155349.1236188-11-lkml@antheas.dev> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250317155349.1236188-1-lkml@antheas.dev> References: <20250317155349.1236188-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: <174222685908.25594.7954128283982990338@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" 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 | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/drivers/platform/x86/oxpec.c b/drivers/platform/x86/oxpec.c index 61b070168249e..14fa70652087b 100644 --- a/drivers/platform/x86/oxpec.c +++ b/drivers/platform/x86/oxpec.c @@ -731,7 +731,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; } @@ -745,15 +765,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: --=20 2.48.1 From nobody Wed Dec 17 13:54:10 2025 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 B54BA1DEFEB; Mon, 17 Mar 2025 15: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=1742226865; cv=none; b=roLFHenQRhLI9PRzPH7m+cLJnm+vw9zq0EQc5Cvsx/f81CD+RDKTA4MQ0QL0C5nKtzwV1+jI6necmXVEMS/qFfXhxdhOJ6/2yAuhAzu7Q4M4e354LDgkpRv1mBN7QqR3EAxoc26z1ikQ/CzAdpq2M9qDgekIV6A2tYrIOd0sT/o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742226865; c=relaxed/simple; bh=HcsJpujgZY7mO6VKp9SoPFrQvWWUshutuHAMYSvfDGI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Kmo2xAN9d/8CK2z7ZZKgZxxg3tLKijCZX6M0Ega3kDyYXQXSGNK8ku8QpDISJRO04yI6fQKDVeDQXFJeuEq3sArEansmphsMxMdGhfFXvkDSZRUH3K5mMtVhikgScclp2Vchbij65BwRYpEMVq8IZgHbdggSejEFvWO1M+kcEds= 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=tdjonn+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="tdjonn+Q" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:cbc0:999f:73ad:33bd]) by linux1587.grserver.gr (Postfix) with ESMTPSA id B63CF2E09474; Mon, 17 Mar 2025 17:54:19 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1742226861; bh=YJycPDX/cjvicqrkGk+zll68e9CXw3i6IlVAGb9QQdQ=; h=From:To:Subject; b=tdjonn+Qjy546va6bpVsO06NYXkhes7cd6IflTkeON8DYBxyYmQpAJk+gZQE+qHPO i8MMKnN+WJOqk1a2jvG7GtrZeriWll2/Bnv6KBNVshZV4xgeVJhCamX3tj6UPQcaHb 4Y/DbH7PUDlJ6fUa9ERxdcQ4wBEOJE2GBft1hka8= 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, Antheas Kapenekakis Subject: [PATCH v5 11/13] platform/x86: oxpec: Follow reverse xmas convention for tt_toggle Date: Mon, 17 Mar 2025 16:53:47 +0100 Message-ID: <20250317155349.1236188-12-lkml@antheas.dev> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250317155349.1236188-1-lkml@antheas.dev> References: <20250317155349.1236188-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: <174222686128.25675.16028193768684724029@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" 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 14fa70652087b..39a29295f9cfe 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.48.1 From nobody Wed Dec 17 13:54:10 2025 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 DA0381E1E16; Mon, 17 Mar 2025 15: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=1742226867; cv=none; b=KfDQ/ZzigHLHwKYZC3ne1we6C2k70nqn7hJg/EPfwHgRGVB5eVUdUVS5CF2TryqSrJN2M4qDCN8XAjB53bXVQMzhCDUCEXeLvy+2t+paGRINQTtbGxdgdgzTZkyvL84slCCb8E1yyimtwOUdQ9K7uVQeovncr6vVvTuVp54MR/0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742226867; c=relaxed/simple; bh=cW2UPrnoXx0rPUrV3/62dWo6Cgavut3RLl2FAa9j+I8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dpxrX/IRVIgSkO7WYrKzkeIY+SbGJUjQGHMWChoXEu78Hth0qxbYuI1mOYQpza/BY/+c4/lOg5UwbV/SuP9Ug1bJUZSnpEb5BjO7aZAmyuT8+SF2gJfFTdfzH4tYLe3wjAN9ubutEw6rqGzUfABMrlP7xIGvAasPGSRBlATHo0s= 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=GNqBblDZ; 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="GNqBblDZ" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:cbc0:999f:73ad:33bd]) by linux1587.grserver.gr (Postfix) with ESMTPSA id EF1D92E09476; Mon, 17 Mar 2025 17:54:21 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1742226863; bh=B6iqgpk2OAq9KZsEPpwvBhRAPBQ0hAJ+6x8yLp+3kUI=; h=From:To:Subject; b=GNqBblDZPUaSQpLPlIgBqYcx9LU7J/o+npTusU0UiJCOStiAIu9+iWupBQdelMjNU YeDwvSN3idDPbyJzZFHRK1AKm19N+rk083wTcruRmjOa59PRxgJrTc2Dgpb6TA7/xS MQudkPaQ0fwZIRQ5jWo9snaQFlMa0cReqZGPR1x8= 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, Antheas Kapenekakis Subject: [PATCH v5 12/13] power: supply: add inhibit-charge-awake to charge_behaviour Date: Mon, 17 Mar 2025 16:53:48 +0100 Message-ID: <20250317155349.1236188-13-lkml@antheas.dev> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250317155349.1236188-1-lkml@antheas.dev> References: <20250317155349.1236188-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: <174222686352.25753.1822690390033735237@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" 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. 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/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..8d036faf220ec 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[] =3D= { 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_INHIBIT_CHARGE_AWAKE] =3D "inhibit-charge-= awake", [POWER_SUPPLY_CHARGE_BEHAVIOUR_FORCE_DISCHARGE] =3D "force-discharge", }; =20 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 6ed53b2921624..bb8e9e62ce834 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.48.1 From nobody Wed Dec 17 13:54:10 2025 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 341801E5B77; Mon, 17 Mar 2025 15: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=1742226870; cv=none; b=PUpmqW+GTTVC6oxMsR2WQJV19CkPezC/O88GUbVTpS6jTnVRoQ3XZ2WQKi3cDJenkkEW+7LkpHT89cUoyyo0hnONenFTRP+KCCopX8Ynusm8NL/8nWhLj29oiNtCw8uzSilcNyJyPHjB652KFaRw5ZOoXc+2kDm9dpi9AwKyQeM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742226870; c=relaxed/simple; bh=Y7K/RuMpkjeDrO4M011u3Dk/gKKBgruwRACBn5H/Azg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=h6u8HKhTr+eQ3Mzn9+X7a/5hEZjaELqA87lI653T3NS5C04MkDuTJnZwNj1Xz16gVbzcILgMqrt5ovGiXZ7HdwpTARznseEW+elwb0RohxSLJmbtxdpXNRW3j8aKxUWUGK6LlgnwS9rP/wJQLJyIMBU4f7M5X/FGDcR+Mm4Um8U= 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=1pKMO8ut; 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="1pKMO8ut" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:cbc0:999f:73ad:33bd]) by linux1587.grserver.gr (Postfix) with ESMTPSA id 4EC982E0947C; Mon, 17 Mar 2025 17:54:24 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1742226866; bh=H0HeL6UFDvvlyKc7aV7cQGD8RGlrpo0C8vrVLj3ZgcA=; h=From:To:Subject; b=1pKMO8utYpPvYPdC8D5+CIsvJTLRySjY/q7bfyiYBKYkYOHoTsqnJ61B5Q0D3fzRG kFJy2UHzUKAjA9klvbWNLxKl4x7ztKXVy/HG3mgGORxetcrZwicAN6mKZMu069EriD pzyp59Jm0mZFvEBvrbTia/xZPpTpzzTuX4napPOw= 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, Antheas Kapenekakis Subject: [PATCH v5 13/13] platform/x86: oxpec: Add charge threshold and behaviour to OneXPlayer Date: Mon, 17 Mar 2025 16:53:49 +0100 Message-ID: <20250317155349.1236188-14-lkml@antheas.dev> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250317155349.1236188-1-lkml@antheas.dev> References: <20250317155349.1236188-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: <174222686573.25833.9637588748769200232@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" 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. Signed-off-by: Antheas Kapenekakis --- drivers/platform/x86/Kconfig | 1 + drivers/platform/x86/oxpec.c | 164 ++++++++++++++++++++++++++++++++++- 2 files changed, 161 insertions(+), 4 deletions(-) diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig index 82cfc76bc5c9f..f4d993658c01f 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 39a29295f9cfe..88d839c2a4834 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_X1 (BIT(POWER_SUPPLY_CHARGE_BEHAVIOUR= _AUTO) | \ + 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,136 @@ 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 1; + default: + break; + } + return 0; +} + +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 > 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, +}; + +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_X1, + .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) +{ + /* OneXPlayer devices only have one battery. */ + if (strcmp(battery->desc->name, "BAT0") !=3D 0 && + strcmp(battery->desc->name, "BAT1") !=3D 0 && + strcmp(battery->desc->name, "BATC") !=3D 0 && + strcmp(battery->desc->name, "BATT") !=3D 0) + return -ENODEV; + + 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) { @@ -845,12 +994,19 @@ static const struct hwmon_chip_info oxp_ec_chip_info = =3D { static int oxp_platform_probe(struct platform_device *pdev) { struct device *dev =3D &pdev->dev; - struct device *hwdev; + int ret; =20 - hwdev =3D devm_hwmon_device_register_with_info(dev, "oxpec", NULL, - &oxp_ec_chip_info, NULL); + oxp_dev =3D dev; + ret =3D PTR_ERR_OR_ZERO(devm_hwmon_device_register_with_info( + dev, "oxp_ec", NULL, &oxp_ec_chip_info, NULL)); =20 - return PTR_ERR_OR_ZERO(hwdev); + if (ret) + return ret; + + if (oxp_psy_ext_supported()) + return devm_battery_hook_register(dev, &battery_hook); + + return 0; } =20 static struct platform_driver oxp_platform_driver =3D { --=20 2.48.1