Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1550540
| Path | csiph.com!news.mixmin.net!news.unit0.net!news.panservice.it!bofh.it!news.nic.it!robomod |
|---|---|
| From | Lee Jones <lee.jones@linaro.org> |
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 2/3] mfd: cros_ec: Send suspend state notification to EC |
| Date | Wed, 04 Jan 2017 10:10:02 +0100 |
| Message-ID | <sVPK2-2AQ-29@gated-at.bofh.it> (permalink) |
| References | <sP4Xv-6N6-5@gated-at.bofh.it> <sP4Xv-6N6-7@gated-at.bofh.it> |
| X-Original-To | Thierry Escande <thierry.escande@collabora.com> |
| Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=5SSMxdoPQ8SGiSh9aHEnMS+EsSWmfYcE8WiCzx94bsQ=; b=DjcArIqCiDKWc7VxPGLv21ET+MvBAPwPsDW5ku64TLQ84WkzUtS1rpUFX7SxIv7zDl 5ordiuE69ghf4TmjWgp3QGMApGaKd2xYrmG+dInQVHz4Ev9J5UQsh6CJchyhKvuA4iDb zlKHDw+HAo8M0EPaaa07B7j/s9LMTWarZgUQo= |
| X-Google-Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=5SSMxdoPQ8SGiSh9aHEnMS+EsSWmfYcE8WiCzx94bsQ=; b=d+J2Zs+9DBKN9Im1jscbOGU+SWr46mjQ8q3pKtdg5fpfPrfaM2Wu7InyGPbyyj0M8f X6KFESznd7+oSLrhgbCs0OjxLMJaK3oMhWu5q8f41KmNyv6yK5mZ1mkHHCrK8CNZ4DJt fUawpDVQ+cV4Sjt7IJp/w9zzVFD9THkuCxeBNYk5VTvuF/g95bRBoKbzl3naMD+RYwrW Xd+Jt/zHiXX9OcDKTBijzpcquaSG5+IB0jgO8iSPRZYpsdTs7KUWBJeoQ4KKGjIk8VEK gXUw/476/PyE6t6pO+hXYagkE8pl9v1dNwLABioA29FdcO/jxFj3ez867C4nJ2O5wJcE xttQ== |
| X-Gm-Message-State | AIkVDXJTlZlk4I4rT94mWXHNxjuxCtx5iq+A3xQSO4Hl2oUYgQDA0TZC+NUvDibxTgbsaGBs |
| X-Received | by 10.28.64.136 with SMTP id n130mr50594999wma.45.1483520604132; Wed, 04 Jan 2017 01:03:24 -0800 (PST) |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Disposition | inline |
| Content-Transfer-Encoding | 8bit |
| User-Agent | Mutt/1.6.2 (2016-07-01) |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 141 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | Benson Leung <bleung@chromium.org>, linux-kernel@vger.kernel.org |
| X-Original-Date | Wed, 4 Jan 2017 09:07:07 +0000 |
| X-Original-Message-ID | <20170104090706.GN27589@dell> |
| X-Original-References | <1481911058-28604-1-git-send-email-thierry.escande@collabora.com> <1481911058-28604-3-git-send-email-thierry.escande@collabora.com> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1550540 |
Show key headers only | View raw
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?
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 */
>
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread
Re: [PATCH 2/3] mfd: cros_ec: Send suspend state notification to EC Lee Jones <lee.jones@linaro.org> - 2017-01-04 10:10 +0100 Re: [PATCH 2/3] mfd: cros_ec: Send suspend state notification to EC Thierry Escande <thierry.escande@collabora.com> - 2017-01-04 15:20 +0100
csiph-web