From patchwork Tue Sep 2 11:12:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Gautam X-Patchwork-Id: 4824541 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9699C9F2ED for ; Tue, 2 Sep 2014 11:16:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 918D020170 for ; Tue, 2 Sep 2014 11:16:03 +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 77E66200FF for ; Tue, 2 Sep 2014 11:16:02 +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 1XOm1Z-0000wF-2M; Tue, 02 Sep 2014 11:13:21 +0000 Received: from mail-pa0-x235.google.com ([2607:f8b0:400e:c03::235]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XOm1R-0000o4-6g for linux-arm-kernel@lists.infradead.org; Tue, 02 Sep 2014 11:13:13 +0000 Received: by mail-pa0-f53.google.com with SMTP id fa1so14214371pad.26 for ; Tue, 02 Sep 2014 04:12:52 -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=P04NEk9IWH1HGtWKAbSOInrJN7iP8juCzMY/lfCI+hs=; b=rsDf1Eb+2bCovKdiElsbE05+P0tq54qrEohMNW6mNsSmlDXVfOqG84vMrTEE6hxSpv 68ujkG8GiANM6kLrcPwTF3bjZYrB/q1AZ3gKhbsnWnsC+D1+ddCKoSnK6QH0kgj1G82F YrNEgZfFmAQjh0Hk9g4+WYx8EtnLJAz9gcqeSNszD3h+Pfrz1Rrku2AsB1AvMHiwxWgL RtEd3nYV3ZcFu1yAERIF3dR30oN1tF/BwBxsuBPh/oFf2xJy75BZ7/eP/9KLYuGc0alR Kp3vG1C/o8TJoL8wWojbrms5JODdWgAtysbBfxj9pCDIKcvYb0wcuaDtommUrd4DIwbm WEVg== X-Received: by 10.68.65.69 with SMTP id v5mr3619497pbs.156.1409656372071; Tue, 02 Sep 2014 04:12:52 -0700 (PDT) Received: from vivek-linuxpc.sisodomain.com ([14.140.216.146]) by mx.google.com with ESMTPSA id ry9sm3602503pbc.94.2014.09.02.04.12.47 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 02 Sep 2014 04:12:51 -0700 (PDT) From: Vivek Gautam To: linux-usb@vger.kernel.org Subject: [PATCH v6 3/4] usb: hcd: Calibrate PHY post hcd reset Date: Tue, 2 Sep 2014 16:42:17 +0530 Message-Id: <1409656338-20337-4-git-send-email-gautam.vivek@samsung.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1409656338-20337-1-git-send-email-gautam.vivek@samsung.com> References: <1409656338-20337-1-git-send-email-gautam.vivek@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140902_041313_273380_91B08290 X-CRM114-Status: GOOD ( 11.81 ) X-Spam-Score: -0.4 (/) Cc: linux-samsung-soc@vger.kernel.org, sergei.shtylyov@cogentembedded.com, mathias.nyman@intel.com, gregkh@linuxfoundation.org, jg1.han@samsung.com, linux-kernel@vger.kernel.org, balbi@ti.com, kishon@ti.com, kgene.kim@samsung.com, stern@rowland.harvard.edu, Vivek Gautam , heikki.krogerus@linux.intel.com, 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=-3.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE,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 hcd 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. So facilitating the HCDs to calibrate the PHY. Signed-off-by: Vivek Gautam --- drivers/usb/core/hcd.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index c4ed66c..6e01d09 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -2202,6 +2202,7 @@ int hcd_bus_resume(struct usb_device *rhdev, pm_message_t msg) struct usb_hcd *hcd = container_of(rhdev->bus, struct usb_hcd, self); int status; int old_state = hcd->state; + int ret; dev_dbg(&rhdev->dev, "usb %sresume\n", (PMSG_IS_AUTO(msg) ? "auto-" : "")); @@ -2216,6 +2217,15 @@ int hcd_bus_resume(struct usb_device *rhdev, pm_message_t msg) hcd->state = HC_STATE_RESUMING; status = hcd->driver->bus_resume(hcd); + + /* calibrate the phy here */ + ret = phy_calibrate(hcd->gen_phy); + if (ret < 0 && ret != -ENOTSUPP) { + dev_err(hcd->self.controller, + "failed to calibrate USB PHY\n"); + return ret; + } + clear_bit(HCD_FLAG_WAKEUP_PENDING, &hcd->flags); if (status == 0) { struct usb_device *udev; @@ -2738,6 +2748,14 @@ int usb_add_hcd(struct usb_hcd *hcd, } hcd->rh_pollable = 1; + /* calibrate the phy here */ + retval = phy_calibrate(hcd->gen_phy); + if (retval < 0 && retval != -ENOTSUPP) { + dev_err(hcd->self.controller, + "failed to calibrate USB PHY\n"); + return retval; + } + /* NOTE: root hub and controller capabilities may not be the same */ if (device_can_wakeup(hcd->self.controller) && device_can_wakeup(&hcd->self.root_hub->dev))