summaryrefslogtreecommitdiff
path: root/include/power.h
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2017-10-16 16:03:24 -0700
committerchrome-bot <chrome-bot@chromium.org>2017-10-23 04:28:23 -0700
commitb6733343abb6d9b7ce7446b94f312dab51d46fac (patch)
treed54387e14251c5285e09225658e79a8822a42554 /include/power.h
parent8d639f58ea58c851eb226af9fe676693fbc901f8 (diff)
downloadchrome-ec-b6733343abb6d9b7ce7446b94f312dab51d46fac.tar.gz
power: Add task-safe API to control 5V rail.
For certain cannonlake designs, the 5V rail can be controlled by both the chipset task as well as other tasks such as the USB charger tasks to perform BC1.2 detection. This commit introduces an API that allows the tasks to enable/disable the 5V rail. Enable requests will immediately enable the rail, however, attempting to disable the rail will only result in a request. Once all tasks want to turn off the 5V rail, the rail will be turned off. A bitmask is introduced to keep track of the requests. Index 0 is for the chipset task. All of this is gated behind a config option: CONFIG_POWER_PP5000_CONTROL BUG=b:65991615 BRANCH=None TEST=With other zoombini code, verify that 5V can be enabled and disabled. Change-Id: I1722b4a272c4d6ee24408929f5a7402051bb9cf3 Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/722322 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org>
Diffstat (limited to 'include/power.h')
-rw-r--r--include/power.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/include/power.h b/include/power.h
index 52316628fd..20b2ee6cf6 100644
--- a/include/power.h
+++ b/include/power.h
@@ -10,6 +10,7 @@
#include "common.h"
#include "gpio.h"
+#include "task_id.h"
enum power_state {
/* Steady states */
@@ -209,4 +210,18 @@ void power_reset_host_sleep_state(enum host_sleep_event sleep_event);
#endif /* CONFIG_POWER_S0IX */
#endif /* CONFIG_POWER_TRACK_HOST_SLEEP_STATE */
+/**
+ * Enable/Disable the PP5000 rail.
+ *
+ * This function will turn on the 5V rail immediately if requested. However,
+ * the rail will not turn off until all tasks want it off.
+ *
+ * NOTE: Be careful when calling from deferred functions, as they will all be
+ * executed within the same task context! (The HOOKS task).
+ *
+ * @param tid: The caller's task ID.
+ * @param enable: 1 to turn on the rail, 0 to request the rail to be turned off.
+ */
+void power_5v_enable(task_id_t tid, int enable);
+
#endif /* __CROS_EC_POWER_H */