Commit 11121c24 authored by Badhri Jagan Sridharan's avatar Badhri Jagan Sridharan Committed by Greg Kroah-Hartman

usb: typec: tcpci: Implement callbacks for FRS

Implement tcpc.enable_frs to enable TCPC to receive
Fast role swap signal.

Additionally set the sink disconnect threshold to 4v
to prevent disconnect during Fast Role swap.
Signed-off-by: default avatarBadhri Jagan Sridharan <badhri@google.com>
Reviewed-by: default avatarHeikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20201008061556.1402293-8-badhri@google.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 8dc4bd07
...@@ -268,6 +268,22 @@ static int tcpci_set_vconn(struct tcpc_dev *tcpc, bool enable) ...@@ -268,6 +268,22 @@ static int tcpci_set_vconn(struct tcpc_dev *tcpc, bool enable)
enable ? TCPC_POWER_CTRL_VCONN_ENABLE : 0); enable ? TCPC_POWER_CTRL_VCONN_ENABLE : 0);
} }
static int tcpci_enable_frs(struct tcpc_dev *dev, bool enable)
{
struct tcpci *tcpci = tcpc_to_tcpci(dev);
int ret;
/* To prevent disconnect during FRS, set disconnect threshold to 3.5V */
ret = tcpci_write16(tcpci, TCPC_VBUS_SINK_DISCONNECT_THRESH, enable ? 0 : 0x8c);
if (ret < 0)
return ret;
ret = regmap_update_bits(tcpci->regmap, TCPC_POWER_CTRL, TCPC_FAST_ROLE_SWAP_EN, enable ?
TCPC_FAST_ROLE_SWAP_EN : 0);
return ret;
}
static int tcpci_set_bist_data(struct tcpc_dev *tcpc, bool enable) static int tcpci_set_bist_data(struct tcpc_dev *tcpc, bool enable)
{ {
struct tcpci *tcpci = tcpc_to_tcpci(tcpc); struct tcpci *tcpci = tcpc_to_tcpci(tcpc);
...@@ -611,6 +627,7 @@ struct tcpci *tcpci_register_port(struct device *dev, struct tcpci_data *data) ...@@ -611,6 +627,7 @@ struct tcpci *tcpci_register_port(struct device *dev, struct tcpci_data *data)
tcpci->tcpc.set_roles = tcpci_set_roles; tcpci->tcpc.set_roles = tcpci_set_roles;
tcpci->tcpc.pd_transmit = tcpci_pd_transmit; tcpci->tcpc.pd_transmit = tcpci_pd_transmit;
tcpci->tcpc.set_bist_data = tcpci_set_bist_data; tcpci->tcpc.set_bist_data = tcpci_set_bist_data;
tcpci->tcpc.enable_frs = tcpci_enable_frs;
err = tcpci_parse_config(tcpci); err = tcpci_parse_config(tcpci);
if (err < 0) if (err < 0)
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#define TCPC_PD_INT_REV 0xa #define TCPC_PD_INT_REV 0xa
#define TCPC_ALERT 0x10 #define TCPC_ALERT 0x10
#define TCPC_ALERT_EXTND BIT(14)
#define TCPC_ALERT_EXTENDED_STATUS BIT(13) #define TCPC_ALERT_EXTENDED_STATUS BIT(13)
#define TCPC_ALERT_VBUS_DISCNCT BIT(11) #define TCPC_ALERT_VBUS_DISCNCT BIT(11)
#define TCPC_ALERT_RX_BUF_OVF BIT(10) #define TCPC_ALERT_RX_BUF_OVF BIT(10)
...@@ -37,6 +38,9 @@ ...@@ -37,6 +38,9 @@
#define TCPC_EXTENDED_STATUS_MASK 0x16 #define TCPC_EXTENDED_STATUS_MASK 0x16
#define TCPC_EXTENDED_STATUS_MASK_VSAFE0V BIT(0) #define TCPC_EXTENDED_STATUS_MASK_VSAFE0V BIT(0)
#define TCPC_ALERT_EXTENDED_MASK 0x17
#define TCPC_SINK_FAST_ROLE_SWAP BIT(0)
#define TCPC_CONFIG_STD_OUTPUT 0x18 #define TCPC_CONFIG_STD_OUTPUT 0x18
#define TCPC_TCPC_CTRL 0x19 #define TCPC_TCPC_CTRL 0x19
...@@ -63,6 +67,7 @@ ...@@ -63,6 +67,7 @@
#define TCPC_POWER_CTRL 0x1c #define TCPC_POWER_CTRL 0x1c
#define TCPC_POWER_CTRL_VCONN_ENABLE BIT(0) #define TCPC_POWER_CTRL_VCONN_ENABLE BIT(0)
#define TCPC_FAST_ROLE_SWAP_EN BIT(7)
#define TCPC_CC_STATUS 0x1d #define TCPC_CC_STATUS 0x1d
#define TCPC_CC_STATUS_TOGGLING BIT(5) #define TCPC_CC_STATUS_TOGGLING BIT(5)
...@@ -74,11 +79,14 @@ ...@@ -74,11 +79,14 @@
#define TCPC_POWER_STATUS 0x1e #define TCPC_POWER_STATUS 0x1e
#define TCPC_POWER_STATUS_UNINIT BIT(6) #define TCPC_POWER_STATUS_UNINIT BIT(6)
#define TCPC_POWER_STATUS_SOURCING_VBUS BIT(4)
#define TCPC_POWER_STATUS_VBUS_DET BIT(3) #define TCPC_POWER_STATUS_VBUS_DET BIT(3)
#define TCPC_POWER_STATUS_VBUS_PRES BIT(2) #define TCPC_POWER_STATUS_VBUS_PRES BIT(2)
#define TCPC_FAULT_STATUS 0x1f #define TCPC_FAULT_STATUS 0x1f
#define TCPC_ALERT_EXTENDED 0x21
#define TCPC_COMMAND 0x23 #define TCPC_COMMAND 0x23
#define TCPC_CMD_WAKE_I2C 0x11 #define TCPC_CMD_WAKE_I2C 0x11
#define TCPC_CMD_DISABLE_VBUS_DETECT 0x22 #define TCPC_CMD_DISABLE_VBUS_DETECT 0x22
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment