summaryrefslogtreecommitdiff
path: root/driver/tcpm/tcpci.c
diff options
context:
space:
mode:
authorParth Malkan <parthmalkan@google.com>2021-08-10 21:54:59 +0000
committerCommit Bot <commit-bot@chromium.org>2021-09-24 22:54:51 +0000
commit06d89b033065d9c96f4a6e53129b22b912fae224 (patch)
tree34c7038c6fe35b915db34d42aa7112be5a5e095f /driver/tcpm/tcpci.c
parentd4938b281fede972db577180efb791a47c47140b (diff)
downloadchrome-ec-06d89b033065d9c96f4a6e53129b22b912fae224.tar.gz
SSFC: Framework to support two charger sources
Many platforms have requirements to support more than one charge source (eg. pirika). It can't be supported by just enabling two different CONFIGS as that can lead to conflicts. Eg.USD_PD_VBUS_DETECT_TCPC vs USB_PD_VBUS_DETECT_DISCHARGE. This change provides a framework that supports two different charger sources in the same build. Please see the CL for relevant logs. BRANCH=None BUG=b:194375840 TEST=make -j buildall Signed-off-by: Parth Malkan <parthmalkan@google.com> Change-Id: I309cc5930233983e615d90a4290fc749abf7aa2d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3088232 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'driver/tcpm/tcpci.c')
-rw-r--r--driver/tcpm/tcpci.c35
1 files changed, 21 insertions, 14 deletions
diff --git a/driver/tcpm/tcpci.c b/driver/tcpm/tcpci.c
index 73a4b68295..1e08e0967d 100644
--- a/driver/tcpm/tcpci.c
+++ b/driver/tcpm/tcpci.c
@@ -21,6 +21,7 @@
#include "usb_common.h"
#include "usb_mux.h"
#include "usb_pd.h"
+#include "usb_pd_flags.h"
#include "usb_pd_tcpc.h"
#include "usb_pd_tcpm.h"
#include "util.h"
@@ -321,14 +322,20 @@ static int init_alert_mask(int port)
* Create mask of alert events that will cause the TCPC to
* signal the TCPM via the Alert# gpio line.
*/
- mask = TCPC_REG_ALERT_TX_SUCCESS | TCPC_REG_ALERT_TX_FAILED |
- TCPC_REG_ALERT_TX_DISCARDED | TCPC_REG_ALERT_RX_STATUS |
- TCPC_REG_ALERT_RX_HARD_RST | TCPC_REG_ALERT_CC_STATUS |
- TCPC_REG_ALERT_FAULT
-#ifdef CONFIG_USB_PD_VBUS_DETECT_TCPC
- | TCPC_REG_ALERT_POWER_STATUS
-#endif
- ;
+ if (get_usb_pd_vbus_detect() == USB_PD_VBUS_DETECT_TCPC) {
+ mask = TCPC_REG_ALERT_TX_SUCCESS | TCPC_REG_ALERT_TX_FAILED |
+ TCPC_REG_ALERT_TX_DISCARDED | TCPC_REG_ALERT_RX_STATUS |
+ TCPC_REG_ALERT_RX_HARD_RST | TCPC_REG_ALERT_CC_STATUS |
+ TCPC_REG_ALERT_FAULT
+ | TCPC_REG_ALERT_POWER_STATUS
+ ;
+ } else {
+ mask = TCPC_REG_ALERT_TX_SUCCESS | TCPC_REG_ALERT_TX_FAILED |
+ TCPC_REG_ALERT_TX_DISCARDED | TCPC_REG_ALERT_RX_STATUS |
+ TCPC_REG_ALERT_RX_HARD_RST | TCPC_REG_ALERT_CC_STATUS |
+ TCPC_REG_ALERT_FAULT
+ ;
+ }
/* TCPCI Rev2 includes SAFE0V alerts */
if (TCPC_FLAGS_VSAFE0V(tcpc_config[port].flags))
@@ -361,11 +368,11 @@ static int init_power_status_mask(int port)
uint8_t mask;
int rv;
-#ifdef CONFIG_USB_PD_VBUS_DETECT_TCPC
- mask = TCPC_REG_POWER_STATUS_VBUS_PRES;
-#else
- mask = 0;
-#endif
+ if (get_usb_pd_vbus_detect() == USB_PD_VBUS_DETECT_TCPC)
+ mask = TCPC_REG_POWER_STATUS_VBUS_PRES;
+ else
+ mask = 0;
+
rv = tcpc_write(port, TCPC_REG_POWER_STATUS_MASK , mask);
return rv;
@@ -1142,7 +1149,7 @@ static void tcpci_check_vbus_changed(int port, int alert, uint32_t *pd_event)
tcpc_vbus[port] = BIT(VBUS_SAFE0V);
}
- if (IS_ENABLED(CONFIG_USB_PD_VBUS_DETECT_TCPC) &&
+ if ((get_usb_pd_vbus_detect() == USB_PD_VBUS_DETECT_TCPC) &&
IS_ENABLED(CONFIG_USB_CHARGER)) {
/* Update charge manager with new VBUS state */
usb_charger_vbus_change(port,