From patchwork Wed Sep 16 12:57:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 312397 Delivered-To: patch@linaro.org Received: by 2002:a92:5ad1:0:0:0:0:0 with SMTP id b78csp415988ilg; Wed, 16 Sep 2020 05:33:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxiaj3Q9LxhGu7I4L1ZJVdThtQKbfdzOkrfkQfRrNVnebgfVlVFw2pkKulg3ZjqKR325QfY X-Received: by 2002:a50:fe82:: with SMTP id d2mr26509512edt.86.1600259639710; Wed, 16 Sep 2020 05:33:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1600259639; cv=pass; d=google.com; s=arc-20160816; b=RZKDcNLmK7Mur7hYVHvKEGEMx6Esgs48e9OeDumsTySh66/dd3g+X+NWcHbuaqBbIr 0CHt8nazV0md8322ODpYoSD3s2dW9PJ9lyV3LTi3NPrrMbA+vL2IyCIeTyTJOUq0HxDb oG8QpRMetuOBzDHWAZkrEUKmo/l8Wd8qgpryZr7KiAWrWD6L+bawUfsIRYtaX5ywcPQ+ B4SJ+Cw/v2IH0z73mMNPaM8Q2OasCHIj5q3O39H1lB8/lrroqROZ94YRzev+2vemx8bW S8HFjO09HTPA/3LTk2PI49BTFsi/lVS9x9rDIjTe9Q5tR4uEliAZ4UmZKOJgaCWaNu/5 IZHg== 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=qar1WVFYIp3jtTXqjKT9WTv5Ausey5Btw1NwSYOMEEw=; b=Fc6C4Bo/SXxu6zWBxT7B4mbOqyy3LKiBJe6w5AvN9vVoenhG8GMgDwptHRicAN5dDd P1hOtREQAfohMyQjWzpS6T5yXAA/ByrCAew7kLy76NBcjCkJyVypXAGJl8OzIwbNQNbK LH6/In7R/EV6FKughEr/q/01Wdc1CGIbBtMqCZDcezF4OUrdbdxxIgKrrFXrTxXhrhkJ dxMuI7SqLCNWdeAbxeQMvKDgeQ7BVLnj3h54N6SLC+VOyJJNeGEOvlUYGWvKbRhcG/hJ V6Wo3/vNE/KHT1roPt21MBEk+/0qoSD66FLYdG2QmOY3Uq/Gh/fIhvnuwWsAewRkzeue mYjA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=XV3PoIaw; 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 p21si12051256edq.151.2020.09.16.05.33.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Sep 2020 05:33:59 -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=XV3PoIaw; 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 501A482383; Wed, 16 Sep 2020 14:31:46 +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="XV3PoIaw"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9777682376; Wed, 16 Sep 2020 14:31:40 +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 EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on20629.outbound.protection.outlook.com [IPv6:2a01:111:f400:7d00::629]) (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 C512B82358 for ; Wed, 16 Sep 2020 14:31:37 +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=ctRPTSvP1oVJD9SIccPQZFjzQHVauRqUdfVkl+ce9MLfqpsTaGWTo2MwO+pvKeRSCr+9BPL9rG5+ldJy+A7efoCBzqMju5FLuCvXqOBsa6jbv3HgKnHLTWbpEALEiytn31EIVYvXzw6/NJ317JwyHKdvssnDLVVs8NqD2YsR2waEeB9WxtNRWU0LYNDm3MKmyNCJojtwmY2wmQQH9HRvaAvgIS1CH6nRW1m9zGCS57sfzpZNKxwNEZ52kNLWXKdsShnCjZmvdtC6tySeJUkVaCFR01c2q9JG8r2BLF+ZkDIPrL3I+Xs6RBthR1ltq8wGE7nkWriR3GyCc71bETa8pA== 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=qar1WVFYIp3jtTXqjKT9WTv5Ausey5Btw1NwSYOMEEw=; b=GKIjzRklNFTkwyuyNg8WaXw2sTmjEjHYKEyI7nUPUvlqe1I4Wjp7BzjdTBQhOhK2MMTUWeswZaTdbAGPA6pQ87NYC16FJa5DGwHSYdyHllRasX79HRC5IbMXMh7R7AhcYPDMWLx35Z4w3/U/D+T51ZCirQvO5gYcu+nMGWl3ujdYIT+75jc0A62UaLQd98bCYuu3ymJUdTIMJJYOp5B/X0eo6oH0XrbvS8Yfu7886AzQWWPUEoClkcAj6JyJOtyfz9wR1ieXEi1AmHHTXlhog5+GESCn8vHd4GM62VvaCg5qxf9KX53vOy1rVuSxlvjyckT9ntl43pmhOqHEACkz0g== 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=qar1WVFYIp3jtTXqjKT9WTv5Ausey5Btw1NwSYOMEEw=; b=XV3PoIawea7F2+KTknjAn+0g1pzOVHYEqD5xvRvm8dTP0sqGq2D8KmXol08tdt3HvsIuhGHesnRLMRgWbhhDPpAJwv41v+dH3KDachuFySrP5PqAJd98Rvoa9IsdAGL0QzFG6LqVOPnyvAdhHvKnwe4fjFGTcRSdHrz8Wy36W60= 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 DB3PR0402MB3915.eurprd04.prod.outlook.com (2603:10a6:8:e::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3370.17; Wed, 16 Sep 2020 12:31:36 +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:36 +0000 From: peng.fan@nxp.com To: sbabic@denx.de, marex@denx.de Cc: uboot-imx@nxp.com, u-boot@lists.denx.de, Ye Li , Peng Fan Subject: [PATCH 12/13] usb: ehci-mx6: Fix PHY power up issue on iMX8 platforms Date: Wed, 16 Sep 2020 20:57:04 +0800 Message-Id: <20200916125705.4341-13-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:34 +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: 2ca7388a-96e7-489f-4dd5-08d85a3c73d2 X-MS-TrafficTypeDiagnostic: DB3PR0402MB3915: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:873; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aAzrXjk9w+b5Q3820j8Z6Vpcrobrjos70eFP0tjqa5pdaHsMHUGl6KRW1wl7ZU0V2T4z49fgqaOssuK6T9jzBG5k0y4F7LLbHAqMuHCY6jWxCMMINWE5HBz+dQcMHwIpdtYiSt+Ml4NgasRJulfZcrSqQGkUcg4pBDBy002JMgGEGTTv1r95IjGR+D9XA3oCFFayvpEX8ucuXLawCPYZ4iJDy7k3BwbNY0dlKjEQaHP3QLkK1Wb275O2ClybxXvYWbn01ZMA0jkFSYkx4DnNUr06aQEvUm+0YfCF6vJsfKPhCr1KGj0sea3F6mHD+gC3k8MLvSF6Zqk/Hx8mOHDhOA== 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)(366004)(136003)(376002)(346002)(39860400002)(396003)(186003)(16526019)(6512007)(8936002)(54906003)(36756003)(6486002)(2906002)(1076003)(6506007)(478600001)(2616005)(956004)(5660300002)(6666004)(83380400001)(52116002)(316002)(86362001)(4326008)(26005)(66476007)(8676002)(9686003)(66946007)(66556008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: Cq2rtVn55xFv6Ga3uiJoB94XK1Ugbs1pMI7oXGUACqev7wzcOtLnoRWP23lcHA8EMraBJ86X/n/EQpbRawPnXVk00ZVtePCgPZVH5k+cLoCdvx73zeady8auzXQ1I5OK9rxNOByP+G/HR2LdU3PMajk/ZC3aMosa6DyPZdhAN99AIpok55S6azrEsHRQF1rSVOuiGqycjdrnNIT628O00yR0/6fEdq1cp01a5wQKakUIRZ4/XALaCx+fSUL31woXFXe/mBmTI3lGf/141ysPKVLJcLBli64pd2u/pHmZTFYiyRY/sZEMHkLAD6IaPwunGFl1naljdQgAg4s2P8LHF05a84N4/zq9r6/V6fnkxDEDn797w1oSZAaVpsxYlr+Epgdp/kfdAXw/gJgq1zQM5ewcoDOIu+7WChYO7wJG+Js1lduzWtcWLw8rv9KymjTT/d6Mz4rL06lRNaDmeMFwhSWjlF4s/Jhs2lKDXEgEwuHnmJMwp1qLG3AMB72lVwmZHi/6le5V+WiLE7yemAG0JKCqFtB7RgkmX3Z1GIiFHjTPVRB1cYB/J2ZcQmiXFojvnSGhWEIJJp8vH5TNcTAqkaU2NfSDlfW1gO4i8Yv7jMKpcBHwaSpuLgLw8wVAwP/tzh93TvC4mz2it+Jn5KcqHg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2ca7388a-96e7-489f-4dd5-08d85a3c73d2 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:36.2844 (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: EE8HVekF22LScOENzBJFdRx6NTjn2l/fYcTokVumKZoLuH29YxYNWL6lX4Gavap3TqEtnFh+4iSbTT7Kd08HvQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR0402MB3915 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: Ye Li On iMX8 platforms like 8QM/QXP, we must power up the USB PHY resource before accessing the PHY. However, current init flow access the USB PHY in ehci_mx6_common_init prior than ehci_usb_phy_mode where the PHY is power up. Fix the issue by adding ehci_get_usb_phy function to parse the PHY address from DTB and power up the PHY before ehci_mx6_common_init. Signed-off-by: Ye Li Signed-off-by: Peng Fan --- drivers/usb/host/ehci-mx6.c | 58 +++++++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 18 deletions(-) -- 2.28.0 diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c index 7079750a93..080bde71d3 100644 --- a/drivers/usb/host/ehci-mx6.c +++ b/drivers/usb/host/ehci-mx6.c @@ -517,6 +517,7 @@ struct ehci_mx6_priv_data { struct usb_ehci *ehci; struct udevice *vbus_supply; enum usb_init_type init_type; + void *__iomem phy_base; int portnr; }; @@ -592,11 +593,39 @@ int __weak board_ehci_usb_phy_mode(struct udevice *dev) static int ehci_usb_phy_mode(struct udevice *dev) { struct ehci_mx6_priv_data *priv = dev_get_priv(dev); - void *__iomem addr = dev_read_addr_ptr(dev); void *__iomem phy_ctrl, *__iomem phy_status; + u32 val; + + if (is_mx6() || is_mx7ulp() || is_imx8()) { + phy_ctrl = (void __iomem *)(priv->phy_base + USBPHY_CTRL); + val = readl(phy_ctrl); + + if (val & USBPHY_CTRL_OTG_ID) + priv->init_type = USB_INIT_DEVICE; + else + priv->init_type = USB_INIT_HOST; + } else if (is_mx7() || is_imx8mm() || is_imx8mn()) { + phy_status = (void __iomem *)(priv->phy_base + + USBNC_PHY_STATUS_OFFSET); + val = readl(phy_status); + + if (val & USBNC_PHYSTATUS_ID_DIG) + priv->init_type = USB_INIT_DEVICE; + else + priv->init_type = USB_INIT_HOST; + } else { + return -EINVAL; + } + + return 0; +} + +static int ehci_get_usb_phy(struct udevice *dev) +{ + struct ehci_mx6_priv_data *priv = dev_get_priv(dev); + void *__iomem addr = (void *__iomem)devfdt_get_addr(dev); const void *blob = gd->fdt_blob; int offset = dev_of_offset(dev), phy_off; - u32 val; /* * About fsl,usbphy, Refer to @@ -627,23 +656,9 @@ static int ehci_usb_phy_mode(struct udevice *dev) return ret; } #endif - - phy_ctrl = (void __iomem *)(addr + USBPHY_CTRL); - val = readl(phy_ctrl); - - if (val & USBPHY_CTRL_OTG_ID) - priv->init_type = USB_INIT_DEVICE; - else - priv->init_type = USB_INIT_HOST; + priv->phy_base = addr; } else if (is_mx7() || is_imx8mm() || is_imx8mn()) { - phy_status = (void __iomem *)(addr + - USBNC_PHY_STATUS_OFFSET); - val = readl(phy_status); - - if (val & USBNC_PHYSTATUS_ID_DIG) - priv->init_type = USB_INIT_DEVICE; - else - priv->init_type = USB_INIT_HOST; + priv->phy_base = addr; } else { return -EINVAL; } @@ -765,6 +780,13 @@ static int ehci_usb_probe(struct udevice *dev) if (ret) debug("%s: No vbus supply\n", dev->name); #endif + + ret = ehci_get_usb_phy(dev); + if (ret) { + debug("%s: fail to get USB PHY base\n", dev->name); + return ret; + } + ret = ehci_mx6_common_init(ehci, priv->portnr); if (ret) return ret;