From patchwork Mon Nov 25 10:01:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kishon Vijay Abraham I X-Patchwork-Id: 3229271 Return-Path: X-Original-To: patchwork-linux-arm@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 3D75DC045B for ; Mon, 25 Nov 2013 10:05:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 17DD220216 for ; Mon, 25 Nov 2013 10:05:32 +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 43A7A201D5 for ; Mon, 25 Nov 2013 10:05:26 +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 1Vkt1E-000140-Fo; Mon, 25 Nov 2013 10:03:53 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Vkt0l-0000yt-OM; Mon, 25 Nov 2013 10:03:23 +0000 Received: from arroyo.ext.ti.com ([192.94.94.40]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Vkt09-0000rH-0z for linux-arm-kernel@lists.infradead.org; Mon, 25 Nov 2013 10:02:47 +0000 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id rAPA23V8003890; Mon, 25 Nov 2013 04:02:03 -0600 Received: from DLEE70.ent.ti.com (dlee70.ent.ti.com [157.170.170.113]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id rAPA21xL030452; Mon, 25 Nov 2013 04:02:02 -0600 Received: from dlep33.itg.ti.com (157.170.170.75) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.2.342.3; Mon, 25 Nov 2013 04:02:01 -0600 Received: from a0393678ub.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id rAPA1XdS012170; Mon, 25 Nov 2013 04:01:55 -0600 From: Kishon Vijay Abraham I To: , , , , , , , Subject: [PATCH v3 03/10] usb: dwc3: preparation for adapting dwc3 to generic phy framework Date: Mon, 25 Nov 2013 15:31:23 +0530 Message-ID: <1385373690-12170-4-git-send-email-kishon@ti.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1385373690-12170-1-git-send-email-kishon@ti.com> References: <1385373690-12170-1-git-send-email-kishon@ti.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131125_050245_203573_89A5438C X-CRM114-Status: UNSURE ( 9.32 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -6.9 (------) Cc: mark.rutland@arm.com, linux@arm.linux.org.uk, s.nawrocki@samsung.com, pawel.moll@arm.com, ijc+devicetree@hellion.org.uk, tony@atomide.com, gregkh@linuxfoundation.org, swarren@wwwdotorg.org, rob.herring@calxeda.com, kishon@ti.com, rob@landley.net, galak@codeaurora.org, grant.likely@linaro.org 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=-4.2 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 Invoke usb_phy api's only if usb_phy does not have error value. This is needed for both the legacy usb_phy and generic phy to co-exist in dwc3 core. Signed-off-by: Kishon Vijay Abraham I --- drivers/usb/dwc3/core.c | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index a49217a..986674f 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -80,8 +80,10 @@ static void dwc3_core_soft_reset(struct dwc3 *dwc) reg |= DWC3_GUSB2PHYCFG_PHYSOFTRST; dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg); - usb_phy_init(dwc->usb2_phy); - usb_phy_init(dwc->usb3_phy); + if (!IS_ERR(dwc->usb2_phy)) + usb_phy_init(dwc->usb2_phy); + if (!IS_ERR(dwc->usb3_phy)) + usb_phy_init(dwc->usb3_phy); mdelay(100); /* Clear USB3 PHY reset */ @@ -341,8 +343,10 @@ err0: static void dwc3_core_exit(struct dwc3 *dwc) { - usb_phy_shutdown(dwc->usb2_phy); - usb_phy_shutdown(dwc->usb3_phy); + if (!IS_ERR(dwc->usb2_phy)) + usb_phy_shutdown(dwc->usb2_phy); + if (!IS_ERR(dwc->usb3_phy)) + usb_phy_shutdown(dwc->usb3_phy); } #define DWC3_ALIGN_MASK (16 - 1) @@ -485,8 +489,10 @@ static int dwc3_probe(struct platform_device *pdev) goto err0; } - usb_phy_set_suspend(dwc->usb2_phy, 0); - usb_phy_set_suspend(dwc->usb3_phy, 0); + if (!IS_ERR(dwc->usb2_phy)) + usb_phy_set_suspend(dwc->usb2_phy, 0); + if (!IS_ERR(dwc->usb3_phy)) + usb_phy_set_suspend(dwc->usb3_phy, 0); ret = dwc3_event_buffers_setup(dwc); if (ret) { @@ -569,8 +575,10 @@ err2: dwc3_event_buffers_cleanup(dwc); err1: - usb_phy_set_suspend(dwc->usb2_phy, 1); - usb_phy_set_suspend(dwc->usb3_phy, 1); + if (!IS_ERR(dwc->usb2_phy)) + usb_phy_set_suspend(dwc->usb2_phy, 1); + if (!IS_ERR(dwc->usb3_phy)) + usb_phy_set_suspend(dwc->usb3_phy, 1); dwc3_core_exit(dwc); err0: @@ -583,8 +591,10 @@ static int dwc3_remove(struct platform_device *pdev) { struct dwc3 *dwc = platform_get_drvdata(pdev); - usb_phy_set_suspend(dwc->usb2_phy, 1); - usb_phy_set_suspend(dwc->usb3_phy, 1); + if (!IS_ERR(dwc->usb2_phy)) + usb_phy_set_suspend(dwc->usb2_phy, 1); + if (!IS_ERR(dwc->usb3_phy)) + usb_phy_set_suspend(dwc->usb3_phy, 1); pm_runtime_put_sync(&pdev->dev); pm_runtime_disable(&pdev->dev); @@ -680,8 +690,10 @@ static int dwc3_suspend(struct device *dev) dwc->gctl = dwc3_readl(dwc->regs, DWC3_GCTL); spin_unlock_irqrestore(&dwc->lock, flags); - usb_phy_shutdown(dwc->usb3_phy); - usb_phy_shutdown(dwc->usb2_phy); + if (!IS_ERR(dwc->usb3_phy)) + usb_phy_shutdown(dwc->usb3_phy); + if (!IS_ERR(dwc->usb2_phy)) + usb_phy_shutdown(dwc->usb2_phy); return 0; } @@ -691,8 +703,10 @@ static int dwc3_resume(struct device *dev) struct dwc3 *dwc = dev_get_drvdata(dev); unsigned long flags; - usb_phy_init(dwc->usb3_phy); - usb_phy_init(dwc->usb2_phy); + if (!IS_ERR(dwc->usb3_phy)) + usb_phy_init(dwc->usb3_phy); + if (!IS_ERR(dwc->usb2_phy)) + usb_phy_init(dwc->usb2_phy); spin_lock_irqsave(&dwc->lock, flags);