Skip to contentSkip to conversation

Add Ayn EC Platform Driver

PATCH Superseded Derek J. Clark 2 participants 6 messages Jul 26, 2025

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover Add Ayn EC Platform Driver

Adds platform driver for Ayn Loki and Tactoy Zeenix handheld devices. Tactoy devices are rebranded Ayn devices with minor modifications to the DMI. The device EC has multiple features implemented by this driver, including a PWN fan with manual and EC controlled automatic modes as well as a user deviced fan curve mode, temperature sensors, and chassis RGB control.

This driver implements PWN fan and temperature control via a hwmon interface, and an RGB chassis interface via a multicolor LED class device. I attempted to break the driver up into four logical patches. Patch 1 adds PWM fan control via a hwmon interface. Patch 2 expands the hwmon interface by adding the temperature sensors. Patch 3 adds the chassis RGB interface through the leds subsystem. Patch 4 adds ABI documentation for the sysfs entries that aren't provided by the standard interfaces, but are needed to fully control the device.

---
v2:
- Fix nits from Alok Tiwari.
v1:
https://lore.kernel.org/platform-driver-x86/[email protected]/T/#mb795b8f5e5ff3c5b88fdd62bd6c97eab404fbc4e
Derek J. Clark (4):
platform/x86: (ayn-ec) Add PWM Fan HWMON Interface platform/x86: (ayn-ec) Add Temperature Sensors platform/x86: (ayn-ec) Add RGB Interface platform/x86: (ayn-ec) Add Ayn EC Platform Documentation

 .../ABI/testing/sysfs-platform-ayn-ec         |  59 ++
 MAINTAINERS                                   |   7 +
 drivers/platform/x86/Kconfig                  |  14 +
 drivers/platform/x86/Makefile                 |   3 +
 drivers/platform/x86/ayn-ec.c                 | 965 ++++++++++++++++++
 5 files changed, 1048 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-platform-ayn-ec
 create mode 100644 drivers/platform/x86/ayn-ec.c
Signature · 1 line
2.50.1
#1 lore raw

PATCH v2 1/4 platform/x86: (ayn-ec) Add PWM Fan HWMON Interface

Adds platform driver for Ayn Loki and Tactoy Zeenix lines of handheld devices. This patch implements a hwmon interface for EC provided manual PWM fan control and user defined fan curves. A global ACPI lock is used when reading or writing from the EC.

There are 4 fan modes implemented in this patch. Modes 0-3 act in accordance with the standard hwmon logic where 0 is 100% fan speed, 1 is manual control, and 2 is automatic control. As the EC only provides 3 modes by default, mode 0 is implemented by setting the device to manual and then setting fan speed to 100% directly. In mode 1 the PWM duty cycle is set in sysfs with values [0-255], which are then scaled to the EC max of 128. Mode 4 is an automatic mode where the fan curve is user defined. There are 5 total set points and each set point takes a temperature in Celsius [0-100] and a PWM duty cycle [0-255]. When the CPU temperature reaches a given set point, the corresponding duty cycle is automatically set by the EC.

---
 MAINTAINERS                   |   6 +
 drivers/platform/x86/Kconfig  |  14 +
 drivers/platform/x86/Makefile |   3 +
 drivers/platform/x86/ayn-ec.c | 595 ++++++++++++++++++++++++++++++++++
 4 files changed, 618 insertions(+)
 create mode 100644 drivers/platform/x86/ayn-ec.c
MAINTAINERS +6 -0
index d61b004005fd..5b816883fe7d 100644
@@ -4035,6 +4035,12 @@ W:	https://ez.analog.com/linux-software-drivers
 F:	Documentation/devicetree/bindings/pwm/adi,axi-pwmgen.yaml
 F:	drivers/pwm/pwm-axi-pwmgen.c
 
+AYN PLATFORM EC DRIVER
+M:	Derek J. Clark <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	drivers/platform/x86/ayn-ec.c
+
 AZ6007 DVB DRIVER
 M:	Mauro Carvalho Chehab <[email protected]>
 L:	[email protected]
drivers/platform/x86/Kconfig +14 -0
index 6d238e120dce..61391be65a7b 100644
@@ -304,6 +304,20 @@ config ASUS_TF103C_DOCK
 	  If you have an Asus TF103C tablet say Y or M here, for a generic x86
 	  distro config say M here.
 
