From patchwork Mon Jul 14 12:49:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Gautam X-Patchwork-Id: 4545901 Return-Path: X-Original-To: patchwork-linux-samsung-soc@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 8BC099F1D6 for ; Mon, 14 Jul 2014 12:51:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BC0A720103 for ; Mon, 14 Jul 2014 12:51:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9737520121 for ; Mon, 14 Jul 2014 12:51:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755386AbaGNMu3 (ORCPT ); Mon, 14 Jul 2014 08:50:29 -0400 Received: from mail-pd0-f176.google.com ([209.85.192.176]:50837 "EHLO mail-pd0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755225AbaGNMuZ (ORCPT ); Mon, 14 Jul 2014 08:50:25 -0400 Received: by mail-pd0-f176.google.com with SMTP id y10so815659pdj.7 for ; Mon, 14 Jul 2014 05:50:24 -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=aVZBM6irGBqczN/8gxpiAVpef55L4NUsV3y03LAI2AI=; b=t3ZukXZNAYIDQYgAq6dfSCNt1EKlnW3r8es45TooNSPCDvCkxdJuRvIj4lHYRGlmXy +m4HZkZzwQgBcl1LX/EaVDVpZjmU3IqGgP4eTw0s+DRX+6F4itAtfkdxvEyIn8zr+Nci PIoRR6l6WHvhlyBDUoONuQy7CQQbS+hqzYLHoBQsZZ4gjmP4i0VTEvEDiEyA6lumYLfz p1SveYGR7dmLGsStc82e6nJ0XR5N/WimXAuL3/wL4Fz0MDG/Htw+oAyDbRlFlwJrEl25 j+aqTqgWivZb+WeklVCRhImWUSm1rHjeODwY/UA+mx8EdwrYV2LcjZSxhYrMGVI2dJS1 Dyzg== X-Received: by 10.68.211.195 with SMTP id ne3mr2839638pbc.121.1405342224793; Mon, 14 Jul 2014 05:50:24 -0700 (PDT) Received: from vivek-linuxpc.sisodomain.com ([14.140.216.146]) by mx.google.com with ESMTPSA id av2sm10788774pbc.16.2014.07.14.05.50.19 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 14 Jul 2014 05:50:24 -0700 (PDT) From: Vivek Gautam To: linux-usb@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, kishon@ti.com, kgene.kim@samsung.com, mathias.nyman@intel.com, jwerner@chromium.org, sergei.shtylyov@cogentembedded.com, heikki.krogerus@linux.intel.com, pratyush.anand@st.com, Vivek Gautam Subject: [PATCH v3 3/4] usb: hcd: Caibrate PHY post hcd reset Date: Mon, 14 Jul 2014 18:19:57 +0530 Message-Id: <1405342198-3870-4-git-send-email-gautam.vivek@samsung.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1405342198-3870-1-git-send-email-gautam.vivek@samsung.com> References: <1405342198-3870-1-git-send-email-gautam.vivek@samsung.com> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,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 | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 2841149..a344b76 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -2206,6 +2206,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-" : "")); @@ -2220,6 +2221,17 @@ 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 */ + 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; + } + } + clear_bit(HCD_FLAG_WAKEUP_PENDING, &hcd->flags); if (status == 0) { struct usb_device *udev; @@ -2742,6 +2754,16 @@ int usb_add_hcd(struct usb_hcd *hcd, } hcd->rh_pollable = 1; + /* calibrate the phy here */ + if (!IS_ERR(hcd->gen_phy)) { + 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))