From patchwork Wed Sep 16 12:56:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 312379 Delivered-To: patch@linaro.org Received: by 2002:a92:5ad1:0:0:0:0:0 with SMTP id b78csp412667ilg; Wed, 16 Sep 2020 05:31:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx1dPRRieGf1his61vsyJ/3PZHA8hFLUiT9Y7IWVxxoKqqZItc8G5rvwDd+C8mwDuM4+utu X-Received: by 2002:a17:906:f157:: with SMTP id gw23mr24873364ejb.325.1600259491553; Wed, 16 Sep 2020 05:31:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1600259491; cv=pass; d=google.com; s=arc-20160816; b=qik8xktoRtlj5rxMmyiybKT+N6Mw1gANSQfqRUg05auS/DemnzqpGEsA16lN54iGtS nGSS0XY8pslIyZtRg2f1GHq4WAIGvlE2Fl5k7wbiLbPorKnt2Y4e0A/n+5gI+DK9TBPb DMcDpe10/NwHGjmktY40Y7018P+JS7Mnxyd2aVtpEMlwWVqtCNFHyhsOhnuS3JItp9pN +POkyDBBt9D1vA8DZguEO9tdiR1MaFj1FqBA+9hF2cEzcYu9ySTqHCAohPvsMQzZjqCQ jfJEkpFW9D6GaKEgqftUE1hTKS5uxmFMeadBCzbSxTzci/N6ugqTybEII4qZVhkJgwpP kpvQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version :content-transfer-encoding:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=cLdxzhUc2n5igzvDB6nnZlu8yeTCwNoyzE7pcDP6wac=; b=qmAzuwIZ3X7IEsPsICNlUeRrJuNAjH9CsFF2vAo1bHiss+23ZFbtYdNMQCfwIupiA6 KW5IRbwABDitHsov7g/tsAZZpTmEnuR41UxjWaCPB86r5Eehq9QlPAtreb6Ryw9UOB8X hXGRY1ftlwSpeEj6grN/5rScpCDaqJQ6SnNHqPqUkB5cEmcfBlewyLUOvRS2tSIHk35B YgvPDYxHNRe5uB1m/4fWlpg3u7NU0hO/S3GfAh9PSPg4yCn8RbV6sja/+JdhElDnixx/ S6qiSyoeJnbCob623HxqkQAf754QdlkVQU23QNYA7+8xW4Pa0aKEU5ALadM49teI5S8C aEGQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=OQuLEDvo; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id s7si12560756edi.576.2020.09.16.05.31.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Sep 2020 05:31:31 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=OQuLEDvo; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EBE0282294; Wed, 16 Sep 2020 14:31:18 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=nxp.com header.i=@nxp.com header.b="OQuLEDvo"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5F8F7822F8; Wed, 16 Sep 2020 14:31:14 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FORGED_SPF_HELO,MSGID_FROM_MTA_HEADER, SPF_HELO_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on0631.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0d::631]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 872F6821F8 for ; Wed, 16 Sep 2020 14:31:11 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=peng.fan@nxp.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WWVHh/ZGo8KXZ4S9GRvfLm/MRnCb51jypWf3POcODKMKbURPLt2WSwgalFzD7MbCnjZO5polwHtp0MrkWTU/nzfHkKkAgdu1p6zTrDn1r5uP6eySKxBZYKbbXW0TmzWg6xV5LkuHfuld3EqLZHGqxCbTJNSJx95IDX5D/6hrvnEkBAlz7EcZQm41HR3QyMJfSv3H8S4srgFiFMtNc48We5ITGx/RaG0lbpg10ecAEElzlm8ISDc4Jj/Rbw547lrmQbbqdek4om00yVgIxISw9fBu+PWeBbM7LNl5FfBOTj3Cpg1IlK+a0kaQbZDs/veqqFQoA7PB0iQduGlYz8tThw== 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=cLdxzhUc2n5igzvDB6nnZlu8yeTCwNoyzE7pcDP6wac=; b=brdeQksU4jqG96tmmgl9xBYBCDG/SHYa1g8sW4SkxUpU++T1zWD2fglZpNFCUjw5hL7aflkKDHcFUH33IMm290nSFG/1AWGf50PBBPMUpry5yYA4eDfjJxkEaF5iaW1Rymq6tVhzhL37jzbvZzA41G2aHl6si0BIFQSt3oQQXuYQdC3uc3H3LFuKV/1cYbTrjT9kt7HVwdxGh+WETkH6HZqqohg86xXRxssmCcDRHrN1eBvZNKxkYX1ZxoLV6CwdNLex9IlxIks149SkhcCIHf0FJktmlo0HMYXX+A+m190UDExI0NRzoQBTli/fYbI8OMr5k9vGpW4iazzbQTvt9Q== 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=cLdxzhUc2n5igzvDB6nnZlu8yeTCwNoyzE7pcDP6wac=; b=OQuLEDvolWY6H5MBx1wMtfcrFW2D/HyQMmLocbwvAWYC5QBdzibOUamryF6BhOBwOawLIWuXKLzbt9B6IbQWsv/cTdm34VkP4UMhKbdO0CoiM6CZU0XB0X6a8qQ3M8ewATrhUFkhfGYK5O5Uv9w3sXTcRUziXLMrNDTyGAey+4Q= Authentication-Results: denx.de; dkim=none (message not signed) header.d=none;denx.de; dmarc=none action=none header.from=nxp.com; Received: from DB6PR0402MB2760.eurprd04.prod.outlook.com (2603:10a6:4:a1::14) by DB7PR04MB4762.eurprd04.prod.outlook.com (2603:10a6:10:16::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3370.16; Wed, 16 Sep 2020 12:31:08 +0000 Received: from DB6PR0402MB2760.eurprd04.prod.outlook.com ([fe80::39ff:13b4:4f28:1413]) by DB6PR0402MB2760.eurprd04.prod.outlook.com ([fe80::39ff:13b4:4f28:1413%10]) with mapi id 15.20.3370.019; Wed, 16 Sep 2020 12:31:08 +0000 From: peng.fan@nxp.com To: sbabic@denx.de, marex@denx.de Cc: uboot-imx@nxp.com, u-boot@lists.denx.de, Peng Fan , Ye Li Subject: [PATCH 01/13] usb: ehci-mx6: Add powerup_fixup implementation Date: Wed, 16 Sep 2020 20:56:53 +0800 Message-Id: <20200916125705.4341-2-peng.fan@nxp.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200916125705.4341-1-peng.fan@nxp.com> References: <20200916125705.4341-1-peng.fan@nxp.com> X-ClientProxiedBy: SGBP274CA0023.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b0::35) To DB6PR0402MB2760.eurprd04.prod.outlook.com (2603:10a6:4:a1::14) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from linux-1xn6.ap.freescale.net (119.31.174.71) by SGBP274CA0023.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b0::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.13 via Frontend Transport; Wed, 16 Sep 2020 12:31:05 +0000 X-Mailer: git-send-email 2.28.0 X-Originating-IP: [119.31.174.71] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: c4b62838-25bf-458e-ef67-08d85a3c62ff X-MS-TrafficTypeDiagnostic: DB7PR04MB4762: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5LB9Rqgljiou4ox3ir5/oAwb0wgdC552t7fuDo0unP2nMrQ3shX02pocfAis1HWn12AgEauprtC3nYWPgb4YFSh1axWBNXJzSWw5Wj5WF87VNC/EljEP4evyaIBkW8GoHixs84PivuzByuVULkBYMuPcGVbdJR2oGHwGWhVERhPA5D5Lsu1kjYrStdgmDQw2HvYZoAB1d5lnKlBlG1cVvgii6pNy3m/LP/ng/0AE+OuOzsc2nhUti0xLg+viUXnIhG86sQTygYkJrcXALwgRIW+ef4eKvPcWv71O7SwcfPgVvHYD6ZEQeqkcgNhpV25r755Ljcoxi7dSiMAVmlVmKA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB6PR0402MB2760.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(136003)(346002)(366004)(39860400002)(66946007)(6486002)(8936002)(26005)(52116002)(54906003)(956004)(9686003)(2616005)(8676002)(66476007)(86362001)(66556008)(6512007)(316002)(478600001)(186003)(6666004)(2906002)(83380400001)(16526019)(36756003)(6506007)(4326008)(5660300002)(1076003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: AZT8ot+sHRjgnNCtSZVdVQpck+D735shOkqY2dUjd6ebyE6yDNhlwDzIDEtFWWd7F8t1xbwNwQ2ztzKXKOfoSkujEr1XmeSKAdwTvxg6wPenHKTNzPCmQWggEoHHUL7IxBEEu2B9Ta7bj6L70p5wJ8F17qzGIczIpHI24lBipTz1nRY07bk0/LPorYEDqLvkBaxZzDw891OEKcA2UvMbyLWb45MXL+IGMVliJKQBcdOoRxFmF93NBqV7HPk2VFBACLsnHAQEgPdyLTUBABaxxhl86Q+bOeCHNoGYeOML3vBqYbOe9FGViWjOTgYIaY9B1N04EMeICXr8e6DUqmO7WsQDQ11svRPUF1qYMuTG2LmL48m0ZN576bKLIJaP1PUPg1mD30b7IS1RQbQkdGdlM5lJ4ZT9CVSKKpIPMMWKkHVdmpU8iY7PC1PDIIkxtqkPlnCAByAaqhzChcb35CRccBQ8N4PFfmxSXcjzIV2gp8cKLvU7Zvf1+Be6TEFLwJj9T5sengZT6WnOrBaR+4Pd44oK7QcFqCiCa0pk55BiKh/aE/TZ771ltRcz5zTVEQyMNoG+RYfa2fPgVgrRh4/NqOl80xX6WvbCo3DYjF7YQO3T5Xi++PaeDb/WiUWYcMZ3Vd/iTJ19oe/ZLoQVuDgT7Q== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c4b62838-25bf-458e-ef67-08d85a3c62ff X-MS-Exchange-CrossTenant-AuthSource: DB6PR0402MB2760.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Sep 2020 12:31:08.3360 (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: eC6seXFixhmDVWmCfJ7qDriz+qZLbvjCCn2yQ4q0cUFQ05D5mUHpyht2z5/d+zydHejZQUUCl7ZHxxpsJak8bQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR04MB4762 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean From: Peng Fan When doing port reset, the PR bit of PORTSC1 will be automatically cleared by our IP, but standard EHCI needs explicit clear by software. The EHCI-HCD driver follow the EHCI specification, so after 50ms wait, it clear the PR bit by writting to the PORTSC1 register with value loaded before setting PR. This sequence is ok for our IP when the delay time is exact. But when the timer is slower, some bits like PE, PSPD have been set by controller automatically after the PR is automatically cleared. So the writing to the PORTSC1 will overwrite these bits set by controller. And eventually the driver gets wrong status. We implement the powerup_fixup operation which delays 50ms and will check the PR until it is cleared by controller. And will update the reg value which is written to PORTSC register by EHCI-HCD driver. This is much safer than depending on the delay time to be accurate and aligining with controller's behaiver. Signed-off-by: Ye Li Signed-off-by: Peng Fan --- drivers/usb/host/ehci-mx6.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) -- 2.28.0 diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c index 37b59758bb..9531fefce0 100644 --- a/drivers/usb/host/ehci-mx6.c +++ b/drivers/usb/host/ehci-mx6.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include "ehci.h" @@ -267,6 +268,21 @@ int usb_phy_mode(int port) } #endif +static void ehci_mx6_powerup_fixup(struct ehci_ctrl *ctrl, uint32_t *status_reg, + uint32_t *reg) +{ + u32 result; + int ret; + + mdelay(50); + + ret = read_poll_timeout(ehci_readl, status_reg, result, !(result & EHCI_PS_PR), 5, 2000); + if (ret) + printf("%s timeout\n", __func__); + + *reg = ehci_readl(status_reg); +} + static void usb_oc_config(int index) { #if defined(CONFIG_MX6) @@ -366,6 +382,10 @@ int ehci_mx6_common_init(struct usb_ehci *ehci, int index) } #if !CONFIG_IS_ENABLED(DM_USB) +static const struct ehci_ops mx6_ehci_ops = { + .powerup_fixup = ehci_mx6_powerup_fixup, +}; + int ehci_hcd_init(int index, enum usb_init_type init, struct ehci_hccr **hccr, struct ehci_hcor **hcor) { @@ -394,6 +414,8 @@ int ehci_hcd_init(int index, enum usb_init_type init, if (ret) return ret; + ehci_set_controller_priv(index, NULL, &mx6_ehci_ops); + type = board_usb_phy_mode(index); if (hccr && hcor) { @@ -467,7 +489,8 @@ static int mx6_init_after_reset(struct ehci_ctrl *dev) } static const struct ehci_ops mx6_ehci_ops = { - .init_after_reset = mx6_init_after_reset + .powerup_fixup = ehci_mx6_powerup_fixup, + .init_after_reset = mx6_init_after_reset }; static int ehci_usb_phy_mode(struct udevice *dev)