From patchwork Fri May 13 10:03:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 9089941 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A74149F1C1 for ; Fri, 13 May 2016 10:05:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B63AE2021F for ; Fri, 13 May 2016 10:05:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B0F0A20219 for ; Fri, 13 May 2016 10:05:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753224AbcEMKFe (ORCPT ); Fri, 13 May 2016 06:05:34 -0400 Received: from bear.ext.ti.com ([198.47.19.11]:59873 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753136AbcEMKEv (ORCPT ); Fri, 13 May 2016 06:04:51 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id u4DA4UA6008254; Fri, 13 May 2016 05:04:30 -0500 Received: from DLEE70.ent.ti.com (dlee70.ent.ti.com [157.170.170.113]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id u4DA4UlB006131; Fri, 13 May 2016 05:04:30 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.3.294.0; Fri, 13 May 2016 05:04:29 -0500 Received: from lta0400828d.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id u4DA3TwJ017953; Fri, 13 May 2016 05:04:25 -0500 From: Roger Quadros To: CC: , , , , , , , , , , , , , , , , , Roger Quadros Subject: [PATCH v8 12/14] usb: hcd: Adapt to OTG core Date: Fri, 13 May 2016 13:03:26 +0300 Message-ID: <1463133808-10630-13-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1463133808-10630-1-git-send-email-rogerq@ti.com> References: <1463133808-10630-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 X-Spam-Status: No, score=-8.3 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 Introduce usb_otg_add/remove_hcd() for use by host controllers that are part of OTG/dual-role port. Non Device tree platforms can use the otg_dev argument to specify the OTG controller device. If otg_dev is NULL then the device tree node's otg-controller property is used to get the otg_dev device. Signed-off-by: Roger Quadros Acked-by: Peter Chen --- drivers/usb/core/hcd.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/usb/hcd.h | 4 ++++ 2 files changed, 59 insertions(+) diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 9484539..cfc8232 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -46,6 +46,11 @@ #include #include #include +#include +#include + +#include +#include #include "usb.h" @@ -3013,6 +3018,56 @@ void usb_remove_hcd(struct usb_hcd *hcd) } EXPORT_SYMBOL_GPL(usb_remove_hcd); +static struct otg_hcd_ops otg_hcd_intf = { + .add = usb_add_hcd, + .remove = usb_remove_hcd, + .usb_bus_start_enum = usb_bus_start_enum, + .usb_control_msg = usb_control_msg, + .usb_hub_find_child = usb_hub_find_child, +}; + +/** + * usb_otg_add_hcd - Register the HCD with OTG core. + * @hcd: the usb_hcd structure to initialize + * @irqnum: Interrupt line to allocate + * @irqflags: Interrupt type flags + * @otg_dev: OTG controller device managing this HCD + * + * Registers the HCD with OTG core. OTG core will call usb_add_hcd() + * or usb_remove_hcd() as necessary. + * If otg_dev is NULL then device tree node is checked for OTG + * controller device via the otg-controller property. + */ +int usb_otg_add_hcd(struct usb_hcd *hcd, + unsigned int irqnum, unsigned long irqflags, + struct device *otg_dev) +{ + struct device *dev = hcd->self.controller; + + if (!otg_dev) { + hcd->otg_dev = of_usb_get_otg(dev->of_node); + if (!hcd->otg_dev) + return -ENODEV; + } else { + hcd->otg_dev = otg_dev; + } + + return usb_otg_register_hcd(hcd, irqnum, irqflags, &otg_hcd_intf); +} +EXPORT_SYMBOL_GPL(usb_otg_add_hcd); + +/** + * usb_otg_remove_hcd - Unregister the HCD with OTG core. + * @hcd: the usb_hcd structure to remove + * + * Unregisters the HCD from the OTG core. + */ +void usb_otg_remove_hcd(struct usb_hcd *hcd) +{ + usb_otg_unregister_hcd(hcd); +} +EXPORT_SYMBOL_GPL(usb_otg_remove_hcd); + void usb_hcd_platform_shutdown(struct platform_device *dev) { diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h index 2017cd4..adcf2e7 100644 --- a/include/linux/usb/hcd.h +++ b/include/linux/usb/hcd.h @@ -472,6 +472,10 @@ extern int usb_hcd_is_primary_hcd(struct usb_hcd *hcd); extern int usb_add_hcd(struct usb_hcd *hcd, unsigned int irqnum, unsigned long irqflags); extern void usb_remove_hcd(struct usb_hcd *hcd); +extern int usb_otg_add_hcd(struct usb_hcd *hcd, + unsigned int irqnum, unsigned long irqflags, + struct device *otg_dev); +extern void usb_otg_remove_hcd(struct usb_hcd *hcd); extern int usb_hcd_find_raw_port_number(struct usb_hcd *hcd, int port1); struct platform_device;