+config AYN_EC
+	tristate "Ayn x86 devices EC platform control"
+	depends on ACPI
+	depends on HWMON
+	select LEDS_CLASS
+	select LEDS_CLASS_MULTICOLOR
+	help
+	  This is a driver for Ayn and Tactoy x86 handheld devices. It provides
+	  temperature monitoring, manual fan speed control, fan curve control,
+	  and chassis RGB settings.
+
+	  If you have an x86 Ayn or Tactoy handheld device say M here. The module
+	  will be called ayn-platform.
+
 config MERAKI_MX100
 	tristate "Cisco Meraki MX100 Platform Driver"
 	depends on GPIOLIB
drivers/platform/x86/Makefile +3 -0
index a0c5848513e3..d32504b89365 100644
@@ -38,6 +38,9 @@ obj-$(CONFIG_ASUS_TF103C_DOCK)	+= asus-tf103c-dock.o
 obj-$(CONFIG_EEEPC_LAPTOP)	+= eeepc-laptop.o
 obj-$(CONFIG_EEEPC_WMI)		+= eeepc-wmi.o
 
+# Ayn
+obj-$(CONFIG_AYN_EC)	+= ayn-ec.o
+
 # Cisco/Meraki
 obj-$(CONFIG_MERAKI_MX100)	+= meraki-mx100.o
 
drivers/platform/x86/ayn-ec.c new file +595 -0

595 lines not on this page · raw message

Signature · 1 line
2.50.1
#2 lore raw

PATCH v2 2/4 platform/x86: (ayn-ec) Add Temperature Sensors

In reply to Derek J. Clark

Adds temperature sensors to the ayn-ec hwmon interface. These read-only values include Battery, Motherboard, Charger IC, vCore, and CPU Core, as well as labels for each entry. The temperature values provided by the EC are whole numbers in degrees Celsius. As hwmon expects millidegrees, we scale the raw value up.

sensors output after this patch is applied:
aynec-isa-0000

Adapter: ISA adapter
fan1:        1876 RPM
Battery:      +29.0°C
Motherboard:  +30.0°C
Charger IC:   +30.0°C
vCore:        +36.0°C
CPU Core:     +48.0°C
---
 drivers/platform/x86/ayn-ec.c | 87 +++++++++++++++++++++++++++++++++++
 1 file changed, 87 insertions(+)
drivers/platform/x86/ayn-ec.c +87 -0
index 7e2187eba9a8..3b4daa7603ee 100644
@@ -50,8 +50,16 @@
 #define AYN_SENSOR_PWM_FAN_TEMP_4_REG	0x19
 #define AYN_SENSOR_PWM_FAN_TEMP_5_REG	0x1B
 
+/* EC Temperature Sensors */
+#define AYN_SENSOR_BAT_TEMP_REG		0x04 /* Battery */
+#define AYN_SENSOR_CHARGE_TEMP_REG	0x07 /* Charger IC */
+#define AYN_SENSOR_MB_TEMP_REG		0x05 /* Motherboard */
+#define AYN_SENSOR_PROC_TEMP_REG	0x09 /* CPU Core */
+#define AYN_SENSOR_VCORE_TEMP_REG	0x08 /* vCore */
+
 /* Handle ACPI lock mechanism */
 #define ACPI_LOCK_DELAY_MS 500
