linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gwendal Grignou <gwendal@chromium.org>
To: enric.balletbo@collabora.com, bleung@chromium.org,
	groeck@chromium.org, lee.jones@linaro.org, jic23@kernel.org,
	broonie@kernel.org, cychiang@chromium.org, tiwai@suse.com
Cc: linux-iio@vger.kernel.org, alsa-devel@alsa-project.org,
	linux-kernel@vger.kernel.org,
	Gwendal Grignou <gwendal@chromium.org>
Subject: [PATCH v3 21/30] mfd: cros_ec: Add Hibernate API
Date: Thu,  9 May 2019 14:13:44 -0700	[thread overview]
Message-ID: <20190509211353.213194-22-gwendal@chromium.org> (raw)
In-Reply-To: <20190509211353.213194-1-gwendal@chromium.org>

Add support for controlling hibernation of the Embedded Controller.

Acked-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Acked-by: Benson Leung <bleung@chromium.org>
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
---
 include/linux/mfd/cros_ec_commands.h | 72 +++++++++++++++++++++++++++-
 1 file changed, 70 insertions(+), 2 deletions(-)

diff --git a/include/linux/mfd/cros_ec_commands.h b/include/linux/mfd/cros_ec_commands.h
index cc054a0a4c4c..7f98c6e63ad1 100644
--- a/include/linux/mfd/cros_ec_commands.h
+++ b/include/linux/mfd/cros_ec_commands.h
@@ -4045,6 +4045,40 @@ struct ec_params_dedicated_charger_limit {
 	uint16_t voltage_lim; /* in mV */
 } __ec_align2;
 
+/*****************************************************************************/
+/* Hibernate/Deep Sleep Commands */
+
+/* Set the delay before going into hibernation. */
+#define EC_CMD_HIBERNATION_DELAY 0x00A8
+
+struct ec_params_hibernation_delay {
+	/*
+	 * Seconds to wait in G3 before hibernate.  Pass in 0 to read the
+	 * current settings without changing them.
+	 */
+	uint32_t seconds;
+} __ec_align4;
+
+struct ec_response_hibernation_delay {
+	/*
+	 * The current time in seconds in which the system has been in the G3
+	 * state.  This value is reset if the EC transitions out of G3.
+	 */
+	uint32_t time_g3;
+
+	/*
+	 * The current time remaining in seconds until the EC should hibernate.
+	 * This value is also reset if the EC transitions out of G3.
+	 */
+	uint32_t time_remaining;
+
+	/*
+	 * The current time in seconds that the EC should wait in G3 before
+	 * hibernating.
+	 */
+	uint32_t hibernate_delay;
+} __ec_align4;
+
 /* Inform the EC when entering a sleep state */
 #define EC_CMD_HOST_SLEEP_EVENT 0x00A9
 
@@ -4052,7 +4086,9 @@ 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
+	HOST_SLEEP_EVENT_S0IX_RESUME  = 4,
+	/* S3 suspend with additional enabled wake sources */
+	HOST_SLEEP_EVENT_S3_WAKEABLE_SUSPEND = 5,
 };
 
 struct ec_params_host_sleep_event {
@@ -4116,6 +4152,36 @@ struct ec_response_host_sleep_event_v1 {
 	};
 } __ec_align4;
 
+/*****************************************************************************/
+/* Device events */
+#define EC_CMD_DEVICE_EVENT 0x00AA
+
+enum ec_device_event {
+	EC_DEVICE_EVENT_TRACKPAD,
+	EC_DEVICE_EVENT_DSP,
+	EC_DEVICE_EVENT_WIFI,
+};
+
+enum ec_device_event_param {
+	/* Get and clear pending device events */
+	EC_DEVICE_EVENT_PARAM_GET_CURRENT_EVENTS,
+	/* Get device event mask */
+	EC_DEVICE_EVENT_PARAM_GET_ENABLED_EVENTS,
+	/* Set device event mask */
+	EC_DEVICE_EVENT_PARAM_SET_ENABLED_EVENTS,
+};
+
+#define EC_DEVICE_EVENT_MASK(event_code) BIT(event_code % 32)
+
+struct ec_params_device_event {
+	uint32_t event_mask;
+	uint8_t param;
+} __ec_align_size1;
+
+struct ec_response_device_event {
+	uint32_t event_mask;
+} __ec_align4;
+
 /*****************************************************************************/
 /* Smart battery pass-through */
 
@@ -4361,12 +4427,14 @@ enum ec_reboot_cmd {
 	/* (command 3 was jump to RW-B) */
 	EC_REBOOT_COLD = 4,          /* Cold-reboot */
 	EC_REBOOT_DISABLE_JUMP = 5,  /* Disable jump until next reboot */
-	EC_REBOOT_HIBERNATE = 6      /* Hibernate EC */
+	EC_REBOOT_HIBERNATE = 6,     /* Hibernate EC */
+	EC_REBOOT_HIBERNATE_CLEAR_AP_OFF = 7, /* and clears AP_OFF flag */
 };
 
 /* Flags for ec_params_reboot_ec.reboot_flags */
 #define EC_REBOOT_FLAG_RESERVED0      BIT(0)  /* Was recovery request */
 #define EC_REBOOT_FLAG_ON_AP_SHUTDOWN BIT(1)  /* Reboot after AP shutdown */
+#define EC_REBOOT_FLAG_SWITCH_RW_SLOT BIT(2)  /* Switch RW slot */
 
 struct ec_params_reboot_ec {
 	uint8_t cmd;           /* enum ec_reboot_cmd */
-- 
2.21.0.1020.gf2820cf01a-goog


  parent reply	other threads:[~2019-05-09 21:15 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-09 21:13 [PATCH v3 00/30] Update cros_ec_commands.h Gwendal Grignou
2019-05-09 21:13 ` [PATCH v3 01/30] mfd: cros_ec: Update license term Gwendal Grignou
2019-05-09 21:13 ` [PATCH v3 02/30] mfd: cros_ec: Zero BUILD_ macro Gwendal Grignou
2019-05-09 21:13 ` [PATCH v3 03/30] mfd: cros_ec: set comments properly Gwendal Grignou
2019-05-09 21:13 ` [PATCH v3 04/30] mfd: cros_ec: add ec_align macros Gwendal Grignou
2019-05-09 21:13 ` [PATCH v3 05/30] mfd: cros_ec: Define commands as 4-digit UPPER CASE hex values Gwendal Grignou
2019-05-09 21:13 ` [PATCH v3 06/30] mfd: cros_ec: use BIT macro Gwendal Grignou
2019-05-09 21:13 ` [PATCH v3 07/30] mfd: cros_ec: Update ACPI interface definition Gwendal Grignou
2019-05-09 21:13 ` [PATCH v3 08/30] mfd: cros_ec: move HDMI CEC API definition Gwendal Grignou
2019-05-09 21:13 ` [PATCH v3 09/30] mfd: cros_ec: Remove zero-size structs Gwendal Grignou
2019-05-09 21:13 ` [PATCH v3 10/30] mfd: cros_ec: Add Flash V2 commands API Gwendal Grignou
2019-05-09 21:13 ` [PATCH v3 11/30] mfd: cros_ec: Add PWM_SET_DUTY API Gwendal Grignou
2019-05-09 21:13 ` [PATCH v3 12/30] mfd: cros_ec: Add lightbar v2 API Gwendal Grignou
2019-05-09 21:13 ` [PATCH v3 13/30] mfd: cros_ec: Expand hash API Gwendal Grignou
2019-05-09 21:13 ` [PATCH v3 14/30] mfd: cros_ec: Add EC transport protocol v4 Gwendal Grignou
2019-05-09 21:13 ` [PATCH v3 15/30] mfd: cros_ec: Complete MEMS sensor API Gwendal Grignou
2019-05-09 21:13 ` [PATCH v3 16/30] mfd: cros_ec: Fix event processing API Gwendal Grignou
2019-05-09 21:13 ` [PATCH v3 17/30] mfd: cros_ec: Add fingerprint API Gwendal Grignou
2019-05-09 21:13 ` [PATCH v3 18/30] mfd: cros_ec: Fix temperature API Gwendal Grignou
2019-05-09 21:13 ` [PATCH v3 19/30] mfd: cros_ec: Complete Power and USB PD API Gwendal Grignou
2019-05-09 21:13 ` [PATCH v3 20/30] mfd: cros_ec: Add API for keyboard testing Gwendal Grignou
2019-05-09 21:13 ` Gwendal Grignou [this message]
2019-05-09 21:13 ` [PATCH v3 22/30] mfd: cros_ec: Add Smart Battery Firmware update API Gwendal Grignou
2019-05-09 21:13 ` [PATCH v3 23/30] mfd: cros_ec: Add I2C passthru protection API Gwendal Grignou
2019-05-09 21:13 ` [PATCH v3 24/30] mfd: cros_ec: Add API for EC-EC communication Gwendal Grignou
2019-05-09 21:13 ` [PATCH v3 25/30] mfd: cros_ec: Add API for Touchpad support Gwendal Grignou
2019-05-09 21:13 ` [PATCH v3 26/30] mfd: cros_ec: Add API for Fingerprint support Gwendal Grignou
2019-05-09 21:13 ` [PATCH v3 27/30] mfd: cros_ec: Add API for rwsig Gwendal Grignou
2019-05-09 21:13 ` [PATCH v3 28/30] mfd: cros_ec: Add SKU ID and Secure storage API Gwendal Grignou
2019-05-09 21:13 ` [PATCH v3 29/30] mfd: cros_ec: Add Management API entry points Gwendal Grignou
2019-05-09 21:13 ` [PATCH v3 30/30] mfd: cros_ec: Update I2S API Gwendal Grignou
2019-05-17 22:48 ` [PATCH v3 00/30] Update cros_ec_commands.h Gwendal Grignou
2019-05-18  6:39   ` Lee Jones
2019-05-21 17:44     ` Benson Leung
2019-05-22  5:53       ` Lee Jones
2019-05-21 13:45 ` [alsa-devel] " Fabien Lahoudere
2019-05-22  5:53   ` Lee Jones
2019-06-03 12:53 ` Lee Jones

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=20190509211353.213194-22-gwendal@chromium.org \
    --to=gwendal@chromium.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=bleung@chromium.org \
    --cc=broonie@kernel.org \
    --cc=cychiang@chromium.org \
    --cc=enric.balletbo@collabora.com \
    --cc=groeck@chromium.org \
    --cc=jic23@kernel.org \
    --cc=lee.jones@linaro.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tiwai@suse.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;
as well as URLs for NNTP newsgroup(s).