From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Antheas Kapenekakis <lkml@antheas.dev>
Cc: platform-driver-x86@vger.kernel.org,
LKML <linux-kernel@vger.kernel.org>,
linux-hwmon@vger.kernel.org, "Hans de Goede" <hansg@kernel.org>,
"Derek John Clark" <derekjohn.clark@gmail.com>,
"Joaquín Ignacio Aramendía" <samsagax@gmail.com>,
"Jean Delvare" <jdelvare@suse.com>,
"Guenter Roeck" <linux@roeck-us.net>
Subject: Re: [PATCH v2 4/6] platform/x86: ayaneo-ec: Add controller power and modules attributes
Date: Wed, 15 Oct 2025 12:08:04 +0300 (EEST) [thread overview]
Message-ID: <83ec8c7c-288f-f5dc-df9c-23094c1a21a0@linux.intel.com> (raw)
In-Reply-To: <9c482e01-88be-af7e-8a73-1e07b8781354@linux.intel.com>
[-- Attachment #1: Type: text/plain, Size: 6195 bytes --]
On Wed, 15 Oct 2025, Ilpo Järvinen wrote:
> On Wed, 15 Oct 2025, Antheas Kapenekakis wrote:
>
> > The Ayaneo 3 features hot-swappable controller modules. The ejection
> > and management is done through HID. However, after ejecting the modules,
> > the controller needs to be power cycled via the EC to re-initialize.
> >
> > For this, the EC provides a variable that holds whether the left or
> > right modules are connected, and a power control register to turn
> > the controller on or off. After ejecting the modules, the controller
> > should be turned off. Then, after both modules are reinserted,
> > the controller may be powered on again to re-initialize.
> >
> > This patch introduces two new sysfs attributes:
> > - `controller_modules`: a read-only attribute that indicates whether
> > the left and right modules are connected (none, left, right, both).
> > - `controller_power`: a read-write attribute that allows the user
> > to turn the controller on or off (with '1'/'0').
> >
> > Therefore, after ejection is complete, userspace can power off the
> > controller, then wait until both modules have been reinserted
> > (`controller_modules` will return 'both') to turn on the controller.
> >
> > Signed-off-by: Antheas Kapenekakis <lkml@antheas.dev>
> > ---
> > .../ABI/testing/sysfs-platform-ayaneo | 19 ++++
> > MAINTAINERS | 1 +
> > drivers/platform/x86/ayaneo-ec.c | 100 ++++++++++++++++++
> > 3 files changed, 120 insertions(+)
> > create mode 100644 Documentation/ABI/testing/sysfs-platform-ayaneo
> >
> > diff --git a/Documentation/ABI/testing/sysfs-platform-ayaneo b/Documentation/ABI/testing/sysfs-platform-ayaneo
> > new file mode 100644
> > index 000000000000..1fa32ba60fd0
> > --- /dev/null
> > +++ b/Documentation/ABI/testing/sysfs-platform-ayaneo
> > @@ -0,0 +1,19 @@
> > +What: /sys/devices/platform/<platform>/controller_power
> > +Date: Oct 2025
> > +KernelVersion: 6.9
> > +Contact: "Antheas Kapenekakis" <lkml@antheas.dev>
> > +Description:
> > + Current controller power state. Allows turning on and off
> > + the controller power (e.g. for power savings). Write 1 to
> > + turn on, 0 to turn off. File is readable and writable.
> > +
> > +What: /sys/devices/platform/<platform>/controller_modules
> > +Date: Oct 2025
> > +KernelVersion: 6.9
> > +Contact: "Antheas Kapenekakis" <lkml@antheas.dev>
> > +Description:
> > + Shows which controller modules are currently connected to
> > + the device. Possible values are "left", "right" and "both".
> > + File is read-only. The Windows software for this device
> > + will only set controller power to 1 if both module sides
> > + are connected (i.e. this file returns "both").
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index 8c4d0c26ca77..3dfa004555dd 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -4191,6 +4191,7 @@ AYANEO PLATFORM EC DRIVER
> > M: Antheas Kapenekakis <lkml@antheas.dev>
> > L: platform-driver-x86@vger.kernel.org
> > S: Maintained
> > +F: Documentation/ABI/testing/sysfs-platform-ayaneo
> > F: drivers/platform/x86/ayaneo-ec.c
> >
> > AZ6007 DVB DRIVER
> > diff --git a/drivers/platform/x86/ayaneo-ec.c b/drivers/platform/x86/ayaneo-ec.c
> > index 23c283f5eb61..363b61fc6e12 100644
> > --- a/drivers/platform/x86/ayaneo-ec.c
> > +++ b/drivers/platform/x86/ayaneo-ec.c
> > @@ -30,9 +30,17 @@
> > #define AYANEO_CHARGE_VAL_AUTO 0xaa
> > #define AYANEO_CHARGE_VAL_INHIBIT 0x55
> >
> > +#define AYANEO_POWER_REG 0x2d
> > +#define AYANEO_POWER_OFF 0xfe
> > +#define AYANEO_POWER_ON 0xff
> > +#define AYANEO_MODULE_REG 0x2f
> > +#define AYANEO_MODULE_LEFT BIT(0)
> > +#define AYANEO_MODULE_RIGHT BIT(1)
Also, add include for BIT().
> > +
> > struct ayaneo_ec_quirk {
> > bool has_fan_control;
> > bool has_charge_control;
> > + bool has_magic_modules;
> > };
> >
> > struct ayaneo_ec_platform_data {
> > @@ -44,6 +52,7 @@ struct ayaneo_ec_platform_data {
> > static const struct ayaneo_ec_quirk ayaneo3 = {
> > .has_fan_control = true,
> > .has_charge_control = true,
> > + .has_magic_modules = true,
> > };
> >
> > static const struct dmi_system_id dmi_table[] = {
> > @@ -262,6 +271,96 @@ static int ayaneo_remove_battery(struct power_supply *battery,
> > return 0;
> > }
> >
> > +static ssize_t controller_power_store(struct device *dev,
> > + struct device_attribute *attr, const char *buf,
> > + size_t count)
> > +{
> > + bool value;
> > + int ret;
> > +
> > + ret = kstrtobool(buf, &value);
> > + if (ret)
> > + return ret;
> > +
> > + ret = ec_write(AYANEO_POWER_REG, value ? AYANEO_POWER_ON : AYANEO_POWER_OFF);
> > + if (ret)
> > + return ret;
> > +
> > + return count;
> > +}
> > +
> > +static ssize_t controller_power_show(struct device *dev,
> > + struct device_attribute *attr, char *buf)
> > +{
> > + int ret;
> > + u8 val;
> > +
> > + ret = ec_read(AYANEO_POWER_REG, &val);
> > + if (ret)
> > + return ret;
> > +
> > + return sysfs_emit(buf, "%d\n", val == AYANEO_POWER_ON);
Add include.
--
i.
> > +}
> > +
> > +static DEVICE_ATTR_RW(controller_power);
> > +
> > +static ssize_t controller_modules_show(struct device *dev,
> > + struct device_attribute *attr, char *buf)
> > +{
> > + bool left, right;
> > + char *out;
> > + int ret;
> > + u8 val;
> > +
> > + ret = ec_read(AYANEO_MODULE_REG, &val);
> > + if (ret)
> > + return ret;
> > +
> > + left = !(val & AYANEO_MODULE_LEFT);
> > + right = !(val & AYANEO_MODULE_RIGHT);
> > +
> > + if (left && right)
> > + out = "both";
> > + else if (left)
> > + out = "left";
> > + else if (right)
> > + out = "right";
> > + else
> > + out = "none";
>
> I suggest using switch/case for this so you don't need the internal
> booleans at all.
>
> BTW, I appreciate it very much this series is split per feature, it's so
> much less daunting to start a review when I know I can actually finish
> before the next interruption (and having to flush context from my
> mind). :-)
>
>
next prev parent reply other threads:[~2025-10-15 9:08 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-15 8:44 [PATCH v2 0/6] platform/x86: ayaneo-ec: Add Ayaneo Embedded Controller platform driver Antheas Kapenekakis
2025-10-15 8:44 ` [PATCH v2 1/6] " Antheas Kapenekakis
2025-10-15 9:04 ` Ilpo Järvinen
2025-10-26 22:25 ` Armin Wolf
2025-10-15 8:44 ` [PATCH v2 2/6] platform/x86: ayaneo-ec: Add hwmon support Antheas Kapenekakis
2025-10-26 22:33 ` Armin Wolf
2025-10-15 8:44 ` [PATCH v2 3/6] platform/x86: ayaneo-ec: Add charge control support Antheas Kapenekakis
2025-10-26 22:35 ` Armin Wolf
2025-10-15 8:44 ` [PATCH v2 4/6] platform/x86: ayaneo-ec: Add controller power and modules attributes Antheas Kapenekakis
2025-10-15 9:05 ` Ilpo Järvinen
2025-10-15 9:08 ` Ilpo Järvinen [this message]
2025-10-26 22:42 ` Armin Wolf
2025-10-15 8:44 ` [PATCH v2 5/6] platform/x86: ayaneo-ec: Move Ayaneo devices from oxpec to ayaneo-ec Antheas Kapenekakis
2025-10-15 9:09 ` Ilpo Järvinen
2025-10-26 22:45 ` Armin Wolf
2025-10-15 8:44 ` [PATCH v2 6/6] platform/x86: ayaneo-ec: Add suspend hook Antheas Kapenekakis
2025-10-15 9:11 ` Ilpo Järvinen
2025-10-15 9:16 ` Antheas Kapenekakis
2025-10-15 9:27 ` Ilpo Järvinen
2025-10-15 9:36 ` Antheas Kapenekakis
2025-10-26 22:49 ` Armin Wolf
2025-10-26 23:17 ` Antheas Kapenekakis
2025-10-28 13:50 ` Armin Wolf
2025-10-28 15:20 ` Antheas Kapenekakis
2025-10-28 15:25 ` Armin Wolf
2025-10-28 17:49 ` Antheas Kapenekakis
2025-10-28 23:14 ` Armin Wolf
2025-10-28 20:26 ` Mario Limonciello
2025-10-28 20:34 ` Antheas Kapenekakis
2025-10-28 21:21 ` Mario Limonciello
2025-10-28 21:39 ` Antheas Kapenekakis
2025-10-29 3:36 ` Mario Limonciello (AMD) (kernel.org)
2025-10-29 8:48 ` Antheas Kapenekakis
2025-10-29 10:22 ` Guenter Roeck
2025-10-29 10:49 ` Antheas Kapenekakis
2025-10-29 14:25 ` Guenter Roeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=83ec8c7c-288f-f5dc-df9c-23094c1a21a0@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=derekjohn.clark@gmail.com \
--cc=hansg@kernel.org \
--cc=jdelvare@suse.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=lkml@antheas.dev \
--cc=platform-driver-x86@vger.kernel.org \
--cc=samsagax@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox