diff options
Diffstat (limited to 'include/usb_common.h')
-rw-r--r-- | include/usb_common.h | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/include/usb_common.h b/include/usb_common.h new file mode 100644 index 0000000000..1fbaa4bd50 --- /dev/null +++ b/include/usb_common.h @@ -0,0 +1,37 @@ +/* Copyright 2019 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +#ifndef __CROS_EC_USB_COMMON_H +#define __CROS_EC_USB_COMMON_H + +/* Functions that are shared between old and new PD stacks */ +#include "usb_pd.h" +#include "usb_pd_tcpm.h" + +/* Returns the battery percentage [0-100] of the system. */ +int usb_get_battery_soc(void); + +/* + * Returns type C current limit (mA), potentially with the DTS flag, based upon + * states of the CC lines on the partner side. + * + * @param polarity 0 if cc1 is primary, otherwise 1 + * @param cc1 value of CC1 set by tcpm_get_cc + * @param cc2 value of CC2 set by tcpm_get_cc + * @return current limit (mA) with DTS flag set if appropriate + */ +typec_current_t usb_get_typec_current_limit(enum pd_cc_polarity_type polarity, + enum tcpc_cc_voltage_status cc1, enum tcpc_cc_voltage_status cc2); + +/** + * Returns the polarity of a Sink. + * + * @param cc1 value of CC1 set by tcpm_get_cc + * @param cc2 value of CC2 set by tcpm_get_cc + * @return 0 if cc1 is primary, else 1 for cc2 being primary + */ +enum pd_cc_polarity_type get_snk_polarity(enum tcpc_cc_voltage_status cc1, + enum tcpc_cc_voltage_status cc2); + +#endif /* __CROS_EC_USB_COMMON_H */ |