mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thierry Escande <thierry.escande@collabora.com>
To: Lee Jones <lee.jones@linaro.org>
Cc: Benson Leung <bleung@chromium.org>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] mfd: cros_ec: Send suspend state notification to EC
Date: Wed, 4 Jan 2017 15:18:11 +0100	[thread overview]
Message-ID: <a9f0060d-1495-8269-4443-e98fad72b271@collabora.com> (raw)
In-Reply-To: <20170104090706.GN27589@dell>

Hi Lee,

On 04/01/2017 10:07, Lee Jones wrote:
> On Fri, 16 Dec 2016, Thierry Escande wrote:
>
>> From: Shawn Nematbakhsh <shawnn@chromium.org>
>>
>> Notify EC when going to or returning from suspend so that proper actions
>> related to wake events can be taken.
>>
>> Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
>> Signed-off-by: Thierry Escande <thierry.escande@collabora.com>
>> ---
>>  drivers/mfd/cros_ec.c                | 49 ++++++++++++++++++++++++++++++++++++
>>  include/linux/mfd/cros_ec_commands.h | 14 +++++++++++
>>  2 files changed, 63 insertions(+)
>
> Can this patch be taken without 3/3?
Yes, both 1st and 2nd patches can be taken without the 3rd one. I'll 
send a v2 with 3/3 in a separate patch.

Regards,
  Thierry

