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: 4824501 Return-Path: X-Original-To: patchwork-linux-samsung-soc@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 B0090C0338 for ; Tue, 2 Sep 2014 11:13:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DF4EF200FF for ; Tue, 2 Sep 2014 11:13:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DAFD120176 for ; Tue, 2 Sep 2014 11:13:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753979AbaIBLMy (ORCPT ); Tue, 2 Sep 2014 07:12:54 -0400 Received: from mail-pd0-f178.google.com ([209.85.192.178]:38409 "EHLO mail-pd0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753890AbaIBLMw (ORCPT ); Tue, 2 Sep 2014 07:12:52 -0400 Received: by mail-pd0-f178.google.com with SMTP id y13so8337817pdi.23 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 Cc: linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, gregkh@linuxfoundation.org, kishon@ti.com, balbi@ti.com, stern@rowland.harvard.edu, kgene.kim@samsung.com, heikki.krogerus@linux.intel.com, mathias.nyman@intel.com, sergei.shtylyov@cogentembedded.com, jg1.han@samsung.com, Vivek Gautam 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> 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=-8.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 | 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))