From patchwork Fri Jun 11 01:47:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Lima X-Patchwork-Id: 12314565 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=-16.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT 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 1850AC48BD1 for ; Fri, 11 Jun 2021 01:50:37 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C405C613B3 for ; Fri, 11 Jun 2021 01:50:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C405C613B3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=AJ8Bqu9ut2Lm8ITdGK9kyp7mjdfdAc0iACiywlvYseg=; b=pN/h/M6VK83DsH rxteMXYZZBG0W30ybRr4OlaHDqjRMYB+5FbF8hsUrYi6DbYGqoMwd2WhhRR8UqsK/l4PyA+9YFGtb WrSLgo94nsVsVCwSHKGqH/98UxZh2LxPY9yRmDluU0+JKf6MyFHRM3cO1fov3crjEWyxM9HMdDfad 9G7VINXGutKLfpqbmgQ8L9a4xfBg6OpNg+wT/AJIvpL/B9za5I12JfksKlus1s6uZaZgm7VZUDMIu Eq1hkSTCVWdycWXesuGaD8Yo2pagLlxuQqZR/Bsu5RCYn9FgnBVFQy0cQUjR3yUslr2SlqaSEeMqS kK5kDIG+huFlsLBtI8oQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lrWHh-0039Ih-27; Fri, 11 Jun 2021 01:48:33 +0000 Received: from mail-vi1eur05on2065.outbound.protection.outlook.com ([40.107.21.65] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lrWHc-0039Dz-O9 for linux-arm-kernel@lists.infradead.org; Fri, 11 Jun 2021 01:48:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cX4wzzYKU9bBWPvlhFpINRli4DoU2wNyGmbOFzudReKQC+zRjy7zF1tM6zy2Pg3+n7Iv8ggf6JhochcGkVjv8GCEh9X6smv6S8E5qqxvCHgNSHTZg80NhTFxzDdZ1BcAu1L1+qYJYqNpC657Oq200APDv1BLz9IYUyE+6Jl6GBNWvb7FgBNBIJCnt6h10/75X57fcN1AMpdnV/mAZrK8BjiorPyOpe83x7Ll/78zlm74xw4kK5nT1WqPrm0uNaj8isyRvCZsaoC3sp1FrDnHj3SkBY1zoKOLFPMTdqhxauBi4QIeN6wXXK9d2jrKzig+c1IHReoqZasPA279yLpbiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PmV0+lDH9jaGfmIwJyw9LvH3Ndz9HgkRkIAyLjBvXLI=; b=QccEBblho03MFGiuUUKAIkF8sKXSjNXHL+ty6aff4X5yf052JGgeM1Db4r/mVddvbqhoEMmjQCcrdSm60P659H+8OteHZUiM0Z7s8IgR8ceSbP3FFrgwX6ghDdXHkxo0R9qD8zgidTrGbE3BCn+eSkeF+HRMhOR7ahggSUTAx/mEc9lnFzvPMderbmxYb3vIP6Woyn092yKPAoTCe7tixXVDQAndSX7+MDEZhgtpEJ/mC6nnHRobOm3F5UTpLsUahauOT3IvrHFRuRhSwoRZ7nPEq9odgC6fs6uabk5pnDweWCzyAWJQKtG60Q/wV1O777cubOKTxsZWBmOkheQt/g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PmV0+lDH9jaGfmIwJyw9LvH3Ndz9HgkRkIAyLjBvXLI=; b=HfjtnyNKMDN/vEsI9g89UQA010cKgJqo+rdc7sBY6PvtIWoI9XXcqp0EQY6JwZcIMh4SysgnY3Pj6nvNFli03whuC7GmkBdL9CZlItRTi4f/90UFKcEe8/pCazMC2HfpZQEWQAqudK8c/E1xISEP6JNcyTg0okYQI6F/8sDU29Q= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=nxp.com; Received: from AM9PR04MB8972.eurprd04.prod.outlook.com (2603:10a6:20b:40b::12) by AM9PR04MB8438.eurprd04.prod.outlook.com (2603:10a6:20b:411::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.20; Fri, 11 Jun 2021 01:48:22 +0000 Received: from AM9PR04MB8972.eurprd04.prod.outlook.com ([fe80::9c0e:ba4f:90df:e8a2]) by AM9PR04MB8972.eurprd04.prod.outlook.com ([fe80::9c0e:ba4f:90df:e8a2%6]) with mapi id 15.20.4195.030; Fri, 11 Jun 2021 01:48:22 +0000 From: Breno Lima To: peter.chen@kernel.org Cc: gregkh@linuxfoundation.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, brenomatheus@gmail.com, jun.li@nxp.com, Breno Lima Subject: [PATCH] mx8mm: usb: chipidea: Fix Battery Charger 1.2 CDP detection Date: Thu, 10 Jun 2021 21:47:55 -0400 Message-Id: <20210611014755.124483-1-breno.lima@nxp.com> X-Mailer: git-send-email 2.25.1 X-Originating-IP: [2601:18d:4b00:3350:8833:e134:ea08:dd5d] X-ClientProxiedBy: BYAPR01CA0064.prod.exchangelabs.com (2603:10b6:a03:94::41) To AM9PR04MB8972.eurprd04.prod.outlook.com (2603:10a6:20b:40b::12) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from breno-Precision-7510.hsd1.ma.comcast.net (2601:18d:4b00:3350:8833:e134:ea08:dd5d) by BYAPR01CA0064.prod.exchangelabs.com (2603:10b6:a03:94::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21 via Frontend Transport; Fri, 11 Jun 2021 01:48:18 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ab071ea5-1b3b-4ac0-7e00-08d92c7afed3 X-MS-TrafficTypeDiagnostic: AM9PR04MB8438: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NfSUkRkZMYwdciNcgL7ejWTJKSJfXX+ofeF30R0HQ39sNAa+wILg6HtcbTl6tBPsX3/7Ail11oz2t2zgfQ6KaI/XXglkJ7c+2SkMLdKbBe/+/3mg+tr7c1ZW43T3njwE6lLWXovC/rq2AShx37d4pJehi5qnlkxzT6rKL2KBKLk7boh/PyoFctMFZ93TMdEOWK7ruB7FbH0AXvfPLbT/ViqgvmFuXBOqL+G9Z8wdJoZcKktl1/rhYapNT7s9aF+FZekm4rtOPuLvvWz/b4qLlkMy32OPSwGABVDEQuxpO22ab1vSliGH4mJuC34BwwgGyO1Dr5Ly4rZnUVIOIlZt0mFtFuUvNaiwTD9ggNFyEKKUbr4nFegU586OIFdlhAJiTsot+s1X5R/z2TjuFF6VbgfpeJsBTwsFmRuvhsr4Qkyl3dq+cbYXDc4UNyHKqcginw8t6Wjn+Bu58V0nEgBfe7rbl52R7HU+Lt7w35zLhnCqM/HWoa+hcZi8SzsY4htrfBynf+JEiy//qwhuaGfy9T9qudP2JuSoVbcUPXguBx5oab0LE1kxA03LqVfexhXFA4Fs96KVLivWJDDRBo1GsHoziPXp97x70QETyd5i1FXCU29AOu64xRBglJl4pi0ccw6Fo4H0W1cwUu2SzLCoNA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR04MB8972.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(136003)(376002)(39860400002)(366004)(346002)(396003)(83380400001)(16526019)(52116002)(6512007)(186003)(36756003)(6666004)(8936002)(1076003)(478600001)(2906002)(6486002)(8676002)(44832011)(66556008)(4326008)(7416002)(86362001)(6506007)(66946007)(2616005)(5660300002)(316002)(66476007)(6916009)(38100700002)(32563001); DIR:OUT; SFP:1101; X-M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+jACLwbGZDGmOZ3a2y+Vu7+9wbgwGPPAelSuIiWt1l6TLlW7Rb2YKNCQF5euXWd6rpliqDe1+JDHGRHfzpDzpuK8T2oyF0Z083t0I4lXx7U5nD2Umgs5LJd4yugoa82Pg6q4/erCAJ/TYBuqqDOaqppTHhes+CWOHYp7M6FVyRt4J4twt3wmtEYSFYz12P3JA0XbdpE4tEWweEWUd5Lz0FxrkTroH7Rc8r6pZoPjk4q3JMEJBa9CmIdzUW70h00ThQxeeiu3fySfs2VCgtIAJfJlZXEcYWivYMBilOKgWP94H6CR4Bo+tN0YP8eDLDS01AhNT0DBH1BSvWvL1CEjPMadlbyO2OT4H9ff6i9b06r06MOon2OYohmA60E8WhcfgwTsGzn X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ab071ea5-1b3b-4ac0-7e00-08d92c7afed3 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8972.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2021 01:48:22.4502 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: yO1w8auqOmmpfa4vkPQ68eGf7KQmepzqiVCk/UF+BL/pb2AaTG86JVunYBaEpVR0ynqdc0Qm0Po8WxEyZG373g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8438 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210610_184828_815501_D8C24AB5 X-CRM114-Status: GOOD ( 12.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org i.MX8MM cannot detect certain CDP USB HUBs. usbmisc_imx.c driver is not following CDP timing requirements defined by USB BC 1.2 specification and section 3.2.4 Detection Timing CDP. During Primary Detection the i.MX device should turn on VDP_SRC and IDM_SINK for a minimum of 40ms (TVDPSRC_ON). After a time of TVDPSRC_ON, the PD is allowed to check the status of the D- line. Current implementation is waiting between 1ms and 2ms, and certain BC 1.2 complaint USB HUBs cannot be detected. Increase delay to 40ms allowing enough time for primary detection. During secondary detection the PD is required to disable VDP_SRC and IDM_SNK, and enable VDM_SRC and IDP_SINK for at least 40ms (TVDMSRC_ON). Current implementation is not disabling VDP_SRC and IDM_SNK, introduce disable sequence in imx7d_charger_secondary_detection() function. VDM_SRC and IDP_SINK should be enabled for at least 40ms (TVDMSRC_ON). Increase delay allowing enough time for detection. Signed-off-by: Breno Lima Signed-off-by: Jun Li --- drivers/usb/chipidea/usbmisc_imx.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/usb/chipidea/usbmisc_imx.c b/drivers/usb/chipidea/usbmisc_imx.c index 4545b23bda3f..bac0f5458cab 100644 --- a/drivers/usb/chipidea/usbmisc_imx.c +++ b/drivers/usb/chipidea/usbmisc_imx.c @@ -686,6 +686,16 @@ static int imx7d_charger_secondary_detection(struct imx_usbmisc_data *data) int val; unsigned long flags; + /* Clear VDATSRCENB0 to disable VDP_SRC and IDM_SNK required by BC 1.2 spec */ + spin_lock_irqsave(&usbmisc->lock, flags); + val = readl(usbmisc->base + MX7D_USB_OTG_PHY_CFG2); + val &= ~MX7D_USB_OTG_PHY_CFG2_CHRG_VDATSRCENB0; + writel(val, usbmisc->base + MX7D_USB_OTG_PHY_CFG2); + spin_unlock_irqrestore(&usbmisc->lock, flags); + + /* TVDMSRC_DIS */ + msleep(20); + /* VDM_SRC is connected to D- and IDP_SINK is connected to D+ */ spin_lock_irqsave(&usbmisc->lock, flags); val = readl(usbmisc->base + MX7D_USB_OTG_PHY_CFG2); @@ -695,7 +705,8 @@ static int imx7d_charger_secondary_detection(struct imx_usbmisc_data *data) usbmisc->base + MX7D_USB_OTG_PHY_CFG2); spin_unlock_irqrestore(&usbmisc->lock, flags); - usleep_range(1000, 2000); + /* TVDMSRC_ON */ + msleep(40); /* * Per BC 1.2, check voltage of D+: @@ -798,7 +809,8 @@ static int imx7d_charger_primary_detection(struct imx_usbmisc_data *data) usbmisc->base + MX7D_USB_OTG_PHY_CFG2); spin_unlock_irqrestore(&usbmisc->lock, flags); - usleep_range(1000, 2000); + /* TVDPSRC_ON */ + msleep(40); /* Check if D- is less than VDAT_REF to determine an SDP per BC 1.2 */ val = readl(usbmisc->base + MX7D_USB_OTG_PHY_STATUS);