From b30f7b8528b87933c4c060aa26019c04227fa3f1 Mon Sep 17 00:00:00 2001 From: Wai-Hong Tam Date: Thu, 29 Apr 2021 16:41:54 -0700 Subject: trogdor: Move the hibernate functions into separate files Move the hiberante functions from baseboard.c and board.c to separate hibernate.c files. This makes Zephyr easier to include the code. BRANCH=None BUG=b:183745774 TEST=Built the EC image and tested EC hibernate on Lazor. Change-Id: Ic2f0a73687075c5d6c0dddbb329abea7a0f27053 Signed-off-by: Wai-Hong Tam Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2861057 Reviewed-by: Jack Rosenthal --- board/lazor/board.c | 31 ------------------------------- board/lazor/build.mk | 1 + board/lazor/hibernate.c | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 31 deletions(-) create mode 100644 board/lazor/hibernate.c (limited to 'board/lazor') diff --git a/board/lazor/board.c b/board/lazor/board.c index e9d5f101e3..4ad8cf51fe 100644 --- a/board/lazor/board.c +++ b/board/lazor/board.c @@ -393,37 +393,6 @@ static void board_init(void) } DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); -void board_hibernate(void) -{ - int i; - - if (!board_is_clamshell()) { - /* - * Sensors are unpowered in hibernate. Apply PD to the - * interrupt lines such that they don't float. - */ - gpio_set_flags(GPIO_ACCEL_GYRO_INT_L, - GPIO_INPUT | GPIO_PULL_DOWN); - gpio_set_flags(GPIO_LID_ACCEL_INT_L, - GPIO_INPUT | GPIO_PULL_DOWN); - } - - /* - * Board rev 5+ has the hardware fix. Don't need the following - * workaround. - */ - if (system_get_board_version() >= 5) - return; - - /* - * Enable the PPC power sink path before EC enters hibernate; - * otherwise, ACOK won't go High and can't wake EC up. Check the - * bug b/170324206 for details. - */ - for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) - ppc_vbus_sink_enable(i, 1); -} - /* Called on AP S0 -> S3 transition */ static void board_chipset_suspend(void) { diff --git a/board/lazor/build.mk b/board/lazor/build.mk index b51eda7cfd..8cf8679e35 100644 --- a/board/lazor/build.mk +++ b/board/lazor/build.mk @@ -13,6 +13,7 @@ BASEBOARD:=trogdor board-y+=battery.o board-y+=board.o +board-y+=hibernate.o board-y+=led.o board-y+=sku.o board-y+=switchcap.o diff --git a/board/lazor/hibernate.c b/board/lazor/hibernate.c new file mode 100644 index 0000000000..2b9bfa44eb --- /dev/null +++ b/board/lazor/hibernate.c @@ -0,0 +1,39 @@ +/* Copyright 2021 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "common.h" +#include "system.h" +#include "usbc_ppc.h" + +void board_hibernate(void) +{ + int i; + + if (!board_is_clamshell()) { + /* + * Sensors are unpowered in hibernate. Apply PD to the + * interrupt lines such that they don't float. + */ + gpio_set_flags(GPIO_ACCEL_GYRO_INT_L, + GPIO_INPUT | GPIO_PULL_DOWN); + gpio_set_flags(GPIO_LID_ACCEL_INT_L, + GPIO_INPUT | GPIO_PULL_DOWN); + } + + /* + * Board rev 5+ has the hardware fix. Don't need the following + * workaround. + */ + if (system_get_board_version() >= 5) + return; + + /* + * Enable the PPC power sink path before EC enters hibernate; + * otherwise, ACOK won't go High and can't wake EC up. Check the + * bug b/170324206 for details. + */ + for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) + ppc_vbus_sink_enable(i, 1); +} -- cgit v1.2.1