summaryrefslogtreecommitdiff
path: root/zephyr/projects/nissa/src/nereid/board_config.c
diff options
context:
space:
mode:
authorPeter Marheine <pmarheine@chromium.org>2022-02-16 14:18:48 +1100
committerCommit Bot <commit-bot@chromium.org>2022-02-16 09:50:33 +0000
commit8a0fd6787abdd5315032066eca3868fdd9133d75 (patch)
tree18aef977ce2f5e5e621dce10f13b04d3df4b5968 /zephyr/projects/nissa/src/nereid/board_config.c
parenta9f8632cbaceea7bf93ebba5933b7d658b97fb5d (diff)
downloadchrome-ec-8a0fd6787abdd5315032066eca3868fdd9133d75.tar.gz
nissa: implement hibernate for nereid
The board_hibernate() functions are moved out of the usbc files since hibernation isn't directly related to USB or charging. BUG=b:219808597 TEST=`hibernate` on console hibernates nereid & nivviks BRANCH=none Signed-off-by: Peter Marheine <pmarheine@chromium.org> Change-Id: I1ff3470906e7757e62e802b9712e3f4d2616a5e0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3466682 Reviewed-by: Andrew McRae <amcrae@google.com> Commit-Queue: Andrew McRae <amcrae@google.com>
Diffstat (limited to 'zephyr/projects/nissa/src/nereid/board_config.c')
-rw-r--r--zephyr/projects/nissa/src/nereid/board_config.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/zephyr/projects/nissa/src/nereid/board_config.c b/zephyr/projects/nissa/src/nereid/board_config.c
index 54480d1177..6454c7aa7b 100644
--- a/zephyr/projects/nissa/src/nereid/board_config.c
+++ b/zephyr/projects/nissa/src/nereid/board_config.c
@@ -9,6 +9,7 @@
#include <kernel.h>
#include <sys/printk.h>
+#include "driver/charger/sm5803.h"
#include "gpio.h"
#include "gpio/gpio_int.h"
#include "hooks.h"
@@ -17,6 +18,8 @@
#include "sub_board.h"
+LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
+
static void nereid_subboard_init(void)
{
enum nissa_sub_board_type sb = nissa_get_sb_type();
@@ -73,3 +76,23 @@ static void board_init(void)
gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1));
}
DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
+
+__override void board_hibernate(void)
+{
+ /* Shut down the chargers */
+ if (board_get_usb_pd_port_count() == 2)
+ sm5803_hibernate(CHARGER_SECONDARY);
+ sm5803_hibernate(CHARGER_PRIMARY);
+ LOG_INF("Charger(s) hibernated");
+ cflush();
+}
+
+/* Trigger shutdown by enabling the Z-sleep circuit */
+__override void board_hibernate_late(void)
+{
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_en_slp_z), 1);
+ /*
+ * The system should hibernate, but there may be
+ * a small delay, so return.
+ */
+}