summaryrefslogtreecommitdiff
path: root/zephyr/include/ap_power
diff options
context:
space:
mode:
Diffstat (limited to 'zephyr/include/ap_power')
-rw-r--r--zephyr/include/ap_power/ap_power.h56
-rw-r--r--zephyr/include/ap_power/ap_power_espi.h35
-rw-r--r--zephyr/include/ap_power/ap_power_events.h2
-rw-r--r--zephyr/include/ap_power/ap_power_interface.h22
-rw-r--r--zephyr/include/ap_power/ap_pwrseq.h3
5 files changed, 98 insertions, 20 deletions
diff --git a/zephyr/include/ap_power/ap_power.h b/zephyr/include/ap_power/ap_power.h
index 182e81ca4d..05387d8431 100644
--- a/zephyr/include/ap_power/ap_power.h
+++ b/zephyr/include/ap_power/ap_power.h
@@ -1,4 +1,4 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* Copyright 2022 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -9,7 +9,16 @@
*
* Defines the API for AP event notification,
* the API to register and receive notification callbacks when
- * application processor (AP) events happen
+ * application processor (AP) events happen.
+ *
+ * When the Zephyr based AP power sequence config is enabled,
+ * the callbacks are almost all invoked within the context
+ * of the power sequence task, so the state is stable
+ * during the callback. The only exception to this is AP_POWER_RESET, which is
+ * invoked as a result of receiving a PLTRST# virtual wire signal (if enabled).
+ *
+ * When the legacy power sequence config is enabled, the callbacks are invoked
+ * from the HOOK_CHIPSET notifications.
*/
#ifndef __AP_POWER_AP_POWER_H__
@@ -87,6 +96,36 @@ enum ap_power_events {
AP_POWER_HARD_OFF = BIT(8),
/** Software reset occurred */
AP_POWER_RESET = BIT(9),
+ /**
+ * AP power state is now known.
+ *
+ * Prior to this event, the state of the AP is unknown
+ * and invalid. When this event is sent, the state is known
+ * and can be queried. Used by clients when their
+ * initialization depends upon the initial state of the AP.
+ */
+ AP_POWER_INITIALIZED = BIT(10),
+
+ /**
+ * S0ix suspend starts.
+ */
+ AP_POWER_S0IX_SUSPEND_START = BIT(11),
+ /**
+ * Transitioning from s0 to s0ix.
+ */
+ AP_POWER_S0IX_SUSPEND = BIT(12),
+ /**
+ * Transitioning from s0ix to s0.
+ */
+ AP_POWER_S0IX_RESUME = BIT(13),
+ /**
+ * si0x resume complete.
+ */
+ AP_POWER_S0IX_RESUME_COMPLETE = BIT(14),
+ /**
+ * Reset s0ix tracking.
+ */
+ AP_POWER_S0IX_RESET_TRACKING = BIT(15),
};
/**
@@ -113,12 +152,12 @@ typedef void (*ap_power_ev_callback_handler_t)(struct ap_power_ev_callback *cb,
* are unique pointers of struct ap_power_ev_callback.
* The storage must be static.
*
- * ap_power_ev_init_callback can be used to initialise this structure.
+ * ap_power_ev_init_callback can be used to initialize this structure.
*/
struct ap_power_ev_callback {
- sys_snode_t node; /* Only usable by AP power event code */
+ sys_snode_t node; /* Only usable by AP power event code */
ap_power_ev_callback_handler_t handler;
- enum ap_power_events events; /* Events to listen for */
+ enum ap_power_events events; /* Events to listen for */
};
/** @endcond */
@@ -129,9 +168,10 @@ struct ap_power_ev_callback {
* @param handler The function pointer to call.
* @param events The bitmask of events to be called for.
*/
-static inline void ap_power_ev_init_callback(struct ap_power_ev_callback *cb,
- ap_power_ev_callback_handler_t handler,
- enum ap_power_events events)
+static inline void
+ap_power_ev_init_callback(struct ap_power_ev_callback *cb,
+ ap_power_ev_callback_handler_t handler,
+ enum ap_power_events events)
{
__ASSERT(cb, "Callback pointer should not be NULL");
__ASSERT(handler, "Callback handler pointer should not be NULL");
diff --git a/zephyr/include/ap_power/ap_power_espi.h b/zephyr/include/ap_power/ap_power_espi.h
new file mode 100644
index 0000000000..2c295054f3
--- /dev/null
+++ b/zephyr/include/ap_power/ap_power_espi.h
@@ -0,0 +1,35 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/**
+ * @file
+ * @brief API for power signal ESPI callback.
+ */
+
+#ifndef __AP_POWER_AP_POWER_ESPI_H__
+#define __AP_POWER_AP_POWER_ESPI_H__
+
+#include <zephyr/drivers/espi.h>
+
+/**
+ * @brief ESPI callback for power signal handling.
+ *
+ * This callback must be registered for the bus events indicated below
+ * as part of the common ESPI initialisation and configuration.
+ *
+ * @param dev ESPI device
+ * @param cb Callback structure
+ * @param event ESPI event data
+ */
+void power_signal_espi_cb(const struct device *dev, struct espi_callback *cb,
+ struct espi_event event);
+
+/*
+ * The ESPI bus events required for the power signal ESPI callback.
+ */
+#define POWER_SIGNAL_ESPI_BUS_EVENTS \
+ (ESPI_BUS_EVENT_CHANNEL_READY | ESPI_BUS_EVENT_VWIRE_RECEIVED)
+
+#endif /* __AP_POWER_AP_POWER_ESPI_H__ */
diff --git a/zephyr/include/ap_power/ap_power_events.h b/zephyr/include/ap_power/ap_power_events.h
index 6181deb2bd..8a6a9764de 100644
--- a/zephyr/include/ap_power/ap_power_events.h
+++ b/zephyr/include/ap_power/ap_power_events.h
@@ -1,4 +1,4 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* Copyright 2022 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
diff --git a/zephyr/include/ap_power/ap_power_interface.h b/zephyr/include/ap_power/ap_power_interface.h
index b82ef053f7..d2808f6075 100644
--- a/zephyr/include/ap_power/ap_power_interface.h
+++ b/zephyr/include/ap_power/ap_power_interface.h
@@ -1,4 +1,4 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* Copyright 2022 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -34,6 +34,8 @@
* is hibernated or all the VRs are turned off.
*/
enum power_states_ndsx {
+ /* Power state machine is not ready; AP state is unknown. */
+ SYS_POWER_STATE_UNINIT,
/*
* Actual power states
*/
@@ -87,17 +89,17 @@ enum power_states_ndsx {
* @brief Represents the state of the AP as a mask.
*/
enum ap_power_state_mask {
- AP_POWER_STATE_HARD_OFF = BIT(0), /* Hard off (G3) */
- AP_POWER_STATE_SOFT_OFF = BIT(1), /* Soft off (S5, S4) */
- AP_POWER_STATE_SUSPEND = BIT(2), /* Suspend (S3) */
- AP_POWER_STATE_ON = BIT(3), /* On (S0) */
- AP_POWER_STATE_STANDBY = BIT(4), /* Standby (S0ix) */
+ AP_POWER_STATE_HARD_OFF = BIT(0), /* Hard off (G3) */
+ AP_POWER_STATE_SOFT_OFF = BIT(1), /* Soft off (S5, S4) */
+ AP_POWER_STATE_SUSPEND = BIT(2), /* Suspend (S3) */
+ AP_POWER_STATE_ON = BIT(3), /* On (S0) */
+ AP_POWER_STATE_STANDBY = BIT(4), /* Standby (S0ix) */
/* Common combinations, any off state */
- AP_POWER_STATE_ANY_OFF = (AP_POWER_STATE_HARD_OFF |
- AP_POWER_STATE_SOFT_OFF),
+ AP_POWER_STATE_ANY_OFF =
+ (AP_POWER_STATE_HARD_OFF | AP_POWER_STATE_SOFT_OFF),
/* This combination covers any kind of suspend i.e. S3 or S0ix. */
- AP_POWER_STATE_ANY_SUSPEND = (AP_POWER_STATE_SUSPEND |
- AP_POWER_STATE_STANDBY),
+ AP_POWER_STATE_ANY_SUSPEND =
+ (AP_POWER_STATE_SUSPEND | AP_POWER_STATE_STANDBY),
};
/**
diff --git a/zephyr/include/ap_power/ap_pwrseq.h b/zephyr/include/ap_power/ap_pwrseq.h
index c83a8b5695..9e1ffd27e8 100644
--- a/zephyr/include/ap_power/ap_pwrseq.h
+++ b/zephyr/include/ap_power/ap_pwrseq.h
@@ -1,4 +1,4 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* Copyright 2022 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -9,4 +9,5 @@
/** Starts the AP power sequence thread */
void ap_pwrseq_task_start(void);
+void ap_pwrseq_wake(void);
#endif /* __AP_POWER_AP_PWRSEQ_H__ */