From patchwork Wed Jul 9 10:01:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Gautam X-Patchwork-Id: 4513011 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 174D0BEEAA for ; Wed, 9 Jul 2014 10:05:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 29848202E5 for ; Wed, 9 Jul 2014 10:05:40 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4899E202B4 for ; Wed, 9 Jul 2014 10:05:39 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1X4oi6-0006ff-Q1; Wed, 09 Jul 2014 10:02:46 +0000 Received: from mail-pa0-x22b.google.com ([2607:f8b0:400e:c03::22b]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1X4ohf-0006GD-L8 for linux-arm-kernel@lists.infradead.org; Wed, 09 Jul 2014 10:02:23 +0000 Received: by mail-pa0-f43.google.com with SMTP id lf10so8993100pab.16 for ; Wed, 09 Jul 2014 03:01:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=rDmnxGJ7wwQWYWIAHUDKISGZ8oYxuW7uLNy4swx12qw=; b=f9Epmm2p31g2bEZB1J3VS+Irrn7HEjZllWs8xl81bu/RxKoDRmT1Ae1u1DGhijth33 FyzAW++UmaR8L5H/Fwq2SF1qUydR8jBcNiQRNldJdurSi5IJeqFUwA6ePCziVfUOW4m4 xW+qQFC7jtAO0kElOoM1t/EImr/5FDGj2BDquMQj7RHaBY8Bm5/KaYE+PCs7uDzmUpjJ gsaShIvk0/UhrFA8zYhEsq0+m8ppZ/FJtJbB9sHBUOrRqDzU03xNCv9SYfdc1eRP/Fjr 1lslNYcFZVDWl8JgC7yxQv4hcFbKuVHrMUoDUf1xsXEhw5fX/9Z+EdC7vuYaJDtM7lHq rD7Q== X-Received: by 10.70.45.97 with SMTP id l1mr10257058pdm.75.1404900118876; Wed, 09 Jul 2014 03:01:58 -0700 (PDT) Received: from vivek-linuxpc.sisodomain.com ([14.140.216.146]) by mx.google.com with ESMTPSA id co3sm58341286pbb.89.2014.07.09.03.01.54 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 09 Jul 2014 03:01:58 -0700 (PDT) From: Vivek Gautam To: linux-usb@vger.kernel.org, linux-samsung-soc@vger.kernel.org Subject: [PATCH v2 3/4] usb: host: xhci-plat: Caibrate PHY post host reset Date: Wed, 9 Jul 2014 15:31:35 +0530 Message-Id: <1404900096-1721-4-git-send-email-gautam.vivek@samsung.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1404900096-1721-1-git-send-email-gautam.vivek@samsung.com> References: <1404900096-1721-1-git-send-email-gautam.vivek@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140709_030219_729112_166AED8B X-CRM114-Status: GOOD ( 13.80 ) X-Spam-Score: -0.4 (/) Cc: pratyush.anand@st.com, kgene.kim@samsung.com, sergei.shtylyov@cogentembedded.com, mathias.nyman@intel.com, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, kishon@ti.com, heikki.krogerus@linux.intel.com, Vivek Gautam , jwerner@chromium.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some quirky PHYs may require to be calibrated post the host controller initialization. The USB 3.0 DRD PHY on Exynos5420/5800 systems, coming along with Synopsys's DWC3 controller, is one such PHY which needs to be calibrated post xhci's reset at initialization time and at resume time, to get the controller work at SuperSpeed. Signed-off-by: Vivek Gautam --- drivers/usb/host/xhci-plat.c | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index e50bd7d..decf349 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -35,7 +35,27 @@ static void xhci_plat_quirks(struct device *dev, struct xhci_hcd *xhci) /* called during probe() after chip reset completes */ static int xhci_plat_setup(struct usb_hcd *hcd) { - return xhci_gen_setup(hcd, xhci_plat_quirks); + struct device *parent; + int ret; + + ret = xhci_gen_setup(hcd, xhci_plat_quirks); + if (ret) { + dev_err(hcd->self.controller, "xhci setup failed\n"); + return ret; + } + + parent = hcd->self.controller->parent; + if (of_device_is_compatible(parent->of_node, "synopsys,dwc3") || + of_device_is_compatible(parent->of_node, "snps,dwc3")) { + if (!IS_ERR(hcd->gen_phy)) { + ret = phy_calibrate(hcd->gen_phy); + if (ret < 0 && ret != -ENOTSUPP) + dev_err(hcd->self.controller, + "failed to calibrate USB PHY\n"); + } + } + + return ret; } static int xhci_plat_start(struct usb_hcd *hcd) @@ -288,8 +308,23 @@ static int xhci_plat_resume(struct device *dev) { struct usb_hcd *hcd = dev_get_drvdata(dev); struct xhci_hcd *xhci = hcd_to_xhci(hcd); + int ret; + + ret = xhci_resume(xhci, 0); + if (ret) + return ret; - return xhci_resume(xhci, 0); + if (of_device_is_compatible(dev->parent->of_node, "synopsys,dwc3") || + of_device_is_compatible(dev->parent->of_node, "snps,dwc3")) { + if (!IS_ERR(hcd->gen_phy)) { + ret = phy_calibrate(hcd->gen_phy); + if (ret < 0 && ret != -ENOTSUPP) + dev_err(hcd->self.controller, + "failed to calibrate USB PHY\n"); + } + } + + return ret; } static const struct dev_pm_ops xhci_plat_pm_ops = {