summaryrefslogtreecommitdiff
path: root/common/host_command_pd.c
diff options
context:
space:
mode:
authorDuncan Laurie <dlaurie@chromium.org>2014-06-20 18:39:05 +0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-06-27 18:31:31 +0000
commit635a57eedede073773e461101a2f6251ad57eb89 (patch)
treeacaa18734f534603c2d12513cf80ef0cfd25636b /common/host_command_pd.c
parentae15dc8ce512d58c7c7757ebfd12c3ca76eb4a08 (diff)
downloadchrome-ec-635a57eedede073773e461101a2f6251ad57eb89.tar.gz
samus: hack to read AC present state from PD
The ACOK input to the EC is not connected to the charger so that signal cannot be relied on for AC presence. Instead have the PD report when it negotiates to 20V and when it disconnects and have the EC use that for AC presence. BUG=chrome-os-partner:29841 BRANCH=none TEST=test charging with zinger on samus system. Change-Id: Ia9096a24ab05d110e31910218dc8c214a846a9a4 Signed-off-by: Duncan Laurie <dlaurie@chromium.org> Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/205145 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'common/host_command_pd.c')
-rw-r--r--common/host_command_pd.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/common/host_command_pd.c b/common/host_command_pd.c
index 5d9a3adf6d..a6f6d54720 100644
--- a/common/host_command_pd.c
+++ b/common/host_command_pd.c
@@ -14,6 +14,8 @@
#define TASK_EVENT_EXCHANGE_PD_STATUS TASK_EVENT_CUSTOM(1)
+static int pd_charger_connected;
+
void host_command_pd_send_status(void)
{
task_set_event(TASK_ID_PDCMD, TASK_EVENT_EXCHANGE_PD_STATUS, 0);
@@ -22,6 +24,8 @@ void host_command_pd_send_status(void)
static void pd_exchange_status(void)
{
struct ec_params_pd_status ec_status;
+ struct ec_response_pd_status pd_status;
+ int rv;
/*
* TODO(crosbug.com/p/29499): Change sending state of charge to
@@ -33,8 +37,22 @@ static void pd_exchange_status(void)
else
ec_status.batt_soc = -1;
- pd_host_command(EC_CMD_PD_EXCHANGE_STATUS, 0, &ec_status,
- sizeof(struct ec_params_pd_status), NULL, 0);
+ rv = pd_host_command(EC_CMD_PD_EXCHANGE_STATUS, 0, &ec_status,
+ sizeof(struct ec_params_pd_status), &pd_status,
+ sizeof(struct ec_response_pd_status));
+
+ if (rv >= 0)
+ pd_charger_connected = pd_status.status &
+ EC_CMD_PD_STATUS_FLAG_CHARGER_CONN;
+}
+
+/*
+ * TODO(crosbug.com/p/29841): remove hack for getting extpower
+ * is present status from PD MCU.
+ */
+int pd_extpower_is_present(void)
+{
+ return pd_charger_connected;
}
void pd_command_task(void)