Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp927041ybh; Wed, 15 Jul 2020 20:42:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzMoYygsw0IDfFp++4RfcaXmB3psSbM9EuFYiGI0BR4Ow/BM7Iz4d999yiIyvnrpTlP3oYf X-Received: by 2002:a05:6402:1246:: with SMTP id l6mr2614243edw.224.1594870956266; Wed, 15 Jul 2020 20:42:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594870956; cv=none; d=google.com; s=arc-20160816; b=JwJuyx1xuwTtqktrYoRYaMNRv4xHKsPyE97E52QCZpKx8XHt4St/NugEBwYap12knJ +A94+guCeiwFKIsNPCefG4ISEV7mNHqx3rvYUyIXnBa3WH+E6LoDiGZMfu1WZgext3We uLLCQg3dNmWTLJIcJPoHLL+jJky4ROm7vDj/d2lK8nzZkMRoZYcPF5aaA2MqWEJGhGF5 RRJjotY2JKZsYTZoH+GfnQCsXvkTAv8EzttaEt2q120faVv183yZ+7HjapAM5DpKRtFh 0WmBPAeeB6lmhC1Tjo7lEFZCrfHI76Dc59KyM/C8W/Ull6bNgISOFLHNJWmlF/1gzV6m Ss/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:from :subject:references:mime-version:message-id:in-reply-to:date :dkim-signature; bh=eyGKIrNpC4d1P/2vRZTid13/ubCOQhtxZ8c/xlJYEpE=; b=bqCX60XEQQr3bhSuwD1P4LyYezkoh13eVgiQBf5DqePbAwSr4F5U9FZz6mGjWllilC 5HpKJHsDo2/tUWQ0Yvj8yPnVren+gi7yNyXhPZBpgzrJW96luFZpZwTnPJlyjwIpCxkG +0tRREPu4zF3ox+aSCAtbvSPaeG9YJSFtEDSuJfAMRt1Wc3Gt+G7PXwTHOZ8lN1F2O4A JSOl5xYgBkh5+gtObJkl6Logmb2pkul61tnyXgks9qfAL4Tvxa0kKr3vrdescWv0ZDJm u2aCruR5Wq6t/qlvzcWBDvtrJc5BekVqZWV5R4u1+yfzTKctCGpyP+F95owGQi15mADs VYNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=X+ZDYKXj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ds7si3388547ejc.717.2020.07.15.20.42.13; Wed, 15 Jul 2020 20:42:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=X+ZDYKXj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728319AbgGPDlu (ORCPT + 99 others); Wed, 15 Jul 2020 23:41:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728280AbgGPDll (ORCPT ); Wed, 15 Jul 2020 23:41:41 -0400 Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C34B5C061755 for ; Wed, 15 Jul 2020 20:41:41 -0700 (PDT) Received: by mail-pg1-x54a.google.com with SMTP id s1so4445751pgq.10 for ; Wed, 15 Jul 2020 20:41:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc:content-transfer-encoding; bh=eyGKIrNpC4d1P/2vRZTid13/ubCOQhtxZ8c/xlJYEpE=; b=X+ZDYKXjnyNj5AU7zCSbrpZoHPKZ51Hrfb1LR4pT/3xzCKM9/fUKUUNTWEEkmBN61r H9ebfBhG/IjIEUBJyrB+9l+v4rQMqLqi8vjpxM6S8K3uja/zR/oeHraNKLjsEb2Y41Rg Qg0v5wHhjIBeqZl8XBah6pM807Jy4VUarcw4gDAk8iUY6ffk+mLqW0vgzy20+mH5QLIX 345hY6WD0ktT+q0dztB9Y2xrSONOgMwxyHCHOsxL63qCLtNA3hSSUwWv3mCSs/n6nN1p /jsSPm6MsS1K9vT7UcT56OVxoU7xF4xqtCO1yBbnVGkUxOtgrxtngHSGmcOMdWg6pkdR 5RdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc:content-transfer-encoding; bh=eyGKIrNpC4d1P/2vRZTid13/ubCOQhtxZ8c/xlJYEpE=; b=X9XU8O2ti7Rsy3lWLRGL9oFgTpppRSK3Uur+AOrKWNT+xBTuouNPHigA+26QIp08O6 9ZHg774HPQW7EJoTkA3e281Evg0YRonyMPzPlZlFCcfIWqulURCtfS7e5hGZcEsrHFrL qhk0JtAAbC/4jhMSaSsUVIWQa8KLH2DzRFpz7eXqxaeBggLQR7v5tcRc5Yq8QSO1cLbY P8RmTQqneTrOA/+HIwj1RGC4e/mKMahhPRvz+Gty9Ksjcfhh7lhVh1tvfyJadKT8HaJC 4If0jiVM4MgKQqs3KXm6YAgg7QkHVlt8do6NrrpvgekWryTqE8nkHVAU5+0jEZkWTx8W Gj3Q== X-Gm-Message-State: AOAM532BGibfZ4ozST4A+4DlRY6FH+OjGcuJNEOlrmHD8pRvJ/q1XY3v VHKYsb8daKk4vJUJ5+hn0jDI3vmmpP0= X-Received: by 2002:a17:90a:1fcb:: with SMTP id z11mr1642988pjz.1.1594870900921; Wed, 15 Jul 2020 20:41:40 -0700 (PDT) Date: Wed, 15 Jul 2020 20:41:28 -0700 In-Reply-To: <20200716034128.1251728-1-badhri@google.com> Message-Id: <20200716034128.1251728-3-badhri@google.com> Mime-Version: 1.0 References: <20200716034128.1251728-1-badhri@google.com> X-Mailer: git-send-email 2.27.0.389.gc38d7665816-goog Subject: [PATCH 3/3 v3] usb: typec: tcpm: Stay in BIST mode till hardreset or unattached From: Badhri Jagan Sridharan To: Guenter Roeck , Heikki Krogerus , reg Kroah-Hartman Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Badhri Jagan Sridharan Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Port starts to toggle when transitioning to unattached state. This is incorrect while in BIST mode. 6.4.3.1 BIST Carrier Mode Upon receipt of a BIST Message, with a BIST Carrier Mode BIST Data Object, the UUT Shall send out a continuous string of BMC encoded alternating "1"s and =E2=80=9C0=E2=80=9Ds. The UUT Shall exit the Continuous BIST Mode withi= n tBISTContMode of this Continuous BIST Mode being enabled(see Section 6.6.7.2). 6.4.3.2 BIST Test Data Upon receipt of a BIST Message, with a BIST Test Data BIST Data Object, the UUT Shall return a GoodCRC Message and Shall enter a test mode in which it sends no further Messages except for GoodCRC Messages in response to received Messages. See Section 5.9.2 for the definition of the Test Data Frame. The test Shall be ended by sending Hard Reset Signaling to reset the UUT. Signed-off-by: Badhri Jagan Sridharan --- Version history: Changes since V1: - None Changes since V2:(Guenter's suggestions) - Fixed formatting error - Reduced timeout to 50ms --- drivers/usb/typec/tcpm/tcpm.c | 7 +++++-- include/linux/usb/pd.h | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c index 379fcab9dbd973..38b958a9650104 100644 --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -3559,6 +3559,8 @@ static void run_state_machine(struct tcpm_port *port) switch (BDO_MODE_MASK(port->bist_request)) { case BDO_MODE_CARRIER2: tcpm_pd_transmit(port, TCPC_TX_BIST_MODE_2, NULL); + tcpm_set_state(port, unattached_state(port), + PD_T_BIST_CONT_MODE); break; case BDO_MODE_TESTDATA: if (port->tcpc->set_bist_data) { @@ -3569,8 +3571,6 @@ static void run_state_machine(struct tcpm_port *port) default: break; } - /* Always switch to unattached state */ - tcpm_set_state(port, unattached_state(port), 0); break; case GET_STATUS_SEND: tcpm_pd_send_control(port, PD_CTRL_GET_STATUS); @@ -3960,6 +3960,9 @@ static void _tcpm_pd_vbus_off(struct tcpm_port *port) static void _tcpm_pd_hard_reset(struct tcpm_port *port) { tcpm_log_force(port, "Received hard reset"); + if (port->bist_request =3D=3D BDO_MODE_TESTDATA && port->tcpc->set_bist_d= ata) + port->tcpc->set_bist_data(port->tcpc, false); + /* * If we keep receiving hard reset requests, executing the hard reset * must have failed. Revert to error recovery if that happens. diff --git a/include/linux/usb/pd.h b/include/linux/usb/pd.h index a665d7f211424d..b6c233e79bd457 100644 --- a/include/linux/usb/pd.h +++ b/include/linux/usb/pd.h @@ -483,4 +483,5 @@ static inline unsigned int rdo_max_power(u32 rdo) #define PD_N_CAPS_COUNT (PD_T_NO_RESPONSE / PD_T_SEND_SOURCE_CAP) #define PD_N_HARD_RESET_COUNT 2 =20 +#define PD_T_BIST_CONT_MODE 50 /* 30 - 60 ms */ #endif /* __LINUX_USB_PD_H */ --=20 2.27.0.389.gc38d7665816-goog