summaryrefslogtreecommitdiff
path: root/common/usbc/usb_pe_drp_sm.c
diff options
context:
space:
mode:
authorAndrew McRae <amcrae@google.com>2019-11-15 11:29:24 +1100
committerCommit Bot <commit-bot@chromium.org>2019-11-21 10:40:08 +0000
commitb240a1bacaeef1f1dfe03c5646de7aad4c21b8a7 (patch)
treebaa42389974becd2bd068d03a5672c82836d3e75 /common/usbc/usb_pe_drp_sm.c
parent753b387ad740feb0f8378d9bcf37c22e0f320483 (diff)
downloadchrome-ec-b240a1bacaeef1f1dfe03c5646de7aad4c21b8a7.tar.gz
tcpmv2: Make battery handling optional.
Some systems like puff do not have a battery, so conditionally compile the battery handling portion of the Type C PD module. BRANCH=none BUG=b:144390300 TEST=EC buildall runtests Change-Id: I72fc41d64820d450161273902eaf99476bf0dfce Signed-off-by: Andrew McRae <amcrae@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1916763 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Andrew McRae <amcrae@chromium.org> Commit-Queue: Andrew McRae <amcrae@chromium.org>
Diffstat (limited to 'common/usbc/usb_pe_drp_sm.c')
-rw-r--r--common/usbc/usb_pe_drp_sm.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c
index 8e75e59ee4..727e1cd220 100644
--- a/common/usbc/usb_pe_drp_sm.c
+++ b/common/usbc/usb_pe_drp_sm.c
@@ -1405,12 +1405,14 @@ static void pe_src_ready_run(int port)
/* Extended Message Requests */
if (ext > 0) {
switch (type) {
+#ifdef CONFIG_BATTERY
case PD_EXT_GET_BATTERY_CAP:
set_state_pe(port, PE_GIVE_BATTERY_CAP);
break;
case PD_EXT_GET_BATTERY_STATUS:
set_state_pe(port, PE_GIVE_BATTERY_STATUS);
break;
+#endif
default:
set_state_pe(port, PE_SEND_NOT_SUPPORTED);
}
@@ -2089,12 +2091,14 @@ static void pe_snk_ready_run(int port)
/* Extended Message Request */
if (ext > 0) {
switch (type) {
+#ifdef CONFIG_BATTERY
case PD_EXT_GET_BATTERY_CAP:
set_state_pe(port, PE_GIVE_BATTERY_CAP);
break;
case PD_EXT_GET_BATTERY_STATUS:
set_state_pe(port, PE_GIVE_BATTERY_STATUS);
break;
+#endif
default:
set_state_pe(port, PE_SEND_NOT_SUPPORTED);
}
@@ -2427,6 +2431,8 @@ static void pe_give_battery_cap_entry(int port)
uint32_t payload = *(uint32_t *)(&emsg[port].buf);
uint16_t *msg = (uint16_t *)emsg[port].buf;
+ if (!IS_ENABLED(CONFIG_BATTERY))
+ return;
print_current_state(port);
/* msg[0] - extended header is set by Protocol Layer */
@@ -2519,6 +2525,8 @@ static void pe_give_battery_status_entry(int port)
uint32_t payload = *(uint32_t *)(&emsg[port].buf);
uint32_t *msg = (uint32_t *)emsg[port].buf;
+ if (!IS_ENABLED(CONFIG_BATTERY))
+ return;
print_current_state(port);
if (battery_is_present()) {