From patchwork Sun Mar 9 11:21:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Antheas Kapenekakis X-Patchwork-Id: 872093 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 26797199949; Sun, 9 Mar 2025 11:21:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.138.42.100 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741519291; cv=none; b=bsnqyti/hsVzqvlZFXd7WRV8xz4yLHDCEMKqWE1y3uYlntqQ+P46xZjE7I4Pdkf4UyIA9VByvxFHwhL+whUU69UJTW3pEX0VSRIHH9jbIXd1cbglhru1R88oTWr8BRyhkZY4kn52Fkm76jPQbguKHKHeTSm0u5nQEs6QRdgYwWA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741519291; c=relaxed/simple; bh=DN4lPGzRvJ5WNcNqzi6UYhqtxe0UJP4nUvlWxCQtf3k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tr0Zimw9LwtWWgPglJPbUbx4hcvWqylHXt8lCSInUjKNgikZlxb5YiXzz7Wfx0szgZF+xhLwucewO4QvqQb9FjTpPH8w/l64lQtPVC9YeAjLNEs8QSNc+2HQRLrukPOVcyrz1xQnfQ4cNsOpmsnHVVnyAuKnFSmu+3RhA1q//6M= 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=d7scwS4L; 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="d7scwS4L" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:8d8a:5967:d692:ea4e]) by linux1587.grserver.gr (Postfix) with ESMTPSA id 36E062E02CAB; Sun, 9 Mar 2025 13:21:22 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1741519284; bh=RYIh6+vPCJzjj/Auw7QFSfgfIxTo9QzItGSvqYtET6k=; h=From:To:Subject; b=d7scwS4LNmjcEsobsVgI87jZPSFPg3SGtmt/l9jpPi2maikF5dzUywJEgxgvjoazU n0NyzwtHcauR9o938tTSQ3ax5k0RZ3ZFSxfq1s1qIeYbEIIW0Phrsi1CWjkgWcAAE/ j9a8GOcmt9CdBQUEUYphAK04sUFTWdm9w+H7Mfg8= Authentication-Results: linux1587.grserver.gr; spf=pass (sender IP is 2a05:f6c2:511b:0:8d8a:5967:d692:ea4e) 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 v3 03/12] platform/x86: oxpec: Move hwmon/oxp-sensors to platform/x86 Date: Sun, 9 Mar 2025 12:21:04 +0100 Message-ID: <20250309112114.1177361-4-lkml@antheas.dev> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250309112114.1177361-1-lkml@antheas.dev> References: <20250309112114.1177361-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: <174151928355.28721.4095908493012173453@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. 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 => oxpec.rst} | 0 MAINTAINERS | 7 ++++--- drivers/hwmon/Kconfig | 11 ----------- drivers/hwmon/Makefile | 1 - drivers/platform/x86/Kconfig | 11 +++++++++++ drivers/platform/x86/Makefile | 3 +++ drivers/{hwmon/oxp-sensors.c => platform/x86/oxpec.c} | 10 ++++------ 8 files changed, 23 insertions(+), 22 deletions(-) rename Documentation/hwmon/{oxp-sensors.rst => oxpec.rst} (100%) 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/oxpec.rst similarity index 100% rename from Documentation/hwmon/oxp-sensors.rst rename to Documentation/hwmon/oxpec.rst diff --git a/MAINTAINERS b/MAINTAINERS index 0248c9eb39d6..a11d346a458b 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -17641,12 +17641,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..4531b20c6b30 100644 --- a/drivers/platform/x86/Kconfig +++ b/drivers/platform/x86/Kconfig @@ -1186,6 +1186,17 @@ 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 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 Sun Mar 9 11:21:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Antheas Kapenekakis X-Patchwork-Id: 872092 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 0F22E1A840D; Sun, 9 Mar 2025 11:21: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=1741519291; cv=none; b=L70VcqL8GPVilZW1aXJ3cjsY3TYCM0SIM7rE12T8Bxli9C8h7gkr6p2EMl6fpHz0Gz5LmeuWF0W/UKSIQTowhoBkQ/FHh4LA+KjBp75lI5/C/+S8WbMZ1yU6v0fk1oF1zLGbYu7jEnPUmBdf3CPrADhvwP0bnmtVFF4sNatA+50= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741519291; c=relaxed/simple; bh=hwbg85IHRmzac4MOiU1b/r7yBMLHOMIeHyC8YX0maYM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rPJbBzQKb6uBg/XY8f2mnLCnmd2d7jwW2y1H+AH6FWIJ+lh+qSBEtOBRQPypjOlvthVflJ5l/u3r+ikJdE97DwfWzJ1kPQJydt9VycFzlRcsPXZ5OZLcDtIuFP3KJFckEXU+q4E9DytKI9/+XoiWAGBj0hqIVcXbbHmSRsNHQy4= 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=aIPfWTaa; 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="aIPfWTaa" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:8d8a:5967:d692:ea4e]) by linux1587.grserver.gr (Postfix) with ESMTPSA id 1D4C82E05696; Sun, 9 Mar 2025 13:21:25 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1741519286; bh=EbAW66MOShp+FMmH6+3P02El1Ie30xboAe3WC3/AJMs=; h=From:To:Subject; b=aIPfWTaaI9j9+VH4LI9SytI3dhe7ae9XHW2mPNom8G+1FtOiBnU/bgZvaAomOlJyq fDRQq8gONGUDOFw9vsSgj6b8NdO0bKQ1STqEbOny1CrzuGrZhlOcBP3MRcRbFJdgAi dfm8Q/HihadmQ06WKwtskwcnBZ06V3pxTwORwZps= Authentication-Results: linux1587.grserver.gr; spf=pass (sender IP is 2a05:f6c2:511b:0:8d8a:5967:d692:ea4e) 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 v3 04/12] ABI: testing: add tt_toggle and tt_led entries Date: Sun, 9 Mar 2025 12:21:05 +0100 Message-ID: <20250309112114.1177361-5-lkml@antheas.dev> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250309112114.1177361-1-lkml@antheas.dev> References: <20250309112114.1177361-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: <174151928638.28801.5989227754740765426@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. Remove the documentation from the hwmon entry, then update its readme to be current. Signed-off-by: Antheas Kapenekakis --- Documentation/ABI/testing/sysfs-platform-oxp | 29 +++++++++ Documentation/hwmon/oxpec.rst | 62 +++++++------------- 2 files changed, 49 insertions(+), 42 deletions(-) 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..8727d5ecaab5 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-platform-oxp @@ -0,0 +1,29 @@ +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 + devices (otherwise it NOOPs). + + This attribute was originally introduced in 6.5, without a + corresponding documentation entry. + +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. + diff --git a/Documentation/hwmon/oxpec.rst b/Documentation/hwmon/oxpec.rst index 581c4dafbfa1..0a0a7c5d0263 100644 --- a/Documentation/hwmon/oxpec.rst +++ b/Documentation/hwmon/oxpec.rst @@ -1,35 +1,41 @@ .. SPDX-License-Identifier: GPL-2.0-or-later -Kernel driver oxp-sensors +Kernel driver oxpec ========================= Authors: - Derek John Clark - Joaquín Ignacio Aramendía + - Antheas Kapenekakis Description: ------------ -Handheld devices from OneNetbook, AOKZOE, AYANEO, And OrangePi provide fan -readings and fan control through their embedded controllers. +Handheld devices from OneXPlayer and AOKZOE provide fan readings and fan +control through their embedded controllers, which can be accessed via this +module. If the device has the platform `tt_toggle` attribute (see +Documentation/ABI/testing/sysfs-platform-oxp), controlling these attributes +without having it engaged is undefined behavior. -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. +In addition, for legacy reasons, this driver provides hwmon functionality +to Ayaneo devices, and the OrangePi Neo (AOKZOE is a sister company of +OneXPlayer and uses the same EC). Supported devices ----------------- Currently the driver supports the following handhelds: - - AOKZOE A1 - AOKZOE A1 PRO + - OneXPlayer 2/2 Pro + - OneXPlayer AMD + - OneXPlayer mini AMD + - OneXPlayer mini AMD PRO + - OneXPlayer OneXFly variants + - OneXPlayer X1 variants + +In addition, until a driver is upstreamed for the following, the driver +also supports controlling them: - AYANEO 2 - AYANEO 2S - AYANEO AIR @@ -41,29 +47,8 @@ Currently the driver supports the following handhelds: - 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 ------------- @@ -79,11 +64,4 @@ pwm1_enable 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) + to set fan speed. \ No newline at end of file From patchwork Sun Mar 9 11:21:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antheas Kapenekakis X-Patchwork-Id: 872091 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 E98C51A9B29; Sun, 9 Mar 2025 11:21: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=1741519294; cv=none; b=cbkiHsd7zsGms5O4pn5ai/WnFigAJLd0beIIoqGJqhUk+B/penjE6dLdu2b5JGroZjpVdBIV0umlkeSsqW8gU+XD/Oy2i3zsbUwx20v/YSZEQXMVzckzJSYkFMh4BlwyWppJxznLe3WIXS/cvnEtkZVw62ceyDlnY8Jbbw4OXBo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741519294; c=relaxed/simple; bh=olnngvSWzuTw7+jwCrrVTLpt5jpDlljE7E7BTT8hoJU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=adCYl0xPGLCdrICb2kemY/tqKOzSrPBVleFMwlqM3V/LDCQymPSI6hvABAH6QsZ2rV/wWqLTHlCQfILclkiNtnGNjCtXHnEZwWKrikd7ppPmRUzB14aYI7QgRpY3PLUPVRKtL3Dabj2m2vFS7EKH7FO4E7UIkKEZgbrdhQcquXw= 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=uZ+LkaHA; 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="uZ+LkaHA" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:8d8a:5967:d692:ea4e]) by linux1587.grserver.gr (Postfix) with ESMTPSA id D07DD2E0735E; Sun, 9 Mar 2025 13:21:26 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1741519288; bh=sNuKsdasOWIkDosj3z6QbzM+DrhvrIIui0OTrZw4L6c=; h=From:To:Subject; b=uZ+LkaHAcnDWH7cWMkzga8oWBhzJ9aQIzowhUW+/ZJgJ9X8jIsEMONZK2JOYt4WZf 4fgZzEk/OCPQWE7vnJKQ64gvb8hLmFVKaA0QHOL31TSkFQMGZo9yq7sLsSLqjr8Spn pgqZViF3UM2mespYaaF2hS7uq/jArckyM2aCm92I= Authentication-Results: linux1587.grserver.gr; spf=pass (sender IP is 2a05:f6c2:511b:0:8d8a:5967:d692:ea4e) 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 v3 05/12] power: supply: add inhibit-charge-s0 to charge_behaviour Date: Sun, 9 Mar 2025 12:21:06 +0100 Message-ID: <20250309112114.1177361-6-lkml@antheas.dev> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250309112114.1177361-1-lkml@antheas.dev> References: <20250309112114.1177361-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: <174151928809.28899.2267117621414514029@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. 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..b5daf757a559 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 Sun Mar 9 11:21:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antheas Kapenekakis X-Patchwork-Id: 872090 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 545B71CAA9E; Sun, 9 Mar 2025 11:21: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=1741519296; cv=none; b=p2aEd3tVJHIhn1dEkiwhgYpLXDVI+lOKP1TIfxPoitJXPQyEdDAzI5v5y9PMJbStvYtbmH75GTp3gnN+294jIOaBL0gsnS5wWS88sPtGR4D/2a/b9Jsj339X4X8w3Hlka4B6JLCaPeUIn53nab3PWRhjL3aEMRKCtdv9ly31kYw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741519296; c=relaxed/simple; bh=mcDiigB2MLujej3Is1lfFTDzDZDST+7UORn7RokivIg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=O12zv6nvE/AwDgaryGh7goVxoXL+HAuyMdOSxSx4Gr9++5HO3ifrPqsARmK7+GgkM3SMRlIGszd4epVkIbJaBpBrUx7iwIV2CBi6fb5xkxcXDbOhRlFnqtxaxO6bdz2MtqpIrqXj+4MHo4o4Ngz8lQvC+mFIyRNEECd5DHWCrWc= 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=v58cANX8; 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="v58cANX8" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:8d8a:5967:d692:ea4e]) by linux1587.grserver.gr (Postfix) with ESMTPSA id 855092E07C2F; Sun, 9 Mar 2025 13:21:30 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1741519292; bh=Irn9TsitqOq21o2rMAMNr7IvOLb5uG37PT+InEpVZNE=; h=From:To:Subject; b=v58cANX8Keox3+vl4ROEwuMQVkARna6pKJ6QiLYaIDz7n8pFlFUQgpB6gyCIxskbf kunpsFOuRKwpaTsTJ/AliWKrlMeM/br/4zPZISEXY/p0caXTUrkcIWBMH6l6iVcGLC OrjsdVUyVICWJQQ0eQBE7gH6QwjLo/woEF/IpU/M= Authentication-Results: linux1587.grserver.gr; spf=pass (sender IP is 2a05:f6c2:511b:0:8d8a:5967:d692:ea4e) 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 v3 07/12] platform/x86: oxpec: Rename ec group to tt_toggle Date: Sun, 9 Mar 2025 12:21:08 +0100 Message-ID: <20250309112114.1177361-8-lkml@antheas.dev> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250309112114.1177361-1-lkml@antheas.dev> References: <20250309112114.1177361-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: <174151929188.29053.16741927704981455335@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. 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 dd6d333ebcfa..9cb024325da5 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 Sun Mar 9 11:21:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antheas Kapenekakis X-Patchwork-Id: 872089 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 006FE1C5D75; Sun, 9 Mar 2025 11:21:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.138.42.100 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741519299; cv=none; b=LCqcrsNgXoeeiqmXTThdPE1sk8fyWbWHp/f+HKRDp17Bs6gb6uYZ8y7mCevP5JJYNXXSSfRzxO0i76bvtpbQy0C8lMCnfoK4b6emmXvp3xP0gCLfwh7H5voUSBnayqi6nb38RSCVNmYftQanRzwYtbdeK/XaUs7eSCe01+t0Y48= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741519299; c=relaxed/simple; bh=HRzNpBwuxZesHpl1/KHQetdHIX+ptJY8nQELmJtGzns=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rM5ep8gL2CGGlnZmUPa5FIyUWO1hu1f3yYoV+RI9+kg+Y0Mz8FvBPQEIc93zpNaMtCwuCiiW/Dy1P3r2XZhtSzN9xm1I17393k4RlQjGWyaTMONvcTZW80GuJExsoKz6pdnrMXh9YYlP0uiGdrSJqXBqn2hFcc33bZ2G5Swpakw= 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=PHfiK91N; 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="PHfiK91N" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:8d8a:5967:d692:ea4e]) by linux1587.grserver.gr (Postfix) with ESMTPSA id 526002E08B75; Sun, 9 Mar 2025 13:21:34 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1741519295; bh=POA7VWhqEycPS2/GdlwwoLBaXcLFTM22qBH+pDUzEP8=; h=From:To:Subject; b=PHfiK91NZFk7nqNNi5TB3QaC6epplUC1hizwZXHAYMicMARZQ/gIRhCuMqGM2a0OM w1vXfA8dZ6MJoT9fPhqqCLkqyzaB/W1e76hCVT8XMgB4nK9ngdGk+i5RJDttMspdZq cA4xyYom5DrKs35nK0PO+8rTMNs4QoXPmUmlz+Bk= Authentication-Results: linux1587.grserver.gr; spf=pass (sender IP is 2a05:f6c2:511b:0:8d8a:5967:d692:ea4e) 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 v3 09/12] platform/x86: oxpec: Move pwm_enable read to its own function Date: Sun, 9 Mar 2025 12:21:10 +0100 Message-ID: <20250309112114.1177361-10-lkml@antheas.dev> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250309112114.1177361-1-lkml@antheas.dev> References: <20250309112114.1177361-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: <174151929568.29204.15800261879330050141@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. 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 eb7eafebbd37..471444fbd786 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 Sun Mar 9 11:21:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antheas Kapenekakis X-Patchwork-Id: 872088 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 A515C1D86D6; Sun, 9 Mar 2025 11:21:41 +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=1741519303; cv=none; b=kD0srQwXsI+srow5qo7GaXLkJCfMQpHJMNWOs4nkE/u0Sgb67R/o67Xlj6bmNsvwr9eT0BTxEidjK9gmE1Egj/xQpl6syiPElhglZ+XZaqkVWl+ilf6SIrJFfUqA3sk1XPT18b0vNhnW7h6NCBPcG1f7XjrdDS/aHPQ5PFXnkn4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741519303; c=relaxed/simple; bh=rt5VBTfbjPWYxj1nYgo+jnlHegeew8S0gSwhdYG0zt0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dvb4OXnHMg/Zel1Sc+s2Jfi0L/+LvO3gJRT1n7cAVx9bGtbcn9srrzpA7ekHcNy1wN6upl1vFiuwoMET4efqarLfaXsjI0rvzvsJPC7sbSIaNV/GmB2H6LEn3IG/T+Kmt9oT40jSuYNr9J4gzmbdpnUraWRHoJsZYmz2OLict64= 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=PqOqWG3A; 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="PqOqWG3A" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:8d8a:5967:d692:ea4e]) by linux1587.grserver.gr (Postfix) with ESMTPSA id EF8172E03EE5; Sun, 9 Mar 2025 13:21:37 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1741519299; bh=9wQuBC2LyjE+2YvDtG4O5yPdBys406tjyhzXkDBw02k=; h=From:To:Subject; b=PqOqWG3ACbUrkCgtSALJc7FSKKW2w2sbDbQa6cWs9FLLMG7XnEPiOQv11Ziv0gfDY YNti1IIuJJvSQeS/QsYqUMMHEOt8XMGQ805rm/Tw9LGhHbhrkdcfcyGyd7PCZxwgth YOAzb5e06w2Osx75Za98K/eLvAyXCvXYZt6vTVLQ= Authentication-Results: linux1587.grserver.gr; spf=pass (sender IP is 2a05:f6c2:511b:0:8d8a:5967:d692:ea4e) 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 v3 11/12] platform/x86: oxpec: Move fan speed read to separate function Date: Sun, 9 Mar 2025 12:21:12 +0100 Message-ID: <20250309112114.1177361-12-lkml@antheas.dev> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250309112114.1177361-1-lkml@antheas.dev> References: <20250309112114.1177361-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: <174151929932.29327.14836465357093040304@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. 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 7dfd798bec87..a06a7c54aa08 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; }