summaryrefslogtreecommitdiff
path: root/drivers/usb/typec/tcpm/fusb302.c
diff options
context:
space:
mode:
authorBadhri Jagan Sridharan <badhri@google.com>2020-12-01 19:17:33 -0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-12-09 14:42:10 +0100
commite4a9378083c57a22624cda8b780ff5f5da4de7ef (patch)
tree79f5e2424b0eab1d4f00e5a43670a45f5497a973 /drivers/usb/typec/tcpm/fusb302.c
parent3a288efb08543b1368f8d49342e5943f1adf58ea (diff)
usb: typec: tcpm: Pass down negotiated rev to update retry count
nRetryCount was updated from 3 to 2 between PD2.0 and PD3.0 spec. nRetryCount in "Table 6-34 Counter parameters" of the PD 2.0 spec is set to 3, whereas, nRetryCount in "Table 6-59 Counter parameters" is set to 2. Pass down negotiated rev in pd_transmit so that low level chip drivers can update the retry count accordingly before attempting packet transmission. This helps in passing "TEST.PD.PORT.ALL.02" of the "Power Delivery Merged" test suite which was initially failing with "The UUT did not retransmit the message nReryCount times" In fusb302 & tcpci drivers, by default the driver sets the retry count to 3 (Default for PD 2.0). Update this to 2, if the negotiated rev is PD 3.0. In wcove, since the retry count is intentionally set to max, leaving it as is. Reviewed-by: Guenter Roeck <linux@roeck-us.net> Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Badhri Jagan Sridharan <badhri@google.com> Link: https://lore.kernel.org/r/20201202031733.647808-1-badhri@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/typec/tcpm/fusb302.c')
-rw-r--r--drivers/usb/typec/tcpm/fusb302.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/drivers/usb/typec/tcpm/fusb302.c b/drivers/usb/typec/tcpm/fusb302.c
index 99562cc65ca6..ebc46b9f776c 100644
--- a/drivers/usb/typec/tcpm/fusb302.c
+++ b/drivers/usb/typec/tcpm/fusb302.c
@@ -343,12 +343,11 @@ static int fusb302_sw_reset(struct fusb302_chip *chip)
return ret;
}
-static int fusb302_enable_tx_auto_retries(struct fusb302_chip *chip)
+static int fusb302_enable_tx_auto_retries(struct fusb302_chip *chip, u8 retry_count)
{
int ret = 0;
- ret = fusb302_i2c_set_bits(chip, FUSB_REG_CONTROL3,
- FUSB_REG_CONTROL3_N_RETRIES_3 |
+ ret = fusb302_i2c_set_bits(chip, FUSB_REG_CONTROL3, retry_count |
FUSB_REG_CONTROL3_AUTO_RETRY);
return ret;
@@ -399,7 +398,7 @@ static int tcpm_init(struct tcpc_dev *dev)
ret = fusb302_sw_reset(chip);
if (ret < 0)
return ret;
- ret = fusb302_enable_tx_auto_retries(chip);
+ ret = fusb302_enable_tx_auto_retries(chip, FUSB_REG_CONTROL3_N_RETRIES_3);
if (ret < 0)
return ret;
ret = fusb302_init_interrupt(chip);
@@ -1017,7 +1016,7 @@ static const char * const transmit_type_name[] = {
};
static int tcpm_pd_transmit(struct tcpc_dev *dev, enum tcpm_transmit_type type,
- const struct pd_message *msg)
+ const struct pd_message *msg, unsigned int negotiated_rev)
{
struct fusb302_chip *chip = container_of(dev, struct fusb302_chip,
tcpc_dev);
@@ -1026,6 +1025,13 @@ static int tcpm_pd_transmit(struct tcpc_dev *dev, enum tcpm_transmit_type type,
mutex_lock(&chip->lock);
switch (type) {
case TCPC_TX_SOP:
+ /* nRetryCount 3 in P2.0 spec, whereas 2 in PD3.0 spec */
+ ret = fusb302_enable_tx_auto_retries(chip, negotiated_rev > PD_REV20 ?
+ FUSB_REG_CONTROL3_N_RETRIES_2 :
+ FUSB_REG_CONTROL3_N_RETRIES_3);
+ if (ret < 0)
+ fusb302_log(chip, "Cannot update retry count ret=%d", ret);
+
ret = fusb302_pd_send_message(chip, msg);
if (ret < 0)
fusb302_log(chip,