From patchwork Sat Feb 22 16:18: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: 867612 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 DE41419AD93; Sat, 22 Feb 2025 16:30:09 +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=1740241811; cv=none; b=lbxfkkbvRDWwfs21s3P65B7K/TuwLvZc6A7UNRpYP/sPK5Pjpy3L1Rjs9KWinGPRr/fn8YnlIYISUmBGfcZrj1tn9Z2c1peLVZ0IA+gJ0l0W1KdkRRTo4EiOfXpmOdEpr8/C0iYJgbgYSDzRppLMiX1iOiteK32nb6y/Tl+RmtI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740241811; c=relaxed/simple; bh=5hTvtGWy7U0s0avSlsCImPWbqjzDdIRWYVapgEdtQSQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rTqTROnvYgND06LJAt1twAfBnKV4Yfr5ctRj4bJ/w942iQ36wUTn+jt0w9F6kwUxosHLNBPPxeSQUwEzYr6rXdl/vrlTw53slq/eTK+hGBqUHIqS/QNYsz68IsGZMyks8pGOzeS4T+O91GNGm0t4hL6iGN1FPbe+znZQvio/yVY= 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=Nizy2vvB; 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="Nizy2vvB" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:cbc0:999f:73ad:33bd]) by linux1587.grserver.gr (Postfix) with ESMTPSA id 0D55C2E08C0D; Sat, 22 Feb 2025 18:20:23 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1740241225; bh=GC519y6vbmddG2cXwg0/Xpucd4pYX//7MaXKPNqTN3I=; h=From:To:Subject; b=Nizy2vvBr7RGCj8oElpSCIQX7858snb55MQvZ5gMwU5tnQ0c6C4k25xFjkPtioms6 2BUq3m4tkFWeFhpa0lyz0HZYdL1uT8tXKlTj04sLGFo09zQQ7yKaeeZ7/IcdBKxCi6 rgBBikjRquV8bqa8MCy0py4BUvliWhGmDkjCNNlw= 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: linux-hwmon@vger.kernel.org Cc: linux-doc@vger.kernel.org, linux-pm@vger.kernel.org, platform-driver-x86@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 v2 01/12] hwmon: (oxp-sensors) Distinguish the X1 variants Date: Sat, 22 Feb 2025 17:18:12 +0100 Message-ID: <20250222161824.172511-2-lkml@antheas.dev> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250222161824.172511-1-lkml@antheas.dev> References: <20250222161824.172511-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: <174024122531.13526.12235562537487038666@linux1587.grserver.gr> X-PPP-Vhost: antheas.dev X-Virus-Scanned: clamav-milter 0.103.11 at linux1587.grserver.gr X-Virus-Status: Clean Currently, the oxp-sensors driver fuzzy matches the X1 variants. Luckily, X1 and X1 mini share most hardware features so this works. However, they are completely different product lines, and there is an expectation that OneXPlayer will release more devices in the X1 line that may have differences. Therefore, distinguish the 3 devices that currently exist in the market. These are the OneXPlayer X1 AMD and Intel variants, and the X1 mini which only has an AMD variant. As far as registers go, all three support the current driver functionality. Signed-off-by: Antheas Kapenekakis --- drivers/hwmon/oxp-sensors.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/drivers/hwmon/oxp-sensors.c b/drivers/hwmon/oxp-sensors.c index 83730d931824..5a4230ad3757 100644 --- a/drivers/hwmon/oxp-sensors.c +++ b/drivers/hwmon/oxp-sensors.c @@ -205,7 +205,28 @@ static const struct dmi_system_id dmi_table[] = { { .matches = { DMI_MATCH(DMI_BOARD_VENDOR, "ONE-NETBOOK"), - DMI_MATCH(DMI_BOARD_NAME, "ONEXPLAYER X1"), + DMI_EXACT_MATCH(DMI_BOARD_NAME, "ONEXPLAYER X1 A"), + }, + .driver_data = (void *)oxp_x1, + }, + { + .matches = { + DMI_MATCH(DMI_BOARD_VENDOR, "ONE-NETBOOK"), + DMI_EXACT_MATCH(DMI_BOARD_NAME, "ONEXPLAYER X1 i"), + }, + .driver_data = (void *)oxp_x1, + }, + { + .matches = { + DMI_MATCH(DMI_BOARD_VENDOR, "ONE-NETBOOK"), + DMI_EXACT_MATCH(DMI_BOARD_NAME, "ONEXPLAYER X1 mini"), + }, + .driver_data = (void *)oxp_x1, + }, + { + .matches = { + DMI_MATCH(DMI_BOARD_VENDOR, "ONE-NETBOOK"), + DMI_EXACT_MATCH(DMI_BOARD_NAME, "ONEXPLAYER X1Pro"), }, .driver_data = (void *)oxp_x1, }, From patchwork Sat Feb 22 16:18:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antheas Kapenekakis X-Patchwork-Id: 867611 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 DE3CA18A6A7; Sat, 22 Feb 2025 16:30:09 +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=1740241811; cv=none; b=CyuKTCEn4ZBkANo4TWee4RlFoj3P6dgA/7Ra8wW8xSujOxWTU3jvKu/BZZ2aV8mVR+HYVuUGg/SoBob6Z1qshnsd0+Cm33GVbL9KVvGAp/vlkPDSUlCTAFeVilgTbbT/PIvJiyY0+vrEOY/1x+zqPjBLUH2Slh+pdsfIoeg9ZzY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740241811; c=relaxed/simple; bh=ptD+E28yWj/4kpUnWw3yg8/4hW05MT59Bca0OrS2HaE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=R+5P2KTmF8h9HUFPE7aesRjdji1M1yR3UiNw8yymo+jiogenzCQC2WaqhKfjUb0Lr9kqXILynbZBCo7OCPCdYJU5xDoQVg74i7OmzijndaXzPXI33FQxRLq+6vKU3wzUAjf2sHXDnMsBeK56J1Q/yovc4hSA0v5jdisRG3SLMYU= 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=rTALcMsd; 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="rTALcMsd" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:cbc0:999f:73ad:33bd]) by linux1587.grserver.gr (Postfix) with ESMTPSA id 85F952E08C35; Sat, 22 Feb 2025 18:20:29 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1740241231; bh=EM2Lq7Ny3PABwKeH6JzcQJhmqKCDaXceVQTUoGmPIOI=; h=From:To:Subject; b=rTALcMsdImVr9GmkzhQjr1XLEtS3MbGkF7Rvcg4YVP3KmwdQU2VXFBA9oyeqKv6RH WqPsxrxee0hhWZ8zuekpQ0pXqoZAn/Jhe8Ak/AZE8fZqGwtga0cMwDADbmy6RxZA21 7MbzajVZEbFTLSm3HldcUmtG9nubE41kwBkpGiIw= 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: linux-hwmon@vger.kernel.org Cc: linux-doc@vger.kernel.org, linux-pm@vger.kernel.org, platform-driver-x86@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 v2 04/12] hwmon: (oxp-sensors) Add charge threshold and bypass to OneXPlayer Date: Sat, 22 Feb 2025 17:18:15 +0100 Message-ID: <20250222161824.172511-5-lkml@antheas.dev> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250222161824.172511-1-lkml@antheas.dev> References: <20250222161824.172511-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: <174024123077.13752.16639534968203733499@linux1587.grserver.gr> X-PPP-Vhost: antheas.dev X-Virus-Scanned: clamav-milter 0.103.11 at linux1587.grserver.gr X-Virus-Status: Clean With the X1 (AMD), OneXPlayer added a charge limit and charge bypass to their devices. Charge limit allows for choosing an arbitrary battery charge setpoint in percentages. Charge bypass allows to instruct the device to stop charging either when its on or always. This feature was then extended for the F1Pro as well. OneXPlayer also released BIOS updates for the X1 Mini, X1 (Intel), and F1 devices that add support for this feature. Therefore, enable it for all F1 and X1 devices. Add both of these under the standard sysfs battery endpoints for them, by looking for the battery. OneXPlayer devices have a single battery. Signed-off-by: Antheas Kapenekakis --- drivers/hwmon/oxp-sensors.c | 206 ++++++++++++++++++++++++++++++++++++ 1 file changed, 206 insertions(+) diff --git a/drivers/hwmon/oxp-sensors.c b/drivers/hwmon/oxp-sensors.c index f7a64fbc8f33..f8ffc78deedd 100644 --- a/drivers/hwmon/oxp-sensors.c +++ b/drivers/hwmon/oxp-sensors.c @@ -26,6 +26,7 @@ #include #include #include +#include /* Handle ACPI lock mechanism */ static u32 oxp_mutex; @@ -89,6 +90,35 @@ static enum oxp_board board; #define OXP_TURBO_RETURN_VAL 0x00 /* Common return val */ +#define OXP_X1_CHARGE_LIMIT_REG 0xA3 /* X1 charge limit (%) */ +#define OXP_X1_CHARGE_BYPASS_REG 0xA4 /* X1 bypass charging */ + +#define OXP_X1_CHARGE_BYPASS_MASK_S0 0x01 +/* + * Cannot control S3, S5 individually. + * X1 Mask is 0x0A, OneXFly F1Pro is just 0x02 + * but the extra bit on the X1 does nothing. + */ +#define OXP_X1_CHARGE_BYPASS_MASK_S3S5 0x02 + +enum charge_type_value_index { + CT_OFF, + CT_S0, + CT_S5, +}; + +static u8 charge_type_values_x1[] = { + [CT_OFF] = 0x00, + [CT_S0] = OXP_X1_CHARGE_BYPASS_MASK_S0, + [CT_S5] = OXP_X1_CHARGE_BYPASS_MASK_S0 | OXP_X1_CHARGE_BYPASS_MASK_S3S5, +}; + +static const char * const charge_type_strings[] = { + [CT_OFF] = "Standard", + [CT_S0] = "BypassS0", + [CT_S5] = "Bypass", +}; + static const struct dmi_system_id dmi_table[] = { { .matches = { @@ -436,6 +466,177 @@ static ssize_t tt_toggle_show(struct device *dev, static DEVICE_ATTR_RW(tt_toggle); +/* Callbacks for turbo toggle attribute */ +static bool charge_control_supported(void) +{ + switch (board) { + case oxp_x1: + case oxp_fly: + return 1; + default: + break; + } + return 0; +} + +static ssize_t charge_type_store(struct device *dev, + struct device_attribute *attr, const char *buf, + size_t count) +{ + u64 val, reg; + int ret; + + ret = __sysfs_match_string(charge_type_strings, + ARRAY_SIZE(charge_type_strings), buf); + if (ret < 0) + return ret; + + switch (board) { + case oxp_x1: + case oxp_fly: + val = charge_type_values_x1[ret]; + reg = OXP_X1_CHARGE_BYPASS_REG; + break; + default: + return -EINVAL; + } + + ret = write_to_ec(reg, val); + if (ret < 0) + return ret; + + return count; +} + +static ssize_t charge_type_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + int ret; + u8 reg; + long val; + const u8 *vals; + char *str; + + switch (board) { + case oxp_x1: + case oxp_fly: + vals = charge_type_values_x1; + reg = OXP_X1_CHARGE_BYPASS_REG; + break; + default: + return -EINVAL; + } + + ret = read_from_ec(reg, 1, &val); + if (ret < 0) + return ret; + + str = (char *) charge_type_strings[0]; + for (ret = 0; ret < ARRAY_SIZE(charge_type_strings); ret++) { + if (val == vals[ret]) { + str = (char *) charge_type_strings[ret]; + break; + } + } + + return sysfs_emit(buf, "%s\n", str); +} + +static DEVICE_ATTR_RW(charge_type); + +static ssize_t charge_control_end_threshold_store(struct device *dev, + struct device_attribute *attr, const char *buf, + size_t count) +{ + u64 val, reg; + int ret; + + ret = kstrtou64(buf, 10, &val); + if (ret < 0) + return ret; + + if (val > 100) + return -EINVAL; + + switch (board) { + case oxp_x1: + case oxp_fly: + reg = OXP_X1_CHARGE_LIMIT_REG; + break; + default: + return -EINVAL; + } + + ret = write_to_ec(reg, val); + if (ret < 0) + return ret; + + return count; +} + +static ssize_t charge_control_end_threshold_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + int ret; + u8 reg; + long val; + + switch (board) { + case oxp_x1: + case oxp_fly: + reg = OXP_X1_CHARGE_LIMIT_REG; + break; + default: + return -EINVAL; + } + + ret = read_from_ec(reg, 1, &val); + if (ret < 0) + return ret; + + return sysfs_emit(buf, "%ld\n", val); +} + +static DEVICE_ATTR_RW(charge_control_end_threshold); + +static int oxp_battery_add(struct power_supply *battery, struct acpi_battery_hook *hook) +{ + /* OneXPlayer devices only have one battery. */ + if (strcmp(battery->desc->name, "BAT0") != 0 && + strcmp(battery->desc->name, "BAT1") != 0 && + strcmp(battery->desc->name, "BATC") != 0 && + strcmp(battery->desc->name, "BATT") != 0) + return -ENODEV; + + if (device_create_file(&battery->dev, + &dev_attr_charge_control_end_threshold)) + return -ENODEV; + + if (device_create_file(&battery->dev, + &dev_attr_charge_type)) { + device_remove_file(&battery->dev, + &dev_attr_charge_control_end_threshold); + return -ENODEV; + } + + return 0; +} + +static int oxp_battery_remove(struct power_supply *battery, struct acpi_battery_hook *hook) +{ + device_remove_file(&battery->dev, + &dev_attr_charge_control_end_threshold); + device_remove_file(&battery->dev, + &dev_attr_charge_type); + return 0; +} + +static struct acpi_battery_hook battery_hook = { + .add_battery = oxp_battery_add, + .remove_battery = oxp_battery_remove, + .name = "OneXPlayer Battery", +}; + /* PWM enable/disable functions */ static int oxp_pwm_enable(void) { @@ -753,6 +954,9 @@ static int __init oxp_platform_init(void) platform_create_bundle(&oxp_platform_driver, oxp_platform_probe, NULL, 0, NULL, 0); + if (charge_control_supported()) + battery_hook_register(&battery_hook); + return PTR_ERR_OR_ZERO(oxp_platform_device); } @@ -760,6 +964,8 @@ static void __exit oxp_platform_exit(void) { platform_device_unregister(oxp_platform_device); platform_driver_unregister(&oxp_platform_driver); + if (charge_control_supported()) + battery_hook_unregister(&battery_hook); } MODULE_DEVICE_TABLE(dmi, dmi_table); From patchwork Sat Feb 22 16:18:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antheas Kapenekakis X-Patchwork-Id: 867616 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 DC21F190468; Sat, 22 Feb 2025 16:20:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.138.42.100 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740241240; cv=none; b=sum1qatdsmHI6QkKBK7/Vtq9wzht4QzsItXxIhHc7kgDaB62dk1a1+djyXMqBvTDur8ayOPsphXVSxJA0n7Fu4ubmAjqLwoLNSuvkQWprfrXbzcA3VdGhfKw98zi1zotleP4NG2mzP29NBVB9ckPeLu4AqWhIJBsgrWBkraLtt8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740241240; c=relaxed/simple; bh=u42XE/bZRm00F2EsLFDQKgKk9ogxHYpt4wTubHuLkn4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CGtpI+ITITBjoMiJKKR7sZHLhG8PZ0Aj03r7puCqsgP6JEsQlmisJqNPKvSXRdkXypYJ7RNgs//yGj1E0bZ+2S1oaXx3e2BfwFHdqGaFw3UhTDoruvoTQARzOnkD+cronP6xU4URnyEtVAfh2Cv4jKXk1FSj2i2k+jYjCafBg14= 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=RLUv/CbM; 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="RLUv/CbM" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:cbc0:999f:73ad:33bd]) by linux1587.grserver.gr (Postfix) with ESMTPSA id 0C38B2E08C3D; Sat, 22 Feb 2025 18:20:32 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1740241234; bh=KeMqyBaVWbZx61DnT63Z+1iDimz2+bstoLs9ZuwiSr4=; h=From:To:Subject; b=RLUv/CbM9F60lpCFV4ArA3/wEmO1DPE/RqMrAKc5bWkKIhci8tEUtC8UbfUYhHRUU gTqVUKaY0S8LJ/a67RqZRo9kFqnp8MxsSl8L8eOgj1VmhEUO0KhXmzcNYo9JCJUUc7 krXSEmcEyKOKhcA2CtmW6KCTNmn/xZj5jlZ0YTiA= 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: linux-hwmon@vger.kernel.org Cc: linux-doc@vger.kernel.org, linux-pm@vger.kernel.org, platform-driver-x86@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 v2 06/12] hwmon: (oxp-sensors) Add turbo led support to X1 devices Date: Sat, 22 Feb 2025 17:18:17 +0100 Message-ID: <20250222161824.172511-7-lkml@antheas.dev> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250222161824.172511-1-lkml@antheas.dev> References: <20250222161824.172511-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: <174024123436.13877.15976266649933873000@linux1587.grserver.gr> X-PPP-Vhost: antheas.dev X-Virus-Scanned: clamav-milter 0.103.11 at linux1587.grserver.gr X-Virus-Status: Clean The X1 and X1 mini lineups feature an LED nested within their turbo button. When turbo takeover is not enabled, the turbo button allows the device to switch from 18W to 25W TDP. When the device is in the 25W TDP mode, the LED is turned on. However, when we engage turbo takeover, the turbo led remains on its last state, which might be illuminated and cannot be currently controlled. Therefore, add the register that controls it under sysfs, to allow userspace to turn it off once engaging turbo takeover and then control it as they wish. As part of researching this topic, I verified that other OneXPlayer devices do not have a turbo led, which makes this feature only applicable to X1 and X1 mini devices. Signed-off-by: Antheas Kapenekakis --- drivers/hwmon/oxp-sensors.c | 84 +++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/drivers/hwmon/oxp-sensors.c b/drivers/hwmon/oxp-sensors.c index 1c01636582d7..9c43ec0fc994 100644 --- a/drivers/hwmon/oxp-sensors.c +++ b/drivers/hwmon/oxp-sensors.c @@ -101,6 +101,12 @@ static enum oxp_board board; */ #define OXP_X1_CHARGE_BYPASS_MASK_S3S5 0x02 +/* X1 Turbo LED */ +#define OXP_X1_TURBO_LED_REG 0x57 + +#define OXP_X1_TURBO_LED_OFF 0x01 +#define OXP_X1_TURBO_LED_ON 0x02 + enum charge_type_value_index { CT_OFF, CT_S0, @@ -466,6 +472,73 @@ static ssize_t tt_toggle_show(struct device *dev, static DEVICE_ATTR_RW(tt_toggle); +/* Callbacks for turbo toggle 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; + int rval; + bool value; + + rval = kstrtobool(buf, &value); + if (rval) + return rval; + + switch (board) { + case oxp_x1: + reg = OXP_X1_TURBO_LED_REG; + val = value ? OXP_X1_TURBO_LED_ON : OXP_X1_TURBO_LED_OFF; + break; + default: + return -EINVAL; + } + rval = write_to_ec(reg, val); + + if (rval) + return rval; + + return count; +} + +static ssize_t tt_led_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + int retval; + u8 reg; + long enval; + long val; + + switch (board) { + case oxp_x1: + reg = OXP_2_TURBO_SWITCH_REG; + enval = OXP_X1_TURBO_LED_ON; + break; + default: + return -EINVAL; + } + + retval = read_from_ec(reg, 1, &val); + if (retval) + return retval; + + return sysfs_emit(buf, "%d\n", val == enval); +} + +static DEVICE_ATTR_RW(tt_led); + /* Callbacks for turbo toggle attribute */ static bool charge_control_supported(void) { @@ -894,8 +967,19 @@ static struct attribute_group oxp_tt_toggle_attribute_group = { .attrs = oxp_tt_toggle_attrs, }; +static struct attribute *oxp_tt_led_attrs[] = { + &dev_attr_tt_led.attr, + NULL +}; + +static struct attribute_group oxp_tt_led_attribute_group = { + .is_visible = tt_led_is_visible, + .attrs = oxp_tt_led_attrs, +}; + static const struct attribute_group *oxp_ec_groups[] = { &oxp_tt_toggle_attribute_group, + &oxp_tt_led_attribute_group, NULL }; From patchwork Sat Feb 22 16:18:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antheas Kapenekakis X-Patchwork-Id: 867615 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 B80501FCD03; Sat, 22 Feb 2025 16:20:40 +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=1740241243; cv=none; b=khAcE6RJ1g1isljqm9fv/R4KRFy1EHXnFi98HVoirfSb7rFBVh3WPxfXJl6yT2qDEg/0ZffCe8oU5ZkKCiFzU2610Ugsif/0LStECQgOzqMbQgAyMo5VCkRumsbTNv6I/8ocSJLKc5pbWlPponFtVL6nnvCTPMxT5dVC25V1ly0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740241243; c=relaxed/simple; bh=212vuWDMZNF1i8vBLykZIC7XgELO4WQi1/b9dWVCp/w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jZ+Y/sbyoE66q3vAWHgsq79VrJqDKU5UlhCoTo1Jtd4nqSWKx3fcVJdXV+rmNNEMcx4P9aDRYesI7eE2Lt5l50gIR0etH96Lu2juoXTgrv+Pmj0k9TidjMYpfkvjIeVh30IHQMxWatoHoZOlBsZ0i+pjW4aFiGklp1uWGypzfbo= 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=JaDMr1Mz; 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="JaDMr1Mz" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:cbc0:999f:73ad:33bd]) by linux1587.grserver.gr (Postfix) with ESMTPSA id B57742E08C39; Sat, 22 Feb 2025 18:20:36 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1740241238; bh=QgpDmK/aeZQymj1q5kxd00CT/+YJkKw8DCalRboAXRQ=; h=From:To:Subject; b=JaDMr1MzFsV5QDiFuatrd5k52KsHkyLk1jEKj5h2+9KUkDdYBCK6nJmsmBHyHIuMc /ll95D5GGxT29c4fc5QByWrIoW1eVAZbhZBbCC5tRL0M9wXs4bnjC2UVIkzxvsYfT8 cV/u0Jse5ZK2vqYXj4JFnFZuVeIb+QZ7WEya/808= 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: linux-hwmon@vger.kernel.org Cc: linux-doc@vger.kernel.org, linux-pm@vger.kernel.org, platform-driver-x86@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 v2 08/12] hwmon: (oxp-sensors) Move pwm value read/write to separate functions Date: Sat, 22 Feb 2025 17:18:19 +0100 Message-ID: <20250222161824.172511-9-lkml@antheas.dev> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250222161824.172511-1-lkml@antheas.dev> References: <20250222161824.172511-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: <174024123796.14012.17454977986390059471@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 sysfs 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. Signed-off-by: Antheas Kapenekakis --- drivers/hwmon/oxp-sensors.c | 162 +++++++++++++++++++----------------- 1 file changed, 87 insertions(+), 75 deletions(-) diff --git a/drivers/hwmon/oxp-sensors.c b/drivers/hwmon/oxp-sensors.c index 1da1e1655f96..dade2f76124e 100644 --- a/drivers/hwmon/oxp-sensors.c +++ b/drivers/hwmon/oxp-sensors.c @@ -802,6 +802,91 @@ static umode_t oxp_ec_hwmon_is_visible(const void *drvdata, } } +/* PWM input read/write functions */ +static int oxp_pwm_input_write(long val) +{ + if (val < 0 || val > 255) + return -EINVAL; + switch (board) { + case orange_pi_neo: + /* scale to range [1-244] */ + val = ((val - 1) * 243 / 254) + 1; + return write_to_ec(ORANGEPI_SENSOR_PWM_REG, val); + case oxp_2: + case oxp_x1: + /* scale to range [0-184] */ + val = (val * 184) / 255; + return write_to_ec(OXP_SENSOR_PWM_REG, val); + case aya_neo_2: + case aya_neo_air: + case aya_neo_air_1s: + case aya_neo_air_plus_mendo: + case aya_neo_air_pro: + case aya_neo_flip: + case aya_neo_geek: + case aya_neo_kun: + case oxp_mini_amd: + case oxp_mini_amd_a07: + /* scale to range [0-100] */ + val = (val * 100) / 255; + return write_to_ec(OXP_SENSOR_PWM_REG, val); + case aok_zoe_a1: + case oxp_fly: + case oxp_mini_amd_pro: + return write_to_ec(OXP_SENSOR_PWM_REG, val); + default: + return -EOPNOTSUPP; + } +} + +static int oxp_pwm_input_read(long *val) +{ + int ret; + + switch (board) { + case orange_pi_neo: + ret = read_from_ec(ORANGEPI_SENSOR_PWM_REG, 1, val); + if (ret) + return ret; + /* scale from range [1-244] */ + *val = ((*val - 1) * 254 / 243) + 1; + break; + case oxp_2: + case oxp_x1: + ret = read_from_ec(OXP_SENSOR_PWM_REG, 1, val); + if (ret) + return ret; + /* scale from range [0-184] */ + *val = (*val * 255) / 184; + break; + case aya_neo_2: + case aya_neo_air: + case aya_neo_air_1s: + case aya_neo_air_plus_mendo: + case aya_neo_air_pro: + case aya_neo_flip: + case aya_neo_geek: + case aya_neo_kun: + case oxp_mini_amd: + case oxp_mini_amd_a07: + ret = read_from_ec(OXP_SENSOR_PWM_REG, 1, val); + if (ret) + return ret; + /* scale from range [0-100] */ + *val = (*val * 255) / 100; + break; + case aok_zoe_a1: + case oxp_fly: + case oxp_mini_amd_pro: + default: + ret = read_from_ec(OXP_SENSOR_PWM_REG, 1, val); + if (ret) + return ret; + break; + } + return 0; +} + static int oxp_platform_read(struct device *dev, enum hwmon_sensor_types type, u32 attr, int channel, long *val) { @@ -842,48 +927,7 @@ static int oxp_platform_read(struct device *dev, enum hwmon_sensor_types type, case hwmon_pwm: switch (attr) { case hwmon_pwm_input: - switch (board) { - case orange_pi_neo: - ret = read_from_ec(ORANGEPI_SENSOR_PWM_REG, 1, val); - if (ret) - return ret; - /* scale from range [1-244] */ - *val = ((*val - 1) * 254 / 243) + 1; - break; - case oxp_2: - case oxp_x1: - ret = read_from_ec(OXP_SENSOR_PWM_REG, 1, val); - if (ret) - return ret; - /* scale from range [0-184] */ - *val = (*val * 255) / 184; - break; - case aya_neo_2: - case aya_neo_air: - case aya_neo_air_1s: - case aya_neo_air_plus_mendo: - case aya_neo_air_pro: - case aya_neo_flip: - case aya_neo_geek: - case aya_neo_kun: - case oxp_mini_amd: - case oxp_mini_amd_a07: - ret = read_from_ec(OXP_SENSOR_PWM_REG, 1, val); - if (ret) - return ret; - /* scale from range [0-100] */ - *val = (*val * 255) / 100; - break; - case aok_zoe_a1: - case oxp_fly: - case oxp_mini_amd_pro: - default: - ret = read_from_ec(OXP_SENSOR_PWM_REG, 1, val); - if (ret) - return ret; - break; - } - return 0; + return oxp_pwm_input_read(val); case hwmon_pwm_enable: return oxp_pwm_read(val); default: @@ -909,39 +953,7 @@ static int oxp_platform_write(struct device *dev, enum hwmon_sensor_types type, return oxp_pwm_disable(); return -EINVAL; case hwmon_pwm_input: - if (val < 0 || val > 255) - return -EINVAL; - switch (board) { - case orange_pi_neo: - /* scale to range [1-244] */ - val = ((val - 1) * 243 / 254) + 1; - return write_to_ec(ORANGEPI_SENSOR_PWM_REG, val); - case oxp_2: - case oxp_x1: - /* scale to range [0-184] */ - val = (val * 184) / 255; - return write_to_ec(OXP_SENSOR_PWM_REG, val); - case aya_neo_2: - case aya_neo_air: - case aya_neo_air_1s: - case aya_neo_air_plus_mendo: - case aya_neo_air_pro: - case aya_neo_flip: - case aya_neo_geek: - case aya_neo_kun: - case oxp_mini_amd: - case oxp_mini_amd_a07: - /* scale to range [0-100] */ - val = (val * 100) / 255; - return write_to_ec(OXP_SENSOR_PWM_REG, val); - case aok_zoe_a1: - case oxp_fly: - case oxp_mini_amd_pro: - return write_to_ec(OXP_SENSOR_PWM_REG, val); - default: - break; - } - break; + return oxp_pwm_input_write(val); default: break; } From patchwork Sat Feb 22 16:18:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antheas Kapenekakis X-Patchwork-Id: 867614 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 B1875190468; Sat, 22 Feb 2025 16:20:43 +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=1740241245; cv=none; b=o/u2BZp7EY0sFFTgR+0f94EER42lzEiqpj4kekeXZd9q/c7fFs1RrFy3VLXO6kdd1UyI8mOWBNvWpEDEhKk+xCOH0WpObef3yUtiMOp6xYCzuJUe+CBgFsBmcLQu/sFOrIqGj8wUhV80bXFe88V9lFwBoecs+xFvNIywT0TAsGk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740241245; c=relaxed/simple; bh=phktHrVXrx6MvbhfYiZZQixFSku3T/sXEsrolwVxvII=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=miRzQk/hVvUGOeLYzLeIr8sFW12VpjuZlee1NZAcr22Tmct/LLQK+bgJBhOmO/oB3Dc2u5sM93CA0EtQ4kbPRrM4rIuMqJkfGyJyTxZoT2wqO6CanvXLC2eL+ct61onVA18UArYh3eW247K9Uu9OkTmJkUbx/utU9zpz9Ec1F5Q= 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=uvb3mLXS; 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="uvb3mLXS" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:cbc0:999f:73ad:33bd]) by linux1587.grserver.gr (Postfix) with ESMTPSA id 66D852E08C34; Sat, 22 Feb 2025 18:20:40 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1740241241; bh=fSj7m78Bdzzrg+IS9nOgqLmd78dOzf2n/LG8zeTOh3c=; h=From:To:Subject; b=uvb3mLXSpAoNmo8b/MvTkxpEQnGs9Q9ahHNIVC/Z0e5djSmDpGwTmQ4X7Mzr65Xeu RltYOSTKGaLjUapocP1Qea175DHkFdmjFt+2Sg7wczfm3eQQkertkspvipTx9GFfUh BbAyBN5NXGgwD0zCczHqHYHODVGkvMLuq4JeT1rA= 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: linux-hwmon@vger.kernel.org Cc: linux-doc@vger.kernel.org, linux-pm@vger.kernel.org, platform-driver-x86@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 v2 10/12] hwmon: (oxp-sensors) Adhere to sysfs-class-hwmon and enable pwm on 2 Date: Sat, 22 Feb 2025 17:18:21 +0100 Message-ID: <20250222161824.172511-11-lkml@antheas.dev> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250222161824.172511-1-lkml@antheas.dev> References: <20250222161824.172511-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: <174024124164.14122.6389862011996770598@linux1587.grserver.gr> X-PPP-Vhost: antheas.dev X-Virus-Scanned: clamav-milter 0.103.11 at linux1587.grserver.gr X-Virus-Status: Clean Currently, the driver does not adhere to the sysfs-class-hwmon specification: 0 is used for auto fan control and 1 is used for manual control. However, it is expected that 0 sets the fan to full speed, 1 sets the fan to manual, and then 2 is used for automatic control. Therefore, change the sysfs API to reflect this and enable pwm on 2. As we are breaking the ABI for this driver, rename oxpec to oxp_ec, reflecting the naming convention used by other drivers, to allow for a smooth migration in current userspace programs. Signed-off-by: Antheas Kapenekakis --- drivers/hwmon/oxp-sensors.c | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/drivers/hwmon/oxp-sensors.c b/drivers/hwmon/oxp-sensors.c index a9332312b2b1..b5ba863a762a 100644 --- a/drivers/hwmon/oxp-sensors.c +++ b/drivers/hwmon/oxp-sensors.c @@ -934,7 +934,27 @@ static int oxp_platform_read(struct device *dev, enum hwmon_sensor_types type, case hwmon_pwm_input: return oxp_pwm_input_read(val); case hwmon_pwm_enable: - return oxp_pwm_read(val); + ret = oxp_pwm_read(val); + if (ret) + return ret; + + /* Check for auto and return 2 */ + if (!*val) { + *val = 2; + return 0; + } + + /* Return 0 if at full fan speed, 1 otherwise */ + ret = oxp_pwm_fan_speed(val); + if (ret) + return ret; + + if (*val == 255) + *val = 0; + else + *val = 1; + + return 0; default: break; } @@ -948,15 +968,24 @@ static int oxp_platform_read(struct device *dev, enum hwmon_sensor_types type, static int oxp_platform_write(struct device *dev, enum hwmon_sensor_types type, u32 attr, int channel, long val) { + int ret; + switch (type) { case hwmon_pwm: switch (attr) { case hwmon_pwm_enable: if (val == 1) return oxp_pwm_enable(); - else if (val == 0) + else if (val == 2) return oxp_pwm_disable(); - return -EINVAL; + else if (val != 0) + return -EINVAL; + + /* Enable PWM and set to max speed */ + ret = oxp_pwm_enable(); + if (ret) + return ret; + return oxp_pwm_input_write(255); case hwmon_pwm_input: return oxp_pwm_input_write(val); default: @@ -1021,7 +1050,7 @@ static int oxp_platform_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct device *hwdev; - hwdev = devm_hwmon_device_register_with_info(dev, "oxpec", NULL, + hwdev = devm_hwmon_device_register_with_info(dev, "oxp_ec", NULL, &oxp_ec_chip_info, NULL); return PTR_ERR_OR_ZERO(hwdev); From patchwork Sat Feb 22 16:18:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Antheas Kapenekakis X-Patchwork-Id: 867613 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 9EA1E11CAF; Sat, 22 Feb 2025 16:20:47 +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=1740241250; cv=none; b=o9d1yBbsxN+iD+UJcVLgAnKHJETClVxZsqqbAQK8TKXtVKpzehxeemp5wtDSMM7UQcAytjr7Fz3D9pY6v6Bfo1vXbJhrP0RBKqm7l02Wu1/ALRaRD5MsSPAQg7LJbetX4uFCSwBROT5MPmdj2ozs+w/qWDUs2C5C2W26fxcyYhU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740241250; c=relaxed/simple; bh=hwbg85IHRmzac4MOiU1b/r7yBMLHOMIeHyC8YX0maYM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=AtuEEKgabALnJ1bSZwqTNvqzzUbaDI6iBV3pgHczGWvD6ONXcd3eOBZh1syRMcSZTs1XJpcfYa5k1Ncq0k40212ItGWCzHdHEvI/53IVREtt7j19Ua8JE73I5CNCeQr0QZwZyj+2A9X2TIj+lVcMge78Uu2QQ3Z3L6FwSvOuvxU= 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=Z2iMBkm4; 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="Z2iMBkm4" Received: from localhost.localdomain (unknown [IPv6:2a05:f6c2:511b:0:cbc0:999f:73ad:33bd]) by linux1587.grserver.gr (Postfix) with ESMTPSA id 017EC2E08C42; Sat, 22 Feb 2025 18:20:43 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antheas.dev; s=default; t=1740241245; bh=EbAW66MOShp+FMmH6+3P02El1Ie30xboAe3WC3/AJMs=; h=From:To:Subject; b=Z2iMBkm4D3sX4nV9jyjTipPoy8WaHiposRA8lSTIPECUQgdDLTC5zTtXqpC3craDD CFesGlhg1usS/tazBDrwYBeQJuq9pe/te5NDdmtd2IQ6oRRtAHAmn/3zfJWT+akRzf pjkOpWA9XeLAtncNBKqX8tuyZYbn3pR/ILfuzjdM= 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: linux-hwmon@vger.kernel.org Cc: linux-doc@vger.kernel.org, linux-pm@vger.kernel.org, platform-driver-x86@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 v2 12/12] ABI: testing: add tt_toggle and tt_led entries Date: Sat, 22 Feb 2025 17:18:23 +0100 Message-ID: <20250222161824.172511-13-lkml@antheas.dev> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250222161824.172511-1-lkml@antheas.dev> References: <20250222161824.172511-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: <174024124534.14264.15912875553873316250@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