summaryrefslogtreecommitdiff
path: root/driver/tcpm/anx7688.c
diff options
context:
space:
mode:
Diffstat (limited to 'driver/tcpm/anx7688.c')
-rw-r--r--driver/tcpm/anx7688.c63
1 files changed, 34 insertions, 29 deletions
diff --git a/driver/tcpm/anx7688.c b/driver/tcpm/anx7688.c
index 5e37352bc5..6ad8a16ff4 100644
--- a/driver/tcpm/anx7688.c
+++ b/driver/tcpm/anx7688.c
@@ -1,4 +1,4 @@
-/* Copyright 2016 The Chromium OS Authors. All rights reserved.
+/* Copyright 2016 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -12,24 +12,24 @@
#include "usb_mux.h"
#if defined(CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE) || \
- defined(CONFIG_USB_PD_TCPC_LOW_POWER) || \
+ defined(CONFIG_USB_PD_TCPC_LOW_POWER) || \
defined(CONFIG_USB_PD_DISCHARGE_TCPC)
#error "Unsupported config options of anx7688 PD driver"
#endif
-#define ANX7688_VENDOR_ALERT BIT(15)
+#define ANX7688_VENDOR_ALERT BIT(15)
-#define ANX7688_REG_STATUS 0x82
+#define ANX7688_REG_STATUS 0x82
#define ANX7688_REG_STATUS_LINK BIT(0)
-#define ANX7688_REG_HPD 0x83
-#define ANX7688_REG_HPD_HIGH BIT(0)
-#define ANX7688_REG_HPD_IRQ BIT(1)
-#define ANX7688_REG_HPD_ENABLE BIT(2)
+#define ANX7688_REG_HPD 0x83
+#define ANX7688_REG_HPD_HIGH BIT(0)
+#define ANX7688_REG_HPD_IRQ BIT(1)
+#define ANX7688_REG_HPD_ENABLE BIT(2)
-#define ANX7688_USBC_ADDR_FLAGS 0x28
-#define ANX7688_REG_RAMCTRL 0xe7
-#define ANX7688_REG_RAMCTRL_BOOT_DONE BIT(6)
+#define ANX7688_USBC_ADDR_FLAGS 0x28
+#define ANX7688_REG_RAMCTRL 0xe7
+#define ANX7688_REG_RAMCTRL_BOOT_DONE BIT(6)
static int anx7688_init(int port)
{
@@ -85,9 +85,9 @@ static void anx7688_update_hpd_enable(int port)
!(status & ANX7688_REG_STATUS_LINK)) {
reg &= ~ANX7688_REG_HPD_IRQ;
tcpc_write(port, ANX7688_REG_HPD,
- (status & ANX7688_REG_STATUS_LINK)
- ? reg | ANX7688_REG_HPD_ENABLE
- : reg & ~ANX7688_REG_HPD_ENABLE);
+ (status & ANX7688_REG_STATUS_LINK) ?
+ reg | ANX7688_REG_HPD_ENABLE :
+ reg & ~ANX7688_REG_HPD_ENABLE);
}
}
@@ -153,6 +153,10 @@ static int anx7688_mux_set(const struct usb_mux *me, mux_state_t mux_state,
/* This driver does not use host command ACKs */
*ack_required = false;
+ /* This driver treats safe mode as none */
+ if (mux_state == USB_PD_MUX_SAFE_MODE)
+ mux_state = USB_PD_MUX_NONE;
+
rv = mux_read(me, TCPC_REG_CONFIG_STD_OUTPUT, &reg);
if (rv != EC_SUCCESS)
return rv;
@@ -195,25 +199,26 @@ static bool anx7688_tcpm_check_vbus_level(int port, enum vbus_level level)
/* ANX7688 is a TCPCI compatible port controller */
const struct tcpm_drv anx7688_tcpm_drv = {
- .init = &anx7688_init,
- .release = &anx7688_release,
- .get_cc = &tcpci_tcpm_get_cc,
+ .init = &anx7688_init,
+ .release = &anx7688_release,
+ .get_cc = &tcpci_tcpm_get_cc,
#ifdef CONFIG_USB_PD_VBUS_DETECT_TCPC
- .check_vbus_level = &anx7688_tcpm_check_vbus_level,
+ .check_vbus_level = &anx7688_tcpm_check_vbus_level,
#endif
- .select_rp_value = &tcpci_tcpm_select_rp_value,
- .set_cc = &tcpci_tcpm_set_cc,
- .set_polarity = &tcpci_tcpm_set_polarity,
+ .select_rp_value = &tcpci_tcpm_select_rp_value,
+ .set_cc = &tcpci_tcpm_set_cc,
+ .set_polarity = &tcpci_tcpm_set_polarity,
#ifdef CONFIG_USB_PD_DECODE_SOP
- .sop_prime_enable = &tcpci_tcpm_sop_prime_enable,
+ .sop_prime_enable = &tcpci_tcpm_sop_prime_enable,
#endif
- .set_vconn = &tcpci_tcpm_set_vconn,
- .set_msg_header = &tcpci_tcpm_set_msg_header,
- .set_rx_enable = &tcpci_tcpm_set_rx_enable,
- .get_message_raw = &tcpci_tcpm_get_message_raw,
- .transmit = &tcpci_tcpm_transmit,
- .tcpc_alert = &anx7688_tcpc_alert,
- .set_bist_test_mode = &tcpci_set_bist_test_mode,
+ .set_vconn = &tcpci_tcpm_set_vconn,
+ .set_msg_header = &tcpci_tcpm_set_msg_header,
+ .set_rx_enable = &tcpci_tcpm_set_rx_enable,
+ .get_message_raw = &tcpci_tcpm_get_message_raw,
+ .transmit = &tcpci_tcpm_transmit,
+ .tcpc_alert = &anx7688_tcpc_alert,
+ .set_bist_test_mode = &tcpci_set_bist_test_mode,
+ .get_bist_test_mode = &tcpci_get_bist_test_mode,
};
#ifdef CONFIG_USB_PD_TCPM_MUX