From patchwork Tue Dec 1 04:22:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Badhri Jagan Sridharan X-Patchwork-Id: 336505 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA2C4C64E8A for ; Tue, 1 Dec 2020 04:23:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 49BC4206DF for ; Tue, 1 Dec 2020 04:23:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="btWG3ONs" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728157AbgLAEXX (ORCPT ); Mon, 30 Nov 2020 23:23:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727976AbgLAEXW (ORCPT ); Mon, 30 Nov 2020 23:23:22 -0500 Received: from mail-pf1-x44a.google.com (mail-pf1-x44a.google.com [IPv6:2607:f8b0:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96259C0613D2 for ; Mon, 30 Nov 2020 20:22:42 -0800 (PST) Received: by mail-pf1-x44a.google.com with SMTP id s201so187363pfs.1 for ; Mon, 30 Nov 2020 20:22:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=N92L65vs0hZN6sbhv8nMQq5Z7xcM5ZZapP+dkcKSuqU=; b=btWG3ONsCv6PeV3rp4vVFHmjusgTjmABN+C30bO1SGVHFSe6C36HvYYA8ndJREdbxs FdRSol/vyFkUDbPfE0BGjqgIfP37sh8D79rUvGOjEJxaSCEo/lJ5WbKrojuDYEkil0N+ 1Z/MKpcDZ3RoBNQpKReNzbAidMoH0Iw1fCPmVGzMh98X1F6RkR5NUawp4sWtcw9dOfvB zITNk/XOaHGym+CMM3ICvOROcfCqzjA1azMME4Yhi6SCpQvXs6B+j0WtIi8VNfEYg3qY gy61pPYTEdsQJ9IkJftP19SqoDustePtMHzucxxnYGok0ncgMcv0+65nuxpgMfao1Q1Q rGYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=N92L65vs0hZN6sbhv8nMQq5Z7xcM5ZZapP+dkcKSuqU=; b=XQfrJ3nY01Zm9gaxpogrOK4r+xxyRMy+3rorzpW/gmkNMf5iTFRwzRicK1VDtFjh2w JSHJ/Bj3bYsalSQvcCmiM7rrNzVgkCGteCM3YPZK+Ij7yk72I4mpmjqgKNXWJ11PazOX 1i7ilt2vFxZdy/s6zhDSM95HPiN5T5XwGJKzss/RCK5qwVpIvd6p4N1qqkzTMWFCPAD4 zuHA+fO5Y42XOthCktkQytoMTnxgZuabr+wb9QsZbCzCTPXccXPhtDK36gJpGaQJKlwP 2bNX2F9+pXm8BfaaiP3aYMkgos2gWAQ0bdHCUaGC2z1s1bO0Cy+YoF4ikjr9Tg5eQcmu y1KA== X-Gm-Message-State: AOAM533xvQT/c7YKbyP4h4QEAUt46eizdMIk37bXl7xnILW4X9M51cxR JbWtTztuz1wUfBuEo/Vhw9xy9QaxhjI= X-Google-Smtp-Source: ABdhPJxhNSfzVMCAuC/49qFFxX8y+9/ZZDYhsrntdi227pnDJ6CxFEJDZzTM3YSri7VOtC1aCo1lP0v350Q= Sender: "badhri via sendgmr" X-Received: from badhri.mtv.corp.google.com ([2620:15c:211:201:f292:1cff:fee0:66cf]) (user=badhri job=sendgmr) by 2002:a17:90a:460a:: with SMTP id w10mr121176pjg.1.1606796561660; Mon, 30 Nov 2020 20:22:41 -0800 (PST) Date: Mon, 30 Nov 2020 20:22:34 -0800 Message-Id: <20201201042237.414235-1-badhri@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.29.2.454.gaff20da3a2-goog Subject: [PATCH v1 1/4] usb: typec: tcpm: Pass down negotiated rev to update retry count From: Badhri Jagan Sridharan To: Guenter Roeck , Heikki Krogerus , Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Badhri Jagan Sridharan Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org 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" Signed-off-by: Badhri Jagan Sridharan --- drivers/usb/typec/tcpm/tcpm.c | 2 +- include/linux/usb/tcpm.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c index 3bbc1f10af49..c73bc3a8356a 100644 --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -667,7 +667,7 @@ static int tcpm_pd_transmit(struct tcpm_port *port, tcpm_log(port, "PD TX, type: %#x", type); reinit_completion(&port->tx_complete); - ret = port->tcpc->pd_transmit(port->tcpc, type, msg); + ret = port->tcpc->pd_transmit(port->tcpc, type, msg, port->negotiated_rev); if (ret < 0) return ret; diff --git a/include/linux/usb/tcpm.h b/include/linux/usb/tcpm.h index e68aaa12886f..efaedd7e8a18 100644 --- a/include/linux/usb/tcpm.h +++ b/include/linux/usb/tcpm.h @@ -121,7 +121,7 @@ struct tcpc_dev { enum typec_cc_status cc); int (*try_role)(struct tcpc_dev *dev, int role); int (*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); int (*set_bist_data)(struct tcpc_dev *dev, bool on); int (*enable_frs)(struct tcpc_dev *dev, bool enable); void (*frs_sourcing_vbus)(struct tcpc_dev *dev); From patchwork Tue Dec 1 04:22:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Badhri Jagan Sridharan X-Patchwork-Id: 336504 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2DAB3C64E90 for ; Tue, 1 Dec 2020 04:23:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C07BD20715 for ; Tue, 1 Dec 2020 04:23:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="cKar4ywh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728241AbgLAEXZ (ORCPT ); Mon, 30 Nov 2020 23:23:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727973AbgLAEXY (ORCPT ); Mon, 30 Nov 2020 23:23:24 -0500 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82399C0613D3 for ; Mon, 30 Nov 2020 20:22:44 -0800 (PST) Received: by mail-pl1-x649.google.com with SMTP id f3so491315plb.11 for ; Mon, 30 Nov 2020 20:22:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=+S6WLRShGGihUykEp6F/TgpvlDwlW9co/pvE2ZfqxPk=; b=cKar4ywhMR58pQho8kIo4YaeR4KHa7Y81RRJLz7sbmZURNCjko63R3RZyS39uw3t/K Zx1hX9k3TtedvNlzfTYMQibox/AZOl1wVNn0svHWgRbZuyN6MmfTsL267PLTZ2HqValh z96nc/S1za8177rGE6V4UkTCJlNgij1fdZ9BubHiV3mzWlrpS7g6FLgxUHLKTZ/gA11q xFfYEfXkP64ARkgDca4mVMjTymH8vrR8iBWfqXOdtWPScliisBvhun+eWbTkSO95irV/ +bIAI1Ozveh0XsqogDaSeJJ0rmg5TBjq3V7iVk6ZsnDb92UGSvlqPoAfno/lJAtEDn06 q3Jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=+S6WLRShGGihUykEp6F/TgpvlDwlW9co/pvE2ZfqxPk=; b=BokyJnuJGzyGnnCx8rL8tfa8zdvCXD58ay14aWLFfSjbQyQzUQNRsWz4N2VeOQRRon 3FOmgnuPoOX3wfD9BwXzC8XaJOVja2vwZGDQhUm2epsHFm/8C1nFza5fsTjbl8Hx6JGJ JQytck5uz2imvEeE2WUhz3QXx9vOoRW+0UymZwLv1HdEOhWetqhJmTshHWvVCf4cTbQr XidtVxxCbJ6k4HSOdZxXa59oMhKG1X91WoTlcByzI3edS2mu4EOGonM2C9cWPyqzb2i8 21RNpnkjAbeia6ZPJ3fHNKkYYdNmFZ5qmK10lBJ5dgR8UzNy0kyUNCH/sUHVZIfNjxqh nupA== X-Gm-Message-State: AOAM533m0Sa8a0AOd3QDLm2x22HdXL+FCcpGGkdzUWws+aODvOOLDusr Jl486Xl44i2Vf6magjjppPdwXojyTbE= X-Google-Smtp-Source: ABdhPJycUimJ5oQ45SUJnUX+dPS6O5B38tRwI+TJXvAzAzIinHumw9QuIQ2BIc2lF5QDMP1fYwTBHy4UJNs= Sender: "badhri via sendgmr" X-Received: from badhri.mtv.corp.google.com ([2620:15c:211:201:f292:1cff:fee0:66cf]) (user=badhri job=sendgmr) by 2002:a63:4956:: with SMTP id y22mr703965pgk.266.1606796563954; Mon, 30 Nov 2020 20:22:43 -0800 (PST) Date: Mon, 30 Nov 2020 20:22:35 -0800 In-Reply-To: <20201201042237.414235-1-badhri@google.com> Message-Id: <20201201042237.414235-2-badhri@google.com> Mime-Version: 1.0 References: <20201201042237.414235-1-badhri@google.com> X-Mailer: git-send-email 2.29.2.454.gaff20da3a2-goog Subject: [PATCH v1 2/4] usb: typec: fusb302: Update retry count based on the negotiated rev From: Badhri Jagan Sridharan To: Guenter Roeck , Heikki Krogerus , Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Badhri Jagan Sridharan Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org 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. Signed-off-by: Badhri Jagan Sridharan --- drivers/usb/typec/tcpm/fusb302.c | 16 +++++++++++----- 1 file 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, From patchwork Tue Dec 1 04:22:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Badhri Jagan Sridharan X-Patchwork-Id: 335555 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56D8BC71156 for ; Tue, 1 Dec 2020 04:23:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 07140206DF for ; Tue, 1 Dec 2020 04:23:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="OuGsA4bI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728264AbgLAEXd (ORCPT ); Mon, 30 Nov 2020 23:23:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728222AbgLAEXc (ORCPT ); Mon, 30 Nov 2020 23:23:32 -0500 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE7A8C0613D6 for ; Mon, 30 Nov 2020 20:22:46 -0800 (PST) Received: by mail-yb1-xb4a.google.com with SMTP id j138so843098ybg.20 for ; Mon, 30 Nov 2020 20:22:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=bC8qMXf4pH6iBEVDPsaERolWnb2dJIL28RYsjRFL4/A=; b=OuGsA4bIHE5xZZ1z4RzofmK9egUx94o1mLQ5bpMdfkbNE7xKreyWzJk6j/9Mj5xbZb YWaNjZ1grDkIt9Wc8qZm3g3Veaten0YwFjrX53TnFUDOLlhtqKwBOgb5srL/VgyezwS0 yh0H8NainQEcPowFXaiRD8SuXt4NQ82chBrewgQQzUya65WJrzge2sRniYZ6v+HyddOU vhVIz4Bezo5nSSOQlLi1Sy9NmBd642kqT3oOFbAHqHRBD1HoCDZLWEh+Hs1QGX/mKvxJ Dg5m9nYE59rmtVt1jZ1arK6gaPNFtD9gjNdFwNO+6evjZD6ugklTH/1HbCy0wtxhlbGK TjJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=bC8qMXf4pH6iBEVDPsaERolWnb2dJIL28RYsjRFL4/A=; b=V1T/DzMPskcJLzKqTDf0lCyVSmhEi3VCg+8tYVqOUXkwxWEjdPpy74tcds2JPuNEhf HUTIP7BzsVPVmgt17zHBET8KPO7cpU2ltg1pGI/Y109FJsrMvGuD7nUL1JCtv1yzxpiA a0cf+xtS+xWq4TsiPVIuWcLtl9U55tXdFrBwU2tv7gqJIk2l4ZnjQpyAa5/Tr+sIIC6a +ig2TVW1PIxkt99RBRQdd6km0luttdpvl05R17ccc791C0vZsmSA4XwG2bmjSBFKCmZO qjJU0BHbtlhmQqphSGI0xzuNrcIwh24n7d3EFnFvMiinqLivx55vGAvtzqFZkVGZeths ba2w== X-Gm-Message-State: AOAM533ZvA9dTKZqtr6hSg6sMLm83kIlGcuSyU6bdraJFoULWFiigbxQ eIfGEV3Hl5FMnfVTwnlmGpJYylAEhSY= X-Google-Smtp-Source: ABdhPJxCH5ojX6Uhs9hJnvfU6H42pJRzjAhULVlA1rHh9/GgO6bdgHO05pZcIcA7YYvBWpHwJxGlpSD3PGY= Sender: "badhri via sendgmr" X-Received: from badhri.mtv.corp.google.com ([2620:15c:211:201:f292:1cff:fee0:66cf]) (user=badhri job=sendgmr) by 2002:a25:40c5:: with SMTP id n188mr1159179yba.116.1606796566005; Mon, 30 Nov 2020 20:22:46 -0800 (PST) Date: Mon, 30 Nov 2020 20:22:36 -0800 In-Reply-To: <20201201042237.414235-1-badhri@google.com> Message-Id: <20201201042237.414235-3-badhri@google.com> Mime-Version: 1.0 References: <20201201042237.414235-1-badhri@google.com> X-Mailer: git-send-email 2.29.2.454.gaff20da3a2-goog Subject: [PATCH v1 3/4] usb: typec: tcpci: Update retry count based on the negotiated rev From: Badhri Jagan Sridharan To: Guenter Roeck , Heikki Krogerus , Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Badhri Jagan Sridharan Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org 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. Signed-off-by: Badhri Jagan Sridharan --- drivers/usb/typec/tcpm/tcpci.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/usb/typec/tcpm/tcpci.c b/drivers/usb/typec/tcpm/tcpci.c index 12d983a75510..98a2455f779f 100644 --- a/drivers/usb/typec/tcpm/tcpci.c +++ b/drivers/usb/typec/tcpm/tcpci.c @@ -18,7 +18,8 @@ #include "tcpci.h" -#define PD_RETRY_COUNT 3 +#define PD_RETRY_COUNT_DEFAULT 3 +#define PD_RETRY_COUNT_3_0_OR_HIGHER 2 #define AUTO_DISCHARGE_DEFAULT_THRESHOLD_MV 3500 #define AUTO_DISCHARGE_PD_HEADROOM_MV 850 #define AUTO_DISCHARGE_PPS_HEADROOM_MV 1250 @@ -447,9 +448,8 @@ static int tcpci_set_vbus(struct tcpc_dev *tcpc, bool source, bool sink) return 0; } -static int tcpci_pd_transmit(struct tcpc_dev *tcpc, - enum tcpm_transmit_type type, - const struct pd_message *msg) +static int tcpci_pd_transmit(struct tcpc_dev *tcpc, enum tcpm_transmit_type type, + const struct pd_message *msg, unsigned int negotiated_rev) { struct tcpci *tcpci = tcpc_to_tcpci(tcpc); u16 header = msg ? le16_to_cpu(msg->header) : 0; @@ -497,7 +497,9 @@ static int tcpci_pd_transmit(struct tcpc_dev *tcpc, } } - reg = (PD_RETRY_COUNT << TCPC_TRANSMIT_RETRY_SHIFT) | (type << TCPC_TRANSMIT_TYPE_SHIFT); + /* nRetryCount is 3 in PD2.0 spec where 2 in PD3.0 spec */ + reg = ((negotiated_rev > PD_REV20 ? PD_RETRY_COUNT_3_0_OR_HIGHER : PD_RETRY_COUNT_DEFAULT) + << TCPC_TRANSMIT_RETRY_SHIFT) | (type << TCPC_TRANSMIT_TYPE_SHIFT); ret = regmap_write(tcpci->regmap, TCPC_TRANSMIT, reg); if (ret < 0) return ret; From patchwork Tue Dec 1 04:22:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Badhri Jagan Sridharan X-Patchwork-Id: 335554 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51ADCC64E8A for ; Tue, 1 Dec 2020 04:24:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D9221206DF for ; Tue, 1 Dec 2020 04:24:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="UMXU8w2c" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728283AbgLAEYD (ORCPT ); Mon, 30 Nov 2020 23:24:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728222AbgLAEYD (ORCPT ); Mon, 30 Nov 2020 23:24:03 -0500 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB3E2C0617A7 for ; Mon, 30 Nov 2020 20:22:48 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id n62so851307ybf.19 for ; Mon, 30 Nov 2020 20:22:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=nruMNWNcZEmjcKrORKjvDrxT0A/8sh/ZqXFGa7woZ+A=; b=UMXU8w2cUY0sT47QLX4rKblaiuaWMGkD5mdqrs1sB8lQ9OFaFFcvwaFABiRHvZdAJ0 Djo2X+h1dd516KdL29sTzsTfOeqAdr4O1+jABIUCaMcjEPHIODUD78xxnLUhVBgrjiZw RW1hYeMREXpX30FB3DP/5vRwPfIhrY4dxpJbBMgZVUvOXKp6InKgdetHbN6aHavldJae K4ADF154w6iKSeRhegIAhyxeDlJKvwwX9AWv2GjHFltK28GBDpoAC0ExgkylgQXs7FCW n+TqD7WGWISpuQe6S3u9Paky/LpjM/CaTLp3wJquZX26syVf/is2cr/6p5nho+epKUpS Nh8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=nruMNWNcZEmjcKrORKjvDrxT0A/8sh/ZqXFGa7woZ+A=; b=U/jq0lJjngQqBXi56Dbd024IXbmx3Dd8yrUca1mqi4fkG+Nr5G9XRsFqm30ZO5gOeS C1u5IUlACJTV8JQ3v8ppbqHPgVUHBKklWTG5QrV3VwGeZ+Gy5twnnDkYgYM6Ftfi4OPE 0ZBOQ8YE7EpcYB/BcjdCzNx8DQW07nw8txEmEAQnJdtpSB4lt2GGPeiKI1u4Pt0TvDGC Beh4mXqLu/6mP6c3GE5kIEpg+Ne5EhFGoSgSKtCWe8xl5KQ+GFlTMVec4DwwEDSUDwcK 0690Kji6EDL9nXTwEIKw9XOlHJIZKsHWFLyFikPBNiRC52atJCxbynMrQgjnTeT1IIHY dsmA== X-Gm-Message-State: AOAM531m5/pDt31HecvIWdlcDxqP/mqoZK+wl24fNp4/JI2OnBdGEnvl kDlOD5My8o0NaMOIRS9A2pdVbrD1yfE= X-Google-Smtp-Source: ABdhPJxg3vHAoPRrWpoNVu9EQE38PNG4trmiTCausd4xox8b0mN9zlPwUuVwTFrHlfajZKjQXgtZ7hepIQI= Sender: "badhri via sendgmr" X-Received: from badhri.mtv.corp.google.com ([2620:15c:211:201:f292:1cff:fee0:66cf]) (user=badhri job=sendgmr) by 2002:a25:830e:: with SMTP id s14mr925680ybk.213.1606796568112; Mon, 30 Nov 2020 20:22:48 -0800 (PST) Date: Mon, 30 Nov 2020 20:22:37 -0800 In-Reply-To: <20201201042237.414235-1-badhri@google.com> Message-Id: <20201201042237.414235-4-badhri@google.com> Mime-Version: 1.0 References: <20201201042237.414235-1-badhri@google.com> X-Mailer: git-send-email 2.29.2.454.gaff20da3a2-goog Subject: [PATCH v1 4/4] usb: typec: wcove: Update wcove_pd_transmit to include negoitated rev From: Badhri Jagan Sridharan To: Guenter Roeck , Heikki Krogerus , Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Badhri Jagan Sridharan Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org pd_transmit callback now passes down negotiated_rev to set retry count accordingly if needed. Signed-off-by: Badhri Jagan Sridharan --- drivers/usb/typec/tcpm/wcove.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/typec/tcpm/wcove.c b/drivers/usb/typec/tcpm/wcove.c index 9b745f432c91..79ae63950050 100644 --- a/drivers/usb/typec/tcpm/wcove.c +++ b/drivers/usb/typec/tcpm/wcove.c @@ -356,7 +356,8 @@ static int wcove_set_pd_rx(struct tcpc_dev *tcpc, bool on) static int wcove_pd_transmit(struct tcpc_dev *tcpc, enum tcpm_transmit_type type, - const struct pd_message *msg) + const struct pd_message *msg, + unsigned int negotiated_rev) { struct wcove_typec *wcove = tcpc_to_wcove(tcpc); unsigned int info = 0;