From patchwork Tue Nov 26 22:45: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: 3241671 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 2BE669F3B8 for ; Tue, 26 Nov 2013 22:45:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6139720549 for ; Tue, 26 Nov 2013 22:45:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 97C4F2053F for ; Tue, 26 Nov 2013 22:45:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755540Ab3KZWpj (ORCPT ); Tue, 26 Nov 2013 17:45:39 -0500 Received: from mail-la0-f46.google.com ([209.85.215.46]:45028 "EHLO mail-la0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756375Ab3KZWpg (ORCPT ); Tue, 26 Nov 2013 17:45:36 -0500 Received: by mail-la0-f46.google.com with SMTP id eh20so4701902lab.5 for ; Tue, 26 Nov 2013 14:45:35 -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=zSvH/HwUxZmhoVcEi2u1QibTU4Cg9wooUFbpBAVSvD0=; b=S/usHXl4r9xm/pqRqee+/s8LqMKhKnQdyyUhBpMi5NnYbJSb7x7saR3iSEY2ynCA1U jQHZo6MRnz5avck9fNNAd8CXqeOOLaq4csul1zXssrq63CTdnrQJCvhz8DmSflIGw493 gF2TG+7F6YqptLg1pBj9ku+D+wJ6UzGBPSirk0SCAPWuBEb2w6nwU8DIyX2UC66LoG0N zCPAQcENXUMgKfstOiIrFGc4+QAsECc1z2L4ikANmTFYnZwVLDFfOZKMqaAqr2zUAZ1L 2+J7Z1ajWfypdam9tlP3qyj0Lyul30gcxRhurhtWlQsyjtT1j3K8k3ttjT8QKjqsOc8F no7g== X-Gm-Message-State: ALoCoQkam8lJDhcrocf3wZxR2babtWdEKN4+VvivA+rJ88udq4kIqdEkAg4pxPCc/TugPFmd29eQ X-Received: by 10.112.219.99 with SMTP id pn3mr10314183lbc.24.1385505934998; Tue, 26 Nov 2013 14:45:34 -0800 (PST) Received: from black.localnet ([93.100.122.208]) by mx.google.com with ESMTPSA id xl4sm46866053lac.9.2013.11.26.14.45.33 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Nov 2013 14:45:34 -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, 27 Nov 2013 02:45:29 +0400 Message-Id: <1385505929-30926-3-git-send-email-valentine.barshak@cogentembedded.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1385505929-30926-1-git-send-email-valentine.barshak@cogentembedded.com> References: <1385505929-30926-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 7527c8e..649506b 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -2589,6 +2589,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]. */