From patchwork Thu Aug 21 14:55:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Gautam X-Patchwork-Id: 4758381 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 E4A809F344 for ; Thu, 21 Aug 2014 14:56:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1B3532018B for ; Thu, 21 Aug 2014 14:56:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F255B201CD for ; Thu, 21 Aug 2014 14:56:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752795AbaHUOzv (ORCPT ); Thu, 21 Aug 2014 10:55:51 -0400 Received: from mail-pa0-f49.google.com ([209.85.220.49]:41743 "EHLO mail-pa0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751999AbaHUOzs (ORCPT ); Thu, 21 Aug 2014 10:55:48 -0400 Received: by mail-pa0-f49.google.com with SMTP id hz1so14561874pad.22 for ; Thu, 21 Aug 2014 07:55:48 -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=ntyCz7nU4dBfb4exBCFmmarN7F0jjCAcC3v7iCUgGtk=; b=b0ZzOgOQyGM++PGHdG74vnwhtxd5NVmXYtKGOdUlKYZZaW1dTfOyGoKyz3/BF6hlCt bAXcYj9D5JgFm/9DFLcpdMjVHMFaO4I5YKFoaqh+QThPh31XgF0hPuId8BjB4y549L5u Bo9QbrYgey59O/b5Ve3CSOYHqCTrRK2xisQ//BkzD/CVR+23jspfW0AwfhL65a8PNW7H zUSOlW7fQH1p+yZgaiKxOfoXAIhKwEbb3xCmeHMvuBTb+kM1qzK2rcU3i+nkRNPJUCfI 51PCoDk9Hx3gXPKbR/Ga24J5+G1YnvaYTTckRkq7m2CFyFRsaaXXeqC6Pv88HeiRfD+r KkAw== X-Received: by 10.66.196.65 with SMTP id ik1mr31891158pac.154.1408632948101; Thu, 21 Aug 2014 07:55:48 -0700 (PDT) Received: from vivek-linuxpc.sisodomain.com ([14.140.216.146]) by mx.google.com with ESMTPSA id wc3sm91835580pac.18.2014.08.21.07.55.43 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 21 Aug 2014 07:55:47 -0700 (PDT) From: Vivek Gautam To: linux-usb@vger.kernel.org Cc: linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, kishon@ti.com, kgene.kim@samsung.com, mathias.nyman@intel.com, stern@rowland.harvard.edu, sergei.shtylyov@cogentembedded.com, heikki.krogerus@linux.intel.com, balbi@ti.com, Vivek Gautam Subject: [PATCH v5 3/4] usb: hcd: Caibrate PHY post hcd reset Date: Thu, 21 Aug 2014 20:25:22 +0530 Message-Id: <1408632923-19591-4-git-send-email-gautam.vivek@samsung.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1408632923-19591-1-git-send-email-gautam.vivek@samsung.com> References: <1408632923-19591-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=-7.5 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 c4ed66c..a42b448 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,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; @@ -2738,6 +2750,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))