From patchwork Thu Jul 4 06:26:42 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ruchika Kharwar X-Patchwork-Id: 2821991 Return-Path: X-Original-To: patchwork-linux-omap@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 37A92BF4A1 for ; Thu, 4 Jul 2013 06:27:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 135E42014A for ; Thu, 4 Jul 2013 06:27:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F096720148 for ; Thu, 4 Jul 2013 06:27:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932990Ab3GDG1Q (ORCPT ); Thu, 4 Jul 2013 02:27:16 -0400 Received: from arroyo.ext.ti.com ([192.94.94.40]:37420 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755207Ab3GDG1P (ORCPT ); Thu, 4 Jul 2013 02:27:15 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id r646RERe001077; Thu, 4 Jul 2013 01:27:14 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id r646REOn012839; Thu, 4 Jul 2013 01:27:14 -0500 Received: from dlelxv24.itg.ti.com (172.17.1.199) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.2.342.3; Thu, 4 Jul 2013 01:27:14 -0500 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dlelxv24.itg.ti.com (8.13.8/8.13.8) with ESMTP id r646REWm005754; Thu, 4 Jul 2013 01:27:14 -0500 Received: from localhost (h56-84.vpn.ti.com [172.24.56.84]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id r646REt28822; Thu, 4 Jul 2013 01:27:14 -0500 (CDT) From: Ruchika Kharwar To: , CC: Felipe Balbi , Kishon Vijay Abraham I , Greg Kroah-Hartman , Ruchika Kharwar Subject: [PATCH] [RFC] usb: dwc3: removal of assumption that usb3 phy always present Date: Thu, 4 Jul 2013 01:26:42 -0500 Message-ID: <1372919202-26755-1-git-send-email-ruchika@ti.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-7.1 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 DRA7XX has several USB OTG subsystems. USB_OTG_SS1 includes a USB1 and USB2 phy. USB_OTG_SS2 includes only a USB2 phy. This patch allows the dwc3 probe to continue if a usb3_phy is not found. This patch currently works for DRA7XX and submitted in the interim a nicer method emerges. Signed-off-by: Ruchika Kharwar --- drivers/usb/dwc3/core.c | 38 ++++++++++++++++++++------------------ drivers/usb/dwc3/gadget.c | 11 ++++++++--- 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 358375e..feea92d 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -100,7 +100,10 @@ static void dwc3_core_soft_reset(struct dwc3 *dwc) dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg); usb_phy_init(dwc->usb2_phy); - usb_phy_init(dwc->usb3_phy); + + if (!IS_ERR(dwc->usb3_phy)) + usb_phy_init(dwc->usb3_phy); + mdelay(100); /* Clear USB3 PHY reset */ @@ -360,7 +363,9 @@ 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->usb3_phy)) + usb_phy_shutdown(dwc->usb3_phy); } #define DWC3_ALIGN_MASK (16 - 1) @@ -450,22 +455,13 @@ static int dwc3_probe(struct platform_device *pdev) } if (IS_ERR(dwc->usb3_phy)) { - ret = PTR_ERR(dwc->usb3_phy); - - /* - * if -ENXIO is returned, it means PHY layer wasn't - * enabled, so it makes no sense to return -EPROBE_DEFER - * in that case, since no PHY driver will ever probe. - */ - if (ret == -ENXIO) - return ret; - - dev_err(dev, "no usb3 phy configured\n"); - return -EPROBE_DEFER; + dev_dbg(dev, "no usb3 phy configured, possibly absent\n"); } usb_phy_set_suspend(dwc->usb2_phy, 0); - usb_phy_set_suspend(dwc->usb3_phy, 0); + + if (!IS_ERR(dwc->usb3_phy)) + usb_phy_set_suspend(dwc->usb3_phy, 0); spin_lock_init(&dwc->lock); platform_set_drvdata(pdev, dwc); @@ -604,7 +600,9 @@ 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->usb3_phy)) + usb_phy_set_suspend(dwc->usb3_phy, 1); pm_runtime_put(&pdev->dev); pm_runtime_disable(&pdev->dev); @@ -700,7 +698,9 @@ 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); + if (!IS_ERR(dwc->usb3_phy)) + usb_phy_shutdown(dwc->usb3_phy); + usb_phy_shutdown(dwc->usb2_phy); return 0; @@ -711,7 +711,9 @@ static int dwc3_resume(struct device *dev) struct dwc3 *dwc = dev_get_drvdata(dev); unsigned long flags; - usb_phy_init(dwc->usb3_phy); + if (!IS_ERR(dwc->usb3_phy)) + usb_phy_init(dwc->usb3_phy); + usb_phy_init(dwc->usb2_phy); msleep(100); diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index b5e5b35..7ca3745 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -2176,7 +2176,9 @@ static void dwc3_gadget_reset_interrupt(struct dwc3 *dwc) if (dwc->revision < DWC3_REVISION_194A) { /* Resume PHYs */ dwc3_gadget_usb2_phy_suspend(dwc, false); - dwc3_gadget_usb3_phy_suspend(dwc, false); + + if (!IS_ERR(dwc->usb3_phy)) + dwc3_gadget_usb3_phy_suspend(dwc, false); } if (dwc->gadget.speed != USB_SPEED_UNKNOWN) @@ -2231,7 +2233,8 @@ static void dwc3_gadget_phy_suspend(struct dwc3 *dwc, u8 speed) case USB_SPEED_HIGH: case USB_SPEED_FULL: case USB_SPEED_LOW: - dwc3_gadget_usb3_phy_suspend(dwc, true); + if (!IS_ERR(dwc->usb3_phy)) + dwc3_gadget_usb3_phy_suspend(dwc, true); break; } } @@ -2649,7 +2652,9 @@ int dwc3_gadget_init(struct dwc3 *dwc) /* Enable USB2 LPM and automatic phy suspend only on recent versions */ if (dwc->revision >= DWC3_REVISION_194A) { dwc3_gadget_usb2_phy_suspend(dwc, false); - dwc3_gadget_usb3_phy_suspend(dwc, false); + + if (!IS_ERR(dwc->usb3_phy)) + dwc3_gadget_usb3_phy_suspend(dwc, false); } ret = usb_add_gadget_udc(dwc->dev, &dwc->gadget);