From patchwork Tue Nov 5 20:33:27 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentine Barshak X-Patchwork-Id: 3143821 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 8DA45BEEB2 for ; Tue, 5 Nov 2013 20:33:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8FE6520588 for ; Tue, 5 Nov 2013 20:33:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 893052058A for ; Tue, 5 Nov 2013 20:33:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755510Ab3KEUdf (ORCPT ); Tue, 5 Nov 2013 15:33:35 -0500 Received: from mail-lb0-f171.google.com ([209.85.217.171]:56413 "EHLO mail-lb0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755497Ab3KEUdd (ORCPT ); Tue, 5 Nov 2013 15:33:33 -0500 Received: by mail-lb0-f171.google.com with SMTP id x18so7014282lbi.16 for ; Tue, 05 Nov 2013 12:33:32 -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=nnk7C2LVv3mj9LPOrcdOJdruXBcn8wWDfQywkkiljtU=; b=C9AOJeINNa6BZW0jmsBUGR1szP6E6tSZEuXqI7UAoysLj3MegQ/mu4gDzrf/5xcFk8 D3jwm6glYBkRhUVQkcrs/SyFg5APwociS9U/Gpixk1j59cRRuFdATI9yFXbMls4Mt+s+ pabYj+tJqoLMZyA4GdQEieoGxJteDLiRq+kJKXwVq5qt51dkIE3UUr/CxjrNlfzpr8d+ Nqko6ekwOijoDsWPN0DV4EWhqQSYZMjwQpKBHMjnOQzgZg8N4rGHQgy0lOfDMV/zB0aM raz+t4XjN4SVAKj8DPXq5G0fF4Yscwa9HU1au1d7obqCVyfW7UFWysGTUvlkDiEZLUL1 ACqQ== X-Gm-Message-State: ALoCoQnHUy3lmyf18hQypc6yPJQtrslvZEiyTJosNDmUGUGu07gH+0mEaYvn/5JzKKPnxhyYVkFs X-Received: by 10.152.36.170 with SMTP id r10mr1485886laj.48.1383683612337; Tue, 05 Nov 2013 12:33:32 -0800 (PST) Received: from black.localnet ([93.100.122.208]) by mx.google.com with ESMTPSA id 8sm29568034laq.5.2013.11.05.12.33.30 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Nov 2013 12:33:31 -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 PATCH 2/2] usb: hcd: Introduce CONFIG_USB_HCD_EXTERNAL_PHY option Date: Wed, 6 Nov 2013 00:33:27 +0400 Message-Id: <1383683607-28119-3-git-send-email-valentine.barshak@cogentembedded.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1383683607-28119-1-git-send-email-valentine.barshak@cogentembedded.com> References: <1383683607-28119-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=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 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 | 20 ++++++++++++++++++++ drivers/usb/host/Kconfig | 11 +++++++++++ 2 files changed, 31 insertions(+) diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index d939521..da9c4ba 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_HCD_EXTERNAL_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]. */ diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index b3f20d7..2e1f2b0 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig @@ -706,3 +706,14 @@ config USB_HCD_TEST_MODE This option is of interest only to developers who need to validate their USB hardware designs. It is not needed for normal use. If unsure, say N. + +config USB_HCD_EXTERNAL_PHY + bool "Set up external USB phy bound to the USB HCD" + select USB_PHY + ---help--- + Some USB host controllers require an external USB phy. + This adds generic USB phy support to the USB HCD driver. + When the HCD is being initialized, the HC driver searches + for a USB phy, bound to the HCD. If no USB phy is bound + to the HCD, the HCD is initialized as usual. + If unsure, say N.