>
> For my own reference:
>   Acked-for-MFD-by: Lee Jones <lee.jones@linaro.org>
>
>> diff --git a/drivers/mfd/cros_ec.c b/drivers/mfd/cros_ec.c
>> index ad48633..b8a5080 100644
>> --- a/drivers/mfd/cros_ec.c
>> +++ b/drivers/mfd/cros_ec.c
>> @@ -23,6 +23,7 @@
>>  #include <linux/module.h>
>>  #include <linux/mfd/core.h>
>>  #include <linux/mfd/cros_ec.h>
>> +#include <linux/suspend.h>
>>  #include <asm/unaligned.h>
>>
>>  #define CROS_EC_DEV_EC_INDEX 0
>> @@ -65,6 +66,24 @@ static irqreturn_t ec_irq_thread(int irq, void *data)
>>  	return IRQ_HANDLED;
>>  }
>>
>> +static int cros_ec_sleep_event(struct cros_ec_device *ec_dev, u8 sleep_event)
>> +{
>> +	struct {
>> +		struct cros_ec_command msg;
>> +		struct ec_params_host_sleep_event req;
>> +	} __packed buf;
>> +
>> +	memset(&buf, 0, sizeof(buf));
>> +
>> +	buf.req.sleep_event = sleep_event;
>> +
>> +	buf.msg.command = EC_CMD_HOST_SLEEP_EVENT;
>> +	buf.msg.version = 0;
>> +	buf.msg.outsize = sizeof(buf.req);
>> +
>> +	return cros_ec_cmd_xfer(ec_dev, &buf.msg);
>> +}
>> +
>>  int cros_ec_register(struct cros_ec_device *ec_dev)
>>  {
>>  	struct device *dev = ec_dev->dev;
>> @@ -136,6 +155,15 @@ int cros_ec_register(struct cros_ec_device *ec_dev)
>>  		}
>>  	}
>>
>> +	/*
>> +	 * Clear sleep event - this will fail harmlessly on platforms that
>> +	 * don't implement the sleep event host command.
>> +	 */
>> +	err = cros_ec_sleep_event(ec_dev, 0);
>> +	if (err < 0)
>> +		dev_dbg(ec_dev->dev, "Error %d clearing sleep event to ec",
>> +			err);
>> +
>>  	dev_info(dev, "Chrome EC device registered\n");
>>
>>  	return 0;
>> @@ -159,6 +187,16 @@ EXPORT_SYMBOL(cros_ec_remove);
>>  int cros_ec_suspend(struct cros_ec_device *ec_dev)
>>  {
>>  	struct device *dev = ec_dev->dev;
>> +	int ret;
>> +	u8 sleep_event;
>> +
>> +	sleep_event = pm_suspend_via_firmware() ? HOST_SLEEP_EVENT_S3_RESUME :
>> +						  HOST_SLEEP_EVENT_S0IX_RESUME;
>> +
>> +	ret = cros_ec_sleep_event(ec_dev, sleep_event);
>> +	if (ret < 0)
>> +		dev_dbg(ec_dev->dev, "Error %d sending suspend event to ec",
>> +			ret);
>>
>>  	if (device_may_wakeup(dev))
>>  		ec_dev->wake_enabled = !enable_irq_wake(ec_dev->irq);
>> @@ -180,9 +218,20 @@ static void cros_ec_drain_events(struct cros_ec_device *ec_dev)
>>
>>  int cros_ec_resume(struct cros_ec_device *ec_dev)
>>  {
>> +	int ret;
>> +	u8 sleep_event;
>> +
>>  	ec_dev->suspended = false;
>>  	enable_irq(ec_dev->irq);
>>
>> +	sleep_event = pm_suspend_via_firmware() ? HOST_SLEEP_EVENT_S3_RESUME :
>> +						  HOST_SLEEP_EVENT_S0IX_RESUME;
>> +
>> +	ret = cros_ec_sleep_event(ec_dev, sleep_event);
>> +	if (ret < 0)
>> +		dev_dbg(ec_dev->dev, "Error %d sending resume event to ec",
>> +			ret);
>> +
>>  	/*
>>  	 * In some cases, we need to distinguish between events that occur
>>  	 * during suspend if the EC is not a wake source. For example,
>> diff --git a/include/linux/mfd/cros_ec_commands.h b/include/linux/mfd/cros_ec_commands.h
>> index 76728ff..4d55132 100644
>> --- a/include/linux/mfd/cros_ec_commands.h
>> +++ b/include/linux/mfd/cros_ec_commands.h
>> @@ -2304,6 +2304,20 @@ struct ec_params_ext_power_current_limit {
>>  	uint32_t limit; /* in mA */
>>  } __packed;
>>
>> +/* Inform the EC when entering a sleep state */
>> +#define EC_CMD_HOST_SLEEP_EVENT 0xa9
>> +
>> +enum host_sleep_event {
>> +	HOST_SLEEP_EVENT_S3_SUSPEND   = 1,
>> +	HOST_SLEEP_EVENT_S3_RESUME    = 2,
>> +	HOST_SLEEP_EVENT_S0IX_SUSPEND = 3,
>> +	HOST_SLEEP_EVENT_S0IX_RESUME  = 4
>> +};
>> +
>> +struct ec_params_host_sleep_event {
>> +	uint8_t sleep_event;
>> +} __packed;
>> +
>>  /*****************************************************************************/
>>  /* Smart battery pass-through */
>>
>

  reply	other threads:[~2017-01-04 14:18 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-16 17:57 [PATCH 0/3] mfd: cros_ec: various improvements Thierry Escande
2016-12-16 17:57 ` [PATCH 1/3] mfd: cros_ec: Prevent data transfer while device is suspended Thierry Escande
2017-01-04  9:06   ` Lee Jones
2017-01-05  8:15   ` Lee Jones
2016-12-16 17:57 ` [PATCH 2/3] mfd: cros_ec: Send suspend state notification to EC Thierry Escande
2017-01-04  9:07   ` Lee Jones
2017-01-04 14:18     ` Thierry Escande [this message]
2017-01-05  8:15   ` Lee Jones
2016-12-16 17:57 ` [PATCH 3/3] mfd: cros_ec: Add ACPI GPE handler for LID0 devices Thierry Escande
2017-01-04  9:06   ` Lee Jones
2017-01-04 17:17     ` Thierry Escande
2017-01-05  7:54       ` Lee Jones
2017-01-05 10:37         ` Thierry Escande
2017-01-05 14:43           ` Lee Jones
2017-01-05 16:39             ` Thierry Escande

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=a9f0060d-1495-8269-4443-e98fad72b271@collabora.com \
    --to=thierry.escande@collabora.com \
    --cc=bleung@chromium.org \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.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

all inboxes | Powered by JetHome®