summaryrefslogtreecommitdiff
path: root/zephyr/subsys
diff options
context:
space:
mode:
authorAndrew McRae <amcrae@google.com>2022-07-12 12:44:16 +1000
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-07-13 07:30:48 +0000
commit7c6d8dab8fd7958e0334c665d6a922eecea670f8 (patch)
tree4184da7807a9dc7213fc7671fcb3e05d0de66c42 /zephyr/subsys
parent44031c6e382eb02ecef93280a5c54b4416f678fe (diff)
downloadchrome-ec-7c6d8dab8fd7958e0334c665d6a922eecea670f8.tar.gz
ap_pwrseq: Use common ESPI init and callback
Use common ESPI init and callback for power signals ESPI callback so that signal changes are guaranteed to be received by the power signal VW handler. BUG=b:237449433 TEST=zmake build nivviks; flash & run BRANCH=none Signed-off-by: Andrew McRae <amcrae@google.com> Change-Id: I1dfbc45bd1944ab124bec42897617463190b6853 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3756994 Reviewed-by: Peter Marheine <pmarheine@chromium.org>
Diffstat (limited to 'zephyr/subsys')
-rw-r--r--zephyr/subsys/ap_pwrseq/signal_vw.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/zephyr/subsys/ap_pwrseq/signal_vw.c b/zephyr/subsys/ap_pwrseq/signal_vw.c
index d2c3c0a8d1..2836a31f20 100644
--- a/zephyr/subsys/ap_pwrseq/signal_vw.c
+++ b/zephyr/subsys/ap_pwrseq/signal_vw.c
@@ -13,6 +13,15 @@
#if HAS_VW_SIGNALS
+/*
+ * A callback must be registered on the ESPI device (for the
+ * bus events that are required to be handled) that calls
+ * power_signal_espi_cb().
+ *
+ * This registration is done in a common ESPI initialisation module so
+ * that there is no possibility of missing events.
+ */
+
LOG_MODULE_DECLARE(ap_pwrseq, CONFIG_AP_PWRSEQ_LOG_LEVEL);
#define INIT_ESPI_SIGNAL(id) \
@@ -48,8 +57,8 @@ static atomic_t signal_valid;
BUILD_ASSERT(ARRAY_SIZE(vw_config) <= (sizeof(atomic_t) * 8));
-static void espi_handler(const struct device *dev, struct espi_callback *cb,
- struct espi_event event)
+void power_signal_espi_cb(const struct device *dev, struct espi_callback *cb,
+ struct espi_event event)
{
LOG_DBG("ESPI event type 0x%x %d:%d", event.evt_type, event.evt_details,
event.evt_data);
@@ -94,15 +103,6 @@ int power_signal_vw_get(enum pwr_sig_vw vw)
void power_signal_vw_init(void)
{
- static struct espi_callback espi_cb;
-
- /* Assumes ESPI device is already configured. */
-
- /* Configure handler for eSPI events */
- espi_init_callback(&espi_cb, espi_handler,
- ESPI_BUS_EVENT_CHANNEL_READY |
- ESPI_BUS_EVENT_VWIRE_RECEIVED);
- espi_add_callback(espi_dev, &espi_cb);
/*
* Check whether the bus is ready, and if so,
* initialise the current values of the signals.