summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-01-21 10:57:32 -0700
committerCommit Bot <commit-bot@chromium.org>2021-01-22 22:53:14 +0000
commit78acb0eeac7e3e42dae13f907440d92d3e6c1aac (patch)
tree5f8486674ec967233a350ac5fbde20951923e6d0
parent9c2c2455beaa6bc5851bfae11740f05aaecb312b (diff)
downloadchrome-ec-78acb0eeac7e3e42dae13f907440d92d3e6c1aac.tar.gz
zephyr: Add support for CHIPSET_RESET_HOOK
Add the options for this and call the hook when enabled. We could avoid the #ifdef by always having espi_reset_handler(). I'm not sure if there is a better way. BUG=b:178104134 BRANCH=none TEST=build for zephyr not sure how to test this feature? Signed-off-by: Simon Glass <sjg@chromium.org> Change-Id: I68d15bb112bc708af6f65befd08f05cb6bc209e0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2642891 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
-rw-r--r--zephyr/Kconfig15
-rw-r--r--zephyr/shim/include/config_chip.h5
-rw-r--r--zephyr/shim/src/espi.c23
3 files changed, 43 insertions, 0 deletions
diff --git a/zephyr/Kconfig b/zephyr/Kconfig
index 822d75f65d..d83f53c884 100644
--- a/zephyr/Kconfig
+++ b/zephyr/Kconfig
@@ -90,6 +90,21 @@ config PLATFORM_EC_CBI
https://chromium.googlesource.com/chromiumos/docs/+/master/design_docs/cros_board_info.md
+config PLATFORM_EC_CHIPSET_RESET_HOOK
+ bool "Provide a hook for when the AP resets"
+ default y
+ help
+ Enables support for the HOOK_CHIPSET_RESET hook. This can be used by
+ code that needs to run before a programmatic reset actually happens.
+ Note that these hooks don't run with a cold reset, only when the AP
+ decides to reset itself.
+
+ You can declare a hook like this:
+
+ DECLARE_HOOK(HOOK_CHIPSET_RESET, do_something, HOOK_PRIO_DEFAULT);
+
+ Then do_something() will be called just before the reset happens.
+
menuconfig PLATFORM_EC_ESPI
bool "eSPI"
depends on ESPI && AP
diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h
index fff357ba3d..f683e46dad 100644
--- a/zephyr/shim/include/config_chip.h
+++ b/zephyr/shim/include/config_chip.h
@@ -92,6 +92,11 @@ enum battery_type {
#define CONFIG_CHARGER_INPUT_CURRENT 512
#endif
+#undef CONFIG_CHIPSET_RESET_HOOK
+#ifdef CONFIG_PLATFORM_EC_CHIPSET_RESET_HOOK
+#define CONFIG_CHIPSET_RESET_HOOK
+#endif
+
#ifdef CONFIG_PLATFORM_EC_EXTPOWER_GPIO
/* This always needs to be defined for this option to work */
#define CONFIG_EXTPOWER
diff --git a/zephyr/shim/src/espi.c b/zephyr/shim/src/espi.c
index 7f653f9543..2652aafa97 100644
--- a/zephyr/shim/src/espi.c
+++ b/zephyr/shim/src/espi.c
@@ -159,6 +159,23 @@ static void espi_peripheral_handler(const struct device *dev,
}
}
+#ifdef CONFIG_PLATFORM_EC_CHIPSET_RESET_HOOK
+static void espi_chipset_reset(void)
+{
+ hook_notify(HOOK_CHIPSET_RESET);
+}
+DECLARE_DEFERRED(espi_chipset_reset);
+
+/* Callback for reset */
+static void espi_reset_handler(const struct device *dev,
+ struct espi_callback *cb,
+ struct espi_event event)
+{
+ hook_call_deferred(&espi_chipset_reset_data, MSEC);
+
+}
+#endif /* CONFIG_PLATFORM_EC_CHIPSET_RESET_HOOK */
+
#define ESPI_DEV DT_LABEL(DT_NODELABEL(espi0))
static const struct device *espi_dev;
@@ -177,6 +194,12 @@ int zephyr_shim_setup_espi(void)
.handler = espi_peripheral_handler,
.event_type = ESPI_BUS_PERIPHERAL_NOTIFICATION,
},
+#ifdef CONFIG_PLATFORM_EC_CHIPSET_RESET_HOOK
+ {
+ .handler = espi_reset_handler,
+ .event_type = ESPI_BUS_RESET,
+ },
+#endif
};
struct espi_cfg cfg = {