Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5951470imu; Mon, 21 Jan 2019 00:09:24 -0800 (PST) X-Google-Smtp-Source: ALg8bN59wAqGBLL5u/Qav5d+Q2BfqdcJV0bsuT9RszsMiN3yGSTKtMesDXgIwDDSmQtVhyux30k7 X-Received: by 2002:a63:f444:: with SMTP id p4mr27069021pgk.124.1548058164490; Mon, 21 Jan 2019 00:09:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548058164; cv=none; d=google.com; s=arc-20160816; b=mbB8tqjFVgwHzsluIq9Yoy2WT4+3RTG3IQPSpzizjPrzKx75FLLwbxjd+w8SpFpdoJ fPJx9mJ0feyl5TfOufS55mt3BmfXfpZb4HJMIzUkoFoJb78fNWWktBgPxEiphuLvkSQG vqSAy1Xfho15IaQEXevgI4AZWQmyiJF2T+mX9mDmxkY4x4/ZhyaScX/mcGvcfzgss+FH zZue87mvTQzWW0VGFJGO4tAxc9q7P4x2uwJJMVK2pIJfreagItfQwOpnDB32xGcCl0SX P6p/Md+0bxm6jjtezr2bmlIh3qGMx/S+Moej4tWXsHUgq4XFXy0GyIVQp3gpkaOy3Do0 Bgbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=OVvBSps+0/2L/lPrp0md7tmg4SnBvJ0ED+KoLkg2AEM=; b=q6UefVcYeq7krWN6ObLJrnlrsmY4PdMJATZtvJZUaLmuWGMpiZFHcUOsKMhnFq7PW4 aRuyJgUEcCGGIOf3bvl9pvGkTcrDb/HXCASRp0CEr39TY4RVVEZ8eBYs5J1a76vjxU2+ EGnPa02+9uCX2ENETksSZj6fBoqm3FeTa/PoF6EZJSg93uP/iM3ivKVgbI2d8CF7GVyG ycsoX6NtmvKuFp4RTxdYt2gWqNIZldJWVdd3eWYJeNbPdFziC2mKTjOLo+PEDDIYbwUD 846v5Yole46ewVJJybVH7sDl/EGtP+fkCqw27ulvSIIlTp243WOQXYqWx/Qcl7Qrhali VP7Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 82si12092287pfa.115.2019.01.21.00.09.09; Mon, 21 Jan 2019 00:09:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728471AbfAUIHO (ORCPT + 99 others); Mon, 21 Jan 2019 03:07:14 -0500 Received: from inva021.nxp.com ([92.121.34.21]:51350 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729883AbfAUIFy (ORCPT ); Mon, 21 Jan 2019 03:05:54 -0500 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 11F0E2000D4; Mon, 21 Jan 2019 04:18:39 +0100 (CET) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 86D39200064; Mon, 21 Jan 2019 04:18:33 +0100 (CET) Received: from titan.ap.freescale.net (TITAN.ap.freescale.net [10.192.208.233]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 89D81402D9; Mon, 21 Jan 2019 11:18:26 +0800 (SGT) From: Yinbo Zhu To: Alan Stern Cc: yinbo.zhu@nxp.com, xiaobo.xie@nxp.com, jerry.huang@nxp.com, ran.wang_1@nxp.com, Greg Kroah-Hartman , Ramneek Mehresh , Nikhil Badola , Suresh Gupta , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Suresh Gupta Subject: [PATCH v1 2/6] usb: phy: Workaround for USB erratum-A005728 Date: Mon, 21 Jan 2019 11:13:00 +0800 Message-Id: <20190121031304.31161-2-yinbo.zhu@nxp.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20190121031304.31161-1-yinbo.zhu@nxp.com> References: <20190121031304.31161-1-yinbo.zhu@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Suresh Gupta PHY_CLK_VALID bit for UTMI PHY in USBDR does not set even if PHY is providing valid clock. Workaround for this involves resetting of PHY and check PHY_CLK_VALID bit multiple times. If PHY_CLK_VALID bit is still not set even after 5 retries, it would be safe to deaclare that PHY clock is not available. This erratum is applicable for USBDR less then ver 2.4. Signed-off-by: Suresh Gupta Signed-off-by: yinbo.zhu --- drivers/usb/host/ehci-fsl.c | 37 ++++++++++++++++++++++++++----------- drivers/usb/host/ehci-fsl.h | 3 +++ 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c index 71c4661..a28ec1e 100644 --- a/drivers/usb/host/ehci-fsl.c +++ b/drivers/usb/host/ehci-fsl.c @@ -176,6 +176,17 @@ static int fsl_ehci_drv_probe(struct platform_device *pdev) return retval; } +static bool usb_phy_clk_valid(struct usb_hcd *hcd) +{ + void __iomem *non_ehci = hcd->regs; + bool ret = true; + + if (!(in_be32(non_ehci + FSL_SOC_USB_CTRL) & PHY_CLK_VALID)) + ret = false; + + return ret; +} + static int ehci_fsl_setup_phy(struct usb_hcd *hcd, enum fsl_usb2_phy_modes phy_mode, unsigned int port_offset) @@ -214,6 +225,16 @@ static int ehci_fsl_setup_phy(struct usb_hcd *hcd, /* fall through */ case FSL_USB2_PHY_UTMI: case FSL_USB2_PHY_UTMI_DUAL: + /* PHY_CLK_VALID bit is de-featured from all controller + * versions below 2.4 and is to be checked only for + * internal UTMI phy + */ + if (pdata->controller_ver > FSL_USB_VER_2_4 && + pdata->have_sysif_regs && !usb_phy_clk_valid(hcd)) { + pr_err("fsl-ehci: USB PHY clock invalid\n"); + return -EINVAL; + } + if (pdata->have_sysif_regs && pdata->controller_ver) { /* controller version 1.6 or above */ clrsetbits_be32(non_ehci + FSL_SOC_USB_CTRL, @@ -232,17 +253,11 @@ static int ehci_fsl_setup_phy(struct usb_hcd *hcd, break; } - /* - * check PHY_CLK_VALID to determine phy clock presence before writing - * to portsc - */ - if (pdata->check_phy_clk_valid) { - if (!(ioread32be(non_ehci + FSL_SOC_USB_CTRL) & - PHY_CLK_VALID)) { - dev_warn(hcd->self.controller, - "USB PHY clock invalid\n"); - return -EINVAL; - } + if (pdata->have_sysif_regs && + pdata->controller_ver > FSL_USB_VER_1_6 && + !usb_phy_clk_valid(hcd)) { + dev_warn(hcd->self.controller, "USB PHY clock invalid\n"); + return -EINVAL; } ehci_writel(ehci, portsc, &ehci->regs->port_status[port_offset]); diff --git a/drivers/usb/host/ehci-fsl.h b/drivers/usb/host/ehci-fsl.h index cbc4220..9d18c6e 100644 --- a/drivers/usb/host/ehci-fsl.h +++ b/drivers/usb/host/ehci-fsl.h @@ -50,4 +50,7 @@ #define UTMI_PHY_EN (1<<9) #define ULPI_PHY_CLK_SEL (1<<10) #define PHY_CLK_VALID (1<<17) + +/* Retry count for checking UTMI PHY CLK validity */ +#define UTMI_PHY_CLK_VALID_CHK_RETRY 5 #endif /* _EHCI_FSL_H */ -- 1.7.1