+
 enum ayn_model {
 	ayn_loki_max = 1,
 	ayn_loki_minipro,
@@ -63,6 +71,20 @@ struct ayn_device {
 	u32 ayn_lock; /* ACPI EC Lock */
 } drvdata;
 
+struct thermal_sensor {
+	char *name;
+	int reg;
+};
+
+static struct thermal_sensor thermal_sensors[] = {
+	{ "Battery", AYN_SENSOR_BAT_TEMP_REG },
+	{ "Motherboard", AYN_SENSOR_MB_TEMP_REG },
+	{ "Charger IC", AYN_SENSOR_CHARGE_TEMP_REG },
+	{ "vCore", AYN_SENSOR_VCORE_TEMP_REG },
+	{ "CPU Core", AYN_SENSOR_PROC_TEMP_REG },
+	{}
+};
+
 /* Handle ACPI lock mechanism */
 #define ACPI_LOCK_DELAY_MS 500
 
@@ -503,6 +525,61 @@ static SENSOR_DEVICE_ATTR_RW(pwm1_auto_point3_temp, pwm_curve, 7);
 static SENSOR_DEVICE_ATTR_RW(pwm1_auto_point4_temp, pwm_curve, 8);
 static SENSOR_DEVICE_ATTR_RW(pwm1_auto_point5_temp, pwm_curve, 9);
 
+/**
+ * thermal_sensor_show() - Read a thermal sensor attribute value.
+ *
+ * @dev: The attribute's parent device.
+ * @attr: The attribute to read.
+ * @buf: Buffer to write the result into.
+ *
+ * Return: Number of bytes read, or an error.
+ */
+static ssize_t thermal_sensor_show(struct device *dev,
+				   struct device_attribute *attr, char *buf)
+{
+	long ret, val;
+	int i;
+
+	i = to_sensor_dev_attr(attr)->index;
+
+	ret = read_from_ec(thermal_sensors[i].reg, 1, &val);
+	if (ret)
+		return ret;
+
+	val = val * 1000L;
+
+	return sysfs_emit(buf, "%ld\n", val);
+}
+
+/**
+ * thermal_sensor_label_show() - Read a thermal sensor attribute label.
+ *
+ * @dev: The attribute's parent device.
+ * @attr: The attribute to read.
+ * @buf: Buffer to read to.
+ *
+ * Return: Number of bytes read, or an error.
+ */
+static ssize_t thermal_sensor_label_show(struct device *dev,
+					 struct device_attribute *attr,
+					 char *buf)
+{
+	int i = to_sensor_dev_attr(attr)->index;
+
+	return sysfs_emit(buf, "%s\n", thermal_sensors[i].name);
+}
+
+static SENSOR_DEVICE_ATTR_RO(temp1_input, thermal_sensor, 0);
+static SENSOR_DEVICE_ATTR_RO(temp2_input, thermal_sensor, 1);
+static SENSOR_DEVICE_ATTR_RO(temp3_input, thermal_sensor, 2);
+static SENSOR_DEVICE_ATTR_RO(temp4_input, thermal_sensor, 3);
+static SENSOR_DEVICE_ATTR_RO(temp5_input, thermal_sensor, 4);
+static SENSOR_DEVICE_ATTR_RO(temp1_label, thermal_sensor_label, 0);
+static SENSOR_DEVICE_ATTR_RO(temp2_label, thermal_sensor_label, 1);
+static SENSOR_DEVICE_ATTR_RO(temp3_label, thermal_sensor_label, 2);
+static SENSOR_DEVICE_ATTR_RO(temp4_label, thermal_sensor_label, 3);
+static SENSOR_DEVICE_ATTR_RO(temp5_label, thermal_sensor_label, 4);
+
 static struct attribute *ayn_sensors_attrs[] = {
 	&sensor_dev_attr_pwm1_auto_point1_pwm.dev_attr.attr,
 	&sensor_dev_attr_pwm1_auto_point1_temp.dev_attr.attr,
@@ -514,6 +591,16 @@ static struct attribute *ayn_sensors_attrs[] = {
 	&sensor_dev_attr_pwm1_auto_point4_temp.dev_attr.attr,
 	&sensor_dev_attr_pwm1_auto_point5_pwm.dev_attr.attr,
 	&sensor_dev_attr_pwm1_auto_point5_temp.dev_attr.attr,
+	&sensor_dev_attr_temp1_input.dev_attr.attr,
+	&sensor_dev_attr_temp1_label.dev_attr.attr,
+	&sensor_dev_attr_temp2_input.dev_attr.attr,
+	&sensor_dev_attr_temp2_label.dev_attr.attr,
+	&sensor_dev_attr_temp3_input.dev_attr.attr,
+	&sensor_dev_attr_temp3_label.dev_attr.attr,
+	&sensor_dev_attr_temp4_input.dev_attr.attr,
+	&sensor_dev_attr_temp4_label.dev_attr.attr,
+	&sensor_dev_attr_temp5_input.dev_attr.attr,
+	&sensor_dev_attr_temp5_label.dev_attr.attr,
 	NULL,
 };
 
Signature · 1 line
2.50.1
#3 lore raw

PATCH v2 3/4 platform/x86: (ayn-ec) Add RGB Interface

In reply to Derek J. Clark

Adds an EC controlled LED Multicolor Class Device for controlling the RGB rings around the joysticks.

The EC provides a single register for each of the colors red, green, and blue, as well as a mode switching register. The EC accepts values [0-255] for all colors. There are two available effects: breathe, which is the default when the device is started, and monocolor. When resuming from sleep the user selected effect will be overwritten by the EC, so the driver retains the last setting and resets on resume. When setting a color, each color register is set before a final "write" code is sent to the device. The EC may briefly reflect the "write" code when writing, but quickly changes to the "monocolor" value once complete. The driver interprets both of these values as "monocolor" in _show to simplify the sysfs exposed to the user.

Two custom attributes are added to the standard LED parent device:
effect, a RW file descriptor used to set the effect, and effect_index, which enumerates the available valid options.

---
 drivers/platform/x86/ayn-ec.c | 283 ++++++++++++++++++++++++++++++++++
 1 file changed, 283 insertions(+)
drivers/platform/x86/ayn-ec.c +283 -0
index 3b4daa7603ee..3bede03a60fe 100644
@@ -28,6 +28,8 @@
 #include <linux/hwmon.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
+#include <linux/led-class-multicolor.h>
+#include <linux/leds.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/sysfs.h>
@@ -57,6 +59,17 @@
 #define AYN_SENSOR_PROC_TEMP_REG	0x09 /* CPU Core */
 #define AYN_SENSOR_VCORE_TEMP_REG	0x08 /* vCore */
 
+/* EC Controlled RGB registers */
+#define AYN_LED_MC_RED_REG	0xB0 /* Range 0x00-0xFF */
+#define AYN_LED_MC_GREEN_REG	0xB1 /* Range 0x00-0xFF */
+#define AYN_LED_MC_BLUE_REG	0xB2 /* Range 0x00-0xFF */
+#define AYN_RGB_EFFECT_REG	0xB3
+
+/* RGB effect modes */
+#define AYN_RGB_EFFECT_BREATHE		0x00
+#define AYN_RGB_EFFECT_MONOCOLOR	0x55
+#define AYN_RGB_EFFECT_WRITE		0xAA
+
 /* Handle ACPI lock mechanism */
 #define ACPI_LOCK_DELAY_MS 500
 
@@ -68,7 +81,9 @@ enum ayn_model {
 };
 
 struct ayn_device {
+	struct led_classdev *led_cdev;
 	u32 ayn_lock; /* ACPI EC Lock */
+	u8 rgb_effect;
 } drvdata;
 
 struct thermal_sensor {
@@ -85,6 +100,30 @@ static struct thermal_sensor thermal_sensors[] = {
 	{}
 };
 
+/* RGB effect values */
+enum RGB_EFFECT_OPTION {
+	BREATHE,
+	MONOCOLOR,
+};
+
+static const char *const RGB_EFFECT_TEXT[] = {
+	[BREATHE] = "breathe",
+	[MONOCOLOR] = "monocolor",
+};
+
+#define DEVICE_ATTR_RW_NAMED(_name, _attrname)               \
+	struct device_attribute dev_attr_##_name = {         \
+		.attr = { .name = _attrname, .mode = 0644 }, \
+		.show = _name##_show,                        \
+		.store = _name##_store,                      \
+	}
+
+#define DEVICE_ATTR_RO_NAMED(_name, _attrname)               \
+	struct device_attribute dev_attr_##_name = {         \
+		.attr = { .name = _attrname, .mode = 0444 }, \
+		.show = _name##_show,                        \
+	}
+
 /* Handle ACPI lock mechanism */
 #define ACPI_LOCK_DELAY_MS 500
 
@@ -606,10 +645,253 @@ static struct attribute *ayn_sensors_attrs[] = {
 
 ATTRIBUTE_GROUPS(ayn_sensors);
 
+/**
+ * rgb_effect_write() - Set the RGB effect stored in drvdata.rgb_effect.
+ */
+static int rgb_effect_write(void)
+{
+	return write_to_ec(AYN_RGB_EFFECT_REG, drvdata.rgb_effect);
+};
+
+/**
+ * rgb_effect_read() - Read the RGB effect and store it in drvdata.rgb_effect.
+ */
+static int rgb_effect_read(void)
+{
+	int ret;
+	long effect;
+
+	ret = read_from_ec(AYN_RGB_EFFECT_REG, 1, &effect);
+	if (ret)
+		return ret;
+
+	switch (effect) {
+	case AYN_RGB_EFFECT_WRITE:
+	case AYN_RGB_EFFECT_MONOCOLOR:
+		drvdata.rgb_effect = AYN_RGB_EFFECT_WRITE;
+		break;
+	default:
+		drvdata.rgb_effect = AYN_RGB_EFFECT_BREATHE;
+	}
+
+	return 0;
+}
+
+/**
+ * rgb_effect_store() - Store the given RGB effect and set it.
+ *
+ * @dev: parent device of the given attribute.
+ * @attr: The attribute to write to.
+ * @buf: Input value string from sysfs write.
+ * @count: The number of bytes written.
+ *
+ * Return: The number of bytes written, or an error.
+ */
+static ssize_t rgb_effect_store(struct device *dev,
+				struct device_attribute *attr, const char *buf,
+				size_t count)
+{
+	int ret;
+
+	ret = sysfs_match_string(RGB_EFFECT_TEXT, buf);
+	if (ret < 0)
+		return ret;
+
+	if (ret)
+		drvdata.rgb_effect = AYN_RGB_EFFECT_WRITE;
+	else
+		drvdata.rgb_effect = AYN_RGB_EFFECT_BREATHE;
+
+	ret = rgb_effect_write();
+	if (ret)
+		return ret;
+
+	return count;
+};
+
+/**
+ * rgb_effect_show() - Read the current RGB effect.
+ *
+ * @dev: parent device of the given attribute.
+ * @attr: The attribute to read.
+ * @buf: Buffer to read to.
+ *
+ * Return: The number of bytes read, or an error.
+ */
+static ssize_t rgb_effect_show(struct device *dev,
+			       struct device_attribute *attr, char *buf)
+{
+	int ret, i;
+
+	ret = rgb_effect_read();
+	if (ret)
+		return ret;
+
+	switch (drvdata.rgb_effect) {
+	case AYN_RGB_EFFECT_WRITE:
+	case AYN_RGB_EFFECT_MONOCOLOR:
+		i = MONOCOLOR;
+		break;
+	default:
+		i = BREATHE;
+		break;
+	}
+
+	return sysfs_emit(buf, "%s\n", RGB_EFFECT_TEXT[i]);
+};
+
+static DEVICE_ATTR_RW_NAMED(rgb_effect, "effect");
+
+/**
+ * rgb_effect_show() - Display the RGB effects available.
+ *
+ * @dev: parent device of the given attribute.
+ * @attr: The attribute to read.
+ * @buf: Buffer to read to.
+ *
+ * Return: The number of bytes read, or an error.
+ */
+static ssize_t rgb_effect_index_show(struct device *dev,
+				     struct device_attribute *attr, char *buf)
+{
+	size_t count = 0;
+	unsigned int i;
+
+	for (i = 0; i < ARRAY_SIZE(RGB_EFFECT_TEXT); i++)
+		count += sysfs_emit_at(buf, count, "%s ", RGB_EFFECT_TEXT[i]);
+
+	buf[count - 1] = '\n';
+
+	return count;
+}
+
+static DEVICE_ATTR_RO_NAMED(rgb_effect_index, "effect_index");
+
+/**
+ * ayn_led_mc_brightness_set() - Write the brightness for the RGB LED.
+ *
+ * @led_cdev: Parent LED device for the led_classdev_mc.
+ * @brightness: Brightness value to write [0-255].
+ */
+static void ayn_led_mc_brightness_set(struct led_classdev *led_cdev,
+				      enum led_brightness brightness)
+{
+	struct led_classdev_mc *led_cdev_mc = lcdev_to_mccdev(led_cdev);
+	struct mc_subled s_led;
+	int i, ret, val;
+
+	switch (drvdata.rgb_effect) {
+	case AYN_RGB_EFFECT_WRITE:
+	case AYN_RGB_EFFECT_MONOCOLOR:
+		break;
+	case AYN_RGB_EFFECT_BREATHE:
+		return;
+	}
+
+	led_cdev->brightness = brightness;
+	for (i = 0; i < led_cdev_mc->num_colors; i++) {
+		s_led = led_cdev_mc->subled_info[i];
+		val = brightness * s_led.intensity / led_cdev->max_brightness;
+		ret = write_to_ec(s_led.channel, val);
+		if (ret) {
+			dev_err(led_cdev->dev,
+				"Error setting brightness:  %d\n", ret);
+			return;
+		}
+	}
+
+	/* Must write mode again to change to set color */
+	write_to_ec(AYN_RGB_EFFECT_REG, AYN_RGB_EFFECT_WRITE);
+};
+
+/**
+ * ayn_led_mc_brightness_get() - Get the brightness for the RGB LED.
+ *
+ * @led_cdev: Parent LED device for the led_classdev_mc.
+ *
+ * Return: Current brightness.
+ */
+static enum led_brightness ayn_led_mc_brightness_get(struct led_classdev *led_cdev)
+{
+	return led_cdev->brightness;
+};
+
+static struct attribute *ayn_led_mc_attrs[] = {
+	&dev_attr_rgb_effect.attr,
+	&dev_attr_rgb_effect_index.attr,
+	NULL,
+};
+
+static struct attribute_group ayn_led_mc_group = {
+	.attrs = ayn_led_mc_attrs,
+};
+
+struct mc_subled ayn_led_mc_subled_info[] = {
+	{
+		.color_index = LED_COLOR_ID_RED,
+		.brightness = 0,
+		.intensity = 0,
+		.channel = AYN_LED_MC_RED_REG,
+	},
+	{
+		.color_index = LED_COLOR_ID_GREEN,
+		.brightness = 0,
+		.intensity = 0,
+		.channel = AYN_LED_MC_GREEN_REG,
+	},
+	{
+		.color_index = LED_COLOR_ID_BLUE,
+		.brightness = 0,
+		.intensity = 0,
+		.channel = AYN_LED_MC_BLUE_REG,
+	},
+};
+
+struct led_classdev_mc ayn_led_mc = {
+	.led_cdev = {
+		.name = "ayn:rgb:joystick_rings",
+		.brightness = 0,
+		.max_brightness = 255,
+		.brightness_set = ayn_led_mc_brightness_set,
+		.brightness_get = ayn_led_mc_brightness_get,
+		.color = LED_COLOR_ID_RGB,
+	},
+	.num_colors = ARRAY_SIZE(ayn_led_mc_subled_info),
+	.subled_info = ayn_led_mc_subled_info,
+};
+
+static int ayn_ec_resume(struct platform_device *pdev)
+{
+	struct led_classdev *led_cdev = drvdata.led_cdev;
+	int ret;
+
+	ret = rgb_effect_write();
+	if (ret)
+		return ret;
+
+	ayn_led_mc_brightness_set(led_cdev, led_cdev->brightness);
+
+	return 0;
+}
+
 static int ayn_ec_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	struct device *hwdev;
+	int ret;
+
+	ret = devm_led_classdev_multicolor_register(dev, &ayn_led_mc);
+	if (ret)
+		return ret;
+
+	ret = devm_device_add_group(ayn_led_mc.led_cdev.dev, &ayn_led_mc_group);
+	if (ret)
+		return ret;
+
+	drvdata.led_cdev = &ayn_led_mc.led_cdev;
+	ret = rgb_effect_read();
+	if (ret)
+		return ret;
 
 	hwdev = devm_hwmon_device_register_with_info(dev, "aynec", NULL,
 						     &ayn_ec_chip_info,
@@ -622,6 +904,7 @@ static struct platform_driver ayn_ec_driver = {
 		.name = "ayn-ec",
 	},
 	.probe = ayn_ec_probe,
+	.resume = ayn_ec_resume,
 };
 
 static struct platform_device *ayn_ec_device;
Signature · 1 line
2.50.1
#4 lore raw

PATCH v2 4/4 platform/x86: (ayn-ec) Add Ayn EC Platform Documentation

In reply to Derek J. Clark

Adds ABI documentation for the ayn-ec platform driver

---
 .../ABI/testing/sysfs-platform-ayn-ec         | 59 +++++++++++++++++++
 MAINTAINERS                                   |  1 +
 2 files changed, 60 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-platform-ayn-ec
Documentation/ABI/testing/sysfs-platform-ayn-ec new file +59 -0
new file mode 100644
index 000000000000..cba68b0870ea
@@ -0,0 +1,59 @@
+What:		/sys/class/hwmon/hwmon[0-9]/pwm1_enable
+Date:		July 2025
+KernelVersion:	6.17
+Contact:	"Derek J. Clark" <[email protected]>
+Description:
+		This sets the PWM fan mode of operation. Valid values are [0-3].
+    Values [0-2] conform with standard hwmon operating modes. Value 3
+    enables user defined fan curve settings.
+
+    Applies to Ayn Loki and Toctoy Zeenix lines of handheld devices.
+
+What:		/sys/class/hwmon/hwmon[0-9]/pwm1_auto_point[1-5]_pwm
+Date:		July 2025
+KernelVersion:	6.17
+Contact:	"Derek J. Clark" <[email protected]>
+Description:
+		This sets the PWM fan duty cycle for the given index of the fan curve.
+    When the temperature reaches the corresponding pwm1_auto_point[1-5]_temp,
+    the EC will automatically increase the fan duty cycle to the given value.
+
+    Values are [0-255]
+
+    Applies to Ayn Loki and Toctoy Zeenix lines of handheld devices.
+
+What:		/sys/class/hwmon/hwmon[0-9]/pwm1_auto_point[1-5]_temp
+Date:		July 2025
+KernelVersion:	6.17
+Contact:	"Derek J. Clark" <[email protected]>
+Description:
+		This sets the activation temperature for the given index of the fan curve.
+    When the temperature reaches the given value, the EC will automatically
+    increase the fan duty cycle to the corresponding pwm1_auto_point[1-5]_pwm
+    value.
+
+    Values are [0-100]
+
+    Applies to Ayn Loki and Toctoy Zeenix lines of handheld devices.
+
+What:		/sys/class/leds/ayn:rgb:joystick_rings/effect
+Date:		July 2025
+KernelVersion:	6.17
+Contact:	"Derek J. Clark" <[email protected]>
+Description:
+		This controls the display effect of the RGB interface.
+
+    Values are monocolor or breathe.
+
+    Applies to Ayn Loki and Toctoy Zeenix lines of handheld devices.
+
+What:		/sys/class/leds/ayn:rgb:joystick_rings/effect_index
+Date:		July 2025
+KernelVersion:	6.17
+Contact:	"Derek J. Clark" <[email protected]>
+Description:
+		This displays the available options for the effect attribute.
+
+    Values are monocolor or breathe.
+
+    Applies to Ayn Loki and Toctoy Zeenix lines of handheld devices.
MAINTAINERS +1 -0
index 5b816883fe7d..199bebbffa0d 100644
@@ -4039,6 +4039,7 @@ AYN PLATFORM EC DRIVER
 M:	Derek J. Clark <[email protected]>
 L:	[email protected]
 S:	Maintained
+F:	Documentation/ABI/testing/sysfs-platform-ayn-ec
 F:	drivers/platform/x86/ayn-ec.c
 
 AZ6007 DVB DRIVER
Signature · 1 line
2.50.1
reviewer
#5 lore raw
In reply to Derek J. Clark
Quoted 1 line · Derek J. Clark

Adds platform driver for Ayn Loki and Tactoy Zeenix handheld devices.

Looks like s/Tactoy/Tectoy/ in all patches & cover letter.

Quoted 4 lines

Tactoy devices are rebranded Ayn devices with minor modifications to the DMI. The device EC has multiple features implemented by this driver, including a PWN fan with manual and EC controlled automatic modes as well as a user deviced fan curve mode, temperature sensors, and chassis

defined ?

Quoted 32 lines

RGB control.

This driver implements PWN fan and temperature control via a hwmon interface, and an RGB chassis interface via a multicolor LED class device. I attempted to break the driver up into four logical patches. Patch 1 adds PWM fan control via a hwmon interface. Patch 2 expands the hwmon interface by adding the temperature sensors. Patch 3 adds the chassis RGB interface through the leds subsystem. Patch 4 adds ABI documentation for the sysfs entries that aren't provided by the standard interfaces, but are needed to fully control the device.

---
v2:
- Fix nits from Alok Tiwari.
v1:
https://lore.kernel.org/platform-driver-x86/[email protected]/T/#mb795b8f5e5ff3c5b88fdd62bd6c97eab404fbc4e
Derek J. Clark (4):
platform/x86: (ayn-ec) Add PWM Fan HWMON Interface platform/x86: (ayn-ec) Add Temperature Sensors platform/x86: (ayn-ec) Add RGB Interface platform/x86: (ayn-ec) Add Ayn EC Platform Documentation

 .../ABI/testing/sysfs-platform-ayn-ec         |  59 ++
 MAINTAINERS                                   |   7 +
 drivers/platform/x86/Kconfig                  |  14 +
 drivers/platform/x86/Makefile                 |   3 +
 drivers/platform/x86/ayn-ec.c                 | 965 ++++++++++++++++++
 5 files changed, 1048 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-platform-ayn-ec
 create mode 100644 drivers/platform/x86/ayn-ec.c
Signature · 1 line
~Randy