Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp6322774ybi; Tue, 4 Jun 2019 22:50:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqyA1Tl/qXEh7AMDKa5wasb0VK17QTcB1ylSbk7Z3QD9NrpuOCzuCudCqoXhjrXIqcEJCVmc X-Received: by 2002:a62:bd11:: with SMTP id a17mr35754238pff.126.1559713828324; Tue, 04 Jun 2019 22:50:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559713828; cv=none; d=google.com; s=arc-20160816; b=NUzjeyql5kocD9+qIkI/4FHZRRxp0DgxYkt+8FKC/xoqu8VKy1uTStLiRp40h9FB/7 Cpg8a6MPlLqvIqrxO5Ijl2DGq+I1n6x4DGQbDEKAUyp9FXkxMx3illJAt0WauUZjnAcT 35MlVJqyjDdLsFQjR2fSMNApxJv0YeVVoMxAHPiWY2F4Rg6461TNvBPLdrD/p4foYoVN UYmkU06dhdDBHg4XC9YxT74wjcI9DOH9vgQ23Hiy7NC4ExZFSaLoahMYQ8pW3nl83bur I7Qna9AVHXYYa7ITDv8j6xnuFhw3Bd4YGGr1dH+3CnKKuxrsxsbzhLIg84yxf1W7XjF5 4eUQ== 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=epFPDTtie8P7S2DPmTaUYtNMuhOFOh5ppphutPj5FcA=; b=usEtEBRrLn7ShauZaelnRVx6mv9P0Y2TAlzKGUBbXDv1ct0zPeb1gxSx2mQ6MIiTru 5qvNkOHzoWS5NSx3/96zLgwGsJQT3YKm9gcimt+tJ9vIb24nnMN0M0w9XS/mrue6Ih/b 49T8psvKJQ2un4+SC0DdRcCXZ/aGf8fDQHD9p4IsZvN0+LoLEFMs/H9gRkx2ks8e3F3a PSWm6YGnci9Q2xHtUstme7cQFFa7oQ/yRjjIH6Dt2VoPUM6IC7dMJ9388pHrioZT+IZs XSUqwYiYWMMLZJB9JQWmM51JaQqe/LOzWzJlX1U1rGNxXGYW4hip96Sakl29jV9Clo/l phfg== 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 y12si25796011pgr.329.2019.06.04.22.49.58; Tue, 04 Jun 2019 22:50:28 -0700 (PDT) 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 S1726636AbfFEFsT (ORCPT + 99 others); Wed, 5 Jun 2019 01:48:19 -0400 Received: from inva021.nxp.com ([92.121.34.21]:43334 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726537AbfFEFsP (ORCPT ); Wed, 5 Jun 2019 01:48:15 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id E8B51200719; Wed, 5 Jun 2019 07:48:12 +0200 (CEST) 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 61B8D200713; Wed, 5 Jun 2019 07:48:07 +0200 (CEST) Received: from localhost.localdomain (mega.ap.freescale.net [10.192.208.232]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 95D7A402DB; Wed, 5 Jun 2019 13:48:00 +0800 (SGT) From: Yinbo Zhu To: Alan Stern Cc: yinbo.zhu@nxp.com, xiaobo.xie@nxp.com, Greg Kroah-Hartman , Ramneek Mehresh , Nikhil Badola , Ran Wang , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, jiafei.pan@nxp.com, Suresh Gupta Subject: [PATCH v6 2/5] usb: phy: Workaround for USB erratum-A005728 Date: Wed, 5 Jun 2019 13:49:49 +0800 Message-Id: <20190605054952.34687-2-yinbo.zhu@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190605054952.34687-1-yinbo.zhu@nxp.com> References: <20190605054952.34687-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 --- Change in v6: Indented the code in ehci-fsl.c 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 38674b7aa51e..8f3bf3efb038 100644 --- a/drivers/usb/host/ehci-fsl.c +++ b/drivers/usb/host/ehci-fsl.c @@ -183,6 +183,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 (!(ioread32be(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) @@ -226,6 +237,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)) { + dev_err(dev, "USB PHY clock invalid\n"); + return -EINVAL; + } + if (pdata->have_sysif_regs && pdata->controller_ver) { /* controller version 1.6 or above */ tmp = ioread32be(non_ehci + FSL_SOC_USB_CTRL); @@ -249,17 +270,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 cbc422032e50..9d18c6e6ab27 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 */ -- 2.17.1