Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3599754imu; Mon, 28 Jan 2019 07:38:09 -0800 (PST) X-Google-Smtp-Source: ALg8bN58UNIEXsT+MiIxgl/OVFVZ2p6Kx3udFGz+wmY1rpcYvITeKBIKoNAAiGguI1ZwQ5ESEmNx X-Received: by 2002:a63:374e:: with SMTP id g14mr20698671pgn.59.1548689889660; Mon, 28 Jan 2019 07:38:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548689889; cv=none; d=google.com; s=arc-20160816; b=fG1ydKTxiXMaYB1HkLelOhU0YujOJaVL1PHJTfHIGg8MUeh6Hn8+3XpgWE9c5ayX/J ya0po4rkQ0fwTeR+yLuiguVAwhJuq2ZJAE+KDF2uJPNg/ppbnaOlZwNuXnh1SSO5Ck8H 2zgsc7zUgWbjPYZG1egZqNyi48qRcVuTuTeouHTzrkvhc2ObjX6zWp8j4vZzL8rYGbzo ldvj+QUIbmIqwLf9OHKDgSnyrQlQbu/y/ejP/6TPFRi+Pdmrvms/6XvgC8795OKQTzhu DMPtI9euYB2Ruvl+gfrz9HMln5xu+f9A75PtpvdFETdYtsSISnqS51eWRz2oDvluYtss 4JBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:in-reply-to :subject:cc:to:from:date; bh=SPPkHawuGsaee7T9RQoQqC7LGflO03TXFoLtDP/anB8=; b=CrRbqszhS8VrkIcW8fy+oVj4+gfOyDvnWboA36XcnOTblVl4DpHPoOb0DizGJmUZ/s d5CkycjHQ+y4UWgHF9M36GNW1oFclTfC8XztubRhBV7KWqXVTT7pqkU0zG27DFWGetJt DySc79ZmcSa6L6asj5oMF64srfu8dBWHUpYScr6XiFsoWb0+vlWbjKMyrAayJK7TioaV 583LT/G7vPgN1PcRrEFr15OGDPyERZC8NR/c23RYFrJ0epBwZCJ5+NbbjLT5JcthrC2O glTHj9JbTDBkaCq5D7fZSMUbbpBU9AuDbwh3xFqc/GfphmgFo+8I5mckoYJ91x5UfdjA E4UQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d15si14092790pgt.498.2019.01.28.07.37.54; Mon, 28 Jan 2019 07:38:09 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726762AbfA1Pgs (ORCPT + 99 others); Mon, 28 Jan 2019 10:36:48 -0500 Received: from iolanthe.rowland.org ([192.131.102.54]:57038 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1726695AbfA1Pgs (ORCPT ); Mon, 28 Jan 2019 10:36:48 -0500 Received: (qmail 3449 invoked by uid 2102); 28 Jan 2019 10:36:47 -0500 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 28 Jan 2019 10:36:47 -0500 Date: Mon, 28 Jan 2019 10:36:47 -0500 (EST) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Yinbo Zhu cc: Xiaobo Xie , Jerry Huang , Ran Wang , Greg Kroah-Hartman , Ramneek Mehresh , Nikhil Badola , Suresh Gupta , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Suresh Gupta Subject: Re: [PATCH v4 2/5] usb: phy: Workaround for USB erratum-A005728 In-Reply-To: <20190125060356.14294-2-yinbo.zhu@nxp.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 25 Jan 2019, Yinbo Zhu wrote: > 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 v4: > Incorrect indentation of the continuation line. > replace pr_err with dev_err. > > drivers/usb/host/ehci-fsl.c | 38 +++++++++++++++++++++++++++----------- > drivers/usb/host/ehci-fsl.h | 3 +++ > 2 files changed, 30 insertions(+), 11 deletions(-) > > diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c > index 38674b7..373a816 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,17 @@ 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, > + "%s: USB PHY clock invalid\n", dev_name(dev)); This looks silly; it prints the device name twice (once because that's what dev_err() does, and then again because you explicitly told it to print the device name). Look at how dev_err() is used in other parts of the driver and do the same thing. > + 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 +271,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"); Once again, you have a continuation line that is indented by the same amount as the code in the inner block. Please fix this properly. > + 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 */ Alan Stern