From patchwork Tue Dec 3 21:42:22 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentine Barshak X-Patchwork-Id: 3278791 Return-Path: X-Original-To: patchwork-linux-sh@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 3FAA69F37A for ; Tue, 3 Dec 2013 21:42:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6C10620439 for ; Tue, 3 Dec 2013 21:42:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9105B2042B for ; Tue, 3 Dec 2013 21:42:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755171Ab3LCVmc (ORCPT ); Tue, 3 Dec 2013 16:42:32 -0500 Received: from mail-lb0-f180.google.com ([209.85.217.180]:64225 "EHLO mail-lb0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755161Ab3LCVm3 (ORCPT ); Tue, 3 Dec 2013 16:42:29 -0500 Received: by mail-lb0-f180.google.com with SMTP id w6so8706799lbh.25 for ; Tue, 03 Dec 2013 13:42:28 -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=VKvCJHXFrB2GnfswlUFaOQbB/xqLyy6t2V09Q5ULkmI=; b=aK/FlntQT5FkL4FHAwgn9pHkANvJLkYx2fV+pE2dp8QvWYnS61Rq2wjLxgMieZbNw5 i0otGs6e7eZ0d96jUNq29MPaUuSMNOwOZeQoRkJAPcFRB9nZeTMPsZT1nr7RmYBxMCnE NgIJqQ2E8zVC4RiHQ25WYEQQB4OQSKoKNgiPQf9xxD/FKElIJmkRVlU4XDvY2WhGMuTy 2eLnFo95eatk5nBqMWCMWh5CxrXdxpYkrce2xyZ/05MmFmSWJbClG5r2IKlNIL8wvgwd onDn9L0Amz8oHywaVLAP7u5KTFDHoFtnSIcyiLcpmKfQWppdYsmrPiYmBZFVJFIzY3J1 nAoA== X-Gm-Message-State: ALoCoQlFMYWNN2mdYnAPItrfRdvZBuT1lEgmbHY8N0zUHImwwSMWhnqiVvsUSaQBpvls8vT9pFoV X-Received: by 10.112.182.72 with SMTP id ec8mr13603lbc.75.1386106948010; Tue, 03 Dec 2013 13:42:28 -0800 (PST) Received: from black.localnet ([93.100.122.208]) by mx.google.com with ESMTPSA id m5sm88888118laj.4.2013.12.03.13.42.26 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Dec 2013 13:42:27 -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: [PATCH 2/2] usb: hcd: Initialize USB phy if needed Date: Wed, 4 Dec 2013 01:42:22 +0400 Message-Id: <1386106942-13730-3-git-send-email-valentine.barshak@cogentembedded.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1386106942-13730-1-git-send-email-valentine.barshak@cogentembedded.com> References: <1386106942-13730-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 --- 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 7527c8e..d3a9bcd 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -2589,6 +2589,24 @@ int usb_add_hcd(struct usb_hcd *hcd, int retval; struct usb_device *rhdev; + if (IS_ENABLED(CONFIG_USB_PHY) && !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; + } + } + dev_info(hcd->self.controller, "%s\n", hcd->product_desc); /* Keep old behaviour if authorized_default is not in [0, 1]. */