platform-driver-x86.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Sebastian Reichel <sre@kernel.org>
Cc: Hans de Goede <hansg@kernel.org>,
	 Bryan O'Donoghue <bryan.odonoghue@linaro.org>,
	 platform-driver-x86@vger.kernel.org,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 3/4] platform: arm64: thinkpad-t14s-ec: add system PM hooks
Date: Thu, 6 Nov 2025 14:07:43 +0200 (EET)	[thread overview]
Message-ID: <06de8e30-c5e1-46b5-d7f6-f5ab441e5b29@linux.intel.com> (raw)
In-Reply-To: <20251106-thinkpad-t14s-ec-improvements-v1-3-109548ae75c0@collabora.com>

On Thu, 6 Nov 2025, Sebastian Reichel wrote:

> Improve support for system suspend. The register information has been
> extracted from the ACPI DSDT code handling Windows Modern Standby. In
> addition to writing to the 0xE0 register, the ACPI function also does
> some changes to the thermal configuration. This part is not implemented.

This doesn't cover why you do that repeated writing, please include 
explanation for it.

> After this patch the laptop's power and LID LEDs will switch into the
> typical breathing animation when the system is suspended and enabled
> normally again after resuming.
> 
> Signed-off-by: Sebastian Reichel <sre@kernel.org>
> ---
>  drivers/platform/arm64/lenovo-thinkpad-t14s.c | 53 +++++++++++++++++++++++----
>  1 file changed, 45 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/platform/arm64/lenovo-thinkpad-t14s.c b/drivers/platform/arm64/lenovo-thinkpad-t14s.c
> index cf6a1d3b2617..066074a1314b 100644
> --- a/drivers/platform/arm64/lenovo-thinkpad-t14s.c
> +++ b/drivers/platform/arm64/lenovo-thinkpad-t14s.c
> @@ -25,14 +25,17 @@
>  #define T14S_EC_CMD_ECWR	0x03
>  #define T14S_EC_CMD_EVT		0xf0
>  
> -#define T14S_EC_REG_LED		0x0c
> -#define T14S_EC_REG_KBD_BL1	0x0d
> -#define T14S_EC_REG_KBD_BL2	0xe1
> -#define T14S_EC_KBD_BL1_MASK	GENMASK_U8(7, 6)
> -#define T14S_EC_KBD_BL2_MASK	GENMASK_U8(3, 2)
> -#define T14S_EC_REG_AUD		0x30
> -#define T14S_EC_MIC_MUTE_LED	BIT(5)
> -#define T14S_EC_SPK_MUTE_LED	BIT(6)
> +#define T14S_EC_REG_LED				0x0c
> +#define T14S_EC_REG_KBD_BL1			0x0d
> +#define T14S_EC_REG_MODERN_STANDBY		0xe0
> +#define T14S_EC_MODERN_STANDBY_ENTRY		BIT(1)
> +#define T14S_EC_MODERN_STANDBY_EXIT		BIT(0)
> +#define T14S_EC_REG_KBD_BL2			0xe1
> +#define T14S_EC_KBD_BL1_MASK			GENMASK_U8(7, 6)
> +#define T14S_EC_KBD_BL2_MASK			GENMASK_U8(3, 2)
> +#define T14S_EC_REG_AUD				0x30
> +#define T14S_EC_MIC_MUTE_LED			BIT(5)
> +#define T14S_EC_SPK_MUTE_LED			BIT(6)
>  
>  #define T14S_EC_EVT_NONE			0x00
>  #define T14S_EC_EVT_KEY_FN_4			0x13
> @@ -202,6 +205,14 @@ static int t14s_ec_read_evt(struct t14s_ec *ec, u8 *val)
>  	return ret;
>  }
>  
> +static void t14s_ec_write_sequence(struct t14s_ec *ec, u8 reg, u8 val, u8 cnt)
> +{
> +	int i;
> +
> +	for (i = 0; i < cnt; i++)
> +		regmap_write(ec->regmap, reg, val);
> +}
> +
>  static int t14s_led_set_status(struct t14s_ec *ec,
>  			       struct t14s_ec_led_classdev *led,
>  			       const enum t14s_ec_led_status_t ledstatus)
> @@ -554,6 +565,7 @@ static int t14s_ec_probe(struct i2c_client *client)
>  		return -ENOMEM;
>  
>  	ec->dev = dev;
> +	i2c_set_clientdata(client, ec);
>  
>  	ec->regmap = devm_regmap_init(dev, &t14s_ec_regmap_bus,
>  				      ec, &t14s_ec_regmap_config);
> @@ -593,6 +605,26 @@ static int t14s_ec_probe(struct i2c_client *client)
>  	return 0;
>  }
>  
> +static int t14s_ec_suspend(struct device *dev)
> +{
> +	struct t14s_ec *ec = dev_get_drvdata(dev);
> +
> +	t14s_ec_write_sequence(ec, T14S_EC_REG_MODERN_STANDBY,
> +			       T14S_EC_MODERN_STANDBY_ENTRY, 3);
> +
> +	return 0;
> +}
> +
> +static int t14s_ec_resume(struct device *dev)
> +{
> +	struct t14s_ec *ec = dev_get_drvdata(dev);
> +
> +	t14s_ec_write_sequence(ec, T14S_EC_REG_MODERN_STANDBY,
> +			       T14S_EC_MODERN_STANDBY_EXIT, 3);
> +
> +	return 0;
> +}
> +
>  static const struct of_device_id t14s_ec_of_match[] = {
>  	{ .compatible = "lenovo,thinkpad-t14s-ec" },
>  	{}
> @@ -605,10 +637,15 @@ static const struct i2c_device_id t14s_ec_i2c_id_table[] = {
>  };
>  MODULE_DEVICE_TABLE(i2c, t14s_ec_i2c_id_table);
>  
> +static const struct dev_pm_ops t14s_ec_pm_ops = {
> +	SYSTEM_SLEEP_PM_OPS(t14s_ec_suspend, t14s_ec_resume)

Add #include for the struct and macro.

-- 
 i.


> +};
> +
>  static struct i2c_driver t14s_ec_i2c_driver = {
>  	.driver = {
>  		.name = "thinkpad-t14s-ec",
>  		.of_match_table = t14s_ec_of_match,
> +		.pm = &t14s_ec_pm_ops,
>  	},
>  	.probe = t14s_ec_probe,
>  	.id_table = t14s_ec_i2c_id_table,
> 
> 

  reply	other threads:[~2025-11-06 12:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-05 23:22 [PATCH 0/4] platform: arm64: thinkpad-t14s-ec: fixes and suspend support Sebastian Reichel
2025-11-05 23:22 ` [PATCH 1/4] platform: arm64: thinkpad-t14s-ec: fix IRQ race condition Sebastian Reichel
2025-11-06  1:40   ` Bryan O'Donoghue
2025-11-05 23:22 ` [PATCH 2/4] platform: arm64: thinkpad-t14s-ec: sleep after EC access Sebastian Reichel
2025-11-05 23:22 ` [PATCH 3/4] platform: arm64: thinkpad-t14s-ec: add system PM hooks Sebastian Reichel
2025-11-06 12:07   ` Ilpo Järvinen [this message]
2025-11-05 23:22 ` [PATCH 4/4] platform: arm64: thinkpad-t14s-ec: add suspend handler for keyboard backlight Sebastian Reichel

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=06de8e30-c5e1-46b5-d7f6-f5ab441e5b29@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=bryan.odonoghue@linaro.org \
    --cc=hansg@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=sre@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).