Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5093746yba; Wed, 8 May 2019 07:48:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqz0TQKjnGz7Y65ZaBoRtJe5bwMVhEhYCC7s6px9UYimliJFf2UTEBRUPu0oRUom9g3yfI1z X-Received: by 2002:a17:902:10c:: with SMTP id 12mr37249987plb.61.1557326910349; Wed, 08 May 2019 07:48:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557326910; cv=none; d=google.com; s=arc-20160816; b=cElOdC1kA2BF6kYVdwHbn464CZEWzLFtgCDxT96i2G4HnS+HGIxuL8YtxpS3GvZOQI l9K+MqYy9lNBm80TinXkpaytCpqiIgRfEpR0kUIiMxnz1AxAKY6CG02S3BK2og298Yo1 M5EKS+8o5OtZvHAH3IgYCstHdoaJCzgN4eebieIR7g/vD9K32GuljWwj0tDCG8YLI8gG eidOAANgjQNhL2gV61kMHgyVBdRazXtLg2DwF6FjyFsgjIjK05K6SAiFUeXMHxwtaXV2 jIA1MlBKP4ydqYgWvkHNfRzT05LwUuRPDxvKNZ4PnmeyAEG7GSykre3kwAUyDE5y0Q6l r5vA== 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=TjwmQ9KMWlUHXG6LuGZz/et3JpgKImIz29xnMPBW4sw=; b=Wd/kSruUH9cV4dtO+VWDZpIUiCOM6DW3xmpLvsCkcRW20FTNZTBRYQgT77IAiGAXEN uVniqAyBNrifipQBLUVYt5kR+ygfVThw7TXGu1YHDDLrMgvaeOlUNmLKR6R7Q7Rvh+L7 23IU6RL7+FNK8eSnqMv3/uktwPcawSv0qBoGLuGpTOXQP4ne2rVXIeg2K8RU8jCt414+ hlyvcZtHOaxaUFngZMIg2mRnSVpN7dp5OxT5QjTQaZfSpOP23CdruhDJ5gbneUbqjozV 3yCNnw5Ugqpvr4FatweIyrNkKEhSz5AjorGb8mBXFAEz6btY2ioS8sG5h+hpcpd6dzBJ /EoQ== 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 u16si8276343pgl.13.2019.05.08.07.48.13; Wed, 08 May 2019 07:48:30 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727993AbfEHOPO (ORCPT + 99 others); Wed, 8 May 2019 10:15:14 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:39734 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1726703AbfEHOPO (ORCPT ); Wed, 8 May 2019 10:15:14 -0400 Received: (qmail 1923 invoked by uid 2102); 8 May 2019 10:15:13 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 8 May 2019 10:15:13 -0400 Date: Wed, 8 May 2019 10:15:13 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Yinbo Zhu cc: Xiaobo Xie , Greg Kroah-Hartman , Ramneek Mehresh , Nikhil Badola , Ran Wang , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Jiafei Pan , Suresh Gupta Subject: Re: [PATCH v5 2/5] usb: phy: Workaround for USB erratum-A005728 In-Reply-To: <20190508060608.33882-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 Wed, 8 May 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 v5: > remove dev_err function unnecessary parameters > > 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 38674b7..1634ac8 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)) { This is still wrong. The line above should be indented four characters less than it is: the '!' should line up with the 'p' in the line above it. Alan Stern > + 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 */ >