From patchwork Mon Aug 17 18:38:27 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: 11719071 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0BE2D13A4 for ; Mon, 17 Aug 2020 18:39:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E7CEF20578 for ; Mon, 17 Aug 2020 18:39:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="c46Psfp3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391141AbgHQSiw (ORCPT ); Mon, 17 Aug 2020 14:38:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391199AbgHQSig (ORCPT ); Mon, 17 Aug 2020 14:38:36 -0400 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 81B46C061389 for ; Mon, 17 Aug 2020 11:38:35 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id o8so19323508ybg.16 for ; Mon, 17 Aug 2020 11:38:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=bhDEBLH2zLMBe1pLGOu37r6jSo02gwq/2nQ1HrTTqF8=; b=c46Psfp3A06TsHYPQDxrj6HTk77Qo5e9uHOhuCwS2+/PiWfuLzZAAT5aeyYg7EBKRJ gQUNht6Q8agUXutMXs2zghPZqD5PkGJAb+1MrBcDGqxvTHqQ8GP4+DVlah9UWhwKYMig /KQmMEF4lmAxPXz9lmD1c5PjRZsZCj1/0ZEefEyR5BueKo1BnG+2fShMgMC3nYLZ1i+S 7eyQ7VEO3SklR5avS/aJY2MUP1f31Yc0nv98UaYlXiDoNdpB6iKL/fmcwyLr5SGTKwd0 FCsmHn8Jp4EuPX6YO0+yXOjuJ4TZfev9NI4sFHBE4sSUbQoH8318ja55U5A7uIbnKZgq K1XA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=bhDEBLH2zLMBe1pLGOu37r6jSo02gwq/2nQ1HrTTqF8=; b=PsV7qQy5/Wyc2tgr65byLp89RyrR6AxQ2jYyyJitx3WEsJDIWV+khIKQtf3v28KB8u wYR9PFw262arwZhN7Yk/QKsqpd9An4eMtL1yVNgYNNi9qGZOUEGsnyKSI4qYhag+OhTF w5lfY/OYLuCN+lXHj3LA+M02SHEH/5QBRv58s5f0mZR0ED7nGb4VKKRvbynsyz0mxsIY r2lrnzNvy2Z8ECgMdVZ4o2gXTPUsydaNhiEJksQwuG3hP63wKKTYR9pE2dtpwQHWEAmn xPN1BGm0L0vghPFwu3lXDGE3Kkhbf3Bk0OWKs3oEFBJURuBc18x4bHam/ZfWiYM1J9Kh 7jlA== X-Gm-Message-State: AOAM531CYSZ2tfwIjgD8rwbYXmNdPchP6YjNDDVHE/MfkZRsdTMM6SwY n5GTu+fmhf4CfvvgBnePVxXt1uN4YGo= X-Google-Smtp-Source: ABdhPJz/rAZPKfdOBjqyngDJSW+wdAEZYbki1trbj21OPfsZyt/sMN27TwHe2POwAolZ6Q0yuVxI48xqJ3I= X-Received: by 2002:a25:240a:: with SMTP id k10mr21720805ybk.275.1597689513586; Mon, 17 Aug 2020 11:38:33 -0700 (PDT) Date: Mon, 17 Aug 2020 11:38:27 -0700 Message-Id: <20200817183828.1895015-1-badhri@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.220.ged08abb693-goog Subject: [PATCH 1/2 v4] tcpm: During PR_SWAP, source caps should be sent only after tSwapSourceStart 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 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The patch addresses the compliance test failures while running TD.PD.CP.E3, TD.PD.CP.E4, TD.PD.CP.E5 of the "Deterministic PD Compliance MOI" test plan published in https://www.usb.org/usbc. For a product to be Type-C compliant, it's expected that these tests are run on usb.org certified Type-C compliance tester as mentioned in https://www.usb.org/usbc. The purpose of the tests TD.PD.CP.E3, TD.PD.CP.E4, TD.PD.CP.E5 is to verify the PR_SWAP response of the device. While doing so, the test asserts that Source Capabilities message is NOT received from the test device within tSwapSourceStart min (20 ms) from the time the last bit of GoodCRC corresponding to the RS_RDY message sent by the UUT was sent. If it does then the test fails. This is in line with the requirements from the USB Power Delivery Specification Revision 3.0, Version 1.2: "6.6.8.1 SwapSourceStartTimer The SwapSourceStartTimer Shall be used by the new Source, after a Power Role Swap or Fast Role Swap, to ensure that it does not send Source_Capabilities Message before the new Sink is ready to receive the Source_Capabilities Message. The new Source Shall Not send the Source_Capabilities Message earlier than tSwapSourceStart after the last bit of the EOP of GoodCRC Message sent in response to the PS_RDY Message sent by the new Source indicating that its power supply is ready." The patch makes sure that TCPM does not send the Source_Capabilities Message within tSwapSourceStart(20ms) by transitioning into SRC_STARTUP only after tSwapSourceStart(20ms). Signed-off-by: Badhri Jagan Sridharan Reviewed-by: Guenter Roeck Reviewed-by: Heikki Krogerus --- Changes since V1: - Comment on the permissible values of tSwapSourceStart Changes since V2: - Fixing alignment issue pointed out by Guenter. - Added Reviewed-by: Guenter Roeck Changes since V3: - Updated commit description and made it elaborate to address Heikki's suggestion. --- drivers/usb/typec/tcpm/tcpm.c | 2 +- include/linux/usb/pd.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c index 3ef37202ee37..d38347bd3335 100644 --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -3555,7 +3555,7 @@ static void run_state_machine(struct tcpm_port *port) */ tcpm_set_pwr_role(port, TYPEC_SOURCE); tcpm_pd_send_control(port, PD_CTRL_PS_RDY); - tcpm_set_state(port, SRC_STARTUP, 0); + tcpm_set_state(port, SRC_STARTUP, PD_T_SWAP_SRC_START); break; case VCONN_SWAP_ACCEPT: diff --git a/include/linux/usb/pd.h b/include/linux/usb/pd.h index b6c233e79bd4..1df895e4680b 100644 --- a/include/linux/usb/pd.h +++ b/include/linux/usb/pd.h @@ -473,6 +473,7 @@ static inline unsigned int rdo_max_power(u32 rdo) #define PD_T_ERROR_RECOVERY 100 /* minimum 25 is insufficient */ #define PD_T_SRCSWAPSTDBY 625 /* Maximum of 650ms */ #define PD_T_NEWSRC 250 /* Maximum of 275ms */ +#define PD_T_SWAP_SRC_START 20 /* Minimum of 20ms */ #define PD_T_DRP_TRY 100 /* 75 - 150 ms */ #define PD_T_DRP_TRYWAIT 600 /* 400 - 800 ms */ From patchwork Mon Aug 17 18:38:28 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: 11719069 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A5351109B for ; Mon, 17 Aug 2020 18:38:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8D40F2063A for ; Mon, 17 Aug 2020 18:38:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="gpPab2cf" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391199AbgHQSix (ORCPT ); Mon, 17 Aug 2020 14:38:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391242AbgHQSik (ORCPT ); Mon, 17 Aug 2020 14:38:40 -0400 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 3E4DCC061345 for ; Mon, 17 Aug 2020 11:38:40 -0700 (PDT) Received: by mail-pl1-x649.google.com with SMTP id w20so1604234plp.8 for ; Mon, 17 Aug 2020 11:38:40 -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; bh=fgr4lPs0or0iB5fosHxX2pUdsKpC2fZEoB73rKcd/Pw=; b=gpPab2cfyT6hCpRcW9yoitZQ1bivgwHZ2ranIeUCOGVWqqdJJGkzeAsDn0bzKfK7Pv 1W4MAPW358Iw9HfcGsyY/MRlsoG1jAhst1mLKAxeiA3WkvVoCFW5l1RI3PxvKiiyJJBv kJcZ0AfIMQzp3c8hLX8+a0afCnLugujKAGoq6Ie/0tf0eg12Noc2Jr6Cz8fPst3LhdMC uvUQ5MfTFeRx7HoqNz+SCpcO7hNipmNDmKul8Y2G6P1xpHJG7tg6dKMFun424z7UB1k2 MbkGXjyU9qSymtGtHAtFaZfZLwooQK5Jtuffs1oqDB3ihKpPWVMwd1udcf54pBbB9e7M 0ILA== 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; bh=fgr4lPs0or0iB5fosHxX2pUdsKpC2fZEoB73rKcd/Pw=; b=EKxGwxT/pmg8Ja1iXlP5LcUwOykzuaxafQThtLx/oc0Cl+KraNgBxhReEvQLP/vE8N I20+1lsHI84sCgL5pGXe2mIof3K87G9/Wh2jONYvqCnrC7y3aNlJ2gTILhR656QXc7Yv 4ZDcA5Ii8Rnxym0wVjxJN3s6NF9kzHyYpdgUIrd/b0Zg4XcldV81D4vYc+LUBqAHLlOl fejiDSBGxkOAQVW70qNwLAagJ7mDNLiBrqYTt7AjVeFlV7VpA7NSwBvipDALECUq4h6a jZ8X050ApZaz/StoAxBlDooJUd4TIv+PZHu4V5paiBAKnL+x+lxi+GM28alCB2PUn/YJ rVJg== X-Gm-Message-State: AOAM533y+gC4cusdzsOLgVUbI8KcuN1gmJU9hYd8VXWBzNtA14/ZHnrI nXrslHQAQjPmsTDZg8WC/1qWM1UqyuA= X-Google-Smtp-Source: ABdhPJx7JMQgnHKmRP+uG+1UdYLjI4cM9KQFTz6ra+2WZ/MkSR53JhDoU90OXmzlexcksXGhfm7i98cnzmw= X-Received: by 2002:a05:6a00:81:: with SMTP id c1mr12660793pfj.189.1597689518510; Mon, 17 Aug 2020 11:38:38 -0700 (PDT) Date: Mon, 17 Aug 2020 11:38:28 -0700 In-Reply-To: <20200817183828.1895015-1-badhri@google.com> Message-Id: <20200817183828.1895015-2-badhri@google.com> Mime-Version: 1.0 References: <20200817183828.1895015-1-badhri@google.com> X-Mailer: git-send-email 2.28.0.220.ged08abb693-goog Subject: [PATCH 2/2 v4] usb: typec: pd: Fix formatting in pd.h header 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 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Replacing spaces with tabs for PD_T_* constants. Signed-off-by: Badhri Jagan Sridharan Reviewed-by: Guenter Roeck Reviewed-by: Heikki Krogerus --- Change history: -First version at v3. Keeping the version number same as the parent. Changes since v3: -Added Reviewed-by tags --- include/linux/usb/pd.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/linux/usb/pd.h b/include/linux/usb/pd.h index 1df895e4680b..f842e4589bd2 100644 --- a/include/linux/usb/pd.h +++ b/include/linux/usb/pd.h @@ -471,9 +471,10 @@ static inline unsigned int rdo_max_power(u32 rdo) #define PD_T_VCONN_SOURCE_ON 100 #define PD_T_SINK_REQUEST 100 /* 100 ms minimum */ #define PD_T_ERROR_RECOVERY 100 /* minimum 25 is insufficient */ -#define PD_T_SRCSWAPSTDBY 625 /* Maximum of 650ms */ -#define PD_T_NEWSRC 250 /* Maximum of 275ms */ +#define PD_T_SRCSWAPSTDBY 625 /* Maximum of 650ms */ +#define PD_T_NEWSRC 250 /* Maximum of 275ms */ #define PD_T_SWAP_SRC_START 20 /* Minimum of 20ms */ +#define PD_T_BIST_CONT_MODE 50 /* 30 - 60 ms */ #define PD_T_DRP_TRY 100 /* 75 - 150 ms */ #define PD_T_DRP_TRYWAIT 600 /* 400 - 800 ms */ @@ -484,5 +485,4 @@ 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 -#define PD_T_BIST_CONT_MODE 50 /* 30 - 60 ms */ #endif /* __LINUX_USB_PD_H */