From patchwork Mon May 2 12:18:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 67019 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp9619qge; Mon, 2 May 2016 05:20:41 -0700 (PDT) X-Received: by 10.66.194.230 with SMTP id hz6mr51299513pac.132.1462191641639; Mon, 02 May 2016 05:20:41 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t4si15925262pai.76.2016.05.02.05.20.41; Mon, 02 May 2016 05:20:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753744AbcEBMUj (ORCPT + 3 others); Mon, 2 May 2016 08:20:39 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:59393 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753794AbcEBMUL (ORCPT ); Mon, 2 May 2016 08:20:11 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id u42CK1sn014800; Mon, 2 May 2016 07:20:01 -0500 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id u42CK1gj005281; Mon, 2 May 2016 07:20:01 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.224.2; Mon, 2 May 2016 07:20:00 -0500 Received: from lta0400828d.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id u42CIxY4027290; Mon, 2 May 2016 07:19:57 -0500 From: Roger Quadros To: CC: , , , , , , , , , , , , , , Roger Quadros Subject: [PATCH v7 14/14] usb: host: xhci-plat: Add otg device to platform data Date: Mon, 2 May 2016 15:18:57 +0300 Message-ID: <1462191537-10314-15-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1462191537-10314-1-git-send-email-rogerq@ti.com> References: <1462191537-10314-1-git-send-email-rogerq@ti.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Host controllers that are part of an OTG/dual-role instance need to somehow pass the OTG controller device information to the HCD core. We use platform data to pass the OTG controller device. Signed-off-by: Roger Quadros --- drivers/usb/host/xhci-plat.c | 35 ++++++++++++++++++++++++++++------- include/linux/usb/xhci_pdriver.h | 3 +++ 2 files changed, 31 insertions(+), 7 deletions(-) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index 5c15e9b..84ebe18 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -230,11 +230,20 @@ static int xhci_plat_probe(struct platform_device *pdev) goto put_usb3_hcd; } - ret = usb_add_hcd(hcd, irq, IRQF_SHARED); + if (pdata && pdata->otg_dev) + ret = usb_otg_add_hcd(hcd, irq, IRQF_SHARED, pdata->otg_dev); + else + ret = usb_add_hcd(hcd, irq, IRQF_SHARED); + if (ret) goto disable_usb_phy; - ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED); + if (pdata && pdata->otg_dev) + ret = usb_otg_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED, + pdata->otg_dev); + else + ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED); + if (ret) goto dealloc_usb2_hcd; @@ -242,7 +251,10 @@ static int xhci_plat_probe(struct platform_device *pdev) dealloc_usb2_hcd: - usb_remove_hcd(hcd); + if (pdata && pdata->otg_dev) + usb_otg_remove_hcd(hcd); + else + usb_remove_hcd(hcd); disable_usb_phy: usb_phy_shutdown(hcd->usb_phy); @@ -260,16 +272,25 @@ put_hcd: return ret; } -static int xhci_plat_remove(struct platform_device *dev) +static int xhci_plat_remove(struct platform_device *pdev) { - struct usb_hcd *hcd = platform_get_drvdata(dev); + struct usb_hcd *hcd = platform_get_drvdata(pdev); struct xhci_hcd *xhci = hcd_to_xhci(hcd); struct clk *clk = xhci->clk; + struct usb_xhci_pdata *pdata = dev_get_platdata(&pdev->dev); + + if (pdata && pdata->otg_dev) + usb_otg_remove_hcd(xhci->shared_hcd); + else + usb_remove_hcd(xhci->shared_hcd); - usb_remove_hcd(xhci->shared_hcd); usb_phy_shutdown(hcd->usb_phy); - usb_remove_hcd(hcd); + if (pdata && pdata->otg_dev) + usb_otg_remove_hcd(hcd); + else + usb_remove_hcd(hcd); + usb_put_hcd(xhci->shared_hcd); if (!IS_ERR(clk)) diff --git a/include/linux/usb/xhci_pdriver.h b/include/linux/usb/xhci_pdriver.h index 376654b..5c68b83 100644 --- a/include/linux/usb/xhci_pdriver.h +++ b/include/linux/usb/xhci_pdriver.h @@ -18,10 +18,13 @@ * * @usb3_lpm_capable: determines if this xhci platform supports USB3 * LPM capability + * @otg_dev: OTG controller device. Only requied if part of + * OTG/dual-role. * */ struct usb_xhci_pdata { unsigned usb3_lpm_capable:1; + struct device *otg_dev; }; #endif /* __USB_CORE_XHCI_PDRIVER_H */