summaryrefslogtreecommitdiff
path: root/power/sdm845.c
diff options
context:
space:
mode:
authorWai-Hong Tam <waihong@google.com>2018-07-20 18:21:13 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-08-13 14:25:13 -0700
commit25c001a6faf1f2db2fd507e945acb92eac911a1a (patch)
treed2f3822f1630fa572e05bd7c7815417b47bb4003 /power/sdm845.c
parent733f93440155db11b8d56c926e501e949da9534b (diff)
downloadchrome-ec-25c001a6faf1f2db2fd507e945acb92eac911a1a.tar.gz
cheza: Check switchcap GPIO0 which indicates outputting good voltage
When turnning the switchcap on, wait its GPIO0 asserted. The GPIO0 is configured as PVC_PG. When the output voltage is over the threshold PVC_PG_ADJ (3.0V), the PVC_PG is asserted. BRANCH=none BUG=b:77957956 TEST=Run "power on" and "power off" on EC console. Adding debug messages, confirmed waiting the signal asserted. Change-Id: Iac72be5290c7ba9988b5861db1dbd84c24f93eda Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/1145952 Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Diffstat (limited to 'power/sdm845.c')
-rw-r--r--power/sdm845.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/power/sdm845.c b/power/sdm845.c
index 89ff8cdb98..881761035e 100644
--- a/power/sdm845.c
+++ b/power/sdm845.c
@@ -67,6 +67,12 @@
/* Wait for polling if the system can boot AP */
#define CAN_BOOT_AP_CHECK_WAIT (100 * MSEC)
+/* The timeout of the check if the switchcap outputs good voltage */
+#define SWITCHCAP_PG_CHECK_TIMEOUT (50 * MSEC)
+
+/* Wait for polling if the switchcap outputs good voltage */
+#define SWITCHCAP_PG_CHECK_WAIT (5 * MSEC)
+
/* Delay between power-on the system and power-on the PMIC */
#define SYSTEM_POWER_ON_DELAY (10 * MSEC)
@@ -212,6 +218,42 @@ DECLARE_HOOK(HOOK_POWER_BUTTON_CHANGE, powerbtn_sdm845_changed,
HOOK_PRIO_DEFAULT);
/**
+ * Wait the switchcap GPIO0 PVC_PG signal asserted.
+ *
+ * When the output voltage is over the threshold PVC_PG_ADJ,
+ * the PVC_PG is asserted.
+ *
+ * PVG_PG_ADJ is configured to 3.0V.
+ * GPIO0 is configured as PVC_PG.
+ *
+ * @param enable 1 to wait the PMIC/AP on.
+ 0 to wait the PMIC/AP off.
+ */
+static void wait_switchcap_power_good(int enable)
+{
+ timestamp_t poll_deadline;
+
+ poll_deadline = get_time();
+ poll_deadline.val += SWITCHCAP_PG_CHECK_TIMEOUT;
+ while (enable != gpio_get_level(GPIO_DA9313_GPIO0) &&
+ get_time().val < poll_deadline.val) {
+ usleep(SWITCHCAP_PG_CHECK_WAIT);
+ }
+
+ /*
+ * Check the timeout case. Just show a message. More check later
+ * will switch the power state.
+ */
+ if (enable != gpio_get_level(GPIO_DA9313_GPIO0)) {
+ if (enable)
+ CPRINTS("SWITCHCAP NO POWER GOOD!");
+ else
+ CPRINTS("SWITCHCAP STILL POWER GOOD!");
+ }
+
+}
+
+/**
* Set the state of the system power signals.
*
* The system power signals are the enable pins of SwitchCap and VBOB.
@@ -223,6 +265,7 @@ static void set_system_power(int enable)
{
CPRINTS("set_system_power(%d)", enable);
gpio_set_level(GPIO_SWITCHCAP_ON_L, enable);
+ wait_switchcap_power_good(enable);
gpio_set_level(GPIO_VBOB_EN, enable);
}