From patchwork Tue Jun 18 07:15:01 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Xie X-Patchwork-Id: 2739641 Return-Path: X-Original-To: patchwork-linux-arm@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 B55189F3A0 for ; Tue, 18 Jun 2013 07:16:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 938DB201FC for ; Tue, 18 Jun 2013 07:16:38 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 461FA201EE for ; Tue, 18 Jun 2013 07:16:37 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Uoq9a-0005CS-Qg; Tue, 18 Jun 2013 07:16:35 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Uoq9Y-0006ez-9B; Tue, 18 Jun 2013 07:16:32 +0000 Received: from na3sys009aog123.obsmtp.com ([74.125.149.149]) by merlin.infradead.org with smtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Uoq9V-0006eJ-KE for linux-arm-kernel@lists.infradead.org; Tue, 18 Jun 2013 07:16:30 +0000 Received: from sc-owa02.marvell.com ([199.233.58.137]) (using TLSv1) by na3sys009aob123.postini.com ([74.125.148.12]) with SMTP ID DSNKUcAJJpeoo68Ey+7gz/nvqsXqwN0jbrOy@postini.com; Tue, 18 Jun 2013 00:16:29 PDT Received: from maili.marvell.com (10.93.76.43) by sc-owa02.marvell.com (10.93.76.22) with Microsoft SMTP Server id 8.3.213.0; Tue, 18 Jun 2013 00:14:41 -0700 Received: from localhost (unknown [10.38.36.239]) by maili.marvell.com (Postfix) with ESMTP id 4CC031CCDBF; Tue, 18 Jun 2013 00:14:41 -0700 (PDT) From: Chao Xie To: , , , , , , , Subject: [PATCH] USB: initialize or shutdown PHY when add or remove host controller Date: Tue, 18 Jun 2013 03:15:01 -0400 Message-ID: <1371539701-11441-1-git-send-email-chao.xie@marvell.com> X-Mailer: git-send-email 1.7.4.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130618_031629_798553_C92FB30C X-CRM114-Status: GOOD ( 12.13 ) X-Spam-Score: -4.2 (----) Cc: Chao Xie X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 Some controller need software to initialize PHY before add host controller, and shut down PHY after remove host controller. Add the generic code for these controllers so they do not need do it in its own host controller driver. Signed-off-by: Chao Xie --- drivers/usb/core/hcd.c | 19 ++++++++++++++++++- 1 files changed, 18 insertions(+), 1 deletions(-) diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index d53547d..b26196b 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -43,6 +43,7 @@ #include #include +#include #include "usb.h" @@ -2531,12 +2532,22 @@ int usb_add_hcd(struct usb_hcd *hcd, */ set_bit(HCD_FLAG_RH_RUNNING, &hcd->flags); + /* Initialize the PHY before other hardware operation. */ + if (hcd->phy) { + retval = usb_phy_init(hcd->phy); + if (retval) { + dev_err(hcd->self.controller, + "can't initialize phy\n"); + goto err_hcd_driver_setup; + } + } + /* "reset" is misnamed; its role is now one-time init. the controller * should already have been reset (and boot firmware kicked off etc). */ if (hcd->driver->reset && (retval = hcd->driver->reset(hcd)) < 0) { dev_err(hcd->self.controller, "can't setup\n"); - goto err_hcd_driver_setup; + goto err_hcd_driver_init_phy; } hcd->rh_pollable = 1; @@ -2608,6 +2619,9 @@ err_hcd_driver_start: if (usb_hcd_is_primary_hcd(hcd) && hcd->irq > 0) free_irq(irqnum, hcd); err_request_irq: +err_hcd_driver_init_phy: + if (hcd->phy) + usb_phy_shutdown(hcd->phy); err_hcd_driver_setup: err_set_rh_speed: usb_put_dev(hcd->self.root_hub); @@ -2674,6 +2688,9 @@ void usb_remove_hcd(struct usb_hcd *hcd) free_irq(hcd->irq, hcd); } + if (hcd->phy) + usb_phy_shutdown(hcd->phy); + usb_put_dev(hcd->self.root_hub); usb_deregister_bus(&hcd->self); hcd_buffer_destroy(hcd);