From patchwork Thu Nov 7 11:14:29 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentine Barshak X-Patchwork-Id: 3152221 X-Patchwork-Delegate: lethal@linux-sh.org Return-Path: X-Original-To: patchwork-linux-sh@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 2778FBEEB2 for ; Thu, 7 Nov 2013 11:14:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 15AE220443 for ; Thu, 7 Nov 2013 11:14:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 838F9204AB for ; Thu, 7 Nov 2013 11:14:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754524Ab3KGLOh (ORCPT ); Thu, 7 Nov 2013 06:14:37 -0500 Received: from mail-lb0-f171.google.com ([209.85.217.171]:38970 "EHLO mail-lb0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753260Ab3KGLOf (ORCPT ); Thu, 7 Nov 2013 06:14:35 -0500 Received: by mail-lb0-f171.google.com with SMTP id x18so301727lbi.2 for ; Thu, 07 Nov 2013 03:14:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=h8Jh+wq2ag74hqWlXYV34SiVHqMc0Dgo8G1QA46Gsbw=; b=b+9RfmMrVhfJi5SyhxxgQRRFOnOCR3Do19XhzbmFxS8sC/NvafBIHsYKf5Tb7vpKHK SRzl0mg6QB8uFKvZb5BQ7GqG842tflbbsqXTAjeIVuEYvDbJIbT4UfRVIZ6Unu+lSbf8 Hytt7X65YZ7rMktRNHbcxKT1ZalS1rUj5lPterauhigATtCARiWSB58vWRpbJZGkvETK bgijMNVhBq9lwZTArHcsHmgQariCMeFojvc0l8FT4rOItuMFNVtJ6vRIRPmfQcjmP3pU jQZMkp81yHEWvQIc+pcljaB87U0BynLsGKY/IqFplwnn6GVdVSuMHiTqpbFMYx43stct s1fw== X-Gm-Message-State: ALoCoQmgxls/Bu/J5FFMlQYSpwnNLKnzfpHp2qcO3nCqx3a2PkldbEU8fYvVI4d6Zy1OnD8EwPQx X-Received: by 10.112.144.5 with SMTP id si5mr353632lbb.33.1383822874666; Thu, 07 Nov 2013 03:14:34 -0800 (PST) Received: from black.localnet ([93.100.122.208]) by mx.google.com with ESMTPSA id vz9sm2479739lbb.17.2013.11.07.03.14.33 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Nov 2013 03:14:33 -0800 (PST) From: Valentine Barshak To: linux-usb@vger.kernel.org, linux-sh@vger.kernel.org Cc: Greg KH , Alan Stern , Felipe Balbi , NeilBrown , Mark Brown , Alex Courbot , Simon Horman , Magnus Damm , Kuninori Morimoto , Laurent Pinchart Subject: [RFC V2 PATCH 2/2] usb: hcd: Initialize USB phy if needed Date: Thu, 7 Nov 2013 15:14:29 +0400 Message-Id: <1383822869-20283-3-git-send-email-valentine.barshak@cogentembedded.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1383822869-20283-1-git-send-email-valentine.barshak@cogentembedded.com> References: <1383822869-20283-1-git-send-email-valentine.barshak@cogentembedded.com> Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 This adds external USB phy support to USB HCD driver that allows to find and initialize external USB phy, bound to the HCD, when the HCD is added. The usb_add_hcd function returns -EPROBE_DEFER if the USB phy, bound to the HCD, is not ready. If no USB phy is bound, the HCD is initialized as usual. Signed-off-by: Valentine Barshak Acked-by: Alan Stern --- drivers/usb/core/hcd.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index d939521..fd09ec6 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -2597,6 +2597,26 @@ int usb_add_hcd(struct usb_hcd *hcd, int retval; struct usb_device *rhdev; +#ifdef CONFIG_USB_PHY + if (!hcd->phy) { + struct usb_phy *phy = usb_get_phy_dev(hcd->self.controller, 0); + + if (IS_ERR(phy)) { + retval = PTR_ERR(phy); + if (retval == -EPROBE_DEFER) + return retval; + } else { + retval = usb_phy_init(phy); + if (retval) { + usb_put_phy(phy); + return retval; + } + hcd->phy = phy; + hcd->remove_phy = 1; + } + } +#endif + dev_info(hcd->self.controller, "%s\n", hcd->product_desc); /* Keep old behaviour if authorized_default is not in [0, 1]. */