summaryrefslogtreecommitdiff
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
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>
-rw-r--r--zephyr/projects/nissa/src/nereid/board_config.c23
-rw-r--r--zephyr/projects/nissa/src/nivviks/board_config.c23
-rw-r--r--zephyr/projects/nissa/src/nivviks/usbc.c23
3 files changed, 46 insertions, 23 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.
+ */
+}
diff --git a/zephyr/projects/nissa/src/nivviks/board_config.c b/zephyr/projects/nissa/src/nivviks/board_config.c
index 88ec4de9c5..622bd7a7ac 100644
--- a/zephyr/projects/nissa/src/nivviks/board_config.c
+++ b/zephyr/projects/nissa/src/nivviks/board_config.c
@@ -9,6 +9,7 @@
#include <kernel.h>
#include <sys/printk.h>
+#include "driver/charger/isl923x_public.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 nivviks_subboard_init(void)
{
enum nissa_sub_board_type sb = nissa_get_sb_type();
@@ -75,3 +78,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)
+ raa489000_hibernate(CHARGER_SECONDARY, true);
+ raa489000_hibernate(CHARGER_PRIMARY, true);
+ 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.
+ */
+}
diff --git a/zephyr/projects/nissa/src/nivviks/usbc.c b/zephyr/projects/nissa/src/nivviks/usbc.c
index df217c6467..8a08eda3a8 100644
--- a/zephyr/projects/nissa/src/nivviks/usbc.c
+++ b/zephyr/projects/nissa/src/nivviks/usbc.c
@@ -10,7 +10,6 @@
#include "hooks.h"
#include "usb_mux.h"
#include "system.h"
-#include "driver/charger/isl923x_public.h"
#include "driver/tcpm/tcpci.h"
#include "driver/tcpm/raa489000.h"
@@ -41,28 +40,6 @@ struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
},
};
-/*
- * Board specific hibernate functions.
- */
-__override void board_hibernate(void)
-{
- /* Shut down the chargers */
- if (board_get_usb_pd_port_count() == 2)
- raa489000_hibernate(CHARGER_SECONDARY, true);
- raa489000_hibernate(CHARGER_PRIMARY, true);
- LOG_INF("Charger(s) hibernated");
- cflush();
-}
-
-__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.
- */
-}
-
int board_is_sourcing_vbus(int port)
{
int regval;