summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2020-04-21 20:27:28 -0700
committerCommit Bot <commit-bot@chromium.org>2020-04-23 03:08:04 +0000
commit00589b7ec50c2faa4aaa3e0d3310777b10c1ffa2 (patch)
tree7f7dcb94e1469f9d6b1bea378a7f8205e05d5b9d
parent333df910313489744af4087d7bf6759f68359267 (diff)
downloadchrome-ec-00589b7ec50c2faa4aaa3e0d3310777b10c1ffa2.tar.gz
dedede: Add board_vbus_presence_change()
Dedede doesn't have a dedicated interrupt for ACOK, however we can use the charger or TCPC to inform us when AC is OK through other means. This commit uses the board_vbus_presence_change() trigger to trigger the HOOK_AC_CHANGE hook. BUG=b:154113446,b:154113465 BRANCH=None TEST=Build and flash waddledoo, plug in AC, verify that "AC on" prints are seen. Unplug AC, verify that "AC off" prints are seen. Signed-off-by: Aseda Aboagye <aaboagye@google.com> Change-Id: I1621135499bb65d13aef4f7fec76bd366def3bdc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2159942 Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r--baseboard/dedede/baseboard.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/baseboard/dedede/baseboard.c b/baseboard/dedede/baseboard.c
index f7fa77feed..fd880dba83 100644
--- a/baseboard/dedede/baseboard.c
+++ b/baseboard/dedede/baseboard.c
@@ -9,8 +9,10 @@
#include "board_config.h"
#include "chipset.h"
#include "common.h"
+#include "extpower.h"
#include "gpio.h"
#include "hooks.h"
+#include "host_command.h"
#include "intel_x86.h"
/******************************************************************************/
@@ -94,6 +96,28 @@ __override void board_after_rsmrst(int rsmrst)
gpio_set_flags(GPIO_PG_PP1050_ST_OD, flags);
}
+/*
+ * Dedede does not have a GPIO indicating ACOK, therefore the charger or TCPC
+ * can call this function once it detects a VBUS presence change with which we
+ * can trigger the HOOK_AC_CHANGE hook.
+ */
+__override void board_vbus_present_change(void)
+{
+ static int last_extpower_present;
+ int extpower_present = extpower_is_present();
+
+ if (last_extpower_present ^ extpower_present) {
+ hook_notify(HOOK_AC_CHANGE);
+
+ if (extpower_present)
+ host_set_single_event(EC_HOST_EVENT_AC_CONNECTED);
+ else
+ host_set_single_event(EC_HOST_EVENT_AC_DISCONNECTED);
+ }
+
+ last_extpower_present = extpower_present;
+}
+
uint32_t pp3300_a_pgood;
__override int intel_x86_get_pg_ec_dsw_pwrok(void)
{