Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2097148ybd; Mon, 24 Jun 2019 00:22:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqw5PUSIEqmh85sEPCIZ4jHAu3GYze/RQI9p2j3avsiK0oyU0RPTI+NY3ylfZ/nIPfH55K7d X-Received: by 2002:a63:5c16:: with SMTP id q22mr28939730pgb.200.1561360920522; Mon, 24 Jun 2019 00:22:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561360920; cv=none; d=google.com; s=arc-20160816; b=qjlhJLf7Fbv/1DdfZjmjPobjmwQs9/CTPZRvbO/CW/DeJCt5x4rbj7hCe5dTm9yzXH zIPuBkj8uhKImKO4V/ckAUkAKzbZ978QUN9aXm5g2JS0bhPR8VCyUBnSWzG08kWWr0yB JBeYsK9ODp85X7Ees1f5VWpJK7IamLeaMBV2OYpfj2qY5HGDZ3kVPtFbCA14TPr3sIph 0+PstK0m7cuN9uPtx75hlCWS3pQ0AVln6gXiIWho4A7EobAhDbG4X4It2ZfRDPiFINbn srBTN3/Diw04OdweUCL3WRyhU1TJRQw1YpapG1Urc8tRRjdcbuq75NveeIqL3Rf98bMw BHYA== 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=BnW3CTHpm0Oy4IVhmiKhfojC8uq2/aSQkt+vxdda1XU=; b=pby9E7QQ4cbtttanAAYoIk7fSkMq5FwzEnFnS1jIopKBTUS9Z3XestP6tc6Smi+CSV Z/f2w63RaCcIrWwDJHvMijkdsK0ZWLqvyZFbfs0URWxJ+xHst1ngTgXiuXCUeAcJdL+I vdlBrKrmt5NR2thOJPp+Sx2GDktMeqxiq9dnWC9nkBWXMbFRIZM2jlFMej2JrkKpMscO klwJl8q8vI4AUKwDbCyLfJBE70381kBHszkHJYaWz2QTu49admEoLkfSsFE4V9esqVFx c64Cr5cvgWEAin7tivToccZUGQ26VR/05MCZCTtAMfW33/zadjmTVqDEmZPv/loWv0oZ MUvQ== 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 n9si10237352pjo.65.2019.06.24.00.21.44; Mon, 24 Jun 2019 00:22:00 -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 S1727659AbfFXHUu (ORCPT + 99 others); Mon, 24 Jun 2019 03:20:50 -0400 Received: from inva020.nxp.com ([92.121.34.13]:55558 "EHLO inva020.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727753AbfFXHUb (ORCPT ); Mon, 24 Jun 2019 03:20:31 -0400 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id E4D031A056F; Mon, 24 Jun 2019 09:20:28 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id E3B5D1A056E; Mon, 24 Jun 2019 09:20:22 +0200 (CEST) Received: from mega.ap.freescale.net (mega.ap.freescale.net [10.192.208.232]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 28002402AB; Mon, 24 Jun 2019 15:20:16 +0800 (SGT) From: Yinbo Zhu To: Alan Stern , Greg Kroah-Hartman Cc: yinbo.zhu@nxp.com, xiaobo.xie@nxp.com, jiafei.pan@nxp.com, Ramneek Mehresh , Nikhil Badola , Ran Wang , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Suresh Gupta Subject: [PATCH v8 2/5] usb: phy: Workaround for USB erratum-A005728 Date: Mon, 24 Jun 2019 15:22:16 +0800 Message-Id: <20190624072219.15258-2-yinbo.zhu@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190624072219.15258-1-yinbo.zhu@nxp.com> References: <20190624072219.15258-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 v2: replace Yinbo.Zhu with Yinbo Zhu. Change in v3: replace in_be32 with ioread32be. Change in v4: Incorrect indentation of the continuation line. replace pr_err with dev_err. 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 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