Linux Hardware Monitor development
 help / color / mirror / Atom feed
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 6/6] platform/x86: ayaneo-ec: Add suspend hook
Date: Wed, 15 Oct 2025 12:27:11 +0300 (EEST)	[thread overview]
Message-ID: <f4f51eef-424e-2290-f6e3-ba4e5c3427e9@linux.intel.com> (raw)
In-Reply-To: <CAGwozwHsMErRA+eDSCH+3XU6Q4Up7qTSqJ5y29-SdP0aMErUTg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3887 bytes --]

On Wed, 15 Oct 2025, Antheas Kapenekakis wrote:

> On Wed, 15 Oct 2025 at 11:11, Ilpo Järvinen
> <ilpo.jarvinen@linux.intel.com> wrote:
> >
> > On Wed, 15 Oct 2025, Antheas Kapenekakis wrote:
> >
> > > The Ayaneo EC resets after hibernation, losing the charge control state.
> > > Add a small PM hook to restore this state on hibernation resume.
> > >
> > > The fan speed is also lost during hibernation, but since hibernation
> > > failures are common with this class of devices, setting a low fan speed
> > > when the userspace program controlling the fan will potentially not
> > > take over could cause the device to overheat, so it is not restored.
> > >
> > > Signed-off-by: Antheas Kapenekakis <lkml@antheas.dev>
> > > ---
> > >  drivers/platform/x86/ayaneo-ec.c | 42 ++++++++++++++++++++++++++++++++
> > >  1 file changed, 42 insertions(+)
> > >
> > > diff --git a/drivers/platform/x86/ayaneo-ec.c b/drivers/platform/x86/ayaneo-ec.c
> > > index 73e9dd39c703..8529f6f8dc69 100644
> > > --- a/drivers/platform/x86/ayaneo-ec.c
> > > +++ b/drivers/platform/x86/ayaneo-ec.c
> > > @@ -37,6 +37,8 @@
> > >  #define AYANEO_MODULE_LEFT   BIT(0)
> > >  #define AYANEO_MODULE_RIGHT  BIT(1)
> > >
> > > +#define AYANEO_CACHE_LEN     1
> > > +
> > >  struct ayaneo_ec_quirk {
> > >       bool has_fan_control;
> > >       bool has_charge_control;
> > > @@ -47,6 +49,8 @@ struct ayaneo_ec_platform_data {
> > >       struct platform_device *pdev;
> > >       struct ayaneo_ec_quirk *quirks;
> > >       struct acpi_battery_hook battery_hook;
> > > +
> > > +     u8 cache[AYANEO_CACHE_LEN];
> > >  };
> > >
> > >  static const struct ayaneo_ec_quirk quirk_fan = {
> > > @@ -464,10 +468,48 @@ static int ayaneo_ec_probe(struct platform_device *pdev)
> > >       return 0;
> > >  }
> > >
> > > +static int ayaneo_freeze(struct device *dev)
> > > +{
> > > +     struct platform_device *pdev = to_platform_device(dev);
> > > +     struct ayaneo_ec_platform_data *data = platform_get_drvdata(pdev);
> > > +     int ret, i = 0;
> > > +
> > > +     if (data->quirks->has_charge_control) {
> > > +             ret = ec_read(AYANEO_CHARGE_REG, &data->cache[i]);
> > > +             if (ret)
> > > +                     return ret;
> > > +             i++;
> >
> > What is this for?
> 
> Adding additional registers to restore. Currently, there is only one
> so it looks out of place.

When are patches for those additional registers going to be submitted?
If it's not like right around the corner, I'd prefer i be added only 
at that time.

In any case, please mention in the changelog there's going to be more to 
registers cache so it becomes justified why you're using an array for the 
cache.

-- 
 i.

> > > +     }
> > > +
> > > +     return 0;
> > > +}
> > > +
> > > +static int ayaneo_thaw(struct device *dev)
> > > +{
> > > +     struct platform_device *pdev = to_platform_device(dev);
> > > +     struct ayaneo_ec_platform_data *data = platform_get_drvdata(pdev);
> > > +     int ret, i = 0;
> > > +
> > > +     if (data->quirks->has_charge_control) {
> > > +             ret = ec_write(AYANEO_CHARGE_REG, data->cache[i]);
> > > +             if (ret)
> > > +                     return ret;
> > > +             i++;
> >
> > Same question here.
> >
> > > +     }
> > > +
> > > +     return 0;
> > > +}
> > > +
> > > +static const struct dev_pm_ops ayaneo_pm_ops = {
> > > +     .freeze = ayaneo_freeze,
> > > +     .thaw = ayaneo_thaw,
> > > +};
> > > +
> > >  static struct platform_driver ayaneo_platform_driver = {
> > >       .driver = {
> > >               .name = "ayaneo-ec",
> > >               .dev_groups = ayaneo_ec_groups,
> > > +             .pm = &ayaneo_pm_ops,
> > >       },
> > >       .probe = ayaneo_ec_probe,
> > >  };
> > >
> >
> > --
> >  i.
> >
> >
> 

  reply	other threads:[~2025-10-15  9:27 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
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 [this message]
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=f4f51eef-424e-2290-f6e3-ba4e5c3427e9@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