summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDuncan Laurie <dlaurie@google.com>2018-01-31 12:55:27 -0800
committerDaisuke Nojiri <dnojiri@chromium.org>2018-02-19 10:33:13 -0800
commit7b74baa39dcefb0af8c139485ef5f06d80997624 (patch)
tree950e1eeb8e2733603490e5493e44e0b5111bfa84
parent9d3d33d172f23f1ef5790461fe89e6808fa00435 (diff)
downloadchrome-ec-7b74baa39dcefb0af8c139485ef5f06d80997624.tar.gz
eve: Use PCH ACOK signal to control Deep Sleep entry
Deep Sleep states (DS3, DS5) are a special mode of the Intel PCH chipset that has very limited wake capabilities and breaks a number of common user expected behahviors. In particular, when in Deep S3 the USB ports are turned off and cannot continue to charge, wake the system, or maintain their internal state as they will lose 5V power. This is particularly painful with gnubby devices as they will need unlocked after every DS3 suspend/resume cycle. The only external signal that the PCH uses to determine whether or not to enter Deep Sx states is the ACPRESENT (aka ACOK) pin. Currently this pin is simply buffered from the charger and will be asserted whenever a charger is connected. This change extends the EC control over the pin to also assert ACPRESENT if either Type-C port is currently supplying VBUS. Now when a USB device is inserted the system will be enter S3 state, but not go into Deep S3 state. This allows the USB device to continue to charge, maintain it's internal state, and wake the system. BUG=b:64406191 BRANCH=eve TEST=verify GPIO_PCH_ACOK pin from the EC in different scenarios and test that system goes into S3 or DS3 state as expected: 1) no charger, no USB device: ACOK not asserted, DS3 enabled 2) charger but no USB device: ACOK asserted, DS3 disabled 3) no charger but USB device: ACOK asserted, DS3 disabled 4) charger and USB device: ACOK asserted, DS3 disabled Change-Id: I1cd132459194382e418970d29b1b195d8132cfad Signed-off-by: Duncan Laurie <dlaurie@google.com> Reviewed-on: https://chromium-review.googlesource.com/896164 Reviewed-by: Furquan Shaikh <furquan@chromium.org>
-rw-r--r--board/eve/board.c26
-rw-r--r--board/eve/board.h1
-rw-r--r--board/eve/usb_pd_policy.c6
3 files changed, 22 insertions, 11 deletions
diff --git a/board/eve/board.c b/board/eve/board.c
index 77de5ef0f5..0f0fabce6b 100644
--- a/board/eve/board.c
+++ b/board/eve/board.c
@@ -444,6 +444,19 @@ int board_has_working_reset_flags(void)
return 1;
}
+/*
+ * Update status of the ACPRESENT pin on the PCH. In order to prevent
+ * Deep S3 when USB is inserted this will indicate that AC is present
+ * if either port is supplying VBUS or there an external charger present.
+ */
+void board_update_ac_status(void)
+{
+ gpio_set_level(GPIO_PCH_ACOK, extpower_is_present() ||
+ board_vbus_source_enabled(0) ||
+ board_vbus_source_enabled(1));
+}
+DECLARE_HOOK(HOOK_AC_CHANGE, board_update_ac_status, HOOK_PRIO_DEFAULT);
+
/* Initialize board. */
static void board_init(void)
{
@@ -459,8 +472,8 @@ static void board_init(void)
/* Enable interrupts from BMI160 sensor. */
gpio_enable_interrupt(GPIO_ACCELGYRO3_INT_L);
- /* Provide AC status to the PCH */
- gpio_set_level(GPIO_PCH_ACOK, extpower_is_present());
+ /* Update AC status to the PCH */
+ board_update_ac_status();
#if defined(CONFIG_KEYBOARD_SCANCODE_MUTABLE) && !defined(TEST_BUILD)
if (board_get_version() == 4) {
@@ -473,15 +486,6 @@ static void board_init(void)
}
DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
-/**
- * Buffer the AC present GPIO to the PCH.
- */
-static void board_extpower(void)
-{
- gpio_set_level(GPIO_PCH_ACOK, extpower_is_present());
-}
-DECLARE_HOOK(HOOK_AC_CHANGE, board_extpower, HOOK_PRIO_DEFAULT);
-
int pd_snk_is_vbus_provided(int port)
{
if (port != 0 && port != 1)
diff --git a/board/eve/board.h b/board/eve/board.h
index af33329374..e843f3a952 100644
--- a/board/eve/board.h
+++ b/board/eve/board.h
@@ -297,6 +297,7 @@ int board_get_version(void);
void board_reset_pd_mcu(void);
void board_set_tcpc_power_mode(int port, int mode);
void led_register_double_tap(void);
+void board_update_ac_status(void);
/* Sensors without hardware FIFO are in forced mode */
#define CONFIG_ACCEL_FORCE_MODE_MASK ((1 << LID_ACCEL) | (1 << LID_LIGHT))
diff --git a/board/eve/usb_pd_policy.c b/board/eve/usb_pd_policy.c
index 73cb23aa85..1d5540aac1 100644
--- a/board/eve/usb_pd_policy.c
+++ b/board/eve/usb_pd_policy.c
@@ -125,6 +125,9 @@ int pd_set_power_supply_ready(int port)
/* notify host of power info change */
pd_send_host_event(PD_EVENT_POWER_CHANGE);
+ /* Update AC status to the PCH */
+ board_update_ac_status();
+
return EC_SUCCESS; /* we are ready */
}
@@ -147,6 +150,9 @@ void pd_power_supply_reset(int port)
/* notify host of power info change */
pd_send_host_event(PD_EVENT_POWER_CHANGE);
+
+ /* Update AC status to the PCH */
+ board_update_ac_status();
}
int pd_board_checks